code:
:: SlaveOnSlaveFeedingWorkAround [nobr]

<<set $nextButton = "Back", $nextLink = "Slave Interact">>

<<set $milkTap = 0, _descM = "milk", _descC = "cum", _eligibilityMilk2 = 0, _eligibilityMilk4 = 0, _eligibilityMilk8 = 0, _eligibilityCum2 = 0, _eligibilityCum4 = 0, _eligibilityCum8 = 0>>

<<for _i = 0; _i < $slaves.length; _i++>> /* milk output */
	<<if $slaves[_i].lactation > 0>>
		<<set $slaves[_i].milkOutput = 0>>
		<<set _milk = milkAmount($slaves[_i])>>
		<<set _milk = (_milk/14)>>
		<<set _milk = Math.trunc(_milk)>>
		<<set $slaves[_i].milkOutput = _milk>>
	<<else>>
		<<set _milk = 0>>
		<<set $slaves[_i].milkOutput = 0>>
	<</if>>
<</for>>
<<for _i = 0; _i < $slaves.length; _i++>> /* cum output */
	<<if $slaves[_i].balls > 0 && $slaves[_i].dick > 0 && $slaves[_i].chastityPenis != 1>>
		<<set $slaves[_i].cumOutput = 0>>
		<<set _cum = cumAmount($slaves[_i])>>
		<<set _cum = (_cum/7)>>
		<<set _cum = (_cum/10)>>
		<<set _cum = Math.trunc(_cum)>>
		<<set $slaves[_i].cumOutput = _cum>>
	<<else>>
		<<set _cum = 0>>
		<<set $slaves[_i].cumOutput = 0>>
	<</if>>
<</for>>

	<<= getSlave($AS).slaveName>> is prepped to drink $his fill; now you must select a slave capable of producing the required amount of milk or ejaculate.

Select an eligible slave to serve as the tap

