From 593ee687ebbf71f7e26e5c6085de541f995f87f5 Mon Sep 17 00:00:00 2001
From: hexall90 <hexall90@gmail.com>
Date: Tue, 19 Sep 2017 20:29:55 +0200
Subject: [PATCH] advances in attackReport

---
 src/SecExp/SecExpBackwardCompatibility.tw |   6 +
 src/SecExp/attackHandler.tw               |  15 +-
 src/SecExp/attackOptions.tw               |  20 +-
 src/SecExp/attackReport.tw                | 380 ++++++++++++++++++----
 src/SecExp/secInit.tw                     |   4 +
 5 files changed, 357 insertions(+), 68 deletions(-)

diff --git a/src/SecExp/SecExpBackwardCompatibility.tw b/src/SecExp/SecExpBackwardCompatibility.tw
index 640eb59b101..e2505b54dca 100644
--- a/src/SecExp/SecExpBackwardCompatibility.tw
+++ b/src/SecExp/SecExpBackwardCompatibility.tw
@@ -92,8 +92,14 @@
 <<if ndef $battleTurns>>
 	<<set $battleTurns = 0>>
 <</if>>
+<<if ndef $bribeCost>>
+	<<set $bribeCost = 0>>
+<</if>>
+
 	
 /* statistics | since these won't get modified in game, it's not necessary to check if they are defined */
+<<set $baseBribePerAttacker = 5>>
+
 <<set $equipMod = 0.15>>
 <<set $secBotsBaseAttack = 9>>
 <<set $secBotsBaseDefense = 5>>
diff --git a/src/SecExp/attackHandler.tw b/src/SecExp/attackHandler.tw
index a3c9c1edea3..eefd27f7c9b 100644
--- a/src/SecExp/attackHandler.tw
+++ b/src/SecExp/attackHandler.tw
@@ -1,6 +1,6 @@
 :: attackHandler [nobr]
 
-<<if $battleResult != 1 || $battleResult != -1>>		/* if the player did not select bribe or surrender */
+<<if $battleResult != 1 && $battleResult != -1>>		/* if the player did not select bribe or surrender */
 /*Init*/
 <<set _turn = 0>>
 <<set _attack = 0>>
@@ -518,8 +518,17 @@ Debug:
 		<<set $battleResult = -2>>
 	<</if>>
 <</if>>
-<<else>>											/* bribe/surrender code */
-	Debug: bribe/surrender
+<<else>>
+	Debug: bribery/surrender chosen
+	<<if $cash >= $bribeCost>>						/* if there's enough cash there's a 10% chance bribery fails. If there isn't there's instead a 50% chance it fails */
+		<<if random(1,100) <= 10>>
+			<<set $battleResult = 0>>
+		<</if>>
+	<<else>>
+		<<if random(1,100) <= 50>>
+			<<set $battleResult = 0>>
+		<</if>>
+	<</if>>
 <</if>>												/* closes bribe/surrender check */
 
 <<if $battleResult > 3 || $battleResult < -3>>
diff --git a/src/SecExp/attackOptions.tw b/src/SecExp/attackOptions.tw
index 8349da6e6c9..d0bbc34bad7 100644
--- a/src/SecExp/attackOptions.tw
+++ b/src/SecExp/attackOptions.tw
@@ -1,5 +1,7 @@
 :: attackOptions [nobr]
 
+
+
 <strong>Attack Imminent</strong>
 <hr>
 The ominous message dominates the screens of your office, <<print $assistantName>> quickly gathers all information available to prepare your arcology for battle.
@@ -209,7 +211,7 @@ With your current readiness level you can <<if $deployedUnits > 0>>still<</if>>
 <<set _sL = $slaveUnits.length>>
 <<set _meL = $mercUnits.length>>
 <<if $deployableUnits > 0>>
-		<<if $secBots.isDeployed == 0 && $secBots.troops > 0>>
+		<<if $secBots.active == 1 && $secBots.isDeployed == 0 && $secBots.troops > 0>>
 			<br>
 			<<secBotsDescription>>
 			<br>
@@ -416,7 +418,21 @@ Offensive Tactics
 	<<goto "attackHandler">>
 <</link>>
 <br>
