diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/depends.txt b/depends.txt index db178d1..a4d5560 100755 --- a/depends.txt +++ b/depends.txt @@ -4,3 +4,5 @@ dye bucket? fire? tnt? +moreores? +lightning? diff --git a/dig_arrow.lua b/dig_arrow.lua index 0a676b5..3cdd689 100755 --- a/dig_arrow.lua +++ b/dig_arrow.lua @@ -29,6 +29,27 @@ minetest.register_node("throwing:arrow_dig_box", { groups = {not_in_creative_inventory=1}, }) +local function addEffect(pos, node) + minetest.sound_play("default_dug_node", {pos=pos, gain=1, max_hear_distance=2*64}) + texture=minetest.registered_nodes[node.name].tiles[1] + minetest.add_particlespawner({ + amount = 16, + time = 0.1, + minpos = pos, + maxpos = pos, + minvel = {x = -5, y = -5, z = -5}, + maxvel = {x = 5, y = 5, z = 5}, + minacc = {x = 0, y = -8, z = 0}, + maxacc = {x = 0, y = -8, z = 0}, + minexptime = 0.8, + maxexptime = 2.0, + minsize = 4, + maxsize = 6, + texture = texture, + collisiondetection = true, + }) +end + local THROWING_ARROW_ENTITY={ physical = false, timer=0, @@ -51,19 +72,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime) 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) + if math.random(0,100) % 1.1 == 0 then -- chance to drop minetest.add_item(pos, "throwing:arrow_dig") end self.object:remove() @@ -80,7 +89,8 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime) 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"}) + addEffect(pos, node) + minetest.dig_node(pos) minetest.add_item(pos, node.name) end self.object:remove() diff --git a/fire_arrow.lua b/fire_arrow.lua index 424d81c..bc40246 100755 --- a/fire_arrow.lua +++ b/fire_arrow.lua @@ -37,7 +37,6 @@ local THROWING_ARROW_ENTITY={ lastpos={}, collisionbox = {0,0,0,0,0,0}, player = "", - bow_damage = 0, } THROWING_ARROW_ENTITY.on_step = function(self, dtime) @@ -54,10 +53,8 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime) 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 + local speed = vector.length(self.object:getvelocity()) + local damage = ((speed + 15)^1.2)/10 obj:punch(puncher, 1.0, { full_punch_interval=1.0, damage_groups={fleshy=damage}, diff --git a/fireworks_arrows.lua b/fireworks_arrows.lua index 167f8b8..8efc2c1 100755 --- a/fireworks_arrows.lua +++ b/fireworks_arrows.lua @@ -1,4 +1,4 @@ -local function throwing_register_fireworks(color, desc) +local function throwing_register_fireworks(color, color2, desc) minetest.register_craftitem("throwing:arrow_fireworks_" .. color, { description = desc .. "fireworks arrow", inventory_image = "throwing_arrow_fireworks_" .. color .. ".png", @@ -26,7 +26,7 @@ local function throwing_register_fireworks(color, desc) {7.5/17, -2.5/17, -2.5/17, 8.5/17, -3.5/17, -3.5/17}, } }, - 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"}, + 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}, }) @@ -39,7 +39,6 @@ local function throwing_register_fireworks(color, desc) lastpos={}, collisionbox = {0,0,0,0,0,0}, player = "", - bow_damage = 0, } local radius = 0.5 @@ -47,18 +46,37 @@ local function throwing_register_fireworks(color, desc) local function add_effects(pos, radius) minetest.add_particlespawner({ amount = 256, - time = 0.2, + time = 0.1, minpos = vector.subtract(pos, radius / 2), maxpos = vector.add(pos, radius / 2), - minvel = {x=-5, y=-5, z=-5}, - maxvel = {x=5, y=5, z=5}, + minvel = {x=-15, y=-15, z=-15}, + maxvel = {x=15, y=15, z=15}, minacc = {x=0, y=-8, z=0}, --~ maxacc = {x=-20, y=-50, z=-50}, minexptime = 2.5, maxexptime = 3, - minsize = 1, - maxsize = 2.5, + minsize = 3, + maxsize = 6, texture = "throwing_sparkle_" .. color .. ".png", + glow=15, + collisiondetection = true, + }) + minetest.add_particlespawner({ + amount = 256, + time = 0.1, + minpos = vector.subtract(pos, radius / 2), + maxpos = vector.add(pos, radius / 2), + minvel = {x=-15, y=-15, z=-15}, + maxvel = {x=15, y=15, z=15}, + minacc = {x=0, y=-8, z=0}, + --~ maxacc = {x=-20, y=-50, z=-50}, + minexptime = 2.5, + maxexptime = 3, + minsize = 3, + maxsize = 6, + texture = "throwing_sparkle_" .. color2 .. ".png", + glow=15, + collisiondetection = true, }) end @@ -77,12 +95,12 @@ local function throwing_register_fireworks(color, desc) THROWING_ARROW_ENTITY.on_step = function(self, dtime) self.timer=self.timer+dtime local newpos = self.object:getpos() - if self.timer < 0.07 then - minetest.sound_play("throwing_firework_launch", {pos=newpos, gain=0.8, max_hear_distance=2*64}) + if self.timer < 0.15 then + minetest.sound_play("throwing_firework_launch", {pos=newpos, gain=1, max_hear_distance=2*64}) end minetest.add_particlespawner({ - amount = 16, - time = 0.1, + amount = 32, + time = 0.2, minpos = newpos, maxpos = newpos, minvel = {x=-5, y=-5, z=-5}, @@ -94,17 +112,20 @@ local function throwing_register_fireworks(color, desc) minsize = 0.5, maxsize = 1, texture = "throwing_sparkle.png", + glow=10 }) 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) + local speed = vector.length(self.object:getvelocity()) + local damage = ((speed + 15)^1.2)/10 + 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 - obj:punch(self.object, 1.0, { + obj:punch(puncher, 1.0, { full_punch_interval=1.0, damage_groups={fleshy=damage}, }, nil) @@ -149,11 +170,15 @@ end --~ Arrows if not DISABLE_FIREWORKS_BLUE_ARROW then - throwing_register_fireworks('blue', 'Blue') + throwing_register_fireworks('blue', 'magenta', 'Blue') end if not DISABLE_FIREWORKS_RED_ARROW then - throwing_register_fireworks('red', 'Red') + throwing_register_fireworks('red', 'orange', 'Red') +end + +if not DISABLE_FIREWORKS_GREEN_ARROW then + throwing_register_fireworks('green', 'cyan', 'Green') end --~ Nodes diff --git a/init.lua b/init.lua index 162af8e..fe07f41 100755 --- a/init.lua +++ b/init.lua @@ -3,15 +3,18 @@ throwing_arrows = { {"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"}, {"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_shell", "throwing:arrow_shell_entity"}, - {"throwing:arrow_fireworks_blue", "throwing:arrow_fireworks_blue_entity"}, {"throwing:arrow_fireworks_red", "throwing:arrow_fireworks_red_entity"}, + {"throwing:arrow_fireworks_blue", "throwing:arrow_fireworks_blue_entity"}, + {"throwing:arrow_fireworks_green", "throwing:arrow_fireworks_green_entity"}, + {"throwing:arrow_rope", "throwing:arrow_rope_entity"}, + {"throwing:arrow_lightning", "throwing:arrow_lightning_entity"}, } dofile(minetest.get_modpath("throwing").."/defaults.lua") @@ -29,7 +32,6 @@ dofile(minetest.get_modpath("throwing").."/tools.lua") dofile(minetest.get_modpath("throwing").."/standard_arrows.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") end @@ -46,7 +48,7 @@ if not DISABLE_BUILD_ARROW then dofile(minetest.get_modpath("throwing").."/build_arrow.lua") end -if minetest.get_modpath('fire') and minetest.get_modpath('tnt') and not DISABLE_TNT_ARROW then +if minetest.get_modpath('tnt') and not DISABLE_TNT_ARROW then dofile(minetest.get_modpath("throwing").."/tnt_arrow.lua") end @@ -54,10 +56,6 @@ if not DISABLE_TORCH_ARROW then dofile(minetest.get_modpath("throwing").."/torch_arrow.lua") end -if minetest.get_modpath('tnt') and not DISABLE_SHELL_ARROW then - dofile(minetest.get_modpath("throwing").."/shell_arrow.lua") -end - if minetest.get_modpath('tnt') then dofile(minetest.get_modpath("throwing").."/fireworks_arrows.lua") end @@ -65,3 +63,11 @@ end if minetest.setting_get("log_mods") then minetest.log("action", "throwing loaded") end + +if minetest.get_modpath('vines') and not DISABLE_ROPE_ARROW then + dofile(minetest.get_modpath("throwing").."/rope_arrow.lua") +end + +if minetest.get_modpath('lightning') and not DISABLE_LIGHTNING_ARROW then + dofile(minetest.get_modpath("throwing").."/lightning_arrow.lua") +end diff --git a/lightning_arrow.lua b/lightning_arrow.lua new file mode 100755 index 0000000..51f801d --- /dev/null +++ b/lightning_arrow.lua @@ -0,0 +1,169 @@ +minetest.register_craftitem("throwing:arrow_lightning", { + description = "Lightning Arrow", + inventory_image = "throwing_arrow_lightning.png", +}) + +minetest.register_node("throwing:arrow_lightning_box", { + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + -- Shaft + {-6.5/17, -1.5/17, -1.5/17, 6.5/17, 1.5/17, 1.5/17}, + --Spitze + {-4.5/17, 2.5/17, 2.5/17, -3.5/17, -2.5/17, -2.5/17}, + {-8.5/17, 0.5/17, 0.5/17, -6.5/17, -0.5/17, -0.5/17}, + --Federn + {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, 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_lightning.png", "throwing_arrow_lightning.png", "throwing_arrow_lightning_back.png", "throwing_arrow_lightning_front.png", "throwing_arrow_lightning_2.png", "throwing_arrow_lightning.png"}, + groups = {not_in_creative_inventory=1}, +}) + +local function addEffect(pos, node) + if minetest.registered_nodes[node.name].tiles~=nil then + texture = minetest.registered_nodes[node.name].tiles[1] + minetest.add_particlespawner({ + amount = 32, + time = 0.1, + minpos = pos, + maxpos = pos, + minvel = {x = -5, y = 0, z = -5}, + maxvel = {x = 5, y = 30, z = 5}, + minacc = {x = 0, y = -8, z = 0}, + maxacc = {x = 0, y = -8, z = 0}, + minexptime = 0.8, + maxexptime = 2.0, + minsize = 4, + maxsize = 6, + texture = texture, + collisiondetection = true, + }) + end +end + +local function addSmoke(pos) +minetest.add_particle({ + pos = pos, + velocity = vector.new(), + acceleration = vector.new(), + expirationtime = 0.4, + size = 50, + collisiondetection = false, + vertical = false, + texture = "tnt_boom.png", + glow = 15, + }) +minetest.add_particlespawner({ + amount = 32, + time = 0.5, + minpos = pos, + maxpos = pos, + minvel = {x = -10, y = -10, z = -10}, + maxvel = {x = 10, y = 10, z = 10}, + minacc = {x = 0, y = 4, z = 0}, + maxacc = {x = 0, y = 4, z = 0}, + minexptime = 1, + maxexptime = 2.5, + minsize = 6, + maxsize = 9, + texture = "tnt_smoke.png", + collisiondetection = true, + glow=5, + }) +end + +local THROWING_ARROW_ENTITY={ + physical = false, + timer=0, + visual = "wielditem", + visual_size = {x=0.1, y=0.1}, + textures = {"throwing:arrow_lightning_box"}, + lastpos={}, + collisionbox = {0,0,0,0,0,0}, + player = "", + bow_damage = 0, +} + + +THROWING_ARROW_ENTITY.on_step = function(self, dtime) + local newpos = self.object:getpos() + minetest.add_particlespawner({ + amount = 16, + time = 0.1, + minpos = newpos, + maxpos = newpos, + minvel = {x=-5+math.random(-5,5), y=-5+math.random(-5,5), z=-5+math.random(-5,5)}, + maxvel = {x=5+math.random(-5,5), y=5+math.random(-5,5), z=5+math.random(-5,5)}, + minacc = vector.new(), + maxacc = {x=5+math.random(-5,5), y=5+math.random(-5,5), z=5+math.random(-5,5)}, + minexptime = 0.1, + maxexptime = 0.2, + minsize = 0.5, + maxsize = 1, + texture = "throwing_sparkle_blue.png", + glow=10 + }) + 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 speed = vector.length(self.object:getvelocity()) + local damage = ((speed + 10)^1.2)/10 + obj:punch(puncher, 1.0, { + full_punch_interval=1.0, + damage_groups={fleshy=damage}, + }, nil) + lightning.strike(newpos) + minetest.sound_play("tnt_explode", {pos=newpos, gain=1, max_hear_distance=2*64}) + addSmoke(newpos) + self.object:remove() + return + end + end + end + if node.name ~= "air" then + lightning.strike(newpos) + minetest.sound_play("tnt_explode", {pos=newpos, gain=1, max_hear_distance=2*64}) + addEffect(newpos, node) + addSmoke(newpos) + self.object:remove() + return + end + self.lastpos={x=pos.x, y=pos.y, z=pos.z} + end + end + self.lastpos={x=newpos.x, y=newpos.y, z=newpos.z} +end + +minetest.register_entity("throwing:arrow_lightning_entity", THROWING_ARROW_ENTITY) + +minetest.register_craft({ + output = 'throwing:arrow_lightning', + recipe = { + {'default:stick', 'default:stick', 'default:pick_steel'}, + } +}) + +minetest.register_craft({ + output = 'throwing:arrow_lightning', + recipe = { + {'default:pick_steel', 'default:stick', 'default:stick'}, + } +}) diff --git a/rope_arrow.lua b/rope_arrow.lua new file mode 100755 index 0000000..4bb10d2 --- /dev/null +++ b/rope_arrow.lua @@ -0,0 +1,141 @@ +minetest.register_craftitem("throwing:arrow_rope", { + description = "Rope Arrow", + inventory_image = "throwing_arrow_rope.png", +}) + +minetest.register_node("throwing:arrow_rope_box", { + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + -- Shaft + {-6.5/17, -1.5/17, -1.5/17, 6.5/17, 1.5/17, 1.5/17}, + --Spitze + {-4.5/17, 2.5/17, 2.5/17, -3.5/17, -2.5/17, -2.5/17}, + {-8.5/17, 0.5/17, 0.5/17, -6.5/17, -0.5/17, -0.5/17}, + --Federn + {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, 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_rope.png", "throwing_arrow_rope.png", "throwing_arrow_rope_back.png", "throwing_arrow_rope_front.png", "throwing_arrow_rope_2.png", "throwing_arrow_rope.png"}, + groups = {not_in_creative_inventory=1}, +}) + +local THROWING_ARROW_ENTITY={ + physical = false, + visual = "wielditem", + visual_size = {x=0.1, y=0.1}, + textures = {"throwing:arrow_rope"}, + lastpos={}, + collisionbox = {0,0,0,0,0,0}, + node = "", + player = "", +} +local function addEffect(pos, node) + minetest.sound_play("default_dug_metal", {pos=pos, gain=1, max_hear_distance=2*64}) + texture=minetest.registered_nodes[node.name].tiles[1] + minetest.add_particlespawner({ + amount = 16, + time = 0.1, + minpos = pos, + maxpos = pos, + minvel = {x = -5, y = -5, z = -5}, + maxvel = {x = 5, y = 5, z = 5}, + minacc = {x = 0, y = -8, z = 0}, + maxacc = {x = 0, y = -8, z = 0}, + minexptime = 0.8, + maxexptime = 2.0, + minsize = 4, + maxsize = 6, + texture = texture, + collisiondetection = true, + }) +end + +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 + 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 speed = vector.length(self.object:getvelocity()) + local damage = ((speed + 5)^1.2)/10 + 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 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 + addEffect(self.lastpos, node) + minetest.place_node(self.lastpos, {name="vines:rope_block"}) + else + local toughness = 0.9 + if math.random() < toughness then + minetest.add_item(self.lastpos, 'throwing:arrow_rope') + else + 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 + self.lastpos={x=newpos.x, y=newpos.y+1, z=newpos.z} +end + +minetest.register_entity("throwing:arrow_rope_entity", THROWING_ARROW_ENTITY) + +minetest.register_craft({ + output = 'throwing:arrow_rope 4', + recipe = { + {'default:stick', 'default:stick', 'group:coal'}, + } +}) + +minetest.register_craft({ + output = 'throwing:arrow_rope 4', + recipe = { + {'group:coal', 'default:stick', 'default:stick'}, + } +}) diff --git a/shell_arrow.lua b/shell_arrow.lua deleted file mode 100755 index f652a6b..0000000 --- a/shell_arrow.lua +++ /dev/null @@ -1,126 +0,0 @@ -minetest.register_craftitem("throwing:arrow_shell", { - description = "Shell arrow", - inventory_image = "throwing_arrow_shell.png", -}) - -minetest.register_node("throwing:arrow_shell_box", { - drawtype = "nodebox", - node_box = { - type = "fixed", - fixed = { - -- Shaft - {-6.5/17, -1.5/17, -1.5/17, 6.5/17, 1.5/17, 1.5/17}, - --Spitze - {-4.5/17, 2.5/17, 2.5/17, -3.5/17, -2.5/17, -2.5/17}, - {-8.5/17, 0.5/17, 0.5/17, -6.5/17, -0.5/17, -0.5/17}, - --Federn - {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, 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_shell.png", "throwing_arrow_shell.png", "throwing_arrow_shell_back.png", "throwing_arrow_shell_front.png", "throwing_arrow_shell_2.png", "throwing_arrow_shell.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_shell_box"}, - lastpos={}, - collisionbox = {0,0,0,0,0,0}, - player = "", - bow_damage = 0, -} - -local radius = 1 - -local function add_effects(pos, radius) - minetest.add_particlespawner({ - amount = 8, - time = 0.5, - minpos = vector.subtract(pos, radius / 2), - maxpos = vector.add(pos, radius / 2), - minvel = {x=-10, y=-10, z=-10}, - maxvel = {x=10, y=10, z=10}, - minacc = vector.new(), - maxacc = vector.new(), - minexptime = 0.5, - maxexptime = 1, - minsize = 0.5, - maxsize = 1, - texture = "tnt_smoke.png", - }) -end - - -local function boom(pos) - minetest.sound_play("shell_explode", {pos=pos, gain=1.5, max_hear_distance=2*64}) - minetest.set_node(pos, {name="tnt:boom"}) - minetest.get_node_timer(pos):start(0.1) - add_effects(pos, radius) -end - --- Back to the arrow - -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}, 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) - boom(pos) - self.object:remove() - return - end - end - - 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=newpos.x, y=newpos.y, z=newpos.z} -end - -minetest.register_entity("throwing:arrow_shell_entity", THROWING_ARROW_ENTITY) - -minetest.register_craft({ - output = 'throwing:arrow_shell 8', - recipe = { - {'default:stick', 'tnt:gunpowder', 'default:bronze_ingot'}, - } -}) - -minetest.register_craft({ - output = 'throwing:arrow_shell 8', - recipe = { - {'default:bronze_ingot', 'tnt:gunpowder', 'default:stick'}, - } -}) diff --git a/sounds/help.ogg b/sounds/help.ogg new file mode 100755 index 0000000..be4344c Binary files /dev/null and b/sounds/help.ogg differ diff --git a/standard_arrows.lua b/standard_arrows.lua index 8ac6a99..bc60c83 100755 --- a/standard_arrows.lua +++ b/standard_arrows.lua @@ -31,6 +31,28 @@ function throwing_register_arrow_standard (kind, desc, eq, toughness, craft) groups = {not_in_creative_inventory=1}, }) +local function add_effects(pos, node) + minetest.sound_play("default_dug_metal", {pos=pos, gain=1, max_hear_distance=2*64}) + if minetest.registered_nodes[node.name].tiles~=nil then + texture = minetest.registered_nodes[node.name].tiles[1] + minetest.add_particlespawner({ + amount = 8, + time = 0.1, + minpos = pos, + maxpos = pos, + minvel = {x = -2, y = -2, z = -2}, + maxvel = {x = 2, y = 2, z = 2}, + minacc = {x = 0, y = -8, z = 0}, + maxacc = {x = 0, y = -8, z = 0}, + minexptime = 0.8, + maxexptime = 2.0, + minsize = 1, + maxsize = 3, + texture = texture, + collisiondetection = true, + }) + end +end local THROWING_ARROW_ENTITY={ physical = false, visual = "wielditem", @@ -39,7 +61,6 @@ function throwing_register_arrow_standard (kind, desc, eq, toughness, craft) lastpos={}, collisionbox = {0,0,0,0,0,0}, player = "", - bow_damage = 0, } THROWING_ARROW_ENTITY.on_step = function(self, dtime) @@ -56,14 +77,13 @@ function throwing_register_arrow_standard (kind, desc, eq, toughness, craft) 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 + local speed = vector.length(self.object:getvelocity()) + local damage = ((speed + eq)^1.2)/10 obj:punch(puncher, 1.0, { full_punch_interval=1.0, damage_groups={fleshy=damage}, }, nil) + minetest.sound_play("default_dug_metal", {pos=objpos, gain=1, max_hear_distance=2*64}) if math.random() < toughness then if math.random(0,100) % 2 == 0 then minetest.add_item(self.lastpos, 'throwing:arrow_' .. kind) @@ -82,6 +102,7 @@ function throwing_register_arrow_standard (kind, desc, eq, toughness, craft) 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 + add_effects(self.lastpos, node) if math.random() < toughness then minetest.add_item(self.lastpos, 'throwing:arrow_' .. kind) else @@ -114,18 +135,21 @@ function throwing_register_arrow_standard (kind, desc, eq, toughness, craft) end if not DISABLE_STONE_ARROW then - throwing_register_arrow_standard ('stone', 'Stone', 4, 0.40, 'group:stone') + throwing_register_arrow_standard ('stone', 'Stone', 5, 0.10, 'group:stone') end if not DISABLE_STEEL_ARROW then - throwing_register_arrow_standard ('steel', 'Steel', 5, 0.50, 'default:steel_ingot') + throwing_register_arrow_standard ('steel', 'Steel', 10, 0.80, 'default:steel_ingot') end if not DISABLE_OBSIDIAN_ARROW then - throwing_register_arrow_standard ('obsidian', 'Obsidian', 6, 0.60, 'default:obsidian') + throwing_register_arrow_standard ('obsidian', 'Obsidian', 15, 0.20, 'default:obsidian') end if not DISABLE_DIAMOND_ARROW then - throwing_register_arrow_standard ('diamond', 'Diamond', 7, 0.70, 'default:diamond') + throwing_register_arrow_standard ('diamond', 'Diamond', 20, 0.40, 'default:diamond') end +if minetest.get_modpath('moreores') and not DISABLE_MITHRIL_ARROW then + throwing_register_arrow_standard ('mithril', 'Mithril', 30, 0.86, 'moreores:mithril_ingot') +end diff --git a/teleport_arrow.lua b/teleport_arrow.lua index 927681f..02f8ec6 100755 --- a/teleport_arrow.lua +++ b/teleport_arrow.lua @@ -37,11 +37,46 @@ local THROWING_ARROW_ENTITY={ lastpos={}, collisionbox = {0,0,0,0,0,0}, player = "", - bow_damage = 0, } +local function add_effects(pos, radius) + minetest.sound_play("throwing_firework_boom", {pos=pos, gain=1, max_hear_distance=2*64}) + minetest.add_particlespawner({ + amount = 128, + time = 0.1, + minpos = vector.subtract(pos, radius / 2), + maxpos = vector.add(pos, radius / 2), + minvel = {x=-5, y=-5, z=-5}, + maxvel = {x=5, y=5, z=5}, + minacc = {x=0, y=0, z=0}, + --~ maxacc = {x=-20, y=-50, z=-50}, + minexptime = 2.5, + maxexptime = 3, + minsize = 2, + maxsize = 4, + texture = "particle_teleport.png", + glow=10, + }) + end THROWING_ARROW_ENTITY.on_step = function(self, dtime) local newpos = self.object:getpos() + + minetest.add_particlespawner({ + amount = 16, + time = 0.1, + minpos = newpos, + maxpos = newpos, + minvel = {x = -math.random(0,2), y = -math.random(0,2), z = -math.random(0,2)}, + maxvel = {x = math.random(0,2), y = math.random(0,2), z = math.random(0,2)}, + minacc = {x=0, y=0, z=0}, + --~ maxacc = {x=-20, y=-50, z=-50}, + minexptime = 2.5, + maxexptime = 3, + minsize = 0.5, + maxsize = 1.3, + texture = "particle_teleport.png", + glow=5, + }) if self.lastpos.x ~= nil then for _, pos in pairs(throwing_get_trajectoire(self, newpos)) do local node = minetest.get_node(pos) @@ -52,6 +87,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime) local player = minetest.get_player_by_name(self.player) if player then player:setpos(self.lastpos) + add_effects(self.lastpos, 5) end end self.object:remove() @@ -68,6 +104,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime) local player = minetest.get_player_by_name(self.player) if player then player:setpos(self.lastpos) + add_effects(self.lastpos, 5) end end self.object:remove() @@ -84,13 +121,13 @@ minetest.register_entity("throwing:arrow_teleport_entity", THROWING_ARROW_ENTITY minetest.register_craft({ output = 'throwing:arrow_teleport', recipe = { - {'default:stick', 'default:stick', 'default:mese_crystal_fragment'} + {'default:stick', 'default:stick', 'default:mese_crystal'} } }) minetest.register_craft({ output = 'throwing:arrow_teleport', recipe = { - {'default:mese_crystal_fragment', 'default:stick', 'default:stick'} + {'default:mese_crystal', 'default:stick', 'default:stick'} } }) diff --git a/textures/.directory b/textures/.directory old mode 100644 new mode 100755 diff --git a/textures/compound_bow.xcf b/textures/compound_bow.xcf new file mode 100755 index 0000000..0540c82 Binary files /dev/null and b/textures/compound_bow.xcf differ diff --git a/textures/compound_bow_unload.xcf b/textures/compound_bow_unload.xcf new file mode 100755 index 0000000..7ded188 Binary files /dev/null and b/textures/compound_bow_unload.xcf differ diff --git a/textures/particle_teleport.png b/textures/particle_teleport.png new file mode 100755 index 0000000..3a45d15 Binary files /dev/null and b/textures/particle_teleport.png differ diff --git a/textures/repeater_crossbow.xcf b/textures/repeater_crossbow.xcf new file mode 100755 index 0000000..34d35bd Binary files /dev/null and b/textures/repeater_crossbow.xcf differ diff --git a/textures/throwing_arbalest.png b/textures/throwing_arbalest.png old mode 100644 new mode 100755 diff --git a/textures/throwing_arbalest_auto.png b/textures/throwing_arbalest_auto.png old mode 100644 new mode 100755 diff --git a/textures/throwing_arbalest_auto_loaded.png b/textures/throwing_arbalest_auto_loaded.png old mode 100644 new mode 100755 diff --git a/textures/throwing_arbalest_loaded.png b/textures/throwing_arbalest_loaded.png old mode 100644 new mode 100755 diff --git a/textures/throwing_arrow_build.png b/textures/throwing_arrow_build.png old mode 100644 new mode 100755 diff --git a/textures/throwing_arrow_build_2.png b/textures/throwing_arrow_build_2.png old mode 100644 new mode 100755 diff --git a/textures/throwing_arrow_build_back.png b/textures/throwing_arrow_build_back.png old mode 100644 new mode 100755 diff --git a/textures/throwing_arrow_build_front.png b/textures/throwing_arrow_build_front.png old mode 100644 new mode 100755 diff --git a/textures/throwing_arrow_diamond.png b/textures/throwing_arrow_diamond.png old mode 100644 new mode 100755 diff --git a/textures/throwing_arrow_diamond_2.png b/textures/throwing_arrow_diamond_2.png old mode 100644 new mode 100755 diff --git a/textures/throwing_arrow_diamond_back.png b/textures/throwing_arrow_diamond_back.png old mode 100644 new mode 100755 diff --git a/textures/throwing_arrow_diamond_front.png b/textures/throwing_arrow_diamond_front.png old mode 100644 new mode 100755 diff --git a/textures/throwing_arrow_dig.png b/textures/throwing_arrow_dig.png old mode 100644 new mode 100755 diff --git a/textures/throwing_arrow_dig_2.png b/textures/throwing_arrow_dig_2.png old mode 100644 new mode 100755 diff --git a/textures/throwing_arrow_dig_back.png b/textures/throwing_arrow_dig_back.png old mode 100644 new mode 100755 diff --git a/textures/throwing_arrow_dig_front.png b/textures/throwing_arrow_dig_front.png old mode 100644 new mode 100755 diff --git a/textures/throwing_arrow_fire.png b/textures/throwing_arrow_fire.png old mode 100644 new mode 100755 diff --git a/textures/throwing_arrow_fire_2.png b/textures/throwing_arrow_fire_2.png old mode 100644 new mode 100755 diff --git a/textures/throwing_arrow_fire_back.png b/textures/throwing_arrow_fire_back.png old mode 100644 new mode 100755 diff --git a/textures/throwing_arrow_fire_front.png b/textures/throwing_arrow_fire_front.png old mode 100644 new mode 100755 diff --git a/textures/throwing_arrow_fireworks_blue.png b/textures/throwing_arrow_fireworks_blue.png old mode 100644 new mode 100755 diff --git a/textures/throwing_arrow_fireworks_blue_2.png b/textures/throwing_arrow_fireworks_blue_2.png old mode 100644 new mode 100755 diff --git a/textures/throwing_arrow_fireworks_blue_back.png b/textures/throwing_arrow_fireworks_blue_back.png old mode 100644 new mode 100755 diff --git a/textures/throwing_arrow_fireworks_blue_front.png b/textures/throwing_arrow_fireworks_blue_front.png old mode 100644 new mode 100755 diff --git a/textures/throwing_arrow_fireworks_green.png b/textures/throwing_arrow_fireworks_green.png new file mode 100755 index 0000000..613f33e Binary files /dev/null and b/textures/throwing_arrow_fireworks_green.png differ diff --git a/textures/throwing_arrow_fireworks_green_2.png b/textures/throwing_arrow_fireworks_green_2.png new file mode 100755 index 0000000..f567f85 Binary files /dev/null and b/textures/throwing_arrow_fireworks_green_2.png differ diff --git a/textures/throwing_arrow_fireworks_green_back.png b/textures/throwing_arrow_fireworks_green_back.png new file mode 100755 index 0000000..185afcb Binary files /dev/null and b/textures/throwing_arrow_fireworks_green_back.png differ diff --git a/textures/throwing_arrow_fireworks_green_front.png b/textures/throwing_arrow_fireworks_green_front.png new file mode 100755 index 0000000..780b948 Binary files /dev/null and b/textures/throwing_arrow_fireworks_green_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 diff --git a/textures/throwing_arrow_fireworks_red_2.png b/textures/throwing_arrow_fireworks_red_2.png old mode 100644 new mode 100755 diff --git a/textures/throwing_arrow_fireworks_red_back.png b/textures/throwing_arrow_fireworks_red_back.png old mode 100644 new mode 100755 diff --git a/textures/throwing_arrow_fireworks_red_front.png b/textures/throwing_arrow_fireworks_red_front.png old mode 100644 new mode 100755 diff --git a/textures/throwing_arrow_lightning.png b/textures/throwing_arrow_lightning.png new file mode 100755 index 0000000..041a21e Binary files /dev/null and b/textures/throwing_arrow_lightning.png differ diff --git a/textures/throwing_arrow_lightning.xcf b/textures/throwing_arrow_lightning.xcf new file mode 100755 index 0000000..8a239f3 Binary files /dev/null and b/textures/throwing_arrow_lightning.xcf differ diff --git a/textures/throwing_arrow_lightning_2.png b/textures/throwing_arrow_lightning_2.png new file mode 100755 index 0000000..85e6696 Binary files /dev/null and b/textures/throwing_arrow_lightning_2.png differ diff --git a/textures/throwing_arrow_lightning_back.png b/textures/throwing_arrow_lightning_back.png new file mode 100755 index 0000000..2eb0eec Binary files /dev/null and b/textures/throwing_arrow_lightning_back.png differ diff --git a/textures/throwing_arrow_lightning_front.png b/textures/throwing_arrow_lightning_front.png new file mode 100755 index 0000000..0260950 Binary files /dev/null and b/textures/throwing_arrow_lightning_front.png differ diff --git a/textures/throwing_arrow_mithril.png b/textures/throwing_arrow_mithril.png new file mode 100755 index 0000000..0334fc7 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 100755 index 0000000..f996394 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 100755 index 0000000..9e4b12f 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 100755 index 0000000..23afa5c Binary files /dev/null and b/textures/throwing_arrow_mithril_front.png differ diff --git a/textures/throwing_arrow_obsidian.png b/textures/throwing_arrow_obsidian.png old mode 100644 new mode 100755 diff --git a/textures/throwing_arrow_obsidian_2.png b/textures/throwing_arrow_obsidian_2.png old mode 100644 new mode 100755 diff --git a/textures/throwing_arrow_obsidian_back.png b/textures/throwing_arrow_obsidian_back.png old mode 100644 new mode 100755 diff --git a/textures/throwing_arrow_obsidian_front.png b/textures/throwing_arrow_obsidian_front.png old mode 100644 new mode 100755 diff --git a/textures/throwing_arrow_rope.png b/textures/throwing_arrow_rope.png new file mode 100755 index 0000000..2fab116 Binary files /dev/null and b/textures/throwing_arrow_rope.png differ diff --git a/textures/throwing_arrow_rope_2.png b/textures/throwing_arrow_rope_2.png new file mode 100755 index 0000000..92b70c1 Binary files /dev/null and b/textures/throwing_arrow_rope_2.png differ diff --git a/textures/throwing_arrow_rope_back.png b/textures/throwing_arrow_rope_back.png new file mode 100755 index 0000000..472df6b Binary files /dev/null and b/textures/throwing_arrow_rope_back.png differ diff --git a/textures/throwing_arrow_rope_front.png b/textures/throwing_arrow_rope_front.png new file mode 100755 index 0000000..9d7c4a2 Binary files /dev/null and b/textures/throwing_arrow_rope_front.png differ diff --git a/textures/throwing_arrow_shell.png b/textures/throwing_arrow_shell.png deleted file mode 100644 index d100424..0000000 Binary files a/textures/throwing_arrow_shell.png and /dev/null differ diff --git a/textures/throwing_arrow_shell_2.png b/textures/throwing_arrow_shell_2.png deleted file mode 100644 index 25f2b3e..0000000 Binary files a/textures/throwing_arrow_shell_2.png and /dev/null differ diff --git a/textures/throwing_arrow_shell_back.png b/textures/throwing_arrow_shell_back.png deleted file mode 100644 index 4b64eaf..0000000 Binary files a/textures/throwing_arrow_shell_back.png and /dev/null differ diff --git a/textures/throwing_arrow_shell_front.png b/textures/throwing_arrow_shell_front.png deleted file mode 100644 index f6d51c4..0000000 Binary files a/textures/throwing_arrow_shell_front.png and /dev/null differ diff --git a/textures/throwing_arrow_steel.png b/textures/throwing_arrow_steel.png old mode 100644 new mode 100755 diff --git a/textures/throwing_arrow_steel_2.png b/textures/throwing_arrow_steel_2.png old mode 100644 new mode 100755 diff --git a/textures/throwing_arrow_steel_back.png b/textures/throwing_arrow_steel_back.png old mode 100644 new mode 100755 diff --git a/textures/throwing_arrow_steel_front.png b/textures/throwing_arrow_steel_front.png old mode 100644 new mode 100755 diff --git a/textures/throwing_arrow_stone.png b/textures/throwing_arrow_stone.png old mode 100644 new mode 100755 diff --git a/textures/throwing_arrow_stone_2.png b/textures/throwing_arrow_stone_2.png old mode 100644 new mode 100755 diff --git a/textures/throwing_arrow_stone_back.png b/textures/throwing_arrow_stone_back.png old mode 100644 new mode 100755 diff --git a/textures/throwing_arrow_stone_front.png b/textures/throwing_arrow_stone_front.png old mode 100644 new mode 100755 diff --git a/textures/throwing_arrow_teleport.png b/textures/throwing_arrow_teleport.png old mode 100644 new mode 100755 index 584735b..e1a7376 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..5fe3d09 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..cc65ee0 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..d61d86d 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 diff --git a/textures/throwing_arrow_tnt_2.png b/textures/throwing_arrow_tnt_2.png old mode 100644 new mode 100755 diff --git a/textures/throwing_arrow_tnt_back.png b/textures/throwing_arrow_tnt_back.png old mode 100644 new mode 100755 diff --git a/textures/throwing_arrow_tnt_front.png b/textures/throwing_arrow_tnt_front.png old mode 100644 new mode 100755 diff --git a/textures/throwing_arrow_torch.png b/textures/throwing_arrow_torch.png old mode 100644 new mode 100755 diff --git a/textures/throwing_arrow_torch_2.png b/textures/throwing_arrow_torch_2.png old mode 100644 new mode 100755 diff --git a/textures/throwing_arrow_torch_back.png b/textures/throwing_arrow_torch_back.png old mode 100644 new mode 100755 diff --git a/textures/throwing_arrow_torch_front.png b/textures/throwing_arrow_torch_front.png old mode 100644 new mode 100755 diff --git a/textures/throwing_bow_composite.png b/textures/throwing_bow_composite.png old mode 100644 new mode 100755 diff --git a/textures/throwing_bow_composite_loaded.png b/textures/throwing_bow_composite_loaded.png old mode 100644 new mode 100755 diff --git a/textures/throwing_bow_royal.png b/textures/throwing_bow_royal.png deleted file mode 100644 index 43c20f8..0000000 Binary files a/textures/throwing_bow_royal.png and /dev/null differ diff --git a/textures/throwing_bow_royal_loaded.png b/textures/throwing_bow_royal_loaded.png deleted file mode 100644 index 3416f2e..0000000 Binary files a/textures/throwing_bow_royal_loaded.png and /dev/null differ diff --git a/textures/throwing_bow_steel.png b/textures/throwing_bow_steel.png old mode 100644 new mode 100755 diff --git a/textures/throwing_bow_steel_loaded.png b/textures/throwing_bow_steel_loaded.png old mode 100644 new mode 100755 diff --git a/textures/throwing_bow_wood.png b/textures/throwing_bow_wood.png old mode 100644 new mode 100755 diff --git a/textures/throwing_bow_wood_loaded.png b/textures/throwing_bow_wood_loaded.png old mode 100644 new mode 100755 diff --git a/textures/throwing_compound_bow.png b/textures/throwing_compound_bow.png new file mode 100755 index 0000000..9bb46c6 Binary files /dev/null and b/textures/throwing_compound_bow.png differ diff --git a/textures/throwing_compound_bow_loaded.png b/textures/throwing_compound_bow_loaded.png new file mode 100755 index 0000000..f1ac201 Binary files /dev/null and b/textures/throwing_compound_bow_loaded.png differ diff --git a/textures/throwing_crossbow.png b/textures/throwing_crossbow.png old mode 100644 new mode 100755 diff --git a/textures/throwing_crossbow_loaded.png b/textures/throwing_crossbow_loaded.png old mode 100644 new mode 100755 diff --git a/textures/throwing_empty.png b/textures/throwing_empty.png old mode 100644 new mode 100755 diff --git a/textures/throwing_longbow.png b/textures/throwing_longbow.png old mode 100644 new mode 100755 diff --git a/textures/throwing_longbow_loaded.png b/textures/throwing_longbow_loaded.png old mode 100644 new mode 100755 diff --git a/textures/throwing_repeating_crossbow.png b/textures/throwing_repeating_crossbow.png new file mode 100755 index 0000000..c4abe82 Binary files /dev/null and b/textures/throwing_repeating_crossbow.png differ diff --git a/textures/throwing_repeating_crossbow_loaded.png b/textures/throwing_repeating_crossbow_loaded.png new file mode 100755 index 0000000..a409fb1 Binary files /dev/null and b/textures/throwing_repeating_crossbow_loaded.png differ diff --git a/textures/throwing_rope_arrow.xcf b/textures/throwing_rope_arrow.xcf new file mode 100755 index 0000000..1e40712 Binary files /dev/null and b/textures/throwing_rope_arrow.xcf differ diff --git a/textures/throwing_sparkle.png b/textures/throwing_sparkle.png old mode 100644 new mode 100755 diff --git a/textures/throwing_sparkle_blue.png b/textures/throwing_sparkle_blue.png old mode 100644 new mode 100755 diff --git a/textures/throwing_sparkle_cyan.png b/textures/throwing_sparkle_cyan.png new file mode 100755 index 0000000..a2c742e Binary files /dev/null and b/textures/throwing_sparkle_cyan.png differ diff --git a/textures/throwing_sparkle_green.png b/textures/throwing_sparkle_green.png new file mode 100755 index 0000000..91fae84 Binary files /dev/null and b/textures/throwing_sparkle_green.png differ diff --git a/textures/throwing_sparkle_magenta.png b/textures/throwing_sparkle_magenta.png new file mode 100755 index 0000000..6eefbab Binary files /dev/null and b/textures/throwing_sparkle_magenta.png differ diff --git a/textures/throwing_sparkle_orange.png b/textures/throwing_sparkle_orange.png new file mode 100755 index 0000000..d17023e Binary files /dev/null and b/textures/throwing_sparkle_orange.png differ diff --git a/textures/throwing_sparkle_red.png b/textures/throwing_sparkle_red.png old mode 100644 new mode 100755 index 59ec68c..c3eca00 Binary files a/textures/throwing_sparkle_red.png and b/textures/throwing_sparkle_red.png differ diff --git a/throwing.conf b/throwing.conf index ed96896..e44b769 100755 --- a/throwing.conf +++ b/throwing.conf @@ -13,12 +13,13 @@ DISABLE_AUTOMATED_ARBALEST = false -- Special Arrows DISABLE_TELEPORT_ARROW = false -DISABLE_DIG_ARROW = true -- Deactivated to prevent griefing -DISABLE_BUILD_ARROW = true -- Deactivated to prevent griefing -DISABLE_TNT_ARROW = true -- Deactivated to prevent griefing -DISABLE_FIRE_ARROW = true -- Deactivated to prevent griefing +DISABLE_DIG_ARROW = false -- Deactivated to prevent griefing +DISABLE_BUILD_ARROW = false -- Deactivated to prevent griefing +DISABLE_TNT_ARROW = false -- Deactivated to prevent griefing +DISABLE_FIRE_ARROW = false -- Deactivated to prevent griefing DISABLE_TORCH_ARROW = false -DISABLE_SHELL_ARROW = true -- Deactivated until crash bug related to this arrow is resolved +DISABLE_SHELL_ARROW = false -- Deactivated until crash bug related to this arrow is resolved +DISABLE_ROPE_ARROW = false -- Fireworks arrows DISABLE_FIREWORKS_BLUE_ARROW = false diff --git a/tnt_arrow.lua b/tnt_arrow.lua index fcabda9..09e24af 100755 --- a/tnt_arrow.lua +++ b/tnt_arrow.lua @@ -36,237 +36,146 @@ local THROWING_ARROW_ENTITY={ visual_size = {x=0.1, y=0.1}, textures = {"throwing:arrow_tnt_box"}, lastpos={}, + player = "", collisionbox = {0,0,0,0,0,0}, } --- TNT functions copied, would be nice to directly call them through an API... - --- loss probabilities array (one in X will be lost) -local loss_prob = {} - -loss_prob["default:cobble"] = 3 -loss_prob["default:dirt"] = 4 - -local radius = tonumber(minetest.setting_get("tnt_radius") or 3) - --- Fill a list with data for content IDs, after all nodes are registered -local cid_data = {} -minetest.after(0, function() - for name, def in pairs(minetest.registered_nodes) do - cid_data[minetest.get_content_id(name)] = { - name = name, - drops = def.drops, - flammable = def.groups.flammable, - } - end -end) - -local function rand_pos(center, pos, radius) - pos.x = center.x + math.random(-radius, radius) - pos.z = center.z + math.random(-radius, radius) -end - -local function eject_drops(drops, pos, radius) - local drop_pos = vector.new(pos) - for _, item in pairs(drops) do - local count = item:get_count() - local max = item:get_stack_max() - if count > max then - item:set_count(max) - end - while count > 0 do - if count < max then - item:set_count(count) - end - rand_pos(pos, drop_pos, radius) - local obj = minetest.add_item(drop_pos, item) - if obj then - obj:get_luaentity().collect = true - obj:setacceleration({x=0, y=-10, z=0}) - obj:setvelocity({x=math.random(-3, 3), y=10, - z=math.random(-3, 3)}) - end - count = count - max - end - end -end - -local function add_drop(drops, item) - item = ItemStack(item) - local name = item:get_name() - if loss_prob[name] ~= nil and math.random(1, loss_prob[name]) == 1 then - return - end - - local drop = drops[name] - if drop == nil then - drops[name] = item - else - drop:set_count(drop:get_count() + item:get_count()) - end -end - -local fire_node = {name="fire:basic_flame"} - -local function destroy(drops, pos, cid) - if minetest.is_protected(pos, "") then - return - end - local def = cid_data[cid] - if def and def.flammable then - minetest.set_node(pos, fire_node) - else - minetest.dig_node(pos) - if def then - local node_drops = minetest.get_node_drops(def.name, "") - for _, item in ipairs(node_drops) do - add_drop(drops, item) - end - end - end -end - - -local function calc_velocity(pos1, pos2, old_vel, power) - local vel = vector.direction(pos1, pos2) - vel = vector.normalize(vel) - vel = vector.multiply(vel, power) - - -- Divide by distance - local dist = vector.distance(pos1, pos2) - dist = math.max(dist, 1) - vel = vector.divide(vel, dist) - - -- Add old velocity - vel = vector.add(vel, old_vel) - return vel -end - -local function entity_physics(pos, radius) - -- Make the damage radius larger than the destruction radius - radius = radius * 2 - local objs = minetest.get_objects_inside_radius(pos, radius) - for _, obj in pairs(objs) do - local obj_pos = obj:getpos() - local obj_vel = obj:getvelocity() - local dist = math.max(1, vector.distance(pos, obj_pos)) - - if obj_vel ~= nil then - obj:setvelocity(calc_velocity(pos, obj_pos, - obj_vel, radius * 10)) - end - - local damage = (5 / dist) * radius - obj:set_hp(obj:get_hp() - damage) - end -end - local function add_effects(pos, radius) - minetest.add_particlespawner({ - amount = 128, - time = 1, - minpos = vector.subtract(pos, radius / 2), - maxpos = vector.add(pos, radius / 2), - minvel = {x=-20, y=-20, z=-20}, - maxvel = {x=20, y=20, z=20}, - minacc = vector.new(), - maxacc = vector.new(), - minexptime = 1, - maxexptime = 3, - minsize = 8, - maxsize = 16, - texture = "tnt_smoke.png", + minetest.add_particle({ + pos = pos, + velocity = vector.new(), + acceleration = vector.new(), + expirationtime = 0.4, + size = radius * 5, + collisiondetection = false, + vertical = false, + texture = "tnt_boom.png", + glow = 15, }) + minetest.add_particlespawner({ + amount = 64, + time = 0.5, + minpos = pos, + maxpos = pos, + minvel = {x = -10, y = -10, z = -10}, + maxvel = {x = 10, y = 10, z = 10}, + minacc = {x = 0, y = 4, z = 0}, + maxacc = {x = 0, y = 4, z = 0}, + minexptime = 1, + maxexptime = 2.5, + minsize = radius * 0.7, + maxsize = radius * 1.5, + texture = "tnt_smoke.png", + collisiondetection = true, + glow=5, + }) end - -local function explode(pos, radius) - local pos = vector.round(pos) - local vm = VoxelManip() - local pr = PseudoRandom(os.time()) - local p1 = vector.subtract(pos, radius) - local p2 = vector.add(pos, radius) - local minp, maxp = vm:read_from_map(p1, p2) - local a = VoxelArea:new({MinEdge = minp, MaxEdge = maxp}) - local data = vm:get_data() - - local drops = {} - local p = {} - - local c_air = minetest.get_content_id("air") - local c_tnt = minetest.get_content_id("tnt:tnt") - local c_tnt_burning = minetest.get_content_id("tnt:tnt_burning") - local c_gunpowder = minetest.get_content_id("tnt:gunpowder") - local c_gunpowder_burning = minetest.get_content_id("tnt:gunpowder_burning") - local c_boom = minetest.get_content_id("tnt:boom") - local c_fire = minetest.get_content_id("fire:basic_flame") - - for z = -radius, radius do - for y = -radius, radius do - local vi = a:index(pos.x + (-radius), pos.y + y, pos.z + z) - for x = -radius, radius do - if (x * x) + (y * y) + (z * z) <= - (radius * radius) + pr:next(-radius, radius) then - local cid = data[vi] - p.x = pos.x + x - p.y = pos.y + y - p.z = pos.z + z - if cid == c_tnt or cid == c_gunpowder then - burn(p) - elseif cid ~= c_tnt_burning and - cid ~= c_gunpowder_burning and - cid ~= c_air and - cid ~= c_fire and - cid ~= c_boom then - destroy(drops, p, cid) - end - end - vi = vi + 1 +local function effectsTexture(pos, node) + if minetest.registered_nodes[node.name].tiles~=nil then + texture = minetest.registered_nodes[node.name].tiles[1] + minetest.add_particlespawner({ + amount = 64, + time = 0.1, + minpos = pos, + maxpos = pos, + minvel = {x = -15, y = -15, z = -15}, + maxvel = {x = 15, y = 15, z = 15}, + minacc = {x = 0, y = -8, z = 0}, + maxacc = {x = 0, y = -8, z = 0}, + minexptime = 0.8, + maxexptime = 2.0, + minsize = 4, + maxsize = 6, + texture = texture, + collisiondetection = true, + }) end - end - end - - return drops end - local function boom(pos) - minetest.sound_play("tnt_explode", {pos=pos, gain=1.5, max_hear_distance=2*64}) - minetest.set_node(pos, {name="tnt:boom"}) - minetest.get_node_timer(pos):start(0.5) - - local drops = explode(pos, radius) - entity_physics(pos, radius) - eject_drops(drops, pos, radius) - add_effects(pos, radius) + minetest.sound_play("tnt_explode", {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 + minetest.add_node(pos, {name="throwing:firework_boom"}) + minetest.get_node_timer(pos):start(0.2) + end + add_effects(pos, 10) end -- Back to the arrow - +local function damageInRadius(damage, puncher, pos, radius) + local targs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, radius) + for k, targ in pairs(targs) do + local dist=math.sqrt(((targ:getpos().x-pos.x)^2)+((targ:getpos().y-pos.y)^2)+((targ:getpos().z-pos.z)^2)) + local newDamage=damage/math.max(dist, 1) + minetest.log("action", "Target:" .. dist .. ". Damage:" .. newDamage .. ".") + targ:set_velocity({x=0, y=500, z=0}) + targ:punch(puncher, 1.0, { + full_punch_interval=1.0, + damage_groups={fleshy=newDamage}, + }, nil) + end +end THROWING_ARROW_ENTITY.on_step = function(self, dtime) + self.timer=self.timer+dtime local newpos = self.object:getpos() + if self.timer < 0.15 then + minetest.sound_play("tnt_ignite", {pos=newpos, gain=1, max_hear_distance=2*64}) + end + minetest.add_particlespawner({ + amount = 32, + time = 0.2, + minpos = newpos, + maxpos = newpos, + minvel = {x=-5, y=-5, z=-5}, + maxvel = {x=5, y=5, z=5}, + minacc = vector.new(), + maxacc = vector.new(), + minexptime = 0.3, + maxexptime = 0.5, + minsize = 0.5, + maxsize = 1, + texture = "throwing_sparkle.png", + glow=10 + }) 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) + 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 - boom(pos) - self.object:remove() - return + 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 + damageInRadius(30, puncher, pos, 8) + effectsTexture(pos, node) + boom(pos) + self.object:remove() + return + end end end - - if node.name ~= "air" then - boom(pos) + + if self.timer > 2 or node.name ~= "air" 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 + damageInRadius(30, puncher, pos, 8) + effectsTexture(pos, node) + boom(pos) 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_tnt_entity", THROWING_ARROW_ENTITY) minetest.register_craft({ diff --git a/tools.lua b/tools.lua index 4eba3c9..a1e2b25 100755 --- 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}, 15, 1.5, 50, false, { + throwing_register_bow ('bow_wood', 'Wooden bow', {x=1, y=1, z=0.5}, 20, 1, 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}, 20, 1.5, 100, false, { + throwing_register_bow ('longbow', 'Longbow', {x=1, y=2.5, z=0.5}, 23, 2, 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}, 25, 2, 150, false, { + throwing_register_bow ('bow_composite', 'Composite bow', {x=1, y=1.4, z=0.5}, 25, 1.5, 150, false, { {'farming:string', 'group:wood', ''}, {'farming:string', '', 'default:steel_ingot'}, {'farming:string', 'group:wood', ''}, @@ -23,15 +23,15 @@ 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}, 30, 2, 250, false, { + throwing_register_bow ('bow_steel', 'Steel bow', {x=1, y=1.4, z=0.5}, 30, 1.5, 250, false, { {'farming:string', 'default:steel_ingot', ''}, {'farming:string', '', 'default:steel_ingot'}, {'farming:string', 'default:steel_ingot', ''}, }) end -if not DISABLE_ROYAL_BOW then - throwing_register_bow ('bow_royal', 'Royal bow', {x=1, y=1.5, z=0.5}, 35, 1, 750, false, { +if not DISABLE_COMPOUND_BOW then + throwing_register_bow ('compound_bow', 'Compound bow', {x=1, y=1.5, z=0.5}, 35, 1, 750, false, { {'farming:string', 'group:wood', 'default:diamond'}, {'farming:string', '', 'default:gold_ingot'}, {'farming:string', 'group:wood', 'default:diamond'}, @@ -41,7 +41,15 @@ end --function throwing_register_bow (name, desc, scale, stiffness, reload_time, toughness, is_cross, craft) if not DISABLE_CROSSBOW then - throwing_register_bow ('crossbow', 'Crossbow', {x=1, y=1.3, z=0.5}, 40, 5, 80, true, { + throwing_register_bow ('crossbow', 'Crossbow', {x=1, y=1.3, z=0.5}, 45, 3.5, 80, true, { + {'group:wood', 'farming:string', ''}, + {'default:steel_ingot', 'farming:string', 'group:wood'}, + {'group:wood', 'farming:string', ''}, + }) +end + +if not DISABLE_REPEATING_CROSSBOW then + throwing_register_bow ('repeating_crossbow', 'Repeating crossbow', {x=1, y=1.3, z=0.5}, 25, 0.5, 80, true, { {'group:wood', 'farming:string', ''}, {'default:steel_ingot', 'farming:string', 'group:wood'}, {'group:wood', 'farming:string', ''}, @@ -49,7 +57,7 @@ if not DISABLE_CROSSBOW then end if not DISABLE_ARBALEST then - throwing_register_bow ('arbalest', 'Arbalest', {x=1, y=1.3, z=0.5}, 50, 5, 120, true, { + throwing_register_bow ('arbalest', 'Arbalest', {x=1, y=1.3, z=0.5}, 60, 5, 120, true, { {'default:steel_ingot', 'farming:string', 'default:stick'}, {'default:steel_ingot', 'farming:string', 'default:steel_ingot'}, {'default:steel_ingot', 'farming:string', 'default:stick'}, @@ -57,7 +65,7 @@ if not DISABLE_ARBALEST then end if not DISABLE_AUTOMATED_ARBALEST then - throwing_register_bow ('arbalest_auto', 'Automated arbalest', {x=1, y=1.3, z=0.5}, 50, 1.5, 60, true, { + throwing_register_bow ('arbalest_auto', 'Automated arbalest', {x=1, y=1.3, z=0.5}, 60, 2, 60, true, { {'default:steel_ingot', 'farming:string', 'default:mese_crystal'}, {'default:steel_ingot', 'farming:string', 'default:steel_ingot'}, {'default:steel_ingot', 'farming:string', 'default:mese_crystal'}, diff --git a/torch_arrow.lua b/torch_arrow.lua index 50899cf..b464086 100755 --- a/torch_arrow.lua +++ b/torch_arrow.lua @@ -29,6 +29,29 @@ minetest.register_node("throwing:arrow_torch_box", { groups = {not_in_creative_inventory=1}, }) +local function add_effects(pos, node) + minetest.sound_play("default_dug_node", {pos=pos, gain=1, max_hear_distance=2*64}) + if minetest.registered_nodes[node.name].tiles~=nil then + texture = minetest.registered_nodes[node.name].tiles[1] + minetest.add_particlespawner({ + amount = 8, + time = 0.1, + minpos = pos, + maxpos = pos, + minvel = {x = -2, y = -2, z = -2}, + maxvel = {x = 2, y = 2, z = 2}, + minacc = {x = 0, y = -8, z = 0}, + maxacc = {x = 0, y = -8, z = 0}, + minexptime = 0.8, + maxexptime = 2.0, + minsize = 1, + maxsize = 3, + texture = texture, + collisiondetection = true, + }) + end +end + local THROWING_ARROW_ENTITY={ physical = false, visual = "wielditem", @@ -38,7 +61,6 @@ local THROWING_ARROW_ENTITY={ collisionbox = {0,0,0,0,0,0}, node = "", player = "", - bow_damage = 0, } THROWING_ARROW_ENTITY.on_step = function(self, dtime) @@ -55,10 +77,8 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime) 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 + local speed = vector.length(self.object:getvelocity()) + local damage = ((speed + 5)^1.2)/10 obj:punch(puncher, 1.0, { full_punch_interval=1.0, damage_groups={fleshy=damage}, @@ -95,6 +115,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime) local dir=vector.direction(self.lastpos, pos) local wall=minetest.dir_to_wallmounted(dir) minetest.add_node(self.lastpos, {name="default:torch", param2 = wall}) + add_effects(self.lastpos, node) else local toughness = 0.9 if math.random() < toughness then