From 54300bb6252f7e54f9ac68213b0920e903d2e22c Mon Sep 17 00:00:00 2001
From: Svornost <11434-svornost@users.noreply.gitgud.io>
Date: Sun, 28 Jun 2020 20:19:04 -0700
Subject: [PATCH] Make recon error normal instead of linear, because that's how
 real statistical error works.  Remove $expectedEquip and $estimatedMen global
 variables.

---
 js/003-data/gameVariableData.js                |  3 ---
 src/Mods/SecExp/SecExpBackwardCompatibility.tw |  8 +-------
 src/Mods/SecExp/attackGenerator.tw             | 11 -----------
 src/Mods/SecExp/attackOptions.tw               | 14 ++++++++------
 4 files changed, 9 insertions(+), 27 deletions(-)

diff --git a/js/003-data/gameVariableData.js b/js/003-data/gameVariableData.js
index 98b66a44388..abd2b079514 100644
--- a/js/003-data/gameVariableData.js
+++ b/js/003-data/gameVariableData.js
@@ -505,11 +505,8 @@ App.Data.resetOnNGPlus = {
 	battleTurns: 0,
 	tacticsSuccessful: 0,
 	leaderWounded: 0,
-	/* 0=no wound, 1=mute, 2=blind, 3=amputee, 4=health */
 	gainedCombat: 0,
 	gainedWarfare: 0,
-	expectedEquip: 0,
-	estimatedMen: 0,
 	SFIntervention: 0,
 	rebellingID: [],
 	saveValid: 0,
diff --git a/src/Mods/SecExp/SecExpBackwardCompatibility.tw b/src/Mods/SecExp/SecExpBackwardCompatibility.tw
index 1be97c1e455..3d83d3eb82b 100644
--- a/src/Mods/SecExp/SecExpBackwardCompatibility.tw
+++ b/src/Mods/SecExp/SecExpBackwardCompatibility.tw
@@ -558,7 +558,7 @@
 	<<set $tacticsSuccessful = 0>>
 <</if>>
 <<if ndef $leaderWounded>>
-	<<set $leaderWounded = 0>>				/* 0=no wound, 1=mute, 2=blind, 3=amputee, 4=health */
+	<<set $leaderWounded = 0>>
 <</if>>
 <<if ndef $gainedCombat>>
 	<<set $gainedCombat = 0>>
@@ -566,12 +566,6 @@
 <<if ndef $gainedWarfare>>
 	<<set $gainedWarfare = 0>>
 <</if>>
-<<if ndef $expectedEquip>>
-	<<set $expectedEquip = 0>>
-<</if>>
-<<if ndef $estimatedMen>>
-	<<set $estimatedMen = 0>>
-<</if>>
 <<if ndef $SFIntervention>>
 	<<set $SFIntervention = 0>>
 <</if>>
diff --git a/src/Mods/SecExp/attackGenerator.tw b/src/Mods/SecExp/attackGenerator.tw
index 0a3b0b7c65d..9c9e19961b4 100644
--- a/src/Mods/SecExp/attackGenerator.tw
+++ b/src/Mods/SecExp/attackGenerator.tw
@@ -173,15 +173,4 @@
 			<</if>>
 		<</if>>
 	<</if>>
-
-	<<set $estimatedMen = Math.round($attackTroops * (1 + either(-1,1) * (random(3,4) - App.SecExp.battle.recon()) * 0.1))>>
-	<<if App.SecExp.battle.recon() == 3>>
-		<<set $expectedEquip = $attackEquip + random(-1,1)>>
-	<<elseif App.SecExp.battle.recon() == 2>>
-		<<set $expectedEquip = $attackEquip + random(-1,2)>>
-	<<elseif App.SecExp.battle.recon() == 1>>
-		<<set $expectedEquip = $attackEquip + random(-2,2)>>
-	<<else>>
-		<<set $expectedEquip = $attackEquip + random(-2,3)>>
-	<</if>>
 <</if>>
\ No newline at end of file
diff --git a/src/Mods/SecExp/attackOptions.tw b/src/Mods/SecExp/attackOptions.tw
index efee7d2cc43..3f9cf5ba9d1 100644
--- a/src/Mods/SecExp/attackOptions.tw
+++ b/src/Mods/SecExp/attackOptions.tw
@@ -147,6 +147,8 @@
 <</if>>
 <br><br>
 __Recon__:
+<<set _estimatedMen = normalRandInt($attackTroops, $attackTroops * (4 - App.SecExp.battle.recon()) * 0.05)>>
+<<set _expectedEquip = normalRandInt($attackEquip, (4 - App.SecExp.battle.recon()) * 0.25)>>
 <br>
 It seems your troops and your adversary will fight
 <<if $battleTerrain == "rural">>
@@ -177,16 +179,16 @@ It seems your troops and your adversary will fight
 <<else>>
 	Your recon capabilities are almost non-existent. The information collected will be wild guesses at best:
 <</if>>
-approximately <strong><<print $estimatedMen>> men</strong> are coming, they seem to be
-<<if $expectedEquip <= 0>>
+approximately <strong><<print _estimatedMen>> men</strong> are coming, they seem to be
+<<if _expectedEquip <= 0>>
 	<strong>poorly armed</strong>. Old rusty small arms are the norm with just a few barely working civilian vehicles.
-<<elseif $expectedEquip == 1>>
+<<elseif _expectedEquip == 1>>
 	<strong>lightly armed</strong>, mostly with small arms and some repurposed civilian vehicles with scattered machine gun support. There's no sign of heavy vehicles, artillery or aircraft.
-<<elseif $expectedEquip == 2>>
+<<elseif _expectedEquip == 2>>
 	<strong>decently armed</strong> with good quality small arms, machine guns and a few mortars. There appear to be some heavy military vehicles coming as well.
-<<elseif $expectedEquip == 3>>
+<<elseif _expectedEquip == 3>>
 	<strong>well armed</strong> with high quality small arms, snipers, demolitions teams, heavy duty machine guns and mortars. Heavy military vehicles are numerous and a few artillery pieces are accompanying the detachment.
-<<elseif $expectedEquip >= 4>>
+<<elseif _expectedEquip >= 4>>
 	<strong>extremely well armed</strong> with excellent small arms and specialized teams with heavy duty infantry support weapons. Heavy presence of armored military vehicles, artillery pieces and even some attack helicopters.
 <</if>>
 
-- 
GitLab