Code:
###Restauration beginn###
elif iTechType == gc.getInfoTypeForString("TECH_REACTION"):
if (gc.getGame().isOption(gc.getInfoTypeForString("GAMEOPTION_SPAWN_NEW_CIVS"))):
DeadCivArray = []
ReturnPlayerID =-1
for iPlayer in range(gc.getMAX_PLAYERS()):
pDeadPlayer = gc.getPlayer(iPlayer)
if (pDeadPlayer.isEverAlive() ):
if (not pDeadPlayer.isAlive() ):
DeadCivArray.append(iPlayer)
if len(DeadCivArray ) > 0:
iMeineZufallszahl = CyGame().getSorenRandNum(len(DeadCivArray), 'IllBeBack')
iReturnPlayerID=DeadCivArray[iMeineZufallszahl]
if (iReturnPlayerID != -1):
pReturnEmpire = gc.getPlayer(iReturnPlayerID )
iReturnTeam = pReturnEmpire.getTeam ()
pReturnTeam = gc.getTeam(iReturnTeam)
for iPlayer2 in range(gc.getMAX_PLAYERS()):
pPlayer2 = gc.getPlayer(iPlayer2)
if(pPlayer2.getTeam() != iReturnTeam ):
if (not gc.getTeam(pPlayer2.getTeam()).isBarbarian() ):
gc.getTeam(pPlayer2.getTeam()).makePeace(iReturnTeam)
(loopCity, iter) = pPlayer2.firstCity(True)
while(loopCity):
if not (loopCity.isCapital()):
if (loopCity.getOriginalOwner() == iReturnPlayerID):
iCityX = loopCity.getX()
iCityY = loopCity.getY()
pReturnEmpire.acquireCity(loopCity,False,True)
###init Units
for i in range(6):
Defender = loopCity.getConscriptUnit ()
pReturnEmpire.initUnit( Defender, iCityX,iCityY, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH )
pReturnEmpire.initUnit( gc.getInfoTypeForString("UNIT_KARABINIERS"), iCityX,iCityY, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH )
for i in range(3):
pReturnEmpire.initUnit( gc.getInfoTypeForString("UNIT_FIELD_CANNON"), iCityX,iCityY, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH )
pReturnEmpire.initUnit( gc.getInfoTypeForString("UNIT_WORKER"), iCityX,iCityY, UnitAITypes.UNITAI_WORKER, DirectionTypes.DIRECTION_NORTH )
pReturnEmpire.initUnit( gc.getInfoTypeForString("UNIT_BASTION"), iCityX,iCityY, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH )
pReturnEmpire.initUnit( gc.getInfoTypeForString("UNIT_CANNON"), iCityX,iCityY, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH )
pReturnEmpire.initUnit( gc.getInfoTypeForString("UNIT_GARDEINFANTERY"), iCityX,iCityY, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH )
pReturnEmpire.initUnit( gc.getInfoTypeForString("UNIT_COASTALFORTRESS"), iCityX,iCityY, UnitAITypes.UNITAI_RANGED_ATTACK, DirectionTypes.DIRECTION_NORTH )
pReturnEmpire.initUnit( gc.getInfoTypeForString("UNIT_AUFKLAERER"), iCityX,iCityY, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH )
pReturnEmpire.initUnit( gc.getInfoTypeForString("UNIT_BALLON"), iCityX,iCityY, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH )
pReturnEmpire.initUnit( gc.getInfoTypeForString("UNIT_STAR_FORT"), iCityX,iCityY, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH )
if loopCity.isCoastal(20):
for i in range(3):
pReturnEmpire.initUnit( gc.getInfoTypeForString("UNIT_MISSILE_SHIP"), iCityX,iCityY, UnitAITypes.UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH )
pReturnEmpire.initUnit( gc.getInfoTypeForString("UNIT_WORKBOAT"), iCityX,iCityY, UnitAITypes.UNITAI_WORKER_SEA, DirectionTypes.DIRECTION_NORTH )
pReturnEmpire.initUnit( gc.getInfoTypeForString("UNIT_GALIOT_A_BOMBE"), iCityX,iCityY, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH )
pReturnEmpire.initUnit( gc.getInfoTypeForString("UNIT_BRIGG"), iCityX,iCityY, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH )
pReturnEmpire.initUnit( gc.getInfoTypeForString("UNIT_DREIDECKER"), iCityX,iCityY, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH )
###init Units
###init Gebäude und Kultur
iExtraCulture = loopCity.getCulture(iPlayer2 )/2
loopCity.changeCulture(iReturnPlayerID,iExtraCulture,1)
loopCity.setNumRealBuilding(gc.getInfoTypeForString("BUILDING_BEWAESSERUNG"),1)
loopCity.setNumRealBuilding(gc.getInfoTypeForString("BUILDING_GRANARY"),1)
loopCity.setNumRealBuilding(gc.getInfoTypeForString("BUILDING_STABLE"),1)
loopCity.setNumRealBuilding(gc.getInfoTypeForString("BUILDING_MARKET"),1)
loopCity.setNumRealBuilding(gc.getInfoTypeForString("BUILDING_BARRACKS"),1)
loopCity.setNumRealBuilding(gc.getInfoTypeForString("BUILDING_TRAINING"),1)
loopCity.setNumRealBuilding(gc.getInfoTypeForString("BUILDING_LIBRARY"),1)
loopCity.setNumRealBuilding(gc.getInfoTypeForString("BUILDING_WAFFENKAMMER"),1)
loopCity.setNumRealBuilding(gc.getInfoTypeForString("BUILDING_LAZARETT"),1)
loopCity.setNumRealBuilding(gc.getInfoTypeForString("BUILDING_HARBOR"),1)
loopCity.setNumRealBuilding(gc.getInfoTypeForString("BUILDING_SCHOOL"),1)
loopCity.setNumRealBuilding(gc.getInfoTypeForString("BUILDING_JAIL"),1)
loopCity.setNumRealBuilding(gc.getInfoTypeForString("BUILDING_TOWN_CENTER"),1)
loopCity.setNumRealBuilding(gc.getInfoTypeForString("BUILDING_FORGE"),1)
###init Gebäude und Kultur
(loopCity, iter) = pPlayer2.nextCity(iter, true)
###Basisbeförderungen Einheiten
(loopUnit, iter) = pReturnEmpire.firstUnit(true)
while(loopUnit):
loopUnit.changeExperience(7,12,false,false,false)
if (loopUnit.getDomainType() == gc.getInfoTypeForString("DOMAIN_SEA")):
loopUnit.setHasPromotion(gc.getInfoTypeForString("PROMOTION_BREITSEITE1"),1)
loopUnit.setHasPromotion(gc.getInfoTypeForString("PROMOTION_COMBAT1"),1)
loopUnit.setHasPromotion(gc.getInfoTypeForString("PROMOTION_COASTGUARD1"),1)
elif (loopUnit.getDomainType() == gc.getInfoTypeForString("DOMAIN_IMMOBILE")):
loopUnit.setHasPromotion(gc.getInfoTypeForString("PROMOTION_CITY_GARRISON1"),1)
loopUnit.setHasPromotion(gc.getInfoTypeForString("PROMOTION_DRILL1"),1)
# elif (loopUnit.getDomainType() == gc.getInfoTypeForString("DOMAIN_AIR")):
# loopUnit.setHasPromotion(gc.getInfoTypeForString("PROMOTION_COMBAT1"),1)
else:
loopUnit.setHasPromotion(gc.getInfoTypeForString("PROMOTION_CITY_RAIDER1"),1)
loopUnit.setHasPromotion(gc.getInfoTypeForString("PROMOTION_PINCH1"),1)
loopUnit.setHasPromotion(gc.getInfoTypeForString("PROMOTION_REITERFALLE1"),1)
loopUnit.setHasPromotion(gc.getInfoTypeForString("PROMOTION_CITY_GARRISON1"),1)
loopUnit.setHasPromotion(gc.getInfoTypeForString("PROMOTION_COMBAT1"),1)
(loopUnit, iter) = (pReturnEmpire.nextUnit(iter, true))
###Basisbeförderungen Einheiten
for iPlayer in range(gc.getMAX_PLAYERS()):
if gc.getPlayer(iPlayer).isHuman():
popup = PyPopup.PyPopup(-1)
popup.setHeaderString(CyTranslator().getText("TXT_KEY_HEADER_RESTAURATION",(-1,-1)))
popup.setBodyString(CyTranslator().getText("TXT_KEY_MESSAGE_RESTAURATION",(pReturnEmpire.getCivilizationDescription(0),pReturnEmpire.getCivilizationDescription(0))))
popup.launch(True, PopupStates.POPUPSTATE_IMMEDIATE)
## ###Restauration end###
Seltsamerweise wird allerdings der grüne Teil (eventuell auch der dahinter mit den Gebäuden) in jeder der Städte, die im Testszenario zurückgegeben wurden, dreimal durchlaufen (bei insgesamt 4 zurückgegebenen Städten). Dadurch entstehen 3x soviele kostenlose Einheiten wie geplant. Einen zweiten Durchlauf könnte ich mir sogar noch erklären: Erst erhält der Spieler seine Städte zurück, und dann, als er selbst an der Reihe ist, bekommt er sie noch einmal zurückgegeben. Aber wo liegt mein Denkfehler, dass er sie ein drittes Mal erhält?