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

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