Two-noun activities

Hello,

I was looking for a way to carry out an activity that refers to a specific noun and I found out the solution in Example 139 (Witnessed 1) of Writing with Inform.

[code]Warning about failure of something is an activity.

Rule for warning about failure of a device (called the machine): … etc.[/code]
and then

carry out the warning about failure activity with the machine; 

Then, I realised that I need a way to carry out an activity that has to two nouns: killing someone with something (or killing something with something). I tried to define the activity in a way similar to defining a new action, but it didn’t work:

[code]Killing it with something is an activity.

Rule for killing a person (called the victim) with a thing (called the murder weapon):
if the player is not in the location of the victim:
say "You charge into [the location of the victim]. ";
say “You ruthlessly attack and kill [the victim] with [the murder weapon].”;
move the player to the location of the victim;
now the victim is dead.
[/code]
and when I want the activity to happen:

carry out the killing... err... with... I dunno

:open_mouth:

OK, this is definitely wrong. But what is the right way to write a two-noun activity?
(Not a two-noun action, mind you.)

Thanks!

I don’t think you can. An activity is essentially a specialized rulebook, and a rulebook can be object-based, but you only get to define the one object.

You can, however, pass variables to an activity, and the variables will be remembered throughout the before, for, and after rules.

[code]Killing something is an activity.

The killing activity has an object called the weapon.

Before killing a person:
if the player carries a lethal thing:
let the weapon be a random lethal thing carried by the player.

Rule for killing a person:
say “You rush in, brandishing [the weapon].”

etc.[/code]

If you don’t mind me asking, why are you wrapping this in an activity? Based on what I’ve seen of your code in threads so far, this could probably all be handled with the action-processing rulebooks.

Hi Mike,

Thanks for the reply.

My code so far (Bates Motel) is not the actual game I am currently working on, but something I quickly put together to illustrate my point as clearly as possible when asking about regions etc. on this forum.

In the actual game I’m working on, I have the player going berserk under specific circumstances, smashing objects and killing people involuntarily. (You’ve already replied one or two of my questions, here.) So, I don’t want the player to have “kill” as an option for action, but I do want to have it carried out as an activity by the game itself, when the above circumstances are met.

Cheers,
G.

An action doesn’t need to be an option for the player. If you just do this:

Killing it with is an action applying to a visible thing and a thing.

then you’ll be able to write “try killing Janet with the toothpaste,” but the player won’t be able to invoke that directly as an action, because there aren’t any Understand lines for it.

On the other hand, if you don’t need before/after/check stuff on killing, and if you don’t want general action rules to apply (for instance, if you have a “Before doing anything when…” rule), then you might be able to get away with a phrase:

To kill a person (called the victim) with a thing (called the murder weapon): if the player is not in the location of the victim: say "You charge into [the location of the victim]. "; say "You ruthlessly attack and kill [the victim] with [the murder weapon]."; move the player to the location of the victim; now the victim is dead.

This will work if this encapsulates everything you want to do with “kill Janet with toothpaste”–if you don’t need any Before or After rules. The thing about activities is that they let you write Before (activity) and After (activity) rules (these are not quite the same as the rules for actions), and they also allow you to write multiple rules that preempt each other. (Though you can kind of do that with phrases too–see §11.3 of Writing with Inform.) But if you don’t need that extra stuff, then the activity and action machinery just seems like it’ll give you more headache.

Oh, man, I haven’t gone that far in the Writing with Inform handbook, yet, and it’s full of meaty stuff… Yes, it seems that a phrase will do the trick. Thanks for the replies and the patience, Matt!