code:
:: Widgets [widget]

<<widget "toggledebug">>
	<<if $debug>>
		<<set $debug to 1>>
	<<else>>
		<<set $debug to 0>>
	<</if>>
<</widget>>

<<widget "statbar">>

		<<if $args[0] is 0>>
		<<else>>
			<<set _percent=Math.floor(($args[0]/$args[1])*100)>>
			<<switch Math.floor(_percent/10)>>
				<<case 8 9>><<set _statColor to "pinkbar">>
				<<case 6 7>><<set _statColor to "purplebar">>
				<<case 4 5>><<set _statColor to "bluebar">>
				<<case 2 3>><<set _statColor to "lbluebar">>
				<<case 0 1>><<set _statColor to "tealbar">>
				<<default>><<set _statColor to "redbar">>
			<</switch>>

		<</if>>

<</widget>>

<<widget "statbarinverted">>
	<<set _now to $args[0]>><<set _max to $args[1]>>

		<<if $args[0] is 0>>
		<<else>>
			<<set _percent=Math.floor(($args[0]/$args[1])*100)>>
			<<switch Math.floor(_percent/10)>>
				<<case 8 9>><<set _statColor to "tealbar">>
				<<case 6 7>><<set _statColor to "lbluebar">>
				<<case 4 5>><<set _statColor to "bluebar">>
				<<case 2 3>><<set _statColor to "purplebar">>
				<<case 0 1>><<set _statColor to "pinkbar">>
				<<default>><<set _statColor to "greenbar">>
			<</switch>>

		<</if>>

<</widget>>

<<widget "wateraction">>
	<<if $swimmingskill lt 100>>
		<<set $seconds += 18>><<set $oxygen -= 180>>
		<<if $lake_ice_broken gte 1>>
			<<if random(1, 120) lte 18>>
				<<unset $lake_ice_broken>>
			<</if>>
		<</if>>
	<<elseif $swimmingskill lt 200>>
		<<set $seconds += 15>><<set $oxygen -= 150>>
		<<if $lake_ice_broken gte 1>>
			<<if random(1, 120) lte 15>>
				<<unset $lake_ice_broken>>
			<</if>>
		<</if>>
	<<elseif $swimmingskill lt 300>>
		<<set $seconds += 12>><<set $oxygen -= 120>>
		<<if $lake_ice_broken gte 1>>
			<<if random(1, 120) lte 12>>
				<<unset $lake_ice_broken>>
			<</if>>
		<</if>>
	<<elseif $swimmingskill lt 400>>
		<<set $seconds += 10>><<set $oxygen -= 100>>
		<<if $lake_ice_broken gte 1>>
			<<if random(1, 120) lte 10>>
				<<unset $lake_ice_broken>>
			<</if>>
		<</if>>
	<<elseif $swimmingskill lt 500>>
		<<set $seconds += 8>><<set $oxygen -= 80>>
		<<if $lake_ice_broken gte 1>>
			<<if random(1, 120) lte 8>>
				<<unset $lake_ice_broken>>
			<</if>>
		<</if>>
	<<elseif $swimmingskill lt 600>>
		<<set $seconds += 8>><<set $oxygen -= 80>>
		<<if $lake_ice_broken gte 1>>
			<<if random(1, 120) lte 8>>
				<<unset $lake_ice_broken>>
			<</if>>
		<</if>>
	<<elseif $swimmingskill lt 700>>
		<<set $seconds += 7>><<set $oxygen -= 70>>
		<<if $lake_ice_broken gte 1>>
			<<if random(1, 120) lte 7>>
				<<unset $lake_ice_broken>>
			<</if>>
		<</if>>
	<<elseif $swimmingskill lt 800>>
		<<set $seconds += 7>><<set $oxygen -= 70>>
		<<if $lake_ice_broken gte 1>>
			<<if random(1, 120) lte 7>>
				<<unset $lake_ice_broken>>
			<</if>>
		<</if>>
	<<elseif $swimmingskill lt 900>>
		<<set $seconds += 6>><<set $oxygen -= 60>>
		<<if $lake_ice_broken gte 1>>
			<<if random(1, 120) lte 6>>
				<<unset $lake_ice_broken>>
			<</if>>
		<</if>>
	<<elseif $swimmingskill lt 1000>>
		<<set $seconds += 6>><<set $oxygen -= 60>>
		<<if $lake_ice_broken gte 1>>
			<<if random(1, 120) lte 6>>
				<<unset $lake_ice_broken>>
			<</if>>
		<</if>>
	<<else>>
		<<set $seconds += 5>><<set $oxygen -= 50>>
		<<if $lake_ice_broken gte 1>>
			<<if random(1, 120) lte 5>>
				<<unset $lake_ice_broken>>
			<</if>>
		<</if>>
	<</if>>
<</widget>>

<<widget "underwater">>
	<<water>><<set $underwater to 1>><<set $underwatercheck to 1>>
	<<if $combat isnot 1>>
		<<if $seconds gte 60>>
			<<set $seconds -= 60>>
			<<pass 1>>
		<</if>>
		<<if $oxygen lt 0 and $nooxygen is 1>>
			<<set $stress += 1000>>
		<<elseif $oxygen lt 0 and $nooxygen isnot 1>>
			<<set $nooxygen to 1>>
		<<else>>
			<<set $nooxygen to 0>>
		<</if>>
		Air:
		<<if $oxygen lt 0>>
			You can't breathe! Your stress will increase and you'll soon pass out if you can't find air.
		<</if>>
		<<oxygencaption>>
		<<if $underwaterintro isnot 1 and $combat isnot 1>>
			<<set $underwaterintro to 1>>
			You can't hold your breath forever. You will pass less time and use less air per action with a higher swimming skill.

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

<<widget "oxygenrefresh">>
	<<set $oxygen to $oxygenmax>>
<</widget>>

<<widget "oxygen">>
<<if $args[0]>>
	<<set $oxygen += $args[0]>>
<</if>>
<<if $args[0] lt 0>>
	<<set _strangle to 1>>
<</if>>
<<set $oxygen = Math.clamp($oxygen, 0, $oxygenmax)>>
<</widget>>

<<widget "passwater">>
	<<if $outside is 1 and $weather is "clear">>
		<<if $upperwet gte 1>>
			<<set $upperwet -= ($pass * 2)>>
		<</if>>
		<<if $lowerwet gte 1>>
			<<set $lowerwet -= ($pass * 2)>>
		<</if>>
		<<if $underlowerwet gte 1>>
			<<if $worn.lower.type.includes("naked")>>
				<<set $underlowerwet -= ($pass * 2)>>
			<<else>>
				<<set $underlowerwet -= $pass>>
			<</if>>
		<</if>>
		<<if $underupperwet gte 1>>
			<<if $worn.upper.type.includes("naked")>>
				<<set $underupperwet -= ($pass * 2)>>
			<<else>>
				<<set $underupperwet -= $pass>>
			<</if>>
		<</if>>
	<<elseif $outside is 1 and $weather is "rain">>
		<<if !$worn.upper.type.includes("naked") and !$worn.upper.type.includes("swim") and !$worn.head.type.includes("rainproof") and !$worn.upper.type.includes("stealthy")>>
			<<set $upperwet += $pass>>
		<</if>>
		<<if !$worn.lower.type.includes("naked") and !$worn.lower.type.includes("swim") and !$worn.head.type.includes("rainproof") and !$worn.lower.type.includes("stealthy")>>
			<<set $lowerwet += $pass>>
		<</if>>
		<<if !$worn.under_lower.type.includes("naked") and !$worn.under_lower.type.includes("swim") and !$worn.head.type.includes("rainproof") and !$worn.under_lower.type.includes("stealthy")>>
			<<set $underlowerwet += $pass>>
		<</if>>
		<<if !$worn.under_upper.type.includes("naked") and !$worn.under_upper.type.includes("swim") and !$worn.head.type.includes("rainproof") and !$worn.under_upper.type.includes("stealthy")>>
			<<set $underupperwet += $pass>>
		<</if>>
	<<else>>
		<<if $upperwet gte 1>>
			<<set $upperwet -= $pass>>
		<</if>>
		<<if $lowerwet gte 1>>
			<<set $lowerwet -= $pass>>
		<</if>>
		<<if $underlowerwet gte 1>>
			<<set $underlowerwet -= $pass>>
		<</if>>
		<<if $underupperwet gte 1>>
			<<set $underupperwet -= $pass>>
		<</if>>
	<</if>>
	/* Commented out, new system is the "passArousalWetness" widget

	<<if $vaginaWetness gte 60 and !$worn.under_lower.type.includes("naked") and !$worn.under_lower.type.includes("swim")>>
		<<set $underlowerwet += Math.log10($vaginaWetness - 59) * 2 * $pass>>
		<<set $pantiesSoaked to ($underlowerwet gte 100)>>

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

<<widget "passArousalWetness">>
	<<if $player.vaginaExist>>
		<<set $_wetnessChange to 0>>
		<<set $_arousalPercent to Math.clamp($arousal / $arousalmax, 0, 1)>>

		<<if $arousal gte $arousalmax * (2/5)>>
			<<set $_wetnessChange to 1 + ($_arousalPercent * 2)>>

			<<set $_wetnessPercent to Math.clamp($vaginaArousalWetness / 100, 0, 1)>>
			<<set $_wetnessChange to Math.floor($_wetnessChange * 2 * (1 - $_wetnessPercent))>>
		<</if>>

		<<set $_wetnessChange -= 0.1 * $timeSinceArousal * (1-$_arousalPercent)>>

		<<if $arousal gte $arousalmax * (3/5) and $_wetnessChange lt 0>>
			<<set $_wetnessChange to 0>>
		<</if>>

		<<set $vaginaArousalWetness += Math.round($_wetnessChange * $pass)>>

		<<if $vaginaArousalWetness gte 60>>
			<<set $vaginaArousalWetness to Math.floor(120 - (3600/$vaginaArousalWetness))>>

			<<set $_change to 1 + Math.log10($vaginaArousalWetness - 59)>>
			<<set $_change to Math.clamp($_change, 1, 3)>>

			<<if !$worn.under_lower.type.includes("naked") and !$worn.under_lower.type.includes("swim")>>
				<<set $underlowerwet += Math.round($_change * $pass)>>
				<<set $underlowerwet to Math.clamp($underlowerwet, 0, 100 + $pass)>>
				<<set $pantiesSoaked to ($underlowerwet gte 100)>>
			<</if>>

			/* <<if ($underlowerwet gte 100 or $worn.under_lower.type.includes("naked")) and !$worn.lower.type.includes("naked") and !$worn.lower.type.includes("swim")>>
				<<set $lowerwet += Math.round($_change * $pass)>>
			<</if>> */
		<</if>>

		<<set $vaginaArousalWetness to Math.clamp($vaginaArousalWetness, 0, 100)>>
		<<vaginaWetnessCalculate>>
	<</if>>
<</widget>>

<<widget "pass">>
	<<if $args[1]>>
		<<if $args[1].includes("h", 0)>>
			<<set $pass to ($args[0]*60)>>
		<<elseif $args[1].includes("d", 0)>>
			<<set $pass to ($args[0]*1440)>>
		<</if>>
	<<elseif $args[0]>>
		<<set $pass to $args[0]>>
	<<else>>
		<<set $pass to 0>>
	<</if>>
	<<pregProgressTime $pass>>
	<<if $controlled is 0 and $anxiety gte 2>>
		<<set $stress += $pass>>
		<<if $backgroundTraits.includes("crossdresser") and ($player.gender is $player.gender_appearance) and $player.gender isnot "h">>
			<<set $stress += $pass>>
		<</if>>
	<<elseif $controlled is 0 and $anxiety gte 1 or $stress gte $stressmax>>
	<<else>>
		<<set $stress -= $pass>>
		<<if $backgroundTraits.includes("crossdresser") and ($player.gender isnot $player.gender_appearance) and $player.gender isnot "h">>
			<<set $stress -= $pass>>
		<</if>>
	<</if>>
	<<if $body_temperature is "cold">>
		<<set $stress += ($pass * 2)>>
	<<elseif $body_temperature is "chilly">>
		<<set $stress += $pass>>
	<</if>>

	<<if $hallucinogen gt 0>>
		<<set $hallucinogen -= $pass>>
	<</if>>
	<<if $drunk gt 0>>
		<<tiredness $pass pass>>
		<<set $drunk -= $pass>>
	<</if>>
	<<if $drugged gt 0>>
		<<set $drugged -= $pass>>
	<</if>>
	<<if $pain gt 0>>
		<<set $pain -= $pass>>
	<</if>>
	<<if $pass gt 1200>>
		<<set $tiredness to 0>>
	<<else>>
		<<tiredness $pass pass>>
	<</if>>
	<<set $time += $pass>><<set $minute += $pass>>
	<<if $backgroundTraits.includes("lustful")>>
		<<set _arousalMult to 0.2 * (12 - Math.floor($purity / 80)) + 1>>
		<<if $purity lte 50>>
			<<set _arousalMult++>>
			<<set _arousalmax to 10000>>
		<<else>>
			<<set _arousalmax to 9000>>
		<</if>>
		<<arousal `_arousalMult * $pass`>><<arousalpass>>
	<<else>>
		<<arousal `$pass * -10`>><<arousalpass>>
	<</if>>
	<<if $arousal lt ($arousalmax / 4)>>
		<<set $timeSinceArousal += $pass>>
	<<else>>
		<<set $timeSinceArousal to 1>>
	<</if>>
	<<if $player.vaginaExist>>
		<<passArousalWetness>>
	<</if>>
	<<passwater>>
	<<if $daystate is "day" and $weather is "clear" and $outside is 1 and $location isnot "forest" and !$worn.head.type.includes("shade")>>
		<<if $season is "winter">>
			<<tanned `$pass / 4`>>
		<<elseif $season is "summer">>
			<<tanned `$pass`>>
		<<else>>
			<<tanned `$pass / 2`>>
		<</if>>
	<</if>>
<</widget>>

<<widget "neutral">>
	<<if $args[0]>>
		<<if $consensual isnot 1>>
			<<if $drunk gte 480>>
				<<set $stress += ($args[0] * 3)>>
			<<elseif $drunk gte 360>>
				<<set $stress += ($args[0] * 4)>>
			<<elseif $drunk gte 240>>
				<<set $stress += ($args[0] * 6)>>
			<<elseif $drunk gte 120>>
				<<set $stress += ($args[0] * 8)>>
			<<elseif $drunk gte 1>>
				<<set $stress += ($args[0] * 9)>>
			<<else>>
				<<set $stress += ($args[0] * 10)>>
			<</if>>
			<<combattrauma $args[0]>>
		<</if>>
		<<set _arousal to 20 * $args[0]>>
		<<arousal _arousal>>
		<<set $enemyarousal += $args[0]>>
	<</if>>
<</widget>>

<<widget "neutralbreast">>
	<<if $args[0]>>
		<<if $consensual isnot 1>>
			<<if $drunk gte 480>>
				<<set $stress += ($args[0] * 3)>>
			<<elseif $drunk gte 360>>
				<<set $stress += ($args[0] * 4)>>
			<<elseif $drunk gte 240>>
				<<set $stress += ($args[0] * 6)>>
			<<elseif $drunk gte 120>>
				<<set $stress += ($args[0] * 8)>>
			<<elseif $drunk gte 1>>
				<<set $stress += ($args[0] * 9)>>
			<<else>>
				<<set $stress += ($args[0] * 10)>>
			<</if>>
			<<combattrauma $args[0]>>
		<</if>>
		<<set _arousal to 20 * $args[0] * $breastsensitivity>>
		<<arousal _arousal>>
		<<set $enemyarousal += $args[0]>>
	<</if>>
<</widget>>

<<widget "neutralgenitals">>
	<<if $args[0]>>
		<<if $consensual isnot 1>>
			<<if $drunk gte 480>>
				<<set $stress += ($args[0] * 3)>>
			<<elseif $drunk gte 360>>
				<<set $stress += ($args[0] * 4)>>
			<<elseif $drunk gte 240>>
				<<set $stress += ($args[0] * 6)>>
			<<elseif $drunk gte 120>>
				<<set $stress += ($args[0] * 8)>>
			<<elseif $drunk gte 1>>
				<<set $stress += ($args[0] * 9)>>
			<<else>>
				<<set $stress += ($args[0] * 10)>>
			<</if>>
			<<combattrauma $args[0]>>
		<</if>>
		<<set _arousal to 20 * $args[0] * $genitalsensitivity>>
		<<arousal _arousal>>
		<<set $enemyarousal += $args[0]>>
	<</if>>
<</widget>>

<<widget "sex">>
	<<if $args[0]>>
		<<if $consensual isnot 1>>
			<<if $drunk gte 480>>
				<<set $stress += ($args[0] * 3)>>
			<<elseif $drunk gte 360>>
				<<set $stress += ($args[0] * 4)>>
			<<elseif $drunk gte 240>>
				<<set $stress += ($args[0] * 6)>>
			<<elseif $drunk gte 120>>
				<<set $stress += ($args[0] * 8)>>
			<<elseif $drunk gte 1>>
				<<set $stress += ($args[0] * 9)>>
			<<else>>
				<<set $stress += ($args[0] * 10)>>
			<</if>>
			<<combattrauma $args[0]>>
		<<else>>
			<<set $stress -= 10 * $args[0]>>
		<</if>>
		<<set _arousal to 20 * $args[0]>>
		<<arousal _arousal>>
		<<set $enemyarousal += 2 * $args[0]>>
	<</if>>
<</widget>>

<<widget "sexControl">>
<<if $args[0] and $args[1] gte 800>>
	<<if $args[1] gte 1000>>
		<<set _loss to 5 * $args[0]>>
	<<elseif between($args[1], 900, 1000)>>
		<<set _loss to 4 * $args[0]>>
	<<else>>
		<<set _loss to 3 * $args[0]>>
	<</if>>
	<<if $enemyarousal gte $enemyarousalmax * 0.7>>
		<<set _loss *= 2>>
	<</if>>
	<<if $enemyarousal gte $enemyarousalmax * 0.9>>
		<<set _loss *= 2>>
	<</if>>
	<<set _loss *= $enemyArousalLossReduction>>
	<<if $enemyArousalLossReduction gt 0.2>>
		<<set $enemyArousalLossReduction -= 0.04>>
	<</if>>
	<<set $enemyarousal -= Math.round(_loss)>>
<</if>>
<</widget>>

<<widget "violence">>

	<<if $args.length gte 1>>
		<<set _violence = $args[0]>>
		<<set _stressMod = $args[1] || 1>>
		<<set _traumaMod = $args[2] || 1>>
		<<set _painMod = $args[3] || 1>>
		<<set _arousalMod = $args[4] || 1>>

		<<if _violence gt 0 or _violence lt 0>>
			<<if $drunk gte 480>>
				<<set _drunkMod = 3>>
			<<elseif $drunk gte 360>>
				<<set _drunkMod = 4>>
			<<elseif $drunk gte 240>>
				<<set _drunkMod = 6>>
			<<elseif $drunk gte 120>>
				<<set _drunkMod = 8>>
			<<elseif $drunk gte 1>>
				<<set _drunkMod = 9>>
			<<else>>
				<<set _drunkMod = 10>>
			<</if>>
			<<if $possessed is true and _violence gte 0>>
				<<set $control += _violence>>
				<<set $wraith.will -= _violence>>
				<<set _possessMod to 3>>
			<<else>>
				<<set _possessMod to 1>>
			<</if>>
			<<set $stress += (_violence * _drunkMod * _stressMod) * (1 - ($masochism / 1200))>>
			<<combattrauma _violence * _traumaMod>>
			<<set $pain += (_violence * _painMod * (1 - ($masochism / 1200)) * (1 - ($sciencetrait / 10)) / _possessMod)>>
			<<set _arousal to (_violence * _arousalMod * (0 + ($masochism / 18)))>>
			<<arousal _arousal/_possessMod>>
			<<set $arousalmasochism += (_violence * (0 + ($masochism / 7)))>>
			<<if $orgasmdown gte 1>>
				<<if $masochism gte 800>>
					<<set $masochism += (_violence / 20)>>
				<<elseif $masochism gte 500>>
					<<set $masochism += (_violence / 10)>>
				<<elseif $masochism gte 300>>
					<<set $masochism += (_violence / 6)>>
				<<elseif $masochism gte 100>>
					<<set $masochism += (_violence / 2)>>
				<<else>>
					<<set $masochism += _violence>>
				<</if>>
			<</if>>
			<<if _violence gte 6>>
				<<set $enemyanger -= 5>>
			<<else>>
				<<set $enemyanger -= _violence>>
			<</if>>
			<<set $enemyarousal += 1>>
		<</if>>
	<</if>>
<</widget>>

<<widget "violence_noncombat">>
	<<if $args.length gte 1>>
		<<set _violence = $args[0]>>
		<<set _stressMod = $args[1] || 1>>
		<<set _traumaMod = $args[2] || 1>>
		<<set _painMod = $args[3] || 1>>
		<<set _arousalMod = $args[4] || 1>>

		<<if _violence gt 0 or _violence lt 0>>
			<<if $drunk gte 480>>
				<<set _drunkMod = 3>>
			<<elseif $drunk gte 360>>
				<<set _drunkMod = 4>>
			<<elseif $drunk gte 240>>
				<<set _drunkMod = 6>>
			<<elseif $drunk gte 120>>
				<<set _drunkMod = 8>>
			<<elseif $drunk gte 1>>
				<<set _drunkMod = 9>>
			<<else>>
				<<set _drunkMod = 10>>
			<</if>>
			<<set $stress += (_violence * _drunkMod * _stressMod) * (1 - ($masochism / 1200))>>
			<<trauma _violence * _traumaMod>>
			<<set $pain += (_violence * _painMod * (1 - ($masochism / 1200)) * (1 - ($sciencetrait / 10)))>>
			<<set _arousal to (_violence * _arousalMod * (0 + ($masochism / 18)))>>
			<<arousal _arousal>>
			<<set $arousalmasochism += (_violence * (0 + ($masochism / 7)))>>
			<<if $orgasmdown gte 1>>
				<<if $masochism gte 800>>
					<<set $masochism += (_violence / 20)>>
				<<elseif $masochism gte 500>>
					<<set $masochism += (_violence / 10)>>
				<<elseif $masochism gte 300>>
					<<set $masochism += (_violence / 6)>>
				<<elseif $masochism gte 100>>
					<<set $masochism += (_violence / 2)>>
				<<else>>
					<<set $masochism += _violence>>
				<</if>>
			<</if>>
		<</if>>
	<</if>>
<</widget>>

<<widget "submission">>
	<<if $args[0]>>
		<<if $consensual isnot 1>>
			<<if $drunk gte 480>>
				<<set $stress += ($args[0] * 3)>>
			<<elseif $drunk gte 360>>
				<<set $stress += ($args[0] * 4)>>
			<<elseif $drunk gte 240>>
				<<set $stress += ($args[0] * 6)>>
			<<elseif $drunk gte 120>>
				<<set $stress += ($args[0] * 8)>>
			<<elseif $drunk gte 1>>
				<<set $stress += ($args[0] * 9)>>
			<<else>>
				<<set $stress += ($args[0] * 10)>>
			<</if>>
			<<set $submissive += 1>>
		<<else>>
			<<set $stress -= 10 * $args[0]>>
			<<set $assertive += 1>>
		<</if>>
		<<set _arousal to 20 * $args[0]>>
		<<arousal _arousal>>
		<<set $enemyarousal += 3 * $args[0]>>
		<<set $enemytrust += 2>>
	<</if>>
<</widget>>

<<widget "defiance">>
	<<if $args[0]>>
		<<set _defiance to ($args[0] * (1 + ($sadism / 1000)))>>
		<<set _negargs = -_defiance>>
		<<set $stress -= 10 * _defiance>>
		<<combattrauma _negargs>>
		<<set $enemyanger += 5 * _defiance>>
		<<set $submissive -= 1>>
		<<set $enemytrust -= 4>>
		<<set _defiance_arousal to (_defiance * ($sadism / 40))>>
		<<arousal _defiance_arousal>>
		<<if $arousal gte ($arousalmax * 0.8)>>
			<<sadism $args[0]>>
		<</if>>
		<<set _thedamage to (2 * _defiance * ($physique / 4000))>>
		<<set $enemyhealth -= _thedamage>>
		<<if $args[1] isnot undefined>>
			<<if $args[2] isnot undefined>>
				<<set $NPCList[$args[1]].health -= (_thedamage/2)>>
				<<set $NPCList[$args[2]].health -= (_thedamage/2)>>
				<<if $enemyno gte 2>>
					<<npcdamage $args[1]>>
					<<npcdamage $args[2]>>
				<</if>>
			<<else>>
				<<set $NPCList[$args[1]].health -= _thedamage>>
				<<if $enemyno gte 2>>
					<<npcdamage $args[1]>>
				<</if>>
			<</if>>
			<<if $newtarget isnot undefined>>
				<<setnewtarget>>
			<</if>>
		<<else>>
			<<for _npctodamage to 0; _npctodamage lt $enemynomax; _npctodamage++>>
				<<if $NPCList[_npctodamage].active is "active" and $NPCList[_npctodamage].stance isnot "defeated">>
					<<set $NPCList[_npctodamage].health -= (_thedamage/$enemyno)>>/* Divide damage by all current active enemies. */
					<<if $enemyno gte 2>>
						<<npcdamage _npctodamage>>
					<</if>>
				<</if>>
			<</for>>
		<</if>>
	<</if>>
