1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2025-01-11 18:40:25 +01:00

fixed mores bug in throwing mod

enable dig_arrow
This commit is contained in:
crabman77 2015-07-29 02:30:46 +02:00
parent 9ca3ac9383
commit f1018dfaaf
10 changed files with 65 additions and 31 deletions

View File

@ -38,6 +38,9 @@ local THROWING_ARROW_ENTITY={
lastpos={}, lastpos={},
collisionbox = {0,0,0,0,0,0}, collisionbox = {0,0,0,0,0,0},
node = "", node = "",
player = "",
inventory = false,
stack = false,
} }
THROWING_ARROW_ENTITY.on_step = function(self, dtime) THROWING_ARROW_ENTITY.on_step = function(self, dtime)
@ -50,7 +53,6 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
for k, obj in pairs(objs) do for k, obj in pairs(objs) do
if obj:get_luaentity() ~= nil then if obj:get_luaentity() ~= nil then
if obj:get_luaentity().name ~= "throwing:arrow_build_entity" and obj:get_luaentity().name ~= "__builtin:item" then if obj:get_luaentity().name ~= "throwing:arrow_build_entity" and obj:get_luaentity().name ~= "__builtin:item" then
self.object:remove()
if self.inventory and self.stack and not minetest.setting_getbool("creative_mode") then if self.inventory and self.stack and not minetest.setting_getbool("creative_mode") then
self.inventory:remove_item("main", {name=self.stack:get_name()}) self.inventory:remove_item("main", {name=self.stack:get_name()})
end end
@ -63,6 +65,8 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
else else
minetest.add_item(self.lastpos, 'default:stick') minetest.add_item(self.lastpos, 'default:stick')
end end
self.object:remove()
return
end end
end end
end end
@ -70,18 +74,18 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
if self.lastpos.x~=nil then if self.lastpos.x~=nil then
if node.name ~= "air" then if node.name ~= "air" then
self.object:remove()
if self.inventory and self.stack and not minetest.setting_getbool("creative_mode") then if self.inventory and self.stack and not minetest.setting_getbool("creative_mode") then
self.inventory:remove_item("main", {name=self.stack:get_name()}) self.inventory:remove_item("main", {name=self.stack:get_name()})
end end
if self.stack then if self.stack then
if not string.find(node.name, "water") and not string.find(node.name, "lava") and not string.find(node.name, "torch") and self.stack:get_definition().type == "node" and self.stack:get_name() ~= "default:torch" then if not minetest.is_protected(self.lastpos, self.player) and not string.find(node.name, "water") and not string.find(node.name, "lava") and not string.find(node.name, "torch") and self.stack:get_definition().type == "node" and self.stack:get_name() ~= "default:torch" then
minetest.place_node(self.lastpos, {name=self.stack:get_name()}) minetest.place_node(self.lastpos, {name=self.stack:get_name()})
else else
minetest.add_item(self.lastpos, {name=self.stack:get_name()}) minetest.add_item(self.lastpos, {name=self.stack:get_name()})
end end
end end
minetest.add_item(self.lastpos, 'default:shovel_steel') minetest.add_item(self.lastpos, 'default:shovel_steel')
self.object:remove()
end end
end end
self.lastpos={x=pos.x, y=pos.y, z=pos.z} self.lastpos={x=pos.x, y=pos.y, z=pos.z}

View File

