Code:
def doMeteorites(self):
feat_meteor = gc.getInfoTypeForString('FEATURE_METEORS')
feat_brand = gc.getInfoTypeForString('FEATURE_SMOKE')
feat_swamp = gc.getInfoTypeForString('FEATURE_SWAMP')
feat_flood_plains = gc.getInfoTypeForString('FEATURE_FLOOD_PLAINS')
feat_oasis = gc.getInfoTypeForString('FEATURE_OASIS')
feat_forest = gc.getInfoTypeForString('FEATURE_FOREST')
feat_forest2 = gc.getInfoTypeForString('FEATURE_DICHTERWALD')
feat_forest_burnt = gc.getInfoTypeForString('FEATURE_FOREST_BURNT')
iImpType1 = gc.getInfoTypeForString("IMPROVEMENT_LUMBER_CAMP")
bonus_magnetit = gc.getInfoTypeForString("BONUS_MAGNETIT")
bonus_oreichalkos = gc.getInfoTypeForString("BONUS_OREICHALKOS")
bonusPlotArray = []
# 0 = WORLDSIZE_DUEL
# 1 = WORLDSIZE_TINY
# 2 = WORLDSIZE_SMALL
# 3 = WORLDSIZE_STANDARD
# 4 = WORLDSIZE_LARGE
# 5 = WORLDSIZE_HUGE
iMaxEffect = 0
iMapSize = gc.getMap().getWorldSize()
if iMapSize == 0: iMax = 1
elif iMapSize == 1: iMax = 2
elif iMapSize == 2: iMax = 4
elif iMapSize == 3: iMax = 6
elif iMapSize == 4: iMax = 8
elif iMapSize == 5: iMax = 10
else: iMax = 12
# 20 Chancen fuer max. iMax Meteorstrikes
for i in range (20):
# Maximal iMax Effekte
if iMaxEffect == iMax: break
iMapW = gc.getMap().getGridWidth()
iMapH = gc.getMap().getGridHeight()
iRandX = self.myRandom(iMapW, None)
iRandY = self.myRandom(iMapH, None)
pPlot = gc.getMap().plot(iRandX, iRandY)
if None != pPlot and not pPlot.isNone():
iMaxEffect += 1
# Modernisierung und Strasse entfernen
if not pPlot.isCity():
pPlot.setRouteType(-1)
pPlot.setImprovementType(-1)
iPlayer = pPlot.getOwner()
if pPlot.isVisibleToWatchingHuman():
CyCamera().JustLookAtPlot(pPlot)
popupInfo = CyPopupInfo()
popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT)
popupInfo.setText(CyTranslator().getText("TXT_KEY_DISASTER_METEORITES",("",)))
popupInfo.addPopup(gc.getGame().getActivePlayer())
CyInterface().addMessage(gc.getGame().getActivePlayer(), True, 12, CyTranslator().getText("TXT_KEY_DISASTER_METEORITES",("",)),"AS2D_METEORSTRIKE",2,gc.getFeatureInfo(feat_meteor).getButton(),ColorTypes(7),iRandX,iRandY,True,True)
# Effekt
iEffect = gc.getInfoTypeForString("EFFECT_METEORS")
CyEngine().triggerEffect( iEffect, pPlot.getPoint() )
# Stadt
if pPlot.isCity():
pCity = pPlot.getPlotCity()
iPop_alt = pCity.getPopulation()
iPop_neu = int(pCity.getPopulation() / 2)
if iPop_neu < 2: iPop_neu = 1
pCity.setPopulation(iPop_neu)
pCity.setFood(0)
if iPlayer != -1:
if pPlot.isVisibleToWatchingHuman():
if iPlayer == gc.getGame().getActivePlayer():
CyInterface().addMessage(iPlayer, True, 12, CyTranslator().getText("TXT_KEY_DISASTER_METEORITES_CITY",(pCity.getName(),iPop_neu,iPop_alt)),None,2,gc.getFeatureInfo(feat_meteor).getButton(),ColorTypes(7),iRandX,iRandY,True,True)
else:
CyInterface().addMessage(gc.getGame().getActivePlayer(), True, 12, CyTranslator().getText("TXT_KEY_DISASTER_METEORITES_CITY_OTHER",(pOwner.getCivilizationAdjective(2),pCity.getName())),None,2,gc.getFeatureInfo(feat_meteor).getButton(),ColorTypes(2),iRandX,iRandY,True,True)
# City, Wahrscheinlichkeit in %
self.doKillUnits(pPlot,10)
self.doDestroyCityBuildings(pCity,33)
# Stadtmauern zerstoeren
self.doDestroyWalls(pCity)
# rundherum Brand generieren und dabei 50:50 Modernis und Strassen entfernen
for i in range(3):
for j in range(3):
loopPlot = gc.getMap().plot(iRandX - 1 + i, iRandY - 1 + j)
if None != loopPlot and not loopPlot.isNone():
if loopPlot.getFeatureType() != feat_swamp and loopPlot.getFeatureType() != feat_flood_plains and not loopPlot.isPeak() \
and not loopPlot.isWater() and loopPlot.getFeatureType() != feat_oasis:
if loopPlot.getFeatureType() == feat_forest or loopPlot.getFeatureType() == feat_forest2:
loopPlot.setFeatureType(feat_forest_burnt,0)
else:
loopPlot.setFeatureType(feat_brand,0)
if loopPlot.getImprovementType() == iImpType1: loopPlot.setImprovementType(-1)
if self.myRandom(2, None) == 1:
if not loopPlot.isCity():
loopPlot.setRouteType(-1)
loopPlot.setImprovementType(-1)
self.doKillUnits(loopPlot,20)
# Plot fuer Magnetit/Oreichalkos Bonus checken
if not loopPlot.isWater() and not loopPlot.isCity() and not loopPlot.isPeak() and loopPlot.getBonusType(loopPlot.getOwner()) == -1:
bonusPlotArray.append(loopPlot)
# Chance einer neuen Bonus Resource, 25% - danach 50:50 - Magnetit:Oreichalkos
if len(bonusPlotArray) > 0:
iRand = self.myRandom(8, None)
if iRand < 2:
if iRand == 0: iNewBonus = bonus_magnetit
else: iNewBonus = bonus_oreichalkos
iRandPlot = self.myRandom(len(bonusPlotArray), None)
bonusPlotArray[iRandPlot].setBonusType(iNewBonus)
if bonusPlotArray[iRandPlot].getOwner() > -1:
if gc.getPlayer(bonusPlotArray[iRandPlot].getOwner()).isHuman():
CyInterface().addMessage(bonusPlotArray[iRandPlot].getOwner(), True, 10, CyTranslator().getText("TXT_KEY_NEW_BONUS",(gc.getBonusInfo(iNewBonus).getDescription(),)), None, 2, gc.getBonusInfo(iNewBonus).getButton(), ColorTypes(14), bonusPlotArray[iRandPlot].getX(), bonusPlotArray[iRandPlot].getY(), True, True)