crunch
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 

481 wiersze
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. // health percent/sec
  159. this.damageRatePercent = 1/86400;
  160. // kg/sec
  161. this.digestRate = 80/8640;
  162. }
  163. digest(time) {
  164. let lines = [];
  165. this.contents.forEach(function(prey) {
  166. if (prey.health > 0) {
  167. let damage = Math.min(prey.health, this.damageRate * time + this.damageRatePercent * prey.maxHealth * time);
  168. prey.health -= damage;
  169. time -= damage / (this.damageRate + this.damageRatePercent * prey.maxHealth);
  170. if (prey.health + damage > 50 && prey.health <= 50) {
  171. lines.push(this.describeDamage(prey));
  172. }
  173. if (prey.health <= 0) {
  174. lines.push(this.describeKill(prey));
  175. }
  176. }
  177. if (prey.health <= 0) {
  178. let digested = Math.min(prey.mass, this.digestRate * time);
  179. prey.mass -= digested;
  180. this.owner.changeStamina(digested*10);
  181. this.fill(digested);
  182. }
  183. if (prey.mass <= 0) {
  184. lines.push(this.describeFinish(prey));
  185. this.finish(prey);
  186. }
  187. }, this);
  188. this.contents = this.contents.filter(function(prey) {
  189. return prey.mass > 0;
  190. });
  191. return lines;
  192. }
  193. feed(prey) {
  194. this.contents.push(prey);
  195. }
  196. fullness() {
  197. return this.contents.reduce((total, prey) => total + prey.mass, 0);
  198. }
  199. }
  200. class Stomach extends Container {
  201. constructor(owner,bowels) {
  202. super(owner);
  203. this.bowels = bowels;
  204. }
  205. describeDamage(prey) {
  206. return "Your guts gurgle and churn, slowly wearing down " + prey.description("the") + " trapped within.";
  207. }
  208. describeKill(prey) {
  209. return prey.description("The") + "'s struggles wane as your stomach overpowers them.";
  210. }
  211. describeFinish(prey) {
  212. return "Your churning guts have reduced " + prey.description("a") + " to meaty chyme.";
  213. }
  214. fill(amount) {
  215. this.bowels.add(amount);
  216. }
  217. finish(prey) {
  218. this.bowels.finish(prey);
  219. }
  220. }
  221. class Butt extends Container {
  222. constructor(owner, bowels, stomach) {
  223. super(owner);
  224. this.bowels = bowels;
  225. this.stomach = stomach;
  226. }
  227. digest(time) {
  228. this.contents.forEach(function (x) {
  229. x.timeInButt += time;
  230. });
  231. let lines = super.digest(time);
  232. let pushed = this.contents.filter(prey => prey.timeInButt >= 60 * 30);
  233. pushed.forEach(function(x) {
  234. this.stomach.feed(x);
  235. lines.push("Your winding guts squeeze " + x.description("the") + " into your stomach.");
  236. },this);
  237. this.contents = this.contents.filter(prey => prey.timeInButt < 60 * 30);
  238. return lines;
  239. }
  240. describeDamage(prey) {
  241. return "Your bowels gurgle and squeeze, working to wear down " + prey.description("the") + " trapped in those musky confines.";
  242. }
  243. describeKill(prey) {
  244. return prey.description("The") + " abruptly stops struggling, overpowered by your winding intestines.";
  245. }
  246. describeFinish(prey) {
  247. return "That delicious " + prey.description() + " didn't even make it to your stomach...now they're gone.";
  248. }
  249. feed(prey) {
  250. prey.timeInButt = 0;
  251. super.feed(prey);
  252. }
  253. fill(amount) {
  254. this.bowels.add(amount);
  255. }
  256. finish(prey) {
  257. this.bowels.finish(prey);
  258. }
  259. }
  260. function WasteContainer(name) {
  261. this.name = name;
  262. this.fullness = 0;
  263. this.contents = [];
  264. this.add = function(amount) {
  265. this.fullness += amount;
  266. };
  267. this.finish = function(prey) {
  268. if (prey.prefs.scat)
  269. this.contents.push(prey);
  270. };
  271. }
  272. function Bowels() {
  273. WasteContainer.call(this, "Bowels");
  274. }
  275. // PLAYER PREY
  276. function plead(predator) {
  277. return {
  278. name: "Plead",
  279. desc: "Ask very, very nicely for the predator to let you go. More effective if you haven't hurt your predator.",
  280. struggle: function(player) {
  281. let escape = Math.random() < predator.health / predator.maxHealth && Math.random() < 0.33;
  282. if (player.health <= 0) {
  283. escape = escape && Math.random() < 0.25;
  284. }
  285. if (escape) {
  286. player.clear();
  287. predator.clear();
  288. return {
  289. "escape": "escape",
  290. "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"]
  291. };
  292. } else {
  293. return {
  294. "escape": "stuck",
  295. "lines": ["You plead with " + predator.description("the") + " to let you go, but they refuse."]
  296. };
  297. }
  298. }
  299. };
  300. }
  301. function struggle(predator) {
  302. return {
  303. name: "Struggle",
  304. desc: "Try to squirm free. More effective if you've hurt your predator.",
  305. struggle: function(player) {
  306. let escape = Math.random() > predator.health / predator.maxHealth && Math.random() < 0.33;
  307. if (player.health <= 0 || player.stamina <= 0) {
  308. escape = escape && Math.random() < 0.25;
  309. }
  310. if (escape) {
  311. player.clear();
  312. predator.clear();
  313. return {
  314. "escape": "escape",
  315. "lines": ["You struggle and squirm, forcing " + predator.description("the") + " to hork you up. They groan and stumble away, exhausted by your efforts."]
  316. };
  317. } else {
  318. return {
  319. "escape": "stuck",
  320. "lines": ["You squirm and writhe within " + predator.description("the") + " to no avail."]
  321. };
  322. }
  323. }
  324. };
  325. }
  326. function struggleStay(predator) {
  327. return {
  328. name: "Struggle",
  329. desc: "Try to squirm free. More effective if you've hurt your predator.",
  330. struggle: function(player) {
  331. let escape = Math.random() > predator.health / predator.maxHealth && Math.random() < 0.33;
  332. if (player.health <= 0 || player.stamina <= 0) {
  333. escape = escape && Math.random() < 0.25;
  334. }
  335. if (escape) {
  336. player.clear();
  337. predator.clear();
  338. return {
  339. "escape": "stay",
  340. "lines": ["You struggle and squirm, forcing " + predator.description("the") + " to hork you up. They're not done with you yet..."]
  341. };
  342. } else {
  343. return {
  344. "escape": "stuck",
  345. "lines": ["You squirm and writhe within " + predator.description("the") + " to no avail."]
  346. };
  347. }
  348. }
  349. };
  350. }
  351. function rub(predator) {
  352. return {
  353. name: "Rub",
  354. desc: "Rub rub rub",
  355. struggle: function(player) {
  356. return {
  357. "escape": "stuck",
  358. "lines": ["You rub the walls of your predator's belly. At least " + predator.description("the") + " is getting something out of this."]
  359. };
  360. }
  361. };
  362. }
  363. function submit(predator) {
  364. return {
  365. name: "Submit",
  366. desc: "Do nothing",
  367. struggle: function(player) {
  368. return {
  369. "escape": "stuck",
  370. "lines": ["You do nothing."]
  371. };
  372. }
  373. };
  374. }