GetAILevel

From NWN Lexicon

Contents

[edit] GetAILevel(object)

Retrieves the current AI (artificial intelligence) level that a creature is running at.

int GetAILevel(
    object oTarget = OBJECT_SELF
);

[edit] Parameters

oTarget

Creature to check the AI level of. (Default: OBJECT_SELF)


[edit] Description

Returns the current AI_LEVEL_* value that a creature is running at. Different AI levels indicate how smart a creature acts and how much CPU time and priority it receives. Creatures that are standing by doing nothing generally have AI_LEVEL_LOW, but when a creature enters combat it will have AI_LEVEL_NORMAL by default.



[edit] Remarks

Too many creatures with AI_LEVEL_NORMAL will tax the processor and performance degradation will occur.

AI_LEVEL_DEFAULT is recommended. Also note that the "smartness" is not actual "The AI will decide to do a worse action" but, "The AI doesn't have as much time from the CPU, and may have delayed actions".

On a creature with unset AI level or ai level set to -1 (default or invalid), function returns AI_LEVEL_LOW when there is a player character in same area as creature or AI_LEVEL_VERY_LOW when not.


[edit] Version

1.30

[edit] Example

// If the AI level is not AI_LEVEL_DEFAULT, set it to it!
 
void main()
{
    if(GetAILevel() != AI_LEVEL_DEFAULT)
    {
        SetAILevel(OBJECT_SELF, AI_LEVEL_DEFAULT);
    }
}

[edit] See Also

functions: 

SetAILevel

constants: 

AI_LEVEL_* Constants



 author: Charles Feduke, editor: Jasperre
 

Personal tools
Categories