Phyton question. How to call unit?

Joined
Dec 13, 2004
Messages
155
Location
Estonia (EU)
This is a code from snaitf's unit allegence mod. As i understand, this create new unit what the loser's unit was. Question is, how to create sertain unit what you have in unit list? For example unit type UNIT_WORKER or UNIT_SLAVE?

newUnit = playerX.player.initUnit(pLoser.getUnitType(), pLoser.getX(), pLoser.getY(), UnitAITypes.NO_UNITAI)

what must be written in this line? "pLoser.getUnitType()" how you call unit from list?

How to create sertain unit by phyton?

I'm not a good script writer, i want to mod snaift's code to get slave unit if you win a battle. To have 20% or 30% chance if your civic is slave.
 
xType = unitX.getUnitCombatType()
yType = unitY.getUnitCombatType()
unitSlave = gc.getInfoTypeForString("UNIT_SLAVE")
SlaveryCivic = gc.getInfoTypeForString("CIVIC_SLAVERY")
if (...)
if (yType != gc.getInfoTypeForString("UNITCOMBAT_SIEGE") and yType != gc.getInfoTypeForString("UNITCOMBAT_ARMOR") and yType != gc.getInfoTypeForString("UNITCOMBAT_HELICOPTER") and yType != gc.getInfoTypeForString("UNITCOMBAT_NAVAL") and yType != gc.getInfoTypeForString("NONE")):
if (xType != gc.getInfoTypeForString("UNITCOMBAT_HELICOPTER") and xType != gc.getInfoTypeForString("NONE")):
iRand = random.randint(1, 100)
if (iRand >= 50):
newUnit = playerX.player.initUnit(unitSlave, pWinner.getX(), pWinner.getY(), UnitAITypes.NO_UNITAI)
 
Back
Top Bottom