Minor improvements to basic punch

This commit is contained in:
ElCeejo 2022-08-01 14:05:10 -07:00 committed by GitHub
parent 7fa1c522eb
commit 35fb5b680e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

16
api.lua
View file

@ -436,7 +436,7 @@ function creatura.drop_items(self)
end end
end end
function creatura.basic_punch_func(self, puncher, time_from_last_punch, tool_capabilities, direction) 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 = ""
if puncher:is_player() then if puncher:is_player() then
@ -446,21 +446,21 @@ function creatura.basic_punch_func(self, puncher, time_from_last_punch, tool_cap
and is_value_in_table(self.immune_to, tool)) then and is_value_in_table(self.immune_to, tool)) then
return return
end end
self:apply_knockback(direction) self:apply_knockback(dir, 12)
if not tool_capabilities if not tool_caps
or not tool_capabilities.damage_groups or not tool_caps.damage_groups
or not tool_capabilities.damage_groups.fleshy then or not tool_caps.damage_groups.fleshy then
tool_capabilities = { tool_caps = {
damage_groups = { damage_groups = {
fleshy = 2 fleshy = 2
} }
} }
end end
self:hurt(tool_capabilities.damage_groups.fleshy) self:hurt(tool_caps.damage_groups.fleshy)
if random(4) < 2 then if random(4) < 2 then
self:play_sound("hurt") self:play_sound("hurt")
end end
if time_from_last_punch > 0.5 then if tflp > 0.5 then
self:play_sound("hit") self:play_sound("hit")
end end
self:indicate_damage() self:indicate_damage()