# pre_sleep

!! Deals with all the triggers that happen to prepare to for the sleep cycle, before the dream events start.
!!
!! Moved here from pre_sleep_events
!! When done: Move to dream_events


if $ARGS[0] = 'start' or $ARGS[0] = '':
	menu_off = 1
	sleepVars['slept_in'] = 0
	gt 'pre_sleep_events', 'start'
end

if $ARGS[0] = 'pre_sleep2':
	menu_off = 1
	if clo_flag['bed'] = 0:
		clo_flag['bed'] = 1
		$lastwornclothingtype['bed'] = $clothingworntype
		lastwornclothingnumber['bed'] = clothingwornnumber
		$lastwornpantytype['bed'] = $pantyworntype
		lastwornpantynumber['bed'] = pantywornnumber
		$lastwornbratype['bed'] = $braworntype
		lastwornbranumber['bed'] = brawornnumber
	end
	if sleepVars['bedPanty'] = 2:
		gs 'underwear', 'remove'
	elseif sleepVars['bedPanty'] = 1:
		gs 'underwear', 'wear'
	end
	if $clothingworntype ! 'nude':
		strip_here = 1
		gs 'clothing', 'strip'
	end

	gt 'pre_sleep', 'prepare_sleep'
end

if $ARGS[0] = 'prepare_sleep':
	menu_off = 1
	if $clothingworntype ! 'nude':
		'<center><img <<$set_imgh>> src="images/shared/home/bed.jpg"></center>'
	else
		'<center><img <<$set_imgh>> src="images/shared/home/bedroom/son.jpg"></center>'
	end
	gs 'stat'
	*nl
	if alarmVars['alarmOn'] = 1:
		if alarmVars['alarm_holiday'] = 1 and kanikuli ! 0 or ((hour => alarmVars['timerEndH'] and (week = 5 or week = 6)) or (hour < alarmVars['timerEndH'] and (week = 6 or week = 7))):
			'You run through your regular nightly routine, setting your alarm for <<func(''alarmclock'', ''alarm_display'', alarmVars[''timerEndH''], alarmVars[''timerEndM''])>>, you undress, and prepare for sleep:'
		else
			'You run through your regular nightly routine, setting your alarm for <<func(''alarmclock'', ''alarm_display'', alarmVars[''timerH''], alarmVars[''timerM''])>>, you undress, and prepare for sleep:'
		end
	else
		'You run through your regular nightly routine, not bothering to setting your alarm, you undress, and prepare for sleep:'
	end

	pcs_hairbsh = 0
	pain['killer'] = 0

	if mid($start_type, 1, 2) = 'sg' and $loc ! 'bedrPar' and SchoolAtestat = 0:
		sleepVars['notathomesleep'] += 1
	else
		sleepVars['notathomesleep'] = 0
	end

	if succubusflag = 1 and sucwalkday <= daystart and (succhungry < (0 - 1 - succublvl) or pcs_willpwr < ((succublvl * willpowermax) / 13) or sucpowzeroed >= 3): gs 'succubus', 'sucwalkinginit'

	if analplugIN = 1 and vibratorIN = 1:
		*nl
		if sleepVars['bedAnal'] = 1 and sleepVars['bedVibrator'] = 1:
			analplugIN = 0 & analplugout = 0
			vibratorIN = 0
			gs 'stat'
			'Before going to bed, you take out your butt plug and vibrator and give it a quick wash.'
		elseif sleepVars['bedAnal'] = 1 and sleepVars['bedVibrator'] = 0:
			vibratorIN = 0
			gs 'stat'
			'Before going to bed, you take out your vibrator and give it a quick wash.'
			'You decide to leave your butt plug in.'
		elseif sleepVars['bedAnal'] = 0 and sleepVars['bedVibrator'] = 1:
			analplugIN = 0 & analplugout = 0
			gs 'stat'
			'Before going to bed, you take out your butt plug and give it a quick wash.'
			'You decide to leave your vibrator in.'
		else
			'You decide to leave your butt plug and vibrator in.'
		end
	elseif analplugIN = 1 and vibratorIN = 0:
		*nl
		if sleepVars['bedAnal'] = 1:
			analplugIN = 0 & analplugout = 0
			gs 'stat'
			'Before going to bed, you take out your butt plug and give it a quick wash.'
		else
			*nl
			'You decide to leave your butt plug in.'
		end
	elseif analplugIN = 0 and vibratorIN = 1:
		*nl
		if sleepVars['bedVibrator'] = 1:
			vibratorIN = 0
			'Before going to bed, you take out your vibrator and give it a quick wash.'
		else
			'You decide to leave your vibrator in.'
		end
	end

	if $shoeworntype = 'none':
		$bed['shoetype'] = 'none'
	else
		$bed['shoetype'] = $shoeworntype
		bed['shoenumber'] = shoewornnumber
!!		gs 'shoes', 'strip'
	end

	*nl
	if sleepVars['bedPanty'] = 1:
		if $pantyworntype = 'none' and $braworntype = 'none':
			'You put on your bra and panties.'
		elseif $pantyworntype ! 'none' and $braworntype = 'none':
			'You put on your bra.'
		elseif $pantyworntype ! 'none' and $braworntype ! 'none':
			'You put on your panties.'
		else
			'You change your bra and panties.'
		end
	elseif sleepVars['bedPanty'] = 2:
		if $pantyworntype ! 'none' or $braworntype ! 'none':
			'You remove your bra and panties.'
		elseif $pantyworntype ! 'none' and $braworntype = 'none':
			'You remove your panties.'
		elseif $braworntype ! 'none':
			'You remove your bra.'
		end
	else
		'You were too tired to worry about your underwear, so for tonight you left it as is.'
	end

	*nl
	if $hairstyle ! '':
		$hairstyle
	else
		'Your hair is loose and free.'
	end

	if pcs_makeup > 1 and cosmetic_tattoo = 0:
		pcs_makeup = 0
		vidageday -= 1
		gs 'body', 'SkinLoss', 'MakeUpSleep'
		*nl
		'You went to bed wearing your makeup, which will smear your face as you sleep; your skin will age faster from this!'
	end

	if fat > 5 and stringimplant = 1: bodyVars['bust_silicone'] += 1 & fat -= 5

	xgt 'pre_sleep', 'mod_sleeptriggers'

end

if $ARGS[0] = 'mod_sleeptriggers':
	!! This location is here to allow mods to hook into the system.
	!! Either check for: if $ARGS[0] = 'pre_sleep' and $ARGS[1] = 'mod_triggers'
	!!
	!! This is NOT for events!!

	gs 'LOCA', 'pre_sleep', 'mod_sleeptriggers'
	xgt 'pre_sleep', 'end'
end

if $ARGS[0] = 'end':
	act 'Sleep...':
	!!flag to stop autosave breaking my awesome clothing thingy
		clo_flag['bed'] = 0
		InSleep = 1
		gs 'stat'

		gt 'sleep', 'start'
	end
end




--- pre_sleep ---------------------------------
