error with BUG or my modmod of CvEventManager

omegaflames

Warlord
Joined
Sep 21, 2012
Messages
181
Downloaded and installed FallfromHeaven2041n, FfH2041o, and more_naval_ai__for_ffh2__v2_53_patch (and I'm running BTS 3.19). Made a copy of the entire FFH2 so I could add my modmod of it to it and after getting all the files updated (I used the compare plugin of notepad++ to see what was different since MNAI has been updated since I last played with FFH2). Now I'm not getting any python errors from Civ4 but BUG is tossing up an error in the ingame messages every time a unit moves.
Code:
Error in unitmove event handler <bound method cveventmanager.onunitmove of <BUGeventmanager.BUGeventmanager instanace at 0xe0971148>>
in cveventmanager.py i have
Code:
	def onUnitMove(self, argsList):
		'unit move'
		pPlot,pUnit,pOldPlot = argsList
		player = PyPlayer(pUnit.getOwner())
		unitInfo = PyInfo.UnitInfo(pUnit.getUnitType())

		if player.isHuman() == False:
			if pUnit.getOwner() == pPlot.getOwner():
				if pUnit.canCast(gc.getInfoTypeForString('SPELL_SPRING'), False):
					pUnit.cast(gc.getInfoTypeForString('SPELL_SPRING'))
				if pUnit.canCast(gc.getInfoTypeForString('SPELL_SCORCH'), False):
					pUnit.cast(gc.getInfoTypeForString('SPELL_SCORCH'))
				if pUnit.canCast(gc.getInfoTypeForString('SPELL_SNOWYDAY'), False):
					pUnit.cast(gc.getInfoTypeForString('SPELL_SNOWYDAY'))
#		if player and unitInfo:
#			CvUtil.pyPrint('Player %d Civilization %s unit %s is moving to %d, %d' 
#				%(player.getID(), player.getCivilizationName(), unitInfo.getDescription(), 
#				pUnit.getX(), pUnit.getY()))
		if (not self.__LOG_MOVEMENT):
			return
I can't find anything wrong with my code and I can't figure out how to get BUG to actually log anything no matter what settings I give it under the logging tab in its options. Any help figuring out what I'm doing wrong or a pointer to how to decode that BUG error message would be appreciated.

edit: these are my settings (sry the pics are so big imgur blows them up sometimes)
 
managed to figure out what part of BUG was tossing out the error message (please note I changed the actual error message so I could figure out what to look at). This is the code giving me the message.
Code:
	def _handleDefaultEvent(self, eventType, argsList):
		if self.EventHandlerMap.has_key(eventType):
			for eventHandler in self.EventHandlerMap[eventType]:
				try:
					eventHandler(argsList)
				except:
					BugUtil.trace("_handleDefaultEvent Error in %s event handler %s", eventType, eventHandler)
as best I can tell this means onUnitMove doesn't have an eventHandler but since it's part of the default actions of CvEventManager.py (and is turned on in PythonCallBackDefines.xml) then I really have no idea what I'm supposed to do as I don't even know what an eventhandler is. I tried commenting out the "BugUtil.trace" line to at least stop the errors from showing ingame but that completely broke the game, so I'm lost.
 
BUG errors can be a pain in the butt. It's probably a configuration thing though I cant really say for sure. Maybe so some searching on the BUG forum for answers.

Also, it looks like the code under if player.isHuman() == False: is something that you added? If so, try commenting that section out and see if it helps (and as an aside, I doubt you really want the AI to cast Scorch all the time - it will end up turning its own lands into Desert!)
 
I ended up changing the BUG code to
Code:
	def _handleDefaultEvent(self, eventType, argsList):
		if self.EventHandlerMap.has_key(eventType):
			for eventHandler in self.EventHandlerMap[eventType]:
				try:
					eventHandler(argsList)
				except:
					CvUtil.pyPrint("BugEventManager.py _handleDefaultEvent error")
#					BugUtil.trace("_handleDefaultEvent Error in %s event handler %s", eventType, eventHandler)
and that at least stopped the ingame error messages and at some point logging for BUG randomly started working again and I have no idea what I did to get that to happen as I made a few changes between checking to see if it was working.

Yes everything under that command was added by me and I totally rewrote those 3 spells so that only malakim would turn something into desert (and I added a +1 to food for desert tiles for them so it would be viable for them to live in a pure desert environment. As it is currently written in my modmod malakim will try to take their lands to desert, illians will try to take to snow, and everyone else iirc try to take to grassland. It's not the best method of getting the AI to terraform but so far it's working (or at least it should be *shrug)
 
Top Bottom