code tidy (part 3)

This commit is contained in:
tenplus1 2022-09-28 19:01:53 +01:00
parent 8086043b13
commit f4daef264d
16 changed files with 1025 additions and 830 deletions

View File

@ -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,
@ -110,12 +114,16 @@ mobs:register_arrow("nssm:snow_arrow", {
-- 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}
@ -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,11 +199,11 @@ 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
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
@ -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,11 +258,11 @@ 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
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
@ -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,

View File

@ -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)

View File

@ -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,
]]--
})

View File

@ -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

View File

@ -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,10 +153,12 @@ mobs:register_mob("nssm:morgut", {
if found == 0 then
if self.inventory[j].num == 0 then
-- found an empty place
found = 2
index = j
else
-- found a corrsponding itemstack
if self.inventory[j].name == n then

View File

@ -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

View File

@ -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
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)
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

View File

@ -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

View File

@ -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

View File

@ -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
@ -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,13 +242,13 @@ 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 math.abs(v.x) > math.abs(v.z) then
if (v.x) > 0 then
dx = 1
else
@ -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})
@ -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()
@ -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)
@ -530,8 +521,7 @@ 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()))
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),
obj:set_velocity({
x = math.random(-3, 3),
y = math.random(0, 10),
z = math.random(-3, 3)})
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

View File

@ -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}
}
})

View File

@ -1,10 +1,10 @@
--non eatable craftitems
-- non-eatable craftitems
local function nssm_craftitem(name, descr)
minetest.register_craftitem("nssm:" .. name, {
description = descr,
image = name .. ".png",
image = name .. ".png"
})
end
@ -196,9 +196,7 @@ minetest.register_ore({
y_min = -1000,
y_max = 40
})
end -- END for loop
end
minetest.register_ore({
ore_type = "scatter",
@ -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",
{
name = "venomous_gas_animated.png",
animation = {
type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 3.0}
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 3.0
}
}
},
paramtype = "light",
@ -374,9 +377,12 @@ minetest.register_node("nssm:pumpbomb", {
light_source = 5,
groups = {not_in_creative_inventory = 1},
drop = "",
on_timer = function(pos, elapsed)
tnt_boom_nssm(pos, {damage_radius = 4, radius = 3, ignore_protection = false})
minetest.set_node(pos, {name = "air"})
tnt_boom_nssm(pos, {damage_radius = 4, radius = 3, ignore_protection = false})
end
})
@ -387,6 +393,7 @@ minetest.register_abm({
neighbors = {"air"},
interval = 2,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
if minetest.is_protected(pos, "") then
@ -401,55 +408,18 @@ minetest.register_abm({
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 = {{
tiles = {
{
name = "phoenix_fire_animated.png",
animation = {
type = "vertical_frames",
aspect_w = 16, aspect_h = 16, length = 1}
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,6 +447,7 @@ 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
@ -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,7 +837,6 @@ 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)
@ -940,7 +910,6 @@ 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)
@ -951,6 +920,7 @@ minetest.register_tool("nssm:gratuitousness_battleaxe", {
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,7 +999,7 @@ 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
@ -1104,7 +1073,6 @@ 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
pos = vector.add(pos, vec)
@ -1113,25 +1081,30 @@ minetest.register_tool("nssm:falchion_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
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
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
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"})
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"})
if math.random(3) == 1 then
v.y = v.y + 2
drop = minetest.add_item(v, "nssm:life_energy 1")
@ -1431,16 +1451,18 @@ 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"})
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
@ -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",
@ -1654,8 +1679,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",
type = "shapeless",
@ -1850,20 +1873,20 @@ 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",
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")
@ -1876,32 +1899,46 @@ end
-- Eggs
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
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
})
@ -1965,11 +2002,15 @@ nssm_register_egg2 ("morwa", "Morwa")
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
minetest.register_node("nssm:morwa_statue", {
description = "Morwa Statue",
drawtype = "mesh",
@ -2005,12 +2049,10 @@ 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}
}
})
@ -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)

View File

@ -2,6 +2,7 @@
-- functions
local function spears_shot(itemstack, player)
local spear = itemstack:get_name() .. '_entity'
local playerpos = player:get_pos()
local obj = minetest.add_entity({
@ -9,7 +10,9 @@ 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
@ -17,17 +20,22 @@ local function spears_shot (itemstack, player)
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 = {
physical = false,
timer = 0,
@ -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,6 +133,7 @@ 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
@ -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,
@ -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
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,6 +247,7 @@ minetest.register_tool("nssm:spear_of_peace", {
})
local function spears_set_sentity(kind, eq, toughness)
local SUPERSPEAR_ENTITY = {
physical = false,
timer = 0,
@ -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,6 +345,7 @@ 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

File diff suppressed because it is too large Load Diff

View File

@ -4,10 +4,13 @@ minetest.register_entity("nssm:rainbow", {
textures = {"transparent.png"},
velocity = 10,
hp_max = 50,
on_step = function (self, pos, node, dtime)
self.timer = self.timer or os.time()
local pos = self.object:get_pos()
if minetest.is_protected(pos, "") then
return
end
@ -18,13 +21,17 @@ minetest.register_entity("nssm:rainbow", {
end
if minetest.get_node(pos) then
local n = minetest.get_node(pos).name
if n ~= "nyancat:nyancat_rainbow" then
if n == "air" then
minetest.set_node(pos, {name = "nyancat:nyancat_rainbow"})
else
minetest.chat_send_all("Nome:" .. n)
minetest.set_node(pos, {name = "nyancat:nyancat"})
self.object:remove()
end
end
@ -35,7 +42,10 @@ minetest.register_entity("nssm:rainbow", {
minetest.register_tool("nssm:rainbow_staff", {
description = "Rainbow Staff",
inventory_image = "rainbow_staff.png",
groups = {not_in_creative_inventory = 1}
on_use = function(itemstack, placer, pointed_thing)
local dir = placer:get_look_dir()
local playerpos = placer:get_pos()
local obj = minetest.add_entity({
@ -43,9 +53,11 @@ minetest.register_tool("nssm:rainbow_staff", {
y = playerpos.y + 2 + dir.y,
z = playerpos.z + dir.z
}, "nssm:rainbow")
local vec = {x = dir.x * 6, y = dir.y * 6, z = dir.z * 6}
obj:set_velocity(vec)
return itemstack
end,
groups = {not_in_creative_inventory = 1}
end
})