Simple Python Things

OK anything on this yet?


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

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

RuntimeError: unidentifiable C++ exception

This time it happened when an enemy(normal civ) attacked my civ:confused:
 
A small correction. Replace "else if" with "elif" .

:lol: :lol: :cool:

Yes, my friend :)
I´m not programmer but i discoved it by system "try and error" :)
thanks. With this code I can combine more sort of slaves in one event and it is what i need. Art of all slave types is same. For player is change in usage only :) Now it all works OK in my mod :)


I have one more project here if is here somebody, who can help.

In my idea may be possible capture enemy capitol with unique palace and this unique palace will be changed in captured city to courthouse with same model as unique palace. ( Conservation unique model (historical building) in game )
The_J and ST_Martin helped me with base work but some error is in...

I find programmers for help with this idea. Can you all help, please? This thread is full of excellent programmers.

Sorry for my bad English :( ( I can make unique palaces for all civs of course... ) And sorry for fourth infiltration :(

Base modcomp with US as trial civilization is here:
 
What kind of errors did you have? I had to replace the spaces with tabs and after that it worked well. With nothing else changed, I had a couthouse in the conquered enemy's capital.

Problem is that In captured city is new courthouse but with courthouse model. I need for preservation historical building ( in case of my minimod: White house ) in game have in captured city courthouse with captured palace ( White house ) model. It is wherewith I need help.

Next problem is solve in code this event one time only. When I will capture second enemy city what is now new enemy capital must be here clasic palace and mustn't after capture be changed to next courthouse.
In this case must be unique palace building in game once only. First time in first capitol and after in captured city as courthouse with unique model.

Sorry for me bad English.
Can you all please help me with this minimod?

Thanks for answer and help
Hroch
 
@Strategyonly: No, no idea what's going on.
I have to remember to download your mod, so that you can give me a savegame and see it myself.

@hrochland:
- In your XML is an error, you have no entry for DCCOURTHOUSE in your BuildingsInfos.xml
- And you should set iConquestProb for the courthouses to 100, else you will sometimes not get a courthouse.

Next problem is solve in code this event one time only. When I will capture second enemy city what is now new enemy capital must be here clasic palace and mustn't after capture be changed to next courthouse.

One problem here: The python code can't see, why a capital has been moved.
Example:
- You capture Washington, new capital will be Philadelphia (or so).
- America decides to build the capital new in Philadelphia, because it's just better.
For python, both is the same, it can't see a difference, why it was moved.

It can be made so, that you can only capture the white house, when you capture the first found city, when it is a capital. That can be done relativly easy. So in the second example, you would not get the white house, when you capture one of your cities.


....but man, i have an easier suggestion, with no python.
- Make a new wonder, white house
- And make it a free building class for america, like this here (in CivilizationInfos.xml):
PHP:
			<FreeBuildingClasses>
				<FreeBuildingClass>
					<BuildingClassType>BUILDINGCLASS_PALACE</BuildingClassType>
					<bFreeBuildingClass>1</bFreeBuildingClass>
				</FreeBuildingClass>
			</FreeBuildingClasses>
- Then america will start with a palace and the white house. Or you can just make them start with only the white house.
- The white house will at the beginning be in the capital.
- If it's a wonder, it can't be moved
- It will not be moved, when you capture the capital

Is way easier, i think :), and will do, what you want.



Another thing: I'm out of modding for the next 2 or 3 weeks.
Semester holidays, and i'll stay for that time at my parents, without my gaming pc. So don't expect anything new from me. I'll sure be here for answering questions, but i can't test anything or fix more complicated errors.
 
@Strategyonly: No, no idea what's going on.
I have to remember to download your mod, so that you can give me a savegame and see it myself.


One thing i forgot to mention, it only happens around once in every 60-70 turns:confused:
 
One thing i forgot to mention, it only happens around once in every 60-70 turns:confused:

Then it must be a strange exception of which i have not thought yet.

Does SpawnACiv work on Scenarios? no I DO NOT have England :please: reply

Yes, it should.
But some things to note: For example, the civ you want to spawn, does it when the second civ researches iron working.
If you give every civ iron working by default in the scenario, the new civ will not spawn. If only some (not all), then the new civ will spawn, when the next time iron working is researched.
But besides that, there should not be any problems.
Only if the map is to crowded, the city placement could fail, don't forget this.
 
Yes, it should.
But some things to note: For example, the civ you want to spawn, does it when the second civ researches iron working.
If you give every civ iron working by default in the scenario, the new civ will not spawn. If only some (not all), then the new civ will spawn, when the next time iron working is researched.
But besides that, there should not be any problems.
Only if the map is to crowded, the city placement could fail, don't forget this.

:thanx: this mod is the best ;) :trophy:
 
