Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Neverwinter Nights: Enhanced Edition has been released! Visit nwn.beamdog.com to make an order. NWN:EE FAQ is available.
Soundtracks for BG:EE, SoD, BG2:EE, IWD:EE, PST:EE are now available in the Beamdog store.
Attention, new and old users! Please read the new rules of conduct for the forums, and we hope you enjoy your stay!

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: 354
    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: 19
    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.