def showRevoltDictPopup( self ) : bodStr = "" for idx in range(0,gc.getMAX_PLAYERS()): if( gc.getPlayer(idx).isEverAlive() ) : ePlayer = idx bodStr += "%d "%(idx) bodStr += "<color=%d,%d,%d,%d>" %(gc.getPlayer(ePlayer).getPlayerTextColorR(), gc.getPlayer(ePlayer).getPlayerTextColorG(), gc.getPlayer(ePlayer).getPlayerTextColorB(), gc.getPlayer(ePlayer).getPlayerTextColorA()) bodStr += "%s"%(gc.getPlayer(idx).getCivilizationShortDescription(0)) if( SDTK.sdObjectExists( 'BarbarianCiv', gc.getPlayer(idx) ) ) : bodStr += " BARB (%d)"%(SDTK.sdObjectGetVal( 'BarbarianCiv', gc.getPlayer(idx), "SpawnTurn" )) elif( not RevData.revObjectGetVal( gc.getPlayer(idx), 'RevolutionTurn' ) == None ): bodStr += " REB (%d)"%(RevData.revObjectGetVal( gc.getPlayer(idx), 'RevolutionTurn' )) bodStr += ": " for revData in RevData.revObjectGetVal( gc.getPlayer(idx), 'RevoltDict' ).values() : bodStr += "%d,%d ; "%(revData.iRevTurn,revData.dict.get('iRevPlayer',-1)) bodStr += "</color>" bodStr += "\n" # if( RevolutionInit.RevolutionInst == None ) : # bodStr += "RevolutionInit.RevInst is None\n" # else : # bodStr += "RevolutionInit.RevInst is initialized\n" popup = PyPopup.PyPopup() popup.setBodyString( bodStr ) popup.launch()
def onCityBuilt( argsList ): city = argsList[0] RevData.initCity( city ) pPlayer = GC.getPlayer( city.getOwner() ) if( pPlayer.isNPC() ) : city.setRevolutionIndex( int(.4*RevOpt.getAlwaysViolentThreshold()) ) city.setRevIndexAverage(city.getRevolutionIndex()) return if( not city.area().getID() == pPlayer.getCapitalCity().area().getID() ) : city.setRevolutionIndex( int(.35*RevOpt.getInstigateRevolutionThreshold()) ) else : city.setRevolutionIndex( int(.25*RevOpt.getInstigateRevolutionThreshold()) ) city.setRevIndexAverage(city.getRevolutionIndex()) revTurn = RevData.revObjectGetVal( pPlayer, 'RevolutionTurn' ) if revTurn != None and pPlayer.getNumCities() < 4 and GAME.getGameTurn() - revTurn < 25: relID = pPlayer.getStateReligion() if relID > -1: if LOG_DEBUG: print "[REV] New rebel city %s given rebel religion" % city.getName() city.setHasReligion(relID, True, False, False)
def assimilateHandler(iPlayerID, netUserData, popupReturn): global noAssimilateList if popupReturn.getButtonClicked() == 0: if LOG_DEBUG: print "[REV] Assimilation accepted!" if netUserData[2]: pMotherland = GC.getPlayer(RevData.revObjectGetVal(GC.getPlayer(netUserData[0]), 'MotherlandID' )) pMotherland.AI_changeAttitudeExtra( etUserData[1], pMotherland.AI_getAttitudeExtra(netUserData[0])) if LOG_DEBUG: print "[REV] Rebel motherland %s extra attidude to %s now %d"%(pMotherland.getCivilizationDescription(0), GC.getPlayer(netUserData[1]).getCivilizationDescription(0), pMotherland.AI_getAttitudeExtra(netUserData[0])) [iOdds, attackerTeam, victimTeam] = RevUtils.computeWarOdds(pMotherland, GC.getPlayer(netUserData[1]), GC.getPlayer(netUserData[0]).getCapitalCity().area(), False, True, True) if attackerTeam.canDeclareWar(victimTeam.getID()) and iOdds > GAME.getSorenRandNum(100, 'Revolution: War'): if LOG_DEBUG: print "[REV] Rebel motherland takes exception, team %d declare war on team %d"%(attackerTeam.getID(), victimTeam.getID()) attackerTeam.declareWar( victimTeam.getID(), True, WarPlanTypes.NO_WARPLAN ) GC.getPlayer(netUserData[1]).assimilatePlayer(netUserData[0]) elif popupReturn.getButtonClicked() == 1: if LOG_DEBUG: print "[REV] Assimilation postponed" else: if LOG_DEBUG: print "[REV] Assimilation rejected!" noAssimilateList.append(netUserData[0])
def showSpawnListPopup( self ) : bodStr = "" for idx in range(0,gc.getMAX_PLAYERS()): bodStr += "%d"%(idx) bodStr += ": " for [iPlayer,iRevoltIdx] in RevData.revObjectGetVal( gc.getPlayer(idx), 'SpawnList' ) : bodStr += "%d,%d ; "%(iPlayer,iRevoltIdx) bodStr += "\n" # if( RevolutionInit.RevolutionInst == None ) : # bodStr += "RevolutionInit.RevInst is None\n" # else : # bodStr += "RevolutionInit.RevInst is initialized\n" popup = PyPopup.PyPopup() popup.setBodyString( bodStr ) popup.launch()
def checkForAssimilation(): iNumPlayers = 0 iMaxEra = 0 players = [] for iPlayerX in xrange(MAX_PC_PLAYERS): CyPlayerX = GC.getPlayer(iPlayerX) if CyPlayerX.isAlive() and not CyPlayerX.isMinorCiv(): iNumPlayers += 1 if not CyPlayerX.isHuman(): players.append((iPlayerX, CyPlayerX)) iEra = CyPlayerX.getCurrentEra() if iEra > iMaxEra: iMaxEra = iEra if iNumPlayers == 0: return MAP = GC.getMap() minNumPlots = int((MAP.getLandPlots()/(1.0*iNumPlayers) + .5)/3.0) + 1 if minNumPlots > 21: minNumPlots = 21 elif minNumPlots < 9: minNumPlots = 9 iTurn = GAME.getGameTurn() for iPlayerX, CyPlayerX in players: CyTeamX = GC.getTeam(CyPlayerX.getTeam()) CyCity0 = CyPlayerX.getCapitalCity() if CyCity0 is None: continue iTurnAcquiredCity0 = CyCity0.getGameTurnAcquired() CyPlot0 = None szCiv = CyPlayerX.getCivilizationDescription(0) iMinCities = GC.getWorldInfo(MAP.getWorldSize()).getTargetNumCities() iNumCities = CyPlayerX.getNumCities() # We know this is greater than 0 as a capital city has been confirmed. bRiskWar = False iPlayerML = RevData.revObjectGetVal(CyPlayerX, 'MotherlandID') if iPlayerML != None: CyPlayerML = GC.getPlayer(iPlayerML) bWarSeparatist = CyTeamX.isAtWar(CyPlayerML.getTeam()) if bWarSeparatist: revTurn = RevData.revObjectGetVal(CyPlayerX, 'RevolutionTurn') if revTurn != None and iTurn - revTurn < 40: bRiskWar = True CyPlayerDominant = None joinPlayerID = RevData.revObjectGetVal(CyPlayerX, 'JoinPlayerID') if not joinPlayerID == None and iTurn - iTurnAcquiredCity0 < 30 and not CyTeamX.isAVassal(): if iNumCities < iMinCities: iOdds = 12 + iNumCities * 2 if iPlayerML != None and bWarSeparatist: iCivType = CyPlayerX.getCivilizationType() for CyCityML in CyPlayerML.cities(): if RevData.getCityVal(CyCityML, 'RevolutionCiv') == iCivType: revTurn = RevData.getCityVal(pCity, 'RevolutionTurn') if revTurn != None and iTurn - revTurn < 25: iOdds -= 2 if iOdds > 10 + GAME.getSorenRandNum(100, 'Revolution: Assimilate'): CyPlayerDominant = GC.getPlayer(joinPlayerID) print " Revolt - Assimilation! The rebel %s are requesting again to join the %s now that they've captured %d cities"%(szCiv, CyPlayerDominant.getCivilizationDescription(0), iNumCities) else: if iTurn - iTurnAcquiredCity0 > 15 and iNumCities < iMinCities: iTotalLand = CyPlayerX.getTotalLand() if iTotalLand < minNumPlots: if CyCity0.area().getNumCities() < iNumCities + 2: continue # Isolated if CyTeamX.getNumMembers() > 1: continue # In alliance iOdds = 2*(minNumPlots - iTotalLand) + (4 + 4*iMaxEra)/CyCity0.getPopulation() if CyCity0.getOccupationTimer() > 0: iOdds *= 3 iOdds += CyCity0.getRevolutionIndex()/100 CyPlot0 = CyCity0.plot() ### Special cases if CyTeamX.isAVassal(): if iOdds > 10 + GAME.getSorenRandNum(100, 'Revolution: Assimilate'): # If player is a Vassal, should only be allowed to assimilate with master CyPlayerMaster = None for iTeamY in xrange(MAX_PC_TEAMS): if not CyTeamX.isVassal(iTeamY): continue iPlayerMaster = GC.getTeam(iTeamY).getLeaderID() CyPlayerMaster = GC.getPlayer(iPlayerMaster) print " Revolt - Assimilation! Vassal %s considering assimilation to master %s" %(szCiv, CyPlayerMaster.getCivilizationDescription(0)) relations = CyPlayerX.AI_getAttitude(iPlayerMaster) if CyPlot0.getCulture(iPlayerMaster)/(1.0*CyPlot0.countTotalCulture()) > .25: # Assimilate with master with large culture in city if not relations == AttitudeTypes.ATTITUDE_FURIOUS: if not CyPlayerMaster.isHuman(): CyPlayerDominant = CyPlayerMaster elif not iPlayerX in noAssimilateList: CyPlayerDominant = CyPlayerMaster if CyPlayerDominant: print " Revolt - Assimilation to master based on culture" elif relations in (AttitudeTypes.ATTITUDE_PLEASED, AttitudeTypes.ATTITUDE_FRIENDLY): # Assimilate with friendly, powerful master masterPower = CyPlayerMaster.getPower() vassalPower = CyPlayerX.getPower() if masterPower > 3*vassalPower: if not CyPlayerMaster.isHuman(): CyPlayerDominant = CyPlayerMaster elif not iPlayerX in noAssimilateList: CyPlayerDominant = CyPlayerMaster if CyPlayerDominant: print " Revolt - Assimilation to friendly and powerful master" break elif CyPlot0.calculateCulturePercent(iPlayerX) < 60: ### Capital has foreign influence iPlayerCult = CyPlot0.calculateCulturalOwner() # iPlayerCult guaranteed to be alive if iPlayerCult != iPlayerX: iOdds += 15 if iOdds > 10 + GAME.getSorenRandNum(100, 'Revolution: Assimilate'): print " Revolt - Assimilation! %s considering assimilation by culture" % szCiv if iPlayerCult > -1 and iPlayerCult != iPlayerX and not CyPlayerX.AI_getAttitude(iPlayerCult) == AttitudeTypes.ATTITUDE_FURIOUS: ## Assimilate with cultural owner CyPlayerY = GC.getPlayer(iPlayerCult) if CyPlayerY.isAlive(): if not CyPlayerY.isHuman(): CyPlayerDominant = CyPlayerY elif not iPlayerX in noAssimilateList: CyPlayerDominant = CyPlayerY if CyPlayerDominant: print " Revolt - Assimilation culture owner: " + CyPlayerDominant.getCivilizationDescription(0) if not CyPlayerDominant: ## Check for good relations with second place culture iMaxCult2 = 0 for iPlayerY in xrange(MAX_PC_PLAYERS): if iPlayerY in (iPlayerX, iPlayerCult): continue CyPlayerY = GC.getPlayer(iPlayerY) if not CyPlayerY.isAlive(): continue iCulture = CyPlot0.getCulture(iPlayerY) if iCulture > iMaxCult2: iPlayerCult2 = iPlayerY CyPlayerCult2 = CyPlayerY iMaxCult2 = iCulture iTotalCulture = CyPlot0.countTotalCulture() if iMaxCult2/(1.0*iTotalCulture) > .2: relations = CyPlayerX.AI_getAttitude(iPlayerCult2) if relations in (AttitudeTypes.ATTITUDE_PLEASED, AttitudeTypes.ATTITUDE_FRIENDLY) \ or relations == AttitudeTypes.ATTITUDE_CAUTIOUS and iMaxCult2/(1.0*iTotalCulture) > .4: if not CyPlayerCult2.isHuman(): CyPlayerDominant = CyPlayerCult2 elif not iPlayerX in noAssimilateList: CyPlayerDominant = CyPlayerCult2 if CyPlayerDominant: print " Revolt - Assimilation to friendly, 2nd culture player" if CyPlayerDominant: # Assimilate! if CyPlayerDominant.isHuman(): # Zoom to city if CyPlot0 is None: CyPlot0 = CyCity0.plot() CyCamera().JustLookAt(CyPlot0.getPoint()) # Additions by Caesium et al caesiumtR = CyUserProfile().getResolutionString(CyUserProfile().getResolution()) caesiumtextResolution = caesiumtR.split('x') caesiumpasx = int(caesiumtextResolution[0])/10 caesiumpasy = int(caesiumtextResolution[1])/10 popup = PyPopup.PyPopup(RevDefs.assimilationPopup, contextType = EventContextTypes.EVENTCONTEXT_ALL, bDynamic = False) if centerPopups: popup.setPosition(3*caesiumpasx,3*caesiumpasy) # Additions by Caesium et al bodStr = TRNSLTR.getText("TXT_KEY_REV_ASSIM_POPUP", ()) %(szCiv, szCiv) if bRiskWar: bodStr += '\n\n' + TRNSLTR.getText("TXT_KEY_REV_ASSIM_POPUP_REBEL", ())%(CyPlayerML.getCivilizationDescription(0)) popup.setBodyString(bodStr) popup.addSeparator() popup.addButton(TRNSLTR.getText("TXT_KEY_REV_BUTTON_ACCEPT",())) popup.addButton(TRNSLTR.getText("TXT_KEY_REV_BUTTON_MAYBE_LATER",())) popup.addButton(TRNSLTR.getText("TXT_KEY_REV_BUTTON_NEVER",())) popup.setUserData((iPlayerX, CyPlayerDominant.getID(), bRiskWar)) popup.launch(bCreateOkButton = False) else: if bRiskWar: # Assimilating a rebel involves potential war declaration, attitude issues CyPlayerML.AI_changeAttitudeExtra(CyPlayerDominant.getID(), CyPlayerML.AI_getAttitudeExtra(iPlayerX)) print " Revolt - The %s (motherland of the rebel %s) is considering attacking the %s over the assimilation"%(CyPlayerML.getCivilizationDescription(0),szCiv,CyPlayerDominant.getCivilizationDescription(0)) [iOdds,attackerTeam,victimTeam] = RevUtils.computeWarOdds(CyPlayerML, CyPlayerDominant, CyCity0.area(), False, True, True ) if attackerTeam.canDeclareWar(victimTeam.getID()) and iOdds > GAME.getSorenRandNum(100, 'Revolution: War'): print " Revolt - Rebel motherland takes exception to assimilation, team %d declare war on team %d"%(attackerTeam.getID(), victimTeam.getID()) attackerTeam.declareWar( victimTeam.getID(), True, WarPlanTypes.NO_WARPLAN ) CyPlayerDominant.assimilatePlayer(iPlayerX)
def updateRevolutionIndices( argsList ) : owner,playerType,pCity,bConquest,bTrade = argsList newOwnerID = pCity.getOwner() newOwner = GC.getPlayer(newOwnerID) newOwnerCiv = newOwner.getCivilizationType() oldOwnerID = pCity.getPreviousOwner() orgOwnerID = pCity.getOriginalOwner() if( newOwner.isNPC() ) : return newRevIdx = 400 changeRevIdx = -40 if( bConquest ) : # Occupied cities also rack up rev points each turn newRevIdx += pCity.getRevolutionIndex()/4 newRevIdx = min( [newRevIdx, 600] ) if( pCity.plot().calculateCulturePercent( newOwnerID ) > 90 ) : changeRevIdx -= 75 newRevIdx -= 100 elif( pCity.plot().calculateCulturePercent( newOwnerID ) > 40 ) : changeRevIdx -= 35 newRevIdx -= 60 elif( pCity.plot().calculateCulturePercent( newOwnerID ) > 20 ) : changeRevIdx -= 30 elif( bTrade ) : newRevIdx += pCity.getRevolutionIndex()/3 newRevIdx = min( [newRevIdx, 650] ) if( pCity.plot().calculateCulturePercent( newOwnerID ) > 90 ) : newRevIdx -= 50 else : # Probably cultural conversion newRevIdx -= 100 if( pCity.plot().calculateCulturePercent( newOwnerID ) > 50 ) : changeRevIdx -= 25 if( newOwner.isRebel() and newOwnerCiv == RevData.getCityVal(pCity, 'RevolutionCiv') ) : changeRevIdx -= 50 newRevIdx -= 200 elif( newOwnerID == pCity.getOriginalOwner() ) : changeRevIdx -= 25 newRevIdx -= 100 if( pCity.getHighestPopulation() < 6 ) : changeRevIdx += 20 newRevIdx -= 50 changeRevIdx = int(math.floor( cityAcquiredModifier*changeRevIdx + .5 )) print " Revolt - Acquisition of %s by %s reduces rev indices by %d" %(pCity.getName(), newOwner.getCivilizationDescription(0), changeRevIdx) iCityID = pCity.getID() for pListCity in newOwner.cities(): if pListCity.getID() != iCityID: pListCity.changeRevolutionIndex(changeRevIdx) revIdxHist = RevData.getCityVal(pListCity,'RevIdxHistory') revIdxHist['Events'][0] += changeRevIdx RevData.updateCityVal(pListCity, 'RevIdxHistory', revIdxHist) print " Revolt - New rev idx for %s is %d" %(pCity.getName(), newRevIdx) pCity.setRevolutionIndex( newRevIdx ) pCity.setRevIndexAverage( newRevIdx ) pCity.setRevolutionCounter( acquiredTurns ) pCity.setReinforcementCounter( 0 ) RevData.updateCityVal( pCity, 'RevIdxHistory', RevDefs.initRevIdxHistory() ) if newOwner.isRebel(): if newOwner.getNumCities() > 1 and RevData.revObjectGetVal(newOwner, 'CapitalName') == CvUtil.convertToStr(pCity.getName()): # Rebel has captured their instigator city, make this their capital print "[REV] Rebel %s have captured their instigator city, %s! Moving capital." %(newOwner.getCivilizationDescription(0), pCity.getName()) if newOwner.isHuman(): # TODO: support this with a popup question pass else: eCapitalBuilding = GC.getInfoTypeForString(RevDefs.sXMLPalace) oldCapital = newOwner.getCapitalCity() oldCapital.setNumRealBuilding(eCapitalBuilding, 0) pCity.setNumRealBuilding(eCapitalBuilding, 1) # Ripple effects through other rebellious cities for cityX in GC.getPlayer(oldOwnerID).cities(): reinfCount = cityX.getReinforcementCounter() if reinfCount > 2 and RevData.getCityVal(cityX, 'RevolutionCiv') == newOwner.getCivilizationType(): if reinfCount < 5: reinfCount = 2 else: reinfCount -= 2 print "[REV] Accelerating reinforcement in " + cityX.getName() # Setting below two will turn off reinforcement if reinfCount < 2: reinfCount = 2 cityX.setReinforcementCounter(reinfCount)
def checkRebelBonuses(argsList): # Give bonuses to a rebel player who successfully captures one of their rebellious cities owner, playerType, pCity, bConquest, bTrade = argsList newOwnerID = pCity.getOwner() newOwner = GC.getPlayer(newOwnerID) newOwnerCiv = newOwner.getCivilizationType() oldOwnerID = pCity.getPreviousOwner() orgOwnerID = pCity.getOriginalOwner() # TODO: Handle case where city is acquired by disorganized rebels if newOwnerID == GC.getBARBARIAN_PLAYER() and pCity.getRevolutionCounter() > 0: print "[REV] City %s captured by barb rebels!" % pCity.getName() oldOwner = GC.getPlayer(oldOwnerID) if not oldOwnerID == orgOwnerID: orgOwner = GC.getPlayer(orgOwnerID) if pCity.countTotalCultureTimes100() > 100*100: if not oldOwnerID == pCity.findHighestCulture(): cultOwner = GC.getPlayer(pCity.findHighestCulture()) elif newOwnerCiv == RevData.getCityVal(pCity, 'RevolutionCiv'): # TODO: Check whether revolt is active in RevoltData if pCity.getReinforcementCounter() > 0 or (pCity.unhappyLevel(0) - pCity.happyLevel()) > 0: print "[REV] Rebellious pCity %s is captured by rebel identity %s (%d)!!!" %(pCity.getName(), newOwner.getCivilizationDescription(0), newOwnerCiv) newOwnerTeam = GC.getTeam(newOwner.getTeam()) oldOwner = GC.getPlayer(oldOwnerID) oldOwnerTeam = GC.getTeam(oldOwner.getTeam()) if oldOwnerTeam.isAVassal(): for teamID in xrange(MAX_PC_TEAMS): if oldOwnerTeam.isVassal(teamID): oldOwnerTeam = GC.getTeam(teamID) ix = pCity.getX() iy = pCity.getY() [iWorker, iBestDefender, iCounter, iAttack] = RevUtils.getHandoverUnitTypes(pCity) newUnitList = [] # Couple units regardless of rebel status newUnitList.append(newOwner.initUnit(iBestDefender, ix, iy, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)) if pCity.getPopulation() > 4: newUnitList.append(newOwner.initUnit(iCounter, ix, iy, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)) if newOwner.isRebel(): # Extra benefits if still considered a rebel szTxt = TRNSLTR.getText("TXT_KEY_REV_MESS_YOUR_CAPTURE",())%(pCity.getName()) icon = CyArtFileMgr().getInterfaceArtInfo("INTERFACE_RESISTANCE").getPath() sound = "AS2D_CITY_REVOLT" eMsgType = InterfaceMessageTypes.MESSAGE_TYPE_MINOR_EVENT iMsgTime = GC.getEVENT_MESSAGE_TIME() CvUtil.sendMessage(szTxt, newOwnerID, iMsgTime, icon, ColorTypes(8), ix, iy, True, True, eMsgType, sound, False) szTxt = TRNSLTR.getText("TXT_KEY_REV_MESS_REBEL_CONTROL",())%(newOwner.getCivilizationDescription(0),pCity.getName()) CvUtil.sendMessage(szTxt, oldOwnerID, iMsgTime, None, ColorTypes(7), eMsgType=eMsgType, bForce=False) # Gold iGold = GAME.getSorenRandNum(min([80,8*pCity.getPopulation()]), 'Rev') + 8 szTxt = TRNSLTR.getText("TXT_KEY_REV_MESS_YOUR_CAPTURE_GOLD",()) %(pCity.getName(),iGold) CvUtil.sendMessage(szTxt, newOwnerID, iMsgTime, icon, ColorTypes(8), ix, iy, False, False, eMsgType, sound, False) newOwner.changeGold(iGold) # Culture newCulVal = int( revCultureModifier*max([pCity.getCulture(oldOwnerID),pCity.countTotalCultureTimes100()/200]) ) newPlotVal = int( revCultureModifier*max([pCity.plot().getCulture(oldOwnerID),pCity.plot().countTotalCulture()/2]) ) RevUtils.giveCityCulture( pCity, newOwnerID, newCulVal, newPlotVal) # Extra units if iWorker != -1: newUnitList.append(newOwner.initUnit(iWorker, ix, iy, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)) if pCity.getPopulation() > 7: newUnitList.append(newOwner.initUnit(iBestDefender, ix, iy, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)) if pCity.getPopulation() > 4 and newOwnerTeam.getPower(True) < oldOwnerTeam.getPower(True)/4: newUnitList.append(newOwner.initUnit(iAttack, ix, iy, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)) if newOwner.getNumCities() <= 1: # Extra units for first city captured newUnitList.append(newOwner.initUnit(iCounter, ix, iy, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)) if newOwnerTeam.getPower(True) < oldOwnerTeam.getPower(True)/2: newUnitList.append(newOwner.initUnit(iBestDefender, ix, iy, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)) newUnitList.append(newOwner.initUnit(iAttack, ix, iy, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)) elif newOwnerTeam.getPower(True) < oldOwnerTeam.getPower(True): newUnitList.append(newOwner.initUnit(iAttack, ix, iy, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)) # Give a boat to island rebels if pCity.isCoastal(10) and pCity.area().getNumCities() < 3 and pCity.area().getNumTiles() < 25: iBestCombat = -1 for iUnitX in xrange(GC.getNumUnitInfos()): info = GC.getUnitInfo(iUnitX) if (info.getDomainType() == DomainTypes.DOMAIN_SEA and info.getUnitAIType(UnitAITypes.UNITAI_ASSAULT_SEA) and newOwner.canTrain(iUnitX,False,False) ): iCombat = info.getCombat() if iBestCombat < iCombat: bestUnit = info iBestUnit = iUnitX iBestCombat = iCombat if iBestCombat > -1: newOwner.initUnit(iBestUnit, ix, iy, UnitAITypes.UNITAI_ASSAULT_SEA, DirectionTypes.DIRECTION_SOUTH) print "Rev - Rebels get a %s to raid motherland" % bestUnit.getDescription() # Change city disorder timer to favor new player iTurns = pCity.getOccupationTimer() iTurns = iTurns/4 + 1 pCity.setOccupationTimer(iTurns) # Temporary happiness boost pCity.changeRevSuccessTimer( int(iTurns + RevUtils.getGameSpeedMod()*15) ) # Trigger golden age for rebel civ under certain circumstances revTurn = RevData.revObjectGetVal(newOwner, 'RevolutionTurn') if not revTurn == None and GAME.getGameTurn() - revTurn < 4*GAME.goldenAgeLength(): if newOwner.getNumCities() == 3: if not newOwner.getCitiesLost(): # By verifying they've never lost a city, gaurantee it doesn't happen multiple times szTxt = TRNSLTR.getText("TXT_KEY_REV_MESS_GOLDEN_AGE",()) CvUtil.sendMessage(szTxt, newOwnerID, iMsgTime, icon, ColorTypes(8), ix, iy, False, False, eMsgType, sound, False) newOwner.changeGoldenAgeTurns( int(1.5*GAME.goldenAgeLength()) ) else: # Conqueror not considered a rebel, fewer benefits # Culture newCulVal = int(revCultureModifier*max([pCity.getCulture(oldOwnerID)/2,pCity.countTotalCultureTimes100()/400])) newPlotVal = int(revCultureModifier*max([pCity.plot().getCulture(oldOwnerID)/2,pCity.plot().countTotalCulture()/4])) RevUtils.giveCityCulture(pCity, newOwnerID, newCulVal, newPlotVal) # Change city disorder timer to favor new player iTurns = pCity.getOccupationTimer() iTurns = min([iTurns, iTurns/3 + 1]) pCity.setOccupationTimer(iTurns) # Temporary happiness boost pCity.changeRevSuccessTimer(int(iTurns + RevUtils.getGameSpeedMod()*6)) # Injure free units for unit in newUnitList: if unit.canFight(): iDamage = 20 + GAME.getSorenRandNum(20,'Rev - Injure unit') unit.setDamage(iDamage, oldOwnerID) else: # City once rebelled as this civ type, but not currently rebellious if LOG_DEBUG: print "[REV] %s, captured by former rebel identity: %s (%d)!"%(pCity.getName(),newOwner.getCivilizationDescription(0),newOwnerCiv) newCulVal = int( revCultureModifier*max([pCity.getCulture(oldOwnerID)/2,pCity.countTotalCultureTimes100()/400]) ) newPlotVal = int( revCultureModifier*max([pCity.plot().getCulture(oldOwnerID)/2,pCity.plot().countTotalCulture()/4]) ) RevUtils.giveCityCulture( pCity, newOwnerID, newCulVal, newPlotVal) iTurns = pCity.getOccupationTimer() iTurns = iTurns/2 + 1 pCity.setOccupationTimer(iTurns)