Page 1 of 1
Incapacitated player
Posted: Wed Dec 11, 2019 10:05 pm
by Ice Cream Jonsey
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?
Re: Incapacitated player
Posted: Thu Dec 12, 2019 6:51 am
by pinback
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.
Re: Incapacitated player
Posted: Thu Dec 12, 2019 10:37 am
by RealNC
Page 92 of The Hugo Book might help.
Re: Incapacitated player
Posted: Thu Dec 12, 2019 10:39 am
by Flack
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.
Code: Select all
if (in dungeon) {
if (verb -eq look) {
action
} elseif {
if (verb -eq talk) {
action
} else {
"You are incompacitated, chum.
}
Terrible pseudo code, but mabye something along those lines?
Re: Incapacitated player
Posted: Thu Dec 12, 2019 12:11 pm
by Roody_Yogurt
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
}
}
Re: Incapacitated player
Posted: Thu Dec 12, 2019 1:00 pm
by pinback
So, a filter that all verbs are sent through that can react to a global variable. Nice going, Pinback!
Re: Incapacitated player
Posted: Thu Dec 12, 2019 1:22 pm
by Roody_Yogurt
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:
Code: Select all
routine RoomSounds(obj)
{
if verbroutine = &DoListen and not object
return location
else
return false
}
where you would put something like this in the rooms which have sounds:
Code: Select all
before
{
RoomSounds(location)
{
"No sounds but the wind."
}
}