crunch
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

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