big steppy
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 

480 wiersze
12 KiB

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