Milk Slaves

		2 Liters

		4 Liters

		8 Liters

	/* 2 Liters */

		<<for _i = 0; _i < $slaves.length; _i++>>

				<<if $slaves[_i].milkOutput >= 2>>
					<<if ($slaves[_i].ID != getSlave($AS).ID) && $slaves[_i].nipples != "fuckable">>
						<<set _name = SlaveFullName($slaves[_i])>>
						<<print "[[_name|FSlaveFeed][$milkTap = $slaves[" + _i + "], getSlave($AS).inflation = 1, getSlave($AS).inflationType = _descM, getSlave($AS).inflationMethod = 3]]">>
						<<if relativeTerm(getSlave($AS), $slaves[_i]) != null>>
							<<print relativeTerm(getSlave($AS), $slaves[_i])>>
						<</if>>
						<<if $slaves[_i].relationshipTarget == getSlave($AS).ID>>
							<<switch $slaves[_i].relationship>>
							<<case 1>>
								friends
							<<case 2>>
								best friends
							<<case 3>>
								friends with benefits
							<<case 4>>
								lover
							<<case 5>>
								slave $wife
							<</switch>>
						<</if>>
						<<if $slaves[_i].rivalryTarget == getSlave($AS).ID>>
							<<switch $slaves[_i].relationship>>
							<<case 1>>
								dislikes
							<<case 2>>
								rival
							<<case 3>>
								bitterly hates
							<</switch>>
						<</if>>
						<<set _eligibilityMilk2 = 1>>
					<</if>>
				<</if>>

		<</for>>
		<<if (_eligibilityMilk2 == 0)>>

				You have no slaves capable of producing two liters of milk.

		<</if>>

	<<if getSlave($AS).pregKnown == 0>>
		/* 4 Liters */

			<<for _i = 0; _i < $slaves.length; _i++>>

					<<if $slaves[_i].milkOutput >= 4>>
						<<if ($slaves[_i].ID != getSlave($AS).ID) && $slaves[_i].nipples != "fuckable">>
							<<set _name = SlaveFullName($slaves[_i])>>
							<<print "[[_name|FSlaveFeed][$milkTap = $slaves[" + _i + "], getSlave($AS).inflation = 2, getSlave($AS).inflationType = _descM, getSlave($AS).inflationMethod = 3]]">>
							<<if relativeTerm(getSlave($AS), $slaves[_i]) != null>>
								<<print relativeTerm(getSlave($AS), $slaves[_i])>>
							<</if>>
							<<if $slaves[_i].relationshipTarget == getSlave($AS).ID>>
								<<switch $slaves[_i].relationship>>
								<<case 1>>
									friends
								<<case 2>>
									best friends
								<<case 3>>
									friends with benefits
								<<case 4>>
									lover
								<<case 5>>
									slave $wife
								<</switch>>
							<</if>>
							<<if $slaves[_i].rivalryTarget == getSlave($AS).ID>>
								<<switch $slaves[_i].relationship>>
								<<case 1>>
									dislikes
								<<case 2>>
									rival
								<<case 3>>
									bitterly hates
								<</switch>>
							<</if>>
							<<set _eligibilityMilk4 = 1>>
						<</if>>
					<</if>>

			<</for>>
			<<if (_eligibilityMilk4 == 0)>>

					You have no slaves capable of producing four liters of milk.

			<</if>>

		/* 8 Liters */

			<<for _i = 0; _i < $slaves.length; _i++>>

					<<if $slaves[_i].milkOutput >= 8>>
						<<if ($slaves[_i].ID != getSlave($AS).ID) && $slaves[_i].nipples != "fuckable">>
							<<set _name = SlaveFullName($slaves[_i])>>
							<<print "[[_name|FSlaveFeed][$milkTap = $slaves[" + _i + "], getSlave($AS).inflation = 3, getSlave($AS).inflationType = _descM, getSlave($AS).inflationMethod = 3]]">>
							<<if relativeTerm(getSlave($AS), $slaves[_i]) != null>>
								<<print relativeTerm(getSlave($AS), $slaves[_i])>>
							<</if>>
							<<if $slaves[_i].relationshipTarget == getSlave($AS).ID>>
								<<switch $slaves[_i].relationship>>
								<<case 1>>
									friends
								<<case 2>>
									best friends
								<<case 3>>
									friends with benefits
								<<case 4>>
									lover
								<<case 5>>
									slave $wife
								<</switch>>
							<</if>>
							<<if $slaves[_i].rivalryTarget == getSlave($AS).ID>>
								<<switch $slaves[_i].relationship>>
									<<case 1>>
										dislikes
									<<case 2>>
										rival
									<<case 3>>
										bitterly hates
								<</switch>>
							<</if>>
							<<set _eligibilityMilk8 = 1>>
						<</if>>
					<</if>>

			<</for>>
			<<if (_eligibilityMilk8 == 0)>>

					You have no slaves capable of producing eight liters of milk.

			<</if>>

	<<else>>

			Due to $his pregnancy, $he is incapable of keeping down more than two liters of milk.

	<</if>>

Cum Slaves

			2 Liters

			4 Liters

			8 Liters

		/* 2 Liters */

			<<for _i = 0; _i < $slaves.length; _i++>>

					<<if $slaves[_i].cumOutput >= 2>>
						<<if ($slaves[_i].ID != getSlave($AS).ID)>>
							<<set _name = SlaveFullName($slaves[_i])>>
							<<print "[[_name|FSlaveFeed][$milkTap = $slaves[" + _i + "], getSlave($AS).inflation = 1, getSlave($AS).inflationType = _descC, getSlave($AS).inflationMethod = 3]]">>
							<<set _eligibilityCum2 = 1>>
						<</if>>
					<</if>>

			<</for>>
			<<if (_eligibilityCum2 == 0)>>

					You have no slaves capable of producing two liters of cum.

			<</if>>

		<<if getSlave($AS).pregKnown == 0>>
			/* 4 Liters */

				<<for _i = 0; _i < $slaves.length; _i++>>

						<<if $slaves[_i].cumOutput >= 4>>
							<<if ($slaves[_i].ID != getSlave($AS).ID)>>
								<<set _name = SlaveFullName($slaves[_i])>>
								<<print "[[_name|FSlaveFeed][$milkTap = $slaves[" + _i + "], getSlave($AS).inflation = 2, getSlave($AS).inflationType = _descC, getSlave($AS).inflationMethod = 3]]">>
								<<set _eligibilityCum4 = 1>>
							<</if>>
						<</if>>

				<</for>>

				<<if (_eligibilityCum4 == 0)>>

						You have no slaves capable of producing four liters of cum.

				<</if>>

			/* 8 Liters */

				<<for _i = 0; _i < $slaves.length; _i++>>

						<<if $slaves[_i].cumOutput >= 8>>
							<<if ($slaves[_i].ID != getSlave($AS).ID)>>
								<<set _name = SlaveFullName($slaves[_i])>>
								<<print "[[_name|FSlaveFeed][$milkTap = $slaves[" + _i + "], getSlave($AS).inflation = 3, getSlave($AS).inflationType = _descC, getSlave($AS).inflationMethod = 3]]">>
								<<set _eligibilityCum8 = 1>>
							<</if>>
						<</if>>

				<</for>>
				<<if (_eligibilityCum8 == 0)>>

						You have no slaves capable of producing eight liters of cum.

				<</if>>

		<<else>>

				Due to $his pregnancy, $he is incapable of keeping down more than two liters of cum.

		<</if>>


