Do you happen to know the function the game uses when partisans emerge from a captured city? I'd essentially like to do this, but focused around a unit instead of a city.
From
the Apolyton archive (post 57 of linked page):
shortcuts from rules.txt:
Communism=Cmn, Conscription=Csc, Guerrilla Warfare=Gue, Gunpowder=Gun
CityLevel = RoundDown[( CitySize+4)/8 ]
CitySize is the size of the city
before the capture.
BNP: basic number of partisans
TypeMultiplier: a multiplier that affects the result
defender's techs | attacker has Gue | BNP | TypeMultiplier |
Gue | no | CityLevel -1 | 2 |
Gue | yes | CityLevel | 1 |
Cmn+Gun | irrelevant | CityLevel -1 | 1 |
CscModifier: Conscription modifier
defender has Csc | CscModifier |
yes | 1 |
no | 0 |
GovtModifier: Government modifier
GovtModifier=1/2*abs(govindexD-govindexA)
(abs...absolute value)
govindexD- defender's government index value
govindexA- attacker's government index value
Index values:
Anarchy=1,Desp=2, Mon=3, Com=4, Fund=5, Rep =6, Dem=7
The formula:
Partisans = (BNP + CscModifier + GovtModifier*CityLevel) * TypeMultiplier
(the result is rounded down)
Notes:
Partisans can pop up only on empty ground squares in "the working city radius" (squares that may be worked in the city window).
The max. number of partisans is 20 - i.e. only one partisan may pop up on one square.
If city was founded by attacker then no partisans pop up.
The Guerilla Warfare obtained by conquering the city counts, in other words it affects the number of partisans (partisans pop up
after the attacker chooses a defender's tech).
No effect: unhappy, content, happy people; wltxd, city improvements, killed defender/attacker, decrease of inhabitants by siege, type of terrain.
The defensive value of a terrain affect where the emerging partisans are placed: first partisan to the best devensive terrain and so on. There is a special pattern of placing partisans if all terrain is the same: first square is north-east from the city, then clockwise around the city (this pattern is equal to the pattern of barbs coming from huts and to the pattern of cultivating squares around cities by AI).
A simplified conclusion:
There are two situations when partisans arise: the defender has Guerilla Warfare or the defender has Gunpowder+Communism. Guerilla Warfare produces twice more partisans than the combination Gunpowder+Communism.
The effect of Guerilla Warfare and Gunpowder+Communism is not cumulated: only Guerilla Warfare applies.
Conscription adds 1 or 2 partisans.
Every point of "governments difference" raises the number of partisans by 50%.
The number of partisans depends on the city size: The smallest city that produces them has size 4. Next turning points are 12, 20, 28, 36 etc.
Guerilla Warfare is the only attacker's tech that affects the number of partisans.
Overview (for equal governments):
defender's techs / attacker's techs | gue | gue+csc | cmn+gun | cmn+gun+csc |
number of partisans for
citylevel1 citylevel2 citylevel3 citylevel4... | 0 2 4 6 ... | 2 4 6 8... | 0 1 2 3... | 1 2 3 4... |
| gue/gue | gue+csc/gue | | |
1 2 3 4... | 2 3 4 5... | | | |