mirror of
https://github.com/ElCeejo/creatura.git
synced 2025-03-22 23:52:22 +00:00
Fix code
This commit is contained in:
parent
2922ebd230
commit
6a0a9b30d4
1 changed files with 10 additions and 7 deletions
11
api.lua
11
api.lua
|
@ -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)
|
||||||
|
if tool then
|
||||||
local wear = floor((tool_caps.damage_groups.full_punch_interval / 75) * 9000)
|
local wear = floor((tool_caps.damage_groups.full_punch_interval / 75) * 9000)
|
||||||
local tool = puncher:get_wielded_item()
|
|
||||||
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
|
||||||
|
|
Loading…
Add table
Reference in a new issue