crunch
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.
 
 
 

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