RegisterForDetectionLOSGain - ScriptObject

From the Fallout4 CreationKit Wiki
Jump to navigation Jump to search

Member of: ScriptObject

Registers this script to receive a single OnGainLOS based on actor detection or current player camera view. If the viewer is currently looking at the target, the event will be sent immediately.

Only the script that registers for an event will receive it. Other scripts attached to the same form, alias, or magic effect will not receive the event unless they also register for it.

Syntax[edit | edit source]

Function RegisterForDetectionLOSGain(Actor akViewer, ObjectReference akTarget) native

Parameters[edit | edit source]

  • akViewer: The Actor that will be looking for the target.
  • akTarget: The target the actor will be looking for. If the viewer is not the player, this must be an actor.

Return Value[edit | edit source]

None

Examples[edit | edit source]

; Register for the first time that Me sees Spot
RegisterForDetectionLOSGain(Me, Spot)

Notes[edit | edit source]

  • The form that this function is called on doesn't have to be the viewer or the target. In this way you could have a quest that gets LOS events from between the player and the quest objective.
  • If the viewer is the player the target may be an actor, or an object. If the viewer is an actor that isn't the player, then the target must be an actor. Actors will simply do a single check (using the detection system) and the player will do three picks (low, medium, and high) clipped to the camera to see if they see it.
  • Since LOS picks are expensive, they are heavily throttled in code. The more scripts that register for LOS events, the more the delay each script will have in receiving its events. As a general rule, one pick will be done per frame - not counting objects that can be trivially determined not to see each other (example: player looking for something that is behind them). So for example, if 30 scripts register to know when the player can see something, and that something is in the camera view (but maybe hiding behind a log) then the script may not get a LOS event for a full second - or if the player looks away and then looks back within a second, no events will be sent.
  • A script can only be registered for one kind of LOS event per viewer/target pair. If you register for LOS lost or a direct LOS event between the same two objects, this registration will be dropped.
  • Aliases and quests will automatically unregister for this event when the quest stops. Active magic effects will automatically unregister when they are removed.

See Also[edit | edit source]