SetTrapDetectedBy(object, object, int)

Makes a trap detected by a creature.

int SetTrapDetectedBy(
    object oTrap,
    object oDetector,
    int bDetected = TRUE
);

Parameters

oTrap

A placeable, door or trigger

oDetector

A creature

bDetected

Sets whether oTrap has been detected or not.

Description

Set oDetector to have detected oTrap.



Remarks

This function can be used to make sure a character is aware of a trap.

This also works on traps that are flagged as not detectable. It can thus be used to force the PC to do a quest before the location of certain traps are revealed to him or her.

The return value of this function seems a little useless or bugged. One would suspect that it returns whether there was a trap on oTrap and thus could be flagged as detected. However, when a non-trap object is passed to oTrap, it still returns TRUE. Passing OBJECT_INVALID to either of the parameters will make it return FALSE, though. and there may be other instances that cause it to return FALSE as well. However, I would recommend against relying on it.

Furthermore, the fact that the function returns an integer means that it can't be delayed. If you want to delay it, you'll have to create a wrapper function as shown below, and call that instead.


Version

1.67

Example

// script to be used in objects onUsed event
// makes user detect the trap on object with tag "Chest1"
void main()
{
    object oTrap = GetObjectByTag("Chest1");
    object oDetector = GetLastUsedBy();
    SetTrapDetectedBy(oTrap, oDetector);
}


//Function to allow delaying of this command:
void VoidReturningSetTrapDetectedBy(object oTrap, object oDetector)
{
SetTrapDetectedBy(oTrap, oDetector);
}

See Also

functions: GetLastTrapDetected | GetTrapBaseType | GetTrapCreator | GetTrapDetectable | GetTrapDetectDC | GetTrapDetectedBy | GetTrapDisarmable | GetTrapDisarmDC | GetTrapFlagged | GetTrapKeyTag | GetTrapOneShot
categories: Traps Functions


 author: Chaz Mead, editor: Lilac Soul, Mistress