====== Plugin:OnTakeDamage ======
OnTakeDamage is called when any pawn ( [[api:cPlayer]] or mobs ; "Receiver") is damaged / hurt. It is called for any damage caused to a pawn, including environmental damage. The plugins may modify the amount of damage or effects with this hook by editting the TakeDamageInfo struct passed.

If any plugin returns "true", no more plugins are called and no damage and no effects will be applied to the Receiver. If all plugins return false, the server applies the [[API:TakeDamageInfo|TakeDamageInfo]] structure's damage and effects to the Receiver.

===== Parameters =====
<code lua>
function OnTakeDamage(Receiver, TDI)
</code>
Parameters:
| Receiver | [[API:cPawn|cPawn]] | The entity that is receiving the damage |
| TDI | [[API:TakeDamageInfo|TakeDamageInfo]] | Description of the damage and effects to be dealt |

===== Return values =====
If the function returns false, other callbacks are called and then the final TDI is applied to Receiver.
If the function returns true, no other callbacks are called, and no damage nor effects are applied.

===== Register Callback =====
To register your plugin for a callback on this function use the hook [[api:plugin:hooks | HOOK_TAKE_DAMAGE]]
<code lua>
PluginManager = cPluginManager:GetPluginManager()
PluginManager:AddHook( Plugin, cPluginManager.HOOK_TAKE_DAMAGE )
</code>

===== Example code =====
<code lua>
function OnTakeDamage(Receiver, TDI)
	-- log the damage to server log:
	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>
