Garry's Mod Wiki

ENTITY:OnTraceAttack

  ENTITY:OnTraceAttack( CTakeDamageInfo info, Vector dir, table trace )

Description

Called when a trace attack is done against the entity, allowing override of the damage being dealt by altering the CTakeDamageInfo.

This is called before ENTITY:OnTakeDamage.

This hook is only called for ai, anim (as of version 2026.07.03) and nextbot type entities.

Arguments

1 CTakeDamageInfo info
The damage info
2 Vector dir
The direction the damage goes in
3 table trace
The TraceResult structure of the attack, containing the hitgroup.