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.
 
 
 

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