Simple Python Things

hmm...the exceptions are turned on, right?
RoM is the biggest modpack around, and i know, that Zappara has min. added 1 era. Did he maybe also change the old eras?

Only for testing: Could you maybe add the line CyInterface().addMessage(etc..., which is at the end of the code, directly after iImprovement, iX, iY = argsList in the next line?
Then build an improvement, and look, if it throws an exception (with this change, it should throw one; only for testing). I just want to see, if the whole thing at all works.

OK i changed it to:
Code:
def onImprovementBuilt(self, argsList):
		'Improvement Built'
		iImprovement, iX, iY = argsList
		CyInterface().addMessage
###Militia Start ###

NO error messages?
 
You should have added the whole line, which was already in the file ;).
But doesn't matter, this should also have thrown an exception.
This means, that this file is not importet by the BUG eventmanager, so it can't do anything, because it's not in the game.
Check again, how you've added it to the game and the BUG loading thing. At this point, i can't help further, because i don't have any idea about the BUG settings, sorry :dunno: :(.
 
Shouldn't it be something like this?
Code:
if pWinner.isHasPromotion(gc.getInfoTypeForString('PROMOTION_INDUSTRYESPIONAGE')) and [COLOR="Blue"]gc.getPlayer(pLoser.getOwner()).getCurrentResearch()[/COLOR]>=0:

No, the research is tied to the team, not to the player (or i remember it wrong), but before the >=0: a pair of brackets () is missing.
Sorry for that.

It's possible to have different researches in one team but each player can have only one current research at a time. So I don't think it would be wise to tie current research to a team.
See the attachment. ;)

Oh, really, i didn't look closely enough at my files, you're right (including the code).

OK now i get this error WHEN enemy civ attacks my civ:

Traceback (most recent call last):
File "BugEventManager", line 350, in _handleDefaultEvent
File "Espionage", line 105, in onCombatResult

Code:
if iResearch >= 500:				
                                myteam.changeResearchProgress(pPlayer.getCurrentResearch (),20,pWinner.getOwner())
                                otherteam.changeResearchProgress(otherplayer.getCurrentResearch (),-20,pLoser.getOwner())
				message = 1
			elif iResearch >= 25:
				[B]myteam.changeResearchProgress(pPlayer.getCurrentResearch (),iResearchStolen,pWinner.getOwner())[/B]
				otherteam.changeResearchProgress(otherplayer.getCurrentResearch (),-iResearchStolen,pLoser.getOwner())
				message = 2

RuntimeError: unidentifiable C++ exception
 
OK now i get this error WHEN enemy civ attacks my civ:

Everytime?
Because i would expect this error, when you don't research anything.

bah, it seems, i forgot some important exception handlers :mad:.
 
mmhh...try to replace iResearchStolen in this line with int(iResearchStolen)
I guess, that is the problem.

OK here's what i did:
Code:
elif iResearch >= 25:
				myteam.changeResearchProgress(pPlayer.getCurrentResearch (),int(iResearchStolen),pWinner.getOwner())
				otherteam.changeResearchProgress(otherplayer.getCurrentResearch (),-iResearchStolen,pLoser.getOwner())
				message = 2

and i get this error WHEN a civ attacks my civ.

Traceback (most recent call last):
File "BugEventManager", line 350, in _handleDefaultEvent
File "Espionage", line 105, in onCombatResult
RuntimeError: unidentifiable C++ exception
 
Again the same line :confused:?
Not maybe the next one?
Just in case: Replace the -iResearchStolen with -int(iResearchStolen).

If it's really a problem with the same line again, then it would be good, if you could, just for testing, replace int(iResearchStolen) with...let's say 10 (like said, just a test).
I want to see, if that changes anything.
 
Again the same line :confused:?
Not maybe the next one?
Just in case: Replace the -iResearchStolen with -int(iResearchStolen).

If it's really a problem with the same line again, then it would be good, if you could, just for testing, replace int(iResearchStolen) with...let's say 10 (like said, just a test).
I want to see, if that changes anything.

