jkp1187
Unindicted Co-Conspirator
Hello, me again. This time I'm trying to get Barbarian naval units to spawn as part of a random event. I basically want the event to be similar to the existing barbarian events, except that they spawn as privateers.
I wrote what I thought would be the correct code to do this, but nothing happens every time I try to trigger the event. I am not getting any XML errors, nor do I have any python errors in the log....the event just isn't firing. This is the code I have....
I wrote what I thought would be the correct code to do this, but nothing happens every time I try to trigger the event. I am not getting any XML errors, nor do I have any python errors in the log....the event just isn't firing. This is the code I have....
Code:
def canTriggerBlackbeard(argsList):
kTriggeredData = argsList[0]
pPlayer = gc.getPlayer(kTriggeredData.ePlayer)
# If Barbarians are disabled in this game, this event will not occur.
if gc.getGame().isOption(GameOptionTypes.GAMEOPTION_NO_BARBARIANS):
return false
# At least one civ on the board must know Chemistry.
bFoundValid = false
iTech = CvUtil.findInfoTypeNum(gc.getTechInfo, gc.getNumTechInfos(), 'TECH_CHEMISTRY')
for iPlayer in range(gc.getMAX_CIV_PLAYERS()):
loopPlayer = gc.getPlayer(iPlayer)
if loopPlayer.isAlive():
if gc.getTeam(loopPlayer.getTeam()).isHasTech(iTech):
bFoundValid = true
break
if not bFoundValid:
return false
# At least one civ on the board must know Astronomy.
bFoundValid = false
iTech = CvUtil.findInfoTypeNum(gc.getTechInfo, gc.getNumTechInfos(), 'TECH_ASTRONOMY')
for iPlayer in range(gc.getMAX_CIV_PLAYERS()):
loopPlayer = gc.getPlayer(iPlayer)
if loopPlayer.isAlive():
if gc.getTeam(loopPlayer.getTeam()).isHasTech(iTech):
bFoundValid = true
break
if not bFoundValid:
return false
# Find an eligible plot
map = gc.getMap()
for i in range(map.numPlots()):
plot = map.plotByIndex(i)
if (plot.getOwner() == -1 and plot.isWater() and not plot.isImpassable() and plot.area().getCitiesPerPlayer(kTriggeredData.ePlayer) > 0):
return true
return false