RogerBacon
King
- Joined
- Nov 16, 2003
- Messages
- 649
Hi,
I thought the above if statement would only be executed if the active player's unit won. It turns out, however, that it only works if the human player's unit wins the combat. getActivePlayer() returns the human player only and never an AI.
Is there any easy way to find out if the winner of a fight was the attacker or defender?
Roger Bacon
Code:
def onCombatResult(self, argsList):
'Combat Result'
pWinner,pLoser = argsList
playerX = PyPlayer(pWinner.getOwner())
unitX = PyInfo.UnitInfo(pWinner.getUnitType())
playerY = PyPlayer(pLoser.getOwner())
unitY = PyInfo.UnitInfo(pLoser.getUnitType())
# make sure the attacker won
if (pLoser.getOwner() != theGame.getActivePlayer()):
# do stuff
I thought the above if statement would only be executed if the active player's unit won. It turns out, however, that it only works if the human player's unit wins the combat. getActivePlayer() returns the human player only and never an AI.
Is there any easy way to find out if the winner of a fight was the attacker or defender?
Roger Bacon