Platyping's Python

on the 5th line you have
Code:
iPlayerX != pPlayer
, this should be:

Code:
iPlayerX != pPlayer.getID()
or
Code:
iPlayerX != iPlayer

if iPlayer exists of course!

I would rename bPlayer to something like barbPlayer, just for clearness of meaning. Other than that it should work perfectly fine!
 
Heya Platy,

quasion about eden,

i have some questions about you code: (ive changed the names):
Spoiler :
Code:
# Eden Project Start ##
		if iProjectType == gc.getInfoTypeForString("TERRAFORMIG_MACHINE_PROJECT1"):
			pPlayer = gc.getPlayer(pCity.getOwner())
			iTeam = pPlayer.getTeam()
			for iPlayerX in range(gc.getMAX_CIV_PLAYERS()):
				pPlayerX = gc.getPlayer(iPlayerX)
				if pPlayerX.isAlive() and pPlayerX.getTeam() == iTeam:
					capital = pPlayerX.getCapitalCity()
					for i in range(21):
						pPlot = capital.getCityIndexPlot(i)
						if pPlot.getTerrainType() == gc.getInfoTypeForString("TERRAIN_GRASS"):
							pPlot.setTerrainType(gc.getInfoTypeForString("TERRAIN_GRASS2"), 1, 1)
						elif pPlot.getTerrainType() == gc.getInfoTypeForString("TERRAIN_TUNDRA"):
							pPlot.setTerrainType(gc.getInfoTypeForString("TERRAIN_TUNDRA2"), 1, 1)
						elif pPlot.getTerrainType() == gc.getInfoTypeForString("TERRAIN_PLAINS"):
							pPlot.setTerrainType(gc.getInfoTypeForString("TERRAIN_PLAINS2"), 1, 1)
						elif pPlot.getTerrainType() == gc.getInfoTypeForString("TERRAIN_DESERT"):
							pPlot.setTerrainType(gc.getInfoTypeForString("TERRAIN_DESERT2"), 1, 1)
						elif pPlot.getTerrainType() == gc.getInfoTypeForString("TERRAIN_SNOW"):
							pPlot.setTerrainType(gc.getInfoTypeForString("TERRAIN_SNOW2"), 1, 1)
					CyInterface().addMessage(iPlayerX,true,15,CyTranslator().getText("TXT_EDEN",(capital.getName(),)),'',0,'',-1,-1,-1, false,false)
## Eden Project End ##


this line: "for i in range(21):" = if i write - 50 , does it mean 50 tiles of the city im building it ill have a terraform?


this line: does it mean i can only build it in capital? if i want all cities?

converting the code to building - if i change this "if iProjectType =" to
"if ibuildingType ="

and put the whole code between:

game = gc.getGame()

#code here
if ((not gc.getGame().isNetworkMultiPlayer()) and (pCity.getOwner() == gc.getGame().getActivePlayer()) and isWorldWonderClass(gc.getBuildingInfo(iBuildingType).getBuildingClassType())):

will it work for a regular building?
 
for the range(50) thing, nope, the 21 represents the 21 working tiles of the city, it can only cycle through the BFC, you will get errors above 21.

you will need to define the variable iBuildingType, so you will need to do some different code.
 
Code:
	def onEndGameTurn(self, argsList):
		'Called at the end of the end of each turn'
		iGameTurn = argsList[0]
