From 51dc2b911ca6c04eaa69ea599427f2c1fd4586bf Mon Sep 17 00:00:00 2001
From: hexall90 <hexall90@gmail.com>
Date: Mon, 11 Sep 2017 11:04:23 +0200
Subject: [PATCH] Finished implementation of stimulants in the incubator

---
 src/init/storyInit.tw          |  1 -
 src/pregmod/incubator.tw       |  4 +-
 src/pregmod/incubatorReport.tw | 75 ++++++++++++++++++++++++++++------
 3 files changed, 65 insertions(+), 15 deletions(-)

diff --git a/src/init/storyInit.tw b/src/init/storyInit.tw
index dd3bc19bc3a..1f607721e48 100644
--- a/src/init/storyInit.tw
+++ b/src/init/storyInit.tw
@@ -464,7 +464,6 @@ DairyRestraintsSetting($dairyRestraintsSetting)
 <<set $incubatorMusclesSetting = 0>>
 <<set $incubatorGrowthStimsSetting = 0>>
 <<set $incubatorReproductionSetting = 0>>
-<<set $growthStimMod = 0>>
 <<set $incubatorName = "the Incubator">>
 <<set $incubatorNameCaps = "The Incubator">>
 <<set $reservedChildren = 0>>
diff --git a/src/pregmod/incubator.tw b/src/pregmod/incubator.tw
index 576ba4cb484..e7914ba3afa 100644
--- a/src/pregmod/incubator.tw
+++ b/src/pregmod/incubator.tw
@@ -189,8 +189,10 @@ Target age for release: <<textbox "$targetAge" $targetAge "Incubator">> [[Minimu
 <br>
 <<if $incubatorUpgradeGrowthStims == 1>>
 	Advanced monitoring and stimulants injection systems have been installed in the tanks to monitor and maintain a developing child's height.
-<<else>>
+<<elseif $growthStim == 1>>
 	There are no systems in place to control a growing child's height. [[Upgrade the growth tanks with stimulants injection systems|Incubator][$cash -= Math.trunc(20000*$upgradeMultiplierArcology), $incubatorUpgradeGrowthStims = 1]] //Costs ยค<<print Math.trunc(20000*$upgradeMultiplierArcology)>> and will increase upkeep costs//
+<<else>>
+	There are no systems in place to control a growing child's height and the medical facilities lack the capability to fabricate growth stimulants.
 <</if>>
 
 <br>
diff --git a/src/pregmod/incubatorReport.tw b/src/pregmod/incubatorReport.tw
index 2e5a1e50029..1d90cc53b54 100644
--- a/src/pregmod/incubatorReport.tw
+++ b/src/pregmod/incubatorReport.tw
@@ -138,27 +138,75 @@
 		<</if>>
 	<</if>>
 
-	<<if $incubatorUpgradeGrowthStims == 1>>
+	<<if $incubatorUpgradeGrowthStims == 1 && $incubatorGrowthStimsSetting != 0>>
 		<br>
-		<<if $tanks[_inc].height >= Math.clamp((Height.mean($slaves[$i]) * 1.25),0,274)>>
-			The monitoring system detects her body is not able to support further increases in height.
+		<<set _heightLimit =  Math.clamp((Height.mean($tanks[_inc].height) * 1.25),0,274)>>
+		<<set _heightLimitAge = Height.forAge($tanks[_inc].height, $tanks[_inc])>>
+		<<if $tanks[_inc].height >= _heightLimit>>
+			The monitoring system detects her body is not able to support further increases in height, so it carefully regulates stimulants injections to @@.yellow;maintain current stature.@@
+			<<set $tanks[_inc].height = _heightLimit>>
 		<<elseif $incubatorGrowthStimsSetting == 2>>
 			The monitoring system floods her body with growth stimulants, causing @@.green;a sharp increase in growth.@@
-			<<set $growthStimMod = 3>>
+			<<if $incubatorWeightSetting >= 1 && $incubatorMusclesSetting <= 1 && $incubatorReproductionSetting <= 1>>
+				<<if $incubatorUpgradeSpeed == 52>>
+					<<set $tanks[_inc].height += random(3,6)>>
+				<<elseif $incubatorUpgradeSpeed == 18>>
+					<<set $tanks[_inc].height += random(2,5)>>
+				<<elseif $incubatorUpgradeSpeed == 9>>
+					<<set $tanks[_inc].height += random(1,4)>>
+				<<elseif $incubatorUpgradeSpeed == 6>>
+					<<set $tanks[_inc].height += random(1,3)>>
+				<<elseif $incubatorUpgradeSpeed == 5>>
+					<<set $tanks[_inc].height += random(1,2)>>
+				<</if>>
+			<<else>>
+				<<if $incubatorUpgradeSpeed == 52>>
+					<<set $tanks[_inc].height += random(2,5)>>
+				<<elseif $incubatorUpgradeSpeed == 18>>
+					<<set $tanks[_inc].height += random(1,4)>>
+				<<elseif $incubatorUpgradeSpeed == 9>>
+					<<set $tanks[_inc].height += random(1,3)>>
+				<<elseif $incubatorUpgradeSpeed == 6>>
+					<<set $tanks[_inc].height += random(1,2)>>
+				<<elseif $incubatorUpgradeSpeed == 5>>
+					<<set $tanks[_inc].height += random(0,1)>>
+				<</if>>
+			<</if>>
+
 		<<elseif $incubatorGrowthStimsSetting == 1>>
-			<<if $tanks[_inc].height > Height.forAge($slaves[$i].height, $slaves[$i])>>
-				The monitoring system detects her body is struggling to keep up with her growth and @@.green;decreases her growth stimulants dosage.@@
-				<<set $growthStimMod = 1>>
+			<<if $tanks[_inc].height > _heightLimitAge>>
+				The monitoring system detects she is near the expected height, so it carefully regulates stimulants injections to @@.yellow;maintain current stature.@@
+				<<if random(1,10) == 10>>
+					<<if $incubatorUpgradeSpeed == 52>>
+						<<set $tanks[_inc].height += random(1,4)>>
+					<<elseif $incubatorUpgradeSpeed == 18>>
+						<<set $tanks[_inc].height += random(1,3)>>
+					<<elseif $incubatorUpgradeSpeed == 9>>
+						<<set $tanks[_inc].height += random(1,2)>>
+					<<elseif $incubatorUpgradeSpeed == 6>>
+						<<set $tanks[_inc].height += random(0,1)>>
+					<<elseif $incubatorUpgradeSpeed == 5>>
+						<<set $tanks[_inc].height += random(0,1)>>
+					<</if>>
+				<</if>>
 			<<else>>
 				The monitoring system detects her body is capable of developing more rapidly and @@.green;increases her growth stimulants dosage.@@
-				<<set $growthStimMod = 2>>
-			<</if>>
-		<<elseif $incubatorGrowthStimsSetting == 0>>
-			With the stimulants injections offline, her body is left to develop naturally.
-			<<if $growthStimMod != 0>>
-				<<set $growthStimMod = 0>>
+				<<if $incubatorUpgradeSpeed == 52>>
+					<<set $tanks[_inc].height += random(1,4)>>
+				<<elseif $incubatorUpgradeSpeed == 18>>
+					<<set $tanks[_inc].height += random(1,3)>>
+				<<elseif $incubatorUpgradeSpeed == 9>>
+					<<set $tanks[_inc].height += random(1,2)>>
+				<<elseif $incubatorUpgradeSpeed == 6>>
+					<<set $tanks[_inc].height += random(0,1)>>
+				<<elseif $incubatorUpgradeSpeed == 5>>
+					<<set $tanks[_inc].height += random(0,1)>>
+				<</if>>
 			<</if>>
 		<</if>>
+		<<set $tanks[_inc].height = Math.clamp($tanks[_inc].height, 0, _heightLimit)>>
+	<<else>>
+		With the stimulants injections offline, her body is left to develop naturally.
 	<</if>>
 	
 	<<if $incubatorUpgradeReproduction == 1>>
@@ -616,6 +664,7 @@
 	<<set $tanks[_inc].hips = Math.clamp($tanks[_inc].hips, -2, 2)>>
 	<<set $tanks[_inc].balls = Math.clamp($tanks[_inc].balls, 0, 40)>>
 	<<set $tanks[_inc].boobs = Math.clamp($tanks[_inc].boobs, 0, 30000)>>
+	<<set $tanks[_inc].height = Math.clamp($tanks[_inc].height, 0, 274)>>
 <br>
 <</for>>
 /*
-- 
GitLab