Conditional understanding? E.g. disabling "ask"?

Is there a way to make the system understand actions and commands contextually?

Say, “poke” meaning one thing when you’re using a computer in the game and another when you’re trying to move a squirrel or something, or “ask” giving you “No, don’t make a sound!” in one room but the normal “What do you want to ask …” results in another?

This has a number of applications: “attack” working in a hostile area and not in any others, etc.


This works on one level, but it’s not quite all the way there.

(This should be in the inform development subforum)

These are all pretty reasonable things to want to do. The way I’d do is with check rules for the actions you want to make conditional.

So it would look something like this (though obviously you’d have to define all the relevant actions first):

Check poking:
if the location of the player is the computer room begin;
try using the computer instead;
otherwise if the squirrel is held by the player;
try massaging the squirrel instead;
end if.

With a check rule, every time you try do the thing being checked (attacking, poking, asking etc.) the game engine checks the list of conditions, and can have it do or say other things as well or instead. If none of the conditions are met, the action goes off as usual.

It seems like there’s been a gradual shift in Inform away from using parsing to distinguish actions, and towards using action processing rules (mainly “check” and “instead”). The reason is that more information is available to the game when parsing is done - specifically, the person asked, the noun and the second noun (or the topic understood) are chosen and can be tested easily.

Also because consistent parsing is more transparent to players. This has always been good practice, as a general rule.

Yeah, I don’t think there’s any ‘gradual shift’ about it. The official I7 documentation explains Understanding several chapters later than the action sequence, and always has.

(Does some other source teach you Understanding before action rules? It’s been a while since I read Aaron’s book.)

What if you put some kind of object in every room and made it so that “attacking” or whatever was understood as applying to that object only.

Then the object attacks whatever you provided as an argument while making it look like you did the dirty work-- not mentioning itself, using your weapon data, etc. The equivalent of “give mercenary weapon and tell him to attack troll” being just “attack troll”.

This might fix some issues, wouldn’t it?

I was thinking of special tokens like [things inside], [someone], and [something preferably held], as well as the “carried thing” specification in action definitions. Except for “things inside,” none of these constructs rule out any visible objects entirely, they just cause special actions or messages to take place during parsing or early in command processing, but they are less flexible than normal action-processing rules.

I think “carried thing” is officially deprecated now, and [things inside] feels like legacy code to me. The others haven’t been discouraged in documentation, but I don’t think they’re encouraged either. I could imagine a “gradual shift” away from them as part of the same trend.

This is probably a very basic issue that has a simple solution, but I’m not quite grasping what exactly it is that you’re trying to accomplish. Practically every action has default behavior that usually blocks the action with a generic refusal message. For everything that should do something other than the default you add a set of rules that make it happen.

Maybe if you could write a short hypothetical transcript that would show the behavior you’re after?

This isn’t what I’m after, per se, but a kludge to get there.

“Attack Proxy” is, for the purposes of this, a hidden entity that will never show up in any descriptions under normal conditions. It is a proxy through which the operation of the “attack” command may be modified. There could be any number of proxies for any number of functions. I’m thinking here of, say, “ask” proxies, “look” proxies, etc.

The machine has been made to understand “attacking” as "giving either the current weapon or the specified weapon to the hidden entity “Attack Proxy” and instructing it to attack the specified target; thus

is the same as

whereupon it returns something like

under standard conditions.

and if certain conditions are met, the attack proxy (or ask proxy, or whatever) gives certain responses, e.g.

(you’re in the Chicago Dero Caves and tried attack once)

(this is like the “mistake” feature)

(you’re in the Chicago Dero Caves and tried attack twice)

(like the “mistake” feature with changing mistake text)

(you’re in the Chicago Dero Caves and tried attack three times)

Then, the fourth time, you shoot and almost get eviscerated by angry deros.

Another example would be, say, “ask” with no arguments:

(you’re a Dero in the Chrysler Basement and trying “ask” once:)

(you’re a Dero in the Chrysler Basement and trying “ask” twice:)

(you’re a Dero in the Chrysler Basement and trying “ask” five times:)

(you’re a Dero in the Chrysler Basement and trying “ask” more than five times:)

(or if you tried to ask “about” something to the empty room it could list the topic you tried to ask about in the last failure text)

