Garry's Mod Wiki

Revision Difference

WEAPON:DoImpactEffect#512123

<function name="DoImpactEffect" parent="WEAPON" type="hook">⤶ <ishook>yes</ishook>⤶ <description>Called so the weapon can override the impact effects it makes.</description>⤶ <realm>Shared</realm>⤶ <predicted>No</predicted>⤶ <args>⤶ <arg name="tr" type="table">A &lt;page&gt;TraceResult&lt;/page&gt; from player&#x27;s eyes to the impact point</arg>⤶ <arg name="damageType" type="number">The damage type of bullet. See &lt;page&gt;DMG&lt;/page&gt;</arg>⤶ </args>⤶ <rets>⤶ <ret name="" type="boolean">Return true to not do the default thing - which is to call UTIL_ImpactTrace in C++</ret>⤶ </rets>⤶ </function>⤶ ⤶ <example>⤶ <description>Makes the SWEP have the AR2 bullet impact effect.</description>⤶ <code>⤶ function SWEP:DoImpactEffect( tr, nDamageType )⤶ ⤶ if ( tr.HitSky ) then return end⤶ ⤶ local effectdata = EffectData()⤶ effectdata:SetOrigin( tr.HitPos + tr.HitNormal )⤶ effectdata:SetNormal( tr.HitNormal )⤶ util.Effect( "AR2Impact", effectdata )⤶ ⤶ end⤶ </code>⤶ ⤶ </example>