modified: init.lua
modified: lava_titan.lua modified: nssm_api.lua Working on protections
This commit is contained in:
parent
8b8598a023
commit
9ee5e46aae
2
init.lua
2
init.lua
@ -1,6 +1,6 @@
|
|||||||
local path = minetest.get_modpath("nssm")
|
local path = minetest.get_modpath("nssm")
|
||||||
dofile(path.."/api.lua")
|
dofile(path.."/api.lua")
|
||||||
dofile(path.."/spawn.lua")
|
--dofile(path.."/spawn.lua")
|
||||||
|
|
||||||
--Mobs
|
--Mobs
|
||||||
dofile(path.."/ant_queen.lua")
|
dofile(path.."/ant_queen.lua")
|
||||||
|
@ -81,6 +81,7 @@ nssm:register_mob("nssm:lava_titan", {
|
|||||||
do_custom = function (self)
|
do_custom = function (self)
|
||||||
|
|
||||||
--Digging ability:
|
--Digging ability:
|
||||||
|
--[[
|
||||||
local v = self.object:getvelocity()
|
local v = self.object:getvelocity()
|
||||||
local pos = self.object:getpos()
|
local pos = self.object:getpos()
|
||||||
local c=3
|
local c=3
|
||||||
@ -96,13 +97,16 @@ nssm:register_mob("nssm:lava_titan", {
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
]]--
|
||||||
|
nssm:digging_ability(self, nil, self.run_velocity, {x=0, y=5, z=0})
|
||||||
|
|
||||||
--Melting ability (puts lava where he passes)
|
--Melting ability (puts lava where he passes)
|
||||||
pos.y=pos.y-1
|
--[[pos.y=pos.y-1
|
||||||
local n = minetest.env:get_node(pos).name
|
local n = minetest.env:get_node(pos).name
|
||||||
if n~="default:lava_source" then
|
if n~="default:lava_source" then
|
||||||
minetest.env:set_node(pos, {name="default:lava_source"})
|
minetest.env:set_node(pos, {name="default:lava_source"})
|
||||||
end
|
end
|
||||||
|
]]
|
||||||
|
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
116
nssm_api.lua
116
nssm_api.lua
@ -45,7 +45,13 @@ end
|
|||||||
|
|
||||||
|
|
||||||
function nssm:round(n)
|
function nssm:round(n)
|
||||||
return n % 1 >= 0.5 and math.ceil(n) or math.floor(n)
|
if (n>0) then
|
||||||
|
return n % 1 >= 0.5 and math.ceil(n) or math.floor(n)
|
||||||
|
else
|
||||||
|
n=-n
|
||||||
|
local t = n % 1 >= 0.5 and math.ceil(n) or math.floor(n)
|
||||||
|
return -t
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function nssm:explosion_particles(pos, exp_radius)
|
function nssm:explosion_particles(pos, exp_radius)
|
||||||
@ -178,5 +184,113 @@ function nssm:explosion(pos, exp_radius, fire)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- SPECIAL ABILITIES OF SOME MOBS
|
||||||
|
function nssm:digging_ability(
|
||||||
|
self, --the entity of the mob
|
||||||
|
group, --group of the blocks the mob can dig: nil=everything
|
||||||
|
max_vel, --max velocity of the mob
|
||||||
|
dim --vector representing the dimensions of the mob
|
||||||
|
)
|
||||||
|
|
||||||
|
local v = self.object:getvelocity()
|
||||||
|
local pos = self.object:getpos()
|
||||||
|
|
||||||
|
if minetest.is_protected(pos, "") then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local h = dim.y
|
||||||
|
|
||||||
|
local max = 0
|
||||||
|
--local posmax = 0 -- 1 = x, -1=-x, 2 = z, -2 = -z
|
||||||
|
local yaw = (self.object:getyaw() + self.rotate) or 0
|
||||||
|
local x = math.sin(yaw)*-1
|
||||||
|
local z = math.cos(yaw)
|
||||||
|
|
||||||
|
|
||||||
|
local i = 1
|
||||||
|
local i1 = -1
|
||||||
|
local k = 1
|
||||||
|
local k1 = -1
|
||||||
|
|
||||||
|
local multiplier = 2
|
||||||
|
|
||||||
|
if x>0 then
|
||||||
|
--minetest.chat_send_all("X positivo")
|
||||||
|
i = nssm:round(x*max_vel)*multiplier
|
||||||
|
else
|
||||||
|
--minetest.chat_send_all("X negativo")
|
||||||
|
i1 = nssm:round(x*max_vel)*multiplier
|
||||||
|
end
|
||||||
|
|
||||||
|
if z>0 then
|
||||||
|
--minetest.chat_send_all("Z positivo")
|
||||||
|
k = nssm:round(z*max_vel)*multiplier
|
||||||
|
else
|
||||||
|
--minetest.chat_send_all("Z negativo")
|
||||||
|
k1 = nssm:round(z*max_vel)*multiplier
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--[[
|
||||||
|
if math.abs(v.x)>math.abs(v.z) then
|
||||||
|
max = math.abs(v.x)
|
||||||
|
if v.x>0 then
|
||||||
|
i = max*multiplier
|
||||||
|
else
|
||||||
|
i1 = max*multiplier
|
||||||
|
end
|
||||||
|
else
|
||||||
|
max = math.abs(v.z)
|
||||||
|
if v.z>0 then
|
||||||
|
k = max*multiplier
|
||||||
|
else
|
||||||
|
k1 = max*multiplier
|
||||||
|
end
|
||||||
|
end
|
||||||
|
]]--
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
for dx = i1, i do
|
||||||
|
for dy = 0, h do
|
||||||
|
for dz = k1, k do
|
||||||
|
local p = {x=pos.x+dx, y=pos.y+dy, z=pos.z+dz}
|
||||||
|
if minetest.is_protected(p, singleplayer) then
|
||||||
|
minetest.chat_send_all("Protetto")
|
||||||
|
end
|
||||||
|
|
||||||
|
local n = minetest.env:get_node(p).name
|
||||||
|
--local up = {x=pos.x+dx, y=pos.y+dy, z=pos.z+dz}
|
||||||
|
if group == nil then
|
||||||
|
if minetest.get_item_group(n, "unbreakable") == 1 or minetest.is_protected(p, "") then
|
||||||
|
else
|
||||||
|
minetest.env:set_node(p, {name="air"})
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if (minetest.get_item_group(n, group)==1) and (minetest.get_item_group(n, "unbreakable") ~= 1) and not (minetest.is_protected(p, "")) then
|
||||||
|
minetest.env:set_node(p, {name="air"})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--[[
|
||||||
|
for dx = -c*(math.abs(v.x))-1 , c*(math.abs(v.x))+1 do
|
||||||
|
for dy=0,h do
|
||||||
|
for dz = -c*(math.abs(v.z))-1 , c*(math.abs(v.z))+1 do
|
||||||
|
local p = {x=pos.x+dx, y=pos.y, z=pos.z+dz}
|
||||||
|
local t = {x=pos.x+dx, y=pos.y+dy, z=pos.z+dz}
|
||||||
|
local n = minetest.env:get_node(p).name
|
||||||
|
if (n~="default:water_source" and n~="default:water_flowing") then
|
||||||
|
minetest.env:set_node(t, {name="air"})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
]]
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user