fix bugs and add additional debug information
This commit is contained in:
parent
c356da14ed
commit
00692065ed
@ -130,6 +130,8 @@ function mobf_spawn_at_night_entity(mob_name,mob_transform,spawning_data,environ
|
||||
if gametime > 0.25 and
|
||||
gametime < 0.75 then
|
||||
dbg_mobf.spawning_lvl3("MOBF: wrong time for at night spawner")
|
||||
self.spawner_last_result = "daytime"
|
||||
self.spawner_time_passed = self.spawner_mob_spawndata.respawndelay
|
||||
return
|
||||
end
|
||||
|
||||
@ -189,13 +191,15 @@ function mobf_spawn_at_night_entity(mob_name,mob_transform,spawning_data,environ
|
||||
--TODO try to move spawner to better place
|
||||
|
||||
self.spawner_time_passed = self.spawner_mob_spawndata.respawndelay
|
||||
self.spawner_last_result = "at_night:" .. dump(reason)
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
--check if current light is dark enough
|
||||
|
||||
if minetest.env:get_node_light(pos) > 6 then
|
||||
self.spawner_time_passed = self.spawner_mob_spawndata.respawndelay
|
||||
self.spawner_last_result = "at_night: to much light"
|
||||
return
|
||||
end
|
||||
|
||||
@ -210,11 +214,15 @@ function mobf_spawn_at_night_entity(mob_name,mob_transform,spawning_data,environ
|
||||
entity.dynamic_data ~= nil and
|
||||
entity.dynamic_data.spawning ~= nil then
|
||||
entity.dynamic_data.spawning.spawner = "at_night_mapgen"
|
||||
self.spawner_last_result = "at_night successfull"
|
||||
else
|
||||
self.spawner_last_result = "at_night failed to spawn"
|
||||
end
|
||||
self.spawner_time_passed = self.spawner_mob_spawndata.respawndelay
|
||||
else
|
||||
self.spawner_time_passed = self.spawner_mob_spawndata.respawndelay
|
||||
dbg_mobf.spawning_lvl2("MOBF: not spawning " .. self.spawner_mob_name .. " there's a mob around")
|
||||
self.spawner_last_result = "at_night: to much mobs around"
|
||||
end
|
||||
end,
|
||||
"_at_night")
|
||||
|
@ -112,29 +112,79 @@ function mobf_spawn_in_deep_large_caves_entity(mob_name,mob_transform,spawning_d
|
||||
spawning.register_spawner_entity(mob_name,mob_transform,spawning_data,environment,
|
||||
function(self)
|
||||
local pos = self.object:getpos()
|
||||
|
||||
local newpos = pos
|
||||
|
||||
local good = true
|
||||
local reason = ""
|
||||
|
||||
dbg_mobf.spawning_lvl3("MOBF: " .. dump(self.spawner_mob_env))
|
||||
local max_tries = 25
|
||||
|
||||
--check if own position is good
|
||||
local pos_below = {x=pos.x,y=pos.y-1,z=pos.z}
|
||||
local node_below = minetest.env:get_node(pos_below)
|
||||
for try=1,max_tries,1 do
|
||||
|
||||
if newpos == nil then
|
||||
|
||||
newpos = {}
|
||||
good = true
|
||||
|
||||
local max_offset = 0.4*self.spawner_mob_spawndata.density
|
||||
|
||||
dbg_mobf.spawning_lvl2("MOBF: trying to get new random value, max_offset:" ..max_offset)
|
||||
|
||||
newpos.x = math.floor(pos.x +
|
||||
math.random(0,max_offset) +
|
||||
0.5)
|
||||
newpos.z = math.floor(pos.z +
|
||||
math.random(0,max_offset) +
|
||||
0.5)
|
||||
newpos.y = mobf_get_surface(newpos.x,newpos.z,pos.y-5, pos.y+5)
|
||||
end
|
||||
|
||||
dbg_mobf.spawning_lvl3("MOBF: " .. dump(self.spawner_mob_env))
|
||||
|
||||
if not mobf_contains({ "default:stone","default:gravel","default:dirt" },node_below.name) then
|
||||
good = false
|
||||
if newpos.y ~= nil then
|
||||
--check if own position is good
|
||||
local pos_below = {x=newpos.x,y=newpos.y-1,z=newpos.z}
|
||||
local node_below = minetest.env:get_node(pos_below)
|
||||
|
||||
|
||||
if not mobf_contains({ "default:stone","default:gravel","default:dirt" },node_below.name) then
|
||||
reason = "wrong surface"
|
||||
good = false
|
||||
end
|
||||
|
||||
--check if there s enough space above to place mob
|
||||
if mobf_air_above(pos_below,self.spawner_mob_spawndata.height) ~= true then
|
||||
reason = "ceiling to low"
|
||||
good = false
|
||||
end
|
||||
else
|
||||
good = false
|
||||
reason = "dlc: floor not found"
|
||||
end
|
||||
|
||||
--this is first check
|
||||
if not good and try == 1 then
|
||||
dbg_mobf.spawning_lvl2("MOBF: deep large caves: not spawning for "
|
||||
.. self.spawner_mob_name .. " somehow got to bad place: "..
|
||||
reason)
|
||||
--TODO try to move spawner to better place
|
||||
else
|
||||
--abort if we found a valid pos
|
||||
if good and try ~= 1 then
|
||||
try = max_tries +1
|
||||
else
|
||||
newpos = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--check if there s enough space above to place mob
|
||||
if mobf_air_above(pos_below,self.spawner_mob_spawndata.height) ~= true then
|
||||
good = false
|
||||
end
|
||||
|
||||
|
||||
if not good then
|
||||
dbg_mobf.spawning_lvl2("MOBF: DLC not spawning for " .. self.spawner_mob_name .. " somehow got to bad place")
|
||||
--TODO try to move spawner to better place
|
||||
|
||||
self.spawner_time_passed = self.spawner_mob_spawndata.respawndelay
|
||||
self.spawner_last_result = dump(reason)
|
||||
return
|
||||
end
|
||||
|
||||
@ -143,11 +193,19 @@ function mobf_spawn_in_deep_large_caves_entity(mob_name,mob_transform,spawning_d
|
||||
pos,
|
||||
self.spawner_mob_spawndata.density,true) < 2 then
|
||||
|
||||
spawning.spawn_and_check(self.spawner_mob_name,"__default",pos,"at_night_spawner_ent")
|
||||
if spawning.spawn_and_check(self.spawner_mob_name,
|
||||
"__default",
|
||||
newpos,
|
||||
"at_night_spawner_ent") then
|
||||
self.spawner_last_result = "dlc: successfull"
|
||||
else
|
||||
self.spawner_last_result = "dlc: spawning failed"
|
||||
end
|
||||
self.spawner_time_passed = self.spawner_mob_spawndata.respawndelay
|
||||
else
|
||||
self.spawner_time_passed = self.spawner_mob_spawndata.respawndelay
|
||||
dbg_mobf.spawning_lvl2("MOBF: not spawning " .. self.spawner_mob_name .. " there's a mob around")
|
||||
self.spawner_last_result = "dlc: mob around"
|
||||
end
|
||||
end)
|
||||
|
||||
|
@ -205,15 +205,25 @@ function mobf_spawn_in_shadows_entity(mob_name,mob_transform,spawning_data,envir
|
||||
end
|
||||
|
||||
if good and mobf_mob_around(self.spawner_mob_name,
|
||||
self.spawner_mob_transform,
|
||||
pos, -- this is intended we really want to know mobs around spawner not new pos
|
||||
self.spawner_mob_spawndata.density,true) == 0 then
|
||||
spawning.spawn_and_check(
|
||||
self.spawner_mob_name,"__default",newpos,"shadows_spawner_ent")
|
||||
self.spawner_mob_transform,
|
||||
-- this is intended we really want to know
|
||||
-- mobs around spawner not new pos
|
||||
pos,
|
||||
self.spawner_mob_spawndata.density,true) == 0 then
|
||||
if spawning.spawn_and_check(
|
||||
self.spawner_mob_name,
|
||||
"__default",
|
||||
newpos,
|
||||
"shadows_spawner_ent") then
|
||||
self.spawner_last_result = "successfull"
|
||||
else
|
||||
self.spawner_last_result = "failed to spawn"
|
||||
end
|
||||
else
|
||||
dbg_mobf.spawning_lvl2("MOBF: shadows: not spawning " ..
|
||||
self.spawner_mob_name ..
|
||||
" there's a mob around or pos not ok: " .. dump(good) .. " rsn: " .. dump(reason))
|
||||
self.spawner_last_result = dump(reason)
|
||||
end
|
||||
|
||||
self.spawner_time_passed = self.spawner_mob_spawndata.respawndelay
|
||||
|
Loading…
x
Reference in New Issue
Block a user