a munch adventure
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 

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