From 75f510167159cacad42cd759fb2d9efa51daa6c9 Mon Sep 17 00:00:00 2001
From: Pregmodder <pregmodder@gmail.com>
Date: Wed, 23 May 2018 11:43:48 -0400
Subject: [PATCH] Bodyswapping and fixes

---
 src/pregmod/fSlaveFeed.tw                 |   2 +-
 src/pregmod/huskSlaveSwap.tw              |  17 ++
 src/pregmod/huskSlaveSwapWorkaround.tw    |   2 +
 src/pregmod/slaveSlaveSwap.tw             | 191 ++++++++++++++++++++++
 src/pregmod/slaveSlaveSwapWorkaround.tw   |  19 +++
 src/pregmod/widgets/bodyswapWidgets.tw    |   8 +-
 src/pregmod/widgets/pregmodWidgets.tw     |   6 +
 src/uncategorized/pCoupAttempt.tw         |   6 +
 src/uncategorized/pUndergroundRailroad.tw |   9 +-
 src/uncategorized/reBoomerang.tw          |   6 +
 src/uncategorized/remoteSurgery.tw        |   6 +-
 src/uncategorized/slaveSold.tw            |   9 +-
 src/utility/slaveCreationWidgets.tw       |   2 +-
 13 files changed, 271 insertions(+), 12 deletions(-)
 create mode 100644 src/pregmod/slaveSlaveSwap.tw
 create mode 100644 src/pregmod/slaveSlaveSwapWorkaround.tw

diff --git a/src/pregmod/fSlaveFeed.tw b/src/pregmod/fSlaveFeed.tw
index 21309b9d213..7592aec7e94 100644
--- a/src/pregmod/fSlaveFeed.tw
+++ b/src/pregmod/fSlaveFeed.tw
@@ -186,7 +186,7 @@ Next, you see to $activeSlave.slaveName.
 <<elseif $activeSlave.mother == $milkTap.ID>>
 	$milkTap.slaveName sighs contently as _his2 little $girl once again suckles from _his2 breasts. You enjoy the show, specifically the sight of $activeSlave.slaveName's belly steadily growing larger until <<if $activeSlave.inflation == 3>>$his belly is round and taut, making $him look pregnant. $He pops off $his mother's nipple and settles into _his2 breasts for a short rest while hiccuping<<if $activeSlave.amp != 1>> and rubbing $his gurgling stomach<</if>><<elseif $activeSlave.inflation == 2>>$his belly is round, jiggling and sloshing with milk. $He pops off $his mother's nipple and settles into _his2 breasts for a short rest while hiccuping<<if $activeSlave.amp != 1>> and teasing $his wobbling, gurgling stomach<</if>><<elseif $activeSlave.inflation == 1>>$his belly is distended and sloshing with milk. $He pops off $his mother's nipple and settles into _his2 breasts for a short rest while hiccuping<<if $activeSlave.amp != 1>> and teasing $his gurgling stomach<</if>><</if>>.
 <<elseif $activeSlave.father == $milkTap.ID>>
-	$milkTap.slaveName moans lewdly as _his2 daughter suckles from _his2 breasts<<if $milkTap.dick > 0 && canAchieveErction($milkTap)>>, _his2 dick throbbing with lust<</if>>. You enjoy the show, specifically the sight of $activeSlave.slaveName's belly steadily growing larger until <<if $activeSlave.inflation == 3>>$his belly is round and taut, making $him look pregnant. $He pops off $his father's nipple and settles into _his2 breasts for a short rest while hiccuping<<if $activeSlave.amp != 1>> and rubbing $his gurgling stomach<</if>><<elseif $activeSlave.inflation == 2>>$his belly is round, jiggling and sloshing with milk. $He pops off $his father's nipple and settles into _his2 breasts for a short rest while hiccuping<<if $activeSlave.amp != 1>> and teasing $his wobbling, gurgling stomach<</if>><<elseif $activeSlave.inflation == 1>>$his belly is distended and sloshing with milk. $He pops off $his father's nipple and settles into _his2 breasts for a short rest while hiccuping<<if $activeSlave.amp != 1>> and teasing $his gurgling stomach<</if>><</if>><<if $milkTap.dick > 0 && canAchieveErction($milkTap)>><<if $activeSlave.sexualQuirk == "perverted">>. The way $he is wiggling $his hips suggests $he isn't finished with $his daddy just yet, and $his father's moaning confirms $he is teasing him with $his rear. $He giggles as the horny cow unloads on $his backside<<else>>. $He doesn't stay put for long, as a strong moan and a blast of cum across $his rear from the horny cow startles $his from $his rest<</if>><</if>>.
+	$milkTap.slaveName moans lewdly as _his2 daughter suckles from _his2 breasts<<if $milkTap.dick > 0 && canAchieveErection($milkTap)>>, _his2 dick throbbing with lust<</if>>. You enjoy the show, specifically the sight of $activeSlave.slaveName's belly steadily growing larger until <<if $activeSlave.inflation == 3>>$his belly is round and taut, making $him look pregnant. $He pops off $his father's nipple and settles into _his2 breasts for a short rest while hiccuping<<if $activeSlave.amp != 1>> and rubbing $his gurgling stomach<</if>><<elseif $activeSlave.inflation == 2>>$his belly is round, jiggling and sloshing with milk. $He pops off $his father's nipple and settles into _his2 breasts for a short rest while hiccuping<<if $activeSlave.amp != 1>> and teasing $his wobbling, gurgling stomach<</if>><<elseif $activeSlave.inflation == 1>>$his belly is distended and sloshing with milk. $He pops off $his father's nipple and settles into _his2 breasts for a short rest while hiccuping<<if $activeSlave.amp != 1>> and teasing $his gurgling stomach<</if>><</if>><<if $milkTap.dick > 0 && canAchieveErection($milkTap)>><<if $activeSlave.sexualQuirk == "perverted">>. The way $he is wiggling $his hips suggests $he isn't finished with $his daddy just yet, and $his father's moaning confirms $he is teasing him with $his rear. $He giggles as the horny cow unloads on $his backside<<else>>. $He doesn't stay put for long, as a strong moan and a blast of cum across $his rear from the horny cow startles $his from $his rest<</if>><</if>>.
 <<elseif $milkTap.mother == $activeSlave.ID>>
 	$milkTap.slaveName moans lewdly as _he2 enjoys some role reversal as _his2 mother suckles from _his2 breasts. You enjoy the show, specifically the sight of $activeSlave.slaveName's belly steadily growing larger until <<if $activeSlave.inflation == 3>>$his belly is round and taut, making $him look pregnant. $He pops off $his daughter's nipple and settles into _his2 breasts for a short rest while hiccuping<<if $activeSlave.amp != 1>> and rubbing $his gurgling stomach<</if>><<elseif $activeSlave.inflation == 2>>$his belly is round, jiggling and sloshing with milk. $He pops off $his daughter's nipple and settles into _his2 breasts for a short rest while hiccuping<<if $activeSlave.amp != 1>> and teasing $his wobbling, gurgling stomach<</if>><<elseif $activeSlave.inflation == 1>>$his belly is distended and sloshing with milk. $He pops off $his daughter's nipple and settles into _his2 breasts for a short rest while hiccuping<<if $activeSlave.amp != 1>> and teasing $his gurgling stomach<</if>><</if>>.
 <<elseif $milkTap.father == $activeSlave.ID>>