## AI Entity Start ##
		iEntity = gc.getInfoTypeForString("BUILDINGCLASS_AI_ENTITY")
		if CyGame().getBuildingClassCreatedCount(iEntity) > 0:
			bEntity = False
			for iTeamX in xrange(gc.getMAX_TEAMS()):
				pTeamX = gc.getTeam(iTeamX)
				if pTeamX.getBuildingClassCount(iEntity) > 0:
					bEntity = True
					break
			if bEntity:
				if CyGame().getSorenRandNum(2, "Rampage") == 0:
					bPlayer = gc.getPlayer(gc.getBARBARIAN_PLAYER())
					for iPlayerX in xrange(gc.getMAX_CIV_PLAYERS()):
						pPlayerX = gc.getPlayer(iPlayerX)
						if not pPlayerX.isAlive(): continue
						if pPlayerX.getBuildingClassCount(iEntity) > 0: continue
						pPlayerX.changeAnarchyTurns(5)
						(loopCity, iter) = pPlayerX.firstCity(false)
						while(loopCity):
							if not loopCity.area().isBorderObstacle(pPlayerX.getTeam()):
								for x in range(loopCity.getX() - 1, loopCity.getX() + 2):
									for y in range(loopCity.getY() - 1, loopCity.getY() + 2):
										pPlot = CyMap().plot(x,y)
										if not pPlot.isWater() and not pPlot.isCity() and not pPlot.isImpassable():
											if CyGame().getSorenRandNum(3, "Rampage") == 0:
												for i in range(3):
													bPlayer.initUnit(gc.getInfoTypeForString("UNIT_ASSAULT_MECH"), x, y, UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION)
								(loopCity, iter) = pPlayerX.nextCity(iter, false)
						CyInterface().addMessage(iPlayerX,true,15,CyTranslator().getText("TXT_AI_RAMPAGE",()),'',0,'',-1,-1,-1, true,true)
##

As I said, if you want to retain it as National Wonder, you have to shift it out to onEndGameTurn and do a lot of amendments. Else, it is going to trigger multiple times on the same victim.
 
Your AI Entity, i am remake him:
For Rivals:
4% Chance to sink into Anarchy for 5 turns
Spawns hostile Assault Mech throughout the empire
For you:
50% chance to protect you from rival's AI Entity, if you don't have AI Entity, expect havoc in your cities
10% chance to destroy rival's AI Entity

Code:
Code:
## AI Entity Start ##
		if pPlayer.getBuildingClassCount(gc.getInfoTypeForString("BUILDINGCLASS_AI_ENTITY")) == 1:
			if CyGame().getSorenRandNum(25, "Rampage") == 0:
				for iPlayerX in xrange(gc.getMAX_CIV_PLAYERS()):
					pPlayerX = gc.getPlayer(iPlayerX)
					if pPlayerX.isAlive() and iPlayerX != pPlayer.getID():
						pPlayerX.changeAnarchyTurns(5)
						if pPlayerX.getBuildingClassCount(gc.getInfoTypeForString("BUILDINGCLASS_GREAT_WALL")) == 0:
							if CyGame().getSorenRandNum(10, "Rampage") == 0:
								while pPlayerX.getBuildingClassCount(gc.getInfoTypeForString("BUILDINGCLASS_AI_ENTITY")) > 0:
									pPlayerX.removeBuildingClass(gc.getInfoTypeForString("BUILDINGCLASS_AI_ENTITY"))
								CyInterface().addMessage(iPlayerX,true,15,CyTranslator().getText("TXT_AI_ENTITY_DESTROYED",()),'',0,'',-1,-1,-1, true,true)
								CyInterface().addMessage(iPlayer,true,15,CyTranslator().getText("TXT_AI_ENTITY_RAMPAGE",()),'',0,'',-1,-1,-1, true,true)
							if pPlayerX.getBuildingClassCount(gc.getInfoTypeForString("BUILDINGCLASS_AI_ENTITY")) == 1:
								if CyGame().getSorenRandNum(2, "Rampage") == 0:
									bPlayer = gc.getPlayer(gc.getBARBARIAN_PLAYER())
									(loopCity, iter) = pPlayerX.firstCity(false)
									while(loopCity):
										for x in range(loopCity.getX() - 1, loopCity.getX() + 2):
											for y in range(loopCity.getY() - 1, loopCity.getY() + 2):
												pPlot = CyMap().plot(x,y)
												if not pPlot.isWater() and not pPlot.isCity() and not pPlot.isImpassable():
													if CyGame().getSorenRandNum(3, "Rampage") == 0:
														for i in range(3):
															pNewUnit = bPlayer.initUnit(gc.getInfoTypeForString("UNIT_ASSAULT_MECH"), x, y, UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION)
										(loopCity, iter) = pPlayerX.nextCity(iter, false)
									CyInterface().addMessage(iPlayerX,true,15,CyTranslator().getText("TXT_AI_RAMPAGE_ENEMY",()),'',0,'',-1,-1,-1, true,true)
								else:
									CyInterface().addMessage(iPlayerX,true,15,CyTranslator().getText("TXT_AI_ENT_DEFENSE",()),'',0,'',-1,-1,-1, true,true)
							else:	
								bPlayer = gc.getPlayer(gc.getBARBARIAN_PLAYER())
								(loopCity, iter) = pPlayerX.firstCity(false)
								while(loopCity):
									for x in range(loopCity.getX() - 1, loopCity.getX() + 2):
										for y in range(loopCity.getY() - 1, loopCity.getY() + 2):
											pPlot = CyMap().plot(x,y)
											if not pPlot.isWater() and not pPlot.isCity() and not pPlot.isImpassable():
												if CyGame().getSorenRandNum(3, "Rampage") == 0:
													for i in range(3):
														pNewUnit = bPlayer.initUnit(gc.getInfoTypeForString("UNIT_ASSAULT_MECH"), x, y, UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION)
									(loopCity, iter) = pPlayerX.nextCity(iter, false)
								CyInterface().addMessage(iPlayerX,true,15,CyTranslator().getText("TXT_AI_RAMPAGE_ENEMY",()),'',0,'',-1,-1,-1, true,true)
				CyInterface().addMessage(iPlayer,true,15,CyTranslator().getText("TXT_AI_RAMPAGE",()),'',0,'',-1,-1,-1, true,true)

