a munch adventure
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

179 line
5.6 KiB

  1. (() => {
  2. let digestRate = 0.5;
  3. function devour(state, count) {
  4. state.player.stats.stomach.value += count;
  5. state.player.stats.eaten.value += count;
  6. playRandomSfx("swallow");
  7. }
  8. function digest(state, count) {
  9. if (count === undefined) {
  10. count = digestRate * (state.player.stats.stomach.value / 100 + 2);
  11. }
  12. count = Math.min(state.player.stats.stomach.value, count);
  13. count = Math.floor(count);
  14. state.player.stats.stomach.value -= count;
  15. state.player.stats.digested.value += count;
  16. state.player.stats.gas.value += count * 3;
  17. }
  18. sfxGroups = {
  19. "swallow": [
  20. "sfx/swallows/swallow-1.ogg",
  21. "sfx/swallows/swallow-2.ogg",
  22. "sfx/swallows/swallow-3.ogg",
  23. "sfx/swallows/swallow-4.ogg",
  24. "sfx/swallows/swallow-5.ogg",
  25. "sfx/swallows/swallow-6.ogg",
  26. "sfx/swallows/swallow-7.ogg",
  27. ]
  28. }
  29. function playRandomSfx(category) {
  30. const choice = Math.floor(Math.random() * sfxGroups[category].length);
  31. playSfx(sfxGroups[category][choice]);
  32. }
  33. stories.push({
  34. id: "mass-vore",
  35. name: "Mass Vore",
  36. tags: [
  37. "Player Predator",
  38. "Macro/Micro",
  39. "Digestion"
  40. ],
  41. sounds: [
  42. "sfx/belches/belch.ogg",
  43. "loop/stomach/stomach.ogg"
  44. ].concat(sfxGroups["swallow"]),
  45. preload: [
  46. "loop/stomach/stomach.ogg"
  47. ],
  48. intro: {
  49. start: "city",
  50. setup: state => {
  51. state.player.stats.fullness = {
  52. name: "Fullness",
  53. type: "meter",
  54. get value() {
  55. return state.player.stats.gas.value + state.player.stats.stomach.value;
  56. },
  57. min: 0,
  58. max: 10000,
  59. color: "rgb(200,20,100)"
  60. };
  61. state.player.stats.gas = {
  62. name: "Gas",
  63. type: "meter",
  64. value: 0,
  65. min: 0,
  66. get max() {
  67. return 10000 - state.player.stats.stomach.value;
  68. },
  69. color: "rgb(10,200,100)"
  70. }
  71. state.player.stats.stomach = {
  72. name: "Stomach",
  73. type: "meter",
  74. value: 0,
  75. min: 0,
  76. max: 10000,
  77. color: "rgb(255,10,150)"
  78. }
  79. state.player.stats.eaten = {
  80. name: "Eaten",
  81. type: "counter",
  82. value: 0
  83. }
  84. state.player.stats.digested = {
  85. name: "Digested",
  86. type: "counter",
  87. value: 0
  88. }
  89. startTimer({
  90. id: "belch",
  91. func: state => {
  92. if (state.player.stats.gas.value > state.player.stats.gas.max) {
  93. print(["BUURRRRRP!"]);
  94. playSfx("sfx/belches/belch.ogg");
  95. state.player.stats.gas.value /= 3;
  96. }
  97. return true;
  98. },
  99. delay: 100,
  100. loop: true,
  101. classes: [
  102. ]
  103. }, state);
  104. startTimer({
  105. id: "digestion",
  106. func: state => {
  107. digest(state);
  108. const rateChange = (digestRate - 0.5) / 1000
  109. digestRate -= rateChange;
  110. let vol = state.player.stats.fullness.value / state.player.stats.fullness.max
  111. vol = Math.sqrt(vol);
  112. playLoop("loop/stomach/stomach.ogg", vol);
  113. return true;
  114. },
  115. delay: 1000/60,
  116. loop: true,
  117. classes: [
  118. ]
  119. }, state);
  120. },
  121. intro: state => {
  122. print(["Munch time"]);
  123. }
  124. },
  125. world: {
  126. "city": {
  127. id: "",
  128. name: "",
  129. desc: "",
  130. move: (room, state) => {
  131. },
  132. enter: (room, state) => {
  133. },
  134. exit: (room, state) => {
  135. },
  136. hooks: [
  137. ],
  138. actions: [
  139. {
  140. name: "Eat",
  141. desc: "Munch!",
  142. execute: (room, state) => {
  143. const victims = Math.floor((0.5 + Math.random()) * 500);
  144. print(["You scoop up " + victims + " people and swallow them down."]);
  145. devour(state, victims);
  146. }
  147. },
  148. {
  149. name: "Rub",
  150. desc: "Rub your belly",
  151. execute: (room, state) => {
  152. print(["You rub over the " + state.player.stats.stomach.value + " prey in your guts, hastening their digestion."]);
  153. digestRate += 0.25;
  154. }
  155. }
  156. ],
  157. exits: {
  158. }
  159. }
  160. }
  161. });
  162. })();