GetHasFeatEffect(int, object)

From NWN Lexicon
Jump to navigationJump to search

Determines whether a creature has the effects of a feat.

int GetHasFeatEffect(
    int nFeat,
    object oObject = OBJECT_SELF
);

Parameters

nFeat
FEAT_*
oObject
The object to investigate. (Default: OBJECT_SELF)


Description

Returns TRUE if oObject has effects on it originating from nFeat, otherwise FALSE. Note the caveat below that this is for spell-like feats, not real combat feats.

This does not detect, for instance, FEAT_KNOCKDOWN, FEAT_CALLED_SHOT, FEAT_STUNNING_FIST or FEAT_SAP ever since these apply effects outside of a script and have invalid SPELLID entries in feat.2da. Other feats (eg: FEAT_DISARM, FEAT_SMITE_EVIL) may provide an instant visual/other effect but of course this would be undetectable as an ongoing effect.

oObject can be anything that can have effects applied to it - creatures, placeable and doors.

It is a reasonably optimal function to call if you only need to check a single feats effect exists.


Remarks

Further testing of this shows this in fact doesn't detect application of combat feats with persistent effects (Knockdown, Called Shot, etc.) although sometimes you can detect those in different ways (generally they have an invalid spell Id) but instead it detects those feats that apply a "spell" effect.

Essentially does this command:

GetHasSpellEffect(StringToInt(Get2DAString("feat", "SPELLID", nFeat)), oObject);

Or to boil it down, it is doing this loop of effects:

int HasCreatureGotFeatEffect(int nSpellID, object oCreature = OBJECT_SELF)
{
    effect eEffect = GetFirstEffect(oCreature);
    while(GetIsEffectValid(eEffect))
    {
        if(GetEffectSpellId(eEffect) == nSpellID) return TRUE;

        eEffect = GetNextEffect(oCreature);
    }
    return FALSE;
}


See Also

functions: 

ActionUseFeat

constants: 

FEAT_* Constants



 author: Tom Cassiotis, editor: Jasperre