Another batch of wither adjustments

This commit is contained in:
the-real-herowl 2023-08-11 16:54:58 +02:00 committed by the-real-herowl
parent c9dc12b081
commit 729d8ec9e0
13 changed files with 102 additions and 20 deletions

@ -612,7 +612,7 @@ function mcl_util.deal_damage(target, damage, mcl_reason)
end end
return return
end end
end elseif not target:is_player() then return end
local is_immortal = target:get_armor_groups().immortal or 0 local is_immortal = target:get_armor_groups().immortal or 0
if is_immortal>0 then if is_immortal>0 then

@ -297,6 +297,7 @@ function mcl_mobs.register_mob(name, def)
return false, true, {} return false, true, {}
end, end,
do_punch = def.do_punch, do_punch = def.do_punch,
deal_damage = def.deal_damage,
on_breed = def.on_breed, on_breed = def.on_breed,
on_grown = def.on_grown, on_grown = def.on_grown,
on_pick_up = def.on_pick_up, on_pick_up = def.on_pick_up,
@ -314,7 +315,9 @@ function mcl_mobs.register_mob(name, def)
harmed_by_heal = def.harmed_by_heal, harmed_by_heal = def.harmed_by_heal,
is_boss = def.is_boss, is_boss = def.is_boss,
dealt_effect = def.dealt_effect, dealt_effect = def.dealt_effect,
on_lightning_strike = def.on_lightning_strike on_lightning_strike = def.on_lightning_strike,
_spawner = def._spawner,
} }
minetest.register_entity(name, setmetatable(final_def,mcl_mobs.mob_class_meta)) minetest.register_entity(name, setmetatable(final_def,mcl_mobs.mob_class_meta))

@ -9,6 +9,14 @@ local function load_schem(filename)
return data return data
end end
local wboss_overworld = 0
local wboss_nether = 0
local wboss_end = 0
local LIM_OVERWORLD = tonumber(minetest.settings:get("wither_cap_overworld")) or 3
local LIM_NETHER = tonumber(minetest.settings:get("wither_cap_nether")) or 10
local LIM_END = tonumber(minetest.settings:get("wither_cap_end")) or 5
local wither_spawn_schems = {} local wither_spawn_schems = {}
for _, d in pairs(dim) do for _, d in pairs(dim) do
@ -35,16 +43,33 @@ local function remove_schem(pos, schem)
end end
end end
local function check_limit(pos)
local dim = mcl_worlds.pos_to_dimension(pos)
if dim == "overworld" and wboss_overworld >= LIM_OVERWORLD then return false
elseif dim == "end" and wboss_end >= LIM_END then return false
elseif wboss_nether >= LIM_NETHER then return false
else return true end
end
local function wither_spawn(pos, player) local function wither_spawn(pos, player)
for _, d in pairs(dim) do for _, d in pairs(dim) do
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) then if check_schem(p, schem) and 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 witherer = wither:get_luaentity() local witherer = wither:get_luaentity()
witherer._spawner = player witherer._spawner = player:get_player_name()
witherer._custom_timer = 0.0
witherer._death_timer = 0.0
witherer._health_old = witherer.hp_max
local dim = mcl_worlds.pos_to_dimension(pos)
if dim == "overworld" then
wboss_overworld = wboss_overworld + 1
elseif dim == "end" then
wboss_end = wboss_end + 1
else wboss_nether = wboss_nether + 1 end
local objects = minetest.get_objects_inside_radius(pos, 20) local objects = minetest.get_objects_inside_radius(pos, 20)
for _, players in ipairs(objects) do for _, players in ipairs(objects) do
if players:is_player() then if players:is_player() then
@ -65,3 +90,13 @@ function wither_head.on_place(itemstack, placer, pointed)
end end
return old_on_place(itemstack, placer, pointed) return old_on_place(itemstack, placer, pointed)
end 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)