@ -37,6 +37,7 @@ local THROWING_ARROW_ENTITY={
textures = {"throwing:arrow_dig_box"}, textures = {"throwing:arrow_dig_box"},
lastpos={}, lastpos={},
collisionbox = {0,0,0,0,0,0}, collisionbox = {0,0,0,0,0,0},
player = "",
} }
THROWING_ARROW_ENTITY.on_step = function(self, dtime) THROWING_ARROW_ENTITY.on_step = function(self, dtime)
@ -54,26 +55,27 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
full_punch_interval=1.0, full_punch_interval=1.0,
damage_groups={fleshy=damage}, damage_groups={fleshy=damage},
}, nil) }, nil)
self.object:remove()
if math.random(0,100) % 2 == 0 then -- 50% of chance to drop //MFF (Mg|07/27/15) if math.random(0,100) % 2 == 0 then -- 50% of chance to drop //MFF (Mg|07/27/15)
minetest.add_item(self.lastpos, "throwing:arrow_dig") minetest.add_item(self.lastpos, "throwing:arrow_dig")
end end
self.object:remove()
return
end end
end end
end end
end end
if self.lastpos.x~=nil then if self.lastpos.x~=nil then
if node.name ~= "air" then 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
if minetest.get_item_group(node.name, "unbreakable") == 0 and not minetest.is_protected(self.lastpos, self.player)
and areas:canInteract(self.lastpos, self.player:get_player_name())
and node.diggable ~= false then and node.diggable ~= false then
minetest.set_node(pos, {name = "air"}) minetest.set_node(pos, {name = "air"})
end
minetest.add_item(self.lastpos, node.name) minetest.add_item(self.lastpos, node.name)
end
minetest.add_item(self.lastpos, "throwing:arrow_dig") minetest.add_item(self.lastpos, "throwing:arrow_dig")
self.object:remove() self.object:remove()
return
end end
end end
self.lastpos={x=pos.x, y=pos.y, z=pos.z} self.lastpos={x=pos.x, y=pos.y, z=pos.z}

View File

@ -37,6 +37,7 @@ local THROWING_ARROW_ENTITY={
textures = {"throwing:arrow_fire_box"}, textures = {"throwing:arrow_fire_box"},
lastpos={}, lastpos={},
collisionbox = {0,0,0,0,0,0}, collisionbox = {0,0,0,0,0,0},
player = "",
} }
THROWING_ARROW_ENTITY.on_step = function(self, dtime) THROWING_ARROW_ENTITY.on_step = function(self, dtime)
@ -54,10 +55,11 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
full_punch_interval=1.0, full_punch_interval=1.0,
damage_groups={fleshy=damage}, damage_groups={fleshy=damage},
}, nil) }, nil)
self.object:remove()
if math.random(0,100) % 2 == 0 then -- 50% of chance to drop //MFF (Mg|07/27/15) if math.random(0,100) % 2 == 0 then -- 50% of chance to drop //MFF (Mg|07/27/15)
minetest.add_item(self.lastpos, 'default:stick') minetest.add_item(self.lastpos, 'default:stick')
end end
self.object:remove()
return
end end
end end
end end
@ -67,6 +69,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
if node.name ~= "air" and node.name ~= "throwing:light" then if node.name ~= "air" and node.name ~= "throwing:light" then
minetest.set_node(self.lastpos, {name="fire:basic_flame"}) minetest.set_node(self.lastpos, {name="fire:basic_flame"})
self.object:remove() self.object:remove()
return
end 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 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 if minetest.get_node(self.lastpos).name == "throwing:light" then

View File

@ -38,6 +38,7 @@ local function throwing_register_fireworks(color, desc)
textures = {"throwing:arrow_fireworks_" .. color .. "_box"}, textures = {"throwing:arrow_fireworks_" .. color .. "_box"},
lastpos={}, lastpos={},
collisionbox = {0,0,0,0,0,0}, collisionbox = {0,0,0,0,0,0},
player = "",
} }
local radius = 0.5 local radius = 0.5
@ -104,20 +105,23 @@ local function throwing_register_fireworks(color, desc)
full_punch_interval=1.0, full_punch_interval=1.0,
damage_groups={fleshy=damage}, damage_groups={fleshy=damage},
}, nil) }, nil)
self.object:remove()
boom(pos) boom(pos)
self.object:remove()
return
end end
end end
end end
end end
if self.timer > 2 then if self.timer > 2 then
self.object:remove()
boom(self.lastpos) boom(self.lastpos)
self.object:remove()
return
end end
if self.lastpos.x~=nil then if self.lastpos.x~=nil then
if node.name ~= "air" and node.name ~= "throwing:firework_trail" then if node.name ~= "air" and node.name ~= "throwing:firework_trail" then
self.object:remove()
boom(self.lastpos) boom(self.lastpos)
self.object:remove()
return
end end
end end
if node.name == 'air' then if node.name == 'air' then

View File

