# Checking if another person is alive during the scene

[Topics merged: Checking if another person is alive during the scene/ “the map region of the location” in an ‘if’ clause]

Hello,

I am trying to write an “if” clause for the game to check if another alive person is in the current scene. I know how to do this for the location, but I haven’t figured out how to do it for all the locations in a current scene.

This is what I have come up with, in regard to the location solution:

[code]A thing can be lethal. A thing is usually not lethal.
A person can be alive or dead. A person is usually alive.

Definition: a thing is other if it is not the player.

The Bathroom is a room.

Janet is a woman in the bathroom.

The kitchen knife is carried by the player. It is a lethal thing. The description of the kitchen knife is “Sharp and stainless.”

The toothpaste is in the bathroom. The description is “Fluoride can kill you.”

Wielding is an action applying to one carried thing. Understand “wield [something]” as wielding.

Carry out wielding:
say “You wield [the noun] without much effect. No wonder. [The noun] is not a weapon of any kind.”

Instead of wielding a lethal thing:
if an other alive person (called victim) is in the location:
say “You ruthlessly attack [the victim].”;
else:
say “You are alone. Whom are you going to fight with?”
[/code]
So, how can I do the same for a scene instead of a location?

Thanks

[code]The Final Battle is a scene.

Instead of wielding a lethal thing during the Final Battle:
if an other alive person (called victim) is in the location:
say “You ruthlessly attack [the victim].”;
else:
say “You are alone. Whom are you going to fight with?”[/code]

If you need to check a range of rooms, you could combine them into a region.

``````The house is a region.
The bathroom is a room in the house. The bedroom is a room in the house.

Instead of wielding something when an other alive person is in the house:
etc.``````

Yes, jrb! The region solution is probably the best.

mikegentry, I am trying to check for alive persons in all rooms, not just the one location, so defining a scene will not solve my problem. Thanks, though!

So, my question now is how to write an ‘if’ clause that concerns the current region (without naming the region). I can write

``if an other alive person (called victim) is in the location:``

but I cannot write

``if an other alive person (called victim) is in the region:``

What is the right way to say this?

By searching the Inform documentation, I found Example 114: Politics as Usual, that uses the term

``map region of the location``

but now the outcome of the following is that “You are alone…” even if Janet is alive. I don’t get it…

[code]A thing can be lethal. A thing is usually not lethal.
A person can be alive or dead. A person is usually alive.

Definition: a thing is other if it is not the player.

The Bedroom is a room. The Bathroom is south of the Bedroom.

The Bates Motel is a region. The Bedroom and the Bathroom are in the Bates Motel.

Janet is a woman in the bathroom.

The kitchen knife is carried by the player. It is a lethal thing. The description of the kitchen knife is “Sharp and stainless.”

The toothpaste is in the bathroom. The description is “Fluoride can kill you.”

Wielding is an action applying to one carried thing. Understand “wield [something]” as wielding.

Carry out wielding:
say “You wield [the noun] without much effect. No wonder. [The noun] is not a weapon of any kind.”

Instead of wielding a lethal thing:
if an alive person (called victim) is in the map region of the location:
say “You ruthlessly attack [the victim].”;
move the player to the location of the victim;
else:
say “You are alone. Whom are you going to fight with?”[/code]

OK, I worked some more and it seems to be working now. I first set “a region that varies” and then I put an “every turn” rule to define it as “the map region of the location.” I wonder if this is the only way to do it.

Here it is, below. If anyone can comment on the orthodoxy or the style of the solution, I would appreciate it:

[code]A thing can be lethal. A thing is usually not lethal.
A person can be alive or dead. A person is usually alive.

Definition: a thing is other if it is not the player.

The current area is a region that varies.

Every turn:
now the current area is the map region of the location.

The Bedroom is a room. The Bathroom is south of the Bedroom.
The Bates Motel is a region. The Bedroom and the Bathroom are in the Bates Motel.

The parking lot is west of the Bedroom. The shop is west of the parking lot.
Exteriors is a region. The shop and the parking lot are in the exteriors.

Janet is a woman in the bathroom. The description is “Young and likeable. You remember that she eats like a bird.”
Alfred is a man in the parking lot. The description is “He is the director.”

