mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2025-12-20 16:55:19 +01:00
improve throwing mod
This commit is contained in:
@@ -42,38 +42,36 @@ local THROWING_ARROW_ENTITY={
|
||||
|
||||
|
||||
THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
||||
self.timer=self.timer+dtime
|
||||
local newpos = self.object:getpos()
|
||||
for _, pos in pairs(get_trajectoire(self, newpos)) do
|
||||
local node = minetest.get_node(pos)
|
||||
if self.timer>0.2 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}, 1)
|
||||
for k, obj in pairs(objs) do
|
||||
if obj:get_luaentity() ~= nil then
|
||||
if obj:get_luaentity().name ~= "throwing:arrow_dig_entity" and obj:get_luaentity().name ~= "__builtin:item" then
|
||||
local damage = 1.5
|
||||
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, "throwing:arrow_dig")
|
||||
end
|
||||
self.object:remove()
|
||||
return
|
||||
if throwing_is_player(self.player, obj) or throwing_is_entity(obj) then
|
||||
local damage = 1.5
|
||||
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, "throwing:arrow_dig")
|
||||
end
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
if node.name ~= "air" and not string.find(node.name, "water_") then
|
||||
if node.name ~= "ignore" and minetest.get_item_group(node.name, "unbreakable") == 0
|
||||
and not minetest.is_protected(pos, self.player)
|
||||
and node.diggable ~= false then
|
||||
minetest.set_node(pos, {name = "air"})
|
||||
minetest.add_item(pos, node.name)
|
||||
if node.name ~= "air" and not string.find(node.name, "water_") then
|
||||
if node.name ~= "ignore" and minetest.get_item_group(node.name, "unbreakable") == 0
|
||||
and not minetest.is_protected(pos, self.player)
|
||||
and node.diggable ~= false then
|
||||
minetest.set_node(pos, {name = "air"})
|
||||
minetest.add_item(pos, node.name)
|
||||
end
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
self.object:remove()
|
||||
return
|
||||
self.lastpos={x=pos.x, y=pos.y, z=pos.z}
|
||||
end
|
||||
end
|
||||
self.lastpos={x=newpos.x, y=newpos.y, z=newpos.z}
|
||||
|
||||
Reference in New Issue
Block a user