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

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