0 votes
by (200 points)

So I have an encounter set up with 3 werewolves. I only want to the story to progress after all 3 are dead. The code I have for that is 

HP: (print: $health)
Werewolf 1 HP: (print: $werewolfMinion1HP) 
Werewolf 2 HP: (print: $werewolfMinion2HP)
Werewolf 3 HP: (print: $werewolfMinion3HP)

(if: $werewolfMinion1HP is <= 0 and $werewolfMinion2HP is <=0 and $werewolfMinion3HP is <= 0)[ [[You have slain the werewolves!->conclusion]] ]
(if: $health is <= 0)[ [[You have died!->Load Game]] ]

(if: $werewolfMinion1HP is <= 90)[ (display: "Wolf Minion 1") ]

(if: $werewolfMinion1HP is <= 0)[You have slain this werewolf!]

(if: $werewolfMinion2HP is <= 90)[(display: "Wolf Minion 2")]

(if: $werewolfMinion2HP is <= 0)[You have slain this werewolf!]

(if: $werewolfMinion3HP is <= 90)[(display: "Wolf Minion 3")]

(if: $werewolfMinion3HP is <= 0)[You have slain this werewolf!]

The displayed pages are all the same but with different variable names as per here:

	(if: $playerToHit is 0)[
		(set: $playerToHit to 6)
	(set: $playerToHit to $playerToHit - 1)
	(set: $playerChance to (random: 1, $playerToHit) )

(if: $playerChance is 1 ) [
You hit the first werewolf with your hatchet! It loses 20 health! [[Attack again->werewolf encounter group]]
(set: $playerToHit to 0)
(set: $werewolfMinion1HP to $werewolfMinion1HP - 20)] 
(else:)[You swing your blade but the first werewolf dodges your attack! [[Attack again?->werewolf encounter group]]]

What can I do to prevent the HP from going lower than 0 when the page reloads for each attack?

1 Answer

+2 votes
by (1.1k points)
selected by
Best answer
(if: $werewolfMinionHP is < 0)[(set: $werewolfMinionHP to 0)]
Welcome to Twine Q&A, where you can ask questions and receive answers from other members of the community.

You can also find hints and information on Twine on the official wiki and the old forums archive.

See a spam question? Flag it instead of downvoting. A question flagged enough times will automatically be hidden while moderators review it.