code:
:: Widgets containers [widget]
<<widget "creatureActivity">>
<<if $args[0]>>
	<<if $args[0] lt 60>>
		Perfect activity
		<<earnFeat "Top Broodmother Host">>
	<<elseif $args[0] lte 70>>
		Amazing activity
	<<elseif $args[0] lte 100>>
		Good activity
	<<elseif $args[0] lte 150>>
		Decent activity
	<<elseif $args[0] lte 200>>
		Okay activity
	<<elseif $args[0] lte 250>>
		Poor activity
	<<elseif $args[0] lte 300>>
		Rare activity
	<<else>>
		Very rare activity
	<</if>>
<</if>>
<</widget>>

<<widget "creatureContainersProgressDay">>
<<set _list to $container.list>>
<<for _i to 0; _i lt _list.length; _i++>>
	<<set _container to $container[_list[_i]]>>
	<<if _container.count is 0>>
		<<set _container.daysSinceFed to 0>>
		<<continue>>
	<</if>>
	<<if _list[_i] is "home">>
		<<if $NPCName[$NPCNameList.indexOf("Kylar")].love gte 75 and $NPCName[$NPCNameList.indexOf("Kylar")].state is "active">>
			<<set _container.kylarHelp to true>>
		<<else>>
			<<set _container.kylarHelp to false>>
		<</if>>
		<<if _container.kylarHelp is true and _container.kylarDelay is 0 and _container.daysSinceFed is _container.maxDaysWithoutFood>>
			<<npcincr Kylar love -1>>
			<<set _container.daysSinceFed -= 1>>
			<<set _container.kylarFed to true>>
		<<elseif _container.kylarHelp is true and _container.kylarDelay gt 0 and _container.daysSinceFed is 0>>
			<<set _container.kylarDelay-->>
			<<set _container.kylarFed to false>>
		<</if>>
	<</if>>
	<<set _container.daysSinceFed += 1>>
	<<if _container.daysSinceFed gt _container.maxDaysWithoutFood>>
		<<set _container.deadCreatures to _container.count>>
		<<for _i to 0; _i lt _container.count; _i++>>
			<<if _container.creatures[_i].creature.includes("Pale") and $wraith and $wraith.state isnot "">>
				<<set $wraith.offspring to "dead">>
				<<set $wraithAnger to 30>>
				<<set $wraithShow to true>>
			<</if>>
		<</for>>
		<<set _container.count to 0>>
		<<set _container.creatures to {}>>
	<</if>>
	<<set _container.visited to false>>
<</for>>
<</widget>>

<<widget "creatureVisit">>
<<set _container to $container[$location]>>
<<set _container.visited to true>>
<<set _container.daysSinceFed to 0>>

/*stress, trauma, fatigue, purity, impurity, hallucinogens*/
<<set _boosts to [false,false,false,false,false,false]>>
<<set _purityGain to 0>><<set _tenticles to 0>><<set _paleChance to 0>>
<<for _i to 0; _i lt _container.maxCount; _i++>>
	<<if _container.creatures[_i] is undefined>>
		<<continue>>
	<</if>>
	<<if _container.creatures[_i] isnot null>>
		<<set _tendingMulti to 1 + (currentSkillValue('tending') / 1000)>>
		<<set _value = Math.floor(5000 / _container.creatures[_i].stats.speed)>>
		<<if _container.upgrades.luxury gt 0>>
			<<set _value to Math.floor(_value * (1 + (0.25 * _container.upgrades.luxury)))>>
		<</if>>
		<<if _value gt 0>>
			<<set $stress -= Math.floor(_value * _tendingMulti)>>
			<<set _boosts[0] to true>>
		<</if>>
		<<if Math.floor(_value / 8) gt 0>>
			<<set $trauma -= Math.floor(_value / 8)>>
			<<set _boosts[1] to true>>
		<</if>>
		<<if _container.creatures[_i].creature is "Slime">>
			<<set _purityGain += 0.5>>
		<</if>>
		<<if _container.creatures[_i].creature is "Pale Slime">>
			<<set _purityGain += 1.5>>
			<<set $hallucinogen += 20>>
			<<set _boosts[5] to true>>
			<<set _paleChance ++>>
		<</if>>
		<<if _container.creatures[_i].creature is "Worm">>
			<<set _purityGain -= 0.5>>
		<</if>>
		<<if _container.creatures[_i].creature is "Tentacle">>
			<<if Math.floor(_value / 4) gt 0>>
				<<set $tiredness -= Math.floor((_value / 4) * _tendingMulti)>>
				<<set _boosts[2] to true>>
			<</if>>
			<<set _tenticles += 0.5>>
		<</if>>
		<<if _container.creatures[_i].creature is "Pale Tentacle">>
			<<if Math.floor(_value / 3) gt 0>>
				<<set $tiredness -= Math.floor((_value / 3) * _tendingMulti)>>
				<<set _boosts[2] to true>>
				<<set $hallucinogen += 30>>
				<<set _boosts[5] to true>>
				<<set _paleChance ++>>
			<</if>>
			<<set _tenticles += 1.5>>
		<</if>>
		<<if _container.creatures[_i].creature is "Vine">>
			<<set _tenticles += 0.5>>
		<</if>>
	<</if>>
<</for>>

<<if _purityGain gt 0>>
	<<set _purityGain += _tenticles>>
<<elseif _purityGain lt 0>>
	<<set _purityGain -= _tenticles>>
<</if>>
<<if Math.floor(_purityGain) gt 0>>
	<<set _purityGain to Math.floor(_purityGain)>>
	<<set _boosts[3] to true>>
<<elseif Math.ceil(_purityGain) lt 0>>
	<<set _purityGain to Math.ceil(_purityGain)>>
	<<set _boosts[4] to true>>
<</if>>
<<purity _purityGain>>

<<if _boosts[0]>> <<lstress>><</if>>
<<if _boosts[1]>> <<ltrauma>><</if>>
<<if _boosts[2]>> <<ltiredness>><</if>>
<<if _boosts[3]>> <<gpurity>><</if>>
<<if _boosts[4]>> <<lpurity>><</if>>
<<if _boosts[5]>> <<ghallucinogens>><</if>>

