/*:: sleep_simple
	<<if getvar("$succubusQW") == 2>>
		<<actCLA '$sleep_txt'>>
			<<if getvar("$clo_flag['bed']") == 0>>
				<<setinit $clo_flag['bed'] = 1>>
				<<run $wardrobe.lastWornSet('bed')>>
			<</if>>
			<<set $menu_off = 1>>
			<<if getvar("$bedPanty") == 2>>
				<<run $wardrobe.strip('panties')>>
			<<elseif getvar("$bedPanty") == 1>>
				<<gs 'underwear' 'wear'>>
			<</if>>
			<<if $wardrobe.clothingworntype != 'nude'>>
				<<set $strip_here = 1>>
				<<run $wardrobe.strip('clothes')>>
			<</if>>
			<<gt 'sleep' 'succhoice'>>
		<</actCLA>>
	<<else>>
		<<actCLA '$sleep_txt'>>
			<<if getvar("$clo_flag['bed']") == 0>>
				<<setinit $clo_flag['bed'] = 1>>
				<<run $wardrobe.lastWornSet('bed')>>
			<</if>>
			<<set $menu_off = 1>>
			<<if getvar("$bedPanty") == 2>>
				<<run $wardrobe.strip('panties')>>
			<<elseif getvar("$bedPanty") == 1>>
				<<gs 'underwear' 'wear'>>
			<</if>>
			<<if $wardrobe.clothingworntype != 'nude'>>
				<<set $strip_here = 1>>
				<<run $wardrobe.strip('clothes')>>
			<</if>>
			<<if getvar("$magf2bdo") == 2>>
				<<gt 'sleep' 'magbstchoice'>>
			<<else>>
				<<gt 'sleep' 'sleep'>>
			<</if>>
		<</actCLA>>
		<<set $sleep_txt to null>>
	<</if>>
<</if>>
 */
:: sleep_scripts[script]
setup.moodletGroups ??= {};
setup.moodletGroups.sleep = {
	accumulationMode: 2
}
setup.moodlets ??= {};
setup.moodlets.sleep_1 = {
	title: "Well rested",
	group: 'sleep',
	description: '',
	effect: 10,
	timeMode: 1,
	duration: 240
};

setup.moodlets.sleep_m1 = {
	title: "Sleepy",
	group: 'sleep',
	description: '',
	effect: -5,
	timeMode: 1,
	duration: 240
};

setup.moodlets.sleep_m2 = {
	title: "Too little sleep",
	group: 'sleep',
	description: '',
	effect: -10,
	timeMode: 1,
	duration: 240
};

setup.moodlets.sleep_m3 = {
	title: "Way too little sleep",
	group: 'sleep',
	description: '',
	effect: -20,
	timeMode: 1,
	duration: 240
};

:: sleep[event]
	<!--<<if $loc == 'nichBedroomServant'>>
		<<gs 'nichBedroomServant' 'sleepEvents'>>
	<</if>>-->
	<<set $pc.isSleeping= 1>>
	<<eventExecute 'dream'>>
	<hr/>
	<<eventExecute 'wakeup'>>

	<<if _eventTime.used >= 60>>
		<<gs 'sleep_apply_wake_moodlet'>>
	<</if>>

	<<gs 'wake'>>

