[SDK MODCOMP] Influence Driven War

moctezuma

Chieftain
Joined
Nov 16, 2001
Messages
52
Influence Driven War v1.1
By: Moctezuma

Downloads

BTS v3.13 download (FIXED):
http://forums.civfanatics.com/attachment.php?attachmentid=171154&stc=1&d=1205266928

BTS v3.03 download:
http://forums.civfanatics.com/attachment.php?attachmentid=171155&stc=1&d=1205266928

Warlords v2.08 download:
http://forums.civfanatics.com/uploads/5028/Influence_Driven_War_11_208.zip

Civ 1.61 download:
http://forums.civfanatics.com/uploads/5028/Influence_Driven_War_11_161.zip

Unzip these files into the "Mods" folder.

Version history
Code:
1.0	 
First version
1.1 
compatible with Warlords v2.08
pillage influence
unit experience multiplier
fort capture multiplier
fixed divide by zero in neutral territory
added a new XML option: minimum city population to generate militia

Description of changes

In vanilla game the culture is generated only by cities using buildings/specialists, and it spreads from them to surrounding territory. Each square (plot, tile) in the game stores accumulated culture for each player individually.

This mod consists of three parts:


------------------------------
1. Combat influence
------------------------------


Military units affect surroundings via combat influence:
After each combat between two units: some amount of culture accumulated in each square of combat area is transferred from loser player/AI to winner player/AI. Combat area (i.e. influence radius) is: attacker plot, defended plot and near surrounding plots (see definition of influence radius bellow).
Note: This way I try to simulate effect of battle victory: some peoples have tendency to give up and flip to victorious side.

Rules:
  • It works for both field battle and city assault.
  • It works for both attacking and defending (also city defending).
  • If last defending unit in city dies: combat influence is increased greatly (an emergency militia may be "auto-drafted", check new resistance rules later).
  • If victorious unit has warlord: combat influence is increased.
  • If attacking unit withdraws: no culture transfer happens.
  • Calculated culture exchange cannot be higher than loser's remaining culture in plot. This means that no culture transfer happens in empty neutral territory: nobody is living there to be influenced. In third-party territory a culture transfer occurs only if some loser's culture is accumulated there.
  • It works also for attacking/defending barbarians in player or barbarian territory (this can be disabled via XML file).
  • Also water squares are affected by combat influence.
  • Naval combats use same influence rules as land combats. Note: if naval battle occurs near land, also land squares are affected (naval influence can be disabled via XML file).
  • No culture is exchanged during city bombardment (via catapults, ships, bombers, ICBM); during fighter interception; or if worker/settler is captured out of city.

If you like exact formulas, here it is:

The culture transfer from loser to winner for each plot within combat area is calculated this way:

Code:
  CultureTransferInPlot = BaseCombatInfluence *
   sqrt (LosersCultureInPlot * GameSpeedMultiplier) * 
   UnitExperienceMultiplier * NoDefenderMultiplier
   WarlordMultiplier * PlotDistanceMultiplier

where:

BaseCombatInfluence :
Default: 4.0
This ratio is good way how you can increase/decrease overall effects of IDW (via GlobalDefinesAlt.xml).

LosersCultureInPlot:
currently accumulated culture in given plot for player which had lost combat.
Note: Result culture transfer cannot be higher that this value.

GameSpeedMultiplier:
quick: 66%, normal: 100%, epic: 150%, marathon: 300%

NoDefenderMultiplier:
if last fort defender dies: +100% (configurable in XML)
if last city defender dies: +150% (configurable in XML)

WarlordMultiplier:
if winner unit has attached warlord: +30%, (only in Warlords version, configurable in XML).

UnitExperienceMultiplier:
experience of victorious unit increases influence.
Default value: +3% per experience point.

PlotDistanceMultiplier:
defines combat area - highest influence is in plots where attacker and defender stays prior to combat, max distance of effect of is similar to 2 square radius of city.

Exact formula is:
Code:
PlotDistanceMultiplier = 
 1 + DistanceFactor
   - DistanceFactor * plot_distance(curr_plot, attacker_plot) 
   - DistanceFactor * plot_distance(curr_plot, defender_plot)
