Preventing the player from changing rooms

Hi guys! In a text adventure game I'm practicing with, I'd like to have an NPC set a flag that puts them close to you and prevents you from changing rooms until you retreat. The flag setting is easy, but is there a simple way to temporarily immobilize the player until a specific command is given?


You need to lock that room. There should be an option in the exit's attributes or features.

This is how it looks on the web version.
_
https://i.imgur.com/DkZTDAk.png
https://i.imgur.com/VsID1P6.png

To unlock it, you need to name the exit. Then you need to find where you want the code to go, and put the unlock exit function there.
_
https://i.imgur.com/CP0wCDt.png
https://i.imgur.com/QinAaS6.png
_

You can also make the exit invisible, not shown, if you prefer that.
_
Here it is on the web version.
_
You need to have the option unchecked for the exit to be invisible.
_
https://i.imgur.com/wLt7ekX.png
https://i.imgur.com/4AJcwj5.png
_
Code to make it visible or invisible. The exit also has to be named for this to work.
_
https://i.imgur.com/0kjA55K.png
_
(I forgot the code to do that big line thing.)


Appreciate it, jmnevil! But what about universally? I could do this, but I would have to code every single exit throughout the game. Doable, but seems inefficient. I've basically coded all of my enemy NPC's to advance to striking range on my character once I enter. I would also have to include the "You can't escape at this range" message in the "Print message when locked" section, which means it would display it whenever a door is actually locked.

Seriously though, thank you for the help! This is certainly an option I can make work with some modifications.


might not be what you want, but maybe this can be of help for you:

https://docs.textadventures.co.uk/quest/guides/immobilise_the_player.html


Have you tried moving the player and NPC to a "combat room" with no exits, then move the player back to the old room when he wins?


One alternative would be modifying the "go" command so that it checks if you're able to move.

It could just be a matter of adding an extra check to the existing command:

    if (exit.visible) {
      if (HasObject (game.pov, "immobilised")) {
        msg (CapFirst (GetDisplayAlias (game.pov.immobilised)) + " won't let you move!")
      }
      else if (exit.locked) {
        msg (exit.lockmessage)
      }
      else if (exit.runscript) {
        if (HasScript(exit, "script")) {
          do (exit, "script")
        }
      }
      else if (exit.lookonly) {
         msg ("[UnresolvedLocation]")
      }
      else {
        if (HasString(exit, "message")) {
          if (not exit.message = "") {
            if (game.clearscreenonroomenter) {
              game.currentexitmessage = exit.message
            }
            else {
              msg(exit.message)
            }
          }
        }
        game.pov.parent = exit.to
      }
    }
    else {
      msg ("[UnresolvedLocation]")
    }

Then when an NPC stops you moving, you just do player.immobilised = some_npc to immobilise them, and set that attribute to null when the player is free to move again.


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums