I just don't get it. I installed the Sphinx in my new mode, but didn't install the python file, and it still works... WHY ? what is the python file there for ?
pPlayer = gc.getPlayer(iPlayer)
for iCity in range(pPlayer.getNumCities()):
pCity = pPlayer.getCity(iCity)
iRefCityList = PyPlayer(iPlayer).getCityList()
for pyCity in iRefCityList:
pCity = pyCity.GetCy()
iCity = pCity.getID()
Has anyone else had problems with the Leonardo's workshop wonder? Mine doesn't seem to work at all. I playted a test-game and built it (I actually built it, I didn't just plop it down anywhere), movie played, culture went up all that stuff, except the upgrade costs were the same. So it must be the python. Can someone help me out here?
I have attached the python file used in my mod, CvGameUtils.py, it was the only one that came in the download. Thanks in advance to anyone who could help me out with this.![]()
·Imhotep·;11090177 said:Don't know if this still is of interest (it's been quite a while since Da Capo asked), but just changing CvGameUtils.py of course won't work as BUG uses it's own version of getUpgradePriceOverride. But getting it to work is simple, you just have to do it the BUG way, as someone mentioned before: Tutorial
Works flawless for me...
def getUpgradePriceOverride(self, argsList):
iPlayer, iUnitID, iUnitTypeUpgrade = argsList
## Militant Trait & Leonardo's Workshop Start ##
pPlayer = gc.getPlayer(iPlayer)
pUnit = pPlayer.getUnit(iUnitID)
iPrice = gc.getDefineINT("BASE_UNIT_UPGRADE_COST")
iPrice += (max(0, (pPlayer.getUnitProductionNeeded(iUnitTypeUpgrade) - pPlayer.getUnitProductionNeeded(pUnit.getUnitType()))) * gc.getDefineINT("UNIT_UPGRADE_COST_PER_PRODUCTION"))
if not pPlayer.isHuman() and not pPlayer.isBarbarian():
pHandicapInfo = gc.getHandicapInfo(gc.getGame().getHandicapType())
iPrice = iPrice * pHandicapInfo.getAIUnitUpgradePercent() / 100
iPrice = iPrice * max(0, ((pHandicapInfo.getAIPerEraModifier() * pPlayer.getCurrentEra()) + 100)) / 100
iPrice += ((gc.getUnitInfo(iUnitTypeUpgrade).getCombat() - gc.getUnitInfo(pUnit.getUnitType()).getCombat()) * 10)
iPrice += ((gc.getUnitInfo(iUnitTypeUpgrade).getAirCombat() - gc.getUnitInfo(pUnit.getUnitType()).getAirCombat()) * 10)
if gc.getUnitInfo(iUnitTypeUpgrade).getUnitCombatType() != pUnit.getUnitCombatType():
iPrice += 40
iPrice = iPrice - ((iPrice * pUnit.getUpgradeDiscount()) / 100)
iTrait = CvUtil.findInfoTypeNum(gc.getTraitInfo,gc.getNumTraitInfos(),'TRAIT_MILITANT')
if pPlayer.hasTrait(iTrait):
b_Leonardo = gc.getInfoTypeForString("BUILDING_LEONARDO")
obsoleteTech = gc.getBuildingInfo(b_Leonardo).getObsoleteTech()
if ( not gc.getTeam(pPlayer.getTeam()).isHasTech(obsoleteTech) or obsoleteTech == -1 ):
if pPlayer.getBuildingClassCount(gc.getInfoTypeForString("BUILDINGCLASS_LEONARDO")) > 0:
iPrice = ((gc.getDefineINT("BASE_UNIT_UPGRADE_COST"))/8*3)
iPrice += (((max(0, (pPlayer.getUnitProductionNeeded(iUnitTypeUpgrade) - pPlayer.getUnitProductionNeeded(pUnit.getUnitType()))) * gc.getDefineINT("UNIT_UPGRADE_COST_PER_PRODUCTION")))/8*3)
iPrice += ((gc.getUnitInfo(iUnitTypeUpgrade).getCombat() - gc.getUnitInfo(pUnit.getUnitType()).getCombat()) * 10/8*3)
iPrice += ((gc.getUnitInfo(iUnitTypeUpgrade).getAirCombat() - gc.getUnitInfo(pUnit.getUnitType()).getAirCombat()) * 10/8*3)
if gc.getUnitInfo(iUnitTypeUpgrade).getUnitCombatType() != pUnit.getUnitCombatType():
iPrice += 40/8*3
if ((not pPlayer.isHuman()) and (not pPlayer.isBarbarian())):
pHandicapInfo = gc.getHandicapInfo(gc.getGame().getHandicapType())
iPrice = ((iPrice * pHandicapInfo.getAIUnitUpgradePercent() / 100)/8*3)
iPrice = ((iPrice * max(0, ((pHandicapInfo.getAIPerEraModifier() * pPlayer.getCurrentEra()) + 100)) / 100)/8*3)
iPrice = ((iPrice - ((iPrice * pUnit.getUpgradeDiscount()) / 100))/8*3)
else:
iPrice = ((gc.getDefineINT("BASE_UNIT_UPGRADE_COST"))/2)
iPrice += (((max(0, (pPlayer.getUnitProductionNeeded(iUnitTypeUpgrade) - pPlayer.getUnitProductionNeeded(pUnit.getUnitType()))) * gc.getDefineINT("UNIT_UPGRADE_COST_PER_PRODUCTION")))/2)
iPrice += ((gc.getUnitInfo(iUnitTypeUpgrade).getCombat() - gc.getUnitInfo(pUnit.getUnitType()).getCombat()) * 10/2)
iPrice += ((gc.getUnitInfo(iUnitTypeUpgrade).getAirCombat() - gc.getUnitInfo(pUnit.getUnitType()).getAirCombat()) * 10/2)
if gc.getUnitInfo(iUnitTypeUpgrade).getUnitCombatType() != pUnit.getUnitCombatType():
iPrice += 40/2
if ((not pPlayer.isHuman()) and (not pPlayer.isBarbarian())):
pHandicapInfo = gc.getHandicapInfo(gc.getGame().getHandicapType())
iPrice = ((iPrice * pHandicapInfo.getAIUnitUpgradePercent() / 100)/2)
iPrice = ((iPrice * max(0, ((pHandicapInfo.getAIPerEraModifier() * pPlayer.getCurrentEra()) + 100)) / 100)/2)
iPrice = ((iPrice - ((iPrice * pUnit.getUpgradeDiscount()) / 100))/2)
else:
iPrice = ((gc.getDefineINT("BASE_UNIT_UPGRADE_COST"))/2)
iPrice += (((max(0, (pPlayer.getUnitProductionNeeded(iUnitTypeUpgrade) - pPlayer.getUnitProductionNeeded(pUnit.getUnitType()))) * gc.getDefineINT("UNIT_UPGRADE_COST_PER_PRODUCTION")))/2)
iPrice += ((gc.getUnitInfo(iUnitTypeUpgrade).getCombat() - gc.getUnitInfo(pUnit.getUnitType()).getCombat()) * 10/2)
iPrice += ((gc.getUnitInfo(iUnitTypeUpgrade).getAirCombat() - gc.getUnitInfo(pUnit.getUnitType()).getAirCombat()) * 10/2)
if gc.getUnitInfo(iUnitTypeUpgrade).getUnitCombatType() != pUnit.getUnitCombatType():
iPrice += 40/2
if ((not pPlayer.isHuman()) and (not pPlayer.isBarbarian())):
pHandicapInfo = gc.getHandicapInfo(gc.getGame().getHandicapType())
iPrice = ((iPrice * pHandicapInfo.getAIUnitUpgradePercent() / 100)/2)
iPrice = ((iPrice * max(0, ((pHandicapInfo.getAIPerEraModifier() * pPlayer.getCurrentEra()) + 100)) / 100)/2)
iPrice = ((iPrice - ((iPrice * pUnit.getUpgradeDiscount()) / 100))/2)
if not pPlayer.hasTrait(iTrait):
b_Leonardo = gc.getInfoTypeForString("BUILDING_LEONARDO")
obsoleteTech = gc.getBuildingInfo(b_Leonardo).getObsoleteTech()
if ( not gc.getTeam(pPlayer.getTeam()).isHasTech(obsoleteTech) or obsoleteTech == -1 ):
if pPlayer.getBuildingClassCount(gc.getInfoTypeForString("BUILDINGCLASS_LEONARDO")) > 0:
iPrice = ((gc.getDefineINT("BASE_UNIT_UPGRADE_COST")) * 3/4)
iPrice += (((max(0, (pPlayer.getUnitProductionNeeded(iUnitTypeUpgrade) - pPlayer.getUnitProductionNeeded(pUnit.getUnitType()))) * gc.getDefineINT("UNIT_UPGRADE_COST_PER_PRODUCTION"))) * 3/4)
iPrice += ((gc.getUnitInfo(iUnitTypeUpgrade).getCombat() - gc.getUnitInfo(pUnit.getUnitType()).getCombat()) * 10*3/4)
iPrice += ((gc.getUnitInfo(iUnitTypeUpgrade).getAirCombat() - gc.getUnitInfo(pUnit.getUnitType()).getAirCombat()) * 10*3/4)
if gc.getUnitInfo(iUnitTypeUpgrade).getUnitCombatType() != pUnit.getUnitCombatType():
iPrice += 40*3/4
if ((not pPlayer.isHuman()) and (not pPlayer.isBarbarian())):
pHandicapInfo = gc.getHandicapInfo(gc.getGame().getHandicapType())
iPrice = ((iPrice * pHandicapInfo.getAIUnitUpgradePercent() / 100) * 3/4)
iPrice = ((iPrice * max(0, ((pHandicapInfo.getAIPerEraModifier() * pPlayer.getCurrentEra()) + 100)) / 100) * 3/4)
iPrice = ((iPrice - ((iPrice * pUnit.getUpgradeDiscount()) / 100)) * 3/4)
# Populist Start -----------------------------------------------------------------------------------------------
# if pUnit.isHasPromotion(gc.getInfoTypeForString("PROMOTION_POPULIST1")):
# iPrice *= 5
# iPrice /= 4
# Populist End -----------------------------------------------------------------------------------------------
return iPrice
## Militant Trait & Leonardo's Workshop End ##
# return -1 # Any value 0 or above will be used
Found it. You should really change the Golden Dawn code to this:
Code:## Golden Dawn Start ## pPlayer = gc.getPlayer( pCity.getOwner( ) ) b_Dawn = gc.getInfoTypeForString("BUILDING_GOLDEN_DAWN") obsoleteTech = gc.getBuildingInfo(b_Dawn).getObsoleteTech() if ( gc.getTeam(pPlayer.getTeam()).isHasTech(obsoleteTech) == false or obsoleteTech == -1 ): for iCity in range(pPlayer.getNumCities()): ppCity = pPlayer.getCity(iCity) if ppCity.getNumActiveBuilding(b_Dawn) == true: iMissionary1 = CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_JEWISH_MISSIONARY') iMissionary2 = CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_CHRISTIAN_MISSIONARY') iMissionary3 = CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_HINDU_MISSIONARY') iMissionary4 = CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_BUDDHIST_MISSIONARY') iMissionary5 = CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_CONFUCIAN_MISSIONARY') iMissionary6 = CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_TAOIST_MISSIONARY') iMissionary7 = CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_ISLAMIC_MISSIONARY') aiMissionaryList = [iMissionary1, iMissionary2, iMissionary3, iMissionary4, iMissionary5, iMissionary6, iMissionary7] if (eUnit in aiMissionaryList): return True ## Golden Dawn End ##
Else you will lose ~50% game speed.
## Leonardo's Workshop Start ##
pPlayer = gc.getPlayer(iPlayer)
pUnit = pPlayer.getUnit(iUnitID)
iPrice = gc.getDefineINT("BASE_UNIT_UPGRADE_COST")
iPrice += (max(0, (pPlayer.getUnitProductionNeeded(iUnitTypeUpgrade) - pPlayer.getUnitProductionNeeded(pUnit.getUnitType()))) * gc.getDefineINT("UNIT_UPGRADE_COST_PER_PRODUCTION"))
if ((not pPlayer.isHuman()) and (not pPlayer.isBarbarian())):
pHandicapInfo = gc.getHandicapInfo(gc.getGame().getHandicapType())
iPrice = iPrice * pHandicapInfo.getAIUnitUpgradePercent() / 100
iPrice = iPrice * max(0, ((pHandicapInfo.getAIPerEraModifier() * pPlayer.getCurrentEra()) + 100)) / 100
iPrice = iPrice - ((iPrice * pUnit.getUpgradeDiscount()) / 100)
b_Leonardo = gc.getInfoTypeForString("BUILDING_LEONARDO")
obsoleteTech = gc.getBuildingInfo(b_Leonardo).getObsoleteTech()
if ( gc.getTeam(pPlayer.getTeam()).isHasTech(obsoleteTech) == false or obsoleteTech == -1 ):
for iCity in range(pPlayer.getNumCities()):
ppCity = pPlayer.getCity(iCity)
if ppCity.getNumActiveBuilding(b_Leonardo) == true:
iPrice = iPrice/2
return iPrice
## return -1 # Any value 0 or above will be used
## Leonardo's Workshop End ##
## Himeji Samurai Castle Start ##
pPlayer = gc.getPlayer( pUnit.getOwner( ) )
pPlayer2 = gc.getPlayer( pPlot.getOwner( ) )
b_Himeji = gc.getInfoTypeForString("BUILDING_HIMEJI_CASTLE")
obsoleteTech = gc.getBuildingInfo(b_Himeji).getObsoleteTech()
if ( gc.getTeam(pPlayer.getTeam()).isHasTech(obsoleteTech) == false or obsoleteTech == -1 ):
for iCity in range(pPlayer.getNumCities()):
ppCity = pPlayer.getCity(iCity)
if ppCity.getNumActiveBuilding(b_Himeji) == true:
[B]iPillageGold = ( ( 0 ) * 2 )
iPillageGold = ( ( CyGame().getSorenRandNum(gc.getImprovementInfo(pPlot.getImprovementType()).getPillageGold(), "Pillage Gold 1") ) * 2 )
iPillageGold += ( ( CyGame().getSorenRandNum(gc.getImprovementInfo(pPlot.getImprovementType()).getPillageGold(), "Pillage Gold 2") ) * 2 )
iPillageGold += ( ( (pUnit.getPillageChange() * iPillageGold) / 100 ) * 2 )[/B]
else:
iPillageGold = 0
iPillageGold = CyGame().getSorenRandNum(gc.getImprovementInfo(pPlot.getImprovementType()).getPillageGold(), "Pillage Gold 1")
iPillageGold += CyGame().getSorenRandNum(gc.getImprovementInfo(pPlot.getImprovementType()).getPillageGold(), "Pillage Gold 2")
iPillageGold += (pUnit.getPillageChange() * iPillageGold) / 100
if pPlot.getOwner( ) >= 0:
if ( gc.getTeam(pPlayer2.getTeam()).isHasTech(obsoleteTech) == false or obsoleteTech == -1 ):
for iCity in range(pPlayer2.getNumCities()):
ppCity = pPlayer2.getCity(iCity)
if ppCity.getNumActiveBuilding(b_Himeji) == true:
iPillageGold = 0
## Himeji Samurai Castle End ##
def doPillageGold(self, argsList):
"controls the gold result of pillaging"
pPlot = argsList[0]
pUnit = argsList[1]
iPillageGold = 0
iPillageGold = CyGame().getSorenRandNum(gc.getImprovementInfo(pPlot.getImprovementType()).getPillageGold(), "Pillage Gold 1")
iPillageGold += CyGame().getSorenRandNum(gc.getImprovementInfo(pPlot.getImprovementType()).getPillageGold(), "Pillage Gold 2")
iPillageGold += (pUnit.getPillageChange() * iPillageGold) / 100
## Himeji Samurai Castle Start ##
pPlayer = gc.getPlayer( pUnit.getOwner( ) )
pPlayer2 = gc.getPlayer( pPlot.getOwner( ) )
b_Himeji = gc.getInfoTypeForString("BUILDING_HIMEJI_CASTLE")
obsoleteTech = gc.getBuildingInfo(b_Himeji).getObsoleteTech()
if ( gc.getTeam(pPlayer.getTeam()).isHasTech(obsoleteTech) == false or obsoleteTech == -1 ):
for iCity in range(pPlayer.getNumCities()):
ppCity = pPlayer.getCity(iCity)
if ppCity.getNumActiveBuilding(b_Himeji) == true:
iPillageGold = iPillageGold * 2
if pPlot.getOwner( ) >= 0:
if ( gc.getTeam(pPlayer2.getTeam()).isHasTech(obsoleteTech) == false or obsoleteTech == -1 ):
for iCity in range(pPlayer2.getNumCities()):
ppCity = pPlayer2.getCity(iCity)
if ppCity.getNumActiveBuilding(b_Himeji) == true:
iPillageGold = 0
## Himeji Samurai Castle End ##
return iPillageGold
·Imhotep·;11090177 said:Don't know if this still is of interest (it's been quite a while since Da Capo asked), but just changing CvGameUtils.py of course won't work as BUG uses it's own version of getUpgradePriceOverride. But getting it to work is simple, you just have to do it the BUG way, as someone mentioned before: Tutorial
Works flawless for me...