Default value of DistanceFactor is 0.2 (20%).
Influence radius and distance multipliers can be modified via XML.

Examples of influence radius:

Distance multipliers used in case of adjacent plot combat:
Code:
                20%  40%  40% 20% 
            20% 60%  80%  80% 60% 20%
            20% 60% 100% 100% 60% 20%
            20% 60%  80%  80% 60% 20%
                20%  40%  40% 20%
Distance multipliers used in case of diagonal combat:
Code:
                20%  20%  20%
            20% 40%  60%  60% 40%
            20% 60% 100%  80% 60% 20%
            20% 60%  80% 100% 60% 20%
                40%  60%  60% 40% 20%
                     20%  20% 20%

-----------------------------------
2. Active city resistance
-----------------------------------


If last defending unit in the city dies and city resistance is sufficient then one militia unit emerges in city, otherwise it is captured just like in vanilla.
Resistance is sufficient if defender's culture in central plot >= attacker's culture in central plot (culture ratios in central city plot you can check also in the city screen).
Note: This new rule tries to simulate active people resistance in highly cultured cities.
Code:
  resistance = (defender_culture_ratio - attacker_culture_ratio) / 2
Militia unit is "auto-drafted":
  • Best available regular unit type is selected using same rules as for standard drafting: i.e. warrior, axeman, maceman, musketman, rifleman,...
  • Auto-drafted unit begins with 25% health (configurable in XML). This represents very low training level of quickly gathered militia.
  • Draft anger is 50% of standard draft anger: high danger means low anger. (configurable in XML)
  • City population is reduced by 1 (it doesn’t depend on unit type).
  • Auto-draft is not limited like standard draft: new militia unit is "auto-drafted" when previous one dies and resistance is still sufficient.
  • When city population is reduced to 1, the city is captured even if resistance is still sufficient.
  • There is no technology requirement for auto-draft: this is not real conscription: imagine peoples that are just trying in defend their homes.
  • It takes some time to accumulate sufficient culture: if city is attacked early no militia emerges.


------------------------------
3. Pillage influence
------------------------------


When enemy unit pillages tile improvement, some amount of accumulated culture is transferred from improvement owner to unit owner. Only single square is affected.

Note: This rule was added to provide incentive for defender to defend own territory and not only stay inside cities. It reflects situation where farmers, miners or villagers escape due to farm, mine or village is burned down by invader.

This rule is optional and can be disabled via XML

Rules:
  • It works only in enemy territory (no influence in friendly or neutral territory)
  • No influence form route pillage (roads, railroads)
  • Works also for sea improvements (e.g. fishing boats)
  • For improvements like towns, each downgrade influences a given square

Code:
CultureTransferInPlot = BasePillageInfluence *
   sqrt (LosersCultureInPlot * GameSpeedMultiplier)

where:

BaseCombatInfluence:
default value: 2.0
It can be easily modified via GlobalDefinesAlt.xml.

LosersCultureInPlot:
currently accumulated culture in given plot for owner of pillaged improvement.
Note: Result culture transfer cannot be higher that this value.

GameSpeedMultiplier:
quick: 66%, normal: 100%, epic: 150%, marathon: 300%



Gameplay

Player is informed about effects of IDW this way:

  • After each battle a number with influence % (i.e. exchanged culture ratio) is shown in the game log. It is calculated in defended plot only, but whole combat area is influenced. Reason that I'm using defended plot here is because it is in most cases the most important one (e.g. central city square).
    [*]Green color means culture increase for you
    [*]Red color means culture decrease for you​
  • When last city defender dies and militia unit is "auto-drafted" a remaining resistance % is shown in the game log.



Result of changes on gameplay:

1. More dynamic borders during wars:

In vanilla game a culture plays significant role only in the beginning. In later stages the borders are almost fixed: big changes happen only if cities are captured.

