munch
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

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