<</widget>>

<<widget "brat">>
	<<if $args[0]>>
		<<set _negargs = -$args[0]>>
		<<if $drunk gte 480>>
			<<set $stress += ($args[0] * 3)>>
		<<elseif $drunk gte 360>>
			<<set $stress += ($args[0] * 4)>>
		<<elseif $drunk gte 240>>
			<<set $stress += ($args[0] * 6)>>
		<<elseif $drunk gte 120>>
			<<set $stress += ($args[0] * 8)>>
		<<elseif $drunk gte 1>>
			<<set $stress += ($args[0] * 9)>>
		<<else>>
			<<set $stress += ($args[0] * 10)>>
		<</if>>
		<<combattrauma _negargs>>
		<<if $args[1] is "demanding">>
			<<set $enemyanger += 20 * $args[0]>>
		<<elseif $NPCList[0].legs isnot "walk">>
			<<set $enemyanger += 5 * $args[0]>>
		<</if>>
		<<set $submissive -= 1>>
		<<set $enemytrust -= 2>>
		<<set $NPCList[0].bold -= ($args[0] * 10)>>
	<</if>>
<</widget>>

<<widget "meek">>
	<<if $args[0]>>
		<<if $consensual isnot 1>>
			<<set $submissive += 1>>
		<<else>>
			<<set $assertive += 1>>
		<</if>>
		<<set _arousal to 20 * $args[0]>>
		<<arousal _arousal>>
		<<set $enemyarousal += $args[0]>>
		<<set $enemytrust += 1>>
		<<set $enemyanger -= $args[0]>>
	<</if>>
<</widget>>

<<widget "crimeup">>
<<if $statFreeze isnot true>>
	<<set _crime_up to 1>>
	<<for _active_clothes range Object.keys($worn)>>
		<<if $worn[_active_clothes].type.includes("stealthy")>>
			<<set _crime_up -= 0.05>>
		<</if>>
	<</for>>
		<<if $args[0]>>
			<<set $crime += Math.trunc($args[0] * _crime_up)>>
			<<set $crimehistory += Math.trunc($args[0] * _crime_up)>>
		<</if>>
		<<if $slimeEvent is "steal something">>
			<<unset $slimeEvent>>
		<</if>>
	<<if $averyCrimeTracker isnot undefined>>
	<<set $averyCrimeTracker+= ($args[0] * _crime_up)>>
	<</if>>
<</if>>
<</widget>>

<<widget "seductionskilluse">>
	<<set $enemyarousal += ($seductionskill / 100)>><<set $seductionskill += 5>>
<</widget>>

<<widget "seductionskilluptext">>
	<<if $seductionskill lt 1000>>
		You feel more confident in your powers of seduction.

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

<<widget "seductionskillusecombat">>
	<<set $enemyarousal += ($seductionskill / 100)>><<set $seductionskill += 5>><<set $seductionskillup to 1>>
<</widget>>

<<widget "oralskilluse">>
	<<set $enemyarousal += ($oralskill / 100)>><<set $oralskill += 5>><<set $oralskillup to 1>>
<</widget>>

<<widget "vaginalskilluse">>
	<<set $enemyarousal += ($vaginalskill / 100)>><<set $vaginalskill += 5>><<set $vaginalskillup to 1>>
<</widget>>

<<widget "analskilluse">>
	<<set $enemyarousal += ($analskill / 100)>><<set $analskill += 5>><<set $analskillup to 1>>
<</widget>>

<<widget "handskilluse">>
	<<set $enemyarousal += ($handskill / 100)>><<set $handskill += 5>><<set $handskillup to 1>>
<</widget>>

<<widget "feetskilluse">>
	<<set $enemyarousal += ($feetskill / 100)>><<set $feetskill += 5>><<set $feetskillup to 1>>
<</widget>>

<<widget "bottomskilluse">>
	<<set $enemyarousal += ($bottomskill / 100)>><<set $bottomskill += 5>><<set $bottomskillup to 1>>
<</widget>>

<<widget "thighskilluse">>
	<<set $enemyarousal += ($thighskill / 100)>><<set $thighskill += 5>><<set $thighskillup to 1>>
<</widget>>

<<widget "chestskilluse">>
	<<set $enemyarousal += ($chestskill / 100)>><<set $chestskill += 5>><<set $chestskillup to 1>>
<</widget>>

<<widget "penileskilluse">>
	<<set $enemyarousal += ($penileskill / 100)>><<set $penileskill += 5>><<set $penileskillup to 1>>
<</widget>>

<<widget "skulduggeryskilluse">>
<<if $statFreeze isnot true>>
	<<set $skulduggery += 3>>
	<<if $skulduggery lt 1000>>
		 You learned a thing or two about skulduggery.

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

<<widget "combatskulduggeryskilluse">>
<<if $statFreeze isnot true>>
	<<set $skulduggery += 3>>
	<<if $skulduggery lt 1000>>
		 You learned a thing or two about skulduggery.
	<</if>>
<</if>>
<</widget>>

<<widget "swimmingskilluse">>
<<if $statFreeze isnot true>>
	<<set $swimmingskill += 9>>
	<<if $swimmingskill lt 1000>>
		 You've become more confident at swimming.

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

<<widget "danceskilluse">>
<<if $statFreeze isnot true>>
	<<danceskill 1>>
	<<if $danceskill lt 1000>>
		 You feel more confident in your dancing abilities.
	<</if>>
<</if>>
<</widget>>

<<widget "scienceskill">>
<<if $statFreeze isnot true>>
	<<switch $sciencetrait>>
		<<case 4>>
			<<set _skill_mod to 0.3>>
		<<case 3>>
			<<set _skill_mod to 0.3>>
		<<case 2>>
			<<set _skill_mod to 0.6>>
		<<case 1>>
			<<set _skill_mod to 1.2>>
		<<default>>
			<<set _skill_mod to 2.4>>
	<</switch>>
	<<if $science_star lt 3 and $args[1] isnot "no_star">>
		<<set $science_star += 1>>
	<</if>>
	<<if $worn.face.type.includes("glasses") and $args[1] isnot "no_star">>
		<<set _skill_mod *= 1.2>>
	<</if>>
	<<if $exposed gte 1 and $args[1] isnot "no_star">>
		<<set _skill_mod *= 1.2>>
	<</if>>
	<<if $args[0]>>
		<<set $science_exam += ($args[0] * _skill_mod)>>
	<<else>>
		<<set $science_exam += (1 * _skill_mod)>>
	<</if>>
	<<exam_clamp science>>
<</if>>
<</widget>>

<<widget "mathsskill">>
<<if $statFreeze isnot true>>
	<<switch $mathstrait>>
		<<case 4>>
			<<set _skill_mod to 0.3>>
		<<case 3>>
			<<set _skill_mod to 0.3>>
		<<case 2>>
			<<set _skill_mod to 0.6>>
		<<case 1>>
			<<set _skill_mod to 1.2>>
		<<default>>
			<<set _skill_mod to 2.4>>
	<</switch>>
	<<if $maths_star lt 3 and $args[1] isnot "no_star">>
		<<set $maths_star += 1>>
	<</if>>
	<<if $worn.face.type.includes("glasses") and $args[1] isnot "no_star">>
		<<set _skill_mod *= 1.2>>
	<</if>>
	<<if $exposed gte 1 and $args[1] isnot "no_star">>
		<<set _skill_mod *= 1.2>>
	<</if>>
	<<if $args[0]>>
		<<set $maths_exam += ($args[0] * _skill_mod)>>
	<<else>>
		<<set $maths_exam += (1 * _skill_mod)>>
	<</if>>
	<<exam_clamp maths>>
<</if>>
<</widget>>

<<widget "englishskill">>
<<if $statFreeze isnot true>>
	<<switch $englishtrait>>
		<<case 4>>
			<<set _skill_mod to 0.3>>
		<<case 3>>
			<<set _skill_mod to 0.3>>
		<<case 2>>
			<<set _skill_mod to 0.6>>
		<<case 1>>
			<<set _skill_mod to 1.2>>
		<<default>>
			<<set _skill_mod to 2.4>>
	<</switch>>
	<<if $english_star lt 3 and $args[1] isnot "no_star">>
		<<set $english_star += 1>>
	<</if>>
	<<if $worn.face.type.includes("glasses") and $args[1] isnot "no_star">>
		<<set _skill_mod *= 1.2>>
	<</if>>
	<<if $exposed gte 1 and $args[1] isnot "no_star">>
		<<set _skill_mod *= 1.2>>
	<</if>>
	<<if $args[0]>>
		<<set $english_exam += ($args[0] * _skill_mod)>>
	<<else>>
		<<set $english_exam += (1 * _skill_mod)>>
	<</if>>
	<<exam_clamp english>>
<</if>>
<</widget>>

<<widget "historyskill">>
<<if $statFreeze isnot true>>
	<<switch $historytrait>>
		<<case 4>>
			<<set _skill_mod to 0.3>>
		<<case 3>>
			<<set _skill_mod to 0.3>>
		<<case 2>>
			<<set _skill_mod to 0.6>>
		<<case 1>>
			<<set _skill_mod to 1.2>>
		<<default>>
			<<set _skill_mod to 2.4>>
	<</switch>>
	<<if $history_star lt 3 and $args[1] isnot "no_star">>
		<<set $history_star += 1>>
	<</if>>
	<<if $worn.face.type.includes("glasses") and $args[1] isnot "no_star">>
		<<set _skill_mod *= 1.2>>
	<</if>>
	<<if $exposed gte 1 and $args[1] isnot "no_star">>
		<<set _skill_mod *= 1.2>>
	<</if>>
	<<if $args[0]>>
		<<set $history_exam += ($args[0] * _skill_mod)>>
	<<else>>
		<<set $history_exam += (1 * _skill_mod)>>
	<</if>>
	<<exam_clamp history>>
<</if>>
<</widget>>

<<widget "passiveStudy">>
<<if $statFreeze isnot true>>
	<<switch $studyBooks.rented>>
		<<case "science">>
			<<scienceskill 6 "no_star">>
		<<case "maths">>
			<<mathsskill 6 "no_star">>
		<<case "English">>
			<<englishskill 6 "no_star">>
		<<case "history">>
			<<historyskill 6 "no_star">>
		<<default>>
	<</switch>>
	<<switch $studyBooks.stolen>>
		<<case "science">>
			<<scienceskill 6 "no_star">>
		<<case "maths">>
			<<mathsskill 6 "no_star">>
		<<case "English">>
			<<englishskill 6 "no_star">>
		<<case "history">>
			<<historyskill 6 "no_star">>
		<<default>>
	<</switch>>
<</if>>
<</widget>>

<<widget "schoolskill">>
<<if $args[0]>>
	<<historyskill $args[0]>>
	<<mathsskill $args[0]>>
	<<scienceskill $args[0]>>
	<<englishskill $args[0]>>
<<else>>
	<<historyskill>>
	<<mathsskill>>
	<<scienceskill>>
	<<englishskill>>
<</if>>
<</widget>>

<<widget "athletics">>
<<if $args[0] and $statFreeze isnot true>>
	<<set _temp to $args[0]>>
	<<if $exposed gte 2>>
		<<set $athletics += 2>>
	<<elseif $exposed is 1>>
		<<set $athletics += 1>>
	<</if>>
	<<set $athletics += Math.trunc(_temp * 1.4)>>
	<<set $athletics to Math.clamp($athletics, 0, 1000)>>
		<<if $bunny gte 2>>
		<<set $athletics to Math.floor(athletics * 1.05)>>
	<</if>>
<</if>>
<</widget>>

<<widget "tending">>
<<if $args[0] and $statFreeze isnot true>>
	<<set $tending += ($args[0] * 2)>>
	<<set $tending to Math.clamp($tending, 0, 1000)>>
<</if>>
<</widget>>

<<widget "danceskill">>
<<if $args[0] and $statFreeze isnot true>>
	<<set $danceskill += $args[0]>>
	<<set $danceskill to Math.clamp($danceskill, 0, 1000)>>
<</if>>
<</widget>>

<<widget "physique">>
<<if $statFreeze isnot true>>
	<<if $args[0]>><<set _temp to $args[0]>><<set $workouts += $args[0]>><<else>><<set _temp to 1>><<set $workouts += 1>><</if>>
	<<if $exposed gte 2>>
		<<set _temp *= 1.2>>
	<<elseif $exposed is 1>>
		<<set _temp *= 1.1>>
	<</if>>
	<<set $physique += 10 * _temp>><<set $physiqueuse += _temp>>
	<<if $args[1]>>
		<<if $args[1] isnot "noMessage">>
			<<if ($combat is 1 and $args[1] isnot "workout") or $args[1] is "invig">>
				 It invigorates you.
			<<else>>
				 You get a good workout.
			<</if>>
		<</if>>
    <<elseif $combat is 1>>
         It invigorates you.
    <<else>>
         You get a good workout.
    <</if>>
<</if>>
<</widget>>

<<widget "physique_loss">>
<<if $args[0] and $statFreeze isnot true>>
	<<set $physique -= 10 * $args[0]>>
<</if>>
<</widget>>

<<widget "bruise">>
	<<if $args[0] and $statFreeze isnot true>>
		<<switch $args[0]>>
		<<case "face">>
			<<set $facebruise += 1>>
		<<case "neck">>
			<<set $neckbruise += 1>>
		<<case "chest">>
			<<set $chestbruise += 1>>
		<<case "rightarm">>
			<<set $rightarmbruise += 1>>
		<<case "leftarm">>
			<<set $leftarmbruise += 1>>
		<<case "tummy">>
			<<set $tummybruise += 1>>
		<<case "bottom">>
			<<set $bottombruise += 1>>
		<<case "thigh">>
			<<set $thighbruise += 1>>
		<<case "anus">>
			<<set $anusbruise += 1>>
		<<case "vagina">>
			<<set $vaginabruise += 1>>
		<<case "penis">>
			<<set $penisbruise += 1>>
		<<case "full">>
			<<set $facebruise += 1>>
			<<set $neckbruise += 1>>
			<<set $chestbruise += 1>>
			<<set $rightarmbruise += 1>>
			<<set $leftarmbruise += 1>>
			<<set $tummybruise += 1>>
			<<set $bottombruise += 1>>
			<<set $thighbruise += 1>>
		<</switch>>
	<</if>>
<</widget>>

<<widget "rapestat">><<if $statFreeze isnot true>><<set $rapestat += 1>><</if>><</widget>>

<<widget "moleststat">><<if $statFreeze isnot true>><<set $moleststat += 1>><</if>><</widget>>

<<widget "vaginalstat">><<if $statFreeze isnot true>><<set $vaginalstat += 1>><</if>><</widget>>

<<widget "vaginalejacstat">><<if $statFreeze isnot true>><<set $vaginalejacstat += 1>><<purity -1>><<internalejac>><<creampie "self" "vagina">><</if>><</widget>>

<<widget "analstat">><<if $statFreeze isnot true>><<set $analstat += 1>><</if>><</widget>>

<<widget "analejacstat">><<if $statFreeze isnot true>><<set $analejacstat += 1>><<purity -1>><<internalejac>><<fertilise>><<creampie "self" "anus">><</if>><</widget>>

<<widget "oralstat">><<if $statFreeze isnot true>><<set $oralstat += 1>><</if>><</widget>>

<<widget "oralejacstat">><<if $statFreeze isnot true>><<set $oralejacstat += 1>><<purity -1>><<internalejac>><<creampie "self" "mouth">><</if>><</widget>>

<<widget "handstat">><<if $statFreeze isnot true>><<set $handstat += 1>><</if>><</widget>>

<<widget "handejacstat">><<if $statFreeze isnot true>><<set $handejacstat += 1>><</if>><</widget>>

<<widget "feetstat">><<if $statFreeze isnot true>><<set $feetstat += 1>><</if>><</widget>>

<<widget "feetejacstat">><<if $statFreeze isnot true>><<set $feetejacstat += 1>><</if>><</widget>>

<<widget "thighstat">><<if $statFreeze isnot true>><<set $thighstat += 1>><</if>><</widget>>

<<widget "thighejacstat">><<if $statFreeze isnot true>><<set $thighejacstat += 1>><</if>><</widget>>

<<widget "cheststat">><<if $statFreeze isnot true>><<set $cheststat += 1>><</if>><</widget>>

<<widget "chestejacstat">><<if $statFreeze isnot true>><<set $chestejacstat += 1>><</if>><</widget>>

<<widget "bottomstat">><<if $statFreeze isnot true>><<set $bottomstat += 1>><</if>><</widget>>

<<widget "bottomejacstat">><<if $statFreeze isnot true>><<set $bottomejacstat += 1>><</if>><</widget>>

<<widget "penilestat">><<if $statFreeze isnot true>><<set $penilestat += 1>><</if>><</widget>>

<<widget "penileejacstat">><<if $statFreeze isnot true>><<set $penileejacstat += 1>><</if>><</widget>>

<<widget "clothesstripstat">><<if $statFreeze isnot true>><<set $clothesstripstat += 1>><</if>><</widget>>

<<widget "clothesruinstat">><<if $statFreeze isnot true>><<set $clothesruinstat += 1>><</if>><</widget>>

<<widget "orgasmstat">><<if $statFreeze isnot true>><<set $orgasmstat += 1>><</if>><</widget>>

<<widget "ejacstat">><<if $statFreeze isnot true>><<set $ejacstat += 1>><</if>><</widget>>

<<widget "hitstat">><<if $statFreeze isnot true>><<set $hitstat += 1>><</if>><</widget>>

<<widget "attackstat">><<if $statFreeze isnot true>><<set $attackstat += 1>><</if>><</widget>>

<<widget "vaginalentranceejacstat">><<if $statFreeze isnot true>><<set $vaginalentranceejacstat += 1>><</if>><</widget>>

<<widget "faceejacstat">><<if $statFreeze isnot true>><<set $faceejacstat += 1>><</if>><</widget>>

<<widget "hairejacstat">><<if $statFreeze isnot true>><<set $hairejacstat += 1>><</if>><</widget>>

<<widget "tummyejacstat">><<if $statFreeze isnot true>><<set $tummyejacstat += 1>><</if>><</widget>>

<<widget "neckejacstat">><<if $statFreeze isnot true>><<set $neckejacstat += 1>><</if>><</widget>>

<<widget "dancestat">><<if $statFreeze isnot true>><<set $dancestat += 1>><</if>><</widget>>

<<widget "distinction_stat">>
<<if $statFreeze isnot true>>
	<<set $distinction_stat += 1>>
	<<if $distinction_stat gte 15>>
		<<earnFeat "Distinguished">>
	<<elseif $distinction_stat gte 5>>
		<<earnFeat "Distinctive">>
	<<else>>
		<<earnFeat "Distinction">>
	<</if>>
<</if>>
<</widget>>

<<widget "knot_stat">>
<<if $statFreeze isnot true>>
	<<if $knot_stat is undefined>>
		<<set $knot_stat to 0>>
	<</if>>
	<<set $knot_stat += 1>>
<</if>>
<</widget>>

<<widget "hunger">>
<<if $args[0] and $statFreeze isnot true>>
	<<set $hunger += $args[0]>>
	<<set $hunger = Math.clamp($hunger, 0, 2000)>>
<</if>>
<</widget>>

<<widget "hunger_description">>
<<if $hunger gte 2000>>You are starving!
<<elseif $hunger gte 1600>>You are famished.
<<elseif $hunger gte 1200>>You are ravenous.
<<elseif $hunger gte 800>>You are hungry.
<<elseif $hunger gte 400>>You are peckish.
<<elseif $hunger gte 1>>You are satiated.
<<else>>You are full.
<</if>>
<</widget>>

<<widget "thirst">>
<<if $thirst gte 2000>>You are dehydrated!
<<elseif $thirst gte 1600>>You are really thirsty.
<<elseif $thirst gte 1200>>You are thirsty.
<<elseif $thirst gte 800>>Your throat is dry.
<<elseif $thirst gte 400>>You are satisfied.
<<elseif $thirst gte 1>>You are satiated.
<<elseif $thirst lte 0>>You are full.
<</if>>
<</widget>>

<<widget "tirednesscaption">>

		Fatigue:
		<<if $showCaptionText is true>>
			<<if $tiredness gte $tirednessmax>>
				You are exhausted.
			<<elseif $tiredness gte ($tirednessmax / 5) * 4>>
				You are fatigued.
			<<elseif $tiredness gte ($tirednessmax / 5) * 3>>
				You are tired.
			<<elseif $tiredness gte ($tirednessmax / 5) * 2>>
				You are wearied.
			<<elseif $tiredness gte $tirednessmax / 5>>
				You are alert.
			<<elseif $tiredness gte 1>>
				You are wide awake.
			<<else>>
				You are refreshed.
			<</if>>
		<</if>>

	<<if $tiredness gte $tirednessmax>>
		<<set $stress += (($tiredness - $tirednessmax) * 16)>><<set $trauma += (($tiredness - $tirednessmax) / 3)>>
	<</if>>

	<<set $tiredness = Math.clamp($tiredness, 0, $tirednessmax)>>
	<<set _showCaptionText to !$showCaptionText>>
	<<statbar $tiredness $tirednessmax _showCaptionText>>

<</widget>>

<<widget "hygiene">>
<<if $hygiene gte 2000>>
	You are filthy.
<<elseif $hygiene gte 1600>>
	You are soiled.
<<elseif $hygiene gte 1200>>
	You are smelly.
<<elseif $hygiene gte 800>>
	You are messy.
<<elseif $hygiene gte 400>>
	You are neat.
<<elseif $hygiene gte 1>>
	You are clean.
<<elseif $hygiene lte 0>>
	You are speckless.
<</if>>
<</widget>>

<<widget "stresscaption">>

		Stress:
		<<if $showCaptionText is true>>
			<<if $stress gte $stressmax>>
				You are overwhelmed!
			<<elseif $stress gte ($stressmax / 5) * 4>>
				You are distressed.
			<<elseif $stress gte ($stressmax / 5) * 3>>
				You are strained.
			<<elseif $stress gte ($stressmax / 5) * 2>>
				You are tense.
			<<elseif $stress gte $stressmax / 5>>
				You are calm.
			<<elseif $stress gte 1>>
				You are placid.
			<<else>>
				You are serene.
			<</if>>
		<</if>>

	<<set $stress = Math.clamp($stress, 0, $stressmax)>>
	<<set _showCaptionText to !$showCaptionText>>
	<<statbar $stress $stressmax _showCaptionText>>

<</widget>>

<<widget "traumacaption">>

		Trauma:
		<<if $showCaptionText is true>>
			<<if $trauma gte $traumamax>>
				You feel numb.
			<<elseif $trauma gte ($traumamax / 5) * 4>>
				You are tormented.
			<<elseif $trauma gte ($traumamax / 5) * 3>>
				You are disturbed.
			<<elseif $trauma gte ($traumamax / 5) * 2>>
				You are troubled.
			<<elseif $trauma gte ($traumamax / 5) * 1>>
				You are nervous.
			<<elseif $trauma gte 1>>
				You are uneasy.
			<<else>>
				You are healthy.
			<</if>>
		<</if>>

	<<set _showCaptionText to !$showCaptionText>>
	<<statbar $trauma $traumamax _showCaptionText>>

<</widget>>

<<widget "innocencecaption">>

		Innocence:
		<<if $showCaptionText is true>>
			<<if $awareness gte 0>>
				You understand.
			<<elseif $awareness gt -40>>
				You are uncertain.
			<<elseif $awareness gt -80>>
				You are perplexed.
			<<elseif $awareness gt -120>>
				You are curious.
			<<elseif $awareness gt -160>>
				You are trusting.
			<<elseif $awareness gt -200>>
				You are naive.
			<<else>>
				You are oblivious.
			<</if>>
		<</if>>

	<<set _showCaptionText to !$showCaptionText>>
	<<statbarinverted $awareness -200 _showCaptionText>>

