Skip to content

noob questions about action queues

The following random script example I pulled from the internet:
void main()
{
    int iUsrEvn = GetUserDefinedEventNumber();

    if (iUsrEvn == 1001) /* OnHeartbeat */
    {
        /* if wounded and no longer in combat then rest and wander */
        if ((GetCurrentHitPoints() < GetMaxHitPoints()) && !GetIsInCombat())
        {
            ActionRest();
            ActionRandomWalk();
        }
    }
}
My questions are these:

If the heartbeat in NWN is every 6 seconds, wont calling ActionRest(); ActionRandomWalk() every 6 seconds completely fill up the action queue because they take longer than 6 seconds to complete, or does the queue have a finite limit of 2 and they just push anything already there off?

Also wont ActionRandomWalk() immediately cancel ActionRest(), so effectively the NPC will always be walking and never resting?

Comments

  • ProlericProleric Member Posts: 1,316
    See Lexicon - ActionRest generally does nothing, but ActionRandomWalk runs forever until actions are cleared, so the script is indeed building a very long queue of actions that will never happen.

    I've never hit a limit to the length of the action queue, so it seems unwise to do stuff like that.
  • DazDaz Member Posts: 127
    I think ActionRest() is actually instantaneous for NPCs, not 100% sure though.

    What this means is that the creature will instantly heal to full and start ActionRandomWalk(), but because the conditional checks for currentHP is less than maxHP, it won't call ActionRest/RandomWalk until it's injured again.
Sign In or Register to comment.