Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Unlocking a locked door?

A topic by ChristopherMerriner created Jun 05, 2020 Views: 280 Replies: 12
Viewing posts 1 to 10

I feel slightly foolish asking this, as perhaps the answer is blindingly obvious and I just can't see it, but...

Is there an explicit command to unlock a door? In the scenario that a locked door is unlocked by an event or an NPC, not by the player having a key. I can work around it with a 'match (unlock door)  ...goto' type thing, or perhaps make  it a block_path and add a condition to it. But would be easier if I could just command the door to be unlocked.

Do you mean you are unable to open the door until a NPC is present or do you want the NPC to be able to lock and unlock the door by themselves?

I need the NPC to unlock the door when they've done their thing.

So what I was hoping for was something like:

door1: is_locked = "true"

If (npc_has_done_their_thing){

:unlock (door1)

But I can't see that such an :unlock command exists. If it doesn't, then  I can work around it using a condition on a block path barrier.

you can do that with normal barriers, since barriers have option to be locked when a bool returns true ( for you, !npc_has_done_their_thing because your bool returns true when you want the door to be unlocked, so you need to reverse that)

Than you just need to set that bool to true when the NPC is done, or to check if the NPC is present in the room and then set it to false, and to true when they are not present.

Submitted

As far as I know, there's no :unlock statement. Doors in Adventuron aren't the nicest doors in the adventure world, as they're one-way doors and you can only have one per room. Although there's a bit of coding involved, I find it easier to just do your own doors, then you're in full control.

If you can, can you take a look at the first three locations in The Witch's Apprentice? There's an unlocked gate between the first and second location and a locked door between the second and third location. The doors can be opened and closed from both sides. The locked door is unlocked by pressing the button on the intercom. It sounds like this is the sort of thing you need.

If this suits your requirements, I can send you some source code.

Thanks Garry. door_operations does what I need for now, but I may call on you if I need to code a door from scratch (which might well happen elsewhere in this game).

Submitted

No problem. I didn't know about that other stuff, so need to dabble with it myself.

Host

To set up a locked door without a key :

   my_door : door {
      from              = my_location
      to                = my_location_2
      is_lockable       = true
      is_locked         = true
   }

To unlock a door:

: door_operation door = "my_door" operation = "unlock" ;

Door operations are always silent (don't print anything).

Thanks - it was the door_operations that I wasn't seeing. Problem solved!

Submitted

Um, just a thought, but seeing as this game has graphics, if the door is shown in your graphics, then the state of the door should be reflected in the graphics. So if the door is closed, it is shown closed in the graphics and if the door is open, it is shown open in the graphics. Otherwise, it could be very misleading/confusing for the player.

True,  but everything relevant will be reported in the text, and the graphics (heaven knows what they will actually turn out like: I can write but I can't draw) will be illustrative but not key to the gameplay. I always found it a bit confounding on those rare occasions when a graphic adventure contained something significant in the graphics that wasn't  mentioned in the text. I suspect that my door will be conveniently just outside of the camera frame...

Host

In Excalibur, there was an open and closed door image. I used the on_open {} and on_close {} handlers in conjunction with the set_graphic command to switch the graphic for the location.

Submitted(+1)

Mine's a little more sophisticated than that, but it boils down to the same thing. When the door state changes, change the image using set_graphic.