<</widget>>

<<widget "controlcaption">>

		Control:
		<<if $showCaptionText is true>>
			<<if $possessed>>
				<<if $control gte $controlmax>>
					You are in control.
				<<elseif $control gte ($controlmax / 5) * 4>>
					You are nearly in control.
				<<elseif $control gte ($controlmax / 5) * 3>>
					You are struggling.
				<<elseif $control gte ($controlmax / 5) * 2>>
					Your body feels hollow.
				<<elseif $control gte ($controlmax / 5) * 1>>
					Your mind is numb.
				<<elseif $control gte 1>>
					You're being puppeteered.
				<<else>>
					You're helpless.
				<</if>>
			<<else>>
				<<if $control gte $controlmax>>
					You are confident.
				<<elseif $control gte ($controlmax / 5) * 4>>
					You are insecure.
				<<elseif $control gte ($controlmax / 5) * 3>>
					You are worried.
				<<elseif $control gte ($controlmax / 5) * 2>>
					You are anxious.
				<<elseif $control gte ($controlmax / 5) * 1>>
					You are scared.
				<<elseif $control gte 1>>
					You are frightened.
				<<else>>
					You are terrified.
				<</if>>
			<</if>>
		<</if>>

	<<set _showCaptionText to !$showCaptionText>>
	<<statbarinverted $control $controlmax _showCaptionText>>

<</widget>>

<<widget "arousalcaption">>

		Arousal:
		<<if $showCaptionText is true>>
			<<if $arousal gte $arousalmax>>
				You shake with arousal.
			<<elseif $arousal gte ($arousalmax / 5) * 4>>
				A heat rises within.
			<<elseif $arousal gte ($arousalmax / 5) * 3>>
				You feel horny.
			<<elseif $arousal gte ($arousalmax / 5) * 2>>
				You feel lustful.
			<<elseif $arousal gte $arousalmax / 5>>
				You feel aroused.
			<<elseif $arousal gte 1>>
				You feel sensual.
			<<else>>
				You feel cold.
			<</if>>
		<</if>>

	<<set _showCaptionText to !$showCaptionText>>
	<<statbar $arousal $arousalmax _showCaptionText>>

<</widget>>

<<widget "allurecaption">>

		Allure:
		<<if $showCaptionText is true>>
			<<if $allure gte (6000 * $alluremod)>>You look like you need to be ravaged.
			<<elseif $allure gte (4000 * $alluremod)>>You look perverted.
			<<elseif $allure gte (3000 * $alluremod)>>You look lewd.
			<<elseif $allure gte (2000 * $alluremod)>>You stand out.
			<<elseif $allure gte (1500 * $alluremod)>>You attract attention.
			<<elseif $allure gte (1000 * $alluremod)>>You attract glances.
			<<else>>You look unremarkable.
			<</if>>
		<</if>>

		<<set $percent=Math.floor(($allure/(8000 * $alluremod))*100)>>
		<<if $allure gte (6000 * $alluremod)>>
		<<print '

'>>
		<<elseif $allure gte (4000 * $alluremod)>>
		<<print '

'>>
		<<elseif $allure gte (3000 * $alluremod)>>
		<<print '

'>>
		<<elseif $allure gte (2000 * $alluremod)>>
		<<print '

'>>
		<<elseif $allure gte (1500 * $alluremod)>>
		<<print '

'>>
		<<elseif $allure gte (1000 * $alluremod)>>
		<<print '

'>>
		<<else>>
		<<print '

'>>
		<</if>>

	<<if $allure gte 8000>><<set $allure to 8000>><</if>>
	<<if $alluretest is 1>>
		<<set $allure += 100000>>
	<<elseif $alluretest is 2>>
		<<set $allure -= 100000>>
	<</if>>

<</widget>>

<<widget "updateallure">>
	<<run new Wikifier(null, '<<calculateallure>>')>>
	<<run $('#allurecaption').replaceWith(new Wikifier(null, '<<allurecaption>>').output)>>
<</widget>>

<<widget "oxygencaption">>

	<<if $args[0] is true>>

			Air:

		<<set _showCaptionText to !$showCaptionText>>
	<<else>>
		<<unset _showCaptionText>>
	<</if>>
	<<statbarinverted $oxygen $oxygenmax _showCaptionText>>

<</widget>>

<<widget "flashbacktown">>
You hear a car horn blare somewhere in the distance, and you panic. Phantom tendrils probe your body and restrict your limbs as a wordless voice jeers and promises endless debasement. It lasts only a moment, but the impression of violation remains.
<<garousal>><<gstress>><<gtrauma>><<arousal 600>><<stress 12>><<trauma 6>>

<</widget>>

<<widget "flashbackhome">>
You hear a car drive past, and you panic. Phantom tendrils probe your body and restrict your limbs as a wordless voice jeers and promises endless debasement. It lasts only a moment, but the impression of violation remains.
<<garousal>><<gstress>><<gtrauma>><<arousal 600>><<stress 6>><<trauma 6>>

<</widget>>

<<widget "flashbackbeach">>
You hear a gull squawk, and you panic. Phantom tendrils probe your body and restrict your limbs as a wordless voice jeers and promises endless debasement. It lasts only a moment, but the impression of violation remains.
<<garousal>><<gstress>><<gtrauma>><<arousal 600>><<stress 6>><<trauma 6>>

<</widget>>

<<widget "flashbackunderground">>
You feel a tremor through the earth, and you panic. Phantom tendrils probe your body and restrict your limbs as a wordless voice jeers and promises endless debasement. It lasts only a moment, but the impression of violation remains.
<<garousal>><<gstress>><<gtrauma>><<arousal 600>><<stress 6>><<trauma 6>>

<</widget>>

<<widget "flashbackschool">>
You remember the last time you were molested at school, and you panic. Phantom tendrils probe your body and restrict your limbs as a wordless voice jeers and promises endless debasement. It lasts only a moment, but the impression of violation remains.
<<garousal>><<gstress>><<gtrauma>><<arousal 600>><<stress 6>><<trauma 6>>

<</widget>>

<<widget "drunk">>
<<if $drunk gt 0>>

			<<if $showCaptionText is true>>
				<<if $drunk lte 120>>
				You are woozy.
				<<elseif $drunk lte 240>>
				You are tipsy.
				<<elseif $drunk lte 360>>
				You are drunk.
				<<elseif $drunk lte 480>>
				You are smashed
				<<else>>
				You are wasted
				<</if>>
			<<else>>
				Drunk:
			<</if>>

			<<set $percent=Math.floor(($drunk/1000)*100)>>
			<<if $drunk gte 500>>
			<<print '

'>>
			<<elseif $drunk gte 400>>
			<<print '

'>>
			<<elseif $drunk gte 300>>
			<<print '

'>>
			<<elseif $drunk gte 200>>
			<<print '

'>>
			<<elseif $drunk gte 100>>
			<<print '

'>>
			<<elseif $drunk gte 1>>
			<<print '

'>>
			<<else>>
			<<print '

'>>
			<</if>>

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

<<widget "drugged">>

<<if $drugged gt 0>>

			<<if $showCaptionText is true>>
				A lewd warmth fills you
			<<else>>
				Drugged:
			<</if>>

			<<set $percent=Math.floor(($drugged/1000)*100)>>
			<<if $drugged gte 500>>
			<<print '

'>>
			<<elseif $drugged gte 400>>
			<<print '

'>>
			<<elseif $drugged gte 300>>
			<<print '

'>>
			<<elseif $drugged gte 200>>
			<<print '

'>>
			<<elseif $drugged gte 100>>
			<<print '

'>>
			<<elseif $drugged gte 1>>
			<<print '

'>>
			<<else>>
			<<print '

'>>
			<</if>>

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

<<widget "hallucinogen">>

<<if $hallucinogen gt 0>>

			<<if $showCaptionText is true>>
				Your perception is altered
			<<else>>
				Hallucinogen:
			<</if>>

			<<set $percent=Math.floor(($hallucinogen/1000)*100)>>
			<<if $hallucinogen gte 500>>
			<<print '

'>>
			<<elseif $hallucinogen gte 400>>
			<<print '

'>>
			<<elseif $hallucinogen gte 300>>
			<<print '

'>>
			<<elseif $hallucinogen gte 200>>
			<<print '

'>>
			<<elseif $hallucinogen gte 100>>
			<<print '

'>>
			<<elseif $hallucinogen gte 1>>
			<<print '

'>>
			<<else>>
			<<print '

'>>
			<</if>>

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

<<widget "paincaption">>

		Pain:
		<<if $showCaptionText is true>>
			<<if $pain gte 100 and $willpowerpain is 0>>You sob uncontrollably.
			<<elseif $pain gte 80>>You cry and whimper.
			<<elseif $pain gte 60>>You are crying.
			<<elseif $pain gte 40>>Tears run down your face.
			<<elseif $pain gte 20>>Tears well in your eyes.
			<<elseif $pain gte 1>>You are upset.
			<<else>>You feel okay.
			<</if>>
		<</if>>

		<<set $percent=Math.floor(($pain/100)*100)>>
		<<if $pain gte 100 and $willpowerpain is 0>>
		<<print '

'>>
		<<elseif $pain gte 80>>
		<<print '

'>>
		<<elseif $pain gte 60>>
		<<print '

'>>
		<<elseif $pain gte 40>>
		<<print '

'>>
		<<elseif $pain gte 20>>
		<<print '

'>>
		<<elseif $pain gte 1>>
		<<print '

'>>
		<<else>>
		<<print '

'>>
		<</if>>

<</widget>>

<<widget "raped">>
<<if $rapeavoid is 1 and $consensual is 0 and $gamemode isnot "soft">>
<<set $rapeavoid to 0>><<set $rapestat += 1>>
	<<if $enemytype is "man" and !($npc.length is 1 and $npc[0] is "Eden")>>
		<<famerape $enemynomax>>
	<</if>>
	<<if $awareness lte 200>>
	<<awareness 5>>
	<<elseif $awareness lte 400>>
	<<awareness 1>>
	<</if>>
	<<if $enemytype is "beast" or $enemytype is "struggle">>
	<<set $beastrapestat += 1>>
		<<if $awareness lte 300>>
		<<awareness 1>>
		<</if>>
	<</if>>
	<<if $enemytype is "tentacles">>
		<<set $tentaclerapestat += 1>>
	<</if>>
	<<if $enemytype is "tentacles" or $enemytype is "struggle">>
		<<if $awareness lte 400>>
			<<awareness 1>>
		<</if>>
	<</if>>
<<controlloss>>
<<elseif $sexavoid is 1 and $consensual is 1>>
<<set $sexavoid to 0>>
	<<if $enemytype is "man" and !($npc.length is 1 and $npc[0] is "Eden")>>
		<<famesex $enemynomax>>
	<</if>>
<<controlloss>>
<</if>>
<</widget>>

<<widget "molested">>
<<if $gamemode is "soft">>
<<set $consensual to 1>>
<</if>>
<<if $molestavoid is 1 and $consensual is 0 and $gamemode isnot "soft">>
<<set $molestavoid to 0>>
<<moleststat>>

	<<if $flashbacks gte 1>>
		<<if $location is "town" and $flashbacktown is 0>>
		<<set $flashbacktown to 14>>
		<</if>>
		<<if $location is "home" and $flashbackhome is 0>>
		<<set $flashbackhome to 14>>
		<</if>>
		<<if $location is "beach" and $flashbackbeach is 0>>
		<<set $flashbackbeach to 14>>
		<</if>>
		<<if $location is "school" and $flashbackschool is 0>>
		<<set $flashbackschool to 14>>
		<</if>>
		<<if $location is "underground" and $flashbackunderground is 0>>
		<<set $flashbackunderground to 14>>
		<</if>>
	<</if>>
	<<if $awareness lte 200>>
	<<awareness 5>>
	<<elseif $awareness lte 400>>
	<<awareness 1>>
	<</if>>
	<<if $enemytype is "beast" or $enemytype is "struggle">>
		<<if $awareness lte 300>>
		<<awareness 1>>
		<</if>>
	<</if>>
	<<if $enemytype is "tentacles" or $enemytype is "struggle">>
		<<if $awareness lte 400>>
		<<awareness 1>>
		<</if>>
	<</if>>
<</if>>
<</widget>>

<<widget "consensual">>

	<<if $awareness lte 200>>
	<<awareness 5>>
	<<elseif $awareness lte 400>>
	<<awareness 1>>
	<</if>>
	<<if $enemytype is "beast" or $enemytype is "struggle">>
		<<if $awareness lte 300>>
		<<awareness 1>>
		<</if>>
	<</if>>
	<<if $enemytype is "tentacles">>
		<<if $awareness lte 400>>
		<<awareness 1>>
		<</if>>
	<</if>>
<<set $trueconsensual to 1>>
<<if $npc.length isnot 0>>
	<<if $npc.length is 1 and ($npc[0] is "Robin" and $NPCName[$NPCNameList.indexOf("Robin")].dom lte 10 and $debug is 1) or ($npc[0] is "Sydney" and $NPCName[$NPCNameList.indexOf("Sydney")].purity gte 50) or ($npc[0] is "Piper")>>
		<<npc_submissive>>
	<</if>>
<</if>>
<</widget>>

<<widget "controlloss">>
<<if $gamemode is "soft">>
<<elseif $consensual is 0>>
<<set $pullaway to 0>>
<<set $novaginal to 0>>
<<set $noanal to 0>>
<<set $nopenile to 0>>
	<<if $control gt 1>>
		<<if $molesttrait gte 1 and $rapeavoid is 1>>
		<<else>>
		<<set $controlstart to $control>><<control -25>>
			<<if $control gte ($controlmax * 0.74)>>
			Your sense of control wavers.
			<<elseif $control gte ($controlmax * 0.49)>>
			Your sense of control falters.
			<<elseif $control gte ($controlmax * 0.24)>>
			Your sense of control cracks.
			<<elseif $control gte 1>>
			Your sense of control breaks down.
			<<else>>
			Your sense of control shatters.
			<</if>>
		<</if>>
	<</if>>
<</if>>
<</widget>>

<<widget "beastescape">>
<<trauma 12>><<pain 6>><<stress 12>><<set $worn.over_lower.integrity -= 20>><<set $worn.over_upper.integrity -= 20>><<set $worn.lower.integrity -= 20>><<set $worn.upper.integrity -= 20>><<set $worn.under_lower.integrity -= 20>><<set $worn.under_upper.integrity -= 20>><<bruise full>><<gpain>><<gstress>><<gtrauma>>
<</widget>>

<<widget "weatherdisplay">>
<<if $season is "winter">>
	<<set _weather_display to "winter">>
<<else>>
	<<set _weather_display to "normal">>
<</if>>
<<if $images is 1>>
	<<if $daystate is "day">>
		<<if $location is "tentworld">>

		<<else>>

		<</if>>
		<<if $location is "tentworld">>

		<<elseif $weather is "clear">>

		<<elseif $weather is "overcast">>

		<<elseif $weather is "rain">>

		<<elseif $weather is "snow">>

		<</if>>
		<<switch $location>>
		<<case beach>>

		<<case sea>>

		<<case home>>

		<<case town>>

		<<case docks>>

		<<case pub>>

		<<case forest>>

		<<case lake>>

		<<case asylum>>
			<<if $hallucinations gte 1>>

			<<else>>

			<</if>>
		<<case tentworld>>

		<<case underground>>

		<<case sewers>>

		<<case school>>

		<<case cabin>>
			<<if $season is "winter">>

			<<else>>

			<</if>>
		<<case pool>>

		<<case landfill>>

		<<case temple>>

		<<case strip_club>>

		<<case shopping_centre>>

		<<case police_station>>

		<<case park>>

		<<case museum>>

		<<case hospital>>

		<<case dance_studio>>

		<<case compound>>

		<<case brothel>>

		<<case cafe>>
			<<if $chef_state gte 9>>

			<<elseif $chef_state gte 7>>

			<<else>>

			<</if>>
		<<case arcade>>

		<<case farm>>

		<<case alex_farm>>
			<<if $bus is "woodland">>

			<<else>>

			<</if>>
		<<case alex_cottage>>

		<<case riding_school>>

		<<case estate>>

		<<case wolf_cave>>

		<<case forest_shop>>

		<<case lake_ruin>>

		<<case moor>>

		<<case tower>>

		<<case castle>>

		<<case night_monster_lair>>

		<<case alley>>
			<<if $bus is "industrial">>

			<<elseif $bus is "residential">>

			<<else>>

			<</if>>
		<<case drain>>

		<<case spa>>

		<<case prison>>

		<<case promenade>>

		<</switch>>
	<<elseif $daystate is "night">>
		<<if $location is "tentworld">>

		<<elseif $moonstate is "evening" and $hour gte 21 or $moonstate is "morning" and $hour lt 6>>

		<<else>>

		<</if>>
		<<if $location is "tentworld">>

		<<elseif $weather is "clear">>

		<<elseif $weather is "overcast">>

		<<elseif $weather is "rain">>

		<<elseif $weather is "snow">>

		<</if>>
		<<switch $location>>
		<<case beach>>

		<<case sea>>

		<<case home>>

		<<case town>>

		<<case docks>>

		<<case pub>>

		<<case forest>>
			<<if $moonstate is "evening" and $hour gte 21 or $moonstate is "morning" and $hour lt 6>>

			<<else>>

			<</if>>
		<<case lake>>
			<<if $moonstate is "evening" and $hour gte 21 or $moonstate is "morning" and $hour lt 6>>

			<<else>>

			<</if>>
		<<case asylum>>
			<<if $hallucinations gte 1>>

			<<else>>

			<</if>>
		<<case tentworld>>

		<<case underground>>

		<<case sewers>>

		<<case school>>

		<<case cabin>>
			<<if $season is "winter">>

			<<else>>

			<</if>>
		<<case pool>>

		<<case landfill>>

		<<case temple>>

		<<case strip_club>>

		<<case shopping_centre>>

		<<case police_station>>

		<<case park>>

		<<case museum>>

		<<case hospital>>

		<<case dance_studio>>

		<<case compound>>

		<<case brothel>>

		<<case cafe>>
			<<if $chef_state gte 9>>

			<<elseif $chef_state gte 7>>

			<<else>>

			<</if>>
		<<case arcade>>

		<<case farm>>

		<<case alex_farm>>
			<<if $bus is "woodland">>

			<<else>>

			<</if>>
		<<case alex_cottage>>

		<<case riding_school>>

		<<case estate>>

		<<case wolf_cave>>

		<<case forest_shop>>

		<<case lake_ruin>>
			<<if $moonstate is "evening" and $hour gte 21 or $moonstate is "morning" and $hour lt 6>>

			<<else>>

			<</if>>
		<<case moor>>

		<<case tower>>
			<<if $moonstate is "evening" and $hour gte 21 or $moonstate is "morning" and $hour lt 6>>

			<<else>>

			<</if>>
		<<case castle>>
			<<if $moonstate is "evening" and $hour gte 21 or $moonstate is "morning" and $hour lt 6>>

			<<else>>

			<</if>>
		<<case night_monster_lair>>

		<<case alley>>
			<<if $bus is "industrial">>
				<<if $moonstate is "evening" and $hour gte 21 or $moonstate is "morning" and $hour lt 6>>

				<<else>>

				<</if>>
			<<elseif $bus is "residential">>
				<<if $moonstate is "evening" and $hour gte 21 or $moonstate is "morning" and $hour lt 6>>

				<<else>>

				<</if>>
			<<else>>
				<<if $moonstate is "evening" and $hour gte 21 or $moonstate is "morning" and $hour lt 6>>

				<<else>>

				<</if>>
			<</if>>
		<<case drain>>

		<<case spa>>

		<<case prison>>
			<<if $moonstate is "evening" and $hour gte 21 or $moonstate is "morning" and $hour lte 6>>

			<<else>>

			<</if>>
		<<case promenade>>

		<</switch>>
	<<elseif $daystate is "dawn">>
		<<if $location is "tentworld">>

		<<else>>

		<</if>>
		<<if $location is "tentworld">>

		<<elseif $weather is "clear">>

		<<elseif $weather is "overcast">>

		<<elseif $weather is "rain">>

		<<elseif $weather is "snow">>

		<</if>>
		<<switch $location>>
		<<case beach>>

		<<case sea>>

		<<case home>>

		<<case town>>

		<<case docks>>

		<<case pub>>

		<<case forest>>

		<<case lake>>

		<<case asylum>>
			<<if $hallucinations gte 1>>

			<<else>>

			<</if>>
		<<case tentworld>>

		<<case underground>>

		<<case sewers>>

		<<case school>>

		<<case cabin>>
			<<if $season is "winter">>

			<<else>>

			<</if>>
		<<case pool>>

		<<case landfill>>

		<<case temple>>

		<<case strip_club>>

		<<case shopping_centre>>

		<<case police_station>>

		<<case park>>

		<<case museum>>

		<<case hospital>>

		<<case dance_studio>>

		<<case compound>>

		<<case brothel>>

		<<case cafe>>
			<<if $chef_state gte 9>>

			<<elseif $chef_state gte 7>>

			<<else>>

			<</if>>
		<<case arcade>>

		<<case farm>>

		<<case alex_farm>>
			<<if $bus is "woodland">>

			<<else>>

			<</if>>
		<<case alex_cottage>>

		<<case riding_school>>

		<<case estate>>

		<<case wolf_cave>>

		<<case forest_shop>>

		<<case lake_ruin>>

		<<case moor>>

		<<case tower>>

		<<case castle>>

		<<case night_monster_lair>>

		<<case alley>>
			<<if $bus is "industrial">>

			<<elseif $bus is "residential">>

			<<else>>

			<</if>>
		<<case drain>>

		<<case spa>>

		<<case prison>>

		<<case promenade>>

		<</switch>>
	<<elseif $daystate is "dusk">>
		<<if $location is "tentworld">>

		<<else>>

		<</if>>
		<<if $location is "tentworld">>

		<<elseif $weather is "clear">>

		<<elseif $weather is "overcast">>

		<<elseif $weather is "rain">>

		<<elseif $weather is "snow">>

		<</if>>
		<<switch $location>>
		<<case beach>>

		<<case sea>>

		<<case home>>

		<<case town>>

		<<case docks>>

		<<case pub>>

		<<case forest>>

		<<case lake>>

		<<case asylum>>
			<<if $hallucinations gte 1>>

			<<else>>

			<</if>>
		<<case tentworld>>

		<<case underground>>

		<<case sewers>>

		<<case school>>

		<<case cabin>>
			<<if $season is "winter">>

			<<else>>

			<</if>>
		<<case pool>>

		<<case landfill>>

		<<case temple>>

		<<case strip_club>>

		<<case shopping_centre>>

		<<case police_station>>

		<<case park>>

		<<case museum>>

		<<case hospital>>

		<<case dance_studio>>

		<<case compound>>

		<<case brothel>>

		<<case cafe>>
			<<if $chef_state gte 9>>

			<<elseif $chef_state gte 7>>

			<<else>>

			<</if>>
		<<case arcade>>

		<<case farm>>

		<<case alex_farm>>
			<<if $bus is "woodland">>

			<<else>>

			<</if>>
		<<case alex_cottage>>

		<<case riding_school>>

		<<case estate>>

		<<case wolf_cave>>

		<<case forest_shop>>

		<<case lake_ruin>>

		<<case moor>>

		<<case tower>>

		<<case castle>>

		<<case night_monster_lair>>

		<<case alley>>
			<<if $bus is "industrial">>

			<<elseif $bus is "residential">>

			<<else>>

			<</if>>
		<<case drain>>

		<<case spa>>

		<<case prison>>

		<<case promenade>>

		<</switch>>
	<</if>>

<<else>>

<<if $daystate is "day">>
	<<if $weather is "clear">>
		It's a bright and sunny day.

	<<elseif $weather is "rain">>
		It's a rainy day.

	<<elseif $weather is "overcast">>
		Clouds are hiding the sun.

	<<elseif $weather is "snow">>
		It's a snowy day.
	<</if>>
<<elseif $daystate is "night">>
	<<if $weather is "clear">>
		The stars are shining.

	<<elseif $weather is "rain">>
		It's a rainy night.

	<<elseif $weather is "overcast">>
		All starlight is blocked by the clouds.

	<<elseif $weather is "snow">>
		It's a snowy night.
	<</if>>
