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.
 
 
 

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