GetHasFeat(int, object)

From NWN Lexicon
Jump to navigationJump to search

Test whether a creature has a particular feat and it is usable.

int GetHasFeat(
    int nFeat,
    object oCreature = OBJECT_SELF


FEAT_* or line ID from feat.2da
Creature to check for feat. (Default: OBJECT_SELF)


Determine whether oCreature has nFeat, and nFeat is usable. Checks the highest level of a feat. Returns TRUE (1) if oCreature has nFeat and its usable, FALSE (0) otherwise.


Sadly there is no way to return the amount of times the feat is usable using this function, it is a binary "Can this feat be used at all". A workaround to this can be to keep checking GetHasFeat when in a loop decreasing the feat uses using DecrementRemainingFeatUses then to reset the uses use IncrementRemainingFeatUses.

The feat doesn't have to be usable to return TRUE, as feats such as Alertness, Simple Weapon Proficiency and so forth can be returned TRUE by this.

Any feat which stacks - such as bard songs, are got through the base (first) feat acquired for it - such as the first entry of FEAT_BARD_SONGS in feats.2da, or the first entry of FEAT_SNEAK_ATTACK in the same 2da.




// If the PC speaker has the feat "Alertness" then the NPC whispers
// "I see you know whats going on around you..."
// Goes in a conversation somewhere.
void main()
    if(GetHasFeat(FEAT_ALERTNESS, GetPCSpeaker()))
        // Speak the whisper
        SpeakString("I see you know whats going on around you...", TALKVOLUME_WHISPER);

See Also


FEAT_* Constants

 author: Iskander Merriman, editor: Jasperre, additional contributor(s): Samvel Oganesyan