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.
 
 
 

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