GetIsResting

From NWN Lexicon
Jump to navigationJump to search



GetIsResting(object)

Check whether a creature is resting.

int GetIsResting(
    object oCreature = OBJECT_SELF
);

Parameters

oCreature

Creature to be checked. (Default: OBJECT_SELF)


Description

Returns TRUE if oCreature is currently resting. Otherwise, returns FALSE.



Remarks

Note that applying effects such as EffectSleep() or animations such as ANIMATION_LOOPING_SIT_CROSS do not count. Only if a PC has selected his or her "rest" function, or if an NPC has been given the ActionRest() script command will this function return TRUE.


Known Bugs

Prior to 1.28, this function always returned FALSE if called outside of the event OnPlayerRest.


Version

1.28

Example

// Creature On Perceive script - if we see a PC who is sleeping, we
// will go "bonk some 'eads!"
void main()
{
    // Get creature perceived
    object oSeen = GetLastPerceived();

    // Get is can see it, or rather, we can now see it. Must also be a PC.
    if(GetLastPerceptionSeen() && GetIsPC(oSeen))
    {
        // Lets go bonk their head if they are resting
        if(GetIsResting(oSeen))
        {
            SpeakString("'ere, you need bonking on der 'ead!");
            ClearAllActions();
            ActionAttack(oSeen);
        }
    }
}

See Also

functions: 

GetLastRestEventType



 author: Jason Harris, editor: Jasperre