MSFD Determine whether an Actor is detected by another Actor
[no fix] GetDetected, "Actor ID" (returns Boolean/short)
If ( GetDetected, Player == 1 )
Returns true if any calling Actor can detect "Actor ID" (thanks for the correction, ThePal!). This function will return 0 if the Actor is hidden in some form, e.g. is sneaking successfully, or has an invisibility or chameleon spell active. According to the helpfile this is a slow function, do not call it a lot (e.g. make a counter to only call it every 3 seconds).
Sample script: The player must approach an object undetected – if not he is "caught"
Begin jeanneScript
float timer
short nolore
if ( GetJournalIndex "EB_Bone" < 20 )
Return
endif
if ( GetJournalIndex EB_Bone >= 40 )
Return
endif
Set timer to ( timer + GetSecondsPassed )
if ( timer < 5 ) ;this makes sure GetDetected is only called every 5 seconds
Return
endif
Set timer to 0
if ( GetDistance Player <= 1024 )
if ( player->GetDistance "com_chest_02 " <=128 )
if ( GetDetected Player == 1 )
ForceGreeting ;The player has been caught and will be punished
Journal EB_Bone 50
endif
endif
endif
End jeanneScript
GetDetected calling an NPC's ID if there's more than one reference in the game will return nothing. For example:
getDetected, "fargoth"
will return 1, but:
GetDetected "Imperial Guard"
Returns nothing. (Not 0, it doesn’t return a value). However if you reference an exact NPC:
GetDetected "Imperial Guard00000002"
A value is returned.
(Forum info / Fliggerty )