diff --git a/src/pregmod/huskSlaveSwap.tw b/src/pregmod/huskSlaveSwap.tw
index 6ec70ad4761..88cbd71af17 100644
--- a/src/pregmod/huskSlaveSwap.tw
+++ b/src/pregmod/huskSlaveSwap.tw
@@ -18,6 +18,23 @@ After an honestly impressive procedure,
 <<slaveCost _oldSlave>>
 <<set _payout = Math.trunc($slaveCost/3)>>
 $slaves[_m].slaveName's body was bought by the Flesh Heap for <<print cashFormat(_payout)>>.
+<<if $slaves[_ss1].bodySwap > 0>>
+	<<set _myBody = $slaves.findIndex(function(s) { return s.origBodyOwnerID == $slaves[_m].ID; })>>
+	<<if _myBody != -1>>
+		<<set $slaves[_myBody].origBodyOwnerID = 0>>
+		<<if $slaves[_myBody].fetish != "mindbroken" && $slaves[_myBody].fuckdoll == 0>>
+			<<if $slaves[_myBody].devotion > 20>>
+				$slaves[_myBody].slaveName is somwhat saddened to see her body leave forever.
+			<<elseif  $slaves[_myBody].devotion >= -50>>
+				$slaves[_myBody].slaveName is @@.medimorchid;disturbed@@ to find her body is gone for good, damaging her @@.gold;ability to trust you.@@
+				<<set $slaves[_myBody].devotion -= 10, $slaves[_myBody].trust -= 5>>
+			<<else>>
+				$slaves[_myBody].slaveName is @@.medimorchid;deeply upset@@ that she'll never see her body again. With so little left, she finds it easy to take vengeance by @@.mediumaquamarine;completely rejecting your ownership of her.@@
+				<<set $slaves[_myBody].devotion -= 50, $slaves[_myBody].trust += 200>>
+			<</if>>
+		<</if>>
+	<</if>>
+<</if>>
 <<set $slaves[_m].bodySwap++>>
 <<set $cash += _payout>>
 <<set $activeSlave = 0, $swappingSlave = 0>>
diff --git a/src/pregmod/huskSlaveSwapWorkaround.tw b/src/pregmod/huskSlaveSwapWorkaround.tw
index 533e6bb6543..f273dde92a5 100644
--- a/src/pregmod/huskSlaveSwapWorkaround.tw
+++ b/src/pregmod/huskSlaveSwapWorkaround.tw
@@ -12,6 +12,7 @@
 __Select an eligible slave:__
 <<for _i = 0; _i < $slaves.length; _i++>>
 	<<if isSlaveAvailable($slaves[_i])>>
+	<<if $slaves[_i].fuckdoll == 0>>
 	<<if ($slaves[_i].PLimb == 0) || ($slaves[_i].PLimb == 1 && $slaves[_i].amp == 1)>>
 	<<if ($slaves[_i].indenture == -1)>>
 	<<if ($slaves[_i].breedingMark == 0)>>
@@ -24,4 +25,5 @@ __Select an eligible slave:__
 	<</if>>
 	<</if>>
 	<</if>>
+	<</if>>
 <</for>>