@ -2,4 +2,4 @@ name = mobs_mc
author = maikerumine author = maikerumine
description = Adds Minecraft-like monsters and animals. description = Adds Minecraft-like monsters and animals.
depends = mcl_init, mcl_particles, mcl_mobs, mcl_wip, mcl_core, mcl_util depends = mcl_init, mcl_particles, mcl_mobs, mcl_wip, mcl_core, mcl_util
optional_depends = default, mcl_tnt, mcl_bows, mcl_throwing, mcl_fishing, bones, mesecons_materials, doc_items optional_depends = default, mcl_tnt, mcl_bows, mcl_throwing, mcl_fishing, bones, mesecons_materials, doc_items, mcl_worlds

@ -114,9 +114,7 @@ mcl_mobs.register_mob("mobs_mc:spider", spider)
local cave_spider = table.copy(spider) local cave_spider = table.copy(spider)
cave_spider.description = S("Cave Spider") cave_spider.description = S("Cave Spider")
cave_spider.textures = { {"mobs_mc_cave_spider.png^(mobs_mc_spider_eyes.png^[makealpha:0,0,0)"} } cave_spider.textures = { {"mobs_mc_cave_spider.png^(mobs_mc_spider_eyes.png^[makealpha:0,0,0)"} }
-- TODO: Poison damage cave_spider.damage = 2
-- TODO: Revert damage to 2
cave_spider.damage = 3 -- damage increased to undo non-existing poison
cave_spider.hp_min = 1 cave_spider.hp_min = 1
cave_spider.hp_max = 12 cave_spider.hp_max = 12
cave_spider.collisionbox = {-0.35, -0.01, -0.35, 0.35, 0.46, 0.35} cave_spider.collisionbox = {-0.35, -0.01, -0.35, 0.35, 0.46, 0.35}

@ -70,6 +70,11 @@ mcl_mobs.register_mob("mobs_mc:witch", {
}, },
view_range = 16, view_range = 16,
fear_height = 4, fear_height = 4,
deal_damage = function(self, damage, mcl_reason)
local factor = 1
if mcl_reason.type == "magic" then factor = 0.15 end
self.health = self.health - factor*damage
end,
}) })
-- potion projectile (EXPERIMENTAL) -- potion projectile (EXPERIMENTAL)

