From e7455c2e9a391d51899bc30b5828534cbc7712f6 Mon Sep 17 00:00:00 2001
From: Svornost <11434-svornost@users.noreply.gitgud.io>
Date: Sat, 29 Jun 2019 15:59:27 -0700
Subject: [PATCH] When generating younger sisters/daughters from the Household
 Liquidator, make sure their physical parameters are set appropriately for
 their age.

---
 src/js/ageAdjustYoungRelative.js              | 101 ++++++++++++++++++
 src/uncategorized/motherDaughterWorkaround.tw |   4 +
 src/uncategorized/siblingsWorkaround.tw       |   4 +
 3 files changed, 109 insertions(+)
 create mode 100644 src/js/ageAdjustYoungRelative.js

diff --git a/src/js/ageAdjustYoungRelative.js b/src/js/ageAdjustYoungRelative.js
new file mode 100644
index 00000000000..35eefdb75ec
--- /dev/null
+++ b/src/js/ageAdjustYoungRelative.js
@@ -0,0 +1,101 @@
+/* When generating a younger relative by cloning an older one (for example, for Household Liquidators),
+ * clamp certain physical parameters of the younger relative appropriately for their physical age.
+ * Generally these adjustments should match the age limiters found in generateNewSlave.js.
+ */
+ 
+ window.AgeAdjustYoungRelative = function(slave) {
+	/* breast size */
+	var origBoobs = slave.boobs;
+	if (slave.physicalAge <= 10) {
+		slave.boobs = Math.clamp(slave.boobs, 0, 100);
+	} else if (slave.physicalAge <= 12) {
+		slave.boobs = Math.clamp(slave.boobs, 0, 300);
+	} else if (slave.physicalAge <= 14) {
+		slave.boobs = Math.clamp(slave.boobs, 0, 400);
+	} else if (slave.physicalAge <= 15) {
+		slave.boobs = Math.clamp(slave.boobs, 0, 450);
+	}
+	
+	/* if we've reduced breast size because of age, reapply minimum weight modifiers */
+	if (origBoobs > slave.boobs && State.variables.weightAffectsAssets !== 0) {
+		if (slave.weight > 190) {
+			slave.boobs += 300;
+		} else if (slave.weight > 160) {
+			slave.boobs += 200;
+		} else if (slave.weight > 30) {
+			slave.boobs += 100;
+		}
+	}
+	
+	/* if we've managed to *increase* breast size, just put it back */
+	if (origBoobs < slave.boobs) {
+		slave.boobs = origBoobs;
+	}
+
+	/* breast shape - preserve if it would have been valid, otherwise reset to normal (don't reroll) */
+	const AllowedBoobShapes = [];
+	if (slave.boobs > 250 && slave.boobs < 800) {
+		AllowedBoobShapes.push("perky");
+		AllowedBoobShapes.push("downward-facing");
+	}
+	if (slave.boobs > 400 && slave.boobs < 1200) {
+		AllowedBoobShapes.push("torpedo-shaped");
+		AllowedBoobShapes.push("wide-set");
+	}
+	if (!AllowedBoobShapes.includes(slave.boobShape)) {
+		slave.boobShape = "normal";
+	}
+	
+	/* voice */
+	if (slave.physicalAge <= 16 && slave.voice <= 1) {
+		slave.voice = 2;
+	}
+	
+	/* XX genitals */
+	if (slave.physicalAge < 20 && slave.vagina > 1) {
+		slave.vagina = 1;
+	}
+	
+	if (slave.physicalAge <= 13 && slave.clit > 1) {
+		slave.clit = 1;
+	}
+	
+	if (slave.physicalAge <= 13 && slave.labia > 1) {
+		slave.labia = 1;
+	} else if (slave.physicalAge <= 15 && slave.labia > 2) {
+		slave.labia = 2;
+	}
+	
+	/* XY genitals */
+	if (slave.physicalAge <= 13) {
+		if (slave.geneticQuirks.wellHung === 2 && slave.physicalAge >= 8 && slave.dick > 4) {
+			slave.dick = 4;
+		} else if (slave.dick > 3) {
+			slave.dick = 3;
+		}
+		if (slave.balls > 3) {
+			slave.balls = 3
+			slave.scrotum = slave.balls;
+		}
+	} else if (slave.physicalAge <= 15) {
+		if (slave.geneticQuirks.wellHung === 2 && slave.dick > 5) {
+			slave.dick = 5;
+		} else if (slave.dick > 3) {
+			slave.dick = 3;
+		}
+		if (slave.balls > 4) {
+			slave.balls = 4;
+			slave.scrotum = slave.balls;
+		}
+	}
+	
+	/* teeth */
+	if (slave.physicalAge < 6) {
+		slave.teeth = "baby";
+	} else if (slave.physicalAge < 12) {
+		slave.teeth = "mixed";
+	}
+	
+	/* reset puberty status */
+	generatePuberty(slave);
+};
diff --git a/src/uncategorized/motherDaughterWorkaround.tw b/src/uncategorized/motherDaughterWorkaround.tw
index e21e5f7e5b3..c0772a486e3 100644
--- a/src/uncategorized/motherDaughterWorkaround.tw
+++ b/src/uncategorized/motherDaughterWorkaround.tw
@@ -69,4 +69,8 @@ Your new pair of slaves look frightened and uncertain, but seem encouraged by ea
 	<<set _secondSlave.butt += random(-1, 1)>>
 <</if>>
 
+<<if _secondSlave.physicalAge <= 15>>
+	<<run AgeAdjustYoungRelative(_secondSlave)>>
+<</if>>
+
 <<run newSlave(_secondSlave)>>
diff --git a/src/uncategorized/siblingsWorkaround.tw b/src/uncategorized/siblingsWorkaround.tw
index 3c3035f7774..6680ab134bd 100644
--- a/src/uncategorized/siblingsWorkaround.tw
+++ b/src/uncategorized/siblingsWorkaround.tw
@@ -67,4 +67,8 @@ Your new pair of slaves look frightened and uncertain, but seem encouraged by ea
 	<<set _secondSlave.butt += random (-1, 1)>>
 <</if>>
 
+<<if _secondSlave.physicalAge <= 15>>
+	<<run AgeAdjustYoungRelative(_secondSlave)>>
+<</if>>
+
 <<run newSlave(_secondSlave)>>
-- 
GitLab