def spawnConquerors(self, iPlayer, iPreferredTarget, tTL, tBR, iNumTargets, iYear, iIntervalTurns, iWarPlan = WarPlanTypes.WARPLAN_TOTAL): lCities = [] for city in utils.getAreaCities(utils.getPlotList(tTL, tBR)): if city.getOwner() != iPlayer and not gc.getTeam(city.getOwner()).isVassal(iPlayer): lCities.append(city) capital = gc.getPlayer(iPlayer).getCapitalCity() lTargetCities = [] for i in range(iNumTargets): if len(lCities) == 0: break targetCity = utils.getHighestEntry(lCities, lambda x: -utils.calculateDistance(x.getX(), x.getY(), capital.getX(), capital.getY()) + int(x.getOwner() == iPreferredTarget) * 1000) lTargetCities.append(targetCity) lCities.remove(targetCity) lOwners = [] for city in lTargetCities: if city.getOwner() not in lOwners: lOwners.append(city.getOwner()) if iPreferredTarget not in lOwners and gc.getPlayer(iPreferredTarget).isAlive(): gc.getTeam(iPlayer).declareWar(iPreferredTarget, True, iWarPlan) for iOwner in lOwners: gc.getTeam(iPlayer).declareWar(iOwner, True, iWarPlan) CyInterface().addMessage(iOwner, False, iDuration, CyTranslator().getText("TXT_KEY_UP_CONQUESTS_TARGET", (gc.getPlayer(iPlayer).getCivilizationShortDescription(0),)), "", 0, "", ColorTypes(iWhite), -1, -1, True, True) for city in lTargetCities: iExtra = 0 if utils.getHumanID() not in [iPlayer, city.getOwner()]: iExtra = 1 #max(1, gc.getPlayer(iPlayer).getCurrentEra()) tPlot = utils.findNearestLandPlot((city.getX(), city.getY()), iPlayer) iBestInfantry = utils.getBestInfantry(iPlayer) iBestSiege = utils.getBestSiege(iPlayer) if iPlayer == iGreece: iBestInfantry = iHoplite iBestSiege = iCatapult utils.makeUnitAI(iBestInfantry, iPlayer, tPlot, UnitAITypes.UNITAI_ATTACK_CITY, 2 + iExtra) utils.makeUnitAI(iBestSiege, iPlayer, tPlot, UnitAITypes.UNITAI_ATTACK_CITY, 1 + 2*iExtra) if iPlayer == iTamils: utils.makeUnitAI(iWarElephant, iPlayer, tPlot, UnitAITypes.UNITAI_ATTACK_CITY, 1) if iPlayer == iSpain: utils.makeUnitAI(utils.getBestCavalry(iPlayer), iPlayer, tPlot, UnitAITypes.UNITAI_ATTACK_CITY, 2 * iExtra)
def spawnConquerors(self, iPlayer, iPreferredTarget, tTL, tBR, iNumTargets, iYear, iIntervalTurns, iWarPlan = WarPlanTypes.WARPLAN_TOTAL): lCities = [] for city in utils.getAreaCities(utils.getPlotList(tTL, tBR)): if city.getOwner() != iPlayer and not gc.getTeam(city.getOwner()).isVassal(iPlayer): lCities.append(city) capital = gc.getPlayer(iPlayer).getCapitalCity() lTargetCities = [] for i in range(iNumTargets): if len(lCities) == 0: break targetCity = utils.getHighestEntry(lCities, lambda x: -utils.calculateDistance(x.getX(), x.getY(), capital.getX(), capital.getY()) + int(x.getOwner() == iPreferredTarget) * 1000) lTargetCities.append(targetCity) lCities.remove(targetCity) lOwners = [] for city in lTargetCities: if city.getOwner() not in lOwners: lOwners.append(city.getOwner()) if iPreferredTarget not in lOwners and gc.getPlayer(iPreferredTarget).isAlive(): gc.getTeam(iPlayer).declareWar(iPreferredTarget, True, iWarPlan) for iOwner in lOwners: gc.getTeam(iPlayer).declareWar(iOwner, True, iWarPlan) CyInterface().addMessage(iOwner, False, iDuration, CyTranslator().getText("TXT_KEY_UP_CONQUESTS_TARGET", (gc.getPlayer(iPlayer).getCivilizationShortDescription(0),)), "", 0, "", ColorTypes(iWhite), -1, -1, True, True) for city in lTargetCities: iExtra = 0 if utils.getHumanID() not in [iPlayer, city.getOwner()]: iExtra = 1 tPlot = utils.findNearestLandPlot((city.getX(), city.getY()), iPlayer) iBestInfantry = utils.getBestInfantry(iPlayer) iBestSiege = utils.getBestSiege(iPlayer) if iPlayer == iGreece: iBestInfantry = iGreekHoplite iBestSiege = iCatapult utils.makeUnitAI(iBestInfantry, iPlayer, tPlot, UnitAITypes.UNITAI_ATTACK_CITY, 2 + iExtra) utils.makeUnitAI(iBestSiege, iPlayer, tPlot, UnitAITypes.UNITAI_ATTACK_CITY, 1 + 2*iExtra) if iPlayer == iTamils: utils.makeUnitAI(iWarElephant, iPlayer, tPlot, UnitAITypes.UNITAI_ATTACK_CITY, 1)
def onGoldenAge(self, argsList): iPlayer = argsList[0] if not data.players[iPlayer].bFirstGoldenAge: data.players[iPlayer].bFirstGoldenAge = True capital = gc.getPlayer(iPlayer).getCapitalCity() if iPlayer in [iPolynesia, iVikings, iIndonesia, iNetherlands]: utils.makeUnit(iSettler, iPlayer, (capital.getX(), capital.getY()), 2) utils.makeUnit(utils.getBestWorker(iPlayer), iPlayer, (capital.getX(), capital.getY()), 1) utils.makeUnit(iWorkboat, iPlayer, (capital.getX(), capital.getY()), 1) utils.makeUnit(utils.getBestInfantry(iPlayer), iPlayer, (capital.getX(), capital.getY()), 1) utils.makeUnit(utils.getBestCounter(iPlayer), iPlayer, (capital.getX(), capital.getY()), 1) utils.makeUnit(utils.getBestDefender(iPlayer), iPlayer, (capital.getX(), capital.getY()), 1) utils.makeUnit(utils.getBestShip(iPlayer), iPlayer, (capital.getX(), capital.getY()), 4) elif iPlayer in [iMaya, iInca, iAztecs, iCongo]: utils.makeUnit(iSettler, iPlayer, (capital.getX(), capital.getY()), 2) utils.makeUnit(utils.getBestWorker(iPlayer), iPlayer, (capital.getX(), capital.getY()), 1) utils.makeUnit(utils.getBestInfantry(iPlayer), iPlayer, (capital.getX(), capital.getY()), 3) utils.makeUnit(utils.getBestCounter(iPlayer), iPlayer, (capital.getX(), capital.getY()), 3) utils.makeUnit(utils.getBestDefender(iPlayer), iPlayer, (capital.getX(), capital.getY()), 3) else: utils.makeUnit(utils.getBestWorker(iPlayer), iPlayer, (capital.getX(), capital.getY()), 1) utils.makeUnit(utils.getBestInfantry(iPlayer), iPlayer, (capital.getX(), capital.getY()), 2) utils.makeUnit(utils.getBestCounter(iPlayer), iPlayer, (capital.getX(), capital.getY()), 2) utils.makeUnit(utils.getBestDefender(iPlayer), iPlayer, (capital.getX(), capital.getY()), 2) utils.makeUnit(utils.getBestSiege(iPlayer), iPlayer, (capital.getX(), capital.getY()), 1) utils.makeUnit(utils.getBestCavalry(iPlayer), iPlayer, (capital.getX(), capital.getY()), 1) if iPlayer == iHarappa: utils.makeUnit(iCityBuilder, iPlayer, (capital.getX(), capital.getY()), 2) elif iPlayer == iAmerica: utils.makeUnit(iPioneer, iPlayer, (capital.getX(), capital.getY()), 2) else: utils.makeUnit(iSettler, iPlayer, (capital.getX(), capital.getY()), 2) sta.onGoldenAge(iPlayer)
def spawnConquerors(self, iPlayer, iPreferredTarget, tTL, tBR, iNumTargets, iYear, iIntervalTurns, iWarPlan=WarPlanTypes.WARPLAN_TOTAL): if not gc.getPlayer(iPlayer).isAlive(): for iTech in sta.getResurrectionTechs(iPlayer): gc.getTeam(gc.getPlayer(iPlayer).getTeam()).setHasTech( iTech, True, iPlayer, False, False) lCities = [] for city in utils.getAreaCities(utils.getPlotList(tTL, tBR)): if city.getOwner() != iPlayer and not gc.getTeam( city.getOwner()).isVassal(iPlayer): if (gc.getDefineINT("AIWAR_PY_CANNOT_DO_AIWAR_TO_HUMAN") > 0 and (city.getOwner() == utils.getHumanID())): pass else: lCities.append(city) capital = gc.getPlayer(iPlayer).getCapitalCity() lTargetCities = [] for i in range(iNumTargets): if len(lCities) == 0: break targetCity = utils.getHighestEntry( lCities, lambda x: -utils.calculateDistance( x.getX(), x.getY(), capital.getX(), capital.getY()) + int( x.getOwner() == iPreferredTarget) * 1000) lTargetCities.append(targetCity) lCities.remove(targetCity) lOwners = [] for city in lTargetCities: if city.getOwner() not in lOwners: lOwners.append(city.getOwner()) if iPreferredTarget >= 0 and iPreferredTarget not in lOwners and gc.getPlayer( iPreferredTarget).isAlive(): if (gc.getDefineINT("AIWAR_PY_CANNOT_DO_AIWAR_TO_HUMAN") > 0 and (iPreferredTarget == utils.getHumanID())): pass else: self.declareWar(iPlayer, iPreferredTarget, iWarPlan) for iOwner in lOwners: self.declareWar(iPlayer, iOwner, iWarPlan) CyInterface().addMessage( iOwner, False, iDuration, CyTranslator().getText( "TXT_KEY_UP_CONQUESTS_TARGET", (gc.getPlayer(iPlayer).getCivilizationShortDescription(0), )), "", 0, "", ColorTypes(iWhite), -1, -1, True, True) #####修改开始##### #消息传送区 if (gc.getDefineINT("PYTHON_USE_ADVANCE_ALERT") == 1): #参数控制 if iPlayer == iGreece: tem_text = '世界军事速递:亚历山大东征开始了!其麾下的军队正在横扫欧亚大陆!' CyInterface().addMessage(gc.getGame().getActivePlayer(), False, iDuration, tem_text, "", 0, "", ColorTypes(iWhite), -1, -1, True, True) # utils.show('军事速递:亚历山大东征开始了!') if iPlayer == iRome: tem_text = '世界军事速递:罗马帝国正在崛起,其军队所向披靡!' CyInterface().addMessage(gc.getGame().getActivePlayer(), False, iDuration, tem_text, "", 0, "", ColorTypes(iWhite), -1, -1, True, True) # utils.show('军事速递:罗马帝国正在崛起,其军队所向披靡!') if iPlayer == iMongolia: tem_text = '世界军事速递:蒙古帝国正在崛起,成吉思汗的军队所向披靡!' CyInterface().addMessage(gc.getGame().getActivePlayer(), False, iDuration, tem_text, "", 0, "", ColorTypes(iWhite), -1, -1, True, True) # utils.show('军事速递:蒙古帝国正在崛起,成吉思汗的军队所向披靡!') if iPlayer == iTurks: tem_text = '世界军事速递:突厥帝国正在崛起,其军队所向披靡!' CyInterface().addMessage(gc.getGame().getActivePlayer(), False, iDuration, tem_text, "", 0, "", ColorTypes(iWhite), -1, -1, True, True) # utils.show('军事速递:突厥帝国正在崛起,其军队所向披靡!') #百年战争 if iPlayer == iEngland and iYear <= 1450 and iYear >= 1250: tem_text = '英法百年战争的腥风血雨正式拉开帷幕!' CyInterface().addMessage(gc.getGame().getActivePlayer(), False, iDuration, tem_text, "", 0, "", ColorTypes(iWhite), -1, -1, True, True) # utils.show('军事速递:突厥帝国正在崛起,其军队所向披靡!') #圣女贞德 if iPlayer == iFrance and iYear <= 1550 and iYear >= 1350: tem_text = '圣女贞德唤起了法国人民的民族感,法国人民为了捍卫家园而战!' CyInterface().addMessage(gc.getGame().getActivePlayer(), False, iDuration, tem_text, "", 0, "", ColorTypes(iWhite), -1, -1, True, True) # utils.show('军事速递:突厥帝国正在崛起,其军队所向披靡!') #十字军 if iPlayer == iEngland and iYear <= 1200 and iYear >= 1000: tem_text = '轰动中东和欧洲的十字军东征开始了!' CyInterface().addMessage(gc.getGame().getActivePlayer(), False, iDuration, tem_text, "", 0, "", ColorTypes(iWhite), -1, -1, True, True) # utils.show('军事速递:突厥帝国正在崛起,其军队所向披靡!') #萨拉丁 if iPlayer == iEgypt and iYear <= 1300 and iYear >= 1100: tem_text = '年轻的领袖萨拉丁率领军队向十字军发起猛烈的进攻!' CyInterface().addMessage(gc.getGame().getActivePlayer(), False, iDuration, tem_text, "", 0, "", ColorTypes(iWhite), -1, -1, True, True) # utils.show('军事速递:突厥帝国正在崛起,其军队所向披靡!') #拿破仑战争 if iPlayer == iFrance and iYear <= 1900 and iYear >= 1700: tem_text = '拿破仑的军队正在欧洲所向披靡!' CyInterface().addMessage(gc.getGame().getActivePlayer(), False, iDuration, tem_text, "", 0, "", ColorTypes(iWhite), -1, -1, True, True) # utils.show('军事速递:突厥帝国正在崛起,其军队所向披靡!') if iYear <= 1930 and iYear >= 1900: tem_text = '第一次世界大战正在进行!' CyInterface().addMessage(gc.getGame().getActivePlayer(), False, iDuration, tem_text, "", 0, "", ColorTypes(iWhite), -1, -1, True, True) # utils.show('军事速递:突厥帝国正在崛起,其军队所向披靡!') if iYear <= 1960 and iYear >= 1930: tem_text = '第二次世界大战正在进行!' CyInterface().addMessage(gc.getGame().getActivePlayer(), False, iDuration, tem_text, "", 0, "", ColorTypes(iWhite), -1, -1, True, True) # utils.show('军事速递:突厥帝国正在崛起,其军队所向披靡!') #####修改结束##### ####修改开始#### for city in lTargetCities: iExtra = 0 + 2 # if utils.getHumanID() not in [iPlayer, city.getOwner()]: # iExtra += 1 #max(1, gc.getPlayer(iPlayer).getCurrentEra()) # # if iPlayer == iMongolia and utils.getHumanID() != iPlayer: # iExtra += 1 tPlot = utils.findNearestLandPlot((city.getX(), city.getY()), iPlayer) if (tPlot): iBestInfantry = utils.getBestInfantry(iPlayer) iBestSiege = utils.getBestSiege(iPlayer) if iPlayer == iGreece: iBestInfantry = iHoplite iBestSiege = iCatapult if iPlayer == iMongolia: iBestInfantry = iKeshik iExtra += 2 if iPlayer == iCarthage and iYear <= 150: iExtra = 0 iBestInfantry = iWarElephant tem_text = '迦太基的汉尼拔将军翻越了阿尔卑斯山,出现在米兰附近!' CyInterface().addMessage(gc.getGame().getActivePlayer(), False, iDuration, tem_text, "", 0, "", ColorTypes(iWhite), -1, -1, True, True) if iPlayer == iBarbarian and iYear <= 150: iExtra = -1 iBestInfantry = iMilitia utils.makeUnitAI(iBestInfantry, iPlayer, tPlot, UnitAITypes.UNITAI_ATTACK_CITY, 1) utils.makeUnitAI(iLightSwordsman, iPlayer, tPlot, UnitAITypes.UNITAI_ATTACK_CITY, 1) tem_text = '斯巴达克斯吹响了反抗罗马的起义号角!' CyInterface().addMessage(gc.getGame().getActivePlayer(), False, iDuration, tem_text, "", 0, "", ColorTypes(iWhite), -1, -1, True, True) if iPlayer == iEngland and iYear <= 1500: iExtra -= 0 iBestInfantry = iLongbowman # utils.makeUnitAI(iBestInfantry, iPlayer, tPlot, UnitAITypes.UNITAI_ATTACK_CITY, 2) # iBestSiege = iCatapult if (iPlayer == iEngland and iYear <= 1250) or ( iPlayer == iHolyRome and iYear <= 1250) or (iPlayer == iFrance and iYear <= 1250): iExtra -= 1 # iBestInfantry = iLongbowman # utils.makeUnitAI(iBestInfantry, iPlayer, tPlot, UnitAITypes.UNITAI_ATTACK_CITY, 2) # iBestSiege = iCatapult if iPlayer == iTurks and iYear <= 1250: iExtra -= 2 if iYear >= 1800: iExtra += 1 if iYear >= 1900: iExtra += 1 if iYear >= 1930: iExtra += 1 if iPreferredTarget == utils.getHumanID() and iYear >= 1300: iExtra = gc.getGame().getHandicapType() + 1 utils.makeUnitAI(iBestInfantry, iPlayer, tPlot, UnitAITypes.UNITAI_ATTACK_CITY, max(2 + iExtra, 1)) utils.makeUnitAI(iBestSiege, iPlayer, tPlot, UnitAITypes.UNITAI_ATTACK_CITY, max(1 + iExtra, 1)) ####修改结束##### if iPlayer == iGreece: utils.makeUnitAI(iCompanion, iPlayer, tPlot, UnitAITypes.UNITAI_ATTACK_CITY, 1) if iPlayer == iTamils: utils.makeUnitAI(iWarElephant, iPlayer, tPlot, UnitAITypes.UNITAI_ATTACK_CITY, 1) if iPlayer == iSpain: utils.makeUnitAI(utils.getBestCavalry(iPlayer), iPlayer, tPlot, UnitAITypes.UNITAI_ATTACK_CITY, 2 * iExtra) if iPlayer == iTurks: utils.makeUnitAI(utils.getBestCavalry(iPlayer), iPlayer, tPlot, UnitAITypes.UNITAI_ATTACK_CITY, 2 + iExtra)