diff --git a/README.txt b/README.txt old mode 100644 new mode 100755 diff --git a/build_arrow.lua b/build_arrow.lua old mode 100644 new mode 100755 index d0cb031..6c66828 --- a/build_arrow.lua +++ b/build_arrow.lua @@ -18,7 +18,7 @@ minetest.register_node("throwing:arrow_build_box", { {7.5/17, -2.5/17, 2.5/17, 6.5/17, -1.5/17, 1.5/17}, {7.5/17, 2.5/17, -2.5/17, 6.5/17, 1.5/17, -1.5/17}, {6.5/17, -1.5/17, -1.5/17, 7.5/17, -2.5/17, -2.5/17}, - + {7.5/17, 2.5/17, 2.5/17, 8.5/17, 3.5/17, 3.5/17}, {8.5/17, -3.5/17, 3.5/17, 7.5/17, -2.5/17, 2.5/17}, {8.5/17, 3.5/17, -3.5/17, 7.5/17, 2.5/17, -2.5/17}, @@ -38,56 +38,66 @@ local THROWING_ARROW_ENTITY={ lastpos={}, collisionbox = {0,0,0,0,0,0}, node = "", + player = "", + inventory = false, + stack = false, + bow_damage = 0, } THROWING_ARROW_ENTITY.on_step = function(self, dtime) self.timer=self.timer+dtime - local pos = self.object:getpos() - local node = minetest.get_node(pos) - if not self.inventory or not self.stack then - self.object:remove() - end - - if self.timer>0.2 then - 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_build_entity" and obj:get_luaentity().name ~= "__builtin:item" then - self.object:remove() + local newpos = self.object:getpos() + 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 throwing_is_player(self.player, obj) or throwing_is_entity(obj) 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()}) end if self.stack then - minetest.add_item(self.lastpos, {name=self.stack:get_name()}) + minetest.add_item(pos, {name=self.stack:get_name()}) end local toughness = 0.95 if math.random() < toughness then - minetest.add_item(self.lastpos, 'throwing:arrow_build') + minetest.add_item(pos, 'throwing:arrow_build') else - minetest.add_item(self.lastpos, 'default:stick') + minetest.add_item(pos, 'default:stick') + end + self.object:remove() + return + end + end + + if node.name ~= "air" + and not string.find(node.name, "water_") + and not (string.find(node.name, 'grass') and not string.find(node.name, 'dirt')) + and not (string.find(node.name, 'farming:') and not string.find(node.name, 'soil')) + and not string.find(node.name, 'flowers:') + and not string.find(node.name, 'fire:') then + if node.name ~= "ignore" and self.inventory and self.stack then + if not minetest.is_protected(self.lastpos, "") + 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()}) + else + minetest.add_item(self.lastpos, {name=self.stack:get_name()}) + end + if not minetest.setting_getbool("creative_mode") then + self.inventory:remove_item("main", {name=self.stack:get_name()}) end end + minetest.add_item(self.lastpos, 'default:shovel_steel') + self.object:remove() + return end + self.lastpos={x=pos.x, y=pos.y, z=pos.z} end end - - if self.lastpos.x~=nil then - if node.name ~= "air" then - self.object:remove() - if self.inventory and self.stack and not minetest.setting_getbool("creative_mode") then - self.inventory:remove_item("main", {name=self.stack:get_name()}) - end - 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 - minetest.place_node(self.lastpos, {name=self.stack:get_name()}) - else - minetest.add_item(self.lastpos, {name=self.stack:get_name()}) - end - end - minetest.add_item(self.lastpos, 'default:shovel_steel') - end - end - self.lastpos={x=pos.x, y=pos.y, z=pos.z} + self.lastpos={x=newpos.x, y=newpos.y, z=newpos.z} end minetest.register_entity("throwing:arrow_build_entity", THROWING_ARROW_ENTITY) diff --git a/crafts.lua b/crafts.lua new file mode 100755 index 0000000..9d74db4 --- /dev/null +++ b/crafts.lua @@ -0,0 +1,13 @@ +-- Craft recipe of the "Mithril String" +minetest.register_craft({ + output = "throwing:string_mithril", + description = "Mithril String", + inventory_image = "string_mithril.png", + type = "shapeless", + recipe = {"default:mithril_ingot", "farming:string"}, +}) + +minetest.register_craftitem("throwing:string_mithril", { + inventory_image = "throwing_string_mithril.png", + description = "Mithril String", +}) diff --git a/defaults.lua b/defaults.lua old mode 100644 new mode 100755 index b6c246f..90518fa --- a/defaults.lua +++ b/defaults.lua @@ -23,7 +23,3 @@ DISABLE_STEEL_ARROW = false DISABLE_DIAMOND_ARROW = false DISABLE_OBSIDIAN_ARROW = false -DISABLE_STONE_SPEAR = false -DISABLE_STEEL_SPEAR = false -DISABLE_DIAMOND_SPEAR = false -DISABLE_OBSIDIAN_SPEAR = false diff --git a/depends.txt b/depends.txt old mode 100644 new mode 100755 diff --git a/description.txt b/description.txt old mode 100644 new mode 100755 diff --git a/dig_arrow.lua b/dig_arrow.lua old mode 100644 new mode 100755 index 4e7cf9b..0a676b5 --- a/dig_arrow.lua +++ b/dig_arrow.lua @@ -18,7 +18,7 @@ minetest.register_node("throwing:arrow_dig_box", { {7.5/17, -2.5/17, 2.5/17, 6.5/17, -1.5/17, 1.5/17}, {7.5/17, 2.5/17, -2.5/17, 6.5/17, 1.5/17, -1.5/17}, {6.5/17, -1.5/17, -1.5/17, 7.5/17, -2.5/17, -2.5/17}, - + {7.5/17, 2.5/17, 2.5/17, 8.5/17, 3.5/17, 3.5/17}, {8.5/17, -3.5/17, 3.5/17, 7.5/17, -2.5/17, 2.5/17}, {8.5/17, 3.5/17, -3.5/17, 7.5/17, 2.5/17, -2.5/17}, @@ -37,50 +37,59 @@ local THROWING_ARROW_ENTITY={ textures = {"throwing:arrow_dig_box"}, lastpos={}, collisionbox = {0,0,0,0,0,0}, + player = "", + bow_damage = 0, } -THROWING_ARROW_ENTITY.on_step = function(self, dtime) - self.timer=self.timer+dtime - local pos = self.object:getpos() - local node = minetest.get_node(pos) - if self.timer>0.2 then - 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) - self.object:remove() - local toughness = 0.9 - if math.random() < toughness then - minetest.add_item(self.lastpos, 'throwing:arrow_dig') - else - minetest.add_item(self.lastpos, 'default:stick') +THROWING_ARROW_ENTITY.on_step = function(self, dtime) + local newpos = self.object:getpos() + 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 throwing_is_player(self.player, obj) or throwing_is_entity(obj) then + if throwing_touch(pos, obj:getpos()) then + local puncher = self.object + if self.player and minetest.get_player_by_name(self.player) then + puncher = minetest.get_player_by_name(self.player) + end + local damage = 1.5 + if self.bow_damage and self.bow_damage > 0 then + damage = damage + (self.bow_damage/12) + end + obj:punch(puncher, 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_") + and not (string.find(node.name, 'grass') and not string.find(node.name, 'dirt')) + and not (string.find(node.name, 'farming:') and not string.find(node.name, 'soil')) + and not string.find(node.name, 'flowers:') + and not string.find(node.name, 'fire:') 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.lastpos={x=pos.x, y=pos.y, z=pos.z} end end - - if self.lastpos.x~=nil then - if node.name ~= "air" then - self.object:remove() - if node.diggable ~= false then - minetest.dig_node(pos) - end - local toughness = 0.65 - if math.random() < toughness then - minetest.add_item(self.lastpos, 'default:pick_steel') - else - minetest.add_item(self.lastpos, 'default:stick') - end - end - end - self.lastpos={x=pos.x, y=pos.y, z=pos.z} + self.lastpos={x=newpos.x, y=newpos.y, z=newpos.z} end minetest.register_entity("throwing:arrow_dig_entity", THROWING_ARROW_ENTITY) diff --git a/fire_arrow.lua b/fire_arrow.lua old mode 100644 new mode 100755 index 9457a87..424d81c --- a/fire_arrow.lua +++ b/fire_arrow.lua @@ -18,7 +18,7 @@ minetest.register_node("throwing:arrow_fire_box", { {7.5/17, -2.5/17, 2.5/17, 6.5/17, -1.5/17, 1.5/17}, {7.5/17, 2.5/17, -2.5/17, 6.5/17, 1.5/17, -1.5/17}, {6.5/17, -1.5/17, -1.5/17, 7.5/17, -2.5/17, -2.5/17}, - + {7.5/17, 2.5/17, 2.5/17, 8.5/17, 3.5/17, 3.5/17}, {8.5/17, -3.5/17, 3.5/17, 7.5/17, -2.5/17, 2.5/17}, {8.5/17, 3.5/17, -3.5/17, 7.5/17, 2.5/17, -2.5/17}, @@ -31,53 +31,73 @@ minetest.register_node("throwing:arrow_fire_box", { local THROWING_ARROW_ENTITY={ physical = false, - timer=0, visual = "wielditem", visual_size = {x=0.1, y=0.1}, textures = {"throwing:arrow_fire_box"}, lastpos={}, collisionbox = {0,0,0,0,0,0}, + player = "", + bow_damage = 0, } THROWING_ARROW_ENTITY.on_step = function(self, dtime) - self.timer=self.timer+dtime - local pos = self.object:getpos() - local node = minetest.get_node(pos) - - if self.timer>0.2 then - local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 2) - for k, obj in pairs(objs) do - if obj:get_luaentity() ~= nil then - if obj:get_luaentity().name ~= "throwing:arrow_fire_entity" and obj:get_luaentity().name ~= "__builtin:item" then - local damage = 4 - obj:punch(self.object, 1.0, { - full_punch_interval=1.0, - damage_groups={fleshy=damage}, - }, nil) - self.object:remove() - minetest.add_item(self.lastpos, 'default:stick') + local newpos = self.object:getpos() + 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}, 2) + for k, obj in pairs(objs) do + local objpos = obj:getpos() + if throwing_is_player(self.player, obj) or throwing_is_entity(obj) then + if throwing_touch(pos, objpos) then + local puncher = self.object + if self.player and minetest.get_player_by_name(self.player) then + puncher = minetest.get_player_by_name(self.player) + end + local damage = 4 + if self.bow_damage and self.bow_damage > 0 then + damage = damage + (self.bow_damage/12) + end + obj:punch(puncher, 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, 'default:stick') + end + self.object:remove() + return + end end end - end - end - if self.lastpos.x~=nil then - if node.name ~= "air" and node.name ~= "throwing:light" then - minetest.set_node(self.lastpos, {name="fire:basic_flame"}) - self.object:remove() - 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 minetest.get_node(self.lastpos).name == "throwing:light" then - minetest.remove_node(self.lastpos) + if node.name ~= "air" + and node.name ~= "throwing:light" + and node.name ~= "fire:basic_flame" + and not (string.find(node.name, 'grass') and not string.find(node.name, 'dirt')) + and not (string.find(node.name, 'farming:') and not string.find(node.name, 'soil')) + and not string.find(node.name, 'flowers:') + and not string.find(node.name, 'fire:') then + if node.name ~= "ignore" then + minetest.set_node(self.lastpos, {name="fire:basic_flame"}) + end + self.object:remove() + return end + if minetest.get_node(pos).name == "air" then minetest.set_node(pos, {name="throwing:light"}) end + if minetest.get_node(self.lastpos).name == "throwing:light" then + minetest.remove_node(self.lastpos) + end + self.lastpos={x=pos.x, y=pos.y, z=pos.z} end end - self.lastpos={x=pos.x, y=pos.y, z=pos.z} + self.lastpos={x=newpos.x, y=newpos.y, z=newpos.z} end + minetest.register_entity("throwing:arrow_fire_entity", THROWING_ARROW_ENTITY) minetest.register_node("throwing:light", { @@ -85,7 +105,7 @@ minetest.register_node("throwing:light", { paramtype = "light", sunlight_propagates = true, tiles = {"throwing_empty.png"}, - light_source = LIGHT_MAX-4, + light_source = default.LIGHT_MAX-4, selection_box = { type = "fixed", fixed = { diff --git a/fireworks_arrows.lua b/fireworks_arrows.lua old mode 100644 new mode 100755 index 4dd38fe..167f8b8 --- a/fireworks_arrows.lua +++ b/fireworks_arrows.lua @@ -3,7 +3,7 @@ local function throwing_register_fireworks(color, desc) description = desc .. "fireworks arrow", inventory_image = "throwing_arrow_fireworks_" .. color .. ".png", }) - + minetest.register_node("throwing:arrow_fireworks_" .. color .. "_box", { drawtype = "nodebox", node_box = { @@ -19,7 +19,7 @@ local function throwing_register_fireworks(color, desc) {7.5/17, -2.5/17, 2.5/17, 6.5/17, -1.5/17, 1.5/17}, {7.5/17, 2.5/17, -2.5/17, 6.5/17, 1.5/17, -1.5/17}, {6.5/17, -1.5/17, -1.5/17, 7.5/17, -2.5/17, -2.5/17}, - + {7.5/17, 2.5/17, 2.5/17, 8.5/17, 3.5/17, 3.5/17}, {8.5/17, -3.5/17, 3.5/17, 7.5/17, -2.5/17, 2.5/17}, {8.5/17, 3.5/17, -3.5/17, 7.5/17, 2.5/17, -2.5/17}, @@ -29,7 +29,7 @@ local function throwing_register_fireworks(color, desc) tiles = {"throwing_arrow_fireworks_" .. color .. ".png", "throwing_arrow_fireworks_" .. color .. ".png", "throwing_arrow_fireworks_" .. color .. "_back.png", "throwing_arrow_fireworks_" .. color .. "_front.png", "throwing_arrow_fireworks_" .. color .. "_2.png", "throwing_arrow_fireworks_" .. color .. ".png"}, groups = {not_in_creative_inventory=1}, }) - + local THROWING_ARROW_ENTITY={ physical = false, timer=0, @@ -38,10 +38,12 @@ local function throwing_register_fireworks(color, desc) textures = {"throwing:arrow_fireworks_" .. color .. "_box"}, lastpos={}, collisionbox = {0,0,0,0,0,0}, + player = "", + bow_damage = 0, } - + local radius = 0.5 - + local function add_effects(pos, radius) minetest.add_particlespawner({ amount = 256, @@ -59,8 +61,8 @@ local function throwing_register_fireworks(color, desc) texture = "throwing_sparkle_" .. color .. ".png", }) end - - + + local function boom(pos) minetest.sound_play("throwing_firework_boom", {pos=pos, gain=1, max_hear_distance=2*64}) if minetest.get_node(pos).name == 'air' or minetest.get_node(pos).name == 'throwing:firework_trail' then @@ -69,21 +71,20 @@ local function throwing_register_fireworks(color, desc) end add_effects(pos, radius) end - + -- Back to the arrow - + THROWING_ARROW_ENTITY.on_step = function(self, dtime) self.timer=self.timer+dtime - local pos = self.object:getpos() - local node = minetest.get_node(pos) + local newpos = self.object:getpos() if self.timer < 0.07 then - minetest.sound_play("throwing_firework_launch", {pos=pos, gain=0.8, max_hear_distance=2*64}) + minetest.sound_play("throwing_firework_launch", {pos=newpos, gain=0.8, max_hear_distance=2*64}) end minetest.add_particlespawner({ amount = 16, time = 0.1, - minpos = pos, - maxpos = pos, + minpos = newpos, + maxpos = newpos, minvel = {x=-5, y=-5, z=-5}, maxvel = {x=5, y=5, z=5}, minacc = vector.new(), @@ -94,48 +95,49 @@ local function throwing_register_fireworks(color, desc) maxsize = 1, texture = "throwing_sparkle.png", }) - if self.timer>0.2 then - local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 2) - for k, obj in pairs(objs) do - if obj:get_luaentity() ~= nil then - if obj:get_luaentity().name ~= "throwing:arrow_fireworks_" .. color .. "_entity" and obj:get_luaentity().name ~= "__builtin:item" then + if self.lastpos.x ~= nil then + for _, pos in pairs(throwing_get_trajectoire(self, newpos)) do + local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 2) + for k, obj in pairs(objs) do + if throwing_is_player(self.player, obj) or throwing_is_entity(obj) then local damage = 2 + if self.bow_damage and self.bow_damage > 0 then + damage = damage + (self.bow_damage/12) + end obj:punch(self.object, 1.0, { full_punch_interval=1.0, damage_groups={fleshy=damage}, }, nil) - self.object:remove() boom(pos) + self.object:remove() + return end end end - end - if self.timer > 2 then - self.object:remove() - boom(self.lastpos) - end - if self.lastpos.x~=nil then - if node.name ~= "air" and node.name ~= "throwing:firework_trail" then - self.object:remove() + local node = minetest.get_node(newpos) + if self.timer > 2 or node.name ~= "air" and node.name ~= "throwing:firework_trail" then boom(self.lastpos) + self.object:remove() + return + end + if node.name == 'air' then + minetest.add_node(newpos, {name="throwing:firework_trail"}) + minetest.get_node_timer(newpos):start(0.1) end end - if node.name == 'air' then - minetest.add_node(pos, {name="throwing:firework_trail"}) - minetest.get_node_timer(pos):start(0.1) - end - self.lastpos={x=pos.x, y=pos.y, z=pos.z} + self.lastpos={x=newpos.x, y=newpos.y, z=newpos.z} end - + + minetest.register_entity("throwing:arrow_fireworks_" .. color .. "_entity", THROWING_ARROW_ENTITY) - + minetest.register_craft({ output = 'throwing:arrow_fireworks_' .. color .. ' 8', recipe = { {'default:stick', 'tnt:gunpowder', 'dye:' .. color}, } }) - + minetest.register_craft({ output = 'throwing:arrow_fireworks_' .. color .. ' 8', recipe = { diff --git a/functions.lua b/functions.lua old mode 100644 new mode 100755 index 0848ac3..0deb46f --- a/functions.lua +++ b/functions.lua @@ -1,6 +1,6 @@ ---~ +--~ --~ Shot and reload system ---~ +--~ local players = {} @@ -16,24 +16,69 @@ minetest.register_on_leaveplayer(function(player) players[playerName] = nil end) +function throwing_is_player(name, obj) + return (obj:is_player() and obj:get_player_name() ~= name) +end + +function throwing_is_entity(obj) + return (obj:get_luaentity() ~= nil + and not string.find(obj:get_luaentity().name, "throwing:") + and obj:get_luaentity().name ~= "__builtin:item" + and obj:get_luaentity().name ~= "gauges:hp_bar" + and obj:get_luaentity().name ~= "signs:text") +end + +function throwing_get_trajectoire(self, newpos) + if self.lastpos.x == nil then + return {newpos} + end + local coord = {} + local nx = (newpos["x"] - self.lastpos["x"])/3 + local ny = (newpos["y"] - self.lastpos["y"])/3 + local nz = (newpos["z"] - self.lastpos["z"])/3 + + if nx and ny and nz then + table.insert(coord, {x=self.lastpos["x"]+nx, y=self.lastpos["y"]+ny ,z=self.lastpos["z"]+nz }) + table.insert(coord, {x=newpos["x"]-nx, y=newpos["y"]-ny ,z=newpos["z"]-nz }) + end + table.insert(coord, newpos) + return coord +end + +function throwing_touch(pos, objpos) + local rx = pos.x - objpos.x + local ry = pos.y - (objpos.y+1) + local rz = pos.z - objpos.z + if (ry < 1 and ry > -1) and (rx < 1 and rx > -1) and (rz < 1 and rz > -1) then + return true + end + return false +end + function throwing_shoot_arrow (itemstack, player, stiffness, is_cross) + if not player then return end local arrow = itemstack:get_metadata() itemstack:set_metadata("") player:set_wielded_item(itemstack) local playerpos = player:getpos() local obj = minetest.add_entity({x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, arrow) + if not obj then return end local dir = player:get_look_dir() obj:setvelocity({x=dir.x*stiffness, y=dir.y*stiffness, z=dir.z*stiffness}) - obj:setacceleration({x=dir.x*-3, y=-8.5, z=dir.z*-3}) + obj:setacceleration({x=dir.x*-3, y=-10, z=dir.z*-3}) obj:setyaw(player:get_look_yaw()+math.pi) if is_cross then minetest.sound_play("throwing_crossbow_sound", {pos=playerpos}) else minetest.sound_play("throwing_bow_sound", {pos=playerpos}) end - obj:get_luaentity().player = player - obj:get_luaentity().inventory = player:get_inventory() - obj:get_luaentity().stack = player:get_inventory():get_stack("main", player:get_wield_index()-1) + if obj:get_luaentity() then + obj:get_luaentity().player = player:get_player_name() + 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().lastpos = {x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z} + obj:get_luaentity().bow_damage = stiffness + end return true end @@ -44,6 +89,7 @@ function throwing_unload (itemstack, player, unloaded, wear) if not minetest.setting_getbool("creative_mode") then player:get_inventory():add_item("main", arrow[1]) end + break end end end @@ -67,6 +113,7 @@ function throwing_reload (itemstack, player, pos, is_cross, loaded) end local meta = arrow[2] player:set_wielded_item({name=loaded, wear=wear, metadata=meta}) + break end end end @@ -80,7 +127,7 @@ function throwing_register_bow (name, desc, scale, stiffness, reload_time, tough description = desc, inventory_image = "throwing_" .. name .. ".png", wield_scale = scale, - stack_max = 1, + stack_max = 1, on_use = function(itemstack, user, pointed_thing) local pos = user:getpos() local playerName = user:get_player_name() @@ -91,7 +138,7 @@ function throwing_register_bow (name, desc, scale, stiffness, reload_time, tough return itemstack end, }) - + minetest.register_tool("throwing:" .. name .. "_loaded", { description = desc, inventory_image = "throwing_" .. name .. "_loaded.png", @@ -104,7 +151,7 @@ function throwing_register_bow (name, desc, scale, stiffness, reload_time, tough end local unloaded = "throwing:" .. name throwing_shoot_arrow(itemstack, user, stiffness, is_cross) - minetest.after(0, throwing_unload, itemstack, user, unloaded, wear) + minetest.after(0, throwing_unload, itemstack, user, unloaded, wear) return itemstack end, on_drop = function(itemstack, dropper, pointed_thing) @@ -114,33 +161,31 @@ function throwing_register_bow (name, desc, scale, stiffness, reload_time, tough end, groups = {not_in_creative_inventory=1}, }) - + minetest.register_craft({ output = 'throwing:' .. name, recipe = craft }) + local craft_width = 1 + -- Since # isn't stable especially when there are nils in the table, count by hand + for _,v in ipairs(craft) do + for i,__ in ipairs(v) do + if i > craft_width then + craft_width = i + end + end + end + local rev_craft = {} + for i,y in ipairs(craft) do + rev_craft[i] = {} + for j,x in ipairs(y) do + rev_craft[i][craft_width-j+1] = x + end + end minetest.register_craft({ output = 'throwing:' .. name, - recipe = { - {craft[1][3], craft[1][2], craft[1][1]}, - {craft[2][3], craft[2][2], craft[2][1]}, - {craft[3][3], craft[3][2], craft[3][1]}, - } + recipe = rev_craft }) end --- Spears - -function throwing_shoot_spear (itemstack, player) - local spear = itemstack:get_name() .. '_entity' - local playerpos = player:getpos() - local obj = minetest.add_entity({x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, spear) - local dir = player:get_look_dir() - obj:setvelocity({x=dir.x*14, y=dir.y*14, z=dir.z*14}) - obj:setacceleration({x=-dir.x*1, y=-9.8, z=-dir.z*1}) - obj:setyaw(player:get_look_yaw()+math.pi) - minetest.sound_play("throwing_bow_sound", {pos=playerpos}) - obj:get_luaentity().wear = itemstack:get_wear() - return true -end diff --git a/init.lua b/init.lua old mode 100644 new mode 100755 index 7ad1419..ca43f8f --- a/init.lua +++ b/init.lua @@ -2,13 +2,14 @@ throwing_arrows = { {"throwing:arrow_steel", "throwing:arrow_steel_entity"}, {"throwing:arrow_stone", "throwing:arrow_stone_entity"}, {"throwing:arrow_obsidian", "throwing:arrow_obsidian_entity"}, + {"throwing:arrow_diamond", "throwing:arrow_diamond_entity"}, + {"throwing:arrow_mithril", "throwing:arrow_mithril_entity"}, --MFF : Only for Hunters {"throwing:arrow_fire", "throwing:arrow_fire_entity"}, {"throwing:arrow_teleport", "throwing:arrow_teleport_entity"}, {"throwing:arrow_dig", "throwing:arrow_dig_entity"}, {"throwing:arrow_build", "throwing:arrow_build_entity"}, {"throwing:arrow_tnt", "throwing:arrow_tnt_entity"}, {"throwing:arrow_torch", "throwing:arrow_torch_entity"}, - {"throwing:arrow_diamond", "throwing:arrow_diamond_entity"}, {"throwing:arrow_shell", "throwing:arrow_shell_entity"}, {"throwing:arrow_fireworks_blue", "throwing:arrow_fireworks_blue_entity"}, {"throwing:arrow_fireworks_red", "throwing:arrow_fireworks_red_entity"}, @@ -27,9 +28,10 @@ dofile(minetest.get_modpath("throwing").."/functions.lua") dofile(minetest.get_modpath("throwing").."/tools.lua") +dofile(minetest.get_modpath("throwing").."/crafts.lua") + dofile(minetest.get_modpath("throwing").."/standard_arrows.lua") -dofile(minetest.get_modpath("throwing").."/spears.lua") if minetest.get_modpath('fire') and minetest.get_modpath('bucket') and not DISABLE_FIRE_ARROW then dofile(minetest.get_modpath("throwing").."/fire_arrow.lua") diff --git a/screenshot.png b/screenshot.png deleted file mode 100644 index 32a89d1..0000000 Binary files a/screenshot.png and /dev/null differ diff --git a/shell_arrow.lua b/shell_arrow.lua old mode 100644 new mode 100755 index 5267cf9..f652a6b --- a/shell_arrow.lua +++ b/shell_arrow.lua @@ -18,7 +18,7 @@ minetest.register_node("throwing:arrow_shell_box", { {7.5/17, -2.5/17, 2.5/17, 6.5/17, -1.5/17, 1.5/17}, {7.5/17, 2.5/17, -2.5/17, 6.5/17, 1.5/17, -1.5/17}, {6.5/17, -1.5/17, -1.5/17, 7.5/17, -2.5/17, -2.5/17}, - + {7.5/17, 2.5/17, 2.5/17, 8.5/17, 3.5/17, 3.5/17}, {8.5/17, -3.5/17, 3.5/17, 7.5/17, -2.5/17, 2.5/17}, {8.5/17, 3.5/17, -3.5/17, 7.5/17, 2.5/17, -2.5/17}, @@ -37,6 +37,8 @@ local THROWING_ARROW_ENTITY={ textures = {"throwing:arrow_shell_box"}, lastpos={}, collisionbox = {0,0,0,0,0,0}, + player = "", + bow_damage = 0, } local radius = 1 @@ -70,35 +72,41 @@ end -- Back to the arrow THROWING_ARROW_ENTITY.on_step = function(self, dtime) - self.timer=self.timer+dtime - local pos = self.object:getpos() - local node = minetest.get_node(pos) - - if self.timer>0.2 then - local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 2) - for k, obj in pairs(objs) do - if obj:get_luaentity() ~= nil then - if obj:get_luaentity().name ~= "throwing:arrow_shell_entity" and obj:get_luaentity().name ~= "__builtin:item" then + local newpos = self.object:getpos() + 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}, 2) + for k, obj in pairs(objs) do + if throwing_is_player(self.player, obj) or throwing_is_entity(obj) then local speed = vector.length(self.object:getvelocity()) local damage = ((speed + 5)^1.2)/10 + 12 + if self.bow_damage and self.bow_damage > 0 then + damage = damage + (self.bow_damage/12) + end obj:punch(self.object, 1.0, { full_punch_interval=1.0, damage_groups={fleshy=damage}, }, nil) - self.object:remove() boom(pos) + self.object:remove() + return end end - end - end - if self.lastpos.x~=nil then - if node.name ~= "air" and not (string.find(node.name, 'grass') and not string.find(node.name, 'dirt')) and not string.find(node.name, 'flowers:') and not string.find(node.name, 'farming:') then - self.object:remove() - boom(self.lastpos) + if node.name ~= "air" + and not (string.find(node.name, 'grass') and not string.find(node.name, 'dirt')) + and not (string.find(node.name, 'farming:') and not string.find(node.name, 'soil')) + and not string.find(node.name, 'flowers:') + and not string.find(node.name, 'fire:') then + boom(self.lastpos) + self.object:remove() + return + end + self.lastpos={x=pos.x, y=pos.y, z=pos.z} end end - self.lastpos={x=pos.x, y=pos.y, z=pos.z} + self.lastpos={x=newpos.x, y=newpos.y, z=newpos.z} end minetest.register_entity("throwing:arrow_shell_entity", THROWING_ARROW_ENTITY) diff --git a/sounds/throwing_bow_sound.ogg b/sounds/throwing_bow_sound.ogg old mode 100644 new mode 100755 index 411598c..20a51da Binary files a/sounds/throwing_bow_sound.ogg and b/sounds/throwing_bow_sound.ogg differ diff --git a/sounds/throwing_crossbow_sound.ogg b/sounds/throwing_crossbow_sound.ogg old mode 100644 new mode 100755 index e30b1e0..bccb7f5 Binary files a/sounds/throwing_crossbow_sound.ogg and b/sounds/throwing_crossbow_sound.ogg differ diff --git a/sounds/throwing_firework_boom.ogg b/sounds/throwing_firework_boom.ogg old mode 100644 new mode 100755 index c25b96a..5db9100 Binary files a/sounds/throwing_firework_boom.ogg and b/sounds/throwing_firework_boom.ogg differ diff --git a/sounds/throwing_firework_launch.ogg b/sounds/throwing_firework_launch.ogg old mode 100644 new mode 100755 index e6165a4..d15c573 Binary files a/sounds/throwing_firework_launch.ogg and b/sounds/throwing_firework_launch.ogg differ diff --git a/sounds/throwing_shell_explode.ogg b/sounds/throwing_shell_explode.ogg old mode 100644 new mode 100755 index ec827f8..38b8e93 Binary files a/sounds/throwing_shell_explode.ogg and b/sounds/throwing_shell_explode.ogg differ diff --git a/spears.lua b/spears.lua deleted file mode 100644 index f8d492e..0000000 --- a/spears.lua +++ /dev/null @@ -1,129 +0,0 @@ -function throwing_register_spear_standard (kind, desc, eq, toughness, craft) - minetest.register_tool("throwing:spear_" .. kind, { - description = desc .. " spear", - inventory_image = "throwing_spear_" .. kind .. ".png", - wield_scale= {x=2,y=1.5,z=1.5}; - on_use = function(itemstack, user, pointed_thing) - if pointed_thing.type == "object" then - local damage = ((eq + 20)^1.2)/10 - pointed_thing.ref:punch(user, 1.0, { - full_punch_interval=1.0, - damage_groups={fleshy=damage}, - }, nil) - if not minetest.setting_getbool("creative_mode") then - itemstack:add_wear(65535/toughness) - end - else - throwing_shoot_spear(itemstack, user) - if not minetest.setting_getbool("creative_mode") then - itemstack:take_item() - end - end - return itemstack - end, - }) - - minetest.register_node("throwing:spear_" .. kind .. "_box", { - drawtype = "nodebox", - node_box = { - type = "fixed", - fixed = { - -- Shaft - {-60/16, -2/16, 2/16, 4, 1/16, -1/16}, - --Spitze - {-4, -1/16, 1/16, -62/16, 0, 0}, - {-62/16, -1.5/16, 1.5/16, -60/16, 0.5/16, -0.5/16}, - } - }, - tiles = {"throwing_spear_box.png"}, - groups = {not_in_creative_inventory=1}, - }) - - local THROWING_SPEAR_ENTITY={ - physical = false, - timer=0, - visual = "wielditem", - visual_size = {x=0.1, y=0.1}, - textures = {"throwing:spear_" .. kind .. "_box"}, - lastpos={}, - collisionbox = {0,0,0,0,0,0}, - } - - THROWING_SPEAR_ENTITY.on_step = function(self, dtime) - self.timer=self.timer+dtime - local pos = self.object:getpos() - local node = minetest.get_node(pos) - if not self.wear then - self.object:remove() - return - end - - if self.timer>0.2 then - local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 2) - for k, obj in pairs(objs) do - if obj:get_luaentity() ~= nil then - if obj:get_luaentity().name ~= "throwing:spear_" .. kind .. "_entity" and obj:get_luaentity().name ~= "__builtin:item" then - local speed = vector.length(self.object:getvelocity()) - local damage = ((speed + eq +5)^1.2)/10 - obj:punch(self.object, 1.0, { - full_punch_interval=1.0, - damage_groups={fleshy=damage}, - }, nil) - self.object:remove() - minetest.add_item(self.lastpos, {name='throwing:spear_' .. kind, count=1, wear=self.wear+65535/toughness, metadata=""}) - --if math.random() < toughness then - --minetest.add_item(self.lastpos, 'throwing:spear_' .. kind) - --else - --minetest.add_item(self.lastpos, 'default:stick') - --end - end - end - end - end - - if self.lastpos.x~=nil then - if node.name ~= "air" and not (string.find(node.name, 'grass') and not string.find(node.name, 'dirt')) and not string.find(node.name, 'flowers:') and not string.find(node.name, 'farming:') then - self.object:remove() - minetest.add_item(self.lastpos, {name='throwing:spear_' .. kind, count=1, wear=self.wear+65535/toughness, metadata=""}) - --if math.random() < toughness then - --minetest.add_item(self.lastpos, 'throwing:spear_' .. kind) - --else - --minetest.add_item(self.lastpos, 'default:stick') - --end - end - end - self.lastpos={x=pos.x, y=pos.y, z=pos.z} - end - - minetest.register_entity("throwing:spear_" .. kind .. "_entity", THROWING_SPEAR_ENTITY) - - minetest.register_craft({ - output = 'throwing:spear_' .. kind, - recipe = { - {'group:wood', 'group:wood', craft}, - } - }) - - minetest.register_craft({ - output = 'throwing:spear_' .. kind, - recipe = { - {craft, 'group:wood', 'group:wood'}, - } - }) -end - -if not DISABLE_STONE_SPEAR then - throwing_register_spear_standard ('stone', 'Stone', 0, 20, 'group:stone') -end - -if not DISABLE_STEEL_SPEAR then - throwing_register_spear_standard ('steel', 'Steel', 5, 30, 'default:steel_ingot') -end - -if not DISABLE_DIAMOND_SPEAR then - throwing_register_spear_standard ('diamond', 'Diamond', 10, 40, 'default:diamond') -end - -if not DISABLE_OBSIDIAN_SPEAR then - throwing_register_spear_standard ('obsidian', 'Obsidian', 15, 30, 'default:obsidian') -end diff --git a/standard_arrows.lua b/standard_arrows.lua old mode 100644 new mode 100755 index 02c1e3e..49b50b3 --- a/standard_arrows.lua +++ b/standard_arrows.lua @@ -3,7 +3,7 @@ function throwing_register_arrow_standard (kind, desc, eq, toughness, craft) description = desc .. " arrow", inventory_image = "throwing_arrow_" .. kind .. ".png", }) - + minetest.register_node("throwing:arrow_" .. kind .. "_box", { drawtype = "nodebox", node_box = { @@ -19,76 +19,92 @@ function throwing_register_arrow_standard (kind, desc, eq, toughness, craft) {7.5/17, -2.5/17, 2.5/17, 6.5/17, -1.5/17, 1.5/17}, {7.5/17, 2.5/17, -2.5/17, 6.5/17, 1.5/17, -1.5/17}, {6.5/17, -1.5/17, -1.5/17, 7.5/17, -2.5/17, -2.5/17}, - + {7.5/17, 2.5/17, 2.5/17, 8.5/17, 3.5/17, 3.5/17}, {8.5/17, -3.5/17, 3.5/17, 7.5/17, -2.5/17, 2.5/17}, {8.5/17, 3.5/17, -3.5/17, 7.5/17, 2.5/17, -2.5/17}, {7.5/17, -2.5/17, -2.5/17, 8.5/17, -3.5/17, -3.5/17}, } }, - tiles = {"throwing_arrow_" .. kind .. ".png", "throwing_arrow_" .. kind .. ".png", "throwing_arrow_" .. kind .. "_back.png", "throwing_arrow_" .. kind .. "_front.png", "throwing_arrow_" .. kind .. "_2.png", "throwing_arrow_" .. kind .. ".png"}, + tiles = {"throwing_arrow_" .. kind .. ".png", "throwing_arrow_" .. kind .. ".png", "throwing_arrow_" .. kind .. "_back.png", "throwing_arrow_" .. kind .. "_front.png", + "throwing_arrow_" .. kind .. "_2.png", "throwing_arrow_" .. kind .. ".png"}, groups = {not_in_creative_inventory=1}, }) - + local THROWING_ARROW_ENTITY={ physical = false, - timer=0, visual = "wielditem", visual_size = {x=0.1, y=0.1}, textures = {"throwing:arrow_" .. kind .. "_box"}, lastpos={}, collisionbox = {0,0,0,0,0,0}, + player = "", + bow_damage = 0, } - + THROWING_ARROW_ENTITY.on_step = function(self, dtime) - self.timer=self.timer+dtime - local pos = self.object:getpos() - local node = minetest.get_node(pos) - - if self.timer>0.2 then - local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 2) - for k, obj in pairs(objs) do - if obj:get_luaentity() ~= nil then - if obj:get_luaentity().name ~= "throwing:arrow_" .. kind .. "_entity" and obj:get_luaentity().name ~= "__builtin:item" then - local speed = vector.length(self.object:getvelocity()) - local damage = ((speed + eq)^1.2)/10 - obj:punch(self.object, 1.0, { - full_punch_interval=1.0, - damage_groups={fleshy=damage}, - }, nil) - self.object:remove() - if math.random() < toughness then - minetest.add_item(self.lastpos, 'throwing:arrow_' .. kind) - else - minetest.add_item(self.lastpos, 'default:stick') + local newpos = self.object:getpos() + 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}, 2) + for k, obj in pairs(objs) do + local objpos = obj:getpos() + if throwing_is_player(self.player, obj) or throwing_is_entity(obj) then + if throwing_touch(pos, objpos) then + local puncher = self.object + if self.player and minetest.get_player_by_name(self.player) then + puncher = minetest.get_player_by_name(self.player) + end + local damage = eq + if self.bow_damage and self.bow_damage > 0 then + damage = damage + (self.bow_damage/12) + end + obj:punch(puncher, 1.0, { + full_punch_interval=1.0, + damage_groups={fleshy=damage}, + }, nil) + if math.random() < toughness then + if math.random(0,100) % 2 == 0 then + minetest.add_item(self.lastpos, 'throwing:arrow_' .. kind) + end + else + minetest.add_item(self.lastpos, 'default:stick') + end + self.object:remove() + return end end end - end - end - - if self.lastpos.x~=nil then - if node.name ~= "air" and not (string.find(node.name, 'grass') and not string.find(node.name, 'dirt')) and not string.find(node.name, 'flowers:') and not string.find(node.name, 'farming:') then - self.object:remove() - if math.random() < toughness then - minetest.add_item(self.lastpos, 'throwing:arrow_' .. kind) - else - minetest.add_item(self.lastpos, 'default:stick') + if node.name ~= "air" + and not string.find(node.name, 'water_') + and not (string.find(node.name, 'grass') and not string.find(node.name, 'dirt')) + and not (string.find(node.name, 'farming:') and not string.find(node.name, 'soil')) + and not string.find(node.name, 'flowers:') + and not string.find(node.name, 'fire:') then + if math.random() < toughness then + minetest.add_item(self.lastpos, 'throwing:arrow_' .. kind) + else + minetest.add_item(self.lastpos, 'default:stick') + end + self.object:remove() + return end + self.lastpos={x=pos.x, y=pos.y, z=pos.z} end end - self.lastpos={x=pos.x, y=pos.y, z=pos.z} + self.lastpos={x=newpos.x, y=newpos.y, z=newpos.z} end - + minetest.register_entity("throwing:arrow_" .. kind .. "_entity", THROWING_ARROW_ENTITY) - + minetest.register_craft({ output = 'throwing:arrow_' .. kind .. ' 16', recipe = { {'default:stick', 'default:stick', craft}, } }) - + minetest.register_craft({ output = 'throwing:arrow_' .. kind .. ' 16', recipe = { @@ -98,17 +114,21 @@ function throwing_register_arrow_standard (kind, desc, eq, toughness, craft) end if not DISABLE_STONE_ARROW then - throwing_register_arrow_standard ('stone', 'Stone', 0, 0.88, 'group:stone') + throwing_register_arrow_standard ('stone', 'Stone', 4, 0.40, 'group:stone') end if not DISABLE_STEEL_ARROW then - throwing_register_arrow_standard ('steel', 'Steel', 5, 0.94, 'default:steel_ingot') -end - -if not DISABLE_DIAMOND_ARROW then - throwing_register_arrow_standard ('diamond', 'Diamond', 10, 0.97, 'default:diamond') + throwing_register_arrow_standard ('steel', 'Steel', 5, 0.50, 'default:steel_ingot') end if not DISABLE_OBSIDIAN_ARROW then - throwing_register_arrow_standard ('obsidian', 'Obsidian', 15, 0.88, 'default:obsidian') + throwing_register_arrow_standard ('obsidian', 'Obsidian', 6, 0.60, 'default:obsidian') +end + +if not DISABLE_DIAMOND_ARROW then + throwing_register_arrow_standard ('diamond', 'Diamond', 7, 0.70, 'default:diamond') +end + +if not DISABLE_MITHRIL_ARROW then + throwing_register_arrow_standard ('mithril', 'Mithril (Hunter)', 8, 0.80, 'default:mithril_ingot') end diff --git a/teleport_arrow.lua b/teleport_arrow.lua old mode 100644 new mode 100755 index d495de3..927681f --- a/teleport_arrow.lua +++ b/teleport_arrow.lua @@ -18,7 +18,7 @@ minetest.register_node("throwing:arrow_teleport_box", { {7.5/17, -2.5/17, 2.5/17, 6.5/17, -1.5/17, 1.5/17}, {7.5/17, 2.5/17, -2.5/17, 6.5/17, 1.5/17, -1.5/17}, {6.5/17, -1.5/17, -1.5/17, 7.5/17, -2.5/17, -2.5/17}, - + {7.5/17, 2.5/17, 2.5/17, 8.5/17, 3.5/17, 3.5/17}, {8.5/17, -3.5/17, 3.5/17, 7.5/17, -2.5/17, 2.5/17}, {8.5/17, 3.5/17, -3.5/17, 7.5/17, 2.5/17, -2.5/17}, @@ -31,48 +31,52 @@ minetest.register_node("throwing:arrow_teleport_box", { local THROWING_ARROW_ENTITY={ physical = false, - timer=0, visual = "wielditem", visual_size = {x=0.1, y=0.1}, textures = {"throwing:arrow_teleport_box"}, lastpos={}, collisionbox = {0,0,0,0,0,0}, player = "", + bow_damage = 0, } THROWING_ARROW_ENTITY.on_step = function(self, dtime) - self.timer=self.timer+dtime - local pos = self.object:getpos() - local node = minetest.get_node(pos) - if not self.player then - self.object:remove() - end - - if self.timer>0.2 then - local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 2) - for k, obj in pairs(objs) do - if obj:get_luaentity() ~= nil then - if obj:get_luaentity().name ~= "throwing:arrow_teleport_entity" and obj:get_luaentity().name ~= "__builtin:item" then - self.object:remove() + local newpos = self.object:getpos() + 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}, 2) + for k, obj in pairs(objs) do + if throwing_is_player(self.player, obj) or throwing_is_entity(obj) then if self.player ~= "" then - self.player:setpos(pos) - self.player:get_inventory():add_item("main", ItemStack("default:stick 2")) + local player = minetest.get_player_by_name(self.player) + if player then + player:setpos(self.lastpos) + end end + self.object:remove() + return end end - end - end - if self.lastpos.x~=nil then - if node.name ~= "air" then - self.object:remove() - if self.player ~= "" then - self.player:setpos(self.lastpos) - self.player:get_inventory():add_item("main", ItemStack("default:stick 2")) + if node.name ~= "air" + and not (string.find(node.name, 'grass') and not string.find(node.name, 'dirt')) + and not (string.find(node.name, 'farming:') and not string.find(node.name, 'soil')) + and not string.find(node.name, 'flowers:') + and not string.find(node.name, 'fire:') then + if self.player ~= "" then + local player = minetest.get_player_by_name(self.player) + if player then + player:setpos(self.lastpos) + end + end + self.object:remove() + return end + self.lastpos={x=pos.x, y=pos.y, z=pos.z} end end - self.lastpos={x=pos.x, y=pos.y, z=pos.z} + self.lastpos={x=newpos.x, y=newpos.y, z=newpos.z} end minetest.register_entity("throwing:arrow_teleport_entity", THROWING_ARROW_ENTITY) diff --git a/textures/___BOW_LOAD.PNG b/textures/___BOW_LOAD.PNG new file mode 100755 index 0000000..58c6637 Binary files /dev/null and b/textures/___BOW_LOAD.PNG differ diff --git a/textures/throwing_arbalest.png b/textures/throwing_arbalest.png old mode 100644 new mode 100755 index f53e377..401ff2c Binary files a/textures/throwing_arbalest.png and b/textures/throwing_arbalest.png differ diff --git a/textures/throwing_arbalest_auto.png b/textures/throwing_arbalest_auto.png index c40cd92..1ceac2b 100644 Binary files a/textures/throwing_arbalest_auto.png and b/textures/throwing_arbalest_auto.png differ diff --git a/textures/throwing_arbalest_auto_loaded.png b/textures/throwing_arbalest_auto_loaded.png index f971b24..34c3057 100644 Binary files a/textures/throwing_arbalest_auto_loaded.png and b/textures/throwing_arbalest_auto_loaded.png differ diff --git a/textures/throwing_arbalest_loaded.png b/textures/throwing_arbalest_loaded.png old mode 100644 new mode 100755 index 09b2cc8..38eb225 Binary files a/textures/throwing_arbalest_loaded.png and b/textures/throwing_arbalest_loaded.png differ diff --git a/textures/throwing_arrow_build.png b/textures/throwing_arrow_build.png old mode 100644 new mode 100755 index d9b4062..52da426 Binary files a/textures/throwing_arrow_build.png and b/textures/throwing_arrow_build.png differ diff --git a/textures/throwing_arrow_build_2.png b/textures/throwing_arrow_build_2.png old mode 100644 new mode 100755 index 1e178e4..9b72e9e Binary files a/textures/throwing_arrow_build_2.png and b/textures/throwing_arrow_build_2.png differ diff --git a/textures/throwing_arrow_build_back.png b/textures/throwing_arrow_build_back.png old mode 100644 new mode 100755 index 621f258..dc300c1 Binary files a/textures/throwing_arrow_build_back.png and b/textures/throwing_arrow_build_back.png differ diff --git a/textures/throwing_arrow_build_front.png b/textures/throwing_arrow_build_front.png old mode 100644 new mode 100755 index 25d47ce..53d47c4 Binary files a/textures/throwing_arrow_build_front.png and b/textures/throwing_arrow_build_front.png differ diff --git a/textures/throwing_arrow_diamond.png b/textures/throwing_arrow_diamond.png old mode 100644 new mode 100755 index a70038a..ac87a0f Binary files a/textures/throwing_arrow_diamond.png and b/textures/throwing_arrow_diamond.png differ diff --git a/textures/throwing_arrow_diamond_2.png b/textures/throwing_arrow_diamond_2.png old mode 100644 new mode 100755 index 485b12f..989e00a Binary files a/textures/throwing_arrow_diamond_2.png and b/textures/throwing_arrow_diamond_2.png differ diff --git a/textures/throwing_arrow_diamond_back.png b/textures/throwing_arrow_diamond_back.png old mode 100644 new mode 100755 index 0c92fba..3ff6422 Binary files a/textures/throwing_arrow_diamond_back.png and b/textures/throwing_arrow_diamond_back.png differ diff --git a/textures/throwing_arrow_diamond_front.png b/textures/throwing_arrow_diamond_front.png old mode 100644 new mode 100755 index 6e545df..aa076de Binary files a/textures/throwing_arrow_diamond_front.png and b/textures/throwing_arrow_diamond_front.png differ diff --git a/textures/throwing_arrow_dig.png b/textures/throwing_arrow_dig.png old mode 100644 new mode 100755 index 6a1d443..3d2e7d9 Binary files a/textures/throwing_arrow_dig.png and b/textures/throwing_arrow_dig.png differ diff --git a/textures/throwing_arrow_dig_2.png b/textures/throwing_arrow_dig_2.png old mode 100644 new mode 100755 index b6d9d1b..83c31c8 Binary files a/textures/throwing_arrow_dig_2.png and b/textures/throwing_arrow_dig_2.png differ diff --git a/textures/throwing_arrow_dig_back.png b/textures/throwing_arrow_dig_back.png old mode 100644 new mode 100755 index 3bc4a60..b903aa1 Binary files a/textures/throwing_arrow_dig_back.png and b/textures/throwing_arrow_dig_back.png differ diff --git a/textures/throwing_arrow_dig_front.png b/textures/throwing_arrow_dig_front.png old mode 100644 new mode 100755 index aa7ff2e..6cf8a53 Binary files a/textures/throwing_arrow_dig_front.png and b/textures/throwing_arrow_dig_front.png differ diff --git a/textures/throwing_arrow_fire.png b/textures/throwing_arrow_fire.png old mode 100644 new mode 100755 index fd3a9d5..30deba4 Binary files a/textures/throwing_arrow_fire.png and b/textures/throwing_arrow_fire.png differ diff --git a/textures/throwing_arrow_fire_2.png b/textures/throwing_arrow_fire_2.png old mode 100644 new mode 100755 index f86579a..1181b35 Binary files a/textures/throwing_arrow_fire_2.png and b/textures/throwing_arrow_fire_2.png differ diff --git a/textures/throwing_arrow_fire_back.png b/textures/throwing_arrow_fire_back.png old mode 100644 new mode 100755 index 8a7d993..f96151c Binary files a/textures/throwing_arrow_fire_back.png and b/textures/throwing_arrow_fire_back.png differ diff --git a/textures/throwing_arrow_fire_front.png b/textures/throwing_arrow_fire_front.png old mode 100644 new mode 100755 index 3994257..9853bd8 Binary files a/textures/throwing_arrow_fire_front.png and b/textures/throwing_arrow_fire_front.png differ diff --git a/textures/throwing_arrow_fireworks_blue.png b/textures/throwing_arrow_fireworks_blue.png old mode 100644 new mode 100755 index 71d4ec8..cd23137 Binary files a/textures/throwing_arrow_fireworks_blue.png and b/textures/throwing_arrow_fireworks_blue.png differ diff --git a/textures/throwing_arrow_fireworks_blue_2.png b/textures/throwing_arrow_fireworks_blue_2.png old mode 100644 new mode 100755 index 51b055c..a9762cf Binary files a/textures/throwing_arrow_fireworks_blue_2.png and b/textures/throwing_arrow_fireworks_blue_2.png differ diff --git a/textures/throwing_arrow_fireworks_blue_back.png b/textures/throwing_arrow_fireworks_blue_back.png old mode 100644 new mode 100755 index 85956a6..1b55403 Binary files a/textures/throwing_arrow_fireworks_blue_back.png and b/textures/throwing_arrow_fireworks_blue_back.png differ diff --git a/textures/throwing_arrow_fireworks_blue_front.png b/textures/throwing_arrow_fireworks_blue_front.png old mode 100644 new mode 100755 index 8674cc8..90fa40a Binary files a/textures/throwing_arrow_fireworks_blue_front.png and b/textures/throwing_arrow_fireworks_blue_front.png differ diff --git a/textures/throwing_arrow_fireworks_red.png b/textures/throwing_arrow_fireworks_red.png old mode 100644 new mode 100755 index 9b13fcd..f5b71ef Binary files a/textures/throwing_arrow_fireworks_red.png and b/textures/throwing_arrow_fireworks_red.png differ diff --git a/textures/throwing_arrow_fireworks_red_2.png b/textures/throwing_arrow_fireworks_red_2.png old mode 100644 new mode 100755 index edb0097..f738eee Binary files a/textures/throwing_arrow_fireworks_red_2.png and b/textures/throwing_arrow_fireworks_red_2.png differ diff --git a/textures/throwing_arrow_fireworks_red_back.png b/textures/throwing_arrow_fireworks_red_back.png old mode 100644 new mode 100755 index 8e90fc5..6bf7c1a Binary files a/textures/throwing_arrow_fireworks_red_back.png and b/textures/throwing_arrow_fireworks_red_back.png differ diff --git a/textures/throwing_arrow_fireworks_red_front.png b/textures/throwing_arrow_fireworks_red_front.png old mode 100644 new mode 100755 index 8d6a629..b7cb99f Binary files a/textures/throwing_arrow_fireworks_red_front.png and b/textures/throwing_arrow_fireworks_red_front.png differ diff --git a/textures/throwing_arrow_mithril.png b/textures/throwing_arrow_mithril.png new file mode 100644 index 0000000..f0ac6ba Binary files /dev/null and b/textures/throwing_arrow_mithril.png differ diff --git a/textures/throwing_arrow_mithril_2.png b/textures/throwing_arrow_mithril_2.png new file mode 100644 index 0000000..4462513 Binary files /dev/null and b/textures/throwing_arrow_mithril_2.png differ diff --git a/textures/throwing_arrow_mithril_back.png b/textures/throwing_arrow_mithril_back.png new file mode 100644 index 0000000..f811502 Binary files /dev/null and b/textures/throwing_arrow_mithril_back.png differ diff --git a/textures/throwing_arrow_mithril_front.png b/textures/throwing_arrow_mithril_front.png new file mode 100644 index 0000000..a96ea87 Binary files /dev/null and b/textures/throwing_arrow_mithril_front.png differ diff --git a/textures/throwing_arrow_model.png b/textures/throwing_arrow_model.png new file mode 100755 index 0000000..4e3ac3e Binary files /dev/null and b/textures/throwing_arrow_model.png differ diff --git a/textures/throwing_arrow_obsidian.png b/textures/throwing_arrow_obsidian.png old mode 100644 new mode 100755 index 2df7a08..6102144 Binary files a/textures/throwing_arrow_obsidian.png and b/textures/throwing_arrow_obsidian.png differ diff --git a/textures/throwing_arrow_obsidian_2.png b/textures/throwing_arrow_obsidian_2.png old mode 100644 new mode 100755 index abccbb3..5e09e2e Binary files a/textures/throwing_arrow_obsidian_2.png and b/textures/throwing_arrow_obsidian_2.png differ diff --git a/textures/throwing_arrow_obsidian_back.png b/textures/throwing_arrow_obsidian_back.png old mode 100644 new mode 100755 index bd1232f..6c89946 Binary files a/textures/throwing_arrow_obsidian_back.png and b/textures/throwing_arrow_obsidian_back.png differ diff --git a/textures/throwing_arrow_obsidian_front.png b/textures/throwing_arrow_obsidian_front.png old mode 100644 new mode 100755 index 2cbed4c..0e96bb0 Binary files a/textures/throwing_arrow_obsidian_front.png and b/textures/throwing_arrow_obsidian_front.png differ diff --git a/textures/throwing_arrow_shell.png b/textures/throwing_arrow_shell.png old mode 100644 new mode 100755 index d100424..8426ec2 Binary files a/textures/throwing_arrow_shell.png and b/textures/throwing_arrow_shell.png differ diff --git a/textures/throwing_arrow_shell_2.png b/textures/throwing_arrow_shell_2.png old mode 100644 new mode 100755 index 25f2b3e..6092857 Binary files a/textures/throwing_arrow_shell_2.png and b/textures/throwing_arrow_shell_2.png differ diff --git a/textures/throwing_arrow_shell_back.png b/textures/throwing_arrow_shell_back.png old mode 100644 new mode 100755 index 4b64eaf..6c89946 Binary files a/textures/throwing_arrow_shell_back.png and b/textures/throwing_arrow_shell_back.png differ diff --git a/textures/throwing_arrow_shell_front.png b/textures/throwing_arrow_shell_front.png old mode 100644 new mode 100755 index f6d51c4..2da98ec Binary files a/textures/throwing_arrow_shell_front.png and b/textures/throwing_arrow_shell_front.png differ diff --git a/textures/throwing_arrow_steel.png b/textures/throwing_arrow_steel.png old mode 100644 new mode 100755 index 9932590..328954e Binary files a/textures/throwing_arrow_steel.png and b/textures/throwing_arrow_steel.png differ diff --git a/textures/throwing_arrow_steel_2.png b/textures/throwing_arrow_steel_2.png old mode 100644 new mode 100755 index c0401a6..632dd1f Binary files a/textures/throwing_arrow_steel_2.png and b/textures/throwing_arrow_steel_2.png differ diff --git a/textures/throwing_arrow_steel_back.png b/textures/throwing_arrow_steel_back.png old mode 100644 new mode 100755 index c7edf56..e1cb7bf Binary files a/textures/throwing_arrow_steel_back.png and b/textures/throwing_arrow_steel_back.png differ diff --git a/textures/throwing_arrow_steel_front.png b/textures/throwing_arrow_steel_front.png old mode 100644 new mode 100755 index ff22af0..7d27afa Binary files a/textures/throwing_arrow_steel_front.png and b/textures/throwing_arrow_steel_front.png differ diff --git a/textures/throwing_arrow_stone.png b/textures/throwing_arrow_stone.png old mode 100644 new mode 100755 index b563af6..66f4502 Binary files a/textures/throwing_arrow_stone.png and b/textures/throwing_arrow_stone.png differ diff --git a/textures/throwing_arrow_stone_2.png b/textures/throwing_arrow_stone_2.png old mode 100644 new mode 100755 index 20182bc..7b4553c Binary files a/textures/throwing_arrow_stone_2.png and b/textures/throwing_arrow_stone_2.png differ diff --git a/textures/throwing_arrow_stone_back.png b/textures/throwing_arrow_stone_back.png old mode 100644 new mode 100755 index 293334e..4c2c7ee Binary files a/textures/throwing_arrow_stone_back.png and b/textures/throwing_arrow_stone_back.png differ diff --git a/textures/throwing_arrow_stone_front.png b/textures/throwing_arrow_stone_front.png old mode 100644 new mode 100755 index 8b35047..a735323 Binary files a/textures/throwing_arrow_stone_front.png and b/textures/throwing_arrow_stone_front.png differ diff --git a/textures/throwing_arrow_teleport.png b/textures/throwing_arrow_teleport.png old mode 100644 new mode 100755 index 584735b..8e83d90 Binary files a/textures/throwing_arrow_teleport.png and b/textures/throwing_arrow_teleport.png differ diff --git a/textures/throwing_arrow_teleport_2.png b/textures/throwing_arrow_teleport_2.png old mode 100644 new mode 100755 index 56192c8..73d7746 Binary files a/textures/throwing_arrow_teleport_2.png and b/textures/throwing_arrow_teleport_2.png differ diff --git a/textures/throwing_arrow_teleport_back.png b/textures/throwing_arrow_teleport_back.png old mode 100644 new mode 100755 index 325c203..fde1da0 Binary files a/textures/throwing_arrow_teleport_back.png and b/textures/throwing_arrow_teleport_back.png differ diff --git a/textures/throwing_arrow_teleport_front.png b/textures/throwing_arrow_teleport_front.png old mode 100644 new mode 100755 index 138f1cf..c27211c Binary files a/textures/throwing_arrow_teleport_front.png and b/textures/throwing_arrow_teleport_front.png differ diff --git a/textures/throwing_arrow_tnt.png b/textures/throwing_arrow_tnt.png old mode 100644 new mode 100755 index c7ee8f1..9339769 Binary files a/textures/throwing_arrow_tnt.png and b/textures/throwing_arrow_tnt.png differ diff --git a/textures/throwing_arrow_tnt_2.png b/textures/throwing_arrow_tnt_2.png old mode 100644 new mode 100755 index 3b53ece..40cec08 Binary files a/textures/throwing_arrow_tnt_2.png and b/textures/throwing_arrow_tnt_2.png differ diff --git a/textures/throwing_arrow_tnt_back.png b/textures/throwing_arrow_tnt_back.png old mode 100644 new mode 100755 index 230bb18..cecc8fa Binary files a/textures/throwing_arrow_tnt_back.png and b/textures/throwing_arrow_tnt_back.png differ diff --git a/textures/throwing_arrow_tnt_front.png b/textures/throwing_arrow_tnt_front.png old mode 100644 new mode 100755 index b7252ac..9ea0b61 Binary files a/textures/throwing_arrow_tnt_front.png and b/textures/throwing_arrow_tnt_front.png differ diff --git a/textures/throwing_arrow_torch.png b/textures/throwing_arrow_torch.png old mode 100644 new mode 100755 index 1c424e4..e7142e3 Binary files a/textures/throwing_arrow_torch.png and b/textures/throwing_arrow_torch.png differ diff --git a/textures/throwing_arrow_torch_2.png b/textures/throwing_arrow_torch_2.png old mode 100644 new mode 100755 index a5800ce..0691a3a Binary files a/textures/throwing_arrow_torch_2.png and b/textures/throwing_arrow_torch_2.png differ diff --git a/textures/throwing_arrow_torch_back.png b/textures/throwing_arrow_torch_back.png old mode 100644 new mode 100755 index 3b9fd11..a42e78d Binary files a/textures/throwing_arrow_torch_back.png and b/textures/throwing_arrow_torch_back.png differ diff --git a/textures/throwing_arrow_torch_front.png b/textures/throwing_arrow_torch_front.png old mode 100644 new mode 100755 index 764a263..afca2d5 Binary files a/textures/throwing_arrow_torch_front.png and b/textures/throwing_arrow_torch_front.png differ diff --git a/textures/throwing_bow_composite.png b/textures/throwing_bow_composite.png old mode 100644 new mode 100755 index 630af5a..1ef7b58 Binary files a/textures/throwing_bow_composite.png and b/textures/throwing_bow_composite.png differ diff --git a/textures/throwing_bow_composite_loaded.png b/textures/throwing_bow_composite_loaded.png old mode 100644 new mode 100755 index 67bf8e5..b76ae1d Binary files a/textures/throwing_bow_composite_loaded.png and b/textures/throwing_bow_composite_loaded.png differ diff --git a/textures/throwing_bow_minotaur_horn.png b/textures/throwing_bow_minotaur_horn.png new file mode 100755 index 0000000..86c450c Binary files /dev/null and b/textures/throwing_bow_minotaur_horn.png differ diff --git a/textures/throwing_bow_minotaur_horn_improved.png b/textures/throwing_bow_minotaur_horn_improved.png new file mode 100755 index 0000000..4d64969 Binary files /dev/null and b/textures/throwing_bow_minotaur_horn_improved.png differ diff --git a/textures/throwing_bow_minotaur_horn_improved_loaded.png b/textures/throwing_bow_minotaur_horn_improved_loaded.png new file mode 100755 index 0000000..3fd87e9 Binary files /dev/null and b/textures/throwing_bow_minotaur_horn_improved_loaded.png differ diff --git a/textures/throwing_bow_minotaur_horn_loaded.png b/textures/throwing_bow_minotaur_horn_loaded.png new file mode 100755 index 0000000..a91f989 Binary files /dev/null and b/textures/throwing_bow_minotaur_horn_loaded.png differ diff --git a/textures/throwing_bow_royal.png b/textures/throwing_bow_royal.png old mode 100644 new mode 100755 index 43c20f8..7567cd7 Binary files a/textures/throwing_bow_royal.png and b/textures/throwing_bow_royal.png differ diff --git a/textures/throwing_bow_royal_loaded.png b/textures/throwing_bow_royal_loaded.png old mode 100644 new mode 100755 index 3416f2e..f815b13 Binary files a/textures/throwing_bow_royal_loaded.png and b/textures/throwing_bow_royal_loaded.png differ diff --git a/textures/throwing_bow_steel.png b/textures/throwing_bow_steel.png old mode 100644 new mode 100755 index 0e1d3d1..1cb1500 Binary files a/textures/throwing_bow_steel.png and b/textures/throwing_bow_steel.png differ diff --git a/textures/throwing_bow_steel_loaded.png b/textures/throwing_bow_steel_loaded.png old mode 100644 new mode 100755 index 16150a6..b2b25d8 Binary files a/textures/throwing_bow_steel_loaded.png and b/textures/throwing_bow_steel_loaded.png differ diff --git a/textures/throwing_bow_wood.png b/textures/throwing_bow_wood.png old mode 100644 new mode 100755 index 9a6c6da..267ec4a Binary files a/textures/throwing_bow_wood.png and b/textures/throwing_bow_wood.png differ diff --git a/textures/throwing_bow_wood_loaded.png b/textures/throwing_bow_wood_loaded.png old mode 100644 new mode 100755 index 251e643..7349237 Binary files a/textures/throwing_bow_wood_loaded.png and b/textures/throwing_bow_wood_loaded.png differ diff --git a/textures/throwing_crossbow.png b/textures/throwing_crossbow.png old mode 100644 new mode 100755 index f8a400b..ab8504d Binary files a/textures/throwing_crossbow.png and b/textures/throwing_crossbow.png differ diff --git a/textures/throwing_crossbow_loaded.png b/textures/throwing_crossbow_loaded.png old mode 100644 new mode 100755 index 5d2b0c7..3b0ec5f Binary files a/textures/throwing_crossbow_loaded.png and b/textures/throwing_crossbow_loaded.png differ diff --git a/textures/throwing_empty.png b/textures/throwing_empty.png old mode 100644 new mode 100755 index 6bbd554..d0ff224 Binary files a/textures/throwing_empty.png and b/textures/throwing_empty.png differ diff --git a/textures/throwing_longbow.png b/textures/throwing_longbow.png old mode 100644 new mode 100755 index 7bdae2f..65dd3bd Binary files a/textures/throwing_longbow.png and b/textures/throwing_longbow.png differ diff --git a/textures/throwing_longbow_loaded.png b/textures/throwing_longbow_loaded.png old mode 100644 new mode 100755 index e03299a..df1ce7a Binary files a/textures/throwing_longbow_loaded.png and b/textures/throwing_longbow_loaded.png differ diff --git a/textures/throwing_sparkle.png b/textures/throwing_sparkle.png old mode 100644 new mode 100755 index 432786e..c5d952a Binary files a/textures/throwing_sparkle.png and b/textures/throwing_sparkle.png differ diff --git a/textures/throwing_sparkle_blue.png b/textures/throwing_sparkle_blue.png old mode 100644 new mode 100755 index d4710a3..d1897dd Binary files a/textures/throwing_sparkle_blue.png and b/textures/throwing_sparkle_blue.png differ diff --git a/textures/throwing_sparkle_red.png b/textures/throwing_sparkle_red.png old mode 100644 new mode 100755 index 59ec68c..e4b3d56 Binary files a/textures/throwing_sparkle_red.png and b/textures/throwing_sparkle_red.png differ diff --git a/textures/throwing_spear_box.png b/textures/throwing_spear_box.png deleted file mode 100644 index 628e171..0000000 Binary files a/textures/throwing_spear_box.png and /dev/null differ diff --git a/textures/throwing_spear_diamond.png b/textures/throwing_spear_diamond.png deleted file mode 100644 index 0e3bc18..0000000 Binary files a/textures/throwing_spear_diamond.png and /dev/null differ diff --git a/textures/throwing_spear_obsidian.png b/textures/throwing_spear_obsidian.png deleted file mode 100644 index cb7cec6..0000000 Binary files a/textures/throwing_spear_obsidian.png and /dev/null differ diff --git a/textures/throwing_spear_steel.png b/textures/throwing_spear_steel.png deleted file mode 100644 index 96a170e..0000000 Binary files a/textures/throwing_spear_steel.png and /dev/null differ diff --git a/textures/throwing_spear_stone.png b/textures/throwing_spear_stone.png deleted file mode 100644 index 78cb06e..0000000 Binary files a/textures/throwing_spear_stone.png and /dev/null differ diff --git a/textures/throwing_string_mithril.png b/textures/throwing_string_mithril.png new file mode 100644 index 0000000..3a5bf45 Binary files /dev/null and b/textures/throwing_string_mithril.png differ diff --git a/throwing.conf b/throwing.conf new file mode 100755 index 0000000..a5e61ba --- /dev/null +++ b/throwing.conf @@ -0,0 +1,39 @@ + +-- You can disable or disable any bow and arrow by writing lines like these inside throwing.conf + +-- Bows +DISABLE_WOODEN_BOW = false +DISABLE_LONGBOW = false +DISABLE_COMPOSITE_BOW = false +DISABLE_STEEL_BOW = false +DISABLE_ROYAL_BOW = false +DISABLE_MINOTAUR_HORN_BOW = false +DISABLE_MINOTAUR_HORN_IMPROVED_BOW = false + +-- Crossbows +DISABLE_CROSSBOW = false +DISABLE_ARBALEST = false +DISABLE_AUTOMATED_ARBALEST = false + +-- Arrow +-- Special Arrows +DISABLE_TELEPORT_ARROW = false +DISABLE_DIG_ARROW = false +DISABLE_BUILD_ARROW = false +DISABLE_TNT_ARROW = true -- Desactivated because too dangerous +DISABLE_FIRE_ARROW = true -- Desactivated because too dangerous +DISABLE_TORCH_ARROW = false +DISABLE_SHELL_ARROW = true -- Desactivated because haven't the dependencie + +-- Fireworks arrows +DISABLE_FIREWORKS_BLUE_ARROW = false +DISABLE_FIREWORKS_RED_ARROW = false + +-- Normal arrows +DISABLE_STONE_ARROW = false +DISABLE_STEEL_ARROW = false +DISABLE_OBSIDIAN_ARROW = false +DISABLE_DIAMOND_ARROW = false +DISABLE_MITHRIL_ARROW = false +-- lesser damages to better damages + diff --git a/throwing.conf.example b/throwing.conf.example old mode 100644 new mode 100755 diff --git a/tnt_arrow.lua b/tnt_arrow.lua old mode 100644 new mode 100755 index d0a4f7d..fcabda9 --- a/tnt_arrow.lua +++ b/tnt_arrow.lua @@ -18,7 +18,7 @@ minetest.register_node("throwing:arrow_tnt_box", { {7.5/17, -2.5/17, 2.5/17, 6.5/17, -1.5/17, 1.5/17}, {7.5/17, 2.5/17, -2.5/17, 6.5/17, 1.5/17, -1.5/17}, {6.5/17, -1.5/17, -1.5/17, 7.5/17, -2.5/17, -2.5/17}, - + {7.5/17, 2.5/17, 2.5/17, 8.5/17, 3.5/17, 3.5/17}, {8.5/17, -3.5/17, 3.5/17, 7.5/17, -2.5/17, 2.5/17}, {8.5/17, 3.5/17, -3.5/17, 7.5/17, 2.5/17, -2.5/17}, @@ -244,26 +244,24 @@ end -- Back to the arrow THROWING_ARROW_ENTITY.on_step = function(self, dtime) - self.timer=self.timer+dtime - local pos = self.object:getpos() - local node = minetest.get_node(pos) - - if self.timer>0.2 then - local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 2) - for k, obj in pairs(objs) do - if obj:get_luaentity() ~= nil then - if obj:get_luaentity().name ~= "throwing:arrow_tnt_entity" and obj:get_luaentity().name ~= "__builtin:item" then - self.object:remove() + local newpos = self.object:getpos() + 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}, 2) + for k, obj in pairs(objs) do + if throwing_is_player(self.player, obj) or throwing_is_entity(obj) then boom(pos) + self.object:remove() + return end end - end - end - if self.lastpos.x~=nil then - if node.name ~= "air" then - self.object:remove() - boom(self.lastpos) + if node.name ~= "air" then + boom(pos) + self.object:remove() + return + end end end self.lastpos={x=pos.x, y=pos.y, z=pos.z} diff --git a/tools.lua b/tools.lua old mode 100644 new mode 100755 index 57ef85c..9489bd4 --- a/tools.lua +++ b/tools.lua @@ -1,5 +1,5 @@ if not DISABLE_WOODEN_BOW then - throwing_register_bow ('bow_wood', 'Wooden bow', {x=1, y=1, z=0.5}, 11, 0.8, 50, false, { + throwing_register_bow ('bow_wood', 'Wooden bow', {x=1, y=1, z=0.5}, 11, 1.6, 50, false, { {'', 'default:stick', ''}, {'farming:string', '', 'default:stick'}, {'', 'default:stick', ''}, @@ -7,7 +7,7 @@ if not DISABLE_WOODEN_BOW then end if not DISABLE_LONGBOW then - throwing_register_bow ('longbow', 'Longbow', {x=1, y=2.5, z=0.5}, 17, 1.8, 100, false, { + throwing_register_bow ('longbow', 'Longbow', {x=1, y=2.5, z=0.5}, 17, 1.5, 100, false, { {'farming:string', 'group:wood', ''}, {'farming:string', '', 'group:wood'}, {'farming:string', 'group:wood', ''}, @@ -15,7 +15,7 @@ if not DISABLE_LONGBOW then end if not DISABLE_COMPOSITE_BOW then - throwing_register_bow ('bow_composite', 'Composite bow', {x=1, y=1.4, z=0.5}, 17, 1, 150, false, { + throwing_register_bow ('bow_composite', 'Composite bow', {x=1, y=1.4, z=0.5}, 17, 2, 150, false, { {'farming:string', 'group:wood', ''}, {'farming:string', '', 'default:steel_ingot'}, {'farming:string', 'group:wood', ''}, @@ -23,7 +23,7 @@ if not DISABLE_COMPOSITE_BOW then end if not DISABLE_STEEL_BOW then - throwing_register_bow ('bow_steel', 'Steel bow', {x=1, y=1.4, z=0.5}, 20, 1.3, 250, false, { + throwing_register_bow ('bow_steel', 'Steel bow', {x=1, y=1.4, z=0.5}, 20, 1.4, 250, false, { {'farming:string', 'default:steel_ingot', ''}, {'farming:string', '', 'default:steel_ingot'}, {'farming:string', 'default:steel_ingot', ''}, @@ -31,13 +31,29 @@ if not DISABLE_STEEL_BOW then end if not DISABLE_ROYAL_BOW then - throwing_register_bow ('bow_royal', 'Royal bow', {x=1, y=1.5, z=0.5}, 18, 1.4, 750, false, { + throwing_register_bow ('bow_royal', 'Royal bow', {x=1, y=1.5, z=0.5}, 25, 1.3, 750, false, { {'farming:string', 'group:wood', 'default:diamond'}, {'farming:string', '', 'default:gold_ingot'}, {'farming:string', 'group:wood', 'default:diamond'}, }) end +--function throwing_register_bow (name, desc, scale, stiffness, reload_time, toughness, is_cross, craft) +if not DISABLE_MINOTAUR_HORN_BOW then + throwing_register_bow ('bow_minotaur_horn', 'Minotaur Horn Bow (Hunter)', {x=1, y=1.5, z=0.5}, 35, 1.2, 1000, false, { + {'farming:string', 'mobs:minotaur_horn', 'mobs:minotaur_horn'}, + {'farming:string', '', 'default:mithril_ingot'}, + {'farming:string', 'mobs:minotaur_horn', 'mobs:minotaur_horn'}, + }) +end + +--function throwing_register_bow (name, desc, scale, stiffness, reload_time, toughness, is_cross, craft) +if not DISABLE_MINOTAUR_HORN_IMPROVED_BOW then + throwing_register_bow ('bow_minotaur_horn_improved', 'Minotaur Horn Improved Bow (Hunter)', {x=1, y=1.5, z=0.5}, 50, 1.5, 2000, false, { + {'throwing:bow_minotaur_horn', 'throwing:string_mithril'}, + }) +end + if not DISABLE_CROSSBOW then throwing_register_bow ('crossbow', 'Crossbow', {x=1, y=1.3, z=0.5}, 28, 5, 80, true, { {'group:wood', 'farming:string', ''}, diff --git a/torch_arrow.lua b/torch_arrow.lua old mode 100644 new mode 100755 index 0de170a..50899cf --- a/torch_arrow.lua +++ b/torch_arrow.lua @@ -18,7 +18,7 @@ minetest.register_node("throwing:arrow_torch_box", { {7.5/17, -2.5/17, 2.5/17, 6.5/17, -1.5/17, 1.5/17}, {7.5/17, 2.5/17, -2.5/17, 6.5/17, 1.5/17, -1.5/17}, {6.5/17, -1.5/17, -1.5/17, 7.5/17, -2.5/17, -2.5/17}, - + {7.5/17, 2.5/17, 2.5/17, 8.5/17, 3.5/17, 3.5/17}, {8.5/17, -3.5/17, 3.5/17, 7.5/17, -2.5/17, 2.5/17}, {8.5/17, 3.5/17, -3.5/17, 7.5/17, 2.5/17, -2.5/17}, @@ -31,31 +31,71 @@ minetest.register_node("throwing:arrow_torch_box", { local THROWING_ARROW_ENTITY={ physical = false, - timer=0, visual = "wielditem", visual_size = {x=0.1, y=0.1}, textures = {"throwing:arrow_torch_box"}, lastpos={}, collisionbox = {0,0,0,0,0,0}, node = "", + player = "", + bow_damage = 0, } THROWING_ARROW_ENTITY.on_step = function(self, dtime) - self.timer=self.timer+dtime - local pos = self.object:getpos() - local node = minetest.get_node(pos) + local newpos = self.object:getpos() + 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}, 0.5) + for k, obj in pairs(objs) do + local objpos = obj:getpos() + if throwing_is_player(self.player, obj) or throwing_is_entity(obj) then + if throwing_touch(pos, objpos) then + local puncher = self.object + if self.player and minetest.get_player_by_name(self.player) then + puncher = minetest.get_player_by_name(self.player) + end + local damage = 0.5 + if self.bow_damage and self.bow_damage > 0 then + damage = damage + (self.bow_damage/12) + end + obj:punch(puncher, 1.0, { + full_punch_interval=1.0, + damage_groups={fleshy=damage}, + }, nil) + local toughness = 0.9 + if math.random() < toughness then + if math.random(0,100) % 2 == 0 then -- 50% of chance to drop //MFF (Mg|07/27/15) + minetest.add_item(pos, 'throwing:arrow_torch') + end + else + minetest.add_item(pos, 'default:stick') + end + self.object:remove() + return + end + end + end - if self.timer>0.2 then - local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 0.5) - for k, obj in pairs(objs) do - if obj:get_luaentity() ~= nil then - if obj:get_luaentity().name ~= "throwing:arrow_torch_entity" and obj:get_luaentity().name ~= "__builtin:item" then - local damage = 0.5 - obj:punch(self.object, 1.0, { - full_punch_interval=1.0, - damage_groups={fleshy=damage}, - }, nil) - self.object:remove() + + if node.name == 'air' then + minetest.add_node(pos, {name="throwing:torch_trail"}) + minetest.get_node_timer(pos):start(0.1) + elseif node.name ~= "air" + and not string.find(node.name, "trail") + and not (string.find(node.name, 'grass') and not string.find(node.name, 'dirt')) + and not (string.find(node.name, 'farming:') and not string.find(node.name, 'soil')) + and not string.find(node.name, 'flowers:') + and not string.find(node.name, 'fire:') then + local player = minetest.get_player_by_name(self.player) + if not player then self.object:remove() return end + if node.name ~= "ignore" and 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 wall=minetest.dir_to_wallmounted(dir) + minetest.add_node(self.lastpos, {name="default:torch", param2 = wall}) + else local toughness = 0.9 if math.random() < toughness then minetest.add_item(self.lastpos, 'throwing:arrow_torch') @@ -63,31 +103,13 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime) minetest.add_item(self.lastpos, 'default:stick') end end + self.object:remove() + return end + self.lastpos={x=pos.x, y=pos.y, z=pos.z} end end - - if self.lastpos.x~=nil then - if node.name == 'air' then - minetest.add_node(pos, {name="throwing:torch_trail"}) - minetest.get_node_timer(pos):start(0.1) - elseif node.name ~= "air" and not string.find(node.name, "trail") then - self.object:remove() - if not string.find(node.name, "water") and not string.find(node.name, "lava") and not string.find(node.name, "torch") then - local dir=vector.direction(self.lastpos, pos) - local wall=minetest.dir_to_wallmounted(dir) - minetest.add_node(self.lastpos, {name="default:torch", param2 = wall}) - else - local toughness = 0.9 - if math.random() < toughness then - minetest.add_item(self.lastpos, 'throwing:arrow_torch') - else - minetest.add_item(self.lastpos, 'default:stick') - end - end - end - end - self.lastpos={x=pos.x, y=pos.y, z=pos.z} + self.lastpos={x=newpos.x, y=newpos.y, z=newpos.z} end minetest.register_entity("throwing:arrow_torch_entity", THROWING_ARROW_ENTITY)