diff --git a/darts.lua b/darts.lua index 59ffbbe..22ae2d4 100644 --- a/darts.lua +++ b/darts.lua @@ -1,27 +1,5 @@ --- arrow (duck_arrow) -mobs:register_arrow("nssm:duck_father", { - visual = "sprite", - visual_size = {x = 1, y = 1}, - textures = {"duck_egg.png"}, - velocity = 8, - -- direct hit - hit_player = function(self, player) - local pos = self.object:get_pos() - duck_explosion(pos) - end, - hit_mob = function(self, player) - local pos = self.object:get_pos() - duck_explosion(pos) - end, - - hit_node = function(self, pos, node) - duck_explosion(pos) - end, - -}) - -function duck_explosion(pos) +local function duck_explosion(pos) if minetest.is_protected(pos, "") then return end @@ -68,6 +46,46 @@ function duck_explosion(pos) end) end +-- arrow (duck_arrow) +mobs:register_arrow("nssm:duck_father", { + visual = "sprite", + visual_size = {x = 1, y = 1}, + textures = {"duck_egg.png"}, + velocity = 8, + -- direct hit + hit_player = function(self, player) + local pos = self.object:get_pos() + duck_explosion(pos) + end, + + hit_mob = function(self, player) + local pos = self.object:get_pos() + duck_explosion(pos) + end, + + hit_node = function(self, pos, node) + duck_explosion(pos) + end, +}) + + +local function ice_explosion(pos) + for i=pos.x-math.random(0, 1), pos.x+math.random(0, 1), 1 do + for j=pos.y-1, pos.y+4, 1 do + for k=pos.z-math.random(0, 1), pos.z+math.random(0, 1), 1 do + local p = {x=i, y=j, z=k} + local n = minetest.get_node(p).name + if minetest.get_item_group(n, "unbreakable") == 1 + or minetest.is_protected(p, "") + or (n == "bones:bones" and not nssm:affectbones(self)) then + else + minetest.set_node({x=i, y=j, z=k}, {name="default:ice"}) + end + end + end + end +end + -- snow_arrow mobs:register_arrow("nssm:snow_arrow", { visual = "sprite", @@ -89,20 +107,6 @@ mobs:register_arrow("nssm:snow_arrow", { end, }) -function ice_explosion(pos) - for i=pos.x-math.random(0, 1), pos.x+math.random(0, 1), 1 do - for j=pos.y-1, pos.y+4, 1 do - for k=pos.z-math.random(0, 1), pos.z+math.random(0, 1), 1 do - local p = {x=i, y=j, z=k} - local n = minetest.get_node(p).name - if minetest.get_item_group(n, "unbreakable") == 1 or minetest.is_protected(p, "") or (n == "bones:bones" and not nssm:affectbones(self)) then - else - minetest.set_node({x=i, y=j, z=k}, {name="default:ice"}) - end - end - end - end -end -- arrow manticore mobs:register_arrow("nssm:spine", { @@ -126,6 +130,7 @@ mobs:register_arrow("nssm:spine", { end, }) + --morbat arrow mobs:register_arrow("nssm:morarrow", { visual = "sprite", @@ -141,6 +146,32 @@ mobs:register_arrow("nssm:morarrow", { end, }) + +local function explosion_web(pos) + pos.y = round(pos.y) + if minetest.is_protected(pos, "") then + return + end + for i=pos.x-1, pos.x+1, 1 do + for j=pos.y-3, pos.y, 1 do + for k=pos.z-1, pos.z+1, 1 do + local p = {x=i,y=j,z=k} + local k = {x=i,y=j+1,z=k} + local current = minetest.get_node(p).name + local ontop = minetest.get_node(k).name + if (current ~= "air") and + (current ~= "nssm:web") and + (ontop == "air") and not + minetest.is_protected(p,"") and not + minetest.is_protected(k,"") then + minetest.set_node(k, {name="nssm:web"}) + end + end + end + end +end + + -- web arrow mobs:register_arrow("nssm:webball", { visual = "sprite", @@ -165,34 +196,31 @@ mobs:register_arrow("nssm:webball", { end }) -function explosion_web(pos) - if minetest.is_protected(pos, "") then - return - end + +function explosion_thickweb(pos) pos.y = round(pos.y) if minetest.is_protected(pos, "") then return end - for i=pos.x-1, pos.x+1, 1 do - for j=pos.y-3, pos.y, 1 do - for k=pos.z-1, pos.z+1, 1 do + for i=pos.x+0, pos.x+0, 1 do + for j=pos.y-2, pos.y, 1 do + for k=pos.z+0, pos.z+0, 1 do local p = {x=i,y=j,z=k} local k = {x=i,y=j+1,z=k} local current = minetest.get_node(p).name local ontop = minetest.get_node(k).name if (current ~= "air") and - (current ~= "nssm:web") and + (current ~= "nssm:thick_web") and (ontop == "air") and not minetest.is_protected(p,"") and not minetest.is_protected(k,"") then - minetest.set_node(k, {name="nssm:web"}) + minetest.set_node(k, {name="nssm:thick_web"}) end end end end end - -- thick_web arrow mobs:register_arrow("nssm:thickwebball", { visual = "sprite", @@ -217,32 +245,6 @@ mobs:register_arrow("nssm:thickwebball", { end }) -function explosion_thickweb(pos) - if minetest.is_protected(pos, "") then - return - end - pos.y = round(pos.y) - if minetest.is_protected(pos, "") then - return - end - for i=pos.x+0, pos.x+0, 1 do - for j=pos.y-2, pos.y, 1 do - for k=pos.z+0, pos.z+0, 1 do - local p = {x=i,y=j,z=k} - local k = {x=i,y=j+1,z=k} - local current = minetest.get_node(p).name - local ontop = minetest.get_node(k).name - if (current ~= "air") and - (current ~= "nssm:thick_web") and - (ontop == "air") and not - minetest.is_protected(p,"") and not - minetest.is_protected(k,"") then - minetest.set_node(k, {name="nssm:thick_web"}) - end - end - end - end -end -- arrow=>phoenix arrow mobs:register_arrow("nssm:phoenix_arrow", { @@ -267,7 +269,8 @@ mobs:register_arrow("nssm:phoenix_arrow", { self.timer = os.time() end - if os.time() - self.timer > 5 or minetest.is_protected(pos, "") or ((n~="air") and (n~="nssm:phoenix_fire")) then + if os.time() - self.timer > 5 or minetest.is_protected(pos, "") + or ((n~="air") and (n~="nssm:phoenix_fire")) then self.object:remove() end @@ -289,22 +292,6 @@ mobs:register_arrow("nssm:phoenix_arrow", { end, }) -mobs:register_arrow("nssm:super_gas", { - visual = "sprite", - visual_size = {x = 1, y = 1}, - textures = {"transparent.png"}, - velocity = 8, - -- direct hit - hit_player = function(self, player) - local p = player:get_pos() - gas_explosion(p) - end, - - hit_node = function(self, pos, node) - gas_explosion(pos) - end -}) - function gas_explosion(pos) if minetest.is_protected(pos, "") then @@ -326,7 +313,23 @@ function gas_explosion(pos) end end --- +mobs:register_arrow("nssm:super_gas", { + visual = "sprite", + visual_size = {x = 1, y = 1}, + textures = {"transparent.png"}, + velocity = 8, + -- direct hit + hit_player = function(self, player) + local p = player:get_pos() + gas_explosion(p) + end, + + hit_node = function(self, pos, node) + gas_explosion(pos) + end +}) + + mobs:register_arrow("nssm:roar_of_the_dragon", { visual = "sprite", visual_size = {x = 1, y = 1}, @@ -348,17 +351,18 @@ mobs:register_arrow("nssm:roar_of_the_dragon", { end local objects = minetest.get_objects_inside_radius(pos, 1) - for _,obj in ipairs(objects) do + for _,obj in ipairs(objects) do local name = obj:get_entity_name() if name~="nssm:roar_of_the_dragon" and name ~= "nssm:mese_dragon" then - obj:set_hp(obj:get_hp()-0.05) - if (obj:get_hp() <= 0) then - if (not obj:is_player()) and name ~= self.object:get_luaentity().name then - obj:remove() - end - end + obj:set_hp(obj:get_hp()-0.05) + if (obj:get_hp() <= 0) then + if (not obj:is_player()) + and name ~= self.object:get_luaentity().name then + obj:remove() + end + end end - end + end minetest.set_node(pos, {name="air"}) if math.random(1,2)==1 then @@ -391,7 +395,8 @@ mobs:register_arrow("nssm:lava_arrow", { for dz=-1, 1, 2 do local p = {x=pos.x+dx, y=pos.y+dy, z=pos.z+dz} local n = minetest.get_node(p).name - if n~="default:lava_flowing" and not minetest.is_protected(p, "") then + if n~="default:lava_flowing" + and not minetest.is_protected(p, "") then minetest.set_node(p, {name="default:lava_flowing"}) end end diff --git a/init.lua b/init.lua index 9fa79e2..eaa34a6 100644 --- a/init.lua +++ b/init.lua @@ -63,10 +63,18 @@ dofile(path.."/mobs/white_werewolf.lua") dofile(path.."/mobs/mese_dragon.lua") --Others -dofile(path.."/rainbow_staff.lua") dofile(path.."/darts.lua") dofile(path.."/nssm_materials.lua") dofile(path.."/nssm_spears.lua") dofile(path.."/nssm_api.lua") dofile(path.."/nssm_weapons.lua") -dofile(path.."/nssm_armor.lua") + +if minetest.registered_nodes["nyancat:nyancat_rainbow"] then + dofile(path.."/rainbow_staff.lua") ; print ("NYAN!!!!!") +end + +if minetest.get_modpath("3d_armor") then + dofile(path.."/nssm_armor.lua") +end + +print("[MOD] NSSM loaded") diff --git a/nssm_api.lua b/nssm_api.lua index 5022dab..85fba3b 100644 --- a/nssm_api.lua +++ b/nssm_api.lua @@ -120,47 +120,47 @@ function round(n) end function explosion_particles(pos, exp_radius) - minetest.add_particlespawner( - 100*exp_radius/2, --amount - 0.1, --time - {x=pos.x-exp_radius, y=pos.y-exp_radius, z=pos.z-exp_radius}, --minpos - {x=pos.x+exp_radius, y=pos.y+exp_radius, z=pos.z+exp_radius}, --maxpos - {x=0, y=0, z=0}, --minvel - {x=0.1, y=0.3, z=0.1}, --maxvel - {x=-0.5,y=1,z=-0.5}, --minacc - {x=0.5,y=1,z=0.5}, --maxacc - 0.1, --minexptime - 4, --maxexptime - 6, --minsize - 12, --maxsize - false, --collisiondetection - "tnt_smoke.png" --texture - ) + minetest.add_particlespawner( + 100*exp_radius/2, --amount + 0.1, --time + {x=pos.x-exp_radius, y=pos.y-exp_radius, z=pos.z-exp_radius}, --minpos + {x=pos.x+exp_radius, y=pos.y+exp_radius, z=pos.z+exp_radius}, --maxpos + {x=0, y=0, z=0}, --minvel + {x=0.1, y=0.3, z=0.1}, --maxvel + {x=-0.5,y=1,z=-0.5}, --minacc + {x=0.5,y=1,z=0.5}, --maxacc + 0.1, --minexptime + 4, --maxexptime + 6, --minsize + 12, --maxsize + false, --collisiondetection + "tnt_smoke.png" --texture + ) end --[[ function explosion(pos, exp_radius, fire, kamehameha_bad) - local radius = exp_radius - -- if area protected or near map limits then no blast damage + local radius = exp_radius + -- if area protected or near map limits then no blast damage if minetest.is_protected(pos, "") or not within_limits(pos, radius) then return end - --sound - minetest.sound_play("boom", { - pos = pos, - max_hear_distance = exp_radius*4, - }) + --sound + minetest.sound_play("boom", { + pos = pos, + max_hear_distance = exp_radius*4, + }) - --particles: - explosion_particles(pos, exp_radius) + --particles: + explosion_particles(pos, exp_radius) - --Damages entities around (not the player) - local objects = minetest.get_objects_inside_radius(pos, exp_radius) - for _,obj in ipairs(objects) do - local obj_p = obj:get_pos() - local vec = {x=obj_p.x-pos.x, y=obj_p.y-pos.y, z=obj_p.z-pos.z} - local dist = (vec.x^2+vec.y^2+vec.z^2)^0.5 + --Damages entities around (not the player) + local objects = minetest.get_objects_inside_radius(pos, exp_radius) + for _,obj in ipairs(objects) do + local obj_p = obj:get_pos() + local vec = {x=obj_p.x-pos.x, y=obj_p.y-pos.y, z=obj_p.z-pos.z} + local dist = (vec.x^2+vec.y^2+vec.z^2)^0.5 local damage = (-exp_radius*dist+exp_radius^2)*2 if not kamehameha_bad then if obj:is_player() then @@ -168,7 +168,7 @@ function explosion(pos, exp_radius, fire, kamehameha_bad) elseif obj:get_luaentity().health then obj:get_luaentity().health = obj:get_luaentity().health - damage check_for_death(obj:get_luaentity()) - end + end else if (obj:get_luaentity()) then local name = obj:get_luaentity().name @@ -178,86 +178,86 @@ function explosion(pos, exp_radius, fire, kamehameha_bad) elseif obj:get_luaentity().health then obj:get_luaentity().health = obj.get_luaentity().health - damage check_for_death(obj:get_luaentity()) - end + end end end end - end + end - --damages blocks around and if necessary put some fire - pos = vector.round(pos) -- voxelmanip doesn't work properly unless pos is rounded ?!?! - local vm = VoxelManip() - local minp, maxp = vm:read_from_map(vector.subtract(pos, radius), vector.add(pos, radius)) + --damages blocks around and if necessary put some fire + pos = vector.round(pos) -- voxelmanip doesn't work properly unless pos is rounded ?!?! + local vm = VoxelManip() + local minp, maxp = vm:read_from_map(vector.subtract(pos, radius), vector.add(pos, radius)) local a = VoxelArea:new({MinEdge = minp, MaxEdge = maxp}) local data = vm:get_data() local p = {} local pr = PseudoRandom(os.time()) - --remove everything near the center of the explosion - for dz=-radius,radius do - for dy=-radius,radius do - local vi = a:index(pos.x + (-radius), pos.y + dy, pos.z + dz) - for dx=-radius,radius do - local p = {x=pos.x+dx, y=pos.y+dy, z=pos.z+dz} + --remove everything near the center of the explosion + for dz=-radius,radius do + for dy=-radius,radius do + local vi = a:index(pos.x + (-radius), pos.y + dy, pos.z + dz) + for dx=-radius,radius do + local p = {x=pos.x+dx, y=pos.y+dy, z=pos.z+dz} - if (dx * dx) + (dy * dy) + (dz * dz) <= (radius * radius) + pr:next(-radius, radius) - and data[vi] ~= c_air - and data[vi] ~= c_ignore - and data[vi] ~= c_obsidian - and data[vi] ~= c_brick - and data[vi] ~= c_chest then + if (dx * dx) + (dy * dy) + (dz * dz) <= (radius * radius) + pr:next(-radius, radius) + and data[vi] ~= c_air + and data[vi] ~= c_ignore + and data[vi] ~= c_obsidian + and data[vi] ~= c_brick + and data[vi] ~= c_chest then - local n = node_ok(p).name - local on_blast = minetest.registered_nodes[n].on_blast + local n = node_ok(p).name + local on_blast = minetest.registered_nodes[n].on_blast - if on_blast then - return on_blast(p) - end + if on_blast then + return on_blast(p) + end - if minetest.get_item_group(n, "unbreakable") ~= 1 then + if minetest.get_item_group(n, "unbreakable") ~= 1 then - -- if chest then drop items inside - if n == "default:chest" - or n == "3dchest:chest" - or n == "bones:bones" then + -- if chest then drop items inside + if n == "default:chest" + or n == "3dchest:chest" + or n == "bones:bones" then - local meta = minetest.get_meta(p) - local inv = meta:get_inventory() + local meta = minetest.get_meta(p) + local inv = meta:get_inventory() - for i = 1, inv:get_size("main") do + for i = 1, inv:get_size("main") do - local m_stack = inv:get_stack("main", i) - local obj = minetest.add_item(p, m_stack) + local m_stack = inv:get_stack("main", i) + local obj = minetest.add_item(p, m_stack) - if obj then + if obj then - obj:set_velocity({ - x = math.random(-2, 2), - y = 7, - z = math.random(-2, 2) - }) - end - end - end + obj:set_velocity({ + x = math.random(-2, 2), + y = 7, + z = math.random(-2, 2) + }) + end + end + end - -- after effects - if fire > 0 - and (minetest.registered_nodes[n].groups.flammable - or math.random(1, 100) <= 3) then - minetest.set_node(p, {name = "fire:basic_flame"}) - else - local dist = round(((pos.x-p.x)^2 + (pos.y-p.y)^2 + (pos.z-p.z)^2)^1/2) - local prob = 2/dist - if math.random(1,100)<=prob*100 then - minetest.remove_node(p) - end - end - end - end - vi = vi+1 - end - end - end + -- after effects + if fire > 0 + and (minetest.registered_nodes[n].groups.flammable + or math.random(1, 100) <= 3) then + minetest.set_node(p, {name = "fire:basic_flame"}) + else + local dist = round(((pos.x-p.x)^2 + (pos.y-p.y)^2 + (pos.z-p.z)^2)^1/2) + local prob = 2/dist + if math.random(1,100)<=prob*100 then + minetest.remove_node(p) + end + end + end + end + vi = vi+1 + end + end + end end ]] diff --git a/nssm_armor.lua b/nssm_armor.lua index bc7041a..e23cb32 100644 --- a/nssm_armor.lua +++ b/nssm_armor.lua @@ -1,193 +1,187 @@ -if minetest.get_modpath("3d_armor") then - - --Armors - local stats = { - wolf = {name="Werewolf", armor=2.8, heal=0, use=800}, - whitewolf = {name="White Werewolf", armor=2.8, heal=0, use=800}, - bloco = {name="Bloco", armor=3.2, heal=0, use=500}, - croco = {name="Crocodile", armor=3, heal=0, use=450}, - ant = {name="Ant", armor=3, heal=0, use=400}, - ice = {name="Ice Teeth", armor=3.2, heal=0, use=410}, - felucco = {name="Felucco", armor=2.8, heal=0, use=800}, - manticore = {name="Manticore", armor=3.4, heal=0, use=440}, - duck = {name="Duck", armor=1.5, heal=0, use=1000}, - black_duck = {name="Black Duck", armor=1.5, heal=0, use=900}, - mor = {name="Morlu", armor=5.3, heal=0, use=30}, - sky = {name="Sky", armor=4.2, heal=0, use=100}, - sandworm = {name="Sandworm", armor=3.4, heal=0, use=400}, - sandbloco = {name="Sand Bloco", armor=3.2, heal=0, use=500}, - web = {name="Cobweb String", armor=2.4, heal=0, use=900}, - denseweb = {name="Dense Cobweb String", armor=3.5, heal=0, use=400}, - } - local materials = { - wolf="nssm:wolf_fur", - whitewolf="nssm:white_wolf_fur", - bloco="nssm:bloco_skin", - croco="nssm:crocodile_skin", - ant="nssm:ant_hard_skin", - ice="nssm:little_ice_tooth", - felucco="nssm:felucco_fur", - manticore="nssm:manticore_fur", - duck="nssm:duck_feather", - black_duck="nssm:black_duck_feather", - mor= "nssm:lustful_moranga", - sandbloco= "nssm:sand_bloco_skin", - sandworm="nssm:sandworm_skin", - sky="nssm:sky_iron", - web="nssm:web_string", - denseweb="nssm:dense_web_string", - } +local stats = { + wolf = {name="Werewolf", armor=2.8, heal=0, use=800}, + whitewolf = {name="White Werewolf", armor=2.8, heal=0, use=800}, + bloco = {name="Bloco", armor=3.2, heal=0, use=500}, + croco = {name="Crocodile", armor=3, heal=0, use=450}, + ant = {name="Ant", armor=3, heal=0, use=400}, + ice = {name="Ice Teeth", armor=3.2, heal=0, use=410}, + felucco = {name="Felucco", armor=2.8, heal=0, use=800}, + manticore = {name="Manticore", armor=3.4, heal=0, use=440}, + duck = {name="Duck", armor=1.5, heal=0, use=1000}, + black_duck = {name="Black Duck", armor=1.5, heal=0, use=900}, + mor = {name="Morlu", armor=5.3, heal=0, use=30}, + sky = {name="Sky", armor=4.2, heal=0, use=100}, + sandworm = {name="Sandworm", armor=3.4, heal=0, use=400}, + sandbloco = {name="Sand Bloco", armor=3.2, heal=0, use=500}, + web = {name="Cobweb String", armor=2.4, heal=0, use=900}, + denseweb = {name="Dense Cobweb String", armor=3.5, heal=0, use=400}, +} - for k, v in pairs(stats) do - minetest.register_tool("nssm:helmet_"..k, { - description = v.name.." Helmet", - inventory_image ="inv_helmet_"..k..".png", - groups = {armor_head=math.floor(4*v.armor), armor_heal=v.heal, armor_use=v.use}, - wear = 0, - }) - minetest.register_tool("nssm:chestplate_"..k, { - description = v.name.." Chestplate", - inventory_image ="inv_chestplate_"..k..".png", - groups = {armor_torso=math.floor(6*v.armor), armor_heal=v.heal, armor_use=v.use}, - wear = 0, - }) - minetest.register_tool("nssm:leggings_"..k, { - description = v.name.." Leggings", - inventory_image = "inv_leggings_"..k..".png", - groups = {armor_legs=math.floor(5*v.armor), armor_heal=v.heal, armor_use=v.use}, - wear = 0, - }) - minetest.register_tool("nssm:boots_"..k, { - description = v.name.." Boots", - inventory_image ="inv_boots_"..k..".png", - groups = {armor_feet=math.floor(3*v.armor), armor_heal=v.heal, armor_use=v.use}, - wear = 0, - }) - end +local materials = { + wolf="nssm:wolf_fur", + whitewolf="nssm:white_wolf_fur", + bloco="nssm:bloco_skin", + croco="nssm:crocodile_skin", + ant="nssm:ant_hard_skin", + ice="nssm:little_ice_tooth", + felucco="nssm:felucco_fur", + manticore="nssm:manticore_fur", + duck="nssm:duck_feather", + black_duck="nssm:black_duck_feather", + mor= "nssm:lustful_moranga", + sandbloco= "nssm:sand_bloco_skin", + sandworm="nssm:sandworm_skin", + sky="nssm:sky_iron", + web="nssm:web_string", + denseweb="nssm:dense_web_string", +} + +for k, v in pairs(stats) do + minetest.register_tool("nssm:helmet_"..k, { + description = v.name.." Helmet", + inventory_image ="inv_helmet_"..k..".png", + groups = {armor_head=math.floor(4*v.armor), armor_heal=v.heal, armor_use=v.use}, + wear = 0, + }) + minetest.register_tool("nssm:chestplate_"..k, { + description = v.name.." Chestplate", + inventory_image ="inv_chestplate_"..k..".png", + groups = {armor_torso=math.floor(6*v.armor), armor_heal=v.heal, armor_use=v.use}, + wear = 0, + }) + minetest.register_tool("nssm:leggings_"..k, { + description = v.name.." Leggings", + inventory_image = "inv_leggings_"..k..".png", + groups = {armor_legs=math.floor(5*v.armor), armor_heal=v.heal, armor_use=v.use}, + wear = 0, + }) + minetest.register_tool("nssm:boots_"..k, { + description = v.name.." Boots", + inventory_image ="inv_boots_"..k..".png", + groups = {armor_feet=math.floor(3*v.armor), armor_heal=v.heal, armor_use=v.use}, + wear = 0, + }) +end + +for k, v in pairs(materials) do + minetest.register_craft({ + output = "nssm:helmet_"..k, + recipe = { + {v, v, v}, + {v, "", v}, + {"", "", ""}, + }, + }) + minetest.register_craft({ + output = "nssm:chestplate_"..k, + recipe = { + {v, "", v}, + {v, v, v}, + {v, v, v}, + }, + }) + minetest.register_craft({ + output = "nssm:leggings_"..k, + recipe = { + {v, v, v}, + {v, "", v}, + {v, "", v}, + }, + }) + minetest.register_craft({ + output = "nssm:boots_"..k, + recipe = { + {v, "", v}, + {v, "", v}, + }, + }) +end - for k, v in pairs(materials) do - minetest.register_craft({ - output = "nssm:helmet_"..k, - recipe = { - {v, v, v}, - {v, "", v}, - {"", "", ""}, - }, - }) - minetest.register_craft({ - output = "nssm:chestplate_"..k, - recipe = { - {v, "", v}, - {v, v, v}, - {v, v, v}, - }, - }) - minetest.register_craft({ - output = "nssm:leggings_"..k, - recipe = { - {v, v, v}, - {v, "", v}, - {v, "", v}, - }, - }) - minetest.register_craft({ - output = "nssm:boots_"..k, - recipe = { - {v, "", v}, - {v, "", v}, - }, - }) - end --shields - if minetest.get_modpath("shields") then - local stats = { - crab = {name="Crab", armor=4, heal=0, use=500}, - ice ={name="Ice Teeth", armor=3.5, heal=0, use=600}, - mor ={name="Morlu", armor=5, use=100}, - masticone ={name="Masticone", armor=4.5, use=300}, - mantis ={name="Mantis", armor=3, use=500}, - } - local materials = { - crab="nssm:crab_carapace_fragment", - ice="nssm:little_ice_tooth", - mor="nssm:lustful_moranga", - masticone="nssm:masticone_skull_fragments", - mantis="nssm:mantis_skin", - } - for k, v in pairs(stats) do - minetest.register_tool("nssm:shield_"..k, { - description = v.name.." Shield", - inventory_image ="inv_shield_"..k..".png", - groups = {armor_head=math.floor(5*v.armor), armor_heal=v.heal, armor_use=v.use}, - wear = 0, - }) +if minetest.get_modpath("shields") then - local m = materials[k] - minetest.register_craft({ - output = "nssm:shield_"..k, - recipe = { - {m, m, m}, - {m, m, m}, - {"", m, ""}, - }, - }) - end - end + local stats = { + crab = {name="Crab", armor=4, heal=0, use=500}, + ice ={name="Ice Teeth", armor=3.5, heal=0, use=600}, + mor ={name="Morlu", armor=5, use=100}, + masticone ={name="Masticone", armor=4.5, use=300}, + mantis ={name="Mantis", armor=3, use=500}, + } + + local materials = { + crab="nssm:crab_carapace_fragment", + ice="nssm:little_ice_tooth", + mor="nssm:lustful_moranga", + masticone="nssm:masticone_skull_fragments", + mantis="nssm:mantis_skin", + } + + for k, v in pairs(stats) do + minetest.register_tool("nssm:shield_"..k, { + description = v.name.." Shield", + inventory_image ="inv_shield_"..k..".png", + groups = {armor_head=math.floor(5*v.armor), armor_heal=v.heal, armor_use=v.use}, + wear = 0, + }) + + local m = materials[k] + minetest.register_craft({ + output = "nssm:shield_"..k, + recipe = { + {m, m, m}, + {m, m, m}, + {"", m, ""}, + }, + }) + end end --Special objects (pumpking helmet, masticone helmet, crowned masticone helmet, crown,) -if minetest.get_modpath("3d_armor") then - - local stats = { - pumpking = {name="Pumpking Head", armor=4, heal=0, use=100}, - masticone ={name="Masticone Head", armor=4, heal=0, use=100}, - crown ={name="Dukking Crown", armor=2, heal=0, use=50}, - masticone_crowned ={name="Masticone Crowned Head", armor=6, heal=0, use=20}, - } - - for k, v in pairs(stats) do - minetest.register_tool("nssm:helmet_"..k, { - description = v.name.." ", - inventory_image ="inv_helmet_"..k..".png", - groups = {armor_shield=math.floor(5*v.armor), armor_heal=v.heal, armor_use=v.use}, - wear = 0, - }) + pumpking = {name="Pumpking Head", armor=4, heal=0, use=100}, + masticone ={name="Masticone Head", armor=4, heal=0, use=100}, + crown ={name="Dukking Crown", armor=2, heal=0, use=50}, + masticone_crowned ={name="Masticone Crowned Head", armor=6, heal=0, use=20}, +} - minetest.register_tool("nssm:chestplate_snake", { - description = "Snake Scute Chestplate", - inventory_image ="inv_chestplate_snake.png", - groups = {armor_torso=40, armor_heal=0, armor_use=100}, - wear = 0, - }) - end - - - - minetest.register_craft({ - output = "nssm:chestplate_snake", - recipe = { - {"default:steel_ingot", "", "default:steel_ingot"}, - {"default:steel_ingot", "nssm:snake_scute", "default:steel_ingot"}, - {"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"}, - }, - }) - minetest.register_craft({ - output = "nssm:helmet_masticone", - recipe = { - {"nssm:masticone_skull_fragments", "nssm:masticone_skull_fragments", "nssm:masticone_skull_fragments"}, - {"nssm:masticone_skull_fragments", "nssm:masticone_skull_fragments", "nssm:masticone_skull_fragments"}, - {"nssm:masticone_skull_fragments", "nssm:masticone_skull_fragments", "nssm:masticone_skull_fragments"}, - }, - }) - minetest.register_craft({ - output = "nssm:helmet_masticone_crowned", - recipe = { - {"", "nssm:helmet_crown", ""}, - {"", "nssm:helmet_masticone", ""}, - {"", "", ""}, - }, - }) +for k, v in pairs(stats) do + minetest.register_tool("nssm:helmet_"..k, { + description = v.name.." ", + inventory_image ="inv_helmet_"..k..".png", + groups = {armor_shield=math.floor(5*v.armor), armor_heal=v.heal, armor_use=v.use}, + wear = 0, + }) + minetest.register_tool("nssm:chestplate_snake", { + description = "Snake Scute Chestplate", + inventory_image ="inv_chestplate_snake.png", + groups = {armor_torso=40, armor_heal=0, armor_use=100}, + wear = 0, + }) end + +minetest.register_craft({ + output = "nssm:chestplate_snake", + recipe = { + {"default:steel_ingot", "", "default:steel_ingot"}, + {"default:steel_ingot", "nssm:snake_scute", "default:steel_ingot"}, + {"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"}, + }, +}) +minetest.register_craft({ + output = "nssm:helmet_masticone", + recipe = { + {"nssm:masticone_skull_fragments", "nssm:masticone_skull_fragments", "nssm:masticone_skull_fragments"}, + {"nssm:masticone_skull_fragments", "nssm:masticone_skull_fragments", "nssm:masticone_skull_fragments"}, + {"nssm:masticone_skull_fragments", "nssm:masticone_skull_fragments", "nssm:masticone_skull_fragments"}, + }, +}) +minetest.register_craft({ + output = "nssm:helmet_masticone_crowned", + recipe = { + {"", "nssm:helmet_crown", ""}, + {"", "nssm:helmet_masticone", ""}, + {"", "", ""}, + }, +}) diff --git a/nssm_materials.lua b/nssm_materials.lua index 48caea7..eb2945b 100644 --- a/nssm_materials.lua +++ b/nssm_materials.lua @@ -1,225 +1,226 @@ --non eatable craftitems -function nssm_register_noneatcraftitems (name, descr) - -minetest.register_craftitem("nssm:"..name, { - description = descr, - image = name..".png", -}) +local function nssm_craftitem (name, descr) + minetest.register_craftitem("nssm:"..name, { + description = descr, + image = name..".png", + }) end -nssm_register_noneatcraftitems ('sky_feather','Sky Feather') -nssm_register_noneatcraftitems ('snake_scute','Snake Scute') -nssm_register_noneatcraftitems ('eyed_tentacle','Eyed Tentacle') ---nssm_register_noneatcraftitems ('king_duck_crown','King Duck Crown') -nssm_register_noneatcraftitems ('great_energy_globe','Great Energy Globe') -nssm_register_noneatcraftitems ('superior_energy_globe','Superior Energy Globe') -nssm_register_noneatcraftitems ('ant_queen_abdomen','Ant Queen Abdomen') ---nssm_register_noneatcraftitems ('masticone_skull','Masticone Skull') -nssm_register_noneatcraftitems ('masticone_skull_fragments','Masticone Skull Fragments') ---nssm_register_noneatcraftitems ('masticone_skull_crowned','Masticone Skull Crowned') -nssm_register_noneatcraftitems ('tentacle_curly','Kraken Tentacle') -nssm_register_noneatcraftitems ('lava_titan_eye','Lava Titan Eye') -nssm_register_noneatcraftitems ('duck_beak','Duck Beak') -nssm_register_noneatcraftitems ('ice_tooth','Ice Tooth') -nssm_register_noneatcraftitems ('little_ice_tooth','Little Ice Tooth') -nssm_register_noneatcraftitems ('digested_sand',"Digested Sand") -nssm_register_noneatcraftitems ('black_ice_tooth','Black Ice Tooth') -nssm_register_noneatcraftitems ('tarantula_chelicerae','Tarantula Chelicerae') -nssm_register_noneatcraftitems ('crab_chela','Crab Chela') -nssm_register_noneatcraftitems ('cursed_pumpkin_seed','Cursed Pumpkin Seed') -nssm_register_noneatcraftitems ('mantis_claw','Mantis Claw') -nssm_register_noneatcraftitems ('manticore_fur','Manticore Fur') -nssm_register_noneatcraftitems ('ant_hard_skin','Ant Hard Skin') -nssm_register_noneatcraftitems ('bloco_skin','Bloco Skin') -nssm_register_noneatcraftitems ('crab_carapace_fragment','Crab Carapace Fragment') -nssm_register_noneatcraftitems ('crocodile_skin','Crocodile Skin') -nssm_register_noneatcraftitems ('manticore_spine','Manticore Spine') -nssm_register_noneatcraftitems ('night_feather','Night Feather') -nssm_register_noneatcraftitems ('sun_feather','Sun Feather') -nssm_register_noneatcraftitems ('duck_feather','Duck Feather') -nssm_register_noneatcraftitems ('black_duck_feather','Black Duck Feather') -nssm_register_noneatcraftitems ('masticone_fang','Masticone Fang') -nssm_register_noneatcraftitems ('white_wolf_fur','White Wolf Fur') -nssm_register_noneatcraftitems ('stoneater_mandible','Stoneater Mandible') -nssm_register_noneatcraftitems ('ant_mandible','Ant Mandible') -nssm_register_noneatcraftitems ('life_energy','Life Energy') -nssm_register_noneatcraftitems ('wolf_fur','Wolf Fur') -nssm_register_noneatcraftitems ('felucco_fur','Felucco Fur') -nssm_register_noneatcraftitems ('felucco_horn','Felucco Horn') -nssm_register_noneatcraftitems ('energy_globe','Energy Globe') -nssm_register_noneatcraftitems ('greedy_soul_fragment','Greedy Soul Fragment') -nssm_register_noneatcraftitems ('lustful_soul_fragment','Lustful Soul Fragment') -nssm_register_noneatcraftitems ('wrathful_soul_fragment','Wrathful Soul Fragment') -nssm_register_noneatcraftitems ('proud_soul_fragment','Proud Soul Fragment') -nssm_register_noneatcraftitems ('slothful_soul_fragment','Slothful Soul Fragment') -nssm_register_noneatcraftitems ('envious_soul_fragment','Envious Soul Fragment') -nssm_register_noneatcraftitems ('gluttonous_soul_fragment','Gluttonous Soul Fragment') -nssm_register_noneatcraftitems ('gluttonous_moranga','Gluttonous Moranga') -nssm_register_noneatcraftitems ('envious_moranga','Envious Moranga') -nssm_register_noneatcraftitems ('proud_moranga','Proud Moranga') -nssm_register_noneatcraftitems ('slothful_moranga','Slothful Moranga') -nssm_register_noneatcraftitems ('lustful_moranga','Lustful Moranga') -nssm_register_noneatcraftitems ('wrathful_moranga','Wrathful Moranga') -nssm_register_noneatcraftitems ('greedy_moranga','Greedy Moranga') -nssm_register_noneatcraftitems ('mantis_skin','Mantis_skin') -nssm_register_noneatcraftitems ('sand_bloco_skin','Sand Bloco Skin') -nssm_register_noneatcraftitems ('sandworm_skin','Sandworm Skin') -nssm_register_noneatcraftitems ('sky_iron','Sky Iron') -nssm_register_noneatcraftitems ('web_string','Cobweb String') -nssm_register_noneatcraftitems ('dense_web_string','Dense Cobweb String') -nssm_register_noneatcraftitems ('black_powder','Black Powder') -nssm_register_noneatcraftitems ('morelentir_dust','Dark Starred Stone Dust') -nssm_register_noneatcraftitems ('empty_evocation_bomb','Empty Evocation Bomb') +nssm_craftitem ('sky_feather','Sky Feather') +nssm_craftitem ('snake_scute','Snake Scute') +nssm_craftitem ('eyed_tentacle','Eyed Tentacle') +--nssm_craftitem ('king_duck_crown','King Duck Crown') +nssm_craftitem ('great_energy_globe','Great Energy Globe') +nssm_craftitem ('superior_energy_globe','Superior Energy Globe') +nssm_craftitem ('ant_queen_abdomen','Ant Queen Abdomen') +--nssm_craftitem ('masticone_skull','Masticone Skull') +nssm_craftitem ('masticone_skull_fragments','Masticone Skull Fragments') +--nssm_craftitem ('masticone_skull_crowned','Masticone Skull Crowned') +nssm_craftitem ('tentacle_curly','Kraken Tentacle') +nssm_craftitem ('lava_titan_eye','Lava Titan Eye') +nssm_craftitem ('duck_beak','Duck Beak') +nssm_craftitem ('ice_tooth','Ice Tooth') +nssm_craftitem ('little_ice_tooth','Little Ice Tooth') +nssm_craftitem ('digested_sand',"Digested Sand") +nssm_craftitem ('black_ice_tooth','Black Ice Tooth') +nssm_craftitem ('tarantula_chelicerae','Tarantula Chelicerae') +nssm_craftitem ('crab_chela','Crab Chela') +nssm_craftitem ('cursed_pumpkin_seed','Cursed Pumpkin Seed') +nssm_craftitem ('mantis_claw','Mantis Claw') +nssm_craftitem ('manticore_fur','Manticore Fur') +nssm_craftitem ('ant_hard_skin','Ant Hard Skin') +nssm_craftitem ('bloco_skin','Bloco Skin') +nssm_craftitem ('crab_carapace_fragment','Crab Carapace Fragment') +nssm_craftitem ('crocodile_skin','Crocodile Skin') +nssm_craftitem ('manticore_spine','Manticore Spine') +nssm_craftitem ('night_feather','Night Feather') +nssm_craftitem ('sun_feather','Sun Feather') +nssm_craftitem ('duck_feather','Duck Feather') +nssm_craftitem ('black_duck_feather','Black Duck Feather') +nssm_craftitem ('masticone_fang','Masticone Fang') +nssm_craftitem ('white_wolf_fur','White Wolf Fur') +nssm_craftitem ('stoneater_mandible','Stoneater Mandible') +nssm_craftitem ('ant_mandible','Ant Mandible') +nssm_craftitem ('life_energy','Life Energy') +nssm_craftitem ('wolf_fur','Wolf Fur') +nssm_craftitem ('felucco_fur','Felucco Fur') +nssm_craftitem ('felucco_horn','Felucco Horn') +nssm_craftitem ('energy_globe','Energy Globe') +nssm_craftitem ('greedy_soul_fragment','Greedy Soul Fragment') +nssm_craftitem ('lustful_soul_fragment','Lustful Soul Fragment') +nssm_craftitem ('wrathful_soul_fragment','Wrathful Soul Fragment') +nssm_craftitem ('proud_soul_fragment','Proud Soul Fragment') +nssm_craftitem ('slothful_soul_fragment','Slothful Soul Fragment') +nssm_craftitem ('envious_soul_fragment','Envious Soul Fragment') +nssm_craftitem ('gluttonous_soul_fragment','Gluttonous Soul Fragment') +nssm_craftitem ('gluttonous_moranga','Gluttonous Moranga') +nssm_craftitem ('envious_moranga','Envious Moranga') +nssm_craftitem ('proud_moranga','Proud Moranga') +nssm_craftitem ('slothful_moranga','Slothful Moranga') +nssm_craftitem ('lustful_moranga','Lustful Moranga') +nssm_craftitem ('wrathful_moranga','Wrathful Moranga') +nssm_craftitem ('greedy_moranga','Greedy Moranga') +nssm_craftitem ('mantis_skin','Mantis_skin') +nssm_craftitem ('sand_bloco_skin','Sand Bloco Skin') +nssm_craftitem ('sandworm_skin','Sandworm Skin') +nssm_craftitem ('sky_iron','Sky Iron') +nssm_craftitem ('web_string','Cobweb String') +nssm_craftitem ('dense_web_string','Dense Cobweb String') +nssm_craftitem ('black_powder','Black Powder') +nssm_craftitem ('morelentir_dust','Dark Starred Stone Dust') +nssm_craftitem ('empty_evocation_bomb','Empty Evocation Bomb') -function nssm_register_eatcraftitems (name, descr, gnam) -minetest.register_craftitem("nssm:"..name, { - description = descr, - image =name..".png", - on_use = minetest.item_eat(gnam), - groups = { meat=1, eatable=1 }, -}) +local function nssm_craftitem_eat (name, descr, gnam) + minetest.register_craftitem("nssm:"..name, { + description = descr, + image =name..".png", + on_use = minetest.item_eat(gnam), + groups = { meat=1, eatable=1 }, + }) end -nssm_register_eatcraftitems ('werewolf_leg','Werewolf Leg',3) -nssm_register_eatcraftitems ('felucco_steak','Felucco Steak',3) -nssm_register_eatcraftitems ('roasted_felucco_steak','Roasted Felucco Steak',6) -nssm_register_eatcraftitems ('heron_leg','Moonheron Leg',2) -nssm_register_eatcraftitems ('chichibios_heron_leg',"Chichibio's Moonheron Leg",4) -nssm_register_eatcraftitems ('crocodile_tail','Crocodile Tail',3) -nssm_register_eatcraftitems ('roasted_crocodile_tail','Roasted Crocodile Tail',6) -nssm_register_eatcraftitems ('roasted_werewolf_leg','Roasted_Werewolf Leg',6) -nssm_register_eatcraftitems ('duck_legs','Duck Legs',1) -nssm_register_eatcraftitems ('roasted_duck_legs','Roasted Duck Leg',3) -nssm_register_eatcraftitems ('ant_leg','Ant Leg',-1) -nssm_register_eatcraftitems ('roasted_ant_leg','Roasted Ant Leg',4) -nssm_register_eatcraftitems ('spider_leg','Spider Leg',-1) -nssm_register_eatcraftitems ('roasted_spider_leg','Roasted Spider Leg',4) ---nssm_register_eatcraftitems ('brain','Brain',3) ---nssm_register_eatcraftitems ('roasted_brain','Roasted Brain',8) -nssm_register_eatcraftitems ('tentacle','Tentacle',2) -nssm_register_eatcraftitems ('roasted_tentacle','Roasted Tentacle',5) -nssm_register_eatcraftitems ('worm_flesh','Worm Flesh',-2) -nssm_register_eatcraftitems ('roasted_worm_flesh','Roasted Worm Flesh',4) -nssm_register_eatcraftitems ('amphibian_heart','Amphibian Heart',1) -nssm_register_eatcraftitems ('roasted_amphibian_heart','Roasted Amphibian Heart',8) -nssm_register_eatcraftitems ('raw_scrausics_wing','Raw Scrausics Wing',1) -nssm_register_eatcraftitems ('spicy_scrausics_wing','Spicy Scrausics Wing',6) -nssm_register_eatcraftitems ('phoenix_nuggets','Phoenix Nuggets',20) -nssm_register_eatcraftitems ('phoenix_tear','Phoenix Tear',20) -nssm_register_eatcraftitems ('frosted_amphibian_heart','Frosted Amphibian Heart',-1) -nssm_register_eatcraftitems ('surimi','Surimi',4) -nssm_register_eatcraftitems ('amphibian_ribs','Amphibian Ribs',2) -nssm_register_eatcraftitems ('roasted_amphibian_ribs','Roasted Amphibian Ribs',6) -nssm_register_eatcraftitems ('dolidrosaurus_fin','Dolidrosaurus Fin',-2) -nssm_register_eatcraftitems ('roasted_dolidrosaurus_fin','Roasted Dolidrosaurus Fin',4) -nssm_register_eatcraftitems ('larva_meat','Larva Meat',-1) -nssm_register_eatcraftitems ('larva_juice','Larva Juice',-3) -nssm_register_eatcraftitems ('larva_soup','Larva Soup',10) -nssm_register_eatcraftitems ('mantis_meat','Mantis Meat',1) -nssm_register_eatcraftitems ('roasted_mantis_meat','Roasted Mantis Meat',4) -nssm_register_eatcraftitems ('spider_meat','Spider Meat',-1) -nssm_register_eatcraftitems ('roasted_spider_meat','Roasted Spider Meat',3) -nssm_register_eatcraftitems ('silk_gland','Silk Gland',-1) -nssm_register_eatcraftitems ('roasted_silk_gland','Roasted Silk Gland',3) -nssm_register_eatcraftitems ('super_silk_gland','Super Silk Gland',-8) -nssm_register_eatcraftitems ('roasted_super_silk_gland','Roasted Super Silk Gland',2) +nssm_craftitem_eat ('werewolf_leg','Werewolf Leg',3) +nssm_craftitem_eat ('felucco_steak','Felucco Steak',3) +nssm_craftitem_eat ('roasted_felucco_steak','Roasted Felucco Steak',6) +nssm_craftitem_eat ('heron_leg','Moonheron Leg',2) +nssm_craftitem_eat ('chichibios_heron_leg',"Chichibio's Moonheron Leg",4) +nssm_craftitem_eat ('crocodile_tail','Crocodile Tail',3) +nssm_craftitem_eat ('roasted_crocodile_tail','Roasted Crocodile Tail',6) +nssm_craftitem_eat ('roasted_werewolf_leg','Roasted_Werewolf Leg',6) +nssm_craftitem_eat ('duck_legs','Duck Legs',1) +nssm_craftitem_eat ('roasted_duck_legs','Roasted Duck Leg',3) +nssm_craftitem_eat ('ant_leg','Ant Leg',-1) +nssm_craftitem_eat ('roasted_ant_leg','Roasted Ant Leg',4) +nssm_craftitem_eat ('spider_leg','Spider Leg',-1) +nssm_craftitem_eat ('roasted_spider_leg','Roasted Spider Leg',4) +--nssm_craftitem_eat ('brain','Brain',3) +--nssm_craftitem_eat ('roasted_brain','Roasted Brain',8) +nssm_craftitem_eat ('tentacle','Tentacle',2) +nssm_craftitem_eat ('roasted_tentacle','Roasted Tentacle',5) +nssm_craftitem_eat ('worm_flesh','Worm Flesh',-2) +nssm_craftitem_eat ('roasted_worm_flesh','Roasted Worm Flesh',4) +nssm_craftitem_eat ('amphibian_heart','Amphibian Heart',1) +nssm_craftitem_eat ('roasted_amphibian_heart','Roasted Amphibian Heart',8) +nssm_craftitem_eat ('raw_scrausics_wing','Raw Scrausics Wing',1) +nssm_craftitem_eat ('spicy_scrausics_wing','Spicy Scrausics Wing',6) +nssm_craftitem_eat ('phoenix_nuggets','Phoenix Nuggets',20) +nssm_craftitem_eat ('phoenix_tear','Phoenix Tear',20) +nssm_craftitem_eat ('frosted_amphibian_heart','Frosted Amphibian Heart',-1) +nssm_craftitem_eat ('surimi','Surimi',4) +nssm_craftitem_eat ('amphibian_ribs','Amphibian Ribs',2) +nssm_craftitem_eat ('roasted_amphibian_ribs','Roasted Amphibian Ribs',6) +nssm_craftitem_eat ('dolidrosaurus_fin','Dolidrosaurus Fin',-2) +nssm_craftitem_eat ('roasted_dolidrosaurus_fin','Roasted Dolidrosaurus Fin',4) +nssm_craftitem_eat ('larva_meat','Larva Meat',-1) +nssm_craftitem_eat ('larva_juice','Larva Juice',-3) +nssm_craftitem_eat ('larva_soup','Larva Soup',10) +nssm_craftitem_eat ('mantis_meat','Mantis Meat',1) +nssm_craftitem_eat ('roasted_mantis_meat','Roasted Mantis Meat',4) +nssm_craftitem_eat ('spider_meat','Spider Meat',-1) +nssm_craftitem_eat ('roasted_spider_meat','Roasted Spider Meat',3) +nssm_craftitem_eat ('silk_gland','Silk Gland',-1) +nssm_craftitem_eat ('roasted_silk_gland','Roasted Silk Gland',3) +nssm_craftitem_eat ('super_silk_gland','Super Silk Gland',-8) +nssm_craftitem_eat ('roasted_super_silk_gland','Roasted Super Silk Gland',2) --ore generation minetest.register_ore({ - ore_type = "scatter", - ore = "nssm:modders_block", - wherein = "default:stone", - clust_scarcity = 50*50*50, - clust_num_ores = 1, - clust_size = 1, - y_min = -115, - y_max = -95, - }) + ore_type = "scatter", + ore = "nssm:modders_block", + wherein = "default:stone", + clust_scarcity = 50*50*50, + clust_num_ores = 1, + clust_size = 1, + y_min = -115, + y_max = -95, +}) + for i=1,9 do -minetest.register_ore({ - ore_type = "scatter", - ore = "nssm:ant_dirt", - wherein = "default:cobble", - clust_scarcity = 1, - clust_num_ores = 1, - clust_size = 1, - y_min = -1, - y_max = 40, - }) minetest.register_ore({ - ore_type = "scatter", - ore = "nssm:ant_dirt", - wherein = "default:mossycobble", - clust_scarcity = 1, - clust_num_ores = 1, - clust_size = 1, - y_min = -1000, - y_max = 40, - }) + ore_type = "scatter", + ore = "nssm:ant_dirt", + wherein = "default:cobble", + clust_scarcity = 1, + clust_num_ores = 1, + clust_size = 1, + y_min = -1, + y_max = 40, +}) minetest.register_ore({ - ore_type = "scatter", - ore = "nssm:ant_dirt", - wherein = "default:sandstonebrick", - clust_scarcity = 1, - clust_num_ores = 1, - clust_size = 1, - y_min = -1000, - y_max = 40, - }) + ore_type = "scatter", + ore = "nssm:ant_dirt", + wherein = "default:mossycobble", + clust_scarcity = 1, + clust_num_ores = 1, + clust_size = 1, + y_min = -1000, + y_max = 40, +}) minetest.register_ore({ - ore_type = "scatter", - ore = "nssm:ant_dirt", - wherein = "stairs:stair_sandstonebrick", - clust_scarcity = 1, - clust_num_ores = 1, - clust_size = 1, - y_min = -1000, - y_max = 40, - }) + ore_type = "scatter", + ore = "nssm:ant_dirt", + wherein = "default:sandstonebrick", + clust_scarcity = 1, + clust_num_ores = 1, + clust_size = 1, + y_min = -1000, + y_max = 40, +}) minetest.register_ore({ - ore_type = "scatter", - ore = "nssm:ant_dirt", - wherein = "stairs:stair_cobble", - clust_scarcity = 1, - clust_num_ores = 1, - clust_size = 1, - y_min = -1000, - y_max = 40, - }) -end + ore_type = "scatter", + ore = "nssm:ant_dirt", + wherein = "stairs:stair_sandstonebrick", + clust_scarcity = 1, + clust_num_ores = 1, + clust_size = 1, + y_min = -1000, + y_max = 40, +}) minetest.register_ore({ - ore_type = "scatter", - ore = "nssm:web", - wherein = "default:junglegrass", - clust_scarcity = 2*2*2, - clust_num_ores = 2, - clust_size = 2, - y_min = -20, - y_max = 200, - }) + ore_type = "scatter", + ore = "nssm:ant_dirt", + wherein = "stairs:stair_cobble", + clust_scarcity = 1, + clust_num_ores = 1, + clust_size = 1, + y_min = -1000, + y_max = 40, +}) + +end -- END for loop minetest.register_ore({ - ore_type = "scatter", - ore = "nssm:web", - wherein = "default:jungleleaves", - clust_scarcity = 4*4*4, - clust_num_ores = 5, - clust_size = 5, - y_min = -20, - y_max = 200, - } -) + ore_type = "scatter", + ore = "nssm:web", + wherein = "default:junglegrass", + clust_scarcity = 2*2*2, + clust_num_ores = 2, + clust_size = 2, + y_min = -20, + y_max = 200, +}) + +minetest.register_ore({ + ore_type = "scatter", + ore = "nssm:web", + wherein = "default:jungleleaves", + clust_scarcity = 4*4*4, + clust_num_ores = 5, + clust_size = 5, + y_min = -20, + y_max = 200, +}) --nodes @@ -256,7 +257,8 @@ minetest.register_node("nssm:venomous_gas", { inventory_image = minetest.inventorycube("venomous_gas.png"), drawtype = "airlike", tiles = { - {name="venomous_gas_animated.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=3.0}} + {name="venomous_gas_animated.png", + animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=3.0}} }, paramtype = "light", walkable = false, @@ -282,7 +284,7 @@ minetest.register_node("nssm:web", { description = "Web", inventory_image = "web.png", tiles = {"web.png"} , - drawtype = "plantlike", + drawtype = "plantlike", paramtype = "light", walkable = false, pointable = true, @@ -303,7 +305,7 @@ minetest.register_node("nssm:thick_web", { description = "Thick Web", inventory_image = "thick_web.png", tiles = {"thick_web.png"} , - drawtype = "firelike", + drawtype = "firelike", paramtype = "light", walkable = false, pointable = true, @@ -396,6 +398,7 @@ minetest.register_abm({ end }) +--[[ These don't actually do anything minetest.register_abm({ nodenames = {"nssm:web"}, neighbors = {"default:junglegrass"}, @@ -434,6 +437,7 @@ minetest.register_abm({ end end }) +]] minetest.register_node("nssm:phoenix_fire", { description = "Phoenix Fire", @@ -450,7 +454,7 @@ minetest.register_node("nssm:phoenix_fire", { walkable = false, buildable_to = false, damage_per_second = 4, - }) +}) minetest.register_abm({ nodenames = {"nssm:phoenix_fire"}, @@ -458,8 +462,8 @@ minetest.register_abm({ interval = 3, chance = 2, action = function(pos, node) - minetest.set_node({x = pos.x, y = pos.y , z = pos.z}, {name = "air"}) - end + minetest.set_node({x = pos.x, y = pos.y , z = pos.z}, {name = "air"}) + end }) minetest.register_abm({ @@ -468,8 +472,8 @@ minetest.register_abm({ interval = 15, chance = 3, action = function(pos, node) - minetest.set_node({x = pos.x, y = pos.y , z = pos.z}, {name = "air"}) - end + minetest.set_node({x = pos.x, y = pos.y , z = pos.z}, {name = "air"}) + end }) --tools @@ -563,15 +567,15 @@ minetest.register_tool("nssm:mantis_battleaxe", { }) minetest.register_node("nssm:rope", { - description = "Rope", - paramtype = "light", + description = "Rope", + paramtype = "light", walkable = false, - climbable = true, - sunlight_propagates = true, + climbable = true, + sunlight_propagates = true, drawtype = "plantlike", - drops = "nssm:rope", - tiles = { "rope.png" }, - groups = {snappy=1}, + drops = "nssm:rope", + tiles = { "rope.png" }, + groups = {snappy=1}, }) minetest.register_tool("nssm:stoneater_pick", { @@ -645,38 +649,19 @@ minetest.register_tool("nssm:felucco_knife", { if minetest.get_modpath("farming") then -farming.register_hoe(":farming:felucco_hoe", { - description = "Felucco Hoe", - inventory_image = "felucco_hoe.png", - max_uses = 290, - material = "nssm:felucco_horn" -}) - -farming.register_hoe(":farming:ant_hoe", { - description = "Ant Hoe", - inventory_image = "ant_hoe.png", - max_uses = 350, - material = "nssm:ant_mandible" -}) - -minetest.register_craft({ - output = 'nssm:ant_hoe', - recipe = { - {'nssm:ant_mandible', 'nssm:ant_mandible'}, - {'', 'group:stick'}, - {'', 'group:stick'}, - } -}) - -minetest.register_craft({ - output = 'nssm:felucco_hoe', - recipe = { - {'nssm:felucco_horn', 'nssm:felucco_horn'}, - {'', 'group:stick'}, - {'', 'group:stick'}, - } -}) + farming.register_hoe(":farming:felucco_hoe", { + description = "Felucco Hoe", + inventory_image = "felucco_hoe.png", + max_uses = 290, + material = "nssm:felucco_horn" + }) + farming.register_hoe(":farming:ant_hoe", { + description = "Ant Hoe", + inventory_image = "ant_hoe.png", + max_uses = 350, + material = "nssm:ant_mandible" + }) end minetest.register_tool("nssm:ant_sword", { @@ -692,8 +677,6 @@ minetest.register_tool("nssm:ant_sword", { }, }) - - minetest.register_tool("nssm:ant_shovel", { description = "Ant Shovel", inventory_image = "ant_shovel.png", @@ -732,8 +715,8 @@ minetest.register_tool("nssm:mantis_axe", { choppy={times={[1]=2.20, [2]=1.00, [3]=0.60}, uses=30, maxlevel=3}, }, damage_groups = {fleshy=5}, - }, - }) + }, +}) minetest.register_tool("nssm:ant_billhook", { description = "Ant Billhook", @@ -746,8 +729,8 @@ minetest.register_tool("nssm:ant_billhook", { snappy={times={[1]=1.40, [2]=1.00, [3]=0.60}, uses=30, maxlevel=3}, }, damage_groups = {fleshy=6}, - }, - }) + }, +}) minetest.register_tool("nssm:duck_beak_pick",{ description = "Duck Beak Pickaxe", @@ -759,7 +742,7 @@ minetest.register_tool("nssm:duck_beak_pick",{ cracky = {times={[1]=1.0, [2]=0.8, [3]=0.20}, uses=3, maxlevel=3}, }, damage_groups = {fleshy=5}, - }, + }, }) minetest.register_tool("nssm:ant_pick", { @@ -854,7 +837,7 @@ minetest.register_tool("nssm:axe_of_pride", { player_inv:set_stack('main', found, items) part = 1 end - else + else if (obj:get_luaentity().health) then --minetest.chat_send_all("Entity") obj:get_luaentity().health = obj:get_luaentity().health -10 @@ -868,7 +851,7 @@ minetest.register_tool("nssm:axe_of_pride", { player_inv:set_stack('main', found, items) part = 1 end - end + end if part == 1 then local s = dropper:get_pos() local p = obj:get_pos() @@ -894,7 +877,7 @@ minetest.register_tool("nssm:axe_of_pride", { end end end - end + end end, }) @@ -912,8 +895,8 @@ minetest.register_tool("nssm:gratuitousness_battleaxe", { damage_groups = {fleshy=18}, }, on_drop = function(itemstack, dropper, pos) - local objects = minetest.get_objects_inside_radius(pos, 10) - local flag = 0 + local objects = minetest.get_objects_inside_radius(pos, 10) + local flag = 0 local vec = dropper:get_look_dir() local pos = dropper:get_pos() --vec.y = 0 @@ -959,78 +942,78 @@ minetest.register_tool("nssm:sword_of_eagerness", { damage_groups = {fleshy=14}, }, on_drop = function(itemstack, dropper, pos) - local objects = minetest.get_objects_inside_radius(pos, 10) - local flag = 0 - for _,obj in ipairs(objects) do + local objects = minetest.get_objects_inside_radius(pos, 10) + local flag = 0 + for _,obj in ipairs(objects) do local part = 0 - if flag == 0 then - local pname = dropper:get_player_name() - local player_inv = minetest.get_inventory({type='player', name = pname}) + if flag == 0 then + local pname = dropper:get_player_name() + local player_inv = minetest.get_inventory({type='player', name = pname}) - if player_inv:is_empty('main') then - --minetest.chat_send_all("Inventory empty") - else - local found = 0 - for i = 1,32 do - local items = player_inv:get_stack('main', i) - local n = items:get_name() - if n == "nssm:energy_globe" then - found = i - break - end - end - if found == 0 then - minetest.chat_send_player(pname, "You haven't got any Energy Globe!") - return - else + if player_inv:is_empty('main') then + --minetest.chat_send_all("Inventory empty") + else + local found = 0 + for i = 1,32 do + local items = player_inv:get_stack('main', i) + local n = items:get_name() + if n == "nssm:energy_globe" then + found = i + break + end + end + if found == 0 then + minetest.chat_send_player(pname, "You haven't got any Energy Globe!") + return + else local pos = obj:get_pos() pos.y = pos.y + 15 - if (obj:is_player()) then - if (obj:get_player_name()~=dropper:get_player_name()) then + if (obj:is_player()) then + if (obj:get_player_name()~=dropper:get_player_name()) then part=1 obj:set_pos(pos) - --flag = 1 + --flag = 1 - local items = player_inv:get_stack('main', found) - items:take_item() - player_inv:set_stack('main', found, items) - end - else - if (obj:get_luaentity().health) then + local items = player_inv:get_stack('main', found) + items:take_item() + player_inv:set_stack('main', found, items) + end + else + if (obj:get_luaentity().health) then obj:get_luaentity().old_y = pos.y - obj:set_pos(pos) + obj:set_pos(pos) part=1 - --flag = 1 + --flag = 1 - local items = player_inv:get_stack('main', found) - items:take_item() - player_inv:set_stack('main', found, items) - end - end + local items = player_inv:get_stack('main', found) + items:take_item() + player_inv:set_stack('main', found, items) + end + end if part==1 then local s = pos s.y = s.y - 15 minetest.add_particlespawner( - 25, --amount - 0.3, --time - vector.subtract(s, 0.5), --minpos - vector.add(s, 0.5), --maxpos - {x=0, y=10, z=0}, --minvel - {x=0.1, y=11, z=0.1}, --maxvel - {x=0,y=1,z=0}, --minacc - {x=0,y=1,z=0}, --maxacc - 0.5, --minexptime - 1, --maxexptime - 1, --minsize - 2, --maxsize - false, --collisiondetection - "slothful_soul_fragment.png" --texture - ) + 25, --amount + 0.3, --time + vector.subtract(s, 0.5), --minpos + vector.add(s, 0.5), --maxpos + {x=0, y=10, z=0}, --minvel + {x=0.1, y=11, z=0.1}, --maxvel + {x=0,y=1,z=0}, --minacc + {x=0,y=1,z=0}, --maxacc + 0.5, --minexptime + 1, --maxexptime + 1, --minsize + 2, --maxsize + false, --collisiondetection + "slothful_soul_fragment.png" --texture + ) end - end - end - end - end + end + end + end + end end, }) @@ -1140,43 +1123,43 @@ minetest.register_tool("nssm:sword_of_envy", { damage_groups = {fleshy=14}, }, on_drop = function(itemstack, dropper, pos) - local objects = minetest.get_objects_inside_radius(pos, 10) - local flag = 0 - for _,obj in ipairs(objects) do - if flag == 0 then - local pname = dropper:get_player_name() - local player_inv = minetest.get_inventory({type='player', name = pname}) + local objects = minetest.get_objects_inside_radius(pos, 10) + local flag = 0 + for _,obj in ipairs(objects) do + if flag == 0 then + local pname = dropper:get_player_name() + local player_inv = minetest.get_inventory({type='player', name = pname}) - if player_inv:is_empty('main') then - --minetest.chat_send_all("Inventory empty") - else - local found = 0 - for i = 1,32 do - local items = player_inv:get_stack('main', i) - local n = items:get_name() - if n == "nssm:energy_globe" then - found = i - break - end - end - if found == 0 then - minetest.chat_send_player(pname, "You haven't got any Energy Globe!") - return - else - if (obj:is_player()) then - --minetest.chat_send_all("Giocatore") - if (obj:get_player_name()~=dropper:get_player_name()) then - local hpp = obj:get_hp() + if player_inv:is_empty('main') then + --minetest.chat_send_all("Inventory empty") + else + local found = 0 + for i = 1,32 do + local items = player_inv:get_stack('main', i) + local n = items:get_name() + if n == "nssm:energy_globe" then + found = i + break + end + end + if found == 0 then + minetest.chat_send_player(pname, "You haven't got any Energy Globe!") + return + else + if (obj:is_player()) then + --minetest.chat_send_all("Giocatore") + if (obj:get_player_name()~=dropper:get_player_name()) then + local hpp = obj:get_hp() obj:set_hp(dropper:get_hp()) dropper:set_hp(hpp) - flag = 1 + flag = 1 - local items = player_inv:get_stack('main', found) - items:take_item() - player_inv:set_stack('main', found, items) - end - else - if (obj:get_luaentity().health) then + local items = player_inv:get_stack('main', found) + items:take_item() + player_inv:set_stack('main', found, items) + end + else + if (obj:get_luaentity().health) then local hpp = obj:get_luaentity().health obj:get_luaentity().health = dropper:get_hp() if hpp > 20 then @@ -1184,18 +1167,18 @@ minetest.register_tool("nssm:sword_of_envy", { else dropper:set_hp(hpp) end - check_for_death(obj:get_luaentity()) - flag = 1 + check_for_death(obj:get_luaentity()) + flag = 1 - local items = player_inv:get_stack('main', found) - items:take_item() - player_inv:set_stack('main', found, items) - end - end - end - end - end - end + local items = player_inv:get_stack('main', found) + items:take_item() + player_inv:set_stack('main', found, items) + end + end + end + end + end + end end, }) @@ -1246,7 +1229,7 @@ minetest.register_tool("nssm:sword_of_gluttony", { items:take_item() player_inv:set_stack('main', found, items) end - else + else if (obj:get_luaentity().health) then if obj:get_luaentity().health <= 32 then local pos = obj:get_pos() @@ -1286,11 +1269,11 @@ minetest.register_tool("nssm:sword_of_gluttony", { ) end end - end + end end end end - end + end end, }) @@ -1309,23 +1292,23 @@ minetest.register_tool("nssm:death_scythe", { }, groups ={not_in_creative_inventory=1}, on_drop = function(itemstack, dropper, pos) - local objects = minetest.get_objects_inside_radius(pos, 10) - local flag = 0 + local objects = minetest.get_objects_inside_radius(pos, 10) + local flag = 0 dropper:set_hp(dropper:get_hp()-9) - for _,obj in ipairs(objects) do + for _,obj in ipairs(objects) do flag = 0 - if (obj:is_player()) then - if (obj:get_player_name()~=dropper:get_player_name()) then - obj:set_hp(obj:get_hp()-40) - flag = 1 - end - else - if (obj:get_luaentity().health) then - obj:get_luaentity().health = obj:get_luaentity().health -40 - check_for_death(obj:get_luaentity()) - flag = 1 - end - end + if (obj:is_player()) then + if (obj:get_player_name()~=dropper:get_player_name()) then + obj:set_hp(obj:get_hp()-40) + flag = 1 + end + else + if (obj:get_luaentity().health) then + obj:get_luaentity().health = obj:get_luaentity().health -40 + check_for_death(obj:get_luaentity()) + flag = 1 + end + end if flag == 1 then for i = 1,math.random(1,2) do drop = minetest.add_item(pos, "nssm:energy_globe 1") @@ -1339,7 +1322,7 @@ minetest.register_tool("nssm:death_scythe", { end end end - end + end local pos = dropper:get_pos() local vec = {x=5,y=5,z=5} local poslist = minetest.find_nodes_in_area(vector.subtract(pos, vec), vector.add(pos,vec), "default:dirt_with_grass") @@ -1797,9 +1780,10 @@ if minetest.get_modpath("nssb") then nssm_register_moranga ("envious") nssm_register_moranga ("proud") end + --Eggs -function nssm_register_egg (name, descr) +local function nssm_register_egg (name, descr) minetest.register_craftitem("nssm:".. name, { description = descr .. " Egg", image = name.."_egg.png", @@ -1815,7 +1799,7 @@ function nssm_register_egg (name, descr) }) end -function nssm_register_egg2 (name, descr) --mobs you can't catch +local function nssm_register_egg2 (name, descr) --mobs you can't catch minetest.register_craftitem("nssm:".. name.."_egg", { description = descr .. " Egg", image = name.."_egg.png", @@ -1920,32 +1904,32 @@ minetest.register_craftitem("nssm:mese_egg", { --experimental morwa statue minetest.register_node("nssm:morwa_statue", { - description = 'Morwa Statue', - drawtype = 'mesh', - mesh = 'morwa_statue.b3d', - tiles = {'morwa_statue.png'}, - inventory_image = 'morwa_statue.png', - groups = {not_in_creative_inventory=1}, - paramtype = 'light', - paramtype2 = 'facedir', - selection_box = { - type = 'fixed', - fixed = {-1, -0.5, -1, 1, 3, 1}, -- Right, Bottom, Back, Left, Top, Front - }, - collision_box = { - type = 'fixed', - fixed = {-1, -0.5, -1, 1, 3, 1}, -- Right, Bottom, Back, Left, Top, Front - }, + description = 'Morwa Statue', + drawtype = 'mesh', + mesh = 'morwa_statue.b3d', + tiles = {'morwa_statue.png'}, + inventory_image = 'morwa_statue.png', + groups = {not_in_creative_inventory=1}, + paramtype = 'light', + paramtype2 = 'facedir', + selection_box = { + type = 'fixed', + fixed = {-1, -0.5, -1, 1, 3, 1}, -- Right, Bottom, Back, Left, Top, Front + }, + collision_box = { + type = 'fixed', + fixed = {-1, -0.5, -1, 1, 3, 1}, -- Right, Bottom, Back, Left, Top, Front + }, }) + --Abm to make the conversion between statue and the entity, caused by light minetest.register_abm({ nodenames = {"nssm:morwa_statue"}, neighbors = {"air"}, - interval = 1, + interval = 2, chance = 1, - action = - function(pos, node) + action = function(pos, node) local pos1 = {x=pos.x, y=pos.y+1, z=pos.z} local n = minetest.get_node(pos1).name if n ~= "air" then @@ -1958,10 +1942,9 @@ minetest.register_abm({ end end }) + --Eggs recipes - - minetest.register_craft({ output = 'nssm:duck', recipe = { diff --git a/nssm_spears.lua b/nssm_spears.lua index 98d0efc..b67e5e0 100644 --- a/nssm_spears.lua +++ b/nssm_spears.lua @@ -1,6 +1,7 @@ ---function -function spears_shot (itemstack, player) +--functions + +local function spears_shot (itemstack, player) local spear = itemstack:get_name() .. '_entity' local playerpos = player:get_pos() local obj = minetest.add_entity({x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, spear) @@ -22,7 +23,7 @@ function spears_shot (itemstack, player) end -function spears_set_entity(kind, eq, toughness) +local function spears_set_entity(kind, eq, toughness) local SPEAR_ENTITY={ physical = false, timer=0, @@ -86,11 +87,11 @@ end --Tools -function spears_register_spear(kind, desc, eq, toughness, material) +local function spears_register_spear(kind, desc, eq, toughness, material) minetest.register_tool("nssm:spear_" .. kind, { description = desc .. " Spear", - wield_image = "spear_" .. kind .. ".png", + wield_image = "spear_" .. kind .. ".png", inventory_image = "spear_" .. kind .. ".png^[transform4", wield_scale= {x=2,y=1,z=1}, on_drop = function(itemstack, user, pointed_thing) @@ -116,18 +117,18 @@ function spears_register_spear(kind, desc, eq, toughness, material) damage_groups = {fleshy=eq}, } }) - + local SPEAR_ENTITY=spears_set_entity(kind, eq, toughness) - + minetest.register_entity("nssm:spear_" .. kind .. "_entity", SPEAR_ENTITY) - + minetest.register_craft({ output = 'nssm:spear_' .. kind, recipe = { {'group:wood', 'group:wood', material}, } }) - + minetest.register_craft({ output = 'nssm:spear_' .. kind, recipe = { @@ -153,36 +154,36 @@ spears_register_spear('felucco_horn', 'Felucco Horn', 7, 9, 'nssm:felucco_horn') --Spear of peace - minetest.register_tool("nssm:spear_of_peace", { - description = "Spear of Peace", - wield_image = "spear_of_peace.png", - inventory_image = "spear_of_peace.png^[transform4", - wield_scale= {x=4,y=2,z=2}, - 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 = 0.7, - max_drop_level=1, - groupcaps={ - snappy = {times={[3]=0.2, [2]=0.2, [1]=0.2}, uses=500, maxlevel=1}, +minetest.register_tool("nssm:spear_of_peace", { + description = "Spear of Peace", + wield_image = "spear_of_peace.png", + inventory_image = "spear_of_peace.png^[transform4", + wield_scale= {x=4,y=2,z=2}, + 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 = 0.7, + max_drop_level=1, + groupcaps={ + snappy = {times={[3]=0.2, [2]=0.2, [1]=0.2}, uses=500, maxlevel=1}, }, - damage_groups = {fleshy=18}, - } - }) - - function spears_set_sentity(kind, eq, toughness) + damage_groups = {fleshy=18}, + } +}) + +local function spears_set_sentity(kind, eq, toughness) local SUPERSPEAR_ENTITY={ physical = false, timer=0, @@ -204,7 +205,7 @@ spears_register_spear('felucco_horn', 'Felucco Horn', 7, 9, 'nssm:felucco_horn') end end, } - + SUPERSPEAR_ENTITY.on_step = function(self, dtime) self.timer=self.timer+dtime local pos = self.object:get_pos() @@ -244,15 +245,14 @@ spears_register_spear('felucco_horn', 'Felucco Horn', 7, 9, 'nssm:felucco_horn') end return SUPERSPEAR_ENTITY end - - SUPERSPEAR_ENTITY=spears_set_sentity("of_peace", 30, 300) - - minetest.register_entity("nssm:spear_of_peace_entity", SUPERSPEAR_ENTITY) - - minetest.register_craft({ - output = 'nssm:spear_of_peace', - recipe = { - {'nssm:wrathful_moranga', 'group:wood', 'group:wood'}, - } - }) - \ No newline at end of file + +SUPERSPEAR_ENTITY=spears_set_sentity("of_peace", 30, 300) + +minetest.register_entity("nssm:spear_of_peace_entity", SUPERSPEAR_ENTITY) + +minetest.register_craft({ + output = 'nssm:spear_of_peace', + recipe = { + {'nssm:wrathful_moranga', 'group:wood', 'group:wood'}, + } +}) diff --git a/nssm_weapons.lua b/nssm_weapons.lua index 396a14a..ed7287e 100644 --- a/nssm_weapons.lua +++ b/nssm_weapons.lua @@ -1,353 +1,349 @@ --Parameters used by some weapons -local default_dir = { - x = 1, - y = 1, - z = 1, -} +local default_dir = {x = 1, y = 1, z = 1} --Function used to shoot: local function weapons_shot(itemstack, placer, pointed_thing, velocity, name) - local dir = placer:get_look_dir(); - local playerpos = placer:get_pos(); - local obj = minetest.add_entity({x=playerpos.x+0+dir.x,y=playerpos.y+2+dir.y,z=playerpos.z+0+dir.z}, "nssm:"..name) - local vec = {x=dir.x*velocity,y=dir.y*velocity,z=dir.z*velocity} - obj:set_velocity(vec) - return itemstack + local dir = placer:get_look_dir(); + local playerpos = placer:get_pos(); + local obj = minetest.add_entity({x=playerpos.x+0+dir.x,y=playerpos.y+2+dir.y,z=playerpos.z+0+dir.z}, "nssm:"..name) + local vec = {x=dir.x*velocity,y=dir.y*velocity,z=dir.z*velocity} + obj:set_velocity(vec) + return itemstack end local function hit(pos, self) - local node = node_ok(pos).name - self.hit_node(self, pos, node) - self.object:remove() - return + local node = node_ok(pos).name + self.hit_node(self, pos, node) + self.object:remove() + return end local function activate_balls(pos) - local radius = 50 - local objects = minetest.get_objects_inside_radius(pos, radius) - for _,obj in ipairs(objects) do - if (obj:get_luaentity() and obj:get_luaentity().name == "nssm:hellzone_grenade") then - obj:get_luaentity().move = 1 - end - end + local radius = 50 + local objects = minetest.get_objects_inside_radius(pos, radius) + for _,obj in ipairs(objects) do + if (obj:get_luaentity() and obj:get_luaentity().name == "nssm:hellzone_grenade") then + obj:get_luaentity().move = 1 + end + end end local function search_on_step2( - self, - dtime, --used to count time - max_time, --after this amount of time the entity is removec - radius, --radius in which look for entities to follow - vel) --velocity of the projectile + self, + dtime, --used to count time + max_time, --after this amount of time the entity is removec + radius, --radius in which look for entities to follow + vel) --velocity of the projectile - local pos = self.object:get_pos() + local pos = self.object:get_pos() - --Disappear after a certain time - if self.life_time == 0 then - self.life_time = os.time() - end - if os.time() - self.life_time > max_time then - self.object:remove() - return - end + --Disappear after a certain time + if self.life_time == 0 then + self.life_time = os.time() + end + if os.time() - self.life_time > max_time then + self.object:remove() + return + end - --Look for an entity to follow - local objects = minetest.get_objects_inside_radius(pos, radius) - local min_dist = 100 - local obj_min = nil - local obj_p = nil - local vec_min = nil - for _,obj in ipairs(objects) do - if (obj:is_player()) then - elseif (obj:get_luaentity() and obj:get_luaentity().name ~= "__builtin:item" and obj:get_luaentity().name ~= self.object:get_luaentity().name) then - obj_p = obj:get_pos() - local vec = {x=obj_p.x-pos.x, y=obj_p.y-pos.y, z=obj_p.z-pos.z} - local dist = (vec.x^2+vec.y^2+vec.z^2)^0.5 - if (dist max_time then - self.object:remove() - return - end + --Disappear after a certain time + if self.life_time == 0 then + self.life_time = os.time() + end + if os.time() - self.life_time > max_time then + self.object:remove() + return + end - --Look for an entity to follow - local objects = minetest.get_objects_inside_radius(pos, radius) - local min_dist = 100 - local obj_min = nil - local obj_p = nil - local vec_min = nil - for _,obj in ipairs(objects) do - if (obj:is_player()) then - elseif (obj:get_luaentity() and obj:get_luaentity().name ~= "__builtin:item" and obj:get_luaentity().name ~= self.object:get_luaentity().name) then - obj_p = obj:get_pos() - local vec = {x=obj_p.x-pos.x, y=obj_p.y-pos.y, z=obj_p.z-pos.z} - local dist = (vec.x^2+vec.y^2+vec.z^2)^0.5 - if (dist max_time then - local node = node_ok(pos).name - self.hit_node(self, pos, node) - self.object:remove() - return - end + if os.time() - self.life_time > max_time then + local node = node_ok(pos).name + self.hit_node(self, pos, node) + self.object:remove() + return + end - self.timer = self.timer + dtime - --minetest.chat_send_all("Timer: "..self.timer) + self.timer = self.timer + dtime + --minetest.chat_send_all("Timer: "..self.timer) - --while going around it damages entities - local objects = minetest.get_objects_inside_radius(pos, 2) - if self.timer > 0.1 then - self.timer = 0 - for _,obj in ipairs(objects) do - if obj:get_luaentity() then - if (obj:get_entity_name() ~= self.object:get_luaentity().name) and (obj:get_luaentity().name ~= "__builtin:item") then - if obj:is_player() then - obj:set_hp(obj:get_hp()-damage) - elseif obj:get_luaentity().health then - obj:get_luaentity().health = obj:get_luaentity().health - damage - --minetest.chat_send_all("Danneggiato: "..obj:get_entity_name().." Vita: "..obj:get_luaentity().health) - check_for_death(obj:get_luaentity()) - end - end - end - end - end + --while going around it damages entities + local objects = minetest.get_objects_inside_radius(pos, 2) + if self.timer > 0.1 then + self.timer = 0 + for _,obj in ipairs(objects) do + if obj:get_luaentity() then + if (obj:get_entity_name() ~= self.object:get_luaentity().name) and (obj:get_luaentity().name ~= "__builtin:item") then + if obj:is_player() then + obj:set_hp(obj:get_hp()-damage) + elseif obj:get_luaentity().health then + obj:get_luaentity().health = obj:get_luaentity().health - damage + --minetest.chat_send_all("Danneggiato: "..obj:get_entity_name().." Vita: "..obj:get_luaentity().health) + check_for_death(obj:get_luaentity()) + end + end + end + end + end - local n = minetest.get_node(pos).name - if n==not_transparent or minetest.get_item_group(n, not_transparent)==1 then - local node = node_ok(pos).name - self.hit_node(self, pos, node) - self.object:remove() - return - else - local vec = self.object:get_velocity() - local c=vel/10 - --calculate how many blocks around need to be removed - local max = 0 - local posmax = 0 - if max 60 then - self.object:remove() - return - end + --Disappear after a certain time + if self.life_time == 0 then + self.life_time = os.time() + end + if os.time() - self.life_time > 60 then + self.object:remove() + return + end - --Look for an entity to follow - local objects = minetest.get_objects_inside_radius(pos, 20) - local min_dist = 100 - local obj_min = nil - local obj_p = nil - local vec_min = nil - for _,obj in ipairs(objects) do - if (obj:is_player()) then - elseif (obj:get_luaentity() and obj:get_luaentity().name ~= "__builtin:item" and obj:get_luaentity().name ~= self.object:get_luaentity().name) then - obj_p = obj:get_pos() - local vec = {x=obj_p.x-pos.x, y=obj_p.y-pos.y, z=obj_p.z-pos.z} - local dist = (vec.x^2+vec.y^2+vec.z^2)^0.5 - if (dist 60 then - self.object:remove() - return - end + --Disappear after a certain time + if self.life_time == 0 then + self.life_time = os.time() + end + if os.time() - self.life_time > 60 then + self.object:remove() + return + end - if self.custom_timer == 0 then - self.custom_timer = os.time() - end + if self.custom_timer == 0 then + self.custom_timer = os.time() + end - if last_pos == nil or (last_pos ~= nil and last_pos ~= pos) then - minetest.set_node(pos, {name="nssm:invisible_light"}) - if last_pos ~= nil then - minetest.set_node(last_pos, {name="air"}) - end - last_pos = pos - end + if last_pos == nil or (last_pos ~= nil and last_pos ~= pos) then + minetest.set_node(pos, {name="nssm:invisible_light"}) + if last_pos ~= nil then + minetest.set_node(last_pos, {name="air"}) + end + last_pos = pos + end - --Look for an entity to follow - local objects = minetest.get_objects_inside_radius(pos, 20) - local min_dist = 100 - local obj_min = nil - local obj_p = nil - local vec_min = nil - for _,obj in ipairs(objects) do - if (obj:is_player()) then - elseif (obj:get_luaentity() and obj:get_luaentity().name ~= "__builtin:item" and obj:get_luaentity().name ~= self.object:get_luaentity().name) then - obj_p = obj:get_pos() - local vec = {x=obj_p.x-pos.x, y=obj_p.y-pos.y, z=obj_p.z-pos.z} - local dist = (vec.x^2+vec.y^2+vec.z^2)^0.5 - if (dist