Civil War in Civ1

tupi

Warlord
Joined
Jun 25, 2011
Messages
241
Location
Russia
How civil war event works in CivDos...
1)Civil war event is called if AI civ has more than 4 cities and somebody captured their capital and human player's place is lower than place of this AI civ.
Problem: city counter and civ place are updated only at the beginning of new turn, so as long as you did not complete your turn you can split old civ as much as you want. But you will not split it into some new rebel civ of new color - instead you will add new cities (if possible) to same rebel civ (why? see (2)) City counter is not updated when you capture enemy city, but it does update (-1) when you destroy "loyalist" city during capture, so in this case number of cities can become 4 or less at current turn.

Civil war event is called during city capture routine, but before capital is captured or destroyed,
so at this moment this city always belongs to its old civ and is not destroyed. Also, old palace is still not destroyed at the moment.

2) game checks civs starting from 1 to 7, and if some civ has 0 unit counter and 0 city counter - this civ will be our "rebel" civ. First aviable civ is selected. Problem here: settlers and nukes are not included into unit counter, so, for example, you can wait with your NONE settler for your own sudden rebel civ! This bug actually happened to somebody on Fanatics, I remember reading about it...
And another problem! Remember, that you can split old civ as long as you want. But its worse than that! Our first "rebel" civ still has 0 cities and 0 units on its counters, so we can split old civ further! This way, we will change more "loyalist" cities and units to rebels, if "loyalist" actually still have some cities for that... Also, it's possible that rebel civ will change its "flavor" in process: for example, Babylonians (rebel) can become Zulu (rebel). In extreme case, you can start another civil war in Loyalist last city, so you will immediately destroy their civ, so only rebel civ will remain from these two.

3) game counts population of all Loyalist cities on every continent

4) game sets "capital continent": where old capital was. Strange and useless code here: if "capital continent" already has been set, it can be changed if Loyalist civ has _another_ city with palace and this city is on the same X line as civ's first settler ("start position X coordinate" in JCivED)...

5) if some "capital continent" was found (this is always true, because C.W. can happen only when capital is captured): call "spawn civ" function for rebel civ...
"Spawn civ" function deletes all existing units of civ. So, if this is a second etc. split on this turn, all previous rebel units are deleted. Game do not use "delete unit" function here, instead it simply goes through all 128 units and change them to -1. So units do NOT deleted properly. For example, bit flag "unit here" is still in world map data on this tile. Usually this is not a problem, because usually there are no units of this color on the map when new civ is spawned.

5) if civ was succesfully spawned*, select which civ from the pair of same color it will be. If new rebel civ is beyond original number of civs (for example, you had selected 5 civs in "level of competition" and rebel civ is number 6th), then its "flavour" selected randomly. Also, in this case, after destruction of rebel civ settler of another civ of this color can appear, just like after destruction of normal civ from 4000 BC.

*if civ was not active (normally, dead civs or civs beyond "level of competition" are not active), then "spawn civ" function simply sets some variables, it does not create first settler. Also in this case it always returns "true". But if civ was active (it's possible, if some active civ had had 0 normal units and 0 cities - for example, if you waited with your NONE settler) - then normal rules to spawn "first" civ settler are used and this function can return "0" if failed to do so.

6) But if vacant place is from some normal dead civ, then some strange rule is used. Dead green, yellow, pink and gray civs always change their "flavour" to another (for example, English always become Greeks and Aztecs always become Egyptians etc.). After destruction of such rebel civ, no new civ can be spawned. But for all other colors (white, blue, cyan) rebel civ in dead civ slot sets its "flavour" randomly, just according to (5) rule. In this case, after destuction of rebel civ, new civ can be spawned, just like in (5).

6) game sets rebel civ leader's name, civ single/adjective and civ plural name

7) if Loyalist civ is the player (can never happen), then game should show non-existent "*SCHISM" message from KING.TXT; for AI, game shows "*ESCHISM"

8) rebels got 1/2 of Loyalist treasury; new Loyalist treasury calculates as old treasury minus rebels' treasury

9) for some reason, game sets rebels' military power as half of Loyalist mil. power. And does not change Loyalist mil. power at all. This data is of course wrong, but maybe it's here so we have at least some changes before correct re-calculation next turn.

10) rebels' bulb meter is changed to lyalists'; same for number of tech

11) same for current government

12) civ. advances data (bit per tech) copied, but not data about source of these civ. advances. So this data is still -1 (so, even though rebel civ _knows_ these techs, in civilopedia these techs will be without "Discovered" or "Taken from <Loyalist civ>" subtitle).

13) rebel's timer to talk with player is set to game_turn-8, which means that they will talk to you only 8 turns later. But because your contact status with them probably is 0, it does not matter and they will speak immediately anyway

14) diplomacy status of rebels to Loyalists is set to 1 ("contact" and nothing more)

15) diplomacy status of Loyalists to rebels is set to 9 ("contact" and "vendetta").
Vendetta between AIs means that they will never talk to each other, so this war will be eternal.
Only if Loyalists will change their govt they will forget all vendettas including this one.

16) game tries to divide loyalists and rebels to their own continents:
initially, loyalist pop. score is population of capital continent and rebel pop. score is 0.
If rebel pop. score is bigger than loyalists' OR current continent is the "capital" continent of loyalists,
then this continent is belong to Loyalists (and its population is added to total Loyalists population, if not their "capital" continent). Else continent is belong to Rebels (and its population is added to total Rebels population).

17) if in result of this divorce, rebel pop. score*2 <= loyalists pop. score (too small!) OR rebel pop. score > loyalists pop. score (too big!), then game uses ALTERNATIVE way to divide loyalists and rebels:
while rebel population*3 < original loyalist population, game selects farest city from old loyalist capital and makes it Rebel. So roughly 1/3 of population are rebels is this case (this always happens when civ has cities only on one continent).

18) but if "continental divorce" population divide ok, then game simply makes all loyalist cities on rebel continents rebel cities.

19) then, game changes some loyalist units to rebels or change their home cities (too much to write and this post is already very big, so I will skip that)

20) game granted rebels a new capital. New capital is selected as a city with smallest sum of distances from all other cities of this civ. "X start coordinate" of civ is changed to X coordinate of this city.

21) if Loyalists is the player (never can happen), then game changes camera position to... current camera position;
and if they are AI, game granted them a new capital. Rules to select it the same as for rebels. "X start coordinate" of civ is changed to X coordinate of this city. Before that, game changes civ of their old capital to -1 to exclude it from this logic (it's important, because at the moment, their old capital is still belong to them).

22) if (1) condition was ok, but game failed to add rebel civ ("civil war" function returned 0) - then game select a city according to (20) rule, excluding captured city (for that, civ of captured civ is temporarily changed to aggressor civ, and after that it's changed back). And current production in this city is changed to Palace. Even if this civilization has no tech for it. Production of palace can not be interrupted by AI, there are special rule about that.
 
Last edited:
fantastic information...

The biggest problem of all this is when a civilization has no capital, and even if they have the technology to build it in most cases they will never do it, only very occasionally I have seen that the Zulus have moved their capital.

Could something be done to force civilizations without capital to build it?
 
How civil war event works in CivDos...
1)Civil war event is called if AI civ has more than 4 cities and somebody captured their capital and human player's place is lower than place of this AI civ.
Problem: city counter and civ place are updated only at the beginning of new turn, so as long as you did not complete your turn you can split old civ as much as you want. But you will not split it into some new rebel civ of new color - instead you will add new cities (if possible) to same rebel civ (why? see (2)) City counter is not updated when you capture enemy city, but it does update (-1) when you destroy "tory" city during capture, so in this case number of cities can become 4 or less at current turn.

Civil war event is called during city capture routine, but before capital is captured or destroyed,
so at this moment this city always belongs to its old civ and is not destroyed. Also, old palace is still not destroyed at the moment.

2) game checks civs starting from 1 to 7, and if some civ has 0 unit counter and 0 city counter - this civ will be our "rebel" civ. First aviable civ is selected. Problem here: settlers and nukes are not included into unit counter, so, for example, you can wait with your NONE settler for your own sudden rebel civ! This bug actually happened to somebody on Fanatics, I remember reading about it...
And another problem! Remember, that you can split old civ as long as you want. But its worse than that! Our first "rebel" civ still has 0 cities and 0 units on its counters, so we can split old civ further! This way, we will change more "tory" cities and units to rebels, if "tory" actually still have some cities for that... Also, it's possible that rebel civ will change its "flavor" in process: for example, Babylonians (rebel) can become Zulu (rebel). In extreme case, you can start another civil war in Tory last city, so you will immediately destroy their civ, so only rebel civ will remain from these two.

3) game counts population of all Tory cities on every continent

4) game sets "capital continent": where is old capital was. Strange and useless code here: if "capital continent" already has been set, it can be changed if Tory civ has _another_ city with palace and this city is on the same X line as civ's first settler ("start position X coordinate" in JCivED)...

5) if some "capital continent" was found (this is always true, because C.W. can happen only when capital is captured): call "spawn civ" function for rebel civ...

5) if civ was succesfully spawned, select which civ from the pair of same color it will be. If new rebel civ is beyond original number of civs (for example, you had selected 5 civs in "level of competition" and rebel civ is number 6th), then its "flavour" selected randomly. Also, in this case, after destruction of rebel civ settler of another civ of this color can appear, just like after destruction of normal civ from 4000 BC.

6) But if vacant place is from some normal dead civ, then some strange rule is used. Dead green, yellow, pink and gray civs always change their "flavour" to another (for example, English always become Greeks and Aztecs always become Egyptians etc.). After destruction of such rebel civ, no new civ can be spawned. But for all other colors (white, blue, cyan) rebel civ in dead civ slot sets its "flavour" randomly, just according to (5) rule. In this case, after destuction of rebel civ, new civ can be spawned, just like in (5).

6) game sets rebel civ leader's name, civ single/adjective and civ plural name

7) if Tory civ is the player (can never happen), then game should show non-existent "*SCHISM" message from KING.TXT; for AI, game shows "*ESCHISM"

8) rebels got 1/2 of Tory treasury; new Tory treasury calculates as old treasury minus rebels' treasury

9) for some reason, game sets rebels' military power as half of Tory mil. power. And does not change Tory mil. power at all. This data is of course wrong, but maybe it's here so we have at least some changes before correct re-calculation next turn.

10) rebels' bulb meter is changed to Tory's; same for number of tech

11) same for current government

12) civ. advances data (bit per tech) copied, but not data about source of these civ. advances. So this data is still -1 (so, even though rebel civ _knows_ these techs, in civilopedia these techs will be without "Discovered" or "Taken from <Tories>" subtitle).

13) rebel's timer to talk with player is set to game_turn-8, which means that they will talk to you only 8 turns later. But because your contact status with them probably is 0, it does not matter and they will speak immediately anyway

14) diplomacy status of rebels to Tories is set to 1 ("contact" and nothing more)

15) diplomacy status of Tories to rebels is set to 9 ("contact" and "vendetta").
Vendetta between AIs means that they will never talk to each other, so this war will be eternal.
Only if Tories will change their govt they will forget all vendettas including this one.

16) game tries to divide Tories and rebels to their own continents:
initially, Tories pop. score is population of capital continent and rebel pop. score is 0.
If rebel pop. score is bigger than Tories' OR current continent is the "capital" continent of tories,
then this continent is belong to Tories (and its population is added to total Tories population, if not their "capital" continent). Else continent is belong to Rebels (and its population is added to total Rebels population).

17) if in result of this divorce, rebel pop. score*2 <= tories pop. score (too small!) OR rebel pop. score > tories pop. score (too big!), then game uses ALTERNATIVE way to divide Tories and rebels:
while rebel population*3 < original tory population, game selects farest city from old tory capital and makes it Rebel. So roughly 1/3 of population are rebels is this case (this always happens when civ has cities only on one continent).

18) but if "continental divorce" population divide ok, then game simply makes all Tory's cities on rebel continents rebel cities.

19) then, game changes some tory units to rebels or change their home cities (too much to write and this post is already very big, so I will skip that)

20) game granted rebels a new capital. New capital is selected as a city with smallest sum of distances from all other cities of this civ. "X start coordinate" of civ is changed to X coordinate of this city.

21) if Tories is the player (never can happen), then game changes camera position to... current camera position;
and if they are AI, game granted them a new capital. Rules to select it the same as for rebels. "X start coordinate" of civ is changed to X coordinate of this city.
This a very long and complex post. What do you mean by Tory? It has something to do with the English Conservative Party? I'm sorry but English is not my mother language.
 
tupi, fascinating information, as always. Adding to your second point, if you split a civ two times in one turn and the rebels "change flavour", I think the units of the first rebel civ are deleted and only the "new" units in the "new" cities of the second rebel civ remain. The old cities are left empty. Although I might be remembering this wrong.

rhaul, I have seen the AI rebuild its palace after losing its capital without an empire split, but only a few times. And I'm not talking about those big civs that run out of things to build and start popping palaces all over the place. This leads me to believe that the logic is in there, but the conditions are rarely met or somehow flawed.

Osvaldo Manso, the Tories were originally the loyalists (loyal to the king) in the English civil war, the Whigs were the rebels. So tupi's Tories are the original civ that was split.
 
This a very long and complex post. What do you mean by Tory? It has something to do with the English Conservative Party? I'm sorry but English is not my mother language.
My slang from Colonization game, sorry. Better to call them Loyalists. EDIT: renamed 'em
 
Last edited:
rhaul, I have seen the AI rebuild its palace after losing its capital without an empire split, but only a few times. And I'm not talking about those big civs that run out of things to build and start popping palaces all over the place. This leads me to believe that the logic is in there, but the conditions are rarely met or somehow flawed.

Yes, I've seen it too, or so I think. The interesting thing would be to know why this behavior fails.
 
tupi, fascinating information, as always. Adding to your second point, if you split a civ two times in one turn and the rebels "change flavour", I think the units of the first rebel civ are deleted and only the "new" units in the "new" cities of the second rebel civ remain. The old cities are left empty. Although I might be remembering this wrong.
I tested and can confirm that this happens. For now I don't understand why.

Probably when "initialize new civ" function's running, it deletes all units of this color on map, should check... Probably this is what happens.
EDIT: nope, units are destroyed only in "destroy this civ" function. In "initialize new civ" only barbarians on distance less than 9 from first settler are destroyed. Huh, never knew about that. Btw, why rebels do not even produce their "spawn" settler?.. Should investigate more. EDIT: if "acitivity flag" of spawned civ is 0, it does not spawn settler in "initialize civ" function. And normally, rebels are created from some dead civ or civ disabled in settings, so their activity flag is 0. But in rare cases, when rebel civ created from some active civ (but with 0 normal units and 0 cities), 1 addional settler will be granted for them. Also in this case spawn of rebel civ can failed, just like spawn of normal "2nd generation" civ (too late, no free place etc.). Also only in this case "initialize new civ" function can return 0.
 
Last edited:
I finally have found condition for AI palace construction. See new added §22. Basically, civ should be bigger than human player and with more than 4 cities. Then, if civil war event failed (usually happens if no free slot for new civ had been found) game selects a city which will start to construct a new palace.

This code was in "bad instruction" chunk in Ghidra because of previous overlay call, so this chunk is skipped in decomp and only asm code available.
 
Last edited:
I finally have found condition for AI palace construction. See new added §22. Basically, civ should be bigger than human player and with more than 4 cities. Then, if civil war event failed (usually happens if no free slot for new civ had been found) game select a city which will start to construct a new palace.

This code was in "bad instruction" chunk in Ghidra because of previous overlay call, so this chunk is skipped in decomp and only asm code available.

Wowwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww, Wonderful news.

Do you think you can modify the conditions for me to make a palace as long as they don't have one?
 
Wowwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww, Wonderful news.

Do you think you can modify the conditions for me to make a palace as long as they don't have one?
Then I should add some code to "select next production" function, but there's no place for that. Recently I have found some unused functions in the game, so theoretically I can re-write them, and call them from "select next production" to save some space here, and then I can add necessary code for selection of palace production... Not the easiest task in slightest, so I'm not gonna try it in foreseeable future at least, sorry.

Another problem: after start of production of palace, AI ignores everything until it finishes it. There's a special rule for that. So you can attack this city and they will still continue to build a palace... In my Sega Megadrive port, today I included such rule this way: if city is ok according §20 rule, then, taking into account city shields storage and civilization treasury, if AI can buy a palace immediately, it can select it with priority of 6 if civilization has no capital and priority of 12 if it has a capital. Not tested it enough yet.
 
Adding to your second point, if you split a civ two times in one turn and the rebels "change flavour", I think the units of the first rebel civ are deleted and only the "new" units in the "new" cities of the second rebel civ remain. The old cities are left empty. Although I might be remembering this wrong.
So. When the game creates a new civ, it is indeed deletes all units of this color. But it does that not in a proper way, without using "delete unit" function. Instead, the game simply changes all units in the list to -1. This is bad, because on the planet map, there are still bits "unit is here" in tiles where those units were before, and those bits are not updated, and maybe some other data are not updated too. Usually it's not a problem, because normally there should not be any units of this color on the map at the moment.
 
Top Bottom