Concerning the Rise of Rome great person technologies

Thanatosimii

Chieftain
Joined
Jun 29, 2004
Messages
26
The rise of Rome mod included with Warlords has five repeatable technologies to create the five great persons (general excluded). Now, I know it isn't the tech xml that actually makes them work, and I've found at least some of what makes it work in the mod's python, but I'm not an exceptionally skilled python modder and I don't know precicely how to backwards engineer that script. Can anyone explain exactly how that works and how to make it work in another mod? I have another one which doesn't have any python files of its own, and I'm honestly not even sure what to start with as far as creating python from scratch goes.

Additionally, I've read a lot of civ IV modding guides that explain how python works as a language, and I'm beginning to grasp it, but does anyone know of any guides more oriented to specifically how to use this knowledge to change specific parts of the game?
 
Hmm... no response.

Well, this is what I'm doing, if anyone can see why it hasn't worked so far.

I've decided to try to import this function into the Chineese Unification mod. I found this text in the rise of rome CvEventManager
(the indents are actually there, btw, it's just that this forum isn't showing them. So python should be reading the file right, despite the way the quotes might be presenting it.)
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)

I gathered that this is what was actually performing the function, so I took the following parts:
# 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")
and
#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)

and put it into the same function in the chineese unification CvEventManager.

I've also copied and pasted the technologies from the Rise of Rome technology xml and put them in the Chineese Unification technology xml, and I inserted the appropriate xml into the GameTextInfos file.

This isn't enough, apparently, or I may have done it wrong.
Anyone know what else is required?
 
ok I'm not a pro at this but i'll give it a shot.

in the rise of rome CIV4Techinfos.xml
Code:
		<TechInfo>
			<Type>TECH_ROR_TRAIN_MERCHANT</Type>
			<Description>TXT_KEY_TECH_ROR_TRAIN_MERCHANT</Description>
			<Civilopedia>TXT_KEY_TECH_ROR_TRAIN_MERCHANT_PEDIA</Civilopedia>
			<Help/>
			<Strategy>TXT_KEY_TECH_ROR_TRAIN_MERCHANT_STRATEGY</Strategy>
			<Advisor>ADVISOR_GROWTH</Advisor>
			<iAIWeight>0</iAIWeight>
			<iAITradeModifier>0</iAITradeModifier>
			<iCost>1000</iCost>
			<Era>ERA_CLASSICAL</Era>
			<FirstFreeUnitClass>NONE</FirstFreeUnitClass>
			<iFeatureProductionModifier>0</iFeatureProductionModifier>
			<iWorkerSpeedModifier>0</iWorkerSpeedModifier>
			<iTradeRoutes>0</iTradeRoutes>
			<iHealth>0</iHealth>
			<iHappiness>0</iHappiness>
			<iFirstFreeTechs>0</iFirstFreeTechs>
			<iAsset>16</iAsset>
			<iPower>4</iPower>
			[B]<bRepeat>1</bRepeat>[/B]
			<bTrade>0</bTrade>
			<bDisable>0</bDisable>
			<bGoodyTech>0</bGoodyTech>
			<bExtraWaterSeeFrom>0</bExtraWaterSeeFrom>
			<bMapCentering>0</bMapCentering>
			<bMapVisible>0</bMapVisible>
			<bMapTrading>0</bMapTrading>
			<bTechTrading>0</bTechTrading>
			<bGoldTrading>0</bGoldTrading>
			<bOpenBordersTrading>0</bOpenBordersTrading>
			<bDefensivePactTrading>0</bDefensivePactTrading>
			<bPermanentAllianceTrading>0</bPermanentAllianceTrading>
			<bVassalTrading>0</bVassalTrading>
			<bBridgeBuilding>0</bBridgeBuilding>
			<bIrrigation>0</bIrrigation>
			<bIgnoreIrrigation>0</bIgnoreIrrigation>
			<bWaterWork>0</bWaterWork>
			<iGridX>1</iGridX>
			<iGridY>4</iGridY>
			<DomainExtraMoves/>
			<CommerceFlexible/>
			<TerrainTrades/>
			<Flavors>
				<Flavor>
					<FlavorType>FLAVOR_GROWTH</FlavorType>
					<iFlavor>1</iFlavor>
				</Flavor>
			</Flavors>
			<OrPreReqs/>
			<AndPreReqs/>
			<Quote>TXT_KEY_TECH_CURRENCY_QUOTE</Quote>
			<Sound>AS2D_TECH_CURRENCY</Sound>
			<SoundMP>AS2D_TECH_MP_CURRENCY</SoundMP>
			<Button>,Art/Interface/Buttons/Units/GreatTycoon.dds,Art/Interface/Buttons/Unit_Resource_Atlas.dds,3,4</Button>
		</TechInfo>

this is where you assign its era, cost, asset, repeatable, power, button, flavor, and where it is in the tech screen (1, 4). Everything else should either be closed like this <statement/> or have 0 or NONE.

you obviously must have the unit in the civ4unitclassinfos.xml and in the civ4unitinfos.xml.

now in the CvRiseOfRomeEventManager.py...


Code:
[snip....]
                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)


you'll need to re-asign these values to the techs you are using... check folder structure and make sure all these match those of the rise of rome mod. that should do it, if not its at least a step in the right direction. Also note that python is really touchy, everything must be exactly as it was originally or it may not work. If you have it written in your code like you do in your previous post, it will definetely not work. I recommend copying the original and keep everything the same which you need.

Even an extra space somewhere could have tremendous repercussions like the entire interface disappearing for example, so make sure you back up the file and never edit the original. your problem is almost definetely the python if all the xml was done correct. Don't forget to call the correct techs. If you have everything tagged correct than you may want to try and just copy the riseofromeeventmanager.py and see what happens (only changing the call for your techs).

also notice in the original code they did warlord, but took it out with a comment. so it would be really easy to re-add the warlord.

now in the CvEventInterface.py

Code:
# Sid Meier's Civilization 4
# Copyright Firaxis Games 2005
#
# CvEventInterface.py
#
# These functions are App Entry Points from C++
# WARNING: These function names should not be changed
# WARNING: These functions can not be placed into a class
#
[B]# No other modules should import this[/B]
#
import CvUtil
import CvEventManager
#import CvTutorial
[B]import CvRiseOfRomeEventManager[/B]
from CvPythonExtensions import *

romeEventManager = CvRiseOfRomeEventManager.CvRiseOfRomeEventManager()
#tutorialEventManager = CvTutorial.CvTutorialEventManager()
normalEventManager = CvEventManager.CvEventManager()

def getEventManager():
	return romeEventManager
	
def onEvent(argsList):
	'Called when a game event happens - return 1 if the event was consumed'
	return getEventManager().handleEvent(argsList)

def applyEvent(argsList):
	context, playerID, netUserData, popupReturn = argsList
	return getEventManager().applyEvent(argsList)

def beginEvent(context, argsList=-1):
	return getEventManager().beginEvent(context, argsList

this is where you may need to do some custom stuff, or just keep the CvRiseOfRomeEventManager.py the same name. I am no python expert, but these are definetely your area's of concern.

hope that helps :)
 
Top Bottom