drop arrow on remove

This commit is contained in:
tchncs 2016-09-01 16:10:34 +02:00
parent 819daa52f1
commit 5013537e24

View File

@ -12,11 +12,11 @@ bows.on_hit_object=function(self,target,hp,user,lastpos)
self.object:set_attach(target, "", {x=(opos.x-pos.x)*4,y=(pos.y-opos.y)*4,z=(pos.z-opos.z)*4},{x=0,y=-90,z=0}) self.object:set_attach(target, "", {x=(opos.x-pos.x)*4,y=(pos.y-opos.y)*4,z=(pos.z-opos.z)*4},{x=0,y=-90,z=0})
else else
bows.arrow_remove(self) bows.arrow_remove(self)
minetest.add_item(self.object:getpos(), self)
end end
return self return self
end end
bows.on_hit_node=function(self,pos,user,lastpos) bows.on_hit_node=function(self,pos,user,lastpos)
if not minetest.registered_nodes[minetest.get_node(pos).name].node_box then if not minetest.registered_nodes[minetest.get_node(pos).name].node_box then
local mpos={x=(pos.x-lastpos.x),y=(pos.y-lastpos.y),z=(pos.z-lastpos.z)} local mpos={x=(pos.x-lastpos.x),y=(pos.y-lastpos.y),z=(pos.z-lastpos.z)}
@ -84,6 +84,7 @@ minetest.register_entity("bows:arrow",{
bows.tmp=nil bows.tmp=nil
self.object:set_properties({textures={self.arrow}}) self.object:set_properties({textures={self.arrow}})
else else
minetest.add_item(self.object:getpos(), self.arrow)
self.object:remove() self.object:remove()
end end
end, end,
@ -98,6 +99,7 @@ minetest.register_entity("bows:arrow",{
if self.stuck then if self.stuck then
if self.target and self.target:get_hp()<=1 then self.timer=-1 end if self.target and self.target:get_hp()<=1 then self.timer=-1 end
if self.timer<0 then if self.timer<0 then
minetest.add_item(self.object:getpos(), self.arrow)
bows.arrow_remove(self) bows.arrow_remove(self)
end end
return self return self