:: SA agent [nobr]

<<if $slaves[$i].boobsImplantType == 1>>
	<<set $slaves[$i].boobsImplant += 50, $slaves[$i].boobs += 50>>
	<<if ($slaves[$i].boobs > 50000)>>
		<<set $slaves[$i].boobs -= 100, $slaves[$i].boobsImplant -= 100>>
		<<if $slaves[$i].inducedNCS == 1>>
			<<set $slaves[$i].boobs -= 100, $slaves[$i].boobsImplant -= 100>>
		<</if>>
	<</if>>
<</if>>
<<if $slaves[$i].inducedNCS == 1>>
		/* NCS is blocking boob expansion. */
<<elseif ($slaves[$i].boobsImplant > 1000)>>
	<<if ($slaves[$i].boobs-$slaves[$i].boobsImplant < 1000) && (random(1,100) > 60)>>
		<<set $slaves[$i].boobs += 50>>
	<</if>>
<<elseif ($slaves[$i].boobsImplant > 600)>>
	<<if ($slaves[$i].boobs-$slaves[$i].boobsImplant < 500) && (random(1,100) > 60)>>
		<<set $slaves[$i].boobs += 50>>
	<</if>>
<<elseif ($slaves[$i].boobsImplant > 0)>>
	<<if ($slaves[$i].boobs-$slaves[$i].boobsImplant < 300) && (random(1,100) > 60)>>
		<<set $slaves[$i].boobs += 50>>
	<</if>>
<</if>>
<<if $slaves[$i].buttImplantType == 1>>
	<<set $slaves[$i].buttImplant += .25, $slaves[$i].butt += .25>>
	<<if ($slaves[$i].butt > 10)>>
		<<set $slaves[$i].butt -= 1, $slaves[$i].buttImplant -= 1>>
		<<if $slaves[$i].inducedNCS == 1>>
			<<set $slaves[$i].butt -= 1, $slaves[$i].buttImplant -= 1>>
		<</if>>
	<</if>>
<</if>>

<<if $slaves[$i].genes == "XX">>
	<<if $slaves[$i].ovaries == 1 || $slaves[$i].mpreg == 1>>
		<<if $slaves[$i].balls > 0 && $slaves[$i].ballType != "sterile">>
			<<if $slaves[$i].hormoneBalance > 20>>
				<<set $slaves[$i].hormoneBalance -= 1>>
			<<elseif $slaves[$i].hormoneBalance < 20>>
				<<set $slaves[$i].hormoneBalance += 1>>
			<</if>>
		<<else>>
			<<if $slaves[$i].hormoneBalance > 60>>
				<<set $slaves[$i].hormoneBalance -= 1>>
			<<elseif $slaves[$i].hormoneBalance < 60>>
				<<set $slaves[$i].hormoneBalance += 1>>
			<</if>>
		<</if>>
	<<else>>
		<<if $slaves[$i].balls > 0 && $slaves[$i].ballType != "sterile">>
			<<if $slaves[$i].hormoneBalance > -20>>
				<<set $slaves[$i].hormoneBalance -= 1>>
			<<elseif $slaves[$i].hormoneBalance < -20>>
				<<set $slaves[$i].hormoneBalance += 1>>
			<</if>>
		<<else>>
			<<if $slaves[$i].hormoneBalance > 20>>
				<<set $slaves[$i].hormoneBalance -= 1>>
			<<elseif $slaves[$i].hormoneBalance < 20>>
				<<set $slaves[$i].hormoneBalance += 1>>
			<</if>>
		<</if>>
	<</if>>
<<elseif $slaves[$i].genes == "XY">>
	<<if $slaves[$i].ovaries == 1 || $slaves[$i].mpreg == 1>>
		<<if $slaves[$i].balls > 0 && $slaves[$i].ballType != "sterile">>
			<<if $slaves[$i].hormoneBalance > 20>>
				<<set $slaves[$i].hormoneBalance -= 1>>
			<<elseif $slaves[$i].hormoneBalance < 20>>
				<<set $slaves[$i].hormoneBalance += 1>>
			<</if>>
		<<else>>
			<<if $slaves[$i].hormoneBalance > 40>>
				<<set $slaves[$i].hormoneBalance -= 1>>
			<<elseif $slaves[$i].hormoneBalance < 40>>
				<<set $slaves[$i].hormoneBalance += 1>>
			<</if>>
		<</if>>
	<<else>>
		<<if $slaves[$i].balls > 0 && $slaves[$i].ballType != "sterile">>
			<<if $slaves[$i].hormoneBalance > -40>>
				<<set $slaves[$i].hormoneBalance -= 1>>
			<<elseif $slaves[$i].hormoneBalance < -40>>
				<<set $slaves[$i].hormoneBalance += 1>>
			<</if>>
		<<else>>
			<<if $slaves[$i].hormoneBalance > 20>>
				<<set $slaves[$i].hormoneBalance -= 1>>
			<<elseif $slaves[$i].hormoneBalance < 20>>
				<<set $slaves[$i].hormoneBalance += 1>>
			<</if>>
		<</if>>
	<</if>>