<<if $wraith and $wraith.state isnot "" and _paleChance gte random(1, 10) and !$possessed>>

	You catch a glimpse of a pale figure standing right next to you. You jump back in shock. It slowly turns to you.

	"Beautiful. Keep <<if _container.count isnot 1>>them<<else>>it<</if>> safe." It disappears with a bright flash. <<stress 6>><<gstress>>
	<<set $wraith.offspring to "alive">>
<</if>>

<</widget>>

:: Containers
<<set $outside to 0>><<set $location to $container.lastLocation>><<effects>>
<<set _container to $container[$location]>>
<<set _pregnancy to $sexStats.anus.pregnancy>>
<<set $checkboxResult to {}>>

<<if _container.count is 0>>
	<<if _container.deadCreatures is 0>>
		You currently have no <<if _pregnancy.namesChildren is true>>children<<else>>parasites<</if>> inside the <<print _container.name>>.

	<<else>>
		After not checking and feeding <<if _pregnancy.namesChildren is true>>your children<<else>>the parasites<</if>>, it looks like some have died. You take your time in burying them.
		<<ggtrauma>>

		<<if _pregnancy.namesChildren is true>>
			<<set _traumaMulti to 2>>
		<<else>>
			<<set _traumaMulti to 1>>
		<</if>>
		<<trauma `30 * _traumaMulti * _container.deadCreatures`>>
		<<if $wraith and $wraith.state isnot "" and $wraithShow>>
			<<unset $wraithShow>>
			You feel something gingerly grab your neck from behind.

			"Unforgivable. You'll join <<if _container.count isnot 1>>them<<else>>it<</if>> soon." <<stress 12>><<trauma 12>><<ggstress>><<ggtrauma>>

			You turn around, but nothing's there.

		<</if>>

		<<link [[Next (1:00)|$passage]]>><<set _container.deadCreatures to 0>><<pass 60>><</link>>
	<</if>>
<<else>>
	<<if _container.visited is false>>
		You check on <<if _pregnancy.namesChildren is true>>your child<<if _container.count isnot 1>>ren<</if>><<else>>the parasite<<if _container.count isnot 1>>s<</if>><</if>>, and make sure <<if _container.count isnot 1>>they have<<else>>it has<</if>> everything <<if _container.count isnot 1>>they need<<else>>it needs<</if>> inside your <<print _container.name>>.

		<<creatureVisit>>
	<<else>>
		You watch your <<if _pregnancy.namesChildren is true>>child<<if _container.count isnot 1>>ren<</if>><<else>>parasite<<if _container.count isnot 1>>s<</if>><</if>> inside your <<print _container.name>>.
	<</if>>

	It has a max capacity of <<number _container.maxCount>> and <<if _pregnancy.namesChildren is true>>your child<<if _container.count isnot 1>>ren<</if>><<else>>the parasite<<if _container.count isnot 1>>s<</if>><</if>> can survive <<number _container.maxDaysWithoutFood>> days without your attention<<if _container.feederName>>, thanks to your <<print _container.feederName>><</if>>. <<if _container.decorations>>You have <<print _container.decorations>> setup within the tank.<</if>>
<</if>>

<<if _container.count gt 0>>

		<<for _i to 0; _i lt _container.maxCount; _i++>>
			<<if _container.creatures[_i] is undefined>>
				<<continue>>
			<</if>>
			<<if _container.creatures[_i] isnot null>>

<<print '<<checkbox "$checkboxResult[' + clone(_i) + ']" false true>>'>> - <<print _container.creatures[_i].creature>> - <<print _container.creatures[_i].stats.gender>> - <<creatureActivity _container.creatures[_i].stats.speed>>

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

<</if>>

<<if _container.deadCreatures is 0>>
	<<if _pregnancy.feltMovement is true>>
		<<if $worn.genitals.anal_shield is 1>>
			You're unable to deliver <<if _pregnancy.namesChildren is true>>your children<<else>>the parasites<</if>> while you have an anal shield.

		<<else>>
			<<if _pregnancy.namesChildren is true>>
				<<link [[Attempt to deliver your baby (1:00)|GiveBirth]]>><<pass 60>><</link>>

			<<else>>
				<<link [[Attempt to deliver the parasite (1:00)|GiveBirth]]>><<pass 60>><</link>>

			<</if>>
		<</if>>
	<<elseif _pregnancy.count - (_pregnancy.motherStatus is 2 ? 1 : 0) gt 0>>
		You don't think <<print (_pregnancy.namesChildren is true ? "your children" : "the parasites")>> are ready for delivery.

	<</if>>

	<<if _container.count gt 0>>
		<<link [[Transfer for selling|$passage]]>>
			<<for _i to 0; _i lt _container.maxCount;_i++>>
				<<if _container.creatures[_i] is undefined>>
					<<continue>>
				<</if>>
				<<if _container[_i] isnot null>>
					<<if $checkboxResult[_i] is true>>
						<<set $number to clone(_i)>>
						<<moveCreature $location "portable" _i>>
					<</if>>
				<</if>>
			<</for>>
		<</link>>

	<</if>>
	<<link [[Leave|$container[$location].leaveLink]]>><</link>>
<</if>>


code:
:: Pregnancy Introduction

<<set $outside to 0>><<set $location to "town">><<effects>>
<<set $sexStats.anus.pregnancy.seenDoctor to 2>>
<<harper_intro>>
"You're experiencing strange sensations in your abdomen?" <<he>> asks. You nod. <<He>> wheels <<his>> chair closer, and places <<his>> stethoscope to your tummy.

<<He>> listens for a moment, then wheels away and types something into <<his>> computer. "You have a parasite problem," <<he>> says. "They're using you as part of their reproductive cycle." <<He>> notices the look on your face, and smiles. "Don't be concerned. They won't harm you. They'll remove themselves when they're ready."

<<He>> spends several minutes explaining how to "birth" the creatures. What to do, and what not to do. It sounds simple. Drop to all fours, and squeeze.

<<He>> turns back to <<his>> computer. "Species like this are of scientific interest," <<he>> continues. "If you're interested in making a bit of money, I'm able to pay you for them on behalf of a local company." <<He>> rises to <<his>> feet. "Is there anything else?"

You shake your head. <<He>> holds open the door for you, and you leave the office. "Be well," <<he>> says as you pass.

<<link [[Return to foyer|Hospital Foyer]]>><<endevent>><</link>>

:: Pregnancy Discussion

<<set $outside to 0>><<set $location to "town">><<effects>>
<<if $firstOption is undefined>><<set $firstOption to true>><</if>>
<<set _pregnancy to $sexStats.anus.pregnancy>>