diff --git a/src/pregmod/slaveSlaveSwap.tw b/src/pregmod/slaveSlaveSwap.tw
new file mode 100644
index 00000000000..bc9bb16fc60
--- /dev/null
+++ b/src/pregmod/slaveSlaveSwap.tw
@@ -0,0 +1,191 @@
+:: Slave Slave Swap [nobr]
+
+<<set $nextButton = "Continue">>
+<<set _ss1 = $slaveIndices[$activeSlave.ID]>>
+<<set _ss1Clone = clone($activeSlave)>>
+<<set _ss2 = $slaveIndices[$swappingSlave.ID]>>
+<<set _ss2Clone = clone($swappingSlave)>>
+<<set _gps1 = $genePool.findIndex(function(s) { return s.ID == $slaves[_ss1].ID; })>>
+<<set _gps1Clone = clone($genePool[_gps1])>>
+<<set _gps2 = $genePool.findIndex(function(s) { return s.ID == $slaves[_ss2].ID; })>>
+<<set _gps2Clone = clone($genePool[_gps2])>>
+
+You strap $activeSlave.slaveName and $swappingSlave.slaveName into the remote surgery and stand back as it goes to work.
+<<BodySwap $slaves[_ss1] _ss2Clone>>
+<<BodySwap $genePool[_gps1] _gps2Clone>>
+<<BodySwap $slaves[_ss2] _ss1Clone>>
+<<BodySwap $genePool[_gps2] _gps1Clone>>
+
+<br><br>
+After an honestly impressive procedure,
+
+<<BodySwapReaction $slaves[_ss1] _ss2Clone>>
+
+<br><br>
+
+In the neighboring bed,
+
+<<BodySwapReaction $slaves[_ss2] _ss1Clone>>
+
+/* figuring out whom has who's body now*/
+
+<<if $slaves[_ss1].bodySwap == 0>>
+	<<set $slaves[_ss1].origBodyOwnerID = _ss2Clone.ID>>
+<<elseif $slaves[_ss2].origBodyOwner !== "">> /* now who's going to be looking for you? */
+	<<set _myBody = $slaves.findIndex(function(s) { return s.origBodyOwnerID == $slaves[_ss2].ID; })>>
+	<<if _myBody != -1>>
+		<<set $slaves[_myBody].origBodyOwnerID = $slaves[_ss1].ID>>
+	<</if>>
+<</if>>
+
+<<if $slaves[_ss2].bodySwap == 0>>
+	<<set $slaves[_ss2].origBodyOwnerID = _ss1Clone.ID>>
+<<elseif $slaves[_ss1].origBodyOwner !== "">> /* now who's going to be looking for you? */
+	<<set _myBody = $slaves.findIndex(function(s) { return s.origBodyOwnerID == $slaves[_ss1].ID; })>>
+	<<if _myBody != -1>>
+		<<set $slaves[_myBody].origBodyOwnerID = $slaves[_ss2].ID>>
+	<</if>>
+<</if>>
+
+/* now to handle who's body it is */
+
+<<if $slaves[_ss2].bodySwap == 0>>
+	<<if $slaves[_ss2].birthSurname>>
+		<<if $surnameOrder != 1>>
+			<<switch $slaves[_ss2].nationality>>
+				<<case "Cambodian" "Chinese" "Hungarian" "Japanese" "Korean" "Mongolian" "Taiwanese" "Vietnamese">>
+					<<if $slaves[_ss2].birthName !== "">>
+						<<set $slaves[_ss1].origBodyOwner = $slaves[_ss2].birthSurname + " " + $slaves[_ss2].birthName>>
+					<<else>>
+						<<set $slaves[_ss1].origBodyOwner = $slaves[_ss2].birthSurname + " " + $slaves[_ss2].slaveName>>
+					<</if>>
+				<<default>>
+					<<if $slaves[_ss2].birthName !== "">>
+						<<set $slaves[_ss1].origBodyOwner = $slaves[_ss2].birthName + " " + $slaves[_ss2].birthSurname>>
+					<<else>>
+						<<set $slaves[_ss1].origBodyOwner = $slaves[_ss2].slaveName + " " + $slaves[_ss2].birthSurname>>
+					<</if>>
+			<</switch>>
+		<<else>>
+			<<if $slaves[_ss2].birthName !== "">>
+				<<set $slaves[_ss1].origBodyOwner = $slaves[_ss2].birthName + " " + $slaves[_ss2].birthSurname>>
+			<<else>>
+				<<set $slaves[_ss1].origBodyOwner = $slaves[_ss2].slaveName + " " + $slaves[_ss2].birthSurname>>
+			<</if>>
+		<</if>>
+	<<elseif $slaves[_ss2].birthName>>
+		<<if $slaves[_ss2].slaveSurname>>
+			<<if $surnameOrder != 1>>
+				<<switch $slaves[_ss2].nationality>>
+					<<case "Cambodian" "Chinese" "Hungarian" "Japanese" "Korean" "Mongolian" "Taiwanese" "Vietnamese">>
+						<<set $slaves[_ss1].origBodyOwner = $slaves[_ss2].slaveSurname + " " + $slaves[_ss2].birthName>>
+					<<default>>
+						<<set $slaves[_ss1].origBodyOwner = $slaves[_ss2].birthName + " " + $slaves[_ss2].slaveSurname>>
+				<</switch>>
+			<<else>>
+				<<set $slaves[_ss1].origBodyOwner = $slaves[_ss2].birthName + " " + $slaves[_ss2].slaveSurname>>
+			<</if>>
+		<<else>>
+			<<set $slaves[_ss1].origBodyOwner = $slaves[_ss2].birthName>>
+		<</if>>
+	<<elseif $slaves[_ss2].slaveSurname>>
+		<<if $surnameOrder != 1>>
+			<<switch $slaves[_ss2].nationality>>
+				<<case "Cambodian" "Chinese" "Hungarian" "Japanese" "Korean" "Mongolian" "Taiwanese" "Vietnamese">>
+					<<set $slaves[_ss1].origBodyOwner = $slaves[_ss2].slaveSurname + " " + $slaves[_ss2].slaveName>>
+				<<default>>
+					<<set $slaves[_ss1].origBodyOwner = $slaves[_ss2].slaveName + " " + $slaves[_ss2].slaveSurname>>
+			<</switch>>
+		<<else>>
+			<<set $slaves[_ss1].origBodyOwner = $slaves[_ss2].slaveName + " " + $slaves[_ss2].slaveSurname>>
+		<</if>>
+	<<else>>
+		<<set $slaves[_ss1].origBodyOwner = $slaves[_ss2].slaveName>>
+	<</if>>
+<<else>> 
+	<<set $slaves[_ss1].origBodyOwner = $slaves[_ss2].origBodyOwner>>
+<</if>>
+
+<<if $slaves[_ss1].bodySwap == 0>>
+	<<if $slaves[_ss1].birthSurname>>
+		<<if $surnameOrder != 1>>
+			<<switch $slaves[_ss1].nationality>>
+				<<case "Cambodian" "Chinese" "Hungarian" "Japanese" "Korean" "Mongolian" "Taiwanese" "Vietnamese">>
+					<<if $slaves[_ss1].birthName !== "">>
+						<<set $slaves[_ss2].origBodyOwner = $slaves[_ss1].birthSurname + " " + $slaves[_ss1].birthName>>
+					<<else>>
+						<<set $slaves[_ss2].origBodyOwner = $slaves[_ss1].birthSurname + " " + $slaves[_ss1].slaveName>>
+					<</if>>
+				<<default>>
+					<<if $slaves[_ss1].birthName !== "">>
+						<<set $slaves[_ss2].origBodyOwner = $slaves[_ss1].birthName + " " + $slaves[_ss1].birthSurname>>
+					<<else>>
+						<<set $slaves[_ss2].origBodyOwner = $slaves[_ss1].slaveName + " " + $slaves[_ss1].birthSurname>>
+					<</if>>
+			<</switch>>
+		<<else>>
+			<<if $slaves[_ss1].birthName !== "">>
+				<<set $slaves[_ss2].origBodyOwner = $slaves[_ss1].birthName + " " + $slaves[_ss1].birthSurname>>
+			<<else>>
+				<<set $slaves[_ss2].origBodyOwner = $slaves[_ss1].slaveName + " " + $slaves[_ss1].birthSurname>>
+			<</if>>
+		<</if>>
+	<<elseif $slaves[_ss1].birthName>>
+		<<if $slaves[_ss1].slaveSurname>>
+			<<if $surnameOrder != 1>>
+				<<switch $slaves[_ss1].nationality>>
+					<<case "Cambodian" "Chinese" "Hungarian" "Japanese" "Korean" "Mongolian" "Taiwanese" "Vietnamese">>
+						<<set $slaves[_ss2].origBodyOwner = $slaves[_ss1].slaveSurname + " " + $slaves[_ss1].birthName>>
+					<<default>>
+						<<set $slaves[_ss2].origBodyOwner = $slaves[_ss1].birthName + " " + $slaves[_ss1].slaveSurname>>
+				<</switch>>
+			<<else>>
+				<<set $slaves[_ss2].origBodyOwner = $slaves[_ss1].birthName + " " + $slaves[_ss1].slaveSurname>>
+			<</if>>
+		<<else>>
+			<<set $slaves[_ss2].origBodyOwner = $slaves[_ss1].birthName>>
+		<</if>>
+	<<elseif $slaves[_ss1].slaveSurname>>
+		<<if $surnameOrder != 1>>
+			<<switch $slaves[_ss2].nationality>>
+				<<case "Cambodian" "Chinese" "Hungarian" "Japanese" "Korean" "Mongolian" "Taiwanese" "Vietnamese">>
+					<<set $slaves[_ss2].origBodyOwner = $slaves[_ss1].slaveSurname + " " + $slaves[_ss1].slaveName>>
+				<<default>>
+					<<set $slaves[_ss2].origBodyOwner = $slaves[_ss1].slaveName + " " + $slaves[_ss1].slaveSurname>>
+			<</switch>>
+		<<else>>
+			<<set $slaves[_ss2].origBodyOwner = $slaves[_ss1].slaveName + " " + $slaves[_ss1].slaveSurname>>
+		<</if>>
+	<<else>>
+		<<set $slaves[_ss2].origBodyOwner = $slaves[_ss1].slaveName>>
+	<</if>>
+<<else>> 
+	<<set $slaves[_ss2].origBodyOwner = $slaves[_ss1].origBodyOwner>>
+<</if>>
+
+
+<<if _ss1Clone.bodySwap > 0>>
+	<<if $slaves[_ss1].origBodyOwnerID == $slaves[_ss1].ID>>
+		<<set $slaves[_ss1].bodySwap = 0>>
+		<<set $slaves[_ss1].origBodyOwnerID = 0>>
+		<<set $slaves[_ss1].origBodyOwner = "">>
+	<<else>>
+		<<set $slaves[_ss1].bodySwap++>>
+	<</if>>
+<<else>>
+	<<set $slaves[_ss1].bodySwap++>>
+<</if>>
+
+<<if $slaves[_ss2].bodySwap > 0>>
+	<<if $slaves[_ss2].origBodyOwnerID == $slaves[_ss2].ID>>
+		<<set $slaves[_ss2].bodySwap = 0>>
+		<<set $slaves[_ss2].origBodyOwnerID = 0>>
+		<<set $slaves[_ss2].origBodyOwner = "">>
+	<<else>>
+		<<set $slaves[_ss2].bodySwap++>>
+	<</if>>
+<<else>>
+	<<set $slaves[_ss2].bodySwap++>>
+<</if>>
+
+<<set $activeSlave = 0, $swappingSlave = 0>>
diff --git a/src/pregmod/slaveSlaveSwapWorkaround.tw b/src/pregmod/slaveSlaveSwapWorkaround.tw
new file mode 100644
index 00000000000..10e67eacfc9
--- /dev/null
+++ b/src/pregmod/slaveSlaveSwapWorkaround.tw
@@ -0,0 +1,19 @@
+:: Slave Slave Swap Workaround [nobr]
+ 
+<<set $nextButton = "Abort Operation", $nextLink = "Main">>
+
+The surgeon awaits the pair of slaves to be strapped into the surgery. So far only $activeSlave.slaveName is prepped:
+<br>
+//Select the slave who will be trading bodies with $object.//
+
+<br><br>
+__Select an eligible slave:__
+<<for _i = 0; _i < $slaves.length; _i++>>
+	<<if isSlaveAvailable($slaves[_i])>>
+	<<if $slaves[_i].fuckdoll == 0>>
+	<<if ($slaves[_i].ID != $activeSlave.ID)>>
+		<br><<print "[[$slaves[_i].slaveName|Slave Slave Swap][$swappingSlave = $slaves[" + _i + "]]]">>
+	<</if>>
+	<</if>>
+	<</if>>
+<</for>>
\ No newline at end of file
diff --git a/src/pregmod/widgets/bodyswapWidgets.tw b/src/pregmod/widgets/bodyswapWidgets.tw
index 4c11b31c08f..2dd5925cd28 100644
--- a/src/pregmod/widgets/bodyswapWidgets.tw
+++ b/src/pregmod/widgets/bodyswapWidgets.tw
@@ -4,13 +4,6 @@
 
 /* first arg is slave getting swapped, second is body she is being swapped to. The second body's physical traits overwrite the originals */
 <<widget "BodySwap">>