+/* calculates bribe cost */
+<<if $week <= 30>>
+	<<set $bribeCost = 5000 + $baseBribePerAttacker * $attackTroops>>
+<<elseif $week <= 30>>
+	<<set $bribeCost = 10000 + $baseBribePerAttacker * $attackTroops>>
+<<elseif $week <= 30>>
+	<<set $bribeCost = 15000 + $baseBribePerAttacker * $attackTroops>>
+<<elseif $week <= 30>>
+	<<set $bribeCost = 20000 + $baseBribePerAttacker * $attackTroops>>
+<<elseif $week <= 30>>
+	<<set $bribeCost = 25000 + $baseBribePerAttacker * $attackTroops>>
+<</if>>
+
 <<link "Attempt to bribe">>
 	<<set $battleResult = 1>>
 	<<goto "attackHandler">>
-<</link>>
\ No newline at end of file
+<</link>>
+<br>&nbsp;&nbsp;&nbsp;&nbsp;//Will cost around ¤<<print Math.round($bribeCost * (1 + either(-1,1) * random(2) * 0.1))>>.//
\ No newline at end of file
diff --git a/src/SecExp/attackReport.tw b/src/SecExp/attackReport.tw
index 8f824e1b006..7b91a7af930 100644
--- a/src/SecExp/attackReport.tw
+++ b/src/SecExp/attackReport.tw
@@ -25,7 +25,7 @@
 <<set $losses = Math.round($losses)>>
 
 <<if $attackType == "raiders">>
-	Today, the $day of $month, $year, our arcology was attacked by a band of wild raiders, $attackTroops men strong. Our defense forces clashed with them 
+	Today, the $day of $month $year, our arcology was attacked by a band of wild raiders, $attackTroops men strong. Our defense forces clashed with them 
 	<<if $battleTerrain == "urban">>
 		in the streets of <<if $terrain == "urban">>the old world city surrounding the arcology<<else>>of the free city<</if>>,
 		<<elseif $battleTerrain == "rural">>
@@ -41,7 +41,7 @@
 	<<elseif $battleTerrain == "wasteland">>
 		in the wastelands outside the free city territory,
 	<</if>>
-	inflicting $enemyLosses casualties, while sustaining $losses casualties themselves.
+	inflicting <<print $enemyLosses>> casualties, while sustaining <<print $losses>> casualties themselves.
 	<<if $battleResult == 3>>
 		<<if $battleTurns <= 5>>
 			The fight was quick and one sided, our men easily stopped the disorganized horde futile attempt at raiding your arcology
@@ -77,8 +77,11 @@
 	<<elseif $battleResult == -2>>
 		The fight was long and hard. Our men in the end had to yield to the horde raiders, which was fortunately unable to capitalized on their victory.
 	<<elseif $battleResult == -1>>
+		You gave your troops the order to surrender, obediently they stand down.
 	<<elseif $battleResult == 0>>
+		You decided in favor of a financial approach rather than open hostilities. Your troops remain inside the arcology's walls.
 	<<elseif 4battleResult == 1>>
+		You decided in favor of a financial approach rather than open hostilities. Your troops remain inside the arcology's walls.
 	<</if>>
 <<elseif $attackType == "free city">>
 	Today, the $day of $month, $year, our arcology was attacked by a contingent of mercenaries hired by a competing free city, $attackTroops men strong. Our defense forces clashed with them 
@@ -97,7 +100,7 @@
 	<<elseif $battleTerrain == "wasteland">>
 		in the wastelands outside the free city territory,
 	<</if>>
-	inflicting $enemyLosses casualties, while sustaining $losses casualties themselves.
+	inflicting <<print $enemyLosses>> casualties, while sustaining <<print $losses>> casualties themselves.
 	<<if $battleResult == 3>>
 		<<if $battleTurns <= 5>>
 			The fight was quick and one sided, our men easily stopped the mercenaries dead in their tracks
@@ -133,8 +136,11 @@
 	<<elseif $battleResult == -2>>
 		The fight was long and hard. Our men in the end had to yield to the slavers, which were fortunately unable to capitalized on their victory.
 	<<elseif $battleResult == -1>>
+		You gave your troops the order to surrender, obediently they stand down.
 	<<elseif $battleResult == 0>>
+		You decided in favor of a financial approach rather than open hostilities. Your troops remain inside the arcology's walls.
 	<<elseif 4battleResult == 1>>
