Modders & units makers Help us please

Try:
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())

		if pWinner.getUnitClassType() == gc.getInfoTypeForString("UNITCLASS_CRUISE_MISSILE"):
			pWinner.kill(0, pWinner.getOwner())
			CvUtil.pyPrint("The Cruise Misile has detonated!")

		if (not self.__LOG_COMBAT):
			return
		if playerX and playerX and unitX and playerY:
			CvUtil.pyPrint('Player %d Civilization %s Unit %s has defeated Player %d Civilization %s Unit %s' 
				%(playerX.getID(), playerX.getCivilizationName(), unitX.getDescription(), 
				playerY.getID(), playerY.getCivilizationName(), unitY.getDescription()))
I'm assuming the unitclass for the unit is UNITCLASS_CRUISE_MISSILE in the XML. Otherwise there may be a typo or something that I'm missing.
 
The Great Apple said:
Try:
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())

		if pWinner.getUnitClassType() == gc.getInfoTypeForString("UNITCLASS_CRUISE_MISSILE"):
			pWinner.kill(0, pWinner.getOwner())
			CvUtil.pyPrint("The Cruise Misile has detonated!")

		if (not self.__LOG_COMBAT):
			return
		if playerX and playerX and unitX and playerY:
			CvUtil.pyPrint('Player %d Civilization %s Unit %s has defeated Player %d Civilization %s Unit %s' 
				%(playerX.getID(), playerX.getCivilizationName(), unitX.getDescription(), 
				playerY.getID(), playerY.getCivilizationName(), unitY.getDescription()))
I'm assuming the unitclass for the unit is UNITCLASS_CRUISE_MISSILE in the XML. Otherwise there may be a typo or something that I'm missing.


thanks I'll try it now:scan:

EDIT Nope doesn't work am i missing something i've put it in cvcustomeventmanager.py and placed it in C:\Documents and Settings\**USER NAME**\My Documents\My Games\Sid Meier's Civilization 4\CustomAssets\python\ i don't know python so i don't know how it goes :(

I've also posted the file
 
Right - I'm not sure about CvCustomEventManager.py. I'd make a copy of CvEventManager.py and stick it in there.

Have you got python logging on? Does it come up with any errors?
 
i done as you said got rid of the cvcustomeventmanager and just put it in cveventmanager, now when i use the missile the game crashes or just freezes i have got a dump file but I can't read it.

how do i enable python logging?

edit foreget that one i found it in your sig lol
 
I got the python logs if you have time to look see maybe you can make something of it... lol To me it looks ok but then everything does
 
I did this a few weeks ago. The game freezes due to pUnit.kill(0....
It needs to be pUint.kill(true,....
I know pUnit.kill(0,0) works for somethings and I don't know why the first parameter has to be true this time around but when I changed it to true it worked fine from there on.

Roger Bacon
 
BTW, something I found out during playing with the SDK, really bad things happen when you use kill(true) on an attacking or selected unit. You actually MUST use setDamage(getMaxHP()) to kill off an attacker. ;)

Oh, and I've implemented missiles via SDK in my combat mod. All that's required is an xml flag in Civ4UnitInfos.xml to tell the code it's a missile. :D

http://forums.civfanatics.com/showpost.php?p=4107344&postcount=143

Dale
 
Dale said:
BTW, something I found out during playing with the SDK, really bad things happen when you use kill(true) on an attacking or selected unit. You actually MUST use setDamage(getMaxHP()) to kill off an attacker. ;)

What happens? Does it not clean up the memory allocated to the unit or something?

Roger Bacon
 
No, it has to do with memory but not cuz it doesn't clean it up, the opposite. When you kill the unit that's currently selected then the next reference to it goes to a NULL section of the unit list. CRASH! It's the old "app reading memory that isn't there" error. :)
 
Back
Top Bottom