Hey, The_J, I am using your Circus Hagenbeck code for the Olympic games and I was wondering if there is something I could add to it so that the city selected has to have a Colosseum in it?
 
Here is a couple of shots to show you whats happening.

The first one must somehow an interference between BUG and the modcomp, but i have no idea, what it could be.
The second one is just strange :confused: :crazyeye:. No idea, what that could be.

:thanx: this mod is the best ;) :trophy:

Thanks :).
I hope you'll use it in a good way ;).
And good luck with your mod :).

Hey, The_J, I am using your Circus Hagenbeck code for the Olympic games and I was wondering if there is something I could add to it so that the city selected has to have a Colosseum in it?

Change this part:
PHP:
                                        iCity = dice.get(pPlayer.getNumCities () , "Cities" )
                                        pCity = pPlayer.getCity(iCity)
                                        if pCity.isNone():continue
                                        pCity.setNumRealBuilding(gc.getInfoTypeForString("BUILDING_CIRCUSHAGENBECK"),1)

to:
PHP:
                                        iCity = dice.get(pPlayer.getNumCities () , "Cities" )
                                        pCity = pPlayer.getCity(iCity)
                                        if pCity.isNone():continue
                                        if not pCity.isHasBuilding(gc.getInfoTypeForString("BUILDING_WHATEVER")):continue
                                        pCity.setNumRealBuilding(gc.getInfoTypeForString("BUILDING_CIRCUSHAGENBECK"),1)


I really wonder, why i did not think of olympia myself. Is a sure more obvious choice than a circus.
 
Thanks.

Well, if you want to there are three different Olympic stadiums out there you could use so I don't see why you wouldn't. You might as well really.
 
The first one must somehow an interference between BUG and the modcomp, but i have no idea, what it could be.
The second one is just strange :confused: :crazyeye:. No idea, what that could be.

The second one is the same as the first one, just were the python error is beginning is all. Its just a second away from the first shot is all.:rolleyes:
 
Hey TJ,

I got a problem with Respawn-promo.

Here's the PythonErr.log:

Code:
Traceback (most recent call last):
  File "BugEventManager", line 350, in _handleDefaultEvent
  File "CvEventManager", line 456, in onCombatResult
RuntimeError: unidentifiable C++ exception

Here's the line 350 of "BugEventManager" in red:

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))

Here's the line 456 of ""CvEventManager" in red:

Code:
###respawn part 1 start###

		pPlayer = gc.getPlayer(pLoser.getOwner())
		pPID = pPlayer.getID()
		promotion = []
		promotion.append(gc.getInfoTypeForString('PROMOTION_LIVE2'))
		promotion.append(gc.getInfoTypeForString('PROMOTION_LIVE1'))
		
		if ((pLoser.isHasPromotion(gc.getInfoTypeForString('PROMOTION_LIVE1')))or(pLoser.isHasPromotion(gc.getInfoTypeForString('PROMOTION_LIVE2')))):
			iUnit = pLoser.getUnitType()                  
			pCity= pPlayer.getCapitalCity()
			iX =pCity.getX()
			iY = pCity.getY()
			if pLoser.getDomainType ()==gc.getInfoTypeForString('DOMAIN_SEA'):
				for iCity in range(pPlayer.getNumCities () ):
					ppCity = pPlayer.getCity(iCity)
					if ppCity.isNone():continue
					if ppCity.getOwner()<>pPID:continue
					pPlot = CyMap().plot(ppCity.getX(),ppCity.getY())
					if pPlot.isCoastalLand ():
						iX = ppCity.getX()
						iY = ppCity.getY()
						break                                

			[COLOR="Red"]newUnit = pPlayer.initUnit(iUnit, iX,iY, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)[/COLOR]
			pLoser.setDamage(0, False)
			newUnit.convert(pLoser)
				
			newUnit.finishMoves()
			counter=0
			CyInterface().addMessage(pPID,false,15,CyTranslator().getText("TXT_KEY_REBORN",()),'',0,'Art/Interface/Buttons/Phoenix.dds',ColorTypes(44), iX, iY, True,True)
			for i in range(2):                                
				counter=counter+1
				newUnit.setHasPromotion(promotion[i], False)                                                
			for i in range(2):
				if pLoser.isHasPromotion(promotion[i]):
					if i==1:
						break
					newUnit.setHasPromotion(promotion[i+1], True)
			pLoser.setDamage(100, False)
###respawn part 1 end###

Disabling line 456 and below gives only Python-errors but no CTD.
I have no idea what's going on :confused:
 
Damn, The_J looks busy, almost makes me feel bad to post this.

So I added the Colosseum requirement to your hagenbeck code, and then I got a syntax error pop-up, I was drunk so I didn't think to look at what it was, but since this is the only thing I added I assume it was the Colosseum thing. I also attempted to properly indent everything and I think I screwed it up. Here's the area of code:

Code:
	def onGameStart(self, argsList):
		'Called at the start of the game'

		self.initScriptData()
		
		### circus hagenbeck start part 2
			if (gc.getGame().getGameTurnYear() <> gc.getDefineINT("START_YEAR")):
				for iPlayer in range (gc.getMAX_PLAYERS()):
					 player = gc.getPlayer(iPlayer)
				if player.isAlive():
					numbuildings = player.countNumBuildings(gc.getInfoTypeForString("BUILDING_CIRCUSHAGENBECK"))
					if numbuildings>0:
						for iCity in range(player.getNumCities()):
							pCity = player.getCity(iCity)
							if pCity.getNumBuilding(gc.getInfoTypeForString("BUILDING_CIRCUSHAGENBECK"))>0:
							self.oldcity = [iPlayer,iCity]
			return
                ###circus hagenbeck end part 2          
		# Are we using the scenario file? If so, then show the backstory popup
		if (CyMap().plot(0,0).getScriptData() == "Scenario"):
			for iPlayer in range(gc.getMAX_PLAYERS()):
				player = gc.getPlayer(iPlayer)
				if (player.isAlive() and player.isHuman()):
					popupInfo = CyPopupInfo()
					popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT)
					szTitle = u"<font=4b>" + localText.getText("TXT_KEY_NEXT_WAR_BACKSTORY_TITLE", ()) + u"</font>"
					szBody = u"<font=3>" + localText.getText("TXT_KEY_NEXT_WAR_BACKSTORY_TEXT", ()) + u"</font>"
					popupInfo.setText(szTitle + u"\n\n" + szBody)
					popupInfo.addPopup(iPlayer)

	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
                                        if not pCity.isHasBuilding(gc.getInfoTypeForString("BUILDING_WHATEVER")):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):
                                            CyInterface().addMessage(iPlayerNum,false,20,CyTranslator().getText("TXT_KEY_CIRCUS_ANNOUNCE",(pCity.getName (),pPlayer.getCivilizationAdjective (1) )),'',0,'Art/Interface/Buttons/General/happy_person.dds',ColorTypes(gc.getInfoTypeForString("COLOR_GREEN")), pCity.getX(), pCity.getY(), True,True) 
                                        
                                        break
###circus hagenbeck end part 3

Can you see what isn't indented properly? Or what the syntax error is?
 
Damn, The_J looks busy, almost makes me feel bad to post this.

No, i'm not really busy atm.

So I added the Colosseum requirement to your hagenbeck code, and then I got a syntax error pop-up, I was drunk so I didn't think to look at what it was

:lol: don't drink and mod.

You might want to correct BUILDING_WHATEVER ;).
 
At this point, yes.
This here:
PHP:
		### circus hagenbeck start part 2
			if (gc.getGame().getGameTurnYear() <> gc.getDefineINT("START_YEAR")):
				for iPlayer in range (gc.getMAX_PLAYERS()):
					 player = gc.getPlayer(iPlayer)
				if player.isAlive():

seems to be wrong intended, the if player.isAlive() statement (and all, what's following) should be intended one tab more.
But it could be the case, that it just appears wrong here. Maybe attach the file to a post here, then i can see it more clearly.
 
Back
Top Bottom