Or maybe

(touching Jack in the coalroom before you’ve met Jack, and he’s not there:)

(touching Jack in the coalroom after you’ve met Jack, and he’s not there:)

I may have got it all wrong, but it seems to me that you want to have a stunt man perform these actions on behalf of the Player Character, while it should still look for all the world (and particularly for the player of the game) as if the PC was the actor.

But what is the point of modelling it that roundabout way? Why not let the PC perform these actions himself/herself in the first place? Why the stunt man?

I think you’re overthinking the problem a bit. I don’t see a reason to use some proxy object when you could just, well, do the same thing without it.

For example the attacking scenario (I don’t know what a dero is but let’s just make two of them):

[code]Outside caves is a room.
Chicago Caves is inside from Outside caves.
The player carries a revolver and a pencil.

A dero is a kind of thing. One dero is in Outside caves. One dero is in Chicago Caves.

Attacking it with is an action applying to one visible thing and one thing.
Understand “attack [something] with [something preferably held]” as attacking it with.

[The default response to attacking something]
Check attacking with:
say “Not a good idea.” instead.

[attacking with a non-weapon]
Check attacking with when the second noun is not the revolver:
say “[The second noun] is not a weapon!” instead.

[Attacking a dero normally]
Instead of attacking a dero with a revolver:
say “You shoot the dero, causing a puff of dust to release from its gruelike fur.”;
[+ whatever combat mechanisms you have]

[attacking in the caves]
Instead of attacking something with a revolver when the location is the Chicago Caves for the first time:
say “SHOOT it? Are you nuts? You’ll have the whole cavern of them after you! Run!”

Instead of attacking something with a revolver when the location is the Chicago Caves for the second time:
say “While you’re trying to solve everything with a gun, that oversized teddy bear is almost on top of you.”

Instead of attacking something with a revolver when the location is the Chicago Caves for the third time:
say “Fine. Do whatever. Get yourself killed. I hope you have UNDO enabled, you fool.”

Instead of attacking something with a revolver when the location is the Chicago Caves for the fourth time:
say “The deros eat you.”;
end the story.

Test me with “attack dero with pencil/attack dero with revolver/in/attack dero with revolver/attack dero with revolver/attack dero with revolver/attack dero with revolver”.[/code]

The resulting transcript is:

Is this what you were thinking about?

Because I don’t know any other way to do it with the current version and this seemed like a potential solution. Maybe there’s a way to do it with a plugin(?) but I don’t have any ideas how to write them.

Yes! But there is also the problem of wanting to do this:

and this

and this

This is what I’m concerned with. Are these all things that can be done currently?

Those can all be done. One thing to note is that there’s a built-in action called “attacking,” invoked by the command “attack foo” (or “hit foo,” “kill foo,” and several other things), whose default behavior is to print “Violence isn’t the answer to this one.” Which we don’t want to say, because violence usually is the answer.

[rant]"“This violence doesn’t solve anything!” “But that’s what violence does best!”[/rant]

So we find the rule that does this and remove it, thus:

The block attacking rule is not listed in the check attacking rulebook.

(You can do this by looking under the “commands” index for the command “attack”; it tells you that it translates to the attacking action, and if you look up that action, you can see that one of the rules governing it is the block attacking rule. Clicking on the little block next to “unlist” automatically drops the above text into your source.)

Now we have to make “attack foo” redirect to attacking it with a weapon, if you have one:

Instead of attacking something: if the player does not carry the revolver: say "You don't have anything to attack [the noun] with!"; otherwise: try attacking the noun with the revolver.

If you implement more than one weapon, you’ll have to change this code so that it checks if the player holds any weapon at all, and you’ll have to figure out a way for this to pick a weapon for you. Also, if you’ve got any timed challenges in here, it’ll be polite to make sure that things like the “if the player does not carry the revolver” case don’t make the timer click down – if the player is supposed to “attack dero with revolver” or die, and “attack dero” kills them, they won’t be pleased.

This automatically takes care of “attack,” because Inform asks “what do you want to attack?”

To take care of “attack with revolver,” we can define another action, and have that action redirect to attacking a random dero with whatever was specified:

[code]Attacking blindly with is an action applying to one thing. Understand “attack with [something]” as attacking blindly with.

