Python debugging and Rise of Rome's great person training function

HanWuDi

Chieftain
Joined
Feb 8, 2009
Messages
56
Rise of Rome has a function which creates a great person in your capital every time you research a repeatable tech. I've been trying to get that to work in other mods for a long time, but it never works.

I've created a barebones mod with the xml for the five new techs and their text, and copied the CvEventManager.py file into my python folder, and then modified the lines:

Code:
	def onTechAcquired(self, argsList):
		'Tech Acquired'
		iTechType, iTeam, iPlayer, bAnnounce = argsList
		# Note that iPlayer may be NULL (-1) and not a refer to a player object
		
		# Show tech splash when applicable
		if (iPlayer > -1 and bAnnounce and not CyInterface().noTechSplash()):
			if (gc.getGame().isFinalInitialized() and not gc.getGame().GetWorldBuilderMode()):
				if ((not gc.getGame().isNetworkMultiPlayer()) and (iPlayer == gc.getGame().getActivePlayer())):
					popupInfo = CyPopupInfo()
					popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
					popupInfo.setData1(iTechType)
					popupInfo.setText(u"showTechSplash")
					popupInfo.addPopup(iPlayer)
				
		if (not self.__LOG_TECH):
			return
		CvUtil.pyPrint('%s was finished by Team %d' 
			%(PyInfo.TechnologyInfo(iTechType).getDescription(), iTeam))

by adding code from CvRiseOfRomeEventManager.py
Code:
	def onTechAcquired(self, argsList):
		'Tech Acquired'
		iTechType, iTeam, iPlayer, bAnnounce = argsList
		# Note that iPlayer may be NULL (-1) and not a refer to a player object
		pCapitalCity = gc.getPlayer(iPlayer).getCapitalCity()
		iMerchant = CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),"UNIT_MERCHANT")
		iScientist = CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),"UNIT_SCIENTIST")
		iArtist = CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),"UNIT_ARTIST")
		iProphet = CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),"UNIT_PROPHET")
		iEngineer = CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),"UNIT_ENGINEER")
		
		# Show tech splash when applicable
		if (iPlayer > -1 and bAnnounce and not CyInterface().noTechSplash()):
			if (gc.getGame().isFinalInitialized() and not gc.getGame().GetWorldBuilderMode()):
				if ((not CyGame().isNetworkMultiPlayer()) and (iPlayer == CyGame().getActivePlayer())):
					popupInfo = CyPopupInfo()
					popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
					popupInfo.setData1(iTechType)
					popupInfo.setText(u"showTechSplash")
					popupInfo.addPopup(iPlayer)
		
#		if iTechType == CvUtil.findInfoTypeNum(gc.getTechInfo,gc.getNumTechInfos(),"TECH_ROR_TRAIN_WARLORD"):
		if iTechType == CvUtil.findInfoTypeNum(gc.getTechInfo,gc.getNumTechInfos(),"TECH_ROR_TRAIN_MERCHANT"):
			gc.getPlayer(iPlayer).initUnit(iMerchant, pCapitalCity.getX(), pCapitalCity.getY(), UnitAITypes.UNITAI_MERCHANT)
		if iTechType == CvUtil.findInfoTypeNum(gc.getTechInfo,gc.getNumTechInfos(),"TECH_ROR_TRAIN_SCIENTIST"):
			gc.getPlayer(iPlayer).initUnit(iScientist, pCapitalCity.getX(), pCapitalCity.getY(), UnitAITypes.UNITAI_SCIENTIST)	
		if iTechType == CvUtil.findInfoTypeNum(gc.getTechInfo,gc.getNumTechInfos(),"TECH_ROR_TRAIN_ARTIST"):
			gc.getPlayer(iPlayer).initUnit(iArtist, pCapitalCity.getX(), pCapitalCity.getY(), UnitAITypes.UNITAI_ARTIST)
		if iTechType == CvUtil.findInfoTypeNum(gc.getTechInfo,gc.getNumTechInfos(),"TECH_ROR_TRAIN_PROPHET"):
			gc.getPlayer(iPlayer).initUnit(iProphet, pCapitalCity.getX(), pCapitalCity.getY(), UnitAITypes.UNITAI_PROPHET)
		if iTechType == CvUtil.findInfoTypeNum(gc.getTechInfo,gc.getNumTechInfos(),"TECH_ROR_TRAIN_ENGINEER"):
			gc.getPlayer(iPlayer).initUnit(iEngineer, pCapitalCity.getX(), pCapitalCity.getY(), UnitAITypes.UNITAI_ENGINEER)

