bows/items_functions.lua

45 lines
1.4 KiB
Lua

bows.arrow_fire_object=function(self,target,hp,user,lastpos)
bows.arrow_fire(self,lastpos,user,target:getpos())
return self
end
bows.arrow_fire=function(self,pos,user,lastpos)
local name=user:get_player_name()
local node=minetest.get_node(lastpos).name
if minetest.is_protected(lastpos, name) then
minetest.chat_send_player(name, minetest.pos_to_string(lastpos) .." is protected")
elseif minetest.registered_nodes[node].buildable_to then
minetest.set_node(lastpos,{name="fire:basic_flame"})
end
bows.arrow_remove(self)
return self
end
bows.arrow_toxic=function(self,target,hp,user,lastpos)
if self.object==nil or user==nil or target==nil or target:get_properties()==nil then
bows.arrow_remove(self)
return self
end
target:punch(user, 3,{full_punch_interval=1.0,damage_groups={fleshy=4}}, "default:sword_wood", nil)
local rnd=math.random(1,10)
if rnd~=4 and target:get_hp()>0 then
minetest.after(math.random(0.5,2), function(self,target,hp,user,lastpos)
bows.arrow_toxic(self,target,hp,user,lastpos)
end, self,target,hp,user,lastpos)
else
bows.arrow_remove(self)
end
end
bows.arrow_admin_object=function(self,target,hp,user,lastpos)
target:set_hp(0)
target:punch(self.object, {full_punch_interval=1.0,damage_groups={fleshy=4}}, "default:sword_wood", nil)
bows.arrow_remove(self)
return self
end
bows.arrow_admin_node=function(self,pos,user,lastpos)
bows.arrow_remove(self)
return self
end