+		You decided in favor of a financial approach rather than open hostilities. Your troops remain inside the arcology's walls.
 	<</if>>
 <<elseif $attackType == "freedom fighters">>
 	Today, the $day of $month, $year, our arcology was attacked by a group of freedom fighters bent on the destruction of the institution of slavery, $attackTroops men strong. Our defense forces clashed with them 
@@ -153,7 +159,7 @@
 	<<elseif $battleTerrain == "wasteland">>
 		in the wastelands outside the free city territory,
 	<</if>>
-	inflicting $enemyLosses casualties, while sustaining $losses casualties themselves.
+	inflicting <<print $enemyLosses>> casualties, while sustaining <<print $losses>> casualties themselves.
 	<<if $battleResult == 3>>
 		<<if $battleTurns <= 5>>
 			The fight was quick and one sided, our men easily stopped the freedom fighters dead in their tracks
@@ -189,11 +195,14 @@
 	<<elseif $battleResult == -2>>
 		The fight was long and hard. Our men in the end had to yield to the freedom figthers, which were fortunately unable to capitalized on their victory.
 	<<elseif $battleResult == -1>>
+		You gave your troops the order to surrender, obediently they stand down.
 	<<elseif $battleResult == 0>>
+		You decided in favor of a financial approach rather than open hostilities. Your troops remain inside the arcology's walls.
 	<<elseif 4battleResult == 1>>
+		You decided in favor of a financial approach rather than open hostilities. Your troops remain inside the arcology's walls.
 	<</if>>
 <<elseif $attackType == "old world">>
-	Today, the $day of $month, $year, our arcology was attacked by an old world nation, boasting a misplaced sense of superiority, $attackTroops men strong. Our defense forces clashed with them 
+	Today, the $day of $month, $year, our arcology was attacked by an old world nation boasting a misplaced sense of superiority, $attackTroops men strong. Our defense forces clashed with them 
 	<<if $battleTerrain == "urban">>
 		in the streets of <<if $terrain == "urban">>the old world city surrounding the arcology<<else>>of the free city<</if>>,
 	<<elseif $battleTerrain == "rural">>
@@ -209,7 +218,7 @@
 	<<elseif $battleTerrain == "wasteland">>
 		in the wastelands outside the free city territory,
 	<</if>>
-	inflicting $enemyLosses casualties, while sustaining $losses casualties themselves.
+	inflicting <<print $enemyLosses>> casualties, while sustaining <<print $losses>> casualties themselves.
 	<<if $battleResult == 3>>
 		<<if $battleTurns <= 5>>
 			The fight was quick and one sided, our men easily stopped the old world soldiers dead in their tracks
@@ -245,60 +254,64 @@
 	<<elseif $battleResult == -2>>
 		The fight was long and hard. Our men in the end had to yield to the old world soldiers, which were fortunately unable to capitalized on their victory.
 	<<elseif $battleResult == -1>>
+		You gave your troops the order to surrender, obediently they stand down.
 	<<elseif $battleResult == 0>>
+		You decided in favor of a financial approach rather than open hostilities. Your troops remain inside the arcology's walls.
 	<<elseif 4battleResult == 1>>
+		You decided in favor of a financial approach rather than open hostilities. Your troops remain inside the arcology's walls.
 	<</if>>
 <</if>>
-<br>
+<br><br>
 /* calculates effects on the city */
 <<if $battleResult == 3>>
 	Thanks to your victory, your @@.green;reputation@@ and @@.gray;authority@@ increased. You were also able to capture
-		<<if $attackType == "raiders">>
-			<<set $rep += 800>>
-			<<set $authority += 800>>
-		<<elseif $attackType == "free city">>
-			<<set $rep += 1200>>
-			<<set $authority += 1200>>
-		<<elseif $attackType == "freedom fighters">>
-			<<set $rep += 1500>>
-			<<set $authority += 1500>>
+	<<if $attackType == "raiders">>
+		<<set $rep += 800>>
+		<<set $authority += 800>>
+	<<elseif $attackType == "free city">>
+		<<set $rep += 1200>>
+		<<set $authority += 1200>>
+	<<elseif $attackType == "freedom fighters">>
+		<<set $rep += 1500>>
+		<<set $authority += 1500>>
 		<<elseif $attackType == "old world">>
