123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- # sleep_simple
- if $ARGS[0] = 'simple':
- !! to avoid sleeping the whole day I decide to calculate 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) * 5
- !! fully exhausted Sveta can recover in 500 minutes = 8 hours of sleep
- !! healthy Sveta can hardly sleep more then 10 hours = 600 minutes
- !! so we can add about 2 hours to time to full as a limit
- sleepVars['time_to_full'] += 60 + rand(0, 90)
- gs 'sleep', 'calc_minutes_to_wakeup'
- gs 'sleep_simple', 'loop'
- end
- if $ARGS[0] = 'forced':
- if ARGS[1] <= 0:
- gs 'sleep_simple', 'simple'
- exit
- end
- sleepVars['time_to_full'] = (100 - pcs_sleep) * 5
- sleepVars['time_to_full'] += 60 + rand(0, 90)
- sleepVars['minutes_to_wakeup'] = ARGS[1]
- gs 'sleep_simple', 'loop'
- end
- if $ARGS[0] = 'sleep_until':
- temp_minutes = (ARGS[1] - hour) * 60 + ARGS[2] - minut
- if temp_minutes < 0: temp_minutes += 1440
- gs 'sleep_simple', 'forced', temp_minutes
- killvar 'temp_minutes'
- end
- if $ARGS[0] = 'loop':
- InSleep = 1
- :sleep_simple_loop
- minut += 1
- sleepVars['stime'] += 1
- sleepVars['time_now'] += 1
- sleepVars['minutes_to_wakeup'] -= 1
- sleepVars['time_to_full'] -= 1
- if recuperation = 0 or SleepVars['no_health'] = 1: sleepVars['health_stock'] += healthmax
- if sleepVars['health_stock'] >= 960:
- pcs_health += sleepVars['health_stock'] / 960
- sleepVars['health_stock'] = sleepVars['health_stock'] mod 960
- end
- if sleepVars['stime'] mod 5 = 0: pcs_sleep += 1
- if sleepVars['stime'] >= 60: sleepVars['stime'] = 0
- if minut = 60: gs 'stat'
- gs 'sleep_simple', 'mod_sleeptriggers'
- if sleepVars['minutes_to_wakeup'] > 0: jump 'sleep_simple_loop'
- sleepVars['no_health'] = 0
- sleepVars['time_now'] = daystart * 1440 + hour * 60 + minut
- InSleep = 0
- gs 'stat'
- end
- if $ARGS[0] = 'mod_sleeptriggers':
- !! This location is here to allow mods to hook into the system.
- !! Check for: if $ARGS[0] = 'sleep_simple' and $ARGS[1] = 'mod_sleeptriggers'
- !!
- !! This is NOT for events!!
- gs 'LOCA', 'sleep_simple', 'mod_sleeptriggers'
- end
- if $ARGS[0] = 'nap_bed':
- cla
- menu_off = 1
- if pcs_sleep < 10:
- gs 'shortgs', 'autosave'
- gt 'pre_sleep', 'prepare_sleep'
- elseif pcs_sleep <= 90:
- InSleep = 1
- gs 'sleep_simple', 'nap_base', 60
- *nl
- if ARGS[1] = 0: 'You sleep about an hour.'
- else
- minut += 5
- *nl
- if ARGS[1] = 0: 'You are not tired enough to sleep, even for a short nap.'
- end
- gs 'stat'
- act 'Get up': InSleep = 0 & gt 'bed_get_out', 'start'
- end
- if $ARGS[0] = 'nap':
- cla
- menu_off = 1
- if pcs_sleep <= 90:
- InSleep = 1
- gs 'sleep_simple', 'nap_base', 60
- *nl
- if ARGS[1] = 0: 'You nap for about an hour.'
- else
- minut += 5
- *nl
- if ARGS[1] = 0: 'You are not tired enough even for a short nap.'
- end
- gs 'stat'
- InSleep = 0
- act 'Get up': gt $loc, $loc_arg
- end
- if $ARGS[0] = 'nap_base':
- if ARGS[1] > 0:
- minut += ARGS[1]
- else
- ARGS[1] *= -1
- end
- pcs_sleep += ARGS[1] / 6
- pcs_health += ARGS[1] / 12
- gs 'stat'
- end
- --- sleep_simple ---------------------------------
|