-<<if $args[1].origin != "You reserved a mindless slave like her from the Flesh Heap.">>
-	<<if $args[0].origBodyOwner == "">>
-		<<set $args[0].origBodyOwner = ("The body of the slave " + $args[1].slaveName)>>
-	<<else>>
-		<<set $args[0].origBodyOwner = $args[1].origBodyOwner>>
-	<</if>>
-<</if>>
 
 <<set WombInit($args[1])>> /*Just to be sure.*/
 <<set $args[0].genes = $args[1].genes>>
@@ -169,6 +162,7 @@
 <<set $args[0].bellyPreg = $args[1].bellyPreg>>
 <<set $args[0].bellyFluid = $args[1].bellyFluid>>
 <<set $args[0].readyOva = $args[1].readyOva>>
+<<set $args[0].reservedChildren = $args[1].reservedChildren>>
 <<set $args[0].womb = $args[1].womb>> /* this is array assigned by reference, if slave body that is $args[1] will be stil used anywhere in code (not discarded) - it's WRONG (they now technically share one womb object). Please tell me about it then. But if old body $args[1] just discarded - it's no problem then.*/
 <<set $args[0].laborCount = $args[1].laborCount>>
 
diff --git a/src/pregmod/widgets/pregmodWidgets.tw b/src/pregmod/widgets/pregmodWidgets.tw
index cb6dd9b4798..6fb12bfed76 100644
--- a/src/pregmod/widgets/pregmodWidgets.tw
+++ b/src/pregmod/widgets/pregmodWidgets.tw
@@ -101,6 +101,12 @@
 <<if ndef $args[0].bodySwap>>
 	<<set $args[0].bodySwap = 0>>
 <</if>>