With new rules you can fight for territory between cities and not only for cities itself. I think that this "frontline" effect really improves gameplay. You can "win" quite large area with several resources even without conquering single enemy city! Possible tactics if you don’t have sufficient power to conquer cities could be stay/pillage/heal near your borders and influence squares by killing approaching enemies.


2. Surprise or backstabbing attacks are less effective:

Attacked city can for short time defend itself even if last defender dies if resistance is sufficient: this increases reaction time for defending player if he has many units in the opposite side of empire.

However you cannot count on auto-drafted units. These are meant only to slow-down attack in case when everything else fails. In most cases a militia units can defend high cultured city only 1-2 turns until real defender units arrive because:
  • Militia unit begins with very low health, so if it is attacked in same turn, it almost certainly dies.
  • City resistance decreases very quickly because victory influence is much higher when last city defender dies (see NoCityDefenderMultiplier).
  • Each auto-drafted unit increases unhappiness in the city.
Note: I cannot make militia units more effective, because then player can abuse it: e.g. move out all defenders from city and later counterattack damaged attackers.


3. High cultured cities are harder to conquer (more militia formed) but easier to hold after capture because city's central square has quite good amount of conqueror’s culture immediately after capture.

This means:

  • No problem with cultural flipping of captured city back to original owner:
    In vanilla is this problem is fixed by disabling startup option: "City flipping after conquest". This is no longer needed in this mod.
  • Much smaller problem with cultural flipping of captured city to neighbor civ, which can be in peace with conqueror.
    Naturally, if just conquered city has been in big cultural pressure prior to capture it will be in pressure also after it, because culture is transferred only from city's previous owner.
Note: culture buildings in newly captured city are still very important because city still begins with zero culture (only plots are influenced by combat).


4. No problems with stealing of conquered city:

This happens often in multiplayer with simultaneous turns but sometimes it occurs also in single-player: Two players are doing joint attack on same enemy city; first player destroys all defenders; second one just waits until last defender remains there and then attacks.

With new rules the city capture is fairer: culture in central city square is increased after each victory for each attacking player separately. If no defender unit is left then attacker, whose culture in central square is higher than owners culture, captures the city.


5. In battles quality counts more than quantity:

With new rules the conquest is easier with smaller stack of high strength units than with bigger stack of low strength units: Veteran unit makes more influence (see UnitExperienceMultiplier) and better victory/loss ratio means more culture transferred to attacker.

Some examples:
  • Suicide catapults are little less effective: due to losses, defender's culture increases more often.
  • Blitz units like tanks are very effective: due to multiple culture exchanges per turn. This really speeds up the conquest of very highly cultured cities in later stages of game, which can be really slow otherwise.
  • Warlord units are more effective than normal units (see WarlordMultiplier).

Remark to AI:
I made no changes here so far. In my test games I haven't seen any AI problems caused by new rules AI should be even more dangerous now because it loves pilaging.


Notes to Modmakers

Package contains also changed SDK sources. Modmakers are free to use my code, as long as my name and the description above is supplied with it.
In the C++ files modified sections are enclosed by: "BEGIN InfluenceDrivenWar" and "END InfluenceDrivenWar",


Thanks to:
  • Newbert (pillage influence idea)
  • Dom Pedro II (fort capture influence idea)
and other CFC members for comments and suggestions for this mod:
 

Attachments

  • Influence Driven War_11_BTS_313.zip
    1.5 MB · Views: 1,238
  • Influence Driven War_11_BTS_303.zip
    1.5 MB · Views: 552
Dom Pedro II said:
Holy hell! This is one of the most expansive modcomps I've seen! I'll download this and play it at work! :D

Gee, must be nice! :badcomp:
 
It seems we have a new face in the Moding community and he's starting out with a big splash, welcome aboard and good luck with your mod.
 
Something to consider for the future might be a boost for forts since controlling them would definitely influence not only the tile its on but also the tiles surrounding it...

EDIT: Also, thank you for posting the source code in the initial download. Sometimes people forget or don't want to and have to be pestered to get them to do it :)
 
Dom Pedro II said:
Something to consider for the future might be a boost for forts since controlling them would definitely influence not only the tile its on but also the tiles surrounding it...