This code work. This affect on all players, if player have AI Entity there is 50% chance to protect yourself from rival AI Entity, and 10% to lose its AI Entity.

TXT:

Spoiler :
Code:
	<TEXT>
		<Tag>TXT_KEY_BUILDING_AI_ENTITY</Tag>
		<English>AI Entity</English>
		</TEXT>
		<TEXT>
		<Tag>TXT_KEY_BUILDING_AI_ENTITY_PEDIA</Tag>
		<English>Artificial intelligence (AI) is the intelligence of machines and the branch of computer science that aims to create it. AI textbooks define the field as "the study and design of intelligent agents" where an intelligent agent is a system that perceives its environment and takes actions that maximize its chances of success. John McCarthy, who coined the term in 1956, defines it as "the science and engineering of making intelligent machines."[PARAGRAPH:2]AI research is highly technical and specialized, deeply divided into subfields that often fail to communicate with each other. Some of the division is due to social and cultural factors: subfields have grown up around particular institutions and the work of individual researchers. AI research is also divided by several technical issues. There are subfields which are focussed on the solution of specific problems, on one of several possible approaches, on the use of widely differing tools and towards the accomplishment of particular applications. The central problems of AI include such traits as reasoning, knowledge, planning, learning, communication, perception and the ability to move and manipulate objects. General intelligence (or "strong AI") is still among the field's long term goals. Currently popular approaches include statistical methods, computational intelligence and traditional symbolic AI. There are enormous number of tools used in AI, including versions of search and mathematical optimization, logic, methods based on probability and economics, and many others.</English>
		</TEXT>
		<TEXT>
		<Tag>TXT_KEY_BUILDING_AI_ENTITY_STRATEGY</Tag>
		<English>[COLOR_BUILDING_TEXT]AI Entity[COLOR_REVERT] is real chaos for rival civilization, there is some chance to make havoc in their empire.</English>
		</TEXT>
		<TEXT>
		<Tag>TXT_KEY_BUILDING_AI_ENTITY_HELP</Tag>
		<English>For Rivals:[NEWLINE][ICON_BULLET]4%% Chance to sink into Anarchy for 5 turns[NEWLINE][ICON_BULLET]Spawns hostile [LINK=UNIT_ASSAULT_MECH]Assault Mech[\LINK] throughout the empire[NEWLINE]For you:[NEWLINE][ICON_BULLET]50%% chance to protect you from rival's AI Entity, if you don't have AI Entity, expect havoc in your cities[NEWLINE][ICON_BULLET]10%% chance to destroy rival's AI Entity[NEWLINE]</English>
		</TEXT>
		<TEXT>
		<Tag>TXT_AI_RAMPAGE</Tag>
		<English>[COLOR_HIGHLIGHT_TEXT]Our AI Entity[COLOR_SELECTED_TEXT] has made havoc in rival's cities!!![COLOR_REVERT]</English>
		</TEXT>
		<TEXT>
		<Tag>TXT_AI_RAMPAGE_ENEMY</Tag>
		<English>[COLOR_HIGHLIGHT_TEXT]Rival AI Entity[COLOR_SELECTED_TEXT] has gone out of control and made havoc in our cities!!![COLOR_REVERT]</English>
		</TEXT>
		<TEXT>
		<Tag>TXT_AI_ENT_DEFENSE</Tag>
		<English>[COLOR_HIGHLIGHT_TEXT]Our AI Entity[COLOR_SELECTED_TEXT] protect us from rival AI Entity!!![COLOR_REVERT]</English>
		</TEXT>
		<TEXT>
		<Tag>TXT_AI_ENTITY_DESTROYED</Tag>
		<English>[COLOR_HIGHLIGHT_TEXT]Our AI Entity[COLOR_SELECTED_TEXT] had been destroyed from rival AI Entity!!![COLOR_REVERT]</English>
		</TEXT>
		<TEXT>
		<Tag>TXT_AI_ENTITY_RAMPAGE</Tag>
		<English>[COLOR_HIGHLIGHT_TEXT]Our AI Entity[COLOR_SELECTED_TEXT] destroyed rival AI Entity!!![COLOR_REVERT]</English>
		</TEXT>
 
