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

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