From f308499076463228063121f9d10b965774bf2e43 Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Thu, 15 Mar 2018 11:34:39 -0400 Subject: [PATCH] Enemies can have custom defeat dialogs now. --- customs.js | 3 +++ dialog.js | 6 +++++- feast.js | 3 +-- vore.js | 2 ++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/customs.js b/customs.js index acdef6d..202fccb 100644 --- a/customs.js +++ b/customs.js @@ -238,4 +238,7 @@ function Trance() { this.startCombat = function() { return ["You yelp and turn around as hot breath spills over your shoulder. A massive sergal has crept up on you...and he looks hungry"]; }; this.digestFinish = function() { return ["The sergal's crushing guts reduce you to a pool of chyme..."]; }; + this.defeated = function() { changeMode("explore"); update(["The sergal winces and stumbles, grabbing a thick branch to steady himself...and snapping in half like a twig. You decide discretion is the better part of valor and run while you can."]); }; + this.prefs.prey = false; + } diff --git a/dialog.js b/dialog.js index 8e45228..be47035 100644 --- a/dialog.js +++ b/dialog.js @@ -66,13 +66,17 @@ function PhoneCall() { function FallenFoe(foe) { DialogNode.call(this); - this.text = ["What do you want to do with your enemy?"]; + this.text = [foe.description("The") + " falls to the ground!", newline, "What do you want to do with your enemy?"]; { let nodeEat = new DialogNode(); this.addChoice("Devour!",nodeEat); nodeEat.text = ["You grab your helpless prey and force them down your gullet. You hack up their wallet a minute later, finding $" + foe.cash + " inside."]; + nodeEat.requirements.push( function(attacker, defender) { + return defender.prefs.prey; + }); + nodeEat.hooks.push(function() { player.cash += foe.cash; }); diff --git a/feast.js b/feast.js index 618516a..311ae52 100644 --- a/feast.js +++ b/feast.js @@ -398,8 +398,7 @@ function attackClicked(index) { update(playerAttacks[index].attack(currentFoe)); if (currentFoe.health <= 0) { - update([currentFoe.description("The") + " falls to the ground!"]); - startDialog(new FallenFoe(currentFoe)); + currentFoe.defeated(); } else if (mode == "combat") { let attack = pick(filterPriority(filterValid(currentFoe.attacks, currentFoe, player)), currentFoe, player); diff --git a/vore.js b/vore.js index e42cbcb..da02382 100644 --- a/vore.js +++ b/vore.js @@ -52,6 +52,8 @@ function Creature(name = "Creature", str=10, dex=10, con=10) { this.startCombat = function() { return [this.description("A") + " appears. It's a fight!"]; }; this.finishDigest = function() { return [this.description("The") + " digests you..."]; }; + + this.defeated = function() { startDialog(new FallenFoe(this)); }; } function Player(name = "Player") {