Incapacitated player

This is a discussion / support forum for the Hugo programming language by Kent Tessman. Hugo is a powerful programming language for making text games / interactive fiction with multimedia support.

Hugo download links: https://www.generalcoffee.com/hugo
Roody Yogurt's Hugo Blog: https://notdeadhugo.blogspot.com
The Hugor interpreter by RealNC: http://ifwiki.org/index.php/Hugor

Moderators: Ice Cream Jonsey, joltcountry

User avatar
Ice Cream Jonsey
Posts: 25294
Joined: Sat Apr 27, 2002 2:44 pm
Location: Colorado
Contact:

Incapacitated player

Post 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?
the dark and gritty...Ice Cream Jonsey!

User avatar
pinback
Posts: 15897
Joined: Sat Apr 27, 2002 3:00 pm
Contact:

Re: Incapacitated player

Post 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.
In the yard, not too far from the car.

User avatar
RealNC
Posts: 1885
Joined: Wed Mar 07, 2012 4:32 am

Re: Incapacitated player

Post by RealNC »

Page 92 of The Hugo Book might help.

User avatar
Flack
Posts: 7874
Joined: Tue Nov 18, 2008 3:02 pm
Location: Oklahoma
Contact:

Re: Incapacitated player

Post 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?
"Jack Flack always escapes." -Davey Osborne

Roody_Yogurt
Posts: 2080
Joined: Mon Apr 29, 2002 6:23 pm
Location: Milwaukee

Re: Incapacitated player

Post 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
    }
}

User avatar
pinback
Posts: 15897
Joined: Sat Apr 27, 2002 3:00 pm
Contact:

Re: Incapacitated player

Post by pinback »

So, a filter that all verbs are sent through that can react to a global variable. Nice going, Pinback!
In the yard, not too far from the car.

Roody_Yogurt
Posts: 2080
Joined: Mon Apr 29, 2002 6:23 pm
Location: Milwaukee

Re: Incapacitated player

Post 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."
		}
	}

Post Reply