code:
:: Slave Slave Swap [nobr]

<<set $nextButton = "Continue">>
<<set _ss1 = $slaveIndices[$AS]>>
<<set _ss1Clone = clone(getSlave(V.AS))>>
<<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 <<= getSlave($AS).slaveName>> and $swappingSlave.slaveName into the remote surgery and stand back as it goes to work.
<<BodySwap $slaves[_ss1] _ss2Clone>>
<<BodySwap $genePool[_gps1] _gps2Clone 1>> /* passing a third argument just to detect if it's a slave from the genepool */
<<BodySwap $slaves[_ss2] _ss1Clone>>
<<BodySwap $genePool[_gps2] _gps1Clone 1>> /* passing a third argument just to detect if it's a slave from the genepool */

After an honestly impressive procedure, $slaves[_ss1].slaveName is recovering nicely.

<<BodySwapReaction $slaves[_ss1] _ss1Clone>>

In the neighboring bed, $slaves[_ss2].slaveName rests peacefully.

<<BodySwapReaction $slaves[_ss2] _ss2Clone>>

/* figuring out whom has whose 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 whose body it is, name-wise */

<<BodySwapName $slaves[_ss1] $slaves[_ss2]>>
<<BodySwapName $slaves[_ss2] $slaves[_ss1]>>

<<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>>

repo_name: Welptard/fc

license: mit


code:
:: 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 <<= getSlave($AS).slaveName>> is prepped:

//Select the slave who will be trading bodies with $him. This operation will cost <<print cashFormat(10000)>>.//

__Select an eligible slave:__
<<for _i = 0; _i < $slaves.length; _i++>>
	<<capture _i>>
		<<if isSlaveAvailable($slaves[_i])>>
			<<if $slaves[_i].fuckdoll == 0>>
				<<if ($slaves[_i].ID != $AS)>>
					<<set _name = SlaveFullName($slaves[_i])>>

[[_name|Slave Slave Swap][$swappingSlave = $slaves[_i], cashX(-10000, "slaveSurgery", $slaves[_i])]]
				<</if>>
			<</if>>
		<</if>>
	<</capture>>
<</for>>


code:
:: Surrogacy [nobr]

<<set $nextButton = "Continue">>

<<switch $surgeryType>>

