Separate fortress monster spawn system
This commit is contained in:
parent
85353e0ce6
commit
aa44226a4e
6 changed files with 89 additions and 9 deletions
43
abms.lua
43
abms.lua
|
@ -4,12 +4,17 @@
|
||||||
local dps_delay = 3000000
|
local dps_delay = 3000000
|
||||||
local last_dps_check = 0
|
local last_dps_check = 0
|
||||||
local cold_delay = 5
|
local cold_delay = 5
|
||||||
|
local monster_delay = 3
|
||||||
local hunger_delay = 60
|
local hunger_delay = 60
|
||||||
local dps_count = hunger_delay
|
local dps_count = hunger_delay
|
||||||
|
-- maximum number of mobs near player in fortresses
|
||||||
|
local fortress_mob_count = 5
|
||||||
|
|
||||||
local get_us_time = minetest.get_us_time
|
local get_us_time = minetest.get_us_time
|
||||||
local floor = math.floor
|
local floor = math.floor
|
||||||
local abs = math.abs
|
local abs = math.abs
|
||||||
local max = math.max
|
local max = math.max
|
||||||
|
local min = math.min
|
||||||
local rand = math.random
|
local rand = math.random
|
||||||
local mushrooms = {"flowers:mushroom_brown", "flowers:mushroom_red"}
|
local mushrooms = {"flowers:mushroom_brown", "flowers:mushroom_red"}
|
||||||
local get_node_light = minetest.get_node_light
|
local get_node_light = minetest.get_node_light
|
||||||
|
@ -35,6 +40,7 @@ minetest.register_globalstep(function(dtime)
|
||||||
if mob.hp_max and mob.object and mob.health and mob.damage then
|
if mob.hp_max and mob.object and mob.health and mob.damage then
|
||||||
local factor = 1 + (max(abs(pos.x), abs(pos.y), abs(pos.z)) / 6200)
|
local factor = 1 + (max(abs(pos.x), abs(pos.y), abs(pos.z)) / 6200)
|
||||||
if fun_caves.is_fortress(pos) then
|
if fun_caves.is_fortress(pos) then
|
||||||
|
mob.started_in_fortress = true
|
||||||
factor = factor * 1.5
|
factor = factor * 1.5
|
||||||
end
|
end
|
||||||
mob.hp_max = floor(mob.hp_max * factor)
|
mob.hp_max = floor(mob.hp_max * factor)
|
||||||
|
@ -51,8 +57,9 @@ minetest.register_globalstep(function(dtime)
|
||||||
local players = get_connected_players()
|
local players = get_connected_players()
|
||||||
for i = 1, #players do
|
for i = 1, #players do
|
||||||
local player = players[i]
|
local player = players[i]
|
||||||
local minp = vector.subtract(player:getpos(), 0.5)
|
local pos = player:getpos()
|
||||||
local maxp = vector.add(player:getpos(), 0.5)
|
local minp = vector.subtract(pos, 0.5)
|
||||||
|
local maxp = vector.add(pos, 0.5)
|
||||||
|
|
||||||
local counts = find_nodes_in_area(minp, maxp, {"group:surface_hot"})
|
local counts = find_nodes_in_area(minp, maxp, {"group:surface_hot"})
|
||||||
if #counts > 1 then
|
if #counts > 1 then
|
||||||
|
@ -66,6 +73,38 @@ minetest.register_globalstep(function(dtime)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if dps_count % monster_delay == 0 then
|
||||||
|
local mob_count = 0
|
||||||
|
for _, mob in pairs(minetest.luaentities) do
|
||||||
|
if mob.health and mob.started_in_fortress then
|
||||||
|
local dist = vector.subtract(pos, mob.object:getpos())
|
||||||
|
local dist2 = max(abs(dist.x), abs(dist.y * 5), abs(dist.z))
|
||||||
|
if dist2 < 30 then
|
||||||
|
--print(mob.name, dist.y)
|
||||||
|
mob_count = mob_count + 1
|
||||||
|
else
|
||||||
|
--print("* not", mob.name, dist2)
|
||||||
|
--print(dump(dist))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if mob_count < fortress_mob_count then
|
||||||
|
local pos1, count = find_nodes_in_area_under_air({x=pos.x-30, y=pos.y-2, z=pos.z-30}, {x=pos.x+30, y=pos.y+2, z=pos.z+30}, {"group:fortress"})
|
||||||
|
if #pos1 > 0 then
|
||||||
|
local pos2 = pos1[rand(#pos1)]
|
||||||
|
pos2.y = pos2.y + 2
|
||||||
|
local name = fun_caves.fortress_spawns[rand(#fun_caves.fortress_spawns)]
|
||||||
|
local mob = minetest.add_entity(pos2, name)
|
||||||
|
if mob then
|
||||||
|
print("Fun Caves: Spawned "..name.." at ("..pos2.x..","..pos2.y..","..pos2.z..")")
|
||||||
|
else
|
||||||
|
print("Fun Caves: failed to spawn "..name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- hunger
|
-- hunger
|
||||||
if dps_count % hunger_delay == 0 then
|
if dps_count % hunger_delay == 0 then
|
||||||
player:set_hp(player:get_hp() - 1)
|
player:set_hp(player:get_hp() - 1)
|
||||||
|
|
|
@ -107,7 +107,7 @@ minetest.register_node("fun_caves:moon_juice", {
|
||||||
})
|
})
|
||||||
|
|
||||||
-- mushroom cap, giant
|
-- mushroom cap, giant
|
||||||
minetest.register_node("fun_caves:giant_mushroom_cap", {
|
local cap = {
|
||||||
description = "Giant Mushroom Cap",
|
description = "Giant Mushroom Cap",
|
||||||
tiles = {"vmg_mushroom_giant_cap.png", "vmg_mushroom_giant_under.png", "vmg_mushroom_giant_cap.png"},
|
tiles = {"vmg_mushroom_giant_cap.png", "vmg_mushroom_giant_under.png", "vmg_mushroom_giant_cap.png"},
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
|
@ -123,7 +123,22 @@ minetest.register_node("fun_caves:giant_mushroom_cap", {
|
||||||
} },
|
} },
|
||||||
light_source = fun_caves.light_max,
|
light_source = fun_caves.light_max,
|
||||||
groups = {fleshy=1, dig_immediate=3, flammable=2, plant=1},
|
groups = {fleshy=1, dig_immediate=3, flammable=2, plant=1},
|
||||||
})
|
}
|
||||||
|
if false then
|
||||||
|
cap.node_box.fixed = {
|
||||||
|
{-0.3, -0.25, -0.3, 0.3, 0.5, 0.3},
|
||||||
|
{-0.3, -0.25, -0.4, 0.3, 0.4, -0.3},
|
||||||
|
{-0.3, -0.25, 0.3, 0.3, 0.4, 0.4},
|
||||||
|
{-0.4, -0.25, -0.3, -0.3, 0.4, 0.3},
|
||||||
|
{0.3, -0.25, -0.3, 0.4, 0.4, 0.3},
|
||||||
|
{-0.4, -0.5, -0.4, 0.4, -0.25, 0.4},
|
||||||
|
{-0.5, -0.5, -0.4, -0.4, -0.25, 0.4},
|
||||||
|
{0.4, -0.5, -0.4, 0.5, -0.25, 0.4},
|
||||||
|
{-0.4, -0.5, -0.5, 0.4, -0.25, -0.4},
|
||||||
|
{-0.4, -0.5, 0.4, 0.4, -0.25, 0.5},
|
||||||
|
}
|
||||||
|
end
|
||||||
|
minetest.register_node("fun_caves:giant_mushroom_cap", cap)
|
||||||
|
|
||||||
-- mushroom cap, huge
|
-- mushroom cap, huge
|
||||||
minetest.register_node("fun_caves:huge_mushroom_cap", {
|
minetest.register_node("fun_caves:huge_mushroom_cap", {
|
||||||
|
|
|
@ -121,7 +121,7 @@ mobs:register_mob("fun_caves:goblin_coal", {
|
||||||
|
|
||||||
})
|
})
|
||||||
mobs:register_egg("fun_caves:goblin_coal", "Goblin Egg (coal)", "default_mossycobble.png", 1)
|
mobs:register_egg("fun_caves:goblin_coal", "Goblin Egg (coal)", "default_mossycobble.png", 1)
|
||||||
mobs:register_spawn("fun_caves:goblin_coal", {"default:coalblock", "default:stone_with_coal", "group:fortress"}, 100, 0, 1 * fun_caves.goblin_spawn_frequency, 3, -51)
|
mobs:register_spawn("fun_caves:goblin_coal", {"default:coalblock", "default:stone_with_coal"}, 100, 0, 1 * fun_caves.goblin_spawn_frequency, 3, -51)
|
||||||
mobs:register_spawn("fun_caves:goblin_coal", {"default:mossycobble", "fun_caves:hot_cobble"}, 100, 0, 1 * fun_caves.goblin_spawn_frequency, 3, -51)
|
mobs:register_spawn("fun_caves:goblin_coal", {"default:mossycobble", "fun_caves:hot_cobble"}, 100, 0, 1 * fun_caves.goblin_spawn_frequency, 3, -51)
|
||||||
|
|
||||||
minetest.register_node("fun_caves:stone_with_coal_trap", {
|
minetest.register_node("fun_caves:stone_with_coal_trap", {
|
||||||
|
|
|
@ -120,7 +120,7 @@ mobs:register_mob("fun_caves:goblin_copper", {
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
mobs:register_egg("fun_caves:goblin_copper", "Goblin Egg (copper)", "default_mossycobble.png", 1)
|
mobs:register_egg("fun_caves:goblin_copper", "Goblin Egg (copper)", "default_mossycobble.png", 1)
|
||||||
mobs:register_spawn("fun_caves:goblin_copper", {"default:stone_with_copper", "group:fortress"}, 100, 0, 1 * fun_caves.goblin_spawn_frequency, 3, -51)
|
mobs:register_spawn("fun_caves:goblin_copper", {"default:stone_with_copper"}, 100, 0, 1 * fun_caves.goblin_spawn_frequency, 3, -51)
|
||||||
mobs:register_spawn("fun_caves:goblin_copper", {"default:mossycobble"}, 100, 0, 1 * fun_caves.goblin_spawn_frequency, 3, -51)
|
mobs:register_spawn("fun_caves:goblin_copper", {"default:mossycobble"}, 100, 0, 1 * fun_caves.goblin_spawn_frequency, 3, -51)
|
||||||
|
|
||||||
minetest.register_node("fun_caves:stone_with_copper_trap", {
|
minetest.register_node("fun_caves:stone_with_copper_trap", {
|
||||||
|
|
|
@ -235,7 +235,8 @@ local function generate(p_minp, p_maxp, seed)
|
||||||
data[ivm] = inner_floor
|
data[ivm] = inner_floor
|
||||||
end
|
end
|
||||||
elseif (z - minp.z) % 5 == 0 or (x - minp.x) % 5 == 0 then
|
elseif (z - minp.z) % 5 == 0 or (x - minp.x) % 5 == 0 then
|
||||||
data[ivm] = DEBUG and node["default:glass"] or inner_wall
|
--data[ivm] = DEBUG and node["default:glass"] or inner_wall
|
||||||
|
data[ivm] = inner_wall
|
||||||
else
|
else
|
||||||
data[ivm] = node["air"]
|
data[ivm] = node["air"]
|
||||||
end
|
end
|
||||||
|
|
29
mobs.lua
29
mobs.lua
|
@ -67,13 +67,12 @@ dofile(fun_caves.path .. "/danglers.lua")
|
||||||
dofile(fun_caves.path .. "/spider.lua")
|
dofile(fun_caves.path .. "/spider.lua")
|
||||||
dofile(fun_caves.path .. "/tarantula.lua")
|
dofile(fun_caves.path .. "/tarantula.lua")
|
||||||
dofile(fun_caves.path .. "/spider_ice.lua")
|
dofile(fun_caves.path .. "/spider_ice.lua")
|
||||||
--dofile(fun_caves.path .. "/dirt_monster.lua")
|
|
||||||
dofile(fun_caves.path .. "/sand_monster.lua")
|
dofile(fun_caves.path .. "/sand_monster.lua")
|
||||||
dofile(fun_caves.path .. "/tar_monster.lua")
|
dofile(fun_caves.path .. "/tar_monster.lua")
|
||||||
|
|
||||||
if minetest.registered_entities["mobs_monster:dirt_monster"] then
|
if minetest.registered_entities["mobs_monster:dirt_monster"] then
|
||||||
-- check this
|
-- check this
|
||||||
mobs:register_spawn("mobs_monster:dirt_monster", {"default:dirt"}, 7, 0, 7000, 1, -50, false)
|
mobs:register_spawn("mobs_monster:dirt_monster", {"default:dirt"}, 7, 0, 4000, 1, -50, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.registered_entities["mobs_slimes:green_big"] then
|
if minetest.registered_entities["mobs_slimes:green_big"] then
|
||||||
|
@ -119,3 +118,29 @@ dofile(fun_caves.path.."/goblin_iron.lua")
|
||||||
dofile(fun_caves.path.."/goblin_gold.lua")
|
dofile(fun_caves.path.."/goblin_gold.lua")
|
||||||
dofile(fun_caves.path.."/goblin_diamond.lua")
|
dofile(fun_caves.path.."/goblin_diamond.lua")
|
||||||
dofile(fun_caves.path.."/goblin_king.lua")
|
dofile(fun_caves.path.."/goblin_king.lua")
|
||||||
|
|
||||||
|
fun_caves.fortress_spawns = {}
|
||||||
|
local t_mobs = {
|
||||||
|
"mobs_monster:dungeon_master",
|
||||||
|
"mobs_monster:lava_flan",
|
||||||
|
"mobs_monster:mese_monster",
|
||||||
|
"mobs_monster:oerkki",
|
||||||
|
"mobs_monster:stone_monster",
|
||||||
|
"fun_caves:spider",
|
||||||
|
"mobs_slimes:green_big",
|
||||||
|
"mobs_slimes:green_medium",
|
||||||
|
"mobs_slimes:green_small",
|
||||||
|
"fun_caves:goblin_cobble",
|
||||||
|
"fun_caves:goblin_copper",
|
||||||
|
"fun_caves:goblin_coal",
|
||||||
|
"fun_caves:goblin_ice",
|
||||||
|
"fun_caves:goblin_iron",
|
||||||
|
"fun_caves:goblin_gold",
|
||||||
|
"fun_caves:goblin_diamond",
|
||||||
|
"fun_caves:goblin_king",
|
||||||
|
}
|
||||||
|
for _, mob in pairs(t_mobs) do
|
||||||
|
if minetest.registered_entities[mob] then
|
||||||
|
fun_caves.fortress_spawns[#fun_caves.fortress_spawns+1] = mob
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue