Lua:buildable ondamage

From Fortress Forever Wiki
Jump to navigationJump to search


buildable_ondamage(buildable, damageinfo)

This function is called whenever a buildable takes damage.

Example

A player shooting nails at a buildable will do no damage.

function buildable_ondamage(buildable, damageinfo)

	local weapon = damageinfo:GetInflictor():GetClassName()
        local attacking_player = damageinfo:GetAttacker()
	local attacker = CastToPlayer( attacking_player )
	
	-- Take no damage from Nail shooting weapons
	if weapon == "ff_projectile_nail" then
		damageinfo:SetDamage(0)
		ChatToPlayer(attacker, "Nope!")
	end
	ConsoleToAll(attacker:GetName().." attacked with "..weapon)
end