NPC Agency [from chat]

Originally sent in LabBarAtory
Lancelot

Working on some NPC agency. Am I correct in understand any such things are following from the Every turn rule? To give a concrete example, in the initial section the PC is looking for money in a house, searching all rooms, accompanied by an NPC. My daughter says it would make more sense the NPC is also searching while the PC does... that sounds kinda cool actually.

HanonO

In general if you want stuff to happen every turn, it pivots off an Every Turn rule, or some other action by the player, such as going or looking.

Like if you don't want your NPCs to move until the player does.

You can also kind of cheat agency in descriptions with idle/ambience messages.

Lancelot

The only thing I do not want an NPC to do is to walk out of the room, I would need to study the "Characters the Player Can Follow" chapter from Jim's Handbook.

oh yeah you mean the random "Stage Business", NPCs "doing" something which actually does not change any state

HanonO

The description of the Study is "It's a study, packed with paperwork.[if Holmes is in the location and the player does not enclose the key] Holmes is here, [one of]searching furiously for the key.[or]puzzling about the location of the key.[or]consulting his phone about potential key hiding spots.[then at random]"

Lancelot

The only problem I can potentially see is the Every Turn rule getting very large... I will probably have to split it up in more manageable chunks.

Ah the "enclose"... that was an eye-opener when I came across that relation.

HanonO

Yes, and the trick with that is you can only technically have one Every Turn rule. If you write multiples, it will only run the last one you wrote.

Lancelot

just a sec

HanonO

"enclose" is a good catch all since the player may not be holding the key, but may be carrying a closed matchbook in their backpack with the key inside.

If your Every Turn sequence gets really complicated, you likely want to have a general Every Turn that refers to other rules to run instead of doing everything directly.

Lancelot

hmm there are a lot of things which can happen actually... the NPC will follow the player (to ensure they stay together, I do not want the NPC to do stuff the PC cannot witness) so thats an easy one. However if the player does anything except move around, then the NPC can do a bunch of things, which would all be handled by this every turn rule...

thats the "manageable chunk" part I am looking for

I have a list of high level actions I want to implement

HanonO

You could put the NPC business in their description and base it on locality.

instead of every turn.

Lancelot

erm sorry that part I do not understand

description does not affect world state, does it?

HanonO

Bob is a man. "[if bob is in the location][bobdesc][bobactions][end if]"

Lancelot

that would only fire if the player does a 'look' wouldn't it?

HanonO

Yes. Depends on if the npc actions are just for atmosphere or actually doing stuff. That's why you can use a "to say" phrase that includes actions.

Lancelot

I want to go for the actually doing stuff... as in "assisting" the player when looking for hidden treasure

HanonO

to say bobactions: if the location is study: say "Bob searches the study for clues."; otherwise if the location is the beach: say "Bob chills with a drink in the sand.";

you can do that either way. This is probably a good forum topic.

1 Like

There are probably more elegant ways and other ways about it, but it’s best to keep your Every Turn rule non specific and delegate to other actions and rules instead of doing all the work, like:

[untested psuedocode]

Every turn:
    say "[movenpcs]";

to say movenpcs:
    if bob is not in the location:
        now bob is in the location;
        say "Bob arrives, a little flustered that you didn't wait for him to catch up.";
    end if;
    if the bad kitty is in the location:
        if the location is not Sunny Window Seat:
            say "That wretched cat sees you and saunters away giving you a pointedly clear raised-tail view of its backside.";
            now the bad kitty is in Sunny Window Seat;
        otherwise [if the location is Sunny Window Seat];
            say "The cat hisses at you in fear that you are here to steal its warm sunlight and skulks off to see if you've fed it again in the past twelve minutes.";
            now the bad kitty is in kitchen;
        end if;
    end if;

I’m sure with something like this you’d probably want to do something advanced like create an “NPC Movement Rulebook” or some such.

1 Like

All good advice! Just flagging that while I don’t have the IDE in front of me, I’m 99% sure you can have as many every turn rules as you want and they’ll all fire by default (unless you start mucking about with “rule succeeds” and that sort of thing).

Edit: in particular, I’ve found having lots of different specific every turn rules - “every turn when scene is happening”, “every turn when NPC is in the location” - super helpful for debugging and managing complexity though of course you need to be careful about interactions.

1 Like

You are probably right and it’s my inexperience with a game that had lots of Every Turn madness. You are right that Every Turn is a rulebook with multiple rules, but if you use a “rule fails” for “rule succeeds” (or possibly?) “continue the action” it might cancel out of the rest of the rules.

I wrote Baker before I likely understood that so that is probably better info.

1 Like

Ditto Hanon that for complicated behavior with a discrete domain, a good strategy can be giving it its own rulebook (or, sometimes, activity). Then a single every turn rule could say just: follow the foo rules or carry out the autonomous behavior activity with Bob.

Another viable alternative would be making it scene-driven, though as Hanon noted, that tends to end up with lots of every turn rules, too. (I made a During is a scene based rulebook thing just for the nicer readability of During <scene>.)

If “assisting the player” means doing things that affect the player’s own action (like, say, steadying a ladder the player is climbing), those things would need different handling that’s kicked off and reported by something within the action-processing rules.

3 Likes

For me, the main benefit of putting an NPC’s rules into their own rulebook is to ensure they only do one thing per turn. If you have several every turn rules, by default every one of them will run. But you can set up your “autonomy rules” (or whatever you’d like to call them) such that only one of them is executed per turn:

Autonomy is a rulebook. The autonomy rulebook has default success.
Every turn (this is the NPC autonomy rule): follow the autonomy rules.

Autonomy when life-threatening danger is happening:
Autonomy when Alice can see the player:
Autonomy: [Happens when no other rule handles the current situation]
2 Likes

Also you can then make an extension that contains the main “agency” machinery, while the specifics are contained in rules declared in the main text.

Or, in general, you can “factor” the agency code into the abstract machinery and the actual behaviors.

1 Like