@ -34,7 +34,7 @@ function throwing_shoot_arrow (itemstack, player, stiffness, is_cross)
minetest.sound_play("throwing_bow_sound", {pos=playerpos}) minetest.sound_play("throwing_bow_sound", {pos=playerpos})
end end
if obj:get_luaentity() then if obj:get_luaentity() then
obj:get_luaentity().player = player obj:get_luaentity().player = player:get_player_name()
obj:get_luaentity().inventory = player:get_inventory() obj:get_luaentity().inventory = player:get_inventory()
obj:get_luaentity().stack = player:get_inventory():get_stack("main", player:get_wield_index()-1) obj:get_luaentity().stack = player:get_inventory():get_stack("main", player:get_wield_index()-1)
end end

View File

@ -37,6 +37,7 @@ local THROWING_ARROW_ENTITY={
textures = {"throwing:arrow_shell_box"}, textures = {"throwing:arrow_shell_box"},
lastpos={}, lastpos={},
collisionbox = {0,0,0,0,0,0}, collisionbox = {0,0,0,0,0,0},
player = "",
} }
local radius = 1 local radius = 1
@ -85,8 +86,9 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
full_punch_interval=1.0, full_punch_interval=1.0,
damage_groups={fleshy=damage}, damage_groups={fleshy=damage},
}, nil) }, nil)
self.object:remove()
boom(pos) boom(pos)
self.object:remove()
return
end end
end end
end end
@ -94,8 +96,9 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
if self.lastpos.x~=nil then if self.lastpos.x~=nil then
if node.name ~= "air" 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 if node.name ~= "air" 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
self.object:remove()
boom(self.lastpos) boom(self.lastpos)
self.object:remove()
return
end end
end end
self.lastpos={x=pos.x, y=pos.y, z=pos.z} self.lastpos={x=pos.x, y=pos.y, z=pos.z}

View File

@ -38,6 +38,7 @@ function throwing_register_arrow_standard (kind, desc, eq, toughness, craft)
textures = {"throwing:arrow_" .. kind .. "_box"}, textures = {"throwing:arrow_" .. kind .. "_box"},
lastpos={}, lastpos={},
collisionbox = {0,0,0,0,0,0}, collisionbox = {0,0,0,0,0,0},
player = "",
} }
THROWING_ARROW_ENTITY.on_step = function(self, dtime) THROWING_ARROW_ENTITY.on_step = function(self, dtime)
@ -56,7 +57,6 @@ function throwing_register_arrow_standard (kind, desc, eq, toughness, craft)
full_punch_interval=1.0, full_punch_interval=1.0,
damage_groups={fleshy=damage}, damage_groups={fleshy=damage},
}, nil) }, nil)
self.object:remove()
if math.random() < toughness then if math.random() < toughness then
if math.random(0,100) % 2 == 0 then if math.random(0,100) % 2 == 0 then
minetest.add_item(self.lastpos, 'throwing:arrow_' .. kind) minetest.add_item(self.lastpos, 'throwing:arrow_' .. kind)
@ -64,19 +64,22 @@ function throwing_register_arrow_standard (kind, desc, eq, toughness, craft)
else else
minetest.add_item(self.lastpos, 'default:stick') minetest.add_item(self.lastpos, 'default:stick')
end end
self.object:remove()
return
end end
end end
end end
end end
if self.lastpos.x~=nil then if self.lastpos.x~=nil then
if node.name ~= "air" 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 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
self.object:remove()
if math.random() < toughness then if math.random() < toughness then
minetest.add_item(self.lastpos, 'throwing:arrow_' .. kind) minetest.add_item(self.lastpos, 'throwing:arrow_' .. kind)
else else
minetest.add_item(self.lastpos, 'default:stick') minetest.add_item(self.lastpos, 'default:stick')
end end
self.object:remove()
return
end end
end end
self.lastpos={x=pos.x, y=pos.y, z=pos.z} self.lastpos={x=pos.x, y=pos.y, z=pos.z}

View File

