0 votes
by (200 points)

I know there is no (hide:) macro, which would make this whole process so much simpler, but here's what I'm trying to do: I have a multi-enemy encounter set up and when the enemy's HP is 0 I want the option to continue attacking to no longer appear. This is the code I'm using (Wolf Minion 1 pages displayed are the encounter mechanics, as in who hits when, how much damage, etc. and this is for one single encounter. I have all 3 encounters listed this way on the same page, just with each one referencing a different display page (i.e. Wolf Minion 2 leads to that wolf's encounter mechanics, same with Wolf Minion 3)


(if: $werewolfMinion1HP is <= 90)[ (display: "Wolf Minion 1") ]
{(if: $werewolfMinion1HP is <= 0)[(set: $werewolfMinion1HP to 0)You have slain this werewolf!]

So as you can see, when the wolf's HP is less than it's original I want the encounter system to run. But how to do I make it so that goes away when they're dead/their HP is 0?

1 Answer

+1 vote
by (159k points)

Please use the Question Tags to state the name and full version number of the Story Format you are using, as answers can vary based on that information. Based on the macro syntax used in your example I will assume you are using Harlowe, I can't tell the story format version from what you have given so I will assume it's v2.1.0

The conditional expressions in the two (if:) macros in your example are related and because you only want the outcome of one of those (if:) to actually be executed then you should be using an (else-if:) macro for one of them. This situation is know as mutually exclusive, which is when you only want one of two (or more) related conditions to be true.

One thing that is unclear in your example is what happens when the $werewolfMinion1HP variable has a value greater-than 90, there for the following example uses logic that makes that use-case irrelevant. 

(if: $werewolfMinion1HP <= 0)[\
	(set: $werewolfMinion1HP to 0)\
	You have slain this werewolf!\
(else-if: $werewolfMinion1HP > 0)[\
	(display: "Wolf Minion 1")\

NOTE: You shouldn't use the Boolean based is operator in when using one of the greater-than or less-than related operators, even though the Harlowe parser has been changed to disregard the invalid is operator in those situation.

<!-- Invalid syntax.. -->
(if: $variable is < "value")[]
(if: $variable is > "value")[]
(if: $variable is <= "value")[]
(if: $variable is >= "value")[]

<!-- Valid syntax.. -->
(if: $variable < "value")[]
(if: $variable > "value")[]
(if: $variable <= "value")[]
(if: $variable >= "value")[]

... the reason for this is that the is operator is the equivalent to == (programming arithmetic for equal-to) so when you write a conditional expression like $variable is < "value" you are telling the story format that the condition is only true when the variable is both:
a. Only equal to "value".
b. Less than "value"

... and that condition is contradictory and can never be true. The same goes for a conditional expression ike $variable is <= "value" except in this case your saying that the variable is both:
a. Only equal to "value".
b. Less-than or equal to "value"

... and again that condition is contradictory and can never be true.