AI Declares War

If you liked this item, please rate it up on Steam Workshop page.

Author: Think Critically

Last revision: 24 Oct, 2023 at 16:04 UTC

File size: 247.81 KB

On Steam Workshop

Description:
Welcome Back, Commanders

This is a script which forces AI to declare war against factions they have a low opinion of. I found that it increases the performance of the AI. Without a war target, AI can become passive and stagnate but once they have a goal they will form a true empire.

By default, the chance of a war declaration increases linearly from 0% to 100% as opinion decreases from -100 to -200. There are a variety of configurable features and I have added MCT support. The default settings are simple and what I recommend.

Using MCT, you can make my script behave identically to other War Declaration scripts, like making war declaration guaranteed at opinion -50 or making war declaration a constant 10% at opinion -150 like FiftyTifty’s removed script. However, MCT is not required for my mod to function.

Default Functionality

If the AI has an opinion lower than -100 towards a faction, then we will roll a random chance to see if we declare a war. The random chance is the absolute value of the opinion minus 100. -100 opinion means 0% chance, -110 opinion means 10% chance, -150 opinion means 50% chance, and -200 opinion means 100% chance. Higher than -100 opinion means we don’t roll so that is also 0%.

By default, the AI will declare war on humans AND AI. When war is declared, the attacker’s military allies and the defender’s allies will both join the war. This script will never force declare war on a vassal or rebel faction, and a rebel or vassal faction will never be forced to declare war. Additionally, a faction will never be forced to declare war on it’s own vassal, ally or client state.

This mod also detects the most recent peace treaty offer between two factions and will not force another war until 10 turns(configurable) after the peace treaty. When a peace offer is rejected, it doesn’t matter and when one is accepted it must be the most recent peace offer between those factions. Unfortunately, this does not detect when a script skips the offer and forces a peace treaty.

Finally, war will not be forcibly declared by a faction that is already in 4 or more wars. However, nothing stops other factions from forcing more than 4 wars on them. This script can only cause 1 war declaration per ai per turn to avoid issues.

MCT Settings

Target Human – Should the script make AI declare war on humans? Default: True
Invite Aggressor Allies – Should the script make AI attacker’s military allies join the war? Default: True
Invite Target Allies – Should the script make AI defender allies join the war? Default: True
Max Wars – If the AI is already in this many wars, it will not be forced to declare more. -1 is unlimited. Default: 4
Grace Turns After Peace – Wait this many turns before trying to force war between two factions who signed a peace treaty. Default: 10

When opinion is above the Base Opinion Threshold, this script will not run.

Scaling Mode

If Opinion Floor is lower then the Base Opinion Threshold, then scaling mode is enabled and the chance of a war declaration will linearly increase from the Base Chance to the Max Scaling Chance as opinion decreases from the Base Opinion Threshold to the Opinion Floor. Below the floor, the chance will be Max Scaling Chance. In between the threshold and the floor, the formula for chance of war declaration is:
((BaseOpinionThreshold – CurrentOpinion)/(BaseOpinionThreshold – OpinionFloor) * (MaxScalingChance – BaseChance)) + BaseChance

Fixed Mode

To disable scaling mode, set the Opinion Floor higher than Base Opinion or set Max Chance lower than Base Chance. When scaling mode is disabled, the chance of war declaration will simply be the base chance.

For example, to mimic FiftyTifty’s script which has a fixed 10% war chance below -150 opinion, use
Base Opinion Threshold: -150
Opinion Floor: -150
Base Chance: 10
Max Scaling Chance: 10
Opinion floor could be any number higher than -150 and scaling chance could be any number less than 10 and my error handling would make it act like this.

Compatibility

There should be no compatibility issues with any mods. This should work with AI overhauls because my mod directly declares war, it does not interfere with them. It also works with script based mods like Bring the Boys home. The only issues are with mods that FORCE peace. You can still use them and it will not break your campaign. I believe it is multiplayer-safe and also safe to remove or add during a campaign but I could be wrong. Let me know in the comments if it works or doesn’t work for those cases.

Inspired by Make AI declare war on other AI more often
All my mods are compatible with SFO.