diff --git a/mods/throwing/fire_arrow.lua b/mods/throwing/fire_arrow.lua index 3e46693f..2e5ab9af 100755 --- a/mods/throwing/fire_arrow.lua +++ b/mods/throwing/fire_arrow.lua @@ -41,22 +41,26 @@ local THROWING_ARROW_ENTITY={ THROWING_ARROW_ENTITY.on_step = function(self, dtime) local newpos = self.object:getpos() - if self.lastpos.x~=nil then + if self.lastpos.x ~= nil then for _, pos in pairs(throwing_get_trajectoire(self, newpos)) do local node = minetest.get_node(pos) local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 2) for k, obj in pairs(objs) do + local objpos = obj:getpos() if throwing_is_player(self.player, obj) or throwing_is_entity(obj) then - local damage = 4 - obj:punch(self.object, 1.0, { - full_punch_interval=1.0, - damage_groups={fleshy=damage}, - }, nil) - if math.random(0,100) % 2 == 0 then -- 50% of chance to drop //MFF (Mg|07/27/15) - minetest.add_item(pos, 'default:stick') + if (pos.x - objpos.x < 0.5 and pos.x - objpos.x > -0.5) and (pos.z - objpos.z < 0.5 and pos.z - objpos.z > -0.5) then + + local damage = 4 + obj:punch(self.object, 1.0, { + full_punch_interval=1.0, + damage_groups={fleshy=damage}, + }, nil) + if math.random(0,100) % 2 == 0 then -- 50% of chance to drop //MFF (Mg|07/27/15) + minetest.add_item(pos, 'default:stick') + end + self.object:remove() + return end - self.object:remove() - return end end @@ -67,19 +71,20 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime) self.object:remove() return end - if math.floor(self.lastpos.x+0.5) ~= math.floor(pos.x+0.5) or math.floor(self.lastpos.y+0.5) ~= math.floor(pos.y+0.5) or math.floor(self.lastpos.z+0.5) ~= math.floor(pos.z+0.5) then - if minetest.get_node(self.lastpos).name == "throwing:light" then - minetest.remove_node(self.lastpos) - end - if minetest.get_node(pos).name == "air" then - minetest.set_node(pos, {name="throwing:light"}) - end + + if minetest.get_node(pos).name == "air" then + minetest.set_node(pos, {name="throwing:light"}) end + if minetest.get_node(self.lastpos).name == "throwing:light" then + minetest.remove_node(self.lastpos) + end + self.lastpos={x=pos.x, y=pos.y, z=pos.z} end end self.lastpos={x=newpos.x, y=newpos.y, z=newpos.z} end + minetest.register_entity("throwing:arrow_fire_entity", THROWING_ARROW_ENTITY) minetest.register_node("throwing:light", { diff --git a/mods/throwing/functions.lua b/mods/throwing/functions.lua index e35a6c5c..8f71c4ad 100755 --- a/mods/throwing/functions.lua +++ b/mods/throwing/functions.lua @@ -24,7 +24,8 @@ function throwing_is_entity(obj) return (obj:get_luaentity() ~= nil and not string.find(obj:get_luaentity().name, "throwing:arrow_") and obj:get_luaentity().name ~= "__builtin:item" - and obj:get_luaentity().name ~= "gauges:hp_bar") + and obj:get_luaentity().name ~= "gauges:hp_bar" + and obj:get_luaentity().name ~= "signs:text") end function throwing_get_trajectoire(self, newpos) if self.lastpos.x == nil then diff --git a/mods/throwing/standard_arrows.lua b/mods/throwing/standard_arrows.lua index ecb4f7d0..ff9824d6 100755 --- a/mods/throwing/standard_arrows.lua +++ b/mods/throwing/standard_arrows.lua @@ -48,20 +48,23 @@ function throwing_register_arrow_standard (kind, desc, eq, toughness, craft) local node = minetest.get_node(pos) local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 2) for k, obj in pairs(objs) do + local objpos = obj:getpos() if throwing_is_player(self.player, obj) or throwing_is_entity(obj) then - obj:punch(self.object, 1.0, { - full_punch_interval=1.0, - damage_groups={fleshy=eq}, - }, nil) - if math.random() < toughness then - if math.random(0,100) % 2 == 0 then - minetest.add_item(self.lastpos, 'throwing:arrow_' .. kind) + if (pos.x - objpos.x < 0.5 and pos.x - objpos.x > -0.5) and (pos.z - objpos.z < 0.5 and pos.z - objpos.z > -0.5) then + obj:punch(self.object, 1.0, { + full_punch_interval=1.0, + damage_groups={fleshy=eq}, + }, nil) + if math.random() < toughness then + if math.random(0,100) % 2 == 0 then + minetest.add_item(self.lastpos, 'throwing:arrow_' .. kind) + end + else + minetest.add_item(self.lastpos, 'default:stick') end - else - minetest.add_item(self.lastpos, 'default:stick') + self.object:remove() + return end - self.object:remove() - return end end if node.name ~= "air" and not string.find(node.name, 'water_') and not string.find(node.name, 'default:grass') and not string.find(node.name, 'default:junglegrass') and not string.find(node.name, 'flowers:') and not string.find(node.name, 'farming:') then