Question before I try to solve it on my own - let's say I want to chain the player up. While self is incapacitated, verbs like jump and push and take don't work. Some do, though, like look and talk.
Is the only real way to go verb by verb in a particular room and check the incapacitated property?
Incapacitated player
Moderators: Ice Cream Jonsey, joltcountry
- Ice Cream Jonsey
- Posts: 30175
- Joined: Sat Apr 27, 2002 2:44 pm
- Location: Colorado
- Contact:
Incapacitated player
the dark and gritty...Ice Cream Jonsey!
- pinback
- Posts: 17910
- Joined: Sat Apr 27, 2002 3:00 pm
- Contact:
Re: Incapacitated player
Can all verbs be sent through a filter that can check the state of a global variable? I forget/never knew if that was possible.
When you need my help because I'm ruining everything, don't look at me.
- RealNC
- Posts: 2301
- Joined: Wed Mar 07, 2012 4:32 am
Re: Incapacitated player
Page 92 of The Hugo Book might help.
- Flack
- Posts: 9084
- Joined: Tue Nov 18, 2008 3:02 pm
- Location: Oklahoma
- Contact:
Re: Incapacitated player
I don't know if this is possible, but I was thinking of something along the lines of checking the location and only allowing certain actions, instead of limiting every single verb. Dunno if that is possible or not, just brainstorming.
Terrible pseudo code, but mabye something along those lines?
Code: Select all
if (in dungeon) {
if (verb -eq look) {
action
} elseif {
if (verb -eq talk) {
action
} else {
"You are incompacitated, chum.
}
"I failed a savings throw and now I am back."
-
- Posts: 2255
- Joined: Mon Apr 29, 2002 6:23 pm
- Location: Milwaukee
Re: Incapacitated player
Nikos has it right. You want AnyVerb. It catches all standard verbs but isn't called by xverbs (SAVE, RESTORE, etc.). You'd want something like this in the applicable room:
Code: Select all
before
{
AnyVerb(location)
{
if player is chained
{
select verbroutine
case &DoLookAround, &DoLook, &DoTalk : return false
case else : "You're chained, duh."
return true
}
else
return false
}
}
- pinback
- Posts: 17910
- Joined: Sat Apr 27, 2002 3:00 pm
- Contact:
Re: Incapacitated player
So, a filter that all verbs are sent through that can react to a global variable. Nice going, Pinback!
When you need my help because I'm ruining everything, don't look at me.
-
- Posts: 2255
- Joined: Mon Apr 29, 2002 6:23 pm
- Location: Milwaukee
Re: Incapacitated player
Nice going, pinback!
Using routines to return variables can be useful for other situations, too. For a long time, it bugged me that the Hugo standard library didn't support >LISTEN without an object, but trying to add support for room sounds was trickier than one would first imagine because messages would be called multiple times throughout the player/location before/after cycle. For a long while, Roodylib got around this by clearing the verbroutine global so messages wouldn't be called a second time. Eventually, this bugged me, though, since ideally, the game should always know what the last turn was.
Somewhat recently, I decided to go a routine based route:
where you would put something like this in the rooms which have sounds:
Using routines to return variables can be useful for other situations, too. For a long time, it bugged me that the Hugo standard library didn't support >LISTEN without an object, but trying to add support for room sounds was trickier than one would first imagine because messages would be called multiple times throughout the player/location before/after cycle. For a long while, Roodylib got around this by clearing the verbroutine global so messages wouldn't be called a second time. Eventually, this bugged me, though, since ideally, the game should always know what the last turn was.
Somewhat recently, I decided to go a routine based route:
Code: Select all
routine RoomSounds(obj)
{
if verbroutine = &DoListen and not object
return location
else
return false
}
Code: Select all
before
{
RoomSounds(location)
{
"No sounds but the wind."
}
}