code tidy (part 3)
This commit is contained in:
parent
8086043b13
commit
f4daef264d
44
darts.lua
44
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,
|
||||
|
||||
|
6
init.lua
6
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")
|
||||
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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
|
||||
})
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
67
nssm_api.lua
67
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
|
||||
|
@ -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}
|
||||
}
|
||||
})
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
118
nssm_spears.lua
118
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)
|
||||
|
||||
|
534
nssm_weapons.lua
534
nssm_weapons.lua
File diff suppressed because it is too large
Load Diff
@ -1,13 +1,16 @@
|
||||
--rainbow!
|
||||
-- rainbow!
|
||||
|
||||
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
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user