crunch
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 

355 строки
8.3 KiB

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