-			<<set $rep += 1200>>
-			<<set $authority += 1200>>
-		<</if>>
-		<<if $attackTroops - $enemyLosses <= 50>>
-			a small amount of attackers,
-			<<set _captives = ($attackTroops - $enemyLosses) * 0.1 * random(1,3)>>
-		<<elseif $attackTroops - $enemyLosses <= 100>>
-			an healthy group of attackers,
-			<<set _captives = ($attackTroops - $enemyLosses) * 0.1 * random(1,3)>>
-		<<elseif $attackTroops - $enemyLosses <= 150>>
-			a big group of attackers,
-			<<set _captives = ($attackTroops - $enemyLosses) * 0.1 * random(1,3)>>
-		<<elseif $attackTroops - $enemyLosses <= 200>>
-			a huge group of attackers,
-			<<set _captives = ($attackTroops - $enemyLosses) * 0.1 * random(1,3)>>
-		<<elseif $attackTroops - $enemyLosses > 200>>
-			a great amount of attackers,
-			<<set _captives = ($attackTroops - $enemyLosses) * 0.1 * random(1,3)>>
-		<</if>>
-		and some of their equipment, which once sold produced
-		<<if attackEquip == 0>>
-			@@.yellowgreen;a small amount of cash.@@
-			<<set $cash += 1000>>
-		<<elseif $attackEquip == 1>>
-			@@.yellowgreen;a moderate amount of cash.@@
-			<<set $cash += 5000>>
-		<<elseif $attackEquip == 2>>
-			@@.yellowgreen;a good amount of cash.@@
-			<<set $cash += 10000>>
-		<<elseif $attackEquip == 3>>
-			@@.yellowgreen;a great amount of cash.@@
-			<<set $cash += 15000>>
-		<<elseif $attackEquip == 4>>
-			@@.yellowgreen;wealth worthy of the mightiest warlord.@@
-			<<set $cash += 20000>>
-		<</if>>
+	<<set $rep += 1200>>
+		<<set $authority += 1200>>
+	<</if>>
+	<<if $attackTroops - $enemyLosses <= 50>>
+		a small amount of attackers,
+		<<set _captives = ($attackTroops - $enemyLosses) * 0.1 * random(1,3)>>
+	<<elseif $attackTroops - $enemyLosses <= 100>>
+		an healthy group of attackers,
+		<<set _captives = ($attackTroops - $enemyLosses) * 0.1 * random(1,3)>>
+	<<elseif $attackTroops - $enemyLosses <= 150>>
+		a big group of attackers,
+		<<set _captives = ($attackTroops - $enemyLosses) * 0.1 * random(1,3)>>
+	<<elseif $attackTroops - $enemyLosses <= 200>>
+		a huge group of attackers,
+		<<set _captives = ($attackTroops - $enemyLosses) * 0.1 * random(1,3)>>
+	<<elseif $attackTroops - $enemyLosses > 200>>
+		a great amount of attackers,
+		<<set _captives = ($attackTroops - $enemyLosses) * 0.1 * random(1,3)>>
+	<</if>>
+	and some of their equipment, which once sold produced
+	<<if attackEquip == 0>>
+		@@.yellowgreen;a small amount of cash.@@
+		<<set $cash += 1000>>
+	<<elseif $attackEquip == 1>>
+		@@.yellowgreen;a moderate amount of cash.@@
+		<<set $cash += 5000>>
+	<<elseif $attackEquip == 2>>
+		@@.yellowgreen;a good amount of cash.@@
+		<<set $cash += 10000>>
+	<<elseif $attackEquip == 3>>
+		@@.yellowgreen;a great amount of cash.@@
+		<<set $cash += 15000>>
+	<<elseif $attackEquip == 4>>
+		@@.yellowgreen;wealth worthy of the mightiest warlord.@@
+		<<set $cash += 20000>>
+	<</if>>
+	<br>
 	@@.red;Damage to the city was virtually non-existent@@, costing only pocket cash to bring the structure back to normal. The inhabitants as well reported little to no injuries, because of this the prosperity of the arcology did not suffer.
 	<<set $cash -= 1000>>
 	<<if $PCvictoryStreak >= 3>>
