I'm trying to adapt spawnciv,
This modcomp allows you to spawn a civ dynamically triggered by technologies during the game :). Explanation from my readme: Credits: cool3a2 for the huns civ, and all the artists who have contributed to the civ: - Ekmek for the...
forums.civfanatics.com
I tried to follow how you did for spawn unit. let's hope so
I also link the file
Thank you
I hope I did well:
##SpawnCivUtil
###MODDER READ THIS:
###You do not have to change anything in this file (only if you changed default terrain)
###all changes have to be done in the CvEventManager.
###This file has to be in the same folder like the CvEventManager.py.
from CvPythonExtensions import *
import sys
import pickle
gc = CyGlobalContext()
SpawnCivList = []
import BugEventManager
import BugPath
def init():
em = BugEventManager.g_eventManager
em.addEventHandler('LoadGame', loadCustomXML)
em.addEventHandler('GameStart', loadCustomXML)
em.addEventHandler('BeginGameTurn', onBeginGameTurn)
def onGameStart(self, argsList):
'Called at the start of the game'
###spawn a civ part 3 start###
MyFile=open("Mods/SpawnACiv_v2/Assets/XML/CustomXML/CIV4SpawnCivInfos.xml")
SpawnCivUtil.ReadMyFile(MyFile,DataPlotX,DataPlotY)
MyFile.close()
###spawn a civ part 3 end###
if (gc.getGame().getGameTurnYear() == gc.getDefineINT("START_YEAR") and not gc.getGame().isOption(GameOptionTypes.GAMEOPTION_ADVANCED_START)):
for iPlayer in range(gc.getMAX_PLAYERS()):
player = gc.getPlayer(iPlayer)
if (player.isAlive() and player.isHuman()):
popupInfo = CyPopupInfo()
popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
popupInfo.setText(u"showDawnOfMan")
popupInfo.addPopup(iPlayer)
else:
CyInterface().setSoundSelectionReady(true)
if gc.getGame().isPbem():
for iPlayer in range(gc.getMAX_PLAYERS()):
player = gc.getPlayer(iPlayer)
if (player.isAlive() and player.isHuman()):
popupInfo = CyPopupInfo()
popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_DETAILS)
popupInfo.setOption1(true)
popupInfo.addPopup(iPlayer)
CvAdvisorUtils.resetNoLiberateCities()
def onBeginGameTurn(self, argsList):
'Called at the beginning of the end of each turn'
iGameTurn = argsList[0]
###spawn a civ part 6 start###
if gc.getMAX_CIV_PLAYERS ()>CyGame().countCivPlayersAlive ():
SpawnCivUtil.TriggerCiv(gc.getActivePlayer().getID(),None,DataPlotX,DataPlotY,iGameTurn)
###spawn a civ part 6 end###
CvTopCivs.CvTopCivs().turnChecker(iGameTurn)
def onEndPlayerTurn(self, argsList):
'Called at the end of a players turn'
iGameTurn, iPlayer = argsList
if (gc.getGame().getElapsedGameTurns() == 1):
if (gc.getPlayer(iPlayer).isHuman()):
if (gc.getPlayer(iPlayer).canRevolution(0)):
popupInfo = CyPopupInfo()
popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_CHANGECIVIC)
popupInfo.addPopup(iPlayer)
CvAdvisorUtils.resetAdvisorNags()
CvAdvisorUtils.endTurnFeats(iPlayer)
def process(iTurn):
for entry in SpawnCivList:
if entry.iTurn == iTurn:
AddCiv(entry)
def onFirstContact(self, argsList):
'Contact'
iTeamX,iHasMetTeamY = argsList
### spawn a civ - part 5 start
SpawnCivUtil.TestIfBarb(iTeamX,iHasMetTeamY)
### spawn a civ - part 5 end
if (not self.__LOG_CONTACT):
return
CvUtil.pyPrint('Team %d has met Team %d' %(iTeamX, iHasMetTeamY))
def onTechAcquired(self, argsList):
'Tech Acquired'
iTechType, iTeam, iPlayer, bAnnounce = argsList
# Note that iPlayer may be NULL (-1) and not a refer to a player object
# Show tech splash when applicable
if (iPlayer > -1 and bAnnounce and not CyInterface().noTechSplash()):
if (gc.getGame().isFinalInitialized() and not gc.getGame().GetWorldBuilderMode()):
if ((not gc.getGame().isNetworkMultiPlayer()) and (iPlayer == gc.getGame().getActivePlayer())):
popupInfo = CyPopupInfo()
popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
popupInfo.setData1(iTechType)
popupInfo.setText(u"showTechSplash")
popupInfo.addPopup(iPlayer)
###spawn a civ part 4 start###
if gc.getMAX_CIV_PLAYERS ()>CyGame().countCivPlayersAlive ():
SpawnCivUtil.TriggerCiv(iPlayer,iTechType,DataPlotX,DataPlotY,None)
###spawn a civ part 4 end###
if (not self.__LOG_TECH):
return
CvUtil.pyPrint('%s was finished by Team %d'
%(PyInfo.TechnologyInfo(iTechType).getDescription(), iTeam))
def TriggerCiv(iPlayer,iTechType,DataPlotX,DataPlotY,iTurn):
PopList = []
for i in xrange(len(SpawnCivList)):
Spawned = SpawnACiv(SpawnCivList
,i,iPlayer,iTechType,iTurn)
if Spawned:
PopList.append(SpawnCivList)
iMaxLoadCiv = len(SpawnCivList)
bListSpawnedCiv = []
for j in range(iMaxLoadCiv):
bListSpawnedCiv.append(SpawnCivList[j].AlreadyTriggered)
DataPlot = CyMap().plot(DataPlotX,DataPlotY)
DataPlot.setScriptData(pickle.dumps(bListSpawnedCiv))
###obsolete
#for i in xrange(len(PopList),0,1):
#SpawnCivList.pop(PopList)
def SpawnACiv(SpawnCiv,ListNum,iPlayer,iTechType,iTurn):
###Test if right tech###
Tech = SpawnCiv.SpawnTech
iHumanTech = SpawnCiv.SpawnTechHumanOnly
bHumanTech = False
#CyInterface().addMessage(0,False,15,"entered code",()),'',0,'Art/Interface/Buttons/General/happy_person.dds',ColorTypes(44), 1, 1, True,True)
if iTechType:
if not ((iTechType ==gc.getInfoTypeForString(Tech)) or (iTechType == gc.getInfoTypeForString(iHumanTech))):
return
if iTechType == gc.getInfoTypeForString(iHumanTech):
bHumanTech = True
if not gc.getPlayer(iPlayer).isHuman():
return
TechCounter=0
for i in xrange (gc.getMAX_CIV_TEAMS ()):
Team = gc.getTeam(i)
if Team.isHasTech(iTechType):
TechCounter=TechCounter+1
if TechCounter>=SpawnCiv.SpawnTechNumber:
break
if (not TechCounter>=SpawnCiv.SpawnTechNumber) and (not bHumanTech):
return
if iTurn:
#CyInterface().addMessage(0,False,15,str(CyGameTextMgr().getDateStr (iTurn+1, False, CyGame().getCalendar (), CyGame().getStartYear (), CyGame().getGameSpeedType ())),'',0,'Art/Interface/Buttons/General/happy_person.dds',ColorTypes(44), 1, 1, True,True)
if not ((iTurn+1 == SpawnCiv.iTurn) or (str(CyGame().getTurnYear(iTurn+1))==SpawnCiv.iYear)):
return
if (str(CyGame().getTurnYear(iTurn+1))==SpawnCiv.iYear):
if SpawnCiv.iMonth>0 and SpawnCiv.iMonth<13:
strDate = CyGameTextMgr().getDateStr (iTurn+1, False, CyGame().getCalendar (), CyGame().getStartYear (), CyGame().getGameSpeedType ())
if "," in strDate:
month, junk = strDate.split(",",1)
month = month.strip()
sMonth = gc.getMonthInfo(SpawnCiv.iMonth-1).getDescription()
if not sMonth in month:
return
if SpawnCiv.AlreadyTriggered:
return
###test, if right number of civs have tech
SpawningChance = CyGame().getSorenRandNum(100, "HowGoodIsTheChance")
if SpawningChance>SpawnCiv.SpawnChance:
SpawnCiv.AlreadyTriggered = True
return
###test, if spawn civ is not already alive
for i in xrange (gc.getMAX_CIV_PLAYERS ()):
pPlayer = gc.getPlayer(i)
myName = pPlayer.getCivilizationType ()
otherName = gc.getInfoTypeForString(SpawnCiv.CivString)
if myName ==otherName:
return
###Find a ID for the civ###
NewID = -1
for NumCiv in xrange (gc.getMAX_PLAYERS ()):
PotPlayer = gc.getPlayer(NumCiv)
if not PotPlayer.isAlive():
NewID = NumCiv
break
if NewID ==-1:
return
###Add Civ to game
iCiv = gc.getInfoTypeForString(SpawnCiv.CivString)
if not str(SpawnCiv.LeaderString)=="-1":
NewLeaderID=gc.getInfoTypeForString(SpawnCiv.LeaderString)
if str(SpawnCiv.LeaderString)=="-1":
CurCiv = gc.getCivilizationInfo(iCiv)
NumLeaders = CurCiv.getNumLeaders ()
dice = gc.getGame().getMapRand()
LeaderNum = dice.get(NumLeaders , "OracleSayMeTheLeader" )
LeaderCounter=0
for iLeaders in range(gc.getNumLeaderHeadInfos ()):
if CurCiv.isLeaders(iLeaders):
if NumLeaders==1:
NewLeaderID =iLeaders
break
else:
if LeaderCounter==LeaderNum:
NewLeaderID=iLeaders
break
LeaderCounter=LeaderCounter+1
CyGame().addPlayer(NewID,NewLeaderID,iCiv)
NewPlayer = gc.getPlayer(NewID)
NewTeam = gc.getTeam(NewPlayer.getTeam())
NewTeamID = NewTeam.getID()
###from an old version, may be reactived later, you never
###now; declareWar is custom function in this file, not used
###at the moment
### function testIfBarb is current version
#declareWar(NewID,SpawnCiv)
#if SpawnCiv.bBarb==True:
#MaxCivs = gc.getMAX_CIV_TEAMS()
#for i in xrange (MaxCivs):
#if i==NewTeamID:continue
#NewTeam.setPermanentWarPeace(i,True)
maxX = CyMap().getGridWidth ()
maxY = CyMap().getGridHeight ()
iTundra = gc.getInfoTypeForString("TERRAIN_TUNDRA")
iDesert = gc.getInfoTypeForString("TERRAIN_DESERT")
iSnow = gc.getInfoTypeForString("TERRAIN_SNOW")
NumSetCities = 0
Counter=0
NewPlayer.setGold(SpawnCiv.Gold)
if SpawnCiv.SpawnX>-1 and SpawnCiv.SpawnY>-1:
if SpawnCiv.SpawnX<CyMap().getGridWidth () and SpawnCiv.SpawnY<CyMap().getGridHeight ():
pPlot = CyMap().plot(SpawnCiv.SpawnX,SpawnCiv.SpawnY)
if not pPlot.isCity():
numUnits = pPlot.getNumUnits ()
for iUnits in xrange(numUnits):
pUnit = pPlot.getUnit(iUnits)
UnitX = pUnit.getX()
UnitY = pUnit.getY()
NewPlot = CyMap().plot(UnitX+1,UnitY+1)
if not NewPlot.isNone() and not NewPlot.isCity():
pUnit.setXY(UnitX+1,UnitY+1,True,True,True)
elif not CyMap().plot(UnitX-1,UnitY-1).isNone() and not CyMap().plot(UnitX-1,UnitY-1).isCity():
pUnit.setXY(UnitX-1,UnitY-1,True,True,True)
elif not CyMap().plot(UnitX+1,UnitY-1).isNone() and not CyMap().plot(UnitX+1,UnitY-1).isCity():
pUnit.setXY(UnitX+1,UnitY-1,True,True,True)
elif not CyMap().plot(UnitX-1,UnitY+1).isNone() and not CyMap().plot(UnitX-1,UnitY+1).isCity():
pUnit.setXY(UnitX-1,UnitY+1,True,True,True)
NewPlayer.initCity(SpawnCiv.SpawnX,SpawnCiv.SpawnY)
NumSetCities = NumSetCities+1
AddTechToPlayer(iPlayer,NewID,SpawnCiv.TechPercent)
AddUnitsToCity(SpawnCiv.SpawnX,SpawnCiv.SpawnY,NewID,SpawnCiv)
while NumSetCities <SpawnCiv.NumCities:
EndangeredPlot = []
CrapPlot = []
SetCity = False
Counter=Counter+1
Endangered = False
if Counter>100:return
if Counter>SpawnCiv.NumCities:return
for iX in xrange (maxX):
for iY in xrange(maxY):
pPlot = CyMap().plot(iX,iY)
if pPlot.isWater() or pPlot.isImpassable():
continue
if pPlot.isOwned():
continue
if pPlot.isUnit():
continue
if SpawnCiv.bCoast:
if not pPlot.isCoastalLand ():
continue
if (pPlot.getTerrainType ()==iDesert) or(pPlot.getTerrainType()==iSnow)or(pPlot.getTerrainType()==iTundra):
CrapPlot.append([pPlot.getX(),pPlot.getY()])
continue
if pPlot.isAdjacentOwned ():
continue
IsCity = checkCity(iX,iY)
if IsCity:continue
for iXLoop in xrange(iX - 2, iX + 3, 1):
for iYLoop in xrange(iY - 2, iY + 3, 1):
TempPlot = CyMap().plot(iXLoop,iYLoop)
if TempPlot.isOwned() or TempPlot.isUnit():
EndangeredPlot.append([pPlot.getX(),pPlot.getY()])
Endangered = True
break
if (Endangered == False):
NewPlayer.initCity(iX,iY)
NumSetCities = NumSetCities+1
SetCity = True
AddTechToPlayer(iPlayer,NewID,SpawnCiv.TechPercent)
AddUnitsToCity(iX,iY,NewID,SpawnCiv)
break
if SetCity ==False:
if len(EndangeredPlot)>0:
iRandPlot = CyGame().getSorenRandNum(len(EndangeredPlot), 'EndangeredPlot')
RandPlot = EndangeredPlot[iRandPlot]
CityX=RandPlot[0]
CityY=RandPlot[1]
NewPlayer.initCity(CityX,CityY)
NumSetCities = NumSetCities+1
AddTechToPlayer(iPlayer,NewID,SpawnCiv.TechPercent)
AddUnitsToCity(CityX,CityY,NewID,SpawnCiv)
elif len(CrapPlot)>0:
iRandPlot = CyGame().getSorenRandNum(len(CrapPlot), 'Crap Plot')
RandPlot = EndangeredPlot[iRandPlot]
CityX=RandPlot[0]
CityY=RandPlot[1]
NewPlayer.initCity(CityX,CityY)
NumSetCities = NumSetCities+1
AddTechToPlayer(iPlayer,NewID,SpawnCiv.TechPercent)
AddUnitsToCity(CityX,CityY,NewID,SpawnCiv)
if SetCity == True:
AddUnitsToCapital(NewID,SpawnCiv)
SpawnCiv.AlreadyTriggered = True
return True
###function should be obsolete
###not used at the moment
### function testIfBarb is current version
def declareWar(iPlayer,SpawnCiv):
if SpawnCiv.bBarb==True:
NewPlayer = gc.getPlayer(iPlayer)
TeamID = NewPlayer.getTeam()
NewTeam = gc.getTeam(TeamID)
for i in xrange(gc.getMAX_CIV_TEAMS ()):
if i==TeamID:continue
NewTeam.declareWar(i,False,WarPlanTypes.WARPLAN_TOTAL)
CurTeam = gc.getTeam(i)
CurTeam.declareWar(TeamID,False,WarPlanTypes.WARPLAN_TOTAL)
for i in range(gc.getMAX_CIV_PLAYERS()):
if i==iPlayer:continue
NewPlayer.AI_setAttitudeExtra(i,-999)
CurPlayer = gc.getPlayer(i)
CurPlayer.AI_setAttitudeExtra(iPlayer,-999)
def AddTechToPlayer(iPlayer,iNewPlayer,TechPercent):
pPlayer = gc.getPlayer(iPlayer)
pTeam = gc.getTeam(pPlayer.getTeam())
NewPlayer = gc.getPlayer(iNewPlayer)
NewTeam = gc.getTeam(NewPlayer.getTeam())
TechPercent = float(TechPercent)/100
TotalTechCounter=0
GridWidth=0
for i in xrange(gc.getNumTechInfos ()):
if pTeam.isHasTech(i):
TotalTechCounter=TotalTechCounter+1
CurTech= gc.getTechInfo(i)
if CurTech.getGridX()>GridWidth:
GridWidth=CurTech.getGridX()
TotalTechCounter=int(TotalTechCounter*TechPercent)
TempTechCounter=0
#CyInterface().addMessage(0,False,15,CyTranslator().getText(str(TotalTechCounter),()),'',0,'Art/Interface/Buttons/General/happy_person.dds',ColorTypes(44), 1, 1, True,True)
for j in xrange(GridWidth):
for i in xrange(gc.getNumTechInfos ()):
CurTech= gc.getTechInfo(i)
if pTeam.isHasTech(i):
if CurTech.getGridX()==j:
NewTeam.setHasTech(i,True,iNewPlayer,False,False)
TempTechCounter=TempTechCounter+1
if TempTechCounter>=TotalTechCounter:
break
if TempTechCounter>=TotalTechCounter:
break
def AddUnitsToCapital(iNewID,SpawnCiv):
pPlayer = gc.getPlayer(iNewID)
Capital = pPlayer.getCapitalCity()
iX = Capital.getX()
iY = Capital.getY()
if SpawnCiv.CapitalUnit !="NONE" and SpawnCiv.CapitalUnit !=-1:
if SpawnCiv.NumberCapitalUnit>0:
for i in xrange(SpawnCiv.NumberCapitalUnit):
pPlayer.initUnit( gc.getInfoTypeForString(SpawnCiv.CapitalUnit), iX,iY, UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION )
def AddUnitsToCity(iX,iY,iNewPlayer,SpawnCiv):
NewPlayer = gc.getPlayer(iNewPlayer)
if SpawnCiv.NumWorker>0:
for i in xrange(SpawnCiv.NumWorker):
NewPlayer.initUnit( gc.getInfoTypeForString("UNIT_WORKER"), iX,iY, UnitAITypes.UNITAI_WORKER, DirectionTypes.NO_DIRECTION )
pCity = CyMap().plot(iX,iY).getPlotCity()
if SpawnCiv.DefenderUnit !="NONE":
if SpawnCiv.DefenderUnit=="-1":
Defender = pCity.getConscriptUnit ()
else:
Defender = gc.getInfoTypeForString(SpawnCiv.DefenderUnit)
if SpawnCiv.NumberDefenderUnit>0:
for i in xrange(SpawnCiv.NumberDefenderUnit):
NewPlayer.initUnit( Defender, iX,iY, UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION )
if SpawnCiv.SecondUnit !="NONE":
if SpawnCiv.SecondUnit=="-1":
Second = pCity.getConscriptUnit ()
else:
Second = gc.getInfoTypeForString(SpawnCiv.SecondUnit)
if SpawnCiv.NumSecondUnit>0:
for i in xrange(SpawnCiv.NumSecondUnit):
NewPlayer.initUnit( Second, iX,iY, UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION )
if pCity.isCoastal(20):
if ((not SpawnCiv.Ships=="-1")and(not SpawnCiv.Ships=="NONE")) and (not SpawnCiv.NumberShips<1):
ThisShip = SpawnCiv.Ships
CurShip = gc.getInfoTypeForString(ThisShip)
NumShip = SpawnCiv.NumberShips
for i in xrange(NumShip):
NewPlayer.initUnit( CurShip, iX,iY, UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION )
def checkCity(iX,iY):
for iXLoop in xrange(iX - 2, iX + 3, 1):
for iYLoop in xrange(iY - 2, iY + 3, 1):
TempPlot = CyMap().plot(iXLoop,iYLoop)
if TempPlot.isCity():return True
return False
def ReadMyFile(MyFile,DataPlotX,DataPlotY):
del SpawnCivList[:]
for CurString in MyFile.readlines():
if "CIVILIZATION_" in CurString:
CurCiv = SpawningCiv()
CurCiv.CivString = CutString(CurString)
elif "Leader" in CurString:
CurCiv.LeaderString = CutString(CurString)
elif "SpawnTech>" in CurString:
CurCiv.SpawnTech = CutString(CurString)
elif "NumberOfSpawnTech" in CurString:
CurCiv.SpawnTechNumber = int(CutString(CurString))
elif "SpawnTechHumanOnly" in CurString:
CurCiv.SpawnTechHumanOnly = CutString(CurString)
elif "iTurn" in CurString:
CurCiv.iTurn = int(CutString(CurString))
elif "iYear" in CurString:
CurCiv.iYear = CutString(CurString)
elif "iMonth" in CurString:
CurCiv.iMonth = int(CutString(CurString))
elif "SpawnChance" in CurString:
CurCiv.SpawnChance = float(CutString(CurString))
elif "IsBarbarianCiv" in CurString:
CuttedString = CutString(CurString)
CurCiv.bBarb = bool(eval(CuttedString))
elif "StartAtCoast" in CurString:
CuttedString = CutString(CurString)
CurCiv.bCoast = bool(eval(CuttedString))
elif "TotalGold" in CurString:
CurCiv.Gold = int(CutString(CurString))
elif "TechPercent" in CurString:
CurCiv.TechPercent =int(CutString(CurString))
elif "DefaultShips" in CurString:
CurCiv.Ships = CutString(CurString)
elif "NumberShipsPerCity" in CurString:
CurCiv.NumberShips = int(CutString(CurString))
elif "NumberOfCities" in CurString:
CurCiv.NumCities = int(CutString(CurString))
elif "StartX" in CurString:
CurCiv.SpawnX = int(CutString(CurString))
elif "StartY" in CurString:
CurCiv.SpawnY = int(CutString(CurString))
elif "NumWorkerPerCity" in CurString:
CurCiv.NumWorker = int(CutString(CurString))
elif "CapitalCityUnit" in CurString:
CurCiv.CapitalUnit = CutString(CurString)
elif "NumCapitalUnit" in CurString:
CurCiv.NumberCapitalUnit = int(CutString(CurString))
elif "DefaultCityDefender" in CurString:
CurCiv.DefenderUnit = CutString(CurString)
elif "NumberCityDefendersPerCity" in CurString:
CurCiv.NumberDefenderUnit = int(CutString(CurString))
elif "DefaultSecondUnit" in CurString:
CurCiv.SecondUnit = CutString(CurString)
elif "NumberSecondUnit" in CurString:
CurCiv.NumSecondUnit = int(CutString(CurString))
SpawnCivList.append(CurCiv)
AddCivAlreadySpawnedInfo(SpawnCivList,DataPlotX,DataPlotY)
def AddCivAlreadySpawnedInfo(SpawnCivList,DataPlotX,DataPlotY):
DataPlot = CyMap().plot(DataPlotX,DataPlotY)
bListSpawnedCiv = pickle.loads(DataPlot.getScriptData ())
iMaxLoadCiv = len(SpawnCivList)
if len(bListSpawnedCiv)>0:
for i in range (iMaxLoadCiv):
SpawnCivList.AlreadyTriggered = bListSpawnedCiv
def TestIfBarb(iTeamX,iHasMetTeamY):
if iTeamX == iHasMetTeamY:
return False
TeamOne = gc.getTeam(iTeamX)
TeamTwo = gc.getTeam(iHasMetTeamY)
pPlayerOne = gc.getPlayer(TeamOne.getLeaderID())
pPlayerTwo = gc.getPlayer(TeamTwo.getLeaderID())
iLenSpawnCiv = len(SpawnCivList)
for i in range(iLenSpawnCiv):
if SpawnCivList.bBarb:
if (gc.getInfoTypeForString(SpawnCivList.CivString)== pPlayerOne.getCivilizationType () ):
TeamOne.declareWar(iHasMetTeamY,False,WarPlanTypes.WARPLAN_TOTAL)
TeamOne.setPermanentWarPeace(iHasMetTeamY,True)
elif (gc.getInfoTypeForString(SpawnCivList.CivString)== pPlayerTwo.getCivilizationType () ):
TeamTwo.declareWar(iTeamX,False,WarPlanTypes.WARPLAN_TOTAL)
TeamTwo.setPermanentWarPeace(iTeamX,True)
def CutString(string):
string = str(string)
string = string.strip()
string = string[2:-1]
BeginPos=-1
EndPos = -1
for i in xrange(len(string)):
if string==">":
BeginPos=i
elif string=="<":
EndPos=i
break
else:
return "-1"
NewString = string[BeginPos+1:EndPos]
return str(NewString)
class SpawningCiv:
def __init__(self):
self.CivString = 0
self.LeaderString = 0
self.SpawnTech = 0
self.SpawnTechHumanOnly = 0
self.SpawnTechNumber = 0
self.iTurn = 0
self.iYear = 0
self.iMonth = 0
self.SpawnChance = 0
self.bCoast = 0
self.Ships = 0
self.NumberShips = 0
self.bBarb = 0
self.NumCities = 0
self.SpawnX = 0
self.SpawnY = 0
self.CapitalUnit = 0
self.NumberCapitalUnit = 0
self.DefenderUnit = 0
self.NumberDefenderUnit = 0
self.NumWorker=0
self.Gold = 0
self.SecondUnit=0
self.NumSecondUnit=0
self.TechPercent=0
self.AlreadyTriggered = False