1
0
Fork 0

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

View File

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

View File

@ -297,6 +297,7 @@ function mcl_mobs.register_mob(name, def)
return false, true, {}
end,
do_punch = def.do_punch,
deal_damage = def.deal_damage,
on_breed = def.on_breed,
on_grown = def.on_grown,
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,
is_boss = def.is_boss,
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))

View File

@ -9,6 +9,14 @@ local function load_schem(filename)
return data
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 = {}
for _, d in pairs(dim) do
@ -35,16 +43,33 @@ local function remove_schem(pos, schem)
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)
for _, d in pairs(dim) do
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) then
if check_schem(p, schem) and 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 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)
for _, players in ipairs(objects) do
if players:is_player() then
@ -65,3 +90,13 @@ function wither_head.on_place(itemstack, placer, pointed)
end
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)

View File

@ -2,4 +2,4 @@ name = mobs_mc
author = maikerumine
description = Adds Minecraft-like monsters and animals.
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

View File

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

View File

@ -70,6 +70,11 @@ mcl_mobs.register_mob("mobs_mc:witch", {
},
view_range = 16,
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)

View File

@ -9,6 +9,10 @@ local S = minetest.get_translator("mobs_mc")
--################### 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", {
description = S("Wither"),
type = "monster",
@ -53,7 +57,7 @@ mcl_mobs.register_mob("mobs_mc:wither", {
},
lava_damage = 0,
fire_damage = 0,
attack_type = "dogshoot",
attack_type = "shoot",
explosion_strength = 8,
dogshoot_stop = true,
arrow = "mobs_mc:wither_skull",
@ -68,31 +72,51 @@ mcl_mobs.register_mob("mobs_mc:wither", {
},
harmed_by_heal = true,
is_boss = true,
do_custom = function(self)
local rand_factor
if self._spawner then
do_custom = function(self, dtime)
self._custom_timer = self._custom_timer + dtime
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 spw = self._spawner: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)
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
-- 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
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
self.base_texture = "mobs_mc_wither_half_health.png"
self.fly = false
self.armor = {undead = 80, fleshy = 80} -- TODO replace with changed arrow resistance
self._arrow_resistant = true
rand_factor = 3
else
self.base_texture = "mobs_mc_wither.png"
self.fly = true
self.armor = {undead = 80, fleshy = 100} -- TODO replace with changed arrow resistance
self._arrow_resistant = false
rand_factor = 10
end
self.object:set_properties({textures={self.base_texture}})
@ -102,7 +126,15 @@ mcl_mobs.register_mob("mobs_mc:wither", {
else
self.arrow = "mobs_mc:wither_skull"
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,
on_spawn = function(self)
minetest.sound_play("mobs_mc_wither_spawn", {object=self.object, gain=1.0, max_hear_distance=64})

View File

@ -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)
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
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