Modern Alliances

Then try this now and see if you get a message lol
Code:
		if CyGame().getSorenRandNum(1, "Wonder Building") == 0:
			CyInterface().addImmediateMessage(CyTranslator().getText("TXT_GLOBAL_JAM",()), None)

If the first line of code already failed, something is wrong here lol

Last resort, change
Code:
if CyGame().getSorenRandNum(1, "Wonder Building") == 0:
to
Code:
if 1 < 2:

If the message still does not appear, something is interfering with your begin game turn codes
 
Try the last test above and see how lol.

By the way, you don't have to exit Civ 4 when testing python codes, they apply in game immediately
 
If you are using BUG, most likely that is the answer.

Paste this code under EndGameTurn codes
Code:
		CyInterface().addImmediateMessage(CyTranslator().getText("TXT_GLOBAL_JAM",()), None)

Most likely it won't work either.

Then try it in BeginPlayerTurn codes
 
yeah, god knows why Begin does not work but End works lol
Shift whole chunk there, remove the added messages codes

By the way, when you say Begin does not show the text, do you mean you only test the first turn?
 
This is just becoming a pain @ this point:mad:
 

Attachments

  • Civ4ScreenShot0008.JPG
    Civ4ScreenShot0008.JPG
    97.3 KB · Views: 57
upload your EventManager here since I dunno what is your line 400
 
Blahh to lazy to upload it, line 400 in red
Code:
def onEndGameTurn(self, argsList):
		'Called at the end of the end of each turn'
		iGameTurn = argsList[0]
		## Ancient Wonders Start ##
		if CyGame().getSorenRandNum(1, "Wonder Building") == 0:
			AncientWonder = []
			for iWonder in range(gc.getNumBuildingInfos()):
				Wonderinfo = gc.getBuildingInfo(iWonder)
				WonderBuildingClass = Wonderinfo.getBuildingClassType()
				WonderSpecialBuilding = Wonderinfo.getSpecialBuildingType()
				if WonderSpecialBuilding == gc.getInfoTypeForString("SPECIALBUILDING_ANCIENT_WONDER") and CyGame().getBuildingClassCreatedCount(WonderBuildingClass) == 0:
					AncientWonder.append(iWonder)

			[COLOR="Red"]CyInterface().addImmediateMessage(CyTranslator().getText("TXT_NUM_ANCIENTS",(len(AncientWonder)),), None)[/COLOR]		
			if len(AncientWonder) > 0:
				OlyPlayer = []
				for iPlayerX in range(gc.getMAX_CIV_PLAYERS()):
					pPlayerX = gc.getPlayer(iPlayerX)
					if pPlayerX.isAlive()==true:
						OlyPlayer.append(pPlayerX)

				pPlayer = OlyPlayer[CyGame().getSorenRandNum(len(OlyPlayer), "which player")]
				citychance = CyGame().getSorenRandNum(pPlayer.getNumCities(), "which city")

				i = 0
				b_WonderBuilt = false
				(loopCity, iter) = pPlayer.firstCity(false)
				while(loopCity):
					if i == citychance:
						WhichWonder = CyGame().getSorenRandNum(len(AncientWonder), "which wonder")
						Wonderinfo = gc.getBuildingInfo(AncientWonder[WhichWonder])
						if Wonderinfo.isWater():
							if loopCity.isCoastal(10):
								loopCity.setNumRealBuilding(AncientWonder[WhichWonder], 1)
								b_WonderBuilt = true
						else:
							loopCity.setNumRealBuilding(AncientWonder[WhichWonder], 1)
							b_WonderBuilt = true
					if b_WonderBuilt == true:
						if ((not gc.getGame().isNetworkMultiPlayer()) and (pPlayer.getID() == gc.getGame().getActivePlayer())):
							popupInfo = CyPopupInfo()
							popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
							popupInfo.setData1(AncientWonder[WhichWonder])
							popupInfo.setData2(loopCity.getID())
							popupInfo.setData3(0)
							popupInfo.setText(u"showWonderMovie")
							popupInfo.addPopup(pPlayer.getID())
						CyInterface().addImmediateMessage(CyTranslator().getText("TXT_ANCIENT_START",(gc.getBuildingInfo(AncientWonder[WhichWonder]).getDescription(),loopCity.getName(),pPlayer.getCivilizationDescriptionKey(),)), None)
						break
					i += 1
					(loopCity, iter) = pPlayer.nextCity(iter, false)
