trace

line

Traces a line and returns the trace data

trace_result_t line(<vec3_t> start, <vec3_t> end, [optional] <entity_t> ignore_entity, [optional] <int> trace_mask = MASK_SOLID)
FieldsDescription

start vec3_t

trace start

end vec3_t

trace end

ignore_entity entity_t

[optional] entity to skip

trace_mask int

[optional] trace mask or MASK_SOLID

Example

local trace_result = trace.line(from, to, local_player)
if(trace_result.entity ~= nil) then
    print("hit:",trace_result.entity:get_name())
end

hull

Performs a hull trace and returns the trace data

trace_result_t hull(<vec3_t> start, <vec3_t> end, <vec3_t> hull_mins, <vec3_t> hull_maxs, [optional] <entity_t> ignore_entity, [optional] <int> trace_mask = MASK_SOLID)
FieldsDescription

start vec3_t

trace start

end vec3_t

trace end

hull_mins vec3_t

trace hull minimum

hull_maxs vec3_t

trace hull maximum

ignore_entity entity_t

[optional] entity to skip

trace_mask int

[optional] trace mask or MASK_SOLID

Example

local trace_result = trace.hull(from, to, box_mins, box_maxs, local_player)
if(trace_result.entity ~= nil) then
    print("hit:",trace_result.entity:get_name())
end

bullet

Performs a bullet trace (autowall) and returns the bullet data

bullet_data_t bullet(<vec3_t> start, <vec3_t> end, [optional] <entity_t> attacker = local_player, [optional] <entity_t> target)
FieldsDescription

start vec3_t

trace start

end vec3_t

trace end

attacker entity_t

[optional] trace from entity, local_player by default

target entity_t

[optional] trace to entity

Example

local trace_result = trace.bullet(from, to, local_player, enemy)
if(trace_result.valid and trace_result.damage > 0) then
    print("player can be damaged")
end

Last updated