keep globals inside nssm table
This commit is contained in:
parent
95b5dc34de
commit
4e5af39fd8
@ -319,7 +319,7 @@ mobs:register_arrow("nssm:phoenix_arrow", {
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
function gas_explosion(pos)
|
local function gas_explosion(pos)
|
||||||
|
|
||||||
if minetest.is_protected(pos, "") then
|
if minetest.is_protected(pos, "") then
|
||||||
return
|
return
|
||||||
@ -375,7 +375,6 @@ mobs:register_arrow("nssm:roar_of_the_dragon", {
|
|||||||
on_step = function(self, dtime)
|
on_step = function(self, dtime)
|
||||||
|
|
||||||
local pos = self.object:get_pos()
|
local pos = self.object:get_pos()
|
||||||
|
|
||||||
local n = minetest.get_node(pos).name
|
local n = minetest.get_node(pos).name
|
||||||
|
|
||||||
if self.timer == 0 then
|
if self.timer == 0 then
|
||||||
@ -390,9 +389,10 @@ mobs:register_arrow("nssm:roar_of_the_dragon", {
|
|||||||
|
|
||||||
for _,obj in ipairs(objects) do
|
for _,obj in ipairs(objects) do
|
||||||
|
|
||||||
local name = obj:get_entity_name()
|
local ent = obj and obj:get_luaentity()
|
||||||
|
local name = ent and ent.name
|
||||||
|
|
||||||
if name ~= "nssm:roar_of_the_dragon"
|
if name and name ~= "nssm:roar_of_the_dragon"
|
||||||
and name ~= "nssm:mese_dragon" then
|
and name ~= "nssm:mese_dragon" then
|
||||||
|
|
||||||
obj:set_hp(obj:get_hp() - 0.05)
|
obj:set_hp(obj:get_hp() - 0.05)
|
||||||
|
@ -97,7 +97,7 @@ mobs:register_mob("nssm:ant_queen", {
|
|||||||
and minetest.get_node(pos1).name == "air"
|
and minetest.get_node(pos1).name == "air"
|
||||||
and counter < 4 then
|
and counter < 4 then
|
||||||
|
|
||||||
explosion_particles(pos1, 1)
|
nssm:explosion_particles(pos1, 1)
|
||||||
|
|
||||||
minetest.add_entity(pos1, "nssm:ant_soldier")
|
minetest.add_entity(pos1, "nssm:ant_soldier")
|
||||||
end
|
end
|
||||||
|
@ -53,7 +53,7 @@ mobs:register_mob("nssm:black_widow", {
|
|||||||
do_custom = function(self)
|
do_custom = function(self)
|
||||||
|
|
||||||
if nssm.spiders_litter_web then
|
if nssm.spiders_litter_web then
|
||||||
webber_ability(self, "nssm:web", 2)
|
nssm:webber_ability(self, "nssm:web", 2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
@ -59,6 +59,6 @@ mobs:register_mob("nssm:icelamander", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
do_custom = function(self)
|
do_custom = function(self)
|
||||||
midas_ability(self, "default:ice", self.run_velocity, 1, 3)
|
nssm:midas_ability(self, "default:ice", self.run_velocity, 1, 3)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
@ -53,6 +53,6 @@ mobs:register_mob("nssm:icesnake", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
do_custom = function(self)
|
do_custom = function(self)
|
||||||
putting_ability(self, "default:ice", self.run_velocity)
|
nssm:putting_ability(self, "default:ice", self.run_velocity)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
@ -59,6 +59,6 @@ mobs:register_mob("nssm:lava_titan", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
do_custom = function (self)
|
do_custom = function (self)
|
||||||
digging_attack(self, nil, self.run_velocity, {x = 0, y = 4, z = 0})
|
nssm:digging_attack(self, nil, self.run_velocity, {x = 0, y = 4, z = 0})
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
@ -64,7 +64,7 @@ mobs:register_mob("nssm:mese_dragon", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
do_custom = function(self)
|
do_custom = function(self)
|
||||||
midas_ability(self, "default:mese_block", self.run_velocity, 2, 3)
|
nssm:midas_ability(self, "default:mese_block", self.run_velocity, 2, 3)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
custom_attack = function(self)
|
custom_attack = function(self)
|
||||||
|
@ -129,7 +129,7 @@ mobs:register_mob("nssm:mordain", {
|
|||||||
d.z = p.z + math.random(-m, m)
|
d.z = p.z + math.random(-m, m)
|
||||||
d.y = p.y
|
d.y = p.y
|
||||||
|
|
||||||
local dist = dist_pos(d, p)
|
local dist = nssm:dist_pos(d, p)
|
||||||
|
|
||||||
if dist >= 2 then
|
if dist >= 2 then
|
||||||
|
|
||||||
|
@ -440,7 +440,8 @@ mobs:register_mob("nssm:morvalar5", {
|
|||||||
|
|
||||||
mobs:set_animation(self, "punch")
|
mobs:set_animation(self, "punch")
|
||||||
|
|
||||||
tnt_boom_nssm(p, {damage_radius = 6, radius = 5, ignore_protection = false})
|
nssm:tnt_boom_nssm(p, {
|
||||||
|
damage_radius = 6, radius = 5, ignore_protection = false})
|
||||||
|
|
||||||
self.morvalar5_timer = os.time()
|
self.morvalar5_timer = os.time()
|
||||||
|
|
||||||
@ -571,7 +572,7 @@ mobs:register_mob("nssm:morvalar4", {
|
|||||||
d.z = p.z + math.random(-m, m)
|
d.z = p.z + math.random(-m, m)
|
||||||
d.y = p.y
|
d.y = p.y
|
||||||
|
|
||||||
local dist = dist_pos(d, p)
|
local dist = nssm:dist_pos(d, p)
|
||||||
|
|
||||||
if dist >= 2 then
|
if dist >= 2 then
|
||||||
|
|
||||||
@ -1054,7 +1055,8 @@ minetest.register_entity("nssm:kamehameha_bad", {
|
|||||||
|
|
||||||
if obj:is_player() then
|
if obj:is_player() then
|
||||||
|
|
||||||
tnt_boom_nssm(pos, {damage_radius = 6, radius = 5, ignore_protection = false})
|
nssm:tnt_boom_nssm(pos, {
|
||||||
|
damage_radius = 6, radius = 5, ignore_protection = false})
|
||||||
|
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
|
|
||||||
@ -1067,7 +1069,8 @@ minetest.register_entity("nssm:kamehameha_bad", {
|
|||||||
|
|
||||||
if name ~= "nssm:morvalar0" and name ~="nssm:kamehameha_bad" then
|
if name ~= "nssm:morvalar0" and name ~="nssm:kamehameha_bad" then
|
||||||
|
|
||||||
tnt_boom_nssm(pos, {damage_radius = 6, radius = 5, ignore_protection = false})
|
nssm:tnt_boom_nssm(pos, {
|
||||||
|
damage_radius = 6, radius = 5, ignore_protection = false})
|
||||||
|
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
end
|
end
|
||||||
|
@ -53,6 +53,6 @@ mobs:register_mob("nssm:sandworm", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
do_custom = function(self)
|
do_custom = function(self)
|
||||||
digging_attack(self, "sand", self.run_velocity, {x = 0, y = 3, z = 0})
|
nssm:digging_attack(self, "sand", self.run_velocity, {x = 0, y = 3, z = 0})
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
@ -57,6 +57,6 @@ mobs:register_mob("nssm:snow_biter", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
do_custom = function(self)
|
do_custom = function(self)
|
||||||
putting_ability(self, "default:ice", self.run_velocity)
|
nssm:putting_ability(self, "default:ice", self.run_velocity)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
@ -57,7 +57,6 @@ mobs:register_mob("nssm:stone_eater", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
do_custom = function(self)
|
do_custom = function(self)
|
||||||
--digging_ability(self, "stone", self.run_velocity, {x=0, y=2, z=0})
|
nssm:digging_attack(self, "stone", self.run_velocity, {x = 0, y = 1, z = 0})
|
||||||
digging_attack(self, "stone", self.run_velocity, {x = 0, y = 1, z = 0})
|
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
@ -55,7 +55,7 @@ mobs:register_mob("nssm:uloboros", {
|
|||||||
do_custom = function(self)
|
do_custom = function(self)
|
||||||
|
|
||||||
if nssm.spiders_litter_web then
|
if nssm.spiders_litter_web then
|
||||||
webber_ability(self, "nssm:web", 2)
|
nssm:webber_ability(self, "nssm:web", 2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
38
nssm_api.lua
38
nssm_api.lua
@ -9,7 +9,7 @@ nssm.lessvirulent = minetest.settings:get_bool("nssm.lessvirulent") or false
|
|||||||
nssm.safebones = minetest.settings:get_bool("nssm.safebones") or false
|
nssm.safebones = minetest.settings:get_bool("nssm.safebones") or false
|
||||||
nssm.cryosave = minetest.settings:get_bool("nssm.cryosave") or false
|
nssm.cryosave = minetest.settings:get_bool("nssm.cryosave") or false
|
||||||
|
|
||||||
function nssm:virulence(mobe)
|
local function virulence(mobe)
|
||||||
|
|
||||||
if not nssm.lessvirulent then
|
if not nssm.lessvirulent then
|
||||||
return 0
|
return 0
|
||||||
@ -23,21 +23,21 @@ function nssm:affectbones(mobe) -- as function for adaptable heuristic
|
|||||||
return not nssm.safebones
|
return not nssm.safebones
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--[[
|
||||||
function drops(drop)
|
function drops(drop)
|
||||||
|
|
||||||
if drop then
|
if drop then
|
||||||
|
|
||||||
drop:setvelocity({
|
drop:set_velocity({
|
||||||
x = math.random(-10, 10) / 9,
|
x = math.random(-10, 10) / 9,
|
||||||
y = 5,
|
y = 5,
|
||||||
z = math.random(-10, 10) / 9
|
z = math.random(-10, 10) / 9
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
]]
|
||||||
|
|
||||||
|
local function perpendicular_vector(vec) --returns a vector rotated of 90° in 2D
|
||||||
function perpendicular_vector(vec) --returns a vector rotated of 90° in 2D
|
|
||||||
|
|
||||||
local ang = math.pi / 2
|
local ang = math.pi / 2
|
||||||
local c = math.cos(ang)
|
local c = math.cos(ang)
|
||||||
@ -50,7 +50,7 @@ function perpendicular_vector(vec) --returns a vector rotated of 90° in 2D
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function add_entity_and_particles(entity, pos, particles, multiplier)
|
function nssm:add_entity_and_particles(entity, pos, particles, multiplier)
|
||||||
|
|
||||||
minetest.add_particlespawner({
|
minetest.add_particlespawner({
|
||||||
amount = 100 * multiplier,
|
amount = 100 * multiplier,
|
||||||
@ -75,7 +75,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
-- get node but use fallback for nil or unknown
|
-- get node but use fallback for nil or unknown
|
||||||
function node_ok(pos, fallback)
|
function nssm:node_ok(pos, fallback)
|
||||||
|
|
||||||
fallback = fallback or "default:dirt"
|
fallback = fallback or "default:dirt"
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ function node_ok(pos, fallback)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function dist_pos(p, s)
|
function nssm:dist_pos(p, s)
|
||||||
|
|
||||||
local v = {
|
local v = {
|
||||||
x = math.abs(s.x - p.x),
|
x = math.abs(s.x - p.x),
|
||||||
@ -104,7 +104,7 @@ function dist_pos(p, s)
|
|||||||
return math.sqrt(v.x ^ 2 + v.y ^ 2 + v.z ^ 2)
|
return math.sqrt(v.x ^ 2 + v.y ^ 2 + v.z ^ 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--[[
|
||||||
--check_for_death functions customized for monsters who respawns (Masticone)
|
--check_for_death functions customized for monsters who respawns (Masticone)
|
||||||
function check_for_death_hydra(self)
|
function check_for_death_hydra(self)
|
||||||
|
|
||||||
@ -140,9 +140,9 @@ function check_for_death_hydra(self)
|
|||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
]]
|
||||||
|
|
||||||
|
local function round(n)
|
||||||
function round(n)
|
|
||||||
|
|
||||||
if (n > 0) then
|
if (n > 0) then
|
||||||
return n % 1 >= 0.5 and math.ceil(n) or math.floor(n)
|
return n % 1 >= 0.5 and math.ceil(n) or math.floor(n)
|
||||||
@ -156,7 +156,7 @@ function round(n)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function explosion_particles(pos, exp_radius)
|
function nssm:explosion_particles(pos, exp_radius)
|
||||||
|
|
||||||
minetest.add_particlespawner({
|
minetest.add_particlespawner({
|
||||||
amount = 100 * exp_radius / 2,
|
amount = 100 * exp_radius / 2,
|
||||||
@ -177,7 +177,7 @@ function explosion_particles(pos, exp_radius)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function digging_attack(
|
function nssm:digging_attack(
|
||||||
self, --the entity of the mob
|
self, --the entity of the mob
|
||||||
group, --group of the blocks the mob can dig: nil=everything
|
group, --group of the blocks the mob can dig: nil=everything
|
||||||
max_vel, --max velocity of the mob
|
max_vel, --max velocity of the mob
|
||||||
@ -237,7 +237,7 @@ function digging_attack(
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function putting_ability( --puts under the mob the block defined as 'p_block'
|
function nssm:putting_ability( --puts under the mob the block defined as 'p_block'
|
||||||
self, --the entity of the mob
|
self, --the entity of the mob
|
||||||
p_block, --definition of the block to use
|
p_block, --definition of the block to use
|
||||||
max_vel --max velocity of the mob
|
max_vel --max velocity of the mob
|
||||||
@ -308,14 +308,14 @@ function putting_ability( --puts under the mob the block defined as 'p_block'
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function webber_ability( --puts randomly around the block defined as w_block
|
function nssm:webber_ability( --puts randomly around the block defined as w_block
|
||||||
self, --the entity of the mob
|
self, --the entity of the mob
|
||||||
w_block, --definition of the block to use
|
w_block, --definition of the block to use
|
||||||
radius --max distance the block can be put
|
radius --max distance the block can be put
|
||||||
)
|
)
|
||||||
|
|
||||||
if nssm:virulence(self) ~= 0
|
if virulence(self) ~= 0
|
||||||
and math.random(1, nssm:virulence(self)) ~= 1 then return end
|
and math.random(1, virulence(self)) ~= 1 then return end
|
||||||
|
|
||||||
local pos = self.object:get_pos()
|
local pos = self.object:get_pos()
|
||||||
|
|
||||||
@ -336,7 +336,7 @@ function webber_ability( --puts randomly around the block defined as w_block
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function midas_ability( --ability to transform every blocks it touches in the m_block block
|
function nssm:midas_ability( --ability to transform every blocks it touches in the m_block block
|
||||||
self, --the entity of the mob
|
self, --the entity of the mob
|
||||||
m_block,
|
m_block,
|
||||||
max_vel, --max velocity of the mob
|
max_vel, --max velocity of the mob
|
||||||
@ -829,7 +829,7 @@ local function tnt_explode(pos, radius, ignore_protection, ignore_on_blast)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function tnt_boom_nssm(pos, def)
|
function nssm:tnt_boom_nssm(pos, def)
|
||||||
|
|
||||||
minetest.sound_play("tnt_explode", {
|
minetest.sound_play("tnt_explode", {
|
||||||
pos = pos, gain = 1.5, max_hear_distance = 2 * 64}, true)
|
pos = pos, gain = 1.5, max_hear_distance = 2 * 64}, true)
|
||||||
|
@ -395,7 +395,7 @@ minetest.register_node("nssm:pumpbomb", {
|
|||||||
|
|
||||||
minetest.set_node(pos, {name = "air"})
|
minetest.set_node(pos, {name = "air"})
|
||||||
|
|
||||||
tnt_boom_nssm(pos, {damage_radius = 4, radius = 3, ignore_protection = false})
|
nssm:tnt_boom_nssm(pos, {damage_radius = 4, radius = 3, ignore_protection = false})
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ end
|
|||||||
|
|
||||||
local function hit(pos, self)
|
local function hit(pos, self)
|
||||||
|
|
||||||
local node = node_ok(pos).name
|
local node = nssm:node_ok(pos).name
|
||||||
|
|
||||||
self.hit_node(self, pos, node)
|
self.hit_node(self, pos, node)
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
@ -216,7 +216,7 @@ local function search_on_step(
|
|||||||
|
|
||||||
if min_dist < 1 then
|
if min_dist < 1 then
|
||||||
|
|
||||||
local node = node_ok(pos).name
|
local node = nssm:node_ok(pos).name
|
||||||
|
|
||||||
self.hit_node(self, pos, node)
|
self.hit_node(self, pos, node)
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
@ -231,7 +231,7 @@ local function search_on_step(
|
|||||||
|
|
||||||
if n ~= "air" and n ~= "default:water_source" and n ~= "default:water_flowing" then
|
if n ~= "air" and n ~= "default:water_source" and n ~= "default:water_flowing" then
|
||||||
|
|
||||||
local node = node_ok(pos).name
|
local node = nssm:node_ok(pos).name
|
||||||
|
|
||||||
self.hit_node(self, pos, node)
|
self.hit_node(self, pos, node)
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
@ -259,7 +259,7 @@ local function default_on_step(
|
|||||||
|
|
||||||
if os.time() - self.life_time > max_time then
|
if os.time() - self.life_time > max_time then
|
||||||
|
|
||||||
local node = node_ok(pos).name
|
local node = nssm:node_ok(pos).name
|
||||||
|
|
||||||
self.hit_node(self, pos, node)
|
self.hit_node(self, pos, node)
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
@ -298,7 +298,7 @@ local function default_on_step(
|
|||||||
|
|
||||||
if n == not_transparent or minetest.get_item_group(n, not_transparent) == 1 then
|
if n == not_transparent or minetest.get_item_group(n, not_transparent) == 1 then
|
||||||
|
|
||||||
local node = node_ok(pos).name
|
local node = nssm:node_ok(pos).name
|
||||||
|
|
||||||
self.hit_node(self, pos, node)
|
self.hit_node(self, pos, node)
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
|
Loading…
Reference in New Issue
Block a user