From 2512dd0a18fd3302ceacea95f9af65cd1de89097 Mon Sep 17 00:00:00 2001
From: hexall <hexall90.gmail.com>
Date: Sun, 10 Sep 2017 12:27:51 +0200
Subject: [PATCH] Fixed logic error in the expected height modifier

---
 src/uncategorized/saDrugs.tw | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/uncategorized/saDrugs.tw b/src/uncategorized/saDrugs.tw
index 5bedf8dfaa7..79a82c7ea6c 100644
--- a/src/uncategorized/saDrugs.tw
+++ b/src/uncategorized/saDrugs.tw
@@ -457,9 +457,16 @@
 			<</if>>
 		<</if>>
 		/*evaluate against slave expected height ...*/
-		<<set _heightDiff = 1 - ($slaves[$i].height / Height.forAge($slaves[$i].height, $slaves[$i]))>>
+		<<set _heightDiff = $slaves[$i].height / Height.forAge($slaves[$i].height, $slaves[$i])>>
+		/*if she is taller than the expected height the growth is reduced, if shorter accelerated,
+		proportionally to the distance from the expected height*/
+		<<if _heightDiff >= 1>>
+			<<set _heightDiff = 1 - _heightDiff>>
+		<<else>>
+			<<set _heightDiff-->>
+		<</if>>
 		/*... and calculates final value*/
-		<<set _growth = (_growth + _growth * _heightDiff) * _ageMod>>	/*if she is taller than the expected height the growth is reduced, if shorter accelerated*/
+		<<set _growth = (_growth + _growth * _heightDiff) * _ageMod>>	
 		<<set _growth = Math.round(Math.clamp(_growth,0,5))>>
 		/*communicates the amount of growth*/
 		<<if _growth < 1>> 												/*in case _heightDiff manages to bring _growth down enough*/
-- 
GitLab