sleep.qsrc 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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 vibratorIN = 1:
  99. sleepVars['vtime'] += 1
  100. if sleepVars['vtime'] >= 5:
  101. pcs_horny += 1
  102. sleepVars['vtime'] = 0
  103. end
  104. end
  105. if recuperation = 0 or SleepVars['no_health'] = 1: sleepVars['health_stock'] += healthmax
  106. if sleepVars['health_stock'] >= 960:
  107. pcs_health += sleepVars['health_stock'] / 960
  108. sleepVars['health_stock'] = sleepVars['health_stock'] mod 960
  109. end
  110. if sleepVars['stime'] mod 5 = 0: pcs_sleep += 1
  111. if sleepVars['stime'] >= 60:
  112. sleepVars['stime'] = 0
  113. if pcs_sleep >= 100 or succublvl > 0:
  114. pcs_condition['lack_of_sleep'] = 0
  115. elseif pcs_condition['lack_of_sleep'] > 0:
  116. pcs_condition['lack_of_sleep'] -= 1
  117. end
  118. gs 'stat'
  119. end
  120. if minut = 60: gs 'stat'
  121. gs 'sleep', 'mod_sleeptriggers'
  122. if sleepVars['stime'] mod 5 = 0: gs 'sleep_events', 'start'
  123. if sleepVars['minutes_to_wakeup'] > 0: jump 'sleep_loop_loop'
  124. sleepVars['no_health'] = 0
  125. xgt 'sleep', 'post_sleep'
  126. end
  127. if $ARGS[0] = 'mod_sleeptriggers':
  128. !! This location is here to allow mods to hook into the system.
  129. !! Check for: if $ARGS[0] = 'pre_sleep' and $ARGS[1] = 'mod_sleeptriggers'
  130. !!
  131. !! This is NOT for events!!
  132. gs 'LOCA', 'sleep', 'mod_sleeptriggers'
  133. end
  134. if $ARGS[0] = 'post_sleep':
  135. menu_off = 1
  136. if succublvl < 0:
  137. skinDailyPenalty -= 1
  138. else
  139. if pcs_condition['lack_of_sleep'] >= 10:
  140. !!Worsening of skin quality if you do not sleep enough.
  141. skinDailyPenalty += 2
  142. elseif pcs_condition['lack_of_sleep'] >= 2:
  143. skinDailyPenalty += 1
  144. elseif pcs_condition['lack_of_sleep'] > 0:
  145. skinDailyPenalty += 0
  146. else
  147. skinDailyPenalty -= 1
  148. end
  149. end
  150. gs 'stat'
  151. xgt 'wakeup', 'start'
  152. end
  153. --- sleep ---------------------------------