Yes, yes, don't forget forts. :)
 
Thanks for all your comments.

Dom Pedro II said:
This is one of the most expansive modcomps I've seen! I'll download this and play it at work!

Maybe it looks complex from my description but if you check the sources you will see that had added only 3 new methods a only 1 existing method: CvCity::CvUnit::updateCombat() was used to hook my code. It is really small mod: new DLL + one XML file used for configuration. This way it should be very easy to integrate it into bigger mods. Most of time I didn’t spent in programming but in playtesting :). Optimizing various constants in XML took me some time, but I still expect same changes here (maybe unit experience multiplier).

Dom Pedro II said:
Something to consider for the future might be a boost for forts since controlling them would definitely influence not only the tile its on but also the tiles surrounding it...

This mod component is very small and it works very well without any reprogramming of AI because units influence squares only when they fight and that is something what AI does quite well. Your suggestion is very interesting indeed. I had similar idea: big force stationed in cities or in military structures (terrain improvements like castles, forts) should definitely influence surroundings. It would require correct placing the units near your borders, in your culturally endangered cities and near enemy cities you want to culturally flip. I don’t want to introduce new rules from which only players can benefit so it would require:
  • reprogramming the AI that it should build military structures, and relocate them as your borders expand.
  • reprogramming the AI that it places the units in optimal places (which can very complex).
Note: Culture generated by units should be very limited otherwise you can place huge stack of units in the places where it is currently needed: this is micromanagement intensive and player/AI will be susceptible to surprise attacks.

The idea is very good; maybe I will work on it in some new mod.

Impaler[WrG said:
]It seems we have a new face in the Moding community and he's starting out with a big splash, welcome aboard and good luck with your mod.

I'm registered here for quite long time, but I didn't made any moding so far because I'm not interested in adding new stuff (like units) or modifying existing rules (like build times, game speeds) because I respect that Firaxis made very good job here. I'm doing programming as my real job so when the game code (SDK) was released I began to think how to improve the game via introducing new concepts. Culture is part of game which I like the most and war (especially in later eras) is part that I didn't like too much, so I made something what integrates some cultural aspects with wars.
 
moctezuma said:
Maybe it looks complex from my description but if you check the sources you will see that had added only 3 new methods a only 1 existing method: CvCity::CvUnit::updateCombat() was used to hook my code. It is really small mod: new DLL + one XML file used for configuration.

Yes, I realized that when I downloaded it. But it's also expansive in terms of just how much it effects even if the changes are fairly simple.


This mod component is very small and it works very well without any reprogramming of AI because units influence squares only when they fight and that is something what AI does quite well. Your suggestion is very interesting indeed. I had similar idea: big force stationed in cities or in military structures (terrain improvements like castles, forts) should definitely influence surroundings. It would require correct placing the units near your borders, in your culturally endangered cities and near enemy cities you want to culturally flip. I don’t want to introduce new rules from which only players can benefit so it would require:
  • reprogramming the AI that it should build military structures, and relocate them as your borders expand.
  • reprogramming the AI that it places the units in optimal places (which can very complex).
Well, the AI already knows how to defend its bonuses, so that will probably be the key to getting them to man forts.

I hadn't been thinking about forts expanding the cultural borders in and of themselves, but rather as a consequence of being captured (since you said that the flipping occurs after a battle) which means it would be the player who would really be at the disadvantage since the AI never builds forts and would thus not lose any territory should they be captured by the enemy.

Still, I would like very much to see the AI use forts even moderately well.
 
I hadn't been thinking about forts expanding the cultural borders in and of themselves, but rather as a consequence of being captured (since you said that the flipping occurs after a battle) which means it would be the player who would really be at the disadvantage since the AI never builds forts and would thus not lose any territory should they be captured by the enemy.
This is good idea and very easy to implement. In the next version of mod I will put there also FortCaptureMultiplier with defualt value e.g. 200%.
 