To make this:
Code:
	def onTechAcquired(self, argsList):
		'Tech Acquired'
		iTechType, iTeam, iPlayer, bAnnounce = argsList
		# Note that iPlayer may be NULL (-1) and not a refer to a player object
		pCapitalCity = gc.getPlayer(iPlayer).getCapitalCity()
		iMerchant = CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),"UNIT_MERCHANT")
		iScientist = CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),"UNIT_SCIENTIST")
		iArtist = CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),"UNIT_ARTIST")
		iProphet = CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),"UNIT_PROPHET")
		iEngineer = CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),"UNIT_ENGINEER")
		
		# Show tech splash when applicable
		if (iPlayer > -1 and bAnnounce and not CyInterface().noTechSplash()):
			if (gc.getGame().isFinalInitialized() and not gc.getGame().GetWorldBuilderMode()):
				if ((not CyGame().isNetworkMultiPlayer()) and (iPlayer == CyGame().getActivePlayer())):
					popupInfo = CyPopupInfo()
					popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
					popupInfo.setData1(iTechType)
					popupInfo.setText(u"showTechSplash")
					popupInfo.addPopup(iPlayer)
		
#		if iTechType == CvUtil.findInfoTypeNum(gc.getTechInfo,gc.getNumTechInfos(),"TECH_ROR_TRAIN_WARLORD"):
		if iTechType == CvUtil.findInfoTypeNum(gc.getTechInfo,gc.getNumTechInfos(),"TECH_TRAIN_MERCHANT"):
			gc.getPlayer(iPlayer).initUnit(iMerchant, pCapitalCity.getX(), pCapitalCity.getY(), UnitAITypes.UNITAI_MERCHANT)
		if iTechType == CvUtil.findInfoTypeNum(gc.getTechInfo,gc.getNumTechInfos(),"TECH_TRAIN_SCIENTIST"):
			gc.getPlayer(iPlayer).initUnit(iScientist, pCapitalCity.getX(), pCapitalCity.getY(), UnitAITypes.UNITAI_SCIENTIST)	
		if iTechType == CvUtil.findInfoTypeNum(gc.getTechInfo,gc.getNumTechInfos(),"TECH_TRAIN_ARTIST"):
			gc.getPlayer(iPlayer).initUnit(iArtist, pCapitalCity.getX(), pCapitalCity.getY(), UnitAITypes.UNITAI_ARTIST)
		if iTechType == CvUtil.findInfoTypeNum(gc.getTechInfo,gc.getNumTechInfos(),"TECH_TRAIN_PRIEST"):
			gc.getPlayer(iPlayer).initUnit(iProphet, pCapitalCity.getX(), pCapitalCity.getY(), UnitAITypes.UNITAI_PROPHET)
		if iTechType == CvUtil.findInfoTypeNum(gc.getTechInfo,gc.getNumTechInfos(),"TECH_TRAIN_ENGINEER"):
			gc.getPlayer(iPlayer).initUnit(iEngineer, pCapitalCity.getX(), pCapitalCity.getY(), UnitAITypes.UNITAI_ENGINEER)
				
		if (not self.__LOG_TECH):
			return
		CvUtil.pyPrint('%s was finished by Team %d' 
			%(PyInfo.TechnologyInfo(iTechType).getDescription(), iTeam))

This has never worked. So I turned on some debugging and I got this error in my debug log:
Traceback (most recent call last):

File "CvEventInterface", line 23, in onEvent

File "CvEventManager", line 187, in handleEvent

File "CvEventManager", line 697, in onTechAcquired