<<case "surrogacy">>

	<<if $receptrix.ID == -1>>
		Since the surgery required only a local anesthetic, you remain fully aware of the procedure as the autosurgery carries it out. You slowly rise to your feet, a hand to your lower belly, appreciating the new life growing within you.
		<<set $PC.pregKnown = 1>>
		<<run WombSurrogate($PC, 1, $donatrix, $impregnatrix.ID, 1)>>
		<<run WombNormalizePreg($PC)>>
	<<else>>
		<<set $receptrix.pregKnown = 1>>
		<<run WombSurrogate($receptrix, 1, $donatrix, $impregnatrix.ID, 1)>>
		<<run WombNormalizePreg($receptrix)>>
		<<setLocalPronouns $receptrix>>
		<<if $receptrix.fetish == "mindbroken">>
			$receptrix.slaveName leaves the surgery with a certain warmth in $his lower abdomen, $he knows that $he has been impregnated.
		<<elseif ($receptrix.fetish == "pregnancy") && ($receptrix.fetishStrength > 60) && ($receptrix.fetishKnown == 1)>>
			<<if canSee($receptrix)>>
				Since the surgery required only a local anesthetic, $receptrix.slaveName remained fully aware throughout the procedure. $He was overjoyed at the sight of the syringe containing $his future child emptying into $his womb.
			<<else>>
				$receptrix.slaveName leaves the surgery with a certain warmth in $his lower abdomen, $he knows that $he has been impregnated.
			<</if>>
			$He is @@.hotpink; filled with joy@@ over the life settling into $his womb and can't wait to see the result. $He's so pleased that $he now @@.mediumaquamarine;trusts@@ your plans for $his body.
			<<set $receptrix.trust += 4, $receptrix.devotion += 10>>
		<<elseif ($receptrix.devotion > 50)>>
			<<if canSee($receptrix)>>
				Since the surgery required only a local anesthetic, $receptrix.slaveName remained fully aware throughout the procedure. $He watched the syringe containing $his new pregnancy empty into $his womb with rapt attention.
			<<else>>
				$receptrix.slaveName leaves the surgery with a certain warmth in $his lower abdomen, $he knows that $he has been impregnated.
			<</if>>
			$He's @@.hotpink;grateful@@ that you think $him worthy of carrying this child, and a little nervous about how $he'll perform as a surrogate.
			<<set $receptrix.devotion += 4>>
		<<elseif ($receptrix.devotion >= -20)>>
			<<if canSee($receptrix)>>
				Since the surgery required only a local anesthetic, $receptrix.slaveName remained fully aware throughout the procedure. From the syringe making contact with $his skin, to the egg's delivery into $his womb and $his subsequent impregnation, $he couldn't look away.
			<<else>>
				$receptrix.slaveName leaves the surgery with a certain warmth in $his lower abdomen, $he knows that $he has been impregnated.
			<</if>>
			$He understands the realities of $his life as a slave, so it isn't much of a shock. $He is @@.gold;sensibly fearful@@ of your total power over $his body.
			<<set $receptrix.trust -= 10>>
		<<else>>
			<<if canSee($receptrix)>>
				Since the surgery required only a local anesthetic, $receptrix.slaveName remained fully aware throughout the procedure. The moment $he realized what was happening, $he shut $his eyes tight, only opening them again as $he feels the slight tingle of the injector exiting $his lower abdomen.
			<<else>>
				$receptrix.slaveName leaves the surgery with a certain warmth in $his lower abdomen, $he knows that $he has been impregnated.
			<</if>>
			$He does not understand the realities of $his life as a slave at a core level, so $he's @@.mediumorchid;terrified and angry@@ that you have forced $him to bear this child, even more so as $he realizes $he doesn't know who the father is. $He is @@.gold;sensibly fearful@@ of your total power over $his body and the future of the life $he now harbors within $him.
			<<set $receptrix.trust -= 15, $receptrix.devotion -= 15>>
		<</if>>
		<<set _surr = $slaves.findIndex(function(s) { return s.ID == $receptrix.ID; })>>
		<<set $slaves[_surr] = $receptrix>>
	<</if>>
	<<set $receptrix = 0, $impregnatrix = 0, $donatrix = 0>>

