def onCityAcquiredAndKept(self, argsList):
iPreviousOwner, iNewOwner, city, bConquest, bTrade = argsList
pNewOwner = gc.getPlayer(iNewOwner)
if bConquest and not city.plot().getRegionID() in con.lCoreRegions[iNewOwner] and not city.plot().getRegionID() in con.lNormalRegions[iNewOwner] and not city.plot().getRegionID() in con.lBroaderRegions[iNewOwner]:
iLocalPower = -1
for iLoopCiv in range(con.iNumPlayers):
if gc.getPlayer(iLoopCiv).isAlive() and city.plot().getRegionID() in con.lCoreRegions[iLoopCiv] or city.plot().getRegionID() in con.lNormalRegions[iLoopCiv]:
iLocalPower = iLoopCiv
break
if iLocalPower != -1:
for x in range(city.getX() -2, city.getX() + 2):
for y in range(city.getY() - 2, city.getY() + 2):
plot = gc.getMap().plot(x, y)
iNumUnits = plot.getNumUnits()
j = 0
for i in range(iNumUnits):
unit = plot.getUnit(j)
unitType = unit.getUnitType()
if (unit.getOwner() == iNewOwner):
unit.kill(False, iNewOwner)
if pNewOwner.getCapitalCity().getX() != -1 and pNewOwner.getCapitalCity().getY() != -1:
utils.makeUnit(unitType, iNewOwner, [pNewOwner.getCapitalCity().getX(), pNewOwner.getCapitalCity().getY()], 1)
else:
randomCity = utils.getRandomCity(iNewOwner)
utils.makeUnit(unitType, iNewOwner, [randomCity.getX(), randomCity.getY()], 1)
else:
j += 1
utils.flipCity((city.getX(), city.getY()), 0, 0, iLocalPower, [])
utils.makeUnit(con.iSpearman, iLocalPower, [city.getX(), city.getY()], 2)
lCoreList = []
lNormalList = []
lBroaderList = []
for iLoopCiv in range(con.iNumPlayers):
if gc.getPlayer(iLoopCiv).isAlive():
if city.plot().getRegionID() in con.lCoreAreas[iLoopCiv]:
lCoreList.append(iLoopCiv)
elif city.plot().getRegionID() in con.lNormalAreas[iLoopCiv]:
lNormalList.append(iLoopCiv)
elif city.plot().getRegionID() in con.lBroaderAreas[iLoopCiv]:
lBroaderList.append(iLoopCiv)
if len(lCoreList) > 0: lCivList = lCoreList
elif len(lNormalList) > 0: lCivList = lNormalList
else: lCivList = lBroaderList
if len(lCivList) > 0:
iRand = gc.getGame().getSorenRandNum(len(lCivList), 'random civ')
iLocalCiv = lCivList[iRand]
CvEventReporter::getInstance().openBorders(getID(), eTeam, bNewValue);
Your code looks correct (although you're currently not iterating a square around the city, remember that range(x, y) iterates [x, x+1, ...., y-2, y-1]) so maybe you're right that the unit that conquers the city is "in limbo". No idea how to deal with it.the unit I'm talking about is the unit that captures the city. for some reason it doesn't get deleted and recreated along with the others. the method runs through all the plots within 1 plot of the city and deletes and recreates elsewhere any units found there belonging to the the civ that took the city. this works for all units, including a spy I preplaced on the city plot itself, but not for the unit that took the city, it stays there. I've tried flipping the city first and then dealing with the units and also units first and then city, but either way, that 1 unit is unaffected. also if I ask python to report the number of units in each plot, that unit is not counted.
def onCityAcquiredAndKept(self, argsList):
iPreviousOwner, iNewOwner, city, bConquest, bTrade = argsList
if bConquest and iNewOwner != utils.getHumanID() and iNewOwner < iNumPlayers and iPreviousOwner >= iNumPlayers and not city.plot().getRegionID() in con.lCoreRegions[iNewOwner] and not city.plot().getRegionID() in con.lNormalRegions[iNewOwner] and not city.plot().getRegionID() in con.lBroaderRegions[iNewOwner]:
sd.setDistantConquest(iNewOwner, 0, 1)
# from RFCCWAIWars.py
def getDistantConquest( self, i, j ):
return self.scriptDict['lDistantConquest'][i][j]
def setDistantConquest( self, i, j, iNewValue ):
self.scriptDict['lDistantConquest'][i][j] = iNewValue
#------------Distant Conquest
'lDistantConquest': [[-1, -1, -1],
[-1, -1, -1],
[-1, -1, -1],
[-1, -1, -1],
[-1, -1, -1],
[-1, -1, -1],
[-1, -1, -1],
[-1, -1, -1],
[-1, -1, -1],
[-1, -1, -1],
[-1, -1, -1],
[-1, -1, -1],
[-1, -1, -1],
[-1, -1, -1],
[-1, -1, -1],
[-1, -1, -1],
[-1, -1, -1],
[-1, -1, -1],
[-1, -1, -1],
[-1, -1, -1],
[-1, -1, -1],
[-1, -1, -1],
[-1, -1, -1],
[-1, -1, -1],
[-1, -1, -1],
[-1, -1, -1],
[-1, -1, -1],
[-1, -1, -1],
[-1, -1, -1],
[-1, -1, -1],
[-1, -1, -1],
[-1, -1, -1],
[-1, -1, -1],
[-1, -1, -1],
[-1, -1, -1],
[-1, -1, -1],
[-1, -1, -1],
[-1, -1, -1],
[-1, -1, -1]],
I am spawning units in an independent city on the birth of a neighboring civ, to make the city harder to capture. the units appear, but then disappear on the next turn. whats happening? is the AI disbanding them for some reason? this happens after the new civ declares war by entering the independents territory.
if (bRaze)
{
gDLL->getInterfaceIFace()->popupAddGenericButton(pPopup, gDLL->getText("TXT_KEY_POPUP_RAZE_CAPTURED_CITY").c_str(), NULL, 1, WIDGET_GENERAL);
}
if (bRaze)
{
if civic = slavery
{
gDLL->getInterfaceIFace()->popupAddGenericButton(pPopup, gDLL->getText("TXT_KEY_POPUP_RAZE_AND_ENSLAVE_CAPTURED_CITY").c_str(), NULL, 1, WIDGET_GENERAL);
}
else:
{
gDLL->getInterfaceIFace()->popupAddGenericButton(pPopup, gDLL->getText("TXT_KEY_POPUP_RAZE_CAPTURED_CITY").c_str(), NULL, 1, WIDGET_GENERAL);
}
}
happy to announce that the popup asking whether you want to keep or raze a city on capture now tells you that you can enslave the city if you are running slavery.