@@ -306,7 +319,7 @@
 		<<set $arcologies[0].prosperity += 5>>
 	<</if>>
 <<elseif $battleResult == -3>>
-	Due to your defeat, your your @@.red;reputation@@ and @@.red;authority@@ decreased. Obviously your troops were not able to capture anyone or anything.
+	Due to your defeat, your @@.red;reputation@@ and @@.red;authority@@ decreased. Obviously your troops were not able to capture anyone or anything.
 	<<if $attackType == "raiders">>
 		<<set $rep -= 400>>
 		<<set $authority -= 400>>
@@ -320,6 +333,7 @@
 		<<set $rep -= 600>>
 		<<set $authority -= 600>>
 	<</if>>
+	<br>
 	In the raiding following the battle @@.red;the arcology sustained heavy damage@@, which will cost quite the amount of cash to fix. Reports of @@.red;citizens or slaves killed or missing@@ flood your office for a few days following the defeat.
 	<<set $cash -= 5000>>
 	<<if $week <= 30>>
@@ -345,32 +359,212 @@
 	<</if>>
 	<<if $PClossStreak >= 3>>
 		This only confirms the fears of many, @@.red;your arcology is not safe@@ and it is clear their business will be better somewhere else.
-		<<set $arcologies[0].prosperity += 5>>
+		<<set $arcologies[0].prosperity -= 5>>
 	<</if>>
 <<elseif $battleResult == 2>>
-	<strong>Partial victory!</strong>
+	Thanks to your victory, your @@.green;reputation@@ and @@.gray;authority@@ slightly increased. Our men were not able to capture any attacker, however some equipment was seized during the enemy hasty retreat, 
+	<<if $attackType == "raiders">>
+		<<set $rep += 200>>
+		<<set $authority += 200>>
+	<<elseif $attackType == "free city">>
+		<<set $rep += 300>>
+		<<set $authority += 300>>
+	<<elseif $attackType == "freedom fighters">>
+		<<set $rep += 450>>
+		<<set $authority += 450>>
+	<<elseif $attackType == "old world">>
+		<<set $rep += 300>>
+		<<set $authority += 300>>
+	<</if>>
+	which once sold produced
+	<<if $attackEquip == 0>>
+		@@.yellowgreen;a bit of cash.@@
+		<<set $cash += 500>>
+	<<elseif $attackEquip == 1>>
+		@@.yellowgreen;a small amount of cash.@@
+		<<set $cash += 2500>>
+	<<elseif $attackEquip == 2>>
+		@@.yellowgreen;a moderate amount of cash.@@
+		<<set $cash += 5000>>
+	<<elseif $attackEquip == 3>>
+		@@.yellowgreen;a good amount of cash.@@
+		<<set $cash += 7500>>
+	<<elseif $attackEquip == 4>>
+		@@.yellowgreen;a great amount of cash.@@
+		<<set $cash += 10000>>
+	<</if>>
+	<br>
+	Damage to the city was @@.red;limited@@, it won't take much to rebuild. Very few citizens or slaves were involved in the fight and even fewer met their end, safeguarding the prosperity of the arcology.
+	<<set $cash -= 2000>>
+	<<set $ACitizens -= random(10)>>
+	<<set $ASlaves -= random(20)>>
 <<elseif $battleResult == -2>>