Is it possible/simple for the Buddhas of Bamiyan code to be adjusted so it only allows the city it was built in to complete hurried production on the same turn? I love this effect, but the way I'm using it in my mod, it's too powerful if all the owner's cities get the benefit.
 
Is it possible/simple for the Buddhas of Bamiyan code to be adjusted so it only allows the city it was built in to complete hurried production on the same turn? I love this effect, but the way I'm using it in my mod, it's too powerful if all the owner's cities get the benefit.

Just use
Code:
if pCity.isHasBuilding(gc.getInfoTypeForString("BUILDING_BUDDHAS_OF_BAMIYAN")):
instead of the present if code (check the building spelling)?
 
use getNumActiveBuilding instead.
Skip the step to check for obsolete tech.
 
I might have an older version but there is no obsolete check here.
Code:
## Buddhas of Bamiyan Start ##
		if pPlayer.getBuildingClassCount(gc.getInfoTypeForString("BUILDINGCLASS_BUDDHAS_OF_BAMIYAN")) == 1:
			pCity.popOrder(0, true, false)
 
Because I already mentioned that I cannot be bothered to add obsolete check for wonders without obsolete techs in the notes.
 
platyping, would you be interested in applying your python prowess to creation of a unit?

I have always wanted to see a unit for Civs with the civic pacifism where the unique unit, when killed by another civ, would cause war weariness on the attacking civ.

Your help would be greatly appreciated.
 
I mentioned before that I no longer accept personal requests.
However, I can lend a guiding hand to whoever wish to try the task.
Thus, you should post in the request thread or main forum
 
onUnitKilled, or onCombatResults, depending on design:
1) Check Unit Type/ Unit Class
2) Check Owner's Civics
3) Find the Killer
4) Add X War Weariness to Killer's Team
5) Decide whether this amount should be adjusted by Enemy WW modifiers, or Killer's WW Reduction Modifiers, as well as gamespeed, handicap etc

Done
 
Just a question if it is possible :D

I noticed your Morale, which I kinda like, and it got me thinking :

Is it possible to make a unit remember how much "minus" moves it got in the previous round, and then apply it for the next round?
i.e. a unit have 1 out of 5 moves left. It then moves on top of a hill which is 4 moves. It is basically -3 moves, but next turn it will have 5 moves. Would it be possible for it to only have 2 moves? (5 - (1-4))

A side question ;)
Is it possible to use 1.5 moves pr diagonal move? (I know its basically only 1.41 or around there but traveling is usually not in a straight line, so the 0.09 could illustrate curved roads ;))
 
1) Not possible unless you use script data or other means to remember for every single unit.
=> Not worth the effort

2) Requires onUnitMove for such a minimal change
=> Not worth the effort too
 
May I ask how the Helsinki Cathedral is supposed to work? I added the effect to Chichen Itza (because vanilla Chichen Itza is more or less useless), but either I did it wrong, or I misunderstood the effect - my interpretation was that, if I would build this wonder and then go on to capture an enemy city, I would get the culture - and thus also the tiles - that this city had before I captured it. But even though I changed the percentage to 50%, nothing seems to happen?
 
If it doesn't work in the original download, then I will look into it. 10% in original is not alot to own tiles.
 
Top Bottom