+<<if ndef $args[0].origBodyOwner>>
+	<<set $args[0].origBodyOwner = "">>
+<</if>>
+<<if ndef $args[0].origBodyOwnerID>>
+	<<set $args[0].origBodyOwnerID = 0>>
+<</if>>
 <<if ndef $args[0].father>>
 	<<set $args[0].father = 0>>
 <</if>>
diff --git a/src/uncategorized/pCoupAttempt.tw b/src/uncategorized/pCoupAttempt.tw
index 12bf5fe1180..4356f70b0df 100644
--- a/src/uncategorized/pCoupAttempt.tw
+++ b/src/uncategorized/pCoupAttempt.tw
@@ -185,6 +185,12 @@ You are awakened in the middle of the night by a jolt that shakes the entire arc
 			<</for>>
 		<</if>>
 	<</if>>
+	<<if $traitorStats.boomerangBody > 0>>
+		<<set _pca = $slaveIndices[$traitorStats.traitorBody]>>
+		<<if def _pca>>
+			<<set $slaves[_pca].origBodyOwnerID = $activeSlave.ID>>
+		<</if>>
+	<</if>>
 	<<set $traitor.health = random(-80,-60)>>
 	<<set $traitor.origin = "She was your slave, but you freed her, which she repaid by participating in a coup attempt against you. It failed, and she is again your chattel.">>
 	<<AddSlave $traitor>> /* skip New Slave Intro */
diff --git a/src/uncategorized/pUndergroundRailroad.tw b/src/uncategorized/pUndergroundRailroad.tw
index 84379644fcd..7dfc080a88c 100644
--- a/src/uncategorized/pUndergroundRailroad.tw
+++ b/src/uncategorized/pUndergroundRailroad.tw
@@ -98,7 +98,7 @@ that several nondescript citizens she sees occasionally at work have passed a fe
 		<<if def $i>><<set $slaves[$i].relationshipTarget = 0, $slaves[$i].relationship = 0>><<else>>@@.red;Error, relationshipTarget not found.@@<</if>>
 	<</if>>
 	<<set $traitor = $activeSlave>>
-	<<set $traitorStats = {PCpregSource: 0, PCmother: 0, PCfather: 0, traitorMother: [], traitorFather: [], traitorPregSources: [], traitorMotherTank: [], traitorFatherTank: []}>>
+	<<set $traitorStats = {PCpregSource: 0, PCmother: 0, PCfather: 0, traitorMother: [], traitorFather: [], traitorPregSources: [], traitorMotherTank: [], traitorFatherTank: [], traitorBody: 0}>>
 	<<if $familyTesting == 1>>
 		<<if $traitor.ID == $PC.pregSource>>
 			<<set $traitorStats.PCpregSource = $traitor.ID>>
@@ -142,6 +142,13 @@ that several nondescript citizens she sees occasionally at work have passed a fe
 			<</if>>
 		<</for>>
 	<</if>>
