Advertisement
Guest User

Untitled

a guest
Jul 4th, 2015
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 276.02 KB | None | 0 0
  1. # Sid Meier's Civilization 4
  2. # Copyright Firaxis Games 2006
  3. #
  4. # CvEventManager
  5. # This class is passed an argsList from CvAppInterface.onEvent
  6. # The argsList can contain anything from mouse location to key info
  7. # The EVENTLIST that are being notified can be found
  8.  
  9. from CvPythonExtensions import *
  10. import CvUtil
  11. import CvScreensInterface
  12. import CvDebugTools
  13. #import CvWBPopups
  14. import PyHelpers
  15. import Popup as PyPopup
  16. import CvCameraControls
  17. import CvTopCivs
  18. import sys
  19. #import CvWorldBuilderScreen
  20. import CvAdvisorUtils
  21. import CvTechChooser
  22.  
  23. import CvIntroMovieScreen
  24. import CustomFunctions
  25. import ScenarioFunctions
  26.  
  27. #FfH: Card Game: begin
  28. import CvSomniumInterface
  29. import CvCorporationScreen
  30. #FfH: Card Game: end
  31.  
  32. #FfH: Added by Kael 10/15/2008 for OOS Logging
  33. import OOSLogger
  34. #FfH: End Add
  35.  
  36. ## Ultrapack ##
  37. import WBCityEditScreen
  38. import WBUnitScreen
  39. import WBPlayerScreen
  40. import WBGameDataScreen
  41. import WBPlotScreen
  42. import CvPlatyBuilderScreen
  43. ## Ultrapack ##
  44.  
  45. import Blizzards        #Added in Blizzards: TC01
  46.  
  47.  
  48. #My pickle for the x and y values when moving the Stack of Doom#
  49. import pickle
  50. #My BugData for storing the x and y values when moving the SoD#
  51. import BugData
  52.  
  53.  
  54. # globals
  55. cf = CustomFunctions.CustomFunctions()
  56. gc = CyGlobalContext()
  57. localText = CyTranslator()
  58. PyPlayer = PyHelpers.PyPlayer
  59. PyInfo = PyHelpers.PyInfo
  60. sf = ScenarioFunctions.ScenarioFunctions()
  61. game = gc.getGame()
  62.  
  63. #FfH: Card Game: begin
  64. cs = CvCorporationScreen.cs
  65. #FfH: Card Game: end
  66.  
  67. Blizzards = Blizzards.Blizzards()       #Added in Blizzards: TC01
  68.  
  69. # globals
  70. ###################################################
  71. class CvEventManager:
  72.     def __init__(self):
  73.         #################### ON EVENT MAP ######################
  74.         #print "EVENTMANAGER INIT"
  75.  
  76.         self.bCtrl = False
  77.         self.bShift = False
  78.         self.bAlt = False
  79.         self.bAllowCheats = False
  80.  
  81.         # OnEvent Enums
  82.         self.EventLButtonDown=1
  83.         self.EventLcButtonDblClick=2
  84.         self.EventRButtonDown=3
  85.         self.EventBack=4
  86.         self.EventForward=5
  87.         self.EventKeyDown=6
  88.         self.EventKeyUp=7
  89.  
  90.         self.__LOG_MOVEMENT = 0
  91.         self.__LOG_BUILDING = 0
  92.         self.__LOG_COMBAT = 0
  93.         self.__LOG_CONTACT = 0
  94.         self.__LOG_IMPROVEMENT =0
  95.         self.__LOG_CITYLOST = 0
  96.         self.__LOG_CITYBUILDING = 0
  97.         self.__LOG_TECH = 0
  98.         self.__LOG_UNITBUILD = 0
  99.         self.__LOG_UNITKILLED = 1
  100.         self.__LOG_UNITLOST = 0
  101.         self.__LOG_UNITPROMOTED = 0
  102.         self.__LOG_UNITSELECTED = 0
  103.         self.__LOG_UNITPILLAGE = 0
  104.         self.__LOG_GOODYRECEIVED = 0
  105.         self.__LOG_GREATPERSON = 0
  106.         self.__LOG_RELIGION = 0
  107.         self.__LOG_RELIGIONSPREAD = 0
  108.         self.__LOG_GOLDENAGE = 0
  109.         self.__LOG_ENDGOLDENAGE = 0
  110.         self.__LOG_WARPEACE = 0
  111.         self.__LOG_PUSH_MISSION = 0
  112.  
  113.         ## EVENTLIST
  114.         self.EventHandlerMap = {
  115.             'mouseEvent'            : CvEventManager.onMouseEvent.__get__(self,CvEventManager),
  116.             'kbdEvent'              : CvEventManager.onKbdEvent.__get__(self,CvEventManager),
  117.             'ModNetMessage'                 : CvEventManager.onModNetMessage.__get__(self,CvEventManager),
  118.             'Init'                  : CvEventManager.onInit.__get__(self,CvEventManager),
  119.             'Update'                : CvEventManager.onUpdate.__get__(self,CvEventManager),
  120.             'UnInit'                : CvEventManager.onUnInit.__get__(self,CvEventManager),
  121.             'OnSave'                : CvEventManager.onSaveGame.__get__(self,CvEventManager),
  122.             'OnPreSave'             : CvEventManager.onPreSave.__get__(self,CvEventManager),
  123.             'OnLoad'                : CvEventManager.onLoadGame.__get__(self,CvEventManager),
  124.             'GameStart'             : CvEventManager.onGameStart.__get__(self,CvEventManager),
  125.             'GameEnd'               : CvEventManager.onGameEnd.__get__(self,CvEventManager),
  126.             'plotRevealed'          : CvEventManager.onPlotRevealed.__get__(self,CvEventManager),
  127.             'plotFeatureRemoved'    : CvEventManager.onPlotFeatureRemoved.__get__(self,CvEventManager),
  128.             'plotPicked'            : CvEventManager.onPlotPicked.__get__(self,CvEventManager),
  129.             'nukeExplosion'         : CvEventManager.onNukeExplosion.__get__(self,CvEventManager),
  130.             'gotoPlotSet'           : CvEventManager.onGotoPlotSet.__get__(self,CvEventManager),
  131.             'BeginGameTurn'         : CvEventManager.onBeginGameTurn.__get__(self,CvEventManager),
  132.             'EndGameTurn'           : CvEventManager.onEndGameTurn.__get__(self,CvEventManager),
  133.             'BeginPlayerTurn'       : CvEventManager.onBeginPlayerTurn.__get__(self,CvEventManager),
  134.             'EndPlayerTurn'         : CvEventManager.onEndPlayerTurn.__get__(self,CvEventManager),
  135.             'endTurnReady'          : CvEventManager.onEndTurnReady.__get__(self,CvEventManager),
  136.             'combatResult'          : CvEventManager.onCombatResult.__get__(self,CvEventManager),
  137.             'combatLogCalc'         : CvEventManager.onCombatLogCalc.__get__(self,CvEventManager),
  138.             'combatLogHit'          : CvEventManager.onCombatLogHit.__get__(self,CvEventManager),
  139.             'improvementBuilt'      : CvEventManager.onImprovementBuilt.__get__(self,CvEventManager),
  140.             'improvementDestroyed'  : CvEventManager.onImprovementDestroyed.__get__(self,CvEventManager),
  141.             'routeBuilt'            : CvEventManager.onRouteBuilt.__get__(self,CvEventManager),
  142.             'firstContact'          : CvEventManager.onFirstContact.__get__(self,CvEventManager),
  143.             'cityBuilt'             : CvEventManager.onCityBuilt.__get__(self,CvEventManager),
  144.             'cityRazed'             : CvEventManager.onCityRazed.__get__(self,CvEventManager),
  145.             'cityAcquired'          : CvEventManager.onCityAcquired.__get__(self,CvEventManager),
  146.             'cityAcquiredAndKept'   : CvEventManager.onCityAcquiredAndKept.__get__(self,CvEventManager),
  147.             'cityLost'              : CvEventManager.onCityLost.__get__(self,CvEventManager),
  148.             'cultureExpansion'      : CvEventManager.onCultureExpansion.__get__(self,CvEventManager),
  149.             'cityGrowth'            : CvEventManager.onCityGrowth.__get__(self,CvEventManager),
  150.             'cityDoTurn'            : CvEventManager.onCityDoTurn.__get__(self,CvEventManager),
  151.             'cityBuildingUnit'  : CvEventManager.onCityBuildingUnit.__get__(self,CvEventManager),
  152.             'cityBuildingBuilding'  : CvEventManager.onCityBuildingBuilding.__get__(self,CvEventManager),
  153.             'cityRename'                : CvEventManager.onCityRename.__get__(self,CvEventManager),
  154.             'cityHurry'             : CvEventManager.onCityHurry.__get__(self,CvEventManager),
  155.             'selectionGroupPushMission'     : CvEventManager.onSelectionGroupPushMission.__get__(self,CvEventManager),
  156.             'unitMove'              : CvEventManager.onUnitMove.__get__(self,CvEventManager),
  157.             'unitSetXY'             : CvEventManager.onUnitSetXY.__get__(self,CvEventManager),
  158.             'unitCreated'           : CvEventManager.onUnitCreated.__get__(self,CvEventManager),
  159.             'unitBuilt'             : CvEventManager.onUnitBuilt.__get__(self,CvEventManager),
  160.             'unitKilled'            : CvEventManager.onUnitKilled.__get__(self,CvEventManager),
  161.             'unitLost'              : CvEventManager.onUnitLost.__get__(self,CvEventManager),
  162.             'unitPromoted'          : CvEventManager.onUnitPromoted.__get__(self,CvEventManager),
  163.             'unitSelected'          : CvEventManager.onUnitSelected.__get__(self,CvEventManager),
  164.             'UnitRename'                : CvEventManager.onUnitRename.__get__(self,CvEventManager),
  165.             'unitPillage'               : CvEventManager.onUnitPillage.__get__(self,CvEventManager),
  166.             'unitSpreadReligionAttempt' : CvEventManager.onUnitSpreadReligionAttempt.__get__(self,CvEventManager),
  167.             'unitGifted'                : CvEventManager.onUnitGifted.__get__(self,CvEventManager),
  168.             'unitBuildImprovement'              : CvEventManager.onUnitBuildImprovement.__get__(self,CvEventManager),
  169.             'goodyReceived'         : CvEventManager.onGoodyReceived.__get__(self,CvEventManager),
  170.             'greatPersonBorn'       : CvEventManager.onGreatPersonBorn.__get__(self,CvEventManager),
  171.             'buildingBuilt'         : CvEventManager.onBuildingBuilt.__get__(self,CvEventManager),
  172.             'projectBuilt'          : CvEventManager.onProjectBuilt.__get__(self,CvEventManager),
  173.             'techAcquired'          : CvEventManager.onTechAcquired.__get__(self,CvEventManager),
  174.             'techSelected'          : CvEventManager.onTechSelected.__get__(self,CvEventManager),
  175.             'religionFounded'       : CvEventManager.onReligionFounded.__get__(self,CvEventManager),
  176.             'religionSpread'        : CvEventManager.onReligionSpread.__get__(self,CvEventManager),
  177.             'religionRemove'        : CvEventManager.onReligionRemove.__get__(self,CvEventManager),
  178.             'corporationFounded'    : CvEventManager.onCorporationFounded.__get__(self,CvEventManager),
  179.             'corporationSpread'     : CvEventManager.onCorporationSpread.__get__(self,CvEventManager),
  180.             'corporationRemove'     : CvEventManager.onCorporationRemove.__get__(self,CvEventManager),
  181.             'goldenAge'             : CvEventManager.onGoldenAge.__get__(self,CvEventManager),
  182.             'endGoldenAge'          : CvEventManager.onEndGoldenAge.__get__(self,CvEventManager),
  183.             'chat'                  : CvEventManager.onChat.__get__(self,CvEventManager),
  184.             'victory'               : CvEventManager.onVictory.__get__(self,CvEventManager),
  185.             'vassalState'           : CvEventManager.onVassalState.__get__(self,CvEventManager),
  186.             'changeWar'             : CvEventManager.onChangeWar.__get__(self,CvEventManager),
  187.             'setPlayerAlive'        : CvEventManager.onSetPlayerAlive.__get__(self,CvEventManager),
  188.             'playerChangeStateReligion'     : CvEventManager.onPlayerChangeStateReligion.__get__(self,CvEventManager),
  189.             'playerGoldTrade'       : CvEventManager.onPlayerGoldTrade.__get__(self,CvEventManager),
  190.             'windowActivation'      : CvEventManager.onWindowActivation.__get__(self,CvEventManager),
  191.             'gameUpdate'            : CvEventManager.onGameUpdate.__get__(self,CvEventManager),     # sample generic event
  192.         }
  193.  
  194.         ################## Events List ###############################
  195.         #
  196.         # Dictionary of Events, indexed by EventID (also used at popup context id)
  197.         #   entries have name, beginFunction, applyFunction [, randomization weight...]
  198.         #
  199.         # Normal events first, random events after
  200.         #
  201.         ################## Events List ###############################
  202.         self.Events={
  203.             CvUtil.EventEditCityName : ('EditCityName', self.__eventEditCityNameApply, self.__eventEditCityNameBegin),
  204.             CvUtil.EventPlaceObject : ('PlaceObject', self.__eventPlaceObjectApply, self.__eventPlaceObjectBegin),
  205.             CvUtil.EventAwardTechsAndGold: ('AwardTechsAndGold', self.__eventAwardTechsAndGoldApply, self.__eventAwardTechsAndGoldBegin),
  206.             CvUtil.EventEditUnitName : ('EditUnitName', self.__eventEditUnitNameApply, self.__eventEditUnitNameBegin),
  207. ## Platy Builder ##
  208.             CvUtil.EventWBLandmarkPopup : ('WBLandmarkPopup', self.__eventWBLandmarkPopupApply, self.__eventWBScriptPopupBegin),
  209.             CvUtil.EventShowWonder: ('ShowWonder', self.__eventShowWonderApply, self.__eventShowWonderBegin),
  210.             1111 : ('WBPlayerScript', self.__eventWBPlayerScriptPopupApply, self.__eventWBScriptPopupBegin),
  211.             2222 : ('WBCityScript', self.__eventWBCityScriptPopupApply, self.__eventWBScriptPopupBegin),
  212.             3333 : ('WBUnitScript', self.__eventWBUnitScriptPopupApply, self.__eventWBScriptPopupBegin),
  213.             4444 : ('WBGameScript', self.__eventWBGameScriptPopupApply, self.__eventWBScriptPopupBegin),
  214.             5555 : ('WBPlotScript', self.__eventWBPlotScriptPopupApply, self.__eventWBScriptPopupBegin),
  215. #Magister Start
  216.             6666 : ('WBPlayerRename', self.__eventEditPlayerNameApply, self.__eventEditPlayerNameBegin),
  217.             6777 : ('WBPlayerRename', self.__eventEditCivNameApply, self.__eventEditCivNameBegin),
  218.             6888 : ('WBPlayerRename', self.__eventEditCivShortNameApply, self.__eventEditCivShortNameBegin),
  219.             6999 : ('WBPlayerRename', self.__eventEditCivAdjApply, self.__eventEditCivAdjBegin),
  220. #Magister Stop
  221. ## Platy Builder ##
  222.         }
  223. ## FfH Card Game: begin
  224.         self.Events[CvUtil.EventSelectSolmniumPlayer] = ('selectSolmniumPlayer', self.__EventSelectSolmniumPlayerApply, self.__EventSelectSolmniumPlayerBegin)
  225.         self.Events[CvUtil.EventSolmniumAcceptGame] = ('solmniumAcceptGame', self.__EventSolmniumAcceptGameApply, self.__EventSolmniumAcceptGameBegin)
  226.         self.Events[CvUtil.EventSolmniumConcedeGame] = ('solmniumConcedeGame', self.__EventSolmniumConcedeGameApply, self.__EventSolmniumConcedeGameBegin)
  227. ## FfH Card Game: end
  228.  
  229. #################### EVENT STARTERS ######################
  230.     def handleEvent(self, argsList):
  231.         'EventMgr entry point'
  232.         # extract the last 6 args in the list, the first arg has already been consumed
  233.         self.origArgsList = argsList    # point to original
  234.         tag = argsList[0]               # event type string
  235.         idx = len(argsList)-6
  236.         bDummy = False
  237.         self.bDbg, bDummy, self.bAlt, self.bCtrl, self.bShift, self.bAllowCheats = argsList[idx:]
  238.         ret = 0
  239.         if self.EventHandlerMap.has_key(tag):
  240.             fxn = self.EventHandlerMap[tag]
  241.             ret = fxn(argsList[1:idx])
  242.         return ret
  243.  
  244. #################### EVENT APPLY ######################
  245.     def beginEvent( self, context, argsList=-1 ):
  246.         'Begin Event'
  247.         entry = self.Events[context]
  248.         return entry[2]( argsList )
  249.  
  250.     def applyEvent( self, argsList ):
  251.         'Apply the effects of an event '
  252.         context, playerID, netUserData, popupReturn = argsList
  253.  
  254.         if context == CvUtil.PopupTypeEffectViewer:
  255.             return CvDebugTools.g_CvDebugTools.applyEffectViewer( playerID, netUserData, popupReturn )
  256.  
  257.         entry = self.Events[context]
  258.  
  259.         if ( context not in CvUtil.SilentEvents ):
  260.             self.reportEvent(entry, context, (playerID, netUserData, popupReturn) )
  261.         return entry[1]( playerID, netUserData, popupReturn )   # the apply function
  262.  
  263.     def reportEvent(self, entry, context, argsList):
  264.         'Report an Event to Events.log '
  265.         if (gc.getGame().getActivePlayer() != -1):
  266.             message = "DEBUG Event: %s (%s)" %(entry[0], gc.getActivePlayer().getName())
  267.             CyInterface().addImmediateMessage(message,"")
  268.             CvUtil.pyPrint(message)
  269.         return 0
  270.  
  271. #################### ON EVENTS ######################
  272.     def onKbdEvent(self, argsList):
  273.         'keypress handler - return 1 if the event was consumed'
  274.  
  275.         eventType,key,mx,my,px,py = argsList
  276.         game = gc.getGame()
  277.  
  278.         if (self.bAllowCheats):
  279.             # notify debug tools of input to allow it to override the control
  280.             argsList = (eventType,key,self.bCtrl,self.bShift,self.bAlt,mx,my,px,py,gc.getGame().isNetworkMultiPlayer())
  281.             if ( CvDebugTools.g_CvDebugTools.notifyInput(argsList) ):
  282.                 return 0
  283.  
  284.         if ( eventType == self.EventKeyDown ):
  285.             theKey=int(key)
  286.  
  287. #FfH: Added by Kael 07/05/2008
  288.             if (theKey == int(InputTypes.KB_LEFT)):
  289.                 if self.bCtrl:
  290.                         CyCamera().SetBaseTurn(CyCamera().GetBaseTurn() - 45.0)
  291.                         return 1
  292.                 elif self.bShift:
  293.                         CyCamera().SetBaseTurn(CyCamera().GetBaseTurn() - 10.0)
  294.                         return 1
  295.  
  296.             if (theKey == int(InputTypes.KB_RIGHT)):
  297.                     if self.bCtrl:
  298.                             CyCamera().SetBaseTurn(CyCamera().GetBaseTurn() + 45.0)
  299.                             return 1
  300.                     elif self.bShift:
  301.                             CyCamera().SetBaseTurn(CyCamera().GetBaseTurn() + 10.0)
  302.                             return 1
  303. #FfH: End Add
  304.  
  305.             CvCameraControls.g_CameraControls.handleInput( theKey )
  306.  
  307.             if (self.bAllowCheats):
  308.                 # Shift - T (Debug - No MP)
  309.                 if (theKey == int(InputTypes.KB_T)):
  310.                     if ( self.bShift ):
  311.                         CvEventManager.beginEvent(self,CvUtil.EventAwardTechsAndGold)
  312.                         #self.beginEvent(CvUtil.EventCameraControlPopup)
  313.                         return 1
  314.  
  315.                 elif (theKey == int(InputTypes.KB_W)):
  316.                     if ( self.bShift and self.bCtrl):
  317.                         CvEventManager.beginEvent(self,CvUtil.EventShowWonder)
  318.                         return 1
  319.  
  320.                 # Shift - ] (Debug - currently mouse-overd unit, health += 10
  321.                 elif (theKey == int(InputTypes.KB_LBRACKET) and self.bShift ):
  322.                     unit = CyMap().plot(px, py).getUnit(0)
  323.                     if ( not unit.isNone() ):
  324.                         d = min( unit.maxHitPoints()-1, unit.getDamage() + 10 )
  325.                         unit.setDamage( d, PlayerTypes.NO_PLAYER )
  326.  
  327.                 # Shift - [ (Debug - currently mouse-overd unit, health -= 10
  328.                 elif (theKey == int(InputTypes.KB_RBRACKET) and self.bShift ):
  329.                     unit = CyMap().plot(px, py).getUnit(0)
  330.                     if ( not unit.isNone() ):
  331.                         d = max( 0, unit.getDamage() - 10 )
  332.                         unit.setDamage( d, PlayerTypes.NO_PLAYER )
  333.  
  334.                 elif (theKey == int(InputTypes.KB_F1)):
  335.                     if ( self.bShift ):
  336.                         CvScreensInterface.replayScreen.showScreen(False)
  337.                         return 1
  338.                     # don't return 1 unless you want the input consumed
  339.  
  340.                 elif (theKey == int(InputTypes.KB_F2)):
  341.                     if ( self.bShift ):
  342.                         import CvDebugInfoScreen
  343.                         CvScreensInterface.showDebugInfoScreen()
  344.                         return 1
  345.  
  346.                 elif (theKey == int(InputTypes.KB_F3)):
  347.                     if ( self.bShift ):
  348.                         CvScreensInterface.showDanQuayleScreen(())
  349.                         return 1
  350.  
  351.                 elif (theKey == int(InputTypes.KB_F4)):
  352.                     if ( self.bShift ):
  353.                         CvScreensInterface.showUnVictoryScreen(())
  354.                         return 1
  355.  
  356.         return 0
  357.  
  358.     def onModNetMessage(self, argsList):
  359.         'Called whenever CyMessageControl().sendModNetMessage() is called - this is all for you modders!'
  360.  
  361.         iData1, iData2, iData3, iData4, iData5 = argsList
  362.  
  363. #       print("Modder's net message!")
  364. #       CvUtil.pyPrint( 'onModNetMessage' )
  365.  
  366. #FfH Card Game: begin
  367.         if iData1 == CvUtil.Somnium : # iData1 == 0 : Solmnium message, iData2 = function, iData3 to iData5 = parameters
  368.             if iData2 == 0 :
  369.                 if (iData3 == gc.getGame().getActivePlayer()):
  370.                     self.__EventSelectSolmniumPlayerBegin()
  371.             elif iData2 == 1 :
  372.                 if (iData4 == gc.getGame().getActivePlayer()):
  373.                     self.__EventSolmniumConcedeGameBegin((iData3, iData4))
  374.             else :
  375.                 cs.applyAction(iData2, iData3, iData4, iData5)
  376. # FfH Card Game: end
  377.  
  378. ## OOS fix by Snarko
  379.         elif (iData1 == CvUtil.ChangeCiv): #iData1 is unused, to allow for a condition here. It must not be zero (would trigger somnium)
  380.             CyGame().reassignPlayerAdvanced(iData2, iData3, -1)
  381. ## Declare war to Barbarians.
  382.         elif (iData1 == CvUtil.BarbarianWar):
  383.             gc.getTeam(iData2).declareWar(iData3, False, WarPlanTypes.WARPLAN_TOTAL)
  384.         elif (iData1 == CvUtil.HyboremWhisper):
  385.             pPlayer = gc.getPlayer(iData2)
  386.             pPlot = CyMap().plot(iData3, iData4)
  387.             pCity = pPlot.getPlotCity()
  388.             pPlayer.acquireCity(pCity, False, True)
  389.  
  390.     def onInit(self, argsList):
  391.         'Called when Civ starts up'
  392.         CvUtil.pyPrint( 'OnInit' )
  393.  
  394.     def onUpdate(self, argsList):
  395.         'Called every frame'
  396.         fDeltaTime = argsList[0]
  397.  
  398.         # allow camera to be updated
  399.         CvCameraControls.g_CameraControls.onUpdate( fDeltaTime )
  400.  
  401.     def onWindowActivation(self, argsList):
  402.         'Called when the game window activates or deactivates'
  403.         bActive = argsList[0]
  404.  
  405.     def onUnInit(self, argsList):
  406.         'Called when Civ shuts down'
  407.         CvUtil.pyPrint('OnUnInit')
  408.  
  409.     def onPreSave(self, argsList):
  410.         "called before a game is actually saved"
  411.         CvUtil.pyPrint('OnPreSave')
  412.  
  413.     def onSaveGame(self, argsList):
  414.         "return the string to be saved - Must be a string"
  415.         return ""
  416.  
  417.     def onLoadGame(self, argsList):
  418.         CvAdvisorUtils.resetNoLiberateCities()
  419.         return 0
  420.  
  421.     def onGameStart(self, argsList):
  422.         'Called at the start of the game'
  423.  
  424.         if CyGame().getWBMapScript():
  425.             sf.gameStart()
  426.         else:
  427.             introMovie = CvIntroMovieScreen.CvIntroMovieScreen()
  428.             introMovie.interfaceScreen()
  429.  
  430.         if gc.getGame().isOption(GameOptionTypes.GAMEOPTION_THAW):
  431. # Enhanced End of Winter - Adpated from FlavourMod
  432.             '''    
  433.             iDesert = gc.getInfoTypeForString('TERRAIN_DESERT')
  434.             iGrass = gc.getInfoTypeForString('TERRAIN_GRASS')
  435.             iPlains = gc.getInfoTypeForString('TERRAIN_PLAINS')
  436.             iSnow = gc.getInfoTypeForString('TERRAIN_SNOW')
  437.             iTundra = gc.getInfoTypeForString('TERRAIN_TUNDRA')
  438.             for i in range (CyMap().numPlots()):
  439.                 pPlot = CyMap().plotByIndex(i)
  440.                 if pPlot.getFeatureType() == -1:
  441.                     if pPlot.getImprovementType() == -1:
  442.                         if pPlot.isWater() == False:
  443.                             iTerrain = pPlot.getTerrainType()
  444.                             if iTerrain == iTundra:
  445.                                 pPlot.setTempTerrainType(iSnow, CyGame().getSorenRandNum(90, "Bob") + 10)
  446.                             if iTerrain == iGrass:
  447.                                 pPlot.setTempTerrainType(iTundra, CyGame().getSorenRandNum(90, "Bob") + 10)
  448.                             if iTerrain == iPlains:
  449.                                 pPlot.setTempTerrainType(iTundra, CyGame().getSorenRandNum(90, "Bob") + 10)
  450.                             if iTerrain == iDesert:
  451.                                 pPlot.setTempTerrainType(iPlains, CyGame().getSorenRandNum(90, "Bob") + 10)
  452.             '''
  453.             FLAT_WORLDS = ["ErebusWrap", "Erebus"]          # map scripts with wrapping but no equator
  454.             MAX_EOW_PERCENTAGE = 0.25                       # percentage of EoW on total game turns
  455.             THAW_DELAY_PERCENTAGE = 0.05                    # don't start thawing for x percent of EoW
  456.  
  457.             # forest varieties
  458.             DECIDUOUS_FOREST = 0
  459.             CONIFEROUS_FOREST = 1
  460.             SNOWY_CONIFEROUS_FOREST = 2
  461.            
  462.             dice = gc.getGame().getSorenRand()
  463.  
  464.             iDesert = gc.getInfoTypeForString('TERRAIN_DESERT')
  465.             iGrass = gc.getInfoTypeForString('TERRAIN_GRASS')
  466.             iMarsh = gc.getInfoTypeForString('TERRAIN_MARSH')
  467.             iPlains = gc.getInfoTypeForString('TERRAIN_PLAINS')
  468.             iSnow = gc.getInfoTypeForString('TERRAIN_SNOW')
  469.             iTundra = gc.getInfoTypeForString('TERRAIN_TUNDRA')
  470.             iIce = gc.getInfoTypeForString('FEATURE_ICE')
  471.             iForest = gc.getInfoTypeForString('FEATURE_FOREST')
  472.             iJungle = gc.getInfoTypeForString('FEATURE_JUNGLE')
  473.             iBlizzard = gc.getInfoTypeForString('FEATURE_BLIZZARD')
  474.  
  475. #           iTotalGameTurns = gc.getGameSpeedInfo(CyGame().getGameSpeedType()).getGameTurnInfo(0).iNumGameTurnsPerIncrement
  476. #           iMaxEOWTurns = max(1, int(iTotalGameTurns * MAX_EOW_PERCENTAGE))
  477. #           iThawDelayTurns = max(1, int(iMaxEOWTurns * THAW_DELAY_PERCENTAGE))
  478.  
  479.             iMaxLatitude = max(CyMap().getTopLatitude(), abs(CyMap().getBottomLatitude()))
  480.             bIsFlatWorld = not (CyMap().isWrapX() or CyMap().isWrapY()) or CyMap().getMapScriptName() in FLAT_WORLDS
  481.  
  482.             for i in range (CyMap().numPlots()):
  483.                 pPlot = CyMap().plotByIndex(i)
  484.                 eTerrain = pPlot.getTerrainType()
  485.                 eFeature = pPlot.getFeatureType()
  486.                 iVariety = pPlot.getFeatureVariety()
  487.                 eBonus = pPlot.getBonusType(TeamTypes.NO_TEAM)
  488.  
  489.                 iTurns = dice.get(110, "Thaw") + 40
  490.                 iTurns = (iTurns * gc.getGameSpeedInfo(CyGame().getGameSpeedType()).getVictoryDelayPercent()) / 100
  491.                 if not bIsFlatWorld:
  492.                     iLatitude = abs(pPlot.getLatitude())
  493.                     iTurns = int(iTurns * ((float(iLatitude) / iMaxLatitude) ** 0.4))
  494. #               iTurns += iThawDelayTurns
  495.  
  496.                 # cover erebus' oceans and lakes in ice
  497.                 if pPlot.isWater():
  498.                     if bIsFlatWorld:
  499.                         if dice.get(100, "Bob") < 90:
  500.                             pPlot.setTempFeatureType(iIce, 0, iTurns)
  501.                     elif iLatitude + 10 > dice.get(50, "Bob"):
  502.                         pPlot.setTempFeatureType(iIce, 0, iTurns)
  503.  
  504.                 # change terrains to colder climate versions
  505.                 if eTerrain == iTundra:
  506.                     if dice.get(100, "Tundra to Snow") < 90:
  507.                         pPlot.setTempTerrainType(iSnow, iTurns)
  508.                 elif eTerrain == iGrass:
  509.                     if eFeature != iJungle:
  510.                         if dice.get(100, "Grass to Snow or Tundra") < 60:
  511.                             pPlot.setTempTerrainType(iSnow, iTurns)
  512.                         else:
  513.                             pPlot.setTempTerrainType(iTundra, iTurns)
  514.                 elif eTerrain == iPlains:
  515.                     if dice.get(100, "Plains to Snow or Tundra") < 30:
  516.                         pPlot.setTempTerrainType(iSnow, iTurns)
  517.                     else:
  518.                         pPlot.setTempTerrainType(iTundra, iTurns)
  519.                 elif eTerrain == iDesert:
  520.                     if dice.get(100, "Desert to Tundra or Plains") < 50:
  521.                         pPlot.setTempTerrainType(iTundra, iTurns)
  522.                     else:
  523.                         pPlot.setTempTerrainType(iPlains, iTurns)
  524.                 elif eTerrain == iMarsh:
  525.                     pPlot.setTempTerrainType(iGrass, iTurns)
  526.  
  527.                 # change forests to colder climate versions
  528.                 if eFeature == iForest:
  529.                     if iVariety == DECIDUOUS_FOREST:
  530.                         pPlot.setTempFeatureType(iForest, CONIFEROUS_FOREST, iTurns)
  531.                     elif iVariety == CONIFEROUS_FOREST:
  532.                         pPlot.setTempFeatureType(iForest, SNOWY_CONIFEROUS_FOREST, iTurns)
  533.                 elif eFeature == iJungle:
  534.                     pPlot.setTempFeatureType(iForest, DECIDUOUS_FOREST, iTurns)
  535.                 elif eFeature == FeatureTypes.NO_FEATURE:
  536.                     if dice.get(100, "Spawn Blizzard") < 5:
  537.                         pPlot.setFeatureType(iBlizzard, -1)
  538.  
  539.                 # remove invalid bonuses or replace them (if food) with a valid surrogate
  540.                 if eBonus != BonusTypes.NO_BONUS:
  541.                     pPlot.setBonusType(BonusTypes.NO_BONUS)
  542.                     if not pPlot.canHaveBonus(eBonus, True):
  543.                         if gc.getBonusInfo(eBonus).getYieldChange(YieldTypes.YIELD_FOOD) > 0:
  544.                             iPossibleTempFoodBonuses = []
  545.                             for iLoopBonus in range(gc.getNumBonusInfos()):
  546.                                 if gc.getBonusInfo(iLoopBonus).getYieldChange(YieldTypes.YIELD_FOOD) > 0:
  547.                                     if pPlot.canHaveBonus(iLoopBonus, True):
  548.                                         iPossibleTempFoodBonuses.append(iLoopBonus)
  549.                             pPlot.setBonusType(eBonus)
  550.                             if len(iPossibleTempFoodBonuses) > 0:
  551.                                 pPlot.setTempBonusType(iPossibleTempFoodBonuses[dice.get(len(iPossibleTempFoodBonuses), "Bob")], iTurns)
  552.                             else:
  553.                                 pPlot.setTempBonusType(BonusTypes.NO_BONUS, iTurns)
  554.                         else:
  555.                             pPlot.setBonusType(eBonus)
  556.                             pPlot.setTempBonusType(BonusTypes.NO_BONUS, iTurns)
  557.                     else:
  558.                         pPlot.setBonusType(eBonus)
  559.             Blizzards.doBlizzardTurn()
  560. # End Enhanced End of Winter
  561.  
  562.         for iPlayer in range(gc.getMAX_PLAYERS()):
  563.             player = gc.getPlayer(iPlayer)
  564.             if player.isAlive():
  565.                 if player.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_ELOHIM'):
  566.                     cf.showUniqueImprovements(iPlayer)
  567.  
  568.         if not gc.getGame().isNetworkMultiPlayer():
  569.             t = "TROPHY_FEAT_INTRODUCTION"
  570.             if not CyGame().isHasTrophy(t):
  571.                 CyGame().changeTrophyValue(t, 1)
  572.                 sf.addPopupWB(CyTranslator().getText("TXT_KEY_FFH_INTRO",()),'art/interface/popups/FfHIntro.dds')
  573.  
  574.         if CyGame().isOption(gc.getInfoTypeForString('GAMEOPTION_NO_BARBARIANS')) == False and (not CyGame().getWBMapScript()):
  575.             iGoblinFort = gc.getInfoTypeForString('IMPROVEMENT_GOBLIN_FORT')
  576.             bPlayer = gc.getPlayer(gc.getBARBARIAN_PLAYER())
  577.             for i in range (CyMap().numPlots()):
  578.                 pPlot = CyMap().plotByIndex(i)
  579.                 if pPlot.getImprovementType() == iGoblinFort:
  580.                     bPlayer.initUnit(gc.getInfoTypeForString('UNIT_ARCHER_SCORPION_CLAN'), pPlot.getX(), pPlot.getY(), UnitAITypes.UNITAI_LAIRGUARDIAN, DirectionTypes.DIRECTION_SOUTH)
  581.  
  582.         if (gc.getGame().getGameTurnYear() == gc.getDefineINT("START_YEAR") and not gc.getGame().isOption(GameOptionTypes.GAMEOPTION_ADVANCED_START)):
  583.             if not CyGame().getWBMapScript():
  584.                 for iPlayer in range(gc.getMAX_PLAYERS()):
  585.                     player = gc.getPlayer(iPlayer)
  586.                     if player.isAlive() and player.isHuman():
  587.                         popupInfo = CyPopupInfo()
  588.                         popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
  589.                         popupInfo.setText(u"showDawnOfMan")
  590.                         popupInfo.addPopup(iPlayer)
  591.         else:
  592.             CyInterface().setSoundSelectionReady(True)
  593.  
  594.         if gc.getGame().isPbem():
  595.             for iPlayer in range(gc.getMAX_PLAYERS()):
  596.                 player = gc.getPlayer(iPlayer)
  597.                 if player.isAlive() and player.isHuman():
  598.                     popupInfo = CyPopupInfo()
  599.                     popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_DETAILS)
  600.                     popupInfo.setOption1(False)
  601.                     popupInfo.addPopup(iPlayer)
  602.  
  603.         # Super Forts
  604.         CyMap().calculateCanalAndChokePoints()
  605.  
  606.         CvAdvisorUtils.resetNoLiberateCities()
  607.        
  608.        
  609.         #Set the Armageddon Counter in World Builder rather than in python
  610.         #CyGame().changeGlobalCounter(8)
  611.        
  612.        
  613.         #Make the pop-up text for this scenario
  614.         #Write a story in CIV4GameText_FFH2.xml
  615.         sf.addPopupWB(CyTranslator().getText("TXT_KEY_WB_ELOHIM_SCENARIO_INTRO",()), 'art/interface/popups/Blood of Angels.dds')
  616.        
  617.        
  618.        
  619.         #Find and set the Team (i.e. player) ID numbers for each civ in the game (could be done manually since it is a scenario with fixed civs)
  620.         #ID's need to be remembered for the onBeginGameTurn section (so if code is moved away from CvEventManager.py to other files then use pickle + Bugdata to remember it perhaps?)
  621.         for iGoodAndEvilPlayer in range(gc.getMAX_PLAYERS()):
  622.             pGoodAndEvilPlayer = gc.getPlayer(iGoodAndEvilPlayer)
  623.             if pGoodAndEvilPlayer.isAlive():
  624.                 if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_BANNOR'):
  625.                     iBannorTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  626.                 if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_CALABIM'):
  627.                     iCalabimTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  628.                 if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_CLAN_OF_EMBERS'):
  629.                     iClanOfEmbersTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  630.                 if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_DOVIELLO'):
  631.                     iDovielloTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  632.                 if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_ELOHIM'):
  633.                     iElohimTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  634.                 if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_KURIOTATES'):
  635.                     iKuriotatesTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  636.                 if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LJOSALFAR'):
  637.                     iLjosalfarTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  638.                 if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LUCHUIRP'):
  639.                     iLuchuirpTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  640.                 if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_SHEAIM'):
  641.                     iSheaimTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  642.                 if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_SVARTALFAR'):
  643.                     iSvartalfarTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  644.  
  645.                
  646.                    
  647.         #Make the good civs at permanent peace with eachother, the evil civs at non-permanent peace with eachother, and the good and evil civs at war      
  648.         #If the setPermanentWarPeace boolean is True then the civs cannot change their peace or war status.  Use declareWar first to keep them at war with the True boolean.
  649.         #If the declareWar boolean is True then you get a pop-up message that the civ declares war on you, if it is False then there is no pop-up message
  650.         #If the meet boolean is True then you get a pop-up message that you met them for the first time, if it is False then there is no pop-up message
  651.        
  652.         for iWarAndPeaceTeam in range(gc.getMAX_CIV_TEAMS()):
  653.             pWarAndPeaceTeam = gc.getTeam(iWarAndPeaceTeam)
  654.             if pWarAndPeaceTeam.isAlive():
  655.                 #Make good civs meet other good civs
  656.                 if iWarAndPeaceTeam == iBannorTeamID:
  657.                     pWarAndPeaceTeam.meet(iElohimTeamID, False)
  658.                     pWarAndPeaceTeam.meet(iKuriotatesTeamID, False)
  659.                     pWarAndPeaceTeam.meet(iLjosalfarTeamID, False)
  660.                     pWarAndPeaceTeam.meet(iLuchuirpTeamID, False)
  661.                 if iWarAndPeaceTeam == iElohimTeamID:
  662.                     pWarAndPeaceTeam.meet(iKuriotatesTeamID, False)
  663.                     pWarAndPeaceTeam.meet(iLjosalfarTeamID, False)
  664.                     pWarAndPeaceTeam.meet(iLuchuirpTeamID, False)
  665.                 if iWarAndPeaceTeam == iKuriotatesTeamID:
  666.                     pWarAndPeaceTeam.meet(iLjosalfarTeamID, False)
  667.                     pWarAndPeaceTeam.meet(iLuchuirpTeamID, False)
  668.                 if iWarAndPeaceTeam == iLjosalfarTeamID:
  669.                     pWarAndPeaceTeam.meet(iLuchuirpTeamID, False)
  670.                 #Make evil civs meet other evil civs
  671.                 if iWarAndPeaceTeam == iCalabimTeamID:
  672.                     pWarAndPeaceTeam.meet(iClanOfEmbersTeamID, False)
  673.                     pWarAndPeaceTeam.meet(iDovielloTeamID, False)
  674.                     pWarAndPeaceTeam.meet(iSheaimTeamID, False)
  675.                     pWarAndPeaceTeam.meet(iSvartalfarTeamID, False)
  676.                 if iWarAndPeaceTeam == iClanOfEmbersTeamID:
  677.                     pWarAndPeaceTeam.meet(iDovielloTeamID, False)
  678.                     pWarAndPeaceTeam.meet(iSheaimTeamID, False)
  679.                     pWarAndPeaceTeam.meet(iSvartalfarTeamID, False)
  680.                 if iWarAndPeaceTeam == iDovielloTeamID:
  681.                     pWarAndPeaceTeam.meet(iSheaimTeamID, False)
  682.                     pWarAndPeaceTeam.meet(iSvartalfarTeamID, False)
  683.                 if iWarAndPeaceTeam == iSheaimTeamID:
  684.                     pWarAndPeaceTeam.meet(iSvartalfarTeamID, False)        
  685.                 #This section makes the evils civs at war with the good civs
  686.                 if iWarAndPeaceTeam == iCalabimTeamID:
  687.                     pWarAndPeaceTeam.declareWar(iBannorTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
  688.                     pWarAndPeaceTeam.setPermanentWarPeace(iBannorTeamID, True)
  689.                     pWarAndPeaceTeam.declareWar(iElohimTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
  690.                     pWarAndPeaceTeam.setPermanentWarPeace(iElohimTeamID, True)
  691.                     pWarAndPeaceTeam.declareWar(iKuriotatesTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
  692.                     pWarAndPeaceTeam.setPermanentWarPeace(iKuriotatesTeamID, True)
  693.                     pWarAndPeaceTeam.declareWar(iLjosalfarTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
  694.                     pWarAndPeaceTeam.setPermanentWarPeace(iLjosalfarTeamID, True)
  695.                     pWarAndPeaceTeam.declareWar(iLuchuirpTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
  696.                     pWarAndPeaceTeam.setPermanentWarPeace(iLuchuirpTeamID, True)
  697.                 if iWarAndPeaceTeam == iClanOfEmbersTeamID:
  698.                     pWarAndPeaceTeam.declareWar(iBannorTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
  699.                     pWarAndPeaceTeam.setPermanentWarPeace(iBannorTeamID, True)
  700.                     pWarAndPeaceTeam.declareWar(iElohimTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
  701.                     pWarAndPeaceTeam.setPermanentWarPeace(iElohimTeamID, True)
  702.                     pWarAndPeaceTeam.declareWar(iKuriotatesTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
  703.                     pWarAndPeaceTeam.setPermanentWarPeace(iKuriotatesTeamID, True)
  704.                     pWarAndPeaceTeam.declareWar(iLjosalfarTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
  705.                     pWarAndPeaceTeam.setPermanentWarPeace(iLjosalfarTeamID, True)
  706.                     pWarAndPeaceTeam.declareWar(iLuchuirpTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
  707.                     pWarAndPeaceTeam.setPermanentWarPeace(iLuchuirpTeamID, True)
  708.                 if iWarAndPeaceTeam == iDovielloTeamID:
  709.                     pWarAndPeaceTeam.declareWar(iBannorTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
  710.                     pWarAndPeaceTeam.setPermanentWarPeace(iBannorTeamID, True)
  711.                     pWarAndPeaceTeam.declareWar(iElohimTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
  712.                     pWarAndPeaceTeam.setPermanentWarPeace(iElohimTeamID, True)
  713.                     pWarAndPeaceTeam.declareWar(iKuriotatesTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
  714.                     pWarAndPeaceTeam.setPermanentWarPeace(iKuriotatesTeamID, True)
  715.                     pWarAndPeaceTeam.declareWar(iLjosalfarTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
  716.                     pWarAndPeaceTeam.setPermanentWarPeace(iLjosalfarTeamID, True)
  717.                     pWarAndPeaceTeam.declareWar(iLuchuirpTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
  718.                     pWarAndPeaceTeam.setPermanentWarPeace(iLuchuirpTeamID, True)
  719.                 if iWarAndPeaceTeam == iSheaimTeamID:
  720.                     pWarAndPeaceTeam.declareWar(iBannorTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
  721.                     pWarAndPeaceTeam.setPermanentWarPeace(iBannorTeamID, True)
  722.                     pWarAndPeaceTeam.declareWar(iElohimTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
  723.                     pWarAndPeaceTeam.setPermanentWarPeace(iElohimTeamID, True)
  724.                     pWarAndPeaceTeam.declareWar(iKuriotatesTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
  725.                     pWarAndPeaceTeam.setPermanentWarPeace(iKuriotatesTeamID, True)
  726.                     pWarAndPeaceTeam.declareWar(iLjosalfarTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
  727.                     pWarAndPeaceTeam.setPermanentWarPeace(iLjosalfarTeamID, True)
  728.                     pWarAndPeaceTeam.declareWar(iLuchuirpTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
  729.                     pWarAndPeaceTeam.setPermanentWarPeace(iLuchuirpTeamID, True)
  730.                 if iWarAndPeaceTeam == iSvartalfarTeamID:
  731.                     pWarAndPeaceTeam.declareWar(iBannorTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
  732.                     pWarAndPeaceTeam.setPermanentWarPeace(iBannorTeamID, True)
  733.                     pWarAndPeaceTeam.declareWar(iElohimTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
  734.                     pWarAndPeaceTeam.setPermanentWarPeace(iElohimTeamID, True)
  735.                     pWarAndPeaceTeam.declareWar(iKuriotatesTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
  736.                     pWarAndPeaceTeam.setPermanentWarPeace(iKuriotatesTeamID, True)
  737.                     pWarAndPeaceTeam.declareWar(iLjosalfarTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
  738.                     pWarAndPeaceTeam.setPermanentWarPeace(iLjosalfarTeamID, True)
  739.                     pWarAndPeaceTeam.declareWar(iLuchuirpTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
  740.                     pWarAndPeaceTeam.setPermanentWarPeace(iLuchuirpTeamID, True)
  741.                 #This makes good civs be at peace with good civs
  742.                 if iWarAndPeaceTeam == iBannorTeamID:
  743.                     pWarAndPeaceTeam.setPermanentWarPeace(iElohimTeamID, True)
  744.                     pWarAndPeaceTeam.setPermanentWarPeace(iKuriotatesTeamID, True)
  745.                     pWarAndPeaceTeam.setPermanentWarPeace(iLjosalfarTeamID, True)
  746.                     pWarAndPeaceTeam.setPermanentWarPeace(iLuchuirpTeamID, True)
  747.                 if iWarAndPeaceTeam == iElohimTeamID:
  748.                     pWarAndPeaceTeam.setPermanentWarPeace(iKuriotatesTeamID, True)
  749.                     pWarAndPeaceTeam.setPermanentWarPeace(iLjosalfarTeamID, True)
  750.                     pWarAndPeaceTeam.setPermanentWarPeace(iLuchuirpTeamID, True)
  751.                 if iWarAndPeaceTeam == iKuriotatesTeamID:
  752.                     pWarAndPeaceTeam.setPermanentWarPeace(iLjosalfarTeamID, True)
  753.                     pWarAndPeaceTeam.setPermanentWarPeace(iLuchuirpTeamID, True)
  754.                 if iWarAndPeaceTeam == iLjosalfarTeamID:
  755.                     pWarAndPeaceTeam.setPermanentWarPeace(iLuchuirpTeamID, True)
  756.        
  757.        
  758.         #Try setting the attitudes between evil and good civs at -100 using VOID AI_setAttitudeExtra (PlayerType eIndex, INT iNewValue) and making iNewValue == -100
  759.         #pDovPlayer.AI_setAttitudeExtra(0, 100) makes the Doviello have a +100 attitude with the human player (maybe human player is 0 on eIndex and Doviello player is pDovPlayer)
  760.         #pWarAndPeaceCiv.AI_setAttitudeExtra(iNAMECivID, -100)
  761.         #setAttitude only works in reference to the Player not the Team
  762.         #bPlayer = gc.getPlayer(gc.getBARBARIAN_PLAYER()) will get the barbarian player - can something similar be done to find each good civ and each evil civ?
  763.        
  764.         #This section becomes irrelevant if war is set in python already
  765.         #This gets CivID's for each player firstly
  766.         for iGoodVsEvilPlayer in range(gc.getMAX_PLAYERS()):
  767.             pGoodVsEvilPlayer = gc.getPlayer(iGoodVsEvilPlayer)
  768.             if pGoodVsEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_BANNOR'):
  769.                 iBannorCivID = pGoodVsEvilPlayer.getID()
  770.             if pGoodVsEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_CALABIM'):
  771.                 iCalabimCivID = pGoodVsEvilPlayer.getID()  
  772.             if pGoodVsEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_CLAN_OF_EMBERS'):
  773.                 iClanOfEmbersCivID = pGoodVsEvilPlayer.getID()
  774.             if pGoodVsEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_DOVIELLO'):
  775.                 iDovielloCivID = pGoodVsEvilPlayer.getID() 
  776.             if pGoodVsEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_ELOHIM'):
  777.                 iElohimCivID = pGoodVsEvilPlayer.getID()   
  778.             if pGoodVsEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_KURIOTATES'):
  779.                 iKuriotatesCivID = pGoodVsEvilPlayer.getID()   
  780.             if pGoodVsEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LJOSALFAR'):
  781.                 iLjosalfarCivID = pGoodVsEvilPlayer.getID()
  782.             if pGoodVsEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LUCHUIRP'):
  783.                 iLuchuirpCivID = pGoodVsEvilPlayer.getID() 
  784.             if pGoodVsEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_SHEAIM'):
  785.                 iSheaimCivID = pGoodVsEvilPlayer.getID()   
  786.             if pGoodVsEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_SVARTALFAR'):
  787.                 iSvartalfarCivID = pGoodVsEvilPlayer.getID()   
  788.  
  789.         #This uses those CivID's from above to set negative attitudes between good and evil civs
  790.         #This was done to work out a solution to the AI not building cities issue but it didn't work.  Might be useful for something else though.
  791.         for iGoodVsEvilPlayer2 in range(gc.getMAX_PLAYERS()):
  792.             pGoodVsEvilPlayer2 = gc.getPlayer(iGoodVsEvilPlayer2)
  793.             if pGoodVsEvilPlayer2.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_BANNOR'):
  794.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iCalabimCivID, -100)
  795.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iClanOfEmbersCivID, -100)
  796.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iDovielloCivID, -100)
  797.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iSheaimCivID, -100)
  798.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iSvartalfarCivID, -100)
  799.             if pGoodVsEvilPlayer2.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_CALABIM'):
  800.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iBannorCivID, -100)
  801.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iElohimCivID, -100)
  802.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iKuriotatesCivID, -100)
  803.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iLjosalfarCivID, -100)
  804.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iLuchuirpCivID, -100)
  805.             if pGoodVsEvilPlayer2.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_CLAN_OF_EMBERS'):
  806.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iBannorCivID, -100)
  807.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iElohimCivID, -100)
  808.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iKuriotatesCivID, -100)
  809.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iLjosalfarCivID, -100)
  810.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iLuchuirpCivID, -100)
  811.             if pGoodVsEvilPlayer2.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_DOVIELLO'):
  812.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iBannorCivID, -100)
  813.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iElohimCivID, -100)
  814.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iKuriotatesCivID, -100)
  815.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iLjosalfarCivID, -100)
  816.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iLuchuirpCivID, -100)
  817.             if pGoodVsEvilPlayer2.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_ELOHIM'):
  818.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iCalabimCivID, -100)
  819.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iClanOfEmbersCivID, -100)
  820.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iDovielloCivID, -100)
  821.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iSheaimCivID, -100)
  822.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iSvartalfarCivID, -100)
  823.             if pGoodVsEvilPlayer2.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_KURIOTATES'):
  824.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iCalabimCivID, -100)
  825.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iClanOfEmbersCivID, -100)
  826.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iDovielloCivID, -100)
  827.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iSheaimCivID, -100)
  828.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iSvartalfarCivID, -100)
  829.             if pGoodVsEvilPlayer2.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LJOSALFAR'):
  830.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iCalabimCivID, -100)
  831.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iClanOfEmbersCivID, -100)
  832.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iDovielloCivID, -100)
  833.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iSheaimCivID, -100)
  834.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iSvartalfarCivID, -100)
  835.             if pGoodVsEvilPlayer2.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LUCHUIRP'):
  836.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iCalabimCivID, -100)
  837.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iClanOfEmbersCivID, -100)
  838.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iDovielloCivID, -100)
  839.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iSheaimCivID, -100)
  840.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iSvartalfarCivID, -100)
  841.             if pGoodVsEvilPlayer2.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_SHEAIM'):
  842.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iBannorCivID, -100)
  843.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iElohimCivID, -100)
  844.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iKuriotatesCivID, -100)
  845.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iLjosalfarCivID, -100)
  846.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iLuchuirpCivID, -100)
  847.             if pGoodVsEvilPlayer2.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_SVARTALFAR'):
  848.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iBannorCivID, -100)
  849.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iElohimCivID, -100)
  850.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iKuriotatesCivID, -100)
  851.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iLjosalfarCivID, -100)
  852.                 pGoodVsEvilPlayer2.AI_setAttitudeExtra(iLuchuirpCivID, -100)
  853.  
  854.  
  855.                    
  856.     def onGameEnd(self, argsList):
  857.         'Called at the End of the game'
  858.         print("Game is ending")
  859.         return
  860.  
  861.     def onBeginGameTurn(self, argsList):
  862.         'Called at the beginning of the end of each turn'
  863.         iGameTurn = argsList[0]
  864.  
  865.         if not CyGame().isUnitClassMaxedOut(gc.getInfoTypeForString('UNITCLASS_ORTHUS'), 0):
  866.             if not CyGame().isOption(gc.getInfoTypeForString('GAMEOPTION_NO_ORTHUS')):
  867.                 iOrthusTurn = 75
  868.                 bOrthus = False
  869.                 if CyGame().getGameSpeedType() == gc.getInfoTypeForString('GAMESPEED_QUICK'):
  870.                     if iGameTurn >= iOrthusTurn / 3 * 2:
  871.                         bOrthus = True
  872.                 elif CyGame().getGameSpeedType() == gc.getInfoTypeForString('GAMESPEED_NORMAL'):
  873.                     if iGameTurn >= iOrthusTurn:
  874.                         bOrthus = True
  875.                 elif CyGame().getGameSpeedType() == gc.getInfoTypeForString('GAMESPEED_EPIC'):
  876.                     if iGameTurn >= iOrthusTurn * 3 / 2:
  877.                         bOrthus = True
  878.                 elif CyGame().getGameSpeedType() == gc.getInfoTypeForString('GAMESPEED_MARATHON'):
  879.                     if iGameTurn >= iOrthusTurn * 3:
  880.                         bOrthus = True
  881.                 if bOrthus:
  882.                     bValid=True
  883.                     for i in range (CyMap().numPlots()):
  884.                         pPlot = CyMap().plotByIndex(i)
  885.                         iPlot = -1
  886.                         if pPlot.getImprovementType()==gc.getInfoTypeForString('IMPROVEMENT_GOBLIN_FORT'):
  887.                             bPlayer = gc.getPlayer(gc.getBARBARIAN_PLAYER())
  888.                             if not pPlot.isVisibleOtherUnit(gc.getBARBARIAN_PLAYER()):
  889.                                 bPlayer.initUnit(gc.getInfoTypeForString('UNIT_ORTHUS'), pPlot.getX(), pPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
  890.                                 bValid=False
  891.                                 break
  892.                     if bValid:
  893.                         iUnit = gc.getInfoTypeForString('UNIT_ORTHUS')
  894.                         cf.addUnit(iUnit)
  895.                         if( CyGame().getAIAutoPlay(CyGame().getActivePlayer()) == 0 ) :
  896.                             cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_ORTHUS_CREATION",()), str(gc.getUnitInfo(iUnit).getImage()))
  897.  
  898.         if not CyGame().isOption(gc.getInfoTypeForString('GAMEOPTION_NO_PLOT_COUNTER')):
  899.             cf.doHellTerrain()
  900.  
  901.         if CyGame().getWBMapScript():
  902.             sf.doTurn()
  903.  
  904. # FfH Card Game: begin
  905.         cs.doTurn()
  906. # FfH Card Game: end
  907.  
  908.         Blizzards.doBlizzardTurn()      #Added in Blizzards: TC01
  909.        
  910. #       if( CyGame().getAIAutoPlay(self) == 0 ) :
  911.         if( game.getAIAutoPlay(game.getActivePlayer()) == 0 ) :
  912.             CvTopCivs.CvTopCivs().turnChecker(iGameTurn)
  913.            
  914.        
  915.         #Check if each evil team is alive and if so, add 0.1 to the AC
  916.         #Check if Luchuirp have turned evil (maybe by checking if they are at war with Elohim) and if they are alive and if so, add 0.5 to the AC
  917.         #   if gc.getTeam(iLuchuirpTeamID).isAlive:
  918.         #       if gc.getTeam(iLuchuirpTeamID).isAtWar(iElohimTeamID):
  919.        
  920.         #Makes the human Elohim player win if the AC = 0, #2 is a conquest victory (change this to the diplo victory). Also make Elohim win if a complete conquest victory is achieved.
  921.         iElohimPlayer = 0
  922.         pElohimPlayer = gc.getPlayer(iElohimPlayer)
  923.         if CyGame().getGlobalCounter() <= 0:
  924.             gc.getGame().setWinner(pElohimPlayer.getTeam(), 6)
  925.            
  926.         #Debug to test if the victory condition is working
  927.         #CyGame().changeGlobalCounter(-2)
  928.        
  929.        
  930.         #I need to redo the teamID's because they are forgotten from onGameStart
  931.         for iGoodAndEvilPlayer in range(gc.getMAX_PLAYERS()):
  932.             pGoodAndEvilPlayer = gc.getPlayer(iGoodAndEvilPlayer)
  933.             #if pGoodAndEvilPlayer.isAlive(): #This line breaks the code
  934.             if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_BANNOR'):
  935.                 iBannorTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  936.                 iBannorPower = gc.getTeam(iBannorTeamID).getPower(True)
  937.             if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_CALABIM'):
  938.                 iCalabimTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  939.             if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_CLAN_OF_EMBERS'):
  940.                 iClanOfEmbersTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  941.             if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_DOVIELLO'):
  942.                 iDovielloTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  943.             if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_ELOHIM'):
  944.                 iElohimTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  945.                 iElohimPower = gc.getTeam(iElohimTeamID).getPower(True)
  946.             if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_KURIOTATES'):
  947.                 iKuriotatesTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  948.                 iKuriotatesPower = gc.getTeam(iKuriotatesTeamID).getPower(True)
  949.             if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LJOSALFAR'):
  950.                 iLjosalfarTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  951.                 iLjosalfarPower = gc.getTeam(iLjosalfarTeamID).getPower(True)
  952.             if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LUCHUIRP'):
  953.                 iLuchuirpTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  954.                 iLuchuirpPower = gc.getTeam(iLuchuirpTeamID).getPower(True)
  955.             if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_SHEAIM'):
  956.                 iSheaimTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  957.             if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_SVARTALFAR'):
  958.                 iSvartalfarTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  959.  
  960.                
  961.        
  962.         #Increase the AC for each evil civ alive (and slightly more if Luchuirp have turned evil)
  963.         #Has a 1 in 22 chance of increasing the AC by 1 point each turn (the AC is an integer only)
  964.         if gc.getTeam(iCalabimTeamID).isAlive:
  965.             if CyGame().getSorenRandNum(22, "CalabimAC") <= 1:
  966.                 CyGame().changeGlobalCounter(1)
  967.         if gc.getTeam(iClanOfEmbersTeamID).isAlive:            
  968.             if CyGame().getSorenRandNum(22, "ClanOfEmbersAC") <= 1:
  969.                 CyGame().changeGlobalCounter(1)
  970.         if gc.getTeam(iDovielloTeamID).isAlive:            
  971.             if CyGame().getSorenRandNum(22, "DovielloAC") <= 1:
  972.                 CyGame().changeGlobalCounter(1)
  973.         if gc.getTeam(iSheaimTeamID).isAlive:              
  974.             if CyGame().getSorenRandNum(22, "SheaimAC") <= 1:
  975.                 CyGame().changeGlobalCounter(1)
  976.         if gc.getTeam(iSvartalfarTeamID).isAlive:              
  977.             if CyGame().getSorenRandNum(22, "SvartalfarAC") <= 1:
  978.                 CyGame().changeGlobalCounter(1)
  979.         if gc.getTeam(iLuchuirpTeamID).isAtWar(iElohimTeamID):
  980.             if CyGame().getSorenRandNum(22, "LuchuirpWarAC") <= 2:
  981.                 CyGame().changeGlobalCounter(1)        
  982.                
  983.        
  984.         #If the civ isn't alive then the score won't be defined and therefore will cause an error when used
  985.         if not gc.getTeam(iLuchuirpTeamID).isAlive:
  986.             iLuchuirpPower = 0
  987.         if not gc.getTeam(iBannorTeamID).isAlive:
  988.             iBannorPower = 0
  989.         if not gc.getTeam(iElohimTeamID).isAlive:
  990.             iElohimPower = 0
  991.         if not gc.getTeam(iKuriotatesTeamID).isAlive:
  992.             iKuriotatesPower = 0
  993.         if not gc.getTeam(iLjosalfarTeamID).isAlive:
  994.             iLjosalfarPower = 0
  995.            
  996.            
  997.        
  998.         #Make the Luchuirp declare war on the other good civs if the Luchuirp power > (Elohim + Ljosalfar + Kuriotates + Bannor) power
  999.         #Elohim will always be alive while the game is running since that is the player
  1000.         #If the setPermanentWarPeace boolean is True then the civs cannot change their peace or war status.  Use declareWar first to keep them at war with the True boolean.
  1001.         #If the declareWar boolean is True then you get a pop-up message that the civ declares war on you, if it is False then there is no pop-up message
  1002.         if gc.getTeam(iLuchuirpTeamID).isAlive:
  1003.             if not gc.getTeam(iLuchuirpTeamID).isAtWar(iElohimTeamID):
  1004.                 if iLuchuirpPower > (iBannorPower + iElohimPower + iKuriotatesPower + iLjosalfarPower):
  1005.                     sf.addPopupWB(CyTranslator().getText("TXT_KEY_WB_ELOHIM_SCENARIO_LUCHUIRP_WAR_GOOD",()),'')
  1006.                     for iWarAndPeaceTeam in range(gc.getMAX_CIV_TEAMS()):
  1007.                         pWarAndPeaceTeam = gc.getTeam(iWarAndPeaceTeam)
  1008.                         if pWarAndPeaceTeam.isAlive():
  1009.                             if iWarAndPeaceTeam == iLuchuirpTeamID:
  1010.                                 pWarAndPeaceTeam.setPermanentWarPeace(iBannorTeamID, False)
  1011.                                 pWarAndPeaceTeam.declareWar(iBannorTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
  1012.                                 pWarAndPeaceTeam.setPermanentWarPeace(iBannorTeamID, True)
  1013.                                 pWarAndPeaceTeam.setPermanentWarPeace(iElohimTeamID, False)
  1014.                                 pWarAndPeaceTeam.declareWar(iElohimTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
  1015.                                 pWarAndPeaceTeam.setPermanentWarPeace(iElohimTeamID, True)
  1016.                                 pWarAndPeaceTeam.setPermanentWarPeace(iKuriotatesTeamID, False)
  1017.                                 pWarAndPeaceTeam.declareWar(iKuriotatesTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
  1018.                                 pWarAndPeaceTeam.setPermanentWarPeace(iKuriotatesTeamID, True)
  1019.                                 pWarAndPeaceTeam.setPermanentWarPeace(iLjosalfarTeamID, False)
  1020.                                 pWarAndPeaceTeam.declareWar(iLjosalfarTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
  1021.                                 pWarAndPeaceTeam.setPermanentWarPeace(iLjosalfarTeamID, True)
  1022.            
  1023.  
  1024.            
  1025.         #Marshalling tile = (59,11)
  1026.         #Target tile = (16,10)
  1027.         #Move SoD units to marshalling tile from Turn 200-300
  1028.         #Move SoD units from mashalling tile to target tile from Turn 300-350
  1029.        
  1030.         #SoD promotion is given to units built within a certain time period in onUnitBuilt
  1031.        
  1032.         #Get rid of HELD promotion for all SoD units once they reach the target tile because SoD's not in the stack get stuck on the way to the marshalling point!#
  1033.         #This may cause bugs if new cities are made etc - maybe change to checking what turn it is?
  1034.         #This code moves the SoD units from the cities to the marshalling tile#
  1035.         #Maybe just get rid of the HELD promotion if it tries to move into an illegal tile instead of trying to move it around#
  1036.         #Change lines 1037, 1808, 1822, 2380, 2422, 2446, 2455, 3650, 3677
  1037.         if iGameTurn < 60 and iGameTurn > 10:
  1038.             for iGoodSofDPlayer in range(gc.getMAX_PLAYERS()):
  1039.                 pGoodSofDPlayer = gc.getPlayer(iGoodSofDPlayer)
  1040.                 if (pGoodSofDPlayer.isAlive()):
  1041.                     if pGoodSofDPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_BANNOR'):
  1042.                         pySofD = PyPlayer(iGoodSofDPlayer)
  1043.                         if pGoodSofDPlayer.getNumUnits() > 0:
  1044.                             for pMayMoveUnit in pySofD.getUnitList():
  1045.                                 if pMayMoveUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_SofD')):
  1046.                                     iSoDUnitMoved = 0
  1047.                                     if pMayMoveUnit.getY() < 11:
  1048.                                         pMayMoveUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), True)
  1049.                                         if pMayMoveUnit.getX() < 59 and iSoDUnitMoved == 0:
  1050.                                             pPossiblePlot = CyMap().plot(pMayMoveUnit.getX() + 1, pMayMoveUnit.getY() + 1)
  1051.                                             if pMayMoveUnit.canMoveInto(pPossiblePlot, False, True, False):
  1052.                                                 if pPossiblePlot.getNumUnits() > 0:
  1053.                                                     for iPossibleEnemy in range(pPossiblePlot.getNumUnits()):
  1054.                                                         pOtherUnitOwner = pPossiblePlot.getUnit(iPossibleEnemy).getOwner()
  1055.                                                         iOtherUnitTeam = gc.getTeam(pOtherUnitOwner)
  1056.                                                         if iOtherUnitTeam.isBarbarian() == True:
  1057.                                                             iSoDUnitMoved = 1
  1058.                                                         if iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1059.                                                                 iSoDUnitMoved = 1
  1060.                                                         if not iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1061.                                                                 pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1062.                                                                 iSoDUnitMoved = 1
  1063.                                                 if pPossiblePlot.getNumUnits() == 0:
  1064.                                                     pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1065.                                                     iSoDUnitMoved = 1                                          
  1066.                                                 #War is done by team so either don't keep moving if another unit is there or find the Elohim team and find the other unit's team
  1067.                                                 #Elohim team ID is always 0 because it is the human player
  1068.                                                 #War with Elohim is used as a proxy for war with any of the other good civs
  1069.                                         if pMayMoveUnit.getX() > 59 and iSoDUnitMoved == 0:
  1070.                                             pPossiblePlot = CyMap().plot(pMayMoveUnit.getX() - 1, pMayMoveUnit.getY() + 1)
  1071.                                             if pMayMoveUnit.canMoveInto(pPossiblePlot, False, True, False):
  1072.                                                 if pPossiblePlot.getNumUnits() > 0:
  1073.                                                     for iPossibleEnemy in range(pPossiblePlot.getNumUnits()):
  1074.                                                         pOtherUnitOwner = pPossiblePlot.getUnit(iPossibleEnemy).getOwner()
  1075.                                                         iOtherUnitTeam = gc.getTeam(pOtherUnitOwner)
  1076.                                                         if iOtherUnitTeam.isBarbarian() == True:
  1077.                                                             iSoDUnitMoved = 1
  1078.                                                         if iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1079.                                                                 iSoDUnitMoved = 1
  1080.                                                         if not iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1081.                                                                 pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1082.                                                                 iSoDUnitMoved = 1
  1083.                                                 if pPossiblePlot.getNumUnits() == 0:                                           
  1084.                                                     pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1085.                                                     iSoDUnitMoved = 1
  1086.                                         if pMayMoveUnit.getX() == 59 and iSoDUnitMoved == 0:
  1087.                                             pPossiblePlot = CyMap().plot(pMayMoveUnit.getX(), pMayMoveUnit.getY() + 1)
  1088.                                             if pMayMoveUnit.canMoveInto(pPossiblePlot, False, True, False):
  1089.                                                 if pPossiblePlot.getNumUnits() > 0:
  1090.                                                     for iPossibleEnemy in range(pPossiblePlot.getNumUnits()):
  1091.                                                         pOtherUnitOwner = pPossiblePlot.getUnit(iPossibleEnemy).getOwner()
  1092.                                                         iOtherUnitTeam = gc.getTeam(pOtherUnitOwner)
  1093.                                                         if iOtherUnitTeam.isBarbarian() == True:
  1094.                                                             iSoDUnitMoved = 1
  1095.                                                         if iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1096.                                                                 iSoDUnitMoved = 1
  1097.                                                         if not iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1098.                                                                 pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1099.                                                                 iSoDUnitMoved = 1
  1100.                                                 if pPossiblePlot.getNumUnits() == 0:                                           
  1101.                                                     pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1102.                                                     iSoDUnitMoved = 1                                              
  1103.                                     if pMayMoveUnit.getY() > 11:
  1104.                                         pMayMoveUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), True)
  1105.                                         if pMayMoveUnit.getX() < 59 and iSoDUnitMoved == 0:
  1106.                                             pPossiblePlot = CyMap().plot(pMayMoveUnit.getX() + 1, pMayMoveUnit.getY() - 1)
  1107.                                             if pMayMoveUnit.canMoveInto(pPossiblePlot, False, True, False):
  1108.                                                 if pPossiblePlot.getNumUnits() > 0:
  1109.                                                     for iPossibleEnemy in range(pPossiblePlot.getNumUnits()):
  1110.                                                         pOtherUnitOwner = pPossiblePlot.getUnit(iPossibleEnemy).getOwner()
  1111.                                                         iOtherUnitTeam = gc.getTeam(pOtherUnitOwner)
  1112.                                                         if iOtherUnitTeam.isBarbarian() == True:
  1113.                                                             iSoDUnitMoved = 1
  1114.                                                         if iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1115.                                                                 iSoDUnitMoved = 1
  1116.                                                         if not iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1117.                                                                 pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1118.                                                                 iSoDUnitMoved = 1
  1119.                                                 if pPossiblePlot.getNumUnits() == 0:                                           
  1120.                                                     pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)  
  1121.                                                     iSoDUnitMoved = 1
  1122.                                         if pMayMoveUnit.getX() > 59 and iSoDUnitMoved == 0:
  1123.                                             pPossiblePlot = CyMap().plot(pMayMoveUnit.getX() - 1, pMayMoveUnit.getY() - 1)
  1124.                                             if pMayMoveUnit.canMoveInto(pPossiblePlot, False, True, False):
  1125.                                                 if pPossiblePlot.getNumUnits() > 0:
  1126.                                                     for iPossibleEnemy in range(pPossiblePlot.getNumUnits()):
  1127.                                                         pOtherUnitOwner = pPossiblePlot.getUnit(iPossibleEnemy).getOwner()
  1128.                                                         iOtherUnitTeam = gc.getTeam(pOtherUnitOwner)
  1129.                                                         if iOtherUnitTeam.isBarbarian() == True:
  1130.                                                             iSoDUnitMoved = 1
  1131.                                                         if iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1132.                                                                 iSoDUnitMoved = 1
  1133.                                                         if not iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1134.                                                                 pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1135.                                                                 iSoDUnitMoved = 1
  1136.                                                 if pPossiblePlot.getNumUnits() == 0:                                           
  1137.                                                     pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)  
  1138.                                                     iSoDUnitMoved = 1
  1139.                                         if pMayMoveUnit.getX() == 59 and iSoDUnitMoved == 0:
  1140.                                             pPossiblePlot = CyMap().plot(pMayMoveUnit.getX(), pMayMoveUnit.getY() - 1)
  1141.                                             if pMayMoveUnit.canMoveInto(pPossiblePlot, False, True, False):
  1142.                                                 if pPossiblePlot.getNumUnits() > 0:
  1143.                                                     for iPossibleEnemy in range(pPossiblePlot.getNumUnits()):
  1144.                                                         pOtherUnitOwner = pPossiblePlot.getUnit(iPossibleEnemy).getOwner()
  1145.                                                         iOtherUnitTeam = gc.getTeam(pOtherUnitOwner)
  1146.                                                         if iOtherUnitTeam.isBarbarian() == True:
  1147.                                                             iSoDUnitMoved = 1
  1148.                                                         if iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1149.                                                                 iSoDUnitMoved = 1
  1150.                                                         if not iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1151.                                                                 pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1152.                                                                 iSoDUnitMoved = 1
  1153.                                                 if pPossiblePlot.getNumUnits() == 0:                                           
  1154.                                                     pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1155.                                                     iSoDUnitMoved = 1
  1156.                                     if pMayMoveUnit.getY() == 11:
  1157.                                         pMayMoveUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), True)
  1158.                                         if pMayMoveUnit.getX() < 59 and iSoDUnitMoved == 0:
  1159.                                             pPossiblePlot = CyMap().plot(pMayMoveUnit.getX() + 1, pMayMoveUnit.getY())
  1160.                                             if pMayMoveUnit.canMoveInto(pPossiblePlot, False, True, False):
  1161.                                                 if pPossiblePlot.getNumUnits() > 0:
  1162.                                                     for iPossibleEnemy in range(pPossiblePlot.getNumUnits()):
  1163.                                                         pOtherUnitOwner = pPossiblePlot.getUnit(iPossibleEnemy).getOwner()
  1164.                                                         iOtherUnitTeam = gc.getTeam(pOtherUnitOwner)
  1165.                                                         if iOtherUnitTeam.isBarbarian() == True:
  1166.                                                             iSoDUnitMoved = 1
  1167.                                                         if iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1168.                                                                 iSoDUnitMoved = 1
  1169.                                                         if not iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1170.                                                                 pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1171.                                                                 iSoDUnitMoved = 1
  1172.                                                 if pPossiblePlot.getNumUnits() == 0:                                           
  1173.                                                     pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)  
  1174.                                                     iSoDUnitMoved = 1
  1175.                                         if pMayMoveUnit.getX() > 59 and iSoDUnitMoved == 0:
  1176.                                             pPossiblePlot = CyMap().plot(pMayMoveUnit.getX() - 1, pMayMoveUnit.getY())
  1177.                                             if pMayMoveUnit.canMoveInto(pPossiblePlot, False, True, False):
  1178.                                                 if pPossiblePlot.getNumUnits() > 0:
  1179.                                                     for iPossibleEnemy in range(pPossiblePlot.getNumUnits()):
  1180.                                                         pOtherUnitOwner = pPossiblePlot.getUnit(iPossibleEnemy).getOwner()
  1181.                                                         iOtherUnitTeam = gc.getTeam(pOtherUnitOwner)
  1182.                                                         if iOtherUnitTeam.isBarbarian() == True:
  1183.                                                             iSoDUnitMoved = 1
  1184.                                                         if iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1185.                                                                 iSoDUnitMoved = 1
  1186.                                                         if not iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1187.                                                                 pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1188.                                                                 iSoDUnitMoved = 1
  1189.                                                 if pPossiblePlot.getNumUnits() == 0:                                           
  1190.                                                     pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1191.                                                     iSoDUnitMoved = 1
  1192.                     if pGoodSofDPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_ELOHIM'):
  1193.                         pySofD = PyPlayer(iGoodSofDPlayer)
  1194.                         if pGoodSofDPlayer.getNumUnits() > 0:
  1195.                             for pMayMoveUnit in pySofD.getUnitList():
  1196.                                 if pMayMoveUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_SofD')):
  1197.                                     iSoDUnitMoved = 0
  1198.                                     if pMayMoveUnit.getY() < 11:
  1199.                                         pMayMoveUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), True)
  1200.                                         if pMayMoveUnit.getX() < 59 and iSoDUnitMoved == 0:
  1201.                                             pPossiblePlot = CyMap().plot(pMayMoveUnit.getX() + 1, pMayMoveUnit.getY() + 1)
  1202.                                             if pMayMoveUnit.canMoveInto(pPossiblePlot, False, True, False):
  1203.                                                 if pPossiblePlot.getNumUnits() > 0:
  1204.                                                     for iPossibleEnemy in range(pPossiblePlot.getNumUnits()):
  1205.                                                         pOtherUnitOwner = pPossiblePlot.getUnit(iPossibleEnemy).getOwner()
  1206.                                                         iOtherUnitTeam = gc.getTeam(pOtherUnitOwner)
  1207.                                                         if iOtherUnitTeam.isBarbarian() == True:
  1208.                                                             iSoDUnitMoved = 1
  1209.                                                         if iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1210.                                                                 iSoDUnitMoved = 1
  1211.                                                         if not iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1212.                                                                 pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1213.                                                                 iSoDUnitMoved = 1
  1214.                                                 if pPossiblePlot.getNumUnits() == 0:
  1215.                                                     pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1216.                                                     iSoDUnitMoved = 1                                          
  1217.                                                 #War is done by team so either don't keep moving if another unit is there or find the Elohim team and find the other unit's team
  1218.                                                 #Elohim team ID is always 0 because it is the human player
  1219.                                                 #War with Elohim is used as a proxy for war with any of the other good civs
  1220.                                         if pMayMoveUnit.getX() > 59 and iSoDUnitMoved == 0:
  1221.                                             pPossiblePlot = CyMap().plot(pMayMoveUnit.getX() - 1, pMayMoveUnit.getY() + 1)
  1222.                                             if pMayMoveUnit.canMoveInto(pPossiblePlot, False, True, False):
  1223.                                                 if pPossiblePlot.getNumUnits() > 0:
  1224.                                                     for iPossibleEnemy in range(pPossiblePlot.getNumUnits()):
  1225.                                                         pOtherUnitOwner = pPossiblePlot.getUnit(iPossibleEnemy).getOwner()
  1226.                                                         iOtherUnitTeam = gc.getTeam(pOtherUnitOwner)
  1227.                                                         if iOtherUnitTeam.isBarbarian() == True:
  1228.                                                             iSoDUnitMoved = 1
  1229.                                                         if iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1230.                                                                 iSoDUnitMoved = 1
  1231.                                                         if not iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1232.                                                                 pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1233.                                                                 iSoDUnitMoved = 1
  1234.                                                 if pPossiblePlot.getNumUnits() == 0:                                           
  1235.                                                     pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1236.                                                     iSoDUnitMoved = 1
  1237.                                         if pMayMoveUnit.getX() == 59 and iSoDUnitMoved == 0:
  1238.                                             pPossiblePlot = CyMap().plot(pMayMoveUnit.getX(), pMayMoveUnit.getY() + 1)
  1239.                                             if pMayMoveUnit.canMoveInto(pPossiblePlot, False, True, False):
  1240.                                                 if pPossiblePlot.getNumUnits() > 0:
  1241.                                                     for iPossibleEnemy in range(pPossiblePlot.getNumUnits()):
  1242.                                                         pOtherUnitOwner = pPossiblePlot.getUnit(iPossibleEnemy).getOwner()
  1243.                                                         iOtherUnitTeam = gc.getTeam(pOtherUnitOwner)
  1244.                                                         if iOtherUnitTeam.isBarbarian() == True:
  1245.                                                             iSoDUnitMoved = 1
  1246.                                                         if iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1247.                                                                 iSoDUnitMoved = 1
  1248.                                                         if not iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1249.                                                                 pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1250.                                                                 iSoDUnitMoved = 1
  1251.                                                 if pPossiblePlot.getNumUnits() == 0:                                           
  1252.                                                     pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1253.                                                     iSoDUnitMoved = 1                                              
  1254.                                     if pMayMoveUnit.getY() > 11:
  1255.                                         pMayMoveUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), True)
  1256.                                         if pMayMoveUnit.getX() < 59 and iSoDUnitMoved == 0:
  1257.                                             pPossiblePlot = CyMap().plot(pMayMoveUnit.getX() + 1, pMayMoveUnit.getY() - 1)
  1258.                                             if pMayMoveUnit.canMoveInto(pPossiblePlot, False, True, False):
  1259.                                                 if pPossiblePlot.getNumUnits() > 0:
  1260.                                                     for iPossibleEnemy in range(pPossiblePlot.getNumUnits()):
  1261.                                                         pOtherUnitOwner = pPossiblePlot.getUnit(iPossibleEnemy).getOwner()
  1262.                                                         iOtherUnitTeam = gc.getTeam(pOtherUnitOwner)
  1263.                                                         if iOtherUnitTeam.isBarbarian() == True:
  1264.                                                             iSoDUnitMoved = 1
  1265.                                                         if iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1266.                                                                 iSoDUnitMoved = 1
  1267.                                                         if not iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1268.                                                                 pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1269.                                                                 iSoDUnitMoved = 1
  1270.                                                 if pPossiblePlot.getNumUnits() == 0:                                           
  1271.                                                     pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)  
  1272.                                                     iSoDUnitMoved = 1
  1273.                                         if pMayMoveUnit.getX() > 59 and iSoDUnitMoved == 0:
  1274.                                             pPossiblePlot = CyMap().plot(pMayMoveUnit.getX() - 1, pMayMoveUnit.getY() - 1)
  1275.                                             if pMayMoveUnit.canMoveInto(pPossiblePlot, False, True, False):
  1276.                                                 if pPossiblePlot.getNumUnits() > 0:
  1277.                                                     for iPossibleEnemy in range(pPossiblePlot.getNumUnits()):
  1278.                                                         pOtherUnitOwner = pPossiblePlot.getUnit(iPossibleEnemy).getOwner()
  1279.                                                         iOtherUnitTeam = gc.getTeam(pOtherUnitOwner)
  1280.                                                         if iOtherUnitTeam.isBarbarian() == True:
  1281.                                                             iSoDUnitMoved = 1
  1282.                                                         if iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1283.                                                                 iSoDUnitMoved = 1
  1284.                                                         if not iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1285.                                                                 pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1286.                                                                 iSoDUnitMoved = 1
  1287.                                                 if pPossiblePlot.getNumUnits() == 0:                                           
  1288.                                                     pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)  
  1289.                                                     iSoDUnitMoved = 1
  1290.                                         if pMayMoveUnit.getX() == 59 and iSoDUnitMoved == 0:
  1291.                                             pPossiblePlot = CyMap().plot(pMayMoveUnit.getX(), pMayMoveUnit.getY() - 1)
  1292.                                             if pMayMoveUnit.canMoveInto(pPossiblePlot, False, True, False):
  1293.                                                 if pPossiblePlot.getNumUnits() > 0:
  1294.                                                     for iPossibleEnemy in range(pPossiblePlot.getNumUnits()):
  1295.                                                         pOtherUnitOwner = pPossiblePlot.getUnit(iPossibleEnemy).getOwner()
  1296.                                                         iOtherUnitTeam = gc.getTeam(pOtherUnitOwner)
  1297.                                                         if iOtherUnitTeam.isBarbarian() == True:
  1298.                                                             iSoDUnitMoved = 1
  1299.                                                         if iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1300.                                                                 iSoDUnitMoved = 1
  1301.                                                         if not iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1302.                                                                 pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1303.                                                                 iSoDUnitMoved = 1
  1304.                                                 if pPossiblePlot.getNumUnits() == 0:                                           
  1305.                                                     pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1306.                                                     iSoDUnitMoved = 1
  1307.                                     if pMayMoveUnit.getY() == 11:
  1308.                                         pMayMoveUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), True)
  1309.                                         if pMayMoveUnit.getX() < 59 and iSoDUnitMoved == 0:
  1310.                                             pPossiblePlot = CyMap().plot(pMayMoveUnit.getX() + 1, pMayMoveUnit.getY())
  1311.                                             if pMayMoveUnit.canMoveInto(pPossiblePlot, False, True, False):
  1312.                                                 if pPossiblePlot.getNumUnits() > 0:
  1313.                                                     for iPossibleEnemy in range(pPossiblePlot.getNumUnits()):
  1314.                                                         pOtherUnitOwner = pPossiblePlot.getUnit(iPossibleEnemy).getOwner()
  1315.                                                         iOtherUnitTeam = gc.getTeam(pOtherUnitOwner)
  1316.                                                         if iOtherUnitTeam.isBarbarian() == True:
  1317.                                                             iSoDUnitMoved = 1
  1318.                                                         if iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1319.                                                                 iSoDUnitMoved = 1
  1320.                                                         if not iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1321.                                                                 pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1322.                                                                 iSoDUnitMoved = 1
  1323.                                                 if pPossiblePlot.getNumUnits() == 0:                                           
  1324.                                                     pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)  
  1325.                                                     iSoDUnitMoved = 1
  1326.                                         if pMayMoveUnit.getX() > 59 and iSoDUnitMoved == 0:
  1327.                                             pPossiblePlot = CyMap().plot(pMayMoveUnit.getX() - 1, pMayMoveUnit.getY())
  1328.                                             if pMayMoveUnit.canMoveInto(pPossiblePlot, False, True, False):
  1329.                                                 if pPossiblePlot.getNumUnits() > 0:
  1330.                                                     for iPossibleEnemy in range(pPossiblePlot.getNumUnits()):
  1331.                                                         pOtherUnitOwner = pPossiblePlot.getUnit(iPossibleEnemy).getOwner()
  1332.                                                         iOtherUnitTeam = gc.getTeam(pOtherUnitOwner)
  1333.                                                         if iOtherUnitTeam.isBarbarian() == True:
  1334.                                                             iSoDUnitMoved = 1
  1335.                                                         if iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1336.                                                                 iSoDUnitMoved = 1
  1337.                                                         if not iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1338.                                                                 pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1339.                                                                 iSoDUnitMoved = 1
  1340.                                                 if pPossiblePlot.getNumUnits() == 0:                                           
  1341.                                                     pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1342.                                                     iSoDUnitMoved = 1
  1343.                     if pGoodSofDPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_KURIOTATES'):
  1344.                         pySofD = PyPlayer(iGoodSofDPlayer)
  1345.                         if pGoodSofDPlayer.getNumUnits() > 0:
  1346.                             for pMayMoveUnit in pySofD.getUnitList():
  1347.                                 if pMayMoveUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_SofD')):
  1348.                                     iSoDUnitMoved = 0
  1349.                                     if pMayMoveUnit.getY() < 11:
  1350.                                         pMayMoveUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), True)
  1351.                                         if pMayMoveUnit.getX() < 59 and iSoDUnitMoved == 0:
  1352.                                             pPossiblePlot = CyMap().plot(pMayMoveUnit.getX() + 1, pMayMoveUnit.getY() + 1)
  1353.                                             if pMayMoveUnit.canMoveInto(pPossiblePlot, False, True, False):
  1354.                                                 if pPossiblePlot.getNumUnits() > 0:
  1355.                                                     for iPossibleEnemy in range(pPossiblePlot.getNumUnits()):
  1356.                                                         pOtherUnitOwner = pPossiblePlot.getUnit(iPossibleEnemy).getOwner()
  1357.                                                         iOtherUnitTeam = gc.getTeam(pOtherUnitOwner)
  1358.                                                         if iOtherUnitTeam.isBarbarian() == True:
  1359.                                                             iSoDUnitMoved = 1
  1360.                                                         if iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1361.                                                                 iSoDUnitMoved = 1
  1362.                                                         if not iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1363.                                                                 pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1364.                                                                 iSoDUnitMoved = 1
  1365.                                                 if pPossiblePlot.getNumUnits() == 0:
  1366.                                                     pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1367.                                                     iSoDUnitMoved = 1                                          
  1368.                                                 #War is done by team so either don't keep moving if another unit is there or find the Elohim team and find the other unit's team
  1369.                                                 #Elohim team ID is always 0 because *I THINK* it is the human player (maybe team 0 is the barbarian player?)
  1370.                                                 #War with Elohim is used as a proxy for war with any of the other good civs
  1371.                                         if pMayMoveUnit.getX() > 59 and iSoDUnitMoved == 0:
  1372.                                             pPossiblePlot = CyMap().plot(pMayMoveUnit.getX() - 1, pMayMoveUnit.getY() + 1)
  1373.                                             if pMayMoveUnit.canMoveInto(pPossiblePlot, False, True, False):
  1374.                                                 if pPossiblePlot.getNumUnits() > 0:
  1375.                                                     for iPossibleEnemy in range(pPossiblePlot.getNumUnits()):
  1376.                                                         pOtherUnitOwner = pPossiblePlot.getUnit(iPossibleEnemy).getOwner()
  1377.                                                         iOtherUnitTeam = gc.getTeam(pOtherUnitOwner)
  1378.                                                         if iOtherUnitTeam.isBarbarian() == True:
  1379.                                                             iSoDUnitMoved = 1
  1380.                                                         if iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1381.                                                                 iSoDUnitMoved = 1
  1382.                                                         if not iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1383.                                                                 pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1384.                                                                 iSoDUnitMoved = 1
  1385.                                                 if pPossiblePlot.getNumUnits() == 0:                                           
  1386.                                                     pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1387.                                                     iSoDUnitMoved = 1
  1388.                                         if pMayMoveUnit.getX() == 59 and iSoDUnitMoved == 0:
  1389.                                             pPossiblePlot = CyMap().plot(pMayMoveUnit.getX(), pMayMoveUnit.getY() + 1)
  1390.                                             if pMayMoveUnit.canMoveInto(pPossiblePlot, False, True, False):
  1391.                                                 if pPossiblePlot.getNumUnits() > 0:
  1392.                                                     for iPossibleEnemy in range(pPossiblePlot.getNumUnits()):
  1393.                                                         pOtherUnitOwner = pPossiblePlot.getUnit(iPossibleEnemy).getOwner()
  1394.                                                         iOtherUnitTeam = gc.getTeam(pOtherUnitOwner)
  1395.                                                         if iOtherUnitTeam.isBarbarian() == True:
  1396.                                                             iSoDUnitMoved = 1
  1397.                                                         if iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1398.                                                                 iSoDUnitMoved = 1
  1399.                                                         if not iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1400.                                                                 pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1401.                                                                 iSoDUnitMoved = 1
  1402.                                                 if pPossiblePlot.getNumUnits() == 0:                                           
  1403.                                                     pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1404.                                                     iSoDUnitMoved = 1                                              
  1405.                                     if pMayMoveUnit.getY() > 11:
  1406.                                         pMayMoveUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), True)
  1407.                                         if pMayMoveUnit.getX() < 59 and iSoDUnitMoved == 0:
  1408.                                             pPossiblePlot = CyMap().plot(pMayMoveUnit.getX() + 1, pMayMoveUnit.getY() - 1)
  1409.                                             if pMayMoveUnit.canMoveInto(pPossiblePlot, False, True, False):
  1410.                                                 if pPossiblePlot.getNumUnits() > 0:
  1411.                                                     for iPossibleEnemy in range(pPossiblePlot.getNumUnits()):
  1412.                                                         pOtherUnitOwner = pPossiblePlot.getUnit(iPossibleEnemy).getOwner()
  1413.                                                         iOtherUnitTeam = gc.getTeam(pOtherUnitOwner)
  1414.                                                         if iOtherUnitTeam.isBarbarian() == True:
  1415.                                                             iSoDUnitMoved = 1
  1416.                                                         if iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1417.                                                                 iSoDUnitMoved = 1
  1418.                                                         if not iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1419.                                                                 pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1420.                                                                 iSoDUnitMoved = 1
  1421.                                                 if pPossiblePlot.getNumUnits() == 0:                                           
  1422.                                                     pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)  
  1423.                                                     iSoDUnitMoved = 1
  1424.                                         if pMayMoveUnit.getX() > 59 and iSoDUnitMoved == 0:
  1425.                                             pPossiblePlot = CyMap().plot(pMayMoveUnit.getX() - 1, pMayMoveUnit.getY() - 1)
  1426.                                             if pMayMoveUnit.canMoveInto(pPossiblePlot, False, True, False):
  1427.                                                 if pPossiblePlot.getNumUnits() > 0:
  1428.                                                     for iPossibleEnemy in range(pPossiblePlot.getNumUnits()):
  1429.                                                         pOtherUnitOwner = pPossiblePlot.getUnit(iPossibleEnemy).getOwner()
  1430.                                                         iOtherUnitTeam = gc.getTeam(pOtherUnitOwner)
  1431.                                                         if iOtherUnitTeam.isBarbarian() == True:
  1432.                                                             iSoDUnitMoved = 1
  1433.                                                         if iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1434.                                                                 iSoDUnitMoved = 1
  1435.                                                         if not iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1436.                                                                 pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1437.                                                                 iSoDUnitMoved = 1
  1438.                                                 if pPossiblePlot.getNumUnits() == 0:                                           
  1439.                                                     pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)  
  1440.                                                     iSoDUnitMoved = 1
  1441.                                         if pMayMoveUnit.getX() == 59 and iSoDUnitMoved == 0:
  1442.                                             pPossiblePlot = CyMap().plot(pMayMoveUnit.getX(), pMayMoveUnit.getY() - 1)
  1443.                                             if pMayMoveUnit.canMoveInto(pPossiblePlot, False, True, False):
  1444.                                                 if pPossiblePlot.getNumUnits() > 0:
  1445.                                                     for iPossibleEnemy in range(pPossiblePlot.getNumUnits()):
  1446.                                                         pOtherUnitOwner = pPossiblePlot.getUnit(iPossibleEnemy).getOwner()
  1447.                                                         iOtherUnitTeam = gc.getTeam(pOtherUnitOwner)
  1448.                                                         if iOtherUnitTeam.isBarbarian() == True:
  1449.                                                             iSoDUnitMoved = 1
  1450.                                                         if iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1451.                                                                 iSoDUnitMoved = 1
  1452.                                                         if not iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1453.                                                                 pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1454.                                                                 iSoDUnitMoved = 1
  1455.                                                 if pPossiblePlot.getNumUnits() == 0:                                           
  1456.                                                     pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1457.                                                     iSoDUnitMoved = 1
  1458.                                     if pMayMoveUnit.getY() == 11:
  1459.                                         pMayMoveUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), True)
  1460.                                         if pMayMoveUnit.getX() < 59 and iSoDUnitMoved == 0:
  1461.                                             pPossiblePlot = CyMap().plot(pMayMoveUnit.getX() + 1, pMayMoveUnit.getY())
  1462.                                             if pMayMoveUnit.canMoveInto(pPossiblePlot, False, True, False):
  1463.                                                 if pPossiblePlot.getNumUnits() > 0:
  1464.                                                     for iPossibleEnemy in range(pPossiblePlot.getNumUnits()):
  1465.                                                         pOtherUnitOwner = pPossiblePlot.getUnit(iPossibleEnemy).getOwner()
  1466.                                                         iOtherUnitTeam = gc.getTeam(pOtherUnitOwner)
  1467.                                                         if iOtherUnitTeam.isBarbarian() == True:
  1468.                                                             iSoDUnitMoved = 1
  1469.                                                         if iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1470.                                                                 iSoDUnitMoved = 1
  1471.                                                         if not iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1472.                                                                 pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1473.                                                                 iSoDUnitMoved = 1
  1474.                                                 if pPossiblePlot.getNumUnits() == 0:                                           
  1475.                                                     pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)  
  1476.                                                     iSoDUnitMoved = 1
  1477.                                         if pMayMoveUnit.getX() > 59 and iSoDUnitMoved == 0:
  1478.                                             pPossiblePlot = CyMap().plot(pMayMoveUnit.getX() - 1, pMayMoveUnit.getY())
  1479.                                             if pMayMoveUnit.canMoveInto(pPossiblePlot, False, True, False):
  1480.                                                 if pPossiblePlot.getNumUnits() > 0:
  1481.                                                     for iPossibleEnemy in range(pPossiblePlot.getNumUnits()):
  1482.                                                         pOtherUnitOwner = pPossiblePlot.getUnit(iPossibleEnemy).getOwner()
  1483.                                                         iOtherUnitTeam = gc.getTeam(pOtherUnitOwner)
  1484.                                                         if iOtherUnitTeam.isBarbarian() == True:
  1485.                                                             iSoDUnitMoved = 1
  1486.                                                         if iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1487.                                                                 iSoDUnitMoved = 1
  1488.                                                         if not iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1489.                                                                 pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1490.                                                                 iSoDUnitMoved = 1
  1491.                                                 if pPossiblePlot.getNumUnits() == 0:                                           
  1492.                                                     pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1493.                                                     iSoDUnitMoved = 1
  1494.                     if pGoodSofDPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LJOSALFAR'):
  1495.                         pySofD = PyPlayer(iGoodSofDPlayer)
  1496.                         if pGoodSofDPlayer.getNumUnits() > 0:
  1497.                             for pMayMoveUnit in pySofD.getUnitList():
  1498.                                 if pMayMoveUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_SofD')):
  1499.                                     iSoDUnitMoved = 0
  1500.                                     if pMayMoveUnit.getY() < 11:
  1501.                                         pMayMoveUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), True)
  1502.                                         if pMayMoveUnit.getX() < 59 and iSoDUnitMoved == 0:
  1503.                                             pPossiblePlot = CyMap().plot(pMayMoveUnit.getX() + 1, pMayMoveUnit.getY() + 1)
  1504.                                             if pMayMoveUnit.canMoveInto(pPossiblePlot, False, True, False):
  1505.                                                 if pPossiblePlot.getNumUnits() > 0:
  1506.                                                     for iPossibleEnemy in range(pPossiblePlot.getNumUnits()):
  1507.                                                         pOtherUnitOwner = pPossiblePlot.getUnit(iPossibleEnemy).getOwner()
  1508.                                                         iOtherUnitTeam = gc.getTeam(pOtherUnitOwner)
  1509.                                                         if iOtherUnitTeam.isBarbarian() == True:
  1510.                                                             iSoDUnitMoved = 1
  1511.                                                         if iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1512.                                                                 iSoDUnitMoved = 1
  1513.                                                         if not iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1514.                                                                 pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1515.                                                                 iSoDUnitMoved = 1
  1516.                                                 if pPossiblePlot.getNumUnits() == 0:
  1517.                                                     pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1518.                                                     iSoDUnitMoved = 1                                          
  1519.                                                 #War is done by team so either don't keep moving if another unit is there or find the Elohim team and find the other unit's team
  1520.                                                 #Elohim team ID is always 0 because it is the human player
  1521.                                                 #War with Elohim is used as a proxy for war with any of the other good civs
  1522.                                         if pMayMoveUnit.getX() > 59 and iSoDUnitMoved == 0:
  1523.                                             pPossiblePlot = CyMap().plot(pMayMoveUnit.getX() - 1, pMayMoveUnit.getY() + 1)
  1524.                                             if pMayMoveUnit.canMoveInto(pPossiblePlot, False, True, False):
  1525.                                                 if pPossiblePlot.getNumUnits() > 0:
  1526.                                                     for iPossibleEnemy in range(pPossiblePlot.getNumUnits()):
  1527.                                                         pOtherUnitOwner = pPossiblePlot.getUnit(iPossibleEnemy).getOwner()
  1528.                                                         iOtherUnitTeam = gc.getTeam(pOtherUnitOwner)
  1529.                                                         if iOtherUnitTeam.isBarbarian() == True:
  1530.                                                             iSoDUnitMoved = 1
  1531.                                                         if iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1532.                                                                 iSoDUnitMoved = 1
  1533.                                                         if not iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1534.                                                                 pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1535.                                                                 iSoDUnitMoved = 1
  1536.                                                 if pPossiblePlot.getNumUnits() == 0:                                           
  1537.                                                     pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1538.                                                     iSoDUnitMoved = 1
  1539.                                         if pMayMoveUnit.getX() == 59 and iSoDUnitMoved == 0:
  1540.                                             pPossiblePlot = CyMap().plot(pMayMoveUnit.getX(), pMayMoveUnit.getY() + 1)
  1541.                                             if pMayMoveUnit.canMoveInto(pPossiblePlot, False, True, False):
  1542.                                                 if pPossiblePlot.getNumUnits() > 0:
  1543.                                                     for iPossibleEnemy in range(pPossiblePlot.getNumUnits()):
  1544.                                                         pOtherUnitOwner = pPossiblePlot.getUnit(iPossibleEnemy).getOwner()
  1545.                                                         iOtherUnitTeam = gc.getTeam(pOtherUnitOwner)
  1546.                                                         if iOtherUnitTeam.isBarbarian() == True:
  1547.                                                             iSoDUnitMoved = 1
  1548.                                                         if iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1549.                                                                 iSoDUnitMoved = 1
  1550.                                                         if not iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1551.                                                                 pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1552.                                                                 iSoDUnitMoved = 1
  1553.                                                 if pPossiblePlot.getNumUnits() == 0:                                           
  1554.                                                     pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1555.                                                     iSoDUnitMoved = 1                                              
  1556.                                     if pMayMoveUnit.getY() > 11:
  1557.                                         pMayMoveUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), True)
  1558.                                         if pMayMoveUnit.getX() < 59 and iSoDUnitMoved == 0:
  1559.                                             pPossiblePlot = CyMap().plot(pMayMoveUnit.getX() + 1, pMayMoveUnit.getY() - 1)
  1560.                                             if pMayMoveUnit.canMoveInto(pPossiblePlot, False, True, False):
  1561.                                                 if pPossiblePlot.getNumUnits() > 0:
  1562.                                                     for iPossibleEnemy in range(pPossiblePlot.getNumUnits()):
  1563.                                                         pOtherUnitOwner = pPossiblePlot.getUnit(iPossibleEnemy).getOwner()
  1564.                                                         iOtherUnitTeam = gc.getTeam(pOtherUnitOwner)
  1565.                                                         if iOtherUnitTeam.isBarbarian() == True:
  1566.                                                             iSoDUnitMoved = 1
  1567.                                                         if iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1568.                                                                 iSoDUnitMoved = 1
  1569.                                                         if not iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1570.                                                                 pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1571.                                                                 iSoDUnitMoved = 1
  1572.                                                 if pPossiblePlot.getNumUnits() == 0:                                           
  1573.                                                     pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)  
  1574.                                                     iSoDUnitMoved = 1
  1575.                                         if pMayMoveUnit.getX() > 59 and iSoDUnitMoved == 0:
  1576.                                             pPossiblePlot = CyMap().plot(pMayMoveUnit.getX() - 1, pMayMoveUnit.getY() - 1)
  1577.                                             if pMayMoveUnit.canMoveInto(pPossiblePlot, False, True, False):
  1578.                                                 if pPossiblePlot.getNumUnits() > 0:
  1579.                                                     for iPossibleEnemy in range(pPossiblePlot.getNumUnits()):
  1580.                                                         pOtherUnitOwner = pPossiblePlot.getUnit(iPossibleEnemy).getOwner()
  1581.                                                         iOtherUnitTeam = gc.getTeam(pOtherUnitOwner)
  1582.                                                         if iOtherUnitTeam.isBarbarian() == True:
  1583.                                                             iSoDUnitMoved = 1
  1584.                                                         if iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1585.                                                                 iSoDUnitMoved = 1
  1586.                                                         if not iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1587.                                                                 pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1588.                                                                 iSoDUnitMoved = 1
  1589.                                                 if pPossiblePlot.getNumUnits() == 0:                                           
  1590.                                                     pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)  
  1591.                                                     iSoDUnitMoved = 1
  1592.                                         if pMayMoveUnit.getX() == 59 and iSoDUnitMoved == 0:
  1593.                                             pPossiblePlot = CyMap().plot(pMayMoveUnit.getX(), pMayMoveUnit.getY() - 1)
  1594.                                             if pMayMoveUnit.canMoveInto(pPossiblePlot, False, True, False):
  1595.                                                 if pPossiblePlot.getNumUnits() > 0:
  1596.                                                     for iPossibleEnemy in range(pPossiblePlot.getNumUnits()):
  1597.                                                         pOtherUnitOwner = pPossiblePlot.getUnit(iPossibleEnemy).getOwner()
  1598.                                                         iOtherUnitTeam = gc.getTeam(pOtherUnitOwner)
  1599.                                                         if iOtherUnitTeam.isBarbarian() == True:
  1600.                                                             iSoDUnitMoved = 1
  1601.                                                         if iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1602.                                                                 iSoDUnitMoved = 1
  1603.                                                         if not iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1604.                                                                 pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1605.                                                                 iSoDUnitMoved = 1
  1606.                                                 if pPossiblePlot.getNumUnits() == 0:                                           
  1607.                                                     pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1608.                                                     iSoDUnitMoved = 1
  1609.                                     if pMayMoveUnit.getY() == 11:
  1610.                                         pMayMoveUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), True)
  1611.                                         if pMayMoveUnit.getX() < 59 and iSoDUnitMoved == 0:
  1612.                                             pPossiblePlot = CyMap().plot(pMayMoveUnit.getX() + 1, pMayMoveUnit.getY())
  1613.                                             if pMayMoveUnit.canMoveInto(pPossiblePlot, False, True, False):
  1614.                                                 if pPossiblePlot.getNumUnits() > 0:
  1615.                                                     for iPossibleEnemy in range(pPossiblePlot.getNumUnits()):
  1616.                                                         pOtherUnitOwner = pPossiblePlot.getUnit(iPossibleEnemy).getOwner()
  1617.                                                         iOtherUnitTeam = gc.getTeam(pOtherUnitOwner)
  1618.                                                         if iOtherUnitTeam.isBarbarian() == True:
  1619.                                                             iSoDUnitMoved = 1
  1620.                                                         if iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1621.                                                                 iSoDUnitMoved = 1
  1622.                                                         if not iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1623.                                                                 pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1624.                                                                 iSoDUnitMoved = 1
  1625.                                                 if pPossiblePlot.getNumUnits() == 0:                                           
  1626.                                                     pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)  
  1627.                                                     iSoDUnitMoved = 1
  1628.                                         if pMayMoveUnit.getX() > 59 and iSoDUnitMoved == 0:
  1629.                                             pPossiblePlot = CyMap().plot(pMayMoveUnit.getX() - 1, pMayMoveUnit.getY())
  1630.                                             if pMayMoveUnit.canMoveInto(pPossiblePlot, False, True, False):
  1631.                                                 if pPossiblePlot.getNumUnits() > 0:
  1632.                                                     for iPossibleEnemy in range(pPossiblePlot.getNumUnits()):
  1633.                                                         pOtherUnitOwner = pPossiblePlot.getUnit(iPossibleEnemy).getOwner()
  1634.                                                         iOtherUnitTeam = gc.getTeam(pOtherUnitOwner)
  1635.                                                         if iOtherUnitTeam.isBarbarian() == True:
  1636.                                                             iSoDUnitMoved = 1
  1637.                                                         if iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1638.                                                                 iSoDUnitMoved = 1
  1639.                                                         if not iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1640.                                                                 pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1641.                                                                 iSoDUnitMoved = 1
  1642.                                                 if pPossiblePlot.getNumUnits() == 0:                                           
  1643.                                                     pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1644.                                                     iSoDUnitMoved = 1
  1645.                     if pGoodSofDPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LUCHUIRP'):
  1646.                         pySofD = PyPlayer(iGoodSofDPlayer)
  1647.                         if pGoodSofDPlayer.getNumUnits() > 0:
  1648.                             for pMayMoveUnit in pySofD.getUnitList():
  1649.                                 if pMayMoveUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_SofD')):
  1650.                                     iSoDUnitMoved = 0
  1651.                                     if pMayMoveUnit.getY() < 11:
  1652.                                         pMayMoveUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), True)
  1653.                                         if pMayMoveUnit.getX() < 59 and iSoDUnitMoved == 0:
  1654.                                             pPossiblePlot = CyMap().plot(pMayMoveUnit.getX() + 1, pMayMoveUnit.getY() + 1)
  1655.                                             if pMayMoveUnit.canMoveInto(pPossiblePlot, False, True, False):
  1656.                                                 if pPossiblePlot.getNumUnits() > 0:
  1657.                                                     for iPossibleEnemy in range(pPossiblePlot.getNumUnits()):
  1658.                                                         pOtherUnitOwner = pPossiblePlot.getUnit(iPossibleEnemy).getOwner()
  1659.                                                         iOtherUnitTeam = gc.getTeam(pOtherUnitOwner)
  1660.                                                         if iOtherUnitTeam.isBarbarian() == True:
  1661.                                                             iSoDUnitMoved = 1
  1662.                                                         if iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1663.                                                                 iSoDUnitMoved = 1
  1664.                                                         if not iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1665.                                                                 pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1666.                                                                 iSoDUnitMoved = 1
  1667.                                                 if pPossiblePlot.getNumUnits() == 0:
  1668.                                                     pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1669.                                                     iSoDUnitMoved = 1                                          
  1670.                                                 #War is done by team so either don't keep moving if another unit is there or find the Elohim team and find the other unit's team
  1671.                                                 #Elohim team ID is always 0 because it is the human player
  1672.                                                 #War with Elohim is used as a proxy for war with any of the other good civs
  1673.                                         if pMayMoveUnit.getX() > 59 and iSoDUnitMoved == 0:
  1674.                                             pPossiblePlot = CyMap().plot(pMayMoveUnit.getX() - 1, pMayMoveUnit.getY() + 1)
  1675.                                             if pMayMoveUnit.canMoveInto(pPossiblePlot, False, True, False):
  1676.                                                 if pPossiblePlot.getNumUnits() > 0:
  1677.                                                     for iPossibleEnemy in range(pPossiblePlot.getNumUnits()):
  1678.                                                         pOtherUnitOwner = pPossiblePlot.getUnit(iPossibleEnemy).getOwner()
  1679.                                                         iOtherUnitTeam = gc.getTeam(pOtherUnitOwner)
  1680.                                                         if iOtherUnitTeam.isBarbarian() == True:
  1681.                                                             iSoDUnitMoved = 1
  1682.                                                         if iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1683.                                                                 iSoDUnitMoved = 1
  1684.                                                         if not iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1685.                                                                 pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1686.                                                                 iSoDUnitMoved = 1
  1687.                                                 if pPossiblePlot.getNumUnits() == 0:                                           
  1688.                                                     pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1689.                                                     iSoDUnitMoved = 1
  1690.                                         if pMayMoveUnit.getX() == 59 and iSoDUnitMoved == 0:
  1691.                                             pPossiblePlot = CyMap().plot(pMayMoveUnit.getX(), pMayMoveUnit.getY() + 1)
  1692.                                             if pMayMoveUnit.canMoveInto(pPossiblePlot, False, True, False):
  1693.                                                 if pPossiblePlot.getNumUnits() > 0:
  1694.                                                     for iPossibleEnemy in range(pPossiblePlot.getNumUnits()):
  1695.                                                         pOtherUnitOwner = pPossiblePlot.getUnit(iPossibleEnemy).getOwner()
  1696.                                                         iOtherUnitTeam = gc.getTeam(pOtherUnitOwner)
  1697.                                                         if iOtherUnitTeam.isBarbarian() == True:
  1698.                                                             iSoDUnitMoved = 1
  1699.                                                         if iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1700.                                                                 iSoDUnitMoved = 1
  1701.                                                         if not iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1702.                                                                 pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1703.                                                                 iSoDUnitMoved = 1
  1704.                                                 if pPossiblePlot.getNumUnits() == 0:                                           
  1705.                                                     pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1706.                                                     iSoDUnitMoved = 1                                              
  1707.                                     if pMayMoveUnit.getY() > 11:
  1708.                                         pMayMoveUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), True)
  1709.                                         if pMayMoveUnit.getX() < 59 and iSoDUnitMoved == 0:
  1710.                                             pPossiblePlot = CyMap().plot(pMayMoveUnit.getX() + 1, pMayMoveUnit.getY() - 1)
  1711.                                             if pMayMoveUnit.canMoveInto(pPossiblePlot, False, True, False):
  1712.                                                 if pPossiblePlot.getNumUnits() > 0:
  1713.                                                     for iPossibleEnemy in range(pPossiblePlot.getNumUnits()):
  1714.                                                         pOtherUnitOwner = pPossiblePlot.getUnit(iPossibleEnemy).getOwner()
  1715.                                                         iOtherUnitTeam = gc.getTeam(pOtherUnitOwner)
  1716.                                                         if iOtherUnitTeam.isBarbarian() == True:
  1717.                                                             iSoDUnitMoved = 1
  1718.                                                         if iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1719.                                                                 iSoDUnitMoved = 1
  1720.                                                         if not iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1721.                                                                 pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1722.                                                                 iSoDUnitMoved = 1
  1723.                                                 if pPossiblePlot.getNumUnits() == 0:                                           
  1724.                                                     pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)  
  1725.                                                     iSoDUnitMoved = 1
  1726.                                         if pMayMoveUnit.getX() > 59 and iSoDUnitMoved == 0:
  1727.                                             pPossiblePlot = CyMap().plot(pMayMoveUnit.getX() - 1, pMayMoveUnit.getY() - 1)
  1728.                                             if pMayMoveUnit.canMoveInto(pPossiblePlot, False, True, False):
  1729.                                                 if pPossiblePlot.getNumUnits() > 0:
  1730.                                                     for iPossibleEnemy in range(pPossiblePlot.getNumUnits()):
  1731.                                                         pOtherUnitOwner = pPossiblePlot.getUnit(iPossibleEnemy).getOwner()
  1732.                                                         iOtherUnitTeam = gc.getTeam(pOtherUnitOwner)
  1733.                                                         if iOtherUnitTeam.isBarbarian() == True:
  1734.                                                             iSoDUnitMoved = 1
  1735.                                                         if iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1736.                                                                 iSoDUnitMoved = 1
  1737.                                                         if not iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1738.                                                                 pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1739.                                                                 iSoDUnitMoved = 1
  1740.                                                 if pPossiblePlot.getNumUnits() == 0:                                           
  1741.                                                     pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)  
  1742.                                                     iSoDUnitMoved = 1
  1743.                                         if pMayMoveUnit.getX() == 59 and iSoDUnitMoved == 0:
  1744.                                             pPossiblePlot = CyMap().plot(pMayMoveUnit.getX(), pMayMoveUnit.getY() - 1)
  1745.                                             if pMayMoveUnit.canMoveInto(pPossiblePlot, False, True, False):
  1746.                                                 if pPossiblePlot.getNumUnits() > 0:
  1747.                                                     for iPossibleEnemy in range(pPossiblePlot.getNumUnits()):
  1748.                                                         pOtherUnitOwner = pPossiblePlot.getUnit(iPossibleEnemy).getOwner()
  1749.                                                         iOtherUnitTeam = gc.getTeam(pOtherUnitOwner)
  1750.                                                         if iOtherUnitTeam.isBarbarian() == True:
  1751.                                                             iSoDUnitMoved = 1
  1752.                                                         if iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1753.                                                                 iSoDUnitMoved = 1
  1754.                                                         if not iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1755.                                                                 pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1756.                                                                 iSoDUnitMoved = 1
  1757.                                                 if pPossiblePlot.getNumUnits() == 0:                                           
  1758.                                                     pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1759.                                                     iSoDUnitMoved = 1
  1760.                                     if pMayMoveUnit.getY() == 11:
  1761.                                         pMayMoveUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), True)
  1762.                                         if pMayMoveUnit.getX() < 59 and iSoDUnitMoved == 0:
  1763.                                             pPossiblePlot = CyMap().plot(pMayMoveUnit.getX() + 1, pMayMoveUnit.getY())
  1764.                                             if pMayMoveUnit.canMoveInto(pPossiblePlot, False, True, False):
  1765.                                                 if pPossiblePlot.getNumUnits() > 0:
  1766.                                                     for iPossibleEnemy in range(pPossiblePlot.getNumUnits()):
  1767.                                                         pOtherUnitOwner = pPossiblePlot.getUnit(iPossibleEnemy).getOwner()
  1768.                                                         iOtherUnitTeam = gc.getTeam(pOtherUnitOwner)
  1769.                                                         if iOtherUnitTeam.isBarbarian() == True:
  1770.                                                             iSoDUnitMoved = 1
  1771.                                                         if iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1772.                                                                 iSoDUnitMoved = 1
  1773.                                                         if not iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1774.                                                                 pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1775.                                                                 iSoDUnitMoved = 1
  1776.                                                 if pPossiblePlot.getNumUnits() == 0:                                           
  1777.                                                     pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)  
  1778.                                                     iSoDUnitMoved = 1
  1779.                                         if pMayMoveUnit.getX() > 59 and iSoDUnitMoved == 0:
  1780.                                             pPossiblePlot = CyMap().plot(pMayMoveUnit.getX() - 1, pMayMoveUnit.getY())
  1781.                                             if pMayMoveUnit.canMoveInto(pPossiblePlot, False, True, False):
  1782.                                                 if pPossiblePlot.getNumUnits() > 0:
  1783.                                                     for iPossibleEnemy in range(pPossiblePlot.getNumUnits()):
  1784.                                                         pOtherUnitOwner = pPossiblePlot.getUnit(iPossibleEnemy).getOwner()
  1785.                                                         iOtherUnitTeam = gc.getTeam(pOtherUnitOwner)
  1786.                                                         if iOtherUnitTeam.isBarbarian() == True:
  1787.                                                             iSoDUnitMoved = 1
  1788.                                                         if iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1789.                                                                 iSoDUnitMoved = 1
  1790.                                                         if not iOtherUnitTeam.isAtWar(0) and iSoDUnitMoved == 0:
  1791.                                                                 pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1792.                                                                 iSoDUnitMoved = 1
  1793.                                                 if pPossiblePlot.getNumUnits() == 0:                                           
  1794.                                                     pMayMoveUnit.setXY(pPossiblePlot.getX(), pPossiblePlot.getY(), False, True, True)
  1795.                                                     iSoDUnitMoved = 1
  1796.                    
  1797.            
  1798.         #The starting and finishing positions need to be changed in def onUnitCreated, def onBeginPlayerTurn, the Bane Divine section, the move to marshalling point above in this section and here.
  1799.         #The AI is given the HELD promotion in def onBeginPlayerTurn otherwise they move off the tile before being given the promotion
  1800.         #This code should give all units in tile(iOldX,iOldY) the HELD promotion so that they can't move anywhere.
  1801.         #iTargetX and iTargetY give the coordinates of the tile that the unit stack is moving into
  1802.         #If it is after turn 30 then move units from the marshalling tile towards the target tile
  1803.         iTargetX = 16
  1804.         iTargetY = 10
  1805.         pTargetPlot = CyMap().plot(iTargetX,iTargetY)
  1806.        
  1807.         #onBeginPlayerTurn is giving units in the marshalling point the HELD promotion which may be unnecessary??
  1808.         if iGameTurn < 60:
  1809.             iOldX = 59
  1810.             iOldY = 11
  1811.             pOldPlot = CyMap().plot(iOldX,iOldY)
  1812.             for i in range(pOldPlot.getNumUnits()):
  1813.                 pUnit = pOldPlot.getUnit(i)
  1814.                 pUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), True)
  1815.             #Remember the x and y values between turns 9 and 10
  1816.             myPickle = [iOldX, iOldY]
  1817.             serializedMyPickle = pickle.dumps(myPickle)
  1818.             BugData.getTable("MY_TABLE").setData(serializedMyPickle)
  1819.  
  1820.         #Make sure in the final version that the target is roughly W of the marshalling point (takes about 45 turns from marshalling point to Sheaim capital)
  1821.         #Check that it only avoids the tile if it's NOT a friendly unit in the tile (invisible friendly units could allow you to move into enemy units though)
  1822.         if iGameTurn >= 60 and iGameTurn <= 120:
  1823.             #Load x and y values
  1824.             serializedMyPickle = BugData.getTable("MY_TABLE").data
  1825.             myPickle = pickle.loads(serializedMyPickle)
  1826.             iOldX = myPickle[0]
  1827.             iOldY = myPickle[1]
  1828.             pOldPlot = CyMap().plot(iOldX, iOldY)
  1829.             UnitsMoved = -1
  1830.            
  1831.            
  1832.             if iOldY == iTargetY and iOldX > iTargetX:
  1833.                 #First choice is to move W if possible
  1834.                 if UnitsMoved == -1:
  1835.                     iNewX = iOldX - 1
  1836.                     iNewY = iOldY
  1837.                     pNewPlot = CyMap().plot(iNewX,iNewY)           
  1838.                     if pNewPlot.isNone() == False:
  1839.                         #Option 1 - pNewPlot is empty
  1840.                         if pNewPlot.getNumUnits() == 0:
  1841.                             if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  1842.                                 for i in range(pOldPlot.getNumUnits(), -1, -1):
  1843.                                     pUnit = pOldPlot.getUnit(i)
  1844.                                     pUnit.setXY(iNewX, iNewY, False, True, True)
  1845.                                 UnitsMoved = 1
  1846.                         #Option 2 - pNewPlot has friendly (not including Luchuirp units) units in it
  1847.                         #Won't enter the loop if no units in the tile
  1848.                         #Could use isAtWar(0) instead which would have the advantage of not moving into Luchuirp (if they have declared war already)
  1849.                         for iBlockingUnits in range(pNewPlot.getNumUnits()):
  1850.                             pPossibleGoodUnit = pNewPlot.getUnit(iBlockingUnits)
  1851.                             pPossibleGoodPlayer = gc.getPlayer(pPossibleGoodUnit.getOwner())
  1852.                             if pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_BANNOR') or pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_ELOHIM') or pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_KURIOTATES') or pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LJOSALFAR'):
  1853.                                 if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  1854.                                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  1855.                                         pUnit = pOldPlot.getUnit(i)
  1856.                                         pUnit.setXY(iNewX, iNewY, False, True, True)
  1857.                                     UnitsMoved = 1
  1858.                
  1859.                 #Second choice is to move NW if possible
  1860.                 if UnitsMoved == -1:
  1861.                     iNewY = iNewY + 1
  1862.                     pNewPlot = CyMap().plot(iNewX,iNewY)           
  1863.                     if pNewPlot.isNone() == False:
  1864.                         #Option 1 - pNewPlot is empty
  1865.                         if pNewPlot.getNumUnits() == 0:
  1866.                             if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  1867.                                 for i in range(pOldPlot.getNumUnits(), -1, -1):
  1868.                                     pUnit = pOldPlot.getUnit(i)
  1869.                                     pUnit.setXY(iNewX, iNewY, False, True, True)
  1870.                                 UnitsMoved = 1
  1871.                         #Option 2 - pNewPlot has friendly (not including Luchuirp units) units in it
  1872.                         #Won't enter the loop if no units in the tile
  1873.                         for iBlockingUnits in range(pNewPlot.getNumUnits()):
  1874.                             pPossibleGoodUnit = pNewPlot.getUnit(iBlockingUnits)
  1875.                             pPossibleGoodPlayer = gc.getPlayer(pPossibleGoodUnit.getOwner())
  1876.                             if pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_BANNOR') or pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_ELOHIM') or pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_KURIOTATES') or pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LJOSALFAR'):
  1877.                                 if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  1878.                                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  1879.                                         pUnit = pOldPlot.getUnit(i)
  1880.                                         pUnit.setXY(iNewX, iNewY, False, True, True)
  1881.                                     UnitsMoved = 1
  1882.                                
  1883.                 #Third choice is to move SW if possible
  1884.                 if UnitsMoved == -1:
  1885.                     iNewY = iNewY - 2
  1886.                     pNewPlot = CyMap().plot(iNewX,iNewY)           
  1887.                     if pNewPlot.isNone() == False:
  1888.                         #Option 1 - pNewPlot is empty
  1889.                         if pNewPlot.getNumUnits() == 0:
  1890.                             if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  1891.                                 for i in range(pOldPlot.getNumUnits(), -1, -1):
  1892.                                     pUnit = pOldPlot.getUnit(i)
  1893.                                     pUnit.setXY(iNewX, iNewY, False, True, True)
  1894.                                 UnitsMoved = 1
  1895.                         #Option 2 - pNewPlot has friendly (not including Luchuirp units) units in it
  1896.                         #Won't enter the loop if no units in the tile
  1897.                         for iBlockingUnits in range(pNewPlot.getNumUnits()):
  1898.                             pPossibleGoodUnit = pNewPlot.getUnit(iBlockingUnits)
  1899.                             pPossibleGoodPlayer = gc.getPlayer(pPossibleGoodUnit.getOwner())
  1900.                             if pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_BANNOR') or pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_ELOHIM') or pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_KURIOTATES') or pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LJOSALFAR'):
  1901.                                 if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  1902.                                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  1903.                                         pUnit = pOldPlot.getUnit(i)
  1904.                                         pUnit.setXY(iNewX, iNewY, False, True, True)
  1905.                                     UnitsMoved = 1
  1906.                                
  1907.                 #Fourth choice is to stay in the same tile
  1908.                 if UnitsMoved == -1:
  1909.                     iNewY = iNewY + 1
  1910.                     iNewX = iNewX + 1
  1911.                     pNewPlot = CyMap().plot(iNewX,iNewY)
  1912.                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  1913.                         pUnit = pOldPlot.getUnit(i)
  1914.                         pUnit.setXY(iNewX, iNewY, False, True, True)
  1915.                     UnitsMoved = 1
  1916.                
  1917.                 #Remember the x and y values between turns
  1918.                 iOldX = iNewX
  1919.                 iOldY = iNewY
  1920.                 myPickle = [iOldX, iOldY]
  1921.                 serializedMyPickle = pickle.dumps(myPickle)
  1922.                 BugData.getTable("MY_TABLE").setData(serializedMyPickle)
  1923.  
  1924.            
  1925.             if iOldY > iTargetY and iOldY < iTargetY + 5 and iOldX > iTargetX:
  1926.                 #First choice is to move SW if possible
  1927.                 if UnitsMoved == -1:
  1928.                     iNewX = iOldX - 1
  1929.                     iNewY = iOldY - 1
  1930.                     pNewPlot = CyMap().plot(iNewX,iNewY)           
  1931.                     if pNewPlot.isNone() == False:
  1932.                         #Option 1 - pNewPlot is empty
  1933.                         if pNewPlot.getNumUnits() == 0:
  1934.                             if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  1935.                                 for i in range(pOldPlot.getNumUnits(), -1, -1):
  1936.                                     pUnit = pOldPlot.getUnit(i)
  1937.                                     pUnit.setXY(iNewX, iNewY, False, True, True)
  1938.                                 UnitsMoved = 1
  1939.                         #Option 2 - pNewPlot has friendly (not including Luchuirp units) units in it
  1940.                         #Won't enter the loop if no units in the tile
  1941.                         for iBlockingUnits in range(pNewPlot.getNumUnits()):
  1942.                             pPossibleGoodUnit = pNewPlot.getUnit(iBlockingUnits)
  1943.                             pPossibleGoodPlayer = gc.getPlayer(pPossibleGoodUnit.getOwner())
  1944.                             if pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_BANNOR') or pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_ELOHIM') or pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_KURIOTATES') or pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LJOSALFAR'):
  1945.                                 if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  1946.                                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  1947.                                         pUnit = pOldPlot.getUnit(i)
  1948.                                         pUnit.setXY(iNewX, iNewY, False, True, True)
  1949.                                     UnitsMoved = 1
  1950.                
  1951.                 #Second choice is to move W if possible
  1952.                 if UnitsMoved == -1:
  1953.                     iNewY = iNewY + 1
  1954.                     pNewPlot = CyMap().plot(iNewX,iNewY)           
  1955.                     if pNewPlot.isNone() == False:
  1956.                         #Option 1 - pNewPlot is empty
  1957.                         if pNewPlot.getNumUnits() == 0:
  1958.                             if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  1959.                                 for i in range(pOldPlot.getNumUnits(), -1, -1):
  1960.                                     pUnit = pOldPlot.getUnit(i)
  1961.                                     pUnit.setXY(iNewX, iNewY, False, True, True)
  1962.                                 UnitsMoved = 1
  1963.                         #Option 2 - pNewPlot has friendly (not including Luchuirp units) units in it
  1964.                         #Won't enter the loop if no units in the tile
  1965.                         for iBlockingUnits in range(pNewPlot.getNumUnits()):
  1966.                             pPossibleGoodUnit = pNewPlot.getUnit(iBlockingUnits)
  1967.                             pPossibleGoodPlayer = gc.getPlayer(pPossibleGoodUnit.getOwner())
  1968.                             if pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_BANNOR') or pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_ELOHIM') or pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_KURIOTATES') or pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LJOSALFAR'):
  1969.                                 if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  1970.                                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  1971.                                         pUnit = pOldPlot.getUnit(i)
  1972.                                         pUnit.setXY(iNewX, iNewY, False, True, True)
  1973.                                     UnitsMoved = 1
  1974.                                
  1975.                 #Third choice is to move NW if possible
  1976.                 if UnitsMoved == -1:
  1977.                     iNewY = iNewY + 1
  1978.                     pNewPlot = CyMap().plot(iNewX,iNewY)           
  1979.                     if pNewPlot.isNone() == False:
  1980.                         #Option 1 - pNewPlot is empty
  1981.                         if pNewPlot.getNumUnits() == 0:
  1982.                             if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  1983.                                 for i in range(pOldPlot.getNumUnits(), -1, -1):
  1984.                                     pUnit = pOldPlot.getUnit(i)
  1985.                                     pUnit.setXY(iNewX, iNewY, False, True, True)
  1986.                                 UnitsMoved = 1
  1987.                         #Option 2 - pNewPlot has friendly (not including Luchuirp units) units in it
  1988.                         #Won't enter the loop if no units in the tile
  1989.                         for iBlockingUnits in range(pNewPlot.getNumUnits()):
  1990.                             pPossibleGoodUnit = pNewPlot.getUnit(iBlockingUnits)
  1991.                             pPossibleGoodPlayer = gc.getPlayer(pPossibleGoodUnit.getOwner())
  1992.                             if pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_BANNOR') or pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_ELOHIM') or pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_KURIOTATES') or pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LJOSALFAR'):
  1993.                                 if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  1994.                                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  1995.                                         pUnit = pOldPlot.getUnit(i)
  1996.                                         pUnit.setXY(iNewX, iNewY, False, True, True)
  1997.                                     UnitsMoved = 1
  1998.                                
  1999.                 #Fourth choice is to stay in the same tile
  2000.                 if UnitsMoved == -1:
  2001.                     iNewY = iNewY - 1
  2002.                     iNewX = iNewX + 1
  2003.                     pNewPlot = CyMap().plot(iNewX,iNewY)
  2004.                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  2005.                         pUnit = pOldPlot.getUnit(i)
  2006.                         pUnit.setXY(iNewX, iNewY, False, True, True)
  2007.                     UnitsMoved = 1
  2008.                
  2009.                 #Remember the x and y values between turns
  2010.                 iOldX = iNewX
  2011.                 iOldY = iNewY
  2012.                 myPickle = [iOldX, iOldY]
  2013.                 serializedMyPickle = pickle.dumps(myPickle)
  2014.                 BugData.getTable("MY_TABLE").setData(serializedMyPickle)
  2015.  
  2016.                
  2017.             if iOldY < iTargetY and iOldY > iTargetY - 5 and iOldX > iTargetX:
  2018.                 #First choice is to move NW if possible
  2019.                 if UnitsMoved == -1:
  2020.                     iNewX = iOldX - 1
  2021.                     iNewY = iOldY + 1
  2022.                     pNewPlot = CyMap().plot(iNewX,iNewY)           
  2023.                     if pNewPlot.isNone() == False:
  2024.                         #Option 1 - pNewPlot is empty
  2025.                         if pNewPlot.getNumUnits() == 0:
  2026.                             if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  2027.                                 for i in range(pOldPlot.getNumUnits(), -1, -1):
  2028.                                     pUnit = pOldPlot.getUnit(i)
  2029.                                     pUnit.setXY(iNewX, iNewY, False, True, True)
  2030.                                 UnitsMoved = 1
  2031.                         #Option 2 - pNewPlot has friendly (not including Luchuirp units) units in it
  2032.                         #Won't enter the loop if no units in the tile
  2033.                         for iBlockingUnits in range(pNewPlot.getNumUnits()):
  2034.                             pPossibleGoodUnit = pNewPlot.getUnit(iBlockingUnits)
  2035.                             pPossibleGoodPlayer = gc.getPlayer(pPossibleGoodUnit.getOwner())
  2036.                             if pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_BANNOR') or pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_ELOHIM') or pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_KURIOTATES') or pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LJOSALFAR'):
  2037.                                 if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  2038.                                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  2039.                                         pUnit = pOldPlot.getUnit(i)
  2040.                                         pUnit.setXY(iNewX, iNewY, False, True, True)
  2041.                                     UnitsMoved = 1
  2042.                
  2043.                 #Second choice is to move W if possible
  2044.                 if UnitsMoved == -1:
  2045.                     iNewY = iNewY - 1
  2046.                     pNewPlot = CyMap().plot(iNewX,iNewY)           
  2047.                     if pNewPlot.isNone() == False:
  2048.                         #Option 1 - pNewPlot is empty
  2049.                         if pNewPlot.getNumUnits() == 0:
  2050.                             if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  2051.                                 for i in range(pOldPlot.getNumUnits(), -1, -1):
  2052.                                     pUnit = pOldPlot.getUnit(i)
  2053.                                     pUnit.setXY(iNewX, iNewY, False, True, True)
  2054.                                 UnitsMoved = 1
  2055.                         #Option 2 - pNewPlot has friendly (not including Luchuirp units) units in it
  2056.                         #Won't enter the loop if no units in the tile
  2057.                         for iBlockingUnits in range(pNewPlot.getNumUnits()):
  2058.                             pPossibleGoodUnit = pNewPlot.getUnit(iBlockingUnits)
  2059.                             pPossibleGoodPlayer = gc.getPlayer(pPossibleGoodUnit.getOwner())
  2060.                             if pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_BANNOR') or pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_ELOHIM') or pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_KURIOTATES') or pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LJOSALFAR'):
  2061.                                 if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  2062.                                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  2063.                                         pUnit = pOldPlot.getUnit(i)
  2064.                                         pUnit.setXY(iNewX, iNewY, False, True, True)
  2065.                                     UnitsMoved = 1
  2066.                                
  2067.                 #Third choice is to move SW if possible
  2068.                 if UnitsMoved == -1:
  2069.                     iNewY = iNewY - 1
  2070.                     pNewPlot = CyMap().plot(iNewX,iNewY)           
  2071.                     if pNewPlot.isNone() == False:
  2072.                         #Option 1 - pNewPlot is empty
  2073.                         if pNewPlot.getNumUnits() == 0:
  2074.                             if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  2075.                                 for i in range(pOldPlot.getNumUnits(), -1, -1):
  2076.                                     pUnit = pOldPlot.getUnit(i)
  2077.                                     pUnit.setXY(iNewX, iNewY, False, True, True)
  2078.                                 UnitsMoved = 1
  2079.                         #Option 2 - pNewPlot has friendly (not including Luchuirp units) units in it
  2080.                         #Won't enter the loop if no units in the tile
  2081.                         for iBlockingUnits in range(pNewPlot.getNumUnits()):
  2082.                             pPossibleGoodUnit = pNewPlot.getUnit(iBlockingUnits)
  2083.                             pPossibleGoodPlayer = gc.getPlayer(pPossibleGoodUnit.getOwner())
  2084.                             if pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_BANNOR') or pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_ELOHIM') or pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_KURIOTATES') or pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LJOSALFAR'):
  2085.                                 if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  2086.                                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  2087.                                         pUnit = pOldPlot.getUnit(i)
  2088.                                         pUnit.setXY(iNewX, iNewY, False, True, True)
  2089.                                     UnitsMoved = 1
  2090.                                
  2091.                 #Fourth choice is to stay in the same tile
  2092.                 if UnitsMoved == -1:
  2093.                     iNewY = iNewY + 1
  2094.                     iNewX = iNewX + 1
  2095.                     pNewPlot = CyMap().plot(iNewX,iNewY)
  2096.                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  2097.                         pUnit = pOldPlot.getUnit(i)
  2098.                         pUnit.setXY(iNewX, iNewY, False, True, True)
  2099.                     UnitsMoved = 1
  2100.                
  2101.                 #Remember the x and y values between turns
  2102.                 iOldX = iNewX
  2103.                 iOldY = iNewY
  2104.                 myPickle = [iOldX, iOldY]
  2105.                 serializedMyPickle = pickle.dumps(myPickle)
  2106.                 BugData.getTable("MY_TABLE").setData(serializedMyPickle)
  2107.                
  2108.                
  2109.             if iOldY >= iTargetY + 5 and iOldX > iTargetX:
  2110.                 #First choice is to move SW if possible
  2111.                 if UnitsMoved == -1:
  2112.                     iNewX = iOldX - 1
  2113.                     iNewY = iOldY - 1
  2114.                     pNewPlot = CyMap().plot(iNewX,iNewY)           
  2115.                     if pNewPlot.isNone() == False:
  2116.                         #Option 1 - pNewPlot is empty
  2117.                         if pNewPlot.getNumUnits() == 0:
  2118.                             if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  2119.                                 for i in range(pOldPlot.getNumUnits(), -1, -1):
  2120.                                     pUnit = pOldPlot.getUnit(i)
  2121.                                     pUnit.setXY(iNewX, iNewY, False, True, True)
  2122.                                 UnitsMoved = 1
  2123.                         #Option 2 - pNewPlot has friendly (not including Luchuirp units) units in it
  2124.                         #Won't enter the loop if no units in the tile
  2125.                         for iBlockingUnits in range(pNewPlot.getNumUnits()):
  2126.                             pPossibleGoodUnit = pNewPlot.getUnit(iBlockingUnits)
  2127.                             pPossibleGoodPlayer = gc.getPlayer(pPossibleGoodUnit.getOwner())
  2128.                             if pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_BANNOR') or pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_ELOHIM') or pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_KURIOTATES') or pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LJOSALFAR'):
  2129.                                 if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  2130.                                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  2131.                                         pUnit = pOldPlot.getUnit(i)
  2132.                                         pUnit.setXY(iNewX, iNewY, False, True, True)
  2133.                                     UnitsMoved = 1
  2134.                                                
  2135.                 #Second choice is to stay in the same tile
  2136.                 if UnitsMoved == -1:
  2137.                     iNewY = iNewY + 1
  2138.                     iNewX = iNewX + 1
  2139.                     pNewPlot = CyMap().plot(iNewX,iNewY)
  2140.                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  2141.                         pUnit = pOldPlot.getUnit(i)
  2142.                         pUnit.setXY(iNewX, iNewY, False, True, True)
  2143.                     UnitsMoved = 1
  2144.                
  2145.                 #Remember the x and y values between turns
  2146.                 iOldX = iNewX
  2147.                 iOldY = iNewY
  2148.                 myPickle = [iOldX, iOldY]
  2149.                 serializedMyPickle = pickle.dumps(myPickle)
  2150.                 BugData.getTable("MY_TABLE").setData(serializedMyPickle)
  2151.                
  2152.  
  2153.             if iOldY <= iTargetY - 5 and iOldX > iTargetX:
  2154.                 #First choice is to move NW if possible
  2155.                 if UnitsMoved == -1:
  2156.                     iNewX = iOldX - 1
  2157.                     iNewY = iOldY + 1
  2158.                     pNewPlot = CyMap().plot(iNewX,iNewY)           
  2159.                     if pNewPlot.isNone() == False:
  2160.                         #Option 1 - pNewPlot is empty
  2161.                         if pNewPlot.getNumUnits() == 0:
  2162.                             if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  2163.                                 for i in range(pOldPlot.getNumUnits(), -1, -1):
  2164.                                     pUnit = pOldPlot.getUnit(i)
  2165.                                     pUnit.setXY(iNewX, iNewY, False, True, True)
  2166.                                 UnitsMoved = 1
  2167.                         #Option 2 - pNewPlot has friendly (not including Luchuirp units) units in it
  2168.                         #Won't enter the loop if no units in the tile
  2169.                         for iBlockingUnits in range(pNewPlot.getNumUnits()):
  2170.                             pPossibleGoodUnit = pNewPlot.getUnit(iBlockingUnits)
  2171.                             pPossibleGoodPlayer = gc.getPlayer(pPossibleGoodUnit.getOwner())
  2172.                             if pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_BANNOR') or pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_ELOHIM') or pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_KURIOTATES') or pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LJOSALFAR'):
  2173.                                 if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  2174.                                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  2175.                                         pUnit = pOldPlot.getUnit(i)
  2176.                                         pUnit.setXY(iNewX, iNewY, False, True, True)
  2177.                                     UnitsMoved = 1
  2178.                                
  2179.                 #Second choice is to stay in the same tile
  2180.                 if UnitsMoved == -1:
  2181.                     iNewY = iNewY -1
  2182.                     iNewX = iNewX + 1
  2183.                     pNewPlot = CyMap().plot(iNewX,iNewY)
  2184.                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  2185.                         pUnit = pOldPlot.getUnit(i)
  2186.                         pUnit.setXY(iNewX, iNewY, False, True, True)
  2187.                     UnitsMoved = 1
  2188.                
  2189.                 #Remember the x and y values between turns
  2190.                 iOldX = iNewX
  2191.                 iOldY = iNewY
  2192.                 myPickle = [iOldX, iOldY]
  2193.                 serializedMyPickle = pickle.dumps(myPickle)
  2194.                 BugData.getTable("MY_TABLE").setData(serializedMyPickle)
  2195.                
  2196.            
  2197.             if iOldY < iTargetY and iOldY > iTargetY - 5 and iOldX == iTargetX:
  2198.                 #First choice is to move N if possible
  2199.                 if UnitsMoved == -1:
  2200.                     iNewX = iOldX
  2201.                     iNewY = iOldY + 1
  2202.                     pNewPlot = CyMap().plot(iNewX,iNewY)           
  2203.                     if pNewPlot.isNone() == False:
  2204.                         #Option 1 - pNewPlot is empty
  2205.                         if pNewPlot.getNumUnits() == 0:
  2206.                             if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  2207.                                 for i in range(pOldPlot.getNumUnits(), -1, -1):
  2208.                                     pUnit = pOldPlot.getUnit(i)
  2209.                                     pUnit.setXY(iNewX, iNewY, False, True, True)
  2210.                                 UnitsMoved = 1
  2211.                         #Option 2 - pNewPlot has friendly (not including Luchuirp units) units in it
  2212.                         #Won't enter the loop if no units in the tile
  2213.                         for iBlockingUnits in range(pNewPlot.getNumUnits()):
  2214.                             pPossibleGoodUnit = pNewPlot.getUnit(iBlockingUnits)
  2215.                             pPossibleGoodPlayer = gc.getPlayer(pPossibleGoodUnit.getOwner())
  2216.                             if pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_BANNOR') or pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_ELOHIM') or pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_KURIOTATES') or pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LJOSALFAR'):
  2217.                                 if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  2218.                                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  2219.                                         pUnit = pOldPlot.getUnit(i)
  2220.                                         pUnit.setXY(iNewX, iNewY, False, True, True)
  2221.                                     UnitsMoved = 1
  2222.            
  2223.                 #Second choice is to stay in the same tile
  2224.                 if UnitsMoved == -1:
  2225.                     iNewY = iNewY - 1
  2226.                     iNewX = iNewX
  2227.                     pNewPlot = CyMap().plot(iNewX,iNewY)
  2228.                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  2229.                         pUnit = pOldPlot.getUnit(i)
  2230.                         pUnit.setXY(iNewX, iNewY, False, True, True)
  2231.                     UnitsMoved = 1
  2232.                
  2233.                 #Remember the x and y values between turns
  2234.                 iOldX = iNewX
  2235.                 iOldY = iNewY
  2236.                 myPickle = [iOldX, iOldY]
  2237.                 serializedMyPickle = pickle.dumps(myPickle)
  2238.                 BugData.getTable("MY_TABLE").setData(serializedMyPickle)
  2239.                
  2240.             if iOldY > iTargetY and iOldY < iTargetY + 5 and iOldX == iTargetX:
  2241.                 #First choice is to move S if possible
  2242.                 if UnitsMoved == -1:
  2243.                     iNewX = iOldX
  2244.                     iNewY = iOldY - 1
  2245.                     pNewPlot = CyMap().plot(iNewX,iNewY)           
  2246.                     if pNewPlot.isNone() == False:
  2247.                         #Option 1 - pNewPlot is empty
  2248.                         if pNewPlot.getNumUnits() == 0:
  2249.                             if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  2250.                                 for i in range(pOldPlot.getNumUnits(), -1, -1):
  2251.                                     pUnit = pOldPlot.getUnit(i)
  2252.                                     pUnit.setXY(iNewX, iNewY, False, True, True)
  2253.                                 UnitsMoved = 1
  2254.                         #Option 2 - pNewPlot has friendly (not including Luchuirp units) units in it
  2255.                         #Won't enter the loop if no units in the tile
  2256.                         for iBlockingUnits in range(pNewPlot.getNumUnits()):
  2257.                             pPossibleGoodUnit = pNewPlot.getUnit(iBlockingUnits)
  2258.                             pPossibleGoodPlayer = gc.getPlayer(pPossibleGoodUnit.getOwner())
  2259.                             if pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_BANNOR') or pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_ELOHIM') or pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_KURIOTATES') or pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LJOSALFAR'):
  2260.                                 if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  2261.                                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  2262.                                         pUnit = pOldPlot.getUnit(i)
  2263.                                         pUnit.setXY(iNewX, iNewY, False, True, True)
  2264.                                     UnitsMoved = 1
  2265.            
  2266.                 #Second choice is to stay in the same tile
  2267.                 if UnitsMoved == -1:
  2268.                     iNewY = iNewY + 1
  2269.                     iNewX = iNewX
  2270.                     pNewPlot = CyMap().plot(iNewX,iNewY)
  2271.                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  2272.                         pUnit = pOldPlot.getUnit(i)
  2273.                         pUnit.setXY(iNewX, iNewY, False, True, True)
  2274.                     UnitsMoved = 1
  2275.                
  2276.                 #Remember the x and y values between turns
  2277.                 iOldX = iNewX
  2278.                 iOldY = iNewY
  2279.                 myPickle = [iOldX, iOldY]
  2280.                 serializedMyPickle = pickle.dumps(myPickle)
  2281.                 BugData.getTable("MY_TABLE").setData(serializedMyPickle)
  2282.                                
  2283.             if iOldY <= iTargetY - 5 and iOldX == iTargetX:
  2284.                 #First choice is to move N if possible
  2285.                 if UnitsMoved == -1:
  2286.                     iNewX = iOldX
  2287.                     iNewY = iOldY + 1
  2288.                     pNewPlot = CyMap().plot(iNewX,iNewY)           
  2289.                     if pNewPlot.isNone() == False:
  2290.                         #Option 1 - pNewPlot is empty
  2291.                         if pNewPlot.getNumUnits() == 0:
  2292.                             if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  2293.                                 for i in range(pOldPlot.getNumUnits(), -1, -1):
  2294.                                     pUnit = pOldPlot.getUnit(i)
  2295.                                     pUnit.setXY(iNewX, iNewY, False, True, True)
  2296.                                 UnitsMoved = 1
  2297.                         #Option 2 - pNewPlot has friendly (not including Luchuirp units) units in it
  2298.                         #Won't enter the loop if no units in the tile
  2299.                         for iBlockingUnits in range(pNewPlot.getNumUnits()):
  2300.                             pPossibleGoodUnit = pNewPlot.getUnit(iBlockingUnits)
  2301.                             pPossibleGoodPlayer = gc.getPlayer(pPossibleGoodUnit.getOwner())
  2302.                             if pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_BANNOR') or pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_ELOHIM') or pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_KURIOTATES') or pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LJOSALFAR'):
  2303.                                 if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  2304.                                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  2305.                                         pUnit = pOldPlot.getUnit(i)
  2306.                                         pUnit.setXY(iNewX, iNewY, False, True, True)
  2307.                                     UnitsMoved = 1
  2308.                                
  2309.                 #Second choice is to stay in the same tile
  2310.                 if UnitsMoved == -1:
  2311.                     iNewY = iNewY -1
  2312.                     iNewX = iNewX
  2313.                     pNewPlot = CyMap().plot(iNewX,iNewY)
  2314.                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  2315.                         pUnit = pOldPlot.getUnit(i)
  2316.                         pUnit.setXY(iNewX, iNewY, False, True, True)
  2317.                     UnitsMoved = 1
  2318.                
  2319.                 #Remember the x and y values between turns
  2320.                 iOldX = iNewX
  2321.                 iOldY = iNewY
  2322.                 myPickle = [iOldX, iOldY]
  2323.                 serializedMyPickle = pickle.dumps(myPickle)
  2324.                 BugData.getTable("MY_TABLE").setData(serializedMyPickle)
  2325.                
  2326.                
  2327.             if iOldY >= iTargetY + 5 and iOldX == iTargetX:
  2328.                 #First choice is to move S if possible
  2329.                 if UnitsMoved == -1:
  2330.                     iNewX = iOldX
  2331.                     iNewY = iOldY - 1
  2332.                     pNewPlot = CyMap().plot(iNewX,iNewY)           
  2333.                     if pNewPlot.isNone() == False:
  2334.                         #Option 1 - pNewPlot is empty
  2335.                         if pNewPlot.getNumUnits() == 0:
  2336.                             if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  2337.                                 for i in range(pOldPlot.getNumUnits(), -1, -1):
  2338.                                     pUnit = pOldPlot.getUnit(i)
  2339.                                     pUnit.setXY(iNewX, iNewY, False, True, True)
  2340.                                 UnitsMoved = 1
  2341.                         #Option 2 - pNewPlot has friendly (not including Luchuirp units) units in it
  2342.                         #Won't enter the loop if no units in the tile
  2343.                         for iBlockingUnits in range(pNewPlot.getNumUnits()):
  2344.                             pPossibleGoodUnit = pNewPlot.getUnit(iBlockingUnits)
  2345.                             pPossibleGoodPlayer = gc.getPlayer(pPossibleGoodUnit.getOwner())
  2346.                             if pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_BANNOR') or pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_ELOHIM') or pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_KURIOTATES') or pPossibleGoodPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LJOSALFAR'):
  2347.                                 if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  2348.                                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  2349.                                         pUnit = pOldPlot.getUnit(i)
  2350.                                         pUnit.setXY(iNewX, iNewY, False, True, True)
  2351.                                     UnitsMoved = 1
  2352.                                
  2353.                 #Second choice is to stay in the same tile
  2354.                 if UnitsMoved == -1:
  2355.                     iNewY = iNewY +1
  2356.                     iNewX = iNewX
  2357.                     pNewPlot = CyMap().plot(iNewX,iNewY)
  2358.                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  2359.                         pUnit = pOldPlot.getUnit(i)
  2360.                         pUnit.setXY(iNewX, iNewY, False, True, True)
  2361.                     UnitsMoved = 1
  2362.                
  2363.                 #Remember the x and y values between turns
  2364.                 iOldX = iNewX
  2365.                 iOldY = iNewY
  2366.                 myPickle = [iOldX, iOldY]
  2367.                 serializedMyPickle = pickle.dumps(myPickle)
  2368.                 BugData.getTable("MY_TABLE").setData(serializedMyPickle)
  2369.                
  2370.  
  2371.             #Get rid of the HELD promotion when the stack reaches the target tile
  2372.             #This is still indented to be included within iGameTurn >35 and <50
  2373.             if iOldX == iTargetX and iOldY == iTargetY:
  2374.                 for i in range(pTargetPlot.getNumUnits()):
  2375.                     pUnit = pTargetPlot.getUnit(i)
  2376.                     pUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), False)
  2377.                    
  2378.  
  2379.         #Use this section to get rid of HELD promotions from SoD units (if they didn't make it into the group then they get stuck)
  2380.         if iGameTurn == 120:
  2381.             for iGoodSofDPlayer in range(gc.getMAX_PLAYERS()):
  2382.                 pGoodSofDPlayer = gc.getPlayer(iGoodSofDPlayer)
  2383.                 if (pGoodSofDPlayer.isAlive()):
  2384.                     if pGoodSofDPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_BANNOR'):
  2385.                         pySofD = PyPlayer(iGoodSofDPlayer)
  2386.                         if pGoodSofDPlayer.getNumUnits() > 0:
  2387.                             for pMaybeHeldUnit in pySofD.getUnitList():
  2388.                                 if pMaybeHeldUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_SofD')):
  2389.                                     if pMaybeHeldUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD')):
  2390.                                         pMaybeHeldUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), False)
  2391.                     if pGoodSofDPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_ELOHIM'):
  2392.                         pySofD = PyPlayer(iGoodSofDPlayer)
  2393.                         if pGoodSofDPlayer.getNumUnits() > 0:
  2394.                             for pMaybeHeldUnit in pySofD.getUnitList():
  2395.                                 if pMaybeHeldUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_SofD')):
  2396.                                     if pMaybeHeldUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD')):
  2397.                                         pMaybeHeldUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), False)
  2398.                     if pGoodSofDPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_KURIOTATES'):
  2399.                         pySofD = PyPlayer(iGoodSofDPlayer)
  2400.                         if pGoodSofDPlayer.getNumUnits() > 0:
  2401.                             for pMaybeHeldUnit in pySofD.getUnitList():
  2402.                                 if pMaybeHeldUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_SofD')):
  2403.                                     if pMaybeHeldUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD')):
  2404.                                         pMaybeHeldUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), False)   
  2405.                     if pGoodSofDPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LJOSALFAR'):
  2406.                         pySofD = PyPlayer(iGoodSofDPlayer)
  2407.                         if pGoodSofDPlayer.getNumUnits() > 0:
  2408.                             for pMaybeHeldUnit in pySofD.getUnitList():
  2409.                                 if pMaybeHeldUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_SofD')):
  2410.                                     if pMaybeHeldUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD')):
  2411.                                         pMaybeHeldUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), False)
  2412.                     if pGoodSofDPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LUCHUIRP'):
  2413.                         pySofD = PyPlayer(iGoodSofDPlayer)
  2414.                         if pGoodSofDPlayer.getNumUnits() > 0:
  2415.                             for pMaybeHeldUnit in pySofD.getUnitList():
  2416.                                 if pMaybeHeldUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_SofD')):
  2417.                                     if pMaybeHeldUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD')):
  2418.                                         pMaybeHeldUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), False)
  2419.  
  2420.  
  2421.         #Popup to explain why Bane Divine will be built
  2422.         if iGameTurn == 100:
  2423.             sf.addPopupWB(CyTranslator().getText("TXT_KEY_WB_ELOHIM_SCENARIO_BANE_DIVINE_CREATE",()),'')                                       
  2424.                                        
  2425.                
  2426.         #Perhaps a better method would be to produce Bane Divine (e.g.) 20 turns after the SoD starts moving out of the marshalling point (59, 11)
  2427.         #Create a ritual on a particular turn and/or when the Stack of Doom reaches (iTargetX, iTargetY) - I decided to use a particular turn because it is easier to do!
  2428.         #Push order: 1st BOOL to set it to make it forever; 2nd BOOL to replace current production; 3rd BOOL to put the new production on bottom of the queue; 4th BOOL to force the production even if you can't normally make it
  2429.         for iBaneCreatePlayer in range(gc.getMAX_PLAYERS()):
  2430.             pTargetPlayer = gc.getPlayer(iBaneCreatePlayer)
  2431.             if pTargetPlayer.isAlive():
  2432.                 if pTargetPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LUCHUIRP'):
  2433.                     if not pTargetPlayer.isHuman():
  2434.                         for pyCity in PyPlayer(iBaneCreatePlayer).getCityList():
  2435.                             pTargetCity = pyCity.GetCy()
  2436.                             if pTargetCity.isCapital():
  2437.                                 #if iGameTurn == 3:
  2438.                                 #Load current (x,y) values of the Stack of Doom and then check if the stack is at the target tile
  2439.                                 serializedMyPickle = BugData.getTable("MY_TABLE").data
  2440.                                 myPickle = pickle.loads(serializedMyPickle)
  2441.                                 iOldX = myPickle[0]
  2442.                                 iOldY = myPickle[1]
  2443.                                 iTargetX = 60
  2444.                                 iTargetY = 18
  2445.                                 #if iOldX == iTargetX and iOldY == iTargetY:
  2446.                                 if iGameTurn == 350:                               
  2447.                                     if pTargetCity.canCreate(gc.getInfoTypeForString('PROJECT_BANE_DIVINE'), True, True):
  2448.                                         pTargetCity.pushOrder(OrderTypes.ORDER_CREATE, gc.getInfoTypeForString('PROJECT_BANE_DIVINE'), -1, False, True, False, False)
  2449.                                         pTargetCity.setProduction(10000)
  2450.                                         return 1
  2451.        
  2452.            
  2453.         #Different popups for the plague depending on whether the Luchuirp have declared war on the other good civs or not             
  2454.         #This gives the plagued promotion to all living units e.g. 5 turns after Bane Divine is built (N.B. Bane Divine == 50, plagued == 55)
  2455.         if iGameTurn == 125:
  2456.             if gc.getTeam(iLuchuirpTeamID).isAlive:
  2457.                 if gc.getTeam(iLuchuirpTeamID).isAtWar(iElohimTeamID):
  2458.                     sf.addPopupWB(CyTranslator().getText("TXT_KEY_WB_ELOHIM_SCENARIO_PLAGUED_LUCHUIRP_BAD",()),'')
  2459.                 if not gc.getTeam(iLuchuirpTeamID).isAtWar(iElohimTeamID):
  2460.                     sf.addPopupWB(CyTranslator().getText("TXT_KEY_WB_ELOHIM_SCENARIO_PLAGUED_LUCHUIRP_GOOD",()),'')
  2461.             for iPlaguedUnitsPlayer in range(gc.getMAX_PLAYERS()):
  2462.                 PlaguedUnitsPlayer = gc.getPlayer(iPlaguedUnitsPlayer)
  2463.                 if PlaguedUnitsPlayer.isAlive():
  2464.                     py = PyPlayer(iPlaguedUnitsPlayer)
  2465.                     for pPlaguedUnit in py.getUnitList():
  2466.                         if pPlaguedUnit.isAlive():
  2467.                             pPlaguedUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_DISEASED'), True)
  2468.  
  2469.                            
  2470.         #Create AI cities randomly here (because the AI very rarely builds cities while they are at war from the start)
  2471.         #check if (3, 48) is owned or has any units on it
  2472.         #roll a die, there is a .1% chance that a calabim city will be built on it (e.g. 29 sites, each has a 0.1% chance of a new city -> 3% chance of a new city that turn)
  2473.         #Needs a new name for each getSorenRandNum for a new random number
  2474.         for iNewCityCivPlayer in range(gc.getMAX_PLAYERS()):
  2475.             pNewCityCivPlayer = gc.getPlayer(iNewCityCivPlayer)
  2476.             if pNewCityCivPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_BANNOR'):
  2477.                 BannorSites = [(47, 3), (53, 3), (58, 3), (63, 3), (68, 3), (45, 8), (50, 8), (61, 9), (43, 13), (48, 13), (53, 13), (58, 13), (63, 13), (45, 18), (50, 18), (55, 18), (60, 18)]
  2478.                 for iBannCityNum in range(len(BannorSites)):
  2479.                     xBannSite = BannorSites[iBannCityNum][0]
  2480.                     yBannSite = BannorSites[iBannCityNum][1]
  2481.                     pBannorCityPlot = CyMap().plot(xBannSite, yBannSite)
  2482.                     if CyGame().getSorenRandNum(1000, "BannorCity"+str(iBannCityNum)) <= 1:
  2483.                         if pBannorCityPlot.getNumUnits() == 0:
  2484.                             if pBannorCityPlot.isOwned() == False:
  2485.                                 pNewCityCivPlayer.initCity(xBannSite, yBannSite)
  2486.                                 pNewCityCivPlayer.initUnit(gc.getInfoTypeForString('UNIT_WARRIOR'), xBannSite, yBannSite, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
  2487.                    
  2488.             if pNewCityCivPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_CALABIM')
  2489.                 CalabimSites = [(3, 48), (7, 48), (12, 48), (17, 48), (23, 48), (28, 48), (7, 43), (13, 43), (20, 43), (25, 43), (3, 39), (16, 39), (8, 38), (27, 38), (23, 35), (4, 33), (18, 33), (28, 33), (9, 31), (14, 30), (23, 30), (4, 29), (9, 26), (15, 25), (3, 24), (20, 24), (5, 20), (10, 20), (17, 19)]
  2490.                 for iCalaCityNum in range(len(CalabimSites)):
  2491.                     xCalaSite = CalabimSites[iCalaCityNum][0]
  2492.                     yCalaSite = CalabimSites[iCalaCityNum][1]
  2493.                     pCalabimCityPlot = CyMap().plot(xCalaSite, yCalaSite)
  2494.                     if CyGame().getSorenRandNum(1000, "CalabimCity"+str(iCalaCityNum)) <= 1:
  2495.                         if pCalabimCityPlot.getNumUnits() == 0:
  2496.                             if pCalabimCityPlot.isOwned() == False:
  2497.                                 pNewCityCivPlayer.initCity(xCalaSite, yCalaSite)
  2498.                                 pNewCityCivPlayer.initUnit(gc.getInfoTypeForString('UNIT_BLOODPET'), xCalaSite, yCalaSite, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
  2499.                                        
  2500.             if pNewCityCivPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_CLAN_OF_EMBERS'):
  2501.                 ClanOfEmbersSites = [(32, 36), (43, 36), (23, 35), (28, 33), (35, 32), (40, 32), (48, 32), (28, 28), (32, 28), (37, 28), (15, 25), (20, 24), (24, 23), (29, 23), (40, 22), (17, 19), (23, 18), (28, 18), (33, 18), (38, 32), (45, 18), (27, 13), (32, 13), (38, 13), (43, 13), (48, 13)]
  2502.                 for iClanCityNum in range(len(ClanOfEmbersSites)):
  2503.                     xClanSite = ClanOfEmbersSites[iClanCityNum][0]
  2504.                     yClanSite = ClanOfEmbersSites[iClanCityNum][1]
  2505.                     pClanOfEmbersCityPlot = CyMap().plot(xClanSite, yClanSite)
  2506.                     if CyGame().getSorenRandNum(1000, "ClanOfEmbersCity"+str(iClanCityNum)) <= 1:
  2507.                         if pClanOfEmbersCityPlot.getNumUnits() == 0:
  2508.                             if pClanOfEmbersCityPlot.isOwned() == False:
  2509.                                 pNewCityCivPlayer.initCity(xClanSite, yClanSite)
  2510.                                 pNewCityCivPlayer.initUnit(gc.getInfoTypeForString('UNIT_WARRIOR'), xClanSite, yClanSite, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
  2511.                        
  2512.             if pNewCityCivPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_DOVIELLO'):
  2513.                 DovielloSites = [(53, 3), (47, 3), (29, 3), (24, 3), (19, 3), (50, 8), (45, 8), (32, 8), (27, 8), (22, 8), (38, 9), (48, 13), (43, 13), (38, 13), (32, 13), (27, 13), (22, 13), (45, 18), (38, 18), (33, 18), (28, 18), (23, 18)]
  2514.                 for iDovCityNum in range(len(DovielloSites)):
  2515.                     xDovSite = DovielloSites[iDovCityNum][0]
  2516.                     yDovSite = DovielloSites[iDovCityNum][1]
  2517.                     pDovielloCityPlot = CyMap().plot(xDovSite, yDovSite)
  2518.                     if CyGame().getSorenRandNum(1000, "DovielloCity"+str(iDovCityNum)) <= 1:
  2519.                         if pDovielloCityPlot.getNumUnits() == 0:
  2520.                             if pDovielloCityPlot.isOwned() == False:
  2521.                                 pNewCityCivPlayer.initCity(xDovSite, yDovSite)
  2522.                                 pNewCityCivPlayer.initUnit(gc.getInfoTypeForString('UNIT_BEASTMAN'), xDovSite, yDovSite, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
  2523.  
  2524.             if pNewCityCivPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_ELOHIM'):
  2525.                 iBlank = 1
  2526.             if pNewCityCivPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_KURIOTATES'):
  2527.                 #The first 4 sites (including capital) will be cities, after that the sites will be settlements
  2528.                 #Kuriotates cities have a radius of 3 compared to other civs that have city radii of 2
  2529.                 #Settlements can get larger when the AI casts Legends or if Octopus Overlords is in the settlements
  2530.                 iKurioSite1 = 0
  2531.                 iKurioSite2 = 0
  2532.                 iKurioSite3 = 0
  2533.                 if pNewCityCivPlayer.getNumCities() < 4:
  2534.                     if CyMap().plot(70, 22).getNumUnits() == 0 and CyMap().plot(70, 22).isOwned() == False:
  2535.                         iKurioSite1 = 5
  2536.                     if CyMap().plot(79, 19).getNumUnits() == 0 and CyMap().plot(70, 22).isOwned() == False:
  2537.                         iKurioSite2 = 5
  2538.                     if CyMap().plot(63, 13).getNumUnits() == 0 and CyMap().plot(70, 22).isOwned() == False:    
  2539.                         iKurioSite3 = 5
  2540.                     if iKurioSite1 == 5 or iKurioSite2 == 5 or iKurioSite3 == 5:
  2541.                         #At least one tier 1 site is vacant
  2542.                         #If all 3 sites are available then chance is 6/1000 each, if 2 sites are available then chance is 11/1000, if 1 site is available then chance is 16/1000
  2543.                         pKuriotatesCityPlot = CyMap().plot(70, 22)
  2544.                         if CyGame().getSorenRandNum(1000, "KuriotatesCity1") <= (21 - iKurioSite1 - iKurioSite2 - iKurioSite3):
  2545.                             if pKuriotatesCityPlot.getNumUnits() == 0:
  2546.                                 if pKuriotatesCityPlot.isOwned() == False:
  2547.                                     pNewCityCivPlayer.initCity(70, 22)
  2548.                                     pNewCityCivPlayer.initUnit(gc.getInfoTypeForString('UNIT_WARRIOR'), 70, 22, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)                                     
  2549.                         pKuriotatesCityPlot = CyMap().plot(79, 19)
  2550.                         if CyGame().getSorenRandNum(1000, "KuriotatesCity2") <= (21 - iKurioSite1 - iKurioSite2 - iKurioSite3):
  2551.                             if pKuriotatesCityPlot.getNumUnits() == 0:
  2552.                                 if pKuriotatesCityPlot.isOwned() == False:
  2553.                                     pNewCityCivPlayer.initCity(79, 19)
  2554.                                     pNewCityCivPlayer.initUnit(gc.getInfoTypeForString('UNIT_WARRIOR'), 79, 19, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)                             
  2555.                         pKuriotatesCityPlot = CyMap().plot(63, 13)
  2556.                         if CyGame().getSorenRandNum(1000, "KuriotatesCity3") <= (21 - iKurioSite1 - iKurioSite2 - iKurioSite3):
  2557.                             if pKuriotatesCityPlot.getNumUnits() == 0:
  2558.                                 if pKuriotatesCityPlot.isOwned() == False:
  2559.                                     pNewCityCivPlayer.initCity(63, 13)
  2560.                                     pNewCityCivPlayer.initUnit(gc.getInfoTypeForString('UNIT_WARRIOR'), 63, 13, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)                             
  2561.                     if iKurioSite1 == 0 and iKurioSite2 == 0 and iKurioSite3 == 0:
  2562.                         #None of the 3 tier 1 sites are vacant but there are less than 4 cities (including the capital)
  2563.                         #Therefore try to build a city on a second tier site
  2564.                         pKuriotatesCityPlot = CyMap().plot(79, 4)
  2565.                         if CyGame().getSorenRandNum(1000, "KuriotatesCity4") <= 8:
  2566.                             if pKuriotatesCityPlot.getNumUnits() == 0:
  2567.                                 if pKuriotatesCityPlot.isOwned() == False:
  2568.                                     pNewCityCivPlayer.initCity(79, 4)
  2569.                                     pNewCityCivPlayer.initUnit(gc.getInfoTypeForString('UNIT_WARRIOR'), 79, 4, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)                              
  2570.                         pKuriotatesCityPlot = CyMap().plot(73, 3)
  2571.                         if CyGame().getSorenRandNum(1000, "KuriotatesCity5") <= 8:
  2572.                             if pKuriotatesCityPlot.getNumUnits() == 0:
  2573.                                 if pKuriotatesCityPlot.isOwned() == False:
  2574.                                     pNewCityCivPlayer.initCity(73, 3)
  2575.                                     pNewCityCivPlayer.initUnit(gc.getInfoTypeForString('UNIT_WARRIOR'), 73, 3, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)                              
  2576.                         pKuriotatesCityPlot = CyMap().plot(66, 8)
  2577.                         if CyGame().getSorenRandNum(1000, "KuriotatesCity6") <= 8:
  2578.                             if pKuriotatesCityPlot.getNumUnits() == 0:
  2579.                                 if pKuriotatesCityPlot.isOwned() == False:
  2580.                                     pNewCityCivPlayer.initCity(66, 8)
  2581.                                     pNewCityCivPlayer.initUnit(gc.getInfoTypeForString('UNIT_WARRIOR'), 66, 8, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)                              
  2582.                         pKuriotatesCityPlot = CyMap().plot(70, 15)
  2583.                         if CyGame().getSorenRandNum(1000, "KuriotatesCity7") <= 8:
  2584.                             if pKuriotatesCityPlot.getNumUnits() == 0:
  2585.                                 if pKuriotatesCityPlot.isOwned() == False:
  2586.                                     pNewCityCivPlayer.initCity(70, 15)
  2587.                                     pNewCityCivPlayer.initUnit(gc.getInfoTypeForString('UNIT_WARRIOR'), 70, 15, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)                             
  2588.                         pKuriotatesCityPlot = CyMap().plot(72, 29)
  2589.                         if CyGame().getSorenRandNum(1000, "KuriotatesCity8") <= 8:
  2590.                             if pKuriotatesCityPlot.getNumUnits() == 0:
  2591.                                 if pKuriotatesCityPlot.isOwned() == False:
  2592.                                     pNewCityCivPlayer.initCity(72, 29)
  2593.                                     pNewCityCivPlayer.initUnit(gc.getInfoTypeForString('UNIT_WARRIOR'), 72, 29, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)                             
  2594.                 if pNewCityCivPlayer.getNumCities() > 3:
  2595.                     #This is when all 4 main cities have been built
  2596.                     #These are settlements only but uses tier 2 and tier 3 sites
  2597.                     pKuriotatesCityPlot = CyMap().plot(79, 4)
  2598.                     if CyGame().getSorenRandNum(1000, "KuriotatesCity9") <= 1:
  2599.                         if pKuriotatesCityPlot.getNumUnits() == 0:
  2600.                             if pKuriotatesCityPlot.isOwned() == False:
  2601.                                 pNewCityCivPlayer.initCity(79, 4)
  2602.                                 pNewCityCivPlayer.initUnit(gc.getInfoTypeForString('UNIT_WARRIOR'), 79, 4, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)                              
  2603.                     pKuriotatesCityPlot = CyMap().plot(73, 3)
  2604.                     if CyGame().getSorenRandNum(1000, "KuriotatesCity10") <= 1:
  2605.                         if pKuriotatesCityPlot.getNumUnits() == 0:
  2606.                             if pKuriotatesCityPlot.isOwned() == False:
  2607.                                 pNewCityCivPlayer.initCity(73, 3)
  2608.                                 pNewCityCivPlayer.initUnit(gc.getInfoTypeForString('UNIT_WARRIOR'), 73, 3, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)                              
  2609.                     pKuriotatesCityPlot = CyMap().plot(66, 8)
  2610.                     if CyGame().getSorenRandNum(1000, "KuriotatesCity11") <= 1:
  2611.                         if pKuriotatesCityPlot.getNumUnits() == 0:
  2612.                             if pKuriotatesCityPlot.isOwned() == False:
  2613.                                 pNewCityCivPlayer.initCity(66, 8)
  2614.                                 pNewCityCivPlayer.initUnit(gc.getInfoTypeForString('UNIT_WARRIOR'), 66, 8, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)                              
  2615.                     pKuriotatesCityPlot = CyMap().plot(70, 15)
  2616.                     if CyGame().getSorenRandNum(1000, "KuriotatesCity12") <= 1:
  2617.                         if pKuriotatesCityPlot.getNumUnits() == 0:
  2618.                             if pKuriotatesCityPlot.isOwned() == False:
  2619.                                 pNewCityCivPlayer.initCity(70, 15)
  2620.                                 pNewCityCivPlayer.initUnit(gc.getInfoTypeForString('UNIT_WARRIOR'), 70, 15, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)                             
  2621.                     pKuriotatesCityPlot = CyMap().plot(72, 29)
  2622.                     if CyGame().getSorenRandNum(1000, "KuriotatesCity13") <= 1:
  2623.                         if pKuriotatesCityPlot.getNumUnits() == 0:
  2624.                             if pKuriotatesCityPlot.isOwned() == False:
  2625.                                 pNewCityCivPlayer.initCity(72, 29)
  2626.                                 pNewCityCivPlayer.initUnit(gc.getInfoTypeForString('UNIT_WARRIOR'), 72, 29, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)                             
  2627.                     pKuriotatesCityPlot = CyMap().plot(76, 3)
  2628.                     if CyGame().getSorenRandNum(1000, "KuriotatesCity14") <= 1:
  2629.                         if pKuriotatesCityPlot.getNumUnits() == 0:
  2630.                             if pKuriotatesCityPlot.isOwned() == False:
  2631.                                 pNewCityCivPlayer.initCity(76, 3)
  2632.                                 pNewCityCivPlayer.initUnit(gc.getInfoTypeForString('UNIT_WARRIOR'), 76, 3, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)                              
  2633.                     pKuriotatesCityPlot = CyMap().plot(68, 2)
  2634.                     if CyGame().getSorenRandNum(1000, "KuriotatesCity15") <= 1:
  2635.                         if pKuriotatesCityPlot.getNumUnits() == 0:
  2636.                             if pKuriotatesCityPlot.isOwned() == False:
  2637.                                 pNewCityCivPlayer.initCity(68, 2)
  2638.                                 pNewCityCivPlayer.initUnit(gc.getInfoTypeForString('UNIT_WARRIOR'), 68, 2, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)                              
  2639.                     pKuriotatesCityPlot = CyMap().plot(61, 3)
  2640.                     if CyGame().getSorenRandNum(1000, "KuriotatesCity16") <= 1:
  2641.                         if pKuriotatesCityPlot.getNumUnits() == 0:
  2642.                             if pKuriotatesCityPlot.isOwned() == False:
  2643.                                 pNewCityCivPlayer.initCity(61, 3)
  2644.                                 pNewCityCivPlayer.initUnit(gc.getInfoTypeForString('UNIT_WARRIOR'), 61, 3, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)                              
  2645.                     pKuriotatesCityPlot = CyMap().plot(63, 7)
  2646.                     if CyGame().getSorenRandNum(1000, "KuriotatesCity17") <= 1:
  2647.                         if pKuriotatesCityPlot.getNumUnits() == 0:
  2648.                             if pKuriotatesCityPlot.isOwned() == False:
  2649.                                 pNewCityCivPlayer.initCity(63, 7)
  2650.                                 pNewCityCivPlayer.initUnit(gc.getInfoTypeForString('UNIT_WARRIOR'), 63, 7, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)                              
  2651.                     pKuriotatesCityPlot = CyMap().plot(74, 14)
  2652.                     if CyGame().getSorenRandNum(1000, "KuriotatesCity18") <= 1:
  2653.                         if pKuriotatesCityPlot.getNumUnits() == 0:
  2654.                             if pKuriotatesCityPlot.isOwned() == False:
  2655.                                 pNewCityCivPlayer.initCity(74, 14) 
  2656.                                 pNewCityCivPlayer.initUnit(gc.getInfoTypeForString('UNIT_WARRIOR'), 74, 14, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)                             
  2657.                     pKuriotatesCityPlot = CyMap().plot(77, 12)
  2658.                     if CyGame().getSorenRandNum(1000, "KuriotatesCity19") <= 1:
  2659.                         if pKuriotatesCityPlot.getNumUnits() == 0:
  2660.                             if pKuriotatesCityPlot.isOwned() == False:
  2661.                                 pNewCityCivPlayer.initCity(77, 12)
  2662.                                 pNewCityCivPlayer.initUnit(gc.getInfoTypeForString('UNIT_WARRIOR'), 77, 12, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)                             
  2663.                     pKuriotatesCityPlot = CyMap().plot(81, 15)
  2664.                     if CyGame().getSorenRandNum(1000, "KuriotatesCity20") <= 1:
  2665.                         if pKuriotatesCityPlot.getNumUnits() == 0:
  2666.                             if pKuriotatesCityPlot.isOwned() == False:
  2667.                                 pNewCityCivPlayer.initCity(81, 15)
  2668.                                 pNewCityCivPlayer.initUnit(gc.getInfoTypeForString('UNIT_WARRIOR'), 81, 15, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)                             
  2669.                     pKuriotatesCityPlot = CyMap().plot(75, 17)
  2670.                     if CyGame().getSorenRandNum(1000, "KuriotatesCity21") <= 1:
  2671.                         if pKuriotatesCityPlot.getNumUnits() == 0:
  2672.                             if pKuriotatesCityPlot.isOwned() == False:
  2673.                                 pNewCityCivPlayer.initCity(75, 17)
  2674.                                 pNewCityCivPlayer.initUnit(gc.getInfoTypeForString('UNIT_WARRIOR'), 75, 17, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)                             
  2675.                     pKuriotatesCityPlot = CyMap().plot(62, 18)
  2676.                     if CyGame().getSorenRandNum(1000, "KuriotatesCity22") <= 1:
  2677.                         if pKuriotatesCityPlot.getNumUnits() == 0:
  2678.                             if pKuriotatesCityPlot.isOwned() == False:
  2679.                                 pNewCityCivPlayer.initCity(62, 18)
  2680.                                 pNewCityCivPlayer.initUnit(gc.getInfoTypeForString('UNIT_WARRIOR'), 62, 18, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)                             
  2681.                     pKuriotatesCityPlot = CyMap().plot(59, 18)
  2682.                     if CyGame().getSorenRandNum(1000, "KuriotatesCity23") <= 1:
  2683.                         if pKuriotatesCityPlot.getNumUnits() == 0:
  2684.                             if pKuriotatesCityPlot.isOwned() == False:
  2685.                                 pNewCityCivPlayer.initCity(59, 18) 
  2686.                                 pNewCityCivPlayer.initUnit(gc.getInfoTypeForString('UNIT_WARRIOR'), 59, 18, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)                             
  2687.                     pKuriotatesCityPlot = CyMap().plot(82, 26)
  2688.                     if CyGame().getSorenRandNum(1000, "KuriotatesCity24") <= 1:
  2689.                         if pKuriotatesCityPlot.getNumUnits() == 0:
  2690.                             if pKuriotatesCityPlot.isOwned() == False:
  2691.                                 pNewCityCivPlayer.initCity(82, 26)
  2692.                                 pNewCityCivPlayer.initUnit(gc.getInfoTypeForString('UNIT_WARRIOR'), 82, 26, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)                             
  2693.  
  2694.             if pNewCityCivPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LJOSALFAR'):
  2695.                 LjosalfarSites = [(38, 43), (43, 48), (49, 48), (55, 48), (61, 48), (66, 48), (38, 43), (43, 43), (57, 43), (63, 43), (47, 39), (55, 38), (64, 38), (38, 38), (43, 36), (48, 32), (54, 34), (61, 34)]
  2696.                 for iLjoCityNum in range(len(LjosalfarSites)):
  2697.                     xLjoSite = LjosalfarSites[iLjoCityNum][0]
  2698.                     yLjoSite = LjosalfarSites[iLjoCityNum][1]
  2699.                     pLjosalfarCityPlot = CyMap().plot(xLjoSite, yLjoSite)
  2700.                     if CyGame().getSorenRandNum(1000, "LjosalfarCity"+str(iLjoCityNum)) <= 1:
  2701.                         if pLjosalfarCityPlot.getNumUnits() == 0:
  2702.                             if pLjosalfarCityPlot.isOwned() == False:
  2703.                                 pNewCityCivPlayer.initCity(xLjoSite, yLjoSite)
  2704.                                 pNewCityCivPlayer.initUnit(gc.getInfoTypeForString('UNIT_WARRIOR'), xLjoSite, yLjoSite, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)     
  2705.                        
  2706.             if pNewCityCivPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LUCHUIRP'):
  2707.                 LuchuirpSites = [(61, 48), (66, 48), (71, 48), (76, 48), (80, 48), (63, 43), (68, 43), (80, 43), (73, 42), (79, 39), (64, 38), (69, 37), (54, 34), (61, 34), (79, 34), (75, 33), (72, 33), (68, 32), (56, 29), (61, 28), (75, 28), (80, 28), (70, 27), (63, 24), (74, 24), (79, 23), (69, 22), (65, 19), (74, 19), (60, 18), (79, 18), (78, 13)]
  2708.                 for iLuchCityNum in range(len(LuchuirpSites)):
  2709.                     xLuchSite = LuchuirpSites[iLuchCityNum][0]
  2710.                     yLuchSite = LuchuirpSites[iLuchCityNum][1]
  2711.                     pLuchuirpCityPlot = CyMap().plot(xLuchSite, yLuchSite)
  2712.                     if CyGame().getSorenRandNum(1000, "LuchuirpCity"+str(iLuchCityNum)) <= 2:
  2713.                         if pLuchuirpCityPlot.getNumUnits() == 0:
  2714.                             if pLuchuirpCityPlot.isOwned() == False:
  2715.                                 pNewCityCivPlayer.initCity(xLuchSite, yLuchSite)
  2716.                                 pNewCityCivPlayer.initUnit(gc.getInfoTypeForString('UNIT_WARRIOR'), xLuchSite, yLuchSite, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)       
  2717.                                                                        
  2718.             if pNewCityCivPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_SHEAIM'):
  2719.                 SheaimSites = [(3, 3), (8, 3), (13, 3), (19, 3), (24, 3), (3, 8), (8, 8), (22, 8), (27, 8), (22, 13), (27, 13), (32, 13), (3, 15), (8, 15), (13, 15), (18, 15), (23, 18), (28, 18), (17, 19), (5, 20), (10, 20), (24, 23), (3, 24), (20, 24), (15, 25), (9, 26)]
  2720.                 for iSheCityNum in range(len(SheaimSites)):
  2721.                     xSheSite = SheaimSites[iSheCityNum][0]
  2722.                     ySheSite = SheaimSites[iSheCityNum][1]
  2723.                     pSheaimCityPlot = CyMap().plot(xSheSite, ySheSite)
  2724.                     if CyGame().getSorenRandNum(1000, "SheaimCity"+str(iSheCityNum)) <= 1:
  2725.                         if pSheaimCityPlot.getNumUnits() == 0:
  2726.                             if pSheaimCityPlot.isOwned() == False:
  2727.                                 pNewCityCivPlayer.initCity(xSheSite, ySheSite)
  2728.                                 pNewCityCivPlayer.initUnit(gc.getInfoTypeForString('UNIT_WARRIOR'), xSheSite, ySheSite, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
  2729.                                    
  2730.             if pNewCityCivPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_SVARTALFAR'):
  2731.                 SvartalfarSites = [(17, 48), (23, 48), (28, 48), (38, 48), (43, 48), (49, 48), (33, 46), (20, 43), (25, 43), (38, 43), (43, 43), (47, 39), (27, 38), (38, 38), (32, 36), (43, 36), (23, 35), (28, 33), (35, 32), (48, 32), (23, 30), (28, 28), (15, 25), (20, 24)]
  2732.                 for iSvartCityNum in range(len(SvartalfarSites)):
  2733.                     xSvartSite = SvartalfarSites[iSvartCityNum][0]
  2734.                     ySvartSite = SvartalfarSites[iSvartCityNum][1]
  2735.                     pSvartalfarCityPlot = CyMap().plot(xSvartSite, ySvartSite)
  2736.                     if CyGame().getSorenRandNum(1000, "SvartalfarCity"+str(iSvartCityNum)) <= 1:
  2737.                         if pSvartalfarCityPlot.getNumUnits() == 0:
  2738.                             if pSvartalfarCityPlot.isOwned() == False:
  2739.                                 pNewCityCivPlayer.initCity(xSvartSite, ySvartSite)
  2740.                                 pNewCityCivPlayer.initUnit(gc.getInfoTypeForString('UNIT_WARRIOR'), xSvartSite, ySvartSite, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
  2741.                                                
  2742.  
  2743.  
  2744.         # Create flames on forest tiles between the Luchuirp and the Ljosalfar if no units are on the tiles (nerfs Ljosalfar and simulates Luchuirp starting fires to harm Ljosalfar)
  2745.         if iGameTurn < 100:
  2746.             FlamePlaces = [(64, 50), (64, 49), (64, 48), (64, 47), (63, 50), (63, 49), (63, 48), (63, 47), (63, 46), (63, 45), (63, 50), (62, 49), (62, 48), (62, 47), (62, 46), (62, 45), (61, 50), (61, 49), (61, 48), (61, 47), (61, 46), (61, 45), (60, 50), (60, 49), (60, 48), (60, 47), (60, 46), (60, 45), (59, 50), (59, 49), (59, 48), (59, 47), (59, 46), (59, 45), (58, 50), (58, 49), (58, 48), (58, 47), (58, 46), (58, 45), (57, 50), (57, 49), (57, 48), (57, 47), (57, 46), (57, 45), (56, 50), (56, 49), (56, 48), (56, 47), (56, 46), (56, 45), (56, 44), (56, 43), (56, 42), (56, 41), (55, 50), (55, 49), (55, 48), (55, 47), (55, 46), (55, 45), (55, 44), (55, 43), (55, 42), (55, 41), (54, 50), (54, 49), (54, 48), (54, 47), (54, 46), (54, 45), (54, 44), (54, 43), (54, 42), (54, 41)]
  2747.             for iFlame in range(len(FlamePlaces)):
  2748.                 xFlame = FlamePlaces[iFlame][0]
  2749.                 yFlame = FlamePlaces[iFlame][1]
  2750.                 pFlamePlot = CyMap().plot(xFlame, yFlame)
  2751.                 if CyGame().getSorenRandNum(1000, "LuchuirpCity"+str(iFlame)) <= 5:
  2752.                     if pFlamePlot.getFeatureType() == gc.getInfoTypeForString('FEATURE_FOREST'):
  2753.                         if pFlamePlot.isOwned() == False:
  2754.                             if pFlamePlot.getNumUnits() == 0:
  2755.                                 pFlamePlot.setFeatureType(gc.getInfoTypeForString('FEATURE_FLAMES'), 0)
  2756.  
  2757.     def onEndGameTurn(self, argsList):
  2758.         'Called at the end of the end of each turn'
  2759.         iGameTurn = argsList[0]
  2760.  
  2761.     def onBeginPlayerTurn(self, argsList):
  2762.         'Called at the beginning of a players turn'
  2763.         iGameTurn, iPlayer = argsList
  2764.         pPlayer = gc.getPlayer(iPlayer)
  2765.         player = PyPlayer(iPlayer)
  2766.  
  2767.         if not pPlayer.isHuman():
  2768.             if not CyGame().getWBMapScript():
  2769.                 cf.warScript(iPlayer)
  2770.  
  2771.         if pPlayer.getCivics(gc.getInfoTypeForString('CIVICOPTION_CULTURAL_VALUES')) == gc.getInfoTypeForString('CIVIC_CRUSADE'):
  2772.             cf.doCrusade(iPlayer)
  2773.  
  2774.         if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_KHAZAD'):
  2775.             cf.doTurnKhazad(iPlayer)
  2776.         elif pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LUCHUIRP'):
  2777.             cf.doTurnLuchuirp(iPlayer)
  2778.  
  2779.         if pPlayer.hasTrait(gc.getInfoTypeForString('TRAIT_INSANE')):
  2780.             if CyGame().getSorenRandNum(1000, "Insane") < 20:
  2781.                 iEvent = CvUtil.findInfoTypeNum(gc.getEventTriggerInfo, gc.getNumEventTriggerInfos(),'EVENTTRIGGER_TRAIT_INSANE')
  2782.                 triggerData = pPlayer.initTriggeredData(iEvent, True, -1, -1, -1, iPlayer, -1, -1, -1, -1, -1)
  2783.  
  2784.         if pPlayer.hasTrait(gc.getInfoTypeForString('TRAIT_ADAPTIVE')):
  2785.             iBaseCycle = 100
  2786.             iCycle = (iBaseCycle * gc.getGameSpeedInfo(CyGame().getGameSpeedType()).getVictoryDelayPercent()) / 100
  2787.             for i in range(10):
  2788.                 if (i * iCycle) - 5 == iGameTurn:
  2789.                     iEvent = CvUtil.findInfoTypeNum(gc.getEventTriggerInfo, gc.getNumEventTriggerInfos(),'EVENTTRIGGER_TRAIT_ADAPTIVE')
  2790.                     triggerData = pPlayer.initTriggeredData(iEvent, True, -1, -1, -1, iPlayer, -1, -1, -1, -1, -1)
  2791.  
  2792.         if pPlayer.isHuman():
  2793.             if pPlayer.hasTrait(gc.getInfoTypeForString('TRAIT_BARBARIAN')):
  2794.                 eTeam = gc.getTeam(gc.getPlayer(gc.getBARBARIAN_PLAYER()).getTeam())
  2795.                 iTeam = pPlayer.getTeam()
  2796.                 if eTeam.isAtWar(iTeam) == False:
  2797.                     if 2 * CyGame().getPlayerScore(iPlayer) >= 3 * CyGame().getPlayerScore(CyGame().getRankPlayer(1)):
  2798.                         if iGameTurn >= 20:
  2799.                             eTeam.declareWar(iTeam, False, WarPlanTypes.WARPLAN_TOTAL)
  2800.                             if iPlayer == CyGame().getActivePlayer():
  2801.                                 cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_BARBARIAN_DECLARE_WAR",()), 'art/interface/popups/Barbarian.dds')
  2802.  
  2803.  
  2804.     def onEndPlayerTurn(self, argsList):
  2805.         'Called at the end of a players turn'
  2806.         iGameTurn, iPlayer = argsList
  2807.         pPlayer = gc.getPlayer(iPlayer)
  2808.         if gc.getGame().getElapsedGameTurns() == 1:
  2809.             if pPlayer.isHuman():
  2810.                 if pPlayer.canRevolution(0):
  2811.                     popupInfo = CyPopupInfo()
  2812.                     popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_CHANGECIVIC)
  2813.                     popupInfo.addPopup(iPlayer)
  2814.  
  2815.         CvAdvisorUtils.resetAdvisorNags()
  2816.         CvAdvisorUtils.endTurnFeats(iPlayer)
  2817.  
  2818.     def onEndTurnReady(self, argsList):
  2819.         iGameTurn = argsList[0]
  2820.  
  2821.     def onFirstContact(self, argsList):
  2822.     ## Platy Builder ##
  2823.         if CyGame().GetWorldBuilderMode() and not CvPlatyBuilderScreen.bPython: return
  2824.     ## Platy Builder ##
  2825.         'Contact'
  2826.         iTeamX,iHasMetTeamY = argsList
  2827.         if (not self.__LOG_CONTACT):
  2828.             return
  2829.         CvUtil.pyPrint('Team %d has met Team %d' %(iTeamX, iHasMetTeamY))
  2830.  
  2831.     def onCombatResult(self, argsList):
  2832.         'Combat Result'
  2833.         pWinner,pLoser = argsList
  2834.         playerX = PyPlayer(pWinner.getOwner())
  2835.         unitX = PyInfo.UnitInfo(pWinner.getUnitType())
  2836.         playerY = PyPlayer(pLoser.getOwner())
  2837.         unitY = PyInfo.UnitInfo(pLoser.getUnitType())
  2838.  
  2839. ## Advanced Tactics Start - ships and siege engines can be captured
  2840. ## adopted from mechaerik War Prize ModComp
  2841.         if gc.getGame().isOption(GameOptionTypes.GAMEOPTION_ADVANCED_TACTICS):
  2842.             pPlayer = gc.getPlayer(pWinner.getOwner())
  2843.             pPlayerLoser = gc.getPlayer(pLoser.getOwner())
  2844.             if (not pWinner.isHiddenNationality()):
  2845.                 if (pLoser.canMoveInto(pWinner.plot(), True, True, False)):
  2846.                     if (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_NAVAL")):
  2847.                         if (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_NAVAL")):
  2848.                             if CyGame().getSorenRandNum(100, "WarPrizes Naval") <= 25:
  2849.                                 iUnit = pLoser.getUnitType()
  2850.                                 newUnit = pPlayer.initUnit(pLoser.getUnitType(), pWinner.getX(), pWinner.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION)
  2851.                                 newUnit.finishMoves()
  2852.                                 newUnit.setDamage(75, pWinner.getOwner())
  2853.                                 if (pPlayer.isHuman()):
  2854.                                     CyInterface().addMessage(pWinner.getOwner(),False,20,CyTranslator().getText("TXT_KEY_WEHAVECAPTUREDSOMETHING",(pLoser.getName(),)),'',0,gc.getUnitInfo(newUnit.getUnitType()).getButton(),ColorTypes(gc.getInfoTypeForString("COLOR_GREEN")), pWinner.getX(), pWinner.getY(), True,True)
  2855.                                 elif (pPlayerLoser.isHuman()):
  2856.                                     CyInterface().addMessage(pLoser.getOwner(),False,20,CyTranslator().getText("TXT_KEY_WEHAVELOSTSOMETHING",(pLoser.getName(),)),'',0,gc.getUnitInfo(newUnit.getUnitType()).getButton(),ColorTypes(gc.getInfoTypeForString("COLOR_RED")), pLoser.getX(), pLoser.getY(), True,True)
  2857.                     if (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_SIEGE")):
  2858.                         if CyGame().getSorenRandNum(100, "WarPrizes Siege") <= 15:
  2859.                             iUnit = pLoser.getUnitType()
  2860.                             newUnit = pPlayer.initUnit(pLoser.getUnitType(), pWinner.getX(), pWinner.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION)
  2861.                             newUnit.finishMoves()
  2862.                             newUnit.setDamage(75, pWinner.getOwner())
  2863.                             if (pPlayer.isHuman()):
  2864.                                 CyInterface().addMessage(pWinner.getOwner(),False,20,CyTranslator().getText("TXT_KEY_MISC_WARPRIZES_SUCCESS",(pLoser.getName(),)),'',0,gc.getUnitInfo(newUnit.getUnitType()).getButton(),ColorTypes(gc.getInfoTypeForString("COLOR_GREEN")), pWinner.getX(), pWinner.getY(), True,True)
  2865.                             elif (pPlayerLoser.isHuman()):
  2866.                                 CyInterface().addMessage(pLoser.getOwner(),False,20,CyTranslator().getText("TXT_KEY_MISC_WARPRIZES_FAILURE",(pLoser.getName(),)),'',0,gc.getUnitInfo(newUnit.getUnitType()).getButton(),ColorTypes(gc.getInfoTypeForString("COLOR_RED")), pLoser.getX(), pLoser.getY(), True,True)
  2867. ## End Advanced Tactics
  2868.  
  2869.         if not self.__LOG_COMBAT:
  2870.             return
  2871.         if playerX and playerX and unitX and playerY:
  2872.             CvUtil.pyPrint('Player %d Civilization %s Unit %s has defeated Player %d Civilization %s Unit %s'
  2873.                 %(playerX.getID(), playerX.getCivilizationName(), unitX.getDescription(),
  2874.                 playerY.getID(), playerY.getCivilizationName(), unitY.getDescription()))
  2875.  
  2876.     def onCombatLogCalc(self, argsList):
  2877.         'Combat Result'
  2878.         genericArgs = argsList[0][0]
  2879.         cdAttacker = genericArgs[0]
  2880.         cdDefender = genericArgs[1]
  2881.         iCombatOdds = genericArgs[2]
  2882.         CvUtil.combatMessageBuilder(cdAttacker, cdDefender, iCombatOdds)
  2883.  
  2884.     def onCombatLogHit(self, argsList):
  2885.         'Combat Message'
  2886.         global gCombatMessages, gCombatLog
  2887.         genericArgs = argsList[0][0]
  2888.         cdAttacker = genericArgs[0]
  2889.         cdDefender = genericArgs[1]
  2890.         iIsAttacker = genericArgs[2]
  2891.         iDamage = genericArgs[3]
  2892.  
  2893.         if cdDefender.eOwner == cdDefender.eVisualOwner:
  2894.             szDefenderName = gc.getPlayer(cdDefender.eOwner).getNameKey()
  2895.         else:
  2896.             szDefenderName = localText.getText("TXT_KEY_TRAIT_PLAYER_UNKNOWN", ())
  2897.         if cdAttacker.eOwner == cdAttacker.eVisualOwner:
  2898.             szAttackerName = gc.getPlayer(cdAttacker.eOwner).getNameKey()
  2899.         else:
  2900.             szAttackerName = localText.getText("TXT_KEY_TRAIT_PLAYER_UNKNOWN", ())
  2901.  
  2902.         if (iIsAttacker == 0):
  2903.             combatMessage = localText.getText("TXT_KEY_COMBAT_MESSAGE_HIT", (szDefenderName, cdDefender.sUnitName, iDamage, cdDefender.iCurrHitPoints, cdDefender.iMaxHitPoints))
  2904.             CyInterface().addCombatMessage(cdAttacker.eOwner,combatMessage)
  2905.             CyInterface().addCombatMessage(cdDefender.eOwner,combatMessage)
  2906.             if (cdDefender.iCurrHitPoints <= 0):
  2907.                 combatMessage = localText.getText("TXT_KEY_COMBAT_MESSAGE_DEFEATED", (szAttackerName, cdAttacker.sUnitName, szDefenderName, cdDefender.sUnitName))
  2908.                 CyInterface().addCombatMessage(cdAttacker.eOwner,combatMessage)
  2909.                 CyInterface().addCombatMessage(cdDefender.eOwner,combatMessage)
  2910.         elif (iIsAttacker == 1):
  2911.             combatMessage = localText.getText("TXT_KEY_COMBAT_MESSAGE_HIT", (szAttackerName, cdAttacker.sUnitName, iDamage, cdAttacker.iCurrHitPoints, cdAttacker.iMaxHitPoints))
  2912.             CyInterface().addCombatMessage(cdAttacker.eOwner,combatMessage)
  2913.             CyInterface().addCombatMessage(cdDefender.eOwner,combatMessage)
  2914.             if (cdAttacker.iCurrHitPoints <= 0):
  2915.                 combatMessage = localText.getText("TXT_KEY_COMBAT_MESSAGE_DEFEATED", (szDefenderName, cdDefender.sUnitName, szAttackerName, cdAttacker.sUnitName))
  2916.                 CyInterface().addCombatMessage(cdAttacker.eOwner,combatMessage)
  2917.                 CyInterface().addCombatMessage(cdDefender.eOwner,combatMessage)
  2918.  
  2919.     def onImprovementBuilt(self, argsList):
  2920.     ## Platy Builder ##
  2921.         if CyGame().GetWorldBuilderMode() and not CvPlatyBuilderScreen.bPython: return
  2922.     ## Platy Builder ##
  2923.         'Improvement Built'
  2924.         iImprovement, iX, iY = argsList
  2925.         pPlot = CyMap().plot(iX, iY)
  2926.  
  2927.         if gc.getImprovementInfo(iImprovement).isUnique():
  2928.             CyEngine().addLandmark(pPlot, CvUtil.convertToStr(gc.getImprovementInfo(iImprovement).getDescription()))
  2929.  
  2930.             if iImprovement == gc.getInfoTypeForString('IMPROVEMENT_RING_OF_CARCER'):
  2931.                 pPlot.setMinLevel(15)
  2932.                 bPlayer = gc.getPlayer(gc.getBARBARIAN_PLAYER())
  2933.                 bPlayer.initUnit(gc.getInfoTypeForString('UNIT_BRIGIT_HELD'), pPlot.getX(), pPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
  2934.             elif iImprovement == gc.getInfoTypeForString('IMPROVEMENT_SEVEN_PINES'):
  2935.                 pPlot.setTerrainType(gc.getInfoTypeForString('TERRAIN_GRASS'), True, True)
  2936.                 pPlot.setFeatureType(gc.getInfoTypeForString('FEATURE_FOREST'), 1)
  2937.  
  2938.         if (not self.__LOG_IMPROVEMENT):
  2939.             return
  2940.         CvUtil.pyPrint('Improvement %s was built at %d, %d'
  2941.             %(PyInfo.ImprovementInfo(iImprovement).getDescription(), iX, iY))
  2942.  
  2943.     def onImprovementDestroyed(self, argsList):
  2944.     ## Platy Builder ##
  2945.         if CyGame().GetWorldBuilderMode() and not CvPlatyBuilderScreen.bPython: return
  2946.     ## Platy Builder ##
  2947.         'Improvement Destroyed'
  2948.         iImprovement, iOwner, iX, iY = argsList
  2949.         if gc.getImprovementInfo(iImprovement).isUnique():
  2950.             pPlot = CyMap().plot(iX, iY)
  2951.             CyEngine().removeLandmark(pPlot)
  2952.             if iImprovement == gc.getInfoTypeForString('IMPROVEMENT_RING_OF_CARCER'):
  2953.                 pPlot.setMinLevel(-1)
  2954.  
  2955.         if iImprovement == gc.getInfoTypeForString('IMPROVEMENT_NECROTOTEM'):
  2956.             CyGame().changeGlobalCounter(-2)
  2957.  
  2958.         if CyGame().getWBMapScript():
  2959.             sf.onImprovementDestroyed(iImprovement, iOwner, iX, iY)
  2960.  
  2961.         if (not self.__LOG_IMPROVEMENT):
  2962.             return
  2963.         CvUtil.pyPrint('Improvement %s was Destroyed at %d, %d'
  2964.             %(PyInfo.ImprovementInfo(iImprovement).getDescription(), iX, iY))
  2965.  
  2966.     def onRouteBuilt(self, argsList):
  2967.     ## Platy Builder ##
  2968.         if CyGame().GetWorldBuilderMode() and not CvPlatyBuilderScreen.bPython: return
  2969.     ## Platy Builder ##
  2970.         'Route Built'
  2971.         iRoute, iX, iY = argsList
  2972.         if (not self.__LOG_IMPROVEMENT):
  2973.             return
  2974.         CvUtil.pyPrint('Route %s was built at %d, %d'
  2975.             %(gc.getRouteInfo(iRoute).getDescription(), iX, iY))
  2976.  
  2977.     def onPlotRevealed(self, argsList):
  2978.     ## Platy Builder ##
  2979.         if CyGame().GetWorldBuilderMode() and not CvPlatyBuilderScreen.bPython: return
  2980.     ## Platy Builder ##
  2981.         'Plot Revealed'
  2982.         pPlot = argsList[0]
  2983.         iTeam = argsList[1]
  2984.  
  2985.     def onPlotFeatureRemoved(self, argsList):
  2986.         'Plot Revealed'
  2987.         pPlot = argsList[0]
  2988.         iFeatureType = argsList[1]
  2989.         pCity = argsList[2] # This can be null
  2990.  
  2991.     def onPlotPicked(self, argsList):
  2992.         'Plot Picked'
  2993.         pPlot = argsList[0]
  2994.         CvUtil.pyPrint('Plot was picked at %d, %d'
  2995.             %(pPlot.getX(), pPlot.getY()))
  2996.  
  2997.     def onNukeExplosion(self, argsList):
  2998.         'Nuke Explosion'
  2999.         pPlot, pNukeUnit = argsList
  3000.         CvUtil.pyPrint('Nuke detonated at %d, %d'
  3001.             %(pPlot.getX(), pPlot.getY()))
  3002.  
  3003.     def onGotoPlotSet(self, argsList):
  3004.         'Nuke Explosion'
  3005.         pPlot, iPlayer = argsList
  3006.  
  3007.     def onBuildingBuilt(self, argsList):
  3008.         'Building Completed'
  3009.         pCity, iBuildingType = argsList
  3010.         player = pCity.getOwner()
  3011.         pPlayer = gc.getPlayer(player)
  3012.         pPlot = pCity.plot()
  3013.         game = gc.getGame()
  3014.         iBuildingClass = gc.getBuildingInfo(iBuildingType).getBuildingClassType()
  3015.  
  3016.         if not gc.getGame().isNetworkMultiPlayer() and (pCity.getOwner() == gc.getGame().getActivePlayer()) and isWorldWonderClass(iBuildingClass):
  3017.     ## Platy Builder ##
  3018.             if not CyGame().GetWorldBuilderMode():
  3019.     ## Platy Builder ##
  3020.                 if gc.getBuildingInfo(iBuildingType).getMovie():
  3021.                     # If this is a wonder...
  3022.                     popupInfo = CyPopupInfo()
  3023.                     popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
  3024.                     popupInfo.setData1(iBuildingType)
  3025.                     popupInfo.setData2(pCity.getID())
  3026.                     popupInfo.setData3(0)
  3027.                     popupInfo.setText(u"showWonderMovie")
  3028.                     popupInfo.addPopup(pCity.getOwner())
  3029.  
  3030.         if iBuildingType == gc.getInfoTypeForString('BUILDING_INFERNAL_GRIMOIRE'):
  3031.             if CyGame().getSorenRandNum(100, "Bob") < 20:
  3032.                 pPlot2 = cf.findClearPlot(-1, pPlot)
  3033.                 if pPlot2 != -1:
  3034.                     bPlayer = gc.getPlayer(gc.getBARBARIAN_PLAYER())
  3035.                     newUnit = bPlayer.initUnit(gc.getInfoTypeForString('UNIT_BALOR'), pPlot2.getX(), pPlot2.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
  3036.                     CyInterface().addMessage(pCity.getOwner(),True,25,CyTranslator().getText("TXT_KEY_MESSAGE_INFERNAL_GRIMOIRE_BALOR",()),'AS2D_BALOR',1,'Art/Interface/Buttons/Units/Balor.dds',ColorTypes(7),newUnit.getX(),newUnit.getY(),True,True)
  3037.                     if pCity.getOwner() == CyGame().getActivePlayer():
  3038.                         cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_INFERNAL_GRIMOIRE_BALOR",()), 'art/interface/popups/Balor.dds')
  3039.  
  3040.         elif iBuildingType == gc.getInfoTypeForString('BUILDING_ALTAR_OF_THE_LUONNOTAR_FINAL'):
  3041.             pCity.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_ALTAR_OF_THE_LUONNOTAR_EXALTED'), 0)
  3042.         elif iBuildingType == gc.getInfoTypeForString('BUILDING_ALTAR_OF_THE_LUONNOTAR_EXALTED'):
  3043.             pCity.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_ALTAR_OF_THE_LUONNOTAR_DIVINE'), 0)
  3044.         elif iBuildingType == gc.getInfoTypeForString('BUILDING_ALTAR_OF_THE_LUONNOTAR_DIVINE'):
  3045.             pCity.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_ALTAR_OF_THE_LUONNOTAR_CONSECRATED'), 0)
  3046.         elif iBuildingType == gc.getInfoTypeForString('BUILDING_ALTAR_OF_THE_LUONNOTAR_CONSECRATED'):
  3047.             pCity.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_ALTAR_OF_THE_LUONNOTAR_BLESSED'), 0)
  3048.         elif iBuildingType == gc.getInfoTypeForString('BUILDING_ALTAR_OF_THE_LUONNOTAR_BLESSED'):
  3049.             pCity.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_ALTAR_OF_THE_LUONNOTAR_ANOINTED'), 0)
  3050.         elif iBuildingType == gc.getInfoTypeForString('BUILDING_ALTAR_OF_THE_LUONNOTAR_ANOINTED'):
  3051.             pCity.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_ALTAR_OF_THE_LUONNOTAR'), 0)
  3052.  
  3053.         elif iBuildingType == gc.getInfoTypeForString('BUILDING_MERCURIAN_GATE'):
  3054.             for iLoop in range(pPlot.getNumUnits(), -1, -1):
  3055.                 pUnit = pPlot.getUnit(iLoop)
  3056.                 pUnit.jumpToNearestValidPlot()
  3057.  
  3058.             iMercurianPlayer = pPlayer.initNewEmpire(gc.getInfoTypeForString('LEADER_BASIUM'), gc.getInfoTypeForString('CIVILIZATION_MERCURIANS'))
  3059.             if iMercurianPlayer != PlayerTypes.NO_PLAYER:
  3060.                 pMercurianPlayer = gc.getPlayer(iMercurianPlayer)
  3061.                 iTeam = pPlayer.getTeam()
  3062.                 iMercurianTeam = pMercurianPlayer.getTeam()
  3063.                 if iTeam < iMercurianTeam:
  3064.                     gc.getTeam(iTeam).addTeam(iMercurianTeam)
  3065.                 else:
  3066.                     gc.getTeam(iMercurianTeam).addTeam(iTeam)
  3067.  
  3068.                 pBasiumUnit = gc.getPlayer(iMercurianPlayer).initUnit(gc.getInfoTypeForString('UNIT_BASIUM'), pPlot.getX(), pPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
  3069.                 pBasiumUnit.setAvatarOfCivLeader(True)
  3070.                 gc.getPlayer(iMercurianPlayer).initUnit(gc.getInfoTypeForString('UNIT_SETTLER'), pPlot.getX(), pPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
  3071.                 gc.getPlayer(iMercurianPlayer).initUnit(gc.getInfoTypeForString('UNIT_ANGEL'), pPlot.getX(), pPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
  3072.                 gc.getPlayer(iMercurianPlayer).initUnit(gc.getInfoTypeForString('UNIT_ANGEL'), pPlot.getX(), pPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
  3073.                 gc.getPlayer(iMercurianPlayer).initUnit(gc.getInfoTypeForString('UNIT_ANGEL'), pPlot.getX(), pPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
  3074.                 gc.getPlayer(iMercurianPlayer).initUnit(gc.getInfoTypeForString('UNIT_ANGEL'), pPlot.getX(), pPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
  3075.                 gc.getPlayer(iMercurianPlayer).initUnit(gc.getInfoTypeForString('UNIT_ANGEL'), pPlot.getX(), pPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
  3076.                 gc.getPlayer(iMercurianPlayer).initUnit(gc.getInfoTypeForString('UNIT_ANGEL'), pPlot.getX(), pPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
  3077.                 gc.getPlayer(iMercurianPlayer).initUnit(gc.getInfoTypeForString('UNIT_WORKER'), pPlot.getX(), pPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
  3078.  
  3079.                 if pPlayer.isHuman():
  3080.                     popupInfo = CyPopupInfo()
  3081.                     popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON)
  3082.                     popupInfo.setText(CyTranslator().getText("TXT_KEY_POPUP_CONTROL_MERCURIANS",()))
  3083.                     popupInfo.setData1(player)
  3084.                     popupInfo.setData2(iMercurianPlayer)
  3085.                     popupInfo.addPythonButton(CyTranslator().getText("TXT_KEY_POPUP_YES", ()), "")
  3086.                     popupInfo.addPythonButton(CyTranslator().getText("TXT_KEY_POPUP_NO", ()), "")
  3087.                     popupInfo.setOnClickedPythonCallback("reassignPlayer")
  3088.                     popupInfo.addPopup(player)
  3089.  
  3090.         elif iBuildingType == gc.getInfoTypeForString('BUILDING_TOWER_OF_THE_ELEMENTS'):
  3091.             lList = ['UNIT_AIR_ELEMENTAL', 'UNIT_EARTH_ELEMENTAL', 'UNIT_FIRE_ELEMENTAL', 'UNIT_WATER_ELEMENTAL']
  3092.             iUnit = gc.getInfoTypeForString(lList[CyGame().getSorenRandNum(len(lList), "Pick Elemental")-1])
  3093.             newUnit = pPlayer.initUnit(iUnit, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_CITY_DEFENSE, DirectionTypes.DIRECTION_SOUTH)
  3094.             newUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), True)
  3095.             CyInterface().addMessage(player,True,25,CyTranslator().getText("TXT_KEY_MESSAGE_TOWER_OF_THE_ELEMENTS_SPAWN",()),'',1,gc.getUnitInfo(iUnit).getButton(),ColorTypes(8),pCity.getX(),pCity.getY(),True,True)
  3096.             iElemental = gc.getInfoTypeForString('PROMOTION_ELEMENTAL')
  3097.             iStrong = gc.getInfoTypeForString('PROMOTION_STRONG')
  3098.             apUnitList = PyPlayer(player).getUnitList()
  3099.             for pUnit in apUnitList:
  3100.                 if pUnit.isHasPromotion(iElemental):
  3101.                     pUnit.setHasPromotion(iStrong, True)
  3102.  
  3103.         elif iBuildingType == gc.getInfoTypeForString('BUILDING_TOWER_OF_NECROMANCY'):
  3104.             iUndead = gc.getInfoTypeForString('PROMOTION_UNDEAD')
  3105.             iStrong = gc.getInfoTypeForString('PROMOTION_STRONG')
  3106.             apUnitList = PyPlayer(player).getUnitList()
  3107.             for pUnit in apUnitList:
  3108.                 if pUnit.isHasPromotion(iUndead):
  3109.                     pUnit.setHasPromotion(iStrong, True)
  3110.  
  3111.         elif iBuildingType == gc.getInfoTypeForString('BUILDING_TEMPLE_OF_THE_HAND'):
  3112.             iSnow = gc.getInfoTypeForString('TERRAIN_SNOW')
  3113.             iFlames = gc.getInfoTypeForString('FEATURE_FLAMES')
  3114.             iFloodPlains = gc.getInfoTypeForString('FEATURE_FLOOD_PLAINS')
  3115.             iForest = gc.getInfoTypeForString('FEATURE_FOREST')
  3116.             iJungle = gc.getInfoTypeForString('FEATURE_JUNGLE')
  3117.             iScrub = gc.getInfoTypeForString('FEATURE_SCRUB')
  3118.             iSmoke = gc.getInfoTypeForString('IMPROVEMENT_SMOKE')
  3119.             iBlizzard = gc.getInfoTypeForString('FEATURE_BLIZZARD')
  3120.             iX = pCity.getX()
  3121.             iY = pCity.getY()
  3122.             for iiX in range(iX-2, iX+3, 1):
  3123.                 for iiY in range(iY-2, iY+3, 1):
  3124.                     pLoopPlot = CyMap().plot(iiX,iiY)
  3125.                     if not pLoopPlot.isNone():
  3126.                         if not pLoopPlot.isWater():
  3127.                             pLoopPlot.setTerrainType(iSnow, True, True)
  3128.                             if pLoopPlot.getImprovementType() == iSmoke:
  3129.                                 pLoopPlot.setImprovementType(-1)
  3130.                             iFeature = pLoopPlot.getFeatureType()
  3131.                             if iFeature == iForest:
  3132.                                 pLoopPlot.setFeatureType(iForest, 2)
  3133.                             if iFeature == iJungle:
  3134.                                 pLoopPlot.setFeatureType(iForest, 2)
  3135.                             if iFeature == iFlames:
  3136.                                 pLoopPlot.setFeatureType(-1, -1)
  3137.                             if iFeature == iFloodPlains:
  3138.                                 pLoopPlot.setFeatureType(-1, -1)
  3139.                             if iFeature == iScrub:
  3140.                                 pLoopPlot.setFeatureType(-1, -1)
  3141.                             if CyGame().getSorenRandNum(100, "Snowfall") < 2:
  3142.                                 pLoopPlot.setFeatureType(iBlizzard, -1)
  3143.             CyEngine().triggerEffect(gc.getInfoTypeForString('EFFECT_SNOWFALL'),pPlot.getPoint())
  3144.  
  3145.         elif iBuildingType == gc.getInfoTypeForString('BUILDING_GRAND_MENAGERIE'):
  3146.             if pPlayer.isHuman():
  3147.                 if not CyGame().getWBMapScript():
  3148.                     t = "TROPHY_FEAT_GRAND_MENAGERIE"
  3149.                     if not CyGame().isHasTrophy(t):
  3150.                         CyGame().changeTrophyValue(t, 1)
  3151.  
  3152.         CvAdvisorUtils.buildingBuiltFeats(pCity, iBuildingType)
  3153.  
  3154.         if (not self.__LOG_BUILDING):
  3155.             return
  3156.         CvUtil.pyPrint('%s was finished by Player %d Civilization %s'
  3157.             %(PyInfo.BuildingInfo(iBuildingType).getDescription(), pCity.getOwner(), gc.getPlayer(pCity.getOwner()).getCivilizationDescription(0)))
  3158.  
  3159.     def onProjectBuilt(self, argsList):
  3160.         'Project Completed'
  3161.         pCity, iProjectType = argsList
  3162.         game = gc.getGame()
  3163.         iPlayer = pCity.getOwner()
  3164.         pPlayer = gc.getPlayer(iPlayer)
  3165.         if not gc.getGame().isNetworkMultiPlayer() and pCity.getOwner() == gc.getGame().getActivePlayer():
  3166.     ## Platy Builder ##
  3167.             if not CyGame().GetWorldBuilderMode():
  3168.     ## Platy Builder ##
  3169.                 popupInfo = CyPopupInfo()
  3170.                 popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
  3171.                 popupInfo.setData1(iProjectType)
  3172.                 popupInfo.setData2(pCity.getID())
  3173.                 popupInfo.setData3(2)
  3174.                 popupInfo.setText(u"showWonderMovie")
  3175.                 popupInfo.addPopup(iPlayer)
  3176.  
  3177.         if iProjectType == gc.getInfoTypeForString('PROJECT_BANE_DIVINE'):
  3178.             iCombatDisciple = gc.getInfoTypeForString('UNITCOMBAT_DISCIPLE')
  3179.             for iLoopPlayer in range(gc.getMAX_PLAYERS()):
  3180.                 pLoopPlayer = gc.getPlayer(iLoopPlayer)
  3181.                 if pLoopPlayer.isAlive() :
  3182.                     apUnitList = PyPlayer(iLoopPlayer).getUnitList()
  3183.                     for pUnit in apUnitList:
  3184.                         if pUnit.getUnitCombatType() == iCombatDisciple:
  3185.                             pUnit.kill(False, pCity.getOwner())
  3186.  
  3187.         elif iProjectType == gc.getInfoTypeForString('PROJECT_GENESIS'):
  3188.             if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_ILLIANS'):
  3189.                 cf.snowgenesis(iPlayer)
  3190.             else:
  3191.                 cf.genesis(iPlayer)
  3192.  
  3193.         elif iProjectType == gc.getInfoTypeForString('PROJECT_GLORY_EVERLASTING'):
  3194.             iDemon = gc.getInfoTypeForString('PROMOTION_DEMON')
  3195.             iUndead = gc.getInfoTypeForString('PROMOTION_UNDEAD')
  3196.             for iLoopPlayer in range(gc.getMAX_PLAYERS()):
  3197.                 pLoopPlayer = gc.getPlayer(iLoopPlayer)
  3198.                 player = PyPlayer(iLoopPlayer)
  3199.                 if pLoopPlayer.isAlive():
  3200.                     apUnitList = player.getUnitList()
  3201.                     for pUnit in apUnitList:
  3202.                         if (pUnit.isHasPromotion(iDemon) or pUnit.isHasPromotion(iUndead)):
  3203.                             pUnit.kill(False, iPlayer)
  3204.  
  3205.         elif iProjectType == gc.getInfoTypeForString('PROJECT_RITES_OF_OGHMA'):
  3206.             i = 7
  3207.             iSize = CyMap().getWorldSize()
  3208.             if iSize == gc.getInfoTypeForString('WORLDSIZE_DUEL'):
  3209.                 i -= 3
  3210.             elif iSize == gc.getInfoTypeForString('WORLDSIZE_TINY'):
  3211.                 i =- 2
  3212.             elif iSize == gc.getInfoTypeForString('WORLDSIZE_SMALL'):
  3213.                 i -= 1
  3214.             elif iSize == gc.getInfoTypeForString('WORLDSIZE_LARGE'):
  3215.                 i += 1
  3216.             elif iSize == gc.getInfoTypeForString('WORLDSIZE_HUGE'):
  3217.                 i += 3
  3218.             cf.addBonus('BONUS_MANA',i,'Art/Interface/Buttons/WorldBuilder/mana_button.dds')
  3219.  
  3220.         elif iProjectType == gc.getInfoTypeForString('PROJECT_NATURES_REVOLT'):
  3221.             bPlayer = gc.getPlayer(gc.getBARBARIAN_PLAYER())
  3222.             py = PyPlayer(gc.getBARBARIAN_PLAYER())
  3223.             iAxeman = gc.getInfoTypeForString('UNITCLASS_AXEMAN')
  3224.             iBear = gc.getInfoTypeForString('UNIT_BEAR')
  3225.             iHeroicDefense = gc.getInfoTypeForString('PROMOTION_HEROIC_DEFENSE')
  3226.             iHeroicDefense2 = gc.getInfoTypeForString('PROMOTION_HEROIC_DEFENSE2')
  3227.             iHeroicStrength = gc.getInfoTypeForString('PROMOTION_HEROIC_STRENGTH')
  3228.             iHeroicStrength2 = gc.getInfoTypeForString('PROMOTION_HEROIC_STRENGTH2')
  3229.             iHunter = gc.getInfoTypeForString('UNITCLASS_HUNTER')
  3230.             iLion = gc.getInfoTypeForString('UNIT_LION')
  3231.             iScout = gc.getInfoTypeForString('UNITCLASS_SCOUT')
  3232.             iTiger = gc.getInfoTypeForString('UNIT_TIGER')
  3233.             iWarrior = gc.getInfoTypeForString('UNITCLASS_WARRIOR')
  3234.             iWolf = gc.getInfoTypeForString('UNIT_WOLF')
  3235.             iWorker = gc.getInfoTypeForString('UNITCLASS_WORKER')
  3236.             for pUnit in py.getUnitList():
  3237.                 bValid = False
  3238.                 if pUnit.getUnitClassType() == iWorker:
  3239.                     iNewUnit = iWolf
  3240.                     bValid = True
  3241.                 elif pUnit.getUnitClassType() == iScout:
  3242.                     iNewUnit = iLion
  3243.                     bValid = True
  3244.                 elif pUnit.getUnitClassType() == iWarrior:
  3245.                     iNewUnit = iLion
  3246.                     bValid = True
  3247.                 elif pUnit.getUnitClassType() == iHunter:
  3248.                     iNewUnit = iTiger
  3249.                     bValid = True
  3250.                 elif pUnit.getUnitClassType() == iAxeman:
  3251.                     iNewUnit = iBear
  3252.                     bValid = True
  3253.                 if bValid:
  3254.                     newUnit = bPlayer.initUnit(iNewUnit, pUnit.getX(), pUnit.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
  3255.                     newUnit = bPlayer.initUnit(iNewUnit, pUnit.getX(), pUnit.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
  3256.                     newUnit = bPlayer.initUnit(iNewUnit, pUnit.getX(), pUnit.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
  3257.                     pUnit.kill(True, PlayerTypes.NO_PLAYER)
  3258.             for iLoopPlayer in range(gc.getMAX_PLAYERS()):
  3259.                 pLoopPlayer = gc.getPlayer(iLoopPlayer)
  3260.                 if pLoopPlayer.isAlive():
  3261.                     py = PyPlayer(iLoopPlayer)
  3262.                     for pUnit in py.getUnitList():
  3263.                         if pUnit.isAnimal():
  3264.                             pUnit.setHasPromotion(iHeroicDefense, True)
  3265.                             pUnit.setHasPromotion(iHeroicDefense2, True)
  3266.                             pUnit.setHasPromotion(iHeroicStrength, True)
  3267.                             pUnit.setHasPromotion(iHeroicStrength2, True)
  3268.  
  3269.         elif iProjectType == gc.getInfoTypeForString('PROJECT_BLOOD_OF_THE_PHOENIX'):
  3270.             py = PyPlayer(iPlayer)
  3271.             apUnitList = py.getUnitList()
  3272.             for pUnit in apUnitList:
  3273.                 if pUnit.isAlive():
  3274.                     if pUnit.getUnitCombatType() != UnitCombatTypes.NO_UNITCOMBAT:
  3275.                         pUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_IMMORTAL'), True)
  3276.  
  3277.         elif iProjectType == gc.getInfoTypeForString('PROJECT_PURGE_THE_UNFAITHFUL'):
  3278.             for pyCity in PyPlayer(iPlayer).getCityList():
  3279.                 pCity2 = pyCity.GetCy()
  3280.                 iRnd = CyGame().getSorenRandNum(2, "Bob")
  3281.                 StateBelief = pPlayer.getStateReligion()
  3282.                 if StateBelief == gc.getInfoTypeForString('RELIGION_THE_ORDER'):
  3283.                     iRnd = iRnd - 1
  3284.                 for iTarget in range(gc.getNumReligionInfos()):
  3285.                     if (StateBelief != iTarget and pCity2.isHasReligion(iTarget) and pCity2.isHolyCityByType(iTarget) == False):
  3286.                         pCity2.setHasReligion(iTarget, False, True, True)
  3287.                         iRnd = iRnd + 1
  3288.                         for i in range(gc.getNumBuildingInfos()):
  3289.                             if gc.getBuildingInfo(i).getPrereqReligion() == iTarget:
  3290.                                 pCity2.setNumRealBuilding(i, 0)
  3291.                 if iRnd > 0:
  3292.                     pCity2.setOccupationTimer(iRnd)
  3293.  
  3294.         elif iProjectType == gc.getInfoTypeForString('PROJECT_BIRTHRIGHT_REGAINED'):
  3295.             pPlayer.setFeatAccomplished(FeatTypes.FEAT_GLOBAL_SPELL, False)
  3296.  
  3297.         elif iProjectType == gc.getInfoTypeForString('PROJECT_SAMHAIN'):
  3298.             for pyCity in PyPlayer(iPlayer).getCityList():
  3299.                 pCity = pyCity.GetCy()
  3300.                 pCity.changeHappinessTimer(20)
  3301.             iCount = CyGame().countCivPlayersAlive() + int(CyGame().getHandicapType()) - 5
  3302.             for i in range(iCount):
  3303.                 cf.addUnit(gc.getInfoTypeForString('UNIT_FROSTLING'))
  3304.                 cf.addUnit(gc.getInfoTypeForString('UNIT_FROSTLING'))
  3305.                 cf.addUnit(gc.getInfoTypeForString('UNIT_FROSTLING_ARCHER'))
  3306.                 cf.addUnit(gc.getInfoTypeForString('UNIT_FROSTLING_WOLF_RIDER'))
  3307.             cf.addUnit(gc.getInfoTypeForString('UNIT_MOKKA'))
  3308.  
  3309.         elif iProjectType == gc.getInfoTypeForString('PROJECT_THE_WHITE_HAND'):
  3310.             newUnit1 = pPlayer.initUnit(gc.getInfoTypeForString('UNIT_PRIEST_OF_WINTER'), pCity.getX(), pCity.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
  3311.             newUnit1.setName("Dumannios")
  3312.             newUnit2 = pPlayer.initUnit(gc.getInfoTypeForString('UNIT_PRIEST_OF_WINTER'), pCity.getX(), pCity.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
  3313.             newUnit2.setName("Riuros")
  3314.             newUnit3 = pPlayer.initUnit(gc.getInfoTypeForString('UNIT_PRIEST_OF_WINTER'), pCity.getX(), pCity.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
  3315.             newUnit3.setName("Anagantios")
  3316.  
  3317.         elif iProjectType == gc.getInfoTypeForString('PROJECT_THE_DEEPENING'):
  3318.             iDesert = gc.getInfoTypeForString('TERRAIN_DESERT')
  3319.             iGrass = gc.getInfoTypeForString('TERRAIN_GRASS')
  3320.             iMarsh = gc.getInfoTypeForString('TERRAIN_MARSH')
  3321.             iPlains = gc.getInfoTypeForString('TERRAIN_PLAINS')
  3322.             iSnow = gc.getInfoTypeForString('TERRAIN_SNOW')
  3323.             iTundra = gc.getInfoTypeForString('TERRAIN_TUNDRA')
  3324.             iBlizzard = gc.getInfoTypeForString('FEATURE_BLIZZARD')
  3325.             iModifier = (gc.getGameSpeedInfo(CyGame().getGameSpeedType()).getVictoryDelayPercent() * 20) / 100
  3326.             iTimer = 40 + iModifier
  3327.             for i in range (CyMap().numPlots()):
  3328.                 pPlot = CyMap().plotByIndex(i)
  3329.                 bValid = False
  3330.                 if pPlot.isWater() == False:
  3331.                     if CyGame().getSorenRandNum(100, "The Deepening") < 25:
  3332.                         iTerrain = pPlot.getTerrainType()
  3333.                         chance = CyGame().getSorenRandNum(100, "Bob")
  3334.                         if iTerrain == iSnow:
  3335.                             bValid = True
  3336.                         elif iTerrain == iTundra:
  3337.                             pPlot.setTempTerrainType(iSnow, CyGame().getSorenRandNum(iTimer, "Bob") + 10)
  3338.                             bValid = True
  3339.                         elif iTerrain == iGrass or iTerrain == iMarsh:
  3340.                             if chance < 40:
  3341.                                 pPlot.setTempTerrainType(iSnow, CyGame().getSorenRandNum(iTimer, "Bob") + 10)
  3342.                             else:
  3343.                                 pPlot.setTempTerrainType(iTundra, CyGame().getSorenRandNum(iTimer, "Bob") + 10)
  3344.                             bValid = True
  3345.                         elif iTerrain == iPlains:
  3346.                             if chance < 60:
  3347.                                 pPlot.setTempTerrainType(iSnow, CyGame().getSorenRandNum(iTimer, "Bob") + 10)
  3348.                             else:
  3349.                                 pPlot.setTempTerrainType(iTundra, CyGame().getSorenRandNum(iTimer, "Bob") + 10)
  3350.                             bValid = True
  3351.                         elif iTerrain == iDesert:
  3352.                             if chance < 10:
  3353.                                 pPlot.setTempTerrainType(iSnow, CyGame().getSorenRandNum(iTimer, "Bob") + 10)
  3354.                             elif chance < 30:
  3355.                                 pPlot.setTempTerrainType(iTundra, CyGame().getSorenRandNum(iTimer, "Bob") + 10)
  3356.                             else:
  3357.                                 pPlot.setTempTerrainType(iPlains, CyGame().getSorenRandNum(iTimer, "Bob") + 10)
  3358.                         if bValid:
  3359.                             if CyGame().getSorenRandNum(750, "The Deepening") < 10:
  3360.                                 pPlot.setFeatureType(iBlizzard,-1)
  3361.  
  3362.         elif iProjectType == gc.getInfoTypeForString('PROJECT_STIR_FROM_SLUMBER'):
  3363.             pPlayer.initUnit(gc.getInfoTypeForString('UNIT_DRIFA'), pCity.getX(), pCity.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
  3364.  
  3365.         elif iProjectType == gc.getInfoTypeForString('PROJECT_THE_DRAW'):
  3366.             iTeam = pPlayer.getTeam()
  3367.             eTeam = gc.getTeam(iTeam)
  3368.             for iLoopPlayer in range(gc.getMAX_PLAYERS()):
  3369.                 pLoopPlayer = gc.getPlayer(iLoopPlayer)
  3370.                 if pLoopPlayer.isAlive() and pLoopPlayer.getTeam() == iTeam:
  3371.                     pLoopPlayer.changeNoDiplomacyWithEnemies(1)
  3372.             for iLoopTeam in range(gc.getMAX_TEAMS()):
  3373.                 if iLoopTeam != iTeam:
  3374.                     if iLoopTeam != gc.getPlayer(gc.getBARBARIAN_PLAYER()).getTeam():
  3375.                         eLoopTeam = gc.getTeam(iLoopTeam)
  3376.                         if eLoopTeam.isAlive():
  3377.                             if not eLoopTeam.isAVassal():
  3378.                                 eTeam.declareWar(iLoopTeam, False, WarPlanTypes.WARPLAN_LIMITED)
  3379.             py = PyPlayer(iPlayer)
  3380.             for pUnit in py.getUnitList():
  3381.                 iDmg = pUnit.getDamage() * 2
  3382.                 if iDmg > 99:
  3383.                     iDmg = 99
  3384.                 if iDmg < 50:
  3385.                     iDmg = 50
  3386.                 pUnit.setDamage(iDmg, iPlayer)
  3387.             for pyCity in PyPlayer(iPlayer).getCityList():
  3388.                 pLoopCity = pyCity.GetCy()
  3389.                 iPop = int(pLoopCity.getPopulation() / 2)
  3390.                 if iPop < 1:
  3391.                     iPop = 1
  3392.                 pLoopCity.setPopulation(iPop)
  3393.  
  3394.         elif iProjectType == gc.getInfoTypeForString('PROJECT_ASCENSION'):
  3395.             pAuricUnit = pPlayer.initUnit(gc.getInfoTypeForString('UNIT_AURIC_ASCENDED'), pCity.getX(), pCity.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
  3396.             pAuricUnit.setAvatarOfCivLeader(True)
  3397.             if pPlayer.isHuman():
  3398.                 t = "TROPHY_FEAT_ASCENSION"
  3399.                 if not CyGame().isHasTrophy(t):
  3400.                     CyGame().changeTrophyValue(t, 1)
  3401.             if not CyGame().getWBMapScript():
  3402.                 iBestPlayer = -1
  3403.                 iBestValue = 0
  3404.                 for iLoopPlayer in range(gc.getMAX_PLAYERS()):
  3405.                     pLoopPlayer = gc.getPlayer(iLoopPlayer)
  3406.                     if pLoopPlayer.isAlive():
  3407.                         if not pLoopPlayer.isBarbarian():
  3408.                             if pLoopPlayer.getTeam() != pPlayer.getTeam():
  3409.                                 iValue = CyGame().getSorenRandNum(500, "Ascension")
  3410.                                 if pLoopPlayer.isHuman():
  3411.                                     iValue += 2000
  3412.                                 iValue += (20 - CyGame().getPlayerRank(iLoopPlayer)) * 50
  3413.                                 if iValue > iBestValue:
  3414.                                     iBestValue = iValue
  3415.                                     iBestPlayer = iLoopPlayer
  3416.                 if iBestPlayer != -1:
  3417.                     pBestPlayer = gc.getPlayer(iBestPlayer)
  3418.                     pBestCity = pBestPlayer.getCapitalCity()
  3419.                     if pBestPlayer.isHuman():
  3420.                         iEvent = CvUtil.findInfoTypeNum(gc.getEventTriggerInfo, gc.getNumEventTriggerInfos(),'EVENTTRIGGER_GODSLAYER')
  3421.                         triggerData = gc.getPlayer(iBestPlayer).initTriggeredData(iEvent, True, -1, pBestCity.getX(), pBestCity.getY(), iBestPlayer, -1, -1, -1, -1, -1)
  3422.                     else:
  3423.                         pBestPlayer.initUnit(gc.getInfoTypeForString('EQUIPMENT_GODSLAYER'), pBestCity.getX(), pBestCity.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
  3424.  
  3425.         elif iProjectType == gc.getInfoTypeForString('PROJECT_PACT_OF_THE_NILHORN'):
  3426.             newUnit1 = pPlayer.initUnit(gc.getInfoTypeForString('UNIT_HILL_GIANT'), pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_ATTACK, DirectionTypes.DIRECTION_NORTH)
  3427.             newUnit1.setName("Larry")
  3428.             newUnit1.AI_setGroupflag(10)
  3429.             newUnit1.setUnitAIType(gc.getInfoTypeForString('UNITAI_ATTACK_CITY'))
  3430.             newUnit2 = pPlayer.initUnit(gc.getInfoTypeForString('UNIT_HILL_GIANT'), pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_ATTACK, DirectionTypes.DIRECTION_NORTH)
  3431.             newUnit2.setName("Curly")
  3432.             newUnit2.AI_setGroupflag(10)
  3433.             newUnit2.setUnitAIType(gc.getInfoTypeForString('UNITAI_ATTACK_CITY'))
  3434.             newUnit3 = pPlayer.initUnit(gc.getInfoTypeForString('UNIT_HILL_GIANT'), pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_ATTACK, DirectionTypes.DIRECTION_NORTH)
  3435.             newUnit3.setName("Moe")
  3436.             newUnit3.AI_setGroupflag(10)
  3437.             newUnit3.setUnitAIType(gc.getInfoTypeForString('UNITAI_ATTACK_CITY'))
  3438.  
  3439. #some AI help
  3440.             if pPlayer.isHuman():
  3441.                 newUnit1.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HIDDEN_NATIONALITY'), True)
  3442.                 newUnit2.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HIDDEN_NATIONALITY'), True)
  3443.                 newUnit3.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HIDDEN_NATIONALITY'), True)
  3444.  
  3445.  
  3446.  
  3447.     def onSelectionGroupPushMission(self, argsList):
  3448.         'selection group mission'
  3449.         eOwner = argsList[0]
  3450.         eMission = argsList[1]
  3451.         iNumUnits = argsList[2]
  3452.         listUnitIds = argsList[3]
  3453.         if not self.__LOG_PUSH_MISSION:
  3454.             return
  3455.         if pHeadUnit:
  3456.             CvUtil.pyPrint("Selection Group pushed mission %d" %(eMission))
  3457.  
  3458.     def onUnitMove(self, argsList):
  3459.         'unit move'
  3460.         pPlot,pUnit,pOldPlot = argsList
  3461.         player = PyPlayer(pUnit.getOwner())
  3462.         unitInfo = PyInfo.UnitInfo(pUnit.getUnitType())
  3463.         if not self.__LOG_MOVEMENT:
  3464.             return
  3465.         if player and unitInfo:
  3466.             CvUtil.pyPrint('Player %d Civilization %s unit %s is moving to %d, %d'
  3467.                 %(player.getID(), player.getCivilizationName(), unitInfo.getDescription(),
  3468.                 pUnit.getX(), pUnit.getY()))
  3469.  
  3470.     def onUnitSetXY(self, argsList):
  3471.         'units xy coords set manually'
  3472.         pPlot,pUnit = argsList
  3473.         player = PyPlayer(pUnit.getOwner())
  3474.         unitInfo = PyInfo.UnitInfo(pUnit.getUnitType())
  3475.         if not self.__LOG_MOVEMENT:
  3476.             return
  3477.  
  3478.     def onUnitCreated(self, argsList):
  3479.     ## Platy Builder ##
  3480.         if CyGame().GetWorldBuilderMode() and not CvPlatyBuilderScreen.bPython: return
  3481.     ## Platy Builder ##
  3482.         'Unit Completed'
  3483.         unit = argsList[0]
  3484.         player = PyPlayer(unit.getOwner())
  3485.         pPlayer = gc.getPlayer(unit.getOwner())
  3486.         iChanneling2 = gc.getInfoTypeForString('PROMOTION_CHANNELING2')
  3487.         iChanneling3 = gc.getInfoTypeForString('PROMOTION_CHANNELING3')
  3488.  
  3489.         if unit.getUnitCombatType() == gc.getInfoTypeForString('UNITCOMBAT_ADEPT'):
  3490.             lCheckThis = ['AIR', 'BODY', 'CHAOS', 'EARTH', 'ENCHANTMENT', 'ENTROPY', 'FIRE', 'ICE', 'LAW', 'LIFE', 'METAMAGIC', 'MIND', 'NATURE', 'SHADOW', 'SPIRIT', 'SUN', 'WATER']
  3491.             for item in lCheckThis:
  3492.                 iNum = pPlayer.getNumAvailableBonuses(gc.getInfoTypeForString('BONUS_MANA_' + item))
  3493.                 if iNum > 1:
  3494.                     unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_' + item + '1'), True)
  3495.                     if (iNum > 2 and unit.isHasPromotion(iChanneling2)):
  3496.                         unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_' + item + '2'), True)
  3497.                         if (iNum > 3 and unit.isHasPromotion(iChanneling3)):
  3498.                             unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_' + item + '3'), True)
  3499.  
  3500.         if unit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_ELEMENTAL')):
  3501.             if pPlayer.getNumBuilding(gc.getInfoTypeForString('BUILDING_TOWER_OF_THE_ELEMENTS')) > 0:
  3502.                 unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_STRONG'), True)
  3503.  
  3504.         if unit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_UNDEAD')):
  3505.             if pPlayer.getNumBuilding(gc.getInfoTypeForString('BUILDING_TOWER_OF_NECROMANCY')) > 0:
  3506.                 unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_STRONG'), True)
  3507.  
  3508. #UNITAI for Adepts and Terraformers
  3509.         if not pPlayer.isHuman() and not pPlayer.isBarbarian():
  3510.             if unit.getUnitType() == gc.getInfoTypeForString('UNIT_DEVOUT'):
  3511.                 numberterraformer = 0
  3512.                 for pUnit in player.getUnitList():
  3513.                     if pUnit.getUnitType() == gc.getInfoTypeForString('UNIT_DEVOUT'):
  3514.                         if pUnit.getUnitAIType() == gc.getInfoTypeForString('UNITAI_TERRAFORMER'):
  3515.                             numberterraformer += 1
  3516.                 if numberterraformer < pPlayer.getNumCities()*CyGame().getGlobalCounter()/100:
  3517.                     unit.setUnitAIType(gc.getInfoTypeForString('UNITAI_TERRAFORMER'))
  3518.                 elif numberterraformer < 3:
  3519.                     unit.setUnitAIType(gc.getInfoTypeForString('UNITAI_TERRAFORMER'))
  3520.  
  3521.             numTreeTerraformer=0
  3522.             if unit.getUnitType() == gc.getInfoTypeForString('UNIT_PRIEST_OF_LEAVES'):
  3523.                 neededTreeTerraformer = 1
  3524.                 if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LJOSALFAR') or pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_SVARTALFAR'):
  3525.                     neededTreeTerraformer += pPlayer.getNumCities()/3
  3526.                 for pUnit in player.getUnitList():
  3527.                     if pUnit.getUnitType() == gc.getInfoTypeForString('UNIT_PRIEST_OF_LEAVES'):
  3528.                         if pUnit.getUnitAIType() == gc.getInfoTypeForString('UNITAI_TERRAFORMER'):
  3529.                             numTreeTerraformer += 1
  3530.                 if numTreeTerraformer < neededTreeTerraformer:
  3531.                     unit.setUnitAIType(gc.getInfoTypeForString('UNITAI_TERRAFORMER'))
  3532.  
  3533.             if unit.getUnitClassType() == gc.getInfoTypeForString('UNITCLASS_ADEPT'):
  3534.  
  3535.                 bCanMageTerraform = False
  3536.                 if pPlayer.countOwnedBonuses(gc.getInfoTypeForString('BONUS_MANA_WATER'), False) > 0:
  3537.                     bCanMageTerraform = True
  3538.                 elif pPlayer.countOwnedBonuses(gc.getInfoTypeForString('BONUS_MANA_SUN'), False) > 0:
  3539.                     bCanMageTerraform = True
  3540.  
  3541.                 numbermageterrafomer = (pPlayer.AI_getNumAIUnits(gc.getInfoTypeForString('UNITAI_TERRAFORMER')) - numTreeTerraformer)
  3542.                 numbermanaupgrade = pPlayer.AI_getNumAIUnits(gc.getInfoTypeForString('UNITAI_MANA_UPGRADE'))
  3543.  
  3544.                 bHasAI = False
  3545.                 canupgrademana = False
  3546.  
  3547.                 if pPlayer.isHasTech(gc.getInfoTypeForString('TECH_SORCERY')):
  3548.                     canupgrademana=True
  3549.                 elif pPlayer.isHasTech(gc.getInfoTypeForString('TECH_ALTERATION')):
  3550.                     canupgrademana=True
  3551.                 elif pPlayer.isHasTech(gc.getInfoTypeForString('TECH_DIVINATION')):
  3552.                     canupgrademana=True
  3553.                 elif pPlayer.isHasTech(gc.getInfoTypeForString('TECH_ELEMENTALISM')):
  3554.                     canupgrademana=True
  3555.                 elif pPlayer.isHasTech(gc.getInfoTypeForString('TECH_NECROMANCY')):
  3556.                     canupgrademana=True
  3557.  
  3558.  
  3559.                 if numbermanaupgrade == 0:
  3560.                     unit.setUnitAIType(gc.getInfoTypeForString('UNITAI_MANA_UPGRADE'))
  3561.                     bHasAI = True
  3562.                 if canupgrademana:
  3563.                     if pPlayer.countOwnedBonuses(gc.getInfoTypeForString('BONUS_MANA'), False) > numbermanaupgrade * 2:
  3564.                         unit.setUnitAIType(gc.getInfoTypeForString('UNITAI_MANA_UPGRADE'))
  3565.                         bHasAI = True
  3566.  
  3567.                 if not bHasAI:
  3568.                     if bCanMageTerraform:
  3569.                         if numbermageterrafomer < 2:
  3570.                             unit.setUnitAIType(gc.getInfoTypeForString('UNITAI_TERRAFORMER'))
  3571.                             bHasAI = True
  3572.  
  3573.                 if not bHasAI:
  3574.                     pPlot = unit.plot()
  3575.                     if pPlayer.AI_getNumAIUnits(gc.getInfoTypeForString('UNITAI_MAGE')) < pPlayer.getNumCities() / 2:
  3576.                         unit.setUnitAIType(gc.getInfoTypeForString('UNITAI_MAGE'))
  3577.                     elif pPlot.area().getAreaAIType(pPlayer.getTeam()) == AreaAITypes.AREAAI_DEFENSIVE:
  3578.                         unit.setUnitAIType(gc.getInfoTypeForString('UNITAI_MAGE'))
  3579.                     else:
  3580.                         unit.setUnitAIType(gc.getInfoTypeForString('UNITAI_WARWIZARD'))
  3581.  
  3582.         if CyGame().getWBMapScript():
  3583.             sf.onUnitCreated(unit)
  3584.  
  3585.         if not self.__LOG_UNITBUILD:
  3586.             return
  3587.  
  3588.     def onUnitBuilt(self, argsList):
  3589.         'Unit Completed'
  3590.         city = argsList[0]
  3591.         unit = argsList[1]
  3592.         player = PyPlayer(city.getOwner())
  3593.         pPlayer = gc.getPlayer(unit.getOwner())
  3594.  
  3595.         # Advanced Tactics - Diverse Grigori (idea and base code taken from FFH Tweakmod)
  3596.         if gc.getGame().isOption(GameOptionTypes.GAMEOPTION_ADVANCED_TACTICS):
  3597.             if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_GRIGORI'):
  3598.                 unit.setReligion(-1)
  3599.                 if unit.getRace() == -1:
  3600.                     iChance = 40
  3601.                     if CyGame().getSorenRandNum(100, "Grigori Racial Diversity") <= iChance:
  3602.                         race = CyGame().getSorenRandNum(3, "Bob")
  3603.                         if race == 0 and unit.isAlive():
  3604.                             unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_ORC'), True)
  3605.                         elif race == 1 and unit.isAlive():
  3606.                             race = CyGame().getSorenRandNum(2, "Elvish division")
  3607.                             if race == 0:
  3608.                                 unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_ELF'), True)
  3609.                             elif race == 1:
  3610.                                 unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_DARK_ELF'), True)
  3611.                         elif race == 2:
  3612.                             if (unit.isAlive()):
  3613.                                 unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_DWARF'), True)
  3614.         # End Advanced Tactics
  3615.  
  3616.         if unit.getUnitType() == gc.getInfoTypeForString('UNIT_BEAST_OF_AGARES'):
  3617.             if city.getCivilizationType() != gc.getInfoTypeForString('CIVILIZATION_INFERNAL'):
  3618.                 iPop = city.getPopulation() - 4
  3619.                 if iPop <= 1:
  3620.                     iPop = 1
  3621.                 city.setPopulation(iPop)
  3622.                 city.setOccupationTimer(4)
  3623.  
  3624.         elif unit.getUnitType() == gc.getInfoTypeForString('UNIT_ACHERON'):
  3625.             unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), True)
  3626.             city.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_THE_DRAGONS_HORDE'), 1)
  3627.             iX = city.getX()
  3628.             iY = city.getY()
  3629.             for iiX in range(iX-1, iX+2, 1):
  3630.                 for iiY in range(iY-1, iY+2, 1):
  3631.                     pPlot = CyMap().plot(iiX,iiY)
  3632.                     if (pPlot.getFeatureType() == gc.getInfoTypeForString('FEATURE_FOREST') or pPlot.getFeatureType() == gc.getInfoTypeForString('FEATURE_JUNGLE')):
  3633.                         pPlot.setFeatureType(gc.getInfoTypeForString('FEATURE_FLAMES'), 0)
  3634.             if( game.getAIAutoPlay(game.getActivePlayer()) == 0 ) :
  3635.                 cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_ACHERON_CREATION",()), str(gc.getUnitInfo(unit.getUnitType()).getImage()))
  3636.  
  3637.         if city.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_WARRENS')) > 0:
  3638.             if isWorldUnitClass(unit.getUnitClassType()) == False:
  3639.                 if isNationalUnitClass(unit.getUnitClassType()) == False:
  3640.                     if not unit.isMechUnit():
  3641. #                       if unit.getUnitCombatType() != UnitCombatTypes.NO_UNITCOMBAT:
  3642.                         if unit.isAlive():
  3643.                             newUnit = pPlayer.initUnit(unit.getUnitType(), city.getX(), city.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
  3644.                             city.applyBuildEffects(newUnit)
  3645.  
  3646.         CvAdvisorUtils.unitBuiltFeats(city, unit)
  3647.  
  3648.        
  3649.         #I need to redo the teamID's because they are forgotten from onGameStart
  3650.         if CyGame().getGameTurn() >= 10 and CyGame().getGameTurn() < 60:
  3651.             for iGoodAndEvilPlayer in range(gc.getMAX_PLAYERS()):
  3652.                 pGoodAndEvilPlayer = gc.getPlayer(iGoodAndEvilPlayer)
  3653.                 #if pGoodAndEvilPlayer.isAlive(): #This line breaks the code
  3654.                 if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_BANNOR'):
  3655.                     iBannorTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  3656.                 if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_CALABIM'):
  3657.                     iCalabimTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  3658.                 if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_CLAN_OF_EMBERS'):
  3659.                     iClanOfEmbersTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  3660.                 if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_DOVIELLO'):
  3661.                     iDovielloTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  3662.                 if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_ELOHIM'):
  3663.                     iElohimTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  3664.                 if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_KURIOTATES'):
  3665.                     iKuriotatesTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  3666.                 if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LJOSALFAR'):
  3667.                     iLjosalfarTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  3668.                 if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LUCHUIRP'):
  3669.                     iLuchuirpTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  3670.                 if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_SHEAIM'):
  3671.                     iSheaimTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  3672.                 if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_SVARTALFAR'):
  3673.                     iSvartalfarTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  3674.  
  3675.        
  3676.         #Give units the Stack of Doom (SoD) promotion between certain turns#
  3677.         if CyGame().getGameTurn() >= 10 and CyGame().getGameTurn() < 60:
  3678.             if gc.getTeam(iBannorTeamID).isAlive:
  3679.                 if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_BANNOR'):
  3680.                     unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_SofD'), True)
  3681.             if gc.getTeam(iElohimTeamID).isAlive:
  3682.                 if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_ELOHIM'):
  3683.                     unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_SofD'), True)
  3684.             if gc.getTeam(iKuriotatesTeamID).isAlive:
  3685.                 if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_KURIOTATES'):
  3686.                     unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_SofD'), True)
  3687.             if gc.getTeam(iLjosalfarTeamID).isAlive:
  3688.                 if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LJOSALFAR'):
  3689.                     unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_SofD'), True)
  3690.             #Check if Luchuirp are at peace with the other good civs (using Elohim peace as a proxy) before getting them to join the good civs' SoD
  3691.             if gc.getTeam(iLuchuirpTeamID).isAlive:
  3692.                 if not gc.getTeam(iLuchuirpTeamID).isAtWar(iElohimTeamID):
  3693.                     if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LUCHUIRP'):
  3694.                         unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_SofD'), True)
  3695.  
  3696.        
  3697.        
  3698.        
  3699.         if not self.__LOG_UNITBUILD:
  3700.             return
  3701.         CvUtil.pyPrint('%s was finished by Player %d Civilization %s'
  3702.             %(PyInfo.UnitInfo(unit.getUnitType()).getDescription(), player.getID(), player.getCivilizationName()))
  3703.            
  3704.    
  3705.                        
  3706.     def onUnitKilled(self, argsList):
  3707.         'Unit Killed'
  3708.         unit, iAttacker = argsList
  3709.         iPlayer = unit.getOwner()
  3710.         pPlayer = gc.getPlayer(iPlayer)
  3711.         player = PyPlayer(iPlayer)
  3712.         attacker = PyPlayer(iAttacker)
  3713.         pPlot = unit.plot()
  3714.         iX = unit.getX()
  3715.         iY = unit.getY()
  3716.  
  3717.         if unit.isAlive() and not unit.isImmortal():
  3718.             iSoulForge = gc.getInfoTypeForString('BUILDING_SOUL_FORGE')
  3719.             if gc.getGame().getBuildingClassCreatedCount(gc.getInfoTypeForString("BUILDINGCLASS_SOUL_FORGE")) > 0:
  3720.                 for iiX in range(iX-1, iX+2, 1):
  3721.                     for iiY in range(iY-1, iY+2, 1):
  3722.                         pPlot2 = CyMap().plot(iiX,iiY)
  3723.                         if pPlot2.isCity():
  3724.                             pCity = pPlot2.getPlotCity()
  3725.                             if pCity.getNumRealBuilding(iSoulForge) > 0:
  3726.                                 pCity.changeProduction(unit.getExperience() + 10)
  3727.                                 CyInterface().addMessage(pCity.getOwner(),True,25,CyTranslator().getText("TXT_KEY_MESSAGE_SOUL_FORGE",()),'AS2D_DISCOVERBONUS',1,'Art/Interface/Buttons/Buildings/Soulforge.dds',ColorTypes(7),pCity.getX(),pCity.getY(),True,True)
  3728.  
  3729.             if pPlot.isCity():
  3730.                 pCity = pPlot.getPlotCity()
  3731.                 if pCity.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_MOKKAS_CAULDRON')) > 0:
  3732.                     if pCity.getOwner() == unit.getOwner():
  3733.                         iUnit = cf.getUnholyVersion(unit)
  3734.                         if iUnit != -1:
  3735.                             newUnit = pPlayer.initUnit(iUnit, pCity.getX(), pCity.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
  3736.                             newUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_DEMON'), True)
  3737.                             newUnit.setDamage(50, PlayerTypes.NO_PLAYER)
  3738.                             newUnit.finishMoves()
  3739.                             szBuffer = gc.getUnitInfo(newUnit.getUnitType()).getDescription()
  3740.                             CyInterface().addMessage(unit.getOwner(),True,25,CyTranslator().getText("TXT_KEY_MESSAGE_MOKKAS_CAULDRON",((szBuffer, ))),'AS2D_DISCOVERBONUS',1,'Art/Interface/Buttons/Buildings/Mokkas Cauldron.dds',ColorTypes(7),pCity.getX(),pCity.getY(),True,True)
  3741.  
  3742.             if (unit.getReligion() == gc.getInfoTypeForString('RELIGION_COUNCIL_OF_ESUS') or unit.getReligion() == gc.getInfoTypeForString('RELIGION_THE_ASHEN_VEIL') or unit.getReligion() == gc.getInfoTypeForString('RELIGION_OCTOPUS_OVERLORDS') or unit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_DEATH1')) or unit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_ENTROPY1'))):
  3743.                 cf.giftUnit(gc.getInfoTypeForString('UNIT_MANES'), gc.getInfoTypeForString('CIVILIZATION_INFERNAL'), 0, unit.plot(), unit.getOwner())
  3744.                 cf.giftUnit(gc.getInfoTypeForString('UNIT_MANES'), gc.getInfoTypeForString('CIVILIZATION_INFERNAL'), 0, unit.plot(), unit.getOwner())
  3745.             elif (unit.getReligion() == gc.getInfoTypeForString('RELIGION_THE_EMPYREAN') or unit.getReligion() == gc.getInfoTypeForString('RELIGION_THE_ORDER') or unit.getReligion() == gc.getInfoTypeForString('RELIGION_RUNES_OF_KILMORPH') or (unit.getUnitCombatType() != gc.getInfoTypeForString('UNITCOMBAT_ANIMAL') and pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_MERCURIANS'))):
  3746.                 cf.giftUnit(gc.getInfoTypeForString('UNIT_ANGEL'), gc.getInfoTypeForString('CIVILIZATION_MERCURIANS'), unit.getExperience(), unit.plot(), unit.getOwner())
  3747.  
  3748.             if unit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_SPIRIT_GUIDE')):
  3749.                 if unit.getExperience() > 0:
  3750.                     py = PyPlayer(iPlayer)
  3751.                     lUnits = []
  3752.                     for pLoopUnit in py.getUnitList():
  3753.                         if pLoopUnit.isAlive():
  3754.                             if not pLoopUnit.isOnlyDefensive():
  3755.                                 if not pLoopUnit.isDelayedDeath():
  3756.                                     lUnits.append(pLoopUnit)
  3757.                     if len(lUnits) > 0:
  3758.                         pUnit = lUnits[CyGame().getSorenRandNum(len(lUnits), "Spirit Guide")-1]
  3759.                         iXP = unit.getExperience() / 2
  3760.                         pUnit.changeExperience(iXP, -1, False, False, False)
  3761. #                       unit.changeExperience(iXP * -1, -1, False, False, False)
  3762.                         CyInterface().addMessage(unit.getOwner(),True,25,CyTranslator().getText("TXT_KEY_MESSAGE_SPIRIT_GUIDE",()),'AS2D_DISCOVERBONUS',1,'Art/Interface/Buttons/Promotions/SpiritGuide.dds',ColorTypes(7),pUnit.getX(),pUnit.getY(),True,True)
  3763.  
  3764.         if unit.getUnitType() == gc.getInfoTypeForString('UNIT_ACHERON'):
  3765.             unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), False)
  3766.  
  3767.         if CyGame().getWBMapScript():
  3768.             sf.onUnitKilled(unit, iAttacker)
  3769.  
  3770. #       if not self.__LOG_UNITKILLED:
  3771. #           return
  3772. #       CvUtil.pyPrint('Player %d Civilization %s Unit %s was killed by Player %d'
  3773. #           %(player.getID(), player.getCivilizationName(), PyInfo.UnitInfo(unit.getUnitType()).getDescription(), attacker.getID()))
  3774.  
  3775.     def onUnitLost(self, argsList):
  3776.     ## Platy Builder ##
  3777.         if CyGame().GetWorldBuilderMode() and not CvPlatyBuilderScreen.bPython: return
  3778.     ## Platy Builder ##
  3779.         'Unit Lost'
  3780.         unit = argsList[0]
  3781.         iPlayer = unit.getOwner()
  3782.         player = PyPlayer(iPlayer)
  3783.         pPlot = unit.plot()
  3784.  
  3785.         if unit.getUnitType() == gc.getInfoTypeForString('UNIT_TREANT'):
  3786.             if pPlot.getFeatureType() == -1:
  3787.                 if pPlot.canHaveFeature(gc.getInfoTypeForString('FEATURE_FOREST_NEW')):
  3788.                     if pPlot.getOwner() == iPlayer:
  3789.                         if CyGame().getSorenRandNum(100, "Treant Spawn Chance") < 50:
  3790.                             pPlot.setFeatureType(gc.getInfoTypeForString('FEATURE_FOREST_NEW'), 0)
  3791.  
  3792.         if not self.__LOG_UNITLOST:
  3793.             return
  3794.         CvUtil.pyPrint('%s was lost by Player %d Civilization %s'
  3795.             %(PyInfo.UnitInfo(unit.getUnitType()).getDescription(), player.getID(), player.getCivilizationName()))
  3796.  
  3797.     def onUnitPromoted(self, argsList):
  3798.         'Unit Promoted'
  3799.         pUnit, iPromotion = argsList
  3800.         if not self.__LOG_UNITPROMOTED:
  3801.             return
  3802.         CvUtil.pyPrint('Unit Promotion Event: %s - %s' %(player.getCivilizationName(), pUnit.getName(),))
  3803.  
  3804.     def onUnitSelected(self, argsList):
  3805.         'Unit Selected'
  3806.         unit = argsList[0]
  3807.         player = PyPlayer(unit.getOwner())
  3808.         if (not self.__LOG_UNITSELECTED):
  3809.             return
  3810.         CvUtil.pyPrint('%s was selected by Player %d Civilization %s'
  3811.             %(PyInfo.UnitInfo(unit.getUnitType()).getDescription(), player.getID(), player.getCivilizationName()))
  3812.  
  3813.     def onUnitRename(self, argsList):
  3814.         'Unit is renamed'
  3815.         pUnit = argsList[0]
  3816.         if (pUnit.getOwner() == gc.getGame().getActivePlayer()):
  3817.             self.__eventEditUnitNameBegin(pUnit)
  3818.  
  3819.     def onUnitPillage(self, argsList):
  3820.         'Unit pillages a plot'
  3821.         pUnit, iImprovement, iRoute, iOwner = argsList
  3822.         iPlotX = pUnit.getX()
  3823.         iPlotY = pUnit.getY()
  3824.         pPlot = CyMap().plot(iPlotX, iPlotY)
  3825.         pPlayer = gc.getPlayer(pUnit.getOwner())
  3826.  
  3827.         if (not self.__LOG_UNITPILLAGE):
  3828.             return
  3829.         CvUtil.pyPrint("Player %d's %s pillaged improvement %d and route %d at plot at (%d, %d)"
  3830.             %(iOwner, PyInfo.UnitInfo(pUnit.getUnitType()).getDescription(), iImprovement, iRoute, iPlotX, iPlotY))
  3831.  
  3832.     def onUnitSpreadReligionAttempt(self, argsList):
  3833.         'Unit tries to spread religion to a city'
  3834.         pUnit, iReligion, bSuccess = argsList
  3835.  
  3836.         iX = pUnit.getX()
  3837.         iY = pUnit.getY()
  3838.         pPlot = CyMap().plot(iX, iY)
  3839.         pCity = pPlot.getPlotCity()
  3840.  
  3841.     def onUnitGifted(self, argsList):
  3842.         'Unit is gifted from one player to another'
  3843.         pUnit, iGiftingPlayer, pPlotLocation = argsList
  3844.  
  3845.     def onUnitBuildImprovement(self, argsList):
  3846.         'Unit begins enacting a Build (building an Improvement or Route)'
  3847.         pUnit, iBuild, bFinished = argsList
  3848.  
  3849.     def onGoodyReceived(self, argsList):
  3850.         'Goody received'
  3851.         iPlayer, pPlot, pUnit, iGoodyType = argsList
  3852.         if (not self.__LOG_GOODYRECEIVED):
  3853.             return
  3854.         CvUtil.pyPrint('%s received a goody' %(gc.getPlayer(iPlayer).getCivilizationDescription(0)),)
  3855.  
  3856.     def onGreatPersonBorn(self, argsList):
  3857.     ## Platy Builder ##
  3858.         if CyGame().GetWorldBuilderMode() and not CvPlatyBuilderScreen.bPython: return
  3859.     ## Platy Builder ##
  3860.         'Unit Promoted'
  3861.         pUnit, iPlayer, pCity = argsList
  3862.         player = PyPlayer(iPlayer)
  3863.         if pUnit.isNone() or pCity.isNone():
  3864.             return
  3865.         if (not self.__LOG_GREATPERSON):
  3866.             return
  3867.         CvUtil.pyPrint('A %s was born for %s in %s' %(pUnit.getName(), player.getCivilizationName(), pCity.getName()))
  3868.  
  3869.     def onTechAcquired(self, argsList):
  3870.     ## Platy Builder ##
  3871.         if CyGame().GetWorldBuilderMode() and not CvPlatyBuilderScreen.bPython: return
  3872.     ## Platy Builder ##
  3873.         'Tech Acquired'
  3874.         iTechType, iTeam, iPlayer, bAnnounce = argsList
  3875.         # Note that iPlayer may be NULL (-1) and not a refer to a player object
  3876.         pPlayer = gc.getPlayer(iPlayer)
  3877.  
  3878.         # Show tech splash when applicable
  3879.         if iPlayer > -1 and bAnnounce and not CyInterface().noTechSplash():
  3880.             if gc.getGame().isFinalInitialized() and not gc.getGame().GetWorldBuilderMode():
  3881.                 if not gc.getGame().isNetworkMultiPlayer() and iPlayer == gc.getGame().getActivePlayer():
  3882.                     popupInfo = CyPopupInfo()
  3883.                     popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
  3884.                     popupInfo.setData1(iTechType)
  3885.                     popupInfo.setText(u"showTechSplash")
  3886.                     popupInfo.addPopup(iPlayer)
  3887.         if iPlayer != -1 and iPlayer != gc.getBARBARIAN_PLAYER():
  3888.             pPlayer = gc.getPlayer(iPlayer)
  3889.             iReligion = -1
  3890.             if iTechType == gc.getInfoTypeForString('TECH_CORRUPTION_OF_SPIRIT'):
  3891.                 iUnit = gc.getInfoTypeForString('UNIT_DISCIPLE_THE_ASHEN_VEIL')
  3892.                 iReligion = gc.getInfoTypeForString('RELIGION_THE_ASHEN_VEIL')
  3893.             elif iTechType == gc.getInfoTypeForString('TECH_ORDERS_FROM_HEAVEN'):
  3894.                 iUnit = gc.getInfoTypeForString('UNIT_DISCIPLE_THE_ORDER')
  3895.                 iReligion = gc.getInfoTypeForString('RELIGION_THE_ORDER')
  3896.             elif iTechType == gc.getInfoTypeForString('TECH_WAY_OF_THE_FORESTS'):
  3897.                 iUnit = gc.getInfoTypeForString('UNIT_DISCIPLE_FELLOWSHIP_OF_LEAVES')
  3898.                 iReligion = gc.getInfoTypeForString('RELIGION_FELLOWSHIP_OF_LEAVES')
  3899.             elif iTechType == gc.getInfoTypeForString('TECH_WAY_OF_THE_EARTHMOTHER'):
  3900.                 iUnit = gc.getInfoTypeForString('UNIT_DISCIPLE_RUNES_OF_KILMORPH')
  3901.                 iReligion = gc.getInfoTypeForString('RELIGION_RUNES_OF_KILMORPH')
  3902.             elif iTechType == gc.getInfoTypeForString('TECH_MESSAGE_FROM_THE_DEEP'):
  3903.                 iUnit = gc.getInfoTypeForString('UNIT_DISCIPLE_OCTOPUS_OVERLORDS')
  3904.                 iReligion = gc.getInfoTypeForString('RELIGION_OCTOPUS_OVERLORDS')
  3905.             elif iTechType == gc.getInfoTypeForString('TECH_HONOR'):
  3906.                 iUnit = gc.getInfoTypeForString('UNIT_DISCIPLE_EMPYREAN')
  3907.                 iReligion = gc.getInfoTypeForString('RELIGION_THE_EMPYREAN')
  3908.             elif iTechType == gc.getInfoTypeForString('TECH_DECEPTION'):
  3909.                 iUnit = gc.getInfoTypeForString('UNIT_NIGHTWATCH')
  3910.                 iReligion = gc.getInfoTypeForString('RELIGION_COUNCIL_OF_ESUS')
  3911.             if iReligion != -1:
  3912.                 if (iReligion==pPlayer.getFavoriteReligion()):
  3913.                     pPlayer.getCapitalCity().setHasReligion(iReligion,True,True,True)  
  3914.                 if CyGame().isReligionFounded(iReligion):
  3915.                     cf.giftUnit(iUnit, pPlayer.getCivilizationType(), 0, -1, -1)
  3916.  
  3917.         if not gc.getGame().isOption(GameOptionTypes.GAMEOPTION_NO_HYBOREM_OR_BASIUM):
  3918.             if iTechType == gc.getInfoTypeForString('TECH_INFERNAL_PACT') and iPlayer != -1:
  3919.                 #iCount = 0
  3920.                 #for iTeam in range(gc.getMAX_TEAMS()):
  3921.                     #pTeam = gc.getTeam(iTeam)
  3922.                     #if pTeam.isHasTech(gc.getInfoTypeForString('TECH_INFERNAL_PACT')):
  3923.                         #iCount = iCount + 1
  3924.                 #if iCount == 1:
  3925.                 if not CyGame().isCivEverActive(gc.getInfoTypeForString('CIVILIZATION_INFERNAL')):
  3926.                     iInfernalPlayer = pPlayer.initNewEmpire(gc.getInfoTypeForString('LEADER_HYBOREM'), gc.getInfoTypeForString('CIVILIZATION_INFERNAL'))
  3927.                     if iInfernalPlayer != PlayerTypes.NO_PLAYER:
  3928.                         pInfernalPlayer = gc.getPlayer(iInfernalPlayer)
  3929.                         pTeam = gc.getTeam(pInfernalPlayer.getTeam())
  3930.  
  3931.                         pBestPlot = -1
  3932.                         iBestPlot = -1
  3933.                         for iLoop in range (CyMap().numPlots()):
  3934.                             pPlot = CyMap().plotByIndex(iLoop)
  3935.                             iX = pPlot.getX()
  3936.                             iY = pPlot.getY()
  3937.                             iPlot = -1
  3938.                             if pInfernalPlayer.canFound(iX, iY):
  3939.                                 if pPlot.getNumUnits() == 0:
  3940.                                     iPlot = CyGame().getSorenRandNum(50, "Place Hyborem")
  3941.                                     iPlot += 50
  3942.                                     iPlot += pPlot.area().getNumTiles() * 2
  3943.                                     iPlot += pPlot.area().getNumUnownedTiles() * 10
  3944.  
  3945.                                     ## Check Big Fat Cross for other players, resources and terrain
  3946.                                     for iCityPlotX in range(iX-1, iX+2, 1):
  3947.                                         for iCityPlotY in range(iY-1, iY+2, 1):
  3948.                                             pCityPlot = CyMap().plot(iCityPlotX,iCityPlotY)
  3949.                                             iCityTerrain = pCityPlot.getTerrainType()
  3950.                                             iCityPlot = pCityPlot.getPlotType()
  3951.                                             iCityBonus = pCityPlot.getBonusType(TeamTypes.NO_TEAM)
  3952.  
  3953.                                             for jPlayer in range(gc.getMAX_PLAYERS()):
  3954.                                                 lPlayer = gc.getPlayer(jPlayer)
  3955.                                                 if lPlayer.isAlive():
  3956.                                                     if pCityPlot.getCulture(jPlayer) > 100:
  3957.                                                         iPlot -= 250
  3958.                                             if pPlot.isAdjacentOwned():
  3959.                                                 iPlot -= 25
  3960.                                             else:
  3961.                                                 iPlot += 15
  3962.                                             if (iCityTerrain == gc.getInfoTypeForString('TERRAIN_SNOW')) or (iCityTerrain == gc.getInfoTypeForString("TERRAIN_DESERT")):
  3963.                                                 iPlot -= 25
  3964.                                             elif (iCityTerrain == gc.getInfoTypeForString('TERRAIN_TUNDRA')):
  3965.                                                 iPlot -= 10
  3966.                                             if (pCityPlot.isWater()):
  3967.                                                 iPlot -= 25
  3968.                                             elif not iCityBonus == BonusTypes.NO_BONUS:
  3969.                                                 iPlot += gc.getBonusInfo(iCityBonus).getYieldChange(YieldTypes.YIELD_PRODUCTION) * 25
  3970.                                                 iPlot += gc.getBonusInfo(iCityBonus).getYieldChange(YieldTypes.YIELD_COMMERCE) * 15
  3971.  
  3972.                             if iPlot > iBestPlot:
  3973.                                 iBestPlot = iPlot
  3974.                                 pBestPlot = pPlot
  3975.  
  3976.                         if pBestPlot != -1:
  3977.                             iFounderTeam = gc.getPlayer(iPlayer).getTeam()
  3978.                             pFounderTeam = gc.getTeam(gc.getPlayer(iPlayer).getTeam())
  3979.                             iInfernalTeam = gc.getPlayer(iInfernalPlayer).getTeam()
  3980.                             pInfernalTeam = gc.getTeam(iInfernalTeam)
  3981.  
  3982.                             iBarbTeam = gc.getBARBARIAN_TEAM()
  3983.                             pInfernalTeam.makePeace(iBarbTeam)
  3984.                             pInfernalPlayer.AI_changeAttitudeExtra(iPlayer, 4)
  3985.  
  3986.                             iX = pBestPlot.getX()
  3987.                             iY = pBestPlot.getY()
  3988.                             pNewUnit = pInfernalPlayer.initUnit(gc.getInfoTypeForString('UNIT_HYBOREM'), iX, iY, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
  3989.                             pNewUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_IMMORTAL'), True)
  3990.                             pNewUnit.setHasCasted(True)
  3991.                             pNewUnit.setAvatarOfCivLeader(True)
  3992.                             iIronWeapon     = gc.getInfoTypeForString('PROMOTION_IRON_WEAPONS')
  3993.                             iMobility1      = gc.getInfoTypeForString('PROMOTION_MOBILITY1')
  3994.                             iSettlerBonus   = gc.getInfoTypeForString('PROMOTION_STARTING_SETTLER')
  3995.                             liStartingUnits = [ (2, gc.getInfoTypeForString('UNIT_LONGBOWMAN'), [iMobility1]                ),
  3996.                                                 (2, gc.getInfoTypeForString('UNIT_CHAMPION'),   [iMobility1, iIronWeapon]   ),
  3997.                                                 (1, gc.getInfoTypeForString('UNIT_WORKER'),     []                          ),
  3998.                                                 (1, gc.getInfoTypeForString('UNIT_IMP'),        [iMobility1]                ),
  3999.                                                 (3, gc.getInfoTypeForString('UNIT_MANES'),      []                          ),
  4000.                                                 (2, gc.getInfoTypeForString('UNIT_SETTLER'),    [iSettlerBonus]             )   ]
  4001.                             for iNumUnits, iUnit, liPromotions in liStartingUnits:
  4002.                                 for iLoop in range(iNumUnits):
  4003.                                     pNewUnit = pInfernalPlayer.initUnit(iUnit, iX, iY, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
  4004.                                     for iPromotion in liPromotions:
  4005.                                         pNewUnit.setHasPromotion(iPromotion, True)
  4006.  
  4007.                             if (game.isOption(GameOptionTypes.GAMEOPTION_ADVANCED_TACTICS)):
  4008.                                 pFounderTeam.setHasEmbassy(iInfernalTeam, True)
  4009.                                 pInfernalTeam.setHasEmbassy(iFounderTeam, True)
  4010.  
  4011.                             pFounderTeam.signOpenBorders(iInfernalTeam)
  4012.                             pInfernalTeam.signOpenBorders(iFounderTeam)
  4013.                             for iPlotIndex in range(CyMap().numPlots()):
  4014.                                 pLoopPlot = CyMap().plotByIndex(iPlotIndex)
  4015.                                 if pLoopPlot.isRevealed(iFounderTeam, False):
  4016.                                     pLoopPlot.setRevealed(iInfernalTeam, True, False, iFounderTeam)
  4017.                                 if pLoopPlot.isRevealed(iInfernalTeam, False):
  4018.                                     pLoopPlot.setRevealed(iFounderTeam, True, False, iInfernalTeam)
  4019.                             for iLoopTeam in range(gc.getMAX_CIV_TEAMS()):
  4020.                                 pLoopTeam = gc.getTeam(iLoopTeam)
  4021.                                 if pLoopTeam.isHasMet(iFounderTeam):
  4022.                                     if pLoopTeam.isAlive():
  4023.                                         pLoopTeam.meet(iInfernalTeam, True)
  4024.                             for iTeam in range(gc.getMAX_TEAMS()):
  4025.                                 if iTeam != iBarbTeam:
  4026.                                     pTeam = gc.getTeam(iTeam)
  4027.                                     if pTeam.isAlive():
  4028.                                         if pFounderTeam.isAtWar(iTeam):
  4029.                                             pInfernalTeam.declareWar(iTeam, False, WarPlanTypes.WARPLAN_LIMITED)
  4030.  
  4031.                             if gc.getPlayer(iPlayer).isHuman():
  4032.                                 popupInfo = CyPopupInfo()
  4033.                                 popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON)
  4034.                                 popupInfo.setText(CyTranslator().getText("TXT_KEY_POPUP_CONTROL_INFERNAL",()))
  4035.                                 popupInfo.setData1(iPlayer)
  4036.                                 popupInfo.setData2(iInfernalPlayer)
  4037.                                 popupInfo.addPythonButton(CyTranslator().getText("TXT_KEY_POPUP_YES", ()), "")
  4038.                                 popupInfo.addPythonButton(CyTranslator().getText("TXT_KEY_POPUP_NO", ()), "")
  4039.                                 popupInfo.setOnClickedPythonCallback("reassignPlayer")
  4040.                                 popupInfo.addPopup(iPlayer)
  4041.  
  4042.         if CyGame().getWBMapScript():
  4043.             sf.onTechAcquired(iTechType, iTeam, iPlayer, bAnnounce)
  4044.  
  4045.         if (not self.__LOG_TECH):
  4046.             return
  4047.         CvUtil.pyPrint('%s was finished by Team %d'
  4048.             %(PyInfo.TechnologyInfo(iTechType).getDescription(), iTeam))
  4049.  
  4050.     def onTechSelected(self, argsList):
  4051.         'Tech Selected'
  4052.         iTechType, iPlayer = argsList
  4053.         if (not self.__LOG_TECH):
  4054.             return
  4055.         CvUtil.pyPrint('%s was selected by Player %d' %(PyInfo.TechnologyInfo(iTechType).getDescription(), iPlayer))
  4056.  
  4057.     def onReligionFounded(self, argsList):
  4058.     ## Platy Builder ##
  4059.         if CyGame().GetWorldBuilderMode() and not CvPlatyBuilderScreen.bPython: return
  4060.     ## Platy Builder ##
  4061.         'Religion Founded'
  4062.         iReligion, iFounder = argsList
  4063.         player = PyPlayer(iFounder)
  4064.         pPlayer = gc.getPlayer(iFounder)
  4065.  
  4066.         iCityId = gc.getGame().getHolyCity(iReligion).getID()
  4067.         if gc.getGame().isFinalInitialized() and not gc.getGame().GetWorldBuilderMode():
  4068.             if not gc.getGame().isNetworkMultiPlayer() and iFounder == gc.getGame().getActivePlayer():
  4069.                 popupInfo = CyPopupInfo()
  4070.                 popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
  4071.                 popupInfo.setData1(iReligion)
  4072.                 popupInfo.setData2(iCityId)
  4073.                 if iReligion == gc.getInfoTypeForString('RELIGION_THE_EMPYREAN') or iReligion == gc.getInfoTypeForString('RELIGION_COUNCIL_OF_ESUS'):
  4074.                     popupInfo.setData3(3)
  4075.                 else:
  4076.                     popupInfo.setData3(1)
  4077.                 popupInfo.setText(u"showWonderMovie")
  4078.                 popupInfo.addPopup(iFounder)
  4079.  
  4080.  
  4081.         if CyGame().getWBMapScript():
  4082.             sf.onReligionFounded(iReligion, iFounder)
  4083.  
  4084.         if (not self.__LOG_RELIGION):
  4085.             return
  4086.         CvUtil.pyPrint('Player %d Civilization %s has founded %s'
  4087.             %(iFounder, player.getCivilizationName(), gc.getReligionInfo(iReligion).getDescription()))
  4088.  
  4089.     def onReligionSpread(self, argsList):
  4090.     ## Platy Builder ##
  4091.         if CyGame().GetWorldBuilderMode() and not CvPlatyBuilderScreen.bPython: return
  4092.     ## Platy Builder ##
  4093.         'Religion Has Spread to a City'
  4094.         iReligion, iOwner, pSpreadCity = argsList
  4095.         player = PyPlayer(iOwner)
  4096.         pPlayer = gc.getPlayer(iOwner)
  4097.  
  4098.         iOrder = gc.getInfoTypeForString('RELIGION_THE_ORDER')
  4099.         iVeil = gc.getInfoTypeForString('RELIGION_THE_ASHEN_VEIL')
  4100.  
  4101.         if iReligion == iOrder and CyGame().getGameTurn() != CyGame().getStartTurn():
  4102.             if (pPlayer.getStateReligion() == iOrder and pSpreadCity.getOccupationTimer() <= 0):
  4103.                 if (CyGame().getSorenRandNum(100, "Order Spawn") < gc.getDefineINT('ORDER_SPAWN_CHANCE')):
  4104.                     eTeam = gc.getTeam(pPlayer.getTeam())
  4105.                     if eTeam.isHasTech(gc.getInfoTypeForString('TECH_FANATICISM')):
  4106.                         iUnit = gc.getInfoTypeForString('UNIT_CRUSADER')
  4107.                         CyInterface().addMessage(iOwner,True,25,CyTranslator().getText("TXT_KEY_MESSAGE_ORDER_SPAWN_CRUSADER",()),'AS2D_UNIT_BUILD_UNIT',1,'Art/Interface/Buttons/Units/Crusader.dds',ColorTypes(8),pSpreadCity.getX(),pSpreadCity.getY(),True,True)
  4108.                     else:
  4109.                         iUnit = gc.getInfoTypeForString('UNIT_DISCIPLE_THE_ORDER')
  4110.                         CyInterface().addMessage(iOwner,True,25,CyTranslator().getText("TXT_KEY_MESSAGE_ORDER_SPAWN_ACOLYTE",()),'AS2D_UNIT_BUILD_UNIT',1,'Art/Interface/Buttons/Units/Disciple Order.dds',ColorTypes(8),pSpreadCity.getX(),pSpreadCity.getY(),True,True)
  4111.                     newUnit = pPlayer.initUnit(iUnit, pSpreadCity.getX(), pSpreadCity.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
  4112.         if pSpreadCity.isHasReligion(iVeil) and iReligion == iOrder:
  4113.             if not pSpreadCity.isHolyCity():
  4114.                 result = CyGame().getSorenRandNum(100, "Order-Veil")
  4115.                 if (result < 35):
  4116.                     CyInterface().addMessage(iOwner,True,25,"A bloodbath ensues as the Order and Veil battle for control of the city! In the end, Ritualists lie dead in the streets. The Order is triumphant!",'AS2D_UNIT_BUILD_UNIT',1,'Art/Interface/Buttons/Religions/Order.dds',ColorTypes(14),pSpreadCity.getX(),pSpreadCity.getY(),True,True)
  4117.                     pSpreadCity.setHasReligion(gc.getInfoTypeForString('RELIGION_THE_ASHEN_VEIL'), False, True, True)
  4118.                     iPop = pSpreadCity.getPopulation()-1
  4119.                     if (iPop > 0):
  4120.                         pSpreadCity.setPopulation(iPop)
  4121.                     CyGame().changeGlobalCounter(-1)
  4122.                 else:
  4123.                     CyInterface().addMessage(iOwner,True,25,"A bloodbath ensues as the Order and Veil battle for control of the city! In the end, the streets are coated in Crusader blood. The Veil is victorious!",'AS2D_UNIT_BUILD_UNIT',1,'Art/Interface/Buttons/Religions/Ashen.dds',ColorTypes(5),pSpreadCity.getX(),pSpreadCity.getY(),True,True)
  4124.                     pSpreadCity.setHasReligion(gc.getInfoTypeForString('RELIGION_THE_ORDER'), False, True, True)
  4125.         elif pSpreadCity.isHasReligion(iOrder) and iReligion == iVeil:
  4126.             if not pSpreadCity.isHolyCity():
  4127.                 result = CyGame().getSorenRandNum(100, "Veil-Order")
  4128.                 if (result < 35):
  4129.                     CyInterface().addMessage(iOwner,True,25,"A bloodbath ensues as the Order and Veil battle for control of the city! In the end, the streets are coated in Crusader blood. The Veil is victorious!",'AS2D_UNIT_BUILD_UNIT',1,'Art/Interface/Buttons/Religions/Ashen.dds',ColorTypes(5),pSpreadCity.getX(),pSpreadCity.getY(),True,True)
  4130.                     pSpreadCity.setHasReligion(gc.getInfoTypeForString('RELIGION_THE_ORDER'), False, True, True)
  4131.                     iPop = pSpreadCity.getPopulation()-1
  4132.                     if (iPop > 0):
  4133.                         pSpreadCity.setPopulation(iPop)
  4134.                     CyGame().changeGlobalCounter(1)
  4135.                 else :
  4136.                     CyInterface().addMessage(iOwner,True,25,"A bloodbath ensues as the Order and Veil battle for control of the city! In the end, Ritualists lie dead in the streets. The Order is triumphant!",'AS2D_UNIT_BUILD_UNIT',1,'Art/Interface/Buttons/Religions/Order.dds',ColorTypes(14),pSpreadCity.getX(),pSpreadCity.getY(),True,True)
  4137.                     pSpreadCity.setHasReligion(gc.getInfoTypeForString('RELIGION_THE_ASHEN_VEIL'), False, True, True)
  4138.  
  4139.         if (not self.__LOG_RELIGIONSPREAD):
  4140.             return
  4141.         CvUtil.pyPrint('%s has spread to Player %d Civilization %s city of %s'
  4142.             %(gc.getReligionInfo(iReligion).getDescription(), iOwner, player.getCivilizationName(), pSpreadCity.getName()))
  4143.  
  4144.     def onReligionRemove(self, argsList):
  4145.     ## Platy Builder ##
  4146.         if CyGame().GetWorldBuilderMode() and not CvPlatyBuilderScreen.bPython: return
  4147.     ## Platy Builder ##
  4148.         'Religion Has been removed from a City'
  4149.         iReligion, iOwner, pRemoveCity = argsList
  4150.         player = PyPlayer(iOwner)
  4151.         if (not self.__LOG_RELIGIONSPREAD):
  4152.             return
  4153.         CvUtil.pyPrint('%s has been removed from Player %d Civilization %s city of %s'
  4154.             %(gc.getReligionInfo(iReligion).getDescription(), iOwner, player.getCivilizationName(), pRemoveCity.getName()))
  4155.  
  4156.     def onCorporationFounded(self, argsList):
  4157.     ## Platy Builder ##
  4158.         if CyGame().GetWorldBuilderMode() and not CvPlatyBuilderScreen.bPython: return
  4159.     ## Platy Builder ##
  4160.         'Corporation Founded'
  4161.         iCorporation, iFounder = argsList
  4162.         player = PyPlayer(iFounder)
  4163.         if (not self.__LOG_RELIGION):
  4164.             return
  4165.         CvUtil.pyPrint('Player %d Civilization %s has founded %s'
  4166.             %(iFounder, player.getCivilizationName(), gc.getCorporationInfo(iCorporation).getDescription()))
  4167.  
  4168.     def onCorporationSpread(self, argsList):
  4169.     ## Platy Builder ##
  4170.         if CyGame().GetWorldBuilderMode() and not CvPlatyBuilderScreen.bPython: return
  4171.     ## Platy Builder ##
  4172.         'Corporation Has Spread to a City'
  4173.         iCorporation, iOwner, pSpreadCity = argsList
  4174.         player = PyPlayer(iOwner)
  4175.         if (not self.__LOG_RELIGIONSPREAD):
  4176.             return
  4177.         CvUtil.pyPrint('%s has spread to Player %d Civilization %s city of %s'
  4178.             %(gc.getCorporationInfo(iCorporation).getDescription(), iOwner, player.getCivilizationName(), pSpreadCity.getName()))
  4179.  
  4180.     def onCorporationRemove(self, argsList):
  4181.     ## Platy Builder ##
  4182.         if CyGame().GetWorldBuilderMode() and not CvPlatyBuilderScreen.bPython: return
  4183.     ## Platy Builder ##
  4184.         'Corporation Has been removed from a City'
  4185.         iCorporation, iOwner, pRemoveCity = argsList
  4186.         player = PyPlayer(iOwner)
  4187.         if (not self.__LOG_RELIGIONSPREAD):
  4188.             return
  4189.         CvUtil.pyPrint('%s has been removed from Player %d Civilization %s city of %s'
  4190.             %(gc.getReligionInfo(iReligion).getDescription(), iOwner, player.getCivilizationName(), pRemoveCity.getName()))
  4191.  
  4192.     def onGoldenAge(self, argsList):
  4193.     ## Platy Builder ##
  4194.         if CyGame().GetWorldBuilderMode() and not CvPlatyBuilderScreen.bPython: return
  4195.     ## Platy Builder ##
  4196.         'Golden Age'
  4197.         iPlayer = argsList[0]
  4198.         player = PyPlayer(iPlayer)
  4199.         if (not self.__LOG_GOLDENAGE):
  4200.             return
  4201.         CvUtil.pyPrint('Player %d Civilization %s has begun a golden age'
  4202.             %(iPlayer, player.getCivilizationName()))
  4203.  
  4204.     def onEndGoldenAge(self, argsList):
  4205.     ## Platy Builder ##
  4206.         if CyGame().GetWorldBuilderMode() and not CvPlatyBuilderScreen.bPython: return
  4207.     ## Platy Builder ##
  4208.         'End Golden Age'
  4209.         iPlayer = argsList[0]
  4210.         player = PyPlayer(iPlayer)
  4211.         if (not self.__LOG_ENDGOLDENAGE):
  4212.             return
  4213.         CvUtil.pyPrint('Player %d Civilization %s golden age has ended'
  4214.             %(iPlayer, player.getCivilizationName()))
  4215.  
  4216.     def onChangeWar(self, argsList):
  4217.     ## Platy Builder ##
  4218.         if CyGame().GetWorldBuilderMode() and not CvPlatyBuilderScreen.bPython: return
  4219.     ## Platy Builder ##
  4220.         'War Status Changes'
  4221.         bIsWar = argsList[0]
  4222.         iTeam = argsList[1]
  4223.         iRivalTeam = argsList[2]
  4224.  
  4225.     def onChat(self, argsList):
  4226.         'Chat Message Event'
  4227.         chatMessage = "%s" %(argsList[0],)
  4228.  
  4229.     def onSetPlayerAlive(self, argsList):
  4230.         'Set Player Alive Event'
  4231.         iPlayerID = argsList[0]
  4232.         bNewValue = argsList[1]
  4233.         CvUtil.pyPrint("Player %d's alive status set to: %d" %(iPlayerID, int(bNewValue)))
  4234.  
  4235.         if not bNewValue and gc.getGame().getGameTurnYear() >= 5:
  4236.             pPlayer = gc.getPlayer(iPlayerID)
  4237.             if pPlayer.getAlignment() == gc.getInfoTypeForString('ALIGNMENT_GOOD'):
  4238.                 CyGame().changeGlobalCounter(5)
  4239.             elif pPlayer.getAlignment() == gc.getInfoTypeForString('ALIGNMENT_EVIL'):
  4240.                 CyGame().changeGlobalCounter(-5)
  4241.             if CyGame().getWBMapScript():
  4242.                 sf.playerDefeated(pPlayer)
  4243.             else:
  4244.                 iLeader = pPlayer.getLeaderType()
  4245.                 if iLeader == gc.getInfoTypeForString('LEADER_ALEXIS'):
  4246.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_CALABIM",()),'art/interface/popups/Alexis.dds')
  4247.                 elif iLeader == gc.getInfoTypeForString('LEADER_AMELANCHIER'):
  4248.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_LJOSALFAR",()),'art/interface/popups/Amelanchier.dds')
  4249.                 elif iLeader == gc.getInfoTypeForString('LEADER_ARENDEL'):
  4250.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_LJOSALFAR",()),'art/interface/popups/Arendel.dds')
  4251.                 elif iLeader == gc.getInfoTypeForString('LEADER_ARTURUS'):
  4252.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_KHAZAD",()),'art/interface/popups/Arturus.dds')
  4253.                 elif iLeader == gc.getInfoTypeForString('LEADER_AURIC'):
  4254.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_ILLIANS",()),'art/interface/popups/Auric.dds')
  4255.                 elif iLeader == gc.getInfoTypeForString('LEADER_BASIUM'):
  4256.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_MERCURIANS",()),'art/interface/popups/Basium.dds')
  4257.                 elif iLeader == gc.getInfoTypeForString('LEADER_BEERI'):
  4258.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_LUCHUIRP",()),'art/interface/popups/Beeri.dds')
  4259.                 elif iLeader == gc.getInfoTypeForString('LEADER_CAPRIA'):
  4260.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_BANNOR",()),'art/interface/popups/Capria.dds')
  4261.                 elif iLeader == gc.getInfoTypeForString('LEADER_CARDITH'):
  4262.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_KURIOTATES",()),'art/interface/popups/Cardith.dds')
  4263.                 elif iLeader == gc.getInfoTypeForString('LEADER_CASSIEL'):
  4264.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_GRIGORI",()),'art/interface/popups/Cassiel.dds')
  4265.                 elif iLeader == gc.getInfoTypeForString('LEADER_CHARADON'):
  4266.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_DOVIELLO",()),'art/interface/popups/Charadon.dds')
  4267.                 elif iLeader == gc.getInfoTypeForString('LEADER_DAIN'):
  4268.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_AMURITES",()),'art/interface/popups/Dain.dds')
  4269.                 elif iLeader == gc.getInfoTypeForString('LEADER_DECIUS'):
  4270.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_DECIUS",()),'art/interface/popups/Decius.dds')
  4271.                 elif iLeader == gc.getInfoTypeForString('LEADER_EINION'):
  4272.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_ELOHIM",()),'art/interface/popups/Einion.dds')
  4273.                 elif iLeader == gc.getInfoTypeForString('LEADER_ETHNE'):
  4274.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_ELOHIM",()),'art/interface/popups/Ethne.dds')
  4275.                 elif iLeader == gc.getInfoTypeForString('LEADER_FAERYL'):
  4276.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_SVARTALFAR",()),'art/interface/popups/Faeryl.dds')
  4277.                 elif iLeader == gc.getInfoTypeForString('LEADER_FALAMAR'):
  4278.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_LANUN",()),'art/interface/popups/Falamar.dds')
  4279.                 elif iLeader == gc.getInfoTypeForString('LEADER_FLAUROS'):
  4280.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_CALABIM",()),'art/interface/popups/Flauros.dds')
  4281.                 elif iLeader == gc.getInfoTypeForString('LEADER_GARRIM'):
  4282.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_LUCHUIRP",()),'art/interface/popups/Garrim.dds')
  4283.                 elif iLeader == gc.getInfoTypeForString('LEADER_HANNAH'):
  4284.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_HANNAH",()),'art/interface/popups/Hannah.dds')
  4285.                 elif iLeader == gc.getInfoTypeForString('LEADER_HYBOREM'):
  4286.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_INFERNAL",()),'art/interface/popups/Hyborem.dds')
  4287.                 elif iLeader == gc.getInfoTypeForString('LEADER_JONAS'):
  4288.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_CLAN_OF_EMBERS",()),'art/interface/popups/Jonus.dds')
  4289.                 elif iLeader == gc.getInfoTypeForString('LEADER_KANDROS'):
  4290.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_KHAZAD",()),'art/interface/popups/Kandros.dds')
  4291.                 elif iLeader == gc.getInfoTypeForString('LEADER_KEELYN'):
  4292.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_KEELYN",()),'art/interface/popups/Keelyn.dds')
  4293.                 elif iLeader == gc.getInfoTypeForString('LEADER_MAHALA'):
  4294.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_DOVIELLO",()),'art/interface/popups/Mahala.dds')
  4295.                 elif iLeader == gc.getInfoTypeForString('LEADER_SANDALPHON'):
  4296.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_SIDAR",()),'art/interface/popups/Sandalphon.dds')
  4297.                 elif iLeader == gc.getInfoTypeForString('LEADER_OS-GABELLA'):
  4298.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_SHEAIM",()),'art/interface/popups/Os-Gabella.dds')
  4299.                 elif iLeader == gc.getInfoTypeForString('LEADER_PERPENTACH'):
  4300.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_BALSERAPHS",()),'art/interface/popups/Perpentach.dds')
  4301.                 elif iLeader == gc.getInfoTypeForString('LEADER_RHOANNA'):
  4302.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_HIPPUS",()),'art/interface/popups/Rhoanna.dds')
  4303.                 elif iLeader == gc.getInfoTypeForString('LEADER_SABATHIEL'):
  4304.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_BANNOR",()),'art/interface/popups/Sabathiel.dds')
  4305.                 elif iLeader == gc.getInfoTypeForString('LEADER_SHEELBA'):
  4306.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_CLAN_OF_EMBERS",()),'art/interface/popups/Sheelba.dds')
  4307.                 elif iLeader == gc.getInfoTypeForString('LEADER_TASUNKE'):
  4308.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_HIPPUS",()),'art/interface/popups/Tasunke.dds')
  4309.                 elif iLeader == gc.getInfoTypeForString('LEADER_TEBRYN'):
  4310.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_SHEAIM",()),'art/interface/popups/Tebryn.dds')
  4311.                 elif iLeader == gc.getInfoTypeForString('LEADER_THESSA'):
  4312.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_LJOSALFAR",()),'art/interface/popups/Thessa.dds')
  4313.                 elif iLeader == gc.getInfoTypeForString('LEADER_VALLEDIA'):
  4314.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_AMURITES",()),'art/interface/popups/Valledia.dds')
  4315.                 elif iLeader == gc.getInfoTypeForString('LEADER_VARN'):
  4316.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_MALAKIM",()),'art/interface/popups/Varn.dds')
  4317.  
  4318.     def onPlayerChangeStateReligion(self, argsList):
  4319.     ## Platy Builder ##
  4320.         if CyGame().GetWorldBuilderMode() and not CvPlatyBuilderScreen.bPython: return
  4321.     ## Platy Builder ##
  4322.         'Player changes his state religion'
  4323.         iPlayer, iNewReligion, iOldReligion = argsList
  4324.         if iNewReligion != iOldReligion:
  4325.             pPlayer = gc.getPlayer(iPlayer)
  4326.             if iNewReligion == -1:
  4327.                 iCurrentEra = pPlayer.getCurrentEra()
  4328.                 iEra = iCurrentEra
  4329.                 if not (iCurrentEra == gc.getInfoTypeForString('ERA_ANCIENT') or iCurrentEra == gc.getInfoTypeForString('ERA_CLASSICAL') or iCurrentEra == gc.getInfoTypeForString('ERA_MEDIEVAL')):
  4330.                     iEra = gc.getGame().getStartEra()
  4331.                     pPlayer.setCurrentEra(iEra)
  4332.             elif iNewReligion == gc.getInfoTypeForString('RELIGION_THE_ORDER'):
  4333.                 pPlayer.setCurrentEra(gc.getInfoTypeForString('ERA_ORDE'))
  4334.             elif iNewReligion == gc.getInfoTypeForString('RELIGION_THE_EMPYREAN'):
  4335.                 pPlayer.setCurrentEra(gc.getInfoTypeForString('ERA_EMPY'))
  4336.             elif iNewReligion == gc.getInfoTypeForString('RELIGION_RUNES_OF_KILMORPH'):
  4337.                 pPlayer.setCurrentEra(gc.getInfoTypeForString('ERA_RUNE'))
  4338.             elif iNewReligion == gc.getInfoTypeForString('RELIGION_FELLOWSHIP_OF_LEAVES'):
  4339.                 pPlayer.setCurrentEra(gc.getInfoTypeForString('ERA_LEAF'))
  4340.             elif iNewReligion == gc.getInfoTypeForString('RELIGION_OCTOPUS_OVERLORDS'):
  4341.                 pPlayer.setCurrentEra(gc.getInfoTypeForString('ERA_OCTO'))
  4342.             elif iNewReligion == gc.getInfoTypeForString('RELIGION_COUNCIL_OF_ESUS'):
  4343.                 pPlayer.setCurrentEra(gc.getInfoTypeForString('ERA_COUN'))
  4344.             elif iNewReligion == gc.getInfoTypeForString('RELIGION_THE_ASHEN_VEIL'):
  4345.                 pPlayer.setCurrentEra(gc.getInfoTypeForString('ERA_VEIL'))
  4346.  
  4347.     def onPlayerGoldTrade(self, argsList):
  4348.         'Player Trades gold to another player'
  4349.         iFromPlayer, iToPlayer, iGoldAmount = argsList
  4350.  
  4351.     def onCityBuilt(self, argsList):
  4352.         'City Built'
  4353.         city = argsList[0]
  4354.         pPlot = city.plot()
  4355.         pPlayer = gc.getPlayer(city.getOwner())
  4356.  
  4357.         if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_INFERNAL'):
  4358.             city.setHasReligion(gc.getInfoTypeForString('RELIGION_THE_ASHEN_VEIL'), True, True, True)
  4359.             city.setPopulation(3)
  4360.             city.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_ELDER_COUNCIL'), 1)
  4361.             city.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_TRAINING_YARD'), 1)
  4362.             city.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_OBSIDIAN_GATE'), 1)
  4363.             city.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_FORGE'), 1)
  4364.             city.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_MAGE_GUILD'), 1)
  4365.             city.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_DEMONIC_CITIZENS'), 1)
  4366.  
  4367.         elif pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_BARBARIAN'):
  4368.             eTeam = gc.getTeam(gc.getPlayer(gc.getBARBARIAN_PLAYER()).getTeam())
  4369.  
  4370.             iUnit = gc.getInfoTypeForString('UNIT_ARCHER')
  4371.             if eTeam.isHasTech(gc.getInfoTypeForString('TECH_BOWYERS')) or CyGame().getStartEra() > gc.getInfoTypeForString('ERA_CLASSICAL'):
  4372.                 iUnit = gc.getInfoTypeForString('UNIT_LONGBOWMAN')
  4373.             newUnit2 = pPlayer.initUnit(iUnit, city.getX(), city.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
  4374.             newUnit3 = pPlayer.initUnit(iUnit, city.getX(), city.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
  4375.             newUnit2.setHasPromotion(gc.getInfoTypeForString('PROMOTION_ORC'), True)
  4376.             newUnit3.setHasPromotion(gc.getInfoTypeForString('PROMOTION_ORC'), True)
  4377.             if not eTeam.isHasTech(gc.getInfoTypeForString('TECH_ARCHERY')) or CyGame().getStartEra() == gc.getInfoTypeForString('ERA_ANCIENT'):
  4378.                 newUnit2.setHasPromotion(gc.getInfoTypeForString('PROMOTION_WEAK'), True)
  4379.                 newUnit3.setHasPromotion(gc.getInfoTypeForString('PROMOTION_WEAK'), True)
  4380.  
  4381.         if CyGame().getWBMapScript():
  4382.             sf.onCityBuilt(city)
  4383.  
  4384.         if (city.getOwner() == CyGame().getActivePlayer())and ( CyGame().getAIAutoPlay(CyGame().getActivePlayer()) == 0 ):
  4385.             if not CyGame().GetWorldBuilderMode():#Platy WorldBuilder
  4386.                 self.__eventEditCityNameBegin(city, False)
  4387.         CvUtil.pyPrint('City Built Event: %s' %(city.getName()))
  4388.  
  4389.     def onCityRazed(self, argsList):
  4390.     ## Platy Builder ##
  4391.         if CyGame().GetWorldBuilderMode() and not CvPlatyBuilderScreen.bPython: return
  4392.     ## Platy Builder ##
  4393.         'City Razed'
  4394.         city, iPlayer = argsList
  4395.         iOwner = city.findHighestCulture()
  4396.  
  4397.         # Partisans!
  4398. #       if city.getPopulation > 1 and iOwner != -1 and iPlayer != -1:
  4399. #           owner = gc.getPlayer(iOwner)
  4400. #           if not owner.isBarbarian() and owner.getNumCities() > 0:
  4401. #               if gc.getTeam(owner.getTeam()).isAtWar(gc.getPlayer(iPlayer).getTeam()):
  4402. #                   if gc.getNumEventTriggerInfos() > 0: # prevents mods that don't have events from getting an error
  4403. #                       iEvent = CvUtil.findInfoTypeNum(gc.getEventTriggerInfo, gc.getNumEventTriggerInfos(),'EVENTTRIGGER_PARTISANS')
  4404. #                       if iEvent != -1 and gc.getGame().isEventActive(iEvent) and owner.getEventTriggerWeight(iEvent) >= 0:
  4405. #                           triggerData = owner.initTriggeredData(iEvent, True, -1, city.getX(), city.getY(), iPlayer, city.getID(), -1, -1, -1, -1)
  4406.  
  4407.         iAngel = gc.getInfoTypeForString('UNIT_ANGEL')
  4408.         iInfernal = gc.getInfoTypeForString('CIVILIZATION_INFERNAL')
  4409.         iManes = gc.getInfoTypeForString('UNIT_MANES')
  4410.         iMercurians = gc.getInfoTypeForString('CIVILIZATION_MERCURIANS')
  4411.         pPlayer = gc.getPlayer(iPlayer)
  4412.         if gc.getPlayer(city.getOriginalOwner()).getAlignment() == gc.getInfoTypeForString('ALIGNMENT_EVIL'):
  4413.             if gc.getPlayer(city.getOriginalOwner()).getCivilizationType() != iInfernal:
  4414.                 for i in range(city.getPopulation()):
  4415.                     cf.giftUnit(iManes, iInfernal, 0, city.plot(), city.getOwner())
  4416.  
  4417.         elif gc.getPlayer(city.getOriginalOwner()).getAlignment() == gc.getInfoTypeForString('ALIGNMENT_NEUTRAL'):
  4418.             for i in range((city.getPopulation() / 4) + 1):
  4419.                 cf.giftUnit(iManes, iInfernal, 0, city.plot(), city.getOwner())
  4420.                 cf.giftUnit(iManes, iInfernal, 0, city.plot(), city.getOwner())
  4421.                 cf.giftUnit(iAngel, iMercurians, 0, city.plot(), city.getOwner())
  4422.  
  4423.         elif gc.getPlayer(city.getOriginalOwner()).getAlignment() == gc.getInfoTypeForString('ALIGNMENT_GOOD'):
  4424.             for i in range((city.getPopulation() / 2) + 1):
  4425.                 cf.giftUnit(iAngel, iMercurians, 0, city.plot(), city.getOwner())
  4426.  
  4427.         pPlot = city.plot()
  4428.         iPop = city.getPopulation()
  4429.         iCalabim = gc.getInfoTypeForString('CIVILIZATION_CALABIM')
  4430.         if pPlayer.getCivilizationType() == iCalabim and iPop > 2:
  4431.             iVampire = gc.getInfoTypeForString('PROMOTION_VAMPIRE')
  4432.             for i in range(pPlot.getNumUnits()):
  4433.                 if iPop < 3: break
  4434.                 pUnit = pPlot.getUnit(i)
  4435.                 if pUnit.isHasPromotion(iVampire):
  4436.                     pUnit.changeExperience(iPop, -1, False, False, False)
  4437.                     iPop = iPop - 1
  4438.  
  4439.         if CyGame().getWBMapScript():
  4440.             sf.onCityRazed(city, iPlayer)
  4441.  
  4442.         CvUtil.pyPrint("City Razed Event: %s" %(city.getName(),))
  4443.  
  4444.     def onCityAcquired(self, argsList):
  4445.     ## Platy Builder ##
  4446.         if CyGame().GetWorldBuilderMode() and not CvPlatyBuilderScreen.bPython: return
  4447.     ## Platy Builder ##
  4448.         'City Acquired'
  4449.         iPreviousOwner,iNewOwner,pCity,bConquest,bTrade = argsList
  4450.         pPlayer = gc.getPlayer(iNewOwner)
  4451.         pPrevious = gc.getPlayer(iPreviousOwner)
  4452.  
  4453. ## FFH
  4454.         if pPrevious.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_INFERNAL'):
  4455.             pCity.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_OBSIDIAN_GATE'), 0)
  4456.  
  4457.         if CyGame().getWBMapScript():
  4458.             sf.onCityAcquired(iPreviousOwner, iNewOwner, pCity, bConquest, bTrade)
  4459.  
  4460.         if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_INFERNAL'):
  4461.             pCity.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_ELDER_COUNCIL'), 1)
  4462.             pCity.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_TRAINING_YARD'), 1)
  4463.             pCity.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_OBSIDIAN_GATE'), 1)
  4464.             pCity.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_FORGE'), 1)
  4465.             pCity.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_MAGE_GUILD'), 1)
  4466.             pCity.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_DEMONIC_CITIZENS'), 1)
  4467. ## END FFH
  4468.  
  4469.     def onCityAcquiredAndKept(self, argsList):
  4470.         'City Acquired and Kept'
  4471.         iOwner,pCity = argsList
  4472.  
  4473.         #Functions added here tend to cause OOS issues
  4474.  
  4475.         CvUtil.pyPrint('City Acquired and Kept Event: %s' %(pCity.getName()))
  4476.  
  4477.     def onCityLost(self, argsList):
  4478.         'City Lost'
  4479.         city = argsList[0]
  4480.         player = PyPlayer(city.getOwner())
  4481.         if (not self.__LOG_CITYLOST):
  4482.             return
  4483.         CvUtil.pyPrint('City %s was lost by Player %d Civilization %s'
  4484.             %(city.getName(), player.getID(), player.getCivilizationName()))
  4485.  
  4486.     def onCultureExpansion(self, argsList):
  4487.     ## Platy Builder ##
  4488.         if CyGame().GetWorldBuilderMode() and not CvPlatyBuilderScreen.bPython: return
  4489.     ## Platy Builder ##
  4490.         'City Culture Expansion'
  4491.         pCity = argsList[0]
  4492.         iPlayer = argsList[1]
  4493.         CvUtil.pyPrint("City %s's culture has expanded" %(pCity.getName(),))
  4494.  
  4495.     def onCityGrowth(self, argsList):
  4496.         'City Population Growth'
  4497.         pCity = argsList[0]
  4498.         iPlayer = argsList[1]
  4499.         CvUtil.pyPrint("%s has grown" %(pCity.getName(),))
  4500.  
  4501.     def onCityDoTurn(self, argsList):
  4502.         'City Production'
  4503.         pCity = argsList[0]
  4504.         iPlayer = argsList[1]
  4505.         pPlot = pCity.plot()
  4506.         iPlayer = pCity.getOwner()
  4507.         pPlayer = gc.getPlayer(iPlayer)
  4508.  
  4509.         if pCity.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_CITADEL_OF_LIGHT')) > 0:
  4510.             iX = pCity.getX()
  4511.             iY = pCity.getY()
  4512.             eTeam = gc.getTeam(pPlayer.getTeam())
  4513.             iBestValue = 0
  4514.             pBestPlot = -1
  4515.             for iiX in range(iX-2, iX+3, 1):
  4516.                 for iiY in range(iY-2, iY+3, 1):
  4517.                     pPlot2 = CyMap().plot(iiX,iiY)
  4518.                     bEnemy = False
  4519.                     bNeutral = False
  4520.                     iValue = 0
  4521.                     if pPlot2.isVisibleEnemyUnit(iPlayer):
  4522.                         for i in range(pPlot2.getNumUnits()):
  4523.                             pUnit = pPlot2.getUnit(i)
  4524.                             if eTeam.isAtWar(pUnit.getTeam()):
  4525.                                 iValue += 5 * pUnit.baseCombatStr()
  4526.                             else:
  4527.                                 bNeutral = True
  4528.                         if (iValue > iBestValue and bNeutral == False):
  4529.                             iBestValue = iValue
  4530.                             pBestPlot = pPlot2
  4531.             if pBestPlot != -1:
  4532.                 for i in range(pBestPlot.getNumUnits()):
  4533.                     pUnit = pBestPlot.getUnit(i)
  4534.                     pUnit.doDamageNoCaster(20, 40, gc.getInfoTypeForString('DAMAGE_FIRE'), False)
  4535.                 if (pBestPlot.getFeatureType() == gc.getInfoTypeForString('FEATURE_FOREST') or pBestPlot.getFeatureType() == gc.getInfoTypeForString('FEATURE_JUNGLE')):
  4536.                     bValid = True
  4537.                     iImprovement = pPlot.getImprovementType()
  4538.                     if iImprovement != -1 :
  4539.                         if gc.getImprovementInfo(iImprovement).isPermanent():
  4540.                             bValid = False
  4541.                     if bValid:
  4542.                         if CyGame().getSorenRandNum(100, "Flames Spread") < gc.getDefineINT('FLAMES_SPREAD_CHANCE'):
  4543.                             pBestPlot.setImprovementType(gc.getInfoTypeForString('IMPROVEMENT_SMOKE'))
  4544.                 CyEngine().triggerEffect(gc.getInfoTypeForString('EFFECT_PILLAR_OF_FIRE'),pBestPlot.getPoint())
  4545.  
  4546.         if pCity.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_HALL_OF_MIRRORS')) > 0:
  4547.             if CyGame().getSorenRandNum(100, "Hall of Mirrors") < 100:
  4548.                 pUnit = -1
  4549.                 iBestValue = -1
  4550.                 iX = pCity.getX()
  4551.                 iY = pCity.getY()
  4552.                 eTeam = gc.getTeam(pPlayer.getTeam())
  4553.                 for iiX in range(iX-1, iX+2, 1):
  4554.                     for iiY in range(iY-1, iY+2, 1):
  4555.                         pLoopPlot = CyMap().plot(iiX,iiY)
  4556.                         if not pLoopPlot.isNone():
  4557.                             if pLoopPlot.isVisibleEnemyUnit(iPlayer):
  4558.                                 for i in range(pLoopPlot.getNumUnits()):
  4559.                                     pUnit2 = pLoopPlot.getUnit(i)
  4560.                                     if eTeam.isAtWar(pUnit2.getTeam()):
  4561.                                         iValue = CyGame().getSorenRandNum(100, "Hall of Mirrors")
  4562.                                         if (iValue > iBestValue):
  4563.                                             iBestValue = iValue
  4564.                                             pUnit = pUnit2
  4565.                 if pUnit != -1:
  4566.                     newUnit = pPlayer.initUnit(pUnit.getUnitType(), pCity.getX(), pCity.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
  4567.                     newUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_ILLUSION'), True)
  4568.  
  4569. ##--------      Unofficial Bug Fix: Modified by Denev   --------##
  4570. # Copy not only unit type, but also unit artstyle.
  4571.                     newUnit.setUnitArtStyleType(pUnit.getUnitArtStyleType())
  4572. ##--------      Unofficial Bug Fix: End Modify          --------##
  4573.  
  4574.                     if pPlayer.hasTrait(gc.getInfoTypeForString('TRAIT_SUMMONER')):
  4575.                         newUnit.setDuration(5)
  4576.                     else:
  4577.                         newUnit.setDuration(3)
  4578.  
  4579.         if pCity.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_EYES_AND_EARS_NETWORK')) > 0:
  4580.             iArete = gc.getInfoTypeForString('TECH_ARETE')
  4581.             iHiddenPaths = gc.getInfoTypeForString('TECH_HIDDEN_PATHS')
  4582.             iInfernalPact = gc.getInfoTypeForString('TECH_INFERNAL_PACT')
  4583.             iMindStapling = gc.getInfoTypeForString('TECH_MIND_STAPLING')
  4584.             iSeafaring = gc.getInfoTypeForString('TECH_SEAFARING')
  4585.             eTeam = gc.getTeam(pPlayer.getTeam())
  4586.             listTeams = []
  4587.             for iPlayer2 in range(gc.getMAX_PLAYERS()):
  4588.                 pPlayer2 = gc.getPlayer(iPlayer2)
  4589.                 if (pPlayer2.isAlive() and iPlayer2 != iPlayer):
  4590.                     iTeam2 = pPlayer2.getTeam()
  4591.                     if eTeam.isOpenBorders(iTeam2):
  4592.                         listTeams.append(gc.getTeam(iTeam2))
  4593.             if len(listTeams) >= 3:
  4594.                 for iTech in range(gc.getNumTechInfos()):
  4595.                     if (iTech != iArete and iTech != iMindStapling and iTech != iHiddenPaths and iTech != iInfernalPact and iTech != iSeafaring):
  4596.                         if eTeam.isHasTech(iTech) == False:
  4597.                             if pPlayer.canResearch(iTech, False):
  4598.                                 iCount = 0
  4599.                                 for i in range(len(listTeams)):
  4600.                                     if listTeams[i].isHasTech(iTech):
  4601.                                         iCount = iCount + 1
  4602.                                 if iCount >= 3:
  4603.                                     eTeam.setHasTech(iTech, True, iPlayer, False, True)
  4604.                                     CyInterface().addMessage(iPlayer,True,25,CyTranslator().getText("TXT_KEY_MESSAGE_EYES_AND_EARS_NETWORK_FREE_TECH",()),'AS2D_TECH_DING',1,'Art/Interface/Buttons/Buildings/Eyesandearsnetwork.dds',ColorTypes(8),pCity.getX(),pCity.getY(),True,True)
  4605.  
  4606.         if pCity.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_PLANAR_GATE')) > 0:
  4607.             iMax = 1
  4608.             iMult = 1
  4609.             if CyGame().getGlobalCounter() >= 50:
  4610.                 iMax = 2
  4611.                 iMult = 1.5
  4612.             if CyGame().getGlobalCounter() >= 75:
  4613.                 iMax = 3
  4614.                 iMult = 2
  4615.             if CyGame().getGlobalCounter() == 100:
  4616.                 iMax = 4
  4617.                 iMult = 2.5
  4618.             if CyGame().getSorenRandNum(10000, "Planar Gate") < gc.getDefineINT('PLANAR_GATE_CHANCE') * iMult:
  4619.                 listUnits = []
  4620.                 iMax = iMax * pPlayer.countNumBuildings(gc.getInfoTypeForString('BUILDING_PLANAR_GATE'))
  4621.                 if pCity.getNumBuilding(gc.getInfoTypeForString('BUILDING_GAMBLING_HOUSE')) > 0:
  4622.                     if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_REVELERS')) < iMax:
  4623.                         listUnits.append(gc.getInfoTypeForString('UNIT_REVELERS'))
  4624.                 if pCity.getNumBuilding(gc.getInfoTypeForString('BUILDING_MAGE_GUILD')) > 0:
  4625.                     if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_MOBIUS_WITCH')) < iMax:
  4626.                         listUnits.append(gc.getInfoTypeForString('UNIT_MOBIUS_WITCH'))
  4627.                 if pCity.getNumBuilding(gc.getInfoTypeForString('BUILDING_CARNIVAL')) > 0:
  4628.                     if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_CHAOS_MARAUDER')) < iMax:
  4629.                         listUnits.append(gc.getInfoTypeForString('UNIT_CHAOS_MARAUDER'))
  4630.                 if pCity.getNumBuilding(gc.getInfoTypeForString('BUILDING_GROVE')) > 0:
  4631.                     if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_MANTICORE')) < iMax:
  4632.                         listUnits.append(gc.getInfoTypeForString('UNIT_MANTICORE'))
  4633.                 if pCity.getNumBuilding(gc.getInfoTypeForString('BUILDING_PUBLIC_BATHS')) > 0:
  4634.                     if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_SUCCUBUS')) < iMax:
  4635.                         listUnits.append(gc.getInfoTypeForString('UNIT_SUCCUBUS'))
  4636.                 if pCity.getNumBuilding(gc.getInfoTypeForString('BUILDING_OBSIDIAN_GATE')) > 0:
  4637.                     if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_MINOTAUR')) < iMax:
  4638.                         listUnits.append(gc.getInfoTypeForString('UNIT_MINOTAUR'))
  4639.                 if pCity.getNumBuilding(gc.getInfoTypeForString('BUILDING_TEMPLE_OF_THE_VEIL')) > 0:
  4640.                     if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_TAR_DEMON')) < iMax:
  4641.                         listUnits.append(gc.getInfoTypeForString('UNIT_TAR_DEMON'))
  4642.                 if len(listUnits) > 0:
  4643.                     iUnit = listUnits[CyGame().getSorenRandNum(len(listUnits), "Planar Gate")]
  4644.                     newUnit = pPlayer.initUnit(iUnit, pPlot.getX(), pPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
  4645.                     CyInterface().addMessage(iPlayer,True,25,CyTranslator().getText("TXT_KEY_MESSAGE_PLANAR_GATE",()),'AS2D_DISCOVERBONUS',1,gc.getUnitInfo(newUnit.getUnitType()).getButton(),ColorTypes(8),pCity.getX(),pCity.getY(),True,True)
  4646.                     if iUnit == gc.getInfoTypeForString('UNIT_MOBIUS_WITCH'):
  4647.                         promotions = [ 'PROMOTION_AIR1','PROMOTION_BODY1','PROMOTION_CHAOS1','PROMOTION_DEATH1','PROMOTION_EARTH1','PROMOTION_ENCHANTMENT1','PROMOTION_ENTROPY1','PROMOTION_FIRE1','PROMOTION_LAW1','PROMOTION_LIFE1','PROMOTION_MIND1','PROMOTION_NATURE1','PROMOTION_SHADOW1','PROMOTION_SPIRIT1','PROMOTION_SUN1','PROMOTION_WATER1' ]
  4648.                         newUnit.setLevel(4)
  4649.                         newUnit.setExperience(14, -1)
  4650.                         for i in promotions:
  4651.                             if CyGame().getSorenRandNum(10, "Bob") == 1:
  4652.                                 newUnit.setHasPromotion(gc.getInfoTypeForString(i), True)
  4653.  
  4654.         if gc.getPlayer(pCity.getOwner()).getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_INFERNAL'):
  4655.             if pCity.isHasReligion(gc.getInfoTypeForString('RELIGION_THE_ORDER')):
  4656.                 pCity.setHasReligion(gc.getInfoTypeForString('RELIGION_THE_ORDER'), False, True, True)
  4657.             if pCity.isHasReligion(gc.getInfoTypeForString('RELIGION_THE_ASHEN_VEIL')) == False:
  4658.                 pCity.setHasReligion(gc.getInfoTypeForString('RELIGION_THE_ASHEN_VEIL'), True, True, True)
  4659.  
  4660.         if gc.getPlayer(pCity.getOwner()).getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_MERCURIANS'):
  4661.             if pCity.isHasReligion(gc.getInfoTypeForString('RELIGION_THE_ASHEN_VEIL')):
  4662.                 pCity.setHasReligion(gc.getInfoTypeForString('RELIGION_THE_ASHEN_VEIL'), False, True, True)
  4663.  
  4664.         if pCity.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_SHRINE_OF_SIRONA')) > 0:
  4665.             pPlayer.setFeatAccomplished(FeatTypes.FEAT_HEAL_UNIT_PER_TURN, True)
  4666.  
  4667.         if pCity.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_THE_DRAGONS_HORDE')) > 0:
  4668.             if pPlayer.isBarbarian():
  4669.                 if CyGame().getSorenRandNum(100, "Bob") < gc.getHandicapInfo(gc.getGame().getHandicapType()).getLairSpawnRate():
  4670.                     iUnit = gc.getInfoTypeForString('UNIT_DISCIPLE_OF_ACHERON')
  4671. #                   eTeam = gc.getTeam(pPlayer.getTeam())
  4672. #                   if eTeam.isHasTech(gc.getInfoTypeForString('TECH_SORCERY')):
  4673. #                       iUnit = gc.getInfoTypeForString('UNIT_SON_OF_THE_INFERNO')
  4674.                     newUnit = pPlayer.initUnit(iUnit, pPlot.getX(), pPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
  4675.  
  4676.         CvAdvisorUtils.cityAdvise(pCity, iPlayer)
  4677.  
  4678.     def onCityBuildingUnit(self, argsList):
  4679.         'City begins building a unit'
  4680.         pCity = argsList[0]
  4681.         iUnitType = argsList[1]
  4682.         if (not self.__LOG_CITYBUILDING):
  4683.             return
  4684.         CvUtil.pyPrint("%s has begun building a %s" %(pCity.getName(),gc.getUnitInfo(iUnitType).getDescription()))
  4685.  
  4686.     def onCityBuildingBuilding(self, argsList):
  4687.         'City begins building a Building'
  4688.         pCity = argsList[0]
  4689.         iBuildingType = argsList[1]
  4690.         if (not self.__LOG_CITYBUILDING):
  4691.             return
  4692.         CvUtil.pyPrint("%s has begun building a %s" %(pCity.getName(),gc.getBuildingInfo(iBuildingType).getDescription()))
  4693.  
  4694.     def onCityRename(self, argsList):
  4695.         'City is renamed'
  4696.         pCity = argsList[0]
  4697.         if (pCity.getOwner() == gc.getGame().getActivePlayer()):
  4698.             self.__eventEditCityNameBegin(pCity, True)
  4699.  
  4700.     def onCityHurry(self, argsList):
  4701.         'City is renamed'
  4702.         pCity = argsList[0]
  4703.         iHurryType = argsList[1]
  4704.  
  4705.     def onVictory(self, argsList):
  4706.         'Victory'
  4707.         iTeam, iVictory = argsList
  4708.         if (iVictory >= 0 and iVictory < gc.getNumVictoryInfos()):
  4709.             for iPlayer in range(gc.getMAX_PLAYERS()):
  4710.                 pPlayer = gc.getPlayer(iPlayer)
  4711.                 if pPlayer.isAlive():
  4712.                     if pPlayer.isHuman():
  4713.                         if pPlayer.getTeam() == iTeam:
  4714.                             if CyGame().getWBMapScript():
  4715.                                 sf.onVictory(iPlayer, iVictory)
  4716.                             else:
  4717.                                 iCiv = pPlayer.getCivilizationType()
  4718.                                 if iCiv == gc.getInfoTypeForString('CIVILIZATION_AMURITES'):
  4719.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_AMURITES", 1)
  4720.                                 elif iCiv == gc.getInfoTypeForString('CIVILIZATION_BALSERAPHS'):
  4721.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_BALSERAPHS", 1)
  4722.                                 elif iCiv == gc.getInfoTypeForString('CIVILIZATION_BANNOR'):
  4723.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_BANNOR", 1)
  4724.                                 elif iCiv == gc.getInfoTypeForString('CIVILIZATION_CALABIM'):
  4725.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_CALABIM", 1)
  4726.                                 elif iCiv == gc.getInfoTypeForString('CIVILIZATION_CLAN_OF_EMBERS'):
  4727.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_CLAN_OF_EMBERS", 1)
  4728.                                 elif iCiv == gc.getInfoTypeForString('CIVILIZATION_DOVIELLO'):
  4729.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_DOVIELLO", 1)
  4730.                                 elif iCiv == gc.getInfoTypeForString('CIVILIZATION_ELOHIM'):
  4731.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_ELOHIM", 1)
  4732.                                 elif iCiv == gc.getInfoTypeForString('CIVILIZATION_GRIGORI'):
  4733.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_GRIGORI", 1)
  4734.                                 elif iCiv == gc.getInfoTypeForString('CIVILIZATION_HIPPUS'):
  4735.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_HIPPUS", 1)
  4736.                                 elif iCiv == gc.getInfoTypeForString('CIVILIZATION_ILLIANS'):
  4737.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_ILLIANS", 1)
  4738.                                 elif iCiv == gc.getInfoTypeForString('CIVILIZATION_INFERNAL'):
  4739.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_INFERNAL", 1)
  4740.                                 elif iCiv == gc.getInfoTypeForString('CIVILIZATION_KHAZAD'):
  4741.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_KHAZAD", 1)
  4742.                                 elif iCiv == gc.getInfoTypeForString('CIVILIZATION_KURIOTATES'):
  4743.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_KURIOTATES", 1)
  4744.                                 elif iCiv == gc.getInfoTypeForString('CIVILIZATION_LANUN'):
  4745.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_LANUN", 1)
  4746.                                 elif iCiv == gc.getInfoTypeForString('CIVILIZATION_LJOSALFAR'):
  4747.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_LJOSALFAR", 1)
  4748.                                 elif iCiv == gc.getInfoTypeForString('CIVILIZATION_LUCHUIRP'):
  4749.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_LUCHUIRP", 1)
  4750.                                 elif iCiv == gc.getInfoTypeForString('CIVILIZATION_MALAKIM'):
  4751.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_MALAKIM", 1)
  4752.                                 elif iCiv == gc.getInfoTypeForString('CIVILIZATION_MERCURIANS'):
  4753.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_MERCURIANS", 1)
  4754.                                 elif iCiv == gc.getInfoTypeForString('CIVILIZATION_SHEAIM'):
  4755.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_SHEAIM", 1)
  4756.                                 elif iCiv == gc.getInfoTypeForString('CIVILIZATION_SIDAR'):
  4757.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_SIDAR", 1)
  4758.                                 elif iCiv == gc.getInfoTypeForString('CIVILIZATION_SVARTALFAR'):
  4759.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_SVARTALFAR", 1)
  4760.  
  4761.                                 if iVictory == gc.getInfoTypeForString('VICTORY_ALTAR_OF_THE_LUONNOTAR'):
  4762.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_ALTAR_OF_THE_LUONNOTAR", 1)
  4763.                                 elif iVictory == gc.getInfoTypeForString('VICTORY_CONQUEST'):
  4764.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_CONQUEST", 1)
  4765.                                 elif iVictory == gc.getInfoTypeForString('VICTORY_CULTURAL'):
  4766.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_CULTURAL", 1)
  4767.                                 elif iVictory == gc.getInfoTypeForString('VICTORY_DOMINATION'):
  4768.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_DOMINATION", 1)
  4769.                                 elif iVictory == gc.getInfoTypeForString('VICTORY_RELIGIOUS'):
  4770.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_RELIGIOUS", 1)
  4771.                                 elif iVictory == gc.getInfoTypeForString('VICTORY_SCORE'):
  4772.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_SCORE", 1)
  4773.                                 elif iVictory == gc.getInfoTypeForString('VICTORY_TIME'):
  4774.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_TIME", 1)
  4775.                                 elif iVictory == gc.getInfoTypeForString('VICTORY_TOWER_OF_MASTERY'):
  4776.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_TOWER_OF_MASTERY", 1)
  4777.  
  4778.                                 if gc.getGame().isOption(GameOptionTypes.GAMEOPTION_BARBARIAN_WORLD):
  4779.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_BARBARIAN_WORLD", 1)
  4780.                                 if gc.getGame().isOption(GameOptionTypes.GAMEOPTION_CHALLENGE_CUT_LOSERS):
  4781.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_FINAL_FIVE", 1)
  4782.                                 if gc.getGame().isOption(GameOptionTypes.GAMEOPTION_CHALLENGE_HIGH_TO_LOW):
  4783.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_HIGH_TO_LOW", 1)
  4784.                                 if gc.getGame().isOption(GameOptionTypes.GAMEOPTION_CHALLENGE_INCREASING_DIFFICULTY):
  4785.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_INCREASING_DIFFICULTY", 1)
  4786.  
  4787.             victoryInfo = gc.getVictoryInfo(int(iVictory))
  4788.             CvUtil.pyPrint("Victory!  Team %d achieves a %s victory"
  4789.                 %(iTeam, victoryInfo.getDescription()))
  4790.  
  4791.     def onVassalState(self, argsList):
  4792.         'Vassal State'
  4793.         iMaster, iVassal, bVassal = argsList
  4794.  
  4795.         if (bVassal):
  4796.             CvUtil.pyPrint("Team %d becomes a Vassal State of Team %d"
  4797.                 %(iVassal, iMaster))
  4798.         else:
  4799.             CvUtil.pyPrint("Team %d revolts and is no longer a Vassal State of Team %d"
  4800.                 %(iVassal, iMaster))
  4801.  
  4802.     def onGameUpdate(self, argsList):
  4803.         'sample generic event, called on each game turn slice'
  4804.         genericArgs = argsList[0][0]    # tuple of tuple of my args
  4805.         turnSlice = genericArgs[0]
  4806.  
  4807. #FfH: 10/15/2008 Added by Kael for OOS logging.
  4808.         OOSLogger.doGameUpdate()
  4809. #FfH: End add
  4810.  
  4811.     def onMouseEvent(self, argsList):
  4812.         'mouse handler - returns 1 if the event was consumed'
  4813.         eventType,mx,my,px,py,interfaceConsumed,screens = argsList
  4814.         if ( px!=-1 and py!=-1 ):
  4815.             if ( eventType == self.EventLButtonDown ):
  4816.                 if (self.bAllowCheats and self.bCtrl and self.bAlt and CyMap().plot(px,py).isCity() and not interfaceConsumed):
  4817.                     # Launch Edit City Event
  4818.                     CvEventManager.beginEvent(self, CvUtil.EventEditCity, (px,py) )
  4819.                     return 1
  4820.  
  4821.                 elif (self.bAllowCheats and self.bCtrl and self.bShift and not interfaceConsumed):
  4822.                     # Launch Place Object Event
  4823.                     CvEventManager.beginEvent(self, CvUtil.EventPlaceObject, (px, py) )
  4824.                     return 1
  4825.  
  4826.         if ( eventType == self.EventBack ):
  4827.             return CvScreensInterface.handleBack(screens)
  4828.         elif ( eventType == self.EventForward ):
  4829.             return CvScreensInterface.handleForward(screens)
  4830.  
  4831.         return 0
  4832.  
  4833.  
  4834. #################### TRIGGERED EVENTS ##################
  4835.  
  4836.     def __eventPlaceObjectBegin(self, argsList):
  4837.         'Place Object Event'
  4838.         CvDebugTools.CvDebugTools().initUnitPicker(argsList)
  4839.  
  4840.     def __eventPlaceObjectApply(self, playerID, userData, popupReturn):
  4841.         'Place Object Event Apply'
  4842.         if (getChtLvl() > 0):
  4843.             CvDebugTools.CvDebugTools().applyUnitPicker( (popupReturn, userData) )
  4844.  
  4845.     def __eventAwardTechsAndGoldBegin(self, argsList):
  4846.         'Award Techs & Gold Event'
  4847.         CvDebugTools.CvDebugTools().cheatTechs()
  4848.  
  4849.     def __eventAwardTechsAndGoldApply(self, playerID, netUserData, popupReturn):
  4850.         'Award Techs & Gold Event Apply'
  4851.         if (getChtLvl() > 0):
  4852.             CvDebugTools.CvDebugTools().applyTechCheat( (popupReturn) )
  4853.  
  4854.     def __eventShowWonderBegin(self, argsList):
  4855.         'Show Wonder Event'
  4856.         CvDebugTools.CvDebugTools().wonderMovie()
  4857.  
  4858.     def __eventShowWonderApply(self, playerID, netUserData, popupReturn):
  4859.         'Wonder Movie Apply'
  4860.         if (getChtLvl() > 0):
  4861.             CvDebugTools.CvDebugTools().applyWonderMovie( (popupReturn) )
  4862.  
  4863. ## Platy Builder ##
  4864.  
  4865.     def __eventEditUnitNameBegin(self, argsList):
  4866.         pUnit = argsList
  4867.         popup = PyPopup.PyPopup(CvUtil.EventEditUnitName, EventContextTypes.EVENTCONTEXT_ALL)
  4868.         popup.setUserData((pUnit.getID(), CyGame().getActivePlayer()))
  4869.         popup.setBodyString(localText.getText("TXT_KEY_RENAME_UNIT", ()))
  4870.         popup.createEditBox(pUnit.getNameNoDesc())
  4871.         popup.setEditBoxMaxCharCount(25)
  4872.         popup.launch()
  4873.  
  4874.     def __eventEditUnitNameApply(self, playerID, userData, popupReturn):
  4875.         unit = gc.getPlayer(userData[1]).getUnit(userData[0])
  4876.         newName = popupReturn.getEditBoxString(0)
  4877.         unit.setName(newName)
  4878.         if CyGame().GetWorldBuilderMode():
  4879.             WBUnitScreen.WBUnitScreen(CvPlatyBuilderScreen.CvWorldBuilderScreen()).placeStats()
  4880.             WBUnitScreen.WBUnitScreen(CvPlatyBuilderScreen.CvWorldBuilderScreen()).placeCurrentUnit()
  4881.  
  4882.     def __eventEditCityNameBegin(self, city, bRename):
  4883.         popup = PyPopup.PyPopup(CvUtil.EventEditCityName, EventContextTypes.EVENTCONTEXT_ALL)
  4884.         popup.setUserData((city.getID(), bRename, CyGame().getActivePlayer()))
  4885.         popup.setHeaderString(localText.getText("TXT_KEY_NAME_CITY", ()))
  4886.         popup.setBodyString(localText.getText("TXT_KEY_SETTLE_NEW_CITY_NAME", ()))
  4887.         popup.createEditBox(city.getName())
  4888.         popup.setEditBoxMaxCharCount(15)
  4889.         popup.launch()
  4890.  
  4891.     def __eventEditCityNameApply(self, playerID, userData, popupReturn):
  4892.         city = gc.getPlayer(userData[2]).getCity(userData[0])
  4893.         cityName = popupReturn.getEditBoxString(0)
  4894.         city.setName(cityName, not userData[1])
  4895.         if CyGame().GetWorldBuilderMode() and not CyGame().isInAdvancedStart():
  4896.             WBCityEditScreen.WBCityEditScreen().placeStats()
  4897. ## Platy Builder ##
  4898.  
  4899. #Magister Start
  4900.     def __eventEditPlayerNameBegin(self, argsList):
  4901.         pUnit = argsList
  4902.         popup = PyPopup.PyPopup(6666, EventContextTypes.EVENTCONTEXT_ALL)
  4903.         popup.setUserData((pPlayer.getID(),))
  4904.         popup.setBodyString(localText.getText("TXT_KEY_MENU_LEADER_NAME", ()))
  4905.         popup.createEditBox(pPlayer.getName())
  4906.         popup.launch()
  4907.  
  4908.     def __eventEditPlayerNameApply(self, playerID, userData, popupReturn):
  4909.         'Edit Player Name Event'
  4910.         newName = popupReturn.getEditBoxString(0)
  4911.         if (len(newName) > 25):
  4912.             newName = newName[:25]
  4913.         gc.getPlayer(playerID).setName(newName)
  4914.         if CyGame().GetWorldBuilderMode():
  4915.             WBPlayerScreen.WBPlayerScreen().placeStats()
  4916.  
  4917.     def __eventEditCivNameBegin(self, argsList):
  4918.         pUnit = argsList
  4919.         popup = PyPopup.PyPopup(6777, EventContextTypes.EVENTCONTEXT_ALL)
  4920.         popup.setUserData((pPlayer.getID(),))
  4921.         popup.setBodyString(localText.getText("TXT_KEY_RENAME_PLAYER", ()))
  4922.         popup.setBodyString(CyTranslator().getText("TXT_KEY_MENU_CIV_DESC", ()))
  4923.         popup.createEditBox(pPlayer.getCivilizationDescription(pPlayer.getID()))
  4924.         popup.launch()
  4925.  
  4926.     def __eventEditCivNameApply(self, playerID, userData, popupReturn):
  4927.         'Edit Player Name Event'
  4928.         pPlayer = gc.getPlayer(playerID)
  4929.         szNewDesc = pPlayer.getCivilizationDescription(playerID)
  4930.         szNewShort = pPlayer.getCivilizationShortDescription(playerID)
  4931.         szNewAdj = pPlayer.getCivilizationAdjective(playerID)
  4932.         sNew = popupReturn.getEditBoxString(0)
  4933.         if (len(sNew) > 25):
  4934.             sNew = sNew[:25]
  4935.         pPlayer.setCivName(sNew,szNewShort, szNewAdj)
  4936.         if CyGame().GetWorldBuilderMode():
  4937.             WBPlayerScreen.WBPlayerScreen().placeStats()
  4938.  
  4939.     def __eventEditCivShortNameBegin(self, argsList):
  4940.         pUnit = argsList
  4941.         popup = PyPopup.PyPopup(6888, EventContextTypes.EVENTCONTEXT_ALL)
  4942.         popup.setUserData((pPlayer.getID(),))
  4943.         popup.setBodyString(localText.getText("TXT_KEY_RENAME_PLAYER", ()))
  4944.         popup.setBodyString(CyTranslator().getText("TXT_KEY_MENU_CIV_SHORT_DESC", ()))
  4945.         popup.createEditBox(pPlayer.getCivilizationShortDescription(pPlayer.getID()))
  4946.         popup.launch()
  4947.  
  4948.     def __eventEditCivShortNameApply(self, playerID, userData, popupReturn):
  4949.         'Edit Player Name Event'
  4950.         pPlayer = gc.getPlayer(playerID)
  4951.         szNewDesc = pPlayer.getCivilizationDescription(playerID)
  4952.         szNewShort = pPlayer.getCivilizationShortDescription(playerID)
  4953.         szNewAdj = pPlayer.getCivilizationAdjective(playerID)
  4954.         sNew = popupReturn.getEditBoxString(0)
  4955.         if (len(sNew) > 25):
  4956.             sNew = sNew[:25]
  4957.         pPlayer.setCivName(szNewDesc,sNew, szNewAdj)
  4958.         if CyGame().GetWorldBuilderMode():
  4959.             WBPlayerScreen.WBPlayerScreen().placeStats()
  4960.  
  4961.     def __eventEditCivAdjBegin(self, argsList):
  4962.         pUnit = argsList
  4963.         popup = PyPopup.PyPopup(6999, EventContextTypes.EVENTCONTEXT_ALL)
  4964.         popup.setUserData((pPlayer.getID(),))
  4965.         popup.setBodyString(localText.getText("TXT_KEY_RENAME_PLAYER", ()))
  4966.         popup.setBodyString(CyTranslator().getText("TXT_KEY_MENU_CIV_ADJ", ()))
  4967.         popup.createEditBox(pPlayer.getCivilizationAdjective(pPlayer.getID()))
  4968.         popup.launch()
  4969.  
  4970.     def __eventEditCivAdjApply(self, playerID, userData, popupReturn):
  4971.         'Edit Player Name Event'
  4972.         pPlayer = gc.getPlayer(playerID)
  4973.         szNewDesc = pPlayer.getCivilizationDescription(playerID)
  4974.         szNewShort = pPlayer.getCivilizationShortDescription(playerID)
  4975.         szNewAdj = pPlayer.getCivilizationAdjective(playerID)
  4976.         sNew = popupReturn.getEditBoxString(0)
  4977.         if (len(sNew) > 25):
  4978.             sNew = sNew[:25]
  4979.         pPlayer.setCivName(szNewDesc,szNewShort, sNew)
  4980.         if CyGame().GetWorldBuilderMode():
  4981.             WBPlayerScreen.WBPlayerScreen().placeStats()
  4982. #Magister Stop
  4983.  
  4984.     def __eventWBPlayerScriptPopupApply(self, playerID, userData, popupReturn):
  4985.         sScript = popupReturn.getEditBoxString(0)
  4986.         gc.getPlayer(userData[0]).setScriptData(CvUtil.convertToStr(sScript))
  4987.         WBPlayerScreen.WBPlayerScreen().placeScript()
  4988.         return
  4989.  
  4990.     def __eventWBCityScriptPopupApply(self, playerID, userData, popupReturn):
  4991.         sScript = popupReturn.getEditBoxString(0)
  4992.         pCity = gc.getPlayer(userData[0]).getCity(userData[1])
  4993.         pCity.setScriptData(CvUtil.convertToStr(sScript))
  4994.         WBCityEditScreen.WBCityEditScreen().placeScript()
  4995.         return
  4996.  
  4997.     def __eventWBUnitScriptPopupApply(self, playerID, userData, popupReturn):
  4998.         sScript = popupReturn.getEditBoxString(0)
  4999.         pUnit = gc.getPlayer(userData[0]).getUnit(userData[1])
  5000.         pUnit.setScriptData(CvUtil.convertToStr(sScript))
  5001.         WBUnitScreen.WBUnitScreen(CvPlatyBuilderScreen.CvWorldBuilderScreen()).placeScript()
  5002.         return
  5003.  
  5004.     def __eventWBScriptPopupBegin(self):
  5005.         return
  5006.  
  5007.     def __eventWBGameScriptPopupApply(self, playerID, userData, popupReturn):
  5008.         sScript = popupReturn.getEditBoxString(0)
  5009.         CyGame().setScriptData(CvUtil.convertToStr(sScript))
  5010.         WBGameDataScreen.WBGameDataScreen(CvPlatyBuilderScreen.CvWorldBuilderScreen()).placeScript()
  5011.         return
  5012.  
  5013.     def __eventWBPlotScriptPopupApply(self, playerID, userData, popupReturn):
  5014.         sScript = popupReturn.getEditBoxString(0)
  5015.         pPlot = CyMap().plot(userData[0], userData[1])
  5016.         pPlot.setScriptData(CvUtil.convertToStr(sScript))
  5017.         WBPlotScreen.WBPlotScreen().placeScript()
  5018.         return
  5019.  
  5020.     def __eventWBLandmarkPopupApply(self, playerID, userData, popupReturn):
  5021.         sScript = popupReturn.getEditBoxString(0)
  5022.         pPlot = CyMap().plot(userData[0], userData[1])
  5023.         iPlayer = userData[2]
  5024.         if userData[3] > -1:
  5025.             pSign = CyEngine().getSignByIndex(userData[3])
  5026.             iPlayer = pSign.getPlayerType()
  5027.             CyEngine().removeSign(pPlot, iPlayer)
  5028.         if len(sScript):
  5029.             if iPlayer == gc.getBARBARIAN_PLAYER():
  5030.                 CyEngine().addLandmark(pPlot, CvUtil.convertToStr(sScript))
  5031.             else:
  5032.                 CyEngine().addSign(pPlot, iPlayer, CvUtil.convertToStr(sScript))
  5033.         WBPlotScreen.iCounter = 10
  5034.         return
  5035. ## Platy Builder ##
  5036.  
  5037. ## FfH Card Game: begin
  5038.     def __EventSelectSolmniumPlayerBegin(self):
  5039.         iHUPlayer = gc.getGame().getActivePlayer()
  5040.  
  5041.         if iHUPlayer == -1 : return 0
  5042.         if not cs.canStartGame(iHUPlayer) : return 0
  5043.  
  5044.         popup = PyPopup.PyPopup(CvUtil.EventSelectSolmniumPlayer, EventContextTypes.EVENTCONTEXT_ALL)
  5045.  
  5046.         sResText = CyUserProfile().getResolutionString(CyUserProfile().getResolution())
  5047.         sX, sY = sResText.split("x")
  5048.         iXRes = int(sX)
  5049.         iYRes = int(sY)
  5050.  
  5051.         iW = 620
  5052.         iH = 650
  5053.  
  5054.         popup.setSize(iW, iH)
  5055.         popup.setPosition((iXRes - iW) / 2, 30)
  5056.  
  5057.         lStates = []
  5058.  
  5059.         for iPlayer in range(gc.getMAX_CIV_PLAYERS()) :
  5060.             pPlayer = gc.getPlayer(iPlayer)
  5061.  
  5062.             if pPlayer.isNone() : continue
  5063.  
  5064.             if pPlayer.isHuman() :
  5065.                 lPlayerState = cs.getStartGameMPWith(iHUPlayer, iPlayer)
  5066.                 if lPlayerState[0][0] in ["No", "notMet"] : continue
  5067.                 lStates.append([iPlayer, lPlayerState])
  5068.             else :
  5069.                 lPlayerState = cs.getStartGameAIWith(iHUPlayer, iPlayer)
  5070.                 if lPlayerState[0][0] in ["No", "notMet"] : continue
  5071.                 lStates.append([iPlayer, lPlayerState])
  5072.  
  5073.         lPlayerButtons = []
  5074.  
  5075.         popup.addDDS(CyArtFileMgr().getInterfaceArtInfo("SOMNIUM_POPUP_INTRO").getPath(), 0, 0, 512, 128)
  5076.         popup.addSeparator()
  5077.         #popup.setHeaderString(localText.getText("TXT_KEY_SOMNIUM_START", ()), CvUtil.FONT_CENTER_JUSTIFY)
  5078.         if len(lStates) == 0 :
  5079.             popup.setBodyString(localText.getText("TXT_KEY_SOMNIUM_NOONE_MET", ()))
  5080.         else :
  5081.             #popup.setBodyString(localText.getText("TXT_KEY_SOMNIUM_PLAY_WITH", ()))
  5082.             popup.addSeparator()
  5083.             popup.addSeparator()
  5084.  
  5085.             sText = u""
  5086.             for iPlayer, lPlayerState in lStates :
  5087.                 pPlayer = gc.getPlayer(iPlayer)
  5088.                 sPlayerName = pPlayer.getName()
  5089.                 iPositiveChange = gc.getLeaderHeadInfo(pPlayer.getLeaderType()).getMemoryAttitudePercent(MemoryTypes.MEMORY_SOMNIUM_POSITIVE) / 100
  5090.                 iNegativeChange = gc.getLeaderHeadInfo(pPlayer.getLeaderType()).getMemoryAttitudePercent(MemoryTypes.MEMORY_SOMNIUM_NEGATIVE) / 100
  5091.                 bShift = True
  5092.  
  5093.                 for item in lPlayerState :
  5094.  
  5095.                     sTag = item[0]
  5096.                     if (sTag == "atWar") :
  5097.                         if len(sText) > 0 : sText += localText.getText("[NEWLINE]", ())
  5098.                         sText += localText.getText("TXT_KEY_SOMNIUM_AT_WAR", (sPlayerName, ))
  5099.  
  5100.                     elif (sTag == "InGame") :
  5101.                         if len(sText) > 0 : sText += localText.getText("[NEWLINE]", ())
  5102.                         sText += localText.getText("TXT_KEY_SOMNIUM_IN_GAME", (sPlayerName, ))
  5103.  
  5104.                     elif (sTag == "relation") :
  5105.                         delay = item[1]
  5106.                         if (delay > 0) :
  5107.                             if len(sText) > 0 : sText += localText.getText("[NEWLINE]", ())
  5108.                             sText += localText.getText("TXT_KEY_SOMNIUM_GAME_DELAYED", (sPlayerName, delay))
  5109.                         else :
  5110.                             if bShift :
  5111.                                 bShift = False
  5112.                                 popup.addSeparator()
  5113.                             popup.addButton(localText.getText("TXT_KEY_SOMNIUM_GAME_RELATION", (sPlayerName, iPositiveChange, iNegativeChange)))
  5114.                             lPlayerButtons.append((iPlayer, -1))
  5115.  
  5116.                     elif (sTag == "gold") :
  5117.                         for iGold in item[1] :
  5118.                             if bShift :
  5119.                                 bShift = False
  5120.                                 popup.addSeparator()
  5121.                             if iGold == 0 :
  5122.                                 popup.addButton(localText.getText("TXT_KEY_SOMNIUM_GAME_FUN", (sPlayerName, )))
  5123.                                 lPlayerButtons.append((iPlayer, iGold))
  5124.                             else :
  5125.                                 popup.addButton(localText.getText("TXT_KEY_SOMNIUM_GAME_GOLD", (sPlayerName, iGold)))
  5126.                                 lPlayerButtons.append((iPlayer, iGold))
  5127.  
  5128.             if len(sText) > 0 :
  5129.                 popup.addSeparator()
  5130.                 popup.addSeparator()
  5131.                 popup.setBodyString(sText)
  5132.  
  5133.         popup.setUserData(tuple(lPlayerButtons))
  5134.         popup.launch()
  5135.  
  5136.     def __EventSelectSolmniumPlayerApply(self, playerID, userData, popupReturn):
  5137.         if userData :
  5138.             idButtonCliked = popupReturn.getButtonClicked()
  5139.             if idButtonCliked in range(len(userData)) :
  5140.                 iOpponent, iGold = userData[idButtonCliked]
  5141.  
  5142.                 pLeftPlayer = gc.getPlayer(playerID)
  5143.                 pRightPlayer = gc.getPlayer(iOpponent)
  5144.  
  5145.                 if not pRightPlayer.isHuman() :
  5146.                     if (cs.canStartGame(playerID)) and (pLeftPlayer.isAlive()) and (pRightPlayer.isAlive()) :
  5147.                         cs.startGame(playerID, iOpponent, iGold)
  5148.                     else :
  5149.                         CyInterface().addMessage(playerID, True, 25, CyTranslator().getText("TXT_KEY_SOMNIUM_CANT_START_GAME", (gc.getPlayer(iOpponent).getName(), )), '', 1, '', ColorTypes(7), -1, -1, False, False)
  5150.                 else :
  5151.                     if (cs.canStartGame(playerID)) and (cs.canStartGame(iOpponent)) and (pLeftPlayer.isAlive()) and (pRightPlayer.isAlive()) :
  5152.                         if (iOpponent == gc.getGame().getActivePlayer()):
  5153.                             self.__EventSolmniumAcceptGameBegin((playerID, iOpponent, iGold))
  5154.                     else :
  5155.                         CyInterface().addMessage(playerID, True, 25, CyTranslator().getText("TXT_KEY_SOMNIUM_CANT_START_GAME", (gc.getPlayer(iOpponent).getName(), )), '', 1, '', ColorTypes(7), -1, -1, False, False)
  5156.  
  5157.     def __EventSolmniumAcceptGameBegin(self, argslist):
  5158.         iPlayer, iOpponent, iGold = argslist
  5159.         if not gc.getPlayer(iOpponent).isAlive() : return 0
  5160.  
  5161.         popup = PyPopup.PyPopup(CvUtil.EventSolmniumAcceptGame, EventContextTypes.EVENTCONTEXT_ALL)
  5162.  
  5163.         popup.setUserData(argslist)
  5164.  
  5165.         popup.setHeaderString(localText.getText("TXT_KEY_SOMNIUM_START", ()))
  5166.         if iGold > 0 :
  5167.             popup.setBodyString(localText.getText("TXT_KEY_SOMNIUM_ACCEPT_GAME", (gc.getPlayer(iPlayer).getName(), iGold)))
  5168.         else :
  5169.             popup.setBodyString(localText.getText("TXT_KEY_SOMNIUM_ACCEPT_GAME_FUN", (gc.getPlayer(iPlayer).getName(), )))
  5170.  
  5171.         popup.addButton( localText.getText("AI_DIPLO_ACCEPT_1", ()) )
  5172.         popup.addButton( localText.getText("AI_DIPLO_NO_PEACE_3", ()) )
  5173.  
  5174.         popup.launch(False, PopupStates.POPUPSTATE_IMMEDIATE)
  5175.  
  5176.     def __EventSolmniumAcceptGameApply(self, playerID, userData, popupReturn):
  5177.         if userData :
  5178.             iPlayer, iOpponent, iGold = userData
  5179.             idButtonCliked = popupReturn.getButtonClicked()
  5180.             if idButtonCliked == 0 :
  5181.                 if (cs.canStartGame(iPlayer)) and (cs.canStartGame(iOpponent)) and (gc.getPlayer(iPlayer).isAlive()) and (gc.getPlayer(iOpponent).isAlive()) :
  5182.                     cs.startGame(iPlayer, iOpponent, iGold)
  5183.                 else :
  5184.                     CyInterface().addMessage(iPlayer, True, 25, CyTranslator().getText("TXT_KEY_SOMNIUM_CANT_START_GAME", (gc.getPlayer(iOpponent).getName(), )), '', 1, '', ColorTypes(7), -1, -1, False, False)
  5185.                     CyInterface().addMessage(iOpponent, True, 25, CyTranslator().getText("TXT_KEY_SOMNIUM_CANT_START_GAME", (gc.getPlayer(iPlayer).getName(), )), '', 1, '', ColorTypes(7), -1, -1, False, False)
  5186.             else :
  5187.                     CyInterface().addMessage(iPlayer, True, 25, CyTranslator().getText("TXT_KEY_SOMNIUM_REFUSE_GAME", (gc.getPlayer(iOpponent).getName(), iGold)), '', 1, '', ColorTypes(7), -1, -1, False, False)
  5188.  
  5189.     def __EventSolmniumConcedeGameBegin(self, argslist):
  5190.         popup = PyPopup.PyPopup(CvUtil.EventSolmniumConcedeGame, EventContextTypes.EVENTCONTEXT_ALL)
  5191.  
  5192.         popup.setUserData(argslist)
  5193.  
  5194.         popup.setHeaderString(localText.getText("TXT_KEY_SOMNIUM_START", ()))
  5195.         popup.setBodyString(localText.getText("TXT_KEY_SOMNIUM_CONCEDE_GAME", ()))
  5196.  
  5197.         popup.addButton( localText.getText("AI_DIPLO_ACCEPT_1", ()) )
  5198.         popup.addButton( localText.getText("AI_DIPLO_NO_PEACE_3", ()) )
  5199.  
  5200.         popup.launch(False, PopupStates.POPUPSTATE_IMMEDIATE)
  5201.  
  5202.     def __EventSolmniumConcedeGameApply(self, playerID, userData, popupReturn):
  5203.         if userData :
  5204.             idButtonCliked = popupReturn.getButtonClicked()
  5205.             if idButtonCliked == 0 :
  5206.                 cs.endGame(userData[0], userData[1])
  5207. ## FfH Card Game: end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement