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

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