Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • Illuna-Minetest/bows
1 result
Show changes
Commits on Source (3)
This is a fork of https://forum.minetest.net/viewtopic.php?t=14384
\ No newline at end of file
......@@ -2,9 +2,18 @@ bows.nothing=function(self,target,hp,user,lastpos)
return self
end
bows.is_in_entity=function(self,ob)
local collisionbox = ob:get_properties().collisionbox
return (collisionbox[1]+ob:get_pos().x <= self.object:get_pos().x and
collisionbox[2]+ob:get_pos().y <= self.object:get_pos().y and
collisionbox[3]+ob:get_pos().z <= self.object:get_pos().z and
collisionbox[4]+ob:get_pos().x >= self.object:get_pos().x and
collisionbox[5]+ob:get_pos().y >= self.object:get_pos().y and
collisionbox[6]+ob:get_pos().z >= self.object:get_pos().z)
end
bows.on_hit_object=function(self,target,hp,user,lastpos)
target:set_hp(target:get_hp()-hp)
target:punch(user,1, "default:sword_wood", nil)
target:punch(user, 2,{full_punch_interval=1.0,damage_groups={fleshy=hp}}, "default:sword_wood", nil)
if target:get_hp()>0 then
local pos=self.object:getpos()
local opos=target:getpos()
......@@ -121,8 +130,13 @@ minetest.register_entity("bows:arrow",{
self.x=pos.x
self.y=pos.y
self.z=pos.z
for i, ob in pairs(minetest.get_objects_inside_radius(pos, 1)) do
if ob and ((bows.pvp and ob:is_player() and ob:get_player_name()~=self.user:get_player_name()) or (ob:get_luaentity() and ob:get_luaentity().physical and ob:get_luaentity().bow_arrow==nil and ob:get_luaentity().name~="__builtin:item" )) then
for i, ob in pairs(minetest.get_objects_inside_radius(pos, 3)) do
if ob and ((bows.pvp and ob:is_player() and
ob:get_player_name()~=self.user:get_player_name()) or
(ob:get_luaentity() and ob:get_luaentity().physical and
ob:get_luaentity().bow_arrow==nil and
ob:get_luaentity().name~="__builtin:item")) and
bows.is_in_entity(self,ob) then
self.object:setvelocity({x=0, y=0, z=0})
self.object:setacceleration({x=0, y=0, z=0})
self.stuck=true
......