From 28c2d02278afb9ab2f14fd1d3b2a19e9c33df170 Mon Sep 17 00:00:00 2001 From: Andrea Plati Date: Fri, 11 Sep 2015 19:38:10 +0200 Subject: [PATCH] 1.4 --- spears.lua | 123 +++++++++++++++++++++++++++ textures/throwing_spear_box.png | Bin 0 -> 154 bytes textures/throwing_spear_diamond.png | Bin 0 -> 246 bytes textures/throwing_spear_obsidian.png | Bin 0 -> 255 bytes textures/throwing_spear_steel.png | Bin 0 -> 256 bytes textures/throwing_spear_stone.png | Bin 0 -> 258 bytes 6 files changed, 123 insertions(+) create mode 100644 spears.lua create mode 100644 textures/throwing_spear_box.png create mode 100644 textures/throwing_spear_diamond.png create mode 100644 textures/throwing_spear_obsidian.png create mode 100644 textures/throwing_spear_steel.png create mode 100644 textures/throwing_spear_stone.png diff --git a/spears.lua b/spears.lua new file mode 100644 index 0000000..1a93fa5 --- /dev/null +++ b/spears.lua @@ -0,0 +1,123 @@ +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*100)) + end + else + throwing_shoot_spear(itemstack, user) + if not minetest.setting_getbool("creative_mode") then + itemstack:take_item() + end + end + return itemstack + end, + }) + + minetest.register_node("throwing:spear_" .. kind .. "_box", { + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + -- Shaft + {-60/16, -2/16, 2/16, 4, 1/16, -1/16}, + --Spitze + {-4, -1/16, 1/16, -62/16, 0, 0}, + {-62/16, -1.5/16, 1.5/16, -60/16, 0.5/16, -0.5/16}, + } + }, + tiles = {"throwing_spear_box.png"}, + groups = {not_in_creative_inventory=1}, + }) + + local THROWING_SPEAR_ENTITY={ + physical = false, + timer=0, + visual = "wielditem", + visual_size = {x=0.1, y=0.1}, + textures = {"throwing:spear_" .. kind .. "_box"}, + lastpos={}, + collisionbox = {0,0,0,0,0,0}, + } + + THROWING_SPEAR_ENTITY.on_step = function(self, dtime) + self.timer=self.timer+dtime + local pos = self.object:getpos() + local node = minetest.get_node(pos) + + if self.timer>0.2 then + local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 2) + for k, obj in pairs(objs) do + if obj:get_luaentity() ~= nil then + if obj:get_luaentity().name ~= "throwing:spear_" .. kind .. "_entity" and obj:get_luaentity().name ~= "__builtin:item" then + local speed = vector.length(self.object:getvelocity()) + local damage = ((speed + eq +5)^1.2)/10 + obj:punch(self.object, 1.0, { + full_punch_interval=1.0, + damage_groups={fleshy=damage}, + }, nil) + self.object:remove() + if math.random() < toughness then + minetest.add_item(self.lastpos, 'throwing:spear_' .. kind) + else + minetest.add_item(self.lastpos, 'default:stick') + end + end + end + end + end + + if self.lastpos.x~=nil then + if node.name ~= "air" and not string.find(node.name, '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 + self.object:remove() + if math.random() < toughness then + minetest.add_item(self.lastpos, 'throwing:spear_' .. kind) + else + minetest.add_item(self.lastpos, 'default:stick') + end + end + end + self.lastpos={x=pos.x, y=pos.y, z=pos.z} + end + + minetest.register_entity("throwing:spear_" .. kind .. "_entity", THROWING_SPEAR_ENTITY) + + minetest.register_craft({ + output = 'throwing:spear_' .. kind, + recipe = { + {'group:wood', 'group:wood', craft}, + } + }) + + minetest.register_craft({ + output = 'throwing:spear_' .. kind, + recipe = { + {craft, 'group:wood', 'group:wood'}, + } + }) +end + +if not DISABLE_STONE_SPEAR then + throwing_register_spear_standard ('stone', 'Stone', 0, 0.75, 'group:stone') +end + +if not DISABLE_STEEL_SPEAR then + throwing_register_spear_standard ('steel', 'Steel', 5, 0.90, 'default:steel_ingot') +end + +if not DISABLE_DIAMOND_SPEAR then + throwing_register_spear_standard ('diamond', 'Diamond', 10, 0.99, 'default:diamond') +end + +if not DISABLE_OBSIDIAN_SPEAR then + throwing_register_spear_standard ('obsidian', 'Obsidian', 15, 0.80, 'default:obsidian') +end diff --git a/textures/throwing_spear_box.png b/textures/throwing_spear_box.png new file mode 100644 index 0000000000000000000000000000000000000000..628e1718c2da8c8a5de2308bdba07be80f943823 GIT binary patch literal 154 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE^w}67tmK)|3K%r(&7sn8b)5$M>{eS-d+W-20=Au9T zrYmqen2NvHJRy}KI5<(@@L$>65_SLoo_FX|>@jd##CEz~Z`yyJHD`Kwg!TR^w}6uRYvYZAK%pK_7sn8b)5#B>KmV_3)I2t7nK&h+ s{j7jn&}6+`iak$K6jGc|7%|)wU^p7;AG|N_KFD1Rp00i_>zopr0EdWKVE_OC literal 0 HcmV?d00001 diff --git a/textures/throwing_spear_steel.png b/textures/throwing_spear_steel.png new file mode 100644 index 0000000000000000000000000000000000000000..60037a5907bbcca731ca5bcafb5f898ad4f23c87 GIT binary patch literal 256 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE^w}7nK&Dh=dfkM5WE{-7Egi%6Ow$b6gvbQDb{{KB6u;9GYCT)qt9v9we|6_FiOGeC; zlvIoPbJ$}O;}fZ-g&iTz8?+RT3e1^wM5^g}NfM9Z3wNhB0ntl8coePn6-plR@LF{^ sjYD~*r}$j~w<05fO^PX!4LKYPmnMV;^V@B^1#}pLr>mdKI;Vst02mQmVE_OC literal 0 HcmV?d00001 diff --git a/textures/throwing_spear_stone.png b/textures/throwing_spear_stone.png new file mode 100644 index 0000000000000000000000000000000000000000..8daaeacf80cb05f2c634b3f9b611c10455c9a285 GIT binary patch literal 258 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmP~CpW)5_mav&Mxao?r;B5V#pz@pAD=(xPn|lYaQJJ} z!n{LjZfrt~m;2@IB~o_88SJ^ezqe85z!J@WQy>28%jMbs|6jVsh4i2Ps~8K^)w4GI zd7kw1{DD(vP8d9VB=0tfSK+z~YTKMVrB-$&C|u6;CsyI5U(j_dleQv*Z-eX$+pOelF{r5}E+31zxNG literal 0 HcmV?d00001