:: wakeup_events[wakeup_events]

	<<set _desiredSleepLength = _eventTime.requested || 720>>
	<<set _desiredWakeupTime = $time.nowWithMinutesOffset(_desiredSleepLength)>>

	<<event `10000-_desiredSleepLength`>>
		<!-- This is the default event that fires if you had the requested amount of sleep -->
		<<set _eventTime.used = _desiredSleepLength>>
		<<addtime _eventTime.used>>
		<<set $pc.isSleeping= 0>>
		<p>You had more than enough sleep and wake up by yourself.</p>
		<<eventFired>>
	<</event>>

	<<if $alarmClock.on>>
		<<set _nextAlarmClockAlarm = setup.alarmClockNextAlarm()>>
		<<set _minutesTilAlarmClock = (_nextAlarmClockAlarm.getTime() - $time.now.getTime()) / 60000>>
		<<if _nextAlarmClockAlarm.getTime() < _desiredWakeupTime.getTime()>>
			<<event `10000-_minutesTilAlarmClock`>>
				<!-- This is the alarm clock event -->
				<<set _eventTime.used = _minutesTilAlarmClock>>
				<<addtime _eventTime.used>>
				<<set $pc.isSleeping= 0>>
				<p>Your alarm clock wakes you up as scheduled.</p>
				<<eventFired>>
			<</event>>
			<<log 'Sleep: Alarm Clock activated and event queued'>>
		<<else>>
			<<log 'Sleep: Alarm Clock activated but not within sleep duration'>>
		<</if>>
	<<else>>
		<<log 'Sleep: Alarm Clock not activated'>>
	<</if>>
	
	<<set _minutesTilHungerZero = $pc.minutesTilStat('hunger',0)>>
	<<if _desiredSleepLength > _minutesTilHungerZero>>
		<<event `10000-_minutesTilHungerZero`>>
			<!-- This is the hunger event -->
			<<set _eventTime.used = _minutesTilHungerZero>>
			<<addtime _eventTime.used>>
			<<set $pc.isSleeping= 0>>
			<p>The painful emptiness of your stomach wakes you up. You really need to eat something.</p>
			<<eventFired>>
		<</event>>
		<<log 'Sleep: Hunger activated and event queued'>>
	<<else>>
		<<log 'Sleep: Hunger to zero not within sleep duration'>>
	<</if>>
	
	<<set _minutesTilThirstZero = $pc.minutesTilStat('thirst',0)>>
	<<if _desiredSleepLength > _minutesTilThirstZero>>
		<<event `10000-_minutesTilThirstZero`>>
			<!-- This is the thirst event -->
			<<set _eventTime.used = _minutesTilThirstZero>>
			<<addtime _eventTime.used>>
			<<set $pc.isSleeping= 0>>
			<p>The uncomfortable dryness of your mouth wakey you up. You really need to drink something.</p>
			<<eventFired>>
		<</event>>
		<<log 'Sleep: Thirst activated and event queued'>>
	<<else>>
		<<log 'Sleep: Thirst to zero not within sleep duration'>>
	<</if>>
	
:: sleep_apply_wake_moodlet[include]
	<<if $pc.pcs_sleep == 100>>
		<<mood 'sleep_1'>>
	<<elseif $pc.pcs_sleep >= 90>>
		<<mood 'sleep_m1'>>
	<<elseif $pc.pcs_sleep >= 70>>
		<<mood 'sleep_m2'>>
	<<else>>
		<<mood 'sleep_m3'>>
	<</if>>
	

:: sleep_deprecated[deprecated]

	<<for ;!_wake_up && _iterationsLeft > 0;>>

		<!--
			<<if $pc.vibratorin == 1>>
				<<set $vtime += 1>>
				<<if getvar("$vtime") >= 5>>
					<<set $pc.horny += 1>>
					<<set $vtime = 0>>
				<</if>>
				<<if $pc.horny == 100>>
					<<set $pc.horny = 0>>
					<<set $orgasm += 1>>
					<<set $time.minutes += 5>>

					<<image "shared/sex/oface/o_face.jpg">>
					<p>You abruptly wake up in the throes of an orgasm. As you recover, you check the time, <b>$mid(100+hour,2,2):$mid(100+minut,2,2)</b>.</p>
					<<act 'Go back to sleep'>>
						<<gt 'sleep' 'dream'>>
					<</act>>
					<<actCLA 'Give up trying to sleep'>>
						<<image "shared/sex/oface/kotovfirst1.jpg">>
						Maybe trying to sleep with a vibrator in your pussy wasn''t such a good idea.
						<<gs 'sleep' 'wake'>>
					<</actCLA>>
					$exit
				<</if>>
			<<elseif $pc.horny > 80 and $pc.pcs_sleep >= 30 and rand(1,300) == 300 and getvar("$succubusQW") != 1 and getvar("$succubusQW") != 2>>

				<<set $waketext = 'You glance at your alarm clock. It reads <b>$mid(100+hour,2,2):$mid(100+minut,2,2)</b>.'>>
				<<gt 'sleep' 'wake_horny'>>
			<</if>> -->

	<</for>>
	<<if getvar("$pcs_condition['lack_of_sleep']") >= 10>>
		<!-- !!Worsening of skin quality if you do not sleep enough.-->
		<<set $pc.skinDailyPenalty += 2>>
	<<elseif getvar("$pcs_condition['lack_of_sleep']") >= 2>>
		<<set $pc.skinDailyPenalty += 1>>
	<<elseif getvar("$pcs_condition['lack_of_sleep']") > 0>>
		<<set $pc.skinDailyPenalty += 0>>
	<<else>>
		<<set $pc.skinDailyPenalty -= 1>>
	<</if>>


	/*<<if getvar("$slept_in") == 1>>
		You wake up at <b><<time_current>></b>, after sleeping-in a little longer than planned, but at least you've had plenty of sleep.
	<<elseif $pc.pcs_sleep >= 100 and $alarmClock.on and _time_now >= _alarm_time>>
		
	<<elseif $pc.pcs_sleep >= 100>>
		You wake up at <b><<time_current>></b>, no longer tired and ready to start the day with plenty of sleep.
	<<elseif $alarmClock.on and _time_now == _alarm_time>>
		<<set $pc.mood -= 10>>
		Your alarm goes off at <b><<time_current>></b>,
		<<if $pc.pcs_sleep < 90>>
			but you could do with some extra sleep.
		<<else>>
			and you've had plenty of sleep.
		<</if>>
		<!--<<gs 'sleep' 'extra'>>-->
	<</if>>*/
	<<gs 'wake'>>