+	<<if $traitor.bodySwap > 0>>
+		<<set _myBody = $slaves.findIndex(function(s) { return s.origBodyOwnerID == $traitor.ID; })>>
+		<<if _myBody != -1>>
+			<<set $traitorStats.traitorBody = $slaves[_myBody].ID>>
+			<<set $slaves[_myBody].origBodyOwnerID = 0>>
+		<</if>>
+	<</if>>
 	<<include "Remove activeSlave">>
 	<</replace>>
 <</link>>
diff --git a/src/uncategorized/reBoomerang.tw b/src/uncategorized/reBoomerang.tw
index 2745c819357..eed3b7efbf8 100644
--- a/src/uncategorized/reBoomerang.tw
+++ b/src/uncategorized/reBoomerang.tw
@@ -420,6 +420,12 @@ It isn't obvious how she managed to escape, though no doubt you could review the
 			<<set $activeSlave.rivalry = 0, $activeSlave.rivalryTarget = 0>>
 		<</if>>
 	<</if>>
+	<<if $boomerangStats.boomerangBody > 0>>
+		<<set _reb = $slaveIndices[$boomerangStats.boomerangBody]>>
+		<<if def _reb>>
+			<<set $slaves[_reb].origBodyOwnerID = $activeSlave.ID>>
+		<</if>>
+	<</if>>
 	<<set $boomerangStats = 0>>
 	<<replace "#result">>
 		The penthouse opens, and $activeSlave.slaveName stumbles inside, sobbing her thanks. She's immediately conducted to the autosurgery for some quick cosmetic surgery, while you and $assistantName do the necessary work to falsify the arcology records and conceal her origins. Even so, it would probably be wise to keep her off public assignments for a while. In no time at all, she's standing in front of your desk like any other new slave. She waits obediently, knowing that it's in her best interests not to mention anything out of the ordinary.
diff --git a/src/uncategorized/remoteSurgery.tw b/src/uncategorized/remoteSurgery.tw
index d4ca486f4dc..f3943bc8305 100644
--- a/src/uncategorized/remoteSurgery.tw
+++ b/src/uncategorized/remoteSurgery.tw
@@ -1621,5 +1621,9 @@ The prosthesis facility has constructed $possessive prosthetic limbs.
 	<<else>>
 		$pronounCap is no longer in her native body.
 	<</if>>
