diff --git a/mods/throwing/README.txt b/mods/throwing/README.txt index 88e9094c..4d3cf619 100755 --- a/mods/throwing/README.txt +++ b/mods/throwing/README.txt @@ -9,8 +9,9 @@ How to install: http://wiki.minetest.com/wiki/Installing_Mods How to use the mod: -Select the bow and place the arrows into the slot next to it; shoot with left mouse click. +Select a bow and place the arrows into the slot next to it; shoot with left mouse click. Every shoot will take 1 arrow from your inventory and wears out the bow. +Select a spear and attack with left mouse click; it will be used as a melee weapon if pointing any target, otherwise it will be thrown. License: This mod was originally published by Jeija and reworked by PilzAdam @@ -20,6 +21,15 @@ Grahpics & sounds: CC-BY 3.0 (see http://creativecommons.org/licenses/by/3.0/leg Changelog: +Update 1.4.1: +- Fixed spears not retaining wear +- Improved textures +- Torch arrows have light trail + +Update 1.4: +- Added spears, capable of melee and ranged attacks +- Improved arrows textures + Update 1.3: - Added automated arbalest, the ultimate weapon - New arbalest texture coherent with steel color diff --git a/mods/throwing/build_arrow.lua b/mods/throwing/build_arrow.lua index f6a1f5df..6fd664ec 100755 --- a/mods/throwing/build_arrow.lua +++ b/mods/throwing/build_arrow.lua @@ -69,7 +69,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime) end end - if node.name ~= "air" then + if node.name ~= "air" and not string.find(node.name, "water_") and not string.find(node.name, 'grass') and not string.find(node.name, 'flowers:') and not string.find(node.name, 'farming:') 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, "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()}) diff --git a/mods/throwing/defaults.lua b/mods/throwing/defaults.lua index ba3876e0..994765e1 100755 --- a/mods/throwing/defaults.lua +++ b/mods/throwing/defaults.lua @@ -21,4 +21,10 @@ DISABLE_FIREWORKS_RED_ARROW = false DISABLE_STONE_ARROW = false DISABLE_STEEL_ARROW = false DISABLE_DIAMOND_ARROW = false -DISABLE_OBSIDIAN_ARROW = false \ No newline at end of file +DISABLE_OBSIDIAN_ARROW = false + +DISABLE_STONE_SPEAR = false +DISABLE_STEEL_SPEAR = false +DISABLE_DIAMOND_SPEAR = false +DISABLE_OBSIDIAN_SPEAR = false +DISABLE_MITHRIL_SPEAR = false diff --git a/mods/throwing/dig_arrow.lua b/mods/throwing/dig_arrow.lua index 4c7d6c60..beeed38f 100755 --- a/mods/throwing/dig_arrow.lua +++ b/mods/throwing/dig_arrow.lua @@ -61,7 +61,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime) return end end - if node.name ~= "air" and not string.find(node.name, "water_") then + if node.name ~= "air" and not string.find(node.name, "water_") and not string.find(node.name, 'grass') and not string.find(node.name, 'flowers:') and not string.find(node.name, 'farming:') 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 diff --git a/mods/throwing/fire_arrow.lua b/mods/throwing/fire_arrow.lua index 49ebcd5e..f8497d79 100755 --- a/mods/throwing/fire_arrow.lua +++ b/mods/throwing/fire_arrow.lua @@ -64,7 +64,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime) end end - if node.name ~= "air" and node.name ~= "throwing:light" and node.name ~= "fire:basic_flame" then + 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, 'flowers:') and not string.find(node.name, 'farming:') and not string.find(node.name, 'fire:') then if node.name ~= "ignore" then minetest.set_node(self.lastpos, {name="fire:basic_flame"}) end diff --git a/mods/throwing/functions.lua b/mods/throwing/functions.lua index 8f71c4ad..327165a1 100755 --- a/mods/throwing/functions.lua +++ b/mods/throwing/functions.lua @@ -22,11 +22,12 @@ end function throwing_is_entity(obj) return (obj:get_luaentity() ~= nil - and not string.find(obj:get_luaentity().name, "throwing:arrow_") + 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} @@ -175,3 +176,20 @@ function throwing_register_bow (name, desc, scale, stiffness, reload_time, tough 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) + obj:get_luaentity().wear = itemstack:get_wear() + obj:get_luaentity().player = player:get_player_name() + obj:get_luaentity().lastpos = {x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z} + minetest.sound_play("throwing_bow_sound", {pos=playerpos}) + return true +end diff --git a/mods/throwing/init.lua b/mods/throwing/init.lua index 0ef50feb..32b52cb1 100755 --- a/mods/throwing/init.lua +++ b/mods/throwing/init.lua @@ -32,6 +32,8 @@ 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") end diff --git a/mods/throwing/shell_arrow.lua b/mods/throwing/shell_arrow.lua index d4284356..ef9a82d6 100755 --- a/mods/throwing/shell_arrow.lua +++ b/mods/throwing/shell_arrow.lua @@ -90,7 +90,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime) end end - if node.name ~= "air" and not string.find(node.name, 'default:grass') and not string.find(node.name, 'default:junglegrass') and not string.find(node.name, 'flowers:') and not string.find(node.name, 'farming:') then + if node.name ~= "air" and not string.find(node.name, 'grass') and not string.find(node.name, 'flowers:') and not string.find(node.name, 'farming:') and not string.find(node.name, 'fire:') then boom(self.lastpos) self.object:remove() return diff --git a/mods/throwing/spears.lua b/mods/throwing/spears.lua new file mode 100644 index 00000000..3f3e3f6c --- /dev/null +++ b/mods/throwing/spears.lua @@ -0,0 +1,136 @@ +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, + visual = "wielditem", + visual_size = {x=0.1, y=0.1}, + textures = {"throwing:spear_" .. kind .. "_box"}, + lastpos={}, + collisionbox = {0,0,0,0,0,0}, + player = "", + wear = "", + } + + THROWING_SPEAR_ENTITY.on_step = function(self, dtime) + if not self.wear then + self.object:remove() + return + end + 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 (pos.x - objpos.x < 0.5 and pos.x - objpos.x > -0.5) and (pos.z - objpos.z < 0.5 and pos.z - objpos.z > -0.5) 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) + 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 + self.object:remove() + return + end + end + end + if node.name ~= "air" and not string.find(node.name, 'flowers:') and not string.find(node.name, 'fire:') and (node.drawtype and not string.find(node.drawtype, 'plantlike')) then + 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 + 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: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 (Hunter)', 0, 20, 'group:stone') +end + +if not DISABLE_STEEL_SPEAR then + throwing_register_spear_standard ('steel', 'Steel (Hunter)', 5, 30, 'default:steel_ingot') +end + +if not DISABLE_DIAMOND_SPEAR then + throwing_register_spear_standard ('diamond', 'Diamond (Hunter)', 10, 40, 'default:diamond') +end + +if not DISABLE_OBSIDIAN_SPEAR then + throwing_register_spear_standard ('obsidian', 'Obsidian (Hunter)', 15, 30, 'default:obsidian') +end + +if not DISABLE_MITHRIL_SPEAR then + throwing_register_spear_standard ('mithril', 'Mithril (Hunter)', 20, 50, 'moreores:mithril_ingot') +end + diff --git a/mods/throwing/standard_arrows.lua b/mods/throwing/standard_arrows.lua index ff9824d6..c4d728d1 100755 --- a/mods/throwing/standard_arrows.lua +++ b/mods/throwing/standard_arrows.lua @@ -67,7 +67,7 @@ function throwing_register_arrow_standard (kind, desc, eq, toughness, craft) end end end - if node.name ~= "air" and not string.find(node.name, 'water_') and not string.find(node.name, 'default:grass') and not string.find(node.name, 'default:junglegrass') and not string.find(node.name, 'flowers:') and not string.find(node.name, 'farming:') then + if node.name ~= "air" and not string.find(node.name, 'water_') and not string.find(node.name, 'grass') and not string.find(node.name, 'flowers:') and not string.find(node.name, 'farming:') and not string.find(node.name, 'fire:') then if math.random() < toughness then minetest.add_item(self.lastpos, 'throwing:arrow_' .. kind) else diff --git a/mods/throwing/teleport_arrow.lua b/mods/throwing/teleport_arrow.lua index d81fa280..c1c9801f 100755 --- a/mods/throwing/teleport_arrow.lua +++ b/mods/throwing/teleport_arrow.lua @@ -58,7 +58,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime) end end - if node.name ~= "air" then + if node.name ~= "air" and not string.find(node.name, 'grass') and not string.find(node.name, 'flowers:') and not string.find(node.name, 'farming:') and not string.find(node.name, 'fire:') then if self.player ~= "" then local player = minetest.get_player_by_name(self.player) if player then diff --git a/mods/throwing/textures/throwing_spear_box.png b/mods/throwing/textures/throwing_spear_box.png new file mode 100755 index 00000000..ac2c014d Binary files /dev/null and b/mods/throwing/textures/throwing_spear_box.png differ diff --git a/mods/throwing/textures/throwing_spear_diamond.png b/mods/throwing/textures/throwing_spear_diamond.png new file mode 100755 index 00000000..adc58621 Binary files /dev/null and b/mods/throwing/textures/throwing_spear_diamond.png differ diff --git a/mods/throwing/textures/throwing_spear_mithril.png b/mods/throwing/textures/throwing_spear_mithril.png new file mode 100755 index 00000000..84146f5f Binary files /dev/null and b/mods/throwing/textures/throwing_spear_mithril.png differ diff --git a/mods/throwing/textures/throwing_spear_obsidian.png b/mods/throwing/textures/throwing_spear_obsidian.png new file mode 100755 index 00000000..f33833c5 Binary files /dev/null and b/mods/throwing/textures/throwing_spear_obsidian.png differ diff --git a/mods/throwing/textures/throwing_spear_steel.png b/mods/throwing/textures/throwing_spear_steel.png new file mode 100755 index 00000000..5def9547 Binary files /dev/null and b/mods/throwing/textures/throwing_spear_steel.png differ diff --git a/mods/throwing/textures/throwing_spear_stone.png b/mods/throwing/textures/throwing_spear_stone.png new file mode 100755 index 00000000..bced8bb9 Binary files /dev/null and b/mods/throwing/textures/throwing_spear_stone.png differ diff --git a/mods/throwing/throwing.conf b/mods/throwing/throwing.conf index ea87851b..7bb56789 100755 --- a/mods/throwing/throwing.conf +++ b/mods/throwing/throwing.conf @@ -36,3 +36,10 @@ DISABLE_OBSIDIAN_ARROW = false DISABLE_DIAMOND_ARROW = false DISABLE_MITHRIL_ARROW = false -- lesser damages to better damages + +-- Spear +DISABLE_STONE_SPEAR = false +DISABLE_STEEL_SPEAR = false +DISABLE_DIAMOND_SPEAR = false +DISABLE_OBSIDIAN_SPEAR = false +DISABLE_MITHRIL_SPEAR = false diff --git a/mods/throwing/torch_arrow.lua b/mods/throwing/torch_arrow.lua index ab3d565d..a914dd30 100755 --- a/mods/throwing/torch_arrow.lua +++ b/mods/throwing/torch_arrow.lua @@ -66,7 +66,11 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime) end end - if node.name ~= "air" 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") and not string.find(node.name, 'grass') and not string.find(node.name, 'flowers:') and not string.find(node.name, 'farming:') 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") @@ -107,3 +111,14 @@ minetest.register_craft({ {'group:coal', 'default:stick', 'default:stick'}, } }) + +minetest.register_node("throwing:torch_trail", { + drawtype = "airlike", + light_source = default.LIGHT_MAX-1, + walkable = false, + drop = "", + groups = {dig_immediate=3}, + on_timer = function(pos, elapsed) + minetest.remove_node(pos) + end, +})