def doMoveGrasshoppers(pPlot): # Am Plot bleiben 2:3 if CvUtil.myRandom(3, "doMoveGrasshoppers") != 0: return iFeatGrasshopper = gc.getInfoTypeForString("FEATURE_GRASSHOPPER") lPlots = [] # Umkreis checken iRange = 1 for x in xrange(-iRange, iRange+1): for y in xrange(-iRange, iRange+1): loopPlot = plotXY(pPlot.getX(), pPlot.getY(), x, y) if loopPlot and not loopPlot.isNone(): if loopPlot.getFeatureType() == -1: if not loopPlot.isWater() and not loopPlot.isPeak(): lPlots.append(loopPlot) if lPlots: iRand = CvUtil.myRandom(len(lPlots), "doMoveGrasshoppers") # Heuschrecken vom alten Plot entfernen pPlot.setFeatureType(-1, 0) # Heuschrecken auf dem neuen Plot erzeugen lPlots[iRand].setFeatureType(iFeatGrasshopper, 0) # Farmen auf dem neuen Plot vernichten (ausgenommen Weiden) if lPlots[iRand].getImprovementType() != gc.getInfoTypeForString("IMPROVEMENT_PASTURE") \ and lPlots[iRand].getImprovementType() in L.LFarms: lPlots[iRand].setImprovementType(-1)
def convertCity(pCity): iReligion = gc.getInfoTypeForString("RELIGION_CHRISTIANITY") iPlayer = pCity.getOwner() pPlayer = gc.getPlayer(iPlayer) # nicht bei Judentum, Hindu, Buddh und Jain if (not pCity.isHasReligion(gc.getInfoTypeForString("RELIGION_JUDAISM")) and not pCity.isHasReligion(gc.getInfoTypeForString("RELIGION_HINDUISM")) and not pCity.isHasReligion(gc.getInfoTypeForString("RELIGION_BUDDHISM")) and not pCity.isHasReligion(gc.getInfoTypeForString("RELIGION_JAINISMUS"))): if pCity.isCapital(): iChance = 40 # 2.5% elif pCity.isHasBuilding(gc.getInfoTypeForString("BUILDING_STADT")): if pCity.isHasBuilding(gc.getInfoTypeForString("BUILDING_SKLAVENMARKT")): iChance = 30 # 3% else: iChance = 50 # 2% elif pCity.isHasBuilding(gc.getInfoTypeForString("BUILDING_SKLAVENMARKT")): iChance = 40 # 2.5% else: iChance = 75 # 1.5% # bei folgenden Civics Chance verringern if pPlayer.isCivic(gc.getInfoTypeForString("CIVIC_THEOCRACY")): iChance += 25 if pPlayer.isCivic(gc.getInfoTypeForString("CIVIC_AMPHIKTIONIE")): iChance += 25 if CvUtil.myRandom(iChance, "convertCity") == 1: pCity.setHasReligion(iReligion, 1, 1, 0) if pPlayer.isHuman(): iRand = 1 + CvUtil.myRandom(3, "TXT_KEY_MESSAGE_HERESY_2CHRIST_") CyInterface().addMessage(iPlayer, True, 10, CyTranslator().getText("TXT_KEY_MESSAGE_HERESY_2CHRIST_"+str(iRand),(pCity.getName(),0)), None, 2,"Art/Interface/Buttons/Actions/button_kreuz.dds", ColorTypes(11), pCity.getX(), pCity.getY(), True, True)
def setAnimals(eAnimal,plots): pBarbPlayer = gc.getPlayer(gc.getBARBARIAN_PLAYER()) eUnitClass = gc.getUnitInfo(eAnimal).getUnitClassType() iBarbUnits = pBarbPlayer.getUnitClassCount(eUnitClass) # 0 = WORLDSIZE_DUEL # 1 = WORLDSIZE_TINY # 2 = WORLDSIZE_SMALL # 3 = WORLDSIZE_STANDARD # 4 = WORLDSIZE_LARGE # 5 = WORLDSIZE_HUGE iMapSize = gc.getMap().getWorldSize() iAnimals = iMapSize + 1 - iBarbUnits # Ausnahmen if eAnimal == gc.getInfoTypeForString("UNIT_UR"): iAnimals = 2 - iBarbUnits # maximal 2 if iAnimals <= 0: return # Tiere setzen i = 0 while i < iAnimals: iRand = CvUtil.myRandom(len(plots), "spawnAnimalOnPlot") CvUtil.spawnUnit(eAnimal, plots[iRand], pBarbPlayer) #plots.remove(plots[iRand]) i += 1
def doRevoltAnarchy(iPlayer): pPlayer = gc.getPlayer(iPlayer) iRand = CvUtil.myRandom(3, "getAnarchyTurns") if iRand == 1: iBuilding = gc.getInfoTypeForString("BUILDING_PLAGUE") iNumCities = pPlayer.getNumCities() if iNumCities == 0: return iCityPlague = 0 iCityRevolt = 0 (loopCity, pIter) = pPlayer.firstCity(False) while loopCity: if not loopCity.isNone() and loopCity.getOwner() == iPlayer: #only valid cities if loopCity.isHasBuilding(iBuilding): iCityPlague += 1 if loopCity.getOccupationTimer() > 1: # Flunky: changed 0->1, because the counter is not yet updated from the previous round. iCityRevolt += 1 (loopCity, pIter) = pPlayer.nextCity(pIter, False) if iCityRevolt > 1 and iNumCities <= iCityRevolt * 2: pPlayer.changeAnarchyTurns(3) if pPlayer.isHuman(): popupInfo = CyPopupInfo() popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT) popupInfo.setText(CyTranslator().getText("TXT_KEY_MESSAGE_PLAYER_ANARCHY_FROM_REVOLTS", ("", ))) popupInfo.addPopup(iPlayer) elif iNumCities <= iCityPlague * 2: pPlayer.changeAnarchyTurns(2) if pPlayer.isHuman(): popupInfo = CyPopupInfo() popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT) popupInfo.setText(CyTranslator().getText("TXT_KEY_MESSAGE_PLAYER_ANARCHY_FROM_PLAGUE", ("", ))) popupInfo.addPopup(iPlayer)
def getRandomPlot(lPlots): # Zufallsplot vorher auswählen, falls überall Einheiten drauf stehn -> jumpToNearestValidPlot iRand = CvUtil.myRandom(len(lPlots), "") Notfallsplot = lPlots[iRand] # Einen Plot aus den vorgegebenen Plots raussuchen, wo keine Einheiten drauf stehen lNewPlots = [] for p in lPlots: if p.getNumUnits() == 0: lNewPlots.append(p) if len(lNewPlots) == 0: for i in range(Notfallsplot.getNumUnits()): Notfallsplot.getUnit(i).jumpToNearestValidPlot() return Notfallsplot else: iRand = CvUtil.myRandom(len(lNewPlots), "") return lNewPlots[iRand]
def doMoveDesertStorm(lDesertStorm): iFeatDesertstorm = gc.getInfoTypeForString("FEATURE_FALLOUT") iTerrainDesert = gc.getInfoTypeForString("TERRAIN_DESERT") #iDarkIce = gc.getInfoTypeForString("FEATURE_DARK_ICE") lImprovements = [ gc.getInfoTypeForString("IMPROVEMENT_FORT"), gc.getInfoTypeForString("IMPROVEMENT_FORT2"), gc.getInfoTypeForString("IMPROVEMENT_TURM2"), gc.getInfoTypeForString("IMPROVEMENT_MINE") ] # Wegen Wind von West nach Ost, die Reihenfolge der Plot-Liste umkehren lDesertStorm.reverse() for p in lDesertStorm: loopPlot = plotXY(p.getX(), p.getY(), 2, 0) # 2-Plot-Schritte nach Osten if loopPlot and not loopPlot.isNone(): if loopPlot.getTerrainType() == iTerrainDesert: if loopPlot.getFeatureType() == -1: if not loopPlot.isPeak(): bMeldung = False # Entferne Modernisierung 1:3 if loopPlot.getImprovementType() not in lImprovements: if CvUtil.myRandom(3, "doDestroyImprovementDueToDesertStorm") == 1: loopPlot.setImprovementType(-1) bMeldung = True # Entferne Strasse 1:3 if loopPlot.getRouteType() == 0 and not loopPlot.isCity(): if CvUtil.myRandom(3, "doDestroyRouteDueToDesertStorm") == 1: loopPlot.setRouteType(-1) bMeldung = True # Sandsturm setzen loopPlot.setFeatureType(iFeatDesertstorm, 0) # Meldung an den Spieler if bMeldung and loopPlot.getOwner() != -1: if gc.getPlayer(loopPlot.getOwner()).isHuman(): CyInterface().addMessage(gc.getPlayer(loopPlot.getOwner()).getID(), True, 12, CyTranslator().getText("TXT_KEY_DISASTER_DESERTSTORM", ("", )), None, 2, gc.getFeatureInfo(iFeatDesertstorm).getButton(), ColorTypes(7), loopPlot.getX(), loopPlot.getY(), True, True) # Sandsturm entfernen (vorheriger Plot) p.setFeatureType(-1, 0)
def doFogOfWar(iPlayer,iGameTurn): pPlayer = gc.getPlayer(iPlayer) iTeam = pPlayer.getTeam() pTeam = gc.getTeam(iTeam) # Human oder KI alle x Runden, aber unterschiedliche Civs pro Runde fuer optimale Rundenzeiten if pPlayer.isHuman() or (iGameTurn % 20 == iPlayer % 20 and pTeam.isMapTrading()): bDontGoBlackAnymore = False bShowCoasts = False bShowPeaksAndRivers = False if pTeam.isHasTech(gc.getInfoTypeForString("TECH_KARTOGRAPHIE2")): # Strassenkarten bDontGoBlackAnymore = True elif pTeam.isHasTech(gc.getInfoTypeForString("TECH_KARTEN")): # Karte zeichnen bShowCoasts = True bShowPeaksAndRivers = True elif pTeam.isHasTech(gc.getInfoTypeForString("TECH_KARTOGRAPHIE")): # Kartographie: Erste Karten bShowCoasts = True if bDontGoBlackAnymore: return iRange = CyMap().numPlots() for iI in xrange(iRange): pPlot = CyMap().plotByIndex(iI) if not pPlot.isVisible(iTeam, 0): bGoBlack = True # fully black or standard fog of war if pPlot.isCity(): pCity = pPlot.getPlotCity() if pCity.isCapital(): bGoBlack = False elif pCity.getNumWorldWonders() > 0: bGoBlack = False # Holy Mountain Quest if bGoBlack: if CvUtil.getScriptData(pPlot, ["H", "t"]) == "X": bGoBlack = False # Improvements (to normal fog of war) # if bGoBlack: # if pPlot.getImprovementType() == improv1 or pPlot.getImprovementType() == improv2: bGoBlack = False # 50% Chance Verdunkelung if bGoBlack and CvUtil.myRandom(2, "bGoBlack") == 0: bGoBlack = False # Black fog if bGoBlack and pPlot.isRevealed(iTeam, 0): # River and coast (land only) #if pPlot.isRevealed (iTeam, 0) and not (pPlot.isRiverSide() or pPlot.isCoastalLand()): pPlot.setRevealed (iTeam,0,0,-1) # River and coast (land and water) #if pPlot.isRevealed (iTeam, 0) and not (pPlot.isRiverSide() or pPlot.isCoastalLand() or (pPlot.isAdjacentToLand() and pPlot.isWater())): pPlot.setRevealed (iTeam,0,0,-1) if bShowCoasts and (pPlot.isCoastalLand() or pPlot.isAdjacentToLand() and pPlot.isWater()): continue if bShowPeaksAndRivers and (pPlot.isRiverSide() or pPlot.isPeak()): continue pPlot.setRevealed(iTeam, 0, 0, -1)
def doVikings(): iBarbPlayer = gc.getBARBARIAN_PLAYER() pBarbPlayer = gc.getPlayer(iBarbPlayer) iUnitTypeShip = gc.getInfoTypeForString("UNIT_VIKING_1") iUnitTypeUnit = gc.getInfoTypeForString("UNIT_VIKING_2") iDarkIce = gc.getInfoTypeForString("FEATURE_DARK_ICE") iMapW = gc.getMap().getGridWidth() iMapH = gc.getMap().getGridHeight() bMeldung = False for _ in xrange(4): iRandX = CvUtil.myRandom(iMapW, "W") iRandY = iMapH - CvUtil.myRandom(5, "H") loopPlot = gc.getMap().plot(iRandX, iRandY) if loopPlot is not None and not loopPlot.isNone(): if loopPlot.getFeatureType() == iDarkIce: continue if not loopPlot.isUnit() and loopPlot.isWater( ) and not loopPlot.isLake() and not loopPlot.isOwned(): # Wikinger erstellen bMeldung = True CvUtil.spawnUnit(iUnitTypeShip, loopPlot, pBarbPlayer) for _ in xrange(4): CvUtil.spawnUnit(iUnitTypeUnit, loopPlot, pBarbPlayer) if bMeldung: if gc.getGame().getGameTurnYear() == 400: for iPlayer in xrange(gc.getMAX_PLAYERS()): pPlayer = gc.getPlayer(iPlayer) if pPlayer.isAlive() and pPlayer.isHuman(): popupInfo = CyPopupInfo() popupInfo.setButtonPopupType( ButtonPopupTypes.BUTTONPOPUP_TEXT) popupInfo.setText(CyTranslator().getText( "TXT_KEY_MESSAGE_VIKINGS", ("", ))) popupInfo.addPopup(pPlayer.getID()) CyAudioGame().Play2DSound("AS2D_THEIRDECLAREWAR")
def doStrandgut(): iBarbPlayer = gc.getBARBARIAN_PLAYER() pBarbPlayer = gc.getPlayer(iBarbPlayer) iTreibgut = gc.getInfoTypeForString("UNIT_TREIBGUT") iStrandgut = gc.getInfoTypeForString("UNIT_STRANDGUT") iGoldkarren = gc.getInfoTypeForString("UNIT_GOLDKARREN") iDarkIce = gc.getInfoTypeForString("FEATURE_DARK_ICE") eCoast = gc.getInfoTypeForString("TERRAIN_COAST") lUnits = PyPlayer(iBarbPlayer).getUnitsOfType(iTreibgut) # CyInterface().addMessage(gc.getGame().getActivePlayer(), True, 15, CyTranslator().getText("TXT_KEY_MESSAGE_TEST", ("Test",len(lUnits))), None, 2, None, ColorTypes(11), 0, 0, False, False) for loopUnit in lUnits: pPlot = loopUnit.plot() if pPlot.getTerrainType() == eCoast: lPlots = [] iX = pPlot.getX() iY = pPlot.getY() # iRange = 1 for iI in xrange(DirectionTypes.NUM_DIRECTION_TYPES): loopPlot = plotDirection(iX, iY, DirectionTypes(iI)) if loopPlot and not loopPlot.isNone(): if not loopPlot.isWater(): if not loopPlot.isPeak() and not loopPlot.isUnit() and loopPlot.getFeatureType() != iDarkIce: lPlots.append(loopPlot) if lPlots: pPlot = lPlots[CvUtil.myRandom(len(lPlots), "strandgut")] # Create Strandgut CvUtil.spawnUnit(iStrandgut, pPlot, pBarbPlayer) iPlotOwner = pPlot.getOwner() if iPlotOwner != -1 and gc.getPlayer(iPlotOwner).isHuman(): CyInterface().addMessage(iPlotOwner, True, 15, CyTranslator().getText("TXT_KEY_TREIB2STRANDGUT", ()), None, 2, "Art/Interface/Buttons/Units/button_unit_strandgut.dds", ColorTypes(11), pPlot.getX(), pPlot.getY(), True, True) # Disband Treibgut # loopUnit.doCommand(CommandTypes.COMMAND_DELETE, -1, -1) loopUnit.kill(True, -1) # RAMK_CTD elif pPlot.isCity(): # Create Goldkarren CvUtil.spawnUnit(iGoldkarren, pPlot, pBarbPlayer) # Disband Treibgut # CyInterface().addMessage(gc.getGame().getActivePlayer(), True, 15, CyTranslator().getText("disbandTreibgutCity", ()), None, 2, None, ColorTypes(11), pPlot.getX(), pPlot.getY(), False, False) # loopUnit.doCommand(CommandTypes.COMMAND_DELETE, -1, -1) loopUnit.kill(True, -1) # RAMK_CTD
def doHistory(): """++++++++++++++++++ Historische Texte ++++++++++++++++++++++++++++++++++++++++++++++""" iGameYear = gc.getGame().getGameTurnYear() # txts = 0 if iGameYear in lNumHistoryTexts: txts = lNumHistoryTexts[iGameYear] # if txts > 0: iRand = CvUtil.myRandom(txts, "doHistory") # iRand 0 bedeutet keinen Text anzeigen. Bei mehr als 2 Texte immer einen einblenden if txts > 2: iRand += 1 if iRand > 0: text = "TXT_KEY_HISTORY_" if iGameYear < 0: text = text + str(iGameYear * (-1)) + "BC_" + str(iRand) else: text = text + str(iGameYear) + "AD_" + str(iRand) text = CyTranslator().getText("TXT_KEY_HISTORY", ("",)) + " " + CyTranslator().getText(text, ("",)) CyInterface().addMessage(gc.getGame().getActivePlayer(), True, 15, text, None, 2, None, ColorTypes(14), 0, 0, False, False)
def setUnitIntoCave(pPlot): lUnits = [] if pPlot.getFeatureType() == gc.getInfoTypeForString("FEATURE_FOREST"): lUnits.append(gc.getInfoTypeForString("UNIT_BEAR")) lUnits.append(gc.getInfoTypeForString("UNIT_WOLF")) elif pPlot.getFeatureType() == gc.getInfoTypeForString("FEATURE_DICHTERWALD"): lUnits.append(gc.getInfoTypeForString("UNIT_BEAR")) lUnits.append(gc.getInfoTypeForString("UNIT_WOLF")) lUnits.append(gc.getInfoTypeForString("UNIT_UR")) elif pPlot.getFeatureType() == gc.getInfoTypeForString("FEATURE_JUNGLE"): lUnits.append(gc.getInfoTypeForString("UNIT_PANTHER")) lUnits.append(gc.getInfoTypeForString("UNIT_LEOPARD")) lUnits.append(gc.getInfoTypeForString("UNIT_TIGER")) elif pPlot.getTerrainType() == gc.getInfoTypeForString("TERRAIN_DESERT"): lUnits.append(gc.getInfoTypeForString("UNIT_LION")) lUnits.append(gc.getInfoTypeForString("UNIT_HYENA")) elif pPlot.getTerrainType() == gc.getInfoTypeForString("TERRAIN_TUNDRA"): lUnits.append(gc.getInfoTypeForString("UNIT_WOLF")) if lUnits: iRand = CvUtil.myRandom(len(lUnits), "setUnitIntoCave") CvUtil.spawnUnit(lUnits[iRand], pPlot, gc.getPlayer(gc.getBARBARIAN_PLAYER()))
def doHuns(): iHuns = 0 iGameTurn = gc.getGame().getGameTurnYear() if iGameTurn == 250: iHuns = 20 elif iGameTurn == 255: iHuns = 24 elif iGameTurn == 260: iHuns = 28 elif iGameTurn >= 270 and iGameTurn <= 400 and iGameTurn % 10 == 0: iHuns = 28 # Diesen Wert auch unten bei der Meldung angeben! if iHuns == 0: return CivHuns = gc.getInfoTypeForString("CIVILIZATION_HUNNEN") bHunsAlive = False iMaxPlayers = gc.getMAX_PLAYERS() for iPlayer in xrange(iMaxPlayers): pPlayer = gc.getPlayer(iPlayer) # Hunnen sollen nur auftauchen, wenn es nicht bereits Hunnen gibt if pPlayer.getCivilizationType() == CivHuns and pPlayer.isAlive(): bHunsAlive = True break if not bHunsAlive: for iPlayer in xrange(iMaxPlayers): pPlayer = gc.getPlayer(iPlayer) # Message PopUps if iHuns < 28 and pPlayer.isAlive() and pPlayer.isHuman(): popupInfo = CyPopupInfo() popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT) if iHuns == 20: popupInfo.setText(CyTranslator().getText( "TXT_KEY_MESSAGE_HUNNEN_1", ("", ))) elif iHuns == 24: CyAudioGame().Play2DSound("AS2D_THEIRDECLAREWAR") popupInfo.setText(CyTranslator().getText( "TXT_KEY_MESSAGE_HUNNEN_2", ("", ))) else: popupInfo.setText(CyTranslator().getText( "TXT_KEY_MESSAGE_HUNNEN_3", ("", ))) popupInfo.addPopup(pPlayer.getID()) iMapW = gc.getMap().getGridWidth() iMapH = gc.getMap().getGridHeight() iDarkIce = gc.getInfoTypeForString("FEATURE_DARK_ICE") # 15 Versuche einen Plot zu finden bPlot = False for _ in xrange(15): # Diese Koordinaten entsprechen Nord-Osten iRandX = iMapW - 15 + CvUtil.myRandom(15, "W2") iRandY = iMapH - 15 + CvUtil.myRandom(15, "H2") loopPlot = gc.getMap().plot(iRandX, iRandY) if loopPlot is not None and not loopPlot.isNone(): if loopPlot.getFeatureType( ) != iDarkIce and not loopPlot.isUnit( ) and not loopPlot.isWater() and not loopPlot.isOwned( ) and not loopPlot.isPeak(): bPlot = True break if not bPlot: return # Hunnen versuchen zu erstellen False: Ausgeschaltet! if iGameTurn >= 250 and gc.getGame().countCivPlayersAlive( ) < iMaxPlayers and False: # freie PlayerID herausfinden iHunsID = 0 for i in xrange(iMaxPlayers): j = iMaxPlayers - i - 1 pPlayer = gc.getPlayer(j) if not pPlayer.isAlive(): iHunsID = j break if iHunsID == 0: return # Hunnen erstellen LeaderHuns = gc.getInfoTypeForString("LEADER_ATTILA") gc.getGame().addPlayer(iHunsID, LeaderHuns, CivHuns) pPlayer = gc.getPlayer(iHunsID) iUnitSettler = gc.getInfoTypeForString("UNIT_SETTLER") iUnitSpearman = gc.getInfoTypeForString("UNIT_SPEARMAN") iUnitWorker = gc.getInfoTypeForString("UNIT_WORKER") iUnitKeshik = gc.getInfoTypeForString("UNIT_MONGOL_KESHIK") iUnitArcher = gc.getInfoTypeForString("UNIT_REFLEX_ARCHER") iUnitHorse = gc.getInfoTypeForString("UNIT_HORSE") for _ in xrange(3): CvUtil.spawnUnit(iUnitSettler, loopPlot, pPlayer) for _ in xrange(4): CvUtil.spawnUnit(iUnitSpearman, loopPlot, pPlayer) for _ in xrange(6): CvUtil.spawnUnit(iUnitWorker, loopPlot, pPlayer) for _ in xrange(8): CvUtil.spawnUnit(iUnitKeshik, loopPlot, pPlayer) for _ in xrange(9): CvUtil.spawnUnit(iUnitArcher, loopPlot, pPlayer) for _ in xrange(9): CvUtil.spawnUnit(iUnitHorse, loopPlot, pPlayer) pPlayer.setCurrentEra(3) pPlayer.setGold(300) # increasing Anger to all other CIVs # and looking for best tech player pTeam = gc.getTeam(pPlayer.getTeam()) iPlayerBestTechScore = -1 iTechScore = 0 for i in xrange(iMaxPlayers): pSecondPlayer = gc.getPlayer(i) # increases Anger for all AIs if pSecondPlayer.getID() != pPlayer.getID( ) and pSecondPlayer.isAlive(): # Haltung aendern pPlayer.AI_changeAttitudeExtra(i, -5) # Krieg erklaeren pTeam.declareWar(pSecondPlayer.getTeam(), 0, 6) # TechScore herausfinden if iTechScore < pSecondPlayer.getTechScore(): iTechScore = pSecondPlayer.getTechScore() iPlayerBestTechScore = i # Techs geben if iPlayerBestTechScore > -1: xTeam = gc.getTeam( gc.getPlayer(iPlayerBestTechScore).getTeam()) iTechNum = gc.getNumTechInfos() for iTech in xrange(iTechNum): if gc.getTechInfo(iTech) is not None and xTeam.isHasTech( iTech) and not pTeam.isHasTech( iTech) and gc.getTechInfo(iTech).isTrade(): pTeam.setHasTech(iTech, 1, iHunsID, 0, 0) else: iUnitType = gc.getInfoTypeForString('UNIT_MONGOL_KESHIK') pBarbPlayer = gc.getPlayer(gc.getBARBARIAN_PLAYER()) for _ in xrange(iHuns): CvUtil.spawnUnit(iUnitType, loopPlot, pBarbPlayer)
def doSeevoelker(): iBarbPlayer = gc.getBARBARIAN_PLAYER() pBarbPlayer = gc.getPlayer(iBarbPlayer) iUnitTypeShip = gc.getInfoTypeForString("UNIT_SEEVOLK") # Cargo: 3 iUnitTypeWarrior1 = gc.getInfoTypeForString("UNIT_SEEVOLK_1") iUnitTypeWarrior2 = gc.getInfoTypeForString("UNIT_SEEVOLK_2") iUnitTypeWarrior3 = gc.getInfoTypeForString("UNIT_SEEVOLK_3") # Handicap: 0 (Settler) - 8 (Deity) # Worldsize: 0 (Duell) - 5 (Huge) iRange = 1 + gc.getMap().getWorldSize() + gc.getGame().getHandicapType() #iRange = max(iRange,8) iPlots = gc.getMap().numPlots() iLandPlots = gc.getMap().getLandPlots() # Wenn es mehr Land als Wasser gibt if iLandPlots > iPlots / 2: iRange /= 2 for _ in xrange(iRange): # Wird geaendert zu einem Mittelmeerstreifen: x: 5 bis (X-5), y: 5 bis letztes Drittel von Y iMapX = gc.getMap().getGridWidth() - 5 iMapY = int(gc.getMap().getGridHeight() / 3 * 2) iRandX = 5 + CvUtil.myRandom(iMapX, "X") iRandY = 5 + CvUtil.myRandom(iMapY, "Y") loopPlot = gc.getMap().plot(iRandX, iRandY) # Plot soll ein Ozean sein terr_ocean = gc.getInfoTypeForString("TERRAIN_OCEAN") feat_ice = gc.getInfoTypeForString("FEATURE_ICE") iDarkIce = gc.getInfoTypeForString("FEATURE_DARK_ICE") if loopPlot is not None and not loopPlot.isNone(): if loopPlot.getFeatureType() == iDarkIce: continue if not loopPlot.isUnit() and not loopPlot.isOwned( ) and loopPlot.getFeatureType( ) != feat_ice and loopPlot.getTerrainType() == terr_ocean: # Schiffe erstellen iAnz = 1 if bRageBarbs and gc.getGame().getGameTurnYear() > -1000: iAnz = 2 #elif gc.getGame().getGameTurnYear() > -1200: # iAnz = 2 for _ in xrange(iAnz): CvUtil.spawnUnit(iUnitTypeShip, loopPlot, pBarbPlayer) CvUtil.spawnUnit(iUnitTypeWarrior1, loopPlot, pBarbPlayer) CvUtil.spawnUnit(iUnitTypeWarrior2, loopPlot, pBarbPlayer) CvUtil.spawnUnit(iUnitTypeWarrior3, loopPlot, pBarbPlayer) # Meldung PopUp if gc.getGame().getGameTurnYear() > -1400 and gc.getGame().getGameTurnYear( ) < -1380: for iPlayer in xrange(gc.getMAX_PLAYERS()): pPlayer = gc.getPlayer(iPlayer) if pPlayer.isAlive() and pPlayer.isHuman(): popupInfo = CyPopupInfo() popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT) popupInfo.setText(CyTranslator().getText( "TXT_KEY_MESSAGE_SEAPEOPLES", ("", ))) popupInfo.addPopup(pPlayer.getID()) CyAudioGame().Play2DSound("AS2D_THEIRDECLAREWAR")
def createCampUnit(iPlayer, iGameTurn): pPlayer = gc.getPlayer(iPlayer) if not pPlayer.isAlive(): return iTeam = pPlayer.getTeam() pTeam = gc.getTeam(iTeam) #eCiv = gc.getCivilizationInfo(pPlayer.getCivilizationType()) if pPlayer.getUnitClassCount( gc.getInfoTypeForString("UNITCLASS_SPECIAL1")) > 0: # Terrain #eTundra = gc.getInfoTypeForString("TERRAIN_TUNDRA") #eGras = gc.getInfoTypeForString("TERRAIN_GRASS") #eEbene = gc.getInfoTypeForString("TERRAIN_PLAINS") eDesert = gc.getInfoTypeForString("TERRAIN_DESERT") # Feature #eDichterWald = gc.getInfoTypeForString("FEATURE_DICHTERWALD") eCamp = gc.getInfoTypeForString("UNIT_CAMP") lCamps = PyPlayer(pPlayer.getID()).getUnitsOfType(eCamp) for pUnit in lCamps: if pUnit is not None and not pUnit.isNone(): #pUnit.NotifyEntity(MissionTypes.MISSION_FOUND) if pUnit.getFortifyTurns() == 0: return bCreateUnit = False iFortified = CvUtil.getScriptData(pUnit, ["f"], -1) if iFortified == -1: CvUtil.addScriptData(pUnit, "f", iGameTurn) elif (iGameTurn - iFortified) % 5 == 0: bCreateUnit = True if bCreateUnit: pPlot = pUnit.plot() lUnits = [] # Not on hills (for HI) if pPlayer.isHuman() and pPlot.isHills(): CyInterface().addMessage( iPlayer, True, 10, CyTranslator().getText("TXT_KEY_HELP_NOCAMPUNIT", ("", )), None, 2, "Art/Interface/Buttons/General/button_alert_new.dds", ColorTypes(11), pPlot.getX(), pPlot.getY(), True, True) return # Desert if pPlot.getTerrainType() == eDesert: if pPlayer.canTrain( gc.getInfoTypeForString( "UNIT_ARABIA_CAMELARCHER"), 0, 0): lUnits.append( gc.getInfoTypeForString( "UNIT_ARABIA_CAMELARCHER")) if pPlayer.canTrain( gc.getInfoTypeForString( "UNIT_CAMEL_CATAPHRACT"), 0, 0): lUnits.append( gc.getInfoTypeForString( "UNIT_CAMEL_CATAPHRACT")) # Open terrain (primary Mounted only) if not lUnits and pPlot.getFeatureType() == -1: if pPlayer.canTrain( gc.getInfoTypeForString("UNIT_MONGOL_KESHIK"), 0, 0): lUnits.append( gc.getInfoTypeForString("UNIT_MONGOL_KESHIK")) if pPlayer.canTrain( gc.getInfoTypeForString("UNIT_CATAPHRACT"), 0, 0): lUnits.append( gc.getInfoTypeForString("UNIT_CATAPHRACT")) if pPlayer.canTrain( gc.getInfoTypeForString("UNIT_HORSE_ARCHER"), 0, 0): lUnits.append( gc.getInfoTypeForString("UNIT_HORSE_ARCHER")) if not lUnits and pPlayer.canTrain( gc.getInfoTypeForString("UNIT_HORSEMAN"), 0, 0): lUnits.append( gc.getInfoTypeForString("UNIT_HORSEMAN")) # On forests or if no mounted units available/constructable if not lUnits: if pPlayer.canTrain( gc.getInfoTypeForString("UNIT_REFLEX_ARCHER"), 0, 0): lUnits.append( gc.getInfoTypeForString("UNIT_REFLEX_ARCHER")) else: lUnits.append( gc.getInfoTypeForString( "UNIT_COMPOSITE_ARCHER")) if pPlayer.canTrain( gc.getInfoTypeForString("UNIT_SKIRMISHER"), 0, 0): lUnits.append( gc.getInfoTypeForString("UNIT_SKIRMISHER")) if pPlayer.canTrain( gc.getInfoTypeForString("UNIT_AXEMAN2"), 0, 0): lUnits.append( gc.getInfoTypeForString("UNIT_AXEMAN2")) if pPlayer.canTrain( gc.getInfoTypeForString("UNIT_SWORDSMAN"), 0, 0): lUnits.append( gc.getInfoTypeForString("UNIT_SWORDSMAN")) elif pPlayer.canTrain( gc.getInfoTypeForString("UNIT_SCHILDTRAEGER"), 0, 0): lUnits.append( gc.getInfoTypeForString("UNIT_SCHILDTRAEGER")) else: lUnits.append( gc.getInfoTypeForString("UNIT_KURZSCHWERT")) # standard unit lUnits.append(gc.getInfoTypeForString("UNIT_SPEARMAN")) iUnit = -1 if lUnits: iUnit = lUnits[CvUtil.myRandom( len(lUnits), "createCampUnit")] # AI: Einheit autom, verkaufen (Soeldnerposten), falls Geldprobleme if not pPlayer.isHuman() and ( pPlayer.AI_isFinancialTrouble() or pTeam.getAtWarCount(True) == 0): pPlayer.changeGold(25) elif iUnit != -1: # Einheit erstellen CvUtil.spawnUnit(iUnit, pPlot, pPlayer)
def onBeginPlayerTurn(iGameTurn, pPlayer): iTeam = pPlayer.getTeam() iAthen = 0 iSparta = 1 iKorinth = 2 iTheben = 4 iSyrakus = 16 # Event 1: Poteidaia verlangt geringere Abgaben iTurnPotei = 8 # Runde, in der das Popup fuer den Menschen erscheinen soll # Die KI reagiert sofort noch in dieser Runde, der Mensch erhaelt erst in der naechsten Runde das Popup # Nur, wenn Poteidaia existiert + von Athen kontrolliert wird pPoteidaia = CyMap().plot(56, 46).getPlotCity() if iTeam == iAthen and ( (iGameTurn == iTurnPotei - 1 and pPlayer.isHuman()) or (iGameTurn == iTurnPotei and not pPlayer.isHuman()) ) and not pPoteidaia.isNone() and pPoteidaia is not None: if pPoteidaia.getOwner() == iAthen: if pPlayer.isHuman(): popupInfo = CyPopupInfo() popupInfo.setButtonPopupType( ButtonPopupTypes.BUTTONPOPUP_PYTHON) popupInfo.setText(CyTranslator().getText( "TXT_KEY_EVENT_POTEIDAIA_TRIBUT_DESC", ())) popupInfo.setOnClickedPythonCallback( "peloponnesianWarKeinpferd_Poteidaia1") popupInfo.addPythonButton( CyTranslator().getText( "TXT_KEY_EVENT_POTEIDAIA_TRIBUT_OPTION_1", ()), "") popupInfo.addPythonButton( CyTranslator().getText( "TXT_KEY_EVENT_POTEIDAIA_TRIBUT_OPTION_2", ()), "") popupInfo.addPythonButton( CyTranslator().getText( "TXT_KEY_EVENT_POTEIDAIA_TRIBUT_OPTION_3", ()), "") popupInfo.addPopup(iPlayer) else: iAiDecision = CvUtil.myRandom( 3, "peloponnesianWarKeinpferd_Poteidaia1") CvScreensInterface.peloponnesianWarKeinpferd_Poteidaia1( [iAiDecision]) # Event 2: Krieg um Poteidaia iTurnPotei = 18 # Runde, in der die Popups fuer den Menschen erscheinen sollen # Nur, wenn Poteidaia existiert + von Athen kontrolliert wird if iTeam == iAthen and ( (iGameTurn == iTurnPotei - 1 and pPlayer.isHuman()) or (iGameTurn == iTurnPotei and not pPlayer.isHuman()) ) and not pPoteidaia.isNone() and pPoteidaia is not None: if pPoteidaia.getOwner() == iAthen: # Event 2.1: Reaktion Athens # Poteidaia wechselt zu Korinth (Team 2) PAE_City.doRenegadeCity(pPoteidaia, 2, None) pKorinth = gc.getPlayer(iKorinth) ePantodapoi = gc.getInfoTypeForString("UNIT_AUXILIAR_MACEDON") iRange = CvUtil.myRandom(3, "num ePantodapoi") # Korinth erhaelt 0 - 2 zusaetzliche makedonische Hilfstrupps in Poteidaia for _ in range(iRange): pKorinth.initUnit(ePantodapoi, 56, 46, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH) CyInterface().addMessage( gc.getGame().getActivePlayer(), True, 15, CyTranslator().getText( "TXT_KEY_EVENT_POTEIDAIA_KRIEG_WORLDNEWS", ()), None, 2, None, ColorTypes(11), 0, 0, False, False) if pPlayer.isHuman(): popupInfo = CyPopupInfo() popupInfo.setButtonPopupType( ButtonPopupTypes.BUTTONPOPUP_PYTHON) popupInfo.setText(CyTranslator().getText( "TXT_KEY_EVENT_POTEIDAIA_KRIEG_ATHEN_DESC", ())) popupInfo.setOnClickedPythonCallback( "peloponnesianWarKeinpferd_Poteidaia2") popupInfo.addPythonButton( CyTranslator().getText( "TXT_KEY_EVENT_POTEIDAIA_KRIEG_ATHEN_OPTION_1", ()), "") popupInfo.addPythonButton( CyTranslator().getText( "TXT_KEY_EVENT_POTEIDAIA_KRIEG_ATHEN_OPTION_2", ()), "") popupInfo.addPythonButton( CyTranslator().getText( "TXT_KEY_EVENT_POTEIDAIA_KRIEG_ATHEN_OPTION_3", ()), "") popupInfo.addPopup(iPlayer) else: iAiDecision = CvUtil.myRandom( 3, "peloponnesianWarKeinpferd_Poteidaia2") CvScreensInterface.peloponnesianWarKeinpferd_Poteidaia2( [iAiDecision]) # Nur, wenn Poteidaia existiert + von Korinth oder Athen kontrolliert wird (menschlicher Spieler spielt Korinth: zu diesem Zeitpunkt gehoert Poteidaia noch Athen; KI spielt Korinth: ist bereits zu Korinth gewechselt) elif iTeam == iKorinth and ( (iGameTurn == iTurnPotei - 1 and pPlayer.isHuman()) or (iGameTurn == iTurnPotei and not pPlayer.isHuman()) ) and not pPoteidaia.isNone() and pPoteidaia is not None: if pPoteidaia.getOwner() == iKorinth or pPoteidaia.getOwner( ) == iAthen: # Event 2.2: Reaktion Korinths if pPlayer.isHuman(): popupInfo = CyPopupInfo() popupInfo.setButtonPopupType( ButtonPopupTypes.BUTTONPOPUP_PYTHON) popupInfo.setText(CyTranslator().getText( "TXT_KEY_EVENT_POTEIDAIA_KRIEG_KORINTH_DESC", ())) popupInfo.setOnClickedPythonCallback( "peloponnesianWarKeinpferd_Poteidaia3") popupInfo.addPythonButton( CyTranslator().getText( "TXT_KEY_EVENT_POTEIDAIA_KRIEG_KORINTH_OPTION_1", ()), "") popupInfo.addPythonButton( CyTranslator().getText( "TXT_KEY_EVENT_POTEIDAIA_KRIEG_KORINTH_OPTION_2", ()), "") popupInfo.addPythonButton( CyTranslator().getText( "TXT_KEY_EVENT_POTEIDAIA_KRIEG_KORINTH_OPTION_3", ()), "") popupInfo.addPopup(iPlayer) else: iAiDecision = CvUtil.myRandom( 3, "peloponnesianWarKeinpferd_Poteidaia3") CvScreensInterface.peloponnesianWarKeinpferd_Poteidaia3( [iAiDecision]) # Event 3: Megara unterstuetzt Korinth iTurnMegaraAthen = 22 # Runde, in der die Popups fuer den Menschen erscheinen sollen # Nur, wenn Megara existiert + von Korinth kontrolliert wird pMegara = CyMap().plot(55, 30).getPlotCity() if pMegara is not None and not pMegara.isNone(): if iTeam == iAthen and ( (iGameTurn == iTurnMegaraAthen - 1 and pPlayer.isHuman()) or (iGameTurn == iTurnMegaraAthen and not pPlayer.isHuman())): if pMegara.getOwner() == iKorinth: # Event 3.1: Reaktion Athens if pPlayer.isHuman(): popupInfo = CyPopupInfo() popupInfo.setButtonPopupType( ButtonPopupTypes.BUTTONPOPUP_PYTHON) popupInfo.setText(CyTranslator().getText( "TXT_KEY_EVENT_MEGARA_ATHEN_DESC", ())) popupInfo.setOnClickedPythonCallback( "peloponnesianWarKeinpferd_Megara1") popupInfo.addPythonButton( CyTranslator().getText( "TXT_KEY_EVENT_MEGARA_ATHEN_OPTION_1", ()), "") popupInfo.addPythonButton( CyTranslator().getText( "TXT_KEY_EVENT_MEGARA_ATHEN_OPTION_2", ()), "") popupInfo.addPythonButton( CyTranslator().getText( "TXT_KEY_EVENT_MEGARA_ATHEN_OPTION_3", ()), "") popupInfo.addPopup(iPlayer) else: iAiDecision = CvUtil.myRandom( 3, "peloponnesianWarKeinpferd_Megara1") CvScreensInterface.peloponnesianWarKeinpferd_Megara1( [iAiDecision]) # Event 3.2: Reaktion Spartas (nur wenn Sparta noch keinen Krieg mit Athen hat) iTurnMegaraSparta = 23 # Runde, in der die Popups fuer den Menschen erscheinen sollen # Nur, wenn Megara existiert + von Korinth kontrolliert wird if iTeam == iSparta and ( (iGameTurn == iTurnMegaraSparta - 1 and pPlayer.isHuman()) or (iGameTurn == iTurnMegaraSparta and not pPlayer.isHuman())): if pMegara.getOwner( ) == iKorinth and not gc.getTeam(iTeam).isAtWar(iAthen): if pPlayer.isHuman(): popupInfo = CyPopupInfo() popupInfo.setButtonPopupType( ButtonPopupTypes.BUTTONPOPUP_PYTHON) popupInfo.setText(CyTranslator().getText( "TXT_KEY_EVENT_MEGARA_SPARTA_DESC", ())) popupInfo.setOnClickedPythonCallback( "peloponnesianWarKeinpferd_Megara2") popupInfo.addPythonButton( CyTranslator().getText( "TXT_KEY_EVENT_MEGARA_SPARTA_OPTION_1", ()), "") popupInfo.addPythonButton( CyTranslator().getText( "TXT_KEY_EVENT_MEGARA_SPARTA_OPTION_2", ()), "") popupInfo.addPythonButton( CyTranslator().getText( "TXT_KEY_EVENT_MEGARA_SPARTA_OPTION_3", ()), "") popupInfo.addPopup(iPlayer) else: iAiDecision = CvUtil.myRandom( 3, "peloponnesianWarKeinpferd_Megara2") CvScreensInterface.peloponnesianWarKeinpferd_Megara2( [iAiDecision]) # Event 4: Kriegseintritt Thebens iTurnPlataiai = 28 # Runde, in der die Popups fuer den Menschen erscheinen sollen if iTeam == iTheben and ( (iGameTurn == iTurnPlataiai - 1 and pPlayer.isHuman()) or (iGameTurn == iTurnPlataiai and not pPlayer.isHuman())): if not gc.getTeam(iTeam).isAtWar( iAthen): # Nur wenn Theben und Athen Frieden haben if pPlayer.isHuman(): popupInfo = CyPopupInfo() popupInfo.setButtonPopupType( ButtonPopupTypes.BUTTONPOPUP_PYTHON) popupInfo.setText(CyTranslator().getText( "TXT_KEY_EVENT_PLATAIAI_THEBEN_DESC", ())) popupInfo.setOnClickedPythonCallback( "peloponnesianWarKeinpferd_Plataiai1") popupInfo.addPythonButton( CyTranslator().getText( "TXT_KEY_EVENT_PLATAIAI_THEBEN_OPTION_1", ()), "") popupInfo.addPythonButton( CyTranslator().getText( "TXT_KEY_EVENT_PLATAIAI_THEBEN_OPTION_2", ()), "") popupInfo.addPythonButton( CyTranslator().getText( "TXT_KEY_EVENT_PLATAIAI_THEBEN_OPTION_3", ()), "") popupInfo.addPopup(iPlayer) else: iAiDecision = CvUtil.myRandom( 3, "peloponnesianWarKeinpferd_Plataiai1") CvScreensInterface.peloponnesianWarKeinpferd_Plataiai1( [iAiDecision]) # Event 5: Volksversammlung Athens will Krieg gegen Syrakus # Event 5.1: Ankuendigung fuer Athen iTurnSyra1 = 194 # Runde, in der die Popups fuer den Menschen erscheinen sollen pSyrakus = CyMap().plot(15, 24).getPlotCity() # Nur wenn Syrakus (Stadt) noch existiert und der Civ Syrakus gehoert if pSyrakus is not None and not pSyrakus.isNone(): if iTeam == iAthen and (iGameTurn == iTurnSyra1 - 1): if pSyrakus.getOwner() == iSyrakus: if pPlayer.isHuman(): popupInfo = CyPopupInfo() popupInfo.setButtonPopupType( ButtonPopupTypes.BUTTONPOPUP_TEXT) popupInfo.setText(CyTranslator().getText( "TXT_KEY_EVENT_SYRAKUS_ATHEN_SAVEMONEY", ())) popupInfo.addPopup(iPlayer) # Event 5.2: Athen waehlt Groesse der Flotte iTurnSyra2 = 204 # Runde, in der die Popups fuer den Menschen erscheinen sollen if iTeam == iAthen and ( (iGameTurn == iTurnSyra2 - 1 and pPlayer.isHuman()) or (iGameTurn == iTurnSyra2 and not pPlayer.isHuman())): if not gc.getTeam(iTeam).isAtWar( iSyrakus): # Nur wenn Syrakus und Athen Frieden haben if pPlayer.isHuman(): popupInfo = CyPopupInfo() popupInfo.setButtonPopupType( ButtonPopupTypes.BUTTONPOPUP_PYTHON) popupInfo.setText(CyTranslator().getText( "TXT_KEY_EVENT_SYRAKUS_ATHEN_DESC", ())) popupInfo.setOnClickedPythonCallback( "peloponnesianWarKeinpferd_Syra1") popupInfo.addPythonButton( CyTranslator().getText( "TXT_KEY_EVENT_SYRAKUS_ATHEN_OPTION_1", ()), "") popupInfo.addPythonButton( CyTranslator().getText( "TXT_KEY_EVENT_SYRAKUS_ATHEN_OPTION_2", ()), "") popupInfo.addPythonButton( CyTranslator().getText( "TXT_KEY_EVENT_SYRAKUS_ATHEN_OPTION_3", ()), "") popupInfo.addPopup(iPlayer) else: iAiDecision = CvUtil.myRandom( 3, "peloponnesianWarKeinpferd_Syra1") CvScreensInterface.peloponnesianWarKeinpferd_Syra1( [iAiDecision]) # Temporaere Effekte der Events rueckgaengig machen (Event 3.1 Handelsboykott, Event 3.2 Bronze fuer Sparta) if iGameTurn == iTurnMegaraAthen + 10: iAthen = 0 iNordIonien = 12 iSuedIonien = 13 eHafen = gc.getInfoTypeForString("BUILDING_HARBOR") eMarkt = gc.getInfoTypeForString("BUILDING_MARKET") eHafenClass = gc.getBuildingInfo(eHafen).getBuildingClassType() eMarktClass = gc.getBuildingInfo(eMarkt).getBuildingClassType() lPlayer = [iAthen, iNordIonien, iSuedIonien] for iPlayer in lPlayer: pPlayer = gc.getPlayer(iPlayer) iNumCities = pPlayer.getNumCities() for iCity in range(iNumCities): pCity = pPlayer.getCity(iCity) if pCity is not None and not pCity.isNone(): if pCity.isHasBuilding(eHafen): iStandard = 0 # Normaler Goldertrag ohne Event pCity.setBuildingCommerceChange( eHafenClass, 0, iStandard) # 0 = Gold if pCity.isHasBuilding(eMarkt): iStandard = 0 pCity.setBuildingCommerceChange( eMarktClass, 0, iStandard) # 0 = Gold if iGameTurn == iTurnMegaraSparta + 10: # Bronze wird a eBronze = gc.getInfoTypeForString("BONUS_BRONZE") pCity = CyMap().plot(52, 23).getPlotCity() if pCity is not None and not pCity.isNone(): if pCity.getFreeBonus(eBronze) > 1: pCity.changeFreeBonus(eBronze, -1)
def doOlympicGames(): # wurde das Projekt erstellt? if gc.getGame().getProjectCreatedCount(gc.getInfoTypeForString("PROJECT_OLYMPIC_GAMES")) == 0: return # alle 4 Runden if gc.getGame().getCalendar() == gc.getInfoTypeForString("CALENDAR_MONTHS"): iTurns = 48 elif gc.getGame().getCalendar() == gc.getInfoTypeForString("CALENDAR_SEASONS"): iTurns = 16 else: iTurns = 4 if gc.getGame().getElapsedGameTurns() % iTurns == 1: # Inits lCities4Olympiade = [] lHumans = [] lPlayers = [] iTechSchaukampf = gc.getInfoTypeForString("TECH_GLADIATOR") iTechImperialismus = gc.getInfoTypeForString("TECH_NATIONALISM") iTechPapsttum = gc.getInfoTypeForString("TECH_PAPSTTUM") iReligionGreek = gc.getInfoTypeForString("RELIGION_GREEK") iReligionRome = gc.getInfoTypeForString("RELIGION_ROME") iBuildingStadion = gc.getInfoTypeForString("BUILDING_STADION") iBuildingClassStadion = gc.getInfoTypeForString("BUILDINGCLASS_STADION") iBuildingOlympionike = gc.getInfoTypeForString("BUILDING_OLYMPIONIKE") iBuildingClassGymnasion = gc.getInfoTypeForString("BUILDINGCLASS_SPECIAL3") # Los gehts iNumPlayers = gc.getMAX_PLAYERS() for iPlayer in xrange (iNumPlayers): pPlayer = gc.getPlayer(iPlayer) if pPlayer and not pPlayer.isNone() and pPlayer.isAlive(): # and not pPlayer.isBarbarian(): # Hat der Spieler noch nicht Schaukampf erforscht, isser nicht dabei if not gc.getTeam(pPlayer.getTeam()).isHasTech(iTechSchaukampf): continue # Hat der Spieler bereits das Papsttum erforscht, is der Spass vorbei if gc.getTeam(pPlayer.getTeam()).isHasTech(iTechPapsttum): continue # Hat der Spieler Imperialismus erforscht? bAllowRomanGods = False if gc.getTeam(pPlayer.getTeam()).isHasTech(iTechImperialismus): bAllowRomanGods = True # Init des Spezialgebäudes Gymnasion, Gymnasium iBuildingGymnasion = gc.getCivilizationInfo(pPlayer.getCivilizationType()).getCivilizationBuildings(iBuildingClassGymnasion) # Cities iNumCities = pPlayer.getNumCities() for iCity in xrange (iNumCities): pCity = pPlayer.getCity(iCity) if pCity and not pCity.isNone(): # Aktuellen Olympioniken rausschmeissen pCity.setNumRealBuilding(iBuildingOlympionike,0) # Hat die Stadt die richtige Religion? if pCity.isHasReligion(iReligionGreek) or bAllowRomanGods and pCity.isHasReligion(iReligionRome): # Liste für Spielermeldungen if pPlayer.isHuman() and iPlayer not in lHumans: lHumans.append(iPlayer) # Liste verschiedener CIVs if iPlayer not in lPlayers: lPlayers.append(iPlayer) # Stadt an den Spielen zulassen lCities4Olympiade.append(pCity) # Verbesserte Chancen: if pCity.isHasBuilding(iBuildingStadion): lCities4Olympiade.append(pCity) if pCity.isHasBuilding(iBuildingGymnasion): lCities4Olympiade.append(pCity) # Choose new Olympic Winner City # erst ab 2 CIVs if len(lPlayers) <= 1: return iRand = CvUtil.myRandom(len(lCities4Olympiade), "CityOfOlympiadWinner") pCity = lCities4Olympiade[iRand] # Olympionike in die Stadt stellen pCity.setNumRealBuilding(iBuildingOlympionike,1) # Stadion verbessern +1 Kultur if pCity.isHasBuilding(iBuildingStadion): iCulture = pCity.getBuildingCommerceChange(iBuildingClassStadion, CommerceTypes.COMMERCE_CULTURE) + 1 pCity.setBuildingCommerceChange(iBuildingClassStadion, CommerceTypes.COMMERCE_CULTURE, iCulture) # Goldkarren erzeugen CvUtil.spawnUnit(gc.getInfoTypeForString("UNIT_GOLDKARREN"), pCity.plot(), gc.getPlayer(pCity.getOwner())) CvUtil.spawnUnit(gc.getInfoTypeForString("UNIT_GOLDKARREN"), pCity.plot(), gc.getPlayer(pCity.getOwner())) # einen weiteren bei Seasons if iTurns >= 16: CvUtil.spawnUnit(gc.getInfoTypeForString("UNIT_GOLDKARREN"), pCity.plot(), gc.getPlayer(pCity.getOwner())) # zwei weitere bei Months (insg. 5) if iTurns > 16: CvUtil.spawnUnit(gc.getInfoTypeForString("UNIT_GOLDKARREN"), pCity.plot(), gc.getPlayer(pCity.getOwner())) CvUtil.spawnUnit(gc.getInfoTypeForString("UNIT_GOLDKARREN"), pCity.plot(), gc.getPlayer(pCity.getOwner())) # Chance eines beladenen Fuhrwerks if CvUtil.myRandom(4, "Olympia_ChanceOfBonus") == 1: pNewUnit = CvUtil.spawnUnit(gc.getInfoTypeForString("UNIT_SUPPLY_FOOD"), pCity.plot(), gc.getPlayer(pCity.getOwner())) lBonuses = [ gc.getInfoTypeForString("BONUS_OLIVES"), gc.getInfoTypeForString("BONUS_OLIVES"), gc.getInfoTypeForString("BONUS_OLIVES"), gc.getInfoTypeForString("BONUS_OLIVES"), gc.getInfoTypeForString("BONUS_OLIVES"), gc.getInfoTypeForString("BONUS_GRAPES"), gc.getInfoTypeForString("BONUS_GRAPES"), gc.getInfoTypeForString("BONUS_GRAPES"), gc.getInfoTypeForString("BONUS_ROGGEN"), gc.getInfoTypeForString("BONUS_HAFER"), gc.getInfoTypeForString("BONUS_GERSTE"), gc.getInfoTypeForString("BONUS_WHEAT"), gc.getInfoTypeForString("BONUS_HIRSE"), gc.getInfoTypeForString("BONUS_HORSE") ] eBonus = CvUtil.myRandom(len(lBonuses), "Olympia_BonusType") eBonus = lBonuses[eBonus] CvUtil.addScriptData(pNewUnit, "b", eBonus) # Meldung an alle beteiligten Spieler for iPlayer in lHumans: xSound = None iColor = 14 # graublau bShow = False # Extra PopUp wenn HI der Gewinner ist if iPlayer == pCity.getOwner(): xSound = "AS2D_WELOVEKING" iColor = 10 # cyan bShow = True popupInfo = CyPopupInfo() popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT) sText = CyTranslator().getText("TXT_KEY_INFO_OLYMPIC_GAMES_WINNER", (pCity.getName(),gc.getPlayer(pCity.getOwner()).getCivilizationShortDescription(0))) popupInfo.setText(sText) popupInfo.addPopup(iPlayer) # Ingame Text CyInterface().addMessage(iPlayer, True, 15, CyTranslator().getText("TXT_KEY_INFO_OLYMPIC_GAMES_WINNER", (pCity.getName(),gc.getPlayer(pCity.getOwner()).getCivilizationShortDescription(0))), xSound, 2, "Art/Interface/Buttons/Buildings/button_building_olympionike.dds", ColorTypes(iColor), pCity.plot().getX(), pCity.plot().getY(), bShow, bShow)
def doPlotFeatures(): iGameTurn = gc.getGame().getElapsedGameTurns() if iGameTurn < 5: return # Inits iBarbPlayer = gc.getBARBARIAN_PLAYER() pBarbPlayer = gc.getPlayer(iBarbPlayer) # Flotsam terrOzean = gc.getInfoTypeForString("TERRAIN_OCEAN") bFlot = gc.getTeam(pBarbPlayer.getTeam()).isHasTech(gc.getInfoTypeForString("TECH_RUDERER2")) # Barbaren improvements impBarbFort = gc.getInfoTypeForString("IMPROVEMENT_BARBARENFORT") impCave = gc.getInfoTypeForString("IMPROVEMENT_CAVE") impGoody = gc.getInfoTypeForString("IMPROVEMENT_GOODY_HUT") iBarbForts = 0 iCaves = 0 iGoodyHuts = 0 # Animals bonus_lion = gc.getInfoTypeForString("BONUS_LION") bonus_horse = gc.getInfoTypeForString("BONUS_HORSE") bonus_camel = gc.getInfoTypeForString("BONUS_CAMEL") bonus_ivory = gc.getInfoTypeForString("BONUS_IVORY") bonus_dogs = gc.getInfoTypeForString("BONUS_HUNDE") bonus_deer = gc.getInfoTypeForString("BONUS_DEER") bonus_pig = gc.getInfoTypeForString("BONUS_PIG") # features iDarkIce = gc.getInfoTypeForString("FEATURE_DARK_ICE") iFeatBurned = gc.getInfoTypeForString("FEATURE_FOREST_BURNT") iFeatSeuche = gc.getInfoTypeForString("FEATURE_SEUCHE") iTerrDesert = gc.getInfoTypeForString("TERRAIN_DESERT") iTerrPlains = gc.getInfoTypeForString("TERRAIN_PLAINS") iTerrTundra = gc.getInfoTypeForString("TERRAIN_TUNDRA") iFeatForest = gc.getInfoTypeForString("FEATURE_FOREST") iFeatDenseForest = gc.getInfoTypeForString("FEATURE_DICHTERWALD") iFeatJungle = gc.getInfoTypeForString("FEATURE_JUNGLE") # Heuschrecken/Grasshopper iFeatGrasshopper = gc.getInfoTypeForString("FEATURE_GRASSHOPPER") # Desert Storm iFeatDesertstorm = gc.getInfoTypeForString("FEATURE_FALLOUT") lDesertStorm = [] # Plots Ocean = [] Desert = [] Forest = [] DenseForest = [] Tundra = [] Plains = [] Jungle = [] Hills = [] #GoodyPlots = [] # map iMapW = gc.getMap().getGridWidth() iMapH = gc.getMap().getGridHeight() for x in xrange(iMapW): for y in xrange(iMapH): loopPlot = gc.getMap().plot(x, y) if loopPlot and not loopPlot.isNone(): iPlotFeature = loopPlot.getFeatureType() iPlotTerrain = loopPlot.getTerrainType() iPlotImprovement = loopPlot.getImprovementType() if iPlotFeature == iDarkIce: continue if iPlotFeature == iFeatGrasshopper: doMoveGrasshoppers(loopPlot) continue if iPlotFeature == iFeatDesertstorm: lDesertStorm.append(loopPlot) continue if loopPlot.getFeatureType() == iFeatBurned: if CvUtil.myRandom(50, "burntForest2Forest") == 1: loopPlot.setFeatureType(iFeatForest, 0) continue # isWater if loopPlot.isWater(): # Treibgut nur alle 10 Runden erstellen (wenn aktiv) if bFlotsam and gc.getGame().getGameTurn() % 10 == 0: if bFlot and bGoodyHuts: if loopPlot.getOwner() == -1: if iPlotTerrain == terrOzean: if loopPlot.getNumUnits() > 0: Ocean.append(loopPlot) # isLand elif not loopPlot.isPeak(): iPlotOwner = loopPlot.getOwner() # nur ausserhalb von Cities if not loopPlot.isCity(): # Forts oder Handelsposten if iPlotImprovement in L.LImprFortShort: # Init iOwner = -1 iOwner = int(CvUtil.getScriptData(loopPlot, ["p", "t"], loopPlot.getOwner())) # Handelsposten entfernen, wenn der Plot in einem fremden Kulturkreis liegt if iPlotImprovement == gc.getInfoTypeForString("IMPROVEMENT_HANDELSPOSTEN"): if iOwner != iPlotOwner and iPlotOwner != -1: loopPlot.setImprovementType(-1) if gc.getPlayer(iOwner).isHuman(): szText = CyTranslator().getText("TXT_KEY_INFO_CLOSED_TRADEPOST", ("",)) CyInterface().addMessage(iOwner, True, 15, szText, "AS2D_UNIT_BUILD_UNIT", 2, "Art/Interface/Buttons/General/button_alert_new.dds", ColorTypes(7), loopPlot.getX(), loopPlot.getY(), True, True) # Kultur setzen if iPlotOwner == -1: loopPlot.setCulture(iOwner, 1, True) loopPlot.setOwner(iOwner) # Kultur bei Forts #else: # doCheckFortCulture(loopPlot) continue # Check nur alle x Runden (Tier-Spawn) if iGameTurn % 2 == 0: # Lion - 3% Appearance if loopPlot.getBonusType(-1) == bonus_lion and iPlotImprovement == -1: if loopPlot.getNumUnits() == 0: if CvUtil.myRandom(33, "lion") == 1: iUnitType = gc.getInfoTypeForString("UNIT_LION") pBarbPlayer.initUnit(iUnitType, x, y, UnitAITypes.UNITAI_ATTACK, DirectionTypes.DIRECTION_SOUTH) # ***TEST*** #CyInterface().addMessage(gc.getGame().getActivePlayer(), True, 10, "Barb. Atlasloewe erschaffen", None, 2, None, ColorTypes(10), 0, 0, False, False) continue # Wolf - 3% Appearance elif loopPlot.getBonusType(iPlotOwner) == bonus_dogs and iPlotImprovement == -1: if loopPlot.getNumUnits() == 0: if CvUtil.myRandom(33, "wolf") == 1: iUnitType = gc.getInfoTypeForString("UNIT_WOLF") pBarbPlayer.initUnit(iUnitType, x, y, UnitAITypes.UNITAI_ATTACK, DirectionTypes.DIRECTION_SOUTH) continue # Deer - 3% Appearance elif loopPlot.getBonusType(-1) == bonus_deer and iPlotImprovement == -1: if loopPlot.getNumUnits() == 0: iRand = CvUtil.myRandom(33, "deer or bear") if iRand == 1: iUnitType = gc.getInfoTypeForString("UNIT_DEER") pBarbPlayer.initUnit(iUnitType, x, y, UnitAITypes.UNITAI_ATTACK, DirectionTypes.DIRECTION_SOUTH) continue elif iRand == 2: iUnitType = gc.getInfoTypeForString("UNIT_BEAR") pBarbPlayer.initUnit(iUnitType, x, y, UnitAITypes.UNITAI_ATTACK, DirectionTypes.DIRECTION_SOUTH) continue # Boar/Schwarzwild - 3% Appearance elif loopPlot.getBonusType(iPlotOwner) == bonus_pig and iPlotImprovement == -1: if loopPlot.getNumUnits() == 0: if CvUtil.myRandom(33, "boar") == 1: iUnitType = gc.getInfoTypeForString("UNIT_BOAR") pBarbPlayer.initUnit(iUnitType, x, y, UnitAITypes.UNITAI_ATTACK, DirectionTypes.DIRECTION_SOUTH) continue # Horse - 2% Appearance elif loopPlot.getBonusType(iPlotOwner) == bonus_horse: iUnitType = gc.getInfoTypeForString("UNIT_HORSE") #iUnitTypeDom = gc.getInfoTypeForString("UNIT_HORSE") iTechDom = gc.getInfoTypeForString("TECH_PFERDEZUCHT") sTextDom = "TXT_KEY_INFO_DOM_HORSE" if loopPlot.getNumUnits() == 0: if CvUtil.myRandom(50, "horse") == 1: # Check Owner iNewUnitOwner = iBarbPlayer if iPlotOwner != -1 and iPlotOwner != iBarbPlayer: if gc.getTeam(gc.getPlayer(iPlotOwner).getTeam()).isHasTech(iTechDom): iNewUnitOwner = iPlotOwner #iUnitType = iUnitTypeDom elif gc.getPlayer(iPlotOwner).isHuman(): CyInterface().addMessage(iPlotOwner, True, 10, CyTranslator().getText(sTextDom, ("",)), None, 2, gc.getBonusInfo(bonus_horse).getButton(), ColorTypes(13), x, y, True, True) # Add Unit gc.getPlayer(iNewUnitOwner).initUnit(iUnitType, x, y, UnitAITypes.UNITAI_EXPLORE, DirectionTypes.DIRECTION_SOUTH) continue # Camel - 2% Appearance elif loopPlot.getBonusType(iPlotOwner) == bonus_camel: iUnitType = gc.getInfoTypeForString("UNIT_CAMEL") #iUnitTypeDom = gc.getInfoTypeForString("UNIT_CAMEL") iTechDom = gc.getInfoTypeForString("TECH_KAMELZUCHT") sTextDom = "TXT_KEY_INFO_DOM_CAMEL" if loopPlot.getNumUnits() == 0: if CvUtil.myRandom(50, "camel") == 1: # Check Owner iNewUnitOwner = iBarbPlayer if iPlotOwner != -1: if gc.getTeam(gc.getPlayer(iPlotOwner).getTeam()).isHasTech(iTechDom): iNewUnitOwner = iPlotOwner #iUnitType = iUnitTypeDom elif gc.getPlayer(iPlotOwner).isHuman(): CyInterface().addMessage(iPlotOwner, True, 10, CyTranslator().getText(sTextDom, ("",)), None, 2, gc.getBonusInfo(bonus_camel).getButton(), ColorTypes(13), x, y, True, True) # Add Unit gc.getPlayer(iNewUnitOwner).initUnit(iUnitType, x, y, UnitAITypes.UNITAI_EXPLORE, DirectionTypes.DIRECTION_SOUTH) continue # Elefant - 2% Appearance (ab Eisenzeit) elif loopPlot.getBonusType(iPlotOwner) == bonus_ivory and pBarbPlayer.getCurrentEra() >= 2: iUnitType = gc.getInfoTypeForString("UNIT_ELEFANT") if loopPlot.getNumUnits() == 0: if CvUtil.myRandom(50, "ele") == 1: # Check Owner iNewUnitOwner = iBarbPlayer if iPlotOwner != -1: if gc.getTeam(gc.getPlayer(iPlotOwner).getTeam()).isHasTech(gc.getInfoTypeForString("TECH_ELEFANTENZUCHT")): iNewUnitOwner = iPlotOwner elif gc.getPlayer(iPlotOwner).isHuman(): CyInterface().addMessage(iPlotOwner, True, 10, CyTranslator().getText("TXT_KEY_INFO_DOM_ELEFANT", ("",)), None, 2, gc.getBonusInfo(bonus_ivory).getButton(), ColorTypes(13), x, y, True, True) # Add Unit gc.getPlayer(iNewUnitOwner).initUnit(iUnitType, x, y, UnitAITypes.UNITAI_EXPLORE, DirectionTypes.DIRECTION_SOUTH) continue # Barbarenforts/festungen (erzeugt barbarische Einheiten alle x Runden) if iPlotImprovement == impBarbFort: iBarbForts += 1 #if iPlotOwner == -1 or iPlotOwner == iBarbPlayer: if loopPlot.getNumUnits() == 0: # Verteidiger setzen PAE_Barbaren.setFortDefence(loopPlot) elif loopPlot.getNumUnits() > 4: iNum = loopPlot.getNumUnits() - 4 for k in xrange(iNum): loopPlot.getUnit(k).kill(True, -1) elif pBarbPlayer.getCurrentEra() > 0: if bRageBarbs: iTurns = 5 else: iTurns = 10 if gc.getGame().getGameTurn() % iTurns == 0: iAnzUnits = PAE_Barbaren.countNearbyUnits(loopPlot, 2, iBarbPlayer) if iAnzUnits < 6: # Einheiten) setzen PAE_Barbaren.createBarbUnit(loopPlot) continue # Baerenhoehle elif iPlotImprovement == impCave: iCaves += 1 #if loopPlot.getNumUnits() <= 1: if CvUtil.myRandom(15, "cave bear") == 1: if not PAE_Barbaren.checkNearbyUnits(loopPlot,3): # (Plot, Radius) setUnitIntoCave(loopPlot) continue # Goody huts elif iPlotImprovement == impGoody: iGoodyHuts += 1 # Keine Seuche in Deserts if iPlotTerrain == iTerrDesert and iPlotFeature == iFeatSeuche: loopPlot.setFeatureType(-1,0) # leere Plots zwischenspeichern if iGameTurn > 150 and iGameTurn % 10 == 0: if iPlotOwner == -1: if loopPlot.getNumUnits() == 0 and not loopPlot.isActiveVisible(0): # Empty Plots for Animals and Barbs if iPlotTerrain == iTerrDesert: Desert.append(loopPlot) elif iPlotTerrain == iTerrTundra: Tundra.append(loopPlot) elif iPlotFeature == iFeatDenseForest: DenseForest.append(loopPlot) elif iPlotFeature == iFeatJungle: Jungle.append(loopPlot) elif iPlotFeature == iFeatForest: Forest.append(loopPlot) elif iPlotTerrain == iTerrPlains: Plains.append(loopPlot) if loopPlot.isHills(): Hills.append(loopPlot) # end if - not isCity # Plots verarbeiten -------------------------------- # Flotsam (if activated) if bFlotsam and bFlot and bGoodyHuts: if Ocean: if CvUtil.myRandom(33, "setFlotsam") == 1: iUnit = gc.getInfoTypeForString("UNIT_TREIBGUT") iNum = gc.getMap().getWorldSize() + 1 for i in xrange(iNum): CvUtil.spawnUnit(iUnit, Ocean[CvUtil.myRandom(len(Ocean), "spawnFlotsam")], pBarbPlayer) # Tiere setzen -------------------- if Desert: if CvUtil.myRandom(33, "setAnimals4Desert") == 1: setAnimals(gc.getInfoTypeForString("UNIT_CAMEL"),Desert) setAnimals(gc.getInfoTypeForString("UNIT_LION"),Desert) setAnimals(gc.getInfoTypeForString("UNIT_HYENA"),Desert) elif DenseForest: if CvUtil.myRandom(33, "setAnimals4DenseForest") == 1: setAnimals(gc.getInfoTypeForString("UNIT_WOLF"),DenseForest) setAnimals(gc.getInfoTypeForString("UNIT_UR"),DenseForest) setAnimals(gc.getInfoTypeForString("UNIT_BEAR"),DenseForest) elif Tundra: if CvUtil.myRandom(33, "setAnimals4Tundra") == 1: setAnimals(gc.getInfoTypeForString("UNIT_WOLF"),Tundra) setAnimals(gc.getInfoTypeForString("UNIT_BEAR"),Tundra) elif Jungle: if CvUtil.myRandom(33, "setAnimals4Jungle") == 1: setAnimals(gc.getInfoTypeForString("UNIT_PANTHER"),Jungle) setAnimals(gc.getInfoTypeForString("UNIT_TIGER"),Jungle) setAnimals(gc.getInfoTypeForString("UNIT_LEOPARD"),Jungle) setAnimals(gc.getInfoTypeForString("UNIT_ELEFANT"),Jungle) elif Forest: if CvUtil.myRandom(33, "setAnimals4Forest") == 1: setAnimals(gc.getInfoTypeForString("UNIT_WOLF"),Forest) setAnimals(gc.getInfoTypeForString("UNIT_BEAR"),Forest) setAnimals(gc.getInfoTypeForString("UNIT_BOAR"),Forest) setAnimals(gc.getInfoTypeForString("UNIT_DEER"),Forest) elif Plains: if CvUtil.myRandom(33, "setAnimals4Plains") == 1: setAnimals(gc.getInfoTypeForString("UNIT_HYENA"),Plains) setAnimals(gc.getInfoTypeForString("UNIT_LEOPARD"),Plains) #setAnimals(gc.getInfoTypeForString("UNIT_HORSE"),Plains) # Goody huts setzen if bGoodyHuts: nPlots = Jungle + Forest + Plains if nPlots: if CvUtil.myRandom(33, "setGoodyHuts") == 1: setGoodies(impGoody,iGoodyHuts,nPlots) # Barbaren Forts setzen if bBarbForts: nPlots = Hills if nPlots: if CvUtil.myRandom(33, "setBarbForts") == 1: setGoodies(impBarbFort,iBarbForts,nPlots) # Caves setzen nPlots = Jungle + Forest + DenseForest + Desert + Tundra if nPlots: if CvUtil.myRandom(33, "setCaves") == 1: setGoodies(impCave,iCaves,nPlots) # move Desertstorm / Sandsturm bewegen if lDesertStorm: doMoveDesertStorm(lDesertStorm) # Olympiade / Olympic Games / Panhellenic Games doOlympicGames()
def onGameStart(): eBuilding = gc.getInfoTypeForString("BUILDING_SIEDLUNG") # BUILDING_PALACE eTechJagd = gc.getInfoTypeForString("TECH_HUNTING") eTechFischen = gc.getInfoTypeForString("TECH_FISHING") eUnitHunter = gc.getInfoTypeForString("UNIT_HUNTER") eUnitBoot = gc.getInfoTypeForString("UNIT_WORKBOAT") iRange = gc.getMAX_PLAYERS() for iPlayer in xrange(iRange): iResearchBoost = 0 pPlayer = gc.getPlayer(iPlayer) eTeam = pPlayer.getTeam() pTeam = gc.getTeam(eTeam) pCity = pPlayer.getCity(0) if pCity != None and pCity.isHasBuilding(eBuilding): if iPlayer == gc.getInfoTypeForString("CIVILIZATION_ROME"): # Palace if CvUtil.myRandom(10, "PalaceBoost") < 3: iResearchBoost = 15 else: iResearchBoost = 10 # Jagd if CvUtil.myRandom(10, "GiveTech") < 6: # pTeam.setHasTech(TechType eIndex, BOOL bNewValue, PlayerType ePlayer, BOOL bFirst, BOOL bAnnounce) pTeam.setHasTech(eTechJagd, 1, iPlayer, 0, 1) if CvUtil.myRandom(10, "CreateUnit") < 6: pPlayer.initUnit(eUnitHunter, pCity.getX(), pCity.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH) if iPlayer == gc.getInfoTypeForString("CIVILIZATION_CARTHAGE"): # Palace if CvUtil.myRandom(10, "PalaceBoost") < 3: iResearchBoost = 5 else: iResearchBoost = 10 # Fischen if CvUtil.myRandom(10, "GiveTech") < 6: pTeam.setHasTech(eTechFischen, 1, iPlayer, 0, 1) # Jagd if CvUtil.myRandom(10, "GiveTech") < 6: pTeam.setHasTech(eTechJagd, 1, iPlayer, 0, 1) if CvUtil.myRandom(10, "CreateUnit") < 6: pPlayer.initUnit(eUnitHunter, pCity.getX(), pCity.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH) if iPlayer == gc.getInfoTypeForString("CIVILIZATION_PERSIA"): # Palace iRand = CvUtil.myRandom(10, "PalaceBoost") if iRand < 2: iResearchBoost = 5 elif iRand < 3: iResearchBoost = 10 else: iResearchBoost = 15 # Fischen if CvUtil.myRandom(10, "GiveTech") < 8: pTeam.setHasTech(eTechFischen, 1, iPlayer, 0, 1) # Jagd if CvUtil.myRandom(10, "GiveTech") < 6: pTeam.setHasTech(eTechJagd, 1, iPlayer, 0, 1) if CvUtil.myRandom(10, "CreateUnit") < 6: pPlayer.initUnit(eUnitHunter, pCity.getX(), pCity.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH) if iPlayer == gc.getInfoTypeForString("CIVILIZATION_GREECE"): # Palace if CvUtil.myRandom(10, "PalaceBoost") < 3: iResearchBoost = 15 else: iResearchBoost = 10 # Fischen if CvUtil.myRandom(10, "GiveTech") < 8: pTeam.setHasTech(eTechFischen, 1, iPlayer, 0, 1) if CvUtil.myRandom(10, "CreateUnit") < 6: pPlayer.initUnit(eUnitBoot, pCity.getX(), pCity.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH) # alle anderen Spieler: 30% Chance +5 Forschung im Palast elif CvUtil.myRandom(10, "PalaceBoost") < 3: iResearchBoost = 5 if iResearchBoost > 0: eBuildingClass = gc.getBuildingInfo(eBuilding).getBuildingClassType() iResearch = pCity.getBuildingCommerceChange(eBuildingClass, CommerceTypes.COMMERCE_RESEARCH) + iResearchBoost pCity.setBuildingCommerceChange(eBuildingClass, CommerceTypes.COMMERCE_RESEARCH, iResearch)
def setHolyCity(): global bChristentum # Stadt finden pCity = None iJudentum = gc.getInfoTypeForString("RELIGION_JUDAISM") # Prio1: Heilige Stadt des Judentums if gc.getGame().isReligionFounded(iJudentum): pCity = gc.getGame().getHolyCity(iJudentum) # Prio 2: Juedische Stadt if pCity is None: lCities = [] iNumPlayers = gc.getMAX_PLAYERS() for i in range(iNumPlayers): loopPlayer = gc.getPlayer(i) if loopPlayer.isAlive(): iNumCities = loopPlayer.getNumCities() for j in range(iNumCities): loopCity = loopPlayer.getCity(j) if loopCity is not None and not loopCity.isNone(): if loopCity.isHasReligion(iJudentum): lCities.append(loopCity) if lCities: pCity = lCities[CvUtil.myRandom(len(lCities), "holy_jew")] # Prio3: Hauptstadt mit den meisten Sklaven (ink. Gladiatoren) # oder Prio 4: biggest capital city if pCity is None: # falls es nur Staedte ohne Sklaven gibt lCities = [] # fuer den Vergleich mit Staedten mit Sklaven iSumSlaves = 0 # biggest capital iPop = 0 iNumPlayers = gc.getMAX_PLAYERS() for i in range(iNumPlayers): loopPlayer = gc.getPlayer(i) if loopPlayer.isAlive(): loopCity = loopPlayer.getCapitalCity() if loopCity is not None and not loopCity.isNone(): iSlaves = (loopCity.getFreeSpecialistCount(gc.getInfoTypeForString("SPECIALIST_GLADIATOR")) + loopCity.getFreeSpecialistCount(gc.getInfoTypeForString("SPECIALIST_SLAVE")) + loopCity.getFreeSpecialistCount(gc.getInfoTypeForString("SPECIALIST_SLAVE_FOOD")) + loopCity.getFreeSpecialistCount(gc.getInfoTypeForString("SPECIALIST_SLAVE_PROD"))) iCityPop = loopCity.getPopulation() if iSlaves == 0: if iCityPop > iPop: iPop = iCityPop lCities = [] lCities.append(loopCity) elif iCityPop == iPop: lCities.append(loopCity) elif iSumSlaves < iSlaves: iSumSlaves = iSlaves pCity = loopCity if pCity is None: if lCities: pCity = lCities[CvUtil.myRandom(len(lCities), "holy")] # 1. Religion den Barbaren zukommen (sonst kommt Religionswahl bei Theologie) pBarbTeam = gc.getTeam(gc.getPlayer(gc.getBARBARIAN_PLAYER()).getTeam()) pBarbTeam.setHasTech(gc.getInfoTypeForString("TECH_THEOLOGY"), True, gc.getBARBARIAN_PLAYER(), True, False) # 2. Heilige Stadt setzen if pCity is not None: gc.getGame().setHolyCity(gc.getInfoTypeForString("RELIGION_CHRISTIANITY"), pCity, True) bChristentum = True
def createBarbUnit(pPlot): if not bBarbForts: return iBarbPlayer = gc.getBARBARIAN_PLAYER() pBarbPlayer = gc.getPlayer(iBarbPlayer) #eCiv = gc.getCivilizationInfo(pBarbPlayer.getCivilizationType()) iAnz = 1 if bRageBarbs: iAnz += 1 lUnits = [] # Bogen # UNITCLASS_COMPOSITE_ARCHER ist nicht baubar fuer Barbs lTempUnit = [ gc.getInfoTypeForString("UNIT_REFLEX_ARCHER"), gc.getInfoTypeForString("UNIT_ARCHER"), gc.getInfoTypeForString("UNIT_LIGHT_ARCHER") ] iUnit = -1 for iUnit in lTempUnit: if pBarbPlayer.canTrain(iUnit, 0, 0): break if iUnit != -1: lUnits.append(iUnit) # Speer lTempUnit = [ gc.getInfoTypeForString("UNIT_SPEARMAN"), gc.getInfoTypeForString("UNIT_LIGHT_SPEARMAN") ] for iUnit in lTempUnit: if pBarbPlayer.canTrain(iUnit, 0, 0): lUnits.append(iUnit) break # Axt lTempUnit = [ gc.getInfoTypeForString("UNIT_WURFAXT"), gc.getInfoTypeForString("UNIT_AXEMAN2"), gc.getInfoTypeForString("UNIT_AXEMAN"), gc.getInfoTypeForString("UNIT_AXEWARRIOR") ] for iUnit in lTempUnit: if pBarbPlayer.canTrain(iUnit, 0, 0): lUnits.append(iUnit) break # Schwert lTempUnit = [ gc.getInfoTypeForString("UNIT_SWORDSMAN"), gc.getInfoTypeForString("UNIT_SCHILDTRAEGER"), gc.getInfoTypeForString("UNIT_KURZSCHWERT") ] for iUnit in lTempUnit: if pBarbPlayer.canTrain(iUnit, 0, 0): lUnits.append(iUnit) break # Reiter lTempUnit = [ gc.getInfoTypeForString("UNIT_CATAPHRACT"), gc.getInfoTypeForString("UNIT_HORSEMAN") ] for iUnit in lTempUnit: if pBarbPlayer.canTrain(iUnit, 0, 0): lUnits.append(iUnit) break iUnit = gc.getInfoTypeForString("UNIT_HORSE_ARCHER") if pBarbPlayer.canTrain(iUnit, 0, 0): lUnits.append(iUnit) iUnit = gc.getInfoTypeForString("UNIT_CLIBANARII") if pBarbPlayer.canTrain(iUnit, 0, 0): lUnits.append(iUnit) lUnitAIs = [ UnitAITypes.UNITAI_ATTACK, UnitAITypes.UNITAI_PILLAGE, UnitAITypes.UNITAI_ATTACK_CITY_LEMMING ] iAnzUnits = len(lUnits) if iAnzUnits == 0: if gc.getGame().getCurrentEra() > 3: lUnits.append(gc.getInfoTypeForString("UNIT_SWORDSMAN")) elif gc.getGame().getCurrentEra() > 2: lUnits.append(gc.getInfoTypeForString("UNIT_SCHILDTRAEGER")) elif gc.getGame().getCurrentEra() > 1: lUnits.append(gc.getInfoTypeForString("UNIT_SPEARMAN")) elif gc.getGame().getCurrentEra() > 0: lUnits.append(gc.getInfoTypeForString("UNIT_LIGHT_SPEARMAN")) # Einheit setzen for _ in xrange(iAnz): iUnit = lUnits[CvUtil.myRandom(iAnzUnits, "createBarbUnit")] iUnitAI = lUnitAIs[CvUtil.myRandom(len(lUnitAIs), "createBarbUnit_AI")] pUnit = pBarbPlayer.initUnit(iUnit, pPlot.getX(), pPlot.getY(), iUnitAI, DirectionTypes.DIRECTION_SOUTH) pUnit.finishMoves()
def setGoodies(eImprovement,eNum, plots): impBarbFort = gc.getInfoTypeForString("IMPROVEMENT_BARBARENFORT") impCave = gc.getInfoTypeForString("IMPROVEMENT_CAVE") impGoody = gc.getInfoTypeForString("IMPROVEMENT_GOODY_HUT") lGoodies = [impBarbFort,impCave,impGoody] # 0 = WORLDSIZE_DUEL # 1 = WORLDSIZE_TINY # 2 = WORLDSIZE_SMALL # 3 = WORLDSIZE_STANDARD # 4 = WORLDSIZE_LARGE # 5 = WORLDSIZE_HUGE iMapSize = gc.getMap().getWorldSize() * 3 iAnz = iMapSize + 1 - eNum if iAnz <= 0: return i = 0 while i < iAnz: bIgnore = False if not plots: return iRand = CvUtil.myRandom(len(plots), "setBarbFortsOrCavesOrGoodyHuts") plot = plots[iRand] #CyInterface().addMessage(gc.getGame().getActivePlayer(), True, 15, CyTranslator().getText("TXT_KEY_MESSAGE_TEST", ("setGoodies",len(plots))), None, 2, None, ColorTypes(11), 0, 0, False, False) # Umkreis checken iRange = 3 for x in xrange(-iRange, iRange+1): for y in xrange(-iRange, iRange+1): loopPlot = plotXY(plot.getX(), plot.getY(), x, y) if loopPlot and not loopPlot.isNone(): if loopPlot.getImprovementType() in lGoodies or loopPlot.getOwner() != -1: bIgnore = True # Umkreis des gefundenen Plots aus der Plotliste entfernen for x2 in xrange(-iRange, iRange+1): for y2 in xrange(-iRange, iRange+1): loopPlot = plotXY(plot.getX(), plot.getY(), x2, y2) if loopPlot and not loopPlot.isNone(): if loopPlot in plots: plots.remove(loopPlot) break if bIgnore: break i += 1 if bIgnore: continue # Improvement setzen plot.setImprovementType(eImprovement) # Einheit in die Festung setzen if eImprovement == impBarbFort: PAE_Barbaren.setFortDefence(plot) # Einheit in die Cave setzen elif eImprovement == impCave: setUnitIntoCave(plot) # Alle Plots im Umkreis von 4 Feldern aus der Liste entfernen iRange = 4 for x in xrange(-iRange, iRange+1): for y in xrange(-iRange, iRange+1): loopPlot = plotXY(plot.getX(), plot.getY(), x, y) if loopPlot and not loopPlot.isNone(): if loopPlot in plots: plots.remove(loopPlot) return
def doSeewind(): terr_ocean = gc.getInfoTypeForString("TERRAIN_OCEAN") terr_ocean2 = gc.getInfoTypeForString("TERRAIN_DEEP_OCEAN") feat_ice = gc.getInfoTypeForString("FEATURE_ICE") iNumDirection = min(DirectionTypes.NUM_DIRECTION_TYPES, len(L.LSeewind)) # should both be 8 iWindplots = 6 # amount of wind arrows (plots) per wind iDarkIce = gc.getInfoTypeForString("FEATURE_DARK_ICE") iMapW = gc.getMap().getGridWidth() iMapH = gc.getMap().getGridHeight() # get all ocean plots OceanPlots = [] for i in xrange(iMapW): for j in xrange(iMapH): loopPlot = gc.getMap().plot(i, j) if loopPlot and not loopPlot.isNone(): if loopPlot.getTerrainType() == terr_ocean or loopPlot.getTerrainType() == terr_ocean2: if loopPlot.getFeatureType() != feat_ice and loopPlot.getFeatureType() != iDarkIce: OceanPlots.append(loopPlot) if not OceanPlots: return # 0 = WORLDSIZE_DUEL # 1 = WORLDSIZE_TINY # 2 = WORLDSIZE_SMALL # 3 = WORLDSIZE_STANDARD # 4 = WORLDSIZE_LARGE # 5 = WORLDSIZE_HUGE iMaxEffects = (gc.getMap().getWorldSize() + 1) * 2 for i in xrange(iMaxEffects): # get first ocean plot iRand = CvUtil.myRandom(len(OceanPlots), "doSeewind1") loopPlot = OceanPlots[iRand] # First direction iDirection = CvUtil.myRandom(iNumDirection, "doSeewind2") # Start Windplots for j in xrange(iWindplots): if loopPlot and not loopPlot.isNone(): if loopPlot.getFeatureType() == iDarkIce: continue # Flunky: disabled, because already checked # if loopPlot.getFeatureType() != feat_ice and (loopPlot.getTerrainType() == terr_ocean or loopPlot.getTerrainType() == terr_ocean2): # Im Umkreis von 5 soll kein weiteres Windfeature sein bSet = True iRange = 2 for x in xrange(-iRange, iRange+1): for y in xrange(-iRange, iRange+1): pPlot2 = plotXY(loopPlot.getX(), loopPlot.getY(), x, y) if pPlot2.getFeatureType() in L.LSeewind: bSet = False break if not bSet: break if bSet: CvUtil.pyPrint(u'Seewind %d was selected of %d possibilities' %(iDirection, len(L.LSeewind))) loopPlot.setFeatureType(L.LSeewind[iDirection], 0) iDirection = (iDirection + CvUtil.myRandom(3, "doSeewind3") - 1) % iNumDirection loopPlot = plotDirection(loopPlot.getX(), loopPlot.getY(), DirectionTypes(iDirection)) else: break
def removePagans(pCity): iReligion = gc.getInfoTypeForString("RELIGION_CHRISTIANITY") iPlayer = pCity.getOwner() pPlayer = gc.getPlayer(iPlayer) # Kult lCorp = [] iRange = gc.getNumCorporationInfos() for i in range(iRange): if pCity.isHasCorporation(i): lCorp.append(i) # Religion lReli = [] iRange = gc.getNumReligionInfos() for i in range(iRange): if pCity.isHasReligion(i) and i != iReligion: lReli.append(i) # Kult oder Religion entfernen text = "" bUndoCorp = False if lCorp and lReli: if CvUtil.myRandom(2, "undoCorp") == 1: bUndoCorp = True # Kult if lCorp or bUndoCorp: iRand = CvUtil.myRandom(len(lCorp), "removePaganCult") iRange = gc.getNumBuildingInfos() for iBuildingLoop in range(iRange): if pCity.getNumBuilding(iBuildingLoop) > 0: pBuilding = gc.getBuildingInfo(iBuildingLoop) if pBuilding.getPrereqCorporation() == lCorp[iRand]: # Akademien (Corp7) if pBuilding.getType() not in [ gc.getInfoTypeForString("BUILDING_ACADEMY_2"), gc.getInfoTypeForString("BUILDING_ACADEMY_3"), gc.getInfoTypeForString("BUILDING_ACADEMY_4") ]: # Wunder sollen nicht betroffen werden iBuildingClass = pBuilding.getBuildingClassType() if not isWorldWonderClass(iBuildingClass) and not isTeamWonderClass(iBuildingClass) and not isNationalWonderClass(iBuildingClass): pCity.setNumRealBuilding(iBuildingLoop,0) pCity.setHasCorporation(lCorp[iRand], 0, 0, 0) text = gc.getCorporationInfo( lCorp[iRand] ).getText() # Religion elif lReli: iRand = CvUtil.myRandom(len(lReli), "removePaganReli") iRange = gc.getNumBuildingInfos() for iBuildingLoop in range(iRange): if pCity.isHasBuilding(iBuildingLoop): pBuilding = gc.getBuildingInfo(iBuildingLoop) if pBuilding.getPrereqReligion() == lReli[iRand]: # Holy City if pBuilding.getHolyCity() == -1: # Wunder sollen nicht betroffen werden iBuildingClass = pBuilding.getBuildingClassType() if not isWorldWonderClass(iBuildingClass) and not isTeamWonderClass(iBuildingClass) and not isNationalWonderClass(iBuildingClass): pCity.setNumRealBuilding(iBuildingLoop,0) pCity.setHasReligion(lReli[iRand], 0, 0, 0) text = gc.getReligionInfo( lReli[iRand] ).getText() # Meldung if pPlayer.isHuman() and text != "": iRand = 1 + CvUtil.myRandom(3, "TXT_KEY_MESSAGE_HERESY_CULTS_") CyInterface().addMessage(iPlayer, True, 10, CyTranslator().getText("TXT_KEY_MESSAGE_HERESY_CULTS_"+str(iRand),(text,pCity.getName())), None, 2,"Art/Interface/Buttons/Actions/button_kreuz.dds", ColorTypes(11), pCity.getX(), pCity.getY(), True, True)
def Megara2(argsList): iButtonId = argsList[0] iAthen = 0 iSparta = 1 iKorinth = 2 iTheben = 4 pSparta = gc.getPlayer(iSparta) bIsHuman = pSparta.isHuman() if iButtonId == 0: iRand = CvUtil.myRandom(2, "pelo_1") if not gc.getTeam(iSparta).canDeclareWar(iAthen): if bIsHuman: # Kein Krieg moeglich -> Kein Gold/Bronze popupInfo = CyPopupInfo() popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT) popupInfo.setText(CyTranslator().getText("TXT_KEY_EVENT_MEGARA_SPARTA_OPTION_1_NO_WAR_POSSIBLE",())) popupInfo.addPopup(iSparta) # Wenig Gold elif iRand == 0: pSparta.changeGold(200) gc.getTeam(iSparta).declareWar(iAthen, 0, 5) # WARPLAN_TOTAL if bIsHuman: popupInfo = CyPopupInfo() popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT) popupInfo.setText(CyTranslator().getText("TXT_KEY_EVENT_MEGARA_SPARTA_OPTION_1_OUTCOME_LOW",())) popupInfo.addPopup(iSparta) # Viel Gold elif iRand == 1: pSparta.changeGold(1000) gc.getTeam(iSparta).declareWar(iAthen, 0, 5) # WARPLAN_TOTAL if bIsHuman: popupInfo = CyPopupInfo() popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT) popupInfo.setText(CyTranslator().getText("TXT_KEY_EVENT_MEGARA_SPARTA_OPTION_1_OUTCOME_HIGH",())) popupInfo.addPopup(iSparta) # 10 Bronze else: # 10 freie Bronze in der Hauptstadt -> in allen Staedten am Handelsnetz verfuegbar gc.getTeam(iSparta).declareWar(iAthen, 0, 5) # WARPLAN_TOTAL iNumCities = pSparta.getNumCities() eBronze = gc.getInfoTypeForString("BONUS_BRONZE") pCapital = pSparta.getCapitalCity() pCapital.changeFreeBonus(eBronze, 10) if bIsHuman: popupInfo = CyPopupInfo() popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT) popupInfo.setText(CyTranslator().getText("TXT_KEY_EVENT_MEGARA_SPARTA_OPTION_1_OUTCOME_BRONZE",())) popupInfo.addPopup(iSparta) elif iButtonId == 1: iRand = CvUtil.myRandom(1, "pelo_2") if not gc.getTeam(iTheben).canDeclareWar(iAthen): iRand = 1 # Theben kann nicht # Theben ist einverstanden -> Krieg if iRand == 0: if gc.getTeam(iSparta).canDeclareWar(iAthen): gc.getTeam(iSparta).declareWar(iAthen, 0, 5) # WARPLAN_TOTAL gc.getTeam(iTheben).declareWar(iAthen, 0, 5) if bIsHuman: popupInfo = CyPopupInfo() popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT) popupInfo.setText(CyTranslator().getText("TXT_KEY_EVENT_MEGARA_SPARTA_OPTION_2_OUTCOME_SUCCESS",())) popupInfo.addPopup(iSparta) if gc.getTeam(iTheben).isHuman(): popupInfo = CyPopupInfo() popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT) popupInfo.setText(CyTranslator().getText("TXT_KEY_EVENT_MEGARA_SPARTA_OPTION_2_OUTCOME_SUCCESS_THEBEN",())) popupInfo.addPopup(iTheben) elif bIsHuman: popupInfo = CyPopupInfo() popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT) popupInfo.setText(CyTranslator().getText("TXT_KEY_EVENT_MEGARA_SPARTA_OPTION_2_NO_WAR_POSSIBLE",())) popupInfo.addPopup(iSparta) else: if bIsHuman: popupInfo = CyPopupInfo() popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT) popupInfo.setText(CyTranslator().getText("TXT_KEY_EVENT_MEGARA_SPARTA_OPTION_2_OUTCOME_FAILED",())) popupInfo.addPopup(iSparta) elif iButtonId == 2: gc.getPlayer(iKorinth).AI_changeAttitudeExtra(iSparta, -3) if gc.getTeam(iSparta).canDeclareWar(iAthen): # Sparta und Theben ziehen gemeinsam in den Krieg if gc.getTeam(iTheben).canDeclareWar(iAthen): gc.getTeam(iTheben).declareWar(iAthen, 0, 5) # WARPLAN_TOTAL gc.getTeam(iSparta).declareWar(iAthen, 0, 5) if gc.getTeam(iTheben).isHuman(): popupInfo = CyPopupInfo() popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT) popupInfo.setText(CyTranslator().getText("TXT_KEY_EVENT_MEGARA_SPARTA_OPTION_3_OUTCOME_THEBEN",())) popupInfo.addPopup(iTheben) if bIsHuman: popupInfo = CyPopupInfo() popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT) popupInfo.setText(CyTranslator().getText("TXT_KEY_EVENT_MEGARA_SPARTA_OPTION_3_OUTCOME_SPARTA",())) popupInfo.addPopup(iSparta) if gc.getTeam(iKorinth).isHuman(): popupInfo = CyPopupInfo() popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT) popupInfo.setText(CyTranslator().getText("TXT_KEY_EVENT_MEGARA_SPARTA_OPTION_3_OUTCOME_KORINTH",())) popupInfo.addPopup(iKorinth) # Theben hat Friedensvertrag mit Athen elif gc.getTeam(iSparta).canDeclareWar(iAthen): gc.getTeam(iSparta).declareWar(iAthen, 0, 5) # WARPLAN_TOTAL if gc.getTeam(iSparta).isHuman(): popupInfo = CyPopupInfo() popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT) popupInfo.setText(CyTranslator().getText("TXT_KEY_EVENT_MEGARA_SPARTA_OPTION_3_OUTCOME_SPARTA_NO_THEBEN",())) popupInfo.addPopup(iSparta) if gc.getTeam(iKorinth).isHuman(): popupInfo = CyPopupInfo() popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT) popupInfo.setText(CyTranslator().getText("TXT_KEY_EVENT_MEGARA_SPARTA_OPTION_3_OUTCOME_KORINTH_NO_THEBEN",())) popupInfo.addPopup(iKorinth) elif bIsHuman: popupInfo = CyPopupInfo() popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT) popupInfo.setText(CyTranslator().getText("TXT_KEY_EVENT_MEGARA_SPARTA_OPTION_3_NO_WAR_POSSIBLE",())) popupInfo.addPopup(iSparta)
def onEndGameTurn(iGameTurn, sScenarioName): global IceSnow global IceCoast global IceTundra global IceTundra2 global IceEis global IceDesertEbene global IceDesertCoast eTundra = gc.getInfoTypeForString("TERRAIN_TUNDRA") eSnow = gc.getInfoTypeForString("TERRAIN_SNOW") #eGras = gc.getInfoTypeForString("TERRAIN_GRASS") eEbene = gc.getInfoTypeForString("TERRAIN_PLAINS") eEis = gc.getInfoTypeForString("FEATURE_ICE") eCoast = gc.getInfoTypeForString("TERRAIN_COAST") #eDesert = gc.getInfoTypeForString("TERRAIN_DESERT") eDarkIce = gc.getInfoTypeForString("FEATURE_DARK_ICE") if iGameTurn == 1: for x in xrange(CyMap().getGridWidth()): for y in xrange(CyMap().getGridHeight()): pPlot = CyMap().plot(x, y) if pPlot.getTerrainType() == eDarkIce: continue if pPlot.getTerrainType() == eSnow: IceSnow.append(pPlot) elif pPlot.getTerrainType() == eTundra: # Extra Tundra-Bereich, wos langsamer gehn soll if sScenarioName == "SchmelzEuro" and x >= 42 and y >= 49: IceTundra2.append(pPlot) else: IceTundra.append(pPlot) elif pPlot.getFeatureType() == eEis: IceEis.append(pPlot) # Ueberflutung if pPlot.isCoastalLand( ) and not pPlot.isCity() and not pPlot.isHills( ) and not pPlot.isPeak() and pPlot.getBonusType( pPlot.getOwner()) == -1: if sScenarioName == "SchmelzEuro": if y >= 28: IceCoast.append(pPlot) else: IceCoast.append(pPlot) # Desertifizierung if sScenarioName == "SchmelzEuro" and y <= 8: if pPlot.getTerrainType( ) == eEbene and not pPlot.isCoastalLand( ) and not pPlot.isCity() and not pPlot.isRiver(): IceDesertEbene.append(pPlot) elif pPlot.getTerrainType( ) == eCoast and y <= 6 and x >= 2 and x <= 60: IceDesertCoast.append(pPlot) # ---------------- Schmelzen 4/4 (BoggyB)-------- elif iGameTurn > 1: # Normal alle 40 Runden (insg. 940 Runden) # Schnell alle 32 Runden (insg. 770 Runden) # Episch alle 45 Runden (insg. 1095 Runden) # Marathon alle 52 Runden (insg. 1220 Runden) iTurnSchmelzIntervall = 40 iTurnLimit = 800 iGameSpeed = gc.getGame().getGameSpeedType() if iGameSpeed == gc.getInfoTypeForString("GAMESPEED_QUICK"): iTurnSchmelzIntervall = 32 iTurnLimit = 600 elif iGameSpeed == gc.getInfoTypeForString("GAMESPEED_EPIC"): iTurnSchmelzIntervall = 45 iTurnLimit = 900 elif iGameSpeed == gc.getInfoTypeForString("GAMESPEED_MARATHON"): iTurnSchmelzIntervall = 52 iTurnLimit = 1000 # ***TEST*** #CyInterface().addMessage(gc.getGame().getActivePlayer(), True, 10, CyTranslator().getText("TXT_KEY_MESSAGE_TEST",("Summe Eis",len(IceSnow))), None, 2, None, ColorTypes(10), 0, 0, False, False) if iGameTurn % iTurnSchmelzIntervall == 0 and iGameTurn <= iTurnLimit: iWahrscheinlichkeit = 8 # if sScenarioName == "SchmelzWelt": # iWahrscheinlichkeit = 8 eTundra = gc.getInfoTypeForString("TERRAIN_TUNDRA") eSnow = gc.getInfoTypeForString("TERRAIN_SNOW") eGras = gc.getInfoTypeForString("TERRAIN_GRASS") eEbene = gc.getInfoTypeForString("TERRAIN_PLAINS") eEis = gc.getInfoTypeForString("FEATURE_ICE") eCoast = gc.getInfoTypeForString("TERRAIN_COAST") eDesert = gc.getInfoTypeForString("TERRAIN_DESERT") # Schnee -> Tundra if IceSnow: for pPlot in IceSnow: iRand = CvUtil.myRandom(iWahrscheinlichkeit, "IceSnow") if iRand == 1: pPlot.setTerrainType(eTundra, 1, 1) IceSnow.remove(pPlot) # Tundra Liste updaten if sScenarioName == "SchmelzEuro" and pPlot.getX( ) >= 42 and pPlot.getY() >= 49: IceTundra2.append(pPlot) else: IceTundra.append(pPlot) # Tundra -> Gras (25%) oder Ebene (75%) if IceTundra: for pPlot in IceTundra: iRand = CvUtil.myRandom(iWahrscheinlichkeit, "IceTundra") if iRand == 1: iRand = CvUtil.myRandom(4, "IceTundraB") if iRand == 1: pPlot.setTerrainType(eGras, 1, 1) else: pPlot.setTerrainType(eEbene, 1, 1) IceTundra.remove(pPlot) if IceTundra2: for pPlot in IceTundra2: iRand = CvUtil.myRandom(iWahrscheinlichkeit * 3, "IceTundra2") if iRand == 1: iRand = CvUtil.myRandom(4, "IceTundra2B") if iRand == 1: pPlot.setTerrainType(eGras, 1, 1) else: pPlot.setTerrainType(eEbene, 1, 1) IceTundra2.remove(pPlot) # Eis schmilzt if IceEis: for pPlot in IceEis: iRand = CvUtil.myRandom(iWahrscheinlichkeit, "IceEis") if iRand == 1: pPlot.setFeatureType(-1, 0) IceEis.remove(pPlot) # Ueberflutung if IceCoast: for pPlot in IceCoast: iRand = CvUtil.myRandom(50, "IceCoast") if iRand == 1: pPlot.setTerrainType(eCoast, 1, 1) IceCoast.remove(pPlot) # Desertifizierung if sScenarioName == "SchmelzEuro": if IceDesertEbene: for pPlot in IceDesertEbene: iRand = CvUtil.myRandom(iWahrscheinlichkeit, "IceDesertEbene") if iRand == 1: pPlot.setTerrainType(eDesert, 1, 1) pPlot.setImprovementType(-1) IceDesertEbene.remove(pPlot) elif IceDesertCoast: for pPlot in IceDesertCoast: iRand = CvUtil.myRandom(iWahrscheinlichkeit, "IceDesertCoast") if iRand == 1: pPlot.setTerrainType(eEbene, 1, 1) IceDesertCoast.remove(pPlot) # Desert Liste updaten IceDesertEbene.append(pPlot)
def Plataiai1(argsList): iButtonId = argsList[0] iAthen = 0 iTheben = 4 pTheben = gc.getPlayer(iTheben) iX = 55 iY = 33 pPlotPlataiai = CyMap().plot(iX, iY) bIsHuman = pTheben.isHuman() bAthenIsHuman = gc.getPlayer(iAthen).isHuman() # Unabhaengig von Auswahloption wird Krieg erklaert bWar = False if gc.getTeam(iTheben).canDeclareWar(iAthen): gc.getTeam(iTheben).declareWar(iAthen, 0, 5) # WARPLAN_TOTAL bWar = True # Wird kein Krieg erklaert, passiert nichts if bWar: if iButtonId == 0: iRand = CvUtil.myRandom(2, "pelo_3") # Klein if iRand == 0: iCultTheben = pPlotPlataiai.getCulture(iTheben) iCultAthen = pPlotPlataiai.getCulture(iAthen) # Garantieren, dass Theben den Plot besitzt pPlotPlataiai.changeCulture(iTheben, iCultAthen, 1) eHoplit = gc.getInfoTypeForString("UNIT_HOPLIT") pTheben.initUnit(eHoplit, iX, iY, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH) if bIsHuman: popupInfo = CyPopupInfo() popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT) popupInfo.setText(CyTranslator().getText("TXT_KEY_EVENT_PLATAIAI_OPTION_1_OUTCOME_LOW",())) popupInfo.addPopup(iTheben) if bAthenIsHuman: popupInfo = CyPopupInfo() popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT) popupInfo.setText(CyTranslator().getText("TXT_KEY_EVENT_PLATAIAI_OPTION_1_OUTCOME_LOW_ATHEN",())) popupInfo.addPopup(iAthen) # Mittel elif iRand == 1: # Athen erhaelt Plot und 1 Hoplit eHoplit = gc.getInfoTypeForString("UNIT_HOPLIT") iCultTheben = pPlotPlataiai.getCulture(iTheben) iCultAthen = pPlotPlataiai.getCulture(iAthen) pPlotPlataiai.changeCulture(iAthen, iCultTheben, 1) gc.getPlayer(iAthen).initUnit(eHoplit, iX, iY, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH) eSkirmisher = gc.getInfoTypeForString("UNIT_SKIRMISHER") eHorseman = gc.getInfoTypeForString("UNIT_HORSEMAN") for _ in xrange(5): pTheben.initUnit(eHoplit, iX-1, iY-1, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH) for _ in xrange(3): pTheben.initUnit(eSkirmisher, iX-1, iY-1, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH) pTheben.initUnit(eHorseman, iX-1, iY-1, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH) if bIsHuman: popupInfo = CyPopupInfo() popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT) popupInfo.setText(CyTranslator().getText("TXT_KEY_EVENT_PLATAIAI_OPTION_1_OUTCOME_MEDIUM",())) popupInfo.addPopup(iTheben) if bAthenIsHuman: popupInfo = CyPopupInfo() popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT) popupInfo.setText(CyTranslator().getText("TXT_KEY_EVENT_PLATAIAI_OPTION_1_OUTCOME_MEDIUM_ATHEN",())) popupInfo.addPopup(iAthen) elif iRand == 2: # Theben erhaelt Plot und grosse Armee iCultTheben = pPlotPlataiai.getCulture(iTheben) iCultAthen = pPlotPlataiai.getCulture(iAthen) pPlotPlataiai.changeCulture(iTheben, iCultAthen, 1) eSkirmisher = gc.getInfoTypeForString("UNIT_SKIRMISHER") eHorseman = gc.getInfoTypeForString("UNIT_HORSEMAN") eHoplit = gc.getInfoTypeForString("UNIT_HOPLIT") eSupply = gc.getInfoTypeForString("UNIT_SUPPLY_WAGON") eGeneral = gc.getInfoTypeForString("UNIT_GREAT_GENERAL") for _ in xrange(10): pTheben.initUnit(eHoplit, iX, iY, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH) for _ in xrange(5): pTheben.initUnit(eSkirmisher, iX, iY, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH) for _ in xrange(4): pTheben.initUnit(eHorseman, iX, iY, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH) for _ in xrange(2): pTheben.initUnit(eGeneral, iX, iY, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH) pUnit = pTheben.initUnit(eSupply, iX, iY, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH) PAE_Unit.setSupply(pUnit,200) if bIsHuman: popupInfo = CyPopupInfo() popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT) popupInfo.setText(CyTranslator().getText("TXT_KEY_EVENT_PLATAIAI_OPTION_1_OUTCOME_HIGH",())) popupInfo.addPopup(iTheben) if bAthenIsHuman: popupInfo = CyPopupInfo() popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT) popupInfo.setText(CyTranslator().getText("TXT_KEY_EVENT_PLATAIAI_OPTION_1_OUTCOME_HIGH_ATHEN",())) popupInfo.addPopup(iAthen) elif iButtonId == 1: # Athen erhaelt Plot und 1 Hoplit eHoplit = gc.getInfoTypeForString("UNIT_HOPLIT") iCultTheben = pPlotPlataiai.getCulture(iTheben) iCultAthen = pPlotPlataiai.getCulture(iAthen) pPlotPlataiai.changeCulture(iAthen, iCultTheben, 1) gc.getPlayer(iAthen).initUnit(eHoplit, iX, iY, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH) if bIsHuman: popupInfo = CyPopupInfo() popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT) popupInfo.setText(CyTranslator().getText("TXT_KEY_EVENT_PLATAIAI_OPTION_2_OUTCOME",())) popupInfo.addPopup(iTheben) if bAthenIsHuman: popupInfo = CyPopupInfo() popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT) popupInfo.setText(CyTranslator().getText("TXT_KEY_EVENT_PLATAIAI_OPTION_2_OUTCOME_ATHEN",())) popupInfo.addPopup(iAthen) elif iButtonId == 2: iAthenX = 57 iAthenY = 30 pAthenCity = CyMap().plot(iAthenX, iAthenY).getPlotCity() if pAthenCity and not pAthenCity.isNone(): if pAthenCity.getOwner() == iAthen: # Fluechtlinge pAthenCity.changePopulation(1) if bIsHuman: popupInfo = CyPopupInfo() popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT) popupInfo.setText(CyTranslator().getText("TXT_KEY_EVENT_PLATAIAI_OPTION_3_OUTCOME",())) popupInfo.addPopup(iTheben) if bAthenIsHuman: popupInfo = CyPopupInfo() popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT) popupInfo.setText(CyTranslator().getText("TXT_KEY_EVENT_PLATAIAI_OPTION_3_OUTCOME_ATHEN",())) popupInfo.addPopup(iAthen) else: if bIsHuman: popupInfo = CyPopupInfo() popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT) popupInfo.setText(CyTranslator().getText("TXT_KEY_EVENT_PLATAIAI_OPTION_3_OUTCOME_NO_ATHEN",())) popupInfo.addPopup(iTheben) if bAthenIsHuman: popupInfo = CyPopupInfo() popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT) popupInfo.setText(CyTranslator().getText("TXT_KEY_EVENT_PLATAIAI_OPTION_3_OUTCOME_NO_ATHEN_ATHEN",())) popupInfo.addPopup(iAthen) else: if bIsHuman: popupInfo = CyPopupInfo() popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT) popupInfo.setText(CyTranslator().getText("TXT_KEY_EVENT_PLATAIAI_OPTION_3_OUTCOME_NO_ATHEN",())) popupInfo.addPopup(iTheben) if bAthenIsHuman: popupInfo = CyPopupInfo() popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT) popupInfo.setText(CyTranslator().getText("TXT_KEY_EVENT_PLATAIAI_OPTION_3_OUTCOME_NO_ATHEN_ATHEN",())) popupInfo.addPopup(iAthen) elif bIsHuman: popupInfo = CyPopupInfo() popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT) popupInfo.setText(CyTranslator().getText("TXT_KEY_EVENT_PLATAIAI_NO_WAR",())) popupInfo.addPopup(iTheben)