<<elseif $daystate is "dawn">>
	<<if $weather is "clear">>
		The sun is rising.

	<<elseif $weather is "rain">>
		It's a rainy morning.

	<<elseif $weather is "overcast">>
		It's a cloudy morning.

	<<elseif $weather is "snow">>
		It's a snowy morning.
	<</if>>
<<elseif $daystate is "dusk">>
	<<if $weather is "clear">>
		The sun is setting.

	<<elseif $weather is "rain">>
		It's a rainy evening.

	<<elseif $weather is "overcast">>
		It's cloudy evening.

	<<elseif $weather is "snow">>
		It's a snowy evening.
	<</if>>
<</if>>

<</if>>

<</widget>>

<<widget "wearandtear">>
<<if $args[0] is "dance">>
	<<if !$worn.over_upper.type.includes("dance")>>
		<<set $worn.over_upper.integrity -= 1>>
	<</if>>
	<<if !$worn.over_lower.type.includes("dance")>>
		<<set $worn.over_lower.integrity -= 1>>
	<</if>>
	<<if !$worn.upper.type.includes("dance")>>
		<<set $worn.upper.integrity -= 1>>
	<</if>>
	<<if !$worn.lower.type.includes("dance")>>
		<<set $worn.lower.integrity -= 1>>
	<</if>>
	<<if !$worn.under_lower.type.includes("dance")>>
		<<set $worn.under_lower.integrity -= 1>>
	<</if>>
	<<if !$worn.under_upper.type.includes("dance")>>
		<<set $worn.under_upper.integrity -= 1>>
	<</if>>
<<else>>
	<<set $worn.over_upper.integrity -= 1>><<set $worn.over_lower.integrity -= 1>><<set $worn.upper.integrity -= 1>><<set $worn.lower.integrity -= 1>><<set $worn.under_lower.integrity -= 1>><<set $worn.under_upper.integrity -= 1>>
<</if>>
<</widget>>

<<widget "towelup">>
<<if $exposed gte 1>>
	<<if $upperwetstage gte 3>>
	<<upperwear 3>>
	<</if>>
	<<if $lowerwetstage gte 3>>
	<<lowerwear 3>>
	<</if>>
	<<if $worn.upper.exposed gte 1>>
	<<upperwear 14>>
	<<elseif $worn.lower.exposed gte 1>>
	<<lowerwear 3>>
	<</if>>
<</if>>
<</widget>>

<<widget "towelupm">>
<<if $exposed gte 1>>
	<<if $lowerwetstage gte 3>>
	<<lowerwear 3>>
	<</if>>
	<<if $worn.lower.exposed gte 1>>
	<<lowerwear 3>>
	<</if>>
<</if>>
<</widget>>

<<widget "plantupper">>
<<if $worn.upper.exposed gte 2 and $worn.under_upper.exposed gte 1
or $worn.upper.exposed gte 2 and $underupperwetstage gte 3
or $upperwetstage gte 3 and $worn.under_upper.exposed gte 1
or $upperwetstage gte 3 and $underupperwetstage gte 3
or $args[0] is "force">>
<<upperwear 6>>
<</if>>
<</widget>>

<<widget "plantlower">>
<<if $worn.lower.exposed gte 2 and $worn.under_lower.exposed gte 1
or $worn.lower.exposed gte 2 and $underlowerwetstage gte 3
or $lowerwetstage gte 3 and $worn.under_lower.exposed gte 1
or $lowerwetstage gte 3 and $underlowerwetstage gte 3
or $args[0] is "force">>
<<lowerwear 8>>
<</if>>
<</widget>>

<<widget "plantup">>

<<if $worn.upper.exposed gte 2 and $worn.under_upper.exposed gte 1 or $upperwetstage gte 3 and $underupperwetstage gte 3>>
<<upperwear 6>>
<</if>>
<<if $worn.lower.exposed gte 2 and $worn.under_lower.exposed gte 1 or $lowerwetstage gte 3 and $underlowerwetstage gte 3 or $lowerwetstage gte 3 and $worn.under_lower.exposed gte 1>>
<<lowerwear 8>>
<</if>>
<</widget>>

<<widget "schoolspareclothes">>
<<if !$worn.upper.type.includes("school") or !$worn.lower.type.includes("school") and $worn.upper.set is $worn.lower.set>>
	<<upperwear 5>><<set $worn.upper.colour to either("black", "blue", "brown", "green", "pink", "purple", "red", "tangerine", "teal", "white", "yellow")>><<set $worn.upper.integrity /= 2>>
<</if>>
<<if !$worn.lower.type.includes("school")>>
	<<if $clothingselector is "m">>
		<<lowerwear 6>><<set $worn.lower.colour to either("black", "blue", "brown", "green", "pink", "purple", "red", "tangerine", "teal", "white", "yellow")>><<set $worn.lower.integrity /= 2>>
	<<else>>
		<<lowerwear 7>><<set $worn.lower.colour to either("black", "blue", "brown", "green", "pink", "purple", "red", "tangerine", "teal", "white", "yellow")>><<set $worn.lower.integrity /= 2>>
	<</if>>
<</if>>
<</widget>>

<<widget "spareschoolswimsuit">>
<<underupperwear 2>><<set $worn.under_upper.colour to either("black", "blue", "brown", "green", "pink", "purple", "red", "tangerine", "teal", "white", "yellow")>><<set $worn.under_upper.integrity /= 2>>
<<set $worn.under_lower.colour to clone($worn.under_upper.colour)>><<set $worn.under_lower.integrity /= 2>>
<</widget>>

<<widget "spareschoolswimshorts">>
<<underlowerwear 7>><<set $worn.under_lower.colour to either("black", "blue", "brown", "green", "pink", "purple", "red", "tangerine", "teal", "white", "yellow")>><<set $worn.under_lower.integrity /= 2>>
<</widget>>

<<widget "exposure">>

<<if !["beach","pool","sea","lake","lake_ruin"].includes($location)>>
	<<set $libertine to 0>>
<<else>>
	<<set $libertine to 1>>
<</if>>
<<if $location is "dance_studio" and $worn.under_lower.type.includes("dance") and $worn.under_upper.type.includes("dance")>>
	<<set $libertine to 1>>
<</if>>

<<set $worn.over_upper.exposedcarry to $worn.over_upper.exposed>>
<<set $worn.over_lower.exposedcarry to $worn.over_lower.exposed>>
<<set $worn.upper.exposedcarry to $worn.upper.exposed>>
<<set $worn.lower.exposedcarry to $worn.lower.exposed>>
<<set $worn.under_lower.exposedcarry to $worn.under_lower.exposed>>
<<set $worn.under_upper.exposedcarry to $worn.under_upper.exposed>>

<<if $upperwetstage gte 3>>
<<set $worn.upper.exposed to 2>>
<</if>>
<<if $lowerwetstage gte 3>>
<<set $worn.lower.exposed to 2>>
<</if>>
<<if $underlowerwetstage gte 3>>
<<set $worn.under_lower.exposed to 1>>
<</if>>
<<if $underupperwetstage gte 3>>
<<set $worn.under_upper.exposed to 1>>
<</if>>

<<exposedcheck>>

<<set $exposed to 0>>
<<if $worn.upper.exposed gte 1 and $worn.over_upper.exposed gte 1>>
	<<if $player.gender_appearance is "m">>
	<<elseif $libertine gte 1 or $possessed>>
	<<else>>
		<<set $exposed to 1>>
	<</if>>
<</if>>
<<if $worn.upper.exposed gte 2 and $worn.over_upper.exposed gte 2 and $player.gender_appearance isnot "m">>
	<<if $possessed>>
	<<elseif $libertine is 1>>
		<<set $topless to 1>>
	<<else>>
		<<set $exposed to 1>>
	<</if>>
<<else>>
	<<set $topless to 0>>
<</if>>
<<if $worn.lower.exposed gte 1 and $worn.over_lower.exposed gte 1>>
	<<if $libertine gte 1 or $possessed>>
	<<else>>
		<<set $exposed to 1>>
	<</if>>
<</if>>

<<if $worn.lower.exposed gte 2 and $worn.over_lower.exposed gte 2>>
	<<if $possessed>>
	<<elseif $worn.under_lower.exposed gte 1>>
		<<set $exposed to 2>>
	<<elseif $libertine gte 1>>
	<<else>>
		<<set $exposed to 1>>
	<</if>>
<</if>>

<<set $worn.over_upper.exposed to $worn.over_upper.exposedcarry>>
<<set $worn.over_lower.exposed to $worn.over_lower.exposedcarry>>
<<set $worn.upper.exposed to $worn.upper.exposedcarry>>
<<set $worn.lower.exposed to $worn.lower.exposedcarry>>
<<set $worn.under_lower.exposed to $worn.under_lower.exposedcarry>>
<<set $worn.under_upper.exposed to $worn.under_upper.exposedcarry>>

<</widget>>

<<widget "integritycheck">>
<<if $worn.over_upper.name isnot "naked">>
	<<if $worn.over_upper.integrity lte 0>>
		<<set $worn.over_upper.type.push("broken")>>
		<<if $args[0] isnot "no_text">>
			Your $worn.over_upper.name <<upperplural>> ripped into scraps<<if $worn.upper.exposed gte 2>>, exposing your <<breasts>><</if>>.

		<</if>>
	<<overupperruined>><<clothesruinstat>><<if $worn.upper.exposed gte 2>><<set $upperoff to 0>><</if>>
	<</if>>
<</if>>
<<if $worn.over_lower.name isnot "naked">>
	<<if $worn.over_lower.integrity lte 0>>
		<<set $worn.over_lower.type.push("broken")>>
		<<if $args[0] isnot "no_text">>
			Your $worn.over_lower.name <<upperplural>> ripped into scraps<<if $worn.lower.exposed gte 2>>, exposing your <<undies>><</if>>.

		<</if>>
	<<overlowerruined>><<clothesruinstat>><<if $worn.lower.exposed gte 2>><<set $upperoff to 0>><</if>>
	<</if>>
<</if>>
<<if $worn.upper.name isnot "naked">>
	<<if $worn.upper.integrity lte 0>>
		<<set $worn.upper.type.push("broken")>>
		<<if $args[0] isnot "no_text">>
			Your $worn.upper.name <<upperplural>> ripped into scraps, exposing your <<breasts>>.

		<</if>>
	<<upperruined>><<clothesruinstat>><<set $upperoff to 0>>
	<</if>>
<</if>>
<<if $worn.lower.name isnot "naked">>
	<<if $worn.lower.integrity lte 0>>
		<<set $worn.lower.type.push("broken")>>
		<<if $args[0] isnot "no_text">>
			Your $worn.lower.name <<lowerplural>> ripped into scraps, exposing your <<undies>>.

		<</if>>
	<<lowerruined>><<clothesruinstat>><<set $loweroff to 0>>
	<</if>>
<</if>>
<<if $worn.under_upper.name isnot "naked">>
	<<if $worn.under_upper.integrity lte 0>>
		<<set $worn.under_upper.type.push("broken")>>
		<<if $args[0] isnot "no_text">>
			Your $worn.under_upper.name <<underupperplural>> ripped into scraps, exposing your <<breasts>>.

		<</if>>
	<<underupperruined>><<clothesruinstat>><<set $underupperoff to 0>>
	<</if>>
<</if>>
<<if $worn.under_lower.name isnot "naked">>
	<<if $worn.under_lower.integrity lte 0>>
		<<set $worn.under_lower.type.push("broken")>>
		<<if $args[0] isnot "no_text">>
			Your $worn.under_lower.name <<underlowerplural>> ripped into scraps, exposing your <<if $worn.genitals.name isnot "naked">>$worn.genitals.name.<<else>><<genitals>>.<</if>>

		<</if>>
	<<underlowerruined>><<clothesruinstat>><<set $underloweroff to 0>>
	<</if>>
<</if>>
<<if $worn.genitals.name isnot "naked">>
	<<if $worn.genitals.integrity lte 0>>
		<<set _chastityBreak to 1>>
		<<if $args[0] isnot "no_text">>
			Your $worn.genitals.name breaks, exposing your <<genitals>>.

		<</if>>
		<<if $worn.genitals.type.includes("chastity")>>
			<<set $worn.genitals.type.push("broken")>>
			<<if $vaginalchastityparasite isnot 0>>
				With the chastity belt gone, the $vaginalchastityparasite fall out of your vagina.

				<<set $vaginalchastityparasite to 0>>
			<</if>>
			<<if $penilechastityparasite isnot 0>>
				With the chastity belt gone, the $penilechastityparasite fall off of your penis.

				<<set $penilechastityparasite to 0>>
			<</if>>
			<<if $analchastityparasite isnot 0>>
				With the chastity belt gone, the $analchastityparasite fall out of your anus.

				<<set $analchastityparasite to 0>>
			<</if>>
			<<if $worn.genitals.anal_shield is 1>>
				<<set $worn.genitals.anal_shield to 0>>
			<</if>>
		<</if>>
		<<genitalsruined>><<clothesruinstat>>
	<</if>>
<</if>>
<</widget>>

<<widget "arm_unbind">>
<<set $rightboundcarry to 0>>
<<set $leftboundcarry to 0>>
<<set $leftarm to 0>>
<<set $rightarm to 0>>
<<if $worn.upper.type.includes("binding")>>
	<<set _unbind_check to 1>>
	<<if $worn.upper.set is $worn.lower.set>>
		<<set $worn.lower.type.push("broken")>>
		<<lowerruined>>
	<</if>>
	<<set $worn.upper.type.push("broken")>>
	<<upperruined>>
<</if>>
<</widget>>

<<widget "unbind">>
<<set $rightboundcarry to 0>>
<<set $leftboundcarry to 0>>
<<set $leftarm to 0>>
<<set $rightarm to 0>>
<<remove_shackle>>
<<leg_unbind>>
<<if $head is "bound">>
	<<set $head to 0>>
<</if>>
<<if $worn.upper.type.includes("binding")>>
	<<set _unbind_check to 1>>
	<<if $worn.upper.set is $worn.lower.set>>
		<<set $worn.lower.type.push("broken")>>
		<<lowerruined>>
	<</if>>
	<<set $worn.upper.type.push("broken")>>
	<<upperruined>>
<</if>>
<</widget>>

<<widget "bind">>
<<set $leftarm to "bound">>
<<set $rightarm to "bound">>
<</widget>>

<<widget "legbind">>
<<set $leftleg to "bound">>
<<set $rightleg to "bound">>
<<set $feetuse to "bound">>
<</widget>>

<<widget "leg_unbind">>
<<set $leftleg to 0>>
<<set $rightleg to 0>>
<<set $feetuse to 0>>
<</widget>>

<<widget "remove_shackle">>
<<if $worn.feet.type.includes("shackle")>>
	<<set $worn.feet.type.push("broken")>>
	<<feetruined>>
	<<leg_unbind>>
<</if>>
<</widget>>

<<widget "shackle_feet">>
<<feetwear 3>>
<<legbind>>
<</widget>>

<<widget "headbind">>
<<set $head to "bound">>
<</widget>>

<<widget "bindings">>
<<if $leftarm is "bound" and $position isnot "wall">><<set $leftboundcarry to 1>><</if>>
<<if $rightarm is "bound" and $position isnot "wall">><<set $rightboundcarry to 1>><</if>>
<<if $rightboundcarry is 1 and $rightarm isnot "bound">>
<<set $rightarm to "bound">>
<</if>>
<<if $leftboundcarry is 1 and $leftarm isnot "bound">>
<<set $leftarm to "bound">>
<</if>>
<</widget>>

<<widget "water">>
<<if !$worn.upper.type.includes("swim") and !$worn.upper.type.includes("naked") and $args[0] isnot "waist">>
	<<set $upperwet to 200>>
<</if>>
<<if !$worn.lower.type.includes("swim") and !$worn.lower.type.includes("naked")>>
	<<set $lowerwet to 200>>
<</if>>
<<if !$worn.under_lower.type.includes("swim") and !$worn.under_lower.type.includes("naked")>>
	<<set $underlowerwet to 200>>
<</if>>
<<if !$worn.under_upper.type.includes("swim") and !$worn.under_upper.type.includes("naked") and $args[0] isnot "waist">>
	<<set $underupperwet to 200>>
<</if>>

<<waterwash>>
<<set $inwater to 1>>
<<set _water_warmth to 0>>
<<if $location isnot "sea" and $outside is 1 and $season is "winter">>
	<<if $worn.upper.type.includes("diving") or $worn.under_upper.type.includes("diving")>>
		<<set _water_warmth += 1>>
	<</if>>
	<<if $worn.lower.type.includes("diving") or $worn.under_lower.type.includes("diving")>>
		<<set _water_warmth += 1>>
	<</if>>
<<else>>
	<<set _water_warmth to 2>>
<</if>>
<</widget>>

<<widget "storecleanup">>

<<set $action_unclad_over_outfit to 0>>
<<set $action_unclad_over_upper to 0>>
<<set $action_unclad_over_lower to 0>>
<<set $action_unclad_outfit to 0>>
<<set $action_unclad_upper to 0>>
<<set $action_unclad_lower to 0>>
<<set $action_unclad_under_outfit to 0>>
<<set $action_unclad_under_lower to 0>>
<<set $action_unclad_under_upper to 0>>
<<set $action_unclad_legs to 0>>
<<set $action_unclad_feet to 0>>
<<set $action_unclad_neck to 0>>
<<set $action_unclad_head to 0>>
<<set $action_unclad_face to 0>>
<<set $action_unclad_hands to 0>>

<</widget>>

<<widget "arousalpass">>
<<if _arousal is undefined>>
	<<set _arousal to 0>>
<</if>>
<<if $penilechastityparasite isnot 0>>
	<<set _arousal += $pass * 10 * $genitalsensitivity>>
<</if>>
<<if $vaginalchastityparasite isnot 0>>
	<<set _arousal += $pass * 10 * $genitalsensitivity>>
<</if>>
<<if $analchastityparasite isnot 0>>
	<<set _arousal += $pass * 10>>
<</if>>
<<if $parasite.nipples.name>>
	<<set _arousal += $pass * 10 * $breastsensitivity>>
<</if>>
<<if $parasite.penis.name>>
	<<set _arousal += $pass * 10 * $genitalsensitivity>>
<</if>>
<<if $parasite.clit.name>>
	<<set _arousal += $pass * 10 * $genitalsensitivity>>
<</if>>
<<if $parasite.bottom.name>>
	<<set _arousal += $pass * 10>>
<</if>>
<<if $parasite.tummy.name>>
	<<set _arousal += $pass * 10>>
<</if>>
<<if $parasite.left_arm.name>>
	<<set _arousal += $pass * 10>>
<</if>>
<<if $parasite.right_arm.name>>
	<<set _arousal += $pass * 10>>
<</if>>
<<if $parasite.left_thigh.name>>
	<<set _arousal += $pass * 10>>
<</if>>
<<if $parasite.right_thigh.name>>
	<<set _arousal += $pass * 10>>
<</if>>
<<if $drugged gt 1>>
	<<set _arousal += $pass * 10>>
<</if>>
<<if $parasite.left_ear.name is "slime" and random(1, 100) gte 90>>
	<<drugs $pass>>
<</if>>
<<if $parasite.right_ear.name is "slime" and random(1, 100) gte 90>>
	<<drugs $pass>>
<</if>>
<<arousal _arousal>>
<</widget>>

<<widget "undiestrauma">>
<<if !$worn.under_lower.type.includes("naked")>>
<<gtrauma>><<gstress>><<trauma 1>><<stress 1>>
<<else>>
<<gtrauma>><<gstress>><<trauma 3>><<stress 3>>
<</if>>
<</widget>>

<<widget "goo">>
<<goooutsidecount>>

<<if $goooutsidecount gte 1 and $semenoutsidecount gte 1>>
	<<if $goooutsidecount + $semenoutsidecount gte 100>>
		Lewd fluid drenches you from head to toe.

	<<elseif $goooutsidecount + $semenoutsidecount gte 25>>
		You are drenched in slime and semen.

	<<elseif $goooutsidecount + $semenoutsidecount gte 20>>
		You are soaked with slime and semen.

	<<elseif $goooutsidecount + $semenoutsidecount gte 15>>
		Your skin is slick with slime and semen.

	<<elseif $goooutsidecount + $semenoutsidecount gte 10>>
		You are wet with slime and semen.

	<<elseif $goooutsidecount + $semenoutsidecount gte 5>>
		Your skin is moist with slime and semen.

	<<else>>
		You feel slime and semen on your skin.

	<</if>>

<<elseif $goooutsidecount gte 1>>
	<<if $goooutsidecount gte 25>>
		You are drenched in slime.

	<<elseif $goooutsidecount gte 20>>
		You are soaked with slime.

	<<elseif $goooutsidecount gte 15>>
		Your skin is slick with slime.

	<<elseif $goooutsidecount gte 10>>
		You are wet with slime.

	<<elseif $goooutsidecount gte 5>>
		Your skin is moist with slime.

	<<else>>
		You feel slime on your skin.

	<</if>>

<<elseif $semenoutsidecount gte 1>>
	<<if $semenoutsidecount gte 25>>
		You are drenched in semen.

	<<elseif $semenoutsidecount gte 20>>
		You are soaked with semen.

	<<elseif $semenoutsidecount gte 15>>
		Your skin is slick with semen.

	<<elseif $semenoutsidecount gte 10>>
		You are wet with semen.

	<<elseif $semenoutsidecount gte 5>>
		Your skin is moist with semen.

	<<else>>
		You feel semen on your skin.

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

<<if $player.bodyliquid.vagina.goo gte 1 or $player.bodyliquid.vagina.semen gte 1>>
	<<if $player.bodyliquid.vagina.goo gte 1 and $player.bodyliquid.vagina.semen gte 1>>
		<<switch Math.clamp(setup.bodyliquid.combined("vagina"), 1, 5)>>
			<<case 5>>
				Your womb overflows with slime and semen.

			<<case 4>>
				Your <<pussy>> overflows with slime and semen.

			<<case 3>>
				Slime and semen flows from your <<pussy>>.

			<<case 2>>
				Slime and semen stream from your <<pussy>>.

			<<case 1>>
				Slime and semen drip from your <<pussy>>.

		<</switch>>
	<<else>>
		<<if $player.bodyliquid.vagina.goo gte 1>>
			<<set _liquid to "slime">>
			<<set _liquidupper to "Slime">>
		<<else>>
			<<set _liquid to "semen">>
			<<set _liquidupper to "Semen">>
		<</if>>
		<<switch Math.clamp(setup.bodyliquid.combined("vagina"), 1, 5)>>
			<<case 5>>
				Your womb overflows with _liquid.

			<<case 4>>
				Your <<pussy>> overflows with _liquid.

			<<case 3>>
				_liquidupper flows from your <<pussy>>.

			<<case 2>>
				_liquidupper streams from your <<pussy>>.

			<<case 1>>
				_liquidupper drips from your <<pussy>>.

		<</switch>>
	<</if>>
<</if>>

<<if $player.bodyliquid.anus.goo gte 1 or $player.bodyliquid.anus.semen gte 1>>
	<<if $player.bodyliquid.anus.goo gte 1 and $player.bodyliquid.anus.semen gte 1>>
		<<switch Math.clamp(setup.bodyliquid.combined("anus"), 1, 5)>>
			<<case 5>>
				Your bowels overflow with slime and semen.

			<<case 4>>
				Your <<bottom>> overflows with slime and semen.

			<<case 3>>
				Slime and semen flows from your <<bottom>>.

			<<case 2>>
				Slime and semen stream from your <<bottom>>.

			<<case 1>>
				Slime and semen drip from your <<bottom>>.

		<</switch>>
	<<else>>
		<<if $player.bodyliquid.anus.goo gte 1>>
			<<set _liquid to "slime">>
			<<set _liquidupper to "Slime">>
		<<else>>
			<<set _liquid to "semen">>
			<<set _liquidupper to "Semen">>
		<</if>>
		<<switch Math.clamp(setup.bodyliquid.combined("anus"), 1, 5)>>
			<<case 5>>
				Your bowels overflow with _liquid.

			<<case 4>>
				Your <<bottom>> overflows with _liquid.

			<<case 3>>
				_liquidupper flows from your <<bottom>>.

			<<case 2>>
				_liquidupper streams from your <<bottom>>.

			<<case 1>>
				_liquidupper drips from your <<bottom>>.

		<</switch>>
	<</if>>
<</if>>

