From 2960ae965b5c6d9c68dca2ed2eb028844241e19b Mon Sep 17 00:00:00 2001
From: Pregmodder <pregmodder@gmail.com>
Date: Mon, 2 Aug 2021 00:36:07 -0400
Subject: [PATCH] Fix MB intelligence storing

---
 CHANGELOG.md                                  |  3 +++
 slave variables documentation - Pregmod.txt   | 19 ++++++++++---------
 src/events/RE/reMalefactor.js                 |  2 +-
 src/events/REFS/refsWarhound.js               |  2 +-
 src/events/nonRandom/eliteTakeOver.js         |  2 +-
 .../nonRandom/rival/pHostageAcquisition.js    |  2 ++
 src/events/nonRandom/rival/pRivalryActions.js |  2 --
 src/events/reRecruit/blessedVessel.js         |  2 +-
 src/events/scheduled/seHuskSlaveDelivery.js   |  2 +-
 src/events/schools/resFailure.js              |  2 +-
 src/js/utilsSlave.js                          | 14 +++++++++++++-
 src/markets/specificMarkets/slaveShelter.js   |  4 ++--
 src/npc/descriptions/descriptionWidgets.js    |  8 ++++++--
 src/npc/descriptions/mind.js                  | 12 ++++++------
 src/npc/generate/generateGenetics.js          |  2 +-
 src/npc/generate/generateMarketSlave.js       | 12 ++++++------
 16 files changed, 55 insertions(+), 35 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 23158a55f02..ff4fa81c344 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
 
 ## Unreleased
 
+* Elohiem's webGL art update 4
+* near complete conversion of .tw passages to .js
+* fixes
 
 ## 0.10.7.1-4.0.0-alpha.7 - 2021-07-16
 
diff --git a/slave variables documentation - Pregmod.txt b/slave variables documentation - Pregmod.txt
index cfb2d186636..4daddafe301 100644
--- a/slave variables documentation - Pregmod.txt	
+++ b/slave variables documentation - Pregmod.txt	
@@ -2350,15 +2350,16 @@ slave has hip implant
 butt:
 
 butt size
-0	  - flat
-1	  - small
-2	  - plump*
-3	  - big bubble butt
-4	  - huge
-5	  - enormous
-6	  - gigantic
-7	  - ridiculous
-8 - 10 - immense
+0	   - flat
+1      - slightly less flat
+2	   - small
+3	   - big
+4	   - large
+5	   - huge
+6	   - enormous
+7	   - gigantic
+8	   - ridiculous
+9 - 10 - immense
 11 - 20- inhuman
 
 *Descriptions vary for just how big 2 is, as such, it may be better to just go with 3
