Skip to content

Commit

Permalink
Correct conditions and effects of the crusade event
Browse files Browse the repository at this point in the history
  • Loading branch information
dguenms committed Aug 14, 2022
1 parent 2f3829d commit f6eb428
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 39 deletions.
128 changes: 93 additions & 35 deletions Assets/Python/EntryPoints/CvRandomEventInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -2882,35 +2882,59 @@ def canTriggerCrusade(argsList):
trigger = gc.getEventTriggerInfo(kTriggeredData.eTrigger)
player = gc.getPlayer(kTriggeredData.ePlayer)
otherPlayer = gc.getPlayer(kTriggeredData.eOtherPlayer)
holyCity = gc.getGame().getHolyCity(kTriggeredData.eReligion)

iReligion = kTriggeredData.eOtherPlayer
if iReligion == iCatholicism:
iReligion = iOrthodoxy

if iReligion != iOrthodoxy:
return false

holyCity = gc.getGame().getHolyCity(iReligion)

if gc.getGame().isOption(GameOptionTypes.GAMEOPTION_ONE_CITY_CHALLENGE) and gc.getPlayer(kTriggeredData.ePlayer).isHuman():
return false

if player.isHuman() and not gc.getTeam(player.getTeam()).isAtWar(holyCity.getTeam()):
return false

if holyCity.getOwner() == kTriggeredData.eOtherPlayer:
if gc.getPlayer(holyCity.getOwner()).getStateReligion() not in [iOrthodoxy, iCatholicism, iProtestantism]:
kActualTriggeredDataObject = player.getEventTriggered(kTriggeredData.iId)
kActualTriggeredDataObject.iOtherPlayerCityId = holyCity.getID()
kActualTriggeredDataObject.eOtherPlayer = holyCity.getOwner()

return true

if kTriggeredData.eReligion == iCatholicism:
holyCity = gc.getGame().getHolyCity(iOrthodoxy)
if not holyCity.isNone():
if holyCity.getOwner() == kTriggeredData.eOtherPlayer:
kActualTriggeredDataObject = player.getEventTriggered(kTriggeredData.iId)
kActualTriggeredDataObject.iOtherPlayerCityId = holyCity.getID()
kActualTriggeredDataObject.eReligion = ReligionTypes(iOrthodoxy)

return true

return false

def doTriggerCrusade(argsList):
kTriggeredData = argsList[0]

iPlayer = kTriggeredData.ePlayer
iReligion = kTriggeredData.eReligion

if iReligion == iCatholicism:
iReligion = iOrthodoxy

holyCity = gc.getGame().getHolyCity(iReligion)

if not gc.getPlayer(iPlayer).isHuman():
createRoleUnit(iPlayer, capital(iPlayer), iShockCity, 3)
createRoleUnit(iPlayer, capital(iPlayer), iSiege, 2)

gc.getTeam(gc.getPlayer(iPlayer).getTeam()).declareWar(holyCity.getTeam(), True, WarPlanTypes.WARPLAN_LIMITED)

def getHelpCrusade1(argsList):
iEvent = argsList[0]
kTriggeredData = argsList[1]

iReligion = kTriggeredData.ePlayer
if iReligion == iCatholicism:
iReligion = iOrthodoxy

player = gc.getPlayer(kTriggeredData.ePlayer)

holyCity = gc.getGame().getHolyCity(kTriggeredData.eReligion)
holyCity = gc.getGame().getHolyCity(iReligion)

szHelp = localText.getText("TXT_KEY_EVENT_CRUSADE_HELP_1", (holyCity.getNameKey(), ))

Expand All @@ -2921,7 +2945,12 @@ def expireCrusade1(argsList):
kTriggeredData = argsList[1]
player = gc.getPlayer(kTriggeredData.ePlayer)
otherPlayer = gc.getPlayer(kTriggeredData.eOtherPlayer)
holyCity = gc.getGame().getHolyCity(kTriggeredData.eReligion)

iReligion = kTriggeredData.eReligion
if iReligion == iCatholicism:
iReligion = iOrthodoxy

holyCity = gc.getGame().getHolyCity(iReligion)

if holyCity.getOwner() == kTriggeredData.ePlayer:
return false
Expand All @@ -2943,7 +2972,12 @@ def canTriggerCrusadeDone(argsList):
trigger = gc.getEventTriggerInfo(kTriggeredData.eTrigger)

kOrigTriggeredData = player.getEventOccured(trigger.getPrereqEvent(0))
holyCity = gc.getGame().getHolyCity(kOrigTriggeredData.eReligion)

iReligion = kOrigTriggeredData.eReligion
if iReligion == iCatholicism:
iReligion = iOrthodoxy

holyCity = gc.getGame().getHolyCity(iReligion)