@ -50,24 +50,32 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
for k, obj in pairs(objs) do for k, obj in pairs(objs) do
if obj:get_luaentity() ~= nil then if obj:get_luaentity() ~= nil then
if obj:get_luaentity().name ~= "throwing:arrow_teleport_entity" and obj:get_luaentity().name ~= "__builtin:item" then if obj:get_luaentity().name ~= "throwing:arrow_teleport_entity" and obj:get_luaentity().name ~= "__builtin:item" then
self.object:remove()
if self.player ~= "" then if self.player ~= "" then
self.player:setpos(pos) local player = minetest.get_player_by_name(self.player)
self.player:get_inventory():add_item("main", ItemStack("default:stick 2")) if player then
player:setpos(pos)
player:get_inventory():add_item("main", ItemStack("default:stick 2"))
end end
end end
self.object:remove()
return
end
end end
end end
end end
if self.lastpos.x~=nil then if self.lastpos.x~= nil then
if node.name ~= "air" then if node.name ~= "air" then
self.object:remove()
if self.player ~= "" then if self.player ~= "" then
self.player:setpos(self.lastpos) local player = minetest.get_player_by_name(self.player)
self.player:get_inventory():add_item("main", ItemStack("default:stick 2")) if player then
player:setpos(self.lastpos)
player:get_inventory():add_item("main", ItemStack("default:stick 2"))
end end
end end
self.object:remove()
return
end
end end
self.lastpos={x=pos.x, y=pos.y, z=pos.z} self.lastpos={x=pos.x, y=pos.y, z=pos.z}
end end

View File

@ -18,7 +18,7 @@ DISABLE_AUTOMATED_ARBALEST = false
-- Arrow -- Arrow
-- Special Arrows -- Special Arrows
DISABLE_TELEPORT_ARROW = false DISABLE_TELEPORT_ARROW = false
DISABLE_DIG_ARROW = true -- Desactivated because too bugged DISABLE_DIG_ARROW = false
DISABLE_BUILD_ARROW = false DISABLE_BUILD_ARROW = false
DISABLE_TNT_ARROW = true -- Desactivated because too dangerous DISABLE_TNT_ARROW = true -- Desactivated because too dangerous
DISABLE_FIRE_ARROW = true -- Desactivated because too dangerous DISABLE_FIRE_ARROW = true -- Desactivated because too dangerous

View File

@ -38,6 +38,7 @@ local THROWING_ARROW_ENTITY={
lastpos={}, lastpos={},
collisionbox = {0,0,0,0,0,0}, collisionbox = {0,0,0,0,0,0},
node = "", node = "",
player = "",
} }
THROWING_ARROW_ENTITY.on_step = function(self, dtime) THROWING_ARROW_ENTITY.on_step = function(self, dtime)
@ -55,7 +56,6 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
full_punch_interval=1.0, full_punch_interval=1.0,
damage_groups={fleshy=damage}, damage_groups={fleshy=damage},
}, nil) }, nil)
self.object:remove()
local toughness = 0.9 local toughness = 0.9
if math.random() < toughness then if math.random() < toughness then
if math.random(0,100) % 2 == 0 then -- 50% of chance to drop //MFF (Mg|07/27/15) if math.random(0,100) % 2 == 0 then -- 50% of chance to drop //MFF (Mg|07/27/15)
@ -64,6 +64,8 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
else else
minetest.add_item(self.lastpos, 'default:stick') minetest.add_item(self.lastpos, 'default:stick')
end end
self.object:remove()
return
end end
end end
end end
@ -71,8 +73,11 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
if self.lastpos.x~=nil then if self.lastpos.x~=nil then
if node.name ~= "air" then if node.name ~= "air" then
self.object:remove() local player = minetest.get_player_by_name(self.player)
if not string.find(node.name, "water") and not string.find(node.name, "lava") and not string.find(node.name, "torch") then if not player then self.object:remove() return end
if not string.find(node.name, "water") and not string.find(node.name, "lava")
and not string.find(node.name, "torch") and minetest.get_item_group(node.name, "unbreakable") == 0
and not minetest.is_protected(self.lastpos, self.player) and node.diggable ~= false then
local dir=vector.direction(self.lastpos, pos) local dir=vector.direction(self.lastpos, pos)
local wall=minetest.dir_to_wallmounted(dir) local wall=minetest.dir_to_wallmounted(dir)
minetest.add_node(self.lastpos, {name="default:torch", param2 = wall}) minetest.add_node(self.lastpos, {name="default:torch", param2 = wall})
@ -84,6 +89,8 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
minetest.add_item(self.lastpos, 'default:stick') minetest.add_item(self.lastpos, 'default:stick')
end end
end end
self.object:remove()
return
end end
end end
self.lastpos={x=pos.x, y=pos.y, z=pos.z} self.lastpos={x=pos.x, y=pos.y, z=pos.z}