Scenes and Repeated Actions

In my current game i have NPC’s who can say several different things in each scene. I first attempt to implement it like this:

Instead of talking to Bob for the first time during Scene 1, say “‘Hello,’ says Bob”

Instead of talking to Bob for the second time during Scene 1, say “‘Hello again,’ says Bob”

Instead of talking to Bob for the first time during Scene 2, say “‘I loved you in Scene 1,’ says Bob”[/code]

Unfortunately, this doesn’t work because the repetition counter doesn’t seem to take scenes into consideration. If i talk to Bob during scene 1, then the last rule will never fire in Scene 2, since i have already talked to Bob once. The scene condition differs from every other condition in this regard. If, for example, i write:

Instead of talking to Bob while wearing the hat for the first time, say "'Nice hat', says Bob"

Then i can talk to Bob as many times as i want to without the hat, and the rule will still fire the first time i talk to him with it. Is there any way to somehow reset the counter during scenes?

Another thing:

I get tired of writing “…during scene X” after almost every single rule, so i have tried to somehow group rules for a scene into a rulebook like this:

Instead of talking to Bob during Scene 1:
Follow the scene 1 conversation rules.

The Scene 1 conversation rules is a rulebook.

A scene 1 conversation rule:
If the current action is talking to Bob for the first time:
say “‘Hello,’ says Bob”.[/code]

This also doesn’t work, since “for the first time” doesn’t seem to be a part of the current action. Without it, it works fine, but i need Bob to be able to say several different things in each scene. The stuff he says in Scene 2 should be completely independent of what he said in Scene 1. I could implement my own counter, but i also need to be able to take conditions like “…when wearing the hat” into consideration, which seems really hard to do manually - i would need seperate counters for each set of conditions.

This seems like it should be a pretty basic thing to do. Am i missing something?

I guess there are a few mechanisms you want to employ, and there are lots of different ways to deal with them.

First, the simplest form of talk counter is to use a [one of]…[stopping] sequence.

For instance:

instead of talking to bob: say "[one of]'Hi,' says Bob.[or]'Hi again,' says Bob.[or]'Hi for the third time,' says Bob.[or]'I'm not stalking you, I swear it,' says Bob.[stopping]";

This line alone gives you those four responses in turn, and repeats on the last one (for eternity). You can see this is much more wieldy than writing all those ‘instead of talking… for the third time’ lines.

See 5.7 in the docs for other neat variations on [one of].

So I use this method whenever appropriate, because it’s simplest.

But, like in your own ‘talking to Bob for the third time’ lines, the [one of] method doesn’t have a counter you can interfere with. You’d need a real counter (or counters) for that. But you may not need a numeric counter if we just group your dialogue differently. I’m gonna post a demo which does this. It combines:

  • Using [one of]…[stopping] phrases,
  • Keeping an eye on which scene we’re in,
  • Having Bob remark on your hat the first time he sees you wearing it in each scene. To do this, I attached a number to the hat - basically a flag. When Bob comments on the hat, the number becomes 1, and he won’t comment unless the number’s 0. When act two begins, I reset the number to 0 so that he can comment again.

I hope the demo can show you an approach to grouping and ordering dialogue (and other factors which may interrupt - EG whether you’re wearing a hat or not) so it’s easy to manage, and maybe how to use a numeric flag on the side. But I haven’t really gone into using a numeric flag to organise the dialogue itself, just because it wasn’t necessary for this demo.

Copy/paste it into Inform, run it, then type ‘test me’ at the prompt.

[code]“Two acts with Bob”

There is a room called The Office.
Bob is a man in The Office.

player wears a hat.

hat has a number called dug_it.

talking to is an action applying to one thing.
Understand “talk [person]”, “talk to [person]” as talking to.

Carry out talking to Bob:
if act one is happening:
if player wears hat and dug_it of hat is 0:
say “Bob says ‘Nice hat!’”;
now dug_it of hat is 1;
rule succeeds;
say “[one of]‘Hi,’ says Bob.[or]‘Hi again,’ says Bob.[or]‘Hi for the third time,’ says Bob.[or]‘I’m not stalking you, I swear it,’ says Bob.[stopping]”;
rule succeeds;
if act two is happening:
if player wears hat and dug_it of hat is 0:
say “Bob says ‘I wish to remark again that you are wearing a nice hat.’”;
now dug_it of hat is 1;
rule succeeds;
say “[one of]‘You rocked in scene one,’ says Bob.[or]‘Did I tell you how good you were in scene one,’ says Bob.[or]‘I have a habit of repeating myself,’ says Bob.[stopping]”.

act one is a scene. act one begins when play begins. act one ends when the time since act one began is 9 minutes.

When act one begins:
say “*** ACT ONE BEGINS NOW ***[line break]”.

When act one ends:
say “*** ACT ONE IS OVER ***[line break]”.

act two is a scene. act two begins when act one ends.

When act two begins:
now dug_it of hat is 0.

When act two ends:
say “*** ACT TWO IS OVER ***[line break]”.

test me with “i / drop hat / talk to bob / g / wear hat / talk to bob / g / g / g / remove hat / talk to bob / wear hat / talk to bob / g / g /g”.[/code]

Btw, to preserve the formatting of the code, click ‘quote’ on this post, and copy the code out of the window which appears, rather than trying to copy it directly off this forum post.

I like to make kinds of scenes. Well, I always forget that you can’t make kinds of scenes, but you can fake it with adjectives. I’d probably do something like this:

[code]talking to is an action applying to one thing.
Understand “talk [person]”, “talk to [person]” as talking to.

A scene can be conversational.
A person has a number called the talk count.

When a conversational scene begins:
Repeat with speaker running through people:
Now the talk count of speaker is 0.

Carry out talking to someone:
increment the talk count of the noun.[/code]

Also, don’t forget that you can do anything in a say phrase:

[code]Instead of talking to Bob when Act One is happening:
say “[one of]‘Hello, how do you do?’ says Bob[or]‘Lovely weather, isn’t it?’ Bob remarks[or]‘Did you see what Sheila was wearing today?’ Bob says, and then seeing that his comment was inappropriate considering your relationship with Sheila, blushes and ducks out of the room[exit Bob].[stopping]”

To say exit (item - a thing):
remove item from play;[/code]

Thanks for the help both of you, but it turns out all i needed was to write “Instead of talking to Bob when Scene 2 is happening for the first time” and not “Instead of talking to Bob for the first time during Scene 2”. The former version only counts the number of times i have spoken to Bob inside Scene 2, while the latter counts the total number of times and then only applies the rule during Scene 2. That subtle difference took me a while to figure out.

I will definitely keep the Doing Things in a Say Phrase trick in mind for later, though. I had no idea you could do that!