From 3f2bfab67cef1eca076086c898e2e853aefaad23 Mon Sep 17 00:00:00 2001
From: Aaron Veden <veden@vedbyte.com>
Date: Fri, 10 Dec 2021 11:51:39 -0800
Subject: [PATCH] kamikaze settlers are 2.5x more likely during siege state

---
 changelog.txt         | 1 +
 libs/AIAttackWave.lua | 7 ++++++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/changelog.txt b/changelog.txt
index fbf6456..d961831 100644
--- a/changelog.txt
+++ b/changelog.txt
@@ -58,6 +58,7 @@ Date: 23. 11. 2021
     - Siege state no longer uses all spawners only pollution covered and active raid spawners (raid spawners are a status, not necessarily tied to raiding AI state)
     - Increased migration ai state chance at min temperament by 5% and if migration is disabled increased raiding to 70% chance
     - Increased siege chance to 60% chance between temperament (0.05, 0.20) and if migration is disabled increased raiding to 60%
+    - Settling group formed during AI siege state are 2.5x more likely to be kamikaze
   Bugfixes:
     - Fixed chunks not processed due to chunk not being actually generated by game engine. You may notice a small delay before the spawners and worms convert to Rampant new enemy versions.
     - Fixed vengence squads only processing half the expected chunks
diff --git a/libs/AIAttackWave.lua b/libs/AIAttackWave.lua
index dbd5744..c348ef4 100644
--- a/libs/AIAttackWave.lua
+++ b/libs/AIAttackWave.lua
@@ -240,7 +240,12 @@ function aiAttackWave.formSettlers(map, chunk)
                     if universe.NEW_ENEMIES then
                         squad.base = findNearbyBase(map, chunk)
                     end
-                    squad.kamikaze = map.random() < calculateKamikazeThreshold(foundUnits, universe)
+                    local kamikazeThreshold = calculateKamikazeThreshold(foundUnits, universe)
+                    if map.state == AI_STATE_SIEGE then
+                        kamikazeThreshold = kamikazeThreshold * 2.5
+                    end
+                    squad.kamikaze = map.random() < kamikazeThreshold
+
                     universe.builderCount = universe.builderCount + 1
                     map.points = map.points - AI_SETTLER_COST
                     if universe.aiPointsPrintSpendingToChat then