GetDetectMode(object)

Determines if a creature is currently searching.

int GetDetectMode(
    object oCreature
);

Parameters

oCreature

Creature to determine if it is detecting for stealthy creatures.


Description

Returns DETECT_MODE_ACTIVE if oCreature is in search mode and DETECT_MODE_PASSIVE if not.



Known Bugs

Sometimes returns a 2 for DETECT_MODE_PASSIVE instead of 0. A work around appears at the bottom of the code sample.


Version

1.29

Example

// See if a search for a hidden item works when entering a trigger
int nDC = 20;       // Difficulty of search, "20" is just an example
object oPC = GetEnteringObject();
if ( GetIsPC(oPC) ) {
    int nSearch = GetSkillRank( SKILL_SEARCH, oPC );
    // Use only half the search value if not actively searching
    if ( GetDetectMode(oPC) == DETECT_MODE_PASSIVE ) {
        nSearch = nSearch / 2;
    }
    // Use a standard D&D style skill check
    if ( d20() + nSearch >= nDC ) {
        // Search successful - place code here 
    }
}

// fix for GetDetectMode and DETECT_MODE_PASSIVE
// contributed by: Slow Slosh
int GetDetectModeBugFix(object oCreature) 
{
    int iMode = GetDetectMode(oCreature);
    if(iMode == 2) {iMode = DETECT_MODE_PASSIVE;}
    return iMode;
}

See Also

categories: Get Data from Creature Functions
constants: DETECT_MODE_* Constants


 author: Drake Coker, editor: Charles Feduke, additional contributor(s): Slow Slosh