mirror of
https://github.com/ElCeejo/creatura.git
synced 2025-03-21 15:21:24 +00:00
Wear tools when punched
This commit is contained in:
parent
b41924d4cb
commit
2922ebd230
1 changed files with 7 additions and 2 deletions
9
api.lua
9
api.lua
|
@ -447,17 +447,22 @@ function creatura.basic_punch_func(self, puncher, tflp, tool_caps, dir)
|
||||||
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(dir, 12)
|
self:apply_knockback(dir, 8)
|
||||||
if not tool_caps
|
if not tool_caps
|
||||||
or not tool_caps.damage_groups
|
or not tool_caps.damage_groups
|
||||||
or not tool_caps.damage_groups.fleshy then
|
or not tool_caps.damage_groups.fleshy then
|
||||||
tool_caps = {
|
tool_caps = {
|
||||||
damage_groups = {
|
damage_groups = {
|
||||||
fleshy = 2
|
fleshy = 2
|
||||||
}
|
},
|
||||||
|
full_punch_interval = 1.4
|
||||||
}
|
}
|
||||||
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)
|
||||||
|
local tool = puncher:get_wielded_item()
|
||||||
|
tool:add_wear(wear)
|
||||||
|
puncher:set_wielded_item(tool)
|
||||||
if random(4) < 2 then
|
if random(4) < 2 then
|
||||||
self:play_sound("hurt")
|
self:play_sound("hurt")
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue