This commit is contained in:
ElCeejo 2022-08-03 23:36:23 -07:00
parent 2922ebd230
commit 6a0a9b30d4

17
api.lua
View file

@ -439,12 +439,14 @@ end
function creatura.basic_punch_func(self, puncher, tflp, tool_caps, dir) function creatura.basic_punch_func(self, puncher, tflp, tool_caps, dir)
if not puncher then return end if not puncher then return end
local tool = "" local tool
local tool_name = ""
if puncher:is_player() then if puncher:is_player() then
tool = puncher:get_wielded_item():get_name() tool = puncher:get_wielded_item()
tool_name = tool:get_name()
end end
if (self.immune_to if (self.immune_to
and is_value_in_table(self.immune_to, tool)) then and is_value_in_table(self.immune_to, tool_name)) then
return return
end end
self:apply_knockback(dir, 8) self:apply_knockback(dir, 8)
@ -459,10 +461,11 @@ function creatura.basic_punch_func(self, puncher, tflp, tool_caps, dir)
} }
end end
self:hurt(tool_caps.damage_groups.fleshy) self:hurt(tool_caps.damage_groups.fleshy)
local wear = floor((tool_caps.damage_groups.full_punch_interval / 75) * 9000) if tool then
local tool = puncher:get_wielded_item() local wear = floor((tool_caps.damage_groups.full_punch_interval / 75) * 9000)
tool:add_wear(wear) tool:add_wear(wear)
puncher:set_wielded_item(tool) puncher:set_wielded_item(tool)
end
if random(4) < 2 then if random(4) < 2 then
self:play_sound("hurt") self:play_sound("hurt")
end end