diff --git a/darts.lua b/darts.lua index 0c4aa16..e5ee4e0 100644 --- a/darts.lua +++ b/darts.lua @@ -63,12 +63,16 @@ mobs:register_arrow("nssm:duck_father", { -- 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, @@ -106,16 +110,20 @@ mobs:register_arrow("nssm:snow_arrow", { visual = "sprite", visual_size = {x = 1, y = 1}, textures = {"transparent.png"}, - velocity =20, + velocity = 20, -- direct hit hit_player = function(self, player) + local pos = self.object:get_pos() + ice_explosion(pos) end, hit_mob = function(self, player) + local pos = self.object:get_pos() + ice_explosion(pos) end, @@ -134,6 +142,7 @@ mobs:register_arrow("nssm:spine", { -- direct hit hit_player = function(self, player) + player:punch(self.object, 1.0, { full_punch_interval = 1.0, damage_groups = {fleshy = 2} @@ -141,6 +150,7 @@ mobs:register_arrow("nssm:spine", { end, hit_mob = function(self, player) + player:punch(self.object, 1.0, { full_punch_interval = 1.0, damage_groups = {fleshy = 2} @@ -152,7 +162,7 @@ mobs:register_arrow("nssm:spine", { }) ---morbat arrow +-- morbat arrow mobs:register_arrow("nssm:morarrow", { visual = "sprite", visual_size = {x = 0.5, y = 0.5}, @@ -160,6 +170,7 @@ mobs:register_arrow("nssm:morarrow", { velocity= 13, hit_player = function(self, player) + player:punch(self.object, 1.0, { full_punch_interval = 1.0, damage_groups = {fleshy = 3} @@ -188,12 +199,12 @@ local function explosion_web(pos) 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"}) + 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 @@ -210,11 +221,14 @@ mobs:register_arrow("nssm:webball", { -- direct hit hit_player = function(self, player) + local p = player:get_pos() + explosion_web(p) end, hit_mob = function(self, player) + player:punch(self.object, 1.0, { full_punch_interval = 1.0, damage_groups = {fleshy = 1} @@ -244,12 +258,12 @@ function explosion_thickweb(pos) 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"}) + 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 @@ -370,7 +384,9 @@ mobs:register_arrow("nssm:super_gas", { -- direct hit hit_player = function(self, player) + local p = player:get_pos() + gas_explosion(p) end, diff --git a/init.lua b/init.lua index 6c6cc8f..a3e4221 100644 --- a/init.lua +++ b/init.lua @@ -58,10 +58,10 @@ dofile(path .. "/mobs/uloboros.lua") dofile(path .. "/mobs/werewolf.lua") dofile(path .. "/mobs/white_werewolf.lua") ---Final Boss +-- Final Boss dofile(path .. "/mobs/mese_dragon.lua") ---Others +-- Others dofile(path .. "/darts.lua") dofile(path .. "/nssm_materials.lua") dofile(path .. "/nssm_spears.lua") @@ -76,7 +76,7 @@ if minetest.get_modpath("3d_armor") then dofile(path .. "/nssm_armor.lua") end ---Spawn settings +-- Spawn settings dofile(path .. "/spawn.lua") diff --git a/mobs/ant_queen.lua b/mobs/ant_queen.lua index 576fb56..e7b2e1d 100644 --- a/mobs/ant_queen.lua +++ b/mobs/ant_queen.lua @@ -95,9 +95,9 @@ mobs:register_mob("nssm:ant_queen", { end end - if ((pos1.x ~= s.x) and (pos1.z ~= s.z)) - and (minetest.get_node(pos1).name == "air") - and (counter < 4) then + if pos1.x ~= s.x and pos1.z ~= s.z + and minetest.get_node(pos1).name == "air" + and counter < 4 then explosion_particles(pos1, 1) diff --git a/mobs/lava_titan.lua b/mobs/lava_titan.lua index fc412fb..933dff9 100644 --- a/mobs/lava_titan.lua +++ b/mobs/lava_titan.lua @@ -43,22 +43,6 @@ mobs:register_mob("nssm:lava_titan", { arrow = "nssm:lava_arrow", shoot_interval = 2, shoot_offset = 0, - --[[ - on_dist_attack = function(self, player) - local pos = player:get_pos() - for dy=-1, 6, 1 do - for dx=-1, 1, 2 do - 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 - minetest.set_node(p, {name="default:lava_flowing"}) - end - end - end - end - end, - ]] animation = { speed_normal = 25, speed_run = 45, @@ -76,36 +60,5 @@ mobs:register_mob("nssm:lava_titan", { do_custom = function (self) digging_attack(self, nil, self.run_velocity, {x = 0, y = 4, z = 0}) - --digging_ability(self, nil, self.run_velocity, {x=0, y=5, z=0}) - --putting_ability(self, "default:lava_source", self.run_velocity) - end, - --[[ - custom_attack = function (self) - digging_attack - mobs:set_animation(self, "punch") - local p2 = p - local s2 = s - - p2.y = p2.y + 1.5 - s2.y = s2.y + 1.5 - - if mobs:line_of_sight(self, p2, s2) == true then - - -- play attack sound - if self.sounds.attack then - - minetest.sound_play(self.sounds.attack, { - object = self.object, - max_hear_distance = self.sounds.distance - }) - end - - -- punch player - self.attack:punch(self.object, 1.0, { - full_punch_interval = 1.0, - damage_groups = {fleshy = self.damage} - }, nil) - end - end, - ]]-- + end }) diff --git a/mobs/morde.lua b/mobs/morde.lua index 5ca14a8..5bb0c57 100644 --- a/mobs/morde.lua +++ b/mobs/morde.lua @@ -164,7 +164,8 @@ minetest.register_entity("nssm:mortick", { local objects = minetest.get_objects_inside_radius(s, 8) for _,obj in ipairs(objects) do - if (obj:is_player()) then + + if obj:is_player() then self.attack = obj end end @@ -200,7 +201,7 @@ minetest.register_entity("nssm:mortick", { self.object:set_yaw(yaws) --damage player every ten seconds: - if (self.timer > 10) then + if self.timer > 10 then self.timer = 0 self.attack:set_hp(self.attack:get_hp() - self.damage) end diff --git a/mobs/morgut.lua b/mobs/morgut.lua index 069cc0c..41763d6 100644 --- a/mobs/morgut.lua +++ b/mobs/morgut.lua @@ -136,11 +136,10 @@ mobs:register_mob("nssm:morgut", { local player_inv = minetest.get_inventory( {type = "player", name = pname}) - if player_inv:is_empty("main") then - --minetest.chat_send_all("Inventory empty") - else + if not player_inv:is_empty("main") then + for i = 1, 32 do - --minetest.chat_send_all("Inventory is not empty") + local items = player_inv:get_stack("main", i) local n = items:get_name() @@ -154,11 +153,13 @@ mobs:register_mob("nssm:morgut", { if found == 0 then if self.inventory[j].num == 0 then - --found an empty place + + -- found an empty place found = 2 index = j else - --found a corrsponding itemstack + + -- found a corrsponding itemstack if self.inventory[j].name == n then self.inventory[j].num = self.inventory[j].num + 1 diff --git a/mobs/morlu.lua b/mobs/morlu.lua index edd2053..f9f0341 100644 --- a/mobs/morlu.lua +++ b/mobs/morlu.lua @@ -201,21 +201,25 @@ mobs:register_mob("nssm:morlu", { --armor:update_player_visuals(self.attack) --Update personal inventory of armors: - if (self.invnum ~= nil) and (self.invnum <= 5) then + if self.invnum ~= nil and self.invnum <= 5 then self.invnum = self.invnum + 1 self.inventory[self.invnum].name = armor_elements[steal_pos].name end mobs:set_animation(self, "run") + self.flag = 1 self.morlu_timer = os.time() self.curr_attack = self.attack self.state = "" + local pyaw = self.curr_attack:get_look_horizontal() + math.pi / 2 + self.dir = pyaw self.object:set_yaw(pyaw) + if self then set_velocity(self, 4) end @@ -235,6 +239,7 @@ mobs:register_mob("nssm:morlu", { -- play attack sound if self.sounds.attack then + minetest.sound_play(self.sounds.attack, { object = self.object, max_hear_distance = self.sounds.distance @@ -265,11 +270,11 @@ mobs:register_mob("nssm:morlu", { local items = ItemStack(self.inventory[i].name .. " 1") local obj = minetest.add_item(pos, items) - obj:set_velocity({ - x = math.random(-1, 1), - y = 6, - z = math.random(-1, 1) - }) + obj:set_velocity({ + x = math.random(-1, 1), + y = 6, + z = math.random(-1, 1) + }) end end end diff --git a/mobs/morvalar.lua b/mobs/morvalar.lua index f5f349f..d0d8705 100644 --- a/mobs/morvalar.lua +++ b/mobs/morvalar.lua @@ -13,8 +13,11 @@ function respawn_block(self) self.hp_record = self.health else if os.time() - self.stop_timer > time_limit then + minetest.chat_send_all("Time is over!") + self.object:remove() + if minetest.get_modpath("nssb") then minetest.set_node(posmorvalarblock, {name="nssb:morvalar_block"}) end @@ -99,7 +102,8 @@ mobs:register_mob("nssm:morvalar", { local pname = self.attack:get_player_name() local player_inv = minetest.get_inventory({type = "player", name = pname}) - if player_inv:is_empty('armor') then + if player_inv:is_empty("armor") then + -- punch player if he doesn't own an armor self.attack:punch(self.object, 1.0, { full_punch_interval = 1.0, @@ -196,6 +200,7 @@ mobs:register_mob("nssm:morvalar", { -- play attack sound if self.sounds.attack then + minetest.sound_play(self.sounds.attack, { object = self.object, max_hear_distance = self.sounds.distance @@ -284,7 +289,9 @@ mobs:register_mob("nssm:morvalar6", { local s = self.object:get_pos() local p = self.attack:get_pos() + mobs:set_animation(self, "punch") + local m = 2 minetest.after(1, function (self) @@ -295,30 +302,35 @@ mobs:register_mob("nssm:morvalar6", { local player_inv = minetest.get_inventory({ type = "player", name = pname}) - if player_inv:is_empty("main") then - --minetest.chat_send_all("Inventory empty") - else + if not player_inv:is_empty("main") then + local imhungry = 0 for i = 1, 32 do - --minetest.chat_send_all("Inventory is not empty") + local items = player_inv:get_stack("main", i) local n = items:get_name() - if minetest.get_item_group(n, "eatable")==1 then + + if minetest.get_item_group(n, "eatable") == 1 then + imhungry = 1 + for t = 0, 2 do items:take_item() end + player_inv:set_stack("main", i, items) end end if imhungry == 0 then + self.attack:punch(self.object, 1.0, { full_punch_interval = 1.0, damage_groups = {fleshy = self.damage} }, nil) else s.y = s.y + 1.8 + minetest.add_particlespawner({ amount = 1, time = 1, @@ -347,13 +359,16 @@ mobs:register_mob("nssm:morvalar6", { self.morvalar6_timer = os.time() end end - end, self) end end, + on_die = function(self) + local pos = self.object:get_pos() + self.object:remove() + add_entity_and_particles("nssm:morvalar5", pos, "morparticle.png", 10) end }) @@ -405,27 +420,40 @@ mobs:register_mob("nssm:morvalar5", { punch_start = 215, punch_end = 245 }, + do_custom = function(self) respawn_block(self) end, + custom_attack = function (self) + self.morvalar5_timer = (self.morvalar5_timer or os.time()) self.dir = (self.dir or 0) + if (os.time() - self.morvalar5_timer) > 2 then local s = self.object:get_pos() local p = self.attack:get_pos() + minetest.after(2, function(self) + mobs:set_animation(self, "punch") + tnt_boom_nssm(p, {damage_radius = 6, radius = 5, ignore_protection = false}) + self.morvalar5_timer = os.time() + end, self) end end, + on_die = function(self) + local pos = self.object:get_pos() + self.object:remove() + add_entity_and_particles("nssm:morvalar4", pos, "morparticle.png", 10) end }) @@ -483,9 +511,13 @@ mobs:register_mob("nssm:morvalar4", { end, custom_attack = function(self) + self.morvalar4_timer = (self.morvalar4_timer or os.time()) + if (os.time() - self.morvalar4_timer) > 1 then + self.morvalar4_timer = os.time() + local s = self.object:get_pos() local p = self.attack:get_pos() @@ -493,13 +525,16 @@ mobs:register_mob("nssm:morvalar4", { if minetest.line_of_sight({x = p.x, y = p.y + 1.5, z = p.z}, {x = s.x, y = s.y + 1.5, z = s.z}) == true then + -- play attack sound if self.sounds.attack then + minetest.sound_play(self.sounds.attack, { object = self.object, max_hear_distance = self.sounds.distance }, true) end + -- punch player self.attack:punch(self.object, 1.0, { full_punch_interval = 1.0, @@ -508,10 +543,10 @@ mobs:register_mob("nssm:morvalar4", { end minetest.after(1.4, function() + local ty = s.y local flag = 0 local m = 3 - local v = {x = (p.x - s.x) * m, y = ty, z = (p.z - s.z) * m} local d = {x = s.x + v.x, y = ty, z = s.z + v.z} @@ -519,8 +554,10 @@ mobs:register_mob("nssm:morvalar4", { for j = -3, 3 do ty = d.y + j + local current = minetest.get_node({x = d.x, y = ty, z = d.z}).name local up = minetest.get_node({x = d.x, y = ty + 1, z = d.z}).name + if up == "air" and current ~= "air" then d.y = d.y + j + 1.5 flag = 1 @@ -529,15 +566,22 @@ mobs:register_mob("nssm:morvalar4", { end while flag ~= 1 do + d.x = p.x + math.random(-m, m) d.z = p.z + math.random(-m, m) d.y = p.y + local dist = dist_pos(d, p) + if dist >= 2 then + for j = -3, 3 do + ty = d.y + j + local current = minetest.get_node({x = d.x, y = ty, z = d.z}).name local up = minetest.get_node({x = d.x, y = ty + 1, z = d.z}).name + if up == "air" and current ~= "air" then d.y = d.y + j + 1.5 flag = 1 @@ -550,9 +594,13 @@ mobs:register_mob("nssm:morvalar4", { end) end end, + on_die = function(self) + local pos = self.object:get_pos() + self.object:remove() + add_entity_and_particles("nssm:morvalar3", pos, "morparticle.png", 10) end }) @@ -615,8 +663,11 @@ mobs:register_mob("nssm:morvalar3", { end, on_die = function(self) + local pos = self.object:get_pos() + self.object:remove() + add_entity_and_particles("nssm:morvalar2", pos, "morparticle.png", 10) end }) @@ -673,16 +724,22 @@ mobs:register_mob("nssm:morvalar2", { end, custom_attack = function(self) + self.morvalar2_timer = (self.morvalar2_timer or os.time()) + if (os.time() - self.morvalar2_timer) > 1 then + self.morvalar2_timer = os.time() + local s = self.object:get_pos() local p = self.attack:get_pos() - local counter = 0 local objects = minetest.get_objects_inside_radius(s, 7) + for _,obj in ipairs(objects) do + if obj:get_luaentity() then + local name = obj:get_luaentity().name if (name == "nssm:mordain" or name == "nssm:morde" @@ -695,15 +752,20 @@ mobs:register_mob("nssm:morvalar2", { end end end - minetest.chat_send_all("Ne ho contati: "..counter) + + minetest.chat_send_all("Ne ho contati: " .. counter) + if counter < 2 then + mobs:set_animation(self, "punch") local v = vector.subtract(p,s) - --local v = {x = s.x-p.x, y = s.y-p.y , z= s.z-p.z} + v = vector.normalize(v) + local per = perpendicular_vector(v) local p1 = vector.add(s, v) + p1 = vector.subtract(p1, vector.multiply(per, 4)) add_entity_and_particles("nssm:morwa", p1, "morparticle.png", 1) @@ -723,9 +785,13 @@ mobs:register_mob("nssm:morvalar2", { end end end, + on_die = function(self) + local pos = self.object:get_pos() + self.object:remove() + add_entity_and_particles("nssm:morvalar1", pos, "morparticle.png", 10) end }) @@ -782,8 +848,11 @@ mobs:register_mob("nssm:morvalar1", { end, custom_attack = function (self) + self.morvalar1_timer = (self.morvalar1_timer or os.time()) + if (os.time() - self.morvalar1_timer) > 3 then + self.morvalar1_timer = os.time() local s = self.object:get_pos() @@ -795,15 +864,19 @@ mobs:register_mob("nssm:morvalar1", { if minetest.line_of_sight({x = p.x, y = p.y +1.5, z = p.z}, {x = s.x, y = s.y +1.5, z = s.z}) == true then + -- play attack sound if self.sounds.attack then + minetest.sound_play(self.sounds.attack, { object = self.object, max_hear_distance = self.sounds.distance }, true) end + -- punch player self.health = self.health + (self.damage * 3) + self.attack:punch(self.object, 1.0, { full_punch_interval = 1.0, damage_groups = {fleshy = self.damage} @@ -813,8 +886,11 @@ mobs:register_mob("nssm:morvalar1", { end, on_die = function(self) + local pos = self.object:get_pos() + self.object:remove() + add_entity_and_particles("nssm:morvalar0", pos, "morparticle.png", 10) end }) @@ -874,8 +950,11 @@ mobs:register_mob("nssm:morvalar0", { end, custom_attack = function (self) + self.morvalar1_timer = (self.morvalar1_timer or os.time()) + if (os.time() - self.morvalar1_timer) > 1 then + self.morvalar1_timer = os.time() local s = self.object:get_pos() @@ -888,15 +967,20 @@ mobs:register_mob("nssm:morvalar0", { s.y = s.y+0.5 p.y = p.y+0.9 + --direction of the kamehameha local dir = {x = (p.x - s.x) * m, y = (p.y - s.y) * m, z = (p.z - s.z) * m} + obj:set_velocity(dir) end end, on_die = function(self) + local pos = self.object:get_pos() + self.object:remove() + minetest.add_particlespawner({ amount = 500, time = 2, @@ -914,6 +998,7 @@ mobs:register_mob("nssm:morvalar0", { vertical = false, texture = "morparticle.png" }) + if minetest.get_modpath("nssb") then minetest.set_node(posmorvalarblock, {name="nssb:dis_morvalar_block"}) end @@ -923,8 +1008,11 @@ mobs:register_mob("nssm:morvalar0", { minetest.register_entity("nssm:kamehameha_bad", { textures = {"kamehameha.png"}, + on_step = function(self, dtime) + local pos = self.object:get_pos() + if self.timer == 0 then self.timer = os.time() end @@ -934,16 +1022,24 @@ minetest.register_entity("nssm:kamehameha_bad", { end local objects = minetest.get_objects_inside_radius(pos, 2) + for _,obj in ipairs(objects) do + if obj:is_player() then minetest.chat_send_all("Dentro il raggio grande") obj:set_hp(obj:get_hp()-5) end + if obj:get_luaentity() then + local name = obj:get_luaentity().name + if name ~= "nssm:morvalar0" and name ~="nssm:kamehameha_bad" then + obj:set_hp(obj:get_hp() - 5) + if (obj:get_hp() <= 0) then + if (not obj:is_player()) then obj:remove() end @@ -951,28 +1047,43 @@ minetest.register_entity("nssm:kamehameha_bad", { end end end + local objects = minetest.get_objects_inside_radius(pos, 1) + for _,obj in ipairs(objects) do + if obj:is_player() then + tnt_boom_nssm(pos, {damage_radius = 6, radius = 5, ignore_protection = false}) + self.object:remove() + minetest.chat_send_all("Dentro il raggio piccolo") end + if obj:get_luaentity() then + local name = obj:get_luaentity().name + if name ~= "nssm:morvalar0" and name ~="nssm:kamehameha_bad" then + tnt_boom_nssm(pos, {damage_radius = 6, radius = 5, ignore_protection = false}) + self.object:remove() end end end local nodename = minetest.get_node(pos).name + if nodename ~= "air" then - mobs:boom(self, pos, 5)--, 0, 1, true) + + mobs:boom(self, pos, 5) + self.object:remove() end end, + life_time = 40, timer = 0, custom_timer = 0 diff --git a/mobs/sandworm.lua b/mobs/sandworm.lua index 850a81f..7f6ad20 100644 --- a/mobs/sandworm.lua +++ b/mobs/sandworm.lua @@ -51,6 +51,7 @@ mobs:register_mob("nssm:sandworm", { punch_start = 150, punch_end = 180 }, + do_custom = function(self) digging_attack(self, "sand", self.run_velocity, {x = 0, y = 3, z = 0}) end diff --git a/mobs/snow_biter.lua b/mobs/snow_biter.lua index 92a5753..d050725 100644 --- a/mobs/snow_biter.lua +++ b/mobs/snow_biter.lua @@ -55,6 +55,7 @@ mobs:register_mob("nssm:snow_biter", { punch2_start = 200, punch2_end = 215 }, + do_custom = function(self) putting_ability(self, "default:ice", self.run_velocity) end diff --git a/nssm_api.lua b/nssm_api.lua index 78978d9..b17be16 100644 --- a/nssm_api.lua +++ b/nssm_api.lua @@ -94,6 +94,7 @@ end function dist_pos(p, s) + local v = { x = math.abs(s.x - p.x), y = math.abs(s.y - p.y), @@ -183,7 +184,6 @@ function digging_attack( dim --vector representing the dimensions of the mob ) - --if math.random(1,nssm:virulence(self)) ~= 1 then return end if self.attack and self.attack:is_player() then local s = self.object:get_pos() @@ -196,12 +196,10 @@ function digging_attack( local per = perpendicular_vector(dir) local posp = vector.add(s,dir) - --minetest.chat_send_all("La mia posizione:"..minetest.pos_to_string(s)) - --minetest.chat_send_all("La posizione davanti:"..minetest.pos_to_string(posp)) posp = vector.subtract(posp,per) for j = 1, 3 do - --minetest.chat_send_all("pos1:"..minetest.pos_to_string(posp).." per.y= "..dim.y) + if minetest.is_protected(posp, "") then return end @@ -210,8 +208,6 @@ function digging_attack( for i = 0, dim.y do - --minetest.chat_send_all("pos2:"..minetest.pos_to_string(posp).." per.y= "..per.y) - local n = minetest.get_node(pos1).name if group == nil then @@ -223,7 +219,7 @@ function digging_attack( minetest.remove_node(pos1) end else - if ((minetest.get_item_group(n, group)==1) + if ((minetest.get_item_group(n, group) == 1) and (minetest.get_item_group(n, "unbreakable") ~= 1) and (n ~= "bones:bones") and not (minetest.is_protected(pos1, "")) ) then @@ -236,7 +232,6 @@ function digging_attack( posp.y = s.y posp = vector.add(posp,per) - --minetest.chat_send_all("pos3:"..minetest.pos_to_string(posp).." per.y= "..per.y) end end end @@ -247,20 +242,20 @@ function putting_ability( --puts under the mob the block defined as 'p_block' p_block, --definition of the block to use max_vel --max velocity of the mob ) - --if math.random(1,nssm:virulence(self)) ~= 1 then return end local v = self.object:get_velocity() local dx = 0 local dz = 0 - if (math.abs(v.x)>math.abs(v.z)) then - if (v.x)>0 then + if math.abs(v.x) > math.abs(v.z) then + + if (v.x) > 0 then dx = 1 else dx = -1 end else - if (v.z)>0 then + if (v.z) > 0 then dz = 1 else dz = -1 @@ -270,7 +265,7 @@ function putting_ability( --puts under the mob the block defined as 'p_block' local pos = self.object:get_pos() local pos1 - pos.y=pos.y - 1 + pos.y = pos.y - 1 pos1 = {x = pos.x + dx, y = pos.y, z = pos.z + dz} @@ -282,8 +277,7 @@ function putting_ability( --puts under the mob the block defined as 'p_block' } if n ~= p_block and not minetest.is_protected(pos, "") - and (n == "bones:bones" - and nssm:affectbones(self) ) + and (n == "bones:bones" and nssm:affectbones(self) ) and n ~= "air" then minetest.set_node(pos, {name=p_block}) @@ -308,7 +302,7 @@ function putting_ability( --puts under the mob the block defined as 'p_block' local metai = minetest.get_meta(pos1) metai:from_table(oldmetainf[2]) -- this is enough to save the meta - metai:set_string("nssm",n1) + metai:set_string("nssm", n1) end end end @@ -320,12 +314,12 @@ function webber_ability( --puts randomly around the block defined as w_block radius --max distance the block can be put ) - if (nssm:virulence(self) ~= 0) - and (math.random(1, nssm:virulence(self)) ~= 1) then return end + if nssm:virulence(self) ~= 0 + and math.random(1, nssm:virulence(self)) ~= 1 then return end local pos = self.object:get_pos() - if (math.random(55) == 1) then + if math.random(55) == 1 then local dx = math.random(radius) local dz = math.random(radius) @@ -334,8 +328,7 @@ function webber_ability( --puts randomly around the block defined as w_block local n = minetest.get_node(p).name local k = minetest.get_node(t).name - if ((n ~= "air") - and(k == "air")) + if (n ~= "air" and k == "air") and not minetest.is_protected(t, "") then minetest.set_node(t, {name = w_block}) end @@ -350,7 +343,6 @@ function midas_ability( --ability to transform every blocks it touches in the m mult, --multiplier of the dimensions of the area around that need the transformation height --height of the mob ) - --if math.random(1,nssm:virulence(self)) ~= 1 then return end local v = self.object:get_velocity() local pos = self.object:get_pos() @@ -390,7 +382,7 @@ function midas_ability( --ability to transform every blocks it touches in the m local n = minetest.get_node(p).name if minetest.get_item_group(n, "unbreakable") == 1 - or minetest.is_protected(p, "") or n=="air" + or minetest.is_protected(p, "") or n == "air" or (n == "bones:bones" and not nssm:affectbones(self)) or n == m_block then else @@ -401,7 +393,6 @@ function midas_ability( --ability to transform every blocks it touches in the m end end - -- NEW EXPLOSION FUNCTION -- loss probabilities array (one in X will be lost) @@ -529,9 +520,8 @@ local function eject_drops(drops, pos, radius) while count > 0 do - local take = math.max(1,math.min(radius * radius, - count, - item:get_stack_max())) + local take = math.max(1, math.min(radius * radius, + count, item:get_stack_max())) rand_pos(pos, drop_pos, radius) @@ -544,9 +534,11 @@ local function eject_drops(drops, pos, radius) if obj then obj:get_luaentity().collect = true obj:set_acceleration({x = 0, y = -10, z = 0}) - obj:set_velocity({x = math.random(-3, 3), - y = math.random(0, 10), - z = math.random(-3, 3)}) + obj:set_velocity({ + x = math.random(-3, 3), + y = math.random(0, 10), + z = math.random(-3, 3) + }) end count = count - take @@ -627,9 +619,9 @@ local function entity_physics(pos, radius, drops) if objdef and objdef.on_blast then - if ((name == "nssm:pumpking") - or (name == "nssm:morvalar0") - or (name== "nssm:morvalar5")) then + if name == "nssm:pumpking" + or name == "nssm:morvalar0" + or name == "nssm:morvalar5" then do_damage = false do_knockback = false else @@ -641,8 +633,7 @@ local function entity_physics(pos, radius, drops) local obj_vel = obj:get_velocity() - obj:set_velocity(calc_velocity(pos, obj_pos, - obj_vel, radius * 10)) + obj:set_velocity(calc_velocity(pos, obj_pos, obj_vel, radius * 10)) end if do_damage then @@ -702,9 +693,11 @@ local function destroy(drops, npos, cid, c_air, c_fire, on_blast_queue, return c_fire else local node_drops = minetest.get_node_drops(def.name, "") + for _, item in pairs(node_drops) do add_drop(drops, item) end + return c_air end end @@ -788,8 +781,7 @@ local function tnt_explode(pos, radius, ignore_protection, ignore_on_blast) if cid ~= c_air then data[vi] = destroy(drops, p, cid, c_air, c_fire, - on_blast_queue, ignore_protection, - ignore_on_blast) + on_blast_queue, ignore_protection, ignore_on_blast) end end @@ -813,7 +805,6 @@ local function tnt_explode(pos, radius, ignore_protection, ignore_on_blast) local r = vector.length(rad) if r / radius < 1.4 then - --nodeupdate_single(s) core.check_single_for_falling(s) end end diff --git a/nssm_armor.lua b/nssm_armor.lua index fa4f167..de1e2b5 100644 --- a/nssm_armor.lua +++ b/nssm_armor.lua @@ -1,4 +1,4 @@ ---Armors +-- Armors local stats = { wolf = {name = "Werewolf", armor = 2.8, heal = 0, use = 800}, whitewolf = {name = "White Werewolf", armor = 2.8, heal = 0, use = 800}, @@ -168,12 +168,12 @@ if minetest.get_modpath("shields") then end ---Special objects (pumpking helmet, masticone helmet, crowned masticone helmet, crown,) +--Special objects (pumpking helmet, masticone helmet, crowned masticone helmet, crown) 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}, + masticone_crowned = {name = "Masticone Crowned Head", armor = 6, heal = 0, use = 20} } for k, v in pairs(stats) do @@ -206,12 +206,14 @@ minetest.register_craft({ } }) +local tmp = "nssm:masticone_skull_fragments" + 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"} + {tmp, tmp, tmp}, + {tmp, tmp, tmp}, + {tmp, tmp, tmp} } }) diff --git a/nssm_materials.lua b/nssm_materials.lua index 271407f..e8e4250 100644 --- a/nssm_materials.lua +++ b/nssm_materials.lua @@ -1,79 +1,79 @@ ---non eatable craftitems +-- non-eatable craftitems -local function nssm_craftitem (name, descr) +local function nssm_craftitem(name, descr) minetest.register_craftitem("nssm:" .. name, { description = descr, - image = name .. ".png", + image = name .. ".png" }) end -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") +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") -local function nssm_craftitem_eat (name, descr, gnam) +local function nssm_craftitem_eat(name, descr, gnam) minetest.register_craftitem("nssm:" .. name, { description = descr, @@ -83,51 +83,51 @@ local function nssm_craftitem_eat (name, descr, gnam) }) end -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", "Chichibios 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) +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", "Chichibios 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 +-- ore generation minetest.register_ore({ ore_type = "scatter", @@ -135,70 +135,68 @@ minetest.register_ore({ wherein = "default:stone", clust_scarcity = 50*50*50, clust_num_ores = 1, - clust_size = 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: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 -}) + 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 + }) -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 -}) + 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 + }) -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 -}) - -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 -- END for loop + 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 + }) + 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 minetest.register_ore({ ore_type = "scatter", @@ -206,7 +204,7 @@ minetest.register_ore({ wherein = "default:junglegrass", clust_scarcity = 2*2*2, clust_num_ores = 2, - clust_size = 2, + clust_size = 2, y_min = -20, y_max = 200 }) @@ -217,12 +215,12 @@ minetest.register_ore({ wherein = "default:jungleleaves", clust_scarcity = 4*4*4, clust_num_ores = 5, - clust_size = 5, + clust_size = 5, y_min = -20, y_max = 200 }) ---nodes +-- nodes minetest.register_node("nssm:ant_dirt", { description = "Ant Dirt", @@ -257,9 +255,14 @@ 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", @@ -296,7 +299,7 @@ minetest.register_node("nssm:web", { drowning = 0, liquid_renewable = false, liquidtype = "source", - liquid_range= 0, + liquid_range = 0, liquid_alternative_flowing = "nssm:web", liquid_alternative_source = "nssm:web", liquid_viscosity = 20, @@ -317,7 +320,7 @@ minetest.register_node("nssm:thick_web", { drowning = 2, liquid_renewable = false, liquidtype = "source", - liquid_range= 0, + liquid_range = 0, liquid_alternative_flowing = "nssm:thick_web", liquid_alternative_source = "nssm:thick_web", liquid_viscosity = 30, @@ -347,7 +350,7 @@ minetest.register_node("nssm:ink", { buildable_to = true, is_ground_content = false, drop = "", - liquid_range= 0, + liquid_range = 0, drowning = 1, liquid_renewable = false, liquidtype = "source", @@ -360,7 +363,7 @@ minetest.register_node("nssm:ink", { minetest.register_node("nssm:mese_meteor", { description = "Mese Meteor", - tiles = {"mese_meteor.png"} , + tiles = {"mese_meteor.png"}, paramtype = "light", drop = "", groups = {crumbly = 1, falling_node = 1, flammable = 2} @@ -374,19 +377,23 @@ minetest.register_node("nssm:pumpbomb", { light_source = 5, groups = {not_in_creative_inventory = 1}, drop = "", + on_timer = function(pos, elapsed) + + minetest.set_node(pos, {name = "air"}) + tnt_boom_nssm(pos, {damage_radius = 4, radius = 3, ignore_protection = false}) - minetest.set_node(pos, {name="air"}) end }) ---abms +-- abms minetest.register_abm({ nodenames = {"nssm:mese_meteor"}, neighbors = {"air"}, interval = 2, chance = 1, + action = function(pos, node, active_object_count, active_object_count_wider) if minetest.is_protected(pos, "") then @@ -395,61 +402,24 @@ minetest.register_abm({ minetest.set_node({x = pos.x + 1, y = pos.y, z = pos.z}, {name = "fire:basic_flame"}) minetest.set_node({x = pos.x - 1, y = pos.y, z = pos.z}, {name = "fire:basic_flame"}) - minetest.set_node({x = pos.x, y = pos.y, z=pos.z - 1}, {name = "fire:basic_flame"}) - minetest.set_node({x = pos.x, y = pos.y, z=pos.z + 1}, {name = "fire:basic_flame"}) + minetest.set_node({x = pos.x, y = pos.y, z = pos.z - 1}, {name = "fire:basic_flame"}) + minetest.set_node({x = pos.x, y = pos.y, z = pos.z + 1}, {name = "fire:basic_flame"}) minetest.set_node({x = pos.x, y = pos.y + 1, z = pos.z}, {name = "fire:basic_flame"}) end }) ---[[ These don"t actually do anything -minetest.register_abm({ - nodenames = {"nssm:web"}, - neighbors = {"default:junglegrass"}, - interval = 20.0, - chance = 20, - action = function(pos, node, active_object_count, active_object_count_wider) - local n = minetest.get_node(pos).name - if n== "air" then - minetest.set_node({x = pos.x, y = pos.y + 1, z = pos.z}, {name = "nssm:web"}) - end - end -}) - -minetest.register_abm({ - nodenames = {"nssm:web"}, - neighbors = {"default:junglegrass"}, - interval = 20.0, - chance = 20, - action = function(pos, node, active_object_count, active_object_count_wider) - local n = minetest.get_node(pos).name - if n== "air" then - minetest.set_node({x = pos.x + 1, y = pos.y, z = pos.z}, {name = "nssm:web"}) - end - end -}) - -minetest.register_abm({ - nodenames = {"nssm:web"}, - neighbors = {"default:junglegrass"}, - interval = 20.0, - chance = 20, - action = function(pos, node, active_object_count, active_object_count_wider) - local n = minetest.get_node(pos).name - if n== "air" then - minetest.set_node({x = pos.x - 1, y = pos.y, z = pos.z}, {name = "nssm:web"}) - end - end -}) -]] - minetest.register_node("nssm:phoenix_fire", { description = "Phoenix Fire", drawtype = "firelike", - tiles = {{ - name = "phoenix_fire_animated.png", - animation = { - type = "vertical_frames", - aspect_w = 16, aspect_h = 16, length = 1} + tiles = { + { + name = "phoenix_fire_animated.png", + animation = { + type = "vertical_frames", + aspect_w = 16, + aspect_h = 16, + length = 1 + } } }, inventory_image = "phoenix_fire.png", @@ -466,6 +436,7 @@ minetest.register_abm({ neighbors = {"air"}, interval = 3, chance = 2, + action = function(pos, node) minetest.set_node({x = pos.x, y = pos.y , z = pos.z}, {name = "air"}) end @@ -476,12 +447,13 @@ minetest.register_abm({ neighbors = {"air"}, interval = 15, chance = 3, + action = function(pos, node) minetest.set_node({x = pos.x, y = pos.y , z = pos.z}, {name = "air"}) end }) ---tools +-- tools minetest.register_tool("nssm:sun_sword", { description = "Sun Sword", @@ -495,6 +467,7 @@ minetest.register_tool("nssm:sun_sword", { }, damage_groups = {fleshy = 10} }, + minetest.register_on_punchnode(function(pos, node, puncher, pointed_thing) if puncher:get_wielded_item():get_name() == "nssm:sun_sword" then @@ -822,9 +795,8 @@ minetest.register_tool("nssm:axe_of_pride", { 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 + if not player_inv:is_empty("main") then + local found = 0 for i = 1, 32 do @@ -847,7 +819,6 @@ minetest.register_tool("nssm:axe_of_pride", { else if obj:is_player() then - --minetest.chat_send_all("Giocatore") if obj:get_player_name() ~= dropper:get_player_name() then obj:set_hp(obj:get_hp() - 10) @@ -866,10 +837,9 @@ minetest.register_tool("nssm:axe_of_pride", { else if obj:get_luaentity().health then - --minetest.chat_send_all("Entity") obj:get_luaentity().health = obj:get_luaentity().health -10 - dropper:set_hp(dropper:get_hp()+10) + dropper:set_hp(dropper:get_hp() + 10) --flag = 1 local items = player_inv:get_stack("main", found) @@ -923,9 +893,9 @@ minetest.register_tool("nssm:axe_of_pride", { minetest.register_tool("nssm:gratuitousness_battleaxe", { description = "Gratuitousness Battleaxe", inventory_image = "gratuitousness_battleaxe.png", - wield_scale= {x = 2.2, y = 2.2, z = 1.5}, + wield_scale = {x = 2.2, y = 2.2, z = 1.5}, tool_capabilities = { - full_punch_interval =1.6, + full_punch_interval = 1.6, max_drop_level = 1, groupcaps = { snappy = {times = {[1]=0.6, [2]=0.5, [3]=0.4}, uses = 100, maxlevel = 1}, @@ -940,17 +910,17 @@ minetest.register_tool("nssm:gratuitousness_battleaxe", { local flag = 0 local vec = dropper:get_look_dir() local pos = dropper:get_pos() - --vec.y = 0 for i = 1, 10 do pos = vector.add(pos, vec) end local pname = dropper:get_player_name() - local player_inv = minetest.get_inventory({type="player", name = pname}) + local player_inv = minetest.get_inventory({type = "player", name = pname}) local found = 0 for i = 1, 32 do + local items = player_inv:get_stack("main", i) local n = items:get_name() @@ -1003,9 +973,8 @@ minetest.register_tool("nssm:sword_of_eagerness", { 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 + if not player_inv:is_empty("main") then + local found = 0 for i = 1, 32 do @@ -1030,9 +999,9 @@ minetest.register_tool("nssm:sword_of_eagerness", { if (obj:is_player()) then - if (obj:get_player_name()~=dropper:get_player_name()) then + if obj:get_player_name() ~= dropper:get_player_name() then - part=1 + part = 1 obj:set_pos(pos) --flag = 1 @@ -1045,7 +1014,7 @@ minetest.register_tool("nssm:sword_of_eagerness", { if (obj:get_luaentity().health) then obj:get_luaentity().old_y = pos.y obj:set_pos(pos) - part=1 + part = 1 --flag = 1 local items = player_inv:get_stack("main", found) @@ -1104,34 +1073,38 @@ minetest.register_tool("nssm:falchion_of_eagerness", { local vec = dropper:get_look_dir() local pos = dropper:get_pos() - --vec.y = 0 - for i=1, 16 do + for i = 1, 16 do pos = vector.add(pos, vec) end 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 + if not player_inv:is_empty("main") then + local found = 0 + for i = 1, 32 do + local items = player_inv:get_stack("main", i) local n = items:get_name() + if n == "nssm:life_energy" then + if items:get_count() >= 5 then found = i break end end end + if found == 0 then minetest.chat_send_player(pname, "You haven't got enough life_energy!") return else local s = dropper:get_pos() + minetest.add_particlespawner({ amount = 25, time = 0.3, @@ -1148,14 +1121,16 @@ minetest.register_tool("nssm:falchion_of_eagerness", { collisiondetection = false, texture = "slothful_soul_fragment.png" }) + + minetest.remove_node(pos) ; pos.y=pos.y + 1 + minetest.remove_node(pos) ; pos.y=pos.y - 2 minetest.remove_node(pos) - pos.y=pos.y + 1 - minetest.remove_node(pos) - pos.y=pos.y - 2 - minetest.remove_node(pos) + dropper:set_pos(pos) + s = pos s.y = s.y + 10 + minetest.add_particlespawner({ amount - 25, time = 0.3, @@ -1172,8 +1147,11 @@ minetest.register_tool("nssm:falchion_of_eagerness", { collisiondetection = false, texture = "slothful_soul_fragment.png" }) + local items = player_inv:get_stack("main", found) + items:set_count(items:get_count() - 5) + player_inv:set_stack("main", found, items) end end @@ -1195,54 +1173,72 @@ minetest.register_tool("nssm:sword_of_envy", { }, 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}) - if player_inv:is_empty("main") then - --minetest.chat_send_all("Inventory empty") - else + 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 not player_inv:is_empty("main") then + 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 + if obj:is_player() then + + 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 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 + if obj:get_luaentity().health then + local hpp = obj:get_luaentity().health + obj:get_luaentity().health = dropper:get_hp() + if hpp > 20 then dropper:set_hp(20) else dropper:set_hp(hpp) end + flag = 1 local items = player_inv:get_stack("main", found) + items:take_item() + player_inv:set_stack("main", found, items) end end @@ -1268,31 +1264,38 @@ minetest.register_tool("nssm:sword_of_gluttony", { }, 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}) - if player_inv:is_empty("main") then - --minetest.chat_send_all("Inventory empty") - else + 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 not player_inv:is_empty("main") then + 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 - 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 + obj:set_hp(obj:get_hp() - 10) --flag = 1 @@ -1302,12 +1305,13 @@ minetest.register_tool("nssm:sword_of_gluttony", { player_inv:set_stack("main", found, items) end else - if (obj:get_luaentity().health) then + if obj:get_luaentity().health then + if obj:get_luaentity().health <= 32 then + local pos = obj:get_pos() obj:remove() - --check_for_death(obj:get_luaentity()) --flag = 1 --take energy globe from inventory: local items = player_inv:get_stack("main", found) @@ -1315,7 +1319,8 @@ minetest.register_tool("nssm:sword_of_gluttony", { player_inv:set_stack("main", found, items) for i = 1, math.random(4) do - drop = minetest.add_item(pos, "nssm:roasted_duck_legs 1") + drop = minetest.add_item(pos, + "nssm:roasted_duck_legs 1") drops(drop) end @@ -1373,27 +1378,37 @@ 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 + dropper:set_hp(dropper:get_hp() - 9) + for _,obj in ipairs(objects) do + flag = 0 - 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 obj:set_hp(obj:get_hp() - 40) flag = 1 end else - if (obj:get_luaentity().health) then + if obj:get_luaentity().health then obj:get_luaentity().health = obj:get_luaentity().health - 40 flag = 1 end end + if flag == 1 then + for i = 1, math.random(2) do + drop = minetest.add_item(pos, "nssm:energy_globe 1") if drop then + drop:set_velocity({ x = math.random(-10, 10) / 9, y = 5, @@ -1403,13 +1418,16 @@ minetest.register_tool("nssm:death_scythe", { 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") + for _,v in pairs(poslist) do - --minetest.chat_send_all(minetest.pos_to_string(v)) - minetest.set_node(v, {name="default:dirt_with_dry_grass"}) + + minetest.set_node(v, {name = "default:dirt_with_dry_grass"}) + if math.random(3) == 1 then v.y = v.y + 2 drop = minetest.add_item(v, "nssm:life_energy 1") @@ -1419,9 +1437,11 @@ minetest.register_tool("nssm:death_scythe", { local poslist = minetest.find_nodes_in_area_under_air(vector.subtract(pos, vec), vector.add(pos,vec), "group:flora") + for _,v in pairs(poslist) do - --minetest.chat_send_all(minetest.pos_to_string(v)) - minetest.set_node(v, {name="default:dry_shrub"}) + + minetest.set_node(v, {name = "default:dry_shrub"}) + if math.random(3) == 1 then v.y = v.y + 2 drop = minetest.add_item(v, "nssm:life_energy 1") @@ -1431,19 +1451,21 @@ minetest.register_tool("nssm:death_scythe", { local poslist = minetest.find_nodes_in_area(vector.subtract(pos, vec), vector.add(pos,vec), "group:leaves") + for _,v in pairs(poslist) do - --minetest.chat_send_all(minetest.pos_to_string(v)) - minetest.set_node(v, {name="nssm:dead_leaves"}) + + minetest.set_node(v, {name = "nssm:dead_leaves"}) + if math.random(3) == 1 then v.y = v.y + 2 drop = minetest.add_item(v, "nssm:life_energy 1") drops(drop) end end - end, + end }) ---recipes +-- recipes minetest.register_craft({ output = "nssm:web_string", @@ -1553,7 +1575,7 @@ minetest.register_craft({ recipe = { {"", "nssm:king_duck_crown", ""}, {"", "nssm:masticone_skull", ""}, - {"", "", ""}, + {"", "", ""} } })]] @@ -1580,13 +1602,16 @@ minetest.register_craft({ type = "shapeless", recipe = {"nssm:superior_energy_globe"} }) + --[[ +local tmp = "nssm:masticone_skull_fragments" + minetest.register_craft({ output = "nssm:masticone_skull", 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"}, + {tmp, tmp, tmp}, + {tmp, tmp, tmp}, + {tmp, tmp, tmp} } })]] @@ -1624,7 +1649,7 @@ minetest.register_craft({ } }) -function nssm_register_recip (ingredient, dish, tictac) +local function nssm_register_recip(ingredient, dish, tictac) minetest.register_craft({ type = "cooking", @@ -1634,27 +1659,25 @@ function nssm_register_recip (ingredient, dish, tictac) }) end -nssm_register_recip ("worm_flesh", "roasted_worm_flesh", 12) -nssm_register_recip ("duck_legs", "roasted_duck_legs", 6) -nssm_register_recip ("spider_leg", "roasted_spider_leg", 6) -nssm_register_recip ("felucco_steak", "roasted_felucco_steak", 10) -nssm_register_recip ("werewolf_leg", "roasted_werewolf_leg", 10) -nssm_register_recip ("brain", "roasted_brain", 6) -nssm_register_recip ("amphibian_heart", "roasted_amphibian_heart", 6) -nssm_register_recip ("tentacle", "roasted_tentacle", 6) -nssm_register_recip ("frosted_amphibian_heart", "amphibian_heart", 8) -nssm_register_recip ("heron_leg", "chichibios_heron_leg", 20) -nssm_register_recip ("raw_scrausics_wing", "spicy_scrausics_wing", 12) -nssm_register_recip ("ant_leg", "roasted_ant_leg", 6) -nssm_register_recip ("crocodile_tail", "roasted_crocodile_tail", 16) -nssm_register_recip ("dolidrosaurus_fin", "roasted_dolidrosaurus_fin", 8) -nssm_register_recip ("amphibian_ribs", "roasted_amphibian_ribs", 12) -nssm_register_recip ("mantis_meat", "roasted_mantis_meat", 6) -nssm_register_recip ("spider_meat", "roasted_spider_meat", 6) -nssm_register_recip ("silk_gland", "roasted_silk_gland", 4) -nssm_register_recip ("larva_juice", "larva_soup", 20) - - +nssm_register_recip("worm_flesh", "roasted_worm_flesh", 12) +nssm_register_recip("duck_legs", "roasted_duck_legs", 6) +nssm_register_recip("spider_leg", "roasted_spider_leg", 6) +nssm_register_recip("felucco_steak", "roasted_felucco_steak", 10) +nssm_register_recip("werewolf_leg", "roasted_werewolf_leg", 10) +nssm_register_recip("brain", "roasted_brain", 6) +nssm_register_recip("amphibian_heart", "roasted_amphibian_heart", 6) +nssm_register_recip("tentacle", "roasted_tentacle", 6) +nssm_register_recip("frosted_amphibian_heart", "amphibian_heart", 8) +nssm_register_recip("heron_leg", "chichibios_heron_leg", 20) +nssm_register_recip("raw_scrausics_wing", "spicy_scrausics_wing", 12) +nssm_register_recip("ant_leg", "roasted_ant_leg", 6) +nssm_register_recip("crocodile_tail", "roasted_crocodile_tail", 16) +nssm_register_recip("dolidrosaurus_fin", "roasted_dolidrosaurus_fin", 8) +nssm_register_recip("amphibian_ribs", "roasted_amphibian_ribs", 12) +nssm_register_recip("mantis_meat", "roasted_mantis_meat", 6) +nssm_register_recip("spider_meat", "roasted_spider_meat", 6) +nssm_register_recip("silk_gland", "roasted_silk_gland", 4) +nssm_register_recip("larva_juice", "larva_soup", 20) minetest.register_craft({ output = "nssm:larva_juice", @@ -1850,126 +1873,144 @@ if minetest.get_modpath("nssb") then } }) - function nssm_register_moranga (viz) + local function nssm_register_moranga(viz) + + local tmp = "nssm:" .. viz .. "_soul_fragment" minetest.register_craft({ - output = "nssm:".. viz .."_moranga", + output = "nssm:" .. viz .. "_moranga", recipe = { - {"nssm:".. viz .."_soul_fragment", "nssb:moranga_ingot", - "nssm:".. viz .."_soul_fragment"}, - {"nssb:moranga_ingot", "nssm:".. viz .."_soul_fragment", - "nssb:moranga_ingot"}, - {"nssm:".. viz .."_soul_fragment", "nssb:moranga_ingot", - "nssm:".. viz .."_soul_fragment"} + {tmp, "nssb:moranga_ingot", tmp}, + {"nssb:moranga_ingot", tmp, "nssb:moranga_ingot"}, + {tmp, "nssb:moranga_ingot", tmp} } }) end - nssm_register_moranga ("lustful") - nssm_register_moranga ("greedy") - nssm_register_moranga ("slothful") - nssm_register_moranga ("wrathful") - nssm_register_moranga ("gluttonous") - nssm_register_moranga ("envious") - nssm_register_moranga ("proud") + + nssm_register_moranga("lustful") + nssm_register_moranga("greedy") + nssm_register_moranga("slothful") + nssm_register_moranga("wrathful") + nssm_register_moranga("gluttonous") + nssm_register_moranga("envious") + nssm_register_moranga("proud") end ---Eggs +-- Eggs + +local 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", + on_place = function(itemstack, placer, pointed_thing) + local pos1 = minetest.get_pointed_thing_position(pointed_thing, true) + pos1.y = pos1.y + 1.5 + core.after(0.1, function() minetest.add_entity(pos1, "nssm:" .. name) end) + itemstack:take_item() + return itemstack end }) end -local 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", + on_place = function(itemstack, placer, pointed_thing) + local pos1 = minetest.get_pointed_thing_position(pointed_thing, true) + pos1.y = pos1.y + 1.5 + core.after(0.1, function() minetest.add_entity(pos1, "nssm:" .. name) end) + itemstack:take_item() + return itemstack end }) end -nssm_register_egg ("flying_duck", "Flying Duck") -nssm_register_egg ("stone_eater", "Stoneater") -nssm_register_egg ("signosigno", "Signosigno") -nssm_register_egg ("bloco", "Bloco") -nssm_register_egg ("sand_bloco", "Sand Bloco") -nssm_register_egg ("swimming_duck", "Swimming Duck") -nssm_register_egg ("duck", "Duck") -nssm_register_egg2 ("duckking", "Duckking") -nssm_register_egg ("enderduck", "Enderduck") -nssm_register_egg ("spiderduck", "Spiderduck") -nssm_register_egg2 ("echidna", "Echidna") -nssm_register_egg ("werewolf", "Werewolf") -nssm_register_egg ("white_werewolf", "White Werewolf") -nssm_register_egg ("snow_biter", "Snow Biter") -nssm_register_egg2 ("icelamander", "Icelamander") -nssm_register_egg ("icesnake", "Icesnake") -nssm_register_egg2 ("lava_titan", "Lava Titan") -nssm_register_egg ("masticone", "Masticone") -nssm_register_egg ("mantis_beast", "Mantis Beast") -nssm_register_egg ("mantis", "Mantis") -nssm_register_egg ("larva", "Larva") -nssm_register_egg2 ("phoenix", "Phoenix") -nssm_register_egg2 ("night_master", "Night Master") -nssm_register_egg ("scrausics", "Scrausics") -nssm_register_egg ("moonheron", "Moonheron") -nssm_register_egg ("sandworm", "Sandworm") -nssm_register_egg2 ("giant_sandworm", "Giant Sandworm") -nssm_register_egg2 ("ant_queen", "Ant Queen") -nssm_register_egg ("ant_soldier", "Ant Soldier") -nssm_register_egg ("ant_worker", "Ant Worker") -nssm_register_egg ("crocodile", "Crocodile") -nssm_register_egg ("dolidrosaurus", "Dolidrosaurus") -nssm_register_egg ("crab", "Crab") -nssm_register_egg ("octopus", "Octopus") -nssm_register_egg ("xgaloctopus", "Xgaloctopus") -nssm_register_egg ("black_widow", "Black Widow") -nssm_register_egg ("uloboros", "Uloboros") -nssm_register_egg2 ("tarantula", "Tarantula") -nssm_register_egg ("daddy_long_legs", "Daddy Long Legs") -nssm_register_egg2 ("kraken", "Kraken") -nssm_register_egg2 ("pumpking", "Pumpking") -nssm_register_egg ("manticore", "Manticore") -nssm_register_egg ("felucco", "Felucco") -nssm_register_egg ("pumpboom_large", "Large Pumpboom") -nssm_register_egg ("pumpboom_small", "Small Pumpboom") -nssm_register_egg ("pumpboom_medium", "Medium Pumpboom") -nssm_register_egg2 ("mordain", "Mordain") -nssm_register_egg2 ("morgre", "Morgre") -nssm_register_egg2 ("morvy", "Morvy") -nssm_register_egg2 ("morgut", "Morgut") -nssm_register_egg2 ("morde", "Morde") -nssm_register_egg2 ("morlu", "Morlu") -nssm_register_egg2 ("morwa", "Morwa") ---nssm_register_egg ("morvalar", "Morvalar") +nssm_register_egg("flying_duck", "Flying Duck") +nssm_register_egg("stone_eater", "Stoneater") +nssm_register_egg("signosigno", "Signosigno") +nssm_register_egg("bloco", "Bloco") +nssm_register_egg("sand_bloco", "Sand Bloco") +nssm_register_egg("swimming_duck", "Swimming Duck") +nssm_register_egg("duck", "Duck") +nssm_register_egg2("duckking", "Duckking") +nssm_register_egg("enderduck", "Enderduck") +nssm_register_egg("spiderduck", "Spiderduck") +nssm_register_egg2("echidna", "Echidna") +nssm_register_egg("werewolf", "Werewolf") +nssm_register_egg("white_werewolf", "White Werewolf") +nssm_register_egg("snow_biter", "Snow Biter") +nssm_register_egg2("icelamander", "Icelamander") +nssm_register_egg("icesnake", "Icesnake") +nssm_register_egg2("lava_titan", "Lava Titan") +nssm_register_egg("masticone", "Masticone") +nssm_register_egg("mantis_beast", "Mantis Beast") +nssm_register_egg("mantis", "Mantis") +nssm_register_egg("larva", "Larva") +nssm_register_egg2("phoenix", "Phoenix") +nssm_register_egg2("night_master", "Night Master") +nssm_register_egg("scrausics", "Scrausics") +nssm_register_egg("moonheron", "Moonheron") +nssm_register_egg("sandworm", "Sandworm") +nssm_register_egg2("giant_sandworm", "Giant Sandworm") +nssm_register_egg2("ant_queen", "Ant Queen") +nssm_register_egg("ant_soldier", "Ant Soldier") +nssm_register_egg("ant_worker", "Ant Worker") +nssm_register_egg("crocodile", "Crocodile") +nssm_register_egg("dolidrosaurus", "Dolidrosaurus") +nssm_register_egg("crab", "Crab") +nssm_register_egg("octopus", "Octopus") +nssm_register_egg("xgaloctopus", "Xgaloctopus") +nssm_register_egg("black_widow", "Black Widow") +nssm_register_egg("uloboros", "Uloboros") +nssm_register_egg2("tarantula", "Tarantula") +nssm_register_egg("daddy_long_legs", "Daddy Long Legs") +nssm_register_egg2("kraken", "Kraken") +nssm_register_egg2("pumpking", "Pumpking") +nssm_register_egg("manticore", "Manticore") +nssm_register_egg("felucco", "Felucco") +nssm_register_egg("pumpboom_large", "Large Pumpboom") +nssm_register_egg("pumpboom_small", "Small Pumpboom") +nssm_register_egg("pumpboom_medium", "Medium Pumpboom") +nssm_register_egg2("mordain", "Mordain") +nssm_register_egg2("morgre", "Morgre") +nssm_register_egg2("morvy", "Morvy") +nssm_register_egg2("morgut", "Morgut") +nssm_register_egg2("morde", "Morde") +nssm_register_egg2("morlu", "Morlu") +nssm_register_egg2("morwa", "Morwa") +--nssm_register_egg("morvalar", "Morvalar") minetest.register_craftitem("nssm:mese_egg", { description = "Mese Egg", image = "mese_egg.png", + on_place = function(itemstack, placer, pointed_thing) + local pos1 = minetest.get_pointed_thing_position(pointed_thing, true) + pos1.y = pos1.y + 1.5 + minetest.add_particlespawner({ - amount = 1000, + amount = 200, time = 0.2, minpos = {x = pos1.x - 1, y = pos1.y - 1, z = pos1.z - 1}, maxpos = {x = pos1.x + 1, y = pos1.y + 4, z = pos1.z + 1}, @@ -1985,16 +2026,19 @@ minetest.register_craftitem("nssm:mese_egg", { vertical = false, texture = "tnt_smoke.png" }) + core.after(0.4, function() minetest.add_entity(pos1, "nssm:mese_dragon") end) + itemstack:take_item() + return itemstack end }) +-- experimental morwa statue ---experimental morwa statue minetest.register_node("nssm:morwa_statue", { description = "Morwa Statue", drawtype = "mesh", @@ -2005,16 +2049,14 @@ minetest.register_node("nssm:morwa_statue", { paramtype = "light", paramtype2 = "facedir", selection_box = { - type = "fixed", - fixed = {-1, -0.5, -1, 1, 3, 1} -- Right, Bottom, Back, Left, Top, Front + type = "fixed", fixed = {-1, -0.5, -1, 1, 3, 1} }, collision_box = { - type = "fixed", - fixed = {-1, -0.5, -1, 1, 3, 1} -- Right, Bottom, Back, Left, Top, Front + type = "fixed", fixed = {-1, -0.5, -1, 1, 3, 1} } }) ---Abm to make the conversion between statue and the entity, caused by light +-- Abm to make the conversion between statue and the entity, caused by light minetest.register_abm({ nodenames = {"nssm:morwa_statue"}, @@ -2022,11 +2064,14 @@ minetest.register_abm({ interval = 2, chance = 1, 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 return end + if (minetest.get_node_light(pos1) > 8) then minetest.add_entity(pos1, "nssm:morwa") minetest.remove_node(pos) @@ -2034,7 +2079,7 @@ minetest.register_abm({ end }) ---Eggs recipes +-- Eggs recipes minetest.register_craft({ output = "nssm:duck", diff --git a/nssm_spears.lua b/nssm_spears.lua index 5417501..aa782f1 100644 --- a/nssm_spears.lua +++ b/nssm_spears.lua @@ -1,7 +1,8 @@ ---functions +-- functions + +local function spears_shot(itemstack, player) -local function spears_shot (itemstack, player) local spear = itemstack:get_name() .. '_entity' local playerpos = player:get_pos() local obj = minetest.add_entity({ @@ -9,26 +10,33 @@ local function spears_shot (itemstack, player) y = playerpos.y + 1.5, z = playerpos.z }, spear) + local dir = player:get_look_dir() - if spear == "nssm:spear_of_peace_entity" then - sp = 32 - gravity = 9.8 - else - sp = 16 - gravity = 9.8 - end + + if spear == "nssm:spear_of_peace_entity" then + sp = 32 + gravity = 9.8 + else + sp = 16 + gravity = 9.8 + end + local dr = .3 + obj:set_velocity({x = dir.x * sp, y = dir.y * sp, z = dir.z * sp}) obj:set_acceleration({x = -dir.x * dr, y = -gravity, z = -dir.z * dr}) obj:set_yaw(player:get_look_yaw() + math.pi) - minetest.sound_play("spears_sound", {pos = playerpos}, true) obj:get_luaentity().wear = itemstack:get_wear() + + minetest.sound_play("spears_sound", {pos = playerpos}, true) + return true end local function spears_set_entity(kind, eq, toughness) - local SPEAR_ENTITY={ + + local SPEAR_ENTITY = { physical = false, timer = 0, visual = "wielditem", @@ -36,14 +44,20 @@ local function spears_set_entity(kind, eq, toughness) textures = {"nssm:spear_" .. kind}, lastpos={}, collisionbox = {0,0,0,0,0,0}, + on_punch = function(self, puncher) + if puncher then + if puncher:is_player() then + local stack = { name = "nssm: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() @@ -54,41 +68,59 @@ local function spears_set_entity(kind, eq, toughness) } SPEAR_ENTITY.on_step = function(self, dtime) + self.timer=self.timer + dtime + local pos = self.object:get_pos() local node = minetest.get_node(pos) + if not self.wear then self.object:remove() return end + if self.lastpos.x~=nil then + if node.name ~= "air" and not (string.find(node.name, "grass") and not string.find(node.name, "dirt")) and not string.find(node.name, "flowers:") and not string.find(node.name, "farming:") then + self.object:remove() + if self.wear + 65535 / toughness < 65535 then + minetest.add_item(self.lastpos, { name = "nssm:spear_" .. kind, wear = self.wear + 65535 / toughness }) end + elseif self.timer > 0.2 then + local objs = minetest.get_objects_inside_radius({ x = pos.x, y = pos.y, z = pos.z}, 1) + for k, obj in pairs(objs) do + if obj:get_luaentity() ~= nil then + if obj:get_luaentity().name ~= "nssm:spear_" .. kind .. "_entity" and obj:get_luaentity().name ~= "__builtin:item" then + local speed = vector.length(self.object:get_velocity()) local damage = (speed + eq) ^ 1.12 - 20 + obj:punch(self.object, 1.0, { full_punch_interval = 1.0, damage_groups={fleshy = damage} }, nil) + self.object:remove() + if self.wear + 65535 / toughness < 65535 then + minetest.add_item(self.lastpos, { name = "nssm:spear_" .. kind, wear = self.wear + 65535 / toughness @@ -101,10 +133,11 @@ local function spears_set_entity(kind, eq, toughness) end self.lastpos={x = pos.x, y = pos.y, z = pos.z} end + return SPEAR_ENTITY end ---Tools +-- Tools local function spears_register_spear(kind, desc, eq, toughness, material) @@ -113,20 +146,29 @@ local function spears_register_spear(kind, desc, eq, toughness, material) 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) + 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.3, max_drop_level = 1, @@ -138,7 +180,7 @@ local function spears_register_spear(kind, desc, eq, toughness, material) } }) - local SPEAR_ENTITY=spears_set_entity(kind, eq, toughness) + local SPEAR_ENTITY = spears_set_entity(kind, eq, toughness) minetest.register_entity("nssm:spear_" .. kind .. "_entity", SPEAR_ENTITY) @@ -157,42 +199,43 @@ local function spears_register_spear(kind, desc, eq, toughness, material) }) end - spears_register_spear("ant", "Ant", 6, 25, "nssm:ant_mandible") - spears_register_spear("mantis", "Mantis", 6, 10, "nssm:mantis_claw") - spears_register_spear("manticore", "Manticore", 8, 8, "nssm:manticore_spine") - spears_register_spear("ice_tooth", "Ice Tooth", 16, 200, "nssm:ice_tooth") - spears_register_spear("little_ice_tooth", "Little Ice Tooth", 7, 10, "nssm:little_ice_tooth") - spears_register_spear("duck_beak", "Duck Beak", 5, 6, "nssm:duck_beak") - spears_register_spear("felucco_horn", "Felucco Horn", 7, 9, "nssm:felucco_horn") - ---Spear of peace +-- 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, @@ -204,7 +247,8 @@ minetest.register_tool("nssm:spear_of_peace", { }) local function spears_set_sentity(kind, eq, toughness) - local SUPERSPEAR_ENTITY={ + + local SUPERSPEAR_ENTITY = { physical = false, timer = 0, visual = "wielditem", @@ -212,14 +256,20 @@ local function spears_set_sentity(kind, eq, toughness) textures = {"nssm:spear_" .. kind}, lastpos={}, collisionbox = {0,0,0,0,0,0}, + on_punch = function(self, puncher) + if puncher then + if puncher:is_player() then + local stack = { name = "nssm: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() @@ -230,42 +280,59 @@ local function spears_set_sentity(kind, eq, toughness) } SUPERSPEAR_ENTITY.on_step = function(self, dtime) + self.timer=self.timer+dtime + local pos = self.object:get_pos() local node = minetest.get_node(pos) + if not self.wear then self.object:remove() return end + if self.lastpos.x ~= nil then + if node.name ~= "air" and not (string.find(node.name, "grass") and not string.find(node.name, "dirt")) and not string.find(node.name, "flowers:") and not string.find(node.name, "farming:") then + self.object:remove() + if self.wear + 65535 / toughness < 65535 then + minetest.add_item(self.lastpos, { name = "nssm:spear_" .. kind, wear = self.wear + 65535 / toughness }) end + elseif self.timer > 0.2 then + local objs = minetest.get_objects_inside_radius({ x = pos.x, y = pos.y, z = pos.z}, 1) + for k, obj in pairs(objs) do + if obj:get_luaentity() ~= nil then + if obj:get_luaentity().name ~= "nssm:spear_" .. kind .. "_entity" and obj:get_luaentity().name ~= "__builtin:item" then + local speed = vector.length(self.object:get_velocity()) - --minetest.chat_send_all(speed) local damage = (speed + eq) ^ 1.12 - 20 + obj:punch(self.object, 1.0, { full_punch_interval = 1.0, damage_groups={fleshy = damage} }, nil) + self.object:remove() + if self.wear + 65535 / toughness < 65535 then + minetest.add_item(self.lastpos, { name = "nssm:spear_" .. kind, wear = self.wear + 65535 / toughness @@ -278,10 +345,11 @@ local function spears_set_sentity(kind, eq, toughness) end self.lastpos = {x = pos.x, y = pos.y, z = pos.z} end + return SUPERSPEAR_ENTITY end -SUPERSPEAR_ENTITY=spears_set_sentity("of_peace", 30, 300) +SUPERSPEAR_ENTITY = spears_set_sentity("of_peace", 30, 300) minetest.register_entity("nssm:spear_of_peace_entity", SUPERSPEAR_ENTITY) diff --git a/nssm_weapons.lua b/nssm_weapons.lua index c40df88..dcc25ee 100644 --- a/nssm_weapons.lua +++ b/nssm_weapons.lua @@ -1,8 +1,9 @@ ---Parameters used by some weapons +-- Parameters used by some weapons local default_dir = {x = 1, y = 1, z = 1} ---Function used to shoot: +-- 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({ @@ -10,22 +11,33 @@ local function weapons_shot(itemstack, placer, pointed_thing, velocity, name) y = playerpos.y + 2 + dir.y, z = playerpos.z + 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 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 @@ -33,6 +45,7 @@ local function activate_balls(pos) end end + local function search_on_step2( self, dtime, --used to count time @@ -46,6 +59,7 @@ local function search_on_step2( 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 @@ -57,14 +71,19 @@ local function search_on_step2( 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 < min_dist) then min_dist = dist obj_min = obj @@ -73,22 +92,25 @@ local function search_on_step2( end end - --Found an entity to follow: + -- Found an entity to follow: if obj_min ~= nil then + local new_vel = {x = 0, y = 0, z = 0} local dir = 0 local max_diff = 0 - if (max_diff max_time then self.object:remove() return end - - --Look for an entity to follow + -- 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 < min_dist then min_dist = dist obj_min = obj @@ -157,22 +185,25 @@ local function search_on_step( end end - --Found an entity to follow: + -- Found an entity to follow: if obj_min ~= nil then + local new_vel = {x = 0, y = 0, z = 0} local dir = 0 local max_diff = 0 - if (max_diff 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) - --while going around it damages entities + -- 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 and obj:get_luaentity() @@ -242,8 +288,6 @@ local function default_on_step( 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_luaentity_name().." Vita: "..obj:get_luaentity().health) --- check_for_death(obj:get_luaentity()) end end end @@ -251,26 +295,34 @@ local function default_on_step( 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 - - --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 - - 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 - - --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