[Python question on def onCombatResult

Maniac

Apolyton Sage
Joined
Nov 27, 2004
Messages
5,603
Location
Gent, Belgium
If I want to use the "if (pPlayer.getCivics..." condition in an event, how does the game know if I'm talking about the civics of the winner or the loser of the combat? Would something like "if (pLoser.getCivics..." work? I'm trying to make an event that creates a unit for the player who lost a combat, with as condition that that players is running a certain civic.
http://forums.civfanatics.com/showthread.php?t=185378
 
In the method you're using, you can tell who's who from the parameters in the logging message
Code:
def onUnitKilled(self, argsList):
	'Unit Killed'
	unit, iAttacker = argsList
	player = PyPlayer(unit.getOwner())
	attacker = PyPlayer(iAttacker)
	if (not self.__LOG_UNITKILLED):
		return
	CvUtil.pyPrint('Player %d Civilization %s Unit %s was killed by Player %d' 
		%(player.getID(), player.getCivilizationName(), PyInfo.UnitInfo(unit.getUnitType()).getDescription(), attacker.getID()))

So 'player' is the one who lost the unit.
 
Back
Top Bottom