Revision Difference
CTakeDamageInfo:SetDamageForce#564544
<function name="SetDamageForce" parent="CTakeDamageInfo" type="classfunc">
<description>
Sets the directional force of the damage.
<note>
This function only affects entities using the VPHYSICS movetype. This means players and most NPCs won't receive the force vector you provide as knockback.
If the entity taking damage is using the WALK or STEP holdtypes, the damage force is instead automatically calculated. It will push the entity away from the inflictor's <page>Entity:WorldSpaceCenter</page>, scaling the push by a calculated value involving the total amount of damage and the size of the entity. [Source](https://github.com/ValveSoftware/source-sdk-2013/blob/0565403b153dfcde602f6f58d8f4d13483696a13/src/game/server/baseentity.cpp#L1525)
If the entity taking damage is using the WALK or STEP movetypes, the damage force is instead automatically calculated. It will push the entity away from the inflictor's <page>Entity:WorldSpaceCenter</page>, scaling the push by a calculated value involving the total amount of damage and the size of the entity. [Source](https://github.com/ValveSoftware/source-sdk-2013/blob/0565403b153dfcde602f6f58d8f4d13483696a13/src/game/server/baseentity.cpp#L1525)
To disable knockback entirely, see [EFL_NO_DAMAGE_FORCES](https://wiki.facepunch.com/gmod/Enums/EFL#EFL_NO_DAMAGE_FORCES) or use the workaround example below.
</note>
</description>
<realm>Shared</realm>
<args>
<arg name="force" type="Vector">The vector to set the force to.</arg>
</args>
</function>
<example>
<description>Workaround for player knockback quenching.</description>
<code>
local ent = Entity(1)
local oldvel = ent:GetVelocity()
-- Damage taking example
local dmgi = DamageInfo()
dmgi:SetDamageType( DMG_RADIATION )
dmgi:SetDamage( 5 )
dmgi:SetAttacker( Entity(0) )
dmgi:SetInflictor( Entity(0) )
ent:TakeDamageInfo( dmgi )
local newvel = ent:GetVelocity()
ent:SetVelocity( oldvel - newvel )
</code>
</example>