unhappiness revolt questions

Pazyryk

Deity
Joined
Jun 13, 2008
Messages
3,584
Just trying to understand the base mechanism for modding purposes:
  1. This happens at the SUPER_UNHAPPY_THRESHOLD (=-20), correct?
  2. Is there any effect on revolt of additional unhappiness beyond the threshold?
  3. Is there any effect on anything that is not threshold based?
  4. Can anyone explain the revolt constants: REVOLT_COUNTER_MIN (=4), REVOLT_COUNTER_POSSIBLE (=3), REVOLT_NUM_BASE (=100), REVOLT_NUM_CITY_COUNT(=20)? (others?)
  5. Can any of these values be changed on the fly from Lua? (I looked under player methods but didn't find anything)
  6. Is there an easy way to immediately identify (via Lua) a new revolting unit? I assume it will fire the SerialEventUnitCreated event, but how can I tell it from normal barb units?
 
Just trying to understand the base mechanism for modding purposes:
  1. This happens at the SUPER_UNHAPPY_THRESHOLD (=-20), correct?
  2. Is there any effect on revolt of additional unhappiness beyond the threshold?
  3. Is there any effect on anything that is not threshold based?
  4. Can anyone explain the revolt constants: REVOLT_COUNTER_MIN (=4), REVOLT_COUNTER_POSSIBLE (=3), REVOLT_NUM_BASE (=100), REVOLT_NUM_CITY_COUNT(=20)? (others?)
  5. Can any of these values be changed on the fly from Lua? (I looked under player methods but didn't find anything)
  6. Is there an easy way to immediately identify (via Lua) a new revolting unit? I assume it will fire the SerialEventUnitCreated event, but how can I tell it from normal barb units?

My advice? Make a custom scenario and test.
 
Yes, but that would take some effort on my part... (possibly a lot of effort for #4 since these things are hard to reverse-engineer)
 
Can anyone explain the revolt constants: REVOLT_COUNTER_MIN (=4), REVOLT_COUNTER_POSSIBLE (=3), REVOLT_NUM_BASE (=100), REVOLT_NUM_CITY_COUNT(=20)?

From the source

Code:
rebels = (REVOLT_NUM_BASE + rand(100 + ((NumCities - 1) * REVOLT_NUM_CITY_COUNT))) / 100;

turns = REVOLT_COUNTER_MIN + rand(REVOLT_COUNTER_POSSIBLE);
mod = GameSpeed.TrainPercent / 100;
if (mod > 1)    turns *= mod;
if (firstTime)  turns /= 2;
if (turns <= 0) turns = 1;

rebels is the number of units that will spawn, turns is the number of turns until the next (possible) revolt

Can any of these values be changed on the fly from Lua?
No, they are all constants (from GlobalDefines.xml)
 
Is there an easy way to immediately identify (via Lua) a new revolting unit? I assume it will fire the SerialEventUnitCreated event, but how can I tell it from normal barb units?
You can't.

But it would be a fairly trivial DLL mod (in CvPlayer::DoRevolt()) to either set the original owner of the barbarian unit to be the player who is suffereing from the revolt, or to send an additional LuaEvent as the units spawn.
 
Thanks for all the answers! Very helpful.

Don't understand the question
I guess I'm asking whether -50 or -100 or -1000 unhappiness is any worse than -20. Not just for revolt but for any other bad effects. I suspect the answer is No.


On the detection via Lua, I think I could use SerialEventUnitCreated in combination with unit:GetGameTurnCreated() and looking at where the unit is when created. Barbs are only spawned on or by a barb camp, correct? And rebels are spawned on or next to your borders? (Remarkably, in my 1000 hours of playing I've never actually seen a rebel spawn...) I prefer Lua solutions for the moment at least if they are not too messy -- I haven't made the leap into C++ yet, though I will soon.
 
Barbs are only spawned on or by a barb camp, correct?
Depends how many other units are in the vacinity and the surrounding terrain - it will be near, but not necessarily adjacent

And rebels are spawned on or next to your borders?
The first one will always be within your borders, but subsequent ones could be outside (as they are placed in the same hex as the first and then JumpToNearestValidPlot() is used to move them out)
 
Top Bottom