how do i code unconsciousness using a function

i want to make the player able to be knocked out and be unable to use any verb other than wait
>sleep
You close your eyes to rest.
>take object
You are unconscious!


I would suggest creating a command called "unconscious", which has the regular expression pattern ^(?!wait\b) and displays a message saying something like "you can't do that".

When the player is unconscious, there are two options:

  1. Enable the "unconscious" command (which runs for any command other than "wait") by moving it into the player's room. (MoveObjectHere (unconscious))

    • When they wake up, use AddToInventory (unconscious) to disable that command again (adding a command to the inventory is the simplest way to remove it; using RemoveObject would make it work everywhere)
  2. Have a room whose description is something appropriate, and move the player there when they are unconscious.

    • You might need to set an attribute to their previous location, so you can move them back when they wake up.
    • In this case, you would want the unconscious command to always be in that room

Building off the idea of moving the player:
You could create a character with preset attributes that mimic unconsciousness, name it unconscious_player or something, put it in a room that describes being unconscious, and have a built-in timerscript/turnscript for that room that calls some function maybe named playerWakeUp() function after some time.

When the player goes unconscious, have some function maybe named PlayerGoUnconscious() change the game.pov = unconscious_player and then display the room's description (maybe use OnEnterRoom() ). When the turnscript finishes have it change game.pov = player and describe the player waking up.


Log in to post a reply.

Support

Forums