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.
 
 
 

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