if holyCity.getOwner() != kTriggeredData.ePlayer:
return false
Expand All @@ -2954,7 +2988,7 @@ def canTriggerCrusadeDone(argsList):
kActualTriggeredDataObject.eReligion = kOrigTriggeredData.eReligion

for iBuilding in range(gc.getNumBuildingInfos()):
if gc.getBuildingInfo(iBuilding).getHolyCity() == kOrigTriggeredData.eReligion:
if gc.getBuildingInfo(iBuilding).getHolyCity() == iReligion:
kActualTriggeredDataObject.eBuilding = BuildingTypes(iBuilding)
break

Expand All @@ -2964,12 +2998,16 @@ def getHelpCrusadeDone1(argsList):
iEvent = argsList[0]
kTriggeredData = argsList[1]

holyCity = gc.getGame().getHolyCity(kTriggeredData.eReligion)
iReligion = kTriggeredData.eReligion
if iReligion == iCatholicism:
iReligion = iOrthodoxy

holyCity = gc.getGame().getHolyCity(iReligion)
szUnit = gc.getUnitInfo(holyCity.getConscriptUnit()).getTextKey()

#Rhye - start
#iNumUnits = gc.getWorldInfo(gc.getMap().getWorldSize()).getDefaultPlayers() / 2 + 1
iNumUnits = 9 / 2 + 1
iNumUnits = 5
#Rhye - end

szHelp = localText.getText("TXT_KEY_EVENT_CRUSADE_DONE_HELP_1", (iNumUnits, szUnit, holyCity.getNameKey()))
Expand All @@ -2980,7 +3018,11 @@ def canApplyCrusadeDone1(argsList):
iEvent = argsList[0]
kTriggeredData = argsList[1]

holyCity = gc.getGame().getHolyCity(kTriggeredData.eReligion)
iReligion = kTriggeredData.eReligion
if iReligion == iCatholicism:
iReligion = iOrthodoxy

holyCity = gc.getGame().getHolyCity(iReligion)
if -1 == holyCity.getConscriptUnit():
return false

Expand All @@ -2991,11 +3033,15 @@ def applyCrusadeDone1(argsList):
kTriggeredData = argsList[1]
player = gc.getPlayer(kTriggeredData.ePlayer)

holyCity = gc.getGame().getHolyCity(kTriggeredData.eReligion)
iReligion = kTriggeredData.eReligion
if iReligion == iCatholicism:
iReligion = iOrthodoxy

holyCity = gc.getGame().getHolyCity(iReligion)
iUnitType = holyCity.getConscriptUnit()
#Rhye - start
#iNumUnits = gc.getWorldInfo(gc.getMap().getWorldSize()).getDefaultPlayers() / 2 + 1
iNumUnits = 9 / 2 + 1
iNumUnits = 5
#Rhye - end

if iUnitType != -1:
Expand All @@ -3006,7 +3052,11 @@ def getHelpCrusadeDone2(argsList):
iEvent = argsList[0]
kTriggeredData = argsList[1]

holyCity = gc.getGame().getHolyCity(kTriggeredData.eReligion)
iReligion = kTriggeredData.eReligion
if iReligion == iCatholicism:
iReligion = iOrthodoxy

holyCity = gc.getGame().getHolyCity(iReligion)

szHelp = localText.getText("TXT_KEY_EVENT_CRUSADE_DONE_HELP_2", (gc.getBuildingInfo(kTriggeredData.eBuilding).getTextKey(), holyCity.getNameKey()))

Expand All @@ -3016,16 +3066,11 @@ def canApplyCrusadeDone2(argsList):
iEvent = argsList[0]
kTriggeredData = argsList[1]

holyCity = gc.getGame().getHolyCity(kTriggeredData.eReligion)

#Rhye - switch to Jerusalem
if scenario() >= i600AD: #late start condition
if (holyCity.getX() == 60 and holyCity.getY() == 44):
pJerusalem = gc.getMap().plot(73, 38)
if (not pJerusalem.getPlotCity().isNone()):
holyCity = pJerusalem.getPlotCity()
else:
return False #we don't want a Crusade on Rome
iReligion = kTriggeredData.eReligion
if iReligion == iCatholicism:
iReligion = iOrthodoxy

holyCity = gc.getGame().getHolyCity(iReligion)

if -1 == kTriggeredData.eBuilding or holyCity.isHasBuilding(kTriggeredData.eBuilding):
return False
Expand All @@ -3036,7 +3081,11 @@ def applyCrusadeDone2(argsList):
iEvent = argsList[0]
kTriggeredData = argsList[1]

holyCity = gc.getGame().getHolyCity(kTriggeredData.eReligion)
iReligion = kTriggeredData.eReligion
if iReligion == iCatholicism:
iReligion = iOrthodoxy

holyCity = gc.getGame().getHolyCity(iReligion)
holyCity.setNumRealBuilding(kTriggeredData.eBuilding, 1)