ArgumentError: Python argument types in
CyPlayer.initUnit(CyPlayer, int, int, int, CvPythonExtensions.UnitAITypes)
did not match C++ signature:
initUnit(class CyPlayer {lvalue}, int, int, int, enum UnitAITypes, enum DirectionTypes)
ERR: Python function onEvent failed, module CvEventInterface
So according to the reading I've been doing, I get argument errors when I'm using a function designed for a pointer on an integer. My question is, why does this code work in Rise of Rome and not in my mod, and how do I fix this?

I was a wiz with Basic, but I've never been entierly comfortable with function based programming like C, so I'm not entierly sure how to troubleshoot this any further myself.
 
That's a small problem because of the API change between Warlords and BtS, i guess.

Everywhere, where you find something like this:

PHP:
gc.getPlayer(iPlayer).initUnit(iScientist, pCapitalCity.getX(), pCapitalCity.getY(), UnitAITypes.UNITAI_SCIENTIST)

add after UnitAITypes.UNITAI_WHATEVER a
PHP:
,DirectionTypes.NO_DIRECTION


->
PHP:
gc.getPlayer(iPlayer).initUnit(iScientist, pCapitalCity.getX(), pCapitalCity.getY(), UnitAITypes.UNITAI_SCIENTIST,DirectionTypes.NO_DIRECTION)

Do that everywhere, where you find "initUnit"
 
Now, if I wanted to further modify a tech like future tech to have a percentage chance of changing a gamewide stat, like perhaps a 2% chance to increase all pasture hammers by 1, I assume I would need a random number generator. The API reference I'm reading here http://civilization4.net/files/modding/PythonAPI_v160/ says there's a get function under CyRandom that can generate one, can anyone explain how to modify the numbers I get to fall within a certain range?
 
so I would write something like
Code:
if iTechType == CvUtil.findInfoTypeNum(gc.getTechInfo,gc.getNumTechInfos(),"TECH_FUTURE_TECH") and getRand(50) == 0:
	gc.changeImprovementYieldChange(14,1,1)

Or am I not using that right? And would I have to define this function for myself or do I import it?
 
I used
Code:
if iTechType == CvUtil.findInfoTypeNum(gc.getTechInfo,gc.getNumTechInfos(),"TECH_FUTURE_TECH") and gc.getGame().getMapRand().get(50, "Some Chars")  > 25:
	gc.changeImprovementYieldChange(14,1,1)
to see if it would work, and the debug log said
Traceback (most recent call last):

File "CvEventInterface", line 23, in onEvent

File "CvEventManager", line 187, in handleEvent

File "CvEventManager", line 707, in onTechAcquired

AttributeError: 'CyGlobalContext' object has no attribute 'changeImprovementYieldChange'
ERR: Python function onEvent failed, module CvEventInterface

Which I'm guessing means I didn't import the file that contains the function? But when I tried importing CyTeam, which the reference says changeimprovementyieldchange is under, everything goes completely haywire.
 
Uh, sorry :blush:.

Wenn you look at the API, you'll see that changeImprovementYieldChange is a function from CyTeam, so it needs to be triggered for a team.

Like:
PHP:
MyTeam = gc.getTeam (putTheTeamNumberHere)
MyTeam.changeImprovementYieldChange(14,1,1)
 
so If I want to trigger this for whoever researches at tech, and ontechaquired passes that value in iTeam(?), I'd use this?
Code:
gc.getTeam(iTeam).changeImprovementYieldChange(14,1,1)
 
Ok, I got that code to work fine, but now I'm having problems turning this into what I want it to do.

