From d45194470be7f62e69109136e3ebe7045d20dbad Mon Sep 17 00:00:00 2001
From: Svornost <11434-svornost@users.noreply.gitgud.io>
Date: Mon, 6 Jul 2020 20:44:01 -0700
Subject: [PATCH] Move slave deflation to a common function.  Cleaner, and
 fixes a few uncommon bugs.

---
 src/endWeek/saAgent.js                    |  5 +---
 src/endWeek/saInflation.js                | 30 ++++++-------------
 src/facilities/nursery/childInteract.tw   | 20 ++-----------
 src/interaction/slaveInteract.js          | 35 ++++++-----------------
 src/js/DefaultRules.js                    | 13 ++-------
 src/js/assignJS.js                        |  5 +---
 src/js/removeActiveSlave.js               | 34 +++-------------------
 src/js/utilsFC.js                         | 12 ++++++++
 src/npc/interaction/fAbuse.tw             | 12 +++-----
 src/npc/interaction/fSlaveFeed.tw         |  8 +++---
 src/npc/interaction/fillUpButt.tw         |  3 +-
 src/npc/interaction/fillUpFace.tw         |  3 +-
 src/npc/interaction/forceFeeding.tw       |  3 +-
 src/npc/surgery/surgery.js                |  6 +---
 src/pregmod/widgets/bodyswapWidgets.tw    |  6 ++--
 src/uncategorized/arcadeReport.tw         |  3 +-
 src/uncategorized/cellblockReport.tw      |  6 ++--
 src/uncategorized/dairyReport.tw          |  3 +-
 src/uncategorized/pUndergroundRailroad.tw |  4 +--
 19 files changed, 63 insertions(+), 148 deletions(-)