diff --git a/src/events/RE/reMalefactor.js b/src/events/RE/reMalefactor.js
index 00c508accad..319e8d55fa6 100644
--- a/src/events/RE/reMalefactor.js
+++ b/src/events/RE/reMalefactor.js
@@ -242,7 +242,7 @@ App.Events.REMalefactor = class REMalefactor extends App.Events.BaseEvent {
 					break;
 				case "orphanloli":
 					r.push(`You declare ${his} holes fair game for the entire arcology, so that all free citizens can own ${him} for a moment, if they wish. ${He} spends a torturous day in the stocks before being hauled in for enslavement, <span class="health dec">completely broken</span> due to ${his} ordeal, bruises all over ${his} body, cum leaking from ${his} <span class="lime">loosened</span> anus${(slave.vagina > -1) ? ' and <span class="lime">fucked-out</span> pussy' : ""}. The public <span class="reputation inc">enjoys the fun.</span>`);
-					applyMindbroken(slave);
+					applyMindbroken(slave, slave.intelligence);
 					break;
 				case "anchorBaby":
 					r.push(`You declare ${his} holes fair game for the entire arcology; since ${he} wants to produce future slaves, your arcology might as well have the privilege of fathering them. ${He} spends a torturous day in the stocks after ${his} children are taken to a slave orphanage before being hauled in for enslavement, somewhat <span class="health.dec">the worse for wear</span> and <span class="red">acting oddly</span> due to ${his} ordeal, bruises all over ${his} body, cum leaking from ${his} <span class="lime">loosened</span> anus${(slave.vagina > -1) ? ' and <span class="lime">fucked-out</span> pussy' : ""}. The public <span class="reputation inc">enjoys the fun.</span>`);
diff --git a/src/events/REFS/refsWarhound.js b/src/events/REFS/refsWarhound.js
index 4e843ca72aa..9f2c443473e 100644
--- a/src/events/REFS/refsWarhound.js
+++ b/src/events/REFS/refsWarhound.js
@@ -16,7 +16,7 @@ App.Events.refsWarhound = class refsWarhound extends App.Events.BaseEvent {
 			slave.weight -= 100;
 			slave.waist = random(-10, 50);
 		}
-		applyMindbroken(slave);
+		applyMindbroken(slave, -100);
 		configureLimbs(slave, "all", 6);
 		slave.teeth = "pointy";
 		slave.earT = "inu";
diff --git a/src/events/nonRandom/eliteTakeOver.js b/src/events/nonRandom/eliteTakeOver.js
index 51299bd0ca1..a359ac9b030 100644
--- a/src/events/nonRandom/eliteTakeOver.js
+++ b/src/events/nonRandom/eliteTakeOver.js
@@ -639,7 +639,7 @@ App.Events.eliteTakeOver = class eliteTakeOver extends App.Events.BaseEvent {
 						if (slave.boobShape === "saggy" || slave.boobShape === "downward-facing") {
 							slave.boobShape = either("perky", "torpedo-shaped", "wide-set");
 						}
-						applyMindbroken(slave);
+						applyMindbroken(slave, random(70, 100));
 						slave.pubicHStyle = "waxed";
 						slave.underArmHStyle = "waxed";
 						slave.anus = 0;
diff --git a/src/events/nonRandom/rival/pHostageAcquisition.js b/src/events/nonRandom/rival/pHostageAcquisition.js
index 895c76bd3ed..6255fcea9de 100644
--- a/src/events/nonRandom/rival/pHostageAcquisition.js
+++ b/src/events/nonRandom/rival/pHostageAcquisition.js
@@ -257,6 +257,7 @@ App.Events.pHostageAcquisition = function() {
 						r.push(`and broken.`);
 					}
 					r.push(`Although, if ${he} pulls through this, ${he}'ll be devoted to you forever.`);
+					applyMindbroken(V.hostage, V.hostage.intelligence);
 					V.hostage.weight = -100;
 					V.hostage.muscles = -100;
 					if (V.hostage.health.health > -100) {
@@ -528,6 +529,7 @@ App.Events.pHostageAcquisition = function() {
 				} else {
 					r.push(`Your mercenaries radio you upon arrival. "VIP recovered but... I'm so sorry..."`);
 					r.push(`You immediately wretch from the smell that follows the merc troop into your office. You rise to shout at them for tracking it in when you realize what the source of the smell is. A crate containing the twisted, mutilated, inked and pierced body of ${V.hostage.slaveName}. The mercenaries see themselves out as you carefully take a biometric scan of the inert, limbless body before you. ${He} is alive, but barely, and a brain scan shows few signs of activity. You call for some servants to clean ${him} up, hoping that maybe it will draw ${him} out of ${his} stupor. Deep down, you understand the ${girl} you used to know has been twisted and broken completely; never to be the same again.`);
+					applyMindbroken(V.hostage, V.hostage.intelligence);
 					if (V.hostage.health.health > -100) {
 						setHealth(V.hostage, -40, 30, Math.max(V.hostage.health.longDamage, 30), 2, 100);
 					}
diff --git a/src/events/nonRandom/rival/pRivalryActions.js b/src/events/nonRandom/rival/pRivalryActions.js
index c00cb108baf..9947749c877 100644
--- a/src/events/nonRandom/rival/pRivalryActions.js
+++ b/src/events/nonRandom/rival/pRivalryActions.js
@@ -1534,7 +1534,6 @@ App.Events.pRivalryActions = function() {
 						V.hostage.counter.mammary += 50;
 						V.hostage.lactation = 1;
 						V.hostage.lactationDuration = 2;
-						applyMindbroken(V.hostage);
 						/* Make scars worse: */
 						App.Medicine.Modification.addScourged(V.hostage);
 						App.Medicine.Modification.addScar(V.hostage, "left cheek", "generic", 3);
@@ -1637,7 +1636,6 @@ App.Events.pRivalryActions = function() {
 						V.hostage.corsetPiercing = 1;
 						V.hostage.areolaePiercing = 1;
 						V.hostage.tonguePiercing = 2;
-						applyMindbroken(V.hostage);
 						if (seed < 40) {
 							App.Medicine.Modification.addScar(V.hostage, "anus", "burn", 2);
 						} else if (seed < 80) {
diff --git a/src/events/reRecruit/blessedVessel.js b/src/events/reRecruit/blessedVessel.js
index 1dcbb511811..71e857295aa 100644
--- a/src/events/reRecruit/blessedVessel.js
+++ b/src/events/reRecruit/blessedVessel.js
@@ -114,7 +114,7 @@ App.Events.recBlessedVessel = class recBlessedVessel extends App.Events.BaseEven
 			slave.weight = 90;
 			slave.muscles = random(-100, -50);
 			slave.career = "a breeder";
-			applyMindbroken(slave);
+			applyMindbroken(slave, slave.intelligence);
 			return slave;
 		}
 	}
diff --git a/src/events/scheduled/seHuskSlaveDelivery.js b/src/events/scheduled/seHuskSlaveDelivery.js
index 8f4b03d03b7..1fc8b295e0e 100644
--- a/src/events/scheduled/seHuskSlaveDelivery.js
+++ b/src/events/scheduled/seHuskSlaveDelivery.js
@@ -33,7 +33,7 @@ App.Events.SEHuskSlaveDelivery = class SEHuskSlaveDelivery extends App.Events.Ba
 		husk.slaveSurname = "";
 		husk.birthSurname = "";
 		husk.origin = "You reserved a mindless slave like $him from the Flesh Heap.";
-		applyMindbroken(husk);
+		applyMindbroken(husk, -100);
 		husk.career = "a Fuckdoll";
 
 		if (V.huskSlave.sex === 3) {
diff --git a/src/events/schools/resFailure.js b/src/events/schools/resFailure.js
index d8157ac29e5..9457016f683 100644
--- a/src/events/schools/resFailure.js
+++ b/src/events/schools/resFailure.js
@@ -135,7 +135,7 @@ App.Events.RESFailure = class RESFailure extends App.Events.BaseEvent {
 				slave.pubicHStyle = "waxed";
 				slave.underArmHStyle = "waxed";
 				slave.heels = 1;
-				applyMindbroken(slave);
+				applyMindbroken(slave, either(-100, -100, -100, -96, -80, -70, -50));
 				slave.hStyle = "neat";
 				slave.collar = "leather with cowbell";
 				slave.brand["right thigh"] = "the logo of the Cattle Ranch";
diff --git a/src/js/utilsSlave.js b/src/js/utilsSlave.js
index 08e0f560bc8..f92f49fc5a1 100644
--- a/src/js/utilsSlave.js
+++ b/src/js/utilsSlave.js
@@ -2055,6 +2055,11 @@ globalThis.newSlave = function(slave) {
 		V.REReductionCheckinIDs.push(slave.ID);
 	}
 
+	/* special case for MB slave genetic intellignece in slave acquisition */
+	if (slave.savedIntelligence) {
+		slave.intelligence = slave.savedIntelligence;
+	}
+
 	generatePronouns(slave);
 	SetBellySize(slave);
 	V.slaveIndices[slave.ID] = V.slaves.push(slave) - 1;
@@ -2072,6 +2077,10 @@ globalThis.newSlave = function(slave) {
 		slave.intelligence = -100;
 		delete slave.dullIntelligence;
 	}
+	if (slave.savedIntelligence) { // MB sets int to -75
+		slave.intelligence = -75;
+		delete slave.savedIntelligence;
+	}
 
 	if (slave.assignment) {
 		assignJob(slave, slave.assignment);
@@ -3690,7 +3699,7 @@ globalThis.restoreTraitor = function() {
  *
  * @param {App.Entity.SlaveState} slave
  */
-globalThis.applyMindbroken = function(slave) {
+globalThis.applyMindbroken = function(slave, oldIntelligence = -200) {
 	slave.fetish = "mindbroken";
 	slave.fetishStrength = 10;
 	slave.attrXY = 50;
@@ -3704,6 +3713,9 @@ globalThis.applyMindbroken = function(slave) {
 	slave.skill.combat = 0;
 	slave.skill.whoring = 0;
 	slave.skill.entertainment = 0;
+	if (oldIntelligence >= -100) {
+		slave.savedIntelligence = oldIntelligence;
+	}
 	slave.intelligence = -75;
 	slave.intelligenceImplant = 0;
 	slave.sexualFlaw = "none";
diff --git a/src/markets/specificMarkets/slaveShelter.js b/src/markets/specificMarkets/slaveShelter.js
index 4b8bd813215..a4ab86791cd 100644
--- a/src/markets/specificMarkets/slaveShelter.js
+++ b/src/markets/specificMarkets/slaveShelter.js
@@ -52,7 +52,7 @@ App.Markets["Slave Shelter"] = function() {
 					V.shelterSlave.career = "a slave";
 					setHealth(V.shelterSlave, jsRandom(-30, -10));
 					V.shelterSlave.anus = 3;
-					applyMindbroken(V.shelterSlave);
+					applyMindbroken(V.shelterSlave, V.shelterSlave.intelligence);
 					break;
 				case "amputee":
 					V.shelterSlave = GenerateNewSlave(null, {disableDisability: 1});
@@ -100,7 +100,7 @@ App.Markets["Slave Shelter"] = function() {
 					V.shelterSlave.weight = -50;
 					V.shelterSlave.vagina = 9;
 					V.shelterSlave.bellySag = 20;
-					applyMindbroken(V.shelterSlave);
+					applyMindbroken(V.shelterSlave, V.shelterSlave.intelligence);
 					break;
 				case "cannibal victim male":
 					if (V.pedo_mode === 1) {
diff --git a/src/npc/descriptions/descriptionWidgets.js b/src/npc/descriptions/descriptionWidgets.js
index 14fb5798d23..2dd0a09739e 100644
--- a/src/npc/descriptions/descriptionWidgets.js
+++ b/src/npc/descriptions/descriptionWidgets.js
@@ -97,7 +97,9 @@ App.Desc.eyes = function(slave, {market, eventDescription} = {}) {
 			}
 		}
 		r += `, `;
-		if (slave.intelligence > 95) {
+		if (slave.fetish === "mindbroken") {
+			r += `fitting for vacant expression constantly adorning ${his} face; ${his} broken mind lacks the ability to form higher thought and is completely reliant on others to think for ${him}.`;
+		} else if (slave.intelligence > 95) {
 			r += `but ${his} facial expressions reveal ${he} is incisive, quick, cunning; `;
 			if (slave.intelligence + slave.intelligenceImplant >= 130) {
 				r += `with ${his} education, ${he} is so far <span class="deepskyblue">beyond brilliant</span> that ${he} is nearly peerless. `;
@@ -223,7 +225,9 @@ App.Desc.eyes = function(slave, {market, eventDescription} = {}) {
 			}
 		}
 	} else {
-		if (slave.intelligence > 95) {
+		if (slave.fetish === "mindbroken") {
+			r += `${His} ${App.Desc.eyesColor(slave, "", "eye", "eyes", false)} ${hasBothEyes(slave) ? "are" : "is"} dull and vacant; ${his} broken mind lacks the capacity for higher thought.`;
+		} else if (slave.intelligence > 95) {
 			r += `${His} ${App.Desc.eyeColor(slave)}-eyed gaze is incisive, quick, cunning; `;
 			if (slave.intelligence + slave.intelligenceImplant >= 130) {
 				r += `with ${his} education, ${he} is so far <span class="deepskyblue">beyond brilliant</span> that ${he} is nearly peerless. `;
diff --git a/src/npc/descriptions/mind.js b/src/npc/descriptions/mind.js
index a78e387981b..0fbef348f6c 100644
--- a/src/npc/descriptions/mind.js
+++ b/src/npc/descriptions/mind.js
@@ -15,13 +15,13 @@ App.Desc.mind = function(slave, {market, eventDescription} = {}) {
 
 		if (slave.fetish === "mindbroken") {
 			r.push(`However, <span class="coral">${his} mind is fundamentally broken;</span> everything ${he} experiences will quickly be forgotten.`);
+		} else {
+			r.push(behavioralFlaws());
+			r.push(behavioralQuirks());
+			r.push(sexualFlaws());
+			r.push(sexualQuirk());
+			r.push(fetish());
 		}
-
-		r.push(behavioralFlaws());
-		r.push(behavioralQuirks());
-		r.push(sexualFlaws());
-		r.push(sexualQuirk());
-		r.push(fetish());
 		r.push(attraction());
 	} else {
 		r.push(`It's impossible to tell what intelligence or inclinations a Fuckdoll might have by looking at it, but the most recent records indicate that this one is`);
diff --git a/src/npc/generate/generateGenetics.js b/src/npc/generate/generateGenetics.js
index fd1fa8d5e0b..d423845424a 100644
--- a/src/npc/generate/generateGenetics.js
+++ b/src/npc/generate/generateGenetics.js
@@ -1273,7 +1273,7 @@ globalThis.generateChild = function(mother, ovum, incubator = false) {
 			child.tankBaby = 1;
 		} else {
 			child.origin = "$His brain is blank outside of the most basic of functions.";
-			applyMindbroken(child);
+			applyMindbroken(child, child.intelligence);
 			child.tankBaby = 3;
 		}
 		child.intelligenceImplant = 0;
diff --git a/src/npc/generate/generateMarketSlave.js b/src/npc/generate/generateMarketSlave.js
index d963c4ef384..f97424d4254 100644
--- a/src/npc/generate/generateMarketSlave.js
+++ b/src/npc/generate/generateMarketSlave.js
@@ -1150,7 +1150,7 @@ globalThis.generateMarketSlave = function(market = "kidnappers", numArcology = 1
 			}
 			slave.addict = jsEither([0, 0, 0, 10, 10, 20, 30]);
 			slave.chem = jsRandom(0, 1000);
-			applyMindbroken(slave);
+			applyMindbroken(slave, Intelligence.random({limitIntelligence: [-100, 0]}));
 			break;
 		}
 		case "wetware": {
@@ -1875,7 +1875,7 @@ globalThis.generateMarketSlave = function(market = "kidnappers", numArcology = 1
 				slave.underArmHStyle = "waxed";
 				slave.heels = 1;
 				slave.energy = 100;
-				applyMindbroken(slave);
+				applyMindbroken(slave, -100);
 				slave.hStyle = "neat";
 				slave.brand["right thigh"] = "the logo of the Cattle Ranch";
 			} else {
@@ -1913,7 +1913,7 @@ globalThis.generateMarketSlave = function(market = "kidnappers", numArcology = 1
 				slave.pubicHStyle = "waxed";
 				slave.underArmHStyle = "waxed";
 				slave.heels = 1;
-				applyMindbroken(slave);
+				applyMindbroken(slave, jsEither([-100, -100, -100, -100, -60, -60, -30]));
 				slave.hStyle = "neat";
 				slave.collar = "leather with cowbell";
 				slave.brand["right thigh"] = "the logo of the Cattle Ranch";
@@ -2894,7 +2894,7 @@ globalThis.generateMarketSlave = function(market = "kidnappers", numArcology = 1
 					if (jsRandom(1, 100) > 70) {
 						slave.origin = "You purchased $his life at a prison sale. $He was locked away for murder. $His actions weigh heavily on $his conscience.";
 						setHealth(slave, jsRandom(-50, 20), Math.max(normalRandInt(0, 4), 0), Math.max(normalRandInt(0, 4), 0), undefined, jsRandom(40, 100));
-						applyMindbroken(slave);
+						applyMindbroken(slave, jsRandom(-80, 70));
 					} else {
 						slave.origin = "You purchased $his life at a prison sale. $He was locked away for murder.";
 						slave.devotion = jsRandom(-50, -20);
@@ -2911,7 +2911,7 @@ globalThis.generateMarketSlave = function(market = "kidnappers", numArcology = 1
 					if (jsRandom(1, 100) > 50) {
 						slave.origin = "You purchased $his life at a prison sale. $He was locked away for arson. $His actions, and those $he inadvertently killed, weigh heavily on $his conscience.";
 						setHealth(slave, jsRandom(-50, 20), Math.max(normalRandInt(0, 4), 0), Math.max(normalRandInt(0, 4), 0), undefined, jsRandom(40, 100));
-						applyMindbroken(slave);
+						applyMindbroken(slave, jsRandom(-80, 70));
 					} else {
 						slave.origin = "You purchased $his life at a prison sale. $He was locked away for arson.";
 						slave.devotion = jsRandom(-70, -50);
@@ -2990,7 +2990,7 @@ globalThis.generateMarketSlave = function(market = "kidnappers", numArcology = 1
 					if (jsRandom(1, 100) > 60) {
 						slave.origin = "You purchased $his life at a prison sale. $He was locked away for manslaughter. $His actions weigh heavily on $his conscience.";
 						setHealth(slave, jsRandom(-50, -20), Math.max(normalRandInt(0, 4), 0), Math.max(normalRandInt(0, 4), 0), undefined, jsRandom(40, 100));
-						applyMindbroken(slave);
+						applyMindbroken(slave, jsRandom(-80, 70));
 					} else {
 						slave.origin = "You purchased $his life at a prison sale. $He was locked away for manslaughter.";
 						slave.devotion = jsRandom(-70, -50);
-- 
GitLab