<</if>>

/* puberty - not announced for allowing surprise pregnancy */
<<if $slaves[$i].ovaries == 1 || $slaves[$i].mpreg == 1>>
	<<if $slaves[$i].pubertyXX == 0>>
		<<if $slaves[$i].physicalAge >= $slaves[$i].pubertyAgeXX>>
			<<set $slaves[$i].pubertyXX = 1>>
		<</if>>
	<</if>>
<</if>>
<<if $slaves[$i].balls > 0 && $slaves[$i].ballType != "sterile">>
	<<if $slaves[$i].pubertyXY == 0>>
		<<if $slaves[$i].physicalAge >= $slaves[$i].pubertyAgeXY>>
			<<set $slaves[$i].pubertyXY = 1>>
		<</if>>
	<</if>>
<</if>>

<<if $slaves[$i].inflation > 0>>
	<<set $slaves[$i].inflation = 0, $slaves[$i].inflationType = "none", $slaves[$i].inflationMethod = 0, $slaves[$i].milkSource = 0>>
<</if>>

<<if ($slaves[$i].preg > 0)>> /*EFFECTS OF PREGNANCY*/
	<<if $slaves[$i].preg == 5>> /* bad condition logic - with pregnancy control drugs can be not triggered. Or may be trigged by broodmother several times. Need to be revorked. */ 
		<<if $slaves[$i].pregSource == -1>>
			<<set $PC.slavesKnockedUp++>>
		<<elseif $slaves[$i].pregSource > 0>>
			<<set _babyDaddy = $slaveIndices[$slaves[$i].pregSource]>>
			<<set $slaves[_babyDaddy].slavesKnockedUp++>>
		<</if>>
	<</if>>
	<<if ($slaves[$i].preg >= 10)>>
		<<if $slaves[$i].inducedNCS == 1>>
			/* Sort-of No-op, NCS prevents boob growth */
			<<set _boobTarget = 0>>
		<<elseif $slaves[$i].physicalAge >= 18>>
			<<if $slaves[$i].pregType >= 50>>
				<<set _boobTarget = 10000>>
			<<elseif $slaves[$i].pregType >= 30>>
				<<set _boobTarget = 5000>>
			<<elseif $slaves[$i].pregType >= 10>>
				<<set _boobTarget = 2000>>
			<<else>>
				<<set _boobTarget = 1000>>
			<</if>>
		<<elseif $slaves[$i].physicalAge >= 13>>
			<<if $slaves[$i].pregType >= 50>>
				<<set _boobTarget = 5000>>
			<<elseif $slaves[$i].pregType >= 30>>
				<<set _boobTarget = 3200>>
			<<elseif $slaves[$i].pregType >= 10>>
				<<set _boobTarget = 1800>>
			<<else>>
				<<set _boobTarget = 800>>
			<</if>>
		<<elseif $slaves[$i].physicalAge >= 8>>
			<<if $slaves[$i].pregType >= 50>>
				<<set _boobTarget = 1800>>
			<<elseif $slaves[$i].pregType >= 30>>
				<<set _boobTarget = 1400>>
			<<elseif $slaves[$i].pregType >= 10>>
				<<set _boobTarget = 1000>>
			<<else>>
				<<set _boobTarget = 600>>
			<</if>>
		<<else>>
			<<if $slaves[$i].pregType >= 50>>
				<<set _boobTarget = 1000>>
			<<elseif $slaves[$i].pregType >= 30>>
				<<set _boobTarget = 800>>
			<<elseif $slaves[$i].pregType >= 10>>
				<<set _boobTarget = 600>>
			<<else>>
				<<set _boobTarget = 400>>
			<</if>>
		<</if>>
		<<if ($slaves[$i].pregType >= 30)>>
			<<if ($slaves[$i].weight <= 65)>>
				<<set $slaves[$i].weight += 1>>
			<</if>>
			<<if (($slaves[$i].inducedNCS == 0) && (random(1,100) > 60))>>
				<<if (($slaves[$i].boobs - $slaves[$i].boobsImplant) < _boobTarget)>>
					<<set $slaves[$i].boobs += 200>>
					<<if $slaves[$i].boobShape != "saggy" && $slaves[$i].preg > 32 && ($slaves[$i].breastMesh != 1)>>
						<<set $slaves[$i].boobShape = "saggy">>
					<</if>>
				<</if>>
				<<if ($slaves[$i].hips < 2)>>
					<<set $slaves[$i].hips += 1>>
				<</if>>
				<<if ($slaves[$i].butt < 14)>>
					<<set $slaves[$i].butt += 1>>
				<</if>>
			<</if>>
		<<elseif (($slaves[$i].inducedNCS == 0) && ($slaves[$i].pregType >= 10))>>
			<<if random(1,100) > 80 && (($slaves[$i].boobs - $slaves[$i].boobsImplant) < _boobTarget)>>
				<<set $slaves[$i].boobs += 100>>
				<<if $slaves[$i].boobShape != "saggy" && ($slaves[$i].breastMesh != 1)>>
					<<if $slaves[$i].preg > random(32,82)>>
						<<set $slaves[$i].boobShape = "saggy">>
					<</if>>
				<</if>>
			<</if>>
		<<elseif (($slaves[$i].inducedNCS == 0) && (($slaves[$i].boobs - $slaves[$i].boobsImplant) < _boobTarget))>>
			<<if random(1,100) > 80>>
				<<set $slaves[$i].boobs += 50>>
				<<if $slaves[$i].boobShape != "saggy" && $slaves[$i].preg > random(32,100) && ($slaves[$i].breastMesh != 1)>>
					<<set $slaves[$i].boobShape = "saggy">>
				<</if>>
			<</if>>
		<</if>>
		<<if $slaves[$i].inducedNCS == 1>>
			/* No-op, we don't grow hips on NCS */
		<<elseif $slaves[$i].preg > 32 && $slaves[$i].physicalAge >= 18 && $slaves[$i].hips == 1 && $slaves[$i].hipsImplant == 0 && random(1,100) > 90>>
			<<set $slaves[$i].hips += 1>>
		<<elseif $slaves[$i].preg > 28 && $slaves[$i].physicalAge >= 18 && $slaves[$i].hips == 0 && $slaves[$i].hipsImplant == 0 && random(1,100) > 70>>
			<<set $slaves[$i].hips += 1>>
		<</if>>
		<<if $slaves[$i].bellyPreg >= 1500>>
			<<if setup.fakeBellies.includes($slaves[$i].bellyAccessory)>>
				<<set $slaves[$i].bellyAccessory = "none">>
			<</if>>
			<<if ($slaves[$i].preg > 20) && ($slaves[$i].lactation == 0) && $slaves[$i].health >= -20 && $slaves[$i].weight > -30>>
				<<if $slaves[$i].preg > random(18,30)>>
					<<set $slaves[$i].lactation = 1>>
				<</if>>
			<</if>>
		<</if>>
	<</if>> /* closes .preg >= 10 */
