Added new midas_ability

master
npx 2016-04-25 22:06:02 +02:00
parent f3bc7191f2
commit d46fc60f43
3 changed files with 56 additions and 34 deletions

View File

@ -62,23 +62,6 @@ nssm:register_mob("nssm:icelamander", {
dattack_end = 210,
},
do_custom = function(self)
--Big_froster
local pos = self.object:getpos()
if minetest.is_protected(pos, "") then
return
end
local c=3
local v = self.object:getvelocity()
for dx = -c*(math.abs(v.x))-1 , c*(math.abs(v.x))+1 do
for dy=-1,3 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+dy, z=pos.z+dz}
local n = minetest.env:get_node(p).name
if (n~="air") and not minetest.is_protected(p, "") then
minetest.env:set_node(p, {name="default:ice"})
end
end
end
end
nssm:midas_ability(self, "default:ice", self.run_velocity,1, 3)
end,
})

View File

@ -60,22 +60,7 @@ nssm:register_mob("nssm:mese_dragon", {
dattack_end = 160,
},
do_custom = function(self)
--transform the blocks he touches in mese_blocks
local pos = self.object:getpos()
local c=2
local v = self.object:getvelocity()
for dx = -c*(math.abs(v.x))-2 , c*(math.abs(v.x))+2 do
for dy=-1,10 do
for dz = -c*(math.abs(v.z))-2 , c*(math.abs(v.z))+2 do
local p = {x=pos.x+dx, y=pos.y+dy, 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~="air" and n~="nssm:mese_meteor" and n~="fire:basic_flame") then
minetest.env:set_node(t, {name="default:mese_block"})
end
end
end
end
nssm:midas_ability(self, "default:mese_block", self.run_velocity,2, 3)
end,
custom_attack = function(self)

View File

@ -310,3 +310,57 @@ function nssm:webber_ability( --puts randomly around the block defined as w_blo
end
end
end
function nssm:midas_ability( --ability to transform every blocks it touches in the m_block block
self, --the entity of the mob
m_block,
max_vel, --max velocity of the mob
mult, --multiplier of the dimensions of the area around that need the transformation
height --height of the mob
)
local v = self.object:getvelocity()
local pos = self.object:getpos()
if minetest.is_protected(pos, "") then
return
end
local max = 0
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 = mult
if x>0 then
i = nssm:round(x*max_vel)*multiplier
else
i1 = nssm:round(x*max_vel)*multiplier
end
if z>0 then
k = nssm:round(z*max_vel)*multiplier
else
k1 = nssm:round(z*max_vel)*multiplier
end
for dx = i1, i do
for dy = -1, height do
for dz = k1, k do
local p = {x=pos.x+dx, y=pos.y+dy, z=pos.z+dz}
local n = minetest.env:get_node(p).name
if minetest.get_item_group(n, "unbreakable") == 1 or minetest.is_protected(p, "") or n=="air" then
else
minetest.env:set_node(p, {name=m_block})
end
end
end
end
end