<<case "transplant">>

	<<if $receptrix.ID == -1>>
		Since the surgery required only a local anesthetic, you are very aware that you are now carrying <<= getSlave($AS).slaveName>>'s child. You slowly rise to your feet, a hand to your lower belly, appreciating the new life growing within you.
		<<set _fetus = WombRemoveFetus(getSlave($AS), $wombIndex)>>
		<<run WombAddFetus($PC, _fetus)>>
		<<set $PC.pregKnown = 1, $PC.preg = WombMaxPreg($PC), getSlave($AS).preg = WombMaxPreg(getSlave($AS))>>
		<<run WombNormalizePreg($PC)>>
		<<run WombNormalizePreg(getSlave($AS))>>
	<<else>>
		<<set _fetus = WombRemoveFetus($donatrix, $wombIndex)>>
		<<run WombAddFetus($receptrix, _fetus)>>
		<<set $receptrix.pregKnown = 1, $receptrix.preg = WombMaxPreg($receptrix), $donatrix.preg = WombMaxPreg($donatrix)>>
		<<run WombNormalizePreg($receptrix)>>
		<<run WombNormalizePreg($donatrix)>>
		<<if $donatrix.ID == -1>>
			<<set $PC = $donatrix>>
		<<else>>
			<<set _surr = $slaves.findIndex(function(s) { return s.ID == $donatrix.ID; })>>
			<<set $slaves[$slaveIndices[$AS]] = $donatrix>>
		<</if>>
		<<setLocalPronouns $receptrix>>
		<<if $receptrix.fetish == "mindbroken">>
			$receptrix.slaveName leaves the surgery with a certain warmth in $his lower abdomen, $he knows that $he has been impregnated.
		<<elseif ($receptrix.fetish == "pregnancy") && ($receptrix.fetishStrength > 60) && ($receptrix.fetishKnown == 1)>>
			<<if canSee($receptrix)>>
				Since the surgery required only a local anesthetic, $receptrix.slaveName remained fully aware throughout the procedure. $He was overjoyed at the sight of the syringe containing $his future child emptying into $his womb.
			<<else>>
				$receptrix.slaveName leaves the surgery with a certain warmth in $his lower abdomen, $he knows that $he has been impregnated.
			<</if>>
			$He is @@.hotpink; filled with joy@@ over the life resettling into $his womb and can't wait to see the result. $He's so pleased that $he now @@.mediumaquamarine;trusts@@ your plans for $his body.
			<<set $receptrix.trust += 4, $receptrix.devotion += 10>>
		<<elseif ($receptrix.devotion > 50)>>
			<<if canSee($receptrix)>>
				Since the surgery required only a local anesthetic, $receptrix.slaveName remained fully aware throughout the procedure. $He watched the syringe containing $his new pregnancy empty into $his womb with rapt attention.
			<<else>>
				$receptrix.slaveName leaves the surgery with a certain warmth in $his lower abdomen, $he knows that $he has been impregnated.
			<</if>>
			$He's @@.hotpink;grateful@@ that you think $him worthy of carrying this child in <<if $donatrix.ID == -1>>your stead<<else>>lieu of $donatrix.slaveName<</if>>, and a little nervous about how $he'll perform as a surrogate.
			<<set $receptrix.devotion += 4>>
		<<elseif ($receptrix.devotion >= -20)>>
			<<if canSee($receptrix)>>
				Since the surgery required only a local anesthetic, $receptrix.slaveName remained fully aware throughout the procedure. From the syringe making contact with $his skin, to the egg's delivery into $his womb and $his subsequent impregnation, $he couldn't look away.
			<<else>>
				$receptrix.slaveName leaves the surgery with a certain warmth in $his lower abdomen, $he knows that $he has been impregnated.
			<</if>>
			$He understands the realities of $his life as a slave, so it isn't much of a shock. $He is @@.gold;sensibly fearful@@ of your total power over $his body and how you are forcing <<if $donatrix.ID == -1>>your pregnancy upon $him<<else>>$him to carry what should have been $donatrix.slaveName's burden<</if>>.
			<<set $receptrix.trust -= 10>>
		<<else>>
			<<if canSee($receptrix)>>
				Since the surgery required only a local anesthetic, $receptrix.slaveName remained fully aware throughout the procedure. The moment $he realized what was happening, $he shut $his eyes tight, only opening them again as $he feels the slight tingle of the injector exiting $his lower abdomen.
			<<else>>
				$receptrix.slaveName leaves the surgery with a certain warmth in $his lower abdomen, $he knows that $he has been impregnated.
			<</if>>
			$He does not understand the realities of $his life as a slave at a core level, so $he's @@.mediumorchid;terrified and angry@@ that you have forced $him to <<if $donatrix.ID == -1>>carry your child instead of doing so yourself<<else>>bear this child in lieu of $donatrix.slaveName<</if>>. $He is @@.gold;sensibly fearful@@ of your total power over $his body and who else's troubles may be levied upon $him.
			<<set $receptrix.trust -= 15, $receptrix.devotion -= 15>>
		<</if>>
		<<set _surr = $slaves.findIndex(function(s) { return s.ID == $receptrix.ID; })>>
		<<set $slaves[_surr] = $receptrix>>
	<</if>>
	<<set $receptrix = 0, $donatrix = 0, $wombIndex = 0>>

