diff --git a/mods/spears b/mods/spears deleted file mode 160000 index 510ab936..00000000 --- a/mods/spears +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 510ab936b8af7f7edb46d48757020c2b7af408fb diff --git a/mods/spears/README.txt b/mods/spears/README.txt new file mode 100755 index 00000000..94002462 --- /dev/null +++ b/mods/spears/README.txt @@ -0,0 +1,107 @@ +=== SPEARS for MINETEST === + +This mod adds spears to Minetest. It aims at improving the ones introduced within throwing enhanced. + +How to install: +http://wiki.minetest.com/wiki/Installing_Mods + +How to use the mod: +Spear work similarly to other tools such as swords, even if being a little slower. Moreover, a spear can be thrown using the drop key ('Q') or + +License: +This mod was originally published by Jeija and reworked by PilzAdam +Sourcecode: LGPLv2.1 (see http://www.gnu.org/licenses/lgpl-2.1.html) +Grahpics & sounds: CC-BY 3.0 (see http://creativecommons.org/licenses/by/3.0/legalcode) + + +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 + +Update 1.2: +- Added arbalest +- Defaults initialized + +Update 1.1: +- Added crossbow +- Code shrink +- Offensive arrows go through flora's and farming's +- Small fixes + +Update 1.0: +- Definitive reload, unload and shot system based on tool metadata, new global functions, no more "throw" privilege +- New textures for loaded bows +- Fireworks arrows to celebrate! + +Update 1.0rc2: +- Fixed "compare nil with number" due to self.break not being retained +- Filled conf.example's list +- Added Royal bow + +Update 1.0rc1: +- Added longbow and removed golden bow, definitive bow set for stable release. Feature freeze +- Fixed torch arrow recipe, thanks to Excalibur Zero +- Removed config.lua, configuration now goes int throwing.config, see example + +Update 0.9.8: +- New damage calculation for offensive arrows based on arrow's speed and material. Beware that dependency is more than linear for both, so that differences between arrows will be enhanced if they're shot at higher speed. +- Fixed bug that blocked ability to shot after shooting with empty arrow stack. +- Removed annoying debug symbols + +Update 0.9.7: +- Added visual feedback for reload +- Fixed reload for players who die while reloading and for multiplayer +- Changed license for the code to LGPLv2 + +Update 0.9.6: +- Any bow and arrow is now deactivable under config.lua, which won't be overwritten +- Changed license for media to CC-BY + +Update 0.9.5: +- Added shell arrows +- Revised sounds and some textures +- General balancing of bow's statistics + +Update 0.9.4: +- New bow texture +- Made recipes coherent + +Update 0.9.3: +- Added symmetric recipes, fixed golden bow recipe +- Adjusted few parameters + +Update 0.9.2: +- Added a chance to break for many arrows, so they don't last forever and outclass any other tool +- Build and torch arrows won't build on fluids and torches any more, build arrows won't place torches +- TNT arrow digs instead if removing blocks, eventual indestructible nodes are safe +- Added golden bow with possible new bow style +- Changed the (bit OP) composite bow resistance and new recipe +- New teleport arrow recipe, cheaper but single use + +Update 0.9.1: +- Good improvement for torch arrows, now they always attach and are often turned to the right direction +- Git repository will make things nicer + +Update 0.9: +- Now bows have reload times! They depend on weight and quality, anyway no more machine-gun-style shell swarms +- Fixed build arrow behavior, now it placed and consumes the node from the slot [b]right next to the arrow[/b] or drops the item beside it if not a node; no more disappearing nor 'CONTENT_IGNORE' errors +- Code cleanup and rationalization + +Update 0.8.1: +- Fixed wrong texture reference which made some arrows get a bad color during flight. +- Now bows have different stiffness besides wear resistances, which means that they shot arrows at different initial speed and learning to hit the target will become even harder. + Get rid of the old .env: API + Added new bows and new offensive, utility and harmful arrows (these are just my categories, they're not present into the code at all). + Removed stone bow, at least as long as somebody discovers an elastic rock ;) + Non-exploding arrows won't disappear any more after hitting target. \ No newline at end of file diff --git a/mods/spears/defaults.lua b/mods/spears/defaults.lua new file mode 100755 index 00000000..54a4e962 --- /dev/null +++ b/mods/spears/defaults.lua @@ -0,0 +1,5 @@ +DISABLE_STONE_SPEAR = false +DISABLE_STEEL_SPEAR = false +DISABLE_DIAMOND_SPEAR = false +DISABLE_OBSIDIAN_SPEAR = false +DISABLE_MITHRIL_SPEAR = false diff --git a/mods/spears/depends.txt b/mods/spears/depends.txt new file mode 100755 index 00000000..4ad96d51 --- /dev/null +++ b/mods/spears/depends.txt @@ -0,0 +1 @@ +default diff --git a/mods/spears/functions.lua b/mods/spears/functions.lua new file mode 100755 index 00000000..ba15b477 --- /dev/null +++ b/mods/spears/functions.lua @@ -0,0 +1,55 @@ + +function spears_shot (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*.5, y=-9.8, z=-dir.z*.5}) + 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("spears_sound", {pos=playerpos}) + return true +end + +function spears_is_player(name, obj) + return (obj:is_player() and obj:get_player_name() ~= name) +end + +function spears_is_entity(obj) + return (obj:get_luaentity() ~= nil + and not string.find(obj:get_luaentity().name, "spears:") + and obj:get_luaentity().name ~= "__builtin:item" + and obj:get_luaentity().name ~= "gauges:hp_bar" + and obj:get_luaentity().name ~= "signs:text") +end + +function spears_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 spears_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 < 0.4 and rx > -0.4) and (rz < 0.4 and rz > -0.4) then + return true + end + return false +end + diff --git a/mods/spears/init.lua b/mods/spears/init.lua new file mode 100755 index 00000000..842d919b --- /dev/null +++ b/mods/spears/init.lua @@ -0,0 +1,25 @@ +dofile(minetest.get_modpath("spears").."/defaults.lua") + +local input = io.open(minetest.get_modpath("spears").."/spears.conf", "r") +if input then + dofile(minetest.get_modpath("spears").."/spears.conf") + input:close() + input = nil +end + +dofile(minetest.get_modpath("spears").."/functions.lua") + +dofile(minetest.get_modpath("spears").."/tools.lua") + + +if minetest.setting_get("log_mods") then + minetest.log("action", "spears loaded") +end + +--alias +minetest.register_alias("throwing:spear_stone", "spears:spear_stone") +minetest.register_alias("throwing:spear_steel", "spears:spear_steel") +minetest.register_alias("throwing:spear_diamond", "spears:spear_diamond") +minetest.register_alias("throwing:spear_obsidian", "spears:spear_obsidian") +minetest.register_alias("throwing:spear_mithril", "spears:spear_mithril") + diff --git a/mods/spears/sounds/spears_sound.ogg b/mods/spears/sounds/spears_sound.ogg new file mode 100755 index 00000000..ebebd615 Binary files /dev/null and b/mods/spears/sounds/spears_sound.ogg differ diff --git a/mods/spears/textures/spears_spear_diamond.png b/mods/spears/textures/spears_spear_diamond.png new file mode 100755 index 00000000..820fa43a Binary files /dev/null and b/mods/spears/textures/spears_spear_diamond.png differ diff --git a/mods/spears/textures/spears_spear_mithril.png b/mods/spears/textures/spears_spear_mithril.png new file mode 100755 index 00000000..d0ac2a38 Binary files /dev/null and b/mods/spears/textures/spears_spear_mithril.png differ diff --git a/mods/spears/textures/spears_spear_obsidian.png b/mods/spears/textures/spears_spear_obsidian.png new file mode 100755 index 00000000..92255502 Binary files /dev/null and b/mods/spears/textures/spears_spear_obsidian.png differ diff --git a/mods/spears/textures/spears_spear_steel.png b/mods/spears/textures/spears_spear_steel.png new file mode 100755 index 00000000..1a6f9169 Binary files /dev/null and b/mods/spears/textures/spears_spear_steel.png differ diff --git a/mods/spears/textures/spears_spear_stone.png b/mods/spears/textures/spears_spear_stone.png new file mode 100755 index 00000000..a2145a34 Binary files /dev/null and b/mods/spears/textures/spears_spear_stone.png differ diff --git a/mods/spears/tools.lua b/mods/spears/tools.lua new file mode 100755 index 00000000..d14c6e35 --- /dev/null +++ b/mods/spears/tools.lua @@ -0,0 +1,157 @@ +function spears_register_spear(kind, desc, eq, toughness, craft) + + minetest.register_tool("spears:spear_" .. kind, { + description = desc .. " spear", + inventory_image = "spears_spear_" .. kind .. ".png", + wield_scale= {x=2,y=1,z=1}, + + on_drop = function(itemstack, user, pointed_thing) + spears_shot(itemstack, user) + if not minetest.setting_getbool("creative_mode") then + itemstack:take_item() + end + return itemstack + end, + on_place = function(itemstack, user, pointed_thing) + minetest.add_item(pointed_thing.above, itemstack) + if not minetest.setting_getbool("creative_mode") then + itemstack:take_item() + end + return itemstack + end, + tool_capabilities = { + full_punch_interval = 1.5, + max_drop_level=1, + groupcaps={ + cracky = {times={[3]=2}, uses=toughness, maxlevel=1}, + }, + damage_groups = {fleshy=eq}, + } + }) + + --minetest.register_node("spears: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 = {"spears_spear_box.png"}, + --groups = {not_in_creative_inventory=1}, + --}) + + local SPEAR_ENTITY={ + physical = false, + visual = "wielditem", + visual_size = {x=0.15, y=0.1}, + textures = {"spears:spear_" .. kind}, + lastpos={}, + collisionbox = {0,0,0,0,0,0}, + player = "", + wear = 0, + + on_punch = function(self, puncher) + if puncher then + if puncher:is_player() then + local stack = {name='spears:spear_' .. kind, wear=self.wear+65535/toughness} + local inv = puncher:get_inventory() + if inv:room_for_item("main", stack) then + inv:add_item("main", stack) + self.object:remove() + end + end + end + end, + } + + SPEAR_ENTITY.on_step = function(self, dtime) + local pos = self.object:getpos() + local node = minetest.get_node(pos) + 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(spears_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 spears_is_player(self.player, obj) or spears_is_entity(obj) then + if spears_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()) --MFF crabman(28/09/2015) damage valeur equal eq + local damage = eq --((speed + eq +5)^1.2)/10 --MFF crabman(28/09/2015) damage valeur equal eq + obj:punch(puncher, 1.0, { + full_punch_interval=1.0, + damage_groups={fleshy=damage}, + }, nil) + minetest.add_item(self.lastpos, {name='spears:spear_' .. kind, wear=self.wear+65535/toughness}) + 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 + minetest.add_item(self.lastpos, {name='spears:spear_' .. kind, wear=self.wear+65535/toughness}) + 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("spears:spear_" .. kind .. "_entity", SPEAR_ENTITY) + + minetest.register_craft({ + output = 'spears:spear_' .. kind .. ' 4', + recipe = { + {'group:wood', 'group:wood', craft}, + } + }) + + minetest.register_craft({ + output = 'spears:spear_' .. kind .. ' 4', + recipe = { + {craft, 'group:wood', 'group:wood'}, + } + }) +end + +if not DISABLE_STONE_SPEAR then + spears_register_spear('stone', 'Stone (Hunter)', 3, 25, 'group:stone') --MFF crabman(28/09/2015) damage and wear +end + +if not DISABLE_STEEL_SPEAR then + spears_register_spear('steel', 'Steel (Hunter)', 4, 30, 'default:steel_ingot') --MFF crabman(28/09/2015) damage and wear +end + +if not DISABLE_DIAMOND_SPEAR then + spears_register_spear('diamond', 'Diamond (Hunter)', 7, 50, 'default:diamond') --MFF crabman(28/09/2015) damage and wear +end + +if not DISABLE_OBSIDIAN_SPEAR then + spears_register_spear('obsidian', 'Obsidian (Hunter)', 5, 40, 'default:obsidian') --MFF crabman(28/09/2015) damage and wear +end + +if not DISABLE_MITHRIL_SPEAR then + spears_register_spear('mithril', 'Mithril (Hunter)', 8, 200, 'moreores:mithril_ingot') --MFF crabman(28/09/2015) damage and wear +end +