1
0
Fork 0

Change spawn cap groups to spawn_type to give water it's own spawn cap.

This commit is contained in:
ancientmarinerdev 2023-01-28 23:48:48 +00:00 committed by Gitea
parent 106979e64a
commit 044a91e831
1 changed files with 65 additions and 62 deletions

View File

@ -56,10 +56,10 @@ local MISSING_CAP_DEFAULT = 15
local MOBS_CAP_CLOSE = 5
local mob_cap = {
monster = tonumber(minetest.settings:get("mcl_mob_cap_monster")) or 70,
animal = tonumber(minetest.settings:get("mcl_mob_cap_animal")) or 10,
hostile = tonumber(minetest.settings:get("mcl_mob_cap_monster")) or 70,
passive = tonumber(minetest.settings:get("mcl_mob_cap_animal")) or 10,
ambient = tonumber(minetest.settings:get("mcl_mob_cap_ambient")) or 15,
water = tonumber(minetest.settings:get("mcl_mob_cap_water")) or 5, --currently unused
water = tonumber(minetest.settings:get("mcl_mob_cap_water")) or 5,
water_ambient = tonumber(minetest.settings:get("mcl_mob_cap_water_ambient")) or 20, --currently unused
player = tonumber(minetest.settings:get("mcl_mob_cap_player")) or 75,
total = tonumber(minetest.settings:get("mcl_mob_cap_total")) or 500,
@ -280,7 +280,7 @@ local function count_mobs_add_entry (mobs_list, mob_cat)
end
end
--categorise_by can be name or type
--categorise_by can be name or type or spawn_class
local function count_mobs_all(categorise_by, pos)
local mobs_found_wide = {}
local mobs_found_close = {}
@ -736,14 +736,11 @@ if mobs_spawn then
--end
--mcl_log("spawn_class: " .. spawn_class)
mcl_log("mob_type: " .. mob_type)
local type_cap = mob_cap[mob_type] or MISSING_CAP_DEFAULT
local close_zone_cap = MOBS_CAP_CLOSE
local mob_total_wide = mob_counts_wide[mob_type]
if not mob_total_wide then
--mcl_log("none of type found. set as 0")
@ -754,10 +751,6 @@ if mobs_spawn then
if cap_space_wide < 1 then
cap_space_wide = 0
end
mcl_log("wide: " .. mob_total_wide .. "/" .. type_cap)
--mcl_log("mob_total_wide: " .. mob_total_wide)
mcl_log("cap_space_wide: " .. cap_space_wide)
local mob_total_close = mob_counts_close[mob_type]
if not mob_total_close then
@ -770,9 +763,14 @@ if mobs_spawn then
cap_space_close = 0
end
if mob_type == "water" then
mcl_log("mob_type: " .. mob_type .. " and pos: " .. minetest.pos_to_string(pos))
mcl_log("wide: " .. mob_total_wide .. "/" .. type_cap)
mcl_log("cap_space_wide: " .. cap_space_wide)
mcl_log("close: " .. mob_total_close .. "/" .. close_zone_cap)
mcl_log("cap_space_close: " .. cap_space_close)
end
--TODO Remove old checks
local compare_to_old_checks = false
@ -840,7 +838,7 @@ if mobs_spawn then
return
end
local mob_counts_close, mob_counts_wide, total_mobs = count_mobs_all("type", spawning_position)
local mob_counts_close, mob_counts_wide, total_mobs = count_mobs_all("spawn_class", spawning_position)
-- TODO remove output
output_mob_stats(mob_counts_close, total_mobs)
output_mob_stats(mob_counts_wide, total_mobs)
@ -869,16 +867,16 @@ if mobs_spawn then
if mob_def and mob_def.name and minetest.registered_entities[mob_def.name] then
local mob_def_ent = minetest.registered_entities[mob_def.name]
local mob_type = mob_def_ent.type
--local mob_type = mob_def_ent.type
local mob_spawn_class = mob_def_ent.spawn_class
--mcl_log("mob_spawn_class: " .. mob_spawn_class)
-- TODO use spawn class for caps
--local spawn_class = mob_def_ent.spawn_class
--spawn_class = "water"
local cap_space_wide, cap_space_close = mob_cap_space (spawning_position, mob_spawn_class, mob_counts_close, mob_counts_wide)
local cap_space_wide, cap_space_close = mob_cap_space (spawning_position, mob_type, mob_counts_close, mob_counts_wide)
if cap_space_close > 0 and cap_space_wide > 0 and spawn_check(spawning_position,mob_def) then
if cap_space_close > 0 and cap_space_wide > 0 then
mcl_log("Cap space available")
if spawn_check(spawning_position,mob_def) then
if mob_def.type_of_spawning == "water" then
spawning_position = get_water_spawn(spawning_position)
if not spawning_position then
@ -921,7 +919,7 @@ if mobs_spawn then
if spawned then
--mcl_log("We have spawned")
mob_counts_close, mob_counts_wide, total_mobs = count_mobs_all("type", pos)
local new_spawning_position = find_spawning_position(pos)
local new_spawning_position = find_spawning_position(pos, 3)
if new_spawning_position then
mcl_log("Setting new spawning position")
spawning_position = new_spawning_position
@ -929,6 +927,11 @@ if mobs_spawn then
mcl_log("Cannot set new spawning position")
end
end
else
mcl_log("Spawn check failed")
end
else
mcl_log("Cap space full")
end
end