### Unique powers for Glory and Greatness mod, by Baldyr
from GGUtils import *
from GGCaravan import *
### constants
#iMoveDenominator = gc.getDefineINT("MOVE_DENOMINATOR")
setupDesertMap()
# settings
iMayanProbability = 25
iNetherlandsInterest = 3
iJapaneseProbability = 20
tIncanEras = (False, True, False, True, False, True, False)
iGermanProbability = 50
iGermanGold = 50
iOttomanProbability = 50
iOttomanGold = 50
iOttomanCulture = 100
tPersianDomains = (True, False, True, False) # land and sea only
iPersianMoves = 1
# eNums
eBarbarian = gc.getBARBARIAN_PLAYER()
eLand = getIndex("Domain", "Land")
eSea = getIndex("Domain", "Sea")
eFarm = getIndex("Improvement", "Farm")
eMelee = getIndex("UnitCombat", "Melee")
eWarrior = getIndex("Unit", "Warrior")
eWorker = getIndex("Unit", "Worker")
### main functions - called from CvEventManager
def colombia(pCity, ePlayer, bConquest):
"""
No Revolting in Captured cities.
"""
if bConquest and isCivPlayer("Gran Colombia", ePlayer):
pCity.setOccupationTimer(0)
def germany(pWinningUnit, pLosingUnit):
"""
50 percent chance to capture barbarian units and get gold reward.
"""
ePlayer = pWinningUnit.getOwner()
if ( isCivPlayer("Germany", ePlayer)
and pLosingUnit.getDomainType() == eLand
and pLosingUnit.getOwner() == eBarbarian
and isProbabilityPercent(iGermanProbability, "germany") ):
captureUnit(ePlayer, pWinningUnit, pLosingUnit)
grantGold(ePlayer, iGermanGold)
def inca(eTech, ePlayer):
"""
Free Tech on reaching Classical, Renaissance and Modern Eras.
"""
if not isCivPlayer("Inca", ePlayer): return
player = tPlayer[ePlayer]
player.getData()
lIncanEras = player.data
if not lIncanEras:
lIncanEras = list(tIncanEras)
eTechEra = gc.getTechInfo(eTech).getEra()
ePlayerEra = player.CyPlayer.getCurrentEra()
if lIncanEras[eTechEra] == True:
lIncanEras[eTechEra] = None
elif lIncanEras[ePlayerEra] == None:
player.CyTeam.setHasTech(eTech, True, ePlayer, False, True)
lIncanEras[ePlayerEra] = False
player.storeData(lIncanEras)
def japan(pUnit):
"""
20 percent chance for a unit to heal fully after combat victory.
"""
if isCivPlayer("Japan", pUnit.getOwner()) and isProbabilityPercent(iJapaneseProbability, "japan"):
pUnit.setDamage(0, False)
def maya(pWinningUnit, pLosingUnit, ePlayer):
"""
Enslave - 25 percent chance to get a Worker unit any time a land unit is defeated in combat.
"""
if ( isCivPlayer("Maya", ePlayer)
and pLosingUnit.getDomainType() == eLand
and isProbabilityPercent(iMayanProbability, "maya")
and pLosingUnit.getUnitType() >= eWarrior ):
spawnUnit(ePlayer, pWinningUnit.getX(), pWinningUnit.getY())
def netherlands():
"""
Receive 3 percent interest on gold reserves each game turn (rounded down).
"""
for pPlayer in list(player.CyPlayer for player in getCivPlayers("Netherlands")):
if not pPlayer.isAlive(): return
pPlayer.setGold(int(pPlayer.getGold() * ((iNetherlandsInterest + 100) / 100.0)))
def ottoman(*args):
"""
Redirects the calls to the appropriate sub-function depending on what event triggered the original callup.
"""
if isCivPlayer("Ottoman", args[1]):
if isinstance(args[0], CyUnit):
ottomanCapture(*args)
else:
ottomanCulture(*args)
def ottomanCapture(pWinningUnit, ePlayer, pLosingUnit):
"""
5O percent chance to capture enemy ships and earn gold.
"""
if 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:
pCity.changeCulture(ePlayer, iOttomanCulture, True)
def persia(ePlayer):
"""
All land and sea units gain one extra movement point during Golden Ages.
"""
if not isCivPlayer("Persia", ePlayer): return
iExtraMoves = iPersianMoves
if not tPlayer[ePlayer].CyPlayer.isGoldenAge():
iExtraMoves = - iExtraMoves
for eDomain in range(DomainTypes.NUM_DOMAIN_TYPES):
if tPersianDomains[eDomain]:
tPlayer[ePlayer].CyTeam.changeExtraMoves(eDomain, iExtraMoves)
def russia(pUnit, pPlot):
"""
Enemy units in Russian territory take damage when either moving or fighting.
"""
eUnitOwner, ePlotOwner = pUnit.getOwner(), pPlot.getOwner()
if ( isCivPlayerAlive("Russia")
and not eUnitOwner == ePlotOwner
and isCivPlayer("Russia", ePlotOwner)
and isAtWar(ePlotOwner, eUnitOwner) ):
if pUnit.movesLeft() == 0:
pUnit.changeDamage(5, eBarbarian)
def scandinavia(pUnit):
"""
Double Gold from pillaging.
"""
return isCivPlayer("Scandinavia", pUnit.getOwner()) + 1
### assorted functions
def captureUnit(ePlayer, pWinningUnit, pLosingUnit):
"""
Spawns a unit of the pLosingUnit type on the map tile of the pWinningUnit for ePlayer.
"""
spawnUnit(ePlayer, pWinningUnit.getX(), pWinningUnit.getY(), pLosingUnit.getUnitType())
def grantGold(ePlayer, iChange):
"""
Grants iChange gold to ePlayer.
"""
tPlayer[ePlayer].CyPlayer.changeGold(iChange)
def spawnUnit(ePlayer, iX, iY, eType=eWorker, iNum=1):
"""
Spawn iNum units of the eType at the coordinates iX and iY for the ePlayer.
"""
tPlayer[ePlayer].PyPlayer.initUnit(eType, iX, iY, iNum)