-	<strong>Partial defeat!</strong>
+	It was a close defeat, but nonetheless your @@.red;reputation@@ and @@.red;authority@@ slightly decreased. Your troops were not able to capture anyone or anything.
+	<<if $attackType == "raiders">>
+		<<set $rep -= 40>>
+		<<set $authority -= 40>>
+	<<elseif $attackType == "free city">>
+		<<set $rep -= 60>>
+		<<set $authority -= 60>>
+	<<elseif $attackType == "freedom fighters">>
+		<<set $rep -= 75>>
+		<<set $authority -= 75>>
+	<<elseif $attackType == "old world">>
+		<<set $rep -= 60>>
+		<<set $authority -= 60>>
+	<</if>>
+	<br>
+	The enemy did not have the strenght to raid the arcology for long, still @@.red;the arcology sustained some damage damage@@, which will cost a moderate amount of cash to fix. Some citizens and slaves found themselves on the wrong end of a gun and met their demise.
+	Some business sustained heavy damage, slightly impacting the arcology's prosperity.
+	<<set $cash -= 3000>>
+	<<if $week <= 30>>
+		<<set $ACitizens -= random(50)>>
+		<<set $ASlaves -= random(75)>>
+		<<set $arcologies[0].prosperity -= random(2)>>
+	<<elseif $week <= 60>>
+		<<set $ACitizens -= random(60)>>
+		<<set $ASlaves -= random(65)>>
+		<<set $arcologies[0].prosperity -= random(5)>>
+	<<elseif $week <= 90>>
+		<<set $ACitizens -= random(70)>>
+		<<set $ASlaves -= random(95)>>
+		<<set $arcologies[0].prosperity -= random(7)>>
+	<<elseif $week <= 120>>
+		<<set $ACitizens -= random(80)>>
+		<<set $ASlaves -= random(105)>>
+		<<set $arcologies[0].prosperity -= random(10)>>
+	<<else>>
+		<<set $ACitizens -= random(90)>>
+		<<set $ASlaves -= random(115)>>
+		<<set $arcologies[0].prosperity -= random(12)>>
+	<</if>>
 <<elseif $battleResult == -1>>
-	<strong>We surrendered</strong>
+	Rather than waste the lives of your men you decided to surrender, hoping your enemy will cause less damage if you indulge them, this is however a big hit to your status. Your @@.red;reputation@@ and @@.red;authority@@ are significantly impacted. 
+	<<if $attackType == "raiders">>
+		<<set $rep -= 600>>
+		<<set $authority -= 600>>
+	<<elseif $attackType == "free city">>
+		<<set $rep -= 800>>
+		<<set $authority -= 800>>
+	<<elseif $attackType == "freedom fighters">>
+		<<set $rep -= 1000>>
+		<<set $authority -= 1000>>
+	<<elseif $attackType == "old world">>
+		<<set $rep -= 800>>
+		<<set $authority -= 800>>
+	<</if>>
+	<br>
+	The surrender allows the arcology to survive @@.red;mostly intact@@, however reports of @@.red;mass looting and killing of citizens@@ flood your office for a few days. 
+	<<set $cash -= 1000>>
+	<<if $week <= 30>>
+		<<set $ACitizens -= random(80)>>
+		<<set $ASlaves -= random(120)>>
+		<<set $arcologies[0].prosperity -= random(5)>>
+	<<elseif $week <= 60>>
+		<<set $ACitizens -= random(100)>>
+		<<set $ASlaves -= random(140)>>
+		<<set $arcologies[0].prosperity -= random(10)>>
+	<<elseif $week <= 90>>
+		<<set $ACitizens -= random(120)>>
+		<<set $ASlaves -= random(160)>>
+		<<set $arcologies[0].prosperity -= random(15)>>
+	<<elseif $week <= 120>>
+		<<set $ACitizens -= random(140)>>
+		<<set $ASlaves -= random(180)>>
+		<<set $arcologies[0].prosperity -= random(20)>>
+	<<else>>
+		<<set $ACitizens -= random(160)>>
+		<<set $ASlaves -= random(190)>>
+		<<set $arcologies[0].prosperity -= random(25)>>
+	<</if>>
 <<elseif $battleResult == 0>>
-	<strong>We surrendered</strong>
+	Unfortunately your adversary did not accept your money. <<if $attackType == "freedom fighters">> Their ideological crusade would not allow such thing<<else>>They saw your attempt as nothing more than admission of weakness<</if>>. There was no time to organize a defense and so the enemy walked into the arcology as it was his.
+	Your reputation and authority suffer a hit.
+	<<if $attackType == "raiders">>
+		<<set $rep -= 400>>
+		<<set $authority -= 400>>
+	<<elseif $attackType == "free city">>
+		<<set $rep -= 600>>
+		<<set $authority -= 600>>
+	<<elseif $attackType == "freedom fighters">>
+		<<set $rep -= 750>>
+		<<set $authority -= 750>>
+	<<elseif $attackType == "old world">>
+		<<set $rep -= 600>>
+		<<set $authority -= 600>>
+	<</if>>
+	<br>
+	Fortunately the arcology survives @@.red;mostly intact@@, however reports of @@.red;mass looting and killing of citizens@@ flood your office for a few days. 
+	<<set $cash -= 1000>>
+	<<if $week <= 30>>
+		<<set $ACitizens -= random(80)>>
+		<<set $ASlaves -= random(120)>>
+		<<set $arcologies[0].prosperity -= random(5)>>
+	<<elseif $week <= 60>>
+		<<set $ACitizens -= random(100)>>
+		<<set $ASlaves -= random(140)>>
+		<<set $arcologies[0].prosperity -= random(10)>>
+	<<elseif $week <= 90>>
+		<<set $ACitizens -= random(120)>>
+		<<set $ASlaves -= random(160)>>
+		<<set $arcologies[0].prosperity -= random(15)>>
+	<<elseif $week <= 120>>
+		<<set $ACitizens -= random(140)>>
+		<<set $ASlaves -= random(180)>>
+		<<set $arcologies[0].prosperity -= random(20)>>
+	<<else>>
+		<<set $ACitizens -= random(160)>>
+		<<set $ASlaves -= random(190)>>
+		<<set $arcologies[0].prosperity -= random(25)>>
+	<</if>>
+	<br>
 <<elseif $battleResult == 1>>