<<case "clone">>

	<<if $receptrix.ID == -1>>
		Since the surgery required only a local anesthetic, you remain fully aware of the procedure as the autosurgery carries it out. You slowly rise to your feet, a hand to your lower belly, appreciating the clone growing within you.
		<<set $PC.pregKnown = 1>>
		<<run WombImpregnateClone($PC, 1, $donatrix, 1)>>
		<<run WombNormalizePreg($PC)>>
	<<else>>
		<<set $receptrix.pregKnown = 1>>
		<<run WombImpregnateClone($receptrix, 1, $donatrix, 1)>>
		<<run WombNormalizePreg($receptrix)>>
		<<setLocalPronouns $receptrix>>
		<<if $receptrix.fetish == "mindbroken">>
			$receptrix.slaveName leaves the surgery with a certain warmth in $his lower abdomen,
			<<if $receptrix.ID == $donatrix.ID>>
				but has no idea $he carries $his own clone.
			<<else>>
				$he knows that $he has been impregnated.
			<</if>>
		<<elseif ($receptrix.fetish == "pregnancy") && ($receptrix.fetishStrength > 60) && ($receptrix.fetishKnown == 1)>>
			<<if canSee($receptrix)>>
				Since the surgery required only a local anesthetic, $receptrix.slaveName remained fully aware throughout the procedure. $He was overjoyed at the sight of the syringe containing $his <<if $receptrix.ID == $donatrix.ID>>clone<<else>>future child<</if>> emptying into $his womb.
			<<else>>
				$receptrix.slaveName leaves the surgery with a certain warmth in $his lower abdomen, $he knows that $he has been impregnated<<if $receptrix.ID == $donatrix.ID>>, but not that $he now bears $his own clone<</if>>.
			<</if>>
			$He is @@.hotpink; filled with joy@@ over the life settling into $his womb and can't wait to see the result. $He's so pleased that $he now @@.mediumaquamarine;trusts@@ your plans for $his body.
			<<set $receptrix.trust += 4, $receptrix.devotion += 10>>
		<<elseif ($receptrix.devotion > 50)>>
			<<if canSee($receptrix)>>
				Since the surgery required only a local anesthetic, $receptrix.slaveName remained fully aware throughout the procedure. $He watched the syringe containing $his new pregnancy empty into $his womb with rapt attention.
			<<else>>
				$receptrix.slaveName leaves the surgery with a certain warmth in $his lower abdomen, $he knows that $he has been impregnated<<if $receptrix.ID == $donatrix.ID>>, but not that $he now bears $his own clone<</if>>.
			<</if>>
			$He's @@.hotpink;grateful@@ that you think $him worthy of carrying this child, and a little nervous about how $he'll perform as a surrogate.
			<<set $receptrix.devotion += 4>>
		<<elseif ($receptrix.devotion >= -20)>>
			<<if canSee($receptrix)>>
				Since the surgery required only a local anesthetic, $receptrix.slaveName remained fully aware throughout the procedure. From the syringe making contact with $his skin, to the egg's delivery into $his womb and $his subsequent impregnation, $he couldn't look away.
			<<else>>
				$receptrix.slaveName leaves the surgery with a certain warmth in $his lower abdomen, $he knows that $he has been impregnated<<if $receptrix.ID == $donatrix.ID>>, but not that $he now bears $his own clone<</if>>.
			<</if>>
			$He understands the realities of $his life as a slave, so it isn't much of a shock. $He is @@.gold;sensibly fearful@@ of your total power over $his body.
			<<set $receptrix.trust -= 10>>
		<<else>>
			<<if canSee($receptrix)>>
				Since the surgery required only a local anesthetic, $receptrix.slaveName remained fully aware throughout the procedure. The moment $he realized what was happening, $he shut $his eyes tight, only opening them again as $he feels the slight tingle of the injector exiting $his lower abdomen.
			<<else>>
				$receptrix.slaveName leaves the surgery with a certain warmth in $his lower abdomen, $he knows that $he has been impregnated.
			<</if>>
			$He does not understand the realities of $his life as a slave at a core level, so $he's @@.mediumorchid;terrified and angry@@ that you have forced $him to bear <<if $receptrix.ID == $donatrix.ID>>$his own clone and potential replacement<<else>>this child, even more so as $he realizes $he doesn't know who the father is<</if>>. $He is @@.gold;sensibly fearful@@ of your total power over $his body and the future of the life $he now harbors within $him.
			<<set $receptrix.trust -= 15, $receptrix.devotion -= 15>>
		<</if>>
		<<set _surr = $slaves.findIndex(function(s) { return s.ID == $receptrix.ID; })>>
		<<set $slaves[_surr] = $receptrix>>
	<</if>>
	<<if $donatrix.ID != -1 && $donatrix.ID != $receptrix.ID>>
		<<set _surr = $slaves.findIndex(function(s) { return s.ID == $donatrix.ID; })>>
		<<set $slaves[_surr] = $donatrix>>
	<</if>>
	<<set $receptrix = 0, $donatrix = 0>>