@ -9,6 +9,10 @@ local S = minetest.get_translator("mobs_mc")
--################### WITHER --################### WITHER
--################### --###################
mobs_mc.wither_count_overworld = 0
mobs_mc.wither_count_nether = 0
mobs_mc.wither_count_end = 0
mcl_mobs.register_mob("mobs_mc:wither", { mcl_mobs.register_mob("mobs_mc:wither", {
description = S("Wither"), description = S("Wither"),
type = "monster", type = "monster",
@ -53,7 +57,7 @@ mcl_mobs.register_mob("mobs_mc:wither", {
}, },
lava_damage = 0, lava_damage = 0,
fire_damage = 0, fire_damage = 0,
attack_type = "dogshoot", attack_type = "shoot",
explosion_strength = 8, explosion_strength = 8,
dogshoot_stop = true, dogshoot_stop = true,
arrow = "mobs_mc:wither_skull", arrow = "mobs_mc:wither_skull",
@ -68,31 +72,51 @@ mcl_mobs.register_mob("mobs_mc:wither", {
}, },
harmed_by_heal = true, harmed_by_heal = true,
is_boss = true, is_boss = true,
do_custom = function(self) do_custom = function(self, dtime)
local rand_factor self._custom_timer = self._custom_timer + dtime
if self._spawner then if self._custom_timer > 1 then
self.health = math.min(self.health + 1, self.hp_max)
self._custom_timer = self._custom_timer - 1
end
local spawner = minetest.get_player_by_name(self._spawner)
if spawner then
self._death_timer = 0
local pos = self.object:get_pos() local pos = self.object:get_pos()
local spw = self._spawner:get_pos() local spw = spawner:get_pos()
local dist = vector.distance(pos, spw) local dist = vector.distance(pos, spw)
if dist > 60 then -- teleport to the player who spawned the wither if dist > 60 then -- teleport to the player who spawned the wither
local R = 10 local R = 10
pos.x = spw.x + math.random(-r, r) pos.x = spw.x + math.random(-R, R)
pos.y = spw.y + math.random(-r, r) pos.y = spw.y + math.random(-R, R)
pos.z = spw.z + math.random(-r, r) pos.z = spw.z + math.random(-R, R)
self.object:set_pos(pos) self.object:set_pos(pos)
end end
else else
-- TODO implement a death timer here? 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
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
local rand_factor
if self.health < (self.hp_max / 2) then if self.health < (self.hp_max / 2) then
self.base_texture = "mobs_mc_wither_half_health.png" self.base_texture = "mobs_mc_wither_half_health.png"
self.fly = false self.fly = false
self.armor = {undead = 80, fleshy = 80} -- TODO replace with changed arrow resistance self._arrow_resistant = true
rand_factor = 3 rand_factor = 3
else else
self.base_texture = "mobs_mc_wither.png" self.base_texture = "mobs_mc_wither.png"
self.fly = true self.fly = true
self.armor = {undead = 80, fleshy = 100} -- TODO replace with changed arrow resistance self._arrow_resistant = false
rand_factor = 10 rand_factor = 10
end end
self.object:set_properties({textures={self.base_texture}}) self.object:set_properties({textures={self.base_texture}})
@ -102,7 +126,15 @@ mcl_mobs.register_mob("mobs_mc:wither", {
else else
self.arrow = "mobs_mc:wither_skull" self.arrow = "mobs_mc:wither_skull"
end end
-- TODO implement regeneration at rate 1 HP per second end,
do_punch = function(self, hitter, tflp, tool_capabilities, dir)
local ent = hitter:get_luaentity()
if ent and self._arrow_resistant and (string.find(ent.name, "arrow") or string.find(ent.name, "rocket")) then return false end
return true
end,
deal_damage = function(self, damage, mcl_reason)
if self._arrow_resistant and mcl_reason.type == "magic" then return end
self.health = self.health - damage
end, end,
on_spawn = function(self) on_spawn = function(self)
minetest.sound_play("mobs_mc_wither_spawn", {object=self.object, gain=1.0, max_hear_distance=64}) minetest.sound_play("mobs_mc_wither_spawn", {object=self.object, gain=1.0, max_hear_distance=64})

@ -166,6 +166,15 @@ mcl_mob_cap_axolotl (Mob cap axolotl) int 5 0 1024
#Maximum amount of ambient mobs that will spawn near a player (default:15) #Maximum amount of ambient mobs that will spawn near a player (default:15)
mcl_mob_cap_ambient (Mob cap ambient mobs) int 15 0 1024 mcl_mob_cap_ambient (Mob cap ambient mobs) int 15 0 1024
#Maximum amount of wither bosses on the loaded mapchunks in the overworld that allows spawning withers in the overworld (default:3)
wither_cap_overworld (Wither cap overworld) int 3 0 2048
#Maximum amount of wither bosses on the loaded mapchunks in the nether that allows spawning withers in the nether (default:10)
wither_cap_nether (Wither cap nether) int 10 0 2048
#Maximum amount of wither bosses on the loaded mapchunks in the end that allows spawning withers in the end (default:5)
wither_cap_end (Wither cap end) int 5 0 2048
#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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 181 B

After

Width:  |  Height:  |  Size: 150 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 674 B

After

Width:  |  Height:  |  Size: 151 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 660 B

After

Width:  |  Height:  |  Size: 137 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 309 B

After

Width:  |  Height:  |  Size: 250 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 279 B

After

Width:  |  Height:  |  Size: 277 B