Maniac
Apolyton Sage
When an aquaformer or former is destroyed by a barbarian, I want a damaged (aqua)former unit to be created.
This code seemed to do the job:
However I recently noticed that when a stack of two or more aquaformers is attacked, only one 'damaged aquaformer' unit is created. Thus I tried to experiment with other similar python functions, resulting in this:
This code doesn't create any units at all! Can anyone tell why??
And generally does anyone have an idea to create as many 'damaged' units as there were in the stack in the first place?
This code seemed to do the job:
Code:
def onCombatResult(self, argsList):
'Combat Result'
self.parent.onCombatResult(self, argsList)
pWinner,pLoser = argsList
playerX = PyPlayer(pWinner.getOwner())
unitX = PyInfo.UnitInfo(pWinner.getUnitType())
playerY = PyPlayer(pLoser.getOwner())
unitY = PyInfo.UnitInfo(pLoser.getUnitType())
pPlayer = gc.getPlayer(pWinner.getOwner())
pLPlayer = gc.getPlayer(pLoser.getOwner())
if pWinner.getOwner() == gc.getBARBARIAN_PLAYER():
pPlot = pLoser.plot()
if pLoser.getUnitType() == gc.getInfoTypeForString('UNIT_AQUAFORMER'):
newUnit = pLPlayer.initUnit(gc.getInfoTypeForString('UNIT_AQUAFORMER_DAMAGED'), pPlot.getX(), pPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
elif pLoser.getUnitType() == gc.getInfoTypeForString('UNIT_FORMER'):
newUnit = pLPlayer.initUnit(gc.getInfoTypeForString('UNIT_FORMER_DAMAGED'), pPlot.getX(), pPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
However I recently noticed that when a stack of two or more aquaformers is attacked, only one 'damaged aquaformer' unit is created. Thus I tried to experiment with other similar python functions, resulting in this:
Code:
def onUnitKilled(self, argsList):
'Unit Killed'
self.parent.onUnitKilled(self, argsList)
unit, iAttacker = argsList
player = PyPlayer(unit.getOwner())
attacker = PyPlayer(iAttacker)
pAttacker = gc.getPlayer(iAttacker)
iPlayer = unit.getOwner()
pPlayer = gc.getPlayer(iPlayer)
if pAttacker == gc.getBARBARIAN_PLAYER():
pPlot = unit.plot()
if unit.getUnitType() == gc.getInfoTypeForString('UNIT_AQUAFORMER'):
newUnit = pPlayer.initUnit(gc.getInfoTypeForString('UNIT_AQUAFORMER_DAMAGED'), pPlot.getX(), pPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
elif unit.getUnitType() == gc.getInfoTypeForString('UNIT_FORMER'):
newUnit = pPlayer.initUnit(gc.getInfoTypeForString('UNIT_FORMER_DAMAGED'), pPlot.getX(), pPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
This code doesn't create any units at all! Can anyone tell why??
And generally does anyone have an idea to create as many 'damaged' units as there were in the stack in the first place?