# sleep $sleep_loc = 'sleep' !! Deals with the sleep cycle, advancing both time and stats during sleep. !! !! Moved here from pre_sleep !! Move to dream_events. Then back to sleep (this location). !! When busy moves back and forth to sleep_events (and can be redirected from there) !! When done: Move to wakeup if $ARGS[0] = 'full': msg 'gt ''sleep'', ''full'' is depricated! If you did not load an old save, please report this bug. You can continue playing without worry.' gt 'pre_sleep', 'start' end if $ARGS[0] = 'sleep': msg 'gt ''sleep'', ''sleep'' is depricated! If you did not load an old save, please report this bug. You can continue playing without worry.' gt 'pre_sleep', 'prepare_sleep' end if $ARGS[0] = 'dream': msg 'gt ''sleep'', ''dream'' is depricated! If you did not load an old save, please report this bug. You can continue playing without worry.' gt 'sleep', 'start' end if $ARGS[0] = 'wake': msg 'gt ''sleep'', ''wake'' is depricated! If you did not load an old save, please report this bug. You can continue playing without worry.' gt 'wakeup', 'start' end if $ARGS[0] = 'end': msg 'gt ''sleep'', ''end'' is depricated! If you did not load an old save, please report this bug. You can continue playing without worry.' gt 'bed_get_out', 'start' end if $ARGS[0] = '': msg 'gt ''sleep'', is depricated! If you did not load an old save, please report this bug. You can continue playing without worry.' gt 'pre_sleep', 'start' end if $ARGS[0] = 'start': menu_off = 1 gt 'dream_events', 'start' end if $ARGS[0] = 'post_dream': menu_off = 1 !! to avoid sleeping the whole day I decide to calcululate the duration of the sleep in advance !! the quality of the sleep depends on many factors, so the time of sleep can be modify later, especially the part when the time of sleep is shortened sleepVars['time_to_full'] = (100 - pcs_sleep) * 6 !! fully exhausted Sveta can recover in 420 minutes = 7 hours of sleep !! healthy Sveta can hardly sleep more then 10 hours = 600 minutes !! so we can add about 3 hours to time to full as a limit sleepVars['time_to_full'] += 150 + rand(0, 60) xgt 'sleep', 'sleep_handler' end if $ARGS[0] = 'sleep_handler': menu_off = 1 gs 'sleep', 'calc_minutes_to_wakeup' if sleepVars['minutes_to_wakeup'] > 0: xgt 'sleep', 'sleep_loop' else xgt 'sleep', 'post_sleep' end end if $ARGS[0] = 'calc_minutes_to_wakeup': sleepVars['time_now'] = daystart * 1440 + hour * 60 + minut if alarmVars['alarmOn'] = 1: if alarmVars['alarm_holiday'] = 1 and kanikuli ! 0 or ((hour < alarmVars['timerEndH'] and (week = 6 or week = 7)) or (hour => alarmVars['timerEndH'] and (week = 5 or week = 6))): !! use weekend time alarm sleepVars['alarm_time'] = daystart * 1440 + alarmVars['timerEndH'] * 60 + alarmVars['timerEndM'] else sleepVars['alarm_time'] = daystart * 1440 + alarmVars['timerH'] * 60 + alarmVars['timerM'] end if sleepVars['time_now'] > sleepVars['alarm_time']: sleepVars['alarm_time'] += 1440 sleepVars['minutes_to_wakeup'] = min(sleepVars['time_to_full'], sleepVars['alarm_time'] - sleepVars['time_now']) else sleepVars['minutes_to_wakeup'] = sleepVars['time_to_full'] end end if $ARGS[0] = 'sleep_loop': menu_off = 1 :sleep_loop_loop minut += 1 sleepVars['stime'] += 1 sleepVars['time_now'] += 1 sleepVars['minutes_to_wakeup'] -= 1 sleepVars['time_to_full'] -= 1 if recuperation = 0: pcs_health += 5 if vibratorIN = 1: sleepVars['vtime'] += 1 if sleepVars['vtime'] >= 5: pcs_horny += 1 sleepVars['vtime'] = 0 end end if sleepVars['stime'] >= 60: sleepVars['stime'] = 0 pcs_sleep += 15 if pcs_sleep >= 100 or succublvl > 0: pcs_condition['lack_of_sleep'] = 0 elseif pcs_condition['lack_of_sleep'] > 0: pcs_condition['lack_of_sleep'] -= 1 end gs 'stat' end if minut = 60: gs 'stat' gs 'sleep', 'mod_sleeptriggers' if sleepVars['stime'] mod 5 = 0: gs 'sleep_events', 'start' end if sleepVars['minutes_to_wakeup'] > 0: jump 'sleep_loop_loop' killvar 'sleep_loop_loop' xgt 'sleep', 'post_sleep' end if $ARGS[0] = 'mod_sleeptriggers': !! This location is here to allow mods to hook into the system. !! Check for: if $sleep_loc = 'pre_sleep' and $ARGS[0] = 'mod_sleeptriggers' !! !! This is NOT for events!! gs 'LOCA', 'mod_sleeptriggers' end if $ARGS[0] = 'post_sleep': menu_off = 1 if succublvl < 0: skinDailyPenalty -= 1 else if pcs_condition['lack_of_sleep'] >= 10: !!Worsening of skin quality if you do not sleep enough. skinDailyPenalty += 2 elseif pcs_condition['lack_of_sleep'] >= 2: skinDailyPenalty += 1 elseif pcs_condition['lack_of_sleep'] > 0: skinDailyPenalty += 0 else skinDailyPenalty -= 1 end end gs 'stat' xgt 'wakeup', 'start' end if $ARGS[0] = 'extra': act '"Snooze" a few minutes more...': menu_off = 1 slept_in = 1 gs 'stat' gt 'sleep', 'start' end end --- sleep ---------------------------------