My code is now
Code:
	def onTechAcquired(self, argsList):
		'Tech Acquired'
		iTechType, iTeam, iPlayer, bAnnounce = argsList
		# Note that iPlayer may be NULL (-1) and not a refer to a player object
		pCapitalCity = gc.getPlayer(iPlayer).getCapitalCity()
		iMerchant = CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),"UNIT_MERCHANT")
		iScientist = CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),"UNIT_SCIENTIST")
		iArtist = CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),"UNIT_ARTIST")
		iProphet = CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),"UNIT_PROPHET")
		iEngineer = CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),"UNIT_ENGINEER")
		iRandomNumber = gc.getGame().getMapRand().get(50, "Some Chars")
		
		# Show tech splash when applicable
		if (iPlayer > -1 and bAnnounce and not CyInterface().noTechSplash()):
			if (gc.getGame().isFinalInitialized() and not gc.getGame().GetWorldBuilderMode()):
				if ((not CyGame().isNetworkMultiPlayer()) and (iPlayer == CyGame().getActivePlayer())):
					popupInfo = CyPopupInfo()
					popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
					popupInfo.setData1(iTechType)
					popupInfo.setText(u"showTechSplash")
					popupInfo.addPopup(iPlayer)
		
#		if iTechType == CvUtil.findInfoTypeNum(gc.getTechInfo,gc.getNumTechInfos(),"TECH_ROR_TRAIN_WARLORD"):

		if iTechType == CvUtil.findInfoTypeNum(gc.getTechInfo,gc.getNumTechInfos(),"TECH_TRAIN_MERCHANT"):
			gc.getPlayer(iPlayer).initUnit(iMerchant, pCapitalCity.getX(), pCapitalCity.getY(), UnitAITypes.UNITAI_MERCHANT,DirectionTypes.NO_DIRECTION)

		if iTechType == CvUtil.findInfoTypeNum(gc.getTechInfo,gc.getNumTechInfos(),"TECH_TRAIN_SCIENTIST"):
			gc.getPlayer(iPlayer).initUnit(iScientist, pCapitalCity.getX(), pCapitalCity.getY(), UnitAITypes.UNITAI_SCIENTIST,DirectionTypes.NO_DIRECTION)	

		if iTechType == CvUtil.findInfoTypeNum(gc.getTechInfo,gc.getNumTechInfos(),"TECH_TRAIN_ARTIST"):
			gc.getPlayer(iPlayer).initUnit(iArtist, pCapitalCity.getX(), pCapitalCity.getY(), UnitAITypes.UNITAI_ARTIST,DirectionTypes.NO_DIRECTION)

		if iTechType == CvUtil.findInfoTypeNum(gc.getTechInfo,gc.getNumTechInfos(),"TECH_TRAIN_PRIEST"):
			gc.getPlayer(iPlayer).initUnit(iProphet, pCapitalCity.getX(), pCapitalCity.getY(), UnitAITypes.UNITAI_PROPHET,DirectionTypes.NO_DIRECTION)

		if iTechType == CvUtil.findInfoTypeNum(gc.getTechInfo,gc.getNumTechInfos(),"TECH_TRAIN_ENGINEER") and iRandomNumber < 25:
			gc.getPlayer(iPlayer).initUnit(iEngineer, pCapitalCity.getX(), pCapitalCity.getY(), UnitAITypes.UNITAI_ENGINEER,DirectionTypes.NO_DIRECTION)
		else: gc.getTeam(iTeam).changeImprovementYieldChange(14,1,1)
				
		if (not self.__LOG_TECH):
			return
		CvUtil.pyPrint('%s was finished by Team %d' 
			%(PyInfo.TechnologyInfo(iTechType).getDescription(), iTeam))

Now, ought this not give me an engineer 50% of the time and if and only if I don't get one, increase my shields on pasture? Because I get an engineer every turn, and I get a pasture upgrade about 50% of the time, and I'm trying to write a program that gives me only one reward, based on the value of iRandomNumber
 
Because I get an engineer every turn, and I get a pasture upgrade about 50% of the time, and I'm trying to write a program that gives me only one reward, based on the value of iRandomNumber

You get an engineer every turn? Also when you don't get a technology in that turn :confused:?
 
The problem is that you are including the tech test and random number test in the same if() block. If either is false, you gain the +1:hammers:. Here's the code fixed. Also, since you can only acquire one tech at a time in this event, you can use elif to bypass testing for other techs once you've found the one you want.

