From 14b040b51de2c91bd31a96f5986d36bbe2e2a64e Mon Sep 17 00:00:00 2001
From: hexall90 <hexall90@gmail.com>
Date: Mon, 29 Jan 2018 15:07:28 +0100
Subject: [PATCH] adding option for major battles

---
 src/SecExp/SecExpBackwardCompatibility.tw |  3 ++
 src/SecExp/attackGenerator.tw             |  9 +++--
 src/SecExp/rebellionGenerator.tw          |  8 +++++
 src/SecExp/secExpOptions.tw               | 43 +++++++++++++++++++++++
 src/SecExp/secInit.tw                     |  1 +
 5 files changed, 62 insertions(+), 2 deletions(-)

diff --git a/src/SecExp/SecExpBackwardCompatibility.tw b/src/SecExp/SecExpBackwardCompatibility.tw
index 5cc80af14c0..dbd4f433a89 100644
--- a/src/SecExp/SecExpBackwardCompatibility.tw
+++ b/src/SecExp/SecExpBackwardCompatibility.tw
@@ -109,6 +109,9 @@
 <<if ndef $rebellionSpeed>>
 <<set $rebellionSpeed = 1>>
 <</if>>
+<<if ndef $majorBattleMult>>
+<<set $majorBattleMult = 1>>
+<</if>>
 
 /* edicts */
 <<if ndef $edictsUpkeep>>
diff --git a/src/SecExp/attackGenerator.tw b/src/SecExp/attackGenerator.tw
index b9931a6cd48..a0cc052844a 100644
--- a/src/SecExp/attackGenerator.tw
+++ b/src/SecExp/attackGenerator.tw
@@ -234,8 +234,13 @@
 	<<if ($week >= 120 && $attackType != "none") || ($forceMajorBattle == 1 && $foughtThisWeek == 0)>>
 		<<if random(1,100) >= 50 || $forceMajorBattle == 1>>
 			<<set $majorBattle = 1>>
-			<<set $attackTroops *= random(4,6)>>
-			<<set $attackEquip = either(3,4)>>
+			<<if $securityForceCreate == 1>>
+				<<set $attackTroops = Math.trunc($attackTroops * random(4,6) * $majorBattleMult)>>
+				<<set $attackEquip = either(3,4)>>
+			<<else>>
+				<<set set $attackTroops = Math.trunc($attackTroops * random(2,3) * $majorBattleMult)>>
+				<<set $attackEquip = either(2,3,4)>>
+			<</if>>
 			<<set $estimatedMen = Math.round($attackTroops * (1 + either(-1,1) * (random(3,4) - $recon) * 0.1))>>
 			<<if $recon == 3>>
 				<<set $expectedEquip = $attackEquip + random(-1,1)>>
diff --git a/src/SecExp/rebellionGenerator.tw b/src/SecExp/rebellionGenerator.tw
index 8f2a024cabb..21098c61c8b 100644
--- a/src/SecExp/rebellionGenerator.tw
+++ b/src/SecExp/rebellionGenerator.tw
@@ -17,6 +17,8 @@
 	Your high authority does not allow slaves to think too freely.<<set _slave += 10>>
 <<elseif $authority <= 18000>>
 	Your very high authority does not allow slaves to think too freely.<<set _slave += 5>>
+<<else>>
+	Your absolute authority does not allow slaves to have a single free thought.
 <</if>>
 <<if _CSratio <= 0.2>>
 	There are a lot more slaves than citizens, making some doubt their masters are strong enough to stop them.<<set _slave += 30>>
@@ -30,6 +32,8 @@
 	There are less slaves than citizens, making some doubt they would be strong enough to defeat their masters.<<set _slave += 10>>
 <<elseif _CSratio >= 1.2>>
 	There are less slaves than citizens, making some doubt they would be strong enough to defeat their masters.<<set _slave -= 5>>
