Gunner said:
Code:
def onEndPlayerTurn(self, argsList):
'Called at the end of a players turn'
iGameTurn, iPlayer = argsList
player = gc.getPlayer(iPlayer)
unitList = PyPlayer(iPlayer).getUnitList()
if (player.isCivic(gc.getInfoTypeForString("CIVIC_BLITZKRIEG"))):
for pUnit in unitList:
if pUnit.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_ARMOR"):
pUnit.setHasPromotion(gc.getInfoTypeForString("PROMOTION_MARCH"), true)
else:
[B]if player.isAnarchy() == False:[/B]
for pUnit in unitList:
if pUnit.isHasPromotion(gc.getInfoTypeForString("PROMOTION_MARCH")):
pUnit.setHasPromotion(gc.getInfoTypeForString("PROMOTION_MARCH"), false)
Why have you specified the Civilization not to be in Anarchy? Surely it could be in anarchy moving away from blitzkreig, and this wouldn't work until a civic was assigned. I'm not sure if isCivic(...) would pick up civics while in anarchy, so you may either lose, or still have the promotions in anarchy. I don't know.
This code also has the problem that it will remove the march promotion from any unit, even if the promotion wasn't given by the civic. I'm not sure if this is intented or not. Seems like it might be an issue.
It also has some optimisation problems. It wouldn't be too hard to only run it on the turn after the civic changes, avoiding all the unit cycling every turn. You probably wouldn't notice the difference - but it would start to get in the order of seconds added between turns on maps with large amounts of units.
To expand on the base, I'd use something similar to this:
Code:
# THIS BIT GOES ABOVE THE CLASS DEFINITION
iNumPlayers = gc.getGame.countCivPlayersEverAlive()
bBkChange = []
marchList = []
while iNumPlayers <= len(bBKChange):
bBKChange.append(1)
marchList.append([])
#----
# Whatever the class is
class [...]:
# Other events
[...]
def onEndPlayerTurn(self, argsList):
'Called at the end of a players turn'
iGameTurn, iPlayer = argsList
player = gc.getPlayer(iPlayer)
unitList = PyPlayer(iPlayer).getUnitList()
if (player.isCivic(gc.getInfoTypeForString("CIVIC_BLITZKRIEG"))):
if bBKChange[iPlayer]:
marchList[iPlayer] = []
for pUnit in unitList:
if pUnit.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_ARMOR"):
pUnit.setHasPromotion(gc.getInfoTypeForString("PROMOTION_MARCH"), true)
marchList[iPlayer].append(pUnit)
bBKChange[iPlayer] = 0
else:
if not bBKChange[iPlayer]:
for pUnit in marchList[iPlayer]:
pUnit.setHasPromotion(gc.getInfoTypeForString("PROMOTION_MARCH"), false)
bBKChange[iPlayer] = 1
This fixes all the problems I mentioned above. This should track all the units which have been given the march promotion by this code using a list of lists, and also keep track of whether the promotion need be tested for or not (both when you have the civic, and when not). Not very big changes, but the little things make all the difference

.
Note that the bit at the top goes above the class definition, and the rest goes in "def onEndPlayerTurn(...)"
I'm pretty sure it'll work, but if it doesn't, the code posted by Gunner should be fine.
The AI will not recognise the importance of this change.
As for merging, I'd suggest:
Code:
def onEndPlayerTurn(self, argsList):
# INSERT CODE HERE (removing duplicate iGameTurn, iPlayer = argsList)
realSlavery.onEndPlayerTurn(argsList)
self.parent.onEndPlayerTurn
Oh - and if you don't have it, I would suggest enabling python error popups. They give some indication of where/what the problem is, and make the whole thing alot easier to debug. (HidePythonExceptions = 0 in the main Civ4 ini file should do it)
BTW: Gunner - if you don't get any of the above I would be happy to explain.
About the other civic - making the AI's friendlier is best done in the SDK, otherwise you don't get the mouseover info. Kael has written a tutorial covering something similar.