From 729d8ec9e0ad391eeee1d2111fa3074e30de600d Mon Sep 17 00:00:00 2001 From: the-real-herowl Date: Fri, 11 Aug 2023 16:54:58 +0200 Subject: [PATCH] Another batch of wither adjustments --- mods/CORE/mcl_util/init.lua | 2 +- mods/ENTITIES/mcl_mobs/init.lua | 5 +- mods/ENTITIES/mcl_wither_spawning/init.lua | 39 +++++++++++- mods/ENTITIES/mobs_mc/mod.conf | 2 +- mods/ENTITIES/mobs_mc/spider.lua | 4 +- mods/ENTITIES/mobs_mc/witch.lua | 5 ++ mods/ENTITIES/mobs_mc/wither.lua | 56 ++++++++++++++---- settingtypes.txt | 9 +++ textures/mcl_potions_effect_withering.png | Bin 181 -> 150 bytes textures/mcl_potions_icon_regen_wither.png | Bin 674 -> 151 bytes textures/mcl_potions_icon_wither.png | Bin 660 -> 137 bytes textures/mobs_mc_wither_projectile.png | Bin 309 -> 250 bytes textures/mobs_mc_wither_projectile_strong.png | Bin 279 -> 277 bytes 13 files changed, 102 insertions(+), 20 deletions(-) diff --git a/mods/CORE/mcl_util/init.lua b/mods/CORE/mcl_util/init.lua index 5872ce742..d37bb8785 100644 --- a/mods/CORE/mcl_util/init.lua +++ b/mods/CORE/mcl_util/init.lua @@ -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 diff --git a/mods/ENTITIES/mcl_mobs/init.lua b/mods/ENTITIES/mcl_mobs/init.lua index f7699affa..58e418018 100644 --- a/mods/ENTITIES/mcl_mobs/init.lua +++ b/mods/ENTITIES/mcl_mobs/init.lua @@ -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)) diff --git a/mods/ENTITIES/mcl_wither_spawning/init.lua b/mods/ENTITIES/mcl_wither_spawning/init.lua index 6613436ec..fa23c7063 100644 --- a/mods/ENTITIES/mcl_wither_spawning/init.lua +++ b/mods/ENTITIES/mcl_wither_spawning/init.lua @@ -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) diff --git a/mods/ENTITIES/mobs_mc/mod.conf b/mods/ENTITIES/mobs_mc/mod.conf index 5b94879b2..ec7446505 100644 --- a/mods/ENTITIES/mobs_mc/mod.conf +++ b/mods/ENTITIES/mobs_mc/mod.conf @@ -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 diff --git a/mods/ENTITIES/mobs_mc/spider.lua b/mods/ENTITIES/mobs_mc/spider.lua index 90ea384f1..38138a71c 100644 --- a/mods/ENTITIES/mobs_mc/spider.lua +++ b/mods/ENTITIES/mobs_mc/spider.lua @@ -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} diff --git a/mods/ENTITIES/mobs_mc/witch.lua b/mods/ENTITIES/mobs_mc/witch.lua index b00a68116..c9cc3c8ee 100644 --- a/mods/ENTITIES/mobs_mc/witch.lua +++ b/mods/ENTITIES/mobs_mc/witch.lua @@ -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) diff --git a/mods/ENTITIES/mobs_mc/wither.lua b/mods/ENTITIES/mobs_mc/wither.lua index 5859564e4..997378a3a 100644 --- a/mods/ENTITIES/mobs_mc/wither.lua +++ b/mods/ENTITIES/mobs_mc/wither.lua @@ -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}) diff --git a/settingtypes.txt b/settingtypes.txt index 8123ca9d9..4066b6de7 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -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 diff --git a/textures/mcl_potions_effect_withering.png b/textures/mcl_potions_effect_withering.png index df95ad0ea6c851fbf34b1ccb0693f677483e1f78..eed626c6b56a2fcbb82d7ec893b61ae6d163b91d 100644 GIT binary patch delta 121 zcmV-<0EYjy0hR%fBywFzL_t(I%VV&yw*F5EW&jZ@moFd-Q{Mn&r(si!E{9?Oy5DeV zMwZ8F0J0{s3?RiDL>oYs3kZ1wZ!BO76I|iMKuU;XQ_Daoum}Yz&Xh<GIW53>at1|H_*iqF3yWab?NE?mEBaQW81Aw6LV^00000NkvXX Hu0mjf!dppR diff --git a/textures/mcl_potions_icon_regen_wither.png b/textures/mcl_potions_icon_regen_wither.png index 7f82002a9b244ba09e070061732bf1818015cefb..14c6acdad7c663d4c6f082dc6156c00f5973c9f4 100644 GIT binary patch delta 123 zcmV->0EGXd1(yMkBXj^>NklT|NcK1_r3oQ=EnosPz+bl+tUWeAcZh? zNU;C^{|sIK;fhu+UjW9)8uD^72rELE1T-F`16dMg3S1G`T~LKE#TW`;09hee0nBIU d0K@B0004kao_SkQ$K3z`002ovPDHLkV1k2lF+l(T delta 651 zcmV;60(AYC0ip$vBYy#eX+uL$Nkc;*aB^>EX>4Tx04R}tkv&MmKpe$iQ>8^J4ptCx z$WWc^q9VF!6^c+H)C#RSm|Xe=O&XFE7e~Rh;NZt%)xpJCR|i)?5c~jfb#YR3krMxx z6k5c1aNLh~_a1le0HIM~n$#0mH3=^%%lqvKXP61_>FVXWr1f# z%}jcpI7%!QJ6P#pRx&l>N#dBQ>69;IJ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+#loI;ZU(?<6`HcWMsRU&g0N?}9 Wo;T-d6KvuD0000W39kp0pR z=eQRa*9xKV;d9@U@S)>jY!S2k2-`YQd>m9KBS&eno`iGvGFJ&LAJvI12g+yo$N#wJ zII+}7HCvtVtoGs}#w&fqev1>Lp%JvSo`G;|V`IZ{Vr310M$YE6iP<3NbXd>O0q8j5 Y1%Jl1IML9jEdT%j07*qoM6N<$f=S|OSpWb4 delta 282 zcmV+#0pii0u9o!ONI{3d*tE$9({st2ATjg z;dG$kuP8j2<_t70l^VRR*NQ2T0g+|ei&eF*+3M-)_=GbKlX_Yu}JwYW(o;|6z@1vZ|7*S5fPOm{M(_ z;8@*@G2<9BPt0j%4?F`m`fSvMD!3uKmpi~K@R>YLjEwa3jEtP<-tQZaDVsI%!2n!1 gFY*U2zyJi_6BDIVr8YDGzyJUM07*qoM6N<$f(y@qyZ`_I diff --git a/textures/mobs_mc_wither_projectile_strong.png b/textures/mobs_mc_wither_projectile_strong.png index b58d36b1838288917e81120f9a9984f601cdf1d0..4e4c38f737fd1c110d8422897189551d721e896e 100644 GIT binary patch delta 183 zcmV;o07(Cr0+j-gW`CMVL_t&-SACE{iUctX0~LaWs9@;+|7Z7*^vtp|tWE`%Wnl%| zCc?ID_XWy^`~V}?3-Kf)Dt-U}002ovPDHLkV1mAwReAsb delta 185 zcmV;q07n0n0+#}iW`CSXL_t&-(|wSQ3dA4`gDayWL<;);FMF}p`{9lYvSzh@W;5`X z2+JyGcj=#b4x?mVGFI5KL4ItZu)GJL3Mtu;~) ni#a033~`n+*qC$V=cK^{Bi0M?c9QtS00000NkvXXu0mjfP=Hc}