<<if $firstOption is true>>
	<<npc Harper>><<person1>>You don't have to wait long. Doctor Harper emerges from <<his>> office and beckons you over. You enter <<his>> office and take a seat.

	"How can I help you?" <<he>> asks.

<<else>>
	You are in Doctor Harper's office. "Is there anything else I can help you with?" <<he>> asks.

<</if>>

<<if $sexStats.anus.pregnancy.seenDoctor gte 2 and $container.portable.value gt 0>>
	<<if _pregnancy.namesChildren is true>>
		<<link [[Sell the children you're carrying (0:05)|Sell Children]]>><<pass 5>><<set $firstOption to false>><</link>>

	<<else>>
		<<link [[Sell the parasites you're carrying (0:05)|Sell Children]]>><<pass 5>><<set $firstOption to false>><</link>>

	<</if>>
<</if>>
<<if $sexStats.anus.pregnancy.seenDoctor is 3>>
	<<link [[Inquire about feeling something large in your stomach (0:10)|Pregnancy Futa Introduction]]>><<pass 10>><<set $firstOption to false>><</link>>

<</if>>
<<if $sexStats.anus.pregnancy.seenDoctor gte 4 and $sexStats.anus.pregnancy.motherStatus is 2>>
	<<link [[Inquire about anal futa removal (0:30)|Remove Futa Pregnancy]]>><<pass 30>><<set $futaCheck to true>><<set $firstOption to false>><</link>>

<</if>>

<<link [[Return to foyer|Hospital Foyer]]>><<endevent>><<unset $firstOption>><</link>>

:: Sell Children

<<set $outside to 0>><<set $location to "town">><<effects>>
Doctor Harper walks over to <<his>> office door, and locks it. <<He>> sits back down. "What have you brought me today?" <<he>> asks.

You pull out the small container <<he>> gave you. <<He>> looks inside. Seeming satisfied, <<he>> produces another, larger container from beneath <<his>> desk. <<He>> transfers the contents and hands the empty container to you. <<He>> opens a drawer, and counts out <<printmoney $container.portable.value*100>><<set $money += $container.portable.value * 100>>. <<He>> hands it to you.

"The community thanks you," <<he>> says.

<<set $container.portable.value to 0>>
<<set $container.portable.creatures to []>>
<<link [[Next|Pregnancy Discussion]]>><</link>>

:: Pregnancy Futa Introduction

<<set $outside to 0>><<set $location to "town">><<effects>>
<<set $sexStats.anus.pregnancy.seenDoctor to 4>>
"Strange," <<he>> says. "N-not that there's anything to be alarmed about." <<He>> pulls <<his>> chair back to <<his>> computer and types something in.

You wait as <<he>> reads the screen, occasionally tapping on the keyboard. <<He>> pulls a large book from a drawer, blows off dust, and flips through the pages. At last, <<he>> puts the book away and turns to face you.

"You have a parasite," <<he>> says. "An unusual one. It has both sex organs, and is able to mate with itself. We'll need to perform a procedure here in order to remove it. Until then, you'll continue to birth its offspring."

<<link [[Next|Pregnancy Discussion]]>><</link>>

:: Pregnancy Clear

<<link [[Next|Pregnancy Discussion]]>><</link>>

:: Remove Futa Pregnancy

<<set $outside to 0>><<set $location to "town">><<effects>>

<<set _pregnancy to $sexStats.anus.pregnancy>><<set _extra to false>>
<<for _i to 0; _i lt _pregnancy.maxCount; _i++>>
	<<if _pregnancy[_i] isnot null>>
		<<if _pregnancy[_i].stats.gender is "Futa">>
			<<moveCreature _i "destroy">>
			<<set _pregnancy.motherStatus to 1>>
			<<set _pregnancy.maxCount to 2>>
			<<break>>
		<</if>>
	<</if>>
<</for>>

<<set _slotsFree to [false, false]>>
<<for _i to 0; _i lt 4; _i++>>
	<<if _i lt 2 and _pregnancy[_i] is null>>
		<<set _slotsFree[_i] to true>>
	<<elseif _i gte 2 and _pregnancy[_i] isnot null>>
		<<if _slotsFree[0] is true>>
			<<set _pregnancy[0] to clone(_pregnancy[_i])>>
			<<set _slotsFree[0] to false>>
		<<elseif _slotsFree[1] is true>>
			<<set _pregnancy[1] to clone(_pregnancy[_i])>>
			<<set _slotsFree[1] to false>>
		<<else>>
			<<set _extra to true>>
			<<set _pregnancy.count -= 1>>
			<<set _pregnancy.givenBirth += 1>>
		<</if>>
		<<set _pregnancy[_i] to null>>
	<</if>>
<</for>>

"Please undress and lie on the table," <<he>> says while pulling on a latex glove. "No need to be shy." <<He>> turns and rummages through a drawer.

You <<nervously>> remove your clothing while <<his>> back is turned. You lie down on the table, conscious of your <<lewdness>>. <<His>> face neutral, the doctor grasps your legs and pushes them against your shoulders, before tying them down with straps.

"It will be easier if you're still," <<he>> affirms as <<he>> ties down your wrists. You can barely move.

<<if $worn.genitals.anal_shield is 1>>
	<<He>> examines your $worn.under_lower.name, then produces a strange metal device from <<his>> coat. <<He>> taps the metal, and your anal shield falls loose. "I'll return it when I'm done," <<he>> says.

<</if>>

<<He>> opens another drawer, and pulls out a smooth white rod with a round ball on one end. <<He>> pushes the thin end against your <<bottom>>. "Just relax,<<if pregnancyBellyVisible()>> this won't hurt the baby,<</if>>" <<he>> says. It slides in without pain, as if lubricated. Harper twists the other side, and you feel it pulse within you.
<<garousal>><<arousal 1200>>

Harper stares unblinking at your <<bottom>> as the pulsing increases in intensity. Just when you feel like you can't take any more, <<he>> eases it out. The <<if _pregnancy.namesChildren is true>>baby<<else>>parasite<</if>> is wrapped around the end<<if _extra is true>> alongside a smaller one<</if>>. <<He>> puts it in an opaque container, and seals it shut.

"All done," <<he>> says as <<he>> unties the straps. <<He>> turns away as you dress.

<<link [[Next|Pregnancy Discussion]]>><<unset $futaCheck>><</link>>

:: GiveBirth

<<set $outside to 0>><<set $location to $container.lastLocation>><<effects>>
<<set _pregnancy to $sexStats.anus.pregnancy>>
<<set _pregnancy.feltMovement to false>>
<<set _container to $container[$location]>>
<<set $pregResult to "notReady">>
<<set _stressMulti to 2 - _pregnancy.motherStatus>>
<<set $checkboxResult to {}>>
<<set $checkboxReplace to {}>>
<<set $parasiteSelectionCount to 0>>
<<set _vine to 0>><<set _metal to 0>><<set _pale to 0>><<set _swimmer to 0>><<set _crawler to 0>>

Following the directions from Doctor Harper, you get into position and attempt to deliver <<if _pregnancy.namesChildren is true>>your baby<<else>>the parasites<</if>>. <<if _stressMulti gt 0>><<gstress>><</if>><<set $stress += 250 * _stressMulti>>

<<for _i to 0; _i lt _pregnancy.maxCount; _i++>>
	<<if _pregnancy[_i] is null>>
		<<continue>>
	<</if>>
	<<if _pregnancy[_i].stats.gender isnot "Futa">>
		<<set _rand to random(0,100)>>
		<<if (_rand lte 80 and _pregnancy[_i].daysLeft is 0) or (_rand lte 50 and _pregnancy[_i].daysLeft lte 1) or (_rand lte 30 and _pregnancy[_i].daysLeft lte 2) or (_rand lte 10 and _pregnancy[_i].daysLeft lte 3)>>
			<<if $pregResult is "notReady">>
				<<set $pregResult to [clone(_i)]>>
			<<else>>
				<<set $pregResult.push(clone(_i))>>
			<</if>>
		<</if>>
	<</if>>
<</for>>

<<if $pregResult is "notReady">>
	Despite your efforts, none of <<if _pregnancy.namesChildren is true>>your children<<else>>the parasites<</if>> are ready to leave you.

	<<link [[Next|Containers]]>><<unset $pregResult>><</link>>
<<else>>
	Your body shudders, and to the floor falls <<if _pregnancy.namesChildren is true>><<number $pregResult.length>> <<print $pregResult.length gt 1 ? 'babies' : 'baby'>><<else>><<number $pregResult.length>> <<print $pregResult.length gt 1 ? 'parasites' : 'parasite'>><</if>>.

		<<for _i to 0; _i lt $pregResult.length; _i++>>

<<print '<<checkbox "$checkboxResult[' + clone($pregResult[_i]) + ']" false true checked>>'>> - <<print _pregnancy[$pregResult[_i]].creature>> - <<creatureActivity _pregnancy[$pregResult[_i]].stats.speed>>

			<<if _pregnancy[$pregResult[_i]].creature is "Vine">>
				<<set _vine++>>
			<</if>>
			<<if _pregnancy[$pregResult[_i]].creature.includes("Metal")>>
				<<set _metal++>>
			<</if>>
			<<if _pregnancy[$pregResult[_i]].creature.includes("Pale")>>
				<<set _pale++>>
			<</if>>
			<<if _pregnancy[$pregResult[_i]].creature is "Swimmer">>
				<<set _swimmer++>>
			<</if>>
			<<if _pregnancy[$pregResult[_i]].creature is "Crawler">>
				<<set _crawler++>>
			<</if>>
		<</for>>

	<<if _vine gte 1 and !$containerVine and $location is "home">>
		<<set $containerVine to true>>
		You worry that the vine<<if _vine gte 2>>s<</if>> won't be able to survive without being planted in a better environment, but <<if _vine is 1>>it seems<<else>>they seem<</if>> to be fine in your <<print $container[$location].name>>, writhing around. You suspect <<if _vine is 1>>it's<<else>>they're<</if>> not strictly plant life.

	<</if>>
	<<if _metal gte 1 and !$containerMetal and $location is "home">>
		<<set $containerMetal to true>>
		Upon closer inspection, the metal tentacle isn't truly metal. It has a metallic colour and pattern, but it bends and writhes in ways that steel wouldn't be able to. You hope it doesn't need anything in particular to eat.

	<</if>>
	<<if _pale gte 1 and !$containerPale and $location is "home">>
		<<set $containerPale to true>>
		Your hands seem to move on their own, and you find yourself holding the pale creature<<if _pale gte 2>>s<</if>>. <<if _pale gte 2>>They're<<else>>It's<</if>> so pale that <<if _pale gte 2>>they're<<else>>it's<</if>> almost translucent. You feel a twinge of dread, but it's quickly replaced by an odd contentment.
		You should be careful deciding whether to keep <<if _pale gte 2>>them<<else>>it<</if>>.

	<</if>>
	<<if _swimmer gte 1 and !$containerSwimmer and $location is "home">>
		<<set $containerSwimmer to true>>
		The <<if _swimmer gte 2>>swimmers are<<else>>swimmer is<</if>> barely the size of your hand, making <<if _swimmer gte 2>>their<<else>>its<</if>> tentacles both very tiny and relatively oversized.

	<</if>>
	<<if _crawler gte 1 and !$containerCrawler and $location is "home">>
		<<set $containerCrawler to true>>
		It's odd seeing <<if _crawler gte 2>>crawlers<<else>>a crawler<</if>> without a stalagmite.
		<<if _container.upgrades.luxury gte 1>>
			Thanks to the <<print _container.decorations>>, <<if _crawler gte 2>>they<<else>>it<</if>> can find several comfortable places to squeeze into.
		<<else>>
			<<if _crawler gte 2>>They seem<<else>>It seems<</if>> uncomfortable in the open area, with nowhere to hide.
		<</if>>

	<</if>>
	<<if $pregResult.length gt (_container.maxCount - _container.count)>>
		Please select any required to replace, it will replace from top to bottom:

			<<for _i to 0; _i lt _container.maxCount; _i++>>
				<<if _container.creatures[_i] is undefined>>
					<<set $checkboxReplace[_i] to true>>
					<<continue>>
				<</if>>
				<<if _container.creatures[_i] isnot null>>

<<print '<<checkbox "$checkboxReplace[' + clone(_i) + ']" false true ($checkboxReplace[' + clone(_i) + '] ? "checked" : "")>>'>> - <<print _container.creatures[_i].creature>> - <<creatureActivity _container.creatures[_i].stats.speed>>

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

	<</if>>

<<PregEventsResult>>

<</if>>

:: Widgets PregEventsResult [widget]
<<widget "PregEventsResult">>
<<set $outside to 0>><<set $location to $container.lastLocation>><<effects>>
<<set _pregnancy to $sexStats.anus.pregnancy>>
<<set _container to $container[$location]>>
<<set $parasiteSelectionCount to 0>>
<<set $parasiteReplaceArray to []>>
<<set _availableStorage to (_container.maxCount - _container.count)>>
<<for _i to 0; _i lt $pregResult.length; _i++>>
	<<if $checkboxResult[$pregResult[_i]] is true>>
		<<set $parasiteSelectionCount += 1>>
	<</if>>
<</for>>
<<for _i to 0; _i lt _container.count; _i++>>
	<<if $checkboxReplace[_i] is true>>
		<<set $parasiteReplaceArray.push(clone(_i))>>
	<</if>>
<</for>>

<<if $debug is 1>>
	Debug - Keep selected babies result (ID - Checkbox - Result)

	<<for _i to 0; _i lt $pregResult.length;_i++>>
		<<if $checkboxResult[$pregResult[_i]] is true>>
			<<print $pregResult[_i]>> - <<print $checkboxResult[$pregResult[_i]]>> - Keep

		<<elseif $checkboxResult[$pregResult[_i]] is false>>
			<<print $pregResult[_i]>> - <<print $checkboxResult[$pregResult[_i]]>> - Sell

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

<</if>>

<<if $parasiteSelectionCount lte _availableStorage>>
	<<if $parasiteSelectionCount gt 0>>
		<<if _pregnancy.namesChildren is true>>
			<<link [[Keep selected babies|PregEventsResult2]]>>
				<<set $pregChoice to "KeepSelected">>
			<</link>>
		<<else>>
			<<link [[Keep selected parasites|PregEventsResult2]]>>
				<<set $pregChoice to "KeepSelected">>
			<</link>>
		<</if>>
	<</if>>
<<elseif $parasiteSelectionCount gt 0>>
	Not enough storage for selected amount. Please replace <<number $parasiteSelectionCount-_availableStorage>> <<if _pregnancy.namesChildren is true>><<print $parasiteSelectionCount - _availableStorage gt 1 ? 'babies' : 'baby'>><<else>><<print $parasiteSelectionCount - _availableStorage gt 1 ? 'parasites' : 'parasite'>><</if>>.

	<<if ($parasiteSelectionCount - $parasiteReplaceArray.length) is _availableStorage>>
		<<if _pregnancy.namesChildren is true>>
			<<link [[Replace selected babies|PregEventsResult2]]>>
				<<set $pregChoice to "ReplaceSelected">>
			<</link>>
		<<else>>
			<<link [[Replace selected parasites|PregEventsResult2]]>>
				<<set $pregChoice to "ReplaceSelected">>
			<</link>>
		<</if>>
	<</if>>
<</if>>
<<if $pregResult.length lte _availableStorage>>

	<<if _pregnancy.namesChildren is true>>
		<<link [[Keep all babies|PregEventsResult2]]>>
			<<set $pregChoice to "keepAll">>
		<</link>>
	<<else>>
		<<link [[Keep all parasites|PregEventsResult2]]>>
			<<set $pregChoice to "keepAll">>
		<</link>>
	<</if>>
<</if>>

<<if _pregnancy.namesChildren is true>>
	<<link [[Sell all babies|PregEventsResult2]]>>
		<<set $pregChoice to "sellAll">>
	<</link>>
<<else>>
	<<link [[Sell all parasites|PregEventsResult2]]>>
		<<set $pregChoice to "sellAll">>
	<</link>>
<</if>>
<</widget>>

<<widget "resetPregButtons">>

<<replace #pregResult>>
	<<PregEventsResult>>
<</replace>>

<</widget>>

:: PregEventsResult2
<<set $outside to 0>><<set $location to $container.lastLocation>><<effects>>
<<set _pregnancy to $sexStats.anus.pregnancy>>

<<switch $pregChoice>>
<<case "ReplaceSelected">>
	<<for _i to 0; _i lt $pregResult.length;_i++>>
		<<if $checkboxResult[$pregResult[_i]] is true>>
			<<if _i lt $parasiteReplaceArray.length>>
				<<moveCreature $pregResult[_i] "replace" $parasiteReplaceArray[_i]>>
			<<else>>
				<<moveCreature $pregResult[_i] "container">>
			<</if>>
		<<elseif $checkboxResult[$pregResult[_i]] is false>>
			<<moveCreature $pregResult[_i] "portable">>
		<</if>>
	<</for>>
	You decide to keep <<number $parasiteSelectionCount>> of <<if _pregnancy.namesChildren is true>>your children<<else>>the parasites<</if>> and so place <<if $parasiteSelectionCount isnot 1>>them<<else>>it<</if>> in your <<print $container[$location].name>> in place of <<number $parasiteReplaceArray.length>> <<if $parasiteReplaceArray.length gt 1>>others<<else>>other<</if>>, while preparing the rest for Doctor Harper.

<<case "KeepSelected">>
	<<for _i to 0; _i lt $pregResult.length;_i++>>
		<<if $checkboxResult[$pregResult[_i]] is true>>
			<<moveCreature $pregResult[_i] "container">>
		<<elseif $checkboxResult[$pregResult[_i]] is false>>
			<<moveCreature $pregResult[_i] "portable">>
		<</if>>
	<</for>>
	You decide to keep <<number $parasiteSelectionCount>> of <<if _pregnancy.namesChildren is true>>your children<<else>>the parasites<</if>>, and place <<if $parasiteSelectionCount isnot 1>>them<<else>>it<</if>> in your <<print $container[$location].name>> while preparing the rest for Doctor Harper.

<<case "keepAll">>
	<<for _i to 0; _i lt $pregResult.length;_i++>>
		<<moveCreature $pregResult[_i] "container">>
	<</for>>
	You decide to keep all of <<if _pregnancy.namesChildren is true>>your children<<else>>the parasites<</if>>, and place them in your <<print $container[$location].name>>.

<<case "sellAll">>
	<<for _i to 0; _i lt $pregResult.length;_i++>>
		<<moveCreature $pregResult[_i] "portable">>
	<</for>>
	You decide to sell all <<if _pregnancy.namesChildren is true>>your children<<else>>the parasites<</if>>, and prepare to take them to Doctor Harper.

<</switch>>

<<link [[Next|Containers]]>>
	<<unset $pregChoice>><<unset $pregResult>>
	<<unset $checkboxResult>><<unset $checkboxReplace>>
	<<unset $parasiteSelectionCount>><<unset $parasiteReplaceArray>>
<</link>>

:: Pregnancy Birth Hospital Passout
<<set $outside to 0>><<effects>>

Player gets taken to the hospital, labour contractions beginning. Time depends on where the player is.

<<switch $location>>
	<<case "moor" "forest">><<set _time to 60>>
	<<case "town">><<set _time to 15>>
	<<default>><<set _time to 30>>
<</switch>>
<<set _hours to Math.floor(_time / 60)>>
<<set _minutes to _time % 60>>
<<link [["Next (0"+_hours+":"+(_minutes lt 10 ? "0": "")+_minutes+")"| Pregnancy Birth Hospital]]>><<pass _time>><<set $phase to 1>><</link>>

:: Pregnancy Birth Hospital
<<set $outside to 0>><<set $location to "hospital">><<effects>>

<<if $phase is 1>>
	Player gets to the hospital by passing out.
<<else>>
	Player gets to the hospital by going there themselves.
<</if>>

Dr Harper is introduced if required. Harper checks the pc, if its a non-human pregnancy they somehow recognise it.

<<if $worn.genitals.type.includes("hidden")>>
	Chastity Belt is broken if equipped.
	<<set $worn.genitals.type.push("broken")>>
	<<genitalsruined>>

<</if>>

<<switch $sexStats.vagina.pregnancy.type>>
	<<case "human">>
		Dr Harper mentions a hidwife waiting for the player.
		<<link [[Next (00:05)| Pregnancy Birth Hospital 2]]>><<pass 5>><<set $phase to 1>><</link>>
	<<case "wolf">>
		Dr Harper mentions something about the pregnancy being abnormal and having to take the player somewhere.
		<<link [[Next (00:15)| Pregnancy Birth Hospital 2]]>><<pass 15>><<set $phase to 2>><</link>>
<</switch>>

:: Pregnancy Birth Hospital 2
<<set $outside to 0>><<set $location to "hospital">><<effects>>
<<if $phase is 1>>
	Player gets taken to a room where there is a midwife waiting. Labour contractions beginning to get more frequent, pain.
	Player feels the need to "push" but told to hold out a bit longer. Players clothes get removed. Dr Harper Leaves

	<<strip>>
	<<link [[Next (00:05)| Pregnancy Birth Hospital 3]]>><<pass 5>><<endevent>><</link>>
<<elseif $phase is 2>>
	<<switch $sexStats.vagina.pregnancy.type>>
		<<case "wolf">><<set $exitPassage to "Pregnancy Birth Hospital Wolf">>
	<</switch>>
	Player is taken to where they can give birth
	<<link [[Next (01:00)|$exitPassage]]>><<pass 1 hour>><<endevent>><</link>>

	<<link [[Debug exit|Hospital Foyer]]>><<endevent>><</link>>
<</if>>

:: Pregnancy Birth Hospital 3
<<set $outside to 0>><<set $location to "hospital">><<effects>>

Player gets on the bed, midwife checking the player over and helping to prepare. Frequent labour contractions and more pain.
Midwife give the ok to push

<<set _pregnancy to $sexStats.vagina.pregnancy>>
<<if _pregnancy.totalBirthEvents gte 5>>
	<<set _min to 15>>
	<<set _max to 60>>
<<elseif _pregnancy.totalBirthEvents gte 3>>
	<<set _min to 30>>
	<<set _max to 120>>
<<else>>
	<<set _min to 60>>
	<<set _max to 180>>
<</if>>
<<for _i to 7; _i gte 0; _i-->>
	<<if _pregnancy[_i] is null>>
		<<continue>>
	<</if>>
	<<set _max to Math.floor(_max * (1 + Math.floor(_i * 0.2)))>>
	<<set _min to Math.floor(_min * (1 + Math.floor(_i * 0.2)))>>
	<<break>>
<</for>>
<<set $timeCalc to random(_min, _max)>>
<<set _hours to Math.floor($timeCalc / 60)>>
<<set _minutes to $timeCalc % 60>>
<<link [["Next (0"+_hours+":"+(_minutes lt 10 ? "0": "")+_minutes+")"| Pregnancy Birth Hospital 4]]>><<pass $timeCalc>><</link>>

:: Pregnancy Birth Hospital 4
<<set $outside to 0>><<set $location to "hospital">><<effects>>
$timeCalc can be used to he reference how difficult the birth was, base it on the number of children
Player pushes and eventually gives birth, and is given the children to hold. Mild contractions still occur, pain stops here.

<<link [[Next| Pregnancy Birth Hospital 5]]>><<unset $timeCalc>><</link>>

:: Pregnancy Birth Hospital 5
<<set $outside to 0>><<set $location to "hospital">><<effects>>

Player is taken somewhere more comfortable where they can recover and start to have special time with their newborns. Option to name occurs here.

/*Debug args[3] "human" should be removed later*/
/*Debug args[0] should be set to something specific*/
<<birthUi "test" "Pregnancy Birth Hospital 6" _time>>

:: Pregnancy Birth Hospital 6
<<set $outside to 0>><<set $location to "hospital">><<effects>>

Player sleeps/cuddles babies/breastfeeds/looks after them each of them.

Player re-equips clothes
<<clotheson>>

<<link [[Next (24:00)|????]]>><<pass 24 hour>><<endevent>><</link>>

<<link [[Debug exit|Hospital Foyer]]>><<endevent>><</link>>

:: Pregnancy Birth Hospital Wolf
<<set $outside to 0>><<set $location to "hospital">><<effects>>
Player leaves the hospital and is taken to the forest

<<link [[Next (00:15)|Pregnancy Birth Hospital Wolf 2]]>><<pass 15>><<endevent>><</link>>

:: Pregnancy Birth Hospital Wolf 2
<<location "forest">><<effects>>
Player enters the forest on their own?

<<link [[Next (00:15)|Pregnancy Birth Hospital Wolf 3]]>><<pass 15>><<endevent>><</link>>

:: Pregnancy Birth Hospital Wolf 3
<<location "forest">><<effects>>
Extra passage example

<<link [[Next (00:15)|Pregnancy Birth Hospital Wolf 4]]>><<pass 15>><<endevent>><</link>>

:: Pregnancy Birth Hospital Wolf 4
<<set $outside to 0>><<set $location to "wolf_cave">><<effects>>
Player reaches the wolf cave, is guided to the inside of the cave to give birth. Clothes are removed.

<<strip>>
<<if $worn.genitals.type.includes("hidden")>>
	Chastity Belt is broken if equipped.
	"The pack feels your distress" later "Most of the pack has injured mouths after chewing the belt so fiercely to free you"?
	<<set $worn.genitals.type.push("broken")>>
	<<genitalsruined>>

<</if>>
<<link [[Next (00:15)|Pregnancy Birth Hospital Wolf 5]]>><<pass 15>><<endevent>><</link>>

:: Pregnancy Birth Hospital Wolf 5
<<set $outside to 0>><<set $location to "wolf_cave">><<effects>>
The others wolves leave the player alone for them to give birth, sequence should follow similar to the normal birth, though alone this time.

<<link [[Next (00:15)|Pregnancy Birth Hospital Wolf 6]]>><<pass 15>><<endevent>><</link>>

:: Pregnancy Birth Hospital Wolf 6
<<set $outside to 0>><<set $location to "wolf_cave">><<effects>>
Player is finished with giving birth and spends some time to recover and start to have special time with their newborns. Option to name occurs here.

/*Debug args[3] "wolf" should be removed later*/
<<birthUi "wolf_cave" "Pregnancy Birth Hospital Wolf 7" 60>>

:: Pregnancy Birth Hospital Wolf 7
<<set $outside to 0>><<set $location to "wolf_cave">><<effects>>
Player spends time looking after and feeding their children.

Player re-equips clothes.
<<clotheson>>

<<if $syndromewolves isnot 1>>
	<<if $bestialitydisable is "f">>
		After giving birth to pups of your own, you see they're just cute animals. You've gained the "Stockholm Syndrome: Wolves" trait.

	<<else>>
		After giving birth to pups of your own, you see they're just cute monsters. You've gained the "Stockholm Syndrome: Wolf People" trait.

	<</if>>
	<<set $syndromewolves to 1>>
	<<set $wolfevent to 0>>
	<<set $wolfstate to "cave">>
	<<set $wolfpackferocity to 10>>
	<<set $wolfpackharmony to 10>>
<</if>>
<<link [[Next (24:00)|Wolf Cave]]>><<pass 15>><<endevent>><<set $wolfevent to 0>><</link>>

:: pregnancyTest
<<effects>>
<<set $pregnancyTest-->>
<<switch $lastPassage>>
	<<case "Bedroom">>
		You take the pregnancy test, before returning to the bedroom. The test sits on your bed, as you pace back and forth waiting for it to finish.
	<<case "Eden Cabin">>
		You take the pregnancy test in Eden's bathroom, before returning to the main room. You stare at the test in your hand, not daring to look away, waiting for it to finish.
	<<case "Wolf Cave Clearing">>
		You take the pregnancy test out of view from the wolves. You stare at the test in your hand, not daring to look away, waiting for it to finish.
	<<default>>
		You take the pregnancy test. You stare at the test in your hand, not daring to look away, waiting for it to finish.
<</switch>>
The packaging said to wait 3 minutes, but it feels like an eternity passes. <<gstress>><<stress 3>>

<<set $pregnancyStats.pregnancyTestsTaken++>>
<<if !$player.vaginaExist>>
	It's negative. You wonder how it could ever be positive.
<<else>>
	<<set _pregnancy to $sexStats.vagina.pregnancy>>
	<<if _pregnancy.timerStart is null>>
		It's negative.
	<<elseif _pregnancy.timerStart is _pregnancy.timer or (between(_pregnancy.timerStart - _pregnancy.timer, 1, 3) and $random(0,100) gte 3) or (between(_pregnancy.timerStart - _pregnancy.timer, 4, 6) and $random(0,100) gte 15)>>
		It's negative.
	<<else>>
		It's positive. Many thoughts rush through your head, and you sit to collect yourself. <<gstress>><<stress 3>><<garousal>><<arousal 100>>
		<<set _pregnancy.awareOf to true>>
	<</if>>
<</if>>

<<link [[Next|$lastPassage]]>><<unset $lastPassage>><<set $eventskip to 1>><</link>>

:: pregnancyTestWidget [widget]
<<widget "pregnancyTest">>
<<if $args[0]>>
	<<if $pregnancyTest gt 0>>
		<<if $sexStats.vagina.pregnancy.awareOf isnot true>>
			<<link [[Take a pregnancy test (00:05)|pregnancyTest]]>><<pass 5>><<set $lastPassage to $args[0]>><</link>>

		<<elseif $sexStats.vagina.pregnancy.awareOf is true>>
			You have a pregnancy test, but you already know you're pregnant.

		<</if>>
	<</if>>
<</if>>
<</widget>>

:: Pregnancy ultrasound
<<set $outside to 0>><<set $location to "hospital">><<effects>>
<<set _pregnancy to $sexStats.vagina.pregnancy>>
<<harper_intro>>
<<if $ultrasoundIntro isnot 1>>
	<<set $ultrasoundIntro to 1>>
	player is introduced to what ultrasounds are, how it occurs and the reasons why they are done.
<</if>>

Player is taken somewhere where it occurs, they remove their upper related clothes.

<<overupperstrip>>
<<upperstrip>>
<<underupperstrip>>

<<link [[next|Pregnancy ultrasound 2]]>><</link>>

:: Pregnancy ultrasound 2
<<set $outside to 0>><<set $location to "hospital">><<effects>>

Ultrasound occurs, Dr Harper lets them know what going on.
<<set _pregnancy to $sexStats.vagina.pregnancy>>
<<if _pregnancy.currentCount gt 1>>
	<<set _multiple to true>>
<<else>>
	<<set _multiple to false>>
	<<switch _pregnancy[0].gender>>
		<<case "m">>
			<<set $_he to "he">>
			<<set $_He to "He">>
			<<set $_his to "his">>
			<<set $_His to "His">>
		<<case "h">>
			<<set $_he to "she">>
			<<set $_He to "She">>
			<<set $_his to "her">>
			<<set $_His to "Her">>
			<<set $_gender to "female">>
		<<case "f">>
			<<set $_he to "she">>
			<<set $_He to "She">>
			<<set $_his to "her">>
			<<set $_His to "Her">>
			<<set $_gender to "hermaphrodite">>
	<</switch>>
<</if>>
<<switch _pregnancy.type>>
	<<case "human">>
		<<if _pregnancy.timer gte _pregnancy.timerStart * 0.9>>
			<<if _multiple>>
				The babies are small, the ultrasound can only just pick it up. Their tiny hearts are beating about once every second.
				<<if _pregnancy.currentCount gt 1>>
					You know you are carring <<if _pregnancy.currentCount is 3>>triplets<<else>>twins<</if>>.
				<</if>>
			<<else>>
				Your baby is tiny, the ultrasound can only just pick it up. It's tiny heart is beating about once every second.
			<</if>>
		<<elseif _pregnancy.timer gte _pregnancy.timerStart * 0.8>>
			<<if _multiple>>
				The babies are small but you can see more details. You can see the ears and eyes starting to form, tiny buds are starting to form where the arms/legs should be. Their heads are much larger than the rest of the body.
			<<else>>
				Your baby is still tiny but you can see more details. You can see the ears and eyes starting to form, tiny buds are starting to form where the arms/legs should be. The head is much larger than the rest of the body.
			<</if>>
		<<elseif _pregnancy.timer gte _pregnancy.timerStart * 0.7>>
			<<if _multiple>>
				Babies are not so tiny now and fully formed. Arms, hands, fingers, feet and toes fully formed. They are starting to explore by doing things like making a small fist.
			<<else>>
				Your baby is not so tiny now and fully formed. Arms, hands, fingers, feet and toes fully formed. They are starting to explore by doing things like making a small fist.
			<</if>>
		<<elseif _pregnancy.timer gte _pregnancy.timerStart * 0.6>>
			<<if _multiple>>
				Babies continues to grow in size. Their hearts are audible through an instrument called a doppler. Eyelids, eyesbrows, eyelashes, nails and hair are formed. They can suck their own thumbs, yawn, stretch and make faces. Genitalia are fully developed so they can be told to the player.
				<<pregnancyGendersText>>
			<<else>>
				<<print $_He>> continues to grow in size. Heart is audible through an instrument called a doppler. Eyelids, eyesbrows, eyelashes, nails and hair are formed. <<print $_He>> can suck <<print $_his>> own thumbs, yawn, stretch and make faces. Genitalia are fully developed now so you know <<print $_he>> is a little
				<<switch _pregnancy[0].gender>>
					<<case "m">>boy.
					<<case "f">>girl.
					<<case "h">>hermaphrodite.
				<</switch>>
			<</if>>
		<<elseif _pregnancy.timer gte _pregnancy.timerStart * 0.5>>
			<<if _multiple>>
				Babies continues to grow in size. They can move around, developing muscles and exercising them. Hair is growing on their head, protective hair/white coating is growing over the baby, this will shed shortly after birth.
			<<else>>
				<<print $_He>> continues to grow in size. <<print $_He>> can move around, developing muscles and exercising them. Hair is growing on <<print $_his>> head, protective hair/white coating is growing over the baby, this will shed shortly after birth.
			<</if>>
		<<elseif _pregnancy.timer gte _pregnancy.timerStart * 0.4>>
			<<if _multiple>>
				Babies continues to grow in size. Eyelids begin to part and eyes open/close. They have started to develop some body fat, hearing is fully developed. They change position frequently and responds to stimuli, including sound, pain and light. The amniotic fluid begins to diminish.
			<<else>>
				<<print $_He>> continues to grow in size. Eyelids begin to part and eyes open/close. <<print $_He>> has started to develop some body fat, hearing is fully developed. <<print $_He>> change position frequently and responds to stimuli, including sound, pain and light. The amniotic fluid begins to diminish.
			<</if>>
		<<elseif _pregnancy.timer gte _pregnancy.timerStart * 0.3>>
			<<if _multiple>>
				Babies continues to mature and develop more reserves of body fat. They will be will be kicking more at this point. Their brain is developing rapidly at this time, and they can see and hear.
			<<else>>
				<<print $_He>> continues to mature and develop more reserves of body fat. <<print $_He>> will be will be kicking more at this point. <<print $_His>> brain is developing rapidly at this time, and they can see and hear.
			<</if>>
		<<elseif _pregnancy.timer gte _pregnancy.timerStart * 0.2>>
			<<if _multiple>>
				Babies are getting close to being fully grown. Their reflexes are coordinated so they can blink, close the eyes, turn the head, grasp firmly, and respond to sounds, light, and touch. Lungs are close to fully developed.
			<<else>>
				<<print $_He>> is getting close to being fully grown. <<print $_His>> reflexes are coordinated so <<print $_he>> can blink, close the eyes, turn the head, grasp firmly, and respond to sounds, light, and touch. Lungs are close to fully developed.
			<</if>>
		<<elseif _pregnancy.timer gte _pregnancy.timerStart * 0.1>>
			<<if _pregnancy.currentCount gt 1>>
				Babies are almost fully grown, they are slightly smaller than if you wernt pregnanct with <<if _pregnancy.currentCount is 3>>triplets<<else>>twins<</if>>. They will start to move around less, their position will have moved to having their head closer to your pelvis.
			<<else>>
				<<print $_He>> is almost fully grown. <<print $_He>> will start to move around less, <<print $_his>> position will have moved to having <<print $_his>> head closer to your pelvis.
			<</if>>
			Mention the time for labour is starting to get close.
		<<else>>
			<<if _pregnancy.currentCount gt 1>>
				Babies are fully grown and ready to face the world, they are slightly smaller than if you wernt pregnanct with <<if _pregnancy.currentCount is 3>>triplets<<else>>twins<</if>>.
			<<else>>
				<<print $_He>> is fully grown and ready to face the world.
			<</if>>
			Mention labour might occur soon and to be ready for the players water to break.
		<</if>>
	<<case "wolf">>
	<<default>>
<</switch>>

<<link [[next|Pregnancy ultrasound 2]]>><</link>>

:: Pregnancy ultrasound 3
<<set $outside to 0>><<set $location to "hospital">><<effects>>

<<clotheson>>
Player thanks Dr Harper, puts clothes on and leaves.

<<link [[Return to foyer|Hospital Foyer]]>><<endevent>><</link>>

repo_name: Area/degrees

license: mit