mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-22 10:31:06 +01:00
Settings-related fixes
-moved to the cleaner way of obtaining settings values -disabled the anti-troll measures by default -made the wither per-dimension limit dependent on the settings -(anti-troll measures enabled required for wither counting and limit)
This commit is contained in:
parent
20b0f0748d
commit
924a6c1c47
3 changed files with 49 additions and 43 deletions
|
@ -2,6 +2,8 @@ local dim = {"x", "z"}
|
|||
|
||||
local modpath = minetest.get_modpath(minetest.get_current_modname())
|
||||
|
||||
local anti_troll = minetest.settings:get_bool("wither_anti_troll_measures", false)
|
||||
|
||||
local function load_schem(filename)
|
||||
local file = io.open(modpath .. "/schems/" .. filename, "r")
|
||||
local data = minetest.deserialize(file:read())
|
||||
|
@ -56,7 +58,7 @@ local function wither_spawn(pos, player)
|
|||
for i = 0, 2 do
|
||||
local p = vector.add(pos, {x = 0, y = -2, z = 0, [d] = -i})
|
||||
local schem = wither_spawn_schems[d]
|
||||
if check_schem(p, schem) and check_limit(pos) then
|
||||
if check_schem(p, schem) and (not anti_troll or check_limit(pos)) then
|
||||
remove_schem(p, schem)
|
||||
local wither = minetest.add_entity(vector.add(p, {x = 0, y = 1, z = 0, [d] = 1}), "mobs_mc:wither")
|
||||
local wither_ent = wither:get_luaentity()
|
||||
|
@ -88,12 +90,14 @@ function wither_head.on_place(itemstack, placer, pointed)
|
|||
return old_on_place(itemstack, placer, pointed)
|
||||
end
|
||||
|
||||
-- pull wither counts per dimension
|
||||
minetest.register_globalstep(function(dtime)
|
||||
wboss_overworld = mobs_mc.wither_count_overworld
|
||||
wboss_nether = mobs_mc.wither_count_nether
|
||||
wboss_end = mobs_mc.wither_count_end
|
||||
mobs_mc.wither_count_overworld = 0
|
||||
mobs_mc.wither_count_nether = 0
|
||||
mobs_mc.wither_count_end = 0
|
||||
end)
|
||||
if anti_troll then
|
||||
-- pull wither counts per dimension
|
||||
minetest.register_globalstep(function(dtime)
|
||||
wboss_overworld = mobs_mc.wither_count_overworld
|
||||
wboss_nether = mobs_mc.wither_count_nether
|
||||
wboss_end = mobs_mc.wither_count_end
|
||||
mobs_mc.wither_count_overworld = 0
|
||||
mobs_mc.wither_count_nether = 0
|
||||
mobs_mc.wither_count_end = 0
|
||||
end)
|
||||
end
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
--License for code WTFPL and otherwise stated in readmes
|
||||
|
||||
local S = minetest.get_translator("mobs_mc")
|
||||
local mobs_griefing = minetest.settings:get_bool("mobs_griefing") ~= false
|
||||
local follow_spawner = minetest.settings:get_bool("wither_follow_spawner") == true
|
||||
local w_strafes = minetest.settings:get_bool("wither_strafes") ~= false
|
||||
local anti_troll = minetest.settings:get_bool("wither_anti_troll_measures") ~= false
|
||||
local mobs_griefing = minetest.settings:get_bool("mobs_griefing", true)
|
||||
local follow_spawner = minetest.settings:get_bool("wither_follow_spawner", false)
|
||||
local w_strafes = minetest.settings:get_bool("wither_strafes", true)
|
||||
local anti_troll = minetest.settings:get_bool("wither_anti_troll_measures", false)
|
||||
|
||||
local WITHER_INIT_BOOM = 7
|
||||
|
||||
|
@ -170,38 +170,40 @@ mcl_mobs.register_mob("mobs_mc:wither", {
|
|||
self._custom_timer = self._custom_timer - 1
|
||||
end
|
||||
|
||||
if anti_troll and self._spawner then
|
||||
local spawner = minetest.get_player_by_name(self._spawner)
|
||||
if follow_spawner and spawner then
|
||||
self._death_timer = 0
|
||||
local pos = self.object:get_pos()
|
||||
local spw = spawner:get_pos()
|
||||
local dist = vector.distance(pos, spw)
|
||||
if dist > 60 then -- teleport to the player who spawned the wither
|
||||
local R = 10
|
||||
pos.x = spw.x + math.random(-R, R)
|
||||
pos.y = spw.y + math.random(-R, R)
|
||||
pos.z = spw.z + math.random(-R, R)
|
||||
self.object:set_pos(pos)
|
||||
-- anti-troll measures
|
||||
if anti_troll then
|
||||
if self._spawner then
|
||||
local spawner = minetest.get_player_by_name(self._spawner)
|
||||
if follow_spawner and spawner then
|
||||
self._death_timer = 0
|
||||
local pos = self.object:get_pos()
|
||||
local spw = spawner:get_pos()
|
||||
local dist = vector.distance(pos, spw)
|
||||
if dist > 60 then -- teleport to the player who spawned the wither
|
||||
local R = 10
|
||||
pos.x = spw.x + math.random(-R, R)
|
||||
pos.y = spw.y + math.random(-R, R)
|
||||
pos.z = spw.z + math.random(-R, R)
|
||||
self.object:set_pos(pos)
|
||||
end
|
||||
else -- despawn automatically after set time
|
||||
-- HP changes impact timer: taking damage sets it back
|
||||
self._death_timer = self._death_timer + self.health - self._health_old
|
||||
if self.health == self._health_old then self._death_timer = self._death_timer + dtime end
|
||||
if self._death_timer > 100 then
|
||||
self.object:remove()
|
||||
return false
|
||||
end
|
||||
self._health_old = self.health
|
||||
end
|
||||
else -- despawn automatically after set time
|
||||
-- HP changes impact timer: taking damage sets it back
|
||||
self._death_timer = self._death_timer + self.health - self._health_old
|
||||
if self.health == self._health_old then self._death_timer = self._death_timer + dtime end
|
||||
if self._death_timer > 100 then
|
||||
self.object:remove()
|
||||
return false
|
||||
end
|
||||
self._health_old = self.health
|
||||
end
|
||||
-- count withers per dimension
|
||||
local dim = mcl_worlds.pos_to_dimension(self.object:get_pos())
|
||||
if dim == "overworld" then mobs_mc.wither_count_overworld = mobs_mc.wither_count_overworld + 1
|
||||
elseif dim == "nether" then mobs_mc.wither_count_nether = mobs_mc.wither_count_nether + 1
|
||||
elseif dim == "end" then mobs_mc.wither_count_end = mobs_mc.wither_count_end + 1 end
|
||||
end
|
||||
|
||||
-- count withers per dimension
|
||||
local dim = mcl_worlds.pos_to_dimension(self.object:get_pos())
|
||||
if dim == "overworld" then mobs_mc.wither_count_overworld = mobs_mc.wither_count_overworld + 1
|
||||
elseif dim == "nether" then mobs_mc.wither_count_nether = mobs_mc.wither_count_nether + 1
|
||||
elseif dim == "end" then mobs_mc.wither_count_end = mobs_mc.wither_count_end + 1 end
|
||||
|
||||
-- update things dependent on HP
|
||||
local rand_factor
|
||||
if self.health < (self.hp_max / 2) then
|
||||
|
|
|
@ -182,7 +182,7 @@ wither_follow_spawner (Wither following his spawner) bool false
|
|||
wither_strafes (Wither strafes) bool true
|
||||
|
||||
#Wither anti-troll measures (escaping when stuck in a block, despawning when spawner goes offline, teleporting after the spawner). When this is OFF, wither_follow_spawner has no effect.
|
||||
wither_anti_troll_measures (Wither anti-troll measures) bool true
|
||||
wither_anti_troll_measures (Wither anti-troll measures) bool false
|
||||
|
||||
#Display mob icons in inventory instead of mc-like spawn eggs
|
||||
mcl_old_spawn_icons (Old spawn icons instead of eggs) bool false
|
||||
|
|
Loading…
Reference in a new issue