Check attacking blindly with when no dero is in the location:
say “There’s nothing to attack here.” instead.

Check attacking blindly with when the noun is not a revolver:
say “[The noun] is not a weapon!” instead.

Carry out attacking blindly with:
if a dero is in the location:
try attacking a random dero in the location with the noun;
say “There’s nothing to attack here.” [This should never happen, because the check rule should already have stopped this case.][/code]

I think you’ll find that all the ways of attacking the dero increment Juhana’s counter the way you want – you’ll get the messages in order – because every successful attempt ultimately redirects to the action “attacking the dero with the revolver.” (BTW, we didn’t include anything that specifies that you have to be holding the weapon! As it stands, you can attack the dero with the revolver even when the revolver is on the floor. You’d want to include a check for that.)

UPDATE: Whoops, you want different dummy responses. That should be possible – just don’t say “try attacking a random dero in the location with the noun,” but instead make the rules for these actions print your dummy responses.

A series of dummy responses doesn’t require anything more than text with variations:

Instead of attacking something: if the player does not have the revolver: say "[one of]Dummy Response 1[or]Dummy Response 2[or]Dummy Response 3[stopping]".

But it’s better to correct the mistake automatically (ie, assume you’re attacking with the revolver if you have the revolver) than to just print a denial, so as to minimize the amount of time the player spends figuring out what syntax you want him/her to use.

You may also want to look at the extension Armed by David Ratliff, which is a simple combat implementation more or less the way you’re trying to do it.

(Am I the only one who can’t figure out how the proxy would help at all? You’d end up writing the exact same rules to govern the proxy’s actions and you’d need to write rules for handing things back and forth to the proxy, too.)

The proxy was, in retrospect, based on a misunderstanding.

What I’m really trying to do is write a kind of Korsakovia-esque thing that’s in the first person, so

I’m trying to remove/alter everything counter to this, e.g. the immersion-breaking

Since the above appears to be inner monologue, you might as well use the existing “think” action, like so.

Understand the command “ask” as something new.
Understand “ask” as thinking.

Instead of thinking, say “[one of]I kept asking myself, how could this happen?[or]I questioned my judgment.[stopping]”.[/code]

Now “ask” and “think” will both print whichever message is next in that series. It’s also simple to put some conditionals in there so that “ask” will return different statements depending on, say, where you are or what you’ve done so far.

If you’re writing a game in first person past tense, you’d want the extension Custom Library Messages by Ron Newcomb ( Install it (via the Inform IDE), then all you need is the lines

[code]Include Custom Library Messages by Ron Newcomb.

The story tense is past tense.[/code]
and all standard responses will automatically be transformed into the first person and the past tense.

So, doing that, would I be able to make “ask about” and “think about” equivalent, so that I could “think/ask Isidore about iron” and get the key to the Iron Door to use later, while “ask” with no arguments still returns responses 1, 2, 3, 4, 5, etc? I mean, this essentially allows me to do everything I could do with both of them?

If I understand what you want aright, it’s quick to do. Just put in the following two lines (in order – I think this is a case where the order of the source text matters).

Understand the command "think" as something new.

This gets rid of the built-in grammar for “think,” so it’s no longer understood as the thinking action. (See section 16.3.)

Understand the command "think" as "ask".

This makes “think” act like “ask” whenever it occurs in a command. (See section 16.2.) So if your game understood the commands >ASK, >ASK JOHN ABOUT KEY, >ASK ABOUT IRON, it will now understand >THINK, >THINK JOHN ABOUT KEY, and >THINK ABOUT IRON exactly the same way. (>THINK JOHN ABOUT KEY sounds funny – but it’s better to understand more things than fewer things!)

But couldn’t this possibly result in some undesired behavior by the parser? If “think” is being universally interpreted as “ask”, couldn’t thinking about something while in the same room with another NPC (or something else that can be questioned) result in that NPC attempting to respond?

Maybe this would be an opportune time to plug Mike’s “Conversation Motivations” plugin (I’m sorry, sir, I haven’t had a chance to test it thoroughly.) I recall his stating that internal dialog is one of the things his plugin handles.

Otherwise, maybe a table of thought responses?

(Seriously can’t believe I just suggested any kind of solution that involves tables.)