-	<strong>We surrendered</strong>
+	The attackers wisely take the money offered them to leave your territory without further issues. The strenght of the free cities was never in their guns but in their dollars and today events are the perfect demonstration of such strenght.
+	Your @@.green;reputation slightly increases@@.
+	<<if $attackType == "raiders">>
+		<<set $rep += 100>>
+	<<elseif $attackType == "free city">>
+		<<set $rep += 150>>
+	<<elseif $attackType == "freedom fighters">>
+		<<set $rep += 200>>
+	<<elseif $attackType == "old world">>
+		<<set $rep += 150>>
+	<</if>>
+	<<set $cash -= $bribeCost>>
 <</if>>
 
+<br><br>
 
+leaders and tactical decisions 					/*to be done*/
 
+<br>
+
+/* effects on the units */
 <<if $losses > 0>>
 	<<set _loss = Math.trunc($losses / $deployedUnits)>>
 	<<if $deployingBots == 1>>
+		<br>
+		Your squadron of security drones participated in the battle, dominating the airspace and providing vital intelligence to the rest of the army.
 		<<set $secBots.troops -= _loss>>
+		<<if $secBots.troops <= 0>>
+			<<set $secBots.active = 0>>
+			Unfortunately the losses they took were simply too great, their effective combatants are in so small number you can no longer call them a deployable unit. It will take quite the investment to rebuild them. 
+		<</if>>
 	<</if>>
 	<<if $deployingMilitia == 1>>
 		<<set _mL = $militiaUnits.length>>
 		<<for _i = 0; _i < _mL; _i++>>
 			<<if $militiaUnits[_i].isDeployed == 1>>
-				<<set $militiaUnits[_i].troops -= (_loss - _loss * $militiaUnits[_i].medics * 0.25)>>
+				<br>
+				$militiaUnits[_i].platoonName participated in the battle, your proud citizens defending with their lives their arcology.
+				<<if $militiaUnits[_i].medics == 1>>
+					<<print math.trunc(_loss * $militiaUnits[_i].medics * 0.25)>> men were saved by the medics attached to this unit.
+					<<set $militiaUnits[_i].troops -= Math.trunc(_loss - _loss * $militiaUnits[_i].medics * 0.25)>>
+				<</if>>
+				<<if $militiaUnits[_i].troops <= 0>>
+					<<set $militiaUnits[_i].active = 0>>
+					Unfortunately the losses they took were simply too great, their effective combatants are in so small number you can no longer call them a deployable unit. The remnants will be sent home honored as veterans or reorganized in a new unit. 
+				<</if>>
 			<</if>>
 		<</for>>
 	<</if>>
@@ -378,7 +572,16 @@
 		<<set _sL = $slaveUnits.length>>
 		<<for _i = 0; _i < _sL; _i++>>
 			<<if $slaveUnits[_i].isDeployed == 1>>
