1
0

sleep.qsrc 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. # sleep
  2. !! Deals with the sleep cycle, advancing both time and stats during sleep.
  3. !!
  4. !! Moved here from pre_sleep
  5. !! Move to dream_events. Then back to sleep (this location).
  6. !! When busy moves back and forth to sleep_events (and can be redirected from there)
  7. !! When done: Move to wakeup
  8. if $ARGS[0] = 'full':
  9. msg 'gt ''sleep'', ''full'' is depricated! If you did not load an old save, please report this bug. You can continue playing without worry.'
  10. gt 'pre_sleep', 'start'
  11. end
  12. if $ARGS[0] = 'sleep':
  13. msg 'gt ''sleep'', ''sleep'' is depricated! If you did not load an old save, please report this bug. You can continue playing without worry.'
  14. gt 'pre_sleep', 'prepare_sleep'
  15. end
  16. if $ARGS[0] = 'dream':
  17. msg 'gt ''sleep'', ''dream'' is depricated! If you did not load an old save, please report this bug. You can continue playing without worry.'
  18. gt 'sleep', 'start'
  19. end
  20. if $ARGS[0] = 'wake':
  21. msg 'gt ''sleep'', ''wake'' is depricated! If you did not load an old save, please report this bug. You can continue playing without worry.'
  22. gt 'wakeup', 'start'
  23. end
  24. if $ARGS[0] = 'end':
  25. msg 'gt ''sleep'', ''end'' is depricated! If you did not load an old save, please report this bug. You can continue playing without worry.'
  26. gt 'bed_get_out', 'start'
  27. end
  28. if $ARGS[0] = '':
  29. msg 'gt ''sleep'', is depricated! If you did not load an old save, please report this bug. You can continue playing without worry.'
  30. gt 'pre_sleep', 'start'
  31. end
  32. if $ARGS[0] = 'start':
  33. menu_off = 1
  34. gt 'dream_events', 'start'
  35. end
  36. if $ARGS[0] = 'post_dream':
  37. menu_off = 1
  38. !! to avoid sleeping the whole day I decide to calcululate the duration of the sleep in advance
  39. !! 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
  40. sleepVars['time_to_full'] = (100 - pcs_sleep) * 5
  41. !! fully exhausted Sveta can recover in 500 minutes = 8 hours of sleep
  42. !! healthy Sveta can hardly sleep more then 10 hours = 600 minutes
  43. !! so we can add about 2 hours to time to full as a limit
  44. sleepVars['time_to_full'] += 60 + rand(0, 90)
  45. xgt 'sleep', 'sleep_handler'
  46. end
  47. if $ARGS[0] = 'sleep_handler':
  48. menu_off = 1
  49. gs 'sleep', 'calc_minutes_to_wakeup'
  50. if sleepVars['minutes_to_wakeup'] > 0:
  51. xgt 'sleep', 'sleep_loop'
  52. else
  53. killvar 'sleep_loop_loop'
  54. xgt 'sleep', 'post_sleep'
  55. end
  56. end
  57. if $ARGS[0] = 'calc_minutes_to_wakeup':
  58. sleepVars['time_now'] = daystart * 1440 + hour * 60 + minut
  59. if alarmVars['alarmOn'] = 1 and sleepVars['slept_in'] = 0:
  60. if (hour < alarmVars['timerEndH'] and ((alarmVars['alarm_holiday'] = 1 and kanikuli ! 0) or (week = 6 or week = 7))) or (hour => alarmVars['timerEndH'] and ((alarmVars['alarm_holiday'] = 1 and func('sleep', 'is_tomorrow_school_vacation') ! 0) or (week = 5 or week = 6))):
  61. !! use weekend time alarm
  62. sleepVars['alarm_time'] = daystart * 1440 + alarmVars['timerEndH'] * 60 + alarmVars['timerEndM']
  63. else
  64. sleepVars['alarm_time'] = daystart * 1440 + alarmVars['timerH'] * 60 + alarmVars['timerM']
  65. end
  66. if sleepVars['time_now'] > sleepVars['alarm_time']: sleepVars['alarm_time'] += 1440
  67. sleepVars['minutes_to_wakeup'] = min(sleepVars['time_to_full'], sleepVars['alarm_time'] - sleepVars['time_now'])
  68. else
  69. sleepVars['minutes_to_wakeup'] = sleepVars['time_to_full']
  70. end
  71. end
  72. if $ARGS[0] = 'is_tomorrow_school_vacation':
  73. result = 0
  74. if mid($start_type, 1, 2) = 'sg':
  75. if (month = 12 and day = 31) or (month = 1 and day <= 14):
  76. !! Winter Break
  77. result = 2
  78. elseif month = 3 and (day >= 19 and day <= 25):
  79. !! Spring Break
  80. result = 3
  81. elseif (month = 5 and day = 31) or month = 6 or month = 7 or (month = 8 and day <= 30):
  82. !! Summer Break
  83. result = 4
  84. elseif month = 11 and (day >= 3 and day <= 10):
  85. !! Autumn Break
  86. result = 1
  87. end
  88. end
  89. end
  90. if $ARGS[0] = 'sleep_loop':
  91. menu_off = 1
  92. :sleep_loop_loop
  93. minut += 1
  94. sleepVars['stime'] += 1
  95. sleepVars['time_now'] += 1
  96. sleepVars['minutes_to_wakeup'] -= 1
  97. sleepVars['time_to_full'] -= 1
  98. if recuperation = 0 or sleepVars['no_health'] = 1: pcs_health += 5
  99. if vibratorIN = 1:
  100. sleepVars['vtime'] += 1
  101. if sleepVars['vtime'] >= 5:
  102. pcs_horny += 1
  103. sleepVars['vtime'] = 0
  104. end
  105. end
  106. if sleepVars['stime'] mod 5 = 0: pcs_sleep += 1
  107. if sleepVars['stime'] >= 60:
  108. sleepVars['stime'] = 0
  109. if pcs_sleep >= 100 or succublvl > 0:
  110. pcs_condition['lack_of_sleep'] = 0
  111. elseif pcs_condition['lack_of_sleep'] > 0:
  112. pcs_condition['lack_of_sleep'] -= 1
  113. end
  114. gs 'stat'
  115. end
  116. if minut = 60: gs 'stat'
  117. gs 'sleep', 'mod_sleeptriggers'
  118. if sleepVars['stime'] mod 5 = 0:
  119. gs 'sleep_events', 'start'
  120. end
  121. if sleepVars['minutes_to_wakeup'] > 0: jump 'sleep_loop_loop'
  122. sleepVars['no_health'] = 0
  123. xgt 'sleep', 'post_sleep'
  124. end
  125. if $ARGS[0] = 'mod_sleeptriggers':
  126. !! This location is here to allow mods to hook into the system.
  127. !! Check for: if $ARGS[0] = 'pre_sleep' and $ARGS[1] = 'mod_sleeptriggers'
  128. !!
  129. !! This is NOT for events!!
  130. gs 'LOCA', 'sleep', 'mod_sleeptriggers'
  131. end
  132. if $ARGS[0] = 'post_sleep':
  133. menu_off = 1
  134. if succublvl < 0:
  135. skinDailyPenalty -= 1
  136. else
  137. if pcs_condition['lack_of_sleep'] >= 10:
  138. !!Worsening of skin quality if you do not sleep enough.
  139. skinDailyPenalty += 2
  140. elseif pcs_condition['lack_of_sleep'] >= 2:
  141. skinDailyPenalty += 1
  142. elseif pcs_condition['lack_of_sleep'] > 0:
  143. skinDailyPenalty += 0
  144. else
  145. skinDailyPenalty -= 1
  146. end
  147. end
  148. gs 'stat'
  149. xgt 'wakeup', 'start'
  150. end
  151. --- sleep ---------------------------------