<</if>> /* END PREG EFFECTS */

<<if $slaves[$i].belly >= 1000000>>
	<<if $slaves[$i].bellySag < 50>>
		<<set $slaves[$i].bellySag += 1>>
		<<if $slaves[$i].preg > 0>>
			<<set $slaves[$i].bellySagPreg += 1>>
		<</if>>
	<<elseif $slaves[$i].preg > 0 && $slaves[$i].bellySagPreg < 20>>
		<<set $slaves[$i].bellySagPreg += 1>>
	<</if>>
	<<if $slaves[$i].pregControl == "speed up">>
		<<set $slaves[$i].bellySag += 5, $slaves[$i].bellySagPreg += 5>>
	<</if>>
<<elseif $slaves[$i].belly >= 750000>>
	<<if $slaves[$i].bellySag < 30>>
		<<set $slaves[$i].bellySag += 0.7>>
		<<if $slaves[$i].preg > 0>>
			<<set $slaves[$i].bellySagPreg += 0.7>>
		<</if>>
	<<elseif $slaves[$i].preg > 0 && $slaves[$i].bellySagPreg < 30>>
		<<set $slaves[$i].bellySagPreg += 0.7>>
	<</if>>
	<<if $slaves[$i].pregControl == "speed up">>
		<<set $slaves[$i].bellySag += 2, $slaves[$i].bellySagPreg += 2>>
	<</if>>