+<<else>>
+	Citizen and slave population is sufficiently balanced not ot cause problems either way.
 <</if>>
 <<if $security <= 10>>
 	The very low security of the arcology leaves free space for slaves to organize and agitate.<<set _slave += 30>>
@@ -39,6 +43,8 @@
 	The moderate security of the arcology does not allow free space for slaves to organize and agitate.<<set _slave += 10>>
 <<elseif $security >= 90>>
 	The high security of the arcology does not allow free space for slaves to organize and agitate.<<set _slave -= 5>>
+<<else>>
+	The high security of the arcology does not allow free space for slaves to organize and agitate.
 <</if>>
 <<if $arcologies[0].FSDegradationist != "unset">>
 	Many slaves are so disgusted by your degradationist society, that are willing to rise up against their masters to escape.<<set _slave += 30>>
@@ -69,6 +75,8 @@
 	Your high authority does not allow your citizens to think too freely.<<set _citizen += 10>>
 <<elseif $authority <= 18000>>
 	Your very high authority does not allow your citizens to think too freely.<<set _citizen += 5>>
+<<else>>
+	Your absolute authority does not allow your citizens to have a single free thought.
 <</if>>
 <<if $crime >= 90>>
 	The very high crime level of the arcology breeds extreme discontent between your citizens.<<set _citizen += 30>>
diff --git a/src/SecExp/secExpOptions.tw b/src/SecExp/secExpOptions.tw
index bb0b92cbdea..cef1467d494 100644
--- a/src/SecExp/secExpOptions.tw
+++ b/src/SecExp/secExpOptions.tw
@@ -349,6 +349,49 @@ __Battles frequency__:
 <</link>>
 <br>
 <br>
+__Major battle multiplier__:
+<br>Major battle multiplier is set to:<span id="majorBattleMult">
+<<if $majorBattleMult == 0.5>>
+	@@.green;Very low@@
+<<elseif $majorBattleMult == 0.75>>
+	@@.limegreen;Low@@
+<<elseif $majorBattleMult == 1>>
+	@@.yellow;Normal@@
+<<elseif $majorBattleMult == 1.25>>
+	@@.red;high@@
+<<else>>
+	@@.darkred;Very high@@
+<</if>>
+</span>
+<br>
+<<link "Very low">>
+	<<set $majorBattleMult = 0.5>>
+	<<replace "#majorBattleMult">>
+		@@.green;Very low@@
+	<</replace>>
+<</link>> | <<link "Low">>
+	<<set $majorBattleMult = 0.75>>
+	<<replace "#majorBattleMult">>
+		@@.limegreen;Low@@
+	<</replace>>
+<</link>> | <<link "Normal">>
+	<<set $majorBattleMult = 1>>
+	<<replace "#majorBattleMult">>
+		@@.yellow;Normal@@
+	<</replace>>
+<</link>> | <<link "High">>
+	<<set $majorBattleMult = 1.25>>
+	<<replace "#majorBattleMult">>
+		@@.red;High@@
+	<</replace>>
+<</link>> | <<link "Very high">>
+	<<set $majorBattleMult = 1.5>>
+	<<replace "#majorBattleMult">>
+		@@.darkred;Very high@@
+	<</replace>>
+<</link>>
+<br>
+<br>
 __Rebellions buildup speed__:
 <br>Rebellion speed is set to:<span id="rebellionSpeed">
 <<if $rebellionSpeed == 0.5>>
diff --git a/src/SecExp/secInit.tw b/src/SecExp/secInit.tw
index fe2c0b31c56..b2a07a44c57 100644
--- a/src/SecExp/secInit.tw
+++ b/src/SecExp/secInit.tw
@@ -37,6 +37,7 @@
 <<set $allowPrestigeFromBattles = 1>>
 <<set $battleFrequency = 1>>
 <<set $rebellionSpeed = 1>>
+<<set $majorBattleMult = 1>>
 
 /* edicts */
 <<set $edictsUpkeep = 0>>
-- 
GitLab