sleep.qsrc 4.9 KB

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