Garry's Mod Wiki

Revision Difference

ENTITY:OnTraceAttack#568076

<function name="OnTraceAttack" parent="ENTITY" type="hook">⤶ <added>2026.07.03</added>⤶ <description>⤶ Called when a trace attack is done against the entity, allowing override of the damage being dealt by altering the <page>CTakeDamageInfo</page>.⤶ ⤶ This is called before <page>ENTITY:OnTakeDamage</page>.⤶ <note>This hook is only called for `ai`, `nextbot` and `anim` type entities.</note>⤶ </description>⤶ <realm>Server</realm>⤶ <args>⤶ <arg name="info" type="CTakeDamageInfo">The damage info</arg>⤶ <arg name="dir" type="Vector">The direction the damage goes in</arg>⤶ <arg name="trace" type="table">The <page>Structures/TraceResult</page> of the attack, containing the hitgroup.</arg>⤶ </args>⤶ </function>⤶ ⤶