A TADS3/adv3 module providing low-level NPC target-seeking behaviors

A TADS3/adv3 module for simple NPC target-seeking behaviors: targetEngine github repo.

This provides agendas for three basic NPC behaviors: move an NPC to a location, have an NPC take an object, and have an NPC examine something.

To have an NPC use the target engine logic, just declare useTargetEngine = true on the NPC:

      alice: Person 'Alice' 'Alice' 
              "She looks like the first person you'd turn to 
              in a problem. "
              isHer = true
              isProperName = true

              useTargetEngine = true
      ;

Now if you want Alice to take the pebble, you could use:

        // Tells alice to >TAKE the pebble. 
        alice.obtain(pebble);

By itself this won’t send Alice off to find the pebble, it just tells the actor to attempt to take the pebble when and where they see it. You can give an NPC multiple targets, so if you want Alice to gather the ingredients for a BLT, you can use something like:

        alice.obtain(bacon);
        alice.obtain(lettuce);
        alice.obtain(tomato);

…assuming all three objects are defined in the game. This will tell Alice to attempt to take each of the listed items when she encounters them.

The target engine currently provides the following behaviors:

  • moveTo(loc) Attempts to move the NPC to the given location
  • obtain(obj) If the NPC finds themselves in the same location as the object, they will attempt to obtain it
  • observe(obj) If the NPC finds themselves in the same location as the object, they will attempt to examine it

Each of these methods accepts a callback function as the optional second argument. The callback will be called when the target is reached/obtained/completed, with the argument boolean true on success or nil on failure.

This is the first part of a system of more general NPC goal-seeking I’m working on. This is intended to hold just the low-level nuts-and-bolts stuff—no decision-making, just the in-game mechanisms for accomplishing individual tasks.

5 Likes

You are making me want to switch back to adv3 from adv3lite. Nice work!

1 Like