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:
by adding code from CvRiseOfRomeEventManager.py
To make this:
This has never worked. So I turned on some debugging and I got this error in my debug log:
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.
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:
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?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
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.