## Ancient Wonders End ##
 
There should still be a message at bottom just before the "break" to display the global message unless you remove it as well...

Every turn, it will still generate a random number
if CyGame().getSorenRandNum(1, "Wonder Building") == 0:

If it passes the test, it will still go through the Ancient Wonder loop
But if all are built, then
if len(AncientWonder) > 0:
will fail since there is no more AW, length of AW will be 0

Now if you are happy, you can adjust the percentage back to what you like, else it will be working at 100% every turn
 
I switched it to ten, since theres 50 ancient wonders and counting, so 500 turns is plenty

Is there anyway to remove code after it is done? I'm assuming not but it wuold be nice to remove any lag (no matter how small, since its severy turn) when its not necessary
 
Try this instead:
Spoiler :
Code:
## Ancient Wonders Start ##
		if CyGame().getSorenRandNum(1, "Wonder Building") == 0:
			AncientWonder = []
			for iWonder in range(gc.getNumBuildingInfos()):
				Wonderinfo = gc.getBuildingInfo(iWonder)
				WonderBuildingClass = Wonderinfo.getBuildingClassType()
				WonderSpecialBuilding = Wonderinfo.getSpecialBuildingType()
				if WonderSpecialBuilding == gc.getInfoTypeForString("SPECIALBUILDING_ANCIENT_WONDER") and CyGame().getBuildingClassCreatedCount(WonderBuildingClass) == 0:
					AncientWonder.append(iWonder)

			WhichWonder = CyGame().getSorenRandNum(len(AncientWonder), "which wonder")
			Wonderinfo = gc.getBuildingInfo(AncientWonder[WhichWonder])

			if len(AncientWonder) > 0:
				WonderPlayer = []
				for iPlayerX in range(gc.getMAX_CIV_PLAYERS()):
					pPlayerX = gc.getPlayer(iPlayerX)
					if pPlayerX.isAlive():
						if Wonderinfo.isWater():
							if pPlayerX.countNumCoastalCities() > 0:
								WonderPlayer.append(pPlayerX)
						else:
							WonderPlayer.append(pPlayerX)

				pPlayer = WonderPlayer[CyGame().getSorenRandNum(len(WonderPlayer), "which player")]
				WonderCity = []
				(loopCity, iter) = pPlayer.firstCity(false)
				while(loopCity):
					if Wonderinfo.isWater():
						if loopCity.isCoastal(10):
							WonderCity.append(loopCity)
					else:
						WonderCity.append(loopCity)
				if len(WonderCity) > 0:
					pCity = WonderCity[CyGame().getSorenRandNum(len(WonderCity), "which city")]
					pCity.setNumRealBuilding(AncientWonder[WhichWonder], 1)
					if ((not gc.getGame().isNetworkMultiPlayer()) and (pPlayer.getID() == gc.getGame().getActivePlayer())):
						popupInfo = CyPopupInfo()
						popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
						popupInfo.setData1(AncientWonder[WhichWonder])
						popupInfo.setData2(pCity.getID())
						popupInfo.setData3(0)
						popupInfo.setText(u"showWonderMovie")
						popupInfo.addPopup(pPlayer.getID())
					CyInterface().addImmediateMessage(CyTranslator().getText("TXT_ANCIENT_START",(gc.getBuildingInfo(AncientWonder[WhichWonder]).getDescription(),pCity.getName(),pPlayer.getCivilizationDescriptionKey(),)), None)
## Ancient Wonders End ##

The current system selects the city then selects the wonder. If the wonder selected is coastal but the city is not, then nothing happens so chance wasted.

This new system selects wonder first then selects only coastal city so should be better
 
Top Bottom