OK didnt get a chance to do the 10 thing, but i get this now:confused: Again this is only when another civ attacks my civ!

Traceback (most recent call last):
File "BugEventManager", line 350, in _handleDefaultEvent
File "Espionage", line 109, in onCombatResult

Spoiler :
Code:
elif iResearch >= 25:
				myteam.changeResearchProgress(pPlayer.getCurrentResearch (),int(iResearchStolen),pWinner.getOwner())
				otherteam.changeResearchProgress(otherplayer.getCurrentResearch (),-int(iResearchStolen),pLoser.getOwner())
				message = 2
			else:
				[B]myteam.changeResearchProgress(pPlayer.getCurrentResearch (),1,pWinner.getOwner())[/B]
				otherteam.changeResearchProgress(otherplayer.getCurrentResearch (),-1,pLoser.getOwner())
				message = 3

RuntimeError: unidentifiable C++ exception


Also i canNOT get the Militia to work, i even put the units and stuff in the regular files, only thing that is different is the python: And is just isnt working????

http://forums.civfanatics.com/showpost.php?p=8872540&postcount=377
 
OK didnt get a chance to do the 10 thing, but i get this now:confused: Again this is only when another civ attacks my civ!

Traceback (most recent call last):
File "BugEventManager", line 350, in _handleDefaultEvent
File "Espionage", line 109, in onCombatResult

Spoiler :
Code:
elif iResearch >= 25:
				myteam.changeResearchProgress(pPlayer.getCurrentResearch (),int(iResearchStolen),pWinner.getOwner())
				otherteam.changeResearchProgress(otherplayer.getCurrentResearch (),-int(iResearchStolen),pLoser.getOwner())
				message = 2
			else:
				[B]myteam.changeResearchProgress(pPlayer.getCurrentResearch (),1,pWinner.getOwner())[/B]
				otherteam.changeResearchProgress(otherplayer.getCurrentResearch (),-1,pLoser.getOwner())
				message = 3

RuntimeError: unidentifiable C++ exception

:crazyeye: okay, err....WTH.
You say, it only happens when another civ attacks you, right? So not, when you attack another civ, right?
In that case, who does have the promotion? The other civ, or you?

Also i canNOT get the Militia to work, i even put the units and stuff in the regular files, only thing that is different is the python: And is just isnt working????

http://forums.civfanatics.com/showpost.php?p=8872540&postcount=377

Wait, you say, that it does not work, when you build just a new mod, with just the python in it?
 
:crazyeye: okay, err....WTH.
You say, it only happens when another civ attacks you, right? So not, when you attack another civ, right?
In that case, who does have the promotion? The other civ, or you?

Wait, you say, that it does not work, when you build just a new mod, with just the python in it?



I have it, dont know if the AI have it or not?

I have everything in A MOD, but since i have BUG, you got to have it in the init (Config) event area also, and for some reason, ONLY the python is not working. In the logs it says it loaded the module.:crazyeye:
I am all the way to Ren era and no units yet?
 
I have it, dont know if the AI have it or not?

Okay, that's enough to know for this point.
Does the error also appear only for you, when there's a higher research amount? (or did the last suggestion for the other lines fix the problem?)

I guess, it could maybe be a problem with the interface related to BUG, but i'm really not sure :crazyeye:.

I have everything in A MOD, but since i have BUG, you got to have it in the init (Config) event area also, and for some reason, ONLY the python is not working. In the logs it says it loaded the module.:crazyeye:
I am all the way to Ren era and no units yet?

