Room descriptions of persons that move around

This is Inform 7 standard description for a NPC that moves to another room:

You can see Rudolf Carter here.

Rudolf Carter goes north.

This works, of course, but I don’t find it very elegant. In addition, an every turn rule may even write itself in between.

How do you feel about it? How do you handle this? Are there any easy ways to connect the two paragraphs?

(I’m aware of the Hiding a person in room descriptions during a chase sequence? thread – maybe the best solution really is to set the NPC temporarily to undescribed.)

Changing the basic presentation of ‘A is here… A goes (direction)’ is not elementary.

If the player enters a room containing Rudolf Carter, who might be moving this turn, and you don’t want the player to see that message ‘You can see Rudolf Carter here’ when they enter, the program has to know that Rudolf WILL move on this turn. It may not need to know where he’s going yet (that can wait til the every turn rules sort it out) but it has to know that he is going to leave the room. Then it can (a) flag him in some way and so suppress the statement of him being there in the LOOK and (b) Roll that statement into a more graceful Report rule, or ‘Rule for writing a paragraph about Rudolf Cater’ that detail him leaving.

Without this preknowledge, it’s too late for the game to act, if it printed out the room description during this turn, whether due to movement or the player LOOKing.

It’s hard to get around. Making him undescribed just means players won’t know he’s there unless he moves. If he’s guaranteed to move every time you enter the room, you can get away with this approach. But if he lingers for even a turn, you’re back to requiring some kind of manipulation on him. Making him described and undescribed, and/or flagging him if he’s about to move, etc.

Personally I’m fine with the default presentation, and it’s a convention that works. Of course, it doesn’t have to look as spare as ‘A is here’ , ‘A goes north’. You can jazz up the report rule with variations, or the paragraph written about the NPC in the first place. But of course there’s something to be said for clarity, especially if the NPC moves a lot, or there are lots of NPCs.

-Wade

3 Likes

I concur with Wade that it’s fiddly.

Here’s one basic way to make the sentences flow a bit more naturally:

The last person named is a person that varies. Before printing the name of a person (called target): now the last person named is the target.

Report someone going when the room gone from is the location:
	if the person asked is the last person named:
		say "[regarding the person asked][They] leaves in the direction of [the room gone to].";
	otherwise:
		say "[The person asked] leaves in the direction of [the room gone to].";
	rule succeeds;

This will report the movement as “He leaves …” or “She leaves …” as appropriate, referring to the last person named in the output.

Here’s a small example scenario for testing:

The Hub is a room.
The Lab is north of the Hub.
The Annex is north of the Lab.
The Office is south of the Hub.

The last person named is a person that varies. Before printing the name of a person (called target): now the last person named is the target.

Report someone going when the room gone from is the location:
	if the person asked is the last person named:
		say "[regarding the person asked][They] leaves in the direction of [the room gone to].";
	otherwise:
		say "[The person asked] leaves in the direction of [the room gone to].";
	rule succeeds;
	
Rudolf Carter is a man in the Hub.
Jane Doe is a woman in the Hub.

Every turn:
	repeat with NPC running through people who are not the player:
		if NPC is in the location and a random chance of 1 in 2 succeeds:
			[this is to simulate a possible atmospheric message]
			say "[The NPC] looks around nervously.";
		let L be the location of the NPC;
		let R be a random room which is adjacent to L;
		let D be the best route from L to R;
		try NPC going D;

The output reads like this:

Hub
You can see Rudolf Carter and Jane Doe here.

>z
Time passes.

Rudolf Carter leaves in the direction of the Office.

Jane Doe looks around nervously.

She leaves in the direction of the Office.

>l
Hub
Rudolf Carter arrives from the south.

Jane Doe arrives from the south.

>l
Hub
You can see Jane Doe and Rudolf Carter here.

He leaves in the direction of the Lab.

Jane Doe leaves in the direction of the Lab.

This is just a barebones example, there are probably various potential pitfalls and caveats.

The idea is extracted from section 6 (Movement Description) of the much more sophisticated and complicated example “Patient Zero”, cf. 7.13. Traveling Characters.

4 Likes

If you figure out how to consolidate multiple NPC movement reporting…

I’ve so far failed to distill “Patient Zero” into something I can plug and play.

1 Like

Side question: can a person (NPC) have an initial appearance? And would it remain when they move around? Since initial appearance remains until the player picks up an object which is normally blocked on a person by standard rules.

If an NPC has an initial appearance, that should prevent a message like “You can also see the Prime Minister here.”? Or does a kind of person have different rules?

1 Like

Yup, initial appearances work for characters, and would replace the “you can also see…” messages - so that can be a helpful approach to making the prose more interesting though of course you still need a mechanical solution like the one @StJohnLimbo proposed.

2 Likes

Why not something like this? Just postpone describing an NPC until an every turn rule. And of course “George is here” can be any fidgeting or idle behavior you want.

The lab is a room. "The lab is decorated with a mural of the periodic table.".
The garden is west of the lab.

George is a man in the lab.

For printing a locale paragraph about a person (called P):
	set the locale priority of P to 0;
	continue the activity;
	
After looking for the first time:
	say "George is here."; [because every turn rules aren't fired before the first command]
	
Every turn:
	if a random chance of 1 in 2 succeeds:
		try george jumping;
	otherwise if a random chance of 1 in 2 succeeds:
		if the location of george is the garden:
			try george going east;
		otherwise:
			try george going west;
	otherwise if george is in the location:
		if the action name part of the current action is the looking action:
			say "George is here.";
2 Likes

Yeah, this idea occurred to me about 5 minutes after my first post, at which point I was in bed.

If you don’t have too many NPCs, or too many mobile NPCs, this could work well.

You don’t have to necessarily apply it to all NPCs, either. If you comment out the 'For printing a locale paragraph about a person (called P):' in Phil’s example, and just make the particular NPCs that you want to have handled by every turn rules alone undescribed (leaving the others, well, not undescribed) you can mix this method in.

-Wade

2 Likes

Of course then the precise location at which descriptions are printed will be inconsistent between the two classes of NPCs.

What I would do is make some activities like describe mobile NPC or act as mobile NPC and allow the various NPCs to hook into the every turn rule, instead of bloating that one rule. Essentially describe mobile NPC would substitute for printing a locale paragraph about.

Edit: then NPCs would have a default behavior for these activities, and you wouldn’t have to write too many rules.

3 Likes

Thanks so much for the feedback!

Sometimes there are unexpectedly simple solutions in Inform. I was hoping for something like that here, but I’m beginning to understand how intricate this is.
So far I had used an approach that changes the initial appearance depending on the room. From what I’ve read here, I gather that the only way to get the result I want is via an every turn rule.

@StJohnLimbo and @rileypb: Thanks for the code snippets! I will try both of those and see what works best in my case. Once I’ve settled on something I’ll post it here. I’ve already learned a lot from the examples!

I’m not surprised at all, that looks very complex and complicated!

3 Likes