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

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