(Official) LUA Scripting Documentation
intersect_frustum
Frustum intersection query.
Spec:
intersect_frustum(
double x1,
double y1,
double z1,
double x2,
double y2,
double z2,
long fov,
bool players,
bool npcs,
bool display)
Parameters
x1: The x component of the world position at the center of the frustum near planey1: The y component of the world position at the center of the frustum near planez1: The z component of the world position at the center of the frustum near planex2: The x component of the world position at the center of the frustum far planey2: The y component of the world position at the center of the frustum far planez2: The z component of the world position at the center of the frustum far planefov: The field of view of the frustum specified in degrees. If omitted, the default is 60players: true = test for players, false = do not test for players. If omitted, the default is truenpcs: true = test for NPCs, false = do not test for NPCs. If omitted, the default is truedisplay: true = display an outline showing the frustum of the test. If omitted, the default is false
Returns
bool: True if there is at least one players/NPC positioned within the frustum
The context target is set as the closest actor inside the frustum
Example
local dir = vec3(get_view_dir())
local near = vec3(get_eye_pos()) + (dir * 0.2)
local far = near + (dir * 50)
if intersect_frustum(near.x,near.y,near.z,far.x,far.y,far.z,60)
then
set_context("target")
add_health_effect(-10)
end
Incomplete
This documentation is incomplete