diff --git a/shooter/README.md b/shooter/README.md index 7916d2e..760ed55 100644 --- a/shooter/README.md +++ b/shooter/README.md @@ -150,6 +150,7 @@ Used by `shooter.register_weapon` }, on_hit = function(pointed_thing, spec, dir) -- May be used for arbitary shot effects like knock-back, etc. + -- Return `true` to override built-in damage effects end, spec = { -- Weapon specifications diff --git a/shooter/api.lua b/shooter/api.lua index 02c5780..4f63590 100644 --- a/shooter/api.lua +++ b/shooter/api.lua @@ -206,6 +206,12 @@ shooter.is_valid_object = function(object) end local function process_hit(pointed_thing, spec, dir) + local def = minetest.registered_items[spec.name] or {} + if type(def.on_hit) == "function" then + if def.on_hit(pointed_thing, spec, dir) == true then + return + end + end if pointed_thing.type == "node" and config.allow_nodes == true then local pos = minetest.get_pointed_thing_position(pointed_thing, false) shooter.punch_node(pos, spec) @@ -223,10 +229,6 @@ local function process_hit(pointed_thing, spec, dir) end end end - local def = minetest.registered_items[spec.name] or {} - if type(def.on_hit) == "function" then - return def.on_hit(pointed_thing, spec, dir) - end end local function process_round(round)