After examining a person, say “[The noun] is [if the noun is alive]currently enjoying life[else]dead[end if].”

The kitchen knife is carried by the player. It is a lethal thing. The description of the kitchen knife is “Sharp and stainless.”

The toothpaste is in the bathroom. The description is “Fluoride can kill you.”

Wielding is an action applying to one carried thing. Understand “wield [something]” as wielding.

Carry out wielding:
say “You wield [the noun] without much effect. No wonder. [The noun] is not a weapon of any kind.”

Instead of wielding a lethal thing (called the murder weapon):
if an other alive person (called victim) is in the current area:
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;
else:
say “You are alone. Whom are you going to fight with?”
[/code]

Possibly try “enclosed by”, and perhaps just specify a region because they nest.

``if an alive person (called victim) is enclosed by the motel region and the player is enclosed by the motel region:``

You might also make a room adjective that specifically allows violence for finer control.

```A room can be a murderscene. The Hotel Bathroom is a murderscene. ```
Then

[code]if an alive person (called victim) is enclosed by a murderscene (called place):
if the location of the player is not place:
move the player to place;
say “Sensing your victim is in [place], you run there immediately to begin the carnage!”

When play begins:
Repeat with potentialplace running through rooms enclosed by Bates Motel region:
now potentialplace is a murderscene.[/code]

I haven’t tested this code exactly so it might need tweaking, but I’ve done very similar stuff like this in a game.

Hey HanonO, thanks for the answer. If I understand correctly, though, what you suggest does not establish a general rule that refers to the region the player is currently at, which is what I am looking for. I mean, I have to specify actual regions, in order to get it to work.

That’s why I came up with the every turn rule, using the “map region of the location,” above.

I am still left with the question how come I am not allowed to use the terms “location” and “map region of the location” in a similar way.

Hello,

Although I can use the term “the map region of the location” to print the region the player is currently at (just like “location” can be used to print the location of the player), it doesn’t seem to work when I put it in an if clause (while “location” does).

Specifically, in the following code,

``	if an other alive person (called victim) is in the map region of the location:``

doesn’t work as expected (or at least as “location” would).

I would appreciate if someone helped me clarify why this is happening.

Many thanks,
G.

[code]A thing can be lethal. A thing is usually not lethal.
A person can be alive or dead. A person is usually alive.

Definition: a thing is other if it is not the player.

After going to a room:
say “This is part of [the map region of the location].”;
continue the action.

The Bedroom is a room. The Bathroom is south of the Bedroom.
The Bates Motel is a region. The Bedroom and the Bathroom are in the Bates Motel.

The parking lot is west of the Bedroom. The shop is west of the parking lot.
Exteriors is a region. The shop and the parking lot are in the exteriors.

Janet is a woman in the bathroom. The description is “Young and likeable. You remember that she eats like a bird.”
Alfred is a man in the parking lot. The description is “He is the director.”

After examining a person, say “[The noun] is [if the noun is alive]currently enjoying life[else]dead[end if].”

The kitchen knife is carried by the player. It is a lethal thing. The description of the kitchen knife is “Sharp and stainless.”

The toothpaste is in the bathroom. The description is “Fluoride can kill you.”

Wielding is an action applying to one carried thing. Understand “wield [something]” as wielding.

Carry out wielding:
say “You wield [the noun] without much effect. No wonder. [The noun] is not a weapon of any kind.”

Instead of wielding a lethal thing:
if an other alive person (called victim) is in the map region of the location:
say “You ruthlessly attack [the victim].”;
move the player to the location of the victim;
else:
say “You are alone. Whom are you going to fight with?”
[/code]
In order to make things work, I used “a region that varies” and an “every turn rule.” I don’t know if this is the only workaround. So, here it goes:

[code]A thing can be lethal. A thing is usually not lethal.
A person can be alive or dead. A person is usually alive.

Definition: a thing is other if it is not the player.

The current area is a region that varies.

Every turn:
now the current area is the map region of the location.

The Bedroom is a room. The Bathroom is south of the Bedroom.
The Bates Motel is a region. The Bedroom and the Bathroom are in the Bates Motel.