<</switch>>


code:
:: Surrogacy Workaround [nobr]

<<set $nextButton = "Cancel", _eligibility = 0, _eligibilityI = 0, _eligibility2 = 0>>
<<if $donatrix.ID == $PC.ID>>
	<<set _donatrixID = -1>>
<<else>>
	<<set _donatrixID = 0>>
<</if>>
<<if $impregnatrix != "Undecided" && $impregnatrix.ID == -1>><<set _impreg = PlayerName()>><<elseif $impregnatrix != "Undecided">><<set _impreg = SlaveFullName($impregnatrix)>><<else>><<set _impreg = $impregnatrix>><</if>>
<<if $receptrix != "Undecided" && $receptrix.ID == -1>><<set _receive = PlayerName()>><<elseif $receptrix != "Undecided">><<set _receive = SlaveFullName($receptrix)>><<else>><<set _receive = $receptrix>><</if>>

	<<if _donatrixID == -1>>
		You've prepared yourself to have an egg taken from your ovaries;
	<<else>>
		<<= getSlave($AS).slaveName>> is prepped to have an egg harvested from $his ovaries;
	<</if>>
	now you must select a target to fertilize it and who will carry it to term.

_impreg will provide the seed and _receive shall carry it.
<<if _impreg != "Undecided" && _receive != "Undecided">>
	[[Implant fertilized ovum|Surrogacy][cashX(forceNeg($surgeryCost*2), "slaveSurgery"), $surgeryType = "surrogacy"]]
<</if>>

__Semen donatrix: _impreg __

<<for _sw = 0; _sw < $slaves.length; _sw++>>
	<<capture _sw>>
		<<if $slaves[_sw].balls > 0 && $slaves[_sw].pubertyXY == 1 && isSlaveAvailable($slaves[_sw]) && canBreed($donatrix, $slaves[_sw])>>
			<<set _name = SlaveFullName($slaves[_sw])>>

[[_name|Surrogacy Workaround][$impregnatrix = $slaves[_sw]]]
			<<set _eligibility = 1>>
		<</if>>
	<</capture>>
<</for>>
<<if (_eligibility == 0)>>

//You have no slaves with potent sperm.//
<</if>>

<<if $tanks.length > 0 && $incubatorReproductionSetting == 2>>

	__Incubator settings are resulting in large-scale fluid secretion. Select an eligible incubatee to milk for semen:__

	<<for _sw3 = 0; _sw3 < $tanks.length; _sw3++>>
		<<capture _sw3>>
			<<if $tanks[_sw3].balls > 0 && $tanks[_sw3].dick > 0 && canBreed($donatrix, $tanks[_sw3])>>
				<<set _name3 = $tanks[_sw3].slaveName>>
				[[_name3|Surrogacy Workaround][$impregnatrix = $tanks[_sw3]]]
				<<set _eligibilityI = 1>>
			<</if>>
		<</capture>>
	<</for>>
	<<if (_eligibilityI == 0)>>

