Every turn & try rule

I have defined a “shooting” action:

[code]Shooting is an action applying to one thing. Understand “shoot [something]” as shooting. The shooting action has an object called the weapon (matched as “with”). Setting action variables for shooting: now the weapon is a random gun carried by the actor.

A check shooting rule: if the weapon is nothing then say “You don’t have a gun, sir.”

Check shooting: if the noun is not a person, say “Wanton violence is frowned upon.” instead.

Carry out shooting: remove the noun from play; award 10 points; say “[The noun] falls to the floor. That must have hurt; as you step over the body you whisper ‘Sorry about that.’ It makes you feel better.”

Instead of shooting the player: say “You aren’t so depressed as to consider suicide. Yet.”

Instead of someone shooting the player: end the game in death.[/code]

I also have a Guard kind, so that I can make lots of baddies scattered across the map without naming them (as they’re supposed to be cardboard cutout-type villains.) I want them to shoot the player whenever they are in the same room. But the code Every turn when the location of a Guard (called the baddie) is the location of the player: try the baddie shooting the player. isn’t working. Is there another way to do this?

Finally, I want all Guards to have shotguns (another kind). Can I do this? Inform doesn’t like me saying “A Guard usually has a shotgun”, because it’s too vague. What other way can I say this?

That’s because you’ve just named your action “shooting”, but since it takes two nouns, you need to name it “shooting it with”, like so:

Shooting it with is an action applying to two things.

“It” is a placeholder that tells Inform where the first noun will go. Otherwise, Inform has no way of understanding “shooting the victim with the shotgun”.

If the shotgun is already a kind, you can just say:

Every guard carries a shotgun.

Inform is being a little confusing here. The problem is that you can’t talk about the “location” of a guard (or anything else) because “the location” always refers to the player’s location. Instead, use:

Every turn when the location encloses a Guard (called the baddie), try the baddie shooting player.

You could also use:

Every turn when a Guard (called the baddie) is in the location, try the baddie shooting player.

But that will only work if the guard is directly in the room, not if the guard is in a chair or on a bed or something.

Thank you! That was giving me a lot of grief.

One more question: can I have the baddie wait 1 turn for the player to react to its presence? There is no “Every other turn” rule… :unamused: I would set a variable to be the time, then do some sort of statement of “at 1 minute after pause, if the location encloses the baddie, try the baddie shooting the player” but the baddie wouldn’t be carried over into the if statement. I could do a boolean, but I don’t know how that’d work.

You could do it like this:

[code]A guard can be alert.
A guard is usually not alert.

Every turn when the location encloses a guard (called the baddie) and the baddie carries a shotgun and the baddie is not alert:
say “[The baddie] spots you and points his shotgun at you!”;
now the baddie is alert.

Every turn when a guard (called the baddie) is alert (this is the guard kills player rule):
now the baddie is not alert;
if the location encloses the baddie and the baddie carries a shotgun (called the weapon), try the baddie shooting the player with the weapon.

The guard kills player rule is listed first in the every turn rules.[/code]
If you don’t name the second rule and specify that it runs first, the other rule will run first because it’s more specific. Then the game will go straight on to the “guard kills player” rule, instead of waiting until the next turn, causing the player to be killed immediately.