-	[[Swap her body with another of your stock's|Slave Slave Swap Workaround]]
+	<<if $slaves[_i].indenture == -1>>
+		[[Swap her body with another of your stock's|Slave Slave Swap Workaround]]
+	<<else>>
+		//Indentured servants must remain in their own bodies.//
+	<</if>>
 <</if>>
diff --git a/src/uncategorized/slaveSold.tw b/src/uncategorized/slaveSold.tw
index 1ba3569eff0..aaa9dd89ae1 100644
--- a/src/uncategorized/slaveSold.tw
+++ b/src/uncategorized/slaveSold.tw
@@ -13,7 +13,7 @@
 	<<if $activeSlave.devotion > 50>>
 		<<if $activeSlave.trust > 95 || $activeSlave.trust < -20 || $activeSlave.intelligence < 0>>
 			<<set $boomerangSlave = $activeSlave, $boomerangWeeks = 1, $boomerangBuyer = $buyer>>
-			<<set $boomerangStats = {PCpregSource: 0, PCmother: 0, PCfather: 0, boomerangMother: [], boomerangFather: [], boomerangPregSources: [], boomerangMotherTank: [], boomerangFatherTank: [], boomerangRelationship: 0, boomerangRivalry: 0, boomerangRelation: 0}>>
+			<<set $boomerangStats = {PCpregSource: 0, PCmother: 0, PCfather: 0, boomerangMother: [], boomerangFather: [], boomerangPregSources: [], boomerangMotherTank: [], boomerangFatherTank: [], boomerangRelationship: 0, boomerangRivalry: 0, boomerangRelation: 0, boomerangBody: 0}>>
 			<<if $familyTesting == 1>>
 				<<if $activeSlave.ID == $PC.pregSource>>
 					<<set $boomerangStats.PCpregSource = $activeSlave.ID>>
@@ -66,6 +66,13 @@
 			<<if $activeSlave.rivalry > 0>>
 				<<set $boomerangStats.boomerangRivalry = $activeSlave.rivalryTarget>>
 			<</if>>
+			<<if $activeSlave.bodySwap > 0>>
+				<<set _myBody = $slaves.findIndex(function(s) { return s.origBodyOwnerID == $activeSlave.ID; })>>
+				<<if _myBody != -1>>
+					<<set $boomerangStats.boomerangBody = $slaves[_myBody].ID>>
+					<<set $slaves[_myBody].origBodyOwnerID = 0>>
+				<</if>>
+			<</if>>
 		<</if>>
 	<</if>>
 	<</if>>
diff --git a/src/utility/slaveCreationWidgets.tw b/src/utility/slaveCreationWidgets.tw
index cb75915f563..91808cdc2ec 100644
--- a/src/utility/slaveCreationWidgets.tw
+++ b/src/utility/slaveCreationWidgets.tw
@@ -6,7 +6,7 @@
 	Called from Gen XX, Gen XY, CheatMode DB, InitNationalities.
 %/
 <<widget "BaseSlave">>
-	<<set $activeSlave = {slaveName: "blank", slaveSurname: 0, birthName: "blank", birthSurname: 0, genes: "XX", pronoun: "she", possessive: "her", possessivePronoun: "hers", objectReflexive: "herself", object: "her", noun: "girl", weekAcquired: 0, origin: 0, career: 0, ID: 0, prestige: 0, pornFame: 0, pornFameSpending: 0, prestigeDesc: 0, recruiter: 0, relation: 0, relationTarget: 0, relationship: 0, relationshipTarget: 0, rivalry: 0, rivalryTarget: 0, subTarget: 0, father: 0, mother: 0, daughters: 0, sisters: 0, canRecruit: 0, choosesOwnAssignment: 0, assignment: "rest", assignmentVisible: 1, sentence: 0, training: 0, toyHole: "all her holes", indenture: -1, indentureRestrictions: 0, birthWeek: random(0,51), actualAge: 18, visualAge: 18, physicalAge: 18, ovaryAge: 18, ageImplant: 0, health: 0, minorInjury: 0, trust: 0, oldTrust: 0, devotion: 0, oldDevotion: 0, weight: 0, muscles: 0, height: 170, heightImplant: 0, nationality: "slave", race: "white", markings: "none", eyes: 1, eyeColor: "brown", origEye: "brown", eyewear: "none", origHColor: "brown", hColor: "brown", pubicHColor: "brown", skin: "light", hLength: 60, hStyle: "short", pubicHStyle: "neat", waist: 0, corsetPiercing: 0, PLimb: 0, amp: 0, heels:0, voice: 2, voiceImplant: 0, accent: 0, shoulders: 0, shouldersImplant: 0, boobs: 0, boobsImplant: 0, boobsImplantType: 0, boobShape: "normal", nipples: "cute",  nipplesPiercing: 0, nipplesAccessory: 0, areolae: 0, areolaePiercing: 0, boobsTat: 0, lactation: 0, lactationAdaptation: 0, milk: 0, cum: 0, hips: 0, hipsImplant: 0, butt: 0, buttImplant: 0, buttImplantType: 0, buttTat: 0, face: 0, faceImplant: 0, faceShape: "normal", lips: 15, lipsImplant: 0, lipsPiercing: 0, lipsTat: 0, teeth: "normal", tonguePiercing: 0, vagina: 0, vaginaLube: 0, vaginaPiercing: 0, vaginaTat: 0, preg: -1, pregSource: 0, pregType: 0, broodmother: 0, broodmotherFetuses: 0, broodmotherOnHold: 0, broodmotherCountDown: 0, labor: 0, births: 0, cSec: 0, bellyAccessory: "none", labia: 0, clit: 0, clitPiercing: 0, clitSetting: "vanilla", foreskin: 0, anus: 0, dick: 0, analArea: 1, dickPiercing: 0, dickTat: 0, prostate: 0, balls: 0, scrotum: 0, ovaries: 0, anusPiercing: 0, anusTat: 0, makeup: 0, nails: 0, brand: 0, brandLocation: 0, earPiercing: 0, nosePiercing: 0, eyebrowPiercing: 0, navelPiercing: 0, shouldersTat: 0, armsTat: 0, legsTat: 0, backTat: 0, stampTat: 0, vaginalSkill: 0, oralSkill: 0, analSkill: 0, whoreSkill: 0, entertainSkill: 0, combatSkill: 0, livingRules: "spare", speechRules: "restrictive", releaseRules: "restrictive", relationshipRules: "restrictive", standardPunishment: "situational", standardReward: "situational", useRulesAssistant: 1, diet: "healthy", dietCum: 0, dietMilk: 0, tired: 0, hormones: 0, drugs: "no drugs", curatives: 0, chem: 0, aphrodisiacs: 0, addict: 0, fuckdoll: 0, choosesOwnClothes: 0, clothes: "no clothing", collar: "none", shoes: "none", vaginalAccessory: "none", dickAccessory: "none", legAccessory: "none", buttplug: "none", buttplugAttachment: "none", intelligence: 0, intelligenceImplant: 0, energy: 50, need: 0, attrXX: 0, attrXY: 0, attrKnown: 0, fetish: "none", fetishStrength: 70, fetishKnown: 0, behavioralFlaw: "none", behavioralQuirk: "none", sexualFlaw: "none", sexualQuirk: "none", oralCount: 0, vaginalCount: 0, analCount: 0, mammaryCount: 0, penetrativeCount: 0, publicCount: 0, pitKills: 0, customTat: "", customLabel: "", customDesc: "", customTitle: "", customTitleLisp: "", rudeTitle: 0, customImage: 0, currentRules: [], bellyTat: 0, induce: 0, mpreg: 0, inflation: 0, inflationType: "none", inflationMethod: 0, milkSource: 0, cumSource: 0, burst: 0, pregKnown: 0, pregWeek: 0, belly: 0, bellyPreg: 0, bellyFluid: 0, bellyImplant: -1, bellySag: 0, bellySagPreg: 0, bellyPain: 0, cervixImplant: 0, birthsTotal: 0, pubertyAgeXX: 13, pubertyAgeXY: 13, scars: 0, breedingMark: 0, underArmHStyle: "waxed", bodySwap: 0, HGExclude: 0, ballType: "human", eggType: "human", reservedChildren: 0, choosesOwnChastity: 0, pregControl: "none", readyLimbs: [], ageAdjust: 0, bald: 0, origBodyOwner: "", death: "", hormoneBalance: 0, onDiet: 0, breastMesh: 0, slavesFathered: 0, PCChildrenFathered: 0, slavesKnockedUp: 0, PCKnockedUp: 0, origSkin: "white", vasectomy: 0, haircuts: 0, newGamePlus: 0, skillHG: 0, skillRC: 0, skillBG: 0, skillMD: 0, skillDJ: 0, skillNU: 0, skillTE: 0, skillAT: 0, skillST: 0, skillMM: 0, skillWA: 0, tankBaby: 0}>>
+	<<set $activeSlave = {slaveName: "blank", slaveSurname: 0, birthName: "blank", birthSurname: 0, genes: "XX", pronoun: "she", possessive: "her", possessivePronoun: "hers", objectReflexive: "herself", object: "her", noun: "girl", weekAcquired: 0, origin: 0, career: 0, ID: 0, prestige: 0, pornFame: 0, pornFameSpending: 0, prestigeDesc: 0, recruiter: 0, relation: 0, relationTarget: 0, relationship: 0, relationshipTarget: 0, rivalry: 0, rivalryTarget: 0, subTarget: 0, father: 0, mother: 0, daughters: 0, sisters: 0, canRecruit: 0, choosesOwnAssignment: 0, assignment: "rest", assignmentVisible: 1, sentence: 0, training: 0, toyHole: "all her holes", indenture: -1, indentureRestrictions: 0, birthWeek: random(0,51), actualAge: 18, visualAge: 18, physicalAge: 18, ovaryAge: 18, ageImplant: 0, health: 0, minorInjury: 0, trust: 0, oldTrust: 0, devotion: 0, oldDevotion: 0, weight: 0, muscles: 0, height: 170, heightImplant: 0, nationality: "slave", race: "white", markings: "none", eyes: 1, eyeColor: "brown", origEye: "brown", eyewear: "none", origHColor: "brown", hColor: "brown", pubicHColor: "brown", skin: "light", hLength: 60, hStyle: "short", pubicHStyle: "neat", waist: 0, corsetPiercing: 0, PLimb: 0, amp: 0, heels:0, voice: 2, voiceImplant: 0, accent: 0, shoulders: 0, shouldersImplant: 0, boobs: 0, boobsImplant: 0, boobsImplantType: 0, boobShape: "normal", nipples: "cute",  nipplesPiercing: 0, nipplesAccessory: 0, areolae: 0, areolaePiercing: 0, boobsTat: 0, lactation: 0, lactationAdaptation: 0, milk: 0, cum: 0, hips: 0, hipsImplant: 0, butt: 0, buttImplant: 0, buttImplantType: 0, buttTat: 0, face: 0, faceImplant: 0, faceShape: "normal", lips: 15, lipsImplant: 0, lipsPiercing: 0, lipsTat: 0, teeth: "normal", tonguePiercing: 0, vagina: 0, vaginaLube: 0, vaginaPiercing: 0, vaginaTat: 0, preg: -1, pregSource: 0, pregType: 0, broodmother: 0, broodmotherFetuses: 0, broodmotherOnHold: 0, broodmotherCountDown: 0, labor: 0, births: 0, cSec: 0, bellyAccessory: "none", labia: 0, clit: 0, clitPiercing: 0, clitSetting: "vanilla", foreskin: 0, anus: 0, dick: 0, analArea: 1, dickPiercing: 0, dickTat: 0, prostate: 0, balls: 0, scrotum: 0, ovaries: 0, anusPiercing: 0, anusTat: 0, makeup: 0, nails: 0, brand: 0, brandLocation: 0, earPiercing: 0, nosePiercing: 0, eyebrowPiercing: 0, navelPiercing: 0, shouldersTat: 0, armsTat: 0, legsTat: 0, backTat: 0, stampTat: 0, vaginalSkill: 0, oralSkill: 0, analSkill: 0, whoreSkill: 0, entertainSkill: 0, combatSkill: 0, livingRules: "spare", speechRules: "restrictive", releaseRules: "restrictive", relationshipRules: "restrictive", standardPunishment: "situational", standardReward: "situational", useRulesAssistant: 1, diet: "healthy", dietCum: 0, dietMilk: 0, tired: 0, hormones: 0, drugs: "no drugs", curatives: 0, chem: 0, aphrodisiacs: 0, addict: 0, fuckdoll: 0, choosesOwnClothes: 0, clothes: "no clothing", collar: "none", shoes: "none", vaginalAccessory: "none", dickAccessory: "none", legAccessory: "none", buttplug: "none", buttplugAttachment: "none", intelligence: 0, intelligenceImplant: 0, energy: 50, need: 0, attrXX: 0, attrXY: 0, attrKnown: 0, fetish: "none", fetishStrength: 70, fetishKnown: 0, behavioralFlaw: "none", behavioralQuirk: "none", sexualFlaw: "none", sexualQuirk: "none", oralCount: 0, vaginalCount: 0, analCount: 0, mammaryCount: 0, penetrativeCount: 0, publicCount: 0, pitKills: 0, customTat: "", customLabel: "", customDesc: "", customTitle: "", customTitleLisp: "", rudeTitle: 0, customImage: 0, currentRules: [], bellyTat: 0, induce: 0, mpreg: 0, inflation: 0, inflationType: "none", inflationMethod: 0, milkSource: 0, cumSource: 0, burst: 0, pregKnown: 0, pregWeek: 0, belly: 0, bellyPreg: 0, bellyFluid: 0, bellyImplant: -1, bellySag: 0, bellySagPreg: 0, bellyPain: 0, cervixImplant: 0, birthsTotal: 0, pubertyAgeXX: 13, pubertyAgeXY: 13, scars: 0, breedingMark: 0, underArmHStyle: "waxed", bodySwap: 0, HGExclude: 0, ballType: "human", eggType: "human", reservedChildren: 0, choosesOwnChastity: 0, pregControl: "none", readyLimbs: [], ageAdjust: 0, bald: 0, origBodyOwner: "" origBodyOwnerID: 0, death: "", hormoneBalance: 0, onDiet: 0, breastMesh: 0, slavesFathered: 0, PCChildrenFathered: 0, slavesKnockedUp: 0, PCKnockedUp: 0, origSkin: "white", vasectomy: 0, haircuts: 0, newGamePlus: 0, skillHG: 0, skillRC: 0, skillBG: 0, skillMD: 0, skillDJ: 0, skillNU: 0, skillTE: 0, skillAT: 0, skillST: 0, skillMM: 0, skillWA: 0, tankBaby: 0}>>
 <</widget>>
 
 /%
-- 
GitLab