diff --git a/src/endWeek/saAgent.js b/src/endWeek/saAgent.js
index 699f4529064..e98fa74c9d7 100644
--- a/src/endWeek/saAgent.js
+++ b/src/endWeek/saAgent.js
@@ -146,10 +146,7 @@ App.SlaveAssignment.agent = function(slave) {
 	}
 
 	if (slave.inflation > 0) {
-		slave.inflation = 0;
-		slave.inflationType = "none";
-		slave.inflationMethod = 0;
-		slave.milkSource = 0;
+		deflate(slave);
 	}
 
 	if (slave.preg > 0) { // EFFECTS OF PREGNANCY
diff --git a/src/endWeek/saInflation.js b/src/endWeek/saInflation.js
index cb4a3d99836..059c2b33f72 100644
--- a/src/endWeek/saInflation.js
+++ b/src/endWeek/saInflation.js
@@ -61,33 +61,19 @@ App.SlaveAssignment.inflation = (function() {
 	 */
 	function inflationCancellation(slave) {
 		if (slave.assignment === Job.ARCADE || slave.assignment === Job.DAIRY) {
-			slave.inflation = 0, slave.inflationType = "none", slave.inflationMethod = 0, slave.milkSource = 0, SetBellySize(slave);
+			deflate(slave);
 		} else if (slave.inflationType === "milk" && (slave.inflationMethod === 1 || slave.inflationMethod === 2) && (dairyL === 0 || V.dairy === 0) && V.arcologies[0].FSPastoralistLaw !== 1 && (slave.assignment !== Job.CELLBLOCK || V.cellblockDecoration !== "Pastoralist")) {
 			r.push(`You no longer have a functional dairy. <span class="yellow">${His} inflation regimen has been ended.</span>`);
-			slave.inflation = 0;
-			slave.inflationType = "none";
-			slave.inflationMethod = 0;
-			SetBellySize(slave);
+			deflate(slave);
 		} else if (slave.inflationType === "milk" && slave.inflationMethod === 3 && cow.lactation === 0) {
 			r.push(`${cow.slaveName} is no longer lactating and thus can no longer keep ${slave.slaveName} filled with milk. <span class="yellow">${His} inflation regimen has been ended.</span>`);
-			slave.inflation = 0;
-			slave.inflationType = "none";
-			slave.inflationMethod = 0;
-			slave.milkSource = 0;
-			SetBellySize(slave);
+			deflate(slave);
 		} else if (slave.inflationType === "cum" && (slave.inflationMethod === 1 || slave.inflationMethod === 2) && (dairyL === 0 || V.cumSlaves === 0 || V.dairy === 0) && V.arcologies[0].FSPastoralistLaw !== 1) {
 			r.push(`You no longer have a functional cum dairy. <span class="yellow">${His} inflation regimen has been ended.</span>`);
-			slave.inflation = 0;
-			slave.inflationType = "none";
-			slave.inflationMethod = 0;
-			SetBellySize(slave);
+			deflate(slave);
 		} else if (slave.inflationType === "cum" && slave.inflationMethod === 3 && cow.balls === 0) {
 			r.push(`${cow.slaveName} no longer has testicles and thus can no longer keep ${slave.slaveName} filled with cum. <span class="yellow">${His} inflation regimen has been ended.</span>`);
-			slave.inflation = 0;
-			slave.inflationType = "none";
-			slave.inflationMethod = 0;
-			slave.cumSource = 0;
-			SetBellySize(slave);
+			deflate(slave);
 		} else if (slave.bellyImplant >= 1500) {
 			if (slave.inflation > 1) {
 				r.push(`Due to the mounting pressure from ${his} filled abdominal implant, ${he} can no longer fill ${himself} as large as ${he} used to.`);
@@ -245,7 +231,7 @@ App.SlaveAssignment.inflation = (function() {
 				}
 				if (slave.health.condition >= 90) {
 					r.push(`${He} is as healthy as ${he} can be. <span class="yellow">${His} curative enema regimen has been ended.</span>`);
-					slave.inflation = 0, slave.inflationType = "none", slave.inflationMethod = 0, SetBellySize(slave);
+					deflate(slave);
 				}
 				slave.chem += 2;
 				break;
@@ -310,7 +296,7 @@ App.SlaveAssignment.inflation = (function() {
 							r.push(`it`);
 						}
 						r.push(`with the treatment counteracting their efforts. <span class="yellow">${His} tightening enema regimen has been ended.</span>`);
-						slave.inflation = 0, slave.inflationType = "none", slave.inflationMethod = 0, SetBellySize(slave);
+						deflate(slave);
 					} else if ([Job.CLUB, Job.BROTHEL].includes(slave.assignment)) {
 						if (slave.vagina >= 0) {
 							r.push(`them,`);
@@ -325,7 +311,7 @@ App.SlaveAssignment.inflation = (function() {
 							r.push(`it.`);
 						}
 						r.push(`<span class="yellow">${His} tightening enema regimen has been ended.</span>`);
-						slave.inflation = 0, slave.inflationType = "none", slave.inflationMethod = 0, SetBellySize(slave);
+						deflate(slave);
 					}
 				}
 				slave.chem += 2;
diff --git a/src/facilities/nursery/childInteract.tw b/src/facilities/nursery/childInteract.tw
index f8a8a4efe1d..e485043b328 100644
--- a/src/facilities/nursery/childInteract.tw
+++ b/src/facilities/nursery/childInteract.tw
@@ -1202,23 +1202,9 @@ Aphrodisiacs: <b><span id="aphrodisiacs">$activeChild.aphrodisiacs</span>.</b>
 <<if $activeChild.inflation > 0>>
 	<br>&nbsp;&nbsp;&nbsp;&nbsp;
 	__Required Bloating__: <b><span id="inflate"><<if $activeChild.inflation == 3>><<print "$He is required to keep 2 gallons of $activeChild.inflationType in $him at all times">><<elseif $activeChild.inflation == 2>><<print "$He is required to keep 4 liters of $activeChild.inflationType in $him at all times">><<elseif $activeChild.inflation>><<print "$He is required to keep 2 liters of $activeChild.inflationType in $him at all times">><</if>></span></b>.
-	<<if $activeChild.inflationMethod == 3>>
-		<<link "Let $him deflate">>
-			<<set $activeChild.inflation = 0, $activeChild.inflationType = "none" ,$activeChild.inflationMethod = 0, $activeChild.cumSource = 0, $activeChild.milkSource = 0, SetBellySize($activeChild)>>
-			<</link>>
-	<<elseif $activeChild.inflationType == "milk">>
-		<<link "Let $him deflate">>
-			<<set $activeChild.inflation = 0, $activeChild.inflationType = "none" ,$activeChild.inflationMethod = 0, SetBellySize($activeChild)>>
-			<</link>>
-	<<elseif $activeChild.inflationType == "cum">>
-		<<link "Let $him deflate">>
-			<<set $activeChild.inflation = 0, $activeChild.inflationType = "none" ,$activeChild.inflationMethod = 0, SetBellySize($activeChild)>>
-			<</link>>
-	<<else>>
-		<<link "Let $him deflate">>
-			<<set $activeChild.inflation = 0, $activeChild.inflationType = "none" ,$activeChild.inflationMethod = 0, SetBellySize($activeChild)>>
-			<</link>>
-	<</if>>
+	<<link "Let $him deflate">>
+		<<run deflate($activeChild)>>
+	<</link>>
 <</if>>
 </span>
 
diff --git a/src/interaction/slaveInteract.js b/src/interaction/slaveInteract.js
index c6523cfd62c..ece50086303 100644
--- a/src/interaction/slaveInteract.js
+++ b/src/interaction/slaveInteract.js
@@ -1374,33 +1374,14 @@ App.UI.SlaveInteract.bloating = function(slave) {
 		bloating.append(requirement);
 		bloating.append(". ");
 
-		if (slave.inflationMethod === 3) {
-			let link = App.UI.DOM.link(
-				`Let ${him} deflate`,
-				() => {
-					slave.inflation = 0;
-					slave.inflationType = "none";
-					slave.inflationMethod = 0;
-					slave.cumSource = 0;
-					slave.milkSource = 0;
-					SetBellySize(slave);
-					App.UI.SlaveInteract.refreshAll(slave);
-				},
-			);
-			bloating.append(link);
-		} else {
-			let link = App.UI.DOM.link(
-				`Let ${him} deflate`,
-				() => {
-					slave.inflation = 0;
-					slave.inflationType = "none";
-					slave.inflationMethod = 0;
-					SetBellySize(slave);
-					App.UI.SlaveInteract.refreshAll(slave);
-				},
-			);
-			bloating.append(link);
-		}
+		let link = App.UI.DOM.link(
+			`Let ${him} deflate`,
+			() => {
+				deflate(slave);
+				App.UI.SlaveInteract.refreshAll(slave);
+			},
+		);
+		bloating.append(link);
 	}
 	// make sure it updates itself after run
 	return jQuery('#bloating').empty().append(bloating);
diff --git a/src/js/DefaultRules.js b/src/js/DefaultRules.js
index 64098f25463..1e355321f40 100644
--- a/src/js/DefaultRules.js
+++ b/src/js/DefaultRules.js
@@ -1507,12 +1507,7 @@ globalThis.DefaultRules = (function() {
 			if (slave.inflationType !== rule.inflationType) {
 				if ((slave.inflationType === "curative" && slave.health.condition > 90) || (slave.inflationType === "tightener" && slave.anus <= 1 && slave.vagina <= 1)) {
 					r += `<br>${slave.slaveName} cannot benefit from ${his} assigned enema and has been defaulted to none.`;
-					slave.inflation = 0;
-					slave.inflationType = "none";
-					slave.inflationMethod = 0;
-					slave.milkSource = 0;
-					slave.cumSource = 0;
-					SetBellySize(slave);
+					deflate(slave);
 				} else if ((rule.inflationType === "curative" && slave.health.condition > 90) || (rule.inflationType === "tightener" && slave.anus <= 1 && slave.vagina <= 1)) {
 					// empty block
 				} else {
@@ -1534,11 +1529,7 @@ globalThis.DefaultRules = (function() {
 				slave.inflation = 1;
 				SetBellySize(slave);
 			} else if (slave.inflationType === "none") {
-				slave.inflation = 0;
-				slave.inflationMethod = 0;
-				slave.milkSource = 0;
-				slave.cumSource = 0;
-				SetBellySize(slave);
+				deflate(slave);
 			}
 		}
 	}
diff --git a/src/js/assignJS.js b/src/js/assignJS.js
index 6a83d473be1..3cbfd18eee4 100644
--- a/src/js/assignJS.js
+++ b/src/js/assignJS.js
@@ -548,10 +548,7 @@ globalThis.removeJob = function(slave, assignment, saveRecord = false) {
 			case "cellblock":
 				slave.assignment = Job.REST;
 				if (slave.inflation > 0) {
-					slave.inflation = 0;
-					slave.inflationType = "none";
-					slave.inflationMethod = 0;
-					SetBellySize(slave);
+					deflate(slave);
 				}
 				break;
 
diff --git a/src/js/removeActiveSlave.js b/src/js/removeActiveSlave.js
index 1f216d784f9..95ea18e2bda 100644
--- a/src/js/removeActiveSlave.js
+++ b/src/js/removeActiveSlave.js
@@ -80,21 +80,8 @@ globalThis.removeActiveSlave = function() {
 					slave.sisters--;
 				}
 			}
-			if (slave.milkSource !== 0) {
-				if (slave.milkSource === AS_ID) {
-					slave.milkSource = 0;
-					slave.inflation = 0;
-					slave.inflationType = "none";
-					slave.inflationMethod = 0;
-				}
-			}
-			if (slave.cumSource !== 0) {
-				if (slave.cumSource === AS_ID) {
-					slave.cumSource = 0;
-					slave.inflation = 0;
-					slave.inflationType = "none";
-					slave.inflationMethod = 0;
-				}
+			if (slave.cumSource === AS_ID || slave.milkSource === AS_ID) {
+				deflate(slave);
 			}
 			if (slave.ID === V.activeSlave.relationshipTarget) {
 				slave.relationship = 0;
@@ -291,21 +278,8 @@ globalThis.removeNonNGPSlave = function(removedSlave) {
 					}
 					missing = true;
 				}
-				if (slave.milkSource !== 0) {
-					if (slave.milkSource === ID) {
-						slave.milkSource = 0;
-						slave.inflation = 0;
-						slave.inflationType = "none";
-						slave.inflationMethod = 0;
-					}
-				}
-				if (slave.cumSource !== 0) {
-					if (slave.cumSource === ID) {
-						slave.cumSource = 0;
-						slave.inflation = 0;
-						slave.inflationType = "none";
-						slave.inflationMethod = 0;
-					}
+				if (slave.milkSource === ID || slave.cumSource === ID) {
+					deflate(slave);
 				}
 				if (slave.ID === removedSlave.relationshipTarget) {
 					slave.relationship = 0;
diff --git a/src/js/utilsFC.js b/src/js/utilsFC.js
index 027493e3581..3f0b2ea0c45 100644
--- a/src/js/utilsFC.js
+++ b/src/js/utilsFC.js
@@ -2984,3 +2984,15 @@ App.Utils.economicUncertainty = function(arcologyID) {
 	}
 	return jsRandom(100 - uncertainty, 100 + uncertainty) / 100;
 };
+
+/** Deflate a slave (reset inflation to none)
+ * @param {App.Entity.SlaveState} slave
+ */
+globalThis.deflate = function(slave) {
+	slave.inflation = 0;
+	slave.inflationType = "none";
+	slave.inflationMethod = 0;
+	slave.milkSource = 0;
+	slave.cumSource = 0;
+	SetBellySize(slave);
+};
diff --git a/src/npc/interaction/fAbuse.tw b/src/npc/interaction/fAbuse.tw
index 34bec7207e3..8ca0f393366 100644
--- a/src/npc/interaction/fAbuse.tw
+++ b/src/npc/interaction/fAbuse.tw
@@ -58,12 +58,10 @@
 	<<if getSlave($AS).bellyFluid >= 10000>>
 		<<if getSlave($AS).inflationMethod == 2>>
 			which causes $him to discharge $his contained <<= getSlave($AS).inflationType>> all over $himself before collapsing into $his puddle on the floor in agony.
-			<<set getSlave($AS).inflation = 0, getSlave($AS).inflationType = "none", getSlave($AS).inflationMethod = 0, getSlave($AS).cumSource = 0, getSlave($AS).milkSource = 0>>
-			<<run SetBellySize(getSlave($AS))>>
+			<<run deflate(getSlave($AS))>>
 		<<else>>
 			which causes $him to vomit up $his contained <<= getSlave($AS).inflationType>> all over $himself before collapsing into $his puddle on the floor in agony.
-			<<set getSlave($AS).inflation = 0, getSlave($AS).inflationType = "none", getSlave($AS).inflationMethod = 0, getSlave($AS).cumSource = 0, getSlave($AS).milkSource = 0>>
-			<<run SetBellySize(getSlave($AS))>>
+			<<run deflate(getSlave($AS))>>
 		<</if>>
 	<<elseif getSlave($AS).bellyFluid >= 5000>>
 		<<if random(1,100) > getSlave($AS).devotion>>
@@ -71,12 +69,10 @@
 		<<else>>
 			<<if getSlave($AS).inflationMethod == 2>>
 				which causes $him to discharge $his contained <<= getSlave($AS).inflationType>> all over $himself before collapsing into $his puddle on the floor in agony.
-				<<set getSlave($AS).inflation = 0, getSlave($AS).inflationType = "none", getSlave($AS).inflationMethod = 0, getSlave($AS).cumSource = 0, getSlave($AS).milkSource = 0>>
-				<<run SetBellySize(getSlave($AS))>>
+				<<run deflate(getSlave($AS))>>
 			<<else>>
 				which causes $him to vomit up $his contained <<= getSlave($AS).inflationType>> all over $himself before collapsing into $his puddle on the floor in agony.
-				<<set getSlave($AS).inflation = 0, getSlave($AS).inflationType = "none", getSlave($AS).inflationMethod = 0, getSlave($AS).cumSource = 0, getSlave($AS).milkSource = 0>>
-				<<run SetBellySize(getSlave($AS))>>
+				<<run deflate(getSlave($AS))>>
 			<</if>>
 		<</if>>
 	<<else>>
diff --git a/src/npc/interaction/fSlaveFeed.tw b/src/npc/interaction/fSlaveFeed.tw
index c621bc715e6..a91527177c4 100644
--- a/src/npc/interaction/fSlaveFeed.tw
+++ b/src/npc/interaction/fSlaveFeed.tw
@@ -151,8 +151,8 @@ Next, you see to <<= getSlave($AS).slaveName>>.
 
 <<if getSlave($AS).preg > getSlave($AS).pregData.normalBirth/13.33 && getSlave($AS).pregKnown == 0 && getSlave($AS).inflation > 1>>
 	It becomes abundantly clear that something is wrong with <<= getSlave($AS).slaveName>> as $he struggles to down $his milky meal. Before $his health can be affected further, you pull $him into a medical exam. While most of the tests come back normal, one in particular catches your eye; @@.lime;$he is pregnant<<if getSlave($AS).preg > getSlave($AS).pregData.normalBirth/4>> and surprisingly far along<</if>>.@@ $he should be able to still handle at least two liters of milk, however.
-	<<set getSlave($AS).inflation = 0, getSlave($AS).inflationType = "none", getSlave($AS).inflationMethod = 0, getSlave($AS).pregKnown = 1>>
-	<<set _pregDiscovery = 1>>
+	<<run deflate(getSlave($AS))>>
+	<<set getSlave($AS).pregKnown = 1, _pregDiscovery = 1>>
 
 <<elseif $milkTap.fuckdoll > 0>>
 	Slight moaning emanates from the Fuckdoll as <<= getSlave($AS).slaveName>> drinks from _his2 breasts. You enjoy the show, specifically the sight of <<= getSlave($AS).slaveName>>'s belly steadily growing larger until <<if getSlave($AS).inflation == 3>>$his belly is round and taut, making $him look pregnant. $He pops off _his2 nipple and settles into _his2 breasts for a short rest while hiccupping<<if hasAnyArms(getSlave($AS))>> and rubbing $his gurgling stomach<</if>><<elseif getSlave($AS).inflation == 2>>$his belly is round, jiggling and sloshing with milk. $He pops off _his2 nipple and settles into _his2 breasts for a short rest while hiccupping<<if hasAnyArms(getSlave($AS))>> and teasing $his wobbling, gurgling stomach<</if>><<elseif getSlave($AS).inflation == 1>>$his belly is distended and sloshing with milk. $He pops off _his2 nipple and settles into _his2 breasts for a short rest while hiccupping<<if hasAnyArms(getSlave($AS))>> and teasing $his gurgling stomach<</if>><</if>>.
@@ -494,8 +494,8 @@ Next, you see to <<= getSlave($AS).slaveName>>.
 
 <<if getSlave($AS).preg > 3 && getSlave($AS).pregKnown == 0 && getSlave($AS).inflation > 1>>
 	It becomes abundantly clear that something is wrong with <<= getSlave($AS).slaveName>> as $he struggles to down $his thick meal. Before $his health can be affected further, you pull $him into a medical exam. While most of the tests come back normal, one in particular catches your eye; @@.lime;$he is pregnant<<if getSlave($AS).preg > 10>> and surprisingly far along<</if>>.@@ $he should be able to still handle at least two liters of cum, however.
-	<<set getSlave($AS).inflation = 0, getSlave($AS).inflationType = "none", getSlave($AS).inflationMethod = 0, getSlave($AS).pregKnown = 1>>
-	<<set _pregDiscovery = 1>>
+	<<run deflate(getSlave($AS))>>
+	<<set getSlave($AS).pregKnown = 1, _pregDiscovery = 1>>
 
 <<elseif $milkTap.fuckdoll > 0>>
 	Slight moaning emanates from the Fuckdoll as <<= getSlave($AS).slaveName>> sucks _his2 dick. You enjoy the show, specifically the sight of <<= getSlave($AS).slaveName>>'s belly steadily growing larger until <<if getSlave($AS).inflation == 3>>$his belly is round and taut, making $him look pregnant. $He pops off _his2 cock and settles into _his2 balls for a short rest while hiccupping<<if hasAnyArms(getSlave($AS))>> and rubbing $his gurgling stomach<</if>><<elseif getSlave($AS).inflation == 2>>$his belly is round, jiggling and sloshing with cum. $He pops off _his2 cock and settles into _his2 balls for a short rest while hiccupping<<if hasAnyArms(getSlave($AS))>> and teasing $his wobbling, gurgling stomach<</if>><<elseif getSlave($AS).inflation == 1>>$his belly is distended and sloshing with cum. $He pops off _his2 cock and settles into _his2 balls for a short rest while hiccupping<<if hasAnyArms(getSlave($AS))>> and teasing $his gurgling stomach<</if>><</if>>.
diff --git a/src/npc/interaction/fillUpButt.tw b/src/npc/interaction/fillUpButt.tw
index b369ec7e734..fb6591c6a9d 100644
--- a/src/npc/interaction/fillUpButt.tw
+++ b/src/npc/interaction/fillUpButt.tw
@@ -71,7 +71,8 @@ before shoving the equipment into $his
 
 <<if _pregDiscovery == 1>>
 	Not wanting to risk such a mess, you send $him for a medical examination. While most of the tests come back normal, one in particular catches your eye; @@.lime;$he is pregnant<<if getSlave($AS).preg > getSlave($AS).pregData.normalBirth/4>> and surprisingly far along<</if>>.@@ $he should be able to still handle at least two liters of <<= getSlave($AS).inflationType>> up $his ass, however.
-	<<set getSlave($AS).inflation = 0, getSlave($AS).inflationType = "none", getSlave($AS).inflationMethod = 0, getSlave($AS).pregKnown = 1>>
+	<<run deflate(getSlave($AS))>>
+	<<set getSlave($AS).pregKnown = 1>>
 <<elseif getSlave($AS).fetish == "mindbroken">>
 	<<if canWalk(getSlave($AS))>>
 		You instruct $him to present $his buttocks and anus but $he remains still and unresponsive. Talking to a broken mind is pointless.
diff --git a/src/npc/interaction/fillUpFace.tw b/src/npc/interaction/fillUpFace.tw
index fa1034e68fd..f2986ca9e03 100644
--- a/src/npc/interaction/fillUpFace.tw
+++ b/src/npc/interaction/fillUpFace.tw
@@ -25,7 +25,8 @@ You attach a hose to $dairyName tap with the pipes set to pump <<= getSlave($AS)
 
 <<if _pregDiscovery == 1>>
 	Not wanting to risk such a mess, you send $him for a medical examination. While most of the tests come back normal, one in particular catches your eye; @@.lime;$He is pregnant<<if getSlave($AS).preg > getSlave($AS).pregData.normalBirth/4>> and surprisingly far along<</if>>.@@ $He should be able to still handle at least two liters of <<= getSlave($AS).inflationType>>, however.
-	<<set getSlave($AS).inflation = 0, getSlave($AS).inflationType = "none", getSlave($AS).inflationMethod = 0, getSlave($AS).pregKnown = 1>>
+	<<run deflate(getSlave($AS))>>
+	<<set getSlave($AS).pregKnown = 1>>
 <<elseif getSlave($AS).fetish == "mindbroken">>
 	<<if canWalk(getSlave($AS))>>
 		You instruct $him to take a seat on your lap and open $his mouth wide for the hose, but $he remains still and unresponsive. Talking to a broken mind is pointless.
diff --git a/src/npc/interaction/forceFeeding.tw b/src/npc/interaction/forceFeeding.tw
index 263e4f0d5f5..4c7a27e63d9 100644
--- a/src/npc/interaction/forceFeeding.tw
+++ b/src/npc/interaction/forceFeeding.tw
@@ -523,7 +523,8 @@ and a little jiggle from $his gut.
 
 <<if _pregDiscovery == 1>>
 	Once you've managed to stop $his heaving and clean up, you decide to get to the root of this mess. While most of the tests come back normal, one in particular catches your eye; @@.lime;$he is pregnant <<if getSlave($AS).preg > getSlave($AS).pregData.normalBirth/4>> and surprisingly far along<</if>>.@@
-	<<set getSlave($AS).inflation = 0, getSlave($AS).inflationType = "none", getSlave($AS).inflationMethod = 0, getSlave($AS).pregKnown = 1>>
+	<<run deflate(getSlave($AS))>>
+	<<set getSlave($AS).pregKnown = 1>>
 <<else>>
 	<<if getSlave($AS).inflation == 3>>
 		<<if canWalk(getSlave($AS))>>
diff --git a/src/npc/surgery/surgery.js b/src/npc/surgery/surgery.js
index 7db885a87d4..cfb05caf0ff 100644
--- a/src/npc/surgery/surgery.js
+++ b/src/npc/surgery/surgery.js
@@ -1120,9 +1120,5 @@ globalThis.beginFuckdoll = function(slave) {
 	slave.subTarget = 0;
 	slave.sentence = 0;
 	slave.training = 0;
-	slave.inflation = 0;
-	slave.inflationType = "none";
-	slave.inflationMethod = 0;
-	slave.milkSource = 0;
-	slave.cumSource = 0;
+	deflate(slave);
 };
diff --git a/src/pregmod/widgets/bodyswapWidgets.tw b/src/pregmod/widgets/bodyswapWidgets.tw
index c69a68d7bdb..ee9c226b664 100644
--- a/src/pregmod/widgets/bodyswapWidgets.tw
+++ b/src/pregmod/widgets/bodyswapWidgets.tw
@@ -194,8 +194,8 @@
 	<<set $args[0].dietMilk = $args[1].dietMilk>>
 	<<set $args[0].clothes = $args[1].clothes>>
 	<<set $args[0].collar = $args[1].collar>>
-	<<set $args[0].faceAccessory  = $args[1].faceAccessory >>
-	<<set $args[0].mouthAccessory  = $args[1].mouthAccessory >>
+	<<set $args[0].faceAccessory  = $args[1].faceAccessory>>
+	<<set $args[0].mouthAccessory  = $args[1].mouthAccessory>>
 	<<set $args[0].shoes = $args[1].shoes>>
 	<<set $args[0].makeup = $args[1].makeup>>
 	<<set $args[0].nails = $args[1].nails>>
@@ -205,7 +205,6 @@
 	<<set $args[0].buttplugAttachment = $args[1].buttplugAttachment>>
 	<<set $args[0].induce = $args[1].induce>>
 	<<set $args[0].mpreg = $args[1].mpreg>>
-	<<set $args[0].inflation = 0, $args[0].inflationType = "none", $args[0].inflationMethod = 0, $args[0].milkSource = 0, $args[0].cumSource = 0>>
 	<<set $args[0].pregKnown = $args[1].pregKnown>>
 	<<set $args[0].pregWeek = $args[1].pregWeek>>
 	<<set $args[0].belly = $args[1].belly>>
@@ -218,6 +217,7 @@
 	<<set $args[0].cervixImplant = $args[1].cervixImplant>>
 	<<set $args[0].scar = $args[1].scar>>
 	<<set $args[0].pregControl = $args[1].pregControl>>
+	<<run deflate($args[0])>>
 <</if>>
 /*
 <<if def $args[2]>>
diff --git a/src/uncategorized/arcadeReport.tw b/src/uncategorized/arcadeReport.tw
index 627820383a6..12a2ec97d1d 100644
--- a/src/uncategorized/arcadeReport.tw
+++ b/src/uncategorized/arcadeReport.tw
@@ -136,8 +136,7 @@
 		<</if>>
 	<</if>>
 	<<if (_slave.inflation > 0)>>
-		<<set _slave.inflation = 0, _slave.inflationType = "none", _slave.inflationMethod = 0, _slave.milkSource = 0>>
-		<<run SetBellySize(_slave)>>
+		<<run deflate(_slave)>>
 	<</if>>
 	<<if $showEWD != 0>>
 		<br>&nbsp;&nbsp;&nbsp;
diff --git a/src/uncategorized/cellblockReport.tw b/src/uncategorized/cellblockReport.tw
index 3dda3ca2d91..4738d770d7e 100644
--- a/src/uncategorized/cellblockReport.tw
+++ b/src/uncategorized/cellblockReport.tw
@@ -178,8 +178,7 @@
 	<<case "Paternalist">>
 		<<set _slave.rules.living = "normal">>
 		<<if (_slave.inflation > 0)>>
-			<<set _slave.inflation = 0, _slave.inflationType = "none", _slave.inflationMethod = 0, _slave.milkSource = 0>>
-			<<run SetBellySize(_slave)>>
+			<<run deflate(_slave)>>
 		<</if>>
 	<<case "Pastoralist">>
 		<<set _slave.rules.living = "spare">>
@@ -216,8 +215,7 @@
 	<<default>>
 		<<set _slave.rules.living = "spare">>
 		<<if (_slave.inflation > 0)>>
-			<<set _slave.inflation = 0, _slave.inflationType = "none", _slave.inflationMethod = 0, _slave.milkSource = 0>>
-			<<run SetBellySize(_slave)>>
+			<<run deflate(_slave)>>
 		<</if>>
 	<</switch>>
 	<<if $cellblockUpgrade == 1>>
diff --git a/src/uncategorized/dairyReport.tw b/src/uncategorized/dairyReport.tw
index b83bd981ccb..4004c7f2d22 100644
--- a/src/uncategorized/dairyReport.tw
+++ b/src/uncategorized/dairyReport.tw
@@ -431,8 +431,7 @@
 		<<run improveCondition(_slave, 3)>>
 	<</if>>
 	<<if (_slave.inflation > 0)>>
-		<<set _slave.inflation = 0, _slave.inflationType = "none", _slave.inflationMethod = 0, _slave.milkSource = 0>>
-		<<run SetBellySize(_slave)>>
+		<<run deflate(_slave)>>
 	<</if>>
 	<<set _gigantomastiaMod = _slave.geneticQuirks.gigantomastia == 2 ? (_slave.geneticQuirks.macromastia == 2 ? 3 : 2) : 1>>
 	<<if (_slave.lactation > 0) && (($dairySlimMaintain == 0) || (_slave.boobs > 700))>>
diff --git a/src/uncategorized/pUndergroundRailroad.tw b/src/uncategorized/pUndergroundRailroad.tw
index a341d1473d1..9dc6a6247b3 100644
--- a/src/uncategorized/pUndergroundRailroad.tw
+++ b/src/uncategorized/pUndergroundRailroad.tw
@@ -135,7 +135,7 @@ This is disturbing, to say the least. After close investigation, it appears some
 		<<set $traitor = clone($activeSlave)>>
 		<<set $traitor.assignment = "rest">>
 		<<set $traitor.pregControl = "none">>
-		<<set $traitor.inflation = 0, $traitor.inflationType = "none", $traitor.inflationMethod = 0, SetBellySize($traitor)>>
+		<<run deflate($traitor)>>
 		<<set $traitorStats = {PCpregSource: 0, PCmother: 0, PCfather: 0, traitorMother: [], traitorFather: [], traitorPregSources: [], traitorMotherTank: [], traitorFatherTank: [], traitorBody: 0}>>
 		<<if $traitor.ID == $PC.pregSource>>
 			<<set $traitorStats.PCpregSource = $traitor.ID>>
@@ -265,7 +265,7 @@ This is disturbing, to say the least. After close investigation, it appears some
 		<<set $traitor = clone($activeSlave)>>
 		<<set $traitor.assignment = "rest">>
 		<<set $traitor.pregControl = "none">>
-		<<set $traitor.inflation = 0, $traitor.inflationType = "none", $traitor.inflationMethod = 0, SetBellySize($traitor)>>
+		<<run deflate($traitor)>>
 		<<set $traitorStats = {PCpregSource: 0, PCmother: 0, PCfather: 0, traitorMother: [], traitorFather: [], traitorPregSources: [], traitorMotherTank: [], traitorFatherTank: [], traitorBody: 0}>>
 		<<if $traitor.ID == $PC.pregSource>>
 			<<set $traitorStats.PCpregSource = $traitor.ID>>
-- 
GitLab