:: wake_horny
<<if $location_var[$here][0] == 'wake_horny'>>
	<<set $menu_off = 1>>
	<<set $pc.isSleeping= 1>>
	<<set $SleepHorny += 1>>
	<<if !$wardrobe.isWearingPanties>>
		<<if getvar("$SleepHorny") == 1>>
			<<image "shared/home/sleep_horny.jpg">>
		<<elseif getvar("$SleepHorny") == 2>>
			<<image "shared/sex/mast/klit.jpg">>
		<<elseif getvar("$SleepHorny") >= 3>>
			<<image "shared/sex/oface/kotovfirst1.jpg">>
		<</if>>
	<<else>>
		<<if getvar("$SleepHorny") == 1>>
			<<image "shared/sex/mast/start.jpg">>
		<<elseif getvar("$SleepHorny") == 2>>
			<<image "shared/sex/undress/kiska.jpg">>
		<<elseif getvar("$SleepHorny") >= 3>>
			<<image "shared/sex/oface/kotovfirst1.jpg">>
		<</if>>
	<</if>>
	<<$waketext>>
	<<if getvar("$SleepHorny") == 1>>
		Your wet dream and overall horniness rouse you from your sleep. From one moment to the next, you are wide awake and very much aware that your pussy is hot and wet.
		<p>You could try and go back to sleep, of course, but it's doubtful that you would find this kind of sleep very restful; not to mention the frustration that comes with ignoring your needs, but masturbating is an option, too, and not the worst one in this situation. It might take some time, but you'd be able to sleep like a baby after.</p>
		Of course, you could always just give up on trying to sleep and just get up.
	<<elseif getvar("$SleepHorny") == 2>>
		You're so horny that you've woken a second time. Your pussy is still wet and wanting attention.
		<p>You could try and get back to sleep again, but it's doubtful that you will get much sleep, and continuously ignoring your needs won't help; maybe you should masturbate, and make the most of the time that's left.</p>
		Soon you will have to get up one way or another.
	<<elseif getvar("$SleepHorny") >= 3>>
		<p>Once again your horniness has roused you from your sleep. This is getting ridiculous! You are finding it very difficult to get any sleep at all.</p>
		<p>Going back to sleep almost feels like a waste of time at this point;  you won't get much rest at all, at least until you fix the problem.</p>
		<<if $wardrobe.isWearingPanties>>
			<<gs 'underwear' 'remove'>>
			You've removed  your underwear, as your panties were soaked through.
		<</if>>
		Maybe you should just get up.
	<</if>>
	<<if $loc == 'bedrPar' and getvar("$sisterLesb") == 6 and $time.hour < 6>>
		Or... you could wake up Anya and see if your dearest sister would be willing to help you with that.
	<<elseif $loc == 'FedorEv4'>>
		Or... you could wake up Fedor and see if your boyfriend can't help you with that.
	<<elseif $loc == 'bedr' and getvar("$husband") > 0>>
		<p>Or... you could wake up $husName and see if your husband can't help you with that.</p>
	<</if>>
	<<actCLA 'Try and go back to sleep'>>
		<<set $pc.mood -= 10>>
		<<set $pc.pcs_sleep -= 5>>
		<<gt 'sleep' 'dream'>>
	<</actCLA>>
	<<actCLA 'Masturbate'>>
		<<set $pc.isSleeping= 0>> <<gt 'selfplay' 'start'>>
	<</actCLA>>
	<<actCLA 'Get out of bed (0:10)'>>
		<<set $time.minutes += 10>>
		<<gs 'sleep' 'end'>>
	<</actCLA>>
	<<if getvar("$strip_here") == 1>>
		<<actCLA 'Get out of bed and get dressed (0:15)'>>
			<<set $time.minutes += 15>>
			<<run $wardrobe.wear_clothes_legacy('clothes',$lastwornclothingtype['bed'],$lastwornclothingnumber['bed'])>>
			<<run $wardrobe.wear(['panties',$lastwornpantytype['bed'],$lastwornpantynumber['bed']])>>
			<<run $wardrobe.wear(['bra',$lastwornbratype['bed'],$lastwornbranumber['bed']])>>
			<<if $bed['shoetype'] != 'none'>>
				<<run $wardrobe.wear(['shoes',$bed['shoetype'],$bed['shoenumber']])>>
			<</if>>
			<<gs 'sleep' 'end'>>
		<</actCLA>>
	<</if>>
	<<if $loc == 'bedrPar' and getvar("$sisterLesb") == 6 and $time.hour < 6>>
		<<actCLA 'Wake Anya and see if she`s in the mood'>>
			<<set $strip_here = 0>> <<set $pc.isSleeping= 0>> <<gt 'sistersleep' 'sister_sleep'>>
		<</actCLA>>
	<<elseif $loc == 'FedorEv4'>>
		<<actCLA 'Wake Fedor and see if he`s in the mood'>>
			<<set $strip_here = 0>> <<set $pc.isSleeping= 0>> <<gt 'FedorEv4' 'Bedroom 1'>>
		<</actCLA>>
		<!-- !!Intro text doesn''t quite fit event (but doesn''t quite fit - try for baby - scenario either) - custom scene from VK?-->
	<<elseif ($loc == 'bedr' or $loc == 'bedr2x') and getvar("$husband") > 0>>
		<<actCLA 'Wake your husband and see if he`s in the mood'>>
			<<set $strip_here = 0>> <<set $pc.isSleeping= 0>> <<gt 'husbSex' 'variant'>>
		<</actCLA>>
		<!-- !!Should be custom scene - maybe boyfriend/husband overhaul can cover this?-->
	<</if>>