if (not gc.getGame().isNetworkMultiPlayer() and kTriggeredData.ePlayer == gc.getGame().getActivePlayer()):
Expand All @@ -3052,11 +3101,15 @@ def getHelpCrusadeDone3(argsList):
iEvent = argsList[0]
kTriggeredData = argsList[1]

iHolyCityReligion = kTriggeredData.eReligion
if iHolyCityReligion == iCatholicism:
iHolyCityReligion = iOrthodoxy

#Rhye - start
#iNumCities = gc.getWorldInfo(gc.getMap().getWorldSize()).getDefaultPlayers()
iNumCities = 7
#Rhye - end
holyCity = gc.getGame().getHolyCity(kTriggeredData.eReligion)
holyCity = gc.getGame().getHolyCity(iHolyCityReligion)

szHelp = localText.getText("TXT_KEY_EVENT_CRUSADE_DONE_HELP_3", (gc.getReligionInfo(kTriggeredData.eReligion).getTextKey(), iNumCities))

Expand All @@ -3079,7 +3132,12 @@ def canApplyCrusadeDone3(argsList):
def applyCrusadeDone3(argsList):
iEvent = argsList[0]
kTriggeredData = argsList[1]
holyCity = gc.getGame().getHolyCity(kTriggeredData.eReligion)

iHolyCityReligion = kTriggeredData.eReligion
if iHolyCityReligion == iCatholicism:
iHolyCityReligion = iOrthodoxy

holyCity = gc.getGame().getHolyCity(iHolyCityReligion)

listCities = []
for iPlayer in range(gc.getMAX_CIV_PLAYERS()):
Expand Down
6 changes: 3 additions & 3 deletions Assets/XML/Events/CIV4EventTriggerInfos.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12302,9 +12302,9 @@
<bTeam>0</bTeam>
<bGlobal>0</bGlobal>
<bPickPlayer>1</bPickPlayer>
<bOtherPlayerWar>1</bOtherPlayerWar>
<bOtherPlayerWar>0</bOtherPlayerWar>
<bOtherPlayerHasReligion>0</bOtherPlayerHasReligion>
<bOtherPlayerHasOtherReligion>0</bOtherPlayerHasOtherReligion>
<bOtherPlayerHasOtherReligion>1</bOtherPlayerHasOtherReligion>
<bOtherPlayerAI>0</bOtherPlayerAI>
<iOtherPlayerShareBorders>0</iOtherPlayerShareBorders>
<OtherPlayerHasTech>NONE</OtherPlayerHasTech>
Expand All @@ -12315,7 +12315,7 @@
<PythonCanDo>canTriggerCrusade</PythonCanDo>
<PythonCanDoCity/>
<PythonCanDoUnit/>
<PythonCallback/>
<PythonCallback>doTriggerCrusade</PythonCallback>
</EventTriggerInfo>
<EventTriggerInfo>
<Type>EVENTTRIGGER_CRUSADE_DONE</Type>
Expand Down
2 changes: 1 addition & 1 deletion Assets/XML/Text/Events.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3748,7 +3748,7 @@
</TEXT>
<TEXT>
<Tag>TXT_KEY_EVENT_TRIGGER_CRUSADE_DONE_1</Tag>
<English>Congratulations! Your Crusade to secure the sacred lands of %s2_city has wrested control of the city away from the %s1:2_civ_adjective! Please choose a reward from among the benefits that may accrue from the joy your people feel in this successful Crusade.</English>
<English>Congratulations! Your Crusade to secure the sacred lands of %s2_city has wrested control of the city away from the infidels! Please choose a reward from among the benefits that may accrue from the joy your people feel in this successful Crusade.</English>
<French>F&#233;licitations ! Votre croisade pour s&#233;curiser les terres saintes de la ville : %s2_city vous a permis d'arracher le contr&#244;le de la ville aux %s1:2_civ_adjective ! Veuillez choisir une r&#233;compense parmi les avantages dus &#224; la joie du peuple.</French>
<German>Gl&#252;ckwunsch! Ihr Kreuzzug zur Sicherung des heiligen Gebietes der Stadt %s2_city hat die Stadt dem %s1:2_civ_adjective Volk entrissen! W&#228;hlen Sie eine Belohnung aus den Vorteilen aus, die die Freude Ihres Volkes &#252;ber diesen erfolgreichen Kreuzzug Ihnen bieten kann.</German>
<Italian>Congratulazioni! La crociata per conquistare le sacre terre di %s2_city ha tolto il controllo della citt&#224; ai nemici %s1:3_civ_adjective! Scegli una ricompensa tra i benefici derivati dalla gioia del tuo popolo per questa vittoriosa crociata.</Italian>
Expand Down

0 comments on commit f6eb428

Please sign in to comment.