//You have no growing slaves producing sperm.//
	<</if>>
<</if>>

<<if $PC.balls != 0>>

	[[Use your own|Surrogacy Workaround][$impregnatrix = $PC]]
<</if>>

__Chosen surrogate: _receive __

<<for _sw1 = 0; _sw1 < $slaves.length; _sw1++>>
	<<capture _sw1>>
		<<if ($slaves[_sw1].ovaries > 0 || $slaves[_sw1].mpreg > 0) && isSlaveAvailable($slaves[_sw1]) && $slaves[_sw1].preg >= 0 && $slaves[_sw1].preg < 4 && $slaves[_sw1].pregWeek >= 0 && $slaves[_sw1].pubertyXX == 1 && $slaves[_sw1].pregType < 12 && $slaves[_sw1].bellyImplant == -1 && $slaves[_sw1].broodmother == 0 && $slaves[_sw1].inflation <= 2 && $slaves[_sw1].physicalAge < 70>>
			<<set _name2 = SlaveFullName($slaves[_sw1])>>

[[_name2|Surrogacy Workaround][$receptrix = $slaves[_sw1]]] <<if $slaves[_sw1].pregType >= 4>>//Using a slave carrying multiples is inadvisable//<</if>>
			<<set _eligibility2 = 1>>
		<</if>>
	<</capture>>
<</for>>
<<if (_eligibility2 == 0)>>

//You have no slaves capable of acting as a surrogate.//
<</if>>

<<if $PC.vagina != -1 && $PC.preg >= 0 && $PC.preg < 4 && $PC.pregType < 8 && $PC.physicalAge < 70>>

	[[Use your own womb|Surrogacy Workaround][$receptrix = $PC]]
<</if>>


code:
:: test genetics [nobr]

<<set $nextButton = "Back", $nextLink = "Options">>
<<set _seed = 0>>

All slave array slaves MUST be present in genePool or else there is a malfunction.

genePool

index	name	ID	origin

<<for _i = 0; _i < $genePool.length; _i++>>

		_i
		$genePool[_i].slaveName
		$genePool[_i].ID
		$genePool[_i].origin

<</for>>

<<set _neededProperties = ['genes', 'origSkin', 'eye.origColor', 'origHColor', 'nationality', 'origRace', 'face', 'faceShape', 'markings', 'intelligence', 'underArmHStyle', 'pubicHStyle']>>

slaves

index	name	ID	origin	assignment

<<for _i = 0; _i < $slaves.length; _i++>>
	<<set _s = $slaves[_i]>>
	<<set _error = $genePool.every(function(g) { return $slaves[_i].ID !== g.ID; })>>
	<<if _error>><<set _errorCause = "Doesn't exist in the gene pool">><</if>>
	<<if !_error>>
		<<set _missingProperties = _neededProperties.filter(function(p) {
			p = p.split(".");
			let c = _s;
			for (const r of p) {
				if (!(r in c)) {
					return true;
				}
				c = c[r];
			}
			return false;
		})>>
		<<if _missingProperties.length > 0>>
			<<set _error = true, _errorCause = "Missing properties: " + _missingProperties.join(", ")>>
		<</if>>
	<</if>>
	<<if _error>>

			_i
			_s.slaveName
			_s.ID
			_s.origin
			_s.assignment
			_errorCause

	<<else>>

			_i
			_s.slaveName
			_s.ID
			_s.origin
			_s.assignment

	<</if>>
<</for>>

<<if _errorCause>>
	@@.red;Errors in the gene pool detected! Please report this.@@
	<<link "Add missing slaves to the gene pool" "Main">>
		<<for _i = 0; _i < $slaves.length; _i++>>
			<<if $genePool.every(function(g) { return $slaves[_i].ID !== g.ID; })>>
				<<set $genePool.push($slaves[_i])>>
			<</if>>
		<</for>>
	<</link>> //This will not fix missing properties.//
<</if>>