Protect fortress nodes.
This commit is contained in:
parent
aa44226a4e
commit
c9c3153f1d
4 changed files with 39 additions and 21 deletions
33
abms.lua
33
abms.lua
|
@ -34,6 +34,7 @@ minetest.register_globalstep(function(dtime)
|
|||
return
|
||||
end
|
||||
|
||||
-- Promote mobs based on spawn position
|
||||
for _, mob in pairs(minetest.luaentities) do
|
||||
if not mob.initial_promotion then
|
||||
local pos = mob.object:getpos()
|
||||
|
@ -54,6 +55,7 @@ minetest.register_globalstep(function(dtime)
|
|||
end
|
||||
end
|
||||
|
||||
-- Spawn mobs in fortresses -- only when a player is near
|
||||
local players = get_connected_players()
|
||||
for i = 1, #players do
|
||||
local player = players[i]
|
||||
|
@ -61,18 +63,6 @@ minetest.register_globalstep(function(dtime)
|
|||
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"})
|
||||
if #counts > 1 then
|
||||
player:set_hp(player:get_hp() - 1)
|
||||
end
|
||||
|
||||
if dps_count % cold_delay == 0 then
|
||||
counts = find_nodes_in_area(minp, maxp, {"group:surface_cold"})
|
||||
if #counts > 1 then
|
||||
player:set_hp(player:get_hp() - 1)
|
||||
end
|
||||
end
|
||||
|
||||
if dps_count % monster_delay == 0 then
|
||||
local mob_count = 0
|
||||
for _, mob in pairs(minetest.luaentities) do
|
||||
|
@ -105,12 +95,31 @@ minetest.register_globalstep(function(dtime)
|
|||
end
|
||||
end
|
||||
|
||||
if fun_caves.DEBUG and player:get_hp() < 20 then
|
||||
print("HP: "..player:get_hp())
|
||||
player:set_hp(20)
|
||||
return
|
||||
else
|
||||
-- Environmental damage from surfaces/hunger
|
||||
local counts = find_nodes_in_area(minp, maxp, {"group:surface_hot"})
|
||||
if #counts > 1 then
|
||||
player:set_hp(player:get_hp() - 1)
|
||||
end
|
||||
|
||||
if dps_count % cold_delay == 0 then
|
||||
counts = find_nodes_in_area(minp, maxp, {"group:surface_cold"})
|
||||
if #counts > 1 then
|
||||
player:set_hp(player:get_hp() - 1)
|
||||
end
|
||||
end
|
||||
|
||||
-- hunger
|
||||
if dps_count % hunger_delay == 0 then
|
||||
player:set_hp(player:get_hp() - 1)
|
||||
dps_count = hunger_delay
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
last_dps_check = get_us_time()
|
||||
dps_count = dps_count - 1
|
||||
|
|
2
init.lua
2
init.lua
|
@ -3,6 +3,8 @@ fun_caves.version = "1.0"
|
|||
fun_caves.time_factor = 10
|
||||
fun_caves.light_max = 8
|
||||
fun_caves.path = minetest.get_modpath(minetest.get_current_modname())
|
||||
fun_caves.DEBUG = true
|
||||
|
||||
|
||||
|
||||
minetest.register_on_mapgen_init(function(mgparams)
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
local DEBUG = false
|
||||
|
||||
local deco_depth = -30 -- place cave stuff this far beneath the surface
|
||||
local light_depth = -13 -- depth above which to place corals/sea plants
|
||||
local water_level = 1
|
||||
|
@ -169,7 +167,7 @@ fun_caves.is_fortress = function(pos, cs, debug)
|
|||
if debug then
|
||||
print(x, y, z, n, floor((n * 10000) % 19))
|
||||
end
|
||||
if floor((n * 10000) % 19) == 1 or DEBUG then
|
||||
if floor((n * 10000) % 19) == 1 or fun_caves.DEBUG then
|
||||
return true
|
||||
end
|
||||
|
||||
|
@ -235,7 +233,7 @@ local function generate(p_minp, p_maxp, seed)
|
|||
data[ivm] = inner_floor
|
||||
end
|
||||
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] = fun_caves.DEBUG and node["default:glass"] or inner_wall
|
||||
data[ivm] = inner_wall
|
||||
else
|
||||
data[ivm] = node["air"]
|
||||
|
@ -678,7 +676,7 @@ local function generate(p_minp, p_maxp, seed)
|
|||
if write then
|
||||
vm:set_data(data)
|
||||
--vm:set_param2_data(p2data)
|
||||
if DEBUG then
|
||||
if fun_caves.DEBUG then
|
||||
vm:set_lighting({day = 15, night = 15})
|
||||
else
|
||||
vm:calc_lighting({x=minp.x,y=emin.y,z=minp.z},maxp)
|
||||
|
|
|
@ -1,3 +1,12 @@
|
|||
local old_is_protected = minetest.is_protected
|
||||
function minetest.is_protected(pos, name)
|
||||
local node = minetest.get_node_or_nil(pos)
|
||||
if node and minetest.get_item_group(node.name, "fortress") ~= 0 then
|
||||
return true
|
||||
end
|
||||
return old_is_protected(pos, name)
|
||||
end
|
||||
|
||||
-- dirt, cave
|
||||
local newnode = fun_caves.clone_node("default:dirt")
|
||||
newnode.drop = "default:dirt"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue