darkpanda
Dark Prince
- Joined
- Oct 28, 2007
- Messages
- 823
Mize hijacked my interest into the CIV code by asking what's the criteria to trigger an earthquake in a city ? (see here: http://forums.civfanatics.com/showthread.php?p=12718199&post12718199).
Especially, I wanted to know how terrain can affect the occurrence of a city disaster. So I searched a little bit a found the CIV code that handles them, and although there is randomness to it, we can see that terrain does play a role:
City disaster logic
The game logic below is performed TWICE per Civ turn:
I don't know if any of this was described in the CIV manual, in "Rome on 640K a day" or other official Civ documentation, but wasn't totally aware of those rules, and I must say I like the idea of playing with such thoughts: "if we settle near the sea, we are at the mercy of pirates, but near the river, we may endure floodings".
I tried to hack Civ to increase their frequency (change the "2" iterations to "256"), but it seems that there are so many conditions for an event to happen that it had no impact in my sample test game...
Especially, I wanted to know how terrain can affect the occurrence of a city disaster. So I searched a little bit a found the CIV code that handles them, and although there is randomness to it, we can see that terrain does play a role:
City disaster logic
The game logic below is performed TWICE per Civ turn:
- Select a random city ID between 0 and 127
- If the corresponding city does not exist -> finish and loop (this counts as an iteration)
- Else, if the City's owning Civ has only 1 city in total -> finish and loop (this counts as an iteration)
- Else, if the City size is strictly smaller than 5 -> finish and loop (this counts as an iteration)
- Else, select a random value between 0 and 9 and apply the corresponding rules below:
- 0 = EARTHQUAKE
- If City has nearby Hills AND City has buildings other than Palace
- -> EARTHQUAKE; destroys a random building (except for Palace)
- 1 = PLAGUE
- If Civ owning the City does NOT know Medicine AND City has NO Aqueduct AND Civ knows Construction (and City size is not 0, obviously...)
- -> PLAGUE; reduces City Size by 25% (CitySize-CitySize/4)
- 2 = FLOODING
- If City has RIVER nearby AND City has NO City Walls AND Civ knows Masonry AND City Size strictly above 1
- -> FLOODING; reduces City Size by 25% (CitySize-CitySize/4)
- 3 = VOLCANO
- If City has nearby MOUNTAIN AND City has NO Temple AND Civ knows Ceremonial Burial AND City Size strictly above 1
- -> VOLCANO; reduces City Size by 33% (CitySize-CitySize/3)
- 4 = FAMINE
- If City size larger than 1 AND City has NO Granary AND Civ knows Pottery
- -> FAMINE; reduces City Size by 33% (CitySize-CitySize/3)
- 5 = FIRE
- If City has buildings (other than Palace) AND City has NO Aqueduct AND Civ knows Construction
- -> FIRE; destroys a random building (except for Palace)
- 6 = PIRATES
- If City has nearby OCEAN AND City has NO Barracks
- -> PIRATES; plunder your FOOD and SHIELD stocks (reset to 0)
- 7, 8 or 9 = RIOT/SCANDAL/CORRUPTION
- the business rules in this case are much more complex: they involves citizen demands for Temple, Courthouse, Marketplace or Cathedral, suggestion to lower taxes, and can even lead to a City subverting to another Civ, or declaring its own independence... I'll detail them at a later time
- 0 = EARTHQUAKE
- Finish and loop
I don't know if any of this was described in the CIV manual, in "Rome on 640K a day" or other official Civ documentation, but wasn't totally aware of those rules, and I must say I like the idea of playing with such thoughts: "if we settle near the sea, we are at the mercy of pirates, but near the river, we may endure floodings".
I tried to hack Civ to increase their frequency (change the "2" iterations to "256"), but it seems that there are so many conditions for an event to happen that it had no impact in my sample test game...