Code:
	def onTechAcquired(self, argsList):
		'Tech Acquired'
		iTechType, iTeam, iPlayer, bAnnounce = argsList
		# Note that iPlayer may be NULL (-1) and not a refer to a player object
		pCapitalCity = gc.getPlayer(iPlayer).getCapitalCity()
		iMerchant = gc.getInfoTypeForString("UNIT_MERCHANT")
		iScientist = gc.getInfoTypeForString("UNIT_SCIENTIST")
		iArtist = gc.getInfoTypeForString("UNIT_ARTIST")
		iProphet = gc.getInfoTypeForString("UNIT_PROPHET")
		iEngineer = gc.getInfoTypeForString("UNIT_ENGINEER")
		
		# Show tech splash when applicable
		if (iPlayer > -1 and bAnnounce and not CyInterface().noTechSplash()):
			if (gc.getGame().isFinalInitialized() and not gc.getGame().GetWorldBuilderMode()):
				if ((not CyGame().isNetworkMultiPlayer()) and (iPlayer == CyGame().getActivePlayer())):
					popupInfo = CyPopupInfo()
					popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
					popupInfo.setData1(iTechType)
					popupInfo.setText(u"showTechSplash")
					popupInfo.addPopup(iPlayer)
		
		if iTechType == gc.getInfoTypeForString("TECH_TRAIN_MERCHANT"):
			gc.getPlayer(iPlayer).initUnit(iMerchant, pCapitalCity.getX(), pCapitalCity.getY(), UnitAITypes.UNITAI_MERCHANT,DirectionTypes.NO_DIRECTION)

		elif iTechType == gc.getInfoTypeForString("TECH_TRAIN_SCIENTIST"):
			gc.getPlayer(iPlayer).initUnit(iScientist, pCapitalCity.getX(), pCapitalCity.getY(), UnitAITypes.UNITAI_SCIENTIST,DirectionTypes.NO_DIRECTION)	

		elif iTechType == gc.getInfoTypeForString("TECH_TRAIN_ARTIST"):
			gc.getPlayer(iPlayer).initUnit(iArtist, pCapitalCity.getX(), pCapitalCity.getY(), UnitAITypes.UNITAI_ARTIST,DirectionTypes.NO_DIRECTION)

		elif iTechType == gc.getInfoTypeForString("TECH_TRAIN_PRIEST"):
			gc.getPlayer(iPlayer).initUnit(iProphet, pCapitalCity.getX(), pCapitalCity.getY(), UnitAITypes.UNITAI_PROPHET,DirectionTypes.NO_DIRECTION)

		elif iTechType == gc.getInfoTypeForString("TECH_TRAIN_ENGINEER"):
			if gc.getGame().getMapRand().get(2, "EngineerOrBetterPasture") == 0:
				gc.getPlayer(iPlayer).initUnit(iEngineer, pCapitalCity.getX(), pCapitalCity.getY(), UnitAITypes.UNITAI_ENGINEER,DirectionTypes.NO_DIRECTION)
			else:
				gc.getTeam(iTeam).changeImprovementYieldChange(14, 1, 1)
				
		if (not self.__LOG_TECH):
			return
		CvUtil.pyPrint('%s was finished by Team %d' 
			%(PyInfo.TechnologyInfo(iTechType).getDescription(), iTeam))

I've also replaced all the different calls to CvUtil.findInfoTypeNum() with gc.getInfoTypeForString(). You can pass any XML type key to this latter function without having to tell it what type of thing you want to find. And it runs faster.
 
I'm still having the always spawn engineer problem. Every time I research Train Engineer (which I'm probably going to rename "future engineering research" since I don't want the tech to actually always spawn an engineer) I get an engineer, and 50% of the time I get a pasture upgrade. The way I read that code, it ought to be giving me either one or another, never both, but that's what it's doing half the time.
 
Post up the code you are using now so we can verify that it's what we think it is. The way I wrote it, it cannot give both.*

* Void where prohibited. Offer not valid with other coupons. Product shown may differ from actual package contents. Batteries not included.
 