The Parking Lot is west of the Bedroom. The Shop is west of the parking lot.
Exteriors is a region. The shop and the parking lot are in the exteriors.

Janet is a woman in the bathroom. The description is “Young and likeable. You remember that she eats like a bird.”
Alfred is a man in the parking lot. The description is “He is the director.”

After examining a person, say “[The noun] is [if the noun is alive]currently enjoying life[else]dead[end if].”

The kitchen knife is carried by the player. It is a lethal thing. The description of the kitchen knife is “Sharp and stainless.”

The toothpaste is in the bathroom. The description is “Fluoride can kill you.”

Wielding is an action applying to one carried thing. Understand “wield [something]” as wielding.

Carry out wielding:
say “You wield [the noun] without much effect. No wonder. [The noun] is not a weapon of any kind.”

Instead of wielding a lethal thing (called the murder weapon):
if an other alive person (called victim) is in the current area:
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;
else:
say “You are alone. Whom are you going to fight with?”[/code]

I’m not sure why your original code doesn’t work; it might be an Inform bug.

You can use a decide phrase:

```To decide which region is the current area: decide on the map region of the location.```

That lets you use “current area” in an if clause (it worked when I tested it), without having to mess around with global variables or every turn rules.

You’re running into the issue about “in” and regions discussed in §6.11 of Writing with Inform. Usually “in” means the relation of containment–the way in which a thing can be in a container or a room. But “in” can also mean regional containment, which holds when a thing enclosed by any of the rooms in a given region.

Usually Inform infers that “in” means regional containment when we’re talking about a specific region–if you write “If Janet is in the Bates Motel” then the compiler knows that you must mean regional containment, because that’s the only thing that makes sense with a region. But when you use a variable, like (apparently) in this case, sometimes Inform fails to infer that we mean regional containment. (I guess that in the second example, since current area is a region-typed variable, Inform was able to make the inference–but “map region of the location” doesn’t work because it’s defined as an object, since it can be nothing when a room isn’t in any region.

The workaround is that we can explicitly specify regional containment by saying “regionally in.” So in the first code example, if you change " if an other alive person (called victim) is in the map region of the location:" to “if an other alive person (called victim) is regionally in the map region of the location:”, it’ll work.

By the way, be careful about using “in” with rooms. When something is on a supporter or in a container in a room, it doesn’t count as “in” the room, because “in” refers only to direct containment. If you want to allow for that possibility, say “If the location of the victim encloses the player” rather than “If the player is in the location of the victim.”

The issue with the “current area” workarounds is that it can wind up mixing types when you have a room that’s not in a region–then the map region of the room will be nothing, which is an object rather than a location. Add “Backstage is north of the bedroom” (this is probably not accurate film terminology) and Giannis’s solution will throw a run-time error when you go to the bedroom. Mike’s doesn’t seem to throw an error in that case–not sure why–but it seems kind of risky to me to mix objects and regions in this way.

See the other thread; the “map region” property of a room is actually an object variable rather than a region variable (because it could be nothing), and this means that Inform can’t figure out that when you say “in the map region of the location” it’s supposed to check the version of “in” that works on regions rather than the version of “in” that works on rooms and such. If you change “in” to “regionally in” it will work. See §6.11 of Writing with Inform.

Ah, you’re right. I forgot about the “regionally in” phrase.

Yep, indeed, I have opened a new thread on the subject and, yes, the “regionally in” is the magic phrase. Thanks, Matt!

[And I have merged them together into a menacing golem of knowledge. Muahaha. - Hanon]

Giannis’s solution throws the error when you go north to Backstage (when the “every turn” rule fires). Mike’s throws it when you wield the knife (when the “to decide” rule fires).

Of course, it’s easy enough to avoid the issue by making sure every room is in a region, though I don’t think there’s a neat way to do this automatically.

Thanks a lot! The “regionally” solved it all! It did seem to me that an “every turn” rule would be an overkill…

And also thanks for clarifying the difference between “the location of the victim encloses the player” and “the player is in the location of the victim”! I did notice things on supporters being ignored, as if they were not “in the room,” but I didn’t know the correct phrasing to include them.