Advertisement
Guest User

Untitled

a guest
Dec 18th, 2014
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 205.13 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 AC to around 5
  610.         CyGame().changeGlobalCounter(15)
  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.     def onGameEnd(self, argsList):
  759.         'Called at the End of the game'
  760.         print("Game is ending")
  761.         return
  762.  
  763.     def onBeginGameTurn(self, argsList):
  764.         'Called at the beginning of the end of each turn'
  765.         iGameTurn = argsList[0]
  766.  
  767.         if not CyGame().isUnitClassMaxedOut(gc.getInfoTypeForString('UNITCLASS_ORTHUS'), 0):
  768.             if not CyGame().isOption(gc.getInfoTypeForString('GAMEOPTION_NO_ORTHUS')):
  769.                 iOrthusTurn = 75
  770.                 bOrthus = False
  771.                 if CyGame().getGameSpeedType() == gc.getInfoTypeForString('GAMESPEED_QUICK'):
  772.                     if iGameTurn >= iOrthusTurn / 3 * 2:
  773.                         bOrthus = True
  774.                 elif CyGame().getGameSpeedType() == gc.getInfoTypeForString('GAMESPEED_NORMAL'):
  775.                     if iGameTurn >= iOrthusTurn:
  776.                         bOrthus = True
  777.                 elif CyGame().getGameSpeedType() == gc.getInfoTypeForString('GAMESPEED_EPIC'):
  778.                     if iGameTurn >= iOrthusTurn * 3 / 2:
  779.                         bOrthus = True
  780.                 elif CyGame().getGameSpeedType() == gc.getInfoTypeForString('GAMESPEED_MARATHON'):
  781.                     if iGameTurn >= iOrthusTurn * 3:
  782.                         bOrthus = True
  783.                 if bOrthus:
  784.                     bValid=True
  785.                     for i in range (CyMap().numPlots()):
  786.                         pPlot = CyMap().plotByIndex(i)
  787.                         iPlot = -1
  788.                         if pPlot.getImprovementType()==gc.getInfoTypeForString('IMPROVEMENT_GOBLIN_FORT'):
  789.                             bPlayer = gc.getPlayer(gc.getBARBARIAN_PLAYER())
  790.                             if not pPlot.isVisibleOtherUnit(gc.getBARBARIAN_PLAYER()):
  791.                                 bPlayer.initUnit(gc.getInfoTypeForString('UNIT_ORTHUS'), pPlot.getX(), pPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
  792.                                 bValid=False
  793.                                 break
  794.                     if bValid:
  795.                         iUnit = gc.getInfoTypeForString('UNIT_ORTHUS')
  796.                         cf.addUnit(iUnit)
  797.                         if( CyGame().getAIAutoPlay(CyGame().getActivePlayer()) == 0 ) :
  798.                             cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_ORTHUS_CREATION",()), str(gc.getUnitInfo(iUnit).getImage()))
  799.  
  800.         if not CyGame().isOption(gc.getInfoTypeForString('GAMEOPTION_NO_PLOT_COUNTER')):
  801.             cf.doHellTerrain()
  802.  
  803.         if CyGame().getWBMapScript():
  804.             sf.doTurn()
  805.  
  806. # FfH Card Game: begin
  807.         cs.doTurn()
  808. # FfH Card Game: end
  809.  
  810.         Blizzards.doBlizzardTurn()      #Added in Blizzards: TC01
  811.        
  812. #       if( CyGame().getAIAutoPlay(self) == 0 ) :
  813.         if( game.getAIAutoPlay(game.getActivePlayer()) == 0 ) :
  814.             CvTopCivs.CvTopCivs().turnChecker(iGameTurn)
  815.            
  816.            
  817.         #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.
  818.         iElohimPlayer = 0
  819.         pElohimPlayer = gc.getPlayer(iElohimPlayer)
  820.         if CyGame().getGlobalCounter() <= 0:
  821.             gc.getGame().setWinner(pElohimPlayer.getTeam(), 2)
  822.            
  823.         #Debug to test if the victory condition is working
  824.         #CyGame().changeGlobalCounter(-2)
  825.        
  826.        
  827.         #I need to redo the teamID's because they are forgotten from onGameStart
  828.         for iGoodAndEvilPlayer in range(gc.getMAX_PLAYERS()):
  829.             pGoodAndEvilPlayer = gc.getPlayer(iGoodAndEvilPlayer)
  830.             #if pGoodAndEvilPlayer.isAlive(): #This line breaks the code
  831.             if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_BANNOR'):
  832.                 iBannorTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  833.                 iBannorPower = gc.getTeam(iBannorTeamID).getPower(True)
  834.             if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_CALABIM'):
  835.                 iCalabimTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  836.             if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_CLAN_OF_EMBERS'):
  837.                 iClanOfEmbersTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  838.             if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_DOVIELLO'):
  839.                 iDovielloTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  840.             if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_ELOHIM'):
  841.                 iElohimTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  842.                 iElohimPower = gc.getTeam(iElohimTeamID).getPower(True)
  843.             if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_KURIOTATES'):
  844.                 iKuriotatesTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  845.                 iKuriotatesPower = gc.getTeam(iKuriotatesTeamID).getPower(True)
  846.             if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LJOSALFAR'):
  847.                 iLjosalfarTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  848.                 iLjosalfarPower = gc.getTeam(iLjosalfarTeamID).getPower(True)
  849.             if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LUCHUIRP'):
  850.                 iLuchuirpTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  851.                 iLuchuirpPower = gc.getTeam(iLuchuirpTeamID).getPower(True)
  852.             if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_SHEAIM'):
  853.                 iSheaimTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  854.             if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_SVARTALFAR'):
  855.                 iSvartalfarTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  856.  
  857.        
  858.         #If the civ isn't alive then the score won't be defined and therefore will cause an error when used
  859.         if not gc.getTeam(iLuchuirpTeamID).isAlive:
  860.             iLuchuirpPower = 0
  861.         if not gc.getTeam(iBannorTeamID).isAlive:
  862.             iBannorPower = 0
  863.         if not gc.getTeam(iElohimTeamID).isAlive:
  864.             iElohimPower = 0
  865.         if not gc.getTeam(iKuriotatesTeamID).isAlive:
  866.             iKuriotatesPower = 0
  867.         if not gc.getTeam(iLjosalfarTeamID).isAlive:
  868.             iLjosalfarPower = 0
  869.            
  870.        
  871.         #Make the Luchuirp declare war on the other good civs if the Luchuirp power > (Elohim + Ljosalfar + Kuriotates + Bannor) power
  872.         #Elohim will always be alive while the game is running since that is the player
  873.         #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.
  874.         #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
  875.         if gc.getTeam(iLuchuirpTeamID).isAlive:
  876.             if not gc.getTeam(iLuchuirpTeamID).isAtWar(iElohimTeamID):
  877.                 if iLuchuirpPower > (iBannorPower + iElohimPower + iKuriotatesPower + iLjosalfarPower):
  878.                     sf.addPopupWB(CyTranslator().getText("TXT_KEY_WB_ELOHIM_SCENARIO_LUCHUIRP_WAR_GOOD",()),'')
  879.                     for iWarAndPeaceTeam in range(gc.getMAX_CIV_TEAMS()):
  880.                         pWarAndPeaceTeam = gc.getTeam(iWarAndPeaceTeam)
  881.                         if pWarAndPeaceTeam.isAlive():
  882.                             if iWarAndPeaceTeam == iLuchuirpTeamID:
  883.                                 pWarAndPeaceTeam.setPermanentWarPeace(iBannorTeamID, False)
  884.                                 pWarAndPeaceTeam.declareWar(iBannorTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
  885.                                 pWarAndPeaceTeam.setPermanentWarPeace(iBannorTeamID, True)
  886.                                 pWarAndPeaceTeam.setPermanentWarPeace(iElohimTeamID, False)
  887.                                 pWarAndPeaceTeam.declareWar(iElohimTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
  888.                                 pWarAndPeaceTeam.setPermanentWarPeace(iElohimTeamID, True)
  889.                                 pWarAndPeaceTeam.setPermanentWarPeace(iKuriotatesTeamID, False)
  890.                                 pWarAndPeaceTeam.declareWar(iKuriotatesTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
  891.                                 pWarAndPeaceTeam.setPermanentWarPeace(iKuriotatesTeamID, True)
  892.                                 pWarAndPeaceTeam.setPermanentWarPeace(iLjosalfarTeamID, False)
  893.                                 pWarAndPeaceTeam.declareWar(iLjosalfarTeamID, False, WarPlanTypes.WARPLAN_TOTAL)
  894.                                 pWarAndPeaceTeam.setPermanentWarPeace(iLjosalfarTeamID, True)
  895.                
  896.        
  897.         #If it is earlier than turn 35 then move SoD units into the marshalling tile#
  898.         #SoD promotion is given to units built within a certain time period in onUnitBuilt
  899.        
  900.         #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!#
  901.         if iGameTurn < 35:
  902.             for iGoodSofDPlayer in range(gc.getMAX_PLAYERS()):
  903.                 pGoodSofDPlayer = gc.getPlayer(iGoodSofDPlayer)
  904.                 if (pGoodSofDPlayer.isAlive()):
  905.                     if pGoodSofDPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_BANNOR'):
  906.                         pySofD = PyPlayer(iGoodSofDPlayer)
  907.                         if pGoodSofDPlayer.getNumUnits() > 0:
  908.                             for pMayMoveUnit in pySofD.getUnitList():
  909.                                 if pMayMoveUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_SofD')):
  910.                                     #This code works but needs to avoid enemy units, cities
  911.                                     if pMayMoveUnit.getY() < 28:
  912.                                         pMayMoveUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), True)
  913.                                         pMayMoveUnit.setXY(pMayMoveUnit.getX(), pMayMoveUnit.getY() + 1, False, True, True)
  914.                                     if pMayMoveUnit.getY() > 28:
  915.                                         pMayMoveUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), True)
  916.                                         pMayMoveUnit.setXY(pMayMoveUnit.getX(), pMayMoveUnit.getY() - 1, False, True, True)
  917.                                     if pMayMoveUnit.getX() < 67:
  918.                                         pMayMoveUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), True)
  919.                                         pMayMoveUnit.setXY(pMayMoveUnit.getX() + 1, pMayMoveUnit.getY(), False, True, True)
  920.                                     if pMayMoveUnit.getX() > 67:
  921.                                         pMayMoveUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), True)
  922.                                         pMayMoveUnit.setXY(pMayMoveUnit.getX() - 1, pMayMoveUnit.getY(), False, True, True)
  923.                     if pGoodSofDPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_ELOHIM'):
  924.                         pySofD = PyPlayer(iGoodSofDPlayer)
  925.                         if pGoodSofDPlayer.getNumUnits() > 0:
  926.                             for pMayMoveUnit in pySofD.getUnitList():
  927.                                 if pMayMoveUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_SofD')):
  928.                                     #This code works but needs to avoid enemy units, cities
  929.                                     if pMayMoveUnit.getY() < 28:
  930.                                         pMayMoveUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), True)
  931.                                         pMayMoveUnit.setXY(pMayMoveUnit.getX(), pMayMoveUnit.getY() + 1, False, True, True)
  932.                                     if pMayMoveUnit.getY() > 28:
  933.                                         pMayMoveUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), True)
  934.                                         pMayMoveUnit.setXY(pMayMoveUnit.getX(), pMayMoveUnit.getY() - 1, False, True, True)
  935.                                     if pMayMoveUnit.getX() < 67:
  936.                                         pMayMoveUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), True)
  937.                                         pMayMoveUnit.setXY(pMayMoveUnit.getX() + 1, pMayMoveUnit.getY(), False, True, True)
  938.                                     if pMayMoveUnit.getX() > 67:
  939.                                         pMayMoveUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), True)
  940.                                         pMayMoveUnit.setXY(pMayMoveUnit.getX() - 1, pMayMoveUnit.getY(), False, True, True)
  941.                     if pGoodSofDPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_KURIOTATES'):
  942.                         pySofD = PyPlayer(iGoodSofDPlayer)
  943.                         if pGoodSofDPlayer.getNumUnits() > 0:
  944.                             for pMayMoveUnit in pySofD.getUnitList():
  945.                                 if pMayMoveUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_SofD')):
  946.                                     #This code works but needs to avoid enemy units, cities
  947.                                     if pMayMoveUnit.getY() < 28:
  948.                                         pMayMoveUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), True)
  949.                                         pMayMoveUnit.setXY(pMayMoveUnit.getX(), pMayMoveUnit.getY() + 1, False, True, True)
  950.                                     if pMayMoveUnit.getY() > 28:
  951.                                         pMayMoveUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), True)
  952.                                         pMayMoveUnit.setXY(pMayMoveUnit.getX(), pMayMoveUnit.getY() - 1, False, True, True)
  953.                                     if pMayMoveUnit.getX() < 67:
  954.                                         pMayMoveUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), True)
  955.                                         pMayMoveUnit.setXY(pMayMoveUnit.getX() + 1, pMayMoveUnit.getY(), False, True, True)
  956.                                     if pMayMoveUnit.getX() > 67:
  957.                                         pMayMoveUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), True)
  958.                                         pMayMoveUnit.setXY(pMayMoveUnit.getX() - 1, pMayMoveUnit.getY(), False, True, True)
  959.                     if pGoodSofDPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LJOSALFAR'):
  960.                         pySofD = PyPlayer(iGoodSofDPlayer)
  961.                         if pGoodSofDPlayer.getNumUnits() > 0:
  962.                             for pMayMoveUnit in pySofD.getUnitList():
  963.                                 if pMayMoveUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_SofD')):
  964.                                     #This code works but needs to avoid enemy units, cities
  965.                                     if pMayMoveUnit.getY() < 28:
  966.                                         pMayMoveUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), True)
  967.                                         pMayMoveUnit.setXY(pMayMoveUnit.getX(), pMayMoveUnit.getY() + 1, False, True, True)
  968.                                     if pMayMoveUnit.getY() > 28:
  969.                                         pMayMoveUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), True)
  970.                                         pMayMoveUnit.setXY(pMayMoveUnit.getX(), pMayMoveUnit.getY() - 1, False, True, True)
  971.                                     if pMayMoveUnit.getX() < 67:
  972.                                         pMayMoveUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), True)
  973.                                         pMayMoveUnit.setXY(pMayMoveUnit.getX() + 1, pMayMoveUnit.getY(), False, True, True)
  974.                                     if pMayMoveUnit.getX() > 67:
  975.                                         pMayMoveUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), True)
  976.                                         pMayMoveUnit.setXY(pMayMoveUnit.getX() - 1, pMayMoveUnit.getY(), False, True, True)
  977.                     if pGoodSofDPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LUCHUIRP'):
  978.                         pySofD = PyPlayer(iGoodSofDPlayer)
  979.                         if pGoodSofDPlayer.getNumUnits() > 0:
  980.                             for pMayMoveUnit in pySofD.getUnitList():
  981.                                 if pMayMoveUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_SofD')):
  982.                                     #This code works but needs to avoid enemy units, cities
  983.                                     if pMayMoveUnit.getY() < 28:
  984.                                         pMayMoveUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), True)
  985.                                         pMayMoveUnit.setXY(pMayMoveUnit.getX(), pMayMoveUnit.getY() + 1, False, True, True)
  986.                                     if pMayMoveUnit.getY() > 28:
  987.                                         pMayMoveUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), True)
  988.                                         pMayMoveUnit.setXY(pMayMoveUnit.getX(), pMayMoveUnit.getY() - 1, False, True, True)
  989.                                     if pMayMoveUnit.getX() < 67:
  990.                                         pMayMoveUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), True)
  991.                                         pMayMoveUnit.setXY(pMayMoveUnit.getX() + 1, pMayMoveUnit.getY(), False, True, True)
  992.                                     if pMayMoveUnit.getX() > 67:
  993.                                         pMayMoveUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), True)
  994.                                         pMayMoveUnit.setXY(pMayMoveUnit.getX() - 1, pMayMoveUnit.getY(), False, True, True)
  995.                    
  996.            
  997.         #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.
  998.         #The AI is given the HELD promotion in def onBeginPlayerTurn otherwise they move off the tile before being given the promotion
  999.         #This code should give all units in tile(iOldX,iOldY) the HELD promotion so that they can't move anywhere.
  1000.         #iTargetX and iTargetY give the coordinates of the tile that the unit stack is moving into
  1001.         #If it is after turn 30 then move units from the marshalling tile towards the target tile
  1002.         iTargetX = 60
  1003.         iTargetY = 18
  1004.         pTargetPlot = CyMap().plot(iTargetX,iTargetY)
  1005.        
  1006.         #onBeginPlayerTurn is giving units in the marshalling point the HELD promotion which may be unnecessary??
  1007.         if iGameTurn < 35:
  1008.             iOldX = 67
  1009.             iOldY = 28
  1010.             pOldPlot = CyMap().plot(iOldX,iOldY)
  1011.             for i in range(pOldPlot.getNumUnits()):
  1012.                 pUnit = pOldPlot.getUnit(i)
  1013.                 pUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), True)
  1014.             #Remember the x and y values between turns 9 and 10
  1015.             myPickle = [iOldX, iOldY]
  1016.             serializedMyPickle = pickle.dumps(myPickle)
  1017.             BugData.getTable("MY_TABLE").setData(serializedMyPickle)
  1018.  
  1019.         #If I put an Elohim scout SW of the marshalling tile then the SoD doesn't move!  Make sure in the final version that the target is roughly W of the marshalling point
  1020.         #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)
  1021.         if iGameTurn >= 35 and iGameTurn <= 50:
  1022.             #Load x and y values
  1023.             serializedMyPickle = BugData.getTable("MY_TABLE").data
  1024.             myPickle = pickle.loads(serializedMyPickle)
  1025.             iOldX = myPickle[0]
  1026.             iOldY = myPickle[1]
  1027.             pOldPlot = CyMap().plot(iOldX, iOldY)
  1028.             UnitsMoved = -1
  1029.            
  1030.            
  1031.             if iOldY == iTargetY and iOldX > iTargetX:
  1032.                 #First choice is to move W if possible
  1033.                 if UnitsMoved == -1:
  1034.                     iNewX = iOldX - 1
  1035.                     iNewY = iOldY
  1036.                     pNewPlot = CyMap().plot(iNewX,iNewY)           
  1037.                     if pNewPlot.isNone() == False:
  1038.                         #Option 1 - pNewPlot is empty
  1039.                         if pNewPlot.getNumUnits() == 0:
  1040.                             if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  1041.                                 for i in range(pOldPlot.getNumUnits(), -1, -1):
  1042.                                     pUnit = pOldPlot.getUnit(i)
  1043.                                     pUnit.setXY(iNewX, iNewY, False, True, True)
  1044.                                 UnitsMoved = 1
  1045.                         #Option 2 - pNewPlot has friendly (not including Luchuirp units) units in it
  1046.                         #Won't enter the loop if no units in the tile
  1047.                         for iBlockingUnits in range(pNewPlot.getNumUnits()):
  1048.                             pPossibleGoodUnit = pNewPlot.getUnit(iBlockingUnits)
  1049.                             pPossibleGoodPlayer = gc.getPlayer(pPossibleGoodUnit.getOwner())
  1050.                             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'):
  1051.                                 if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  1052.                                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  1053.                                         pUnit = pOldPlot.getUnit(i)
  1054.                                         pUnit.setXY(iNewX, iNewY, False, True, True)
  1055.                                     UnitsMoved = 1
  1056.                
  1057.                 #Second choice is to move NW if possible
  1058.                 if UnitsMoved == -1:
  1059.                     iNewY = iNewY + 1
  1060.                     pNewPlot = CyMap().plot(iNewX,iNewY)           
  1061.                     if pNewPlot.isNone() == False:
  1062.                         #Option 1 - pNewPlot is empty
  1063.                         if pNewPlot.getNumUnits() == 0:
  1064.                             if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  1065.                                 for i in range(pOldPlot.getNumUnits(), -1, -1):
  1066.                                     pUnit = pOldPlot.getUnit(i)
  1067.                                     pUnit.setXY(iNewX, iNewY, False, True, True)
  1068.                                 UnitsMoved = 1
  1069.                         #Option 2 - pNewPlot has friendly (not including Luchuirp units) units in it
  1070.                         #Won't enter the loop if no units in the tile
  1071.                         for iBlockingUnits in range(pNewPlot.getNumUnits()):
  1072.                             pPossibleGoodUnit = pNewPlot.getUnit(iBlockingUnits)
  1073.                             pPossibleGoodPlayer = gc.getPlayer(pPossibleGoodUnit.getOwner())
  1074.                             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'):
  1075.                                 if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  1076.                                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  1077.                                         pUnit = pOldPlot.getUnit(i)
  1078.                                         pUnit.setXY(iNewX, iNewY, False, True, True)
  1079.                                     UnitsMoved = 1
  1080.                                
  1081.                 #Third choice is to move SW if possible
  1082.                 if UnitsMoved == -1:
  1083.                     iNewY = iNewY - 2
  1084.                     pNewPlot = CyMap().plot(iNewX,iNewY)           
  1085.                     if pNewPlot.isNone() == False:
  1086.                         #Option 1 - pNewPlot is empty
  1087.                         if pNewPlot.getNumUnits() == 0:
  1088.                             if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  1089.                                 for i in range(pOldPlot.getNumUnits(), -1, -1):
  1090.                                     pUnit = pOldPlot.getUnit(i)
  1091.                                     pUnit.setXY(iNewX, iNewY, False, True, True)
  1092.                                 UnitsMoved = 1
  1093.                         #Option 2 - pNewPlot has friendly (not including Luchuirp units) units in it
  1094.                         #Won't enter the loop if no units in the tile
  1095.                         for iBlockingUnits in range(pNewPlot.getNumUnits()):
  1096.                             pPossibleGoodUnit = pNewPlot.getUnit(iBlockingUnits)
  1097.                             pPossibleGoodPlayer = gc.getPlayer(pPossibleGoodUnit.getOwner())
  1098.                             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'):
  1099.                                 if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  1100.                                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  1101.                                         pUnit = pOldPlot.getUnit(i)
  1102.                                         pUnit.setXY(iNewX, iNewY, False, True, True)
  1103.                                     UnitsMoved = 1
  1104.                                
  1105.                 #Fourth choice is to stay in the same tile
  1106.                 if UnitsMoved == -1:
  1107.                     iNewY = iNewY + 1
  1108.                     iNewX = iNewX + 1
  1109.                     pNewPlot = CyMap().plot(iNewX,iNewY)
  1110.                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  1111.                         pUnit = pOldPlot.getUnit(i)
  1112.                         pUnit.setXY(iNewX, iNewY, False, True, True)
  1113.                     UnitsMoved = 1
  1114.                
  1115.                 #Remember the x and y values between turns
  1116.                 iOldX = iNewX
  1117.                 iOldY = iNewY
  1118.                 myPickle = [iOldX, iOldY]
  1119.                 serializedMyPickle = pickle.dumps(myPickle)
  1120.                 BugData.getTable("MY_TABLE").setData(serializedMyPickle)
  1121.  
  1122.            
  1123.             if iOldY > iTargetY and iOldY < iTargetY + 5 and iOldX > iTargetX:
  1124.                 #First choice is to move SW if possible
  1125.                 if UnitsMoved == -1:
  1126.                     iNewX = iOldX - 1
  1127.                     iNewY = iOldY - 1
  1128.                     pNewPlot = CyMap().plot(iNewX,iNewY)           
  1129.                     if pNewPlot.isNone() == False:
  1130.                         #Option 1 - pNewPlot is empty
  1131.                         if pNewPlot.getNumUnits() == 0:
  1132.                             if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  1133.                                 for i in range(pOldPlot.getNumUnits(), -1, -1):
  1134.                                     pUnit = pOldPlot.getUnit(i)
  1135.                                     pUnit.setXY(iNewX, iNewY, False, True, True)
  1136.                                 UnitsMoved = 1
  1137.                         #Option 2 - pNewPlot has friendly (not including Luchuirp units) units in it
  1138.                         #Won't enter the loop if no units in the tile
  1139.                         for iBlockingUnits in range(pNewPlot.getNumUnits()):
  1140.                             pPossibleGoodUnit = pNewPlot.getUnit(iBlockingUnits)
  1141.                             pPossibleGoodPlayer = gc.getPlayer(pPossibleGoodUnit.getOwner())
  1142.                             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'):
  1143.                                 if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  1144.                                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  1145.                                         pUnit = pOldPlot.getUnit(i)
  1146.                                         pUnit.setXY(iNewX, iNewY, False, True, True)
  1147.                                     UnitsMoved = 1
  1148.                
  1149.                 #Second choice is to move W if possible
  1150.                 if UnitsMoved == -1:
  1151.                     iNewY = iNewY + 1
  1152.                     pNewPlot = CyMap().plot(iNewX,iNewY)           
  1153.                     if pNewPlot.isNone() == False:
  1154.                         #Option 1 - pNewPlot is empty
  1155.                         if pNewPlot.getNumUnits() == 0:
  1156.                             if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  1157.                                 for i in range(pOldPlot.getNumUnits(), -1, -1):
  1158.                                     pUnit = pOldPlot.getUnit(i)
  1159.                                     pUnit.setXY(iNewX, iNewY, False, True, True)
  1160.                                 UnitsMoved = 1
  1161.                         #Option 2 - pNewPlot has friendly (not including Luchuirp units) units in it
  1162.                         #Won't enter the loop if no units in the tile
  1163.                         for iBlockingUnits in range(pNewPlot.getNumUnits()):
  1164.                             pPossibleGoodUnit = pNewPlot.getUnit(iBlockingUnits)
  1165.                             pPossibleGoodPlayer = gc.getPlayer(pPossibleGoodUnit.getOwner())
  1166.                             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'):
  1167.                                 if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  1168.                                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  1169.                                         pUnit = pOldPlot.getUnit(i)
  1170.                                         pUnit.setXY(iNewX, iNewY, False, True, True)
  1171.                                     UnitsMoved = 1
  1172.                                
  1173.                 #Third choice is to move NW if possible
  1174.                 if UnitsMoved == -1:
  1175.                     iNewY = iNewY + 1
  1176.                     pNewPlot = CyMap().plot(iNewX,iNewY)           
  1177.                     if pNewPlot.isNone() == False:
  1178.                         #Option 1 - pNewPlot is empty
  1179.                         if pNewPlot.getNumUnits() == 0:
  1180.                             if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  1181.                                 for i in range(pOldPlot.getNumUnits(), -1, -1):
  1182.                                     pUnit = pOldPlot.getUnit(i)
  1183.                                     pUnit.setXY(iNewX, iNewY, False, True, True)
  1184.                                 UnitsMoved = 1
  1185.                         #Option 2 - pNewPlot has friendly (not including Luchuirp units) units in it
  1186.                         #Won't enter the loop if no units in the tile
  1187.                         for iBlockingUnits in range(pNewPlot.getNumUnits()):
  1188.                             pPossibleGoodUnit = pNewPlot.getUnit(iBlockingUnits)
  1189.                             pPossibleGoodPlayer = gc.getPlayer(pPossibleGoodUnit.getOwner())
  1190.                             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'):
  1191.                                 if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  1192.                                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  1193.                                         pUnit = pOldPlot.getUnit(i)
  1194.                                         pUnit.setXY(iNewX, iNewY, False, True, True)
  1195.                                     UnitsMoved = 1
  1196.                                
  1197.                 #Fourth choice is to stay in the same tile
  1198.                 if UnitsMoved == -1:
  1199.                     iNewY = iNewY - 1
  1200.                     iNewX = iNewX + 1
  1201.                     pNewPlot = CyMap().plot(iNewX,iNewY)
  1202.                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  1203.                         pUnit = pOldPlot.getUnit(i)
  1204.                         pUnit.setXY(iNewX, iNewY, False, True, True)
  1205.                     UnitsMoved = 1
  1206.                
  1207.                 #Remember the x and y values between turns
  1208.                 iOldX = iNewX
  1209.                 iOldY = iNewY
  1210.                 myPickle = [iOldX, iOldY]
  1211.                 serializedMyPickle = pickle.dumps(myPickle)
  1212.                 BugData.getTable("MY_TABLE").setData(serializedMyPickle)
  1213.  
  1214.                
  1215.             if iOldY < iTargetY and iOldY > iTargetY - 5 and iOldX > iTargetX:
  1216.                 #First choice is to move NW if possible
  1217.                 if UnitsMoved == -1:
  1218.                     iNewX = iOldX - 1
  1219.                     iNewY = iOldY + 1
  1220.                     pNewPlot = CyMap().plot(iNewX,iNewY)           
  1221.                     if pNewPlot.isNone() == False:
  1222.                         #Option 1 - pNewPlot is empty
  1223.                         if pNewPlot.getNumUnits() == 0:
  1224.                             if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  1225.                                 for i in range(pOldPlot.getNumUnits(), -1, -1):
  1226.                                     pUnit = pOldPlot.getUnit(i)
  1227.                                     pUnit.setXY(iNewX, iNewY, False, True, True)
  1228.                                 UnitsMoved = 1
  1229.                         #Option 2 - pNewPlot has friendly (not including Luchuirp units) units in it
  1230.                         #Won't enter the loop if no units in the tile
  1231.                         for iBlockingUnits in range(pNewPlot.getNumUnits()):
  1232.                             pPossibleGoodUnit = pNewPlot.getUnit(iBlockingUnits)
  1233.                             pPossibleGoodPlayer = gc.getPlayer(pPossibleGoodUnit.getOwner())
  1234.                             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'):
  1235.                                 if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  1236.                                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  1237.                                         pUnit = pOldPlot.getUnit(i)
  1238.                                         pUnit.setXY(iNewX, iNewY, False, True, True)
  1239.                                     UnitsMoved = 1
  1240.                
  1241.                 #Second choice is to move W if possible
  1242.                 if UnitsMoved == -1:
  1243.                     iNewY = iNewY - 1
  1244.                     pNewPlot = CyMap().plot(iNewX,iNewY)           
  1245.                     if pNewPlot.isNone() == False:
  1246.                         #Option 1 - pNewPlot is empty
  1247.                         if pNewPlot.getNumUnits() == 0:
  1248.                             if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  1249.                                 for i in range(pOldPlot.getNumUnits(), -1, -1):
  1250.                                     pUnit = pOldPlot.getUnit(i)
  1251.                                     pUnit.setXY(iNewX, iNewY, False, True, True)
  1252.                                 UnitsMoved = 1
  1253.                         #Option 2 - pNewPlot has friendly (not including Luchuirp units) units in it
  1254.                         #Won't enter the loop if no units in the tile
  1255.                         for iBlockingUnits in range(pNewPlot.getNumUnits()):
  1256.                             pPossibleGoodUnit = pNewPlot.getUnit(iBlockingUnits)
  1257.                             pPossibleGoodPlayer = gc.getPlayer(pPossibleGoodUnit.getOwner())
  1258.                             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'):
  1259.                                 if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  1260.                                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  1261.                                         pUnit = pOldPlot.getUnit(i)
  1262.                                         pUnit.setXY(iNewX, iNewY, False, True, True)
  1263.                                     UnitsMoved = 1
  1264.                                
  1265.                 #Third choice is to move SW if possible
  1266.                 if UnitsMoved == -1:
  1267.                     iNewY = iNewY - 1
  1268.                     pNewPlot = CyMap().plot(iNewX,iNewY)           
  1269.                     if pNewPlot.isNone() == False:
  1270.                         #Option 1 - pNewPlot is empty
  1271.                         if pNewPlot.getNumUnits() == 0:
  1272.                             if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  1273.                                 for i in range(pOldPlot.getNumUnits(), -1, -1):
  1274.                                     pUnit = pOldPlot.getUnit(i)
  1275.                                     pUnit.setXY(iNewX, iNewY, False, True, True)
  1276.                                 UnitsMoved = 1
  1277.                         #Option 2 - pNewPlot has friendly (not including Luchuirp units) units in it
  1278.                         #Won't enter the loop if no units in the tile
  1279.                         for iBlockingUnits in range(pNewPlot.getNumUnits()):
  1280.                             pPossibleGoodUnit = pNewPlot.getUnit(iBlockingUnits)
  1281.                             pPossibleGoodPlayer = gc.getPlayer(pPossibleGoodUnit.getOwner())
  1282.                             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'):
  1283.                                 if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  1284.                                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  1285.                                         pUnit = pOldPlot.getUnit(i)
  1286.                                         pUnit.setXY(iNewX, iNewY, False, True, True)
  1287.                                     UnitsMoved = 1
  1288.                                
  1289.                 #Fourth choice is to stay in the same tile
  1290.                 if UnitsMoved == -1:
  1291.                     iNewY = iNewY + 1
  1292.                     iNewX = iNewX + 1
  1293.                     pNewPlot = CyMap().plot(iNewX,iNewY)
  1294.                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  1295.                         pUnit = pOldPlot.getUnit(i)
  1296.                         pUnit.setXY(iNewX, iNewY, False, True, True)
  1297.                     UnitsMoved = 1
  1298.                
  1299.                 #Remember the x and y values between turns
  1300.                 iOldX = iNewX
  1301.                 iOldY = iNewY
  1302.                 myPickle = [iOldX, iOldY]
  1303.                 serializedMyPickle = pickle.dumps(myPickle)
  1304.                 BugData.getTable("MY_TABLE").setData(serializedMyPickle)
  1305.                
  1306.                
  1307.             if iOldY >= iTargetY + 5 and iOldX > iTargetX:
  1308.                 #First choice is to move SW if possible
  1309.                 if UnitsMoved == -1:
  1310.                     iNewX = iOldX - 1
  1311.                     iNewY = iOldY - 1
  1312.                     pNewPlot = CyMap().plot(iNewX,iNewY)           
  1313.                     if pNewPlot.isNone() == False:
  1314.                         #Option 1 - pNewPlot is empty
  1315.                         if pNewPlot.getNumUnits() == 0:
  1316.                             if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  1317.                                 for i in range(pOldPlot.getNumUnits(), -1, -1):
  1318.                                     pUnit = pOldPlot.getUnit(i)
  1319.                                     pUnit.setXY(iNewX, iNewY, False, True, True)
  1320.                                 UnitsMoved = 1
  1321.                         #Option 2 - pNewPlot has friendly (not including Luchuirp units) units in it
  1322.                         #Won't enter the loop if no units in the tile
  1323.                         for iBlockingUnits in range(pNewPlot.getNumUnits()):
  1324.                             pPossibleGoodUnit = pNewPlot.getUnit(iBlockingUnits)
  1325.                             pPossibleGoodPlayer = gc.getPlayer(pPossibleGoodUnit.getOwner())
  1326.                             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'):
  1327.                                 if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  1328.                                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  1329.                                         pUnit = pOldPlot.getUnit(i)
  1330.                                         pUnit.setXY(iNewX, iNewY, False, True, True)
  1331.                                     UnitsMoved = 1
  1332.                                                
  1333.                 #Second choice is to stay in the same tile
  1334.                 if UnitsMoved == -1:
  1335.                     iNewY = iNewY + 1
  1336.                     iNewX = iNewX + 1
  1337.                     pNewPlot = CyMap().plot(iNewX,iNewY)
  1338.                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  1339.                         pUnit = pOldPlot.getUnit(i)
  1340.                         pUnit.setXY(iNewX, iNewY, False, True, True)
  1341.                     UnitsMoved = 1
  1342.                
  1343.                 #Remember the x and y values between turns
  1344.                 iOldX = iNewX
  1345.                 iOldY = iNewY
  1346.                 myPickle = [iOldX, iOldY]
  1347.                 serializedMyPickle = pickle.dumps(myPickle)
  1348.                 BugData.getTable("MY_TABLE").setData(serializedMyPickle)
  1349.                
  1350.  
  1351.             if iOldY <= iTargetY - 5 and iOldX > iTargetX:
  1352.                 #First choice is to move NW if possible
  1353.                 if UnitsMoved == -1:
  1354.                     iNewX = iOldX - 1
  1355.                     iNewY = iOldY + 1
  1356.                     pNewPlot = CyMap().plot(iNewX,iNewY)           
  1357.                     if pNewPlot.isNone() == False:
  1358.                         #Option 1 - pNewPlot is empty
  1359.                         if pNewPlot.getNumUnits() == 0:
  1360.                             if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  1361.                                 for i in range(pOldPlot.getNumUnits(), -1, -1):
  1362.                                     pUnit = pOldPlot.getUnit(i)
  1363.                                     pUnit.setXY(iNewX, iNewY, False, True, True)
  1364.                                 UnitsMoved = 1
  1365.                         #Option 2 - pNewPlot has friendly (not including Luchuirp units) units in it
  1366.                         #Won't enter the loop if no units in the tile
  1367.                         for iBlockingUnits in range(pNewPlot.getNumUnits()):
  1368.                             pPossibleGoodUnit = pNewPlot.getUnit(iBlockingUnits)
  1369.                             pPossibleGoodPlayer = gc.getPlayer(pPossibleGoodUnit.getOwner())
  1370.                             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'):
  1371.                                 if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  1372.                                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  1373.                                         pUnit = pOldPlot.getUnit(i)
  1374.                                         pUnit.setXY(iNewX, iNewY, False, True, True)
  1375.                                     UnitsMoved = 1
  1376.                                
  1377.                 #Second choice is to stay in the same tile
  1378.                 if UnitsMoved == -1:
  1379.                     iNewY = iNewY -1
  1380.                     iNewX = iNewX + 1
  1381.                     pNewPlot = CyMap().plot(iNewX,iNewY)
  1382.                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  1383.                         pUnit = pOldPlot.getUnit(i)
  1384.                         pUnit.setXY(iNewX, iNewY, False, True, True)
  1385.                     UnitsMoved = 1
  1386.                
  1387.                 #Remember the x and y values between turns
  1388.                 iOldX = iNewX
  1389.                 iOldY = iNewY
  1390.                 myPickle = [iOldX, iOldY]
  1391.                 serializedMyPickle = pickle.dumps(myPickle)
  1392.                 BugData.getTable("MY_TABLE").setData(serializedMyPickle)
  1393.                
  1394.            
  1395.             if iOldY < iTargetY and iOldY > iTargetY - 5 and iOldX == iTargetX:
  1396.                 #First choice is to move N if possible
  1397.                 if UnitsMoved == -1:
  1398.                     iNewX = iOldX
  1399.                     iNewY = iOldY + 1
  1400.                     pNewPlot = CyMap().plot(iNewX,iNewY)           
  1401.                     if pNewPlot.isNone() == False:
  1402.                         #Option 1 - pNewPlot is empty
  1403.                         if pNewPlot.getNumUnits() == 0:
  1404.                             if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  1405.                                 for i in range(pOldPlot.getNumUnits(), -1, -1):
  1406.                                     pUnit = pOldPlot.getUnit(i)
  1407.                                     pUnit.setXY(iNewX, iNewY, False, True, True)
  1408.                                 UnitsMoved = 1
  1409.                         #Option 2 - pNewPlot has friendly (not including Luchuirp units) units in it
  1410.                         #Won't enter the loop if no units in the tile
  1411.                         for iBlockingUnits in range(pNewPlot.getNumUnits()):
  1412.                             pPossibleGoodUnit = pNewPlot.getUnit(iBlockingUnits)
  1413.                             pPossibleGoodPlayer = gc.getPlayer(pPossibleGoodUnit.getOwner())
  1414.                             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'):
  1415.                                 if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  1416.                                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  1417.                                         pUnit = pOldPlot.getUnit(i)
  1418.                                         pUnit.setXY(iNewX, iNewY, False, True, True)
  1419.                                     UnitsMoved = 1
  1420.            
  1421.                 #Second choice is to stay in the same tile
  1422.                 if UnitsMoved == -1:
  1423.                     iNewY = iNewY - 1
  1424.                     iNewX = iNewX
  1425.                     pNewPlot = CyMap().plot(iNewX,iNewY)
  1426.                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  1427.                         pUnit = pOldPlot.getUnit(i)
  1428.                         pUnit.setXY(iNewX, iNewY, False, True, True)
  1429.                     UnitsMoved = 1
  1430.                
  1431.                 #Remember the x and y values between turns
  1432.                 iOldX = iNewX
  1433.                 iOldY = iNewY
  1434.                 myPickle = [iOldX, iOldY]
  1435.                 serializedMyPickle = pickle.dumps(myPickle)
  1436.                 BugData.getTable("MY_TABLE").setData(serializedMyPickle)
  1437.                
  1438.             if iOldY > iTargetY and iOldY < iTargetY + 5 and iOldX == iTargetX:
  1439.                 #First choice is to move S if possible
  1440.                 if UnitsMoved == -1:
  1441.                     iNewX = iOldX
  1442.                     iNewY = iOldY - 1
  1443.                     pNewPlot = CyMap().plot(iNewX,iNewY)           
  1444.                     if pNewPlot.isNone() == False:
  1445.                         #Option 1 - pNewPlot is empty
  1446.                         if pNewPlot.getNumUnits() == 0:
  1447.                             if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  1448.                                 for i in range(pOldPlot.getNumUnits(), -1, -1):
  1449.                                     pUnit = pOldPlot.getUnit(i)
  1450.                                     pUnit.setXY(iNewX, iNewY, False, True, True)
  1451.                                 UnitsMoved = 1
  1452.                         #Option 2 - pNewPlot has friendly (not including Luchuirp units) units in it
  1453.                         #Won't enter the loop if no units in the tile
  1454.                         for iBlockingUnits in range(pNewPlot.getNumUnits()):
  1455.                             pPossibleGoodUnit = pNewPlot.getUnit(iBlockingUnits)
  1456.                             pPossibleGoodPlayer = gc.getPlayer(pPossibleGoodUnit.getOwner())
  1457.                             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'):
  1458.                                 if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  1459.                                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  1460.                                         pUnit = pOldPlot.getUnit(i)
  1461.                                         pUnit.setXY(iNewX, iNewY, False, True, True)
  1462.                                     UnitsMoved = 1
  1463.            
  1464.                 #Second choice is to stay in the same tile
  1465.                 if UnitsMoved == -1:
  1466.                     iNewY = iNewY + 1
  1467.                     iNewX = iNewX
  1468.                     pNewPlot = CyMap().plot(iNewX,iNewY)
  1469.                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  1470.                         pUnit = pOldPlot.getUnit(i)
  1471.                         pUnit.setXY(iNewX, iNewY, False, True, True)
  1472.                     UnitsMoved = 1
  1473.                
  1474.                 #Remember the x and y values between turns
  1475.                 iOldX = iNewX
  1476.                 iOldY = iNewY
  1477.                 myPickle = [iOldX, iOldY]
  1478.                 serializedMyPickle = pickle.dumps(myPickle)
  1479.                 BugData.getTable("MY_TABLE").setData(serializedMyPickle)
  1480.                                
  1481.             if iOldY <= iTargetY - 5 and iOldX == iTargetX:
  1482.                 #First choice is to move N if possible
  1483.                 if UnitsMoved == -1:
  1484.                     iNewX = iOldX
  1485.                     iNewY = iOldY + 1
  1486.                     pNewPlot = CyMap().plot(iNewX,iNewY)           
  1487.                     if pNewPlot.isNone() == False:
  1488.                         #Option 1 - pNewPlot is empty
  1489.                         if pNewPlot.getNumUnits() == 0:
  1490.                             if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  1491.                                 for i in range(pOldPlot.getNumUnits(), -1, -1):
  1492.                                     pUnit = pOldPlot.getUnit(i)
  1493.                                     pUnit.setXY(iNewX, iNewY, False, True, True)
  1494.                                 UnitsMoved = 1
  1495.                         #Option 2 - pNewPlot has friendly (not including Luchuirp units) units in it
  1496.                         #Won't enter the loop if no units in the tile
  1497.                         for iBlockingUnits in range(pNewPlot.getNumUnits()):
  1498.                             pPossibleGoodUnit = pNewPlot.getUnit(iBlockingUnits)
  1499.                             pPossibleGoodPlayer = gc.getPlayer(pPossibleGoodUnit.getOwner())
  1500.                             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'):
  1501.                                 if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  1502.                                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  1503.                                         pUnit = pOldPlot.getUnit(i)
  1504.                                         pUnit.setXY(iNewX, iNewY, False, True, True)
  1505.                                     UnitsMoved = 1
  1506.                                
  1507.                 #Second choice is to stay in the same tile
  1508.                 if UnitsMoved == -1:
  1509.                     iNewY = iNewY -1
  1510.                     iNewX = iNewX
  1511.                     pNewPlot = CyMap().plot(iNewX,iNewY)
  1512.                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  1513.                         pUnit = pOldPlot.getUnit(i)
  1514.                         pUnit.setXY(iNewX, iNewY, False, True, True)
  1515.                     UnitsMoved = 1
  1516.                
  1517.                 #Remember the x and y values between turns
  1518.                 iOldX = iNewX
  1519.                 iOldY = iNewY
  1520.                 myPickle = [iOldX, iOldY]
  1521.                 serializedMyPickle = pickle.dumps(myPickle)
  1522.                 BugData.getTable("MY_TABLE").setData(serializedMyPickle)
  1523.                
  1524.                
  1525.             if iOldY >= iTargetY + 5 and iOldX == iTargetX:
  1526.                 #First choice is to move S if possible
  1527.                 if UnitsMoved == -1:
  1528.                     iNewX = iOldX
  1529.                     iNewY = iOldY - 1
  1530.                     pNewPlot = CyMap().plot(iNewX,iNewY)           
  1531.                     if pNewPlot.isNone() == False:
  1532.                         #Option 1 - pNewPlot is empty
  1533.                         if pNewPlot.getNumUnits() == 0:
  1534.                             if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  1535.                                 for i in range(pOldPlot.getNumUnits(), -1, -1):
  1536.                                     pUnit = pOldPlot.getUnit(i)
  1537.                                     pUnit.setXY(iNewX, iNewY, False, True, True)
  1538.                                 UnitsMoved = 1
  1539.                         #Option 2 - pNewPlot has friendly (not including Luchuirp units) units in it
  1540.                         #Won't enter the loop if no units in the tile
  1541.                         for iBlockingUnits in range(pNewPlot.getNumUnits()):
  1542.                             pPossibleGoodUnit = pNewPlot.getUnit(iBlockingUnits)
  1543.                             pPossibleGoodPlayer = gc.getPlayer(pPossibleGoodUnit.getOwner())
  1544.                             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'):
  1545.                                 if (pNewPlot.isWater() == False and pNewPlot.isPeak() == False and pNewPlot.isCity() == False):
  1546.                                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  1547.                                         pUnit = pOldPlot.getUnit(i)
  1548.                                         pUnit.setXY(iNewX, iNewY, False, True, True)
  1549.                                     UnitsMoved = 1
  1550.                                
  1551.                 #Second choice is to stay in the same tile
  1552.                 if UnitsMoved == -1:
  1553.                     iNewY = iNewY +1
  1554.                     iNewX = iNewX
  1555.                     pNewPlot = CyMap().plot(iNewX,iNewY)
  1556.                     for i in range(pOldPlot.getNumUnits(), -1, -1):
  1557.                         pUnit = pOldPlot.getUnit(i)
  1558.                         pUnit.setXY(iNewX, iNewY, False, True, True)
  1559.                     UnitsMoved = 1
  1560.                
  1561.                 #Remember the x and y values between turns
  1562.                 iOldX = iNewX
  1563.                 iOldY = iNewY
  1564.                 myPickle = [iOldX, iOldY]
  1565.                 serializedMyPickle = pickle.dumps(myPickle)
  1566.                 BugData.getTable("MY_TABLE").setData(serializedMyPickle)
  1567.                
  1568.  
  1569.             #Get rid of the HELD promotion when the stack reaches the target tile
  1570.             #This is still indented to be included within iGameTurn >35 and <50
  1571.             if iOldX == iTargetX and iOldY == iTargetY:
  1572.                 for i in range(pTargetPlot.getNumUnits()):
  1573.                     pUnit = pTargetPlot.getUnit(i)
  1574.                     pUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), False)
  1575.                    
  1576.  
  1577.         #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)
  1578.         if iGameTurn == 50:
  1579.             for iGoodSofDPlayer in range(gc.getMAX_PLAYERS()):
  1580.                 pGoodSofDPlayer = gc.getPlayer(iGoodSofDPlayer)
  1581.                 if (pGoodSofDPlayer.isAlive()):
  1582.                     if pGoodSofDPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_BANNOR'):
  1583.                         pySofD = PyPlayer(iGoodSofDPlayer)
  1584.                         if pGoodSofDPlayer.getNumUnits() > 0:
  1585.                             for pMaybeHeldUnit in pySofD.getUnitList():
  1586.                                 if pMaybeHeldUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_SofD')):
  1587.                                     if pMaybeHeldUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD')):
  1588.                                         pMaybeHeldUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), False)
  1589.                     if pGoodSofDPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_ELOHIM'):
  1590.                         pySofD = PyPlayer(iGoodSofDPlayer)
  1591.                         if pGoodSofDPlayer.getNumUnits() > 0:
  1592.                             for pMaybeHeldUnit in pySofD.getUnitList():
  1593.                                 if pMaybeHeldUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_SofD')):
  1594.                                     if pMaybeHeldUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD')):
  1595.                                         pMaybeHeldUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), False)
  1596.                     if pGoodSofDPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_KURIOTATES'):
  1597.                         pySofD = PyPlayer(iGoodSofDPlayer)
  1598.                         if pGoodSofDPlayer.getNumUnits() > 0:
  1599.                             for pMaybeHeldUnit in pySofD.getUnitList():
  1600.                                 if pMaybeHeldUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_SofD')):
  1601.                                     if pMaybeHeldUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD')):
  1602.                                         pMaybeHeldUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), False)   
  1603.                     if pGoodSofDPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LJOSALFAR'):
  1604.                         pySofD = PyPlayer(iGoodSofDPlayer)
  1605.                         if pGoodSofDPlayer.getNumUnits() > 0:
  1606.                             for pMaybeHeldUnit in pySofD.getUnitList():
  1607.                                 if pMaybeHeldUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_SofD')):
  1608.                                     if pMaybeHeldUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD')):
  1609.                                         pMaybeHeldUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), False)
  1610.                     if pGoodSofDPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LUCHUIRP'):
  1611.                         pySofD = PyPlayer(iGoodSofDPlayer)
  1612.                         if pGoodSofDPlayer.getNumUnits() > 0:
  1613.                             for pMaybeHeldUnit in pySofD.getUnitList():
  1614.                                 if pMaybeHeldUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_SofD')):
  1615.                                     if pMaybeHeldUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD')):
  1616.                                         pMaybeHeldUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), False)
  1617.  
  1618.  
  1619.         #Popup to explain why Bane Divine will be built
  1620.         if iGameTurn == 40:
  1621.             sf.addPopupWB(CyTranslator().getText("TXT_KEY_WB_ELOHIM_SCENARIO_BANE_DIVINE_CREATE",()),'')                                       
  1622.                                        
  1623.                
  1624.         #Perhaps a better method would be to produce Bane Divine (e.g.) 20 turns after the SoD starts moving out of the marshalling point (67, 28)
  1625.         #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!
  1626.         #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
  1627.         for iBaneCreatePlayer in range(gc.getMAX_PLAYERS()):
  1628.             pTargetPlayer = gc.getPlayer(iBaneCreatePlayer)
  1629.             if pTargetPlayer.isAlive():
  1630.                 if pTargetPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LUCHUIRP'):
  1631.                     if not pTargetPlayer.isHuman():
  1632.                         for pyCity in PyPlayer(iBaneCreatePlayer).getCityList():
  1633.                             pTargetCity = pyCity.GetCy()
  1634.                             if pTargetCity.isCapital():
  1635.                                 #if iGameTurn == 3:
  1636.                                 #Load current (x,y) values of the Stack of Doom and then check if the stack is at the target tile
  1637.                                 serializedMyPickle = BugData.getTable("MY_TABLE").data
  1638.                                 myPickle = pickle.loads(serializedMyPickle)
  1639.                                 iOldX = myPickle[0]
  1640.                                 iOldY = myPickle[1]
  1641.                                 iTargetX = 60
  1642.                                 iTargetY = 18
  1643.                                 #if iOldX == iTargetX and iOldY == iTargetY:
  1644.                                 if iGameTurn == 50:                            
  1645.                                     if pTargetCity.canCreate(gc.getInfoTypeForString('PROJECT_BANE_DIVINE'), True, True):
  1646.                                         pTargetCity.pushOrder(OrderTypes.ORDER_CREATE, gc.getInfoTypeForString('PROJECT_BANE_DIVINE'), -1, False, True, False, False)
  1647.                                         pTargetCity.setProduction(10000)
  1648.                                         return 1
  1649.        
  1650.            
  1651.         #Different popups for the plague depending on whether the Luchuirp have declared war on the other good civs or not             
  1652.         #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)
  1653.         if iGameTurn == 55:
  1654.             if gc.getTeam(iLuchuirpTeamID).isAlive:
  1655.                 if gc.getTeam(iLuchuirpTeamID).isAtWar(iElohimTeamID):
  1656.                     sf.addPopupWB(CyTranslator().getText("TXT_KEY_WB_ELOHIM_SCENARIO_PLAGUED_LUCHUIRP_BAD",()),'')
  1657.                 if not gc.getTeam(iLuchuirpTeamID).isAtWar(iElohimTeamID):
  1658.                     sf.addPopupWB(CyTranslator().getText("TXT_KEY_WB_ELOHIM_SCENARIO_PLAGUED_LUCHUIRP_GOOD",()),'')
  1659.             for iPlaguedUnitsPlayer in range(gc.getMAX_PLAYERS()):
  1660.                 PlaguedUnitsPlayer = gc.getPlayer(iPlaguedUnitsPlayer)
  1661.                 if PlaguedUnitsPlayer.isAlive():
  1662.                     py = PyPlayer(iPlaguedUnitsPlayer)
  1663.                     for pPlaguedUnit in py.getUnitList():
  1664.                         if pPlaguedUnit.isAlive():
  1665.                             pPlaguedUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_DISEASED'), True)
  1666.  
  1667.  
  1668.     def onEndGameTurn(self, argsList):
  1669.         'Called at the end of the end of each turn'
  1670.         iGameTurn = argsList[0]
  1671.  
  1672.     def onBeginPlayerTurn(self, argsList):
  1673.         'Called at the beginning of a players turn'
  1674.         iGameTurn, iPlayer = argsList
  1675.         pPlayer = gc.getPlayer(iPlayer)
  1676.         player = PyPlayer(iPlayer)
  1677.  
  1678.         if not pPlayer.isHuman():
  1679.             if not CyGame().getWBMapScript():
  1680.                 cf.warScript(iPlayer)
  1681.  
  1682.         if pPlayer.getCivics(gc.getInfoTypeForString('CIVICOPTION_CULTURAL_VALUES')) == gc.getInfoTypeForString('CIVIC_CRUSADE'):
  1683.             cf.doCrusade(iPlayer)
  1684.  
  1685.         if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_KHAZAD'):
  1686.             cf.doTurnKhazad(iPlayer)
  1687.         elif pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LUCHUIRP'):
  1688.             cf.doTurnLuchuirp(iPlayer)
  1689.  
  1690.         if pPlayer.hasTrait(gc.getInfoTypeForString('TRAIT_INSANE')):
  1691.             if CyGame().getSorenRandNum(1000, "Insane") < 20:
  1692.                 iEvent = CvUtil.findInfoTypeNum(gc.getEventTriggerInfo, gc.getNumEventTriggerInfos(),'EVENTTRIGGER_TRAIT_INSANE')
  1693.                 triggerData = pPlayer.initTriggeredData(iEvent, True, -1, -1, -1, iPlayer, -1, -1, -1, -1, -1)
  1694.  
  1695.         if pPlayer.hasTrait(gc.getInfoTypeForString('TRAIT_ADAPTIVE')):
  1696.             iBaseCycle = 100
  1697.             iCycle = (iBaseCycle * gc.getGameSpeedInfo(CyGame().getGameSpeedType()).getVictoryDelayPercent()) / 100
  1698.             for i in range(10):
  1699.                 if (i * iCycle) - 5 == iGameTurn:
  1700.                     iEvent = CvUtil.findInfoTypeNum(gc.getEventTriggerInfo, gc.getNumEventTriggerInfos(),'EVENTTRIGGER_TRAIT_ADAPTIVE')
  1701.                     triggerData = pPlayer.initTriggeredData(iEvent, True, -1, -1, -1, iPlayer, -1, -1, -1, -1, -1)
  1702.  
  1703.         if pPlayer.isHuman():
  1704.             if pPlayer.hasTrait(gc.getInfoTypeForString('TRAIT_BARBARIAN')):
  1705.                 eTeam = gc.getTeam(gc.getPlayer(gc.getBARBARIAN_PLAYER()).getTeam())
  1706.                 iTeam = pPlayer.getTeam()
  1707.                 if eTeam.isAtWar(iTeam) == False:
  1708.                     if 2 * CyGame().getPlayerScore(iPlayer) >= 3 * CyGame().getPlayerScore(CyGame().getRankPlayer(1)):
  1709.                         if iGameTurn >= 20:
  1710.                             eTeam.declareWar(iTeam, False, WarPlanTypes.WARPLAN_TOTAL)
  1711.                             if iPlayer == CyGame().getActivePlayer():
  1712.                                 cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_BARBARIAN_DECLARE_WAR",()), 'art/interface/popups/Barbarian.dds')
  1713.  
  1714.  
  1715.     def onEndPlayerTurn(self, argsList):
  1716.         'Called at the end of a players turn'
  1717.         iGameTurn, iPlayer = argsList
  1718.         pPlayer = gc.getPlayer(iPlayer)
  1719.         if gc.getGame().getElapsedGameTurns() == 1:
  1720.             if pPlayer.isHuman():
  1721.                 if pPlayer.canRevolution(0):
  1722.                     popupInfo = CyPopupInfo()
  1723.                     popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_CHANGECIVIC)
  1724.                     popupInfo.addPopup(iPlayer)
  1725.  
  1726.         CvAdvisorUtils.resetAdvisorNags()
  1727.         CvAdvisorUtils.endTurnFeats(iPlayer)
  1728.  
  1729.     def onEndTurnReady(self, argsList):
  1730.         iGameTurn = argsList[0]
  1731.  
  1732.     def onFirstContact(self, argsList):
  1733.     ## Platy Builder ##
  1734.         if CyGame().GetWorldBuilderMode() and not CvPlatyBuilderScreen.bPython: return
  1735.     ## Platy Builder ##
  1736.         'Contact'
  1737.         iTeamX,iHasMetTeamY = argsList
  1738.         if (not self.__LOG_CONTACT):
  1739.             return
  1740.         CvUtil.pyPrint('Team %d has met Team %d' %(iTeamX, iHasMetTeamY))
  1741.  
  1742.     def onCombatResult(self, argsList):
  1743.         'Combat Result'
  1744.         pWinner,pLoser = argsList
  1745.         playerX = PyPlayer(pWinner.getOwner())
  1746.         unitX = PyInfo.UnitInfo(pWinner.getUnitType())
  1747.         playerY = PyPlayer(pLoser.getOwner())
  1748.         unitY = PyInfo.UnitInfo(pLoser.getUnitType())
  1749.  
  1750. ## Advanced Tactics Start - ships and siege engines can be captured
  1751. ## adopted from mechaerik War Prize ModComp
  1752.         if gc.getGame().isOption(GameOptionTypes.GAMEOPTION_ADVANCED_TACTICS):
  1753.             pPlayer = gc.getPlayer(pWinner.getOwner())
  1754.             pPlayerLoser = gc.getPlayer(pLoser.getOwner())
  1755.             if (not pWinner.isHiddenNationality()):
  1756.                 if (pLoser.canMoveInto(pWinner.plot(), True, True, False)):
  1757.                     if (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_NAVAL")):
  1758.                         if (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_NAVAL")):
  1759.                             if CyGame().getSorenRandNum(100, "WarPrizes Naval") <= 25:
  1760.                                 iUnit = pLoser.getUnitType()
  1761.                                 newUnit = pPlayer.initUnit(pLoser.getUnitType(), pWinner.getX(), pWinner.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION)
  1762.                                 newUnit.finishMoves()
  1763.                                 newUnit.setDamage(75, pWinner.getOwner())
  1764.                                 if (pPlayer.isHuman()):
  1765.                                     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)
  1766.                                 elif (pPlayerLoser.isHuman()):
  1767.                                     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)
  1768.                     if (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_SIEGE")):
  1769.                         if CyGame().getSorenRandNum(100, "WarPrizes Siege") <= 15:
  1770.                             iUnit = pLoser.getUnitType()
  1771.                             newUnit = pPlayer.initUnit(pLoser.getUnitType(), pWinner.getX(), pWinner.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION)
  1772.                             newUnit.finishMoves()
  1773.                             newUnit.setDamage(75, pWinner.getOwner())
  1774.                             if (pPlayer.isHuman()):
  1775.                                 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)
  1776.                             elif (pPlayerLoser.isHuman()):
  1777.                                 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)
  1778. ## End Advanced Tactics
  1779.  
  1780.         if not self.__LOG_COMBAT:
  1781.             return
  1782.         if playerX and playerX and unitX and playerY:
  1783.             CvUtil.pyPrint('Player %d Civilization %s Unit %s has defeated Player %d Civilization %s Unit %s'
  1784.                 %(playerX.getID(), playerX.getCivilizationName(), unitX.getDescription(),
  1785.                 playerY.getID(), playerY.getCivilizationName(), unitY.getDescription()))
  1786.  
  1787.     def onCombatLogCalc(self, argsList):
  1788.         'Combat Result'
  1789.         genericArgs = argsList[0][0]
  1790.         cdAttacker = genericArgs[0]
  1791.         cdDefender = genericArgs[1]
  1792.         iCombatOdds = genericArgs[2]
  1793.         CvUtil.combatMessageBuilder(cdAttacker, cdDefender, iCombatOdds)
  1794.  
  1795.     def onCombatLogHit(self, argsList):
  1796.         'Combat Message'
  1797.         global gCombatMessages, gCombatLog
  1798.         genericArgs = argsList[0][0]
  1799.         cdAttacker = genericArgs[0]
  1800.         cdDefender = genericArgs[1]
  1801.         iIsAttacker = genericArgs[2]
  1802.         iDamage = genericArgs[3]
  1803.  
  1804.         if cdDefender.eOwner == cdDefender.eVisualOwner:
  1805.             szDefenderName = gc.getPlayer(cdDefender.eOwner).getNameKey()
  1806.         else:
  1807.             szDefenderName = localText.getText("TXT_KEY_TRAIT_PLAYER_UNKNOWN", ())
  1808.         if cdAttacker.eOwner == cdAttacker.eVisualOwner:
  1809.             szAttackerName = gc.getPlayer(cdAttacker.eOwner).getNameKey()
  1810.         else:
  1811.             szAttackerName = localText.getText("TXT_KEY_TRAIT_PLAYER_UNKNOWN", ())
  1812.  
  1813.         if (iIsAttacker == 0):
  1814.             combatMessage = localText.getText("TXT_KEY_COMBAT_MESSAGE_HIT", (szDefenderName, cdDefender.sUnitName, iDamage, cdDefender.iCurrHitPoints, cdDefender.iMaxHitPoints))
  1815.             CyInterface().addCombatMessage(cdAttacker.eOwner,combatMessage)
  1816.             CyInterface().addCombatMessage(cdDefender.eOwner,combatMessage)
  1817.             if (cdDefender.iCurrHitPoints <= 0):
  1818.                 combatMessage = localText.getText("TXT_KEY_COMBAT_MESSAGE_DEFEATED", (szAttackerName, cdAttacker.sUnitName, szDefenderName, cdDefender.sUnitName))
  1819.                 CyInterface().addCombatMessage(cdAttacker.eOwner,combatMessage)
  1820.                 CyInterface().addCombatMessage(cdDefender.eOwner,combatMessage)
  1821.         elif (iIsAttacker == 1):
  1822.             combatMessage = localText.getText("TXT_KEY_COMBAT_MESSAGE_HIT", (szAttackerName, cdAttacker.sUnitName, iDamage, cdAttacker.iCurrHitPoints, cdAttacker.iMaxHitPoints))
  1823.             CyInterface().addCombatMessage(cdAttacker.eOwner,combatMessage)
  1824.             CyInterface().addCombatMessage(cdDefender.eOwner,combatMessage)
  1825.             if (cdAttacker.iCurrHitPoints <= 0):
  1826.                 combatMessage = localText.getText("TXT_KEY_COMBAT_MESSAGE_DEFEATED", (szDefenderName, cdDefender.sUnitName, szAttackerName, cdAttacker.sUnitName))
  1827.                 CyInterface().addCombatMessage(cdAttacker.eOwner,combatMessage)
  1828.                 CyInterface().addCombatMessage(cdDefender.eOwner,combatMessage)
  1829.  
  1830.     def onImprovementBuilt(self, argsList):
  1831.     ## Platy Builder ##
  1832.         if CyGame().GetWorldBuilderMode() and not CvPlatyBuilderScreen.bPython: return
  1833.     ## Platy Builder ##
  1834.         'Improvement Built'
  1835.         iImprovement, iX, iY = argsList
  1836.         pPlot = CyMap().plot(iX, iY)
  1837.  
  1838.         if gc.getImprovementInfo(iImprovement).isUnique():
  1839.             CyEngine().addLandmark(pPlot, CvUtil.convertToStr(gc.getImprovementInfo(iImprovement).getDescription()))
  1840.  
  1841.             if iImprovement == gc.getInfoTypeForString('IMPROVEMENT_RING_OF_CARCER'):
  1842.                 pPlot.setMinLevel(15)
  1843.                 bPlayer = gc.getPlayer(gc.getBARBARIAN_PLAYER())
  1844.                 bPlayer.initUnit(gc.getInfoTypeForString('UNIT_BRIGIT_HELD'), pPlot.getX(), pPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
  1845.             elif iImprovement == gc.getInfoTypeForString('IMPROVEMENT_SEVEN_PINES'):
  1846.                 pPlot.setTerrainType(gc.getInfoTypeForString('TERRAIN_GRASS'), True, True)
  1847.                 pPlot.setFeatureType(gc.getInfoTypeForString('FEATURE_FOREST'), 1)
  1848.  
  1849.         if (not self.__LOG_IMPROVEMENT):
  1850.             return
  1851.         CvUtil.pyPrint('Improvement %s was built at %d, %d'
  1852.             %(PyInfo.ImprovementInfo(iImprovement).getDescription(), iX, iY))
  1853.  
  1854.     def onImprovementDestroyed(self, argsList):
  1855.     ## Platy Builder ##
  1856.         if CyGame().GetWorldBuilderMode() and not CvPlatyBuilderScreen.bPython: return
  1857.     ## Platy Builder ##
  1858.         'Improvement Destroyed'
  1859.         iImprovement, iOwner, iX, iY = argsList
  1860.         if gc.getImprovementInfo(iImprovement).isUnique():
  1861.             pPlot = CyMap().plot(iX, iY)
  1862.             CyEngine().removeLandmark(pPlot)
  1863.             if iImprovement == gc.getInfoTypeForString('IMPROVEMENT_RING_OF_CARCER'):
  1864.                 pPlot.setMinLevel(-1)
  1865.  
  1866.         if iImprovement == gc.getInfoTypeForString('IMPROVEMENT_NECROTOTEM'):
  1867.             CyGame().changeGlobalCounter(-2)
  1868.  
  1869.         if CyGame().getWBMapScript():
  1870.             sf.onImprovementDestroyed(iImprovement, iOwner, iX, iY)
  1871.  
  1872.         if (not self.__LOG_IMPROVEMENT):
  1873.             return
  1874.         CvUtil.pyPrint('Improvement %s was Destroyed at %d, %d'
  1875.             %(PyInfo.ImprovementInfo(iImprovement).getDescription(), iX, iY))
  1876.  
  1877.     def onRouteBuilt(self, argsList):
  1878.     ## Platy Builder ##
  1879.         if CyGame().GetWorldBuilderMode() and not CvPlatyBuilderScreen.bPython: return
  1880.     ## Platy Builder ##
  1881.         'Route Built'
  1882.         iRoute, iX, iY = argsList
  1883.         if (not self.__LOG_IMPROVEMENT):
  1884.             return
  1885.         CvUtil.pyPrint('Route %s was built at %d, %d'
  1886.             %(gc.getRouteInfo(iRoute).getDescription(), iX, iY))
  1887.  
  1888.     def onPlotRevealed(self, argsList):
  1889.     ## Platy Builder ##
  1890.         if CyGame().GetWorldBuilderMode() and not CvPlatyBuilderScreen.bPython: return
  1891.     ## Platy Builder ##
  1892.         'Plot Revealed'
  1893.         pPlot = argsList[0]
  1894.         iTeam = argsList[1]
  1895.  
  1896.     def onPlotFeatureRemoved(self, argsList):
  1897.         'Plot Revealed'
  1898.         pPlot = argsList[0]
  1899.         iFeatureType = argsList[1]
  1900.         pCity = argsList[2] # This can be null
  1901.  
  1902.     def onPlotPicked(self, argsList):
  1903.         'Plot Picked'
  1904.         pPlot = argsList[0]
  1905.         CvUtil.pyPrint('Plot was picked at %d, %d'
  1906.             %(pPlot.getX(), pPlot.getY()))
  1907.  
  1908.     def onNukeExplosion(self, argsList):
  1909.         'Nuke Explosion'
  1910.         pPlot, pNukeUnit = argsList
  1911.         CvUtil.pyPrint('Nuke detonated at %d, %d'
  1912.             %(pPlot.getX(), pPlot.getY()))
  1913.  
  1914.     def onGotoPlotSet(self, argsList):
  1915.         'Nuke Explosion'
  1916.         pPlot, iPlayer = argsList
  1917.  
  1918.     def onBuildingBuilt(self, argsList):
  1919.         'Building Completed'
  1920.         pCity, iBuildingType = argsList
  1921.         player = pCity.getOwner()
  1922.         pPlayer = gc.getPlayer(player)
  1923.         pPlot = pCity.plot()
  1924.         game = gc.getGame()
  1925.         iBuildingClass = gc.getBuildingInfo(iBuildingType).getBuildingClassType()
  1926.  
  1927.         if not gc.getGame().isNetworkMultiPlayer() and (pCity.getOwner() == gc.getGame().getActivePlayer()) and isWorldWonderClass(iBuildingClass):
  1928.     ## Platy Builder ##
  1929.             if not CyGame().GetWorldBuilderMode():
  1930.     ## Platy Builder ##
  1931.                 if gc.getBuildingInfo(iBuildingType).getMovie():
  1932.                     # If this is a wonder...
  1933.                     popupInfo = CyPopupInfo()
  1934.                     popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
  1935.                     popupInfo.setData1(iBuildingType)
  1936.                     popupInfo.setData2(pCity.getID())
  1937.                     popupInfo.setData3(0)
  1938.                     popupInfo.setText(u"showWonderMovie")
  1939.                     popupInfo.addPopup(pCity.getOwner())
  1940.  
  1941.         if iBuildingType == gc.getInfoTypeForString('BUILDING_INFERNAL_GRIMOIRE'):
  1942.             if CyGame().getSorenRandNum(100, "Bob") < 20:
  1943.                 pPlot2 = cf.findClearPlot(-1, pPlot)
  1944.                 if pPlot2 != -1:
  1945.                     bPlayer = gc.getPlayer(gc.getBARBARIAN_PLAYER())
  1946.                     newUnit = bPlayer.initUnit(gc.getInfoTypeForString('UNIT_BALOR'), pPlot2.getX(), pPlot2.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
  1947.                     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)
  1948.                     if pCity.getOwner() == CyGame().getActivePlayer():
  1949.                         cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_INFERNAL_GRIMOIRE_BALOR",()), 'art/interface/popups/Balor.dds')
  1950.  
  1951.         elif iBuildingType == gc.getInfoTypeForString('BUILDING_ALTAR_OF_THE_LUONNOTAR_FINAL'):
  1952.             pCity.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_ALTAR_OF_THE_LUONNOTAR_EXALTED'), 0)
  1953.         elif iBuildingType == gc.getInfoTypeForString('BUILDING_ALTAR_OF_THE_LUONNOTAR_EXALTED'):
  1954.             pCity.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_ALTAR_OF_THE_LUONNOTAR_DIVINE'), 0)
  1955.         elif iBuildingType == gc.getInfoTypeForString('BUILDING_ALTAR_OF_THE_LUONNOTAR_DIVINE'):
  1956.             pCity.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_ALTAR_OF_THE_LUONNOTAR_CONSECRATED'), 0)
  1957.         elif iBuildingType == gc.getInfoTypeForString('BUILDING_ALTAR_OF_THE_LUONNOTAR_CONSECRATED'):
  1958.             pCity.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_ALTAR_OF_THE_LUONNOTAR_BLESSED'), 0)
  1959.         elif iBuildingType == gc.getInfoTypeForString('BUILDING_ALTAR_OF_THE_LUONNOTAR_BLESSED'):
  1960.             pCity.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_ALTAR_OF_THE_LUONNOTAR_ANOINTED'), 0)
  1961.         elif iBuildingType == gc.getInfoTypeForString('BUILDING_ALTAR_OF_THE_LUONNOTAR_ANOINTED'):
  1962.             pCity.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_ALTAR_OF_THE_LUONNOTAR'), 0)
  1963.  
  1964.         elif iBuildingType == gc.getInfoTypeForString('BUILDING_MERCURIAN_GATE'):
  1965.             for iLoop in range(pPlot.getNumUnits(), -1, -1):
  1966.                 pUnit = pPlot.getUnit(iLoop)
  1967.                 pUnit.jumpToNearestValidPlot()
  1968.  
  1969.             iMercurianPlayer = pPlayer.initNewEmpire(gc.getInfoTypeForString('LEADER_BASIUM'), gc.getInfoTypeForString('CIVILIZATION_MERCURIANS'))
  1970.             if iMercurianPlayer != PlayerTypes.NO_PLAYER:
  1971.                 pMercurianPlayer = gc.getPlayer(iMercurianPlayer)
  1972.                 iTeam = pPlayer.getTeam()
  1973.                 iMercurianTeam = pMercurianPlayer.getTeam()
  1974.                 if iTeam < iMercurianTeam:
  1975.                     gc.getTeam(iTeam).addTeam(iMercurianTeam)
  1976.                 else:
  1977.                     gc.getTeam(iMercurianTeam).addTeam(iTeam)
  1978.  
  1979.                 pBasiumUnit = gc.getPlayer(iMercurianPlayer).initUnit(gc.getInfoTypeForString('UNIT_BASIUM'), pPlot.getX(), pPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
  1980.                 pBasiumUnit.setAvatarOfCivLeader(True)
  1981.                 gc.getPlayer(iMercurianPlayer).initUnit(gc.getInfoTypeForString('UNIT_SETTLER'), pPlot.getX(), pPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
  1982.                 gc.getPlayer(iMercurianPlayer).initUnit(gc.getInfoTypeForString('UNIT_ANGEL'), pPlot.getX(), pPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
  1983.                 gc.getPlayer(iMercurianPlayer).initUnit(gc.getInfoTypeForString('UNIT_ANGEL'), pPlot.getX(), pPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
  1984.                 gc.getPlayer(iMercurianPlayer).initUnit(gc.getInfoTypeForString('UNIT_ANGEL'), pPlot.getX(), pPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
  1985.                 gc.getPlayer(iMercurianPlayer).initUnit(gc.getInfoTypeForString('UNIT_ANGEL'), pPlot.getX(), pPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
  1986.                 gc.getPlayer(iMercurianPlayer).initUnit(gc.getInfoTypeForString('UNIT_ANGEL'), pPlot.getX(), pPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
  1987.                 gc.getPlayer(iMercurianPlayer).initUnit(gc.getInfoTypeForString('UNIT_ANGEL'), pPlot.getX(), pPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
  1988.                 gc.getPlayer(iMercurianPlayer).initUnit(gc.getInfoTypeForString('UNIT_WORKER'), pPlot.getX(), pPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
  1989.  
  1990.                 if pPlayer.isHuman():
  1991.                     popupInfo = CyPopupInfo()
  1992.                     popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON)
  1993.                     popupInfo.setText(CyTranslator().getText("TXT_KEY_POPUP_CONTROL_MERCURIANS",()))
  1994.                     popupInfo.setData1(player)
  1995.                     popupInfo.setData2(iMercurianPlayer)
  1996.                     popupInfo.addPythonButton(CyTranslator().getText("TXT_KEY_POPUP_YES", ()), "")
  1997.                     popupInfo.addPythonButton(CyTranslator().getText("TXT_KEY_POPUP_NO", ()), "")
  1998.                     popupInfo.setOnClickedPythonCallback("reassignPlayer")
  1999.                     popupInfo.addPopup(player)
  2000.  
  2001.         elif iBuildingType == gc.getInfoTypeForString('BUILDING_TOWER_OF_THE_ELEMENTS'):
  2002.             lList = ['UNIT_AIR_ELEMENTAL', 'UNIT_EARTH_ELEMENTAL', 'UNIT_FIRE_ELEMENTAL', 'UNIT_WATER_ELEMENTAL']
  2003.             iUnit = gc.getInfoTypeForString(lList[CyGame().getSorenRandNum(len(lList), "Pick Elemental")-1])
  2004.             newUnit = pPlayer.initUnit(iUnit, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_CITY_DEFENSE, DirectionTypes.DIRECTION_SOUTH)
  2005.             newUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), True)
  2006.             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)
  2007.             iElemental = gc.getInfoTypeForString('PROMOTION_ELEMENTAL')
  2008.             iStrong = gc.getInfoTypeForString('PROMOTION_STRONG')
  2009.             apUnitList = PyPlayer(player).getUnitList()
  2010.             for pUnit in apUnitList:
  2011.                 if pUnit.isHasPromotion(iElemental):
  2012.                     pUnit.setHasPromotion(iStrong, True)
  2013.  
  2014.         elif iBuildingType == gc.getInfoTypeForString('BUILDING_TOWER_OF_NECROMANCY'):
  2015.             iUndead = gc.getInfoTypeForString('PROMOTION_UNDEAD')
  2016.             iStrong = gc.getInfoTypeForString('PROMOTION_STRONG')
  2017.             apUnitList = PyPlayer(player).getUnitList()
  2018.             for pUnit in apUnitList:
  2019.                 if pUnit.isHasPromotion(iUndead):
  2020.                     pUnit.setHasPromotion(iStrong, True)
  2021.  
  2022.         elif iBuildingType == gc.getInfoTypeForString('BUILDING_TEMPLE_OF_THE_HAND'):
  2023.             iSnow = gc.getInfoTypeForString('TERRAIN_SNOW')
  2024.             iFlames = gc.getInfoTypeForString('FEATURE_FLAMES')
  2025.             iFloodPlains = gc.getInfoTypeForString('FEATURE_FLOOD_PLAINS')
  2026.             iForest = gc.getInfoTypeForString('FEATURE_FOREST')
  2027.             iJungle = gc.getInfoTypeForString('FEATURE_JUNGLE')
  2028.             iScrub = gc.getInfoTypeForString('FEATURE_SCRUB')
  2029.             iSmoke = gc.getInfoTypeForString('IMPROVEMENT_SMOKE')
  2030.             iBlizzard = gc.getInfoTypeForString('FEATURE_BLIZZARD')
  2031.             iX = pCity.getX()
  2032.             iY = pCity.getY()
  2033.             for iiX in range(iX-2, iX+3, 1):
  2034.                 for iiY in range(iY-2, iY+3, 1):
  2035.                     pLoopPlot = CyMap().plot(iiX,iiY)
  2036.                     if not pLoopPlot.isNone():
  2037.                         if not pLoopPlot.isWater():
  2038.                             pLoopPlot.setTerrainType(iSnow, True, True)
  2039.                             if pLoopPlot.getImprovementType() == iSmoke:
  2040.                                 pLoopPlot.setImprovementType(-1)
  2041.                             iFeature = pLoopPlot.getFeatureType()
  2042.                             if iFeature == iForest:
  2043.                                 pLoopPlot.setFeatureType(iForest, 2)
  2044.                             if iFeature == iJungle:
  2045.                                 pLoopPlot.setFeatureType(iForest, 2)
  2046.                             if iFeature == iFlames:
  2047.                                 pLoopPlot.setFeatureType(-1, -1)
  2048.                             if iFeature == iFloodPlains:
  2049.                                 pLoopPlot.setFeatureType(-1, -1)
  2050.                             if iFeature == iScrub:
  2051.                                 pLoopPlot.setFeatureType(-1, -1)
  2052.                             if CyGame().getSorenRandNum(100, "Snowfall") < 2:
  2053.                                 pLoopPlot.setFeatureType(iBlizzard, -1)
  2054.             CyEngine().triggerEffect(gc.getInfoTypeForString('EFFECT_SNOWFALL'),pPlot.getPoint())
  2055.  
  2056.         elif iBuildingType == gc.getInfoTypeForString('BUILDING_GRAND_MENAGERIE'):
  2057.             if pPlayer.isHuman():
  2058.                 if not CyGame().getWBMapScript():
  2059.                     t = "TROPHY_FEAT_GRAND_MENAGERIE"
  2060.                     if not CyGame().isHasTrophy(t):
  2061.                         CyGame().changeTrophyValue(t, 1)
  2062.  
  2063.         CvAdvisorUtils.buildingBuiltFeats(pCity, iBuildingType)
  2064.  
  2065.         if (not self.__LOG_BUILDING):
  2066.             return
  2067.         CvUtil.pyPrint('%s was finished by Player %d Civilization %s'
  2068.             %(PyInfo.BuildingInfo(iBuildingType).getDescription(), pCity.getOwner(), gc.getPlayer(pCity.getOwner()).getCivilizationDescription(0)))
  2069.  
  2070.     def onProjectBuilt(self, argsList):
  2071.         'Project Completed'
  2072.         pCity, iProjectType = argsList
  2073.         game = gc.getGame()
  2074.         iPlayer = pCity.getOwner()
  2075.         pPlayer = gc.getPlayer(iPlayer)
  2076.         if not gc.getGame().isNetworkMultiPlayer() and pCity.getOwner() == gc.getGame().getActivePlayer():
  2077.     ## Platy Builder ##
  2078.             if not CyGame().GetWorldBuilderMode():
  2079.     ## Platy Builder ##
  2080.                 popupInfo = CyPopupInfo()
  2081.                 popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
  2082.                 popupInfo.setData1(iProjectType)
  2083.                 popupInfo.setData2(pCity.getID())
  2084.                 popupInfo.setData3(2)
  2085.                 popupInfo.setText(u"showWonderMovie")
  2086.                 popupInfo.addPopup(iPlayer)
  2087.  
  2088.         if iProjectType == gc.getInfoTypeForString('PROJECT_BANE_DIVINE'):
  2089.             iCombatDisciple = gc.getInfoTypeForString('UNITCOMBAT_DISCIPLE')
  2090.             for iLoopPlayer in range(gc.getMAX_PLAYERS()):
  2091.                 pLoopPlayer = gc.getPlayer(iLoopPlayer)
  2092.                 if pLoopPlayer.isAlive() :
  2093.                     apUnitList = PyPlayer(iLoopPlayer).getUnitList()
  2094.                     for pUnit in apUnitList:
  2095.                         if pUnit.getUnitCombatType() == iCombatDisciple:
  2096.                             pUnit.kill(False, pCity.getOwner())
  2097.  
  2098.         elif iProjectType == gc.getInfoTypeForString('PROJECT_GENESIS'):
  2099.             if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_ILLIANS'):
  2100.                 cf.snowgenesis(iPlayer)
  2101.             else:
  2102.                 cf.genesis(iPlayer)
  2103.  
  2104.         elif iProjectType == gc.getInfoTypeForString('PROJECT_GLORY_EVERLASTING'):
  2105.             iDemon = gc.getInfoTypeForString('PROMOTION_DEMON')
  2106.             iUndead = gc.getInfoTypeForString('PROMOTION_UNDEAD')
  2107.             for iLoopPlayer in range(gc.getMAX_PLAYERS()):
  2108.                 pLoopPlayer = gc.getPlayer(iLoopPlayer)
  2109.                 player = PyPlayer(iLoopPlayer)
  2110.                 if pLoopPlayer.isAlive():
  2111.                     apUnitList = player.getUnitList()
  2112.                     for pUnit in apUnitList:
  2113.                         if (pUnit.isHasPromotion(iDemon) or pUnit.isHasPromotion(iUndead)):
  2114.                             pUnit.kill(False, iPlayer)
  2115.  
  2116.         elif iProjectType == gc.getInfoTypeForString('PROJECT_RITES_OF_OGHMA'):
  2117.             i = 7
  2118.             iSize = CyMap().getWorldSize()
  2119.             if iSize == gc.getInfoTypeForString('WORLDSIZE_DUEL'):
  2120.                 i -= 3
  2121.             elif iSize == gc.getInfoTypeForString('WORLDSIZE_TINY'):
  2122.                 i =- 2
  2123.             elif iSize == gc.getInfoTypeForString('WORLDSIZE_SMALL'):
  2124.                 i -= 1
  2125.             elif iSize == gc.getInfoTypeForString('WORLDSIZE_LARGE'):
  2126.                 i += 1
  2127.             elif iSize == gc.getInfoTypeForString('WORLDSIZE_HUGE'):
  2128.                 i += 3
  2129.             cf.addBonus('BONUS_MANA',i,'Art/Interface/Buttons/WorldBuilder/mana_button.dds')
  2130.  
  2131.         elif iProjectType == gc.getInfoTypeForString('PROJECT_NATURES_REVOLT'):
  2132.             bPlayer = gc.getPlayer(gc.getBARBARIAN_PLAYER())
  2133.             py = PyPlayer(gc.getBARBARIAN_PLAYER())
  2134.             iAxeman = gc.getInfoTypeForString('UNITCLASS_AXEMAN')
  2135.             iBear = gc.getInfoTypeForString('UNIT_BEAR')
  2136.             iHeroicDefense = gc.getInfoTypeForString('PROMOTION_HEROIC_DEFENSE')
  2137.             iHeroicDefense2 = gc.getInfoTypeForString('PROMOTION_HEROIC_DEFENSE2')
  2138.             iHeroicStrength = gc.getInfoTypeForString('PROMOTION_HEROIC_STRENGTH')
  2139.             iHeroicStrength2 = gc.getInfoTypeForString('PROMOTION_HEROIC_STRENGTH2')
  2140.             iHunter = gc.getInfoTypeForString('UNITCLASS_HUNTER')
  2141.             iLion = gc.getInfoTypeForString('UNIT_LION')
  2142.             iScout = gc.getInfoTypeForString('UNITCLASS_SCOUT')
  2143.             iTiger = gc.getInfoTypeForString('UNIT_TIGER')
  2144.             iWarrior = gc.getInfoTypeForString('UNITCLASS_WARRIOR')
  2145.             iWolf = gc.getInfoTypeForString('UNIT_WOLF')
  2146.             iWorker = gc.getInfoTypeForString('UNITCLASS_WORKER')
  2147.             for pUnit in py.getUnitList():
  2148.                 bValid = False
  2149.                 if pUnit.getUnitClassType() == iWorker:
  2150.                     iNewUnit = iWolf
  2151.                     bValid = True
  2152.                 elif pUnit.getUnitClassType() == iScout:
  2153.                     iNewUnit = iLion
  2154.                     bValid = True
  2155.                 elif pUnit.getUnitClassType() == iWarrior:
  2156.                     iNewUnit = iLion
  2157.                     bValid = True
  2158.                 elif pUnit.getUnitClassType() == iHunter:
  2159.                     iNewUnit = iTiger
  2160.                     bValid = True
  2161.                 elif pUnit.getUnitClassType() == iAxeman:
  2162.                     iNewUnit = iBear
  2163.                     bValid = True
  2164.                 if bValid:
  2165.                     newUnit = bPlayer.initUnit(iNewUnit, pUnit.getX(), pUnit.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
  2166.                     newUnit = bPlayer.initUnit(iNewUnit, pUnit.getX(), pUnit.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
  2167.                     newUnit = bPlayer.initUnit(iNewUnit, pUnit.getX(), pUnit.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
  2168.                     pUnit.kill(True, PlayerTypes.NO_PLAYER)
  2169.             for iLoopPlayer in range(gc.getMAX_PLAYERS()):
  2170.                 pLoopPlayer = gc.getPlayer(iLoopPlayer)
  2171.                 if pLoopPlayer.isAlive():
  2172.                     py = PyPlayer(iLoopPlayer)
  2173.                     for pUnit in py.getUnitList():
  2174.                         if pUnit.isAnimal():
  2175.                             pUnit.setHasPromotion(iHeroicDefense, True)
  2176.                             pUnit.setHasPromotion(iHeroicDefense2, True)
  2177.                             pUnit.setHasPromotion(iHeroicStrength, True)
  2178.                             pUnit.setHasPromotion(iHeroicStrength2, True)
  2179.  
  2180.         elif iProjectType == gc.getInfoTypeForString('PROJECT_BLOOD_OF_THE_PHOENIX'):
  2181.             py = PyPlayer(iPlayer)
  2182.             apUnitList = py.getUnitList()
  2183.             for pUnit in apUnitList:
  2184.                 if pUnit.isAlive():
  2185.                     if pUnit.getUnitCombatType() != UnitCombatTypes.NO_UNITCOMBAT:
  2186.                         pUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_IMMORTAL'), True)
  2187.  
  2188.         elif iProjectType == gc.getInfoTypeForString('PROJECT_PURGE_THE_UNFAITHFUL'):
  2189.             for pyCity in PyPlayer(iPlayer).getCityList():
  2190.                 pCity2 = pyCity.GetCy()
  2191.                 iRnd = CyGame().getSorenRandNum(2, "Bob")
  2192.                 StateBelief = pPlayer.getStateReligion()
  2193.                 if StateBelief == gc.getInfoTypeForString('RELIGION_THE_ORDER'):
  2194.                     iRnd = iRnd - 1
  2195.                 for iTarget in range(gc.getNumReligionInfos()):
  2196.                     if (StateBelief != iTarget and pCity2.isHasReligion(iTarget) and pCity2.isHolyCityByType(iTarget) == False):
  2197.                         pCity2.setHasReligion(iTarget, False, True, True)
  2198.                         iRnd = iRnd + 1
  2199.                         for i in range(gc.getNumBuildingInfos()):
  2200.                             if gc.getBuildingInfo(i).getPrereqReligion() == iTarget:
  2201.                                 pCity2.setNumRealBuilding(i, 0)
  2202.                 if iRnd > 0:
  2203.                     pCity2.setOccupationTimer(iRnd)
  2204.  
  2205.         elif iProjectType == gc.getInfoTypeForString('PROJECT_BIRTHRIGHT_REGAINED'):
  2206.             pPlayer.setFeatAccomplished(FeatTypes.FEAT_GLOBAL_SPELL, False)
  2207.  
  2208.         elif iProjectType == gc.getInfoTypeForString('PROJECT_SAMHAIN'):
  2209.             for pyCity in PyPlayer(iPlayer).getCityList():
  2210.                 pCity = pyCity.GetCy()
  2211.                 pCity.changeHappinessTimer(20)
  2212.             iCount = CyGame().countCivPlayersAlive() + int(CyGame().getHandicapType()) - 5
  2213.             for i in range(iCount):
  2214.                 cf.addUnit(gc.getInfoTypeForString('UNIT_FROSTLING'))
  2215.                 cf.addUnit(gc.getInfoTypeForString('UNIT_FROSTLING'))
  2216.                 cf.addUnit(gc.getInfoTypeForString('UNIT_FROSTLING_ARCHER'))
  2217.                 cf.addUnit(gc.getInfoTypeForString('UNIT_FROSTLING_WOLF_RIDER'))
  2218.             cf.addUnit(gc.getInfoTypeForString('UNIT_MOKKA'))
  2219.  
  2220.         elif iProjectType == gc.getInfoTypeForString('PROJECT_THE_WHITE_HAND'):
  2221.             newUnit1 = pPlayer.initUnit(gc.getInfoTypeForString('UNIT_PRIEST_OF_WINTER'), pCity.getX(), pCity.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
  2222.             newUnit1.setName("Dumannios")
  2223.             newUnit2 = pPlayer.initUnit(gc.getInfoTypeForString('UNIT_PRIEST_OF_WINTER'), pCity.getX(), pCity.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
  2224.             newUnit2.setName("Riuros")
  2225.             newUnit3 = pPlayer.initUnit(gc.getInfoTypeForString('UNIT_PRIEST_OF_WINTER'), pCity.getX(), pCity.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
  2226.             newUnit3.setName("Anagantios")
  2227.  
  2228.         elif iProjectType == gc.getInfoTypeForString('PROJECT_THE_DEEPENING'):
  2229.             iDesert = gc.getInfoTypeForString('TERRAIN_DESERT')
  2230.             iGrass = gc.getInfoTypeForString('TERRAIN_GRASS')
  2231.             iMarsh = gc.getInfoTypeForString('TERRAIN_MARSH')
  2232.             iPlains = gc.getInfoTypeForString('TERRAIN_PLAINS')
  2233.             iSnow = gc.getInfoTypeForString('TERRAIN_SNOW')
  2234.             iTundra = gc.getInfoTypeForString('TERRAIN_TUNDRA')
  2235.             iBlizzard = gc.getInfoTypeForString('FEATURE_BLIZZARD')
  2236.             iModifier = (gc.getGameSpeedInfo(CyGame().getGameSpeedType()).getVictoryDelayPercent() * 20) / 100
  2237.             iTimer = 40 + iModifier
  2238.             for i in range (CyMap().numPlots()):
  2239.                 pPlot = CyMap().plotByIndex(i)
  2240.                 bValid = False
  2241.                 if pPlot.isWater() == False:
  2242.                     if CyGame().getSorenRandNum(100, "The Deepening") < 25:
  2243.                         iTerrain = pPlot.getTerrainType()
  2244.                         chance = CyGame().getSorenRandNum(100, "Bob")
  2245.                         if iTerrain == iSnow:
  2246.                             bValid = True
  2247.                         elif iTerrain == iTundra:
  2248.                             pPlot.setTempTerrainType(iSnow, CyGame().getSorenRandNum(iTimer, "Bob") + 10)
  2249.                             bValid = True
  2250.                         elif iTerrain == iGrass or iTerrain == iMarsh:
  2251.                             if chance < 40:
  2252.                                 pPlot.setTempTerrainType(iSnow, CyGame().getSorenRandNum(iTimer, "Bob") + 10)
  2253.                             else:
  2254.                                 pPlot.setTempTerrainType(iTundra, CyGame().getSorenRandNum(iTimer, "Bob") + 10)
  2255.                             bValid = True
  2256.                         elif iTerrain == iPlains:
  2257.                             if chance < 60:
  2258.                                 pPlot.setTempTerrainType(iSnow, CyGame().getSorenRandNum(iTimer, "Bob") + 10)
  2259.                             else:
  2260.                                 pPlot.setTempTerrainType(iTundra, CyGame().getSorenRandNum(iTimer, "Bob") + 10)
  2261.                             bValid = True
  2262.                         elif iTerrain == iDesert:
  2263.                             if chance < 10:
  2264.                                 pPlot.setTempTerrainType(iSnow, CyGame().getSorenRandNum(iTimer, "Bob") + 10)
  2265.                             elif chance < 30:
  2266.                                 pPlot.setTempTerrainType(iTundra, CyGame().getSorenRandNum(iTimer, "Bob") + 10)
  2267.                             else:
  2268.                                 pPlot.setTempTerrainType(iPlains, CyGame().getSorenRandNum(iTimer, "Bob") + 10)
  2269.                         if bValid:
  2270.                             if CyGame().getSorenRandNum(750, "The Deepening") < 10:
  2271.                                 pPlot.setFeatureType(iBlizzard,-1)
  2272.  
  2273.         elif iProjectType == gc.getInfoTypeForString('PROJECT_STIR_FROM_SLUMBER'):
  2274.             pPlayer.initUnit(gc.getInfoTypeForString('UNIT_DRIFA'), pCity.getX(), pCity.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
  2275.  
  2276.         elif iProjectType == gc.getInfoTypeForString('PROJECT_THE_DRAW'):
  2277.             iTeam = pPlayer.getTeam()
  2278.             eTeam = gc.getTeam(iTeam)
  2279.             for iLoopPlayer in range(gc.getMAX_PLAYERS()):
  2280.                 pLoopPlayer = gc.getPlayer(iLoopPlayer)
  2281.                 if pLoopPlayer.isAlive() and pLoopPlayer.getTeam() == iTeam:
  2282.                     pLoopPlayer.changeNoDiplomacyWithEnemies(1)
  2283.             for iLoopTeam in range(gc.getMAX_TEAMS()):
  2284.                 if iLoopTeam != iTeam:
  2285.                     if iLoopTeam != gc.getPlayer(gc.getBARBARIAN_PLAYER()).getTeam():
  2286.                         eLoopTeam = gc.getTeam(iLoopTeam)
  2287.                         if eLoopTeam.isAlive():
  2288.                             if not eLoopTeam.isAVassal():
  2289.                                 eTeam.declareWar(iLoopTeam, False, WarPlanTypes.WARPLAN_LIMITED)
  2290.             py = PyPlayer(iPlayer)
  2291.             for pUnit in py.getUnitList():
  2292.                 iDmg = pUnit.getDamage() * 2
  2293.                 if iDmg > 99:
  2294.                     iDmg = 99
  2295.                 if iDmg < 50:
  2296.                     iDmg = 50
  2297.                 pUnit.setDamage(iDmg, iPlayer)
  2298.             for pyCity in PyPlayer(iPlayer).getCityList():
  2299.                 pLoopCity = pyCity.GetCy()
  2300.                 iPop = int(pLoopCity.getPopulation() / 2)
  2301.                 if iPop < 1:
  2302.                     iPop = 1
  2303.                 pLoopCity.setPopulation(iPop)
  2304.  
  2305.         elif iProjectType == gc.getInfoTypeForString('PROJECT_ASCENSION'):
  2306.             pAuricUnit = pPlayer.initUnit(gc.getInfoTypeForString('UNIT_AURIC_ASCENDED'), pCity.getX(), pCity.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
  2307.             pAuricUnit.setAvatarOfCivLeader(True)
  2308.             if pPlayer.isHuman():
  2309.                 t = "TROPHY_FEAT_ASCENSION"
  2310.                 if not CyGame().isHasTrophy(t):
  2311.                     CyGame().changeTrophyValue(t, 1)
  2312.             if not CyGame().getWBMapScript():
  2313.                 iBestPlayer = -1
  2314.                 iBestValue = 0
  2315.                 for iLoopPlayer in range(gc.getMAX_PLAYERS()):
  2316.                     pLoopPlayer = gc.getPlayer(iLoopPlayer)
  2317.                     if pLoopPlayer.isAlive():
  2318.                         if not pLoopPlayer.isBarbarian():
  2319.                             if pLoopPlayer.getTeam() != pPlayer.getTeam():
  2320.                                 iValue = CyGame().getSorenRandNum(500, "Ascension")
  2321.                                 if pLoopPlayer.isHuman():
  2322.                                     iValue += 2000
  2323.                                 iValue += (20 - CyGame().getPlayerRank(iLoopPlayer)) * 50
  2324.                                 if iValue > iBestValue:
  2325.                                     iBestValue = iValue
  2326.                                     iBestPlayer = iLoopPlayer
  2327.                 if iBestPlayer != -1:
  2328.                     pBestPlayer = gc.getPlayer(iBestPlayer)
  2329.                     pBestCity = pBestPlayer.getCapitalCity()
  2330.                     if pBestPlayer.isHuman():
  2331.                         iEvent = CvUtil.findInfoTypeNum(gc.getEventTriggerInfo, gc.getNumEventTriggerInfos(),'EVENTTRIGGER_GODSLAYER')
  2332.                         triggerData = gc.getPlayer(iBestPlayer).initTriggeredData(iEvent, True, -1, pBestCity.getX(), pBestCity.getY(), iBestPlayer, -1, -1, -1, -1, -1)
  2333.                     else:
  2334.                         pBestPlayer.initUnit(gc.getInfoTypeForString('EQUIPMENT_GODSLAYER'), pBestCity.getX(), pBestCity.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
  2335.  
  2336.         elif iProjectType == gc.getInfoTypeForString('PROJECT_PACT_OF_THE_NILHORN'):
  2337.             newUnit1 = pPlayer.initUnit(gc.getInfoTypeForString('UNIT_HILL_GIANT'), pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_ATTACK, DirectionTypes.DIRECTION_NORTH)
  2338.             newUnit1.setName("Larry")
  2339.             newUnit1.AI_setGroupflag(10)
  2340.             newUnit1.setUnitAIType(gc.getInfoTypeForString('UNITAI_ATTACK_CITY'))
  2341.             newUnit2 = pPlayer.initUnit(gc.getInfoTypeForString('UNIT_HILL_GIANT'), pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_ATTACK, DirectionTypes.DIRECTION_NORTH)
  2342.             newUnit2.setName("Curly")
  2343.             newUnit2.AI_setGroupflag(10)
  2344.             newUnit2.setUnitAIType(gc.getInfoTypeForString('UNITAI_ATTACK_CITY'))
  2345.             newUnit3 = pPlayer.initUnit(gc.getInfoTypeForString('UNIT_HILL_GIANT'), pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_ATTACK, DirectionTypes.DIRECTION_NORTH)
  2346.             newUnit3.setName("Moe")
  2347.             newUnit3.AI_setGroupflag(10)
  2348.             newUnit3.setUnitAIType(gc.getInfoTypeForString('UNITAI_ATTACK_CITY'))
  2349.  
  2350. #some AI help
  2351.             if pPlayer.isHuman():
  2352.                 newUnit1.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HIDDEN_NATIONALITY'), True)
  2353.                 newUnit2.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HIDDEN_NATIONALITY'), True)
  2354.                 newUnit3.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HIDDEN_NATIONALITY'), True)
  2355.  
  2356.  
  2357.  
  2358.     def onSelectionGroupPushMission(self, argsList):
  2359.         'selection group mission'
  2360.         eOwner = argsList[0]
  2361.         eMission = argsList[1]
  2362.         iNumUnits = argsList[2]
  2363.         listUnitIds = argsList[3]
  2364.         if not self.__LOG_PUSH_MISSION:
  2365.             return
  2366.         if pHeadUnit:
  2367.             CvUtil.pyPrint("Selection Group pushed mission %d" %(eMission))
  2368.  
  2369.     def onUnitMove(self, argsList):
  2370.         'unit move'
  2371.         pPlot,pUnit,pOldPlot = argsList
  2372.         player = PyPlayer(pUnit.getOwner())
  2373.         unitInfo = PyInfo.UnitInfo(pUnit.getUnitType())
  2374.         if not self.__LOG_MOVEMENT:
  2375.             return
  2376.         if player and unitInfo:
  2377.             CvUtil.pyPrint('Player %d Civilization %s unit %s is moving to %d, %d'
  2378.                 %(player.getID(), player.getCivilizationName(), unitInfo.getDescription(),
  2379.                 pUnit.getX(), pUnit.getY()))
  2380.  
  2381.     def onUnitSetXY(self, argsList):
  2382.         'units xy coords set manually'
  2383.         pPlot,pUnit = argsList
  2384.         player = PyPlayer(pUnit.getOwner())
  2385.         unitInfo = PyInfo.UnitInfo(pUnit.getUnitType())
  2386.         if not self.__LOG_MOVEMENT:
  2387.             return
  2388.  
  2389.     def onUnitCreated(self, argsList):
  2390.     ## Platy Builder ##
  2391.         if CyGame().GetWorldBuilderMode() and not CvPlatyBuilderScreen.bPython: return
  2392.     ## Platy Builder ##
  2393.         'Unit Completed'
  2394.         unit = argsList[0]
  2395.         player = PyPlayer(unit.getOwner())
  2396.         pPlayer = gc.getPlayer(unit.getOwner())
  2397.         iChanneling2 = gc.getInfoTypeForString('PROMOTION_CHANNELING2')
  2398.         iChanneling3 = gc.getInfoTypeForString('PROMOTION_CHANNELING3')
  2399.  
  2400.         if unit.getUnitCombatType() == gc.getInfoTypeForString('UNITCOMBAT_ADEPT'):
  2401.             lCheckThis = ['AIR', 'BODY', 'CHAOS', 'EARTH', 'ENCHANTMENT', 'ENTROPY', 'FIRE', 'ICE', 'LAW', 'LIFE', 'METAMAGIC', 'MIND', 'NATURE', 'SHADOW', 'SPIRIT', 'SUN', 'WATER']
  2402.             for item in lCheckThis:
  2403.                 iNum = pPlayer.getNumAvailableBonuses(gc.getInfoTypeForString('BONUS_MANA_' + item))
  2404.                 if iNum > 1:
  2405.                     unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_' + item + '1'), True)
  2406.                     if (iNum > 2 and unit.isHasPromotion(iChanneling2)):
  2407.                         unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_' + item + '2'), True)
  2408.                         if (iNum > 3 and unit.isHasPromotion(iChanneling3)):
  2409.                             unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_' + item + '3'), True)
  2410.  
  2411.         if unit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_ELEMENTAL')):
  2412.             if pPlayer.getNumBuilding(gc.getInfoTypeForString('BUILDING_TOWER_OF_THE_ELEMENTS')) > 0:
  2413.                 unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_STRONG'), True)
  2414.  
  2415.         if unit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_UNDEAD')):
  2416.             if pPlayer.getNumBuilding(gc.getInfoTypeForString('BUILDING_TOWER_OF_NECROMANCY')) > 0:
  2417.                 unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_STRONG'), True)
  2418.  
  2419. #UNITAI for Adepts and Terraformers
  2420.         if not pPlayer.isHuman() and not pPlayer.isBarbarian():
  2421.             if unit.getUnitType() == gc.getInfoTypeForString('UNIT_DEVOUT'):
  2422.                 numberterraformer = 0
  2423.                 for pUnit in player.getUnitList():
  2424.                     if pUnit.getUnitType() == gc.getInfoTypeForString('UNIT_DEVOUT'):
  2425.                         if pUnit.getUnitAIType() == gc.getInfoTypeForString('UNITAI_TERRAFORMER'):
  2426.                             numberterraformer += 1
  2427.                 if numberterraformer < pPlayer.getNumCities()*CyGame().getGlobalCounter()/100:
  2428.                     unit.setUnitAIType(gc.getInfoTypeForString('UNITAI_TERRAFORMER'))
  2429.                 elif numberterraformer < 3:
  2430.                     unit.setUnitAIType(gc.getInfoTypeForString('UNITAI_TERRAFORMER'))
  2431.  
  2432.             numTreeTerraformer=0
  2433.             if unit.getUnitType() == gc.getInfoTypeForString('UNIT_PRIEST_OF_LEAVES'):
  2434.                 neededTreeTerraformer = 1
  2435.                 if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LJOSALFAR') or pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_SVARTALFAR'):
  2436.                     neededTreeTerraformer += pPlayer.getNumCities()/3
  2437.                 for pUnit in player.getUnitList():
  2438.                     if pUnit.getUnitType() == gc.getInfoTypeForString('UNIT_PRIEST_OF_LEAVES'):
  2439.                         if pUnit.getUnitAIType() == gc.getInfoTypeForString('UNITAI_TERRAFORMER'):
  2440.                             numTreeTerraformer += 1
  2441.                 if numTreeTerraformer < neededTreeTerraformer:
  2442.                     unit.setUnitAIType(gc.getInfoTypeForString('UNITAI_TERRAFORMER'))
  2443.  
  2444.             if unit.getUnitClassType() == gc.getInfoTypeForString('UNITCLASS_ADEPT'):
  2445.  
  2446.                 bCanMageTerraform = False
  2447.                 if pPlayer.countOwnedBonuses(gc.getInfoTypeForString('BONUS_MANA_WATER'), False) > 0:
  2448.                     bCanMageTerraform = True
  2449.                 elif pPlayer.countOwnedBonuses(gc.getInfoTypeForString('BONUS_MANA_SUN'), False) > 0:
  2450.                     bCanMageTerraform = True
  2451.  
  2452.                 numbermageterrafomer = (pPlayer.AI_getNumAIUnits(gc.getInfoTypeForString('UNITAI_TERRAFORMER')) - numTreeTerraformer)
  2453.                 numbermanaupgrade = pPlayer.AI_getNumAIUnits(gc.getInfoTypeForString('UNITAI_MANA_UPGRADE'))
  2454.  
  2455.                 bHasAI = False
  2456.                 canupgrademana = False
  2457.  
  2458.                 if pPlayer.isHasTech(gc.getInfoTypeForString('TECH_SORCERY')):
  2459.                     canupgrademana=True
  2460.                 elif pPlayer.isHasTech(gc.getInfoTypeForString('TECH_ALTERATION')):
  2461.                     canupgrademana=True
  2462.                 elif pPlayer.isHasTech(gc.getInfoTypeForString('TECH_DIVINATION')):
  2463.                     canupgrademana=True
  2464.                 elif pPlayer.isHasTech(gc.getInfoTypeForString('TECH_ELEMENTALISM')):
  2465.                     canupgrademana=True
  2466.                 elif pPlayer.isHasTech(gc.getInfoTypeForString('TECH_NECROMANCY')):
  2467.                     canupgrademana=True
  2468.  
  2469.  
  2470.                 if numbermanaupgrade == 0:
  2471.                     unit.setUnitAIType(gc.getInfoTypeForString('UNITAI_MANA_UPGRADE'))
  2472.                     bHasAI = True
  2473.                 if canupgrademana:
  2474.                     if pPlayer.countOwnedBonuses(gc.getInfoTypeForString('BONUS_MANA'), False) > numbermanaupgrade * 2:
  2475.                         unit.setUnitAIType(gc.getInfoTypeForString('UNITAI_MANA_UPGRADE'))
  2476.                         bHasAI = True
  2477.  
  2478.                 if not bHasAI:
  2479.                     if bCanMageTerraform:
  2480.                         if numbermageterrafomer < 2:
  2481.                             unit.setUnitAIType(gc.getInfoTypeForString('UNITAI_TERRAFORMER'))
  2482.                             bHasAI = True
  2483.  
  2484.                 if not bHasAI:
  2485.                     pPlot = unit.plot()
  2486.                     if pPlayer.AI_getNumAIUnits(gc.getInfoTypeForString('UNITAI_MAGE')) < pPlayer.getNumCities() / 2:
  2487.                         unit.setUnitAIType(gc.getInfoTypeForString('UNITAI_MAGE'))
  2488.                     elif pPlot.area().getAreaAIType(pPlayer.getTeam()) == AreaAITypes.AREAAI_DEFENSIVE:
  2489.                         unit.setUnitAIType(gc.getInfoTypeForString('UNITAI_MAGE'))
  2490.                     else:
  2491.                         unit.setUnitAIType(gc.getInfoTypeForString('UNITAI_WARWIZARD'))
  2492.  
  2493.         if CyGame().getWBMapScript():
  2494.             sf.onUnitCreated(unit)
  2495.  
  2496.         if not self.__LOG_UNITBUILD:
  2497.             return
  2498.  
  2499.     def onUnitBuilt(self, argsList):
  2500.         'Unit Completed'
  2501.         city = argsList[0]
  2502.         unit = argsList[1]
  2503.         player = PyPlayer(city.getOwner())
  2504.         pPlayer = gc.getPlayer(unit.getOwner())
  2505.  
  2506.         # Advanced Tactics - Diverse Grigori (idea and base code taken from FFH Tweakmod)
  2507.         if gc.getGame().isOption(GameOptionTypes.GAMEOPTION_ADVANCED_TACTICS):
  2508.             if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_GRIGORI'):
  2509.                 unit.setReligion(-1)
  2510.                 if unit.getRace() == -1:
  2511.                     iChance = 40
  2512.                     if CyGame().getSorenRandNum(100, "Grigori Racial Diversity") <= iChance:
  2513.                         race = CyGame().getSorenRandNum(3, "Bob")
  2514.                         if race == 0 and unit.isAlive():
  2515.                             unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_ORC'), True)
  2516.                         elif race == 1 and unit.isAlive():
  2517.                             race = CyGame().getSorenRandNum(2, "Elvish division")
  2518.                             if race == 0:
  2519.                                 unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_ELF'), True)
  2520.                             elif race == 1:
  2521.                                 unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_DARK_ELF'), True)
  2522.                         elif race == 2:
  2523.                             if (unit.isAlive()):
  2524.                                 unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_DWARF'), True)
  2525.         # End Advanced Tactics
  2526.  
  2527.         if unit.getUnitType() == gc.getInfoTypeForString('UNIT_BEAST_OF_AGARES'):
  2528.             if city.getCivilizationType() != gc.getInfoTypeForString('CIVILIZATION_INFERNAL'):
  2529.                 iPop = city.getPopulation() - 4
  2530.                 if iPop <= 1:
  2531.                     iPop = 1
  2532.                 city.setPopulation(iPop)
  2533.                 city.setOccupationTimer(4)
  2534.  
  2535.         elif unit.getUnitType() == gc.getInfoTypeForString('UNIT_ACHERON'):
  2536.             unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), True)
  2537.             city.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_THE_DRAGONS_HORDE'), 1)
  2538.             iX = city.getX()
  2539.             iY = city.getY()
  2540.             for iiX in range(iX-1, iX+2, 1):
  2541.                 for iiY in range(iY-1, iY+2, 1):
  2542.                     pPlot = CyMap().plot(iiX,iiY)
  2543.                     if (pPlot.getFeatureType() == gc.getInfoTypeForString('FEATURE_FOREST') or pPlot.getFeatureType() == gc.getInfoTypeForString('FEATURE_JUNGLE')):
  2544.                         pPlot.setFeatureType(gc.getInfoTypeForString('FEATURE_FLAMES'), 0)
  2545.             if( game.getAIAutoPlay(game.getActivePlayer()) == 0 ) :
  2546.                 cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_ACHERON_CREATION",()), str(gc.getUnitInfo(unit.getUnitType()).getImage()))
  2547.  
  2548.         if city.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_WARRENS')) > 0:
  2549.             if isWorldUnitClass(unit.getUnitClassType()) == False:
  2550.                 if isNationalUnitClass(unit.getUnitClassType()) == False:
  2551.                     if not unit.isMechUnit():
  2552. #                       if unit.getUnitCombatType() != UnitCombatTypes.NO_UNITCOMBAT:
  2553.                         if unit.isAlive():
  2554.                             newUnit = pPlayer.initUnit(unit.getUnitType(), city.getX(), city.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
  2555.                             city.applyBuildEffects(newUnit)
  2556.  
  2557.         CvAdvisorUtils.unitBuiltFeats(city, unit)
  2558.  
  2559.         if not self.__LOG_UNITBUILD:
  2560.             return
  2561.         CvUtil.pyPrint('%s was finished by Player %d Civilization %s'
  2562.             %(PyInfo.UnitInfo(unit.getUnitType()).getDescription(), player.getID(), player.getCivilizationName()))
  2563.            
  2564.    
  2565.         #I need to redo the teamID's because they are forgotten from onGameStart
  2566.         for iGoodAndEvilPlayer in range(gc.getMAX_PLAYERS()):
  2567.             pGoodAndEvilPlayer = gc.getPlayer(iGoodAndEvilPlayer)
  2568.             #if pGoodAndEvilPlayer.isAlive(): #This line breaks the code
  2569.             if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_BANNOR'):
  2570.                 iBannorTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  2571.             if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_CALABIM'):
  2572.                 iCalabimTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  2573.             if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_CLAN_OF_EMBERS'):
  2574.                 iClanOfEmbersTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  2575.             if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_DOVIELLO'):
  2576.                 iDovielloTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  2577.             if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_ELOHIM'):
  2578.                 iElohimTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  2579.             if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_KURIOTATES'):
  2580.                 iKuriotatesTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  2581.             if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LJOSALFAR'):
  2582.                 iLjosalfarTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  2583.             if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LUCHUIRP'):
  2584.                 iLuchuirpTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  2585.             if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_SHEAIM'):
  2586.                 iSheaimTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  2587.             if pGoodAndEvilPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_SVARTALFAR'):
  2588.                 iSvartalfarTeamID = gc.getPlayer(iGoodAndEvilPlayer).getTeam()
  2589.  
  2590.        
  2591.         #Give units the Stack of Doom (SoD) promotion between certain turns#
  2592.         if CyGame().getGameTurn() >= 5 and CyGame().getGameTurn() < 30:
  2593.             if gc.getTeam(iBannorTeamID).isAlive:
  2594.                 if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_BANNOR'):
  2595.                     unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_SofD'), True)
  2596.             if gc.getTeam(iElohimTeamID).isAlive:
  2597.                 if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_ELOHIM'):
  2598.                     unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_SofD'), True)
  2599.             if gc.getTeam(iKuriotatesTeamID).isAlive:
  2600.                 if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_KURIOTATES'):
  2601.                     unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_SofD'), True)
  2602.             if gc.getTeam(iLjosalfarTeamID).isAlive:
  2603.                 if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LJOSALFAR'):
  2604.                     unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_SofD'), True)
  2605.             #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
  2606.             if gc.getTeam(iLuchuirpTeamID).isAlive:
  2607.                 if not gc.getTeam(iLuchuirpTeamID).isAtWar(iElohimTeamID):
  2608.                     if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LUCHUIRP'):
  2609.                         unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_SofD'), True)
  2610.  
  2611.                        
  2612.     def onUnitKilled(self, argsList):
  2613.         'Unit Killed'
  2614.         unit, iAttacker = argsList
  2615.         iPlayer = unit.getOwner()
  2616.         pPlayer = gc.getPlayer(iPlayer)
  2617.         player = PyPlayer(iPlayer)
  2618.         attacker = PyPlayer(iAttacker)
  2619.         pPlot = unit.plot()
  2620.         iX = unit.getX()
  2621.         iY = unit.getY()
  2622.  
  2623.         if unit.isAlive() and not unit.isImmortal():
  2624.             iSoulForge = gc.getInfoTypeForString('BUILDING_SOUL_FORGE')
  2625.             if gc.getGame().getBuildingClassCreatedCount(gc.getInfoTypeForString("BUILDINGCLASS_SOUL_FORGE")) > 0:
  2626.                 for iiX in range(iX-1, iX+2, 1):
  2627.                     for iiY in range(iY-1, iY+2, 1):
  2628.                         pPlot2 = CyMap().plot(iiX,iiY)
  2629.                         if pPlot2.isCity():
  2630.                             pCity = pPlot2.getPlotCity()
  2631.                             if pCity.getNumRealBuilding(iSoulForge) > 0:
  2632.                                 pCity.changeProduction(unit.getExperience() + 10)
  2633.                                 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)
  2634.  
  2635.             if pPlot.isCity():
  2636.                 pCity = pPlot.getPlotCity()
  2637.                 if pCity.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_MOKKAS_CAULDRON')) > 0:
  2638.                     if pCity.getOwner() == unit.getOwner():
  2639.                         iUnit = cf.getUnholyVersion(unit)
  2640.                         if iUnit != -1:
  2641.                             newUnit = pPlayer.initUnit(iUnit, pCity.getX(), pCity.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
  2642.                             newUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_DEMON'), True)
  2643.                             newUnit.setDamage(50, PlayerTypes.NO_PLAYER)
  2644.                             newUnit.finishMoves()
  2645.                             szBuffer = gc.getUnitInfo(newUnit.getUnitType()).getDescription()
  2646.                             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)
  2647.  
  2648.             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'))):
  2649.                 cf.giftUnit(gc.getInfoTypeForString('UNIT_MANES'), gc.getInfoTypeForString('CIVILIZATION_INFERNAL'), 0, unit.plot(), unit.getOwner())
  2650.                 cf.giftUnit(gc.getInfoTypeForString('UNIT_MANES'), gc.getInfoTypeForString('CIVILIZATION_INFERNAL'), 0, unit.plot(), unit.getOwner())
  2651.             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'))):
  2652.                 cf.giftUnit(gc.getInfoTypeForString('UNIT_ANGEL'), gc.getInfoTypeForString('CIVILIZATION_MERCURIANS'), unit.getExperience(), unit.plot(), unit.getOwner())
  2653.  
  2654.             if unit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_SPIRIT_GUIDE')):
  2655.                 if unit.getExperience() > 0:
  2656.                     py = PyPlayer(iPlayer)
  2657.                     lUnits = []
  2658.                     for pLoopUnit in py.getUnitList():
  2659.                         if pLoopUnit.isAlive():
  2660.                             if not pLoopUnit.isOnlyDefensive():
  2661.                                 if not pLoopUnit.isDelayedDeath():
  2662.                                     lUnits.append(pLoopUnit)
  2663.                     if len(lUnits) > 0:
  2664.                         pUnit = lUnits[CyGame().getSorenRandNum(len(lUnits), "Spirit Guide")-1]
  2665.                         iXP = unit.getExperience() / 2
  2666.                         pUnit.changeExperience(iXP, -1, False, False, False)
  2667. #                       unit.changeExperience(iXP * -1, -1, False, False, False)
  2668.                         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)
  2669.  
  2670.         if unit.getUnitType() == gc.getInfoTypeForString('UNIT_ACHERON'):
  2671.             unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HELD'), False)
  2672.  
  2673.         if CyGame().getWBMapScript():
  2674.             sf.onUnitKilled(unit, iAttacker)
  2675.  
  2676. #       if not self.__LOG_UNITKILLED:
  2677. #           return
  2678. #       CvUtil.pyPrint('Player %d Civilization %s Unit %s was killed by Player %d'
  2679. #           %(player.getID(), player.getCivilizationName(), PyInfo.UnitInfo(unit.getUnitType()).getDescription(), attacker.getID()))
  2680.  
  2681.     def onUnitLost(self, argsList):
  2682.     ## Platy Builder ##
  2683.         if CyGame().GetWorldBuilderMode() and not CvPlatyBuilderScreen.bPython: return
  2684.     ## Platy Builder ##
  2685.         'Unit Lost'
  2686.         unit = argsList[0]
  2687.         iPlayer = unit.getOwner()
  2688.         player = PyPlayer(iPlayer)
  2689.         pPlot = unit.plot()
  2690.  
  2691.         if unit.getUnitType() == gc.getInfoTypeForString('UNIT_TREANT'):
  2692.             if pPlot.getFeatureType() == -1:
  2693.                 if pPlot.canHaveFeature(gc.getInfoTypeForString('FEATURE_FOREST_NEW')):
  2694.                     if pPlot.getOwner() == iPlayer:
  2695.                         if CyGame().getSorenRandNum(100, "Treant Spawn Chance") < 50:
  2696.                             pPlot.setFeatureType(gc.getInfoTypeForString('FEATURE_FOREST_NEW'), 0)
  2697.  
  2698.         if not self.__LOG_UNITLOST:
  2699.             return
  2700.         CvUtil.pyPrint('%s was lost by Player %d Civilization %s'
  2701.             %(PyInfo.UnitInfo(unit.getUnitType()).getDescription(), player.getID(), player.getCivilizationName()))
  2702.  
  2703.     def onUnitPromoted(self, argsList):
  2704.         'Unit Promoted'
  2705.         pUnit, iPromotion = argsList
  2706.         if not self.__LOG_UNITPROMOTED:
  2707.             return
  2708.         CvUtil.pyPrint('Unit Promotion Event: %s - %s' %(player.getCivilizationName(), pUnit.getName(),))
  2709.  
  2710.     def onUnitSelected(self, argsList):
  2711.         'Unit Selected'
  2712.         unit = argsList[0]
  2713.         player = PyPlayer(unit.getOwner())
  2714.         if (not self.__LOG_UNITSELECTED):
  2715.             return
  2716.         CvUtil.pyPrint('%s was selected by Player %d Civilization %s'
  2717.             %(PyInfo.UnitInfo(unit.getUnitType()).getDescription(), player.getID(), player.getCivilizationName()))
  2718.  
  2719.     def onUnitRename(self, argsList):
  2720.         'Unit is renamed'
  2721.         pUnit = argsList[0]
  2722.         if (pUnit.getOwner() == gc.getGame().getActivePlayer()):
  2723.             self.__eventEditUnitNameBegin(pUnit)
  2724.  
  2725.     def onUnitPillage(self, argsList):
  2726.         'Unit pillages a plot'
  2727.         pUnit, iImprovement, iRoute, iOwner = argsList
  2728.         iPlotX = pUnit.getX()
  2729.         iPlotY = pUnit.getY()
  2730.         pPlot = CyMap().plot(iPlotX, iPlotY)
  2731.         pPlayer = gc.getPlayer(pUnit.getOwner())
  2732.  
  2733.         if (not self.__LOG_UNITPILLAGE):
  2734.             return
  2735.         CvUtil.pyPrint("Player %d's %s pillaged improvement %d and route %d at plot at (%d, %d)"
  2736.             %(iOwner, PyInfo.UnitInfo(pUnit.getUnitType()).getDescription(), iImprovement, iRoute, iPlotX, iPlotY))
  2737.  
  2738.     def onUnitSpreadReligionAttempt(self, argsList):
  2739.         'Unit tries to spread religion to a city'
  2740.         pUnit, iReligion, bSuccess = argsList
  2741.  
  2742.         iX = pUnit.getX()
  2743.         iY = pUnit.getY()
  2744.         pPlot = CyMap().plot(iX, iY)
  2745.         pCity = pPlot.getPlotCity()
  2746.  
  2747.     def onUnitGifted(self, argsList):
  2748.         'Unit is gifted from one player to another'
  2749.         pUnit, iGiftingPlayer, pPlotLocation = argsList
  2750.  
  2751.     def onUnitBuildImprovement(self, argsList):
  2752.         'Unit begins enacting a Build (building an Improvement or Route)'
  2753.         pUnit, iBuild, bFinished = argsList
  2754.  
  2755.     def onGoodyReceived(self, argsList):
  2756.         'Goody received'
  2757.         iPlayer, pPlot, pUnit, iGoodyType = argsList
  2758.         if (not self.__LOG_GOODYRECEIVED):
  2759.             return
  2760.         CvUtil.pyPrint('%s received a goody' %(gc.getPlayer(iPlayer).getCivilizationDescription(0)),)
  2761.  
  2762.     def onGreatPersonBorn(self, argsList):
  2763.     ## Platy Builder ##
  2764.         if CyGame().GetWorldBuilderMode() and not CvPlatyBuilderScreen.bPython: return
  2765.     ## Platy Builder ##
  2766.         'Unit Promoted'
  2767.         pUnit, iPlayer, pCity = argsList
  2768.         player = PyPlayer(iPlayer)
  2769.         if pUnit.isNone() or pCity.isNone():
  2770.             return
  2771.         if (not self.__LOG_GREATPERSON):
  2772.             return
  2773.         CvUtil.pyPrint('A %s was born for %s in %s' %(pUnit.getName(), player.getCivilizationName(), pCity.getName()))
  2774.  
  2775.     def onTechAcquired(self, argsList):
  2776.     ## Platy Builder ##
  2777.         if CyGame().GetWorldBuilderMode() and not CvPlatyBuilderScreen.bPython: return
  2778.     ## Platy Builder ##
  2779.         'Tech Acquired'
  2780.         iTechType, iTeam, iPlayer, bAnnounce = argsList
  2781.         # Note that iPlayer may be NULL (-1) and not a refer to a player object
  2782.         pPlayer = gc.getPlayer(iPlayer)
  2783.  
  2784.         # Show tech splash when applicable
  2785.         if iPlayer > -1 and bAnnounce and not CyInterface().noTechSplash():
  2786.             if gc.getGame().isFinalInitialized() and not gc.getGame().GetWorldBuilderMode():
  2787.                 if not gc.getGame().isNetworkMultiPlayer() and iPlayer == gc.getGame().getActivePlayer():
  2788.                     popupInfo = CyPopupInfo()
  2789.                     popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
  2790.                     popupInfo.setData1(iTechType)
  2791.                     popupInfo.setText(u"showTechSplash")
  2792.                     popupInfo.addPopup(iPlayer)
  2793.         if iPlayer != -1 and iPlayer != gc.getBARBARIAN_PLAYER():
  2794.             pPlayer = gc.getPlayer(iPlayer)
  2795.             iReligion = -1
  2796.             if iTechType == gc.getInfoTypeForString('TECH_CORRUPTION_OF_SPIRIT'):
  2797.                 iUnit = gc.getInfoTypeForString('UNIT_DISCIPLE_THE_ASHEN_VEIL')
  2798.                 iReligion = gc.getInfoTypeForString('RELIGION_THE_ASHEN_VEIL')
  2799.             elif iTechType == gc.getInfoTypeForString('TECH_ORDERS_FROM_HEAVEN'):
  2800.                 iUnit = gc.getInfoTypeForString('UNIT_DISCIPLE_THE_ORDER')
  2801.                 iReligion = gc.getInfoTypeForString('RELIGION_THE_ORDER')
  2802.             elif iTechType == gc.getInfoTypeForString('TECH_WAY_OF_THE_FORESTS'):
  2803.                 iUnit = gc.getInfoTypeForString('UNIT_DISCIPLE_FELLOWSHIP_OF_LEAVES')
  2804.                 iReligion = gc.getInfoTypeForString('RELIGION_FELLOWSHIP_OF_LEAVES')
  2805.             elif iTechType == gc.getInfoTypeForString('TECH_WAY_OF_THE_EARTHMOTHER'):
  2806.                 iUnit = gc.getInfoTypeForString('UNIT_DISCIPLE_RUNES_OF_KILMORPH')
  2807.                 iReligion = gc.getInfoTypeForString('RELIGION_RUNES_OF_KILMORPH')
  2808.             elif iTechType == gc.getInfoTypeForString('TECH_MESSAGE_FROM_THE_DEEP'):
  2809.                 iUnit = gc.getInfoTypeForString('UNIT_DISCIPLE_OCTOPUS_OVERLORDS')
  2810.                 iReligion = gc.getInfoTypeForString('RELIGION_OCTOPUS_OVERLORDS')
  2811.             elif iTechType == gc.getInfoTypeForString('TECH_HONOR'):
  2812.                 iUnit = gc.getInfoTypeForString('UNIT_DISCIPLE_EMPYREAN')
  2813.                 iReligion = gc.getInfoTypeForString('RELIGION_THE_EMPYREAN')
  2814.             elif iTechType == gc.getInfoTypeForString('TECH_DECEPTION'):
  2815.                 iUnit = gc.getInfoTypeForString('UNIT_NIGHTWATCH')
  2816.                 iReligion = gc.getInfoTypeForString('RELIGION_COUNCIL_OF_ESUS')
  2817.             if iReligion != -1:
  2818.                 if (iReligion==pPlayer.getFavoriteReligion()):
  2819.                     pPlayer.getCapitalCity().setHasReligion(iReligion,True,True,True)  
  2820.                 if CyGame().isReligionFounded(iReligion):
  2821.                     cf.giftUnit(iUnit, pPlayer.getCivilizationType(), 0, -1, -1)
  2822.  
  2823.         if not gc.getGame().isOption(GameOptionTypes.GAMEOPTION_NO_HYBOREM_OR_BASIUM):
  2824.             if iTechType == gc.getInfoTypeForString('TECH_INFERNAL_PACT') and iPlayer != -1:
  2825.                 #iCount = 0
  2826.                 #for iTeam in range(gc.getMAX_TEAMS()):
  2827.                     #pTeam = gc.getTeam(iTeam)
  2828.                     #if pTeam.isHasTech(gc.getInfoTypeForString('TECH_INFERNAL_PACT')):
  2829.                         #iCount = iCount + 1
  2830.                 #if iCount == 1:
  2831.                 if not CyGame().isCivEverActive(gc.getInfoTypeForString('CIVILIZATION_INFERNAL')):
  2832.                     iInfernalPlayer = pPlayer.initNewEmpire(gc.getInfoTypeForString('LEADER_HYBOREM'), gc.getInfoTypeForString('CIVILIZATION_INFERNAL'))
  2833.                     if iInfernalPlayer != PlayerTypes.NO_PLAYER:
  2834.                         pInfernalPlayer = gc.getPlayer(iInfernalPlayer)
  2835.                         pTeam = gc.getTeam(pInfernalPlayer.getTeam())
  2836.  
  2837.                         pBestPlot = -1
  2838.                         iBestPlot = -1
  2839.                         for iLoop in range (CyMap().numPlots()):
  2840.                             pPlot = CyMap().plotByIndex(iLoop)
  2841.                             iX = pPlot.getX()
  2842.                             iY = pPlot.getY()
  2843.                             iPlot = -1
  2844.                             if pInfernalPlayer.canFound(iX, iY):
  2845.                                 if pPlot.getNumUnits() == 0:
  2846.                                     iPlot = CyGame().getSorenRandNum(50, "Place Hyborem")
  2847.                                     iPlot += 50
  2848.                                     iPlot += pPlot.area().getNumTiles() * 2
  2849.                                     iPlot += pPlot.area().getNumUnownedTiles() * 10
  2850.  
  2851.                                     ## Check Big Fat Cross for other players, resources and terrain
  2852.                                     for iCityPlotX in range(iX-1, iX+2, 1):
  2853.                                         for iCityPlotY in range(iY-1, iY+2, 1):
  2854.                                             pCityPlot = CyMap().plot(iCityPlotX,iCityPlotY)
  2855.                                             iCityTerrain = pCityPlot.getTerrainType()
  2856.                                             iCityPlot = pCityPlot.getPlotType()
  2857.                                             iCityBonus = pCityPlot.getBonusType(TeamTypes.NO_TEAM)
  2858.  
  2859.                                             for jPlayer in range(gc.getMAX_PLAYERS()):
  2860.                                                 lPlayer = gc.getPlayer(jPlayer)
  2861.                                                 if lPlayer.isAlive():
  2862.                                                     if pCityPlot.getCulture(jPlayer) > 100:
  2863.                                                         iPlot -= 250
  2864.                                             if pPlot.isAdjacentOwned():
  2865.                                                 iPlot -= 25
  2866.                                             else:
  2867.                                                 iPlot += 15
  2868.                                             if (iCityTerrain == gc.getInfoTypeForString('TERRAIN_SNOW')) or (iCityTerrain == gc.getInfoTypeForString("TERRAIN_DESERT")):
  2869.                                                 iPlot -= 25
  2870.                                             elif (iCityTerrain == gc.getInfoTypeForString('TERRAIN_TUNDRA')):
  2871.                                                 iPlot -= 10
  2872.                                             if (pCityPlot.isWater()):
  2873.                                                 iPlot -= 25
  2874.                                             elif not iCityBonus == BonusTypes.NO_BONUS:
  2875.                                                 iPlot += gc.getBonusInfo(iCityBonus).getYieldChange(YieldTypes.YIELD_PRODUCTION) * 25
  2876.                                                 iPlot += gc.getBonusInfo(iCityBonus).getYieldChange(YieldTypes.YIELD_COMMERCE) * 15
  2877.  
  2878.                             if iPlot > iBestPlot:
  2879.                                 iBestPlot = iPlot
  2880.                                 pBestPlot = pPlot
  2881.  
  2882.                         if pBestPlot != -1:
  2883.                             iFounderTeam = gc.getPlayer(iPlayer).getTeam()
  2884.                             pFounderTeam = gc.getTeam(gc.getPlayer(iPlayer).getTeam())
  2885.                             iInfernalTeam = gc.getPlayer(iInfernalPlayer).getTeam()
  2886.                             pInfernalTeam = gc.getTeam(iInfernalTeam)
  2887.  
  2888.                             iBarbTeam = gc.getBARBARIAN_TEAM()
  2889.                             pInfernalTeam.makePeace(iBarbTeam)
  2890.                             pInfernalPlayer.AI_changeAttitudeExtra(iPlayer, 4)
  2891.  
  2892.                             iX = pBestPlot.getX()
  2893.                             iY = pBestPlot.getY()
  2894.                             pNewUnit = pInfernalPlayer.initUnit(gc.getInfoTypeForString('UNIT_HYBOREM'), iX, iY, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
  2895.                             pNewUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_IMMORTAL'), True)
  2896.                             pNewUnit.setHasCasted(True)
  2897.                             pNewUnit.setAvatarOfCivLeader(True)
  2898.                             iIronWeapon     = gc.getInfoTypeForString('PROMOTION_IRON_WEAPONS')
  2899.                             iMobility1      = gc.getInfoTypeForString('PROMOTION_MOBILITY1')
  2900.                             iSettlerBonus   = gc.getInfoTypeForString('PROMOTION_STARTING_SETTLER')
  2901.                             liStartingUnits = [ (2, gc.getInfoTypeForString('UNIT_LONGBOWMAN'), [iMobility1]                ),
  2902.                                                 (2, gc.getInfoTypeForString('UNIT_CHAMPION'),   [iMobility1, iIronWeapon]   ),
  2903.                                                 (1, gc.getInfoTypeForString('UNIT_WORKER'),     []                          ),
  2904.                                                 (1, gc.getInfoTypeForString('UNIT_IMP'),        [iMobility1]                ),
  2905.                                                 (3, gc.getInfoTypeForString('UNIT_MANES'),      []                          ),
  2906.                                                 (2, gc.getInfoTypeForString('UNIT_SETTLER'),    [iSettlerBonus]             )   ]
  2907.                             for iNumUnits, iUnit, liPromotions in liStartingUnits:
  2908.                                 for iLoop in range(iNumUnits):
  2909.                                     pNewUnit = pInfernalPlayer.initUnit(iUnit, iX, iY, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
  2910.                                     for iPromotion in liPromotions:
  2911.                                         pNewUnit.setHasPromotion(iPromotion, True)
  2912.  
  2913.                             if (game.isOption(GameOptionTypes.GAMEOPTION_ADVANCED_TACTICS)):
  2914.                                 pFounderTeam.setHasEmbassy(iInfernalTeam, True)
  2915.                                 pInfernalTeam.setHasEmbassy(iFounderTeam, True)
  2916.  
  2917.                             pFounderTeam.signOpenBorders(iInfernalTeam)
  2918.                             pInfernalTeam.signOpenBorders(iFounderTeam)
  2919.                             for iPlotIndex in range(CyMap().numPlots()):
  2920.                                 pLoopPlot = CyMap().plotByIndex(iPlotIndex)
  2921.                                 if pLoopPlot.isRevealed(iFounderTeam, False):
  2922.                                     pLoopPlot.setRevealed(iInfernalTeam, True, False, iFounderTeam)
  2923.                                 if pLoopPlot.isRevealed(iInfernalTeam, False):
  2924.                                     pLoopPlot.setRevealed(iFounderTeam, True, False, iInfernalTeam)
  2925.                             for iLoopTeam in range(gc.getMAX_CIV_TEAMS()):
  2926.                                 pLoopTeam = gc.getTeam(iLoopTeam)
  2927.                                 if pLoopTeam.isHasMet(iFounderTeam):
  2928.                                     if pLoopTeam.isAlive():
  2929.                                         pLoopTeam.meet(iInfernalTeam, True)
  2930.                             for iTeam in range(gc.getMAX_TEAMS()):
  2931.                                 if iTeam != iBarbTeam:
  2932.                                     pTeam = gc.getTeam(iTeam)
  2933.                                     if pTeam.isAlive():
  2934.                                         if pFounderTeam.isAtWar(iTeam):
  2935.                                             pInfernalTeam.declareWar(iTeam, False, WarPlanTypes.WARPLAN_LIMITED)
  2936.  
  2937.                             if gc.getPlayer(iPlayer).isHuman():
  2938.                                 popupInfo = CyPopupInfo()
  2939.                                 popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON)
  2940.                                 popupInfo.setText(CyTranslator().getText("TXT_KEY_POPUP_CONTROL_INFERNAL",()))
  2941.                                 popupInfo.setData1(iPlayer)
  2942.                                 popupInfo.setData2(iInfernalPlayer)
  2943.                                 popupInfo.addPythonButton(CyTranslator().getText("TXT_KEY_POPUP_YES", ()), "")
  2944.                                 popupInfo.addPythonButton(CyTranslator().getText("TXT_KEY_POPUP_NO", ()), "")
  2945.                                 popupInfo.setOnClickedPythonCallback("reassignPlayer")
  2946.                                 popupInfo.addPopup(iPlayer)
  2947.  
  2948.         if CyGame().getWBMapScript():
  2949.             sf.onTechAcquired(iTechType, iTeam, iPlayer, bAnnounce)
  2950.  
  2951.         if (not self.__LOG_TECH):
  2952.             return
  2953.         CvUtil.pyPrint('%s was finished by Team %d'
  2954.             %(PyInfo.TechnologyInfo(iTechType).getDescription(), iTeam))
  2955.  
  2956.     def onTechSelected(self, argsList):
  2957.         'Tech Selected'
  2958.         iTechType, iPlayer = argsList
  2959.         if (not self.__LOG_TECH):
  2960.             return
  2961.         CvUtil.pyPrint('%s was selected by Player %d' %(PyInfo.TechnologyInfo(iTechType).getDescription(), iPlayer))
  2962.  
  2963.     def onReligionFounded(self, argsList):
  2964.     ## Platy Builder ##
  2965.         if CyGame().GetWorldBuilderMode() and not CvPlatyBuilderScreen.bPython: return
  2966.     ## Platy Builder ##
  2967.         'Religion Founded'
  2968.         iReligion, iFounder = argsList
  2969.         player = PyPlayer(iFounder)
  2970.         pPlayer = gc.getPlayer(iFounder)
  2971.  
  2972.         iCityId = gc.getGame().getHolyCity(iReligion).getID()
  2973.         if gc.getGame().isFinalInitialized() and not gc.getGame().GetWorldBuilderMode():
  2974.             if not gc.getGame().isNetworkMultiPlayer() and iFounder == gc.getGame().getActivePlayer():
  2975.                 popupInfo = CyPopupInfo()
  2976.                 popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
  2977.                 popupInfo.setData1(iReligion)
  2978.                 popupInfo.setData2(iCityId)
  2979.                 if iReligion == gc.getInfoTypeForString('RELIGION_THE_EMPYREAN') or iReligion == gc.getInfoTypeForString('RELIGION_COUNCIL_OF_ESUS'):
  2980.                     popupInfo.setData3(3)
  2981.                 else:
  2982.                     popupInfo.setData3(1)
  2983.                 popupInfo.setText(u"showWonderMovie")
  2984.                 popupInfo.addPopup(iFounder)
  2985.  
  2986.  
  2987.         if CyGame().getWBMapScript():
  2988.             sf.onReligionFounded(iReligion, iFounder)
  2989.  
  2990.         if (not self.__LOG_RELIGION):
  2991.             return
  2992.         CvUtil.pyPrint('Player %d Civilization %s has founded %s'
  2993.             %(iFounder, player.getCivilizationName(), gc.getReligionInfo(iReligion).getDescription()))
  2994.  
  2995.     def onReligionSpread(self, argsList):
  2996.     ## Platy Builder ##
  2997.         if CyGame().GetWorldBuilderMode() and not CvPlatyBuilderScreen.bPython: return
  2998.     ## Platy Builder ##
  2999.         'Religion Has Spread to a City'
  3000.         iReligion, iOwner, pSpreadCity = argsList
  3001.         player = PyPlayer(iOwner)
  3002.         pPlayer = gc.getPlayer(iOwner)
  3003.  
  3004.         iOrder = gc.getInfoTypeForString('RELIGION_THE_ORDER')
  3005.         iVeil = gc.getInfoTypeForString('RELIGION_THE_ASHEN_VEIL')
  3006.  
  3007.         if iReligion == iOrder and CyGame().getGameTurn() != CyGame().getStartTurn():
  3008.             if (pPlayer.getStateReligion() == iOrder and pSpreadCity.getOccupationTimer() <= 0):
  3009.                 if (CyGame().getSorenRandNum(100, "Order Spawn") < gc.getDefineINT('ORDER_SPAWN_CHANCE')):
  3010.                     eTeam = gc.getTeam(pPlayer.getTeam())
  3011.                     if eTeam.isHasTech(gc.getInfoTypeForString('TECH_FANATICISM')):
  3012.                         iUnit = gc.getInfoTypeForString('UNIT_CRUSADER')
  3013.                         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)
  3014.                     else:
  3015.                         iUnit = gc.getInfoTypeForString('UNIT_DISCIPLE_THE_ORDER')
  3016.                         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)
  3017.                     newUnit = pPlayer.initUnit(iUnit, pSpreadCity.getX(), pSpreadCity.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
  3018.         if pSpreadCity.isHasReligion(iVeil) and iReligion == iOrder:
  3019.             if not pSpreadCity.isHolyCity():
  3020.                 result = CyGame().getSorenRandNum(100, "Order-Veil")
  3021.                 if (result < 35):
  3022.                     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)
  3023.                     pSpreadCity.setHasReligion(gc.getInfoTypeForString('RELIGION_THE_ASHEN_VEIL'), False, True, True)
  3024.                     iPop = pSpreadCity.getPopulation()-1
  3025.                     if (iPop > 0):
  3026.                         pSpreadCity.setPopulation(iPop)
  3027.                     CyGame().changeGlobalCounter(-1)
  3028.                 else:
  3029.                     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)
  3030.                     pSpreadCity.setHasReligion(gc.getInfoTypeForString('RELIGION_THE_ORDER'), False, True, True)
  3031.         elif pSpreadCity.isHasReligion(iOrder) and iReligion == iVeil:
  3032.             if not pSpreadCity.isHolyCity():
  3033.                 result = CyGame().getSorenRandNum(100, "Veil-Order")
  3034.                 if (result < 35):
  3035.                     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)
  3036.                     pSpreadCity.setHasReligion(gc.getInfoTypeForString('RELIGION_THE_ORDER'), False, True, True)
  3037.                     iPop = pSpreadCity.getPopulation()-1
  3038.                     if (iPop > 0):
  3039.                         pSpreadCity.setPopulation(iPop)
  3040.                     CyGame().changeGlobalCounter(1)
  3041.                 else :
  3042.                     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)
  3043.                     pSpreadCity.setHasReligion(gc.getInfoTypeForString('RELIGION_THE_ASHEN_VEIL'), False, True, True)
  3044.  
  3045.         if (not self.__LOG_RELIGIONSPREAD):
  3046.             return
  3047.         CvUtil.pyPrint('%s has spread to Player %d Civilization %s city of %s'
  3048.             %(gc.getReligionInfo(iReligion).getDescription(), iOwner, player.getCivilizationName(), pSpreadCity.getName()))
  3049.  
  3050.     def onReligionRemove(self, argsList):
  3051.     ## Platy Builder ##
  3052.         if CyGame().GetWorldBuilderMode() and not CvPlatyBuilderScreen.bPython: return
  3053.     ## Platy Builder ##
  3054.         'Religion Has been removed from a City'
  3055.         iReligion, iOwner, pRemoveCity = argsList
  3056.         player = PyPlayer(iOwner)
  3057.         if (not self.__LOG_RELIGIONSPREAD):
  3058.             return
  3059.         CvUtil.pyPrint('%s has been removed from Player %d Civilization %s city of %s'
  3060.             %(gc.getReligionInfo(iReligion).getDescription(), iOwner, player.getCivilizationName(), pRemoveCity.getName()))
  3061.  
  3062.     def onCorporationFounded(self, argsList):
  3063.     ## Platy Builder ##
  3064.         if CyGame().GetWorldBuilderMode() and not CvPlatyBuilderScreen.bPython: return
  3065.     ## Platy Builder ##
  3066.         'Corporation Founded'
  3067.         iCorporation, iFounder = argsList
  3068.         player = PyPlayer(iFounder)
  3069.         if (not self.__LOG_RELIGION):
  3070.             return
  3071.         CvUtil.pyPrint('Player %d Civilization %s has founded %s'
  3072.             %(iFounder, player.getCivilizationName(), gc.getCorporationInfo(iCorporation).getDescription()))
  3073.  
  3074.     def onCorporationSpread(self, argsList):
  3075.     ## Platy Builder ##
  3076.         if CyGame().GetWorldBuilderMode() and not CvPlatyBuilderScreen.bPython: return
  3077.     ## Platy Builder ##
  3078.         'Corporation Has Spread to a City'
  3079.         iCorporation, iOwner, pSpreadCity = argsList
  3080.         player = PyPlayer(iOwner)
  3081.         if (not self.__LOG_RELIGIONSPREAD):
  3082.             return
  3083.         CvUtil.pyPrint('%s has spread to Player %d Civilization %s city of %s'
  3084.             %(gc.getCorporationInfo(iCorporation).getDescription(), iOwner, player.getCivilizationName(), pSpreadCity.getName()))
  3085.  
  3086.     def onCorporationRemove(self, argsList):
  3087.     ## Platy Builder ##
  3088.         if CyGame().GetWorldBuilderMode() and not CvPlatyBuilderScreen.bPython: return
  3089.     ## Platy Builder ##
  3090.         'Corporation Has been removed from a City'
  3091.         iCorporation, iOwner, pRemoveCity = argsList
  3092.         player = PyPlayer(iOwner)
  3093.         if (not self.__LOG_RELIGIONSPREAD):
  3094.             return
  3095.         CvUtil.pyPrint('%s has been removed from Player %d Civilization %s city of %s'
  3096.             %(gc.getReligionInfo(iReligion).getDescription(), iOwner, player.getCivilizationName(), pRemoveCity.getName()))
  3097.  
  3098.     def onGoldenAge(self, argsList):
  3099.     ## Platy Builder ##
  3100.         if CyGame().GetWorldBuilderMode() and not CvPlatyBuilderScreen.bPython: return
  3101.     ## Platy Builder ##
  3102.         'Golden Age'
  3103.         iPlayer = argsList[0]
  3104.         player = PyPlayer(iPlayer)
  3105.         if (not self.__LOG_GOLDENAGE):
  3106.             return
  3107.         CvUtil.pyPrint('Player %d Civilization %s has begun a golden age'
  3108.             %(iPlayer, player.getCivilizationName()))
  3109.  
  3110.     def onEndGoldenAge(self, argsList):
  3111.     ## Platy Builder ##
  3112.         if CyGame().GetWorldBuilderMode() and not CvPlatyBuilderScreen.bPython: return
  3113.     ## Platy Builder ##
  3114.         'End Golden Age'
  3115.         iPlayer = argsList[0]
  3116.         player = PyPlayer(iPlayer)
  3117.         if (not self.__LOG_ENDGOLDENAGE):
  3118.             return
  3119.         CvUtil.pyPrint('Player %d Civilization %s golden age has ended'
  3120.             %(iPlayer, player.getCivilizationName()))
  3121.  
  3122.     def onChangeWar(self, argsList):
  3123.     ## Platy Builder ##
  3124.         if CyGame().GetWorldBuilderMode() and not CvPlatyBuilderScreen.bPython: return
  3125.     ## Platy Builder ##
  3126.         'War Status Changes'
  3127.         bIsWar = argsList[0]
  3128.         iTeam = argsList[1]
  3129.         iRivalTeam = argsList[2]
  3130.  
  3131.     def onChat(self, argsList):
  3132.         'Chat Message Event'
  3133.         chatMessage = "%s" %(argsList[0],)
  3134.  
  3135.     def onSetPlayerAlive(self, argsList):
  3136.         'Set Player Alive Event'
  3137.         iPlayerID = argsList[0]
  3138.         bNewValue = argsList[1]
  3139.         CvUtil.pyPrint("Player %d's alive status set to: %d" %(iPlayerID, int(bNewValue)))
  3140.  
  3141.         if not bNewValue and gc.getGame().getGameTurnYear() >= 5:
  3142.             pPlayer = gc.getPlayer(iPlayerID)
  3143.             if pPlayer.getAlignment() == gc.getInfoTypeForString('ALIGNMENT_GOOD'):
  3144.                 CyGame().changeGlobalCounter(5)
  3145.             elif pPlayer.getAlignment() == gc.getInfoTypeForString('ALIGNMENT_EVIL'):
  3146.                 CyGame().changeGlobalCounter(-5)
  3147.             if CyGame().getWBMapScript():
  3148.                 sf.playerDefeated(pPlayer)
  3149.             else:
  3150.                 iLeader = pPlayer.getLeaderType()
  3151.                 if iLeader == gc.getInfoTypeForString('LEADER_ALEXIS'):
  3152.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_CALABIM",()),'art/interface/popups/Alexis.dds')
  3153.                 elif iLeader == gc.getInfoTypeForString('LEADER_AMELANCHIER'):
  3154.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_LJOSALFAR",()),'art/interface/popups/Amelanchier.dds')
  3155.                 elif iLeader == gc.getInfoTypeForString('LEADER_ARENDEL'):
  3156.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_LJOSALFAR",()),'art/interface/popups/Arendel.dds')
  3157.                 elif iLeader == gc.getInfoTypeForString('LEADER_ARTURUS'):
  3158.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_KHAZAD",()),'art/interface/popups/Arturus.dds')
  3159.                 elif iLeader == gc.getInfoTypeForString('LEADER_AURIC'):
  3160.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_ILLIANS",()),'art/interface/popups/Auric.dds')
  3161.                 elif iLeader == gc.getInfoTypeForString('LEADER_BASIUM'):
  3162.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_MERCURIANS",()),'art/interface/popups/Basium.dds')
  3163.                 elif iLeader == gc.getInfoTypeForString('LEADER_BEERI'):
  3164.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_LUCHUIRP",()),'art/interface/popups/Beeri.dds')
  3165.                 elif iLeader == gc.getInfoTypeForString('LEADER_CAPRIA'):
  3166.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_BANNOR",()),'art/interface/popups/Capria.dds')
  3167.                 elif iLeader == gc.getInfoTypeForString('LEADER_CARDITH'):
  3168.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_KURIOTATES",()),'art/interface/popups/Cardith.dds')
  3169.                 elif iLeader == gc.getInfoTypeForString('LEADER_CASSIEL'):
  3170.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_GRIGORI",()),'art/interface/popups/Cassiel.dds')
  3171.                 elif iLeader == gc.getInfoTypeForString('LEADER_CHARADON'):
  3172.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_DOVIELLO",()),'art/interface/popups/Charadon.dds')
  3173.                 elif iLeader == gc.getInfoTypeForString('LEADER_DAIN'):
  3174.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_AMURITES",()),'art/interface/popups/Dain.dds')
  3175.                 elif iLeader == gc.getInfoTypeForString('LEADER_DECIUS'):
  3176.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_DECIUS",()),'art/interface/popups/Decius.dds')
  3177.                 elif iLeader == gc.getInfoTypeForString('LEADER_EINION'):
  3178.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_ELOHIM",()),'art/interface/popups/Einion.dds')
  3179.                 elif iLeader == gc.getInfoTypeForString('LEADER_ETHNE'):
  3180.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_ELOHIM",()),'art/interface/popups/Ethne.dds')
  3181.                 elif iLeader == gc.getInfoTypeForString('LEADER_FAERYL'):
  3182.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_SVARTALFAR",()),'art/interface/popups/Faeryl.dds')
  3183.                 elif iLeader == gc.getInfoTypeForString('LEADER_FALAMAR'):
  3184.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_LANUN",()),'art/interface/popups/Falamar.dds')
  3185.                 elif iLeader == gc.getInfoTypeForString('LEADER_FLAUROS'):
  3186.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_CALABIM",()),'art/interface/popups/Flauros.dds')
  3187.                 elif iLeader == gc.getInfoTypeForString('LEADER_GARRIM'):
  3188.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_LUCHUIRP",()),'art/interface/popups/Garrim.dds')
  3189.                 elif iLeader == gc.getInfoTypeForString('LEADER_HANNAH'):
  3190.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_HANNAH",()),'art/interface/popups/Hannah.dds')
  3191.                 elif iLeader == gc.getInfoTypeForString('LEADER_HYBOREM'):
  3192.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_INFERNAL",()),'art/interface/popups/Hyborem.dds')
  3193.                 elif iLeader == gc.getInfoTypeForString('LEADER_JONAS'):
  3194.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_CLAN_OF_EMBERS",()),'art/interface/popups/Jonus.dds')
  3195.                 elif iLeader == gc.getInfoTypeForString('LEADER_KANDROS'):
  3196.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_KHAZAD",()),'art/interface/popups/Kandros.dds')
  3197.                 elif iLeader == gc.getInfoTypeForString('LEADER_KEELYN'):
  3198.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_KEELYN",()),'art/interface/popups/Keelyn.dds')
  3199.                 elif iLeader == gc.getInfoTypeForString('LEADER_MAHALA'):
  3200.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_DOVIELLO",()),'art/interface/popups/Mahala.dds')
  3201.                 elif iLeader == gc.getInfoTypeForString('LEADER_SANDALPHON'):
  3202.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_SIDAR",()),'art/interface/popups/Sandalphon.dds')
  3203.                 elif iLeader == gc.getInfoTypeForString('LEADER_OS-GABELLA'):
  3204.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_SHEAIM",()),'art/interface/popups/Os-Gabella.dds')
  3205.                 elif iLeader == gc.getInfoTypeForString('LEADER_PERPENTACH'):
  3206.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_BALSERAPHS",()),'art/interface/popups/Perpentach.dds')
  3207.                 elif iLeader == gc.getInfoTypeForString('LEADER_RHOANNA'):
  3208.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_HIPPUS",()),'art/interface/popups/Rhoanna.dds')
  3209.                 elif iLeader == gc.getInfoTypeForString('LEADER_SABATHIEL'):
  3210.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_BANNOR",()),'art/interface/popups/Sabathiel.dds')
  3211.                 elif iLeader == gc.getInfoTypeForString('LEADER_SHEELBA'):
  3212.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_CLAN_OF_EMBERS",()),'art/interface/popups/Sheelba.dds')
  3213.                 elif iLeader == gc.getInfoTypeForString('LEADER_TASUNKE'):
  3214.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_HIPPUS",()),'art/interface/popups/Tasunke.dds')
  3215.                 elif iLeader == gc.getInfoTypeForString('LEADER_TEBRYN'):
  3216.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_SHEAIM",()),'art/interface/popups/Tebryn.dds')
  3217.                 elif iLeader == gc.getInfoTypeForString('LEADER_THESSA'):
  3218.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_LJOSALFAR",()),'art/interface/popups/Thessa.dds')
  3219.                 elif iLeader == gc.getInfoTypeForString('LEADER_VALLEDIA'):
  3220.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_AMURITES",()),'art/interface/popups/Valledia.dds')
  3221.                 elif iLeader == gc.getInfoTypeForString('LEADER_VARN'):
  3222.                     cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_MALAKIM",()),'art/interface/popups/Varn.dds')
  3223.  
  3224.     def onPlayerChangeStateReligion(self, argsList):
  3225.     ## Platy Builder ##
  3226.         if CyGame().GetWorldBuilderMode() and not CvPlatyBuilderScreen.bPython: return
  3227.     ## Platy Builder ##
  3228.         'Player changes his state religion'
  3229.         iPlayer, iNewReligion, iOldReligion = argsList
  3230.         if iNewReligion != iOldReligion:
  3231.             pPlayer = gc.getPlayer(iPlayer)
  3232.             if iNewReligion == -1:
  3233.                 iCurrentEra = pPlayer.getCurrentEra()
  3234.                 iEra = iCurrentEra
  3235.                 if not (iCurrentEra == gc.getInfoTypeForString('ERA_ANCIENT') or iCurrentEra == gc.getInfoTypeForString('ERA_CLASSICAL') or iCurrentEra == gc.getInfoTypeForString('ERA_MEDIEVAL')):
  3236.                     iEra = gc.getGame().getStartEra()
  3237.                     pPlayer.setCurrentEra(iEra)
  3238.             elif iNewReligion == gc.getInfoTypeForString('RELIGION_THE_ORDER'):
  3239.                 pPlayer.setCurrentEra(gc.getInfoTypeForString('ERA_ORDE'))
  3240.             elif iNewReligion == gc.getInfoTypeForString('RELIGION_THE_EMPYREAN'):
  3241.                 pPlayer.setCurrentEra(gc.getInfoTypeForString('ERA_EMPY'))
  3242.             elif iNewReligion == gc.getInfoTypeForString('RELIGION_RUNES_OF_KILMORPH'):
  3243.                 pPlayer.setCurrentEra(gc.getInfoTypeForString('ERA_RUNE'))
  3244.             elif iNewReligion == gc.getInfoTypeForString('RELIGION_FELLOWSHIP_OF_LEAVES'):
  3245.                 pPlayer.setCurrentEra(gc.getInfoTypeForString('ERA_LEAF'))
  3246.             elif iNewReligion == gc.getInfoTypeForString('RELIGION_OCTOPUS_OVERLORDS'):
  3247.                 pPlayer.setCurrentEra(gc.getInfoTypeForString('ERA_OCTO'))
  3248.             elif iNewReligion == gc.getInfoTypeForString('RELIGION_COUNCIL_OF_ESUS'):
  3249.                 pPlayer.setCurrentEra(gc.getInfoTypeForString('ERA_COUN'))
  3250.             elif iNewReligion == gc.getInfoTypeForString('RELIGION_THE_ASHEN_VEIL'):
  3251.                 pPlayer.setCurrentEra(gc.getInfoTypeForString('ERA_VEIL'))
  3252.  
  3253.     def onPlayerGoldTrade(self, argsList):
  3254.         'Player Trades gold to another player'
  3255.         iFromPlayer, iToPlayer, iGoldAmount = argsList
  3256.  
  3257.     def onCityBuilt(self, argsList):
  3258.         'City Built'
  3259.         city = argsList[0]
  3260.         pPlot = city.plot()
  3261.         pPlayer = gc.getPlayer(city.getOwner())
  3262.  
  3263.         if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_INFERNAL'):
  3264.             city.setHasReligion(gc.getInfoTypeForString('RELIGION_THE_ASHEN_VEIL'), True, True, True)
  3265.             city.setPopulation(3)
  3266.             city.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_ELDER_COUNCIL'), 1)
  3267.             city.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_TRAINING_YARD'), 1)
  3268.             city.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_OBSIDIAN_GATE'), 1)
  3269.             city.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_FORGE'), 1)
  3270.             city.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_MAGE_GUILD'), 1)
  3271.             city.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_DEMONIC_CITIZENS'), 1)
  3272.  
  3273.         elif pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_BARBARIAN'):
  3274.             eTeam = gc.getTeam(gc.getPlayer(gc.getBARBARIAN_PLAYER()).getTeam())
  3275.  
  3276.             iUnit = gc.getInfoTypeForString('UNIT_ARCHER')
  3277.             if eTeam.isHasTech(gc.getInfoTypeForString('TECH_BOWYERS')) or CyGame().getStartEra() > gc.getInfoTypeForString('ERA_CLASSICAL'):
  3278.                 iUnit = gc.getInfoTypeForString('UNIT_LONGBOWMAN')
  3279.             newUnit2 = pPlayer.initUnit(iUnit, city.getX(), city.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
  3280.             newUnit3 = pPlayer.initUnit(iUnit, city.getX(), city.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
  3281.             newUnit2.setHasPromotion(gc.getInfoTypeForString('PROMOTION_ORC'), True)
  3282.             newUnit3.setHasPromotion(gc.getInfoTypeForString('PROMOTION_ORC'), True)
  3283.             if not eTeam.isHasTech(gc.getInfoTypeForString('TECH_ARCHERY')) or CyGame().getStartEra() == gc.getInfoTypeForString('ERA_ANCIENT'):
  3284.                 newUnit2.setHasPromotion(gc.getInfoTypeForString('PROMOTION_WEAK'), True)
  3285.                 newUnit3.setHasPromotion(gc.getInfoTypeForString('PROMOTION_WEAK'), True)
  3286.  
  3287.         if CyGame().getWBMapScript():
  3288.             sf.onCityBuilt(city)
  3289.  
  3290.         if (city.getOwner() == CyGame().getActivePlayer())and ( CyGame().getAIAutoPlay(CyGame().getActivePlayer()) == 0 ):
  3291.             if not CyGame().GetWorldBuilderMode():#Platy WorldBuilder
  3292.                 self.__eventEditCityNameBegin(city, False)
  3293.         CvUtil.pyPrint('City Built Event: %s' %(city.getName()))
  3294.  
  3295.     def onCityRazed(self, argsList):
  3296.     ## Platy Builder ##
  3297.         if CyGame().GetWorldBuilderMode() and not CvPlatyBuilderScreen.bPython: return
  3298.     ## Platy Builder ##
  3299.         'City Razed'
  3300.         city, iPlayer = argsList
  3301.         iOwner = city.findHighestCulture()
  3302.  
  3303.         # Partisans!
  3304. #       if city.getPopulation > 1 and iOwner != -1 and iPlayer != -1:
  3305. #           owner = gc.getPlayer(iOwner)
  3306. #           if not owner.isBarbarian() and owner.getNumCities() > 0:
  3307. #               if gc.getTeam(owner.getTeam()).isAtWar(gc.getPlayer(iPlayer).getTeam()):
  3308. #                   if gc.getNumEventTriggerInfos() > 0: # prevents mods that don't have events from getting an error
  3309. #                       iEvent = CvUtil.findInfoTypeNum(gc.getEventTriggerInfo, gc.getNumEventTriggerInfos(),'EVENTTRIGGER_PARTISANS')
  3310. #                       if iEvent != -1 and gc.getGame().isEventActive(iEvent) and owner.getEventTriggerWeight(iEvent) >= 0:
  3311. #                           triggerData = owner.initTriggeredData(iEvent, True, -1, city.getX(), city.getY(), iPlayer, city.getID(), -1, -1, -1, -1)
  3312.  
  3313.         iAngel = gc.getInfoTypeForString('UNIT_ANGEL')
  3314.         iInfernal = gc.getInfoTypeForString('CIVILIZATION_INFERNAL')
  3315.         iManes = gc.getInfoTypeForString('UNIT_MANES')
  3316.         iMercurians = gc.getInfoTypeForString('CIVILIZATION_MERCURIANS')
  3317.         pPlayer = gc.getPlayer(iPlayer)
  3318.         if gc.getPlayer(city.getOriginalOwner()).getAlignment() == gc.getInfoTypeForString('ALIGNMENT_EVIL'):
  3319.             if gc.getPlayer(city.getOriginalOwner()).getCivilizationType() != iInfernal:
  3320.                 for i in range(city.getPopulation()):
  3321.                     cf.giftUnit(iManes, iInfernal, 0, city.plot(), city.getOwner())
  3322.  
  3323.         elif gc.getPlayer(city.getOriginalOwner()).getAlignment() == gc.getInfoTypeForString('ALIGNMENT_NEUTRAL'):
  3324.             for i in range((city.getPopulation() / 4) + 1):
  3325.                 cf.giftUnit(iManes, iInfernal, 0, city.plot(), city.getOwner())
  3326.                 cf.giftUnit(iManes, iInfernal, 0, city.plot(), city.getOwner())
  3327.                 cf.giftUnit(iAngel, iMercurians, 0, city.plot(), city.getOwner())
  3328.  
  3329.         elif gc.getPlayer(city.getOriginalOwner()).getAlignment() == gc.getInfoTypeForString('ALIGNMENT_GOOD'):
  3330.             for i in range((city.getPopulation() / 2) + 1):
  3331.                 cf.giftUnit(iAngel, iMercurians, 0, city.plot(), city.getOwner())
  3332.  
  3333.         pPlot = city.plot()
  3334.         iPop = city.getPopulation()
  3335.         iCalabim = gc.getInfoTypeForString('CIVILIZATION_CALABIM')
  3336.         if pPlayer.getCivilizationType() == iCalabim and iPop > 2:
  3337.             iVampire = gc.getInfoTypeForString('PROMOTION_VAMPIRE')
  3338.             for i in range(pPlot.getNumUnits()):
  3339.                 if iPop < 3: break
  3340.                 pUnit = pPlot.getUnit(i)
  3341.                 if pUnit.isHasPromotion(iVampire):
  3342.                     pUnit.changeExperience(iPop, -1, False, False, False)
  3343.                     iPop = iPop - 1
  3344.  
  3345.         if CyGame().getWBMapScript():
  3346.             sf.onCityRazed(city, iPlayer)
  3347.  
  3348.         CvUtil.pyPrint("City Razed Event: %s" %(city.getName(),))
  3349.  
  3350.     def onCityAcquired(self, argsList):
  3351.     ## Platy Builder ##
  3352.         if CyGame().GetWorldBuilderMode() and not CvPlatyBuilderScreen.bPython: return
  3353.     ## Platy Builder ##
  3354.         'City Acquired'
  3355.         iPreviousOwner,iNewOwner,pCity,bConquest,bTrade = argsList
  3356.         pPlayer = gc.getPlayer(iNewOwner)
  3357.         pPrevious = gc.getPlayer(iPreviousOwner)
  3358.  
  3359. ## FFH
  3360.         if pPrevious.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_INFERNAL'):
  3361.             pCity.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_OBSIDIAN_GATE'), 0)
  3362.  
  3363.         if CyGame().getWBMapScript():
  3364.             sf.onCityAcquired(iPreviousOwner, iNewOwner, pCity, bConquest, bTrade)
  3365.  
  3366.         if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_INFERNAL'):
  3367.             pCity.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_ELDER_COUNCIL'), 1)
  3368.             pCity.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_TRAINING_YARD'), 1)
  3369.             pCity.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_OBSIDIAN_GATE'), 1)
  3370.             pCity.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_FORGE'), 1)
  3371.             pCity.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_MAGE_GUILD'), 1)
  3372.             pCity.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_DEMONIC_CITIZENS'), 1)
  3373. ## END FFH
  3374.  
  3375.     def onCityAcquiredAndKept(self, argsList):
  3376.         'City Acquired and Kept'
  3377.         iOwner,pCity = argsList
  3378.  
  3379.         #Functions added here tend to cause OOS issues
  3380.  
  3381.         CvUtil.pyPrint('City Acquired and Kept Event: %s' %(pCity.getName()))
  3382.  
  3383.     def onCityLost(self, argsList):
  3384.         'City Lost'
  3385.         city = argsList[0]
  3386.         player = PyPlayer(city.getOwner())
  3387.         if (not self.__LOG_CITYLOST):
  3388.             return
  3389.         CvUtil.pyPrint('City %s was lost by Player %d Civilization %s'
  3390.             %(city.getName(), player.getID(), player.getCivilizationName()))
  3391.  
  3392.     def onCultureExpansion(self, argsList):
  3393.     ## Platy Builder ##
  3394.         if CyGame().GetWorldBuilderMode() and not CvPlatyBuilderScreen.bPython: return
  3395.     ## Platy Builder ##
  3396.         'City Culture Expansion'
  3397.         pCity = argsList[0]
  3398.         iPlayer = argsList[1]
  3399.         CvUtil.pyPrint("City %s's culture has expanded" %(pCity.getName(),))
  3400.  
  3401.     def onCityGrowth(self, argsList):
  3402.         'City Population Growth'
  3403.         pCity = argsList[0]
  3404.         iPlayer = argsList[1]
  3405.         CvUtil.pyPrint("%s has grown" %(pCity.getName(),))
  3406.  
  3407.     def onCityDoTurn(self, argsList):
  3408.         'City Production'
  3409.         pCity = argsList[0]
  3410.         iPlayer = argsList[1]
  3411.         pPlot = pCity.plot()
  3412.         iPlayer = pCity.getOwner()
  3413.         pPlayer = gc.getPlayer(iPlayer)
  3414.  
  3415.         if pCity.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_CITADEL_OF_LIGHT')) > 0:
  3416.             iX = pCity.getX()
  3417.             iY = pCity.getY()
  3418.             eTeam = gc.getTeam(pPlayer.getTeam())
  3419.             iBestValue = 0
  3420.             pBestPlot = -1
  3421.             for iiX in range(iX-2, iX+3, 1):
  3422.                 for iiY in range(iY-2, iY+3, 1):
  3423.                     pPlot2 = CyMap().plot(iiX,iiY)
  3424.                     bEnemy = False
  3425.                     bNeutral = False
  3426.                     iValue = 0
  3427.                     if pPlot2.isVisibleEnemyUnit(iPlayer):
  3428.                         for i in range(pPlot2.getNumUnits()):
  3429.                             pUnit = pPlot2.getUnit(i)
  3430.                             if eTeam.isAtWar(pUnit.getTeam()):
  3431.                                 iValue += 5 * pUnit.baseCombatStr()
  3432.                             else:
  3433.                                 bNeutral = True
  3434.                         if (iValue > iBestValue and bNeutral == False):
  3435.                             iBestValue = iValue
  3436.                             pBestPlot = pPlot2
  3437.             if pBestPlot != -1:
  3438.                 for i in range(pBestPlot.getNumUnits()):
  3439.                     pUnit = pBestPlot.getUnit(i)
  3440.                     pUnit.doDamageNoCaster(20, 40, gc.getInfoTypeForString('DAMAGE_FIRE'), False)
  3441.                 if (pBestPlot.getFeatureType() == gc.getInfoTypeForString('FEATURE_FOREST') or pBestPlot.getFeatureType() == gc.getInfoTypeForString('FEATURE_JUNGLE')):
  3442.                     bValid = True
  3443.                     iImprovement = pPlot.getImprovementType()
  3444.                     if iImprovement != -1 :
  3445.                         if gc.getImprovementInfo(iImprovement).isPermanent():
  3446.                             bValid = False
  3447.                     if bValid:
  3448.                         if CyGame().getSorenRandNum(100, "Flames Spread") < gc.getDefineINT('FLAMES_SPREAD_CHANCE'):
  3449.                             pBestPlot.setImprovementType(gc.getInfoTypeForString('IMPROVEMENT_SMOKE'))
  3450.                 CyEngine().triggerEffect(gc.getInfoTypeForString('EFFECT_PILLAR_OF_FIRE'),pBestPlot.getPoint())
  3451.  
  3452.         if pCity.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_HALL_OF_MIRRORS')) > 0:
  3453.             if CyGame().getSorenRandNum(100, "Hall of Mirrors") < 100:
  3454.                 pUnit = -1
  3455.                 iBestValue = -1
  3456.                 iX = pCity.getX()
  3457.                 iY = pCity.getY()
  3458.                 eTeam = gc.getTeam(pPlayer.getTeam())
  3459.                 for iiX in range(iX-1, iX+2, 1):
  3460.                     for iiY in range(iY-1, iY+2, 1):
  3461.                         pLoopPlot = CyMap().plot(iiX,iiY)
  3462.                         if not pLoopPlot.isNone():
  3463.                             if pLoopPlot.isVisibleEnemyUnit(iPlayer):
  3464.                                 for i in range(pLoopPlot.getNumUnits()):
  3465.                                     pUnit2 = pLoopPlot.getUnit(i)
  3466.                                     if eTeam.isAtWar(pUnit2.getTeam()):
  3467.                                         iValue = CyGame().getSorenRandNum(100, "Hall of Mirrors")
  3468.                                         if (iValue > iBestValue):
  3469.                                             iBestValue = iValue
  3470.                                             pUnit = pUnit2
  3471.                 if pUnit != -1:
  3472.                     newUnit = pPlayer.initUnit(pUnit.getUnitType(), pCity.getX(), pCity.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
  3473.                     newUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_ILLUSION'), True)
  3474.  
  3475. ##--------      Unofficial Bug Fix: Modified by Denev   --------##
  3476. # Copy not only unit type, but also unit artstyle.
  3477.                     newUnit.setUnitArtStyleType(pUnit.getUnitArtStyleType())
  3478. ##--------      Unofficial Bug Fix: End Modify          --------##
  3479.  
  3480.                     if pPlayer.hasTrait(gc.getInfoTypeForString('TRAIT_SUMMONER')):
  3481.                         newUnit.setDuration(5)
  3482.                     else:
  3483.                         newUnit.setDuration(3)
  3484.  
  3485.         if pCity.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_EYES_AND_EARS_NETWORK')) > 0:
  3486.             iArete = gc.getInfoTypeForString('TECH_ARETE')
  3487.             iHiddenPaths = gc.getInfoTypeForString('TECH_HIDDEN_PATHS')
  3488.             iInfernalPact = gc.getInfoTypeForString('TECH_INFERNAL_PACT')
  3489.             iMindStapling = gc.getInfoTypeForString('TECH_MIND_STAPLING')
  3490.             iSeafaring = gc.getInfoTypeForString('TECH_SEAFARING')
  3491.             eTeam = gc.getTeam(pPlayer.getTeam())
  3492.             listTeams = []
  3493.             for iPlayer2 in range(gc.getMAX_PLAYERS()):
  3494.                 pPlayer2 = gc.getPlayer(iPlayer2)
  3495.                 if (pPlayer2.isAlive() and iPlayer2 != iPlayer):
  3496.                     iTeam2 = pPlayer2.getTeam()
  3497.                     if eTeam.isOpenBorders(iTeam2):
  3498.                         listTeams.append(gc.getTeam(iTeam2))
  3499.             if len(listTeams) >= 3:
  3500.                 for iTech in range(gc.getNumTechInfos()):
  3501.                     if (iTech != iArete and iTech != iMindStapling and iTech != iHiddenPaths and iTech != iInfernalPact and iTech != iSeafaring):
  3502.                         if eTeam.isHasTech(iTech) == False:
  3503.                             if pPlayer.canResearch(iTech, False):
  3504.                                 iCount = 0
  3505.                                 for i in range(len(listTeams)):
  3506.                                     if listTeams[i].isHasTech(iTech):
  3507.                                         iCount = iCount + 1
  3508.                                 if iCount >= 3:
  3509.                                     eTeam.setHasTech(iTech, True, iPlayer, False, True)
  3510.                                     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)
  3511.  
  3512.         if pCity.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_PLANAR_GATE')) > 0:
  3513.             iMax = 1
  3514.             iMult = 1
  3515.             if CyGame().getGlobalCounter() >= 50:
  3516.                 iMax = 2
  3517.                 iMult = 1.5
  3518.             if CyGame().getGlobalCounter() >= 75:
  3519.                 iMax = 3
  3520.                 iMult = 2
  3521.             if CyGame().getGlobalCounter() == 100:
  3522.                 iMax = 4
  3523.                 iMult = 2.5
  3524.             if CyGame().getSorenRandNum(10000, "Planar Gate") < gc.getDefineINT('PLANAR_GATE_CHANCE') * iMult:
  3525.                 listUnits = []
  3526.                 iMax = iMax * pPlayer.countNumBuildings(gc.getInfoTypeForString('BUILDING_PLANAR_GATE'))
  3527.                 if pCity.getNumBuilding(gc.getInfoTypeForString('BUILDING_GAMBLING_HOUSE')) > 0:
  3528.                     if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_REVELERS')) < iMax:
  3529.                         listUnits.append(gc.getInfoTypeForString('UNIT_REVELERS'))
  3530.                 if pCity.getNumBuilding(gc.getInfoTypeForString('BUILDING_MAGE_GUILD')) > 0:
  3531.                     if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_MOBIUS_WITCH')) < iMax:
  3532.                         listUnits.append(gc.getInfoTypeForString('UNIT_MOBIUS_WITCH'))
  3533.                 if pCity.getNumBuilding(gc.getInfoTypeForString('BUILDING_CARNIVAL')) > 0:
  3534.                     if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_CHAOS_MARAUDER')) < iMax:
  3535.                         listUnits.append(gc.getInfoTypeForString('UNIT_CHAOS_MARAUDER'))
  3536.                 if pCity.getNumBuilding(gc.getInfoTypeForString('BUILDING_GROVE')) > 0:
  3537.                     if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_MANTICORE')) < iMax:
  3538.                         listUnits.append(gc.getInfoTypeForString('UNIT_MANTICORE'))
  3539.                 if pCity.getNumBuilding(gc.getInfoTypeForString('BUILDING_PUBLIC_BATHS')) > 0:
  3540.                     if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_SUCCUBUS')) < iMax:
  3541.                         listUnits.append(gc.getInfoTypeForString('UNIT_SUCCUBUS'))
  3542.                 if pCity.getNumBuilding(gc.getInfoTypeForString('BUILDING_OBSIDIAN_GATE')) > 0:
  3543.                     if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_MINOTAUR')) < iMax:
  3544.                         listUnits.append(gc.getInfoTypeForString('UNIT_MINOTAUR'))
  3545.                 if pCity.getNumBuilding(gc.getInfoTypeForString('BUILDING_TEMPLE_OF_THE_VEIL')) > 0:
  3546.                     if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_TAR_DEMON')) < iMax:
  3547.                         listUnits.append(gc.getInfoTypeForString('UNIT_TAR_DEMON'))
  3548.                 if len(listUnits) > 0:
  3549.                     iUnit = listUnits[CyGame().getSorenRandNum(len(listUnits), "Planar Gate")]
  3550.                     newUnit = pPlayer.initUnit(iUnit, pPlot.getX(), pPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
  3551.                     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)
  3552.                     if iUnit == gc.getInfoTypeForString('UNIT_MOBIUS_WITCH'):
  3553.                         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' ]
  3554.                         newUnit.setLevel(4)
  3555.                         newUnit.setExperience(14, -1)
  3556.                         for i in promotions:
  3557.                             if CyGame().getSorenRandNum(10, "Bob") == 1:
  3558.                                 newUnit.setHasPromotion(gc.getInfoTypeForString(i), True)
  3559.  
  3560.         if gc.getPlayer(pCity.getOwner()).getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_INFERNAL'):
  3561.             if pCity.isHasReligion(gc.getInfoTypeForString('RELIGION_THE_ORDER')):
  3562.                 pCity.setHasReligion(gc.getInfoTypeForString('RELIGION_THE_ORDER'), False, True, True)
  3563.             if pCity.isHasReligion(gc.getInfoTypeForString('RELIGION_THE_ASHEN_VEIL')) == False:
  3564.                 pCity.setHasReligion(gc.getInfoTypeForString('RELIGION_THE_ASHEN_VEIL'), True, True, True)
  3565.  
  3566.         if gc.getPlayer(pCity.getOwner()).getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_MERCURIANS'):
  3567.             if pCity.isHasReligion(gc.getInfoTypeForString('RELIGION_THE_ASHEN_VEIL')):
  3568.                 pCity.setHasReligion(gc.getInfoTypeForString('RELIGION_THE_ASHEN_VEIL'), False, True, True)
  3569.  
  3570.         if pCity.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_SHRINE_OF_SIRONA')) > 0:
  3571.             pPlayer.setFeatAccomplished(FeatTypes.FEAT_HEAL_UNIT_PER_TURN, True)
  3572.  
  3573.         if pCity.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_THE_DRAGONS_HORDE')) > 0:
  3574.             if pPlayer.isBarbarian():
  3575.                 if CyGame().getSorenRandNum(100, "Bob") < gc.getHandicapInfo(gc.getGame().getHandicapType()).getLairSpawnRate():
  3576.                     iUnit = gc.getInfoTypeForString('UNIT_DISCIPLE_OF_ACHERON')
  3577. #                   eTeam = gc.getTeam(pPlayer.getTeam())
  3578. #                   if eTeam.isHasTech(gc.getInfoTypeForString('TECH_SORCERY')):
  3579. #                       iUnit = gc.getInfoTypeForString('UNIT_SON_OF_THE_INFERNO')
  3580.                     newUnit = pPlayer.initUnit(iUnit, pPlot.getX(), pPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
  3581.  
  3582.         CvAdvisorUtils.cityAdvise(pCity, iPlayer)
  3583.  
  3584.     def onCityBuildingUnit(self, argsList):
  3585.         'City begins building a unit'
  3586.         pCity = argsList[0]
  3587.         iUnitType = argsList[1]
  3588.         if (not self.__LOG_CITYBUILDING):
  3589.             return
  3590.         CvUtil.pyPrint("%s has begun building a %s" %(pCity.getName(),gc.getUnitInfo(iUnitType).getDescription()))
  3591.  
  3592.     def onCityBuildingBuilding(self, argsList):
  3593.         'City begins building a Building'
  3594.         pCity = argsList[0]
  3595.         iBuildingType = argsList[1]
  3596.         if (not self.__LOG_CITYBUILDING):
  3597.             return
  3598.         CvUtil.pyPrint("%s has begun building a %s" %(pCity.getName(),gc.getBuildingInfo(iBuildingType).getDescription()))
  3599.  
  3600.     def onCityRename(self, argsList):
  3601.         'City is renamed'
  3602.         pCity = argsList[0]
  3603.         if (pCity.getOwner() == gc.getGame().getActivePlayer()):
  3604.             self.__eventEditCityNameBegin(pCity, True)
  3605.  
  3606.     def onCityHurry(self, argsList):
  3607.         'City is renamed'
  3608.         pCity = argsList[0]
  3609.         iHurryType = argsList[1]
  3610.  
  3611.     def onVictory(self, argsList):
  3612.         'Victory'
  3613.         iTeam, iVictory = argsList
  3614.         if (iVictory >= 0 and iVictory < gc.getNumVictoryInfos()):
  3615.             for iPlayer in range(gc.getMAX_PLAYERS()):
  3616.                 pPlayer = gc.getPlayer(iPlayer)
  3617.                 if pPlayer.isAlive():
  3618.                     if pPlayer.isHuman():
  3619.                         if pPlayer.getTeam() == iTeam:
  3620.                             if CyGame().getWBMapScript():
  3621.                                 sf.onVictory(iPlayer, iVictory)
  3622.                             else:
  3623.                                 iCiv = pPlayer.getCivilizationType()
  3624.                                 if iCiv == gc.getInfoTypeForString('CIVILIZATION_AMURITES'):
  3625.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_AMURITES", 1)
  3626.                                 elif iCiv == gc.getInfoTypeForString('CIVILIZATION_BALSERAPHS'):
  3627.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_BALSERAPHS", 1)
  3628.                                 elif iCiv == gc.getInfoTypeForString('CIVILIZATION_BANNOR'):
  3629.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_BANNOR", 1)
  3630.                                 elif iCiv == gc.getInfoTypeForString('CIVILIZATION_CALABIM'):
  3631.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_CALABIM", 1)
  3632.                                 elif iCiv == gc.getInfoTypeForString('CIVILIZATION_CLAN_OF_EMBERS'):
  3633.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_CLAN_OF_EMBERS", 1)
  3634.                                 elif iCiv == gc.getInfoTypeForString('CIVILIZATION_DOVIELLO'):
  3635.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_DOVIELLO", 1)
  3636.                                 elif iCiv == gc.getInfoTypeForString('CIVILIZATION_ELOHIM'):
  3637.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_ELOHIM", 1)
  3638.                                 elif iCiv == gc.getInfoTypeForString('CIVILIZATION_GRIGORI'):
  3639.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_GRIGORI", 1)
  3640.                                 elif iCiv == gc.getInfoTypeForString('CIVILIZATION_HIPPUS'):
  3641.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_HIPPUS", 1)
  3642.                                 elif iCiv == gc.getInfoTypeForString('CIVILIZATION_ILLIANS'):
  3643.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_ILLIANS", 1)
  3644.                                 elif iCiv == gc.getInfoTypeForString('CIVILIZATION_INFERNAL'):
  3645.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_INFERNAL", 1)
  3646.                                 elif iCiv == gc.getInfoTypeForString('CIVILIZATION_KHAZAD'):
  3647.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_KHAZAD", 1)
  3648.                                 elif iCiv == gc.getInfoTypeForString('CIVILIZATION_KURIOTATES'):
  3649.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_KURIOTATES", 1)
  3650.                                 elif iCiv == gc.getInfoTypeForString('CIVILIZATION_LANUN'):
  3651.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_LANUN", 1)
  3652.                                 elif iCiv == gc.getInfoTypeForString('CIVILIZATION_LJOSALFAR'):
  3653.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_LJOSALFAR", 1)
  3654.                                 elif iCiv == gc.getInfoTypeForString('CIVILIZATION_LUCHUIRP'):
  3655.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_LUCHUIRP", 1)
  3656.                                 elif iCiv == gc.getInfoTypeForString('CIVILIZATION_MALAKIM'):
  3657.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_MALAKIM", 1)
  3658.                                 elif iCiv == gc.getInfoTypeForString('CIVILIZATION_MERCURIANS'):
  3659.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_MERCURIANS", 1)
  3660.                                 elif iCiv == gc.getInfoTypeForString('CIVILIZATION_SHEAIM'):
  3661.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_SHEAIM", 1)
  3662.                                 elif iCiv == gc.getInfoTypeForString('CIVILIZATION_SIDAR'):
  3663.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_SIDAR", 1)
  3664.                                 elif iCiv == gc.getInfoTypeForString('CIVILIZATION_SVARTALFAR'):
  3665.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_SVARTALFAR", 1)
  3666.  
  3667.                                 if iVictory == gc.getInfoTypeForString('VICTORY_ALTAR_OF_THE_LUONNOTAR'):
  3668.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_ALTAR_OF_THE_LUONNOTAR", 1)
  3669.                                 elif iVictory == gc.getInfoTypeForString('VICTORY_CONQUEST'):
  3670.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_CONQUEST", 1)
  3671.                                 elif iVictory == gc.getInfoTypeForString('VICTORY_CULTURAL'):
  3672.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_CULTURAL", 1)
  3673.                                 elif iVictory == gc.getInfoTypeForString('VICTORY_DOMINATION'):
  3674.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_DOMINATION", 1)
  3675.                                 elif iVictory == gc.getInfoTypeForString('VICTORY_RELIGIOUS'):
  3676.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_RELIGIOUS", 1)
  3677.                                 elif iVictory == gc.getInfoTypeForString('VICTORY_SCORE'):
  3678.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_SCORE", 1)
  3679.                                 elif iVictory == gc.getInfoTypeForString('VICTORY_TIME'):
  3680.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_TIME", 1)
  3681.                                 elif iVictory == gc.getInfoTypeForString('VICTORY_TOWER_OF_MASTERY'):
  3682.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_TOWER_OF_MASTERY", 1)
  3683.  
  3684.                                 if gc.getGame().isOption(GameOptionTypes.GAMEOPTION_BARBARIAN_WORLD):
  3685.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_BARBARIAN_WORLD", 1)
  3686.                                 if gc.getGame().isOption(GameOptionTypes.GAMEOPTION_CHALLENGE_CUT_LOSERS):
  3687.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_FINAL_FIVE", 1)
  3688.                                 if gc.getGame().isOption(GameOptionTypes.GAMEOPTION_CHALLENGE_HIGH_TO_LOW):
  3689.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_HIGH_TO_LOW", 1)
  3690.                                 if gc.getGame().isOption(GameOptionTypes.GAMEOPTION_CHALLENGE_INCREASING_DIFFICULTY):
  3691.                                     CyGame().changeTrophyValue("TROPHY_VICTORY_INCREASING_DIFFICULTY", 1)
  3692.  
  3693.             victoryInfo = gc.getVictoryInfo(int(iVictory))
  3694.             CvUtil.pyPrint("Victory!  Team %d achieves a %s victory"
  3695.                 %(iTeam, victoryInfo.getDescription()))
  3696.  
  3697.     def onVassalState(self, argsList):
  3698.         'Vassal State'
  3699.         iMaster, iVassal, bVassal = argsList
  3700.  
  3701.         if (bVassal):
  3702.             CvUtil.pyPrint("Team %d becomes a Vassal State of Team %d"
  3703.                 %(iVassal, iMaster))
  3704.         else:
  3705.             CvUtil.pyPrint("Team %d revolts and is no longer a Vassal State of Team %d"
  3706.                 %(iVassal, iMaster))
  3707.  
  3708.     def onGameUpdate(self, argsList):
  3709.         'sample generic event, called on each game turn slice'
  3710.         genericArgs = argsList[0][0]    # tuple of tuple of my args
  3711.         turnSlice = genericArgs[0]
  3712.  
  3713. #FfH: 10/15/2008 Added by Kael for OOS logging.
  3714.         OOSLogger.doGameUpdate()
  3715. #FfH: End add
  3716.  
  3717.     def onMouseEvent(self, argsList):
  3718.         'mouse handler - returns 1 if the event was consumed'
  3719.         eventType,mx,my,px,py,interfaceConsumed,screens = argsList
  3720.         if ( px!=-1 and py!=-1 ):
  3721.             if ( eventType == self.EventLButtonDown ):
  3722.                 if (self.bAllowCheats and self.bCtrl and self.bAlt and CyMap().plot(px,py).isCity() and not interfaceConsumed):
  3723.                     # Launch Edit City Event
  3724.                     CvEventManager.beginEvent(self, CvUtil.EventEditCity, (px,py) )
  3725.                     return 1
  3726.  
  3727.                 elif (self.bAllowCheats and self.bCtrl and self.bShift and not interfaceConsumed):
  3728.                     # Launch Place Object Event
  3729.                     CvEventManager.beginEvent(self, CvUtil.EventPlaceObject, (px, py) )
  3730.                     return 1
  3731.  
  3732.         if ( eventType == self.EventBack ):
  3733.             return CvScreensInterface.handleBack(screens)
  3734.         elif ( eventType == self.EventForward ):
  3735.             return CvScreensInterface.handleForward(screens)
  3736.  
  3737.         return 0
  3738.  
  3739.  
  3740. #################### TRIGGERED EVENTS ##################
  3741.  
  3742.     def __eventPlaceObjectBegin(self, argsList):
  3743.         'Place Object Event'
  3744.         CvDebugTools.CvDebugTools().initUnitPicker(argsList)
  3745.  
  3746.     def __eventPlaceObjectApply(self, playerID, userData, popupReturn):
  3747.         'Place Object Event Apply'
  3748.         if (getChtLvl() > 0):
  3749.             CvDebugTools.CvDebugTools().applyUnitPicker( (popupReturn, userData) )
  3750.  
  3751.     def __eventAwardTechsAndGoldBegin(self, argsList):
  3752.         'Award Techs & Gold Event'
  3753.         CvDebugTools.CvDebugTools().cheatTechs()
  3754.  
  3755.     def __eventAwardTechsAndGoldApply(self, playerID, netUserData, popupReturn):
  3756.         'Award Techs & Gold Event Apply'
  3757.         if (getChtLvl() > 0):
  3758.             CvDebugTools.CvDebugTools().applyTechCheat( (popupReturn) )
  3759.  
  3760.     def __eventShowWonderBegin(self, argsList):
  3761.         'Show Wonder Event'
  3762.         CvDebugTools.CvDebugTools().wonderMovie()
  3763.  
  3764.     def __eventShowWonderApply(self, playerID, netUserData, popupReturn):
  3765.         'Wonder Movie Apply'
  3766.         if (getChtLvl() > 0):
  3767.             CvDebugTools.CvDebugTools().applyWonderMovie( (popupReturn) )
  3768.  
  3769. ## Platy Builder ##
  3770.  
  3771.     def __eventEditUnitNameBegin(self, argsList):
  3772.         pUnit = argsList
  3773.         popup = PyPopup.PyPopup(CvUtil.EventEditUnitName, EventContextTypes.EVENTCONTEXT_ALL)
  3774.         popup.setUserData((pUnit.getID(), CyGame().getActivePlayer()))
  3775.         popup.setBodyString(localText.getText("TXT_KEY_RENAME_UNIT", ()))
  3776.         popup.createEditBox(pUnit.getNameNoDesc())
  3777.         popup.setEditBoxMaxCharCount(25)
  3778.         popup.launch()
  3779.  
  3780.     def __eventEditUnitNameApply(self, playerID, userData, popupReturn):
  3781.         unit = gc.getPlayer(userData[1]).getUnit(userData[0])
  3782.         newName = popupReturn.getEditBoxString(0)
  3783.         unit.setName(newName)
  3784.         if CyGame().GetWorldBuilderMode():
  3785.             WBUnitScreen.WBUnitScreen(CvPlatyBuilderScreen.CvWorldBuilderScreen()).placeStats()
  3786.             WBUnitScreen.WBUnitScreen(CvPlatyBuilderScreen.CvWorldBuilderScreen()).placeCurrentUnit()
  3787.  
  3788.     def __eventEditCityNameBegin(self, city, bRename):
  3789.         popup = PyPopup.PyPopup(CvUtil.EventEditCityName, EventContextTypes.EVENTCONTEXT_ALL)
  3790.         popup.setUserData((city.getID(), bRename, CyGame().getActivePlayer()))
  3791.         popup.setHeaderString(localText.getText("TXT_KEY_NAME_CITY", ()))
  3792.         popup.setBodyString(localText.getText("TXT_KEY_SETTLE_NEW_CITY_NAME", ()))
  3793.         popup.createEditBox(city.getName())
  3794.         popup.setEditBoxMaxCharCount(15)
  3795.         popup.launch()
  3796.  
  3797.     def __eventEditCityNameApply(self, playerID, userData, popupReturn):
  3798.         city = gc.getPlayer(userData[2]).getCity(userData[0])
  3799.         cityName = popupReturn.getEditBoxString(0)
  3800.         city.setName(cityName, not userData[1])
  3801.         if CyGame().GetWorldBuilderMode() and not CyGame().isInAdvancedStart():
  3802.             WBCityEditScreen.WBCityEditScreen().placeStats()
  3803. ## Platy Builder ##
  3804.  
  3805. #Magister Start
  3806.     def __eventEditPlayerNameBegin(self, argsList):
  3807.         pUnit = argsList
  3808.         popup = PyPopup.PyPopup(6666, EventContextTypes.EVENTCONTEXT_ALL)
  3809.         popup.setUserData((pPlayer.getID(),))
  3810.         popup.setBodyString(localText.getText("TXT_KEY_MENU_LEADER_NAME", ()))
  3811.         popup.createEditBox(pPlayer.getName())
  3812.         popup.launch()
  3813.  
  3814.     def __eventEditPlayerNameApply(self, playerID, userData, popupReturn):
  3815.         'Edit Player Name Event'
  3816.         newName = popupReturn.getEditBoxString(0)
  3817.         if (len(newName) > 25):
  3818.             newName = newName[:25]
  3819.         gc.getPlayer(playerID).setName(newName)
  3820.         if CyGame().GetWorldBuilderMode():
  3821.             WBPlayerScreen.WBPlayerScreen().placeStats()
  3822.  
  3823.     def __eventEditCivNameBegin(self, argsList):
  3824.         pUnit = argsList
  3825.         popup = PyPopup.PyPopup(6777, EventContextTypes.EVENTCONTEXT_ALL)
  3826.         popup.setUserData((pPlayer.getID(),))
  3827.         popup.setBodyString(localText.getText("TXT_KEY_RENAME_PLAYER", ()))
  3828.         popup.setBodyString(CyTranslator().getText("TXT_KEY_MENU_CIV_DESC", ()))
  3829.         popup.createEditBox(pPlayer.getCivilizationDescription(pPlayer.getID()))
  3830.         popup.launch()
  3831.  
  3832.     def __eventEditCivNameApply(self, playerID, userData, popupReturn):
  3833.         'Edit Player Name Event'
  3834.         pPlayer = gc.getPlayer(playerID)
  3835.         szNewDesc = pPlayer.getCivilizationDescription(playerID)
  3836.         szNewShort = pPlayer.getCivilizationShortDescription(playerID)
  3837.         szNewAdj = pPlayer.getCivilizationAdjective(playerID)
  3838.         sNew = popupReturn.getEditBoxString(0)
  3839.         if (len(sNew) > 25):
  3840.             sNew = sNew[:25]
  3841.         pPlayer.setCivName(sNew,szNewShort, szNewAdj)
  3842.         if CyGame().GetWorldBuilderMode():
  3843.             WBPlayerScreen.WBPlayerScreen().placeStats()
  3844.  
  3845.     def __eventEditCivShortNameBegin(self, argsList):
  3846.         pUnit = argsList
  3847.         popup = PyPopup.PyPopup(6888, EventContextTypes.EVENTCONTEXT_ALL)
  3848.         popup.setUserData((pPlayer.getID(),))
  3849.         popup.setBodyString(localText.getText("TXT_KEY_RENAME_PLAYER", ()))
  3850.         popup.setBodyString(CyTranslator().getText("TXT_KEY_MENU_CIV_SHORT_DESC", ()))
  3851.         popup.createEditBox(pPlayer.getCivilizationShortDescription(pPlayer.getID()))
  3852.         popup.launch()
  3853.  
  3854.     def __eventEditCivShortNameApply(self, playerID, userData, popupReturn):
  3855.         'Edit Player Name Event'
  3856.         pPlayer = gc.getPlayer(playerID)
  3857.         szNewDesc = pPlayer.getCivilizationDescription(playerID)
  3858.         szNewShort = pPlayer.getCivilizationShortDescription(playerID)
  3859.         szNewAdj = pPlayer.getCivilizationAdjective(playerID)
  3860.         sNew = popupReturn.getEditBoxString(0)
  3861.         if (len(sNew) > 25):
  3862.             sNew = sNew[:25]
  3863.         pPlayer.setCivName(szNewDesc,sNew, szNewAdj)
  3864.         if CyGame().GetWorldBuilderMode():
  3865.             WBPlayerScreen.WBPlayerScreen().placeStats()
  3866.  
  3867.     def __eventEditCivAdjBegin(self, argsList):
  3868.         pUnit = argsList
  3869.         popup = PyPopup.PyPopup(6999, EventContextTypes.EVENTCONTEXT_ALL)
  3870.         popup.setUserData((pPlayer.getID(),))
  3871.         popup.setBodyString(localText.getText("TXT_KEY_RENAME_PLAYER", ()))
  3872.         popup.setBodyString(CyTranslator().getText("TXT_KEY_MENU_CIV_ADJ", ()))
  3873.         popup.createEditBox(pPlayer.getCivilizationAdjective(pPlayer.getID()))
  3874.         popup.launch()
  3875.  
  3876.     def __eventEditCivAdjApply(self, playerID, userData, popupReturn):
  3877.         'Edit Player Name Event'
  3878.         pPlayer = gc.getPlayer(playerID)
  3879.         szNewDesc = pPlayer.getCivilizationDescription(playerID)
  3880.         szNewShort = pPlayer.getCivilizationShortDescription(playerID)
  3881.         szNewAdj = pPlayer.getCivilizationAdjective(playerID)
  3882.         sNew = popupReturn.getEditBoxString(0)
  3883.         if (len(sNew) > 25):
  3884.             sNew = sNew[:25]
  3885.         pPlayer.setCivName(szNewDesc,szNewShort, sNew)
  3886.         if CyGame().GetWorldBuilderMode():
  3887.             WBPlayerScreen.WBPlayerScreen().placeStats()
  3888. #Magister Stop
  3889.  
  3890.     def __eventWBPlayerScriptPopupApply(self, playerID, userData, popupReturn):
  3891.         sScript = popupReturn.getEditBoxString(0)
  3892.         gc.getPlayer(userData[0]).setScriptData(CvUtil.convertToStr(sScript))
  3893.         WBPlayerScreen.WBPlayerScreen().placeScript()
  3894.         return
  3895.  
  3896.     def __eventWBCityScriptPopupApply(self, playerID, userData, popupReturn):
  3897.         sScript = popupReturn.getEditBoxString(0)
  3898.         pCity = gc.getPlayer(userData[0]).getCity(userData[1])
  3899.         pCity.setScriptData(CvUtil.convertToStr(sScript))
  3900.         WBCityEditScreen.WBCityEditScreen().placeScript()
  3901.         return
  3902.  
  3903.     def __eventWBUnitScriptPopupApply(self, playerID, userData, popupReturn):
  3904.         sScript = popupReturn.getEditBoxString(0)
  3905.         pUnit = gc.getPlayer(userData[0]).getUnit(userData[1])
  3906.         pUnit.setScriptData(CvUtil.convertToStr(sScript))
  3907.         WBUnitScreen.WBUnitScreen(CvPlatyBuilderScreen.CvWorldBuilderScreen()).placeScript()
  3908.         return
  3909.  
  3910.     def __eventWBScriptPopupBegin(self):
  3911.         return
  3912.  
  3913.     def __eventWBGameScriptPopupApply(self, playerID, userData, popupReturn):
  3914.         sScript = popupReturn.getEditBoxString(0)
  3915.         CyGame().setScriptData(CvUtil.convertToStr(sScript))
  3916.         WBGameDataScreen.WBGameDataScreen(CvPlatyBuilderScreen.CvWorldBuilderScreen()).placeScript()
  3917.         return
  3918.  
  3919.     def __eventWBPlotScriptPopupApply(self, playerID, userData, popupReturn):
  3920.         sScript = popupReturn.getEditBoxString(0)
  3921.         pPlot = CyMap().plot(userData[0], userData[1])
  3922.         pPlot.setScriptData(CvUtil.convertToStr(sScript))
  3923.         WBPlotScreen.WBPlotScreen().placeScript()
  3924.         return
  3925.  
  3926.     def __eventWBLandmarkPopupApply(self, playerID, userData, popupReturn):
  3927.         sScript = popupReturn.getEditBoxString(0)
  3928.         pPlot = CyMap().plot(userData[0], userData[1])
  3929.         iPlayer = userData[2]
  3930.         if userData[3] > -1:
  3931.             pSign = CyEngine().getSignByIndex(userData[3])
  3932.             iPlayer = pSign.getPlayerType()
  3933.             CyEngine().removeSign(pPlot, iPlayer)
  3934.         if len(sScript):
  3935.             if iPlayer == gc.getBARBARIAN_PLAYER():
  3936.                 CyEngine().addLandmark(pPlot, CvUtil.convertToStr(sScript))
  3937.             else:
  3938.                 CyEngine().addSign(pPlot, iPlayer, CvUtil.convertToStr(sScript))
  3939.         WBPlotScreen.iCounter = 10
  3940.         return
  3941. ## Platy Builder ##
  3942.  
  3943. ## FfH Card Game: begin
  3944.     def __EventSelectSolmniumPlayerBegin(self):
  3945.         iHUPlayer = gc.getGame().getActivePlayer()
  3946.  
  3947.         if iHUPlayer == -1 : return 0
  3948.         if not cs.canStartGame(iHUPlayer) : return 0
  3949.  
  3950.         popup = PyPopup.PyPopup(CvUtil.EventSelectSolmniumPlayer, EventContextTypes.EVENTCONTEXT_ALL)
  3951.  
  3952.         sResText = CyUserProfile().getResolutionString(CyUserProfile().getResolution())
  3953.         sX, sY = sResText.split("x")
  3954.         iXRes = int(sX)
  3955.         iYRes = int(sY)
  3956.  
  3957.         iW = 620
  3958.         iH = 650
  3959.  
  3960.         popup.setSize(iW, iH)
  3961.         popup.setPosition((iXRes - iW) / 2, 30)
  3962.  
  3963.         lStates = []
  3964.  
  3965.         for iPlayer in range(gc.getMAX_CIV_PLAYERS()) :
  3966.             pPlayer = gc.getPlayer(iPlayer)
  3967.  
  3968.             if pPlayer.isNone() : continue
  3969.  
  3970.             if pPlayer.isHuman() :
  3971.                 lPlayerState = cs.getStartGameMPWith(iHUPlayer, iPlayer)
  3972.                 if lPlayerState[0][0] in ["No", "notMet"] : continue
  3973.                 lStates.append([iPlayer, lPlayerState])
  3974.             else :
  3975.                 lPlayerState = cs.getStartGameAIWith(iHUPlayer, iPlayer)
  3976.                 if lPlayerState[0][0] in ["No", "notMet"] : continue
  3977.                 lStates.append([iPlayer, lPlayerState])
  3978.  
  3979.         lPlayerButtons = []
  3980.  
  3981.         popup.addDDS(CyArtFileMgr().getInterfaceArtInfo("SOMNIUM_POPUP_INTRO").getPath(), 0, 0, 512, 128)
  3982.         popup.addSeparator()
  3983.         #popup.setHeaderString(localText.getText("TXT_KEY_SOMNIUM_START", ()), CvUtil.FONT_CENTER_JUSTIFY)
  3984.         if len(lStates) == 0 :
  3985.             popup.setBodyString(localText.getText("TXT_KEY_SOMNIUM_NOONE_MET", ()))
  3986.         else :
  3987.             #popup.setBodyString(localText.getText("TXT_KEY_SOMNIUM_PLAY_WITH", ()))
  3988.             popup.addSeparator()
  3989.             popup.addSeparator()
  3990.  
  3991.             sText = u""
  3992.             for iPlayer, lPlayerState in lStates :
  3993.                 pPlayer = gc.getPlayer(iPlayer)
  3994.                 sPlayerName = pPlayer.getName()
  3995.                 iPositiveChange = gc.getLeaderHeadInfo(pPlayer.getLeaderType()).getMemoryAttitudePercent(MemoryTypes.MEMORY_SOMNIUM_POSITIVE) / 100
  3996.                 iNegativeChange = gc.getLeaderHeadInfo(pPlayer.getLeaderType()).getMemoryAttitudePercent(MemoryTypes.MEMORY_SOMNIUM_NEGATIVE) / 100
  3997.                 bShift = True
  3998.  
  3999.                 for item in lPlayerState :
  4000.  
  4001.                     sTag = item[0]
  4002.                     if (sTag == "atWar") :
  4003.                         if len(sText) > 0 : sText += localText.getText("[NEWLINE]", ())
  4004.                         sText += localText.getText("TXT_KEY_SOMNIUM_AT_WAR", (sPlayerName, ))
  4005.  
  4006.                     elif (sTag == "InGame") :
  4007.                         if len(sText) > 0 : sText += localText.getText("[NEWLINE]", ())
  4008.                         sText += localText.getText("TXT_KEY_SOMNIUM_IN_GAME", (sPlayerName, ))
  4009.  
  4010.                     elif (sTag == "relation") :
  4011.                         delay = item[1]
  4012.                         if (delay > 0) :
  4013.                             if len(sText) > 0 : sText += localText.getText("[NEWLINE]", ())
  4014.                             sText += localText.getText("TXT_KEY_SOMNIUM_GAME_DELAYED", (sPlayerName, delay))
  4015.                         else :
  4016.                             if bShift :
  4017.                                 bShift = False
  4018.                                 popup.addSeparator()
  4019.                             popup.addButton(localText.getText("TXT_KEY_SOMNIUM_GAME_RELATION", (sPlayerName, iPositiveChange, iNegativeChange)))
  4020.                             lPlayerButtons.append((iPlayer, -1))
  4021.  
  4022.                     elif (sTag == "gold") :
  4023.                         for iGold in item[1] :
  4024.                             if bShift :
  4025.                                 bShift = False
  4026.                                 popup.addSeparator()
  4027.                             if iGold == 0 :
  4028.                                 popup.addButton(localText.getText("TXT_KEY_SOMNIUM_GAME_FUN", (sPlayerName, )))
  4029.                                 lPlayerButtons.append((iPlayer, iGold))
  4030.                             else :
  4031.                                 popup.addButton(localText.getText("TXT_KEY_SOMNIUM_GAME_GOLD", (sPlayerName, iGold)))
  4032.                                 lPlayerButtons.append((iPlayer, iGold))
  4033.  
  4034.             if len(sText) > 0 :
  4035.                 popup.addSeparator()
  4036.                 popup.addSeparator()
  4037.                 popup.setBodyString(sText)
  4038.  
  4039.         popup.setUserData(tuple(lPlayerButtons))
  4040.         popup.launch()
  4041.  
  4042.     def __EventSelectSolmniumPlayerApply(self, playerID, userData, popupReturn):
  4043.         if userData :
  4044.             idButtonCliked = popupReturn.getButtonClicked()
  4045.             if idButtonCliked in range(len(userData)) :
  4046.                 iOpponent, iGold = userData[idButtonCliked]
  4047.  
  4048.                 pLeftPlayer = gc.getPlayer(playerID)
  4049.                 pRightPlayer = gc.getPlayer(iOpponent)
  4050.  
  4051.                 if not pRightPlayer.isHuman() :
  4052.                     if (cs.canStartGame(playerID)) and (pLeftPlayer.isAlive()) and (pRightPlayer.isAlive()) :
  4053.                         cs.startGame(playerID, iOpponent, iGold)
  4054.                     else :
  4055.                         CyInterface().addMessage(playerID, True, 25, CyTranslator().getText("TXT_KEY_SOMNIUM_CANT_START_GAME", (gc.getPlayer(iOpponent).getName(), )), '', 1, '', ColorTypes(7), -1, -1, False, False)
  4056.                 else :
  4057.                     if (cs.canStartGame(playerID)) and (cs.canStartGame(iOpponent)) and (pLeftPlayer.isAlive()) and (pRightPlayer.isAlive()) :
  4058.                         if (iOpponent == gc.getGame().getActivePlayer()):
  4059.                             self.__EventSolmniumAcceptGameBegin((playerID, iOpponent, iGold))
  4060.                     else :
  4061.                         CyInterface().addMessage(playerID, True, 25, CyTranslator().getText("TXT_KEY_SOMNIUM_CANT_START_GAME", (gc.getPlayer(iOpponent).getName(), )), '', 1, '', ColorTypes(7), -1, -1, False, False)
  4062.  
  4063.     def __EventSolmniumAcceptGameBegin(self, argslist):
  4064.         iPlayer, iOpponent, iGold = argslist
  4065.         if not gc.getPlayer(iOpponent).isAlive() : return 0
  4066.  
  4067.         popup = PyPopup.PyPopup(CvUtil.EventSolmniumAcceptGame, EventContextTypes.EVENTCONTEXT_ALL)
  4068.  
  4069.         popup.setUserData(argslist)
  4070.  
  4071.         popup.setHeaderString(localText.getText("TXT_KEY_SOMNIUM_START", ()))
  4072.         if iGold > 0 :
  4073.             popup.setBodyString(localText.getText("TXT_KEY_SOMNIUM_ACCEPT_GAME", (gc.getPlayer(iPlayer).getName(), iGold)))
  4074.         else :
  4075.             popup.setBodyString(localText.getText("TXT_KEY_SOMNIUM_ACCEPT_GAME_FUN", (gc.getPlayer(iPlayer).getName(), )))
  4076.  
  4077.         popup.addButton( localText.getText("AI_DIPLO_ACCEPT_1", ()) )
  4078.         popup.addButton( localText.getText("AI_DIPLO_NO_PEACE_3", ()) )
  4079.  
  4080.         popup.launch(False, PopupStates.POPUPSTATE_IMMEDIATE)
  4081.  
  4082.     def __EventSolmniumAcceptGameApply(self, playerID, userData, popupReturn):
  4083.         if userData :
  4084.             iPlayer, iOpponent, iGold = userData
  4085.             idButtonCliked = popupReturn.getButtonClicked()
  4086.             if idButtonCliked == 0 :
  4087.                 if (cs.canStartGame(iPlayer)) and (cs.canStartGame(iOpponent)) and (gc.getPlayer(iPlayer).isAlive()) and (gc.getPlayer(iOpponent).isAlive()) :
  4088.                     cs.startGame(iPlayer, iOpponent, iGold)
  4089.                 else :
  4090.                     CyInterface().addMessage(iPlayer, True, 25, CyTranslator().getText("TXT_KEY_SOMNIUM_CANT_START_GAME", (gc.getPlayer(iOpponent).getName(), )), '', 1, '', ColorTypes(7), -1, -1, False, False)
  4091.                     CyInterface().addMessage(iOpponent, True, 25, CyTranslator().getText("TXT_KEY_SOMNIUM_CANT_START_GAME", (gc.getPlayer(iPlayer).getName(), )), '', 1, '', ColorTypes(7), -1, -1, False, False)
  4092.             else :
  4093.                     CyInterface().addMessage(iPlayer, True, 25, CyTranslator().getText("TXT_KEY_SOMNIUM_REFUSE_GAME", (gc.getPlayer(iOpponent).getName(), iGold)), '', 1, '', ColorTypes(7), -1, -1, False, False)
  4094.  
  4095.     def __EventSolmniumConcedeGameBegin(self, argslist):
  4096.         popup = PyPopup.PyPopup(CvUtil.EventSolmniumConcedeGame, EventContextTypes.EVENTCONTEXT_ALL)
  4097.  
  4098.         popup.setUserData(argslist)
  4099.  
  4100.         popup.setHeaderString(localText.getText("TXT_KEY_SOMNIUM_START", ()))
  4101.         popup.setBodyString(localText.getText("TXT_KEY_SOMNIUM_CONCEDE_GAME", ()))
  4102.  
  4103.         popup.addButton( localText.getText("AI_DIPLO_ACCEPT_1", ()) )
  4104.         popup.addButton( localText.getText("AI_DIPLO_NO_PEACE_3", ()) )
  4105.  
  4106.         popup.launch(False, PopupStates.POPUPSTATE_IMMEDIATE)
  4107.  
  4108.     def __EventSolmniumConcedeGameApply(self, playerID, userData, popupReturn):
  4109.         if userData :
  4110.             idButtonCliked = popupReturn.getButtonClicked()
  4111.             if idButtonCliked == 0 :
  4112.                 cs.endGame(userData[0], userData[1])
  4113. ## FfH Card Game: end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement