GetMatchCompatibility

From NWN Lexicon
Jump to: navigation, search



GetMatchCompatibility(talent, string, int)

Check if creature is able use a talent from a selected class in the requested method.

int GetMatchCompatibility(
    talent tUse,
    string sClass,
    int nType
);

Parameters

tUse

The talent to check.

sClass

The class to check.

nType

The method to use. (variable) NW_TALENT_*


Description

Returns a boolean true/false if the talent tUse is effective in protecting the NPC versus the sClass passed in. It is used to make random behavior.



Remarks

The function normally called prior to GetMatchCompatibility() is GetCreatureTalentRandom() which can only return a talen an NPC has, then GetMatchCompatibility checks to see if that talent is useful against the specified class.


Requirements

#include " x0_i0_match "

Version

1.26

Example

// NPC AI code (NOT TESTED IN ALL CASES)
// SOME CODE TAKEN FROM nw_i0_generic I TAKE NO CREDIT FOR IT.
#include "x0_i0_match"
void main()
{
    talent tUse;
    struct sEnemies sCount = DetermineEnemies();
    int bValid = FALSE;
    int nCnt;
    string sClass = GetMostDangerousClass(sCount);
 
    while(GetIsTalentValid(tUse) && nCnt < 10)
    {
        tUse = GetCreatureTalentRandom(TALENT_CATEGORY_BENEFICIAL_PROTECTION_SELF);
        if(GetIsTalentValid(tUse) && GetMatchCompatibility(tUse, sClass, NW_TALENT_PROTECT))
        {
            bValid = TRUE;
            nCnt = 11;
        }
        nCnt++;
    }
 
    if(bValid == TRUE)
        SendMessageToPC(GetFirstPC(),"NPC CAN USE TALENT");
}

See Also

functions: 

TalentAdvancedProtectSelf



 author: GoLeM, editor: Charles Feduke, Mistress, additional contributor: Genji