

makes it more fun 
The bottom line is that pickling causes some lag, which is always bad. If the bug isn't in need of a fix, then you could probably do without the lag also.![]()
This approach dawned on me also, but it would add lag to the whole game instead of just when there is actual data to storage/retrieve. (The catapult construction event is probably rare, so the lag wouldn't affect something like 95% of the game.) With autosaves that can be set to every turn, and all.Make sure to use cPickle (import cPickle as pickle), and only load/save in onLoad and OnPreSave. Technically yes there is *some* additional time required, but in practice it's infinitesimal.

)I already defined these values/arrays based on what you wrote earlier (and I have the code for setting the unit type accordingly ready-to-use):also there should be a tech list that can be used for defining what techs count towards spawning units (then the highest of these is the one that the rebellion receives) which will stop explorers...
# Rebellion mod-comp
eDefaultUnit = eWarrior
tAdvancedRebelUnits = (
eAxeman,
eSwordsman,
eAdvancedSpearman,
eAdvancedSwordsman
)
tRebelUnitTechs = (
eBronzeWorking,
eIronWorking,
eAdvancedBronzeWorking,
eAdvanceIronWorking,
)



And what about war/peace? This event causes the two civs going to war, right? Doesn't the other player get a say in whether or no the rebellion should be supported? (I'm thinking that the units could belong to some third civ, but then those need to be flipped anyway...)
Couldn't this be a cap instead? (Like always at least 6 units - or never more than 6 units.) Shouldn't the city be selected somewhat randomly? (The number of citizens could still weigh in proportionally.) What about a spreading civil war that can spill over to near-by cities? (This risk is only removed once all rebel units are dead. What about ending the civil war once you take the first city captured by the rebels - their capital? This takes away the boring business of mopping up scattered enemy forces and gives the player a clear goal for the war effort.)
class Rebellion:
lCurrentRebellions = list()
@classmethod
def checkConditions(cls, pCivPlayer, pCity):
return pCity.isDisorder()
def __init__(self, pCivPlayer, pCity):
self.lCurrentRebellions.append(self)
self.iRebellionTurn = Game.getGameTurn()
self.eCityOwner = pCivPlayer.get(playerID)
self.setRebelPlayer()
self.setUnitType()
self.setNumUnits()
self.plotID = getPlotID(pCity.plot())
self.setRebelUnitSettings()
self.setMessages(pCity.getName())
self.addRebellionMessage()
def setRebelUnitSettings(self):
self.eUnitAI = eAttackCity
self.ePromotion = None
def setUnitFlag(self):
self.unitFlag = "rebel"
def setMessages(self, cityName):
self.rebellionMessage = defaultRebellionMessage % cityName
self.terminationMessage = defaultTerminationMessage % cityName
self.unitSpawnMessage = defaultUnitSpawnMessage
def setRebelPlayer(self):
self.eRebelPlayer = eBarbarian
def setUnitType(self):
iNumTechs = len(tRebelUnitTechs)
for i in xrange(iNumTechs, -1, -1):
eTechType = tRebelUnitTechs[i]
if self.pCivPlayer.get(CyTeam).isHasTech(eTechType):
self.eUnitType = tAdvancedRebelUnits[i]
return
self.eUnitType = eDefaultUnit
def setNumUnits(self):
pCity = self.getCyPlot()
iUnhappyLevel = pCity.unhappyLevel(0)
iPopulation = pCity.getPopulation()
self.iNumUnits = max(1, min(iUnhappyLevel, iPopulation))
def isRebellionTurn(self):
return Game.getGameTurn() == self.iRebellionTurn
def getCityOwner(self):
return instance(self.eCityOwner)
def getRebelCiv(self):
return instance(self.eRebelPlayer)
def getUnitType(self):
return self.eUnitType
def getPlotID(self):
return self.plotID
def getCyPlot(self):
return Map.plotByIndex(self.getPlotID())
def getPlotCoords(self):
return getPlotCoords(self.getPlotID())
def getCyCity(self):
return self.getCyPlot().getPlotCity()
def getNumUnits(self):
return self.iNumUnits
def getUnitAI(self):
return self.eUnitAI
def isPromotion(self):
return self.ePromotion != None
def getPromotion(self):
return self.ePromotion
def isUnitFlag(self):
return self.unitFlag != ""
def getUnitFlag(self):
return self.unitFlag
def checkTermination(self):
if pCity.isDisorder(): return False
unitFlag = self.getUnitFlag()
for pUnit in self.getRebelCiv().get(PyPlayer).getUnitList():
if pUnit.getScriptData() == unitFlag:
return False
self.lCurrentRebellions.remove(self)
self.addTerminationMessage()
return True
def addTerminationMessage(self):
addMessage(self.terminationMessage)
def addRebellionMessage(self):
addMessage(self.rebellionMessage)
def addUnitSpawnMessage(self):
addMessage(self.unitSpawnMessage)
def spawnRebelUnits(self):
iNumUnits = self.getNumUnits()
iX, iY = self.getPlotCoords()
eUnitType, eUnitAI = self.getUnitType(), self.getUnitAI()
while iNumUnits:
pUnit = self.getRebelCiv().get(CyPlayer).initUnit(eUnitType, iX, iY, eNoDirection, eUnitAI)
self.setPromotion(pUnit)
self.setUnitFlag(pUnit)
iNumUnits -= 1
if not self.isRebellionTurn():
self.addUnitSpawnMessage()
def setPromotion(self, pUnit):
if self.isPromotion():
pUnit.setHasPromotion(self.getPromotion())
def setUnitFlag(self, pUnit):
if self.isUnitFlag():
pUnit.setScriptData(self.getUnitFlag())


