RegisterForDirectLOSGain - 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 a direct LOS pick. If the viewer can currently see 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 RegisterForDirectLOSGain(ObjectReference akViewer, ObjectReference akTarget, string asViewerNode = "", \
  string asTargetNode = "") native

Parameters[edit | edit source]

  • akViewer: The ObjectReference that will be looking for the target.
  • akTarget: The target the reference will be looking for.
  • asViewerNode: The node on the viewer to cast the LOS check from. If empty, will cast from the object's root.
    • Default: ""
  • asTargetNode: The node on the target to cast the LOS check to. If empty, will cast to the object's root.
    • Default: ""

Return Value[edit | edit source]

None

Examples[edit | edit source]

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


; Register for the first time that Me sees Spot's head
RegisterForDirectLOSGain(Me, Spot, asTargetNode = "Head")

Notes[edit | edit source]

  • Most of the time you actually want RegisterForDetectionLOSGain instead, as it takes some more things into account and may do a better pick.
  • 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.
  • 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, a detection LOS event between the same two objects, or another direct LOS event between the same two objects but with different nodes, this registration will be dropped.
  • If you use the origin to cast to or from an actor, the ray may hit the ground first. To get around this, use a node on the actor that is higher up, like the pelvis or torso.
  • Aliases and quests will automatically unregister for this event when the quest stops. Active magic effects will automatically unregister when they are removed.
  • Nodes are defined in the nif file. Find them by targeting the object in the console and type SSG and then look at the names of the nodes in the scene graph.

See Also[edit | edit source]