big steppy
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.
 
 
 

492 satır
12 KiB

  1. var strolling = false;
  2. var maxStomachDigest = 10;
  3. var maxBowelsDigest = 10;
  4. var unit = "metric";
  5. var verbose = true;
  6. var biome = "suburb";
  7. var newline = " ";
  8. victims = {};
  9. var macro =
  10. {
  11. "scaling": function(value, scale, factor) { return value * Math.pow(scale,factor); },
  12. "species": "crux",
  13. "color" : "blue",
  14. "baseHeight": 2.26,
  15. get height() { return this.scaling(this.baseHeight, this.scale, 1); },
  16. "baseMass": 135,
  17. get mass () { return this.scaling(this.baseMass, this.scale, 3); },
  18. "basePawArea": 0.1,
  19. get pawArea() { return this.scaling(this.basePawArea, this.scale, 2); },
  20. "baseAnalVoreArea": 0.1,
  21. get analVoreArea() { return this.scaling(this.baseAnalVoreArea, this.scale, 2); },
  22. "baseAssArea": 0.4,
  23. get assArea() { return this.scaling(this.baseAssArea, this.scale, 2); },
  24. "baseHandArea": 0.3,
  25. get handArea() { return this.scaling(this.baseHandArea, this.scale, 2); },
  26. "scale": 3,
  27. "scaleWithMass": function(mass) {
  28. var startMass = this.mass;
  29. var newMass = startMass + mass;
  30. this.scale = Math.pow(newMass / this.baseMass, 1/3);
  31. }
  32. }
  33. function look()
  34. {
  35. var line1 = "You are a " + length(macro.height, unit, true) + " tall " + macro.species + ". You weigh " + mass(macro.mass, unit) + ".";
  36. var line2 = ""
  37. switch(biome) {
  38. case "rural": line2 = "You're standing amongst rural farmhouses and expansive ranches. Cattle are milling about at your feet."; break;
  39. case "suburb": line2 = "You're striding through the winding roads of a suburb."; break;
  40. case "city": line2 = "You're terrorizing the streets of a city. Heavy traffic, worsened by your rampage, is everywhere."; break;
  41. case "downtown": line2 = "You're lurking amongst the skyscrapers of downtown. The streets are packed, and the buildings are practically begging you to knock them over.";
  42. }
  43. update([line1,newline,line2,newline]);
  44. }
  45. function get_living_prey(sum) {
  46. var total = 0;
  47. for (var key in sum) {
  48. if (sum.hasOwnProperty(key)) {
  49. if (key == "Person" || key == "Cow")
  50. total += sum[key];
  51. }
  52. }
  53. return total;
  54. }
  55. function toggle_auto()
  56. {
  57. strolling = !strolling;
  58. document.getElementById("button-stroll").innerHTML = "Status: " + (strolling ? "Strolling" : "Standing");
  59. if (strolling)
  60. update(["You start walking.",newline]);
  61. else
  62. update(["You stop walking.",newline]);
  63. }
  64. function change_location()
  65. {
  66. switch(biome) {
  67. case "suburb": biome = "city"; break;
  68. case "city": biome = "downtown"; break;
  69. case "downtown": biome = "rural"; break;
  70. case "rural": biome = "suburb"; break;
  71. }
  72. document.getElementById("button-location").innerHTML = "Location: " + biome.charAt(0).toUpperCase() + biome.slice(1);
  73. }
  74. function toggle_units()
  75. {
  76. switch(unit) {
  77. case "metric": unit = "customary"; break;
  78. case "customary": unit = "approx"; break;
  79. case "approx": unit = "metric"; break;
  80. }
  81. document.getElementById("button-units").innerHTML = "Units: " + unit.charAt(0).toUpperCase() + unit.slice(1);
  82. update();
  83. }
  84. function toggle_verbose()
  85. {
  86. verbose = !verbose;
  87. document.getElementById("button-verbose").innerHTML = "Descriptions: " + (verbose ? "Verbose" : "Simple");
  88. }
  89. function initVictims()
  90. {
  91. return {
  92. "Person": 0,
  93. "Cow": 0,
  94. "Car": 0,
  95. "Bus": 0,
  96. "Tram": 0,
  97. "Motorcycle": 0,
  98. "House": 0,
  99. "Barn": 0,
  100. "Small Skyscraper": 0,
  101. "Train": 0,
  102. "Train Car": 0,
  103. "Parking Garage": 0,
  104. "Overpass": 0,
  105. };
  106. };
  107. // lists out total people
  108. function summarize(sum, fatal = true)
  109. {
  110. var count = get_living_prey(sum);
  111. return "<b>(" + count + " " + (fatal ? (count > 1 ? "kills" : "kill") : (count > 1 ? "prey" : "prey")) + ")</b>";
  112. }
  113. var stomach = []
  114. var bowels = []
  115. function getOnePrey(biome,area)
  116. {
  117. var potential = ["Person"];
  118. switch(biome) {
  119. case "suburb": potential = ["Person", "Car", "Bus", "Train", "House"]; break;
  120. case "city": potential = ["Person", "Car", "Bus", "Train", "Tram", "House", "Parking Garage"]; break;
  121. case "downtown": potential = ["Person", "Car", "Bus", "Tram", "Small Skyscraper", "Parking Garage"]; break;
  122. case "rural": potential = ["Person", "Barn", "House", "Cow"]; break;
  123. }
  124. var potAreas = []
  125. potential.forEach(function (x) {
  126. potAreas.push([x,areas[x]]);
  127. });
  128. potAreas = potAreas.sort(function (x,y) {
  129. return y[1] - x[1];
  130. });
  131. for (var i=0; i<potAreas.length; i++) {
  132. x = potAreas[i];
  133. if (x[1] < area) {
  134. return new things[x[0]](1);
  135. }
  136. };
  137. return new Person(1);
  138. }
  139. function getPrey(region, area)
  140. {
  141. var weights = {"Person": 1};
  142. switch(region)
  143. {
  144. case "rural": weights = {
  145. "Person": 0.05,
  146. "House": 0.01,
  147. "Barn": 0.01,
  148. "Cow": 0.2
  149. }; break;
  150. case "suburb": weights = {
  151. "Person": 0.5,
  152. "House": 0.5,
  153. "Car": 0.2,
  154. "Train": 0.1,
  155. "Bus": 0.1
  156. }; break;
  157. case "city": weights = {
  158. "Person": 0.5,
  159. "House": 0.2,
  160. "Car": 0.2,
  161. "Train": 0.1,
  162. "Bus": 0.1,
  163. "Tram": 0.1,
  164. "Parking Garage": 0.02
  165. }; break;
  166. case "downtown": weights = {
  167. "Person": 0.5,
  168. "Car": 0.3,
  169. "Bus": 0.15,
  170. "Tram": 0.1,
  171. "Parking Garage": 0.02,
  172. "Small Skyscraper": 0.4
  173. }; break;
  174. }
  175. return fill_area2(area,weights);
  176. }
  177. function updateVictims(type,prey)
  178. {
  179. var sums = prey.sum();
  180. for (var key in sums) {
  181. if (sums.hasOwnProperty(key)) {
  182. victims[type][key] += sums[key];
  183. }
  184. }
  185. }
  186. function feed()
  187. {
  188. var area = macro.handArea;
  189. var prey = getPrey(biome, area);
  190. var line = prey.eat(verbose)
  191. var linesummary = summarize(prey.sum(), false);
  192. var people = get_living_prey(prey.sum());
  193. var sound = "Ulp";
  194. if (people < 3) {
  195. sound = "Ulp.";
  196. } else if (people < 10) {
  197. sound = "Gulp.";
  198. } else if (people < 50) {
  199. sound = "Glrrp.";
  200. } else if (people < 500) {
  201. sound = "Glrrrpkh!";
  202. } else if (people < 5000) {
  203. sound = "GLRRKPKH!";
  204. } else {
  205. sound = "Oh the humanity!";
  206. }
  207. var preyMass = prey.sum_property("mass");
  208. macro.scaleWithMass(preyMass);
  209. stomach.push(prey);
  210. if (stomach.length == 1)
  211. setTimeout(function() { doDigest("stomach"); }, 15000);
  212. updateVictims("stomach",prey);
  213. update([sound,line,linesummary,newline]);
  214. }
  215. function stomp()
  216. {
  217. var area = macro.pawArea;
  218. var prey = getPrey(biome, area);
  219. var line = prey.stomp(verbose)
  220. var linesummary = summarize(prey.sum(), true);
  221. var people = get_living_prey(prey.sum());
  222. var sound = "Thump";
  223. if (people < 3) {
  224. sound = "Thump!";
  225. } else if (people < 10) {
  226. sound = "Squish!";
  227. } else if (people < 50) {
  228. sound = "Crunch!";
  229. } else if (people < 500) {
  230. sound = "CRUNCH!";
  231. } else if (people < 5000) {
  232. sound = "CRRUUUNCH!!";
  233. } else {
  234. sound = "Oh the humanity!";
  235. }
  236. var preyMass = prey.sum_property("mass");
  237. macro.scaleWithMass(preyMass);
  238. updateVictims("stomped",prey);
  239. update([sound,line,linesummary,newline]);
  240. }
  241. function anal_vore()
  242. {
  243. var area = macro.analVoreArea;
  244. var prey = getOnePrey(biome,area);
  245. area = macro.assArea;
  246. var crushed = getPrey(biome,area);
  247. var line1 = prey.anal_vore(verbose, macro.height);
  248. var line1summary = summarize(prey.sum(), false);
  249. var line2 = crushed.buttcrush(verbose);
  250. var line2summary = summarize(crushed.sum(), true);
  251. var people = get_living_prey(prey.sum());
  252. var sound = "Shlp";
  253. if (people < 3) {
  254. sound = "Shlp.";
  255. } else if (people < 10) {
  256. sound = "Squelch.";
  257. } else if (people < 50) {
  258. sound = "Shlurrp.";
  259. } else if (people < 500) {
  260. sound = "SHLRP!";
  261. } else if (people < 5000) {
  262. sound = "SQLCH!!";
  263. } else {
  264. sound = "Oh the humanity!";
  265. }
  266. var people = get_living_prey(crushed.sum());
  267. var sound2 = "Thump";
  268. if (people < 3) {
  269. sound2 = "Thump!";
  270. } else if (people < 10) {
  271. sound2 = "Squish!";
  272. } else if (people < 50) {
  273. sound2 = "Crunch!";
  274. } else if (people < 500) {
  275. sound2 = "CRUNCH!";
  276. } else if (people < 5000) {
  277. sound2 = "CRRUUUNCH!!";
  278. } else {
  279. sound2 = "Oh the humanity!";
  280. }
  281. var preyMass = prey.sum_property("mass");
  282. var crushedMass = prey.sum_property("mass");
  283. macro.scaleWithMass(preyMass);
  284. macro.scaleWithMass(crushedMass);
  285. bowels.push(prey);
  286. if (bowels.length == 1)
  287. setTimeout(function() { doDigest("bowels"); }, 15000);
  288. updateVictims("bowels",prey);
  289. updateVictims("stomped",crushed);
  290. update([sound,line1,line1summary,newline,sound2,line2,line2summary,newline]);
  291. }
  292. function update(lines = [])
  293. {
  294. var log = document.getElementById("log");
  295. lines.forEach(function (x) {
  296. var line = document.createElement('div');
  297. line.innerHTML = x;
  298. log.appendChild(line);
  299. });
  300. log.scrollTop = log.scrollHeight;
  301. document.getElementById("height").innerHTML = "Height: " + length(macro.height, unit);
  302. document.getElementById("mass").innerHTML = "Mass: " + mass(macro.mass, unit);
  303. for (var type in victims) {
  304. if (victims.hasOwnProperty(type)) {
  305. for (var key in victims[type]){
  306. if (victims[type].hasOwnProperty(key)) {
  307. if (document.getElementById("stats-" + type + "-" + key) == null) {
  308. if (victims[type][key] == 0)
  309. continue;
  310. child = document.createElement('div');
  311. child.id = "stats-" + type + "-" + key;
  312. child.classList.add("stat-line");
  313. document.getElementById("stats-" + type).appendChild(child);
  314. }
  315. document.getElementById("stats-" + type + "-" + key).innerHTML = key + ": " + victims[type][key];
  316. }
  317. }
  318. }
  319. }
  320. }
  321. function pick_move()
  322. {
  323. if (!strolling) {
  324. setTimeout(pick_move, 1500 * Math.sqrt(macro.scale));
  325. return;
  326. }
  327. var choice = Math.random();
  328. if (choice < 0.2) {
  329. anal_vore();
  330. } else if (choice < 0.6) {
  331. stomp();
  332. } else {
  333. feed();
  334. }
  335. setTimeout(pick_move, 1500 * Math.sqrt(macro.scale));
  336. }
  337. function grow()
  338. {
  339. var oldHeight = macro.height;
  340. var oldMass = macro.mass;
  341. macro.scale *= 1.2;
  342. var newHeight = macro.height;
  343. var newMass = macro.mass;
  344. var heightDelta = newHeight - oldHeight;
  345. var massDelta = newMass - oldMass;
  346. var heightStr = length(heightDelta, unit);
  347. var massStr = mass(massDelta, unit);
  348. update(["Power surges through you as you grow " + heightStr + " taller and gain " + massStr + " of mass",newline]);
  349. }
  350. // pop the list and digest that object
  351. function doDigest(containerName)
  352. {
  353. var digestType = containerName == "stomach" ? stomach : bowels;
  354. var count = 0
  355. if (containerName == "stomach") {
  356. count = stomach.length;
  357. count = Math.min(count,maxStomachDigest);
  358. } else if (containerName == "bowels") {
  359. count = bowels.length;
  360. count = Math.min(count,maxBowelsDigest);
  361. }
  362. var container = new Container();
  363. while (count > 0) {
  364. --count;
  365. var toDigest = digestType.shift();
  366. if (toDigest.name != "Container")
  367. toDigest = new Container([toDigest]);
  368. container = container.merge(toDigest);
  369. }
  370. var digested = container.sum();
  371. for (var key in victims[containerName]) {
  372. if (victims[containerName].hasOwnProperty(key) && digested.hasOwnProperty(key) ) {
  373. victims["digested"][key] += digested[key];
  374. victims[containerName][key] -= digested[key];
  375. }
  376. }
  377. if (containerName == "stomach")
  378. update(["Your stomach gurgles as it digests " + container.describe(false),summarize(container.sum()),newline]);
  379. else if (containerName == "bowels")
  380. update(["Your bowels churn as they absorb " + container.describe(false),summarize(container.sum()),newline]);
  381. if (digestType.length > 0) {
  382. setTimeout(function() {
  383. doDigest(containerName);
  384. }, 15000);
  385. }
  386. }
  387. window.addEventListener('load', function(event) {
  388. victims["stomped"] = initVictims();
  389. victims["digested"] = initVictims();
  390. victims["stomach"] = initVictims();
  391. victims["bowels"] = initVictims();
  392. document.getElementById("button-look").addEventListener("click",look);
  393. document.getElementById("button-grow").addEventListener("click",grow);
  394. document.getElementById("button-feed").addEventListener("click",feed);
  395. document.getElementById("button-stomp").addEventListener("click",stomp);
  396. document.getElementById("button-anal_vore").addEventListener("click",anal_vore);
  397. document.getElementById("button-stroll").addEventListener("click",toggle_auto);
  398. document.getElementById("button-location").addEventListener("click",change_location);
  399. document.getElementById("button-units").addEventListener("click",toggle_units);
  400. document.getElementById("button-verbose").addEventListener("click",toggle_verbose);
  401. setTimeout(pick_move, 2000);
  402. update();
  403. });