But what happens with a occupied city who's original owner has been eliminated? Would the rebellion revive it by spawning units? (Well not after some amount of game turns after conquest, but anyway.)1. Maybee we should use the original caculations for domestic and occupational (including the civilized stuff, remember: the reduction comes from if the original city owner is barbarian/civilized or not, not the invader.) when I say no termination I do mean it.... the misc refers to the chance of this rebellion, after a certain amount of turns after the city was conquored it is no longer elligeble for an occupational revolt.
So two different percentages then. I might just re-use the half chance from the present setup. (But it can of course be changed later.)2. Not every time it is in revolt... I guess i was not clear enough, maybee 12% chance and 8% for civilized people
What I'm still not getting is why you wanna subtract the angry citizens from the unhappy level.3. ok example time the city has an unhappiness level higher than happiness and it fits the tiny percentage chance... it's unhappiness level is 12 and it has 3 angry citizens so it would spawn 12-3= 9 units spawned

It might not be very convenient to script a popup that allows the human player to chose between war and peace, but it might be doable nonetheless. I'm not sure about how to script the AI behavior...4. I guess the other civ has a say wether they should support it or disband it... maybee they could just recieve the units (good way of gaining more advanced units). about 25% of the time a city is in a flip revolt (where the game is warning you that a flip is imenent) you could get this rebellion!
(What determines whether or no to DOW? A random number generator?)Please update your post - it will make things so much easier going forward!5. Yeah I guess so but maybee with some axemen or chariots... (chariots! that should be added to the unit list....) yes I mean current owner.
Ok, but shouldn't the civil war have a spread effect? Like more and more cities joining in? (The number - any number - of unhappy citizens could be the deciding factor, perhaps together with distance to Palace.) Perhaps we could try this approach once the basic functionality is in...6. Ok example time again!
Greece has 12 cities and 4 of those are over 2 angry citizens. each turn that this is happening it inches closer to civil war and then next turn BOOM! the 4 (which is 30%) cities flip and the strongest of those cities gains 6 units (maybee you could think of another calculation for this?) there you go civil war![]()
<BuildingArtInfo>
<Type>ART_DEF_BUILDING_MIDDLE_EASTERN _COLOSSEUM</Type>
<LSystem>LSYSTEM_3x3</LSystem>
<bAnimated>0</bAnimated>
<fScale>0.77</fScale>
<fInterfaceScale>0.65</fInterfaceScale>
<NIF>Art/Structures/Buildings/arab_col/arab_col.nif</NIF>
<KFM/>
<Button>,Art/Interface/Buttons/Buildings/Colosseum.dds,Art/Interface/Buttons/Buildings_Atlas.dds,2,2</Button>
</BuildingArtInfo>
)