<</if>>

/*:: sleep_extra
<<if $location_var[$here][0] == 'extra'>>
	<<actCLA '"Snooze" a few minutes more...'>>
		<<set $menu_off = 1>>
		<<set $slept_in = 1>>
		<<gt 'sleep' 'dream'>>
	<</actCLA>>
<</if>>
<<if $location_var[$here][0] == 'end'>>
	<!--<<set $menu_off = 1>>
	<<set $time.minutes -= 1>>
	<<set $pc.isSleeping= 0>>
	<<set $slept_in = 0>>
	<<set $strip_here = 0>>
	<<set $SleepHorny = 0>>
	<!-- !! to fudge the first hour wake up sleep loss.--><!--
	<<set $InSleepWake = $time.hour + 1>>
	<<setinit $InSleepWake[1] = $time.daystart>>
	<<if getvar("$fullmorrout") == 1 and $loc == 'bedrPar'>>
		<<gt 'vanrPar'>>
	<<elseif getvar("$fullmorrout") == 1 and $loc == 'bedr'>>
		<<gt 'vanr'>>
	<<elseif getvar("$vomit['morning_sick']") == 1 or getvar("$vomit['hangover']") == 1 or getvar("$vomit['unlucky']") == 1>>
		<<gt 'home_activity' 'vomiting_exit'>>
	<<else>>
		<<gt $location>>
	<</if>>-->
<</if>>
<<if $location_var[$here][0] == 'succhoice'>>
	<<set $menu_off = 1>>
	<<set $time.minutes += 15>>
	<<if $wardrobe.clothingworntype != 'nude'>>
		<<image "shared/home/bed.jpg">>
	<<else>>
		<<image "shared/home/bedroom/son.jpg">>
	<</if>>
	<p></p>
	You toss and turn for a while, but the energy that has been buzzing under your skin since that dream just won''t let you sleep.
	<p></p>
	<p>Thinking about it you realize that you could push the energy out or pull it in!</p>
	<p></p>
	<font color="red"><b>You also feel that both are <i>permanent</i> choices.</b></font>
	<<actCLA 'Try to ignore it and go to sleep'>>
		<<if getvar("$disable_autosave") == 0>>
			<<if setup.startingCharacterTagsIncludes('city')>>
				savegame 'autosave_city.sav'
			<<elseif setup.startingCharacterTagsIncludes('uni')>>
				savegame 'autosave_uni.sav'
			<<else>>
				savegame 'autosave_sg.sav'
			<</if>>
		<</if>>
		<<gt 'sleep' 'sleep'>>
	<</actCLA>>
	<<act 'Push the Energy out for all time'>>
		<<gt 'sleep' 'succhoiceNO'>>
	<</act>>
	<<act 'Pull the Energy in and let it change you permanently'>>
		<<gt 'sleep' 'succhoiceYES'>>
	<</act>>
<</if>>
<<if $location_var[$here][0] == 'succhoiceNO'>>
	<<set $menu_off = 1>>
	<<if $wardrobe.clothingworntype != 'nude'>>
		<<image "shared/home/bed.jpg">>
	<<else>>
		<<image "shared/home/bedroom/son.jpg">>
	<</if>>
	<p></p>
	You push the energy out of you and it dissipates.
	<<set $succubusQW = 3>>
	<<set $pc.horny = 0>>
	<<set $time.minutes += 5>>
	<<actCLA 'Go to sleep'>>
		<<if getvar("$disable_autosave") == 0>>
			<<if setup.startingCharacterTagsIncludes('city')>>
				savegame 'autosave_city.sav'
			<<elseif setup.startingCharacterTagsIncludes('uni')>>
				savegame 'autosave_uni.sav'
			<<else>>
				savegame 'autosave_sg.sav'
			<</if>>
		<</if>>
		<<gt 'sleep' 'sleep'>>
	<</actCLA>>
<</if>>
<<if $location_var[$here][0] == 'succhoiceYES'>>
	<<set $menu_off = 1>>
	<<if $wardrobe.clothingworntype != 'nude'>>
		<<image "shared/home/bed.jpg">>
	<<else>>
		<<image "shared/home/bedroom/son.jpg">>
	<</if>>
	<<set $succubusQW = 4>>
	<p></p>
	You pull the energy deeper into yourself and hold it there.
	<p></p>
	Then you feel pressure building...
	<<wait 450>>
	<<set $time.minutes += 5>>
	BUILDING...
	<<wait 450>>
	<<set $time.minutes += 5>>
	<b>BUILDING...</b>
	<<wait 450>>
	<<set $time.minutes += 5>>
	Power bursts through your body causing you to hop out of bed.
	<<act 'Continue'>>
		<<gt 'sleep' 'succubinit'>>
	<</act>>
<</if>>
<<if $location_var[$here][0] == 'succubinit'>>
	<<set $menu_off = 1>>
	<<set $time.minutes += 10>>
	<!-- !!Sets the succubus flag, succubus level (succublvl), Initial lesbian sex count (suclezsnapshot), initial Succubus hunger (succhungry),-->
	<!-- !! & the succubus descriptor ($sucself1). The -2 on succhungry is to give th PC 2 days to get in the Succubus grove.-->
	<<set $succubusflag = 1>>
	<<set $succublvl = 1>>
	<<set $suclezsnapshot = $lesbian>>
	<<set $succhungry = -2>>
	<<set $sucwalkday = daystart + 2 + rand(0,5)>>
	<<set $sucself1 = 'that feeling'>>
	<<set $pc.horny = 100>>
	<<set $pc.isSleeping= 0>>
	<<set $slept_in = 0>>
	<<set $strip_here = 0>>
	<<image "pc/body/succubusself.jpg">>
	<font color="red">You feel the power flowing around your body for several minutes, leaking through your skin and making changes all throughout you, before fading to a presence deep in your core leaving you looking the same as before... but feeling so different! </font>
	<<if $pc.preg == 1>>
		<<gs 'medical_din' 'remove_preg'>>
		<<set $RecovH = 0>>
	<</if>>
	<<actCLA 'Finish'>>
		<<gt $location>>
	<</actCLA>>
<</if>>
<<if $location_var[$here][0] == 'magbstchoice'>>
	<<set $menu_off = 1>>
	<<set $tittmp = $pc.tits + 1>>
	<<image 'pc/body/tits/t<<tittmp>>.jpg'>>
	<<set $tittmp to null>>
	You have an odd dream where you are looking at your naked chest in a mirror and your breasts seem larger...
	As the dream starts to drift away, you find yourself gazing at the reflection of your breasts and think:
	<<actCLA 'Nice, I wish my breasts really would grow.'>>
		<<set $magf2bdo = 1>>
		<<set $magtarcup += 1>>
		<<set $mgf2bnocnt to null>>
		<<gt 'sleep' 'sleep'>>
	<</actCLA>>
	<<actCLA 'Eh, I don`t like them like that.'>>
		<<set $magf2bdo = 0>> <<set $mgf2bnocnt += 1>> <<gt 'sleep' 'dream'>>
	<</actCLA>>
<</if>>
 */
