Use correct puncher

This commit is contained in:
rubenwardy 2020-03-14 23:17:34 +00:00
parent 5593df448f
commit 777cfe8b24

View file

@ -234,7 +234,11 @@ shooter.punch_node = function(pos, spec)
end end
end end
shooter.punch_object = function(object, tool_caps, dir, on_blast) shooter.punch_object = function(object, tool_caps, dir, on_blast, puncher)
if type(puncher) == "string" then
puncher = minetest.get_player_by_name(puncher)
end
local do_damage = true local do_damage = true
local groups = tool_caps.damage_groups or {} local groups = tool_caps.damage_groups or {}
if on_blast and not object:is_player() then if on_blast and not object:is_player() then
@ -251,7 +255,7 @@ shooter.punch_object = function(object, tool_caps, dir, on_blast)
for k, v in pairs(groups) do for k, v in pairs(groups) do
tool_caps.damage_groups[k] = v * config.damage_multiplier tool_caps.damage_groups[k] = v * config.damage_multiplier
end end
object:punch(object, nil, tool_caps, dir) object:punch(puncher, nil, tool_caps, dir)
return true return true
end end
end end
@ -337,7 +341,7 @@ local function process_hit(pointed_thing, spec, dir)
elseif pointed_thing.type == "object" then elseif pointed_thing.type == "object" then
local object = pointed_thing.ref local object = pointed_thing.ref
if shooter.is_valid_object(object) and if shooter.is_valid_object(object) and
shooter.punch_object(object, spec.tool_caps, dir) then shooter.punch_object(object, spec.tool_caps, dir, nil, spec.user) then
local pos = pointed_thing.intersection_point or object:get_pos() local pos = pointed_thing.intersection_point or object:get_pos()
local groups = object:get_armor_groups() or {} local groups = object:get_armor_groups() or {}
if groups.fleshy then if groups.fleshy then
@ -494,7 +498,7 @@ shooter.blast = function(pos, radius, fleshy, distance, user)
shooter.punch_object(obj, { shooter.punch_object(obj, {
full_punch_interval = 1.0, full_punch_interval = 1.0,
damage_groups = {fleshy=damage}, damage_groups = {fleshy=damage},
}, nil, true) }, nil, true, user)
end end
end end
end end