====== TakeDamageInfo ======
The TakeDamageInfo is a struct that contains the amount of damage, and the entity that caused the damage. It is used in the [[API:Plugin:OnTakeDamage|OnTakeDamage]]() hook and in the [[API:cEntity|cEntity]]'s TakeDamage() function.
===== Member Variables =====

^ Variable ^ Type ^ Meaning ^
| DamageType | eDamageType | Source of the damage. See below for list of values |
| Attacker | [[API:cEntity|cEntity]] | Attacker causing this damage (only if dtAttack) |
| RawDamage | number | Amount of damage that the attack produces on the Receiver, including the Attacker's equipped weapon, but excluding the Receiver's armor |
| 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 | number | Vector specifying the amount and direction of knockback that will be applied to the Receiver |

===== eDamageType =====
This enumerated type describes the source of damage. Note that there is a StringToDamageType() and DamageTypeToString() [[API:Plugin:Globals|helper function]].

^ Value ^ Notes ^
| dtAttack | Entity is being attacked by another entity. the Attacker member variable points to the attacker |
| dtLightning | Entity was struck by a lightning |
| dtFalling | Falling down; dealt when the entity hits the ground |
| dtDrowning | Drowning in water / lava |
| dtSuffocating | Suffocating inside a solid block |
| dtStarving | Hunger-induced damage |
| dtCactusContact | Contact with a cactus block |
| dtLavaContact | Contact with a lava block |
| dtPoisoning | Having the poison effect |
| dtOnFire | Being on fire |
| dtFireContact | Contact with a fire block |
| dtInVoid | Falling into the void (Y < 0) |
| dtPotionOfHarming | Hit by a potion of harming |
| dtAdmin | Damage applied by an admin command |

===== Usage =====
The TDI is passed as the second parameter in the [[api:plugin:ontakedamage|OnTakeDamage]] plugin hook
<code lua>
function Plugin:OnTakeDamage(Receiver, TDI)
	LOG("Damage: Raw ".. TDI.RawDamage .. ", Final:" .. TDI.FinalDamage)

	if ((TDI.Attacker ~= nil) and TDI.Attacker:IsA("cSpider")) then -- Check if the attacker is a Spider
		TDI.FinalDamage = 999 	-- change the damage to 999 ! Super-deadly spiders :D
	end
end
</code>