Demo of time based turns with NPCs

I figured I’d share a short demo of a system where the players actions takes variable amounts of time and in that time between actions NPC turns are simulated. I mainly wanted to share in case this is useful to anyone else but any feedback is appreciated, I’m especially always looking to make things more generalized/abstract. I’m also not too sure how the current structure of how I’m going about this affects performance at all (and if that is something I need to worry about).

In short this is just a couple of variables stored by each person to mark when they last took an action and how long that action lasts (which is within each individual action). These are then used by rules which are followed every turn to determine if enough time has passed for the actor to take another action. For the player this results in an advancing of the time until their action is complete while these rules are run each in game minute to allow the npcs to act. Meaning the npcs can act several times while the player takes a praticularly long action or vice versa.

Demo
``````Lab is a room. Here is a person called gwen.

When play begins:
now the right hand status line is "Time: [time of day]".

Every person has a time called time of the last action.

Every person has a number called minutes the current action takes.

When play begins:
repeat with p running through persons:
now the time of the last action of p is the time of day;
now the minutes the current action takes of p is 0.

Every turn:
follow the player can't act again until the time is right rule.

This is the player can't act again until the time is right rule:
unless the time of day >= the time of the last action of the player plus the minutes the current action takes of the player minutes minus 1 minute:

This is the Gwen's turn rule:
if the time of day >= (the time of the last action of gwen plus the minutes the current action takes of gwen minutes):
try gwen waving hands.

Before an actor doing something:
now the time of the last action of the actor is the time of day.

carry out an actor jumping:
now the minutes the current action takes of the actor is 30;

Carry out an actor waving hands:
now the minutes the current action takes of the actor is 5;

Carry out an actor waiting:
now the minutes the current action takes of the player is 1.

Test me with "jump/wave/z/z/z/z/z/z"``````
7 Likes

excellent idea; can even be adapted to scene-based “abstract” time handling I favour on I7.

Kudos and best regards from Italy,
dott. Piergiorgio.

3 Likes