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.
 
 
 

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