Set mob spawn chance to 2.5 and fix player respawn msg

This commit is contained in:
Wuzzy 2019-02-11 15:49:36 +01:00
parent 9e57828958
commit 5a7952bf92
3 changed files with 21 additions and 15 deletions

View file

@ -65,7 +65,7 @@ local remove_far = false
local difficulty = tonumber(minetest.settings:get("mob_difficulty")) or 1.0 local difficulty = tonumber(minetest.settings:get("mob_difficulty")) or 1.0
local show_health = false local show_health = false
local max_per_block = tonumber(minetest.settings:get("max_objects_per_block") or 99) local max_per_block = tonumber(minetest.settings:get("max_objects_per_block") or 99)
local mobs_spawn_chance = tonumber(minetest.settings:get("mobs_spawn_chance") or 1) local mobs_spawn_chance = tonumber(minetest.settings:get("mobs_spawn_chance") or 2.5)
-- Peaceful mode message so players will know there are no monsters -- Peaceful mode message so players will know there are no monsters
if peaceful_only then if peaceful_only then
@ -3335,7 +3335,7 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light,
nodenames = nodes, nodenames = nodes,
neighbors = neighbors, neighbors = neighbors,
interval = interval, interval = interval,
chance = max(1, (chance * mobs_spawn_chance)), chance = floor(max(1, chance * mobs_spawn_chance)),
catch_up = false, catch_up = false,
action = spawn_abm_action, action = spawn_abm_action,
}) })

View file

@ -2,33 +2,37 @@ mcl_spawn = {}
local mg_name = minetest.get_mapgen_setting("mg_name") local mg_name = minetest.get_mapgen_setting("mg_name")
-- Returns current spawn position of player. -- Returns current custom spawn position of player.
-- Returns nil if player has no custom spawn position.
-- If player is nil or not a player, the default spawn point is returned. -- If player is nil or not a player, the default spawn point is returned.
-- The second return value is true if spawn point is player-chosen, -- The second return value is true if spawn point is player-chosen,
-- false otherwise. -- false otherwise.
mcl_spawn.get_spawn_pos = function(player) mcl_spawn.get_spawn_pos = function(player)
local spawn, custom_spawn local spawn, custom_spawn = nil, false
if player ~= nil and player:is_player() then if player ~= nil and player:is_player() then
spawn = minetest.string_to_pos(player:get_attribute("mcl_beds:spawn")) local attr = player:get_attribute("mcl_beds:spawn")
if attr ~= nil and attr ~= "" then
spawn = minetest.string_to_pos(attr)
custom_spawn = true custom_spawn = true
end end
end
if not spawn or spawn == "" then if not spawn or spawn == "" then
spawn = minetest.setting_get_pos("static_spawnpoint") spawn = minetest.setting_get_pos("static_spawnpoint")
custom_spawn = false custom_spawn = false
end end
if not spawn then if not spawn or spawn == "" then
spawn = { x=0, y=0, z=0 } local attr = player:get_attribute("mcl_spawn:first_spawn")
if mg_name == "flat" then if attr ~= nil and attr ~= "" then
spawn.y = mcl_vars.mg_bedrock_overworld_max + 5 spawn = minetest.string_to_pos(attr)
end
custom_spawn = false custom_spawn = false
end end
end
return spawn, custom_spawn return spawn, custom_spawn
end end
-- Sets the player's spawn position to pos. -- Sets the player's spawn position to pos.
-- Set pos to nil to clear the spawn position. -- Set pos to nil to clear the spawn position.
mcl_spawn.set_spawn_pos = function(player, pos) mcl_spawn.set_spawn_pos = function(player, pos, type)
if pos == nil then if pos == nil then
player:set_attribute("mcl_beds:spawn", "") player:set_attribute("mcl_beds:spawn", "")
else else
@ -39,7 +43,7 @@ end
-- Respawn player at specified respawn position -- Respawn player at specified respawn position
minetest.register_on_respawnplayer(function(player) minetest.register_on_respawnplayer(function(player)
local pos, custom_spawn = mcl_spawn.get_spawn_pos(player) local pos, custom_spawn = mcl_spawn.get_spawn_pos(player)
if custom_spawn then if pos and custom_spawn then
-- Check if bed is still there -- Check if bed is still there
-- and the spawning position is free of solid or damaging blocks. -- and the spawning position is free of solid or damaging blocks.
local node_bed = minetest.get_node(pos) local node_bed = minetest.get_node(pos)
@ -65,5 +69,7 @@ minetest.register_on_respawnplayer(function(player)
end) end)
minetest.register_on_newplayer(function(player) minetest.register_on_newplayer(function(player)
mcl_spawn.set_spawn_pos(player, player:get_pos()) -- Remember where the player spawned first
player:set_attribute("mcl_spawn:first_spawn", minetest.pos_to_string(player:get_pos()))
end) end)

View file

@ -62,7 +62,7 @@ mobs_spawn (Spawn mobs naturally) bool true
# Controls the overall amount of mobs that spawn. The higher the number, # Controls the overall amount of mobs that spawn. The higher the number,
# the less often mobs will spawn. This does not affect mob spawners. # the less often mobs will spawn. This does not affect mob spawners.
mobs_spawn_chance (Mob spawn chance) float 1.0 0.0 mobs_spawn_chance (Mob spawn chance) float 2.5 0.0
# If enabled, only peaceful mobs will appear naturally. This does not # If enabled, only peaceful mobs will appear naturally. This does not
# affect mob spawners. # affect mob spawners.