sleep_simple.qsrc 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. # sleep_simple
  2. if $ARGS[0] = 'simple':
  3. !! to avoid sleeping the whole day I decide to calculate the duration of the sleep in advance
  4. !! 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
  5. sleepVars['time_to_full'] = (100 - pcs_sleep) * 5
  6. !! fully exhausted Sveta can recover in 500 minutes = 8 hours of sleep
  7. !! healthy Sveta can hardly sleep more then 10 hours = 600 minutes
  8. !! so we can add about 2 hours to time to full as a limit
  9. sleepVars['time_to_full'] += 60 + rand(0, 90)
  10. gs 'sleep', 'calc_minutes_to_wakeup'
  11. gs 'sleep_simple', 'loop'
  12. end
  13. if $ARGS[0] = 'forced':
  14. if ARGS[1] <= 0:
  15. gs 'sleep_simple', 'simple'
  16. exit
  17. end
  18. sleepVars['time_to_full'] = (100 - pcs_sleep) * 5
  19. sleepVars['time_to_full'] += 60 + rand(0, 90)
  20. sleepVars['minutes_to_wakeup'] = ARGS[1]
  21. gs 'sleep_simple', 'loop'
  22. end
  23. if $ARGS[0] = 'sleep_until':
  24. temp_minutes = (ARGS[1] - hour) * 60 + ARGS[2] - minut
  25. if temp_minutes < 0: temp_minutes += 1440
  26. gs 'sleep_simple', 'forced', temp_minutes
  27. killvar 'temp_minutes'
  28. end
  29. if $ARGS[0] = 'loop':
  30. InSleep = 1
  31. :sleep_simple_loop
  32. minut += 1
  33. sleepVars['stime'] += 1
  34. sleepVars['time_now'] += 1
  35. sleepVars['minutes_to_wakeup'] -= 1
  36. sleepVars['time_to_full'] -= 1
  37. if recuperation = 0 or SleepVars['no_health'] = 1: sleepVars['health_stock'] += healthmax
  38. if sleepVars['health_stock'] >= 960:
  39. pcs_health += sleepVars['health_stock'] / 960
  40. sleepVars['health_stock'] = sleepVars['health_stock'] mod 960
  41. end
  42. if sleepVars['stime'] mod 5 = 0: pcs_sleep += 1
  43. if sleepVars['stime'] >= 60: sleepVars['stime'] = 0
  44. if minut = 60: gs 'stat'
  45. gs 'sleep_simple', 'mod_sleeptriggers'
  46. if sleepVars['minutes_to_wakeup'] > 0: jump 'sleep_simple_loop'
  47. sleepVars['no_health'] = 0
  48. sleepVars['time_now'] = daystart * 1440 + hour * 60 + minut
  49. InSleep = 0
  50. gs 'stat'
  51. end
  52. if $ARGS[0] = 'mod_sleeptriggers':
  53. !! This location is here to allow mods to hook into the system.
  54. !! Check for: if $ARGS[0] = 'sleep_simple' and $ARGS[1] = 'mod_sleeptriggers'
  55. !!
  56. !! This is NOT for events!!
  57. gs 'LOCA', 'sleep_simple', 'mod_sleeptriggers'
  58. end
  59. if $ARGS[0] = 'nap_bed':
  60. cla
  61. menu_off = 1
  62. if pcs_sleep < 10:
  63. gs 'shortgs', 'autosave'
  64. gt 'pre_sleep', 'prepare_sleep'
  65. elseif pcs_sleep <= 90:
  66. InSleep = 1
  67. gs 'sleep_simple', 'nap_base', 60
  68. *nl
  69. if ARGS[1] = 0: 'You sleep about an hour.'
  70. else
  71. minut += 5
  72. *nl
  73. if ARGS[1] = 0: 'You are not tired enough to sleep, even for a short nap.'
  74. end
  75. gs 'stat'
  76. act 'Get up': InSleep = 0 & gt 'bed_get_out', 'start'
  77. end
  78. if $ARGS[0] = 'nap':
  79. cla
  80. menu_off = 1
  81. if pcs_sleep <= 90:
  82. InSleep = 1
  83. gs 'sleep_simple', 'nap_base', 60
  84. *nl
  85. if ARGS[1] = 0: 'You nap for about an hour.'
  86. else
  87. minut += 5
  88. *nl
  89. if ARGS[1] = 0: 'You are not tired enough even for a short nap.'
  90. end
  91. gs 'stat'
  92. InSleep = 0
  93. act 'Get up': gt $loc, $loc_arg
  94. end
  95. if $ARGS[0] = 'nap_base':
  96. if ARGS[1] > 0:
  97. minut += ARGS[1]
  98. else
  99. ARGS[1] *= -1
  100. end
  101. pcs_sleep += ARGS[1] / 6
  102. pcs_health += ARGS[1] / 12
  103. gs 'stat'
  104. end
  105. --- sleep_simple ---------------------------------