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

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