<<if $player.bodyliquid.mouth.goo gte 1 or $player.bodyliquid.mouth.semen gte 1>>
	<<if $player.bodyliquid.mouth.goo gte 1 and $player.bodyliquid.mouth.semen gte 1>>
		<<switch Math.clamp(setup.bodyliquid.combined("mouth"), 1, 5)>>
			<<case 5>>
				You keep coughing up slime and semen.

			<<case 4>>
				Slime and semen dribble down your chin.

			<<case 3>>
				Slime and semen line the sides of your throat.

			<<case 2>>
				Slime and semen layer the back of your throat.

			<<case 1>>
				The taste of slime and semen permeates your mouth.

		<</switch>>
	<<else>>
		<<if $player.bodyliquid.mouth.goo gte 1>>
			<<set _liquid to "slime">>
			<<set _liquidupper to "Slime">>
		<<else>>
			<<set _liquid to "semen">>
			<<set _liquidupper to "Semen">>
		<</if>>
		<<switch Math.clamp(setup.bodyliquid.combined("mouth"), 1, 5)>>
			<<case 5>>
				You keep coughing up _liquid.

			<<case 4>>
				_liquidupper dribbles down your chin.

			<<case 3>>
				_liquidupper lines the sides of your throat.

			<<case 2>>
				_liquidupper layers the back of your throat.

			<<case 1>>
				The taste of _liquid permeates your mouth.

		<</switch>>
	<</if>>
<</if>>

<</widget>>

<<widget "clampgoo">>
	<<for _bodypart range setup.bodyliquid.bodyparts>>
		<<if $player.bodyliquid[_bodypart]["goo"] gte 5 or $player.bodyliquid[_bodypart]["semen"] gte 5>>
			<<set $player.bodyliquid[_bodypart]["goo"]   to Math.clamp($player.bodyliquid[_bodypart]["goo"],   0, 5)>>
			<<set $player.bodyliquid[_bodypart]["semen"] to Math.clamp($player.bodyliquid[_bodypart]["semen"], 0, 5)>>
		<</if>>
	<</for>>
<</widget>>

<<widget "goocount">>
	<<clampgoo "goocount">>
	<<set $goocount to $player.bodyliquid.neck.goo + $player.bodyliquid.rightarm.goo + $player.bodyliquid.leftarm.goo + $player.bodyliquid.thigh.goo + $player.bodyliquid.bottom.goo + $player.bodyliquid.tummy.goo + $player.bodyliquid.chest.goo + $player.bodyliquid.face.goo + $player.bodyliquid.hair.goo + $player.bodyliquid.feet.goo + $player.bodyliquid.vaginaoutside.goo + ($player.bodyliquid.vagina.goo * 3) + ($player.bodyliquid.penis.goo * 3) + ($player.bodyliquid.anus.goo * 3) + ($player.bodyliquid.mouth.goo * 3)>>
	<<set $semencount to $player.bodyliquid.neck.semen + $player.bodyliquid.rightarm.semen + $player.bodyliquid.leftarm.semen + $player.bodyliquid.thigh.semen + $player.bodyliquid.bottom.semen + $player.bodyliquid.tummy.semen + $player.bodyliquid.chest.semen + $player.bodyliquid.face.semen + $player.bodyliquid.hair.semen + $player.bodyliquid.feet.semen + $player.bodyliquid.vaginaoutside.semen + ($player.bodyliquid.vagina.semen * 3) + ($player.bodyliquid.penis.semen * 3) + ($player.bodyliquid.anus.semen * 3) + ($player.bodyliquid.mouth.semen * 3)>>
	<<set $liquidcount to $goocount + $semencount>>
<</widget>>

<<widget "goooutsidecount">>
	<<clampgoo "goooutsidecount">>
	<<set $goooutsidecount to $player.bodyliquid.neck.goo + $player.bodyliquid.rightarm.goo + $player.bodyliquid.leftarm.goo + $player.bodyliquid.thigh.goo + $player.bodyliquid.bottom.goo + $player.bodyliquid.tummy.goo + $player.bodyliquid.chest.goo + $player.bodyliquid.face.goo + $player.bodyliquid.hair.goo + $player.bodyliquid.feet.goo + $player.bodyliquid.vaginaoutside.goo + ($player.bodyliquid.penis.goo * 3)>>
	<<set $semenoutsidecount to $player.bodyliquid.neck.semen + $player.bodyliquid.rightarm.semen + $player.bodyliquid.leftarm.semen + $player.bodyliquid.thigh.semen + $player.bodyliquid.bottom.semen + $player.bodyliquid.tummy.semen + $player.bodyliquid.chest.semen + $player.bodyliquid.face.semen + $player.bodyliquid.hair.semen + $player.bodyliquid.feet.semen + $player.bodyliquid.vaginaoutside.semen + ($player.bodyliquid.penis.semen * 3)>>
	<<set $liquidoutsidecount to $goooutsidecount + $semenoutsidecount>>
<</widget>>

<<widget "goobodycount">>
	<<clampgoo "goobodycount">>
	<<set $goobodycount to $player.bodyliquid.thigh.goo + $player.bodyliquid.bottom.goo + $player.bodyliquid.tummy.goo + $player.bodyliquid.chest.goo + $player.bodyliquid.vaginaoutside.goo + ($player.bodyliquid.vagina.goo * 3) + ($player.bodyliquid.penis.goo * 3) + ($player.bodyliquid.anus.goo * 3)>>
	<<set $semenbodycount to $player.bodyliquid.thigh.semen + $player.bodyliquid.bottom.semen + $player.bodyliquid.tummy.semen + $player.bodyliquid.chest.semen + $player.bodyliquid.vaginaoutside.semen + ($player.bodyliquid.vagina.semen * 3) + ($player.bodyliquid.penis.semen * 3) + ($player.bodyliquid.anus.semen * 3)>>
	<<set $liquidbodycount to $goobodycount + $semenbodycount>>
<</widget>>

<<widget "outergoo">>
<<set $player.bodyliquid.neck.goo += 1>>
<<set $player.bodyliquid.rightarm.goo += 1>>
<<set $player.bodyliquid.leftarm.goo += 1>>
<<set $player.bodyliquid.thigh.goo += 1>>
<<set $player.bodyliquid.bottom.goo += 1>>
<<set $player.bodyliquid.tummy.goo += 1>>
<<set $player.bodyliquid.chest.goo += 1>>
<<set $player.bodyliquid.face.goo += 1>>
<<set $player.bodyliquid.hair.goo += 1>>
<<set $player.bodyliquid.feet.goo += 1>>
<</widget>>

<<widget "washmakeup">>
<<if $makeup.lipstick != 0 or $makeup.eyeshadow != 0 or $makeup.mascara != 0 or $makeup.concealer != 0>>
	<<set $makeupWashed = 1>>
	<<set $makeup.lipstick = 0>>
	<<set $makeup.eyeshadow = 0>>
	<<set $makeup.mascara = 0>>
	<<set $makeup.concealer = 0>>
<</if>>
<</widget>>

<<widget "waterwash">>

<<if $combat isnot 1>>
	<<for _bodypart range setup.bodyliquid.bodyparts>>
		<<if $player.bodyliquid[_bodypart]["goo"] gte 1>>  <<set $waterwash += 1>><<set $allure += 500>><<set $player.bodyliquid[_bodypart]["goo"] -= 1>><</if>>
		<<if $player.bodyliquid[_bodypart]["semen"] gte 1>><<set $waterwash += 1>><<set $allure += 500>><<set $player.bodyliquid[_bodypart]["semen"] -= 1>><</if>>
	<</for>>
<</if>>

<<if $waterwash gte 10>>
Copious amounts of lewd fluid washes into the water. You hope it doesn't attract attention.

<<elseif $waterwash gte 5>>
Lots of lewd fluid washes into the water. You hope it doesn't attract attention.

<<elseif $waterwash gte 2>>
Lewd fluid washes into the water. You hope it doesn't attract attention.

<<elseif $waterwash is 1>>
Some lewd fluid washes into the water. You hope it doesn't attract attention.

<</if>>
<<set $waterwash to 0>>

<<washmakeup>>

<</widget>>

<<widget "wash">>
	<<for _bodypart range setup.bodyliquid.bodyparts>>
		<<set $player.bodyliquid[_bodypart]["goo"] to 0>>
		<<set $player.bodyliquid[_bodypart]["semen"] to 0>>
	<</for>>
	<<if $parasite.right_thigh.name is "maggot">>
	<<removeparasite right_thigh>>
	<</if>>
	<<if $parasite.left_thigh.name is "maggot">>
	<<removeparasite left_thigh>>
	<</if>>
	<<if $parasite.right_arm.name is "maggot">>
	<<removeparasite right_arm>>
	<</if>>
	<<if $parasite.left_arm.name is "maggot">>
	<<removeparasite left_arm>>
	<</if>>
	<<if $parasite.tummy.name is "maggot">>
	<<removeparasite tummy>>
	<</if>>
	<<if $parasite.bottom.name is "maggot">>
	<<removeparasite bottom>>
	<</if>>

<<for _active_bodypart range setup.bodyparts>>
	<<if $skin[_active_bodypart].pen is "pen" or $skin[_active_bodypart].pen is "lipstick" or $skin[_active_bodypart].pen is "mud">>
		<<bodywriting_clear _active_bodypart>>
	<</if>>
<</for>>
<<washmakeup>>
<</widget>>

<<widget "wash_face">>
<<set $player.bodyliquid.face.semen to 0>>
<<set $player.bodyliquid.face.goo to 0>>
<<if $skin.left_cheek.pen is "pen" or $skin.left_cheek.pen is "lipstick" or $skin.left_cheek.pen is "mud">>
	<<bodywriting_clear left_cheek>>
<</if>>
<<if $skin.right_cheek.pen is "pen" or $skin.right_cheek.pen is "lipstick" or $skin.right_cheek.pen is "mud">>
	<<bodywriting_clear right_cheek>>
<</if>>
<<if $skin.forehead.pen is "pen" or $skin.forehead.pen is "lipstick" or $skin.forehead.pen is "mud">>
	<<bodywriting_clear forehead>>
<</if>>
<<washmakeup>>
<</widget>>

<<widget "wash_mouth">>
<<set $player.bodyliquid.mouth.semen to 0>>
<<set $player.bodyliquid.mouth.goo to 0>>
<</widget>>

<<widget "tipset">>

<<set $tip to random(1000, 3000)>>
<<if $tip lte 2000>>
	<<set $tipreaction to "low">>
<<else>>
	<<set $tipreaction to "mid">>
<</if>>

<<set _temp_tip to $tip>>/*Remembers base tip value*/

	<<if $args[0] is "serving">>
		<<if $worn.upper.type.includes("serving")>>
		<<set $tip += ((_temp_tip * 1.2) - _temp_tip)>>/*20% increase on base value*/
		<</if>>
		<<if $worn.lower.type.includes("serving")>>
		<<set $tip += ((_temp_tip * 1.2) - _temp_tip)>>
		<</if>>
		<<if $worn.under_upper.type.includes("serving") and $worn.upper.exposed gte 2>>
		<<set $tip += ((_temp_tip * 1.2) - _temp_tip)>>
		<</if>>
		<<if $worn.under_lower.type.includes("serving") and $worn.lower.exposed gte 2>>
		<<set $tip += ((_temp_tip * 1.2) - _temp_tip)>>
		<</if>>
		<<if $worn.head.type.includes("serving")>>
		<<set $tip += ((_temp_tip * 1.2) - _temp_tip)>>
		<</if>>
		<<if $worn.face.type.includes("serving")>>
		<<set $tip += ((_temp_tip * 1.2) - _temp_tip)>>
		<</if>>
		<<if $worn.neck.type.includes("serving")>>
		<<set $tip += ((_temp_tip * 1.2) - _temp_tip)>>
		<</if>>
		<<if $worn.legs.type.includes("serving")>>
		<<set $tip += ((_temp_tip * 1.2) - _temp_tip)>>
		<</if>>
		<<if $worn.feet.type.includes("serving")>>
		<<set $tip += ((_temp_tip * 1.2) - _temp_tip)>>
		<</if>>
	<</if>>

<<set $tip to $tipmod * $tip>>
<<set $tip *= (1 + ($attractiveness / 10000))>>
<<if $mathstrait gte 1>>
	<<set $tip *= (1 + ($mathstrait / 4))>>
<</if>>

<<set $tip to Math.trunc($tip)>>
<<if $tip lt $tip_add>>
	<<set $tip to $tip_add>>
<</if>>
<</widget>>

<<widget "tipreceive">>
	<<if random(1, 10000) is 10000>>You gain Brouzouf<<else>>You make<</if>> <<printmoney $tip >>.
	<<set $money += $tip>>
	<<if $tip gte 50000>>
		<<earnFeat "Negotiator">>
	<</if>>
	<<set $tip to 0>>
<</widget>>

<<widget "tip_neg">>
You negotiate a price of <<printmoney $tip>>,
<<if $tipreaction is "low">>
	less than you hoped for.
<<else>>
	which sounds reasonable.
<</if>>
<</widget>>

<<widget "tip_up">>
<<He>> raises <<his>> offer to <<printmoney $tip>>.
<</widget>>

<<widget "passout">>
	<<set $stress -= 5000>>
	<<set $passoutstat += 1>>
<</widget>>

<<widget "vaginaraped">>
	<<if $angel gte 1>>
		<<set $specialTransform to 0>>
	<</if>>
	<<if $angel gte 6>>
		Your halo shatters and your wings blacken. An overwhelming sense of loss overcomes you.
		<<set $trauma to $traumamax>><<set $fallenangel to 2>><<set $specialTransform to 1>>
		<<set $transformationParts.fallenAngel.halo to "default">>
		<<set $transformationParts.fallenAngel.wings to "default">>
		<<set $transformationParts.angel.halo to "disabled">>
		<<set $transformationParts.angel.wings to "disabled">>
		<<earnFeat "Fallen Angel">>
	<<elseif $angel gte 4>>
		Your halo shatters and fades.
		<<set $transformationParts.angel.halo to "disabled">>
	<</if>>
	<<set $angel to 0>><<set $angelbuild to 0>>
	<<if $player.virginity.temple is true>>

		/*Old check, remove when not required*/
		<<set $temple_virginity to 0>>
	<</if>>
	<<set $vaginafucked to 1>>
<</widget>>

<<widget "penisraped">>
	<<if $angel gte 1>>
		<<set $specialTransform to 0>>
	<</if>>
	<<if $angel gte 6>>
		Your halo shatters and your wings blacken. An overwhelming sense of loss overcomes you.
		<<set $trauma to $traumamax>><<set $fallenangel to 2>><<set $specialTransform to 1>>
		<<set $transformationParts.fallenAngel.halo to "default">>
		<<set $transformationParts.fallenAngel.wings to "default">>
		<<set $transformationParts.angel.halo to "disabled">>
		<<set $transformationParts.angel.wings to "disabled">>
		<<earnFeat "Fallen Angel">>
	<<elseif $angel gte 4>>
		Your halo shatters and fades.
		<<set $transformationParts.angel.halo to "disabled">>
	<</if>>
	<<set $angel to 0>><<set $angelbuild to 0>>
	<<if $player.virginity.temple is true>>

		/*Old check, remove when not required*/
		<<set $temple_virginity to 0>>
	<</if>>
	<<set $penisfucked to 1>>
<</widget>>

<<widget "anusraped">>
<<set $anusfucked to 1>>
<</widget>>

<<widget "internalejac">>
	<<if $demon gte 6>>
		<<set $demonabsorb += 1>>
	<</if>>
<</widget>>

<<widget "sexcheck">>/*Sets variable to 1 if the PC is penetrated, penetrating, or similar.*/
<<if $vaginastate is "penetrated" or
$anusstate is "penetrated" or
$mouthstate is "penetrated" or
$penisstate is "otheranus" or
$penisstate is "penetrated" or
$anusstate is "othermouth" or
$vaginastate is "othermouth" or
$penisstate is "othermouth" or
$penisstate is "tentacle" or
$penisstate is "tentacledeep" or
$vaginastate is "tentacle" or
$vaginastate is "tentacledeep" or
$anusstate is "tentacle" or
$anusstate is "tentacledeep" or
$mouthstate is "tentacle" or
$mouthstate is "tentacledeep">>
<<set $current_sex to 1>>
<<else>>
<<set $current_sex to 0>>
<</if>>
<</widget>>

<<widget "textmap">>

<<if $map.movement is true and !$possessed>>
__Map__

|.....Ba ⚊ Cl ⚊ St ⚊ Me

|..╱ ╲ ╱ ╲ ╱ ╲ ╱ ╲

|Do ⚊ Co ⚊ Hi ⚊ Ox ⚊ Ha

|..╲ ╱ ╲ ╱ ╲ ╱ ╲ ╱

|.....Da ⚊ Wo ⚊ Ni ⚊ El

<<else>>
__Map__

|.....Ba ⚊ Cl ⚊ St ⚊ Me

|..╱ ╲ ╱ ╲ ╱ ╲ ╱ ╲

|Do ⚊ Co ⚊ Hi ⚊ Ox ⚊ Ha

|..╲ ╱ ╲ ╱ ╲ ╱ ╲ ╱

|.....Da ⚊ Wo ⚊ Ni ⚊ El

<</if>>

<</widget>>

<<widget map>>
	<<set $map.location to $args[0]>>
	<<if $images is 1 and $map.movement is true and $map.legacy isnot true and !$possessed>>
		<<set _boxLocations to [
			{ x: 1,		y: 46}, /*Domus				*/
			{ x: 38,	y: 9},	/*Barb				*/
			{ x: 38,	y: 83},	/*Danube			*/
			{ x: 63,	y: 46},	/*Connudatus		*/
			{ x: 88,	y: 9},	/*Cliff				*/
			{ x: 88,	y: 83},	/*Wolf				*/
			{ x: 114,	y: 46},	/*High				*/
			{ x: 146,	y: 9},	/*Starfish			*/
			{ x: 146,	y: 83},	/*Nightingale		*/
			{ x: 176,	y: 46},	/*Oxford			*/
			{ x: 204,	y: 9},	/*Mer				*/
			{ x: 204,	y: 83},	/*Elk				*/
			{ x: 230,	y: 46},	/*Harvest			*/
			{ x: 38,	y: 46},	/*Residential Alley	*/
			{ x: 88,	y: 46},	/*Commercial Alley	*/
			{ x: 146,	y: 46},	/*Park				*/
			{ x: 204,	y: 46}	/*Industrial Alley	*/
		]>>

		/*This version of sugarcube doesn't perform any processing inside of SVG elements, so we need to perform those actions ourselves inside a custom macro */
		<<svg 260 130>>
			<image x="2" xlink:href="img/misc/map.png"> </image>
			<image x="2" @xlink:href="'img/misc/maparrow' + $map.location + '.png'"> </image>

			<<for _i to 0; _i lt $map.arrayList.length; _i++>>
				<<set _canMoveTo = $debug || $map.available[$passage].includes($map.arrayList[_i])>>
				<<set _showMarker = $debug || ($map.markers && (_canMoveTo || $passage is $map.arrayList[_i]))>>

					<rect @x="_boxLocations[_i].x"
						  @y="_boxLocations[_i].y"
						  height="34"
						  width="30"
						  @style="'stroke:cyan;fill-opacity:0;stroke-opacity:' + (_showMarker ? '0.6' : '0') + ';'">
					</rect>

			<</for>>
		<</svg>>

	<<elseif $images is 1 and $map.legacy isnot true>>
		<svg width="260" height="130">
			<image x="2" xlink:href="img/misc/map.png"/>
			<image x="2" @xlink:href="'img/misc/maparrow'+$map.location+'.png'"/>
		</svg>
	<<elseif $images is 1>>
		<<if $images is 1 and $map.movement is true and !$possessed>>

			<map id="town-image-map" name="town-image-map">
				<area class="no-numberify" alt="Barb Street" title="Barb Street" coords="62,20,39,42" shape="rect" onclick="mapMove('Barb Street')">
				<area class="no-numberify" alt="Domus Street" title="Domus Street" coords="2,75,26,49" shape="rect" onclick="mapMove('Domus Street')">
				<area class="no-numberify" alt="Danube Street" title="Danube Street" coords="33,110,70,84" shape="rect" onclick="mapMove('Danube Street')">
				<area class="no-numberify" alt="Wolf Street" title="Wolf Street" coords="86,117,114,86" shape="rect" onclick="mapMove('Wolf Street')">
				<area class="no-numberify" alt="High Street" title="High Street" coords="116,77,139,46" shape="rect" onclick="mapMove('High Street')">
				<area class="no-numberify" alt="Connudatus Street" title="Connudatus Street" coords="64,77,88,49" shape="rect" onclick="mapMove('Connudatus Street')">
				<area class="no-numberify" alt="Cliff Street" title="Cliff Street" coords="88,40,117,-1" shape="rect" onclick="mapMove('Cliff Street')">
				<area class="no-numberify" alt="Starfish Street" title="Starfish Street" coords="147,41,172,12" shape="rect" onclick="mapMove('Starfish Street')">
				<area class="no-numberify" alt="Nightingale Street" title="Nightingale Street" coords="143,115,170,82" shape="rect" onclick="mapMove('Nightingale Street')">
				<area class="no-numberify" alt="Oxford Street" title="Oxford Street" coords="170,73,203,45" shape="rect" onclick="mapMove('Oxford Street')">
				<area class="no-numberify" alt="Mer Street" title="Mer Street" coords="202,42,229,14" shape="rect" onclick="mapMove('Mer Street')">
				<area class="no-numberify" alt="Elk Street" title="Elk Street" coords="197,111,238,77" shape="rect" onclick="mapMove('Elk Street')">
				<area class="no-numberify" alt="Harvest Street" title="Harvest Street" coords="252,46,228,76" shape="rect" onclick="mapMove('Harvest Street')">
				<area class="no-numberify" alt="Industrial Alley" title="Industrial Alley" coords="225,73,209,53" shape="rect" onclick="mapMove('Industrial alleyways')">
				<area class="no-numberify" alt="Park" title="Park" coords="154,65,170,52" shape="rect" onclick="mapMove('Park')">
				<area class="no-numberify" alt="Commercial Alley" title="Commercial Alley" coords="94,69,110,56" shape="rect" onclick="mapMove('Commercial alleyways')">
				<area class="no-numberify" alt="Residential Alley" title="Residential Alley" coords="38,70,57,56" shape="rect" onclick="mapMove('Residential alleyways')">
			</map>
		<</if>>

	<<else>>
		<<textmap>>
	<</if>>
<</widget>>

<<widget "rentday">>
	<<set $_text_output to  ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][$rentday-1]>>
	<<print $_text_output>>
<</widget>>

<<widget "tearup">>
	<<if $pain lte 20>>
		<<set $pain to 20>>
	<</if>>
<</widget>>

<<widget "roomoptions">>
	<<if $sexStats.pills.boughtOnce is true or $pills gte 1 or $asylumpills gte 1>>
		<<icon "pill collection">><<link [[Check your pills|PillCollection]]>><<set $pillsExitPassage to $passage>><<endevent>><</link>>

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