But this can't really be :crazyeye:. If the module had loaded, every time you build the right improvement, it had to show an exception. Something here is definetly not loaded, and i can't say, what :(.
 
Okay, that's enough to know for this point.
Does the error also appear only for you, when there's a higher research amount? (or did the last suggestion for the other lines fix the problem?)

I guess, it could maybe be a problem with the interface related to BUG, but i'm really not sure :crazyeye:.



But this can't really be :crazyeye:. If the module had loaded, every time you build the right improvement, it had to show an exception. Something here is definetly not loaded, and i can't say, what :(.

1. Yes the other suggestions SEEMED to work, and its only me that gets the error message not all the time.

2. I left a message in the BUG thread also, they have no idea either why its not working? BUT is isn't. I wonder if it has to be something in the way the NEW python file is created?
 
1. Yes the other suggestions SEEMED to work, and its only me that gets the error message not all the time.

That now even gets more weird.
I have to playtest the modcomp excessivly, because i have at the moment really no idea, what the problem could be :crazyeye:.
Sadly, i don't have civ here at the moment :/.

I wonder if it has to be something in the way the NEW python file is created?

What do you mean with that?
 
I don't see, how this has anything to do with the creation of the file :confused:.

That was the one i made modular with RoM, that does NOT work?

and this is the one i just put in a modular eventmanager, dont think it is working either?

Spoiler :
Code:
def onBeginPlayerTurn(self, argsList):
		'Called at the beginning of a players turn'
		iGameTurn, iPlayer = argsList
		pPlayer = gc.getPlayer(iPlayer)
		
		pPlayer = gc.getPlayer(iPlayer)
		if gc.getTeam(pPlayer.getTeam()).isHasTech(self.iTECH_APPLIED_ECONOMICS):
			obsoleteTech = gc.getBuildingInfo(self.iBUILDING_WORLD_BANK).getObsoleteTech()
			if ( gc.getTeam(pPlayer.getTeam()).isHasTech(obsoleteTech) == false or obsoleteTech == -1 ):
				for iCity in range(pPlayer.getNumCities()):
					ppCity = pPlayer.getCity(iCity)
					if ppCity.getNumActiveBuilding(self.iBUILDING_WORLD_BANK) == true:
						#pPID = pPlayer.getID()
						iGold = pPlayer.getGold( )
						pPlayer.changeGold( iGold//50 )
		
		# Scientific Victory when Ascension Gate is found from player city ie. it has been built
		if CyGame().isVictoryValid(self.iVICTORY_SCIENTIFIC) :
			if gc.getTeam(pPlayer.getTeam()).isHasTech(self.iTECH_SENTIENT_EARTH):
				for iCity in range(pPlayer.getNumCities()):
					ppCity = pPlayer.getCity(iCity)
					if ppCity.getNumActiveBuilding(self.iBUILDING_ASCENSION_GATE) == true:
						CyGame().setWinner(pPlayer.getTeam(), self.iVICTORY_SCIENTIFIC)
		# Crusade Start ##
#		test = ( iGameTurn % 14 )
#		BugUtil.info ( "crusade test: %d", test) 
		obsoleteTech = gc.getBuildingInfo(self.iBUILDING_CRUSADE).getObsoleteTech()

		if ( gc.getTeam(pPlayer.getTeam()).isHasTech(obsoleteTech) == false or obsoleteTech == -1 ):
#			BugUtil.info("RoM - crusader spawn, tech check passed")
			for iCity in range(pPlayer.getNumCities()):
				ppCity = pPlayer.getCity(iCity)
				if ppCity.getNumActiveBuilding(self.iBUILDING_CRUSADE) == true:
					iX = ppCity.getX()
					iY = ppCity.getY()
					estiEnd = CyGame().getEstimateEndTurn()
					if ( estiEnd >= 1800 ):
						if ( iGameTurn % 16 ) == 0:
							for i in range(1):
								pNewUnit = pPlayer.initUnit( self.iUNIT_CRUSADER, iX, iY, UnitAITypes.UNITAI_ATTACK_CITY, DirectionTypes.NO_DIRECTION )
					elif ( estiEnd >= 1400 ):
						if ( iGameTurn % 14 ) == 0:
							for i in range(1):
								pNewUnit = pPlayer.initUnit( self.iUNIT_CRUSADER, iX, iY, UnitAITypes.UNITAI_ATTACK_CITY, DirectionTypes.NO_DIRECTION )
					elif ( estiEnd >= 1000 ):
						if ( iGameTurn % 12 ) == 0:
							for i in range(1):
								pNewUnit = pPlayer.initUnit( self.iUNIT_CRUSADER, iX, iY, UnitAITypes.UNITAI_ATTACK_CITY, DirectionTypes.NO_DIRECTION )
					elif ( estiEnd >= 700 ):
						if ( iGameTurn % 8 ) == 0:
							for i in range(1):
								pNewUnit = pPlayer.initUnit( self.iUNIT_CRUSADER, iX, iY, UnitAITypes.UNITAI_ATTACK_CITY, DirectionTypes.NO_DIRECTION )
					elif ( estiEnd >= 500 ):
						if ( iGameTurn % 6 ) == 0:
							for i in range(1):
								pNewUnit = pPlayer.initUnit( self.iUNIT_CRUSADER, iX, iY, UnitAITypes.UNITAI_ATTACK_CITY, DirectionTypes.NO_DIRECTION )
					elif ( estiEnd >= 300 ):
						if ( iGameTurn % 4 ) == 0:
							for i in range(1):
								pNewUnit = pPlayer.initUnit( self.iUNIT_CRUSADER, iX, iY, UnitAITypes.UNITAI_ATTACK_CITY, DirectionTypes.NO_DIRECTION )
					else:
						if ( iGameTurn % 4 ) == 0:
							for i in range(1):
								pNewUnit = pPlayer.initUnit( self.iUNIT_CRUSADER, iX, iY, UnitAITypes.UNITAI_ATTACK_CITY, DirectionTypes.NO_DIRECTION )
		# Crusade End #

	def onImprovementBuilt(self, argsList):
		'Improvement Built'
		iImprovement, iX, iY = argsList
###Militia Start ###
		pPlot = CyMap().plot(iX, iY)
		if iImprovement == gc.getInfoTypeForString('IMPROVEMENT_FARM'):
                        charity = gc.getInfoTypeForString( "CIVIC_CHARITY" )
                        iPlayer = pPlot.getOwner()
                        pPlayer = gc.getPlayer(iPlayer)
                        if (pPlayer.isCivic(charity)==True):
                                era = pPlayer.getCurrentEra ()
                                if (era == gc.getInfoTypeForString( "ERA_MEDIEVAL" )):
                                        militia = gc.getInfoTypeForString( 'UNIT_MILITIA_MEDIEVAL' )
                                        pNewUnit = pPlayer.initUnit( militia, iX, iY, UnitAITypes.UNITAI_RESERVE, DirectionTypes.NO_DIRECTION )
                                elif (era == gc.getInfoTypeForString( "ERA_RENAISSANCE" )):
                                        militia = gc.getInfoTypeForString( 'UNIT_MILITIA_RENAISSANCE' )
                                        pNewUnit = pPlayer.initUnit( militia, iX, iY, UnitAITypes.UNITAI_RESERVE, DirectionTypes.NO_DIRECTION )
                                elif (era == gc.getInfoTypeForString( "ERA_INDUSTRIAL" )):
                                        militia = gc.getInfoTypeForString( 'UNIT_MILITIA_INDUSTRIAL' )
                                        pNewUnit = pPlayer.initUnit( militia, iX, iY, UnitAITypes.UNITAI_RESERVE, DirectionTypes.NO_DIRECTION )
                                elif (era == gc.getInfoTypeForString( "ERA_MODERN" )):
                                        militia = gc.getInfoTypeForString( 'UNIT_MILITIA_MODERN' )
                                        pNewUnit = pPlayer.initUnit( militia, iX, iY, UnitAITypes.UNITAI_RESERVE, DirectionTypes.NO_DIRECTION )
                                CyInterface().addMessage(iPlayer,False,15,CyTranslator().getText("TXT_RECRUITED",()),'',0,'Art/Interface/Buttons/Civics/Serfdom.dds',ColorTypes(44), iX, iY, True,True)
###Militia End###

	def onBuildingBuilt(self, argsList):
 
Hey The_J, I got some python pop-ups while playing my mod (see attached image). So I looked to see what the issue was and it seems it may have something to do with your Circus Hagenbeck modcomp. I did test it before (but by starting in the Industrial era, this game was started from the ancient era) and it worked, and it may actually still work because I stopped playing it to make this post so I didn't see what happened in 1896, but I just wanted to bring your attention to it. Based on the python pop-ups I went into my DiplomacyEventManager.py file, to line 136, which was in your Hagenbeck code. Here is the section of code it is in, I have highlited the line in question in red:

Code:
	def onBeginGameTurn(self, argsList):
		'Called at the beginning of the end of each turn'
		iGameTurn = argsList[0]
###circus hagenbeck start part 3		
		if (CyGame().getTurnYear(iGameTurn)>=1890) and ( iGameTurn % 3 ==0 ):
                        counter = 0
                        while True:
                                counter = counter+1
                                if counter>=100:break
                                dice = gc.getGame().getMapRand()
                                iPlayer = dice.get(gc.getMAX_PLAYERS (), "Players")
                                pPlayer = gc.getPlayer(iPlayer)
                                if pPlayer.isNone():continue
                                if pPlayer.isAlive():
                                        iCity = dice.get(pPlayer.getNumCities () , "Cities" )
                                        pCity = pPlayer.getCity(iCity)
                                        if pCity.isNone():continue
                                        pCity.setNumRealBuilding(gc.getInfoTypeForString("BUILDING_CIRCUSHAGENBECK"),1)
                                        CyInterface().addMessage(iPlayer,false,20,CyTranslator().getText("TXT_KEY_CIRCUS_MOVED",(pCity.getName (),pCity.getName ())),'',0,'Art/Interface/Buttons/General/happy_person.dds',ColorTypes(gc.getInfoTypeForString("COLOR_GREEN")), pCity.getX(), pCity.getY(), True,True) 
                                        if self.oldcity <>[-1,-1]:
                                                otherplayer = gc.getPlayer(self.oldcity[0])
                                                othercity = otherplayer.getCity(self.oldcity[1])
                                                if not othercity.isNone():
                                                        othercity.setNumRealBuilding(gc.getInfoTypeForString("BUILDING_CIRCUSHAGENBECK"),0)
                                                        CyInterface().addMessage(self.oldcity[0],false,20,CyTranslator().getText("TXT_KEY_CIRCUS_LOST",(othercity.getName (),othercity.getName ())),'',0,'Art/Interface/Buttons/General/warning_popup.dds',ColorTypes(gc.getInfoTypeForString("COLOR_RED")), othercity.getX(), othercity.getY(), True,True)
                                        self.oldcity = [iPlayer,iCity]                                 
                                        MaxPlayers = gc.getMAX_CIV_PLAYERS ()
                                        for iPlayerNum in xrange(MaxPlayers):
                                            [COLOR="Red"]CyInterface().addMessage(iPlayerNum,false,20,CyTranslator().getText("TXT_KEY_CIRCUS_ANNOUNCE",(pCity.getName (),pPlayer.getCivilizationAdjective () )),'',0,'Art/Interface/Buttons/General/happy_person.dds',ColorTypes(gc.getInfoTypeForString("COLOR_GREEN")), pCity.getX(), pCity.getY(), True,True)[/COLOR] 
                                        
                                        break
###circus hagenbeck end part 3

So there's that, it also refers to the BUGEventManager file, line 350, which I have also highlited in red here:

Code:
	def _handleDefaultEvent(self, eventType, argsList):
		if self.EventHandlerMap.has_key(eventType):
			for eventHandler in self.EventHandlerMap[eventType]:
				try:
					[COLOR="Red"]eventHandler(argsList)[/COLOR]
				except:
					BugUtil.trace("Error in %s event handler %s", eventType, BugUtil.escapeXml(eventHandler))

I was wondering what I needed to change here? I'll continue playing to see if it actually works, but I'd still like to see if this can get streamlined. I'll also update you on what happens in 1896. Thanks.

P.S. this error occured in 1892 BTW, so it was before it was even supposed to occur.
 

Attachments

  • DipomacyIIPythonPopUps1.jpg
    DipomacyIIPythonPopUps1.jpg
    52 KB · Views: 53
Back
Top Bottom