<<elseif $slaves[$i].belly >= 600000>>
	<<if $slaves[$i].bellySag < 20>>
		<<set $slaves[$i].bellySag += 0.5>>
		<<if $slaves[$i].preg > 0>>
			<<set $slaves[$i].bellySagPreg += 0.5>>
		<</if>>
	<<elseif $slaves[$i].preg > 0 && $slaves[$i].bellySagPreg < 20>>
		<<set $slaves[$i].bellySagPreg += 0.5>>
	<</if>>
	<<if $slaves[$i].pregControl == "speed up">>
		<<set $slaves[$i].bellySag += 1, $slaves[$i].bellySagPreg += 1>>
	<</if>>
<<elseif $slaves[$i].belly >= 450000>>
	<<if $slaves[$i].bellySag < 15>>
		<<set $slaves[$i].bellySag += 0.4>>
		<<if $slaves[$i].preg > 0>>
			<<set $slaves[$i].bellySagPreg += 0.4>>
		<</if>>
	<<elseif $slaves[$i].preg > 0 && $slaves[$i].bellySagPreg < 15>>
		<<set $slaves[$i].bellySagPreg += 0.4>>
	<</if>>
	<<if $slaves[$i].pregControl == "speed up">>
		<<set $slaves[$i].bellySag += 0.6, $slaves[$i].bellySagPreg += 0.6>>
	<</if>>
<<elseif $slaves[$i].belly >= 300000>>
	<<if $slaves[$i].bellySag < 10>>
		<<set $slaves[$i].bellySag += 0.3>>
		<<if $slaves[$i].preg > 0>>
			<<set $slaves[$i].bellySagPreg += 0.3>>
		<</if>>
	<<elseif $slaves[$i].preg > 0 && $slaves[$i].bellySagPreg < 10>>
		<<set $slaves[$i].bellySagPreg += 0.3>>
	<</if>>
	<<if $slaves[$i].pregControl == "speed up">>
		<<set $slaves[$i].bellySag += 0.5, $slaves[$i].bellySagPreg += 0.5>>
	<</if>>
<<elseif $slaves[$i].belly >= 100000>>
	<<if $slaves[$i].bellySag < 10>>
		<<set $slaves[$i].bellySag += 0.2>>
		<<if $slaves[$i].preg > 0>>
			<<set $slaves[$i].bellySagPreg += 0.2>>
		<</if>>
	<<elseif $slaves[$i].preg > 0 && $slaves[$i].bellySagPreg < 10>>
		<<set $slaves[$i].bellySagPreg += 0.2>>
	<</if>>
	<<if $slaves[$i].pregControl == "speed up">>
		<<set $slaves[$i].bellySag += 0.3, $slaves[$i].bellySagPreg += 0.3>>
	<</if>>
<<elseif ($slaves[$i].bellyPreg >= 10000) || ($slaves[$i].bellyImplant >= 10000)>>
	<<if $slaves[$i].bellySag < 5>>
		<<set $slaves[$i].bellySag += 0.1>>
		<<if $slaves[$i].preg > 0>>
			<<set $slaves[$i].bellySagPreg += 0.1>>
		<</if>>
	<<elseif $slaves[$i].preg > 0 && $slaves[$i].bellySagPreg < 5>>
		<<set $slaves[$i].bellySagPreg += 0.1>>
	<</if>>
	<<if $slaves[$i].pregControl == "speed up">>
		<<set $slaves[$i].bellySag += 0.2, $slaves[$i].bellySagPreg += 0.2>>
	<</if>>
<</if>>
<<if $slaves[$i].bellySagPreg > $slaves[$i].bellySag>>
	<<set $slaves[$i].bellySagPreg = $slaves[$i].bellySag>>
<</if>>

