Just added 2 new calls to CyGame which should help to speed up some python processes, though I could actually only think of one case where it is used already:
CyGame().getNumCivActive(iCiv) - Tells you how many players who are currently alive are this Civilization type
CyGame().getCivActivePlayer(iCiv, iCount) - Tells you the iPlayer number for someone who is using this Civilization Type.
Previously, the closest which existed was
CyGame().isCivEverActive(iCiv) which just told you if at any point in the course of the game anyone has used a certain Civ.
What this does for you is that you can replace a check like this:
Code:
for iPlayer in range(gc.getMAX_PLAYERS()):
pPlayer = gc.getPlayer(iPlayer)
if (pPlayer.isAlive()):
if pPlayer.getCivilizationType() == iCivilization:
With this:
Code:
iNumCivs = CyGame().getNumCivActive(iCivilization)
for i in range (iNumCivs):
iPlayer = CyGame().getCivActivePlayer(iCivilization, i)
Which will be MUCH faster since the loop is done in C++ instead of python. At least, supposedly.
EDIT: @Tarq: I assume you tested it, but it should already be possible for a unit to make a ranged attack without having any movement available. We set that up a while ago since you could make a ranged attack, then move full movement, but not the other way around. So we supposedly fixed that.
EDIT2: Forgot to mention, but this new approach also makes it easy to randomly select one of the Players who uses a certain Civilization.