<<widget "christmas_options">>
<<if $christmas_wrap is 1>>
	<<switch $christmas_gift_robin>>
		<<case "shirt_unwrapped">>
			<<link [[Wrap Robin's shirt and shorts (0:10)|Bedroom Robin Wrap]]>><<pass 10>><<set $christmas_gift_robin to "shirt">><<set $christmas_gift_robin_wrapped to 1>><</link>>

		<<case "sundress_unwrapped">>
			<<link [[Wrap Robin's sundress (0:10)|Bedroom Robin Wrap]]>><<pass 10>><<set $christmas_gift_robin to "sundress">><<set $christmas_gift_robin_wrapped to 1>><</link>>

		<<case "kimono_unwrapped">>
			<<link [[Wrap Robin's kimono (0:10)|Bedroom Robin Wrap]]>><<pass 10>><<set $christmas_gift_robin to "kimono">><<set $christmas_gift_robin_wrapped to 1>><</link>>

		<<case "tuxedo_set_unwrapped">>
			<<link [[Wrap Robin's tuxedo (0:10)|Bedroom Robin Wrap]]>><<pass 10>><<set $christmas_gift_robin to "tuxedo">><<set $christmas_gift_robin_wrapped to 1>><</link>>

		<<case "gothic_gown_unwrapped">>
			<<link [[Wrap Robin's gothic gown (0:10)|Bedroom Robin Wrap]]>><<pass 10>><<set $christmas_gift_robin to "gothic gown">><<set $christmas_gift_robin_wrapped to 1>><</link>>

		<<case "christmas_unwrapped">>
			<<link [[Wrap Robin's Christmas outfit (0:10)|Bedroom Robin Wrap]]>><<pass 10>><<set $christmas_gift_robin to "christmas">><<set $christmas_gift_robin_wrapped to 1>><</link>>

	<</switch>>
	<<if $christmas_gift is "clothes_unwrapped">>
		<<link [[Wrap the orphan's gifts (3:00)|Bedroom Orphans Clothes Wrap]]>><<pass 180>><<set $christmas_gift to "clothes">><</link>>

	<</if>>
<</if>>
<<if $christmas is 1 and !$christmas_wraith>>
	<<rngWraith 1>>
<</if>>
<</widget>>

<<widget "encountersteal">>
	<<set $rng to random(1, 100)>>
	<<if $rng gte 96 and $spray lt $spraymax>>
		<<spray 1>>
		You steal a charge for your pepper spray.
		<<crimeup 50>><<combatskulduggeryskilluse>><<combatcontrol 10>><<gcombatcontrol>>
	<<elseif $rng gte 90 and $compoundstate is undefined and $compoundcard is undefined>>
		<<set $compoundcard to 1>>
		You steal a strange card. There's an address on it, for a location on Elk Street.
	<<else>>
		<<set $rng to random(5, 100)>>
		You steal £<<print $rng>>.
		<<set $money += $rng * 100>><<crimeup $rng>><<combatskulduggeryskilluse>><<combatcontrol 10>><<gcombatcontrol>>
	<</if>>
<</widget>>

<<widget "statbaricons">>
	<<if $images is 1 and $args[0]>>
		<<if $args[1] gte 1>>

		<<elseif $args[2] gte 1>>

		<</if>>
		<<if $args[1] gte 2>>

		<<elseif $args[2] gte 2>>

		<</if>>
		<<if $args[1] gte 3>>

		<<elseif $args[2] gte 3>>

		<</if>>
		<<if $args[1] gte 4>>

		<<elseif $args[2] gte 4>>

		<</if>>
		<<if $args[1] gte 5>>

		<<elseif $args[2] gte 5>>

		<</if>>
		<<if $args[1] gte 6>>

		<<elseif $args[2] gte 6>>

		<</if>>
		<<if $args[1] gte 7>>

		<<elseif $args[2] gte 7>>

		<</if>>
		<<if $args[1] gte 8>>

		<<elseif $args[2] gte 8>>

		<</if>>
		<<if $args[1] gte 9>>

		<<elseif $args[2] gte 9>>

		<</if>>
		<<if $args[1] gte 10>>

		<<elseif $args[2] gte 10>>

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

<<widget "characteristic-text">>
	<<set _config = $args[0]>>

	<<if _config.states and _config.states.length gt 0>>

		<<set _config.currentLevel = 0>>
		/* Loop through the provided states to find the one we are currently at*/
		<<for _i to 0; _i lt _config.states.length; _i++>>
			<<if _config.currentValue gte _config.states[_i].requiredValue>>
				<<set _config.currentLevel = _i>>
			<</if>>
		<</for>>

		/* Set the details to show from the current state */
		<<set _config.preText = _config.states[_config.currentLevel].preText || _config.preText>>
		<<set _config.description = _config.states[_config.currentLevel].description>>
		<<set _config.postText = _config.states[_config.currentLevel].postText || _config.postText>>
		<<set _config.color = _config.states[_config.currentLevel].color>>
	<</if>>

	<<if _config.preText>>
		_config.preText
	<</if>>
	_config.description
	<<if _config.postText>>
		_config.postText
	<</if>>
<</widget>>

<<widget "characteristic-box">>
	<<set _config = $args[0]>>
	<<if _config.states and _config.states.length gt 0>>

		<<set _config.currentLevel = 0>>
		/* Loop through the provided states to find the one we are currently at*/
		<<for _i to 0; _i lt _config.states.length; _i++>>
			<<if _config.currentValue gte _config.states[_i].requiredValue>>
				<<set _config.currentLevel = _i>>
			<</if>>
		<</for>>

		/* Set the details to show from the current state */
		<<set _config.level = 		_config.states[_config.currentLevel].level>>
		<<set _config.description = _config.states[_config.currentLevel].description>>
		<<set _config.color = 		_config.states[_config.currentLevel].color>>

		/* Determine the color of the bottom bar based on a few types, default is to match the level color */
		<<if _config.meterColorType eq 'next'>>
			<<if _config.currentLevel lt _config.states.length - 1>>
				<<set _config.meterColor = _config.states[_config.currentLevel + 1].color>>
			<<else>>
				<<set _config.meterColor = _config.states[_config.currentLevel].color>>
			<</if>>
		<<elseif _config.meterColorType eq 'prev'>>
			<<if _config.currentLevel gt 0>>
				<<set _config.meterColor = _config.states[_config.currentLevel - 1].color>>
			<<else>>
				<<set _config.meterColor = _config.states[_config.currentLevel].color>>
			<</if>>
		<<elseif _config.meterColorType eq 'max'>>
			<<if _config.currentLevel eq _config.states.length - 1>>
				<<set _config.meterColor = _config.states[_config.currentLevel].color>>
			<</if>>
		<<else>>
			<<if _config.meterColor eq undefined>>
				<<set _config.meterColor = _config.states[_config.currentLevel].color>>
			<</if>>
		<</if>>

		/* Calculate the percent to the next level based on the gap between the nearest two states */
		<<if _config.percent isnot undefined>>
			<<set _config.percent = Math.floor(_config.percent)>>
		<<else>>
			<<if _config.currentLevel eq (_config.states.length - 1)>>
				/* Calculate percentage above highest state if max value is specified */
				<<if _config.maxValue>>
					<<set _config.percent = Math.floor(100*(_config.currentValue - _config.states[_config.currentLevel].requiredValue) / (_config.maxValue - _config.states[_config.currentLevel].requiredValue))>>
				<<else>>
					<<set _config.percent = 100>>
				<</if>>
			<<else>>
				<<set _config.percent = Math.floor(100*(_config.currentValue - _config.states[_config.currentLevel].requiredValue) / (_config.states[_config.currentLevel + 1].requiredValue - _config.states[_config.currentLevel].requiredValue))>>
			<</if>>
		<</if>>

	<<else>>
		<<set _config.percent= Math.floor(_config.currentValue)>>
	<</if>>

	<<set _config.barWidth = Math.clamp(_config.percent, 0, 100)>>

			<<if $images is 1 and _config.icon>>

			<</if>>
			_config.name<<characteristic-box-modifier `clone(_config.modifier)`>>
			<<if _config.states>>
				<<if _config.displayType eq "level">>

						<big>_config.level</big>/<<print (_config.states.length - 1)>>

				<<elseif _config.displayType eq "grade">>

						_config.level <<if _config.level neq 'None'>>_config.percent%<</if>>

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

		<<if _config.description>>
			_config.description
		<</if>>
		<<if _config.showStars>>
			Daily Progress

				 0 ? 'bronze_star' : 'empty_star') + '.png'" />
				 1 ? 'silver_star' : 'empty_star') + '.png'" />
				 2 ? 'gold_star'   : 'empty_star') + '.png'" />

		<</if>>

<</widget>>

<<widget "characteristic-box-modifier">><<silently>>
<<if $args[0] isnot undefined or $args[0] isnot 100>>
	<<set $_modifier to $args[0] - 100>>
	<<if $_modifier gt 0>>
		<<set $_result to " (+"+$_modifier+"%)">>
	<<elseif $_modifier lt 0>>
		<<set $_result to " ("+$_modifier+"%)">>
	<</if>>
<</if>>
<</silently>><<if $_result>><<print $_result>><</if>>
<</widget>>

<<widget "relation-text">>
	<<set _config = $args[0]>>

	<<if _config.states and _config.states.length gt 0>>

		<<set _config.currentLevel = _config.states[0]>>
		<<if _config.currentLevel.secondaryStates>>
			<<set _config.currentLevel = _config.currentLevel.secondaryStates[0]>>
		<</if>>

		/* Loop through the provided states to find the one we are currently at*/
		<>

		/* Set the details to show from the current state */
		<<set _config.preText = 	_config.currentLevel.preText || _config.preText>>
		<<set _config.description = _config.currentLevel.description>>
		<<set _config.postText = 	_config.currentLevel.postText || _config.postText>>
		<<set _config.color = 		_config.currentLevel.color>>
	<</if>>

	<<if _config.preText>>
		_config.preText
	<</if>>
	_config.description
	<<if _config.postText>>
		_config.postText
	<</if>>
<</widget>>

<<widget "relation-box-simple">>
	<<set _boxConfig = $args[0]>>

		<<if _boxConfig.name>>

				<<if $images and _boxConfig.icon>>

				<</if>>
				_boxConfig.name

		<</if>>

			_boxConfig.description

<</widget>>

<<widget "relation-box">>
	<<silently>>
		<<set _npcData = $args[0]>>
		<<set _npcOverrides = $args[1] || {}>>

		<>
	<</silently>>
	<<if _npcData and _npcData.init is 1>>
		<<if _npcOverrides and _npcOverrides.important>>

						_npcData.nam
						The _npcData.title

					<<if _loveInterest>>

					<</if>>

					<<npcrelationship _npcData.nam>>

					<<for _j = 0; _j lt _importantNpcStats.length; _j++>>
						<<if _npcData[_importantNpcStats[_j]] gt 0 and _checkRequirements(_importantNpcStats[_j])>>
							<<relation-box-stat _getStatConfig(_importantNpcStats[_j]) true>>
						<</if>>
					<</for>>

		<<else>>

						_npcData.nam
						The _npcData.title

						<<for _j = 0; _j lt _otherNpcStats.length; _j++>>
							<<if _npcData[_otherNpcStats[_j]] gt 0 and _checkRequirements(_otherNpcStats[_j])>>
								<<relation-box-stat _getStatConfig(_importantNpcStats[_j])>>
							<</if>>
						<</for>>

					<<npcrelationship _npcData.nam>>

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

<<widget "relation-box-stat">>
	<<silently>>
		<<set _config = $args[0]>>
		<<set _important = $args[1]>>

		<<set _config.progress = Math.floor(Math.clamp(100*((_config.value - (_config.minValue || 0)) / (_config.maxValue || 100)), 0, 100))>>
	<</silently>>

		<<if _important>>
			_config.name
		<</if>>
		<<if $images>>

					<<if _config.inactiveIcon>>

					<<else>>

					<</if>>

				_config.progress%

		<<else>>
			<<if _important>>
				_config.progress%

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

<</widget>>

<<widget "connector-box">>

<</widget>>

<<widget "oralpassage">>
	<<takeVirginity $args[0] "oral">><<oralstat>><<oralejacstat>><<ejacstat>><<set $hunger -= 200>><<set $thirst -= 200>><<set $player.bodyliquid.mouth.semen += 1>>
<</widget>>

<<widget "relationshipclamp">>
	<<set _i to $NPCNameList.indexOf("Robin")>>
	<<set $NPCName[_i].love = Math.clamp($NPCName[_i].love, 0, 100)>>
	<<set $NPCName[_i].lust = Math.clamp($NPCName[_i].lust, 0, 100)>>
	<<set $NPCName[_i].trauma = Math.clamp($NPCName[_i].trauma, 0, 100)>>
	<<set $NPCName[_i].dom = Math.clamp($NPCName[_i].dom, 0, 100)>>
	<<set _i to $NPCNameList.indexOf("Whitney")>>
	<<set $NPCName[_i].love = Math.clamp($NPCName[_i].love, 0, 30)>>
	<<set $NPCName[_i].lust = Math.clamp($NPCName[_i].lust, 0, 100)>>
	<<set $NPCName[_i].dom = Math.clamp($NPCName[_i].dom, 0, 20)>>
	<<set _i to $NPCNameList.indexOf("Eden")>>
	<<set $NPCName[_i].love = Math.clamp($NPCName[_i].love, 0, 200)>>
	<<set $NPCName[_i].lust = Math.clamp($NPCName[_i].lust, 0, 100)>>
	<<set $NPCName[_i].dom = Math.clamp($NPCName[_i].dom, 0, 150)>>
	<<set _i to $NPCNameList.indexOf("Kylar")>>
	<<set $NPCName[_i].love = Math.clamp($NPCName[_i].love, 0, 100)>>
	<<set $NPCName[_i].lust = Math.clamp($NPCName[_i].lust, 0, 100)>>
	<<set $NPCName[_i].rage = Math.clamp($NPCName[_i].rage, 0, 100)>>
	<<set _i to $NPCNameList.indexOf("Avery")>>
	<<set $NPCName[_i].love = Math.clamp($NPCName[_i].love, 0, 100)>>
	<<set $NPCName[_i].rage = Math.clamp($NPCName[_i].rage, 0, 100)>>
	<<set _i to $NPCNameList.indexOf("Great Hawk")>>
	<<set $NPCName[_i].love = Math.clamp($NPCName[_i].love, 0, 100)>>
	<<set $NPCName[_i].dom = Math.clamp($NPCName[_i].dom, 0, 100)>>
	<<set _i to $NPCNameList.indexOf("Alex")>>
	<<set $NPCName[_i].love = Math.clamp($NPCName[_i].love, 0, 100)>>
	<<set $NPCName[_i].dom = Math.clamp($NPCName[_i].dom, 0, 100)>>
	<<set $NPCName[_i].lust = Math.clamp($NPCName[_i].lust, 0, 100)>>
	<<set _i to $NPCNameList.indexOf("Sydney")>>
	<<set $NPCName[_i].love = Math.clamp($NPCName[_i].love, 0, 150)>>
	<<set $NPCName[_i].lust = Math.clamp($NPCName[_i].lust, 0, 100)>>
	<<set $NPCName[_i].purity = Math.clamp($NPCName[_i].purity, 0, 100)>>
	<<set $NPCName[_i].corruption = Math.clamp($NPCName[_i].corruption, 0, 50)>>
	<<set _i to $NPCNameList.indexOf("Piper")>>
	<<set $NPCName[_i].love = Math.clamp($NPCName[_i].love, 0, 200)>>
	<<set $NPCName[_i].lust = Math.clamp($NPCName[_i].lust, 0, 100)>>
	<<set $NPCName[_i].dom = Math.clamp($NPCName[_i].dom, 0, 100)>>
<</widget>>

<<widget "fringecheck">>
	<<if $fringetype is "default">>
		<<set $fringetype to "messy">>
	<</if>>
<</widget>>

<<widget "haircheck">>
	<<if $hairtype is "default">>
		<<set $hairtype to "messy">>
	<</if>>
<</widget>>

<<widget "fringelength">>
	<<if $fringelength gte 980>>
		and your fringe is very long.
	<<elseif $fringelength gte 800>>
		and your fringe is long.
	<<elseif $fringelength gte 600>>
		and your fringe is somewhat long.
	<<elseif $fringelength gte 400>>
		and your fringe is quite normal.
	<<elseif $fringelength gte 200>>
		and your fringe is short.
	<<else>>
		and your fringe is very short.
	<</if>>
<</widget>>

<<widget "willpowerpain">>
	<<if $pain gte 100 and $willpowerpain is undefined and _willpowerpainchecked isnot true>>
		<<if ($willpower / 10) gte (($pain - 100) + random(1, 100))>>
			The pain threatens to overwhelm, but you endure it.
			<<gwillpower>><<willpower 1>>

		<<else>>
			The pain overwhelms you.
			<<if $position is "stalk">>
				You fall to your knees.
			<</if>>
			<<ggwillpower>><<willpower 5>><<set $willpowerpain to 0>>

		<</if>>
	<<set _willpowerpainchecked to true>>
	<</if>>
<</widget>>

<<widget "willpowerorgasm">>
	<<if $orgasmdown gte 1 and _willpowerorgasmchecked isnot true>>
		<<if ($willpower / 10) gte (($orgasmdown * 30) + random(1, 80))>>
			You endure the orgasmic shivers running through you.
			<<gwillpower>><<willpower 1>><<set $orgasmdown to 0>>

		<<else>>
			You struggle against the orgasmic spasms overwhelming you.
			<<if $position is "stalk">>
				You fall to your knees.
			<</if>>
			<<gwillpower>><<willpower 1>>

		<</if>>
	<<set _willpowerorgasmchecked to true>>
	<</if>>
<</widget>>

<<widget "clothescolour">><<silently>>
	<<set _slot to $args[0]>>
	<<if $worn[_slot].colour isnot 0 and $worn[_slot].colour isnot undefined>>
		<<if $worn[_slot].colour.substring(0, 3) is "wet">>
			<<set _text_output to $worn[_slot].colour.substring(3)>>
		<<elseif $worn[_slot].colour_sidebar is 1>>
			<<if $worn[_slot].colour == "custom">>
				<<set _text_output to getCustomColourName($worn[_slot].colourCustom)>>
			<<else>>
				<<set _text_output to $worn[_slot].colour>>
			<</if>>
		<</if>>
	<</if>>
<</silently>><<print _text_output>><</widget>>

<<widget "nounderwearcheck">>
	/*Checks if the PC is pantiless, but otherwise decent. Results in low level exhibitionism increases.*/
	<<if !$worn.lower.type.includes("naked") and $worn.under_lower.type.includes("naked") and $exposed lte 0 and $exhibitionism lt 19>>
		<<set $no_underwear += 1>>
	<</if>>
	<<if $no_underwear gte 8>>
		<<set $no_underwear to 0>>
		<<set $effectsmessage to 1>>
		<<set $exhibitionism_message to 1>>
	<</if>>
<</widget>>

<<widget "breastfed">>
	<<set $milk_drank_stat += random(1, 5)>>
	<<if random(1, 100) gte 70>><<transform cat 1>><</if>>
	<<if $milkdranktrait is 1>><<physique 1>><</if>>
	<<purity -1>>
	<<set $hunger -= 200>><<set $thirst -= 200>>
<</widget>>

<<widget "nectarfed">>
	<<set _nectarGain to 0>>
	<<set _nectarGain += (Math.ceil($args[0] / 10) + random(0,2))>>
	<<set $nectar_drank_stat += _nectarGain>>
	<<set $nectar_addiction += _nectarGain>>
	<<if $args[0] gte 11>>
		<<purity -1>>
	<</if>>
	<<set $hunger -= ($args[0] * 5)>><<set $thirst -= ($args[0] * 5)>>
	<<drugs $args[0]>><<set $arousal += $args[0]>>
	<<if $ejaculating is 1>>
		<<set $drunk += ($args[0] * 3)>>
		<<set $player.bodyliquid.mouth.goo += 1>>
	<</if>>
	<<if $backgroundTraits.includes("plantlover")>>
		<<if $nectar_timer lte 14>>
			You feel an overwhelming sense of relief. <<stress -12>><<llstress>><<pain -4>><<lpain>>
		<<else>>
			<<set _nectarStress to (-1 * _nectarGain)>>
			<<physique 1 "invig">><<stress _nectarStress>><<lstress>>
		<</if>>
		<<set $nectar_timer to 21>>
	<</if>>
<</widget>>

<<widget "setup_pillory">>
	<<set $pillory_tenant to {person : clone($baseNPC), exists : 0, duration : 0, served : 0, startday: 0, starthour : 0, endday : 0, endhour : 0,
								crowd : 0, wet : 0, upperexposed : 0 , lowerexposed : 0, fruit : 0, fruitstock: 0, face : 0, ass : 0, genital : 0, broken : 0,
								lastviewed : { day : 0, hour: 0}, special : {name : "", desc : ""}}>>
<</widget>>

<<widget "new_npc_pillory">>
	<<if not $args[0]>>
		<<if $rng gte 20>><<generate1>><<else>><<generatec1>><</if>>
		<<set _already_served to random(0,2)>>
	<<else>>
		<<set _already_served to 0>>
	<</if>>
	<<set $pillory_tenant.exists to 1>>
	<<set $pillory_tenant.person to clone($NPCList[0])>>
	<<set $pillory_tenant.duration to random(4,27)>>
	<<set $pillory_tenant.startday to $days>>
	<<set $pillory_tenant.starthour to ($hour - _already_served)>>
	<<set _endhour to ($pillory_tenant.starthour + $pillory_tenant.duration)>>
	<<set $pillory_tenant.endday to $days>>
	<<if _endhour gte 24>><<set $pillory_tenant.endday += 1>><<set _endhour -= 24>><</if>>
	/*Repeat incase $duration is gte 24hrs and starting time gte 21. E.g. worst case: $hour = 23 and duration=27hrs, end time should be 0200 @ +2days.
	So 23 + 27 = 50; add 1 to end-day and minus 24hrs gives 26; add 1 to end-day and minus 24 gives hr 2.*/
	<<if _endhour gte 24>><<set $pillory_tenant.endday += 1>><<set _endhour -= 24>><</if>>
	<<set $pillory_tenant.endhour to _endhour>>
	<<set $pillory_tenant.crowd to 1>>
	<<set $pillory_tenant.wet to 0>>
	<<set $pillory_tenant.upperexposed to 0>>
	<<set $pillory_tenant.lowerexposed to 0>>
	<<set $pillory_tenant.fruit to 0>>
	<<set $pillory_tenant.fruitstock to 3>>
	<<set $pillory_tenant.spank to 0>>
	<<set $pillory_tenant.face to 0>>
	<<set $pillory_tenant.ass to 0>>
	<<set $pillory_tenant.genital to 0>>
	<<set $pillory_tenant.broken to 0>>
	<<set $pillory_tenant.lastviewed.day to $days>>
	<<set $pillory_tenant.lastviewed.hour to $hour>>

	<<person1>>
	<<if $pillory_tenant.special.name is "">>
		A <<person>> <<if _already_served is 0>>is currently being locked into the pillory.<<else>>has recently been locked in the pillory.<</if>>
		<<endevent>>
		<<npc_pillory_release_schedule>>

	<<else>>
		Rumour has it <<he>> is being sent to the pillory.

		<<endevent>>
	<</if>>

<</widget>>

<<widget "imprison_whitney">>
	<<setup_pillory>>
	<<npc Whitney>>
	<<set $pillory_tenant.special.name to "Whitney">>
	<<set $pillory_tenant.special.desc to "bully">>
	<<new_npc_pillory $NPCList[0]>>
	<<endevent>>
	<<set $framed to 0>>
<</widget>>

<<widget "imprison_leighton">>
	<<setup_pillory>>
	<<npc Leighton>>
	<<set $pillory_tenant.special.name to "Leighton">>
	<<if $NPCList[0].pronoun is "f">>
		<<set $pillory_tenant.special.desc to "headmistress">>
	<<else>>
		<<set $pillory_tenant.special.desc to "headmaster">>
	<</if>>
	<<new_npc_pillory $NPCList[0]>>
	<<endevent>>
	<<set $framed to 0>>
<</widget>>

<<widget "get_pillory_npc">>
	<<set $NPCList[0] to clone($pillory_tenant.person)>><<person1>>
<</widget>>

<<widget "A_pillory_person">>
	<<get_pillory_npc>>
	<<if $pillory_tenant.special.name is "">>
		A <<person>>
	<<else>>
		$pillory_tenant.special.name
	<</if>>
<</widget>>

<<widget "The_pillory_person">>
	<<get_pillory_npc>>
	<<if $pillory_tenant.special.name is "">>
		The <<person>>
	<<else>>
		$pillory_tenant.special.name
	<</if>>
<</widget>>

<<widget "the_pillory_person">>
	<<get_pillory_npc>>
	<<if $pillory_tenant.special.name is "">>
		the <<person>>
	<<else>>
		$pillory_tenant.special.name
	<</if>>
<</widget>>

<<widget "the_pillory_person_stop">>
	<<get_pillory_npc>>
	<<if $pillory_tenant.special.name is "">>
		the <<person>>.
	<<else>>
		$pillory_tenant.special.name.
	<</if>>
<</widget>>

<<widget "the_pillory_persons">>
	<<get_pillory_npc>>
	<<if $pillory_tenant.special.name is "">>
		the <<persons>>
	<<else>>
		$pillory_tenant.special.name's
	<</if>>
<</widget>>

<<widget "pillory_type">>
	<<get_pillory_npc>>
	<<if $pillory_tenant.special.name is "">>
		<<person>>
	<<else>>
		$pillory_tenant.special.desc
	<</if>>
<</widget>>

<<widget "the_pillory_type">>
	<<get_pillory_npc>>the
	<<if $pillory_tenant.special.name is "">>
		<<person>>
	<<else>>
		$pillory_tenant.special.desc
	<</if>>
<</widget>>

<<widget "the_pillory_type_stop">>
	<<get_pillory_npc>>the
	<<if $pillory_tenant.special.name is "">>
		<<person>>.
	<<else>>
		$pillory_tenant.special.desc.
	<</if>>
<</widget>>

<<widget "the_pillory_types">>
	<<get_pillory_npc>>the
	<<if $pillory_tenant.special.name is "">>
		<<persons>>
	<<else>>
		$pillory_tenant.special.desc's
	<</if>>
<</widget>>

<<widget "npc_pillory">>
	<<A_pillory_person>> is locked in the town pillory.
	<<npc_pillory_release_schedule>>

	<<endevent>>
<</widget>>

<<widget "npc_pillory_detail">>
	<<get_pillory_npc>>
	<<A_pillory_person>> is locked in the town pillory.
	<<npc_pillory_appearance>>
	<<npc_pillory_abuse>>
	<<npc_pillory_release_schedule>>

	<<endevent>>
<</widget>>

<<widget "npc_pillory_appearance">>
	<<update_npc_pillory_appearance>>
	/*Desc*/
	<<if $daystate is "night">>
		<<if $pillory_tenant.crowd gte 10>>A huge, drunken mob surround
		<<elseif $pillory_tenant.crowd gte 6>>A large, rowdy mob crowd around
		<<elseif $pillory_tenant.crowd gte 4>>A sinister crowd huddle around
		<<else>>A small but sinister group lurk around
		<</if>>
	<<else>>
		<<if $pillory_tenant.crowd gte 10>>An excited, jeering crowd surround
		<<elseif $pillory_tenant.crowd gte 6>>A large crowd press around
		<<elseif $pillory_tenant.crowd gte 4>>A curious group hang around
		<<else>>A small group watch
		<</if>>
	<</if>><<the_pillory_type>> locked prone in the pillory.
	<<if $pillory_tenant.broken gte 32>><<He>> looks traumatised, perhaps permanently broken by the abuse <<hes>> already suffered.
	<<elseif $pillory_tenant.broken gte 16>><<He>> is weeping from the abuse <<hes>> already suffered.
	<<elseif $pillory_tenant.broken gte 8>><<He>> is sobbing from the abuse.
	<<elseif $pillory_tenant.broken gte 4>><<He>> is visibly upset, but trying hard to hide it.
	<<else>><<He>> is defiant, showing a brave face.
	<</if>>

	/*describe exposure*/
	<<if $pillory_tenant.upperexposed gte 3>>
		<<His>> $pillory_tenant.person.breastsdesc are fully exposed to the crowd.
		<<if $pillory_tenant.spank gte 8>><<His>> nipples are red from being pinched, slapped, sucked, bitten and pulled.
		<<elseif $pillory_tenant.spank gte 4>><<His>> nipples looks sore from abuse.
		<</if>>
	<<elseif $pillory_tenant.upperexposed gte 2>>
		<<if $pronoun is "f">>
			<<His>> top has been bared, with only <<his>> bra hiding <<his>> $pillory_tenant.person.breastsdesc from the crowd.
		<<else>>
			<<His>> top has been bared, fully exposing <<his>> $pillory_tenant.person.breastsdesc to the crowd.
			<<if $pillory_tenant.spank gte 8>><<His>> nipples are red from being pinched, slapped, bitten and pulled.
			<<elseif $pillory_tenant.spank gte 4>><<His>> nipples looks sore from abuse.
			<</if>>
		<</if>>
	<<elseif $pillory_tenant.upperexposed gte 1>><<His>> upper clothes have been mauled, partially exposing <<his>> <<if $pronoun is "f">>bra<<else>>$pillory_tenant.person.breastsdesc<</if>> to the crowd.
	<</if>>
	<<if $pillory_tenant.lowerexposed gte 2>><<His>> ass has <<if $pillory_tenant.upperexposed gte 1>>also<</if>> been exposed, making
		<<if $pillory_tenant.person.gender is "f">><<his>> pussy
		<<else>><<his>> $pillory_tenant.person.penisdesc
		<</if>>visible to all.
		<<if $pillory_tenant.spank gte 5>><<His>> ass shows signs of rough
			<<if $pillory_tenant.fruit gte 5>>spanking, and <<his>> <<if $pillory_tenant.face gte 2>>cum<<if $pillory_tenant.face gte 4>>-coated<<else>>-stained<</if>><</if>> face is a mess of bruises and broken fruit.
			<<else>>spanking.
			<</if>>
		<<elseif $pillory_tenant.fruit gte 6>><<His>> <<if $pillory_tenant.face gte 2>>cum<<if $pillory_tenant.face gte 4>>-coated<<else>>-stained<</if>><</if>> face is a mess of bruises and broken fruit.
		<<elseif $pillory_tenant.fruit gte 2>><<His>> <<if $pillory_tenant.face gte 2>>cum<<if $pillory_tenant.face gte 4>>-coated<<else>>-stained<</if>><</if>> face is marked by bruises and broken fruit.
		<</if>>
		<<if $pillory_tenant.ass gte 2>><<His>> ass has been raped more than
			<<if $pillory_tenant.genital gte 2>>once, and
				<<if $pillory_tenant.person.gender is "m">>slime coats <<his>> <<print either("raw","abused","sorry")>> penis.
				<<else>>semen <<if $pillory_tenant.genital gte 4>>pours<<else>>drips<</if>> from <<his>> <<print either("raw","reddened","abused")>> pussy.
				<</if>>
			<<else>>once.
			<</if>>
		<<elseif $pillory_tenant.genital gte 5>><<His>> <<if $pillory_tenant.person.gender is "m">>penis<<else>>pussy<</if>> has been raped raw.
		<<elseif $pillory_tenant.genital gte 2>><<He>> has been raped more than once.
		<</if>>
	<<elseif $pillory_tenant.lowerexposed gte 1>>
		<<His>> <<if $pronoun is "f">>dress has been pulled up over <<his>> waist,<<else>>trousers have been pulled down,<</if>>
		exposing <<his>> underwear to the crowd.
	<<elseif $pillory_tenant.wet is 2>><<His>> clothes are see-through from the rain.
	<<elseif $pillory_tenant.wet is 1>><<His>> clothes are semi-translucent from damp, but are drying out.
	<</if>>
	<<if $pillory_tenant.upperexposed is 0 and $pillory_tenant.lowerexposed is 0 and $pillory_tenant.face is 0 and $pillory_tenant.fruit gte 1>>
		<<if $pillory_tenant.fruit gte 6>><<His>> face is a mess of bruises and broken fruit.
		<<elseif $pillory_tenant.fruit gte 2>><<His>> face is marked by bruises and broken fruit.
		<</if>>
	<</if>>
<</widget>>

<<widget "update_npc_pillory_appearance">>
	<<if ($pillory_tenant.lastviewed.day isnot $days) or ($hour gte $pillory_tenant.lastviewed.hour + 2)>>
		/* last viewed time tracked to avoid this firing on every viewing */
		<<set $pillory_tenant.lastviewed.day to $days>>
		<<set $pillory_tenant.lastviewed.hour to $hour>>

		/*Weather effects*/
		<<if $weather is "rain">><<set $pillory_tenant.wet to 2>>
		<<elseif $pillory_tenant.wet is 2>><<set $pillory_tenant.wet to 1>>
		<<else>><<set $pillory_tenant.wet to 0>>
		<</if>>

		/*Chance of abuse based on crowd and time passed*/
		<<if $days - $pillory_tenant.startday is 2>><<set _chance to 24>>
		<<elseif $days - $pillory_tenant.startday is 1>><<set _chance to 12>>
		<<else>><<set _chance to ($hour - $pillory_tenant.starthour)>>
		<</if>>
		<<set _chance *= $pillory_tenant.crowd>>
		/*increased by spectacle*/
		<<set _factor to ($pillory_tenant.upperexposed + $pillory_tenant.lowerexposed + $pillory_tenant.fruit
							+ $pillory_tenant.spank + $pillory_tenant.face + $pillory_tenant.ass + $pillory_tenant.genital)>>
		<<if $daystate is "night">><<set _factor += 3>><</if>>
		<<if $pillory_tenant.wet is 2>><<set _factor += 4>><</if>>
		<<set _prob to (_chance * _factor)>>

		/*Out of sight changes to tenant */
		<<set $rng to random(0,100)>>
		<<if $rng gte (40 - _prob)>><<set $pillory_tenant.fruit += 1>><</if>>
		<<set $rng to random(0,100)>>
		<<if $rng gte (60 - _prob)>><<set $pillory_tenant.crowd += 2>><</if>>
		<<set $rng to random(0,100)>>
		<<if $rng gte (60 - _prob)>><<set $pillory_tenant.upperexposed += 1>><</if>>
		<<set $rng to random(0,100)>>
		<<if $rng gte (80 - _prob)>><<set $pillory_tenant.lowerexposed += 1>><</if>>
		<<set $rng to random(0,100)>>
		<<if $rng gte (100 - _prob)>><<set $pillory_tenant.crowd += 2>><</if>>
		<<set $rng to random(0,100)>>
		<<if $rng gte (100 - _prob)>><<set $pillory_tenant.fruit += 2>><<set $pillory_tenant.face += 1>><</if>>
		<<set $rng to random(0,100)>>
		<<if $rng gte (100 - _prob) and $pillory_tenant.lowerexposed gte 2>><<set $pillory_tenant.spank += 2>><<else>><<set $pillory_tenant.spank += 1>><</if>>
		<<set $rng to random(0,100)>>
		<<if $rng gte (100 - _prob) and $pillory_tenant.lowerexposed gte 2>><<set $pillory_tenant.genital += 1>><</if>>
		<<set $rng to random(0,100)>>
		<<if $rng gte (100 - _prob) and $pillory_tenant.lowerexposed gte 2>><<set $pillory_tenant.ass += 1>><</if>>

		/*lock down exposure and replenish fruit */
		<<if $pillory_tenant.upperexposed gte 3>><<if $pillory_tenant.person.gender is "f" or $pillory_tenant.person.pronoun is "f">><<set $pillory_tenant.upperexposed to 3>><<else>><<set $pillory_tenant.upperexposed to 2>><</if>><</if>>
		<<if $pillory_tenant.lowerexposed gt 2>><<set $pillory_tenant.lowerexposed to 2>><</if>>
		<<set $pillory_tenant.fruitstock to 3>>
		<<set $pillory_tenant.broken += ($pillory_tenant.ass + $pillory_tenant.genital + $pillory_tenant.face + $pillory_tenant.fruit + $pillory_tenant.spank)>>
	<</if>>
<</widget>>

<<widget "npc_pillory_abuse">>

	<<if ($pillory_tenant.lastviewed.day isnot $days) or ($hour gte $pillory_tenant.lastviewed.hour + 1)>>
		<<set $pillory_tenant.lastviewed.hour to $hour>>
		<<set $rng to random(1,100)>><<generate2>><<person2>>
		<<set _ly to either("violently","openly","angrily","furiously","cheekily","repeatedly","clumsily","roughly","theatrically","dutifully","merrily","gleefully","drunkenly","ineptly")>>
		<<if $daystate isnot "night">>
			<<if $rng gte 56>> /* 45% chance of jeer and shout only, 55% chance of something active */
				A number of people, led by a <<person>> jeer and shout abuse at the prisoner.
			<<elseif $rng gte 41>> /* 15% */
				<<set $rng to random(1,100)>>
				<<if $pillory_tenant.person.pronoun is "f" and $rng gte 40>> /* 60% if upper-exposed F */
					A <<person>> in rough farmer clothes approaches the pillory with a bucket.
					Setting the bucket underneath <<the_pillory_types>> chest, <<person2>><<he>>
					<<if $pillory_tenant.upperexposed lte 1>>displaces the prisoner's top,<</if>>
					<<if $pillory_tenant.upperexposed lte 2>><<set $pillory_tenant.upperexposed to 3>> slips off her bra,<</if>>
					grabs <<the_pillory_types>> $pillory_tenant.person.breastsdesc and sets about trying to milk her into the bucket.

					<<if $rng % 3 is 0>>
						<<if $rng % 2>>
							Milk bursts from her breasts. Smiling, the farmer soon builds up a rhythm, adeptly milking both breasts.

							"Good cow," the farmer ruffles <<the_pillory_persons>> hair before leaving with an almost full bucket.
						<<else>><<set $pillory_tenant.spank += 1>>
							Milk dribbles from <<the_pillory_types>> breasts. With a lot of persistent squeezing and nipple pulling the farmer is eventually
							able to	get a fair amount of milk from the prisoner. Her $pillory_tenant.person.breastsdesc look raw and painful afterward.

							The farmer pats the prisoner's head before leaving with <<person2>><<his>> half-filled bucket.
						<</if>>
					<<else>><<set $pillory_tenant.spank += 1>>
						Despite increasingly rough squeezing and pulling on her nipples, no milk is forthcoming.
						<<if $rng % 2>>
							Finally giving up, the <<person2>><<person>> pats her head. "Poor girl. You're all dried up."

							<<He>> walks behind <<the_pillory_type>> and
							<<if $pillory_tenant.lowerexposed lte 1>>strips <<his>> <<print either("silk panties","plain panties","tattered undies","boyshorts")>>,
							<<else>>holds <<his>> butt-cheeks spread apart<</if>> exposing <<if $pillory_tenant.person.gender is "f">><<his>> pussy <<else>><<his>> ass <</if>>to all.

							"This cow's dry," <<person2>><<he>> calls out to the crowd. <<if $pillory_tenant.person.gender is "f">>"Wants someone to put a calf in her."<<else>>"Wants someone to fill her up."<</if>>

							<<He>> walks away with <<his>> empty bucket.
							<<set $pillory_tenant.lowerexposed to 2>>
						<<else>>
							Finally giving up, the farmer walks away with <<his>> empty bucket.
						<</if>>

					<</if>>
				<<elseif $pillory_tenant.person.gender is "m" and $rng gte 40>>
					A <<person>> in rough farmer clothes approaches the pillory with a clear glass.

					Setting the glass underneath <<the_pillory_types>> groin, <<person2>><<he>>
					<<if $pillory_tenant.lowerexposed lte 0>><<if $pillory_tenant.person.pronoun is "m">>pulls down the prisoner's trousers,<<else>>hitches up the prisoner's skirt,<</if>><</if>>
					<<if $pillory_tenant.lowerexposed lte 1>><<set $pillory_tenant.lowerexposed to 2>><<if $pillory_tenant.person.pronoun is "m">> removes his underpants, <<else>> pulls down her panties, <</if>><</if>>
					grabs the prisoner's $pillory_tenant.person.penisdesc and starts to rub.
					The prisoner looks shocked, then angry, then conflicted, and then shocked again as <<person1>><<he>> cums into a glass in front of a jeering crowd.
					<<person2>>
					<<if $rng % 3>>
						The farmer glances in the glass and then starts again. Seemingly an 'old hand,' <<he>> starts to browse <<his>> phone with
						one hand, while bringing <<the_pillory_type>> to several more orgasms with the other.

						Ten minutes later, the farmer is walking off with a glassful of ejaculate, while <<the_pillory_person>> hangs in the pillory, <<his>> face
						flickering between shock, shame, pain and satiation.
					<<else>><<set $pillory_tenant.spank += 1>>
						The farmer browses <<his>> phone with one hand, while trying to bring <<the_pillory_type>> back to orgasm with the other.

						After a minute or so, the farmer looks confused, then annoyed at <<the_pillory_persons>> lack of response.
						The <<person2>><<person>> pulls a device from <<his>> pocket. <<He>> clips one end of the device to the base of <<the_pillory_types>> penis,
						and slides the other deep into the prisoner's anus.

						The farmer presses a button and with a loud electric crackle, <<the_pillory_person>> yelps, jerks and starts to orgasm continually.

						After about 20 seconds of phone browsing the <<person2>><<person>> turns the device off, glances at the glass, and nods.

						The crowd are engrossed as the farmer repeats this process several more times, until finally the farmer is walking away with a
						glassful of ejaculate, while <<the_pillory_person>> hangs limp in the pillory, <<his>> face twitching with pain, shame and a strange satiation.
					<</if>>

				<<elseif $pillory_tenant.person.gender is "f" and $rng gte 20>>
					A <<person>> in rough farmer clothes approaches the pillory with a glass beaker.

					Setting the beaker underneath <<the_pillory_types>> groin, <<person2>><<he>>
					<<if $pillory_tenant.lowerexposed lte 0>><<if $pillory_tenant.person.pronoun is "f">>hitches up the prisoner's skirt,<<else>>pulls down the prisoner's trousers,<</if>><</if>>
					<<if $pillory_tenant.lowerexposed lte 1>><<set $pillory_tenant.lowerexposed to 2>><<if $pillory_tenant.person.pronoun is "f">> pulls down her panties,<<else>> removes his underpants,<</if>><</if>>
					grabs the prisoner's pussy and starts to rub.
					After a moment's shock, <<the_pillory_person>> pouts and resigns <<himself>> to this debasement. That's when <<he>> feels cold metal shoved up
					<<his>> pussy. A moment later panic crosses <<his>> face as something is clamped to <<his>> clit, and almost instantly waves of electricity hit <<him>>.

					The crowd are engrossed as <<the_pillory_person>> writhes in orgasm after shuddering orgasm. The farmer barely pays attention, holding
					the beaker close underneath to catch <<the_pillory_persons>> fluids, while browsing <<person2>><<his>> phone.
					At last, the farmer turns off and extracts <<his>> machine. <<Hes>> still browsing <<his>> phone as <<he>> walks away with a
					full beaker of fluids.

					<<The_pillory_person>> looks mortified, <<his>> face flitting between shock, shame and sexual exhaustion.
				<<else>>
					<<if $month is "may" or $month is "june" or $month is "july" or $month is "august" and $rng % 4>>
						<<set _bug to either("bee","wasp","bumblebee")>>
						<<The_pillory_person>> shouts and helplessly wriggles and flaps as a _bug starts to circle <<him>>.

						<<if $rng % 3 is 0>>
							A kindly spectator waves the _bug away.
						<<elseif $rng % 3 is 1>>
							The crowd jeer and laugh. Eventually the _bug loses interest and flies away.
						<<else>>
							<<if $pillory_tenant.lowerexposed is 2 and $rng % 2>>
								<<if $pronoun is "m">><<set _part to either("butt","upper leg","inner thigh","dick","balls","hip")>>
								<<else>><<set _part to either("ass","leg","inner thigh","pussy","hip")>>
								<</if>>
							<<elseif $pillory_tenant.upperexposed gte 3 and $pronoun is "f">>
								<<set _part to either("breast","nipple","armpit","ribs","midriff","back")>>
							<<elseif $pillory_tenant.upperexposed gte 2>>
								<<set _part to either("chest","armpit","ribs","belly","back")>>
							<<else>>
								<<set _part to either("arm","shoulder","cheek","leg","waist","wrist","elbow")>>
							<</if>>
							<<He>> <<print either("yells","screams","whines","cries")>> as it lands on <<his>> _part and stings <<him>>.
						<</if>>
					<<else>>
						A furious <<if $pronoun is "m">>monk<<else>>nun<</if>> from the temple scolds the crowd for preying on the morally sick.
						Many people look ashamed and some leave.
						<<set $pillory_tenant.crowd -= 1>>
						<<if $pillory_tenant.upperexposed + $pillory_tenant.lowerexposed gte 1>>
							<<set $pillory_tenant.upperexposed to 0>><<set $pillory_tenant.lowerexposed to 0>>
							The <<if $pronoun is "m">>monk<<else>>nun<</if>> finally restores <<the_pillory_types>> dignity by replacing <<his>> clothes.
						<</if>>
					<</if>>
				<</if>>
			<<elseif $rng gte 36>> /* 5% */
				A <<person>> throws fruit at <<the_pillory_type_stop>> Unable to move or defend, it hits <<him>> directly in the face.
				It looks painful, especially as <<he>> cannot wipe the acids out of <<his>> eyes.
				<<set $pillory_tenant.fruit += 1>>
			<<elseif $rng gte 26>> /* 10% */
				A <<person>> throws fruit at <<the_pillory_type>> but misses completely.
			<<elseif $rng gte 16>> /* 10% */
				A <<person>> walks up to the pillory and _ly fondles <<the_pillory_types>> <<if $pronoun is "f">>breasts.<<else>>balls.<</if>>
			<<elseif $rng gte 11 and $pillory_tenant.upperexposed lt 3>>/* 5% */
				A <<person>> walks up to <<the_pillory_type>> and
				<<if $pillory_tenant.upperexposed is 2>>
					<<if $pronoun is "f">>
					_ly removes <<his>> bra, fully exposing <<his>> $pillory_tenant.person.breastsdesc to a jeering crowd.
					<<else>>
					_ly twists <<his>> nipples.
					<<set $pillory_tenant.spank += 1>>
					<</if>>
				<<elseif $pillory_tenant.upperexposed is 1>>
					<<if $pronoun is "f">>
					fully removes <<his>> top, leaving <<him>> with <<his>> bra exposed to the jeering crowd.
					<<else>>
					fully removes <<his>> top, exposing <<his>> naked $pillory_tenant.person.breastsdesc to the jeering crowd.
					<</if>>
				<<else>>
					<<if $pronoun is "f">>
					lifts <<his>> top, partially exposing <<his>> bra to a jeering crowd.
					<<else>>
					lifts <<his>> top, exposing much of <<his>> chest to the jeering crowd.
					<</if>>
				<</if>><<set $pillory_tenant.upperexposed += 1>>
			<<elseif $rng gte 6 and $pillory_tenant.lowerexposed lt 2>>/* 5% */
				A <<person>> walks up to <<the_pillory_person>> and
				<<if $pillory_tenant.lowerexposed is 1>>
					<<if $pillory_tenant.person.gender is "f">>removes <<the_pillory_types>> underwear, fully exposing <<his>> ass and pussy to the jeering crowd.
					<<else>>fully removes <<the_pillory_types>> underwear, exposing <<his>> ass and <<his>> $pillory_tenant.person.penisdesc to the jeering crowd.
					<</if>>
				<<else>>
					<<if $pronoun is "f">>lifts <<the_pillory_types>> skirt,<<else>>pulls down <<his>> trousers,<</if>> exposing <<his>> underwear to a jeering crowd.
				<</if>><<set $pillory_tenant.lowerexposed += 1>>
			<<else>><<set $pillory_tenant.spank += 1>>/* 5% */
				A <<person>> walks up to <<the_pillory_type>> and spanks <<him>> hard on the ass. The thwack echoes across the street.
			<</if>>
		<<else>> /*night*/
			<<if $rng gte 86>> /* 15% chance of jeer and shout only, 85% chance of something active */
				A number of people, led by a <<person>> jeer and shout at the prisoner.
			<<elseif $rng gte 81>> /* 5% */
				A <<person>> throws fruit at <<the_pillory_type_stop>> Unable to move or defend <<himself>>, it hits <<the_pillory_person>> directly in the face. There is a loud cheer.
				It looks painful, especially as <<he>> cannot wipe the acids out of <<his>> eyes.
				<<set $pillory_tenant.fruit += 1>>
			<<elseif $rng gte 76>> /* 5% */
				A <<person>> throws fruit at <<the_pillory_type>> but misses completely.
			<<elseif $pillory_tenant.person.pronoun is "f" and $pillory_tenant.upperexposed lt 3>>
				<<set $pillory_tenant.upperexposed to 3>>
				A <<person>> walks up to the helpless <<pillory_type>> and displaces all <<his>> upper clothes, fully baring <<his>> <<if $pronoun is "f">>$pillory_tenant.person.breastsdesc<<else>>chest<</if>> to the crowd.
			<<elseif $pillory_tenant.person.pronoun is "m" and $pillory_tenant.upperexposed lt 2>>
				<<set $pillory_tenant.upperexposed to 2>>
				A <<person>> walks up to the helpless <<pillory_type>> and displaces all <<his>> upper clothes, fully baring <<his>> <<if $pronoun is "f">>$pillory_tenant.person.breastsdesc<<else>>chest<</if>> to the crowd.
			<<elseif $pillory_tenant.lowerexposed lt 2>>
				<<set $pillory_tenant.lowerexposed to 2>>
				A <<person>> walks up to the helpless <<pillory_type>> and displaces all <<his>> lower clothes, fully baring <<his>> <<if $pillory_tenant.person.gender is "f">>pussy<<else>>$pillory_tenant.person.penisdesc<</if>> to the crowd. There is a loud cheer.
			<<elseif $rng gte 66>> /* 10% */
				A <<person>> tries to incite a nearby dog to mount the prisoner's naked backside. It
				<<if $rng % 2>>gives <<the_pillory_persons>> ass a few tentative sniffs, but
				<</if>>is not interested.
			<<elseif $rng gte 56>> /* 10% */
				<<set $pillory_tenant.spank += 1>>
				A <<person>> sneaks up behind the pillory and _ly slaps <<the_pillory_types>> exposed <<if $pillory_tenant.person.gender is "f">>cunt.<<else>>balls.<</if>> The crowd jeer and laugh as <<he>> howls in pain.
			<<elseif $rng gte 41>> /* 15% */
				<<set $pillory_tenant.face += 1>>
				A <<person>> walks in front of the pillory and _ly masturbates in front of <<the_pillory_type_stop>>
				<<person2>><<if $pronoun is "m">>Cum soon splatters across <<the_pillory_persons>> face.
				<<else>><<He>> grinds <<his>> cunt against <<the_pillory_persons>><<person2>> face as <<he>> orgasms.
				<</if>> The crowd cheer and laugh.
			<<elseif $rng gte 31>> /* 10% */
				<<set $pillory_tenant.ass += 1>>
				A <<person>> walks behind the pillory and _ly <<if $pronoun is "m">>rapes<<else>>fingers<</if>> <<the_pillory_types>> asshole. The crowd cheer <<person2>><<him>> on.
			<<elseif $rng gte 21>> /* 10% */
				<<set $pillory_tenant.genital += 1>>
				A <<person>> walks behind the pillory and _ly rapes <<if $pronoun is "m">><<the_pillory_person_stop>><<else>><<the_pillory_person>> with a strap-on.<</if>><<person2>> The crowd take pictures and cheer <<him>> on.
			<<elseif $rng gte 11>> /* 10% */
				<<set $pillory_tenant.genital += 1>><<set $pillory_tenant.ass += 1>>
				The crowd watch and photograph as a stray dog _ly rapes <<the_pillory_person_stop>> A <<person2>><<person>> rewards the dog with a <<print either("biscuit.","pat on the head.","sweet.","cream bun.")>>

				The crowd enjoys such a perverted spectacle.
			<<elseif $rng gte 6>> /* 5% */
				<<set $pillory_tenant.ass += 1>><<set $pillory_tenant.face += 1>>
				<<if $rng % 3 is 0>>A couple of off-duty police approach. They make a <<person>> record as they<<else>>Two men approach. Together they<</if>>
				<<if $pillory_tenant.person.gender is "m">>anally-<<else>>_ly <</if>>spit-roast <<the_pillory_person_stop>> The crowd enjoys the spectacle.
			<<else>> /* 5% */
				<<set $pillory_tenant.spank += 1>>
				A <<person>> walks up to <<the_pillory_type>> and spanks <<him>> hard on the ass. The thwack echoes across the street.
			<</if>>
		<</if>>
	<<else>>/* already abused this hour - no action, don't want spamming this scene to accelerate things ridiculously */
		The people around <<print either("jeer at","laugh at","point at","shout abuse at","taunt","mock","leer at")>>
		<<if $weekday isnot 1 and $weekday isnot 7 and (($hour gte 7 and $hour lte 8) or ($hour is 15)) and $schoolday is 1 and $rng lte 34>>
			<<the_pillory_type_stop>> A group of students from the nearby school pass by, gaping at
			<<if $pillory_tenant.lowerexposed gte 2 or $pillory_tenant.upperexposed gte 3>>the lewdly exposed prisoner.
				<<if $rng % 3 is 0>>
				An outraged bystander runs up to the pillory and replaces <<the_pillory_types>> clothes.
				<<set $pillory_tenant.lowerexposed to 0>><<set $pillory_tenant.upperexposed to 0>><</if>>
			<<else>>the prisoner.
			<</if>>
		<<elseif $daystate isnot "night">>
			<<if $rng lte 80>>
				<<the_pillory_type>> and <<print either("mutter among themselves.","take photos.","amuse themselves.")>>
			<<elseif $rng lte 93>>
				<<the_pillory_type_stop>> Some get bored and leave.
				<<set $pillory_tenant.crowd -= 1>>
			<<else>>
				<<the_pillory_type_stop>> A bus drops some people off nearby. A few join the crowd around the pillory.
				<<set $pillory_tenant.crowd += 1>>
			<</if>>
		<<else>>
			<<if $rng lte 67>>
				<<if $pillory_tenant.lowerexposed gte 2 and $rng % 4 is 0>><<the_pillory_type>> and take selfies posing around <<his>> exposed, naked ass.
				<<else>><<the_pillory_type>> and <<print either("mutter darkly.","drink.","throw empty beer cans.","make sinister threats.","take selfies with the prisoner.","tell dirty jokes.")>>
				<</if>>
			<<elseif $rng lte 85>>
				<<the_pillory_type_stop>> Some get tired and leave.
				<<set $pillory_tenant.crowd -= 1>>
			<<else>>
				<<the_pillory_type_stop>> A few people passing by join the crowd around the pillory.
				<<set $pillory_tenant.crowd += 1>>
			<</if>>
		<</if>>
	<</if>>
	<<if $pillory_tenant.upperexposed gte 3>><<if $pillory_tenant.person.gender is "f" or $pillory_tenant.person.pronoun is "f">><<set $pillory_tenant.upperexposed to 3>><<else>><<set $pillory_tenant.upperexposed to 2>><</if>><</if>>
	<<if $pillory_tenant.lowerexposed gt 2>><<set $pillory_tenant.lowerexposed to 2>><</if>>
<</widget>>

<<widget "npc_pillory_release_schedule">>
	<<get_pillory_npc>>

	<<if $days is $pillory_tenant.endday>>
	<<set _a_few to ($pillory_tenant.endhour - $hour)>>
		<<He>> will be released
		<<if _a_few gt 0>>in _a_few hours.
		<<else>>imminently.
		<</if>>
	<<else>>
		<<set _days_left to ($pillory_tenant.endday - $days)>>
		<<He>> is scheduled for release <<if _days_left is 1>>tomorrow<<else>>in two days<</if>> at
		<<switch $pillory_tenant.endhour>>
			<<case 0>>midnight.
			<<case 12>>noon.
			<<default>><<ampm $pillory_tenant.endhour>>.
		<</switch>>
	<</if>>
	<<endevent>>
<</widget>>

<<widget "end_npc_pillory">>
	<<get_pillory_npc>>
	<<if $minute lte 15>>
		A police officer <<print either("is releasing","has just released","is struggling to release","is about to release")>>
		<<the_pillory_person>> from the pillory. <<if $weather is "rain">><<His>> clothes are see-through from the rain.<<elseif $weather is "snow">><<He>> shivers in the cold.<</if>>
	<<elseif $minute lte 30>>
		<<The_pillory_person>> staggers away from the pillory with <<print either("tears","defiance","signs of trauma","fury")>> in <<his>> eyes.
		<<if $weather is "rain">><<His>> clothes are see-through from the rain.<</if>>
	<<else>>
		<<The_pillory_person>> was released and has left. A couple of civil servants clean the pillory.
	<</if>>
	<<set $rng += $pillory_tenant.duration>>
	<<if $rng gte 67 or $rng gte 33 and $weather is "rain">>A large crowd jeers and shouts.<</if>>

	<<setup_pillory>>
	<<endevent>>
<</widget>>

<<widget "drench">>

<<set $hygiene to 3000>>
<<set _i = Math.clamp($args[1], 0, 5)>>

<<if $args[0] is "goo" or $args[0] is "both">>
	<<set $player.bodyliquid.neck.goo += _i>>
	<<set $player.bodyliquid.rightarm.goo += _i>>
	<<set $player.bodyliquid.leftarm.goo += _i>>
	<<set $player.bodyliquid.thigh.goo += _i>>
	<<set $player.bodyliquid.bottom.goo += _i>>
	<<set $player.bodyliquid.tummy.goo += _i>>
	<<set $player.bodyliquid.chest.goo += _i>>
	<<set $player.bodyliquid.face.goo += _i>>
	<<set $player.bodyliquid.hair.goo += _i>>
	<<set $player.bodyliquid.feet.goo += _i>>
	<<if $player.vaginaExist>>
		<<if $args[2] isnot "outside">>
			<<set $player.bodyliquid.vagina.goo += _i>>
		<</if>>
		<<set $player.bodyliquid.vaginaoutside.goo += _i>>
	<</if>>
	<<if $player.penisExist>>
		<<set $player.bodyliquid.penis.goo += _i>>
	<</if>>
	<<if $args[2] isnot "outside">>
		<<set $player.bodyliquid.anus.goo += _i>>
		<<set $player.bodyliquid.mouth.goo += _i>>
	<</if>>
<</if>>

<<if $args[0] isnot "goo">>
	<<set $player.bodyliquid.neck.semen += _i>>
	<<set $player.bodyliquid.rightarm.semen += _i>>
	<<set $player.bodyliquid.leftarm.semen += _i>>
	<<set $player.bodyliquid.thigh.semen += _i>>
	<<set $player.bodyliquid.bottom.semen += _i>>
	<<set $player.bodyliquid.tummy.semen += _i>>
	<<set $player.bodyliquid.chest.semen += _i>>
	<<set $player.bodyliquid.face.semen += _i>>
	<<set $player.bodyliquid.hair.semen += _i>>
	<<set $player.bodyliquid.feet.semen += _i>>
	<<if $player.vaginaExist>>
		<<if $args[2] isnot "outside">>
			<<set $player.bodyliquid.vagina.semen += _i>>
		<</if>>
		<<set $player.bodyliquid.vaginaoutside.semen += _i>>
	<</if>>
	<<if $player.penisExist>>
		<<set $player.bodyliquid.penis.semen += _i>>
	<</if>>
	<<if $args[2] isnot "outside">>
		<<set $player.bodyliquid.anus.semen += _i>>
		<<set $player.bodyliquid.mouth.semen += _i>>
	<</if>>
<</if>>

<</widget>>

<<widget "awarenessup">>
<<set _awareness to $args[1]>>
<<if $awareness gte $args[0]>>
It's nothing you weren't aware of.
<<else>>
<<gawareness>><<awareness _awareness>>
<</if>>
<</widget>>

<<widget "linkradiogroup">>
	<<set _receiver_name to $args[0]>>
	<<set _possible_values_by_label to $args[1]>>
	<<set _set_value to State.getVar(_receiver_name)>>

		<<for _label, _value range _possible_values_by_label>>
			<<capture _receiver_name, _value>>
				<<link _label>>
					<<run State.setVar(_receiver_name, _value)>>
					<<run Engine.show()>>
				<</link>>
			<</capture>>
			|
		<</for>>

<</widget>>

<<widget "radiogroup">>
	<<set _receiver_name to $args[0]>>
	<<set _possible_values_by_label to $args[1]>>
	<<set _set_value to State.getVar(_receiver_name)>>

	<<for _label, _value range _possible_values_by_label>>

		<<if _set_value is _value>>
			<<radiobutton _receiver_name _value checked>>
		<<else>>
			<<radiobutton _receiver_name _value>>
		<</if>>
		_label

	<</for>>
<</widget>>

<<widget "settextcolorfromfemininity">>
	<<if $args[0] gt 0>>
		<<set _text_color to "pink">>
	<<elseif $args[0] lt 0>>
		<<set _text_color to "lblue">>
	<<else>>
		<<set _text_color to "">>
	<</if>>
<</widget>>

<<widget "settextcolorfromgender">>
	<<if $args[0] is "f">>
		<<set _text_color to "pink">>
	<<elseif $args[0] is "m">>
		<<set _text_color to "lblue">>
	<<else>>
		<<set _text_color to "">>
	<</if>>
<</widget>>

<<widget "cheatStart">>
<<set $cheatdisable to "f">><<set $money to 500000>>
<</widget>>

<<widget "swim_check">>
<<if ($worn.upper.type.includes("naked") or $worn.upper.type.includes("swim")) and
($worn.lower.type.includes("naked") or $worn.lower.type.includes("swim")) and
($worn.under_upper.type.includes("naked") or $worn.under_upper.type.includes("swim")) and
($worn.under_lower.type.includes("naked") or $worn.under_lower.type.includes("swim"))>>
	<<set _swim_check to 1>>
<</if>>
<</widget>>

<<widget "skulduggeryuse">>
<<if $skulduggery lte ($skulduggerydifficulty + 100)>>
	<<skulduggeryskilluse>>
<<else>>
	That was too easy. You didn't learn anything.

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

<<widget "wetness_init">>
<<if $objectVersion.vaginaWetness lt 3 or $objectVersion.vaginaWetness is undefined>>
	<<set $vaginaWetness to 0>>
	<<set $trackedArousal to [0]>>
	<<set $masturbation_vaginaFluid to 0>>
	<<set $vaginaArousalWetness to 0>>
	<<set $timeSinceArousal to 0>>

	<<set $objectVersion.vaginaWetness to 3>>
<</if>>
<</widget>>

<<widget "transform">>/*First arg is transformation, second is the intensity of change.*/
<<if $args[1]>>
	<<if $args[0] is "wolf">>
		<<set $wolfbuild += $args[1]>>
		<<set $wolfbuild = Math.clamp($wolfbuild, 0, 100)>>
	<</if>>
	<<if $args[0] is "cat">>
		<<set $catbuild += $args[1]>>
		<<set $catbuild = Math.clamp($catbuild, 0, 100)>>
	<</if>>
	<<if $args[0] is "cow">>
		<<set $cowbuild += $args[1]>>
		<<set $cowbuild = Math.clamp($cowbuild, 0, 100)>>
	<</if>>
	<<if $args[0] is "bird">>
		<<set $birdbuild += $args[1]>>
		<<set $birdbuild = Math.clamp($birdbuild, 0, 100)>>
	<</if>>
	<<if $args[0] is "bunny">>
		<<set $bunnybuild += $args[1]>>
		<<set $bunnybuild = Math.clamp($bunnybuild, 0, 100)>>
	<</if>>
<</if>>
<<if $args[1] gte 1>>
	<<if $args[0] isnot "wolf" and $worn.neck.name isnot "spiked collar" and !_wolfseal>>
		<<set $wolfbuild -= $args[1]>>
		<<set $wolfbuild = Math.clamp($wolfbuild, 0, 100)>>
	<</if>>
	<<if $args[0] isnot "cat" and $worn.neck.name isnot "cat bell collar" and !_catseal>>
		<<set $catbuild -= $args[1]>>
		<<set $catbuild = Math.clamp($catbuild, 0, 100)>>
	<</if>>
	<<if $args[0] isnot "cow" and $worn.neck.name isnot "cow bell" and !_cowseal>>
		<<set $cowbuild -= $args[1]>>
		<<set $cowbuild = Math.clamp($cowbuild, 0, 100)>>
	<</if>>
	<<if $args[0] isnot "bird" and $worn.head.name isnot "feathered hair clip" and !_birdseal>>
		<<set $birdbuild -= $args[1]>>
		<<set $birdbuild = Math.clamp($birdbuild, 0, 100)>>
	<</if>>
	<<if $args[0] isnot "bunny" and $worn.neck.name isnot "bunnycollar" and !_bunnyseal>>
		<<set $bunnybuild -= $args[1]>>
		<<set $bunnybuild = Math.clamp($bunnybuild, 0, 100)>>
	<</if>>
<</if>>
<</widget>>

<<widget "hand_gag">>/*First arg the NPC index. Second arg the hand used.*/
<<if !$worn.face.type.includes("gag") and $args[0] isnot undefined>>
	<<if $args[1] is "left">>
		<<set $mouthuse to "lefthand">><<set $NPCList[$args[0]].lefthand to "mouth">>
	<<else>>
		<<set $mouthuse to "righthand">><<set $NPCList[$args[0]].righthand to "mouth">>
	<</if>>
<</if>>
<</widget>>

<<widget "prop">>
<<for _i = 0; _i < $args.length; _i++>>
	<<set $prop.push($args[_i])>>
<</for>>
<</widget>>

<<widget "schoolrep">>
<<if $args[0] and $args[1] and (!$worn.face.type.includes("mask") or $args[1] lt 0)>>
	<<if $schoolrep[$args[0]] lt 5 or $args[1] lt 0>>
		<<if $args[0] is "crossdress" and ($school_crossdress_day is undefined or $args[1] lt 0)>>
			<<set $school_crossdress_day to 1>>
			<<set $schoolrep[$args[0]] += $args[1]>>
			<<if $schoolrep.crossdress gte 5>>
				<<set $genderknown.pushUnique("Kylar")>>
				<<set $genderknown.pushUnique("Whitney")>>
				<<set $genderknown.pushUnique("Sydney")>>
				<<set $genderknown.pushUnique("Sirris")>>
				<<set $genderknown.pushUnique("River")>>
				<<set $genderknown.pushUnique("Doren")>>
				<<set $genderknown.pushUnique("Winter")>>
				<<set $genderknown.pushUnique("Mason")>>
				<<set $genderknown.pushUnique("Leighton")>>
				<<set $school_crossdress_message to 5>>
			<<elseif $schoolrep.crossdress gte 1 and $args[1] gte 1>>
				<<set $school_crossdress_message to $schoolrep.crossdress>>
			<</if>>
			<<set $schoolrep.crossdress = Math.clamp($schoolrep.crossdress, 0, 5)>>
		<<elseif $args[0] is "herm" and ($school_herm_day is undefined or $args[1] lt 0)>>
			<<set $school_herm_day to 1>>
			<<set $schoolrep[$args[0]] += $args[1]>>
			<<if $schoolrep.herm gte 5>>
				<<set $genderknown.pushUnique("Kylar")>>
				<<set $genderknown.pushUnique("Whitney")>>
				<<set $genderknown.pushUnique("Sydney")>>
				<<set $genderknown.pushUnique("Sirris")>>
				<<set $genderknown.pushUnique("River")>>
				<<set $genderknown.pushUnique("Doren")>>
				<<set $genderknown.pushUnique("Winter")>>
				<<set $genderknown.pushUnique("Mason")>>
				<<set $genderknown.pushUnique("Leighton")>>
				<<set $school_herm_message to 5>>
			<<elseif $schoolrep.herm gte 1 and $args[1] gte 1>>
				<<set $school_herm_message to $schoolrep.herm>>
			<</if>>
			<<set $schoolrep.herm = Math.clamp($schoolrep.herm, 0, 5)>>
		<</if>>
	<</if>>
<</if>>
<</widget>>

<<widget "schoolrep_naked">>
<<if $player.gender is "h">>
	<<schoolrep herm 1>>
<<elseif $player.gender isnot $player.gender_appearance>>
	<<schoolrep crossdress 1>>
<</if>>
<</widget>>

<<widget "event_trigger">>
<<set $danger to random(1, 10000)>>
<<if $danger gte (9900 - $allure)>>
	<<set $event_trigger to 1>>
<</if>>
<</widget>>

<<widget "combat_lewdity_text">>
<<combat_promiscuity_text>>
<<combat_deviancy_text>>
<</widget>>

<<widget "adjust_school_traits">>
<<if $science gte 1000>>
	<<set $sciencetrait to 4>>
<<elseif $science gte 700>>
	<<set $sciencetrait to 3>>
<<elseif $science gte 400>>
	<<set $sciencetrait to 2>>
<<elseif $science gte 200>>
	<<set $sciencetrait to 1>>
<<else>>
	<<set $sciencetrait to 0>>
<</if>>
<<if $maths gte 1000>>
	<<set $mathstrait to 4>>
<<elseif $maths gte 700>>
	<<set $mathstrait to 3>>
<<elseif $maths gte 400>>
	<<set $mathstrait to 2>>
<<elseif $maths gte 200>>
	<<set $mathstrait to 1>>
<<else>>
	<<set $mathstrait to 0>>
<</if>>
<<if $english gte 1000>>
	<<set $englishtrait to 4>>
<<elseif $english gte 700>>
	<<set $englishtrait to 3>>
<<elseif $english gte 400>>
	<<set $englishtrait to 2>>
<<elseif $english gte 200>>
	<<set $englishtrait to 1>>
<<else>>
	<<set $englishtrait to 0>>
<</if>>
<<if $history gte 1000>>
	<<set $historytrait to 4>>
<<elseif $history gte 700>>
	<<set $historytrait to 3>>
<<elseif $history gte 400>>
	<<set $historytrait to 2>>
<<elseif $history gte 200>>
	<<set $historytrait to 1>>
<<else>>
	<<set $historytrait to 0>>
<</if>>
<</widget>>

/*
	Argument 1 is base amount. You can also use decimals.
	Argument 2 is variation.
	Argument 3 is crime.
	<<moneyGain 1>> will give £1.00 which is not stolen.
	<<moneyGain 1 false false>> will give £1.00 which is not stolen.
	<<moneyGain 1 true>> will give between £0.80 and £1.20 which is not stolen.
	<<moneyGain 1 true true>> will give between £0.80 and £1.20 which is stolen, and can scale further with skulduggery.
	<<moneyGain 1 false true>> will give £1.00 which is stolen, and can scale with skulduggery.
*/
<<widget "moneyGain">><<silently>>
<<if $args[0]>>
	<<set _base_amount to $args[0] * 100>>
<<else>>
	<<set _base_amount to 100>>
<</if>>
<<if $args[1]>>
	<<set _variation to Math.floor(random(Math.floor(_base_amount / 5 * -1), Math.floor(_base_amount / 5)))>>
<<else>>
	<<set _variation to 0>>
<</if>>
<<if $args[2]>>
	<<set _skulduggery to clone($skulduggery)>>
	<<if $moorLuck gt 0>>
		<<set _skulduggery to Math.floor(_skulduggery * (1 + ($moorLuck / 100)))>>
	<</if>>
	<<if $worn.hands.type.includes("sticky_fingers")>>
		<<set _skulduggery to Math.floor(_skulduggery * 1.05)>>
	<</if>>
	<<if $harpy gte 2 or $cat gte 2>>
		<<set _skulduggery to Math.floor(_skulduggery * 1.05)>>
	<</if>>
	<<set _skulduggeryMulti to (1 + (_skulduggery / 2000))>>
<<else>>
	<<set _skulduggeryMulti to 1>>
<</if>>
<<set _money_gain to Math.floor((_base_amount + _variation) * _skulduggeryMulti)>>
<<if $args[2]>>
	<<crimeup `_money_gain / 100`>>
<</if>>
<<set $money += _money_gain>>
<</silently>><<printmoney _money_gain>><</widget>>

/*
	Used like above, but only shows the money amount, doesn't add money or crime.
	Use <<crimeup `_money_gain / 100`>> and <<set $money += _money_gain>> where necessary in links, etc.
*/
<<widget "moneyGainDisplay">><<silently>>
<<if $args[0]>>
	<<set _base_amount to $args[0] * 100>>
<<else>>
	<<set _base_amount to 100>>
<</if>>
<<if $args[1]>>
	<<set _variation to Math.floor(random(Math.floor(_base_amount / 5 * -1), Math.floor(_base_amount / 5)))>>
<<else>>
	<<set _variation to 0>>
<</if>>
<<if $args[2]>>
	<<set _skulduggery to clone($skulduggery)>>
	<<if $moorLuck gt 0>>
		<<set _skulduggery to Math.floor(_skulduggery * (1 + ($moorLuck / 100)))>>
	<</if>>
	<<if $worn.hands.type.includes("sticky_fingers")>>
		<<set _skulduggery to Math.floor(_skulduggery * 1.05)>>
	<</if>>
	<<if $harpy gte 2 or $cat gte 2>>
		<<set _skulduggery to Math.floor(_skulduggery * 1.05)>>
	<</if>>
	<<set _skulduggeryMulti to (1 + (_skulduggery / 2000))>>
<<else>>
	<<set _skulduggeryMulti to 1>>
<</if>>
<<set _money_gain to Math.floor((_base_amount + _variation) * _skulduggeryMulti)>>
<</silently>><<printmoney _money_gain>><</widget>>

<<widget "printmoney">><<silently>>
<<if $args.length gt 2 or typeof($args[0]) isnot "number">>
	<<set _printmoney to 'printmoney error: invalid arguments: $args'>>
<<else>>
	<<set _printargs to Math.floor($args[0]); _printmoney to (_printargs gte 0 ? "" : "-") + "£" + (_printargs % 100 ? Math.abs(_printargs/100).toFixed(2) : Math.abs(_printargs)/100)>>
<</if>>
<<if !$args[1]>>
	<<set _printmoney to '' + _printmoney + ''>>
<</if>>
<</silently>><<print _printmoney>>
<</widget>>

<<widget "sadism">>
<<if $args[0]>>
	<<set $sadism += $args[0]>>
<</if>>
<</widget>>

<<widget "enable_rescue">>
<<if $drugged lte 0>>
	<<set $rescue to 1>>
<</if>>
<</widget>>

<<widget "hypnotised">>
<<if $args[0]>>
	<<set $hypnotised += $args[0]>>
<</if>>
<</widget>>