CyrusOrlandeau
Everescan
I'm not sure where else to post this, so after this question please redirect me to the proper area to post future questions like this. Thank you!
This is my problem: I wanted to make a simple modification to the code for equipments/items so that it would work with regular promotions, for example:
When one unit in a stack has the "Commander" promo, any other unit in the stack can use the "Train" spell, and instead of taking an item from the other unit, it gains a different promo (the "train" promo).
I'm working on something to add to the tower concept earlier, but I'm not sure what exactly is causing the problem in this code. Help is much appreciated, I'm stumped.
-A9A
This is my problem: I wanted to make a simple modification to the code for equipments/items so that it would work with regular promotions, for example:
When one unit in a stack has the "Commander" promo, any other unit in the stack can use the "Train" spell, and instead of taking an item from the other unit, it gains a different promo (the "train" promo).
I'm working on something to add to the tower concept earlier, but I'm not sure what exactly is causing the problem in this code. Help is much appreciated, I'm stumped.

Code:
def reqCommanderOrder(caster,unit):
if caster.getUnitCombatType() == gc.getInfoTypeForString ('UNITCOMBAT_NAVAL'):
return False
if caster.getUnitCombatType() == gc.getInfoTypeForString ('UNITCOMBAT_SIEGE'):
return False
if caster.getSpecialUnitType() == gc.getInfoTypeForString ('SPECIALUNIT_SPELL'):
return False
if caster.isHasPromotion(gc.getInfoTypeForString ('PROMOTION_ILLUSION')):
return False
iUnit = gc.getInfoTypeForString(unit)
iProm = gc.getUnitInfo(iUnit).getPromotionInfo()
if caster.isHasPromotion(iProm):
return False
iPlayer = caster.getOwner()
pPlot = caster.plot()
pHolder = -1
for i in range(pPlot.getNumUnits()):
pUnit = pPlot.getUnit(i)
if (pUnit.getOwner() == iPlayer and pUnit.isHasPromotion (iProm)):
pHolder = pUnit
if pHolder == -1:
return False
if pHolder.isHasCasted():
return False
if pHolder.getUnitType() == gc.getInfoTypeForString ('UNIT_BARNAXUS'):
if iProm == gc.getInfoTypeForString ('PROMOTION_PIECES_OF_BARNAXUS'):
return False
pPlayer = gc.getPlayer(iPlayer)
if pPlayer.isHuman() == False:
if caster.baseCombatStr() - 1 <= pHolder.baseCombatStr():
return False
if gc.getUnitInfo(pHolder.getUnitType()).getFreePromotions (iProm):
return False
return True
def spellCommanderOrder(caster,unit):
iUnit = gc.getInfoTypeForString(unit)
iProm = gc.getUnitInfo(iUnit).getPromotionInfo()
iPlayer = caster.getOwner()
pPlot = caster.plot()
pHolder = -1
for i in range(pPlot.getNumUnits()):
pUnit = pPlot.getUnit(i)
if (pUnit.getOwner() == iPlayer and pUnit.isHasPromotion (iProm) and pUnit != caster):
pHolder = pUnit
if pHolder != -1:
caster.setHasPromotion(iProm, True)
-A9A