### Unique powers for Glory and Greatness mod, by Baldyr
from GGUtils import *
# constants
iUnitDiscountPercent = 20
iArabianFood = 2
iArabianCommerce = 1
iCarthageVassalXP = 1
iCarthageVassalGold = 50
eCelticCivic = eHereditaryRule
eChineseCivic = eBureaucracy
iEnglandMoves = 1
tHolyRomanEras = (False, True, False, True, False, False, False) # Classical & Renaissance
iIncaFood = 1
iIndiaCitySize = 2
iIndiaSurplusPercent = 10
eIndianCivic = ePacifism
iJapaneseProbability = 20
maliTechMessage = "Choose a free starting Tech!"
iMayanProbability = 25
iNetherlandsInterest = 3
iGermanProbability = 50
iGermanGold = 25
iOttomanProbability = 50
iOttomanGold = 50
iOttomanCulture = 100
tPersianDomains = eLand, eSea
iPersianMoves = 1
iRomanConstructionDiscount = 20
iRomanUpgradeDiscount = 50
iSpainGoldBonus = 50
iVikingBonus = 100
startingCivicDict = { "Celt": eCelticCivic,
"China": eChineseCivic,
"India": eIndianCivic
}
### setup
for pCivPlayer in CivPlayer.getCivs("Holy Rome"):
pCivPlayer.setData("lFreeEraTechs", list(tHolyRomanEras))
### main functions - called from CvEventManager/CvGameUtils
def startingCivics(ePlayer, eCivic):
"""
Enable Civic type from start.
"""
for name, eStartingCivic in startingCivicDict.iteritems():
if CivPlayer.isCiv(name, ePlayer) and eCivic == eStartingCivic:
return True
return False
def aztecGold(pUnit, ePlayer):
"""
Gold for units killed based on experience of unit.
"""
if isCiv("Aztec", ePlayer):
getCyPlayer(ePlayer).changeGold(pUnit.getExperience())
def carthageVassals(ePlayer):
"""
Extra gold and Great General points for vassals.
"""
if not CivPlayer.isCivAlive("Carthage"): return
pVassalCiv = instance(ePlayer)
for pMasterCiv in CivPlayer.getCivs("Carthage"):
if pVassalCiv.get(CyTeam).isVassal(pMasterCiv.get(CyTeam)):
pVassalCiv.get(CyPlayer).changeCombatExperience(iCarthageVassalXP)
iGold = pVassalCiv.get(CyPlayer).getGold()
iBonusGold = max(1, min(iCarthageVassalGold, iGold / iCarthageVassalGold))
grantGold(ePlayer, iBonusGold)
break
def colombiaOccupation(pCity, ePlayer, bConquest):
"""
No Revolting in Captured cities.
"""
if bConquest and CivPlayer.isCiv("Gran Colombia", ePlayer):
pCity.setOccupationTimer(0)
def germanyCapture(pWinningUnit, pLosingUnit):
"""
50 percent chance to capture barbarian units and get gold reward.
"""
ePlayer = pWinningUnit.getOwner()
if ( CivPlayer.isCiv("Germany", ePlayer)
and pLosingUnit.getDomainType() == eLand
and pLosingUnit.getOwner() == eBarbarian
and isProbabilityPercent(iGermanProbability, "germany") ):
captureUnit(ePlayer, pWinningUnit, pLosingUnit)
grantGold(ePlayer, iGermanGold)
def germanyConscription(pCity):
"""
No Unhappiness for Drafting.
"""
eOwner = pCity.getOwner()
if CivPlayer.isCiv("Germany", eOwner):
iConscriptTimer = pCity.getConscriptAngerTimer()
if iConscriptTimer:
pCity.changeConscriptAngerTimer(-iConscriptTimer)
def englandMovement():
"""
+1 Movement to Ships.
"""
for pTeam in CivPlayer.getCivs("England", CyTeam):
pTeam.changeExtraMoves(iEnglandMoves)
def holyRomeTech(eTech, ePlayer):
"""
Free Tech in the Classical and Renaissance Eras.
"""
if not CivPlayer.isCiv("Inca", ePlayer): return
pCivPlayer = instance(ePlayer)
lHolyRomanEras = pCivPlayer.getData("lFreeTechEras")
eTechEra = gc.getTechInfo(eTech).getEra()
ePlayerEra = pCivPlayer.get(CyPlayer).getCurrentEra()
if lHolyRomanEras[eTechEra] == True:
lHolyRomanEras[eTechEra] = None
elif lHolyRomanEras[ePlayerEra] == None:
pCivPlayer.get(CyTeam).setHasTech(eTech, True, ePlayer, False, True)
lHolyRomanEras[ePlayerEra] = False
## pCivPlayer.setData("lFreeTechEras", lHolyRomanEras)
def indiaPopulation(pCity):
"""
Cities Start with 2 population.
"""
eOwner = pCity.getOwner()
if CivPlayer.isCiv("India", eOwner):
pCity.setPopulation(iIndiaCitySize)
def indiaGrowth(pCity, ePlayer):
"""
Extra food on city growth.
"""
if CivPlayer.isCiv("India", ePlayer):
iFoodBarSize = pCity.getFoodTurnsLeft() * pCity.foodConsumption(False, 0)
iFoodSurplus = int(iFoodBarSize * iIndiaSurplusPercent / 100.0)
pCity.changeFood(iFoodSurplus)
def japanHeal(pUnit):
"""
20 percent chance for a unit to heal fully after combat victory.
"""
if CivPlayer.isCiv("Japan", pUnit.getOwner()) and isProbabilityPercent(iJapaneseProbability, "japan"):
pUnit.setDamage(0, False)
def japanCulture(pUnit):
"""
Units killed in borders add to city culture.
"""
eOwner = pUnit.getOwner()
if CivPlayer.isCiv("Japan", eOwner) and pUnit.plot().getOwner() == eOwner :
iX, iY = pUnit.getX(), pUnit.getY()
eTeam = tPlayer[eOwner].team
pCity = findCity(iX, iY, eOwner, eTeam, True, False, -1, -1, -1)
pCity.changeCulture(eOwner, pUnit.getExperience(), True)
def maliTech():
"""
Can Select a Free Technology to start the game.
"""
for pPlayer in CivPlayer.getCivs("Mali", CyPlayer):
if pPlayer.isHuman():
pPlayer.chooseTech(1, maliTechMessage, False)
else:
pPlayer.AI_chooseFreeTech(1)
def mayaEnslave(pWinningUnit, pLosingUnit):
"""
Enslave - 25 percent chance to get a Worker unit any time a land unit is defeated in combat.
"""
ePlayer = pWinningUnit.getOwner()
if ( CivPlayer.isCiv("Maya", ePlayer)
and pLosingUnit.getDomainType() == eLand
and isProbabilityPercent(iMayanProbability, "maya")
and pLosingUnit.getUnitType() >= eWarrior ):
spawnUnit(ePlayer, pWinningUnit.getX(), pWinningUnit.getY())
def netherlandsInterest():
"""
Receive 3 percent interest on gold reserves each game turn (rounded down).
"""
for pPlayer in CivPlayer.getCivs("Netherlands", CyPlayer):
if not pPlayer.isAlive(): return
pPlayer.setGold(int(pPlayer.getGold() * ((iNetherlandsInterest + 100) / 100.0)))
def ottomanCapture(pWinningUnit, pLosingUnit):
"""
5O percent chance to capture enemy ships and earn gold.
"""
ePlayer = pWinningUnit.getOwner()
if ( CivPlayer.isCiv("Ottoman", ePlayer)
and pLosingUnit.getDomainType() == eSea
and isProbabilityPercent(iOttomanProbability, "ottoman") ):
captureUnit(ePlayer, pWinningUnit, pLosingUnit)
grantGold(ePlayer, iOttomanGold)
def ottomanCulture(pCity, ePlayer, bConquest):
"""
Spread culture in conquered cities.
"""
if bConquest and CivPlayer.isCiv("Ottoman", ePlayer):
pCity.changeCulture(ePlayer, iOttomanCulture, True)
def persiaMovement(ePlayer, bActive):
"""
All land and sea units gain one extra movement point during Golden Ages.
"""
if not CivPlayer.isCiv("Persia", ePlayer): return
iExtraMoves = iPersianMoves
if not bActive:
iExtraMoves = - iExtraMoves
for eDomain in tPersianDomains:
instance(ePlayer).get(CyTeam).changeExtraMoves(eDomain, iExtraMoves)
def romeBuildings(eBuilding, ePlayer):
"""
+25 percent production of buildings already built in the capital.
"""
if ( CivPlayer.isCiv("Rome", ePlayer)
and getCyPlayer(ePlayer).getCapitalCity().isHasBuilding(eBuilding) ):
return iRomanConstructionDiscount / 100.0
return -1
def romeUnits(ePlayer):
"""
-50 percent cost to upgrade units.
"""
if CivPlayer.isCiv("Rome", ePlayer):
return iRomanUpgradeDiscount / 100.0
return -1
def russiaDamage(pUnit, pPlot):
"""
Enemy units in Russian territory take damage when either moving or fighting.
"""
eUnitOwner, ePlotOwner = pUnit.getOwner(), pPlot.getOwner()
if ( CivPlayer.isCivAlive("Russia")
and not eUnitOwner == ePlotOwner
and CivPlayer.isCiv("Russia", ePlotOwner)
and isAtWar(ePlotOwner, eUnitOwner) ):
if pUnit.movesLeft() == 0:
pUnit.changeDamage(5, -1)
def spainGoody(ePlayer, eGoody):
"""
Extra Gold from Goody Huts.
"""
if CivPlayer.isCiv("Spain", ePlayer):
if eGoody == 0:
grantGold(ePlayer, iSpainGoldBonus / 2)
elif eGoody == 1:
grantGold(ePlayer, iSpainGoldBonus)
def vikingPillage(pPlot, pUnit):
"""
Double Gold from pillaging.
"""
return ( CivPlayer.isCiv("Viking", pUnit.getOwner())
and not CivPlayer.isCiv("Viking", pPlot.getOwner())
* iVikingBonus / 100.0 )
def zuluUpgrade(pUnit):
"""
Can Upgrade outside borders.
"""
return CivPlayer.isCiv("Zulu", pUnit.getOwner())