OnPerception
The script attached to this event will fire whenever another creature perceives another creature or PC. Common uses of this script include having the creature yell a battle cry, greet the PC, or run away.
Trigger
Something has entered the creature's perception radius, but is not automatically detected. Note that something does not neccessarily mean a PC.
Function(s)
GetLastPerceived()
returns the last perceived creature (whether or not it was actually seen or heard).
GetLastPerceptionHeard()
returns TRUE or FALSE as to whether the last perceived object was also heard.
GetLastPerceptionInaudible()
returns TRUE or FALSE as to whether or not the last perceived object has become inaudible (unable to be heard).
GetLastPerceptionSeen()
returns TRUE or FALSE as to whether or not the last perceived object was seen.
GetLastPerceptionVanished()
returns TRUE or FALSE as to whether or not the last perceived object can no longer be seen (invisible).
DetermineCombatRound(object, int)
for standard combat round actions.
Remarks
The OnPerception generic AI gives priority to first going into search mode if an enemy has suddenly vanished, then telling the creature to combat an enemy that has appeared.
Example
// creature turns towards anyone he sees // if the creature seen is female, the NPC bows void main() { int nEvent = GetUserDefinedEventNumber(); if (nEvent == 1002) // OnPerception event { object oTarget = GetLastPerceived(); // check for sight if (GetLastPerceptionSeen()) { ActionDoCommand(SetFacingPoint(GetPosition(oTarget))); // if they female, bow if (GetGender(oTarget) == GENDER_FEMALE) { ActionWait(0.5); ActionPlayAnimation(ANIMATION_FIREFORGET_BOW); } } } }
See Also
Objects with Events | Creature | |
functions: | DetermineCombatRound | GetLastPerceived | GetLastPerceptionHeard | GetLastPerceptionInaudible | GetLastPerceptionSeen | GetLastPerceptionVanished |
Send comments on this topic.