Advertisement
Guest User

Untitled

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