crunch
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

623 строки
15 KiB

  1. "use strict";
  2. function StatBuff(type, amount) {
  3. this.stat = type;
  4. this.amount = amount;
  5. }
  6. function Creature(name = "Creature", str = 10, dex = 10, con = 10) {
  7. this.name = name;
  8. this.mass = 80;
  9. this.attacks = [];
  10. this.baseStr = str;
  11. this.baseDex = dex;
  12. this.baseCon = con;
  13. this.statBuffs = [];
  14. this.statMultiplier = function(stat) {
  15. let multiplier = 1;
  16. return this.statBuffs.reduce((multiplier, effect) => (effect.stat == stat) ? multiplier * effect.amount : multiplier, multiplier);
  17. };
  18. Object.defineProperty(this, "str", {
  19. get: function() {
  20. return this.baseStr * this.statMultiplier("str");
  21. },
  22. set: function(val) {
  23. this.baseStr = val;
  24. }
  25. });
  26. Object.defineProperty(this, "dex", {
  27. get: function() {
  28. return this.baseDex * this.statMultiplier("dex");
  29. },
  30. set: function(val) {
  31. this.baseDex = val;
  32. }
  33. });
  34. Object.defineProperty(this, "con", {
  35. get: function() {
  36. return this.baseCon * this.statMultiplier("con");
  37. },
  38. set: function(val) {
  39. this.baseCon = val;
  40. }
  41. });
  42. this.hasName = false;
  43. Object.defineProperty(this, "maxHealth", {
  44. get: function() {
  45. return this.str * 5 + this.con * 10;
  46. }
  47. });
  48. this.health = this.maxHealth;
  49. Object.defineProperty(this, "maxStamina", {
  50. get: function() {
  51. return this.dex * 5 + this.con * 10;
  52. }
  53. });
  54. this.stamina = this.maxStamina;
  55. // fraction of max health per second
  56. this.healthRate = 1 / 86400 * 4;
  57. this.staminaRate = 1 / 86400 * 6;
  58. this.restoreHealth = function(time) {
  59. this.health = Math.min(this.maxHealth, this.health + this.maxHealth * time * this.healthRate);
  60. };
  61. this.restoreStamina = function(time) {
  62. this.stamina = Math.min(this.maxStamina, this.stamina + this.maxStamina * time * this.staminaRate);
  63. };
  64. this.flags = {};
  65. this.clear = function() {
  66. this.flags = {};
  67. };
  68. this.prefs = {
  69. prey: true,
  70. scat: true,
  71. grapple: true,
  72. vore: {
  73. oral: 1,
  74. anal: 1,
  75. cock: 1,
  76. unbirth: 1,
  77. breast: 1,
  78. hard: 1,
  79. soul: 1
  80. }
  81. };
  82. this.cash = Math.floor(Math.random() * 10 + 5);
  83. this.text = {};
  84. this.startCombat = function() {
  85. return [this.description("A") + " appears. It's a fight!"];
  86. };
  87. this.finishCombat = function() {
  88. return [this.description("The") + " scoops up your limp body and gulps you down."];
  89. };
  90. this.finishDigest = function() {
  91. return [this.description("The") + " digests you..."];
  92. };
  93. this.defeated = function() {
  94. startDialog(new FallenFoe(this));
  95. };
  96. this.changeStamina = function(amount) {
  97. this.stamina += amount;
  98. this.stamina = Math.min(this.maxStamina, this.stamina);
  99. this.stamina = Math.max(0, this.stamina);
  100. };
  101. this.tickEffects = function() {
  102. this.statBuffs.forEach(function(x) {
  103. x.tick();
  104. });
  105. this.statBuffs.filter(function(x) {
  106. return x.alive;
  107. });
  108. };
  109. }
  110. function Player(name = "Player") {
  111. Creature.call(this, name, 15, 15, 15);
  112. this.attacks.push(punchAttack(this));
  113. this.attacks.push(flankAttack(this));
  114. this.attacks.push(grapple(this));
  115. this.attacks.push(grappleSubdue(this));
  116. this.attacks.push(grappleDevour(this));
  117. this.attacks.push(grappleAnalVore(this));
  118. this.attacks.push(grappleCockVore(this));
  119. this.attacks.push(grappleUnbirth(this));
  120. this.attacks.push(grappleBreastVore(this));
  121. this.attacks.push(grappleRelease(this));
  122. this.attacks.push(grappledStruggle(this));
  123. this.attacks.push(grappledReverse(this));
  124. this.attacks.push(shrunkGrapple(this));
  125. this.attacks.push(shrunkSwallow(this));
  126. this.attacks.push(shrunkStomp(this));
  127. this.attacks.push(pass(this));
  128. this.attacks.push(flee(this));
  129. this.backupAttack = pass(this);
  130. this.cash = 100;
  131. this.stomach = new Stomach(this);
  132. this.bowels = new Bowels(this, this.stomach);
  133. this.stomach.bowels = this.bowels;
  134. this.balls = new Balls(this);
  135. this.womb = new Womb(this);
  136. this.breasts = new Breasts(this);
  137. this.parts = {};
  138. }
  139. function Anthro(name = "Anthro") {
  140. this.build = pickRandom(["skinny", "fat", "muscular", "sickly", "ordinary"]);
  141. switch (this.build) {
  142. case "skinny":
  143. Creature.call(this, name, 8, 12, 8);
  144. this.mass *= (Math.random() * 0.2 + 0.7);
  145. break;
  146. case "fat":
  147. Creature.call(this, name, 10, 7, 15);
  148. this.mass *= (Math.random() * 0.4 + 1.1);
  149. break;
  150. case "muscular":
  151. Creature.call(this, name, 13, 11, 13);
  152. this.mass *= (Math.random() * 0.1 + 1.1);
  153. break;
  154. case "sickly":
  155. Creature.call(this, name, 6, 8, 6);
  156. this.mass *= (Math.random() * 0.2 + 0.6);
  157. break;
  158. case "ordinary":
  159. Creature.call(this, name, 10, 10, 10);
  160. break;
  161. }
  162. this.species = pickRandom(["dog", "cat", "lizard", "deer", "wolf", "fox"]);
  163. // todo better lol
  164. this.description = function(prefix = "") {
  165. if (this.build == "")
  166. if (prefix == "")
  167. return this.species;
  168. else
  169. return prefix + " " + this.species;
  170. else
  171. if (prefix == "")
  172. return this.build + " " + this.species;
  173. else
  174. return prefix + " " + this.build + " " + this.species;
  175. };
  176. this.attacks.push(new punchAttack(this));
  177. this.attacks.push(new flankAttack(this));
  178. this.attacks.push(new grapple(this));
  179. this.attacks.push(new grappleDevour(this));
  180. this.attacks.push(new grappledStruggle(this));
  181. this.attacks.push(new grappledReverse(this));
  182. this.backupAttack = new pass(this);
  183. this.struggles = [];
  184. this.struggles.push(new plead(this));
  185. this.struggles.push(new struggle(this));
  186. this.struggles.push(new submit(this));
  187. this.digests = [];
  188. this.digests.push(new digestPlayerStomach(this, 20));
  189. this.backupDigest = new digestPlayerStomach(this, 20);
  190. }
  191. function Fen() {
  192. Creature.call(this, name, 1000000, 1099900, 1000000);
  193. this.build = "loomy";
  194. this.species = "crux";
  195. this.description = function(prefix) {
  196. return "Fen";
  197. };
  198. this.attacks = [];
  199. this.attacks.push(new devourPlayer(this));
  200. this.attacks.push(new devourPlayerAnal(this));
  201. this.attacks.push(new leer(this));
  202. this.backupAttack = new poke(this);
  203. this.struggles = [];
  204. this.struggles.push(new rub(this));
  205. this.digests = [];
  206. this.digests.push(new instakillPlayerStomach(this));
  207. this.digests.push(new instakillPlayerBowels(this));
  208. this.backupDigest = new digestPlayerStomach(this, 50);
  209. }
  210. function Micro() {
  211. Creature.call(this, name);
  212. this.health = 5;
  213. this.mass = 0.1 * (Math.random() / 2 - 0.25 + 1);
  214. this.species = pick(["dog", "cat", "lizard", "deer", "wolf", "fox"]);
  215. this.description = function(prefix = "") {
  216. if (prefix == "")
  217. return "micro " + this.species;
  218. else
  219. return prefix + " micro " + this.species;
  220. };
  221. }
  222. // vore stuff here
  223. function Container(owner) {
  224. this.owner = owner;
  225. this.contents = [];
  226. this.waste = 0;
  227. this.digested = [];
  228. // health/sec
  229. this.damageRate = 15 * 100 / 86400;
  230. // health percent/sec
  231. this.damageRatePercent = 1 / 86400;
  232. this.capacity = 100;
  233. // kg/sec
  234. this.digestRate = 80 / 8640;
  235. this.digest = function(time) {
  236. let lines = [];
  237. this.contents.forEach(function(prey) {
  238. if (prey.health > 0) {
  239. let damage = Math.min(prey.health, this.damageRate * time + this.damageRatePercent * prey.maxHealth * time);
  240. prey.health -= damage;
  241. time -= damage / (this.damageRate + this.damageRatePercent * prey.maxHealth);
  242. if (prey.health + damage > 50 && prey.health <= 50) {
  243. lines.push(this.describeDamage(prey));
  244. }
  245. if (prey.health <= 0) {
  246. lines.push(this.describeKill(prey));
  247. }
  248. }
  249. if (prey.health <= 0) {
  250. let digested = Math.min(prey.mass, this.digestRate * time);
  251. prey.mass -= digested;
  252. this.owner.changeStamina(digested * 10);
  253. this.fill(digested);
  254. }
  255. if (prey.mass <= 0) {
  256. lines.push(this.describeFinish(prey));
  257. this.finish(prey);
  258. }
  259. this.contents = this.contents.filter(function(prey) {
  260. return prey.mass > 0;
  261. });
  262. }, this);
  263. return lines;
  264. };
  265. this.feed = function(prey) {
  266. this.contents.push(prey);
  267. };
  268. this.fullness = function() {
  269. return this.contents.reduce((total, prey) => total + prey.mass, 0) + this.waste;
  270. };
  271. this.add = function(amount) {
  272. this.waste += amount;
  273. };
  274. this.finish = function(prey) {
  275. if (prey.prefs.scat)
  276. this.digested.push(prey);
  277. };
  278. }
  279. function Stomach(owner) {
  280. Container.call(this, owner);
  281. this.describeDamage = function(prey) {
  282. return "Your guts gurgle and churn, slowly wearing down " + prey.description("the") + " trapped within.";
  283. };
  284. this.describeKill = function(prey) {
  285. return prey.description("The") + "'s struggles wane as your stomach overpowers them.";
  286. };
  287. this.describeFinish = function(prey) {
  288. return "Your churning guts have reduced " + prey.description("a") + " to meaty chyme.";
  289. };
  290. this.fill = function(amount) {
  291. this.bowels.add(amount);
  292. };
  293. this.finish = function(prey) {
  294. this.bowels.finish(prey);
  295. };
  296. }
  297. function Bowels(owner, stomach) {
  298. Container.call(this, owner);
  299. this.stomach = stomach;
  300. this.parentDigest = this.digest;
  301. this.digest = function(time) {
  302. this.contents.forEach(function(x) {
  303. x.timeInBowels += time;
  304. });
  305. let lines = this.parentDigest(time);
  306. let pushed = this.contents.filter(prey => prey.timeInBowels >= 60 * 30);
  307. pushed.forEach(function(x) {
  308. this.stomach.feed(x);
  309. lines.push("Your winding guts squeeze " + x.description("the") + " into your stomach.");
  310. }, this);
  311. this.contents = this.contents.filter(prey => prey.timeInBowels < 60 * 30);
  312. return lines;
  313. };
  314. this.describeDamage = function(prey) {
  315. return "Your bowels gurgle and squeeze, working to wear down " + prey.description("the") + " trapped in those musky confines.";
  316. };
  317. this.describeKill = function(prey) {
  318. return prey.description("The") + " abruptly stops struggling, overpowered by your winding intestines.";
  319. };
  320. this.describeFinish = function(prey) {
  321. return "That delicious " + prey.description() + " didn't even make it to your stomach...now they're gone.";
  322. };
  323. this.parentFeed = this.feed;
  324. this.feed = function(prey) {
  325. prey.timeInBowels = 0;
  326. this.parentFeed(prey);
  327. };
  328. this.fill = function(amount) {
  329. this.add(amount);
  330. };
  331. this.finish = function(prey) {
  332. this.digested.push(prey);
  333. };
  334. }
  335. function Balls(owner) {
  336. Container.call(this, owner);
  337. this.describeDamage = function(prey) {
  338. return "Your balls slosh as they wear down the " + prey.description("the") + " trapped within.";
  339. };
  340. this.describeKill = function(prey) {
  341. return prey.description("The") + "'s struggles cease, overpowered by your cum-filled balls.";
  342. };
  343. this.describeFinish = function(prey) {
  344. return "Your churning balls have melted " + prey.description("a") + " down to musky cum.";
  345. };
  346. this.fill = function(amount) {
  347. this.add(amount);
  348. };
  349. this.finish = function(prey) {
  350. this.digested.push(prey);
  351. };
  352. }
  353. function Womb(owner) {
  354. Container.call(this, owner);
  355. this.describeDamage = function(prey) {
  356. return "You shiver as " + prey.description("the") + " squrims within your womb.";
  357. };
  358. this.describeKill = function(prey) {
  359. return "Your womb clenches and squeezes, overwhelming " + prey.description("the") + " trapped within.";
  360. };
  361. this.describeFinish = function(prey) {
  362. return "Your womb dissolves " + prey.description("a") + " into femcum.";
  363. };
  364. this.fill = function(amount) {
  365. this.add(amount);
  366. };
  367. this.finish = function(prey) {
  368. this.digested.push(prey);
  369. };
  370. }
  371. function Breasts(owner) {
  372. Container.call(this, owner);
  373. this.describeDamage = function(prey) {
  374. return "Your breasts slosh from side to side, steadily softening " + prey.description("the") + " trapped within.";
  375. };
  376. this.describeKill = function(prey) {
  377. return prey.description("The") + " gives one last mighty shove...and then slumps back in your breasts.";
  378. };
  379. this.describeFinish = function(prey) {
  380. return "Your breasts have broken " + prey.description("a") + " down to creamy milk.";
  381. };
  382. this.fill = function(amount) {
  383. this.add(amount);
  384. };
  385. this.finish = function(prey) {
  386. this.digested.push(prey);
  387. };
  388. }
  389. // PLAYER PREY
  390. function plead(predator) {
  391. return {
  392. name: "Plead",
  393. desc: "Ask very, very nicely for the predator to let you go. More effective if you haven't hurt your predator.",
  394. struggle: function(player) {
  395. let escape = Math.random() < predator.health / predator.maxHealth && Math.random() < 0.33;
  396. if (player.health <= 0) {
  397. escape = escape && Math.random() < 0.25;
  398. }
  399. if (escape) {
  400. player.clear();
  401. predator.clear();
  402. return {
  403. "escape": "escape",
  404. "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"]
  405. };
  406. } else {
  407. return {
  408. "escape": "stuck",
  409. "lines": ["You plead with " + predator.description("the") + " to let you go, but they refuse."]
  410. };
  411. }
  412. }
  413. };
  414. }
  415. function struggle(predator) {
  416. return {
  417. name: "Struggle",
  418. desc: "Try to squirm free. More effective if you've hurt your predator.",
  419. struggle: function(player) {
  420. let escape = Math.random() > predator.health / predator.maxHealth && Math.random() < 0.33;
  421. if (player.health <= 0 || player.stamina <= 0) {
  422. escape = escape && Math.random() < 0.25;
  423. }
  424. if (escape) {
  425. player.clear();
  426. predator.clear();
  427. return {
  428. "escape": "escape",
  429. "lines": ["You struggle and squirm, forcing " + predator.description("the") + " to hork you up. They groan and stumble away, exhausted by your efforts."]
  430. };
  431. } else {
  432. return {
  433. "escape": "stuck",
  434. "lines": ["You squirm and writhe within " + predator.description("the") + " to no avail."]
  435. };
  436. }
  437. }
  438. };
  439. }
  440. function struggleStay(predator) {
  441. return {
  442. name: "Struggle",
  443. desc: "Try to squirm free. More effective if you've hurt your predator.",
  444. struggle: function(player) {
  445. let escape = Math.random() > predator.health / predator.maxHealth && Math.random() < 0.33;
  446. if (player.health <= 0 || player.stamina <= 0) {
  447. escape = escape && Math.random() < 0.25;
  448. }
  449. if (escape) {
  450. player.clear();
  451. predator.clear();
  452. return {
  453. "escape": "stay",
  454. "lines": ["You struggle and squirm, forcing " + predator.description("the") + " to hork you up. They're not done with you yet..."]
  455. };
  456. } else {
  457. return {
  458. "escape": "stuck",
  459. "lines": ["You squirm and writhe within " + predator.description("the") + " to no avail."]
  460. };
  461. }
  462. }
  463. };
  464. }
  465. function rub(predator) {
  466. return {
  467. name: "Rub",
  468. desc: "Rub rub rub",
  469. struggle: function(player) {
  470. return {
  471. "escape": "stuck",
  472. "lines": ["You rub the crushing walls. At least " + predator.description("the") + " is getting something out of this."]
  473. };
  474. }
  475. };
  476. }
  477. function submit(predator) {
  478. return {
  479. name: "Submit",
  480. desc: "Do nothing",
  481. struggle: function(player) {
  482. return {
  483. "escape": "stuck",
  484. "lines": ["You do nothing."]
  485. };
  486. }
  487. };
  488. }