sleep_simple.qsrc 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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: pcs_health += 5
  38. if sleepVars['stime'] mod 5 = 0: pcs_sleep += 1
  39. if sleepVars['stime'] >= 60: sleepVars['stime'] = 0
  40. if minut = 60: gs 'stat'
  41. gs 'sleep_simple', 'mod_sleeptriggers'
  42. if sleepVars['minutes_to_wakeup'] > 0: jump 'sleep_simple_loop'
  43. sleepVars['no_health'] = 0
  44. sleepVars['time_now'] = daystart * 1440 + hour * 60 + minut
  45. InSleep = 0
  46. gs 'stat'
  47. end
  48. if $ARGS[0] = 'mod_sleeptriggers':
  49. !! This location is here to allow mods to hook into the system.
  50. !! Check for: if $ARGS[0] = 'sleep_simple' and $ARGS[1] = 'mod_sleeptriggers'
  51. !!
  52. !! This is NOT for events!!
  53. gs 'LOCA', 'sleep_simple', 'mod_sleeptriggers'
  54. end
  55. if $ARGS[0] = 'nap_bed':
  56. cla
  57. menu_off = 1
  58. if pcs_sleep < 10:
  59. gs 'shortgs', 'autosave'
  60. gt 'pre_sleep', 'prepare_sleep'
  61. elseif pcs_sleep <= 90:
  62. InSleep = 1
  63. gs 'sleep_simple', 'nap_base', 60
  64. *nl
  65. if ARGS[1] = 0: 'You sleep about an hour.'
  66. else
  67. minut += 5
  68. *nl
  69. if ARGS[1] = 0: 'You are not tired enough to sleep, even for a short nap.'
  70. end
  71. gs 'stat'
  72. act 'Get up': InSleep = 0 & gt 'bed_get_out', 'start'
  73. end
  74. if $ARGS[0] = 'nap':
  75. cla
  76. menu_off = 1
  77. if pcs_sleep <= 90:
  78. InSleep = 1
  79. gs 'sleep_simple', 'nap_base', 60
  80. *nl
  81. if ARGS[1] = 0: 'You nap for about an hour.'
  82. else
  83. minut += 5
  84. *nl
  85. if ARGS[1] = 0: 'You are not tired enough even for a short nap.'
  86. end
  87. gs 'stat'
  88. InSleep = 0
  89. act 'Get up': gt $loc, $loc_arg
  90. end
  91. if $ARGS[0] = 'nap_base':
  92. if ARGS[1] > 0:
  93. minut += ARGS[1]
  94. else
  95. ARGS[1] *= -1
  96. end
  97. pcs_sleep += ARGS[1] / 6
  98. pcs_health += ARGS[1] / 12
  99. gs 'stat'
  100. end
  101. --- sleep_simple ---------------------------------