mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-11-28 05:43:43 +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
@ -2,6 +2,8 @@ local dim = {"x", "z"}
|
|||||||
|
|
||||||
local modpath = minetest.get_modpath(minetest.get_current_modname())
|
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 function load_schem(filename)
|
||||||
local file = io.open(modpath .. "/schems/" .. filename, "r")
|
local file = io.open(modpath .. "/schems/" .. filename, "r")
|
||||||
local data = minetest.deserialize(file:read())
|
local data = minetest.deserialize(file:read())
|
||||||
@ -56,7 +58,7 @@ local function wither_spawn(pos, player)
|
|||||||
for i = 0, 2 do
|
for i = 0, 2 do
|
||||||
local p = vector.add(pos, {x = 0, y = -2, z = 0, [d] = -i})
|
local p = vector.add(pos, {x = 0, y = -2, z = 0, [d] = -i})
|
||||||
local schem = wither_spawn_schems[d]
|
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)
|
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 = minetest.add_entity(vector.add(p, {x = 0, y = 1, z = 0, [d] = 1}), "mobs_mc:wither")
|
||||||
local wither_ent = wither:get_luaentity()
|
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)
|
return old_on_place(itemstack, placer, pointed)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- pull wither counts per dimension
|
if anti_troll then
|
||||||
minetest.register_globalstep(function(dtime)
|
-- pull wither counts per dimension
|
||||||
wboss_overworld = mobs_mc.wither_count_overworld
|
minetest.register_globalstep(function(dtime)
|
||||||
wboss_nether = mobs_mc.wither_count_nether
|
wboss_overworld = mobs_mc.wither_count_overworld
|
||||||
wboss_end = mobs_mc.wither_count_end
|
wboss_nether = mobs_mc.wither_count_nether
|
||||||
mobs_mc.wither_count_overworld = 0
|
wboss_end = mobs_mc.wither_count_end
|
||||||
mobs_mc.wither_count_nether = 0
|
mobs_mc.wither_count_overworld = 0
|
||||||
mobs_mc.wither_count_end = 0
|
mobs_mc.wither_count_nether = 0
|
||||||
end)
|
mobs_mc.wither_count_end = 0
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
@ -5,10 +5,10 @@
|
|||||||
--License for code WTFPL and otherwise stated in readmes
|
--License for code WTFPL and otherwise stated in readmes
|
||||||
|
|
||||||
local S = minetest.get_translator("mobs_mc")
|
local S = minetest.get_translator("mobs_mc")
|
||||||
local mobs_griefing = minetest.settings:get_bool("mobs_griefing") ~= false
|
local mobs_griefing = minetest.settings:get_bool("mobs_griefing", true)
|
||||||
local follow_spawner = minetest.settings:get_bool("wither_follow_spawner") == true
|
local follow_spawner = minetest.settings:get_bool("wither_follow_spawner", false)
|
||||||
local w_strafes = minetest.settings:get_bool("wither_strafes") ~= false
|
local w_strafes = minetest.settings:get_bool("wither_strafes", true)
|
||||||
local anti_troll = minetest.settings:get_bool("wither_anti_troll_measures") ~= false
|
local anti_troll = minetest.settings:get_bool("wither_anti_troll_measures", false)
|
||||||
|
|
||||||
local WITHER_INIT_BOOM = 7
|
local WITHER_INIT_BOOM = 7
|
||||||
|
|
||||||
@ -170,38 +170,40 @@ mcl_mobs.register_mob("mobs_mc:wither", {
|
|||||||
self._custom_timer = self._custom_timer - 1
|
self._custom_timer = self._custom_timer - 1
|
||||||
end
|
end
|
||||||
|
|
||||||
if anti_troll and self._spawner then
|
-- anti-troll measures
|
||||||
local spawner = minetest.get_player_by_name(self._spawner)
|
if anti_troll then
|
||||||
if follow_spawner and spawner then
|
if self._spawner then
|
||||||
self._death_timer = 0
|
local spawner = minetest.get_player_by_name(self._spawner)
|
||||||
local pos = self.object:get_pos()
|
if follow_spawner and spawner then
|
||||||
local spw = spawner:get_pos()
|
self._death_timer = 0
|
||||||
local dist = vector.distance(pos, spw)
|
local pos = self.object:get_pos()
|
||||||
if dist > 60 then -- teleport to the player who spawned the wither
|
local spw = spawner:get_pos()
|
||||||
local R = 10
|
local dist = vector.distance(pos, spw)
|
||||||
pos.x = spw.x + math.random(-R, R)
|
if dist > 60 then -- teleport to the player who spawned the wither
|
||||||
pos.y = spw.y + math.random(-R, R)
|
local R = 10
|
||||||
pos.z = spw.z + math.random(-R, R)
|
pos.x = spw.x + math.random(-R, R)
|
||||||
self.object:set_pos(pos)
|
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
|
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
|
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
|
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
|
-- update things dependent on HP
|
||||||
local rand_factor
|
local rand_factor
|
||||||
if self.health < (self.hp_max / 2) then
|
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_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 (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
|
#Display mob icons in inventory instead of mc-like spawn eggs
|
||||||
mcl_old_spawn_icons (Old spawn icons instead of eggs) bool false
|
mcl_old_spawn_icons (Old spawn icons instead of eggs) bool false
|
||||||
|
Loading…
Reference in New Issue
Block a user