-				<<set $slaveUnits[_i].troops -= (_loss - _loss * $slaveUnits[_i].medics * 0.25)>>
+				<br>
+				$slaveUnits[_i].platoonName participated in the battle. While a rare sight, your slave soldiers show no less willingness to fight for their arcology than their free counterparts, be it because of fear or devotion to their owner.
+				<<if $slaveUnits[_i].medics == 1>>
+					<<print math.trunc(_loss * $slaveUnits[_i].medics * 0.25)>> men were saved by the medics attached to this unit.
+					<<set $slaveUnits[_i].troops -= Math.trunc(_loss - _loss * $slaveUnits[_i].medics * 0.25)>>
+				<</if>>
+				<<if $slaveUnits.troops <= 0>>
+					<<set $slaveUnits[_i].active = 0>>
+					Unfortunately the losses they took were simply too great, their effective combatants are in so small number you can no longer call them a deployable unit. The remnants will be sent home honored as veterans or reorganized in a new unit. 
+				<</if>>
 			<</if>>
 		<</for>>
 	<</if>>
@@ -386,15 +589,66 @@
 		<<set _meL = $mercUnits.length>>
 		<<for _i = 0; _i < _meL; _i++>>
 			<<if $mercUnits[_i].isDeployed == 1>>
-				<<set $mercUnits[_i].troops -= (_loss - _loss * $mercUnits[_i].medics * 0.25)>>
+				<br>
+				$mercUnits[_i].platoonName participated in the battle. Mercenaries are a comon sight on the modern battlefield and yours are proud to serve their generous contractor.
+				<<if $mercUnits[_i].medics == 1>>
+					<<print math.trunc(_loss * $mercUnits[_i].medics * 0.25)>> men were saved by the medics attached to this unit.
+					<<set $mercUnits[_i].troops -= Math.trunc(_loss - _loss * $mercUnits[_i].medics * 0.25)>>
+				<</if>>
+				<<if $mercUnits.troops <= 0>>
+					<<set $mercUnits[_i].active = 0>>
+					Unfortunately the losses they took were simply too great, their effective combatants are in so small number you can no longer call them a deployable unit. The remnants will be sent home honored as veterans or reorganized in a new unit. 
+				<</if>>
 			<</if>>
 		<</for>>
 	<</if>>
 <</if>>
 
+<br><br>
 
+<<set _menialPrice = Math.trunc(($slaveCostFactor*1000)/100)*100>>
+<<set _menialPrice = Math.clamp(_menialPrice, 500, 1500)>>
 
-
+<<if _captives > 0>>
+	During the battle <<print _captives>> attackers were captured.
+	<<if random(1,100) <= 25>>
+		<<set _roll = random(1,100)>>
+		<<if _roll <= 33>>
+			Three of them appear to be decent sex slaves candidates.
+			<<set _candidates = 3>>
+			
+		<<elseif _roll <= 66>>
+			Two of them appear to be decent sex slaves candidates.
+			<<set _candidates = 2>>
+		<<else>>
+			One of them appears to be a decent sex slave candidate.
+			<<set _candidates = 1>>
+		<</if>>
+	<</if>>
+	<br>
+	<span id="captOptions">
+	<<link "sell them all immediately">>
+		<<set $cash += _menialPrice * _captives>>
+		<<replace "#captOptions">>Captives sold<</replace>>
+	<</link>>
+	|
+	<<link "Keep them as menial slaves">>
+		<<set $helots += _captives>>
+		<<replace "#captOptions">>Captives added as menial slaves<</replace>>
+	<</link>>
+	<<if _candidates > 0>>
+		|
+		<<link "keep them and sell the rest|not implemented">>
+		
+		<</link>>
+		|
+		<<link "keep them and keep the rest as menial slaves|not implemented">>
+		
+		<</link>>
+	<</if>>
+	</span>
+<</if>>
+	
 /* resets variables */
 <<set $attackType = "none">>
 <<set $chosenTactic = "none">>
diff --git a/src/SecExp/secInit.tw b/src/SecExp/secInit.tw
index df289e1a50d..9b91a0b2dfd 100644
--- a/src/SecExp/secInit.tw
+++ b/src/SecExp/secInit.tw
@@ -44,8 +44,12 @@
 <<set $losses = 0>>
 <<set $enemyLosses = 0>>
 <<set $battleTurns = 0>>
+<<set $bribeCost = 0>>
+
 
 /* statistics */
+<<set $baseBribePerAttacker = 5>>
+
 <<set $equipMod = 0.15>>
 <<set $secBotsBaseAttack = 9>>
 <<set $secBotsBaseDefense = 5>>
-- 
GitLab