Well, it appears we have a new God in the modding Pantheon-up there with such luminaries as TheLopez, Impaler, Jeckel, Kael and Gerikes. I tip my hat to you sir, this looks absolutely AMAZING, and I will have to check it out post-haste ;).

Aussie_Lurker.
 
Aussie_Lurker said:
Well, it appears we have a new God in the modding Pantheon-up there with such luminaries as TheLopez, Impaler, Jeckel, Kael and Gerikes. I tip my hat to you sir, this looks absolutely AMAZING, and I will have to check it out post-haste ;).

Aussie_Lurker.

Hehe, I'm honored you would include me in such esteemed company, but I'm a lowly Lesser Power of Python at best. ;) But thanx for the complament. :D

And I have to agree this, and moctezuma's other work, is very cool and much worth a look. :)
 
This is a very good MODcomponent, I do however have some questions regarding the artificial intelligence:

Remark to AI:

I made no changes here so far. In my test games I haven't seen any AI problems caused by new rules.


This might be an obvious question, but will the computer not suffer from a miscalculation on how conquer a city? I mean the city - based on the Active City Resistance - will get a bonus, and thus the computer opponents must calculate that there might be a need for a larger army to conquer a specific city.
Also you may question the realism of the likeness of civilian resistance killing armies.
This is nonetheless a good piece of work.
 
This looks like a wicked mod! Can't wait to try it...

One suggestion, though. Would it be possible to create a unit action, that would allow a unit to spread a certain amount of cultural influence without engaging in combat? (To prevent abuse, you could limit this ability only to certain unit types, attach it to a promotion and restrict its use depending on proximity to enemy units, for example.) This would be no more tedious than pillaging.

I ask because I find a lot of wars are essentially successive seiges, with intermittent counter seiges - there is little combat in the field. Arguably, this mod provides a further counter incentive to combat in the field, since by moving troops out of the city, you not only risk losing them, but cultural influence at the same time. The addition of a "spread culture" action would defeat this incentive scheme. It would also make border skirmishes a thing of reality and grant a real role to forts (to station troops in along the border).

In any case, the mod looks great and I'm looking forward to trying it.
 
Newbert said:
One suggestion, though. Would it be possible to create a unit action, that would allow a unit to spread a certain amount of cultural influence without engaging in combat? (To prevent abuse, you could limit this ability only to certain unit types, attach it to a promotion and restrict its use depending on proximity to enemy units, for example.) This would be no more tedious than pillaging.
It looks like you "share" my mind! ;) I also dislike too big "siege action" and little field combat. I have similar idea for the next version: I plan to introduce small "culture transfer" from pillaging. This idea may look “too cheap" way how to increase your culture but is has several advantages:
  • No need to teach AI how to use new strategies because it already "loves" pillaging. I think this will increase AI performance in wars.
  • This way I will limit a number of influence actions in single square, because you can pillage given tile only 1 or 2 times, It should not be possible to overuse/abuse it.
  • As you already said: it provides incentive to "defend" your territory instead just staying in the cities.
Note: Pillage influence will occur in pillaged square only, adjacent tiles are not affected.

I will wait with next version of this mod until Warlords patch is available. I hope is will be sometimes in the next weeks.
 
Quijote said:
This might be an obvious question, but will the computer not suffer from a miscalculation on how conquer a city? I mean the city - based on the Active City Resistance - will get a bonus, and thus the computer opponents must calculate that there might be a need for a larger army to conquer a specific city.
Also you may question the realism of the likeness of civilian resistance killing armies.
Effect of militia is actually very small: single full strength "regular” unit can kill at least 5(?) "militias" with 25% health. Really, militias can only slow down the city capture: combat calculator almost always shows 100% for attacker.
Nevertheless, I will check AI sources to see what I can do. Small increase of attacking force if city's resistance is high would be nice.
 
This sounds really cool. I like how cultural boarders have a more front line quality to it. In regards to that, if you were to place some units on the edge of your cultural boarder and fortify them, say for 10 turns before their attacked, should that factor into cultural switch? Meaning that tile would take longer to switch sides because of the strong military presence for the past 10 turns?
 
Top Bottom