<<if $slaves[$i].bellySag > 0 && $slaves[$i].belly < 1500>>
	<<if $slaves[$i].muscles > 95>>
		<<if (random(1,100) > 1)>>
			<<if $slaves[$i].bellySagPreg > 0>>
				<<set $slaves[$i].bellySag -= 0.5, $slaves[$i].bellySagPreg -= 0.5>>
				<<if $slaves[$i].bellySag < 0>>
					<<set $slaves[$i].bellySag = 0, $slaves[$i].bellySagPreg = 0>>
				<</if>>
			<<else>>
				<<set $slaves[$i].bellySag -= 0.5>>
				<<if $slaves[$i].bellySag < 0>>
					<<set $slaves[$i].bellySag = 0>>
				<</if>>
			<</if>>
		<</if>>
	<<elseif $slaves[$i].muscles >= 30>>
		<<if (random(1,100) > 20)>>
			<<if $slaves[$i].bellySagPreg > 0>>
				<<set $slaves[$i].bellySag -= 0.4, $slaves[$i].bellySagPreg -= 0.4>>
				<<if $slaves[$i].bellySag < 0>>
					<<set $slaves[$i].bellySag = 0, $slaves[$i].bellySagPreg = 0>>
				<</if>>
			<<else>>
				<<set $slaves[$i].bellySag -= 0.4>>
				<<if $slaves[$i].bellySag < 0>>
					<<set $slaves[$i].bellySag = 0>>
				<</if>>
			<</if>>
		<</if>>
	<<elseif $slaves[$i].muscles >= 5>>
		<<if (random(1,100) > 40)>>
			<<if $slaves[$i].bellySagPreg > 0>>
				<<set $slaves[$i].bellySag -= 0.3, $slaves[$i].bellySagPreg -= 0.3>>
				<<if $slaves[$i].bellySag < 0>>
					<<set $slaves[$i].bellySag = 0, $slaves[$i].bellySagPreg = 0>>
				<</if>>
			<<else>>
				<<set $slaves[$i].bellySag -= 0.3>>
				<<if $slaves[$i].bellySag < 0>>
					<<set $slaves[$i].bellySag = 0>>
				<</if>>
			<</if>>
		<</if>>
	<<else>>
		<<if (random(1,100) > 60)>>
			<<if $slaves[$i].bellySagPreg > 0>>
				<<set $slaves[$i].bellySag -= 0.2, $slaves[$i].bellySagPreg -= 0.2>>
				<<if $slaves[$i].bellySag < 0>>
					<<set $slaves[$i].bellySag = 0, $slaves[$i].bellySagPreg = 0>>
				<</if>>
			<<else>>
				<<set $slaves[$i].bellySag -= 0.2>>
				<<if $slaves[$i].bellySag < 0>>
					<<set $slaves[$i].bellySag = 0>>
				<</if>>
			<</if>>
		<</if>>
	<</if>>
<</if>>

<<if ($slaves[$i].preg > 37) && ($slaves[$i].broodmother == 0) && (random(1,100) > 90)>>
	<<set $slaves[$i].birthsTotal += WombBirthReady($slaves[$i], 35), WombBirth($slaves[$i], 35), WombFlush($slaves[$i]), $slaves[$i].preg = 0, $slaves[$i].pregWeek = -4, $slaves[$i].pregSource = 0, $slaves[$i].pregType = 0, $slaves[$i].pregKnown = 0 >>
<<elseif ($slaves[$i].preg > 41) && ($slaves[$i].broodmother == 0)>>
	<<set $slaves[$i].birthsTotal += WombBirthReady($slaves[$i], 35), WombBirth($slaves[$i], 35), WombFlush($slaves[$i]), $slaves[$i].preg = 0, $slaves[$i].pregWeek = -4, $slaves[$i].pregSource = 0, $slaves[$i].pregType = 0, $slaves[$i].pregKnown = 0>>
<<elseif ($slaves[$i].preg > 37) && ($slaves[$i].broodmother > 0)>>
	<<if $slaves[$i].broodmother > 0>>
		<<set $slaves[$i].birthsTotal += WombBirthReady($slaves[$i], 37), WombBirth($slaves[$i], 37), $slaves[$i].preg = WombMaxPreg($slaves[$i])>>
	<</if>>
<</if>>

<<run SetBellySize($slaves[$i])>> /*Actually it's now better to set belly size without checking of any conditions. Just to be sure. Should correct forgotten variables too. */

<<if ($slaves[$i].hStyle != "shaved" && $slaves[$i].bald != 1 && $slaves[$i].haircuts == 0) && ($slaves[$i].hLength < 150)>>
	<<set $slaves[$i].hLength += 1>>
<</if>>
