Hi folks,
I’m a bit of a novice coder but am trying to help some students at my Text Adventures club create their games. I was asked on Friday if Inform could do HIDING so that the prisoner could escape from the guards. So I said “Of course!”, not really thinking through how tricky this might be for me to code. Anyway, having magpied some code from one of Ryan Veeder’s games, I’ve been working on it most of the day and think that I’ve found something that seems to work. Does it actually work?
I scaled back my ambitions a bit to concentrate on hiding in just containers. I wasn’t sure how to replace the automatic descriptions for ‘On the desk’ etc for supporters. I also wasn’t sure how I’d implement ‘HIDE behind’…
Anyway, I’d be really grateful if anyone could look over / debug my existing code with whatever duct tape it needs. If there is a more elegant solution anyone knows of, happy to be pointed in the right direction.
PS I found the get in / get out of verbs a bit cranky in the Inform rulebooks so created a new one - am I missing something here?
PPS I enjoyed wrestling with this and think Inform is amazing for a non-programmer to use!
Chapter 0 - Scene setting
A scene can be stealthy.
Guard-attack is a stealthy scene. Guard-attack begins when the player is in the Corridor for the first time. Guard-attack ends when the guards are in the Cells for the first time.
When Guard-attack begins:
play Guard-chat;
Guard-coming plays in two turns from now;
Guard-corridor1 plays in three turns from now;
Guard-corridor2 plays in four turns from now;
Guard-depart plays in five turns from now.
To play Guard-chat:
say "You hear a loud shout of 'Secure all the prisoners!' to the north."
At the time when Guard-coming plays:
say "You can hear the sound of footsteps running towards you from the north."
At the time when Guard-corridor1 plays:
now the guards are in the Corridor;
say "The guards have arrived... [run paragraph on]";
if hidden is true:
say "Outside the bin, you can hear them scuffling and shuffling around the desk.";
else:
say "And they have found you [if player is not in the bin]standing in the middle of the corridor[else]sitting in the bin with the lid open[end if]!";
end the story saying "You're back in prison!";
Every turn when the guards are in the location:
if hidden is true:
continue the action;
else:
say "Oh no... Your activity has alerted the guards... And they have found you!";
end the story saying "You're back in prison!"
At the time when Guard-corridor2 plays:
say "You hear a muffled shout about heading to the cells and grunts of agreement from the other guards."
At the time when Guard-depart plays:
now the guards are in the Cells;
say "You hear the footsteps echoing southwards and then an eerie silence - sounds like the coast is clear."
Chapter 1 - Hiding
Hidden is a truth state that varies.
To decide whether hidden is true:
if attacking the big bin when the guards are in the location, decide no;
if pushing the big bin when the guards are in the location, decide no;
if jumping when the guards are in the location, decide no;
if a closed container contains the player, decide yes;
decide no.
Hiding in is an action applying to one thing.
Understand "hide in/inside/under/underneath/behind [something]" as hiding in. Understand "get under [something]" as hiding in.
Getting out of is an action applying to one thing.
Understand "get out of [something]" as getting out of.
Before getting out of something:
try exiting.
A thing can be a hiding-place. The big bin is a hiding-place.
Check hiding in:
if the scene is not stealthy:
say "There are no guards around, so no need right now." instead;
else if the noun is not a hiding-place:
say "[The noun] wouldn't make much of a hiding spot." instead;
else:
continue the action.
Instead of hiding in the big bin:
say "You wriggle inside, close the lid after you so that you can't be seen and are plunged into...";
now the big bin is closed;
now the player is in the big bin.
Instead of entering the big bin:
try hiding in the big bin.
Before exiting:
if the big bin is closed:
silently try opening the big bin;
continue the action.
Instead of entering the desk:
try hiding in the desk.
Instead of hiding in the large desk:
say "You try hiding under the desk. But your legs poke out so you stand up again.".
Chapter 2 - Place setting
The Cells is room. North from the Cells is the Corridor. North from Corridor is the Armoury. The bed is enterable supporter in the Cells. The large desk is an enterable supporter in the Corridor. The big bin is a closed openable container in the Corridor.
The guards are a plural-named person in Armoury.
Check going north:
if location is Corridor and the guards are in Armoury:
say "But that's where the guards are right now!" instead.
Check going south:
if location is Corridor and the guards are in Armoury:
say "You freeze - there's no way you're going back in that cell!" instead;
if location is Corridor and the guards are in Cells:
say "But that's where the guards are right now!" instead.