0 votes
by (120 points)

I am working with harlowe, and I'm looking to make things easier on the pc mostly. And save myselft some time. 

I have a pretty basic horror story house on the hill set up, where the main character is trying to find items with a basic inventory management system to survive the night. What i want is the random chance of a spirit showing up in the room with you, forcing you to leave the room to avoid taking "mental" damage (ala arkham horror type games). Right now, I can only think of having this reroll by having each cell have its own random event counter.

I'm new to code, so I'm sure im going about this all wrong, but here's what im working with.

(set: $leftsquare1 to (random: 1,5))
(if: $leftsquare1 is 1)[<!--Do Nothing-->]
(if: $leftsquare1 is 2)[<!--Do Nothing-->]
(if: $leftsquare1 is 3)[theres a spooky riddim in this room]
(if: $leftsquare1 is 4)[<!--Do Nothing-->]
(if: $leftsquare1 is 5)[<!--Do Nothing-->]

What I'm literally wanting is to have the die roll when you would enter the room, and if it rolls on the spirit being in the room with you, it locks you out of being able to search the room and find items you might need.

1 Answer

0 votes
by (159k points)

There are a number of methods you can use to achieve the result you desire, the following solution uses an Array variable to contain a list of the Passage Name of each of the potential 'rooms' the spirit can appear in. This variable should be intialised within your project's startup tagged special Passage.

note: I don't the Passage Names of your 'room' passage so I will use Library, Bathroom, and Hallway in this example.

(set: $rooms to (a: "Library", "Bathroom", "Hallway"))

Next you will need a way to make the Spirit move, this can be done by adding a header tagged special passage to your project and then adding code like the following to it. The name of this passage is not important, I named mine Spirit Movement.

(set: $spiritLocation to (either: ...$rooms))

Within each of your 'room' passages you can use the current value of the new $spiritLocation variable combined with the (passage:) macro to determine if you should display your 'search the room' related link.

(if: $spiritLocation is not (passage:)'s name)[{
	(link: "Search Room")[
		<!-- Place code for searching this room within this link's associated hook. -->
	]
}]

You can also use a footer tagged special passage to display if the spirit is in the current 'room' or not, again the name of this passage isn't important. I named mine Is Spirit Here.

{
	(if: $spiritLocation is (passage:)'s name)[
		Spirit is here.
	]
}

 

...