Code:
	def onTechAcquired(self, argsList):
		'Tech Acquired'
		iTechType, iTeam, iPlayer, bAnnounce = argsList
		# Note that iPlayer may be NULL (-1) and not a refer to a player object
		pCapitalCity = gc.getPlayer(iPlayer).getCapitalCity()
		iMerchant = gc.getInfoTypeForString("UNIT_MERCHANT")
		iScientist = gc.getInfoTypeForString("UNIT_SCIENTIST")
		iArtist = gc.getInfoTypeForString("UNIT_ARTIST")
		iProphet = gc.getInfoTypeForString("UNIT_PROPHET")
		iEngineer = gc.getInfoTypeForString("UNIT_ENGINEER")
		
		# Show tech splash when applicable
		if (iPlayer > -1 and bAnnounce and not CyInterface().noTechSplash()):
			if (gc.getGame().isFinalInitialized() and not gc.getGame().GetWorldBuilderMode()):
				if ((not CyGame().isNetworkMultiPlayer()) and (iPlayer == CyGame().getActivePlayer())):
					popupInfo = CyPopupInfo()
					popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
					popupInfo.setData1(iTechType)
					popupInfo.setText(u"showTechSplash")
					popupInfo.addPopup(iPlayer)
		
		if iTechType == gc.getInfoTypeForString("TECH_TRAIN_MERCHANT"):
			gc.getPlayer(iPlayer).initUnit(iMerchant, pCapitalCity.getX(), pCapitalCity.getY(), UnitAITypes.UNITAI_MERCHANT,DirectionTypes.NO_DIRECTION)

		elif iTechType == gc.getInfoTypeForString("TECH_TRAIN_SCIENTIST"):
			gc.getPlayer(iPlayer).initUnit(iScientist, pCapitalCity.getX(), pCapitalCity.getY(), UnitAITypes.UNITAI_SCIENTIST,DirectionTypes.NO_DIRECTION)	

		elif iTechType == gc.getInfoTypeForString("TECH_TRAIN_ARTIST"):
			gc.getPlayer(iPlayer).initUnit(iArtist, pCapitalCity.getX(), pCapitalCity.getY(), UnitAITypes.UNITAI_ARTIST,DirectionTypes.NO_DIRECTION)

		elif iTechType == gc.getInfoTypeForString("TECH_TRAIN_PRIEST"):
			gc.getPlayer(iPlayer).initUnit(iProphet, pCapitalCity.getX(), pCapitalCity.getY(), UnitAITypes.UNITAI_PROPHET,DirectionTypes.NO_DIRECTION)

		elif iTechType == gc.getInfoTypeForString("TECH_TRAIN_ENGINEER"):
			if gc.getGame().getMapRand().get(2, "EngineerOrBetterPasture") == 0:
				gc.getPlayer(iPlayer).initUnit(iEngineer, pCapitalCity.getX(), pCapitalCity.getY(), UnitAITypes.UNITAI_ENGINEER,DirectionTypes.NO_DIRECTION)
			else:
				gc.getTeam(iTeam).changeImprovementYieldChange(14, 1, 1)
				
		if (not self.__LOG_TECH):
			return
		CvUtil.pyPrint('%s was finished by Team %d' 
			%(PyInfo.TechnologyInfo(iTechType).getDescription(), iTeam))

This gives me an engineer every time, and a pasture upgrade half the time.
 
The quickest way to debug is to add in debugging statements. These are visual or logged messages so you can see what's happening as it happens.

Code:
if gc.getGame().getMapRand().get(2, "EngineerOrBetterPasture") == 0:
	[B]CyInterface().addImmediateMessage("Enjoy your Engineer!", "")[/B]
	gc.getPlayer(iPlayer).initUnit(iEngineer, pCapitalCity.getX(), pCapitalCity.getY(), UnitAITypes.UNITAI_ENGINEER,DirectionTypes.NO_DIRECTION)
else:
	[B]CyInterface().addImmediateMessage("Uber Pastures!", "")[/B]
	gc.getTeam(iTeam).changeImprovementYieldChange(14, 1, 1)

Something is really wrong because if/else is an either-or structure. The first block executes or the second block executes--not both nor neither.
 
Back
Top Bottom