Contents
TakeDamageInfo class
This class contains the amount of damage, and the entity that caused the damage. It is used in the
HOOK_TAKE_DAMAGE hook and in the cEntity's TakeDamage() function.
Member variables
Name | Type | Notes |
Attacker |
cEntity |
The entity who is attacking. Only valid if dtAttack. |
DamageType |
eDamageType |
Source of the damage. One of the dtXXX constants. |
FinalDamage |
number |
The final amount of damage that will be applied to the Receiver. It is the RawDamage minus any Receiver's armor-protection. |
Knockback |
Vector3d |
Vector specifying the amount and direction of knockback that will be applied to the Receiver |
RawDamage |
number |
Amount of damage that the attack produces on the Receiver, including the Attacker's equipped weapon, but excluding the Receiver's armor. |
The TDI is passed as the second parameter in the HOOK_TAKE_DAMAGE hook, and can be used to
modify the damage before it is applied to the receiver:
function OnTakeDamage(Receiver, TDI)
LOG("Damage: Raw ".. TDI.RawDamage .. ", Final:" .. TDI.FinalDamage);
-- If the attacker is a spider, make it deal 999 points of damage (insta-death spiders):
if ((TDI.Attacker ~= nil) and TDI.Attacker:IsA("cSpider")) then
TDI.FinalDamage = 999;
end
end
|