Hello All
Another noob questions thread, sorry...
I started looking at Python few weeks ago (thanks Baldyr for the help and links you provided, very usefull).
But I'm still quite confused... Let's check.
For the context, I'm planning a mod that recreates the post war events (revolutions, coup d'etat, guerilla).
First function: to spawn a warrior somewhere
If I understand well, if I launch in an event a
self.guerilla(5, 22, 13)
it would spawn a unit at x22 y13 as a warrior belonging to the civilization 5 as defined in the WBS, right?
Second function, I would need a bit of help...
In this case, I would launch a
self.revCoup(2, 22, 13)
for having the player 2 acquirring the city placed at x22 y13, is that right?
I'm using the plots around (or trying to use maybe) to get all the units of the player loosing the city placed in these plots.
And then, it would have a 40% chance to join the civilization getting the city, but for this, I don't know how to use convert... I tried just spawning a new unit a copying the experience, but then I don't know how to kill the first one...
I think I'm confused with the cy py instances, what you can or have to define, what you have to get...
If it's easier, I don't care defining all cities/civs, as the scenario would be closed with spec civs and cannot build cities.
Thanks for your help!!!
Another noob questions thread, sorry...
I started looking at Python few weeks ago (thanks Baldyr for the help and links you provided, very usefull).
But I'm still quite confused... Let's check.
For the context, I'm planning a mod that recreates the post war events (revolutions, coup d'etat, guerilla).
First function: to spawn a warrior somewhere
Code:
def guerilla (self, player, iX, iY)
unitType = gc.getInfoTypeForString("UNIT_WARRIOR")
player.initUnit(unitType, iX, iY, UnitAITypes.NO_UNITAI)
self.guerilla(5, 22, 13)
it would spawn a unit at x22 y13 as a warrior belonging to the civilization 5 as defined in the WBS, right?
Second function, I would need a bit of help...
Code:
def revCoup (self, player, iX, iY)
pCity = CyMap().plot(iX,iY).getPlotCity()
oplayer = CyCity.getOwner()
# Getting the plots around
lPlots = list()
lXCoord = range(iX - 2, iX + 5)
lYCoord = range(iX - 2, iY + 5)
# Getting the list of units on the plots
lUnit = oplayer.getUnitList()
for cyUnit in lUnit:
if cyUnit at (lXCoord, lYCoord):
randNum = cyGame.getSorenRandNum(100, "revol")
if randNum < 39:
# convert (CyUnit pUnit)
# unitType = getUnitType()
# exp = getExperience()
# kill (BOOL bDelay, PlayerType ePlayer)
else continue
# Getting the city to change owner
player.acquireCity(pCity,false,false)
In this case, I would launch a
self.revCoup(2, 22, 13)
for having the player 2 acquirring the city placed at x22 y13, is that right?
I'm using the plots around (or trying to use maybe) to get all the units of the player loosing the city placed in these plots.
And then, it would have a 40% chance to join the civilization getting the city, but for this, I don't know how to use convert... I tried just spawning a new unit a copying the experience, but then I don't know how to kill the first one...
I think I'm confused with the cy py instances, what you can or have to define, what you have to get...
If it's easier, I don't care defining all cities/civs, as the scenario would be closed with spec civs and cannot build cities.
Thanks for your help!!!