diff --git a/bows.lua b/bows.lua index 0b3f373..e670198 100644 --- a/bows.lua +++ b/bows.lua @@ -1,10 +1,10 @@ local stiffness=0 -local bow_idle=false +local bow_idle=true local reload=0 local throwing_shoot_arrow = function(itemstack, player) - if not bow_idle then - bow_idle=true + if bow_idle then + bow_idle=false for _,arrow in ipairs(arrows) do if player:get_inventory():get_stack("main", player:get_wield_index()+1):get_name() == arrow[1] then if not minetest.setting_getbool("creative_mode") then @@ -16,7 +16,7 @@ local throwing_shoot_arrow = function(itemstack, player) obj:setvelocity({x=dir.x*stiffness, y=dir.y*stiffness, z=dir.z*stiffness}) obj:setacceleration({x=dir.x*-3, y=-10, z=dir.z*-3}) obj:setyaw(player:get_look_yaw()+math.pi) - minetest.sound_play("throwing_sound", {pos=playerpos}) + minetest.sound_play("throwing_bow_sound", {pos=playerpos}) if obj:get_luaentity().player == "" then obj:get_luaentity().player = player end @@ -32,21 +32,22 @@ end local function reloading () minetest.after(reload, function() - bow_idle=false + bow_idle=true end) end minetest.register_tool("throwing:bow_wood", { description = "Wood Bow", inventory_image = "throwing_bow_wood.png", + wield_scale = {x=1, y=1, z=0.5}, stack_max = 1, on_use = function(itemstack, user, pointed_thing) - stiffness = 15 + stiffness = 13 reload = 1.1 if throwing_shoot_arrow(itemstack, user, pointed_thing) then reloading() if not minetest.setting_getbool("creative_mode") then - itemstack:add_wear(65535/100) + itemstack:add_wear(65535/80) end end return itemstack @@ -74,14 +75,15 @@ minetest.register_craft({ minetest.register_tool("throwing:bow_steel", { description = "Steel Bow", inventory_image = "throwing_bow_steel.png", + wield_scale = {x=1, y=1, z=0.5}, stack_max = 1, on_use = function(itemstack, user, pointed_thing) - stiffness = 20 - reload = 1.5 + stiffness = 16 + reload = 1.6 if throwing_shoot_arrow(itemstack, user, pointed_thing) then reloading() if not minetest.setting_getbool("creative_mode") then - itemstack:add_wear(65535/200) + itemstack:add_wear(65535/400) end end return itemstack @@ -109,14 +111,15 @@ minetest.register_craft({ minetest.register_tool("throwing:bow_composite", { description = "Composite Bow", inventory_image = "throwing_bow_composite.png", + wield_scale = {x=1, y=1, z=0.5}, stack_max = 1, on_use = function(itemstack, user, pointed_thing) - stiffness = 25 + stiffness = 16 reload = 1.3 if throwing_shoot_arrow(itemstack, user, pointed_thing) then reloading() if not minetest.setting_getbool("creative_mode") then - itemstack:add_wear(65535/250) + itemstack:add_wear(65535/150) end end return itemstack @@ -144,10 +147,11 @@ minetest.register_craft({ minetest.register_tool("throwing:bow_gold", { description = "Golden Bow", inventory_image = "throwing_bow_gold.png", + wield_scale = {x=1, y=1, z=0.5}, stack_max = 1, on_use = function(itemstack, user, pointed_thing) - stiffness = 20 - reload = 1.5 + stiffness = 16 + reload = 1.6 if throwing_shoot_arrow(itemstack, user, pointed_thing) then reloading() if not minetest.setting_getbool("creative_mode") then diff --git a/init.lua b/init.lua index 250fdb3..6013a43 100644 --- a/init.lua +++ b/init.lua @@ -9,6 +9,7 @@ arrows = { {"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"}, } dofile(minetest.get_modpath("throwing").."/bows.lua") @@ -22,6 +23,8 @@ dofile(minetest.get_modpath("throwing").."/build_arrow.lua") dofile(minetest.get_modpath("throwing").."/tnt_arrow.lua") dofile(minetest.get_modpath("throwing").."/torch_arrow.lua") dofile(minetest.get_modpath("throwing").."/diamond_arrow.lua") +dofile(minetest.get_modpath("throwing").."/shell_arrow.lua") + if minetest.setting_get("log_mods") then minetest.log("action", "throwing loaded") diff --git a/shell_arrow.lua b/shell_arrow.lua new file mode 100644 index 0000000..399a235 --- /dev/null +++ b/shell_arrow.lua @@ -0,0 +1,117 @@ +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}, +} + +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) + 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 damage = 16 + obj:punch(self.object, 1.0, { + full_punch_interval=1.0, + damage_groups={fleshy=damage}, + }, nil) + self.object:remove() + boom(pos) + end + end + end + end + + if self.lastpos.x~=nil then + if node.name ~= "air" then + self.object:remove() + boom(self.lastpos) + end + end + self.lastpos={x=pos.x, y=pos.y, z=pos.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/shell_explode.ogg b/sounds/shell_explode.ogg new file mode 100644 index 0000000..ec827f8 Binary files /dev/null and b/sounds/shell_explode.ogg differ diff --git a/sounds/throwing_bow_sound.ogg b/sounds/throwing_bow_sound.ogg new file mode 100644 index 0000000..de4e22b Binary files /dev/null and b/sounds/throwing_bow_sound.ogg differ diff --git a/sounds/throwing_sound.ogg b/sounds/throwing_sound.ogg deleted file mode 100644 index c8911e5..0000000 Binary files a/sounds/throwing_sound.ogg and /dev/null differ diff --git a/textures/throwing_arrow_shell.png b/textures/throwing_arrow_shell.png new file mode 100644 index 0000000..a1204d0 Binary files /dev/null and b/textures/throwing_arrow_shell.png differ diff --git a/textures/throwing_arrow_shell_2.png b/textures/throwing_arrow_shell_2.png new file mode 100644 index 0000000..ad7bc43 Binary files /dev/null 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 new file mode 100644 index 0000000..4b64eaf Binary files /dev/null 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 new file mode 100644 index 0000000..06b9454 Binary files /dev/null and b/textures/throwing_arrow_shell_front.png differ diff --git a/textures/throwing_arrow_tnt.png b/textures/throwing_arrow_tnt.png index 7f96a55..6625cb0 100644 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 index 5c9b978..426ebff 100644 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_front.png b/textures/throwing_arrow_tnt_front.png index d15904f..38d22e3 100644 Binary files a/textures/throwing_arrow_tnt_front.png and b/textures/throwing_arrow_tnt_front.png differ diff --git a/textures/throwing_bow_composite.png b/textures/throwing_bow_composite.png index fd5819e..6bcc7d2 100644 Binary files a/textures/throwing_bow_composite.png and b/textures/throwing_bow_composite.png differ diff --git a/textures/throwing_bow_gold.png b/textures/throwing_bow_gold.png index 0f1d853..df4f1ad 100644 Binary files a/textures/throwing_bow_gold.png and b/textures/throwing_bow_gold.png differ diff --git a/textures/throwing_bow_steel.png b/textures/throwing_bow_steel.png index fa31582..6828572 100644 Binary files a/textures/throwing_bow_steel.png and b/textures/throwing_bow_steel.png differ diff --git a/textures/throwing_bow_wood.png b/textures/throwing_bow_wood.png index 212336d..3484508 100644 Binary files a/textures/throwing_bow_wood.png and b/textures/throwing_bow_wood.png differ diff --git a/tnt_arrow.lua b/tnt_arrow.lua index 48ffd44..d0a4f7d 100644 --- a/tnt_arrow.lua +++ b/tnt_arrow.lua @@ -274,13 +274,13 @@ minetest.register_entity("throwing:arrow_tnt_entity", THROWING_ARROW_ENTITY) minetest.register_craft({ output = 'throwing:arrow_tnt', recipe = { - {'default:stick', 'default:stick', 'tnt:tnt'}, + {'default:stick', 'tnt:tnt', 'default:bronze_ingot'}, } }) minetest.register_craft({ output = 'throwing:arrow_tnt', recipe = { - {'tnt:tnt', 'default:stick', 'default:stick'}, + {'default:bronze_ingot', 'tnt:tnt', 'default:stick'}, } })