crunch
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 

462 rindas
11 KiB

  1. "use strict";
  2. function Creature(name = "Creature", str=10, dex=10, con=10) {
  3. this.name = name;
  4. this.mass = 80;
  5. this.bowels = new Bowels();
  6. this.stomach = new Stomach(this.bowels);
  7. this.butt = new Butt(this.bowels,this.stomach);
  8. this.attacks = [];
  9. this.str = str;
  10. this.dex = dex;
  11. this.con = con;
  12. this.hasName = false;
  13. Object.defineProperty(this, "maxHealth", {get: function() { return this.str * 5 + this.con * 10 }});
  14. this.health = this.maxHealth;
  15. Object.defineProperty(this, "maxStamina", {get: function() { return this.dex * 5 + this.con * 10 }});
  16. this.stamina = this.maxStamina;
  17. // fraction of max health per second
  18. this.healthRate = 1 / 86400 * 12;
  19. this.staminaRate = 1 / 86400 * 48;
  20. this.restoreHealth = function(time) {
  21. this.health = Math.min(this.maxHealth, this.health + this.maxHealth * time * this.healthRate);
  22. };
  23. this.restoreStamina = function(time) {
  24. this.stamina = Math.min(this.maxStamina, this.stamina + this.maxStamina * time * this.staminaRate);
  25. };
  26. this.flags = {};
  27. this.clear = function() {
  28. this.flags = {};
  29. };
  30. this.prefs = {
  31. prey: true,
  32. scat: true,
  33. analVore: true,
  34. gore: true
  35. };
  36. this.cash = Math.floor(Math.random() * 10 + 5);
  37. this.text = {};
  38. this.startCombat = function() { return [this.description("A") + " appears. It's a fight!"]; };
  39. this.finishCombat = function() { return [this.description("The") + " scoops up your limp body and gulps you down."]; };
  40. this.finishDigest = function() { return [this.description("The") + " digests you..."]; };
  41. this.defeated = function() { startDialog(new FallenFoe(this)); };
  42. this.changeStamina = function(amount) {
  43. this.stamina += amount;
  44. this.stamina = Math.min(this.maxStamina, this.stamina);
  45. this.stamina = Math.max(0, this.stamina);
  46. };
  47. }
  48. function Player(name = "Player") {
  49. Creature.call(this, name, 15, 15, 15);
  50. this.fullness = function() {
  51. return this.stomach.fullness() + this.butt.fullness();
  52. };
  53. this.attacks.push(new punchAttack(this));
  54. this.attacks.push(new flankAttack(this));
  55. this.attacks.push(new grapple(this));
  56. this.attacks.push(new grappleSubdue(this));
  57. this.attacks.push(new grappleDevour(this));
  58. this.attacks.push(new grappleAnalVore(this));
  59. this.attacks.push(new grappleRelease(this));
  60. this.attacks.push(new grappledStruggle(this));
  61. this.attacks.push(new grappledReverse(this));
  62. this.attacks.push(new shrunkGrapple(this));
  63. this.attacks.push(new shrunkSwallow(this));
  64. this.attacks.push(new shrunkStomp(this));
  65. this.attacks.push(new flee(this));
  66. this.backupAttack = new pass(this);
  67. this.cash = 100;
  68. }
  69. function Anthro(name="Anthro") {
  70. this.build = pickRandom(["skinny", "fat", "muscular", "sickly", "ordinary"]);
  71. switch(this.build) {
  72. case "skinny":
  73. Creature.call(this, name, 8, 12, 8);
  74. this.mass *= ( Math.random() * 0.2 + 0.7 );
  75. break;
  76. case "fat":
  77. Creature.call(this, name, 10, 7, 15);
  78. this.mass *= ( Math.random() * 0.4 + 1.1);
  79. break;
  80. case "muscular":
  81. Creature.call(this, name, 13, 11, 13);
  82. this.mass *= ( Math.random() * 0.1 + 1.1);
  83. break;
  84. case "sickly":
  85. Creature.call(this, name, 6, 8, 6);
  86. this.mass *= ( Math.random() * 0.2 + 0.6 );
  87. break;
  88. case "ordinary":
  89. Creature.call(this, name, 10, 10, 10);
  90. break;
  91. }
  92. this.species = pickRandom(["dog","cat","lizard","deer","wolf","fox"]);
  93. // todo better lol
  94. this.description = function(prefix="") {
  95. if (this.build == "")
  96. if (prefix == "")
  97. return this.species;
  98. else
  99. return prefix + " " + this.species;
  100. else
  101. if (prefix == "")
  102. return this.build + " " + this.species;
  103. else
  104. return prefix + " " + this.build + " " + this.species;
  105. };
  106. this.attacks.push(new punchAttack(this));
  107. this.attacks.push(new flankAttack(this));
  108. this.attacks.push(new grapple(this));
  109. this.attacks.push(new grappleDevour(this));
  110. this.attacks.push(new grappledStruggle(this));
  111. this.attacks.push(new grappledReverse(this));
  112. this.backupAttack = new pass(this);
  113. this.struggles = [];
  114. this.struggles.push(new plead(this));
  115. this.struggles.push(new struggle(this));
  116. this.digests = [];
  117. this.digests.push(new digestPlayerStomach(this,20));
  118. this.backupDigest = new digestPlayerStomach(this,20);
  119. }
  120. function Fen() {
  121. Creature.call(this, name, 1000000, 1099900, 1000000);
  122. this.build = "loomy";
  123. this.species = "crux";
  124. this.description = function(prefix) { return "Fen"; };
  125. this.attacks = [];
  126. this.attacks.push(new devourPlayer(this));
  127. this.attacks.push(new leer(this));
  128. this.backupAttack = new poke(this);
  129. this.struggles = [];
  130. this.struggles.push(new rub(this));
  131. this.digests = [];
  132. this.digests.push(new digestPlayerStomach(this,50));
  133. this.digests.push(new instakillPlayerStomach(this));
  134. this.backupDigest = new digestPlayerStomach(this,50);
  135. }
  136. function Micro() {
  137. Creature.call(this, name);
  138. this.health = 5;
  139. this.mass = 0.1 * (Math.random()/2 - 0.25 + 1);
  140. this.species = pick(["dog","cat","lizard","deer","wolf","fox"]);
  141. this.description = function(prefix = "") {
  142. if (prefix == "")
  143. return "micro " + this.species;
  144. else
  145. return prefix + " micro " + this.species;
  146. };
  147. }
  148. // vore stuff here
  149. class Container {
  150. constructor(name) {
  151. this.name = name;
  152. this.contents = [];
  153. // health/sec
  154. this.damageRate = 15*100/86400;
  155. // kg/sec
  156. this.digestRate = 80/8640;
  157. }
  158. digest(time) {
  159. let lines = [];
  160. this.contents.forEach(function(prey) {
  161. if (prey.health > 0) {
  162. let damage = Math.min(prey.health, this.damageRate * time);
  163. prey.health -= damage;
  164. time -= damage / this.damageRate;
  165. if (prey.health + damage > 50 && prey.health <= 50) {
  166. lines.push(this.describeDamage(prey));
  167. }
  168. if (prey.health <= 0) {
  169. lines.push(this.describeKill(prey));
  170. }
  171. }
  172. if (prey.health <= 0) {
  173. let digested = Math.min(prey.mass, this.digestRate * time);
  174. prey.mass -= digested;
  175. this.fill(digested);
  176. }
  177. if (prey.mass <= 0) {
  178. lines.push(this.describeFinish(prey));
  179. this.finish(prey);
  180. }
  181. }, this);
  182. this.contents = this.contents.filter(function(prey) {
  183. return prey.mass > 0;
  184. });
  185. return lines;
  186. }
  187. feed(prey) {
  188. this.contents.push(prey);
  189. }
  190. fullness() {
  191. return this.contents.reduce((total, prey) => total + prey.mass, 0);
  192. }
  193. }
  194. class Stomach extends Container {
  195. constructor(bowels) {
  196. super();
  197. this.bowels = bowels;
  198. }
  199. describeDamage(prey) {
  200. return "Your guts gurgle and churn, slowly wearing down " + prey.description("the") + " trapped within.";
  201. }
  202. describeKill(prey) {
  203. return prey.description("The") + "'s struggles wane as your stomach overpowers them.";
  204. }
  205. describeFinish(prey) {
  206. return "Your churning guts have reduced " + prey.description("a") + " to meaty chyme.";
  207. }
  208. fill(amount) {
  209. this.bowels.add(amount);
  210. }
  211. finish(prey) {
  212. this.bowels.finish(prey);
  213. }
  214. }
  215. class Butt extends Container {
  216. constructor(bowels, stomach) {
  217. super();
  218. this.bowels = bowels;
  219. this.stomach = stomach;
  220. }
  221. digest(time) {
  222. this.contents.forEach(function (x) {
  223. x.timeInButt += time;
  224. });
  225. let lines = super.digest(time);
  226. let pushed = this.contents.filter(prey => prey.timeInButt >= 60 * 30);
  227. pushed.forEach(function(x) {
  228. this.stomach.feed(x);
  229. lines.push("Your winding guts squeeze " + x.description("the") + " into your stomach.");
  230. },this);
  231. this.contents = this.contents.filter(prey => prey.timeInButt < 60 * 30);
  232. return lines;
  233. }
  234. describeDamage(prey) {
  235. return "Your bowels gurgle and squeeze, working to wear down " + prey.description("the") + " trapped in those musky confines.";
  236. }
  237. describeKill(prey) {
  238. return prey.description("The") + " abruptly stops struggling, overpowered by your winding intestines.";
  239. }
  240. describeFinish(prey) {
  241. return "That delicious " + prey.description() + " didn't even make it to your stomach...now they're gone.";
  242. }
  243. feed(prey) {
  244. prey.timeInButt = 0;
  245. super.feed(prey);
  246. }
  247. fill(amount) {
  248. this.bowels.add(amount);
  249. }
  250. finish(prey) {
  251. this.bowels.finish(prey);
  252. }
  253. }
  254. function WasteContainer(name) {
  255. this.name = name;
  256. this.fullness = 0;
  257. this.contents = [];
  258. this.add = function(amount) {
  259. this.fullness += amount;
  260. };
  261. this.finish = function(prey) {
  262. if (prey.prefs.scat)
  263. this.contents.push(prey);
  264. };
  265. }
  266. function Bowels() {
  267. WasteContainer.call(this, "Bowels");
  268. }
  269. // PLAYER PREY
  270. function plead(predator) {
  271. return {
  272. name: "Plead",
  273. desc: "Ask very, very nicely for the predator to let you go. More effective if you haven't hurt your predator.",
  274. struggle: function(player) {
  275. let escape = Math.random() < predator.health / predator.maxHealth && Math.random() < 0.33;
  276. if (player.health <= 0) {
  277. escape = escape && Math.random() < 0.25;
  278. }
  279. if (escape) {
  280. player.clear();
  281. predator.clear();
  282. return {
  283. "escape": "escape",
  284. "lines": ["You plead for " + predator.description("the") + " to let you free, and they begrudingly agree, horking you up and leaving you shivering on the ground"]
  285. };
  286. } else {
  287. return {
  288. "escape": "stuck",
  289. "lines": ["You plead with " + predator.description("the") + " to let you go, but they refuse."]
  290. };
  291. }
  292. }
  293. };
  294. }
  295. function struggle(predator) {
  296. return {
  297. name: "Struggle",
  298. desc: "Try to squirm free. More effective if you've hurt your predator.",
  299. struggle: function(player) {
  300. let escape = Math.random() > predator.health / predator.maxHealth && Math.random() < 0.33;
  301. if (player.health <= 0 || player.stamina <= 0) {
  302. escape = escape && Math.random() < 0.25;
  303. }
  304. if (escape) {
  305. player.clear();
  306. predator.clear();
  307. return {
  308. "escape": "escape",
  309. "lines": ["You struggle and squirm, forcing " + predator.description("the") + " to hork you up. They groan and stumble away, exhausted by your efforts."]
  310. };
  311. } else {
  312. return {
  313. "escape": "stuck",
  314. "lines": ["You squirm and writhe within " + predator.description("the") + " to no avail."]
  315. };
  316. }
  317. }
  318. };
  319. }
  320. function struggleStay(predator) {
  321. return {
  322. name: "Struggle",
  323. desc: "Try to squirm free. More effective if you've hurt your predator.",
  324. struggle: function(player) {
  325. let escape = Math.random() > predator.health / predator.maxHealth && Math.random() < 0.33;
  326. if (player.health <= 0 || player.stamina <= 0) {
  327. escape = escape && Math.random() < 0.25;
  328. }
  329. if (escape) {
  330. player.clear();
  331. predator.clear();
  332. return {
  333. "escape": "stay",
  334. "lines": ["You struggle and squirm, forcing " + predator.description("the") + " to hork you up. They're not done with you yet..."]
  335. };
  336. } else {
  337. return {
  338. "escape": "stuck",
  339. "lines": ["You squirm and writhe within " + predator.description("the") + " to no avail."]
  340. };
  341. }
  342. }
  343. };
  344. }
  345. function rub(predator) {
  346. return {
  347. name: "Rub",
  348. desc: "Rub rub rub",
  349. struggle: function(player) {
  350. return {
  351. "escape": "stuck",
  352. "lines": ["You rub the walls of your predator's belly. At least " + predator.description("the") + " is getting something out of this."]
  353. };
  354. }
  355. };
  356. }