From 747bf16a9461ddf938f530060ff5190347cb3046 Mon Sep 17 00:00:00 2001 From: the-real-herowl Date: Sat, 27 Apr 2024 05:12:42 +0200 Subject: [PATCH] Migrated mobs to the new effects API --- mods/ENTITIES/mcl_mobs/combat.lua | 7 ++----- mods/ENTITIES/mobs_mc/skeleton_wither.lua | 2 +- mods/ENTITIES/mobs_mc/spider.lua | 2 +- mods/ENTITIES/mobs_mc/wither.lua | 10 +++++----- mods/ITEMS/mcl_potions/init.lua | 13 ------------- 5 files changed, 9 insertions(+), 25 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/combat.lua b/mods/ENTITIES/mcl_mobs/combat.lua index 99878be2e..d9df817e4 100644 --- a/mods/ENTITIES/mcl_mobs/combat.lua +++ b/mods/ENTITIES/mcl_mobs/combat.lua @@ -21,8 +21,6 @@ local function atan(x) end end -mcl_mobs.effect_functions = {} - -- check if daytime and also if mob is docile during daylight hours function mob_class:day_docile() @@ -1153,9 +1151,8 @@ function mob_class:do_states_attack (dtime) damage_groups = {fleshy = self.damage} }, nil) if self.dealt_effect then - mcl_mobs.effect_functions[self.dealt_effect.name]( - self.attack, self.dealt_effect.factor, self.dealt_effect.dur - ) + mcl_potions.give_effect_by_level(self.dealt_effect.name, self.attack, + self.dealt_effect.level, self.dealt_effect.dur) end end else diff --git a/mods/ENTITIES/mobs_mc/skeleton_wither.lua b/mods/ENTITIES/mobs_mc/skeleton_wither.lua index c39104f4b..b01fb4b96 100644 --- a/mods/ENTITIES/mobs_mc/skeleton_wither.lua +++ b/mods/ENTITIES/mobs_mc/skeleton_wither.lua @@ -98,7 +98,7 @@ mcl_mobs.register_mob("mobs_mc:witherskeleton", { fire_resistant = true, dealt_effect = { name = "withering", - factor = 1, + level = 1, dur = 10, }, }) diff --git a/mods/ENTITIES/mobs_mc/spider.lua b/mods/ENTITIES/mobs_mc/spider.lua index 16f802c09..d01c7afbe 100644 --- a/mods/ENTITIES/mobs_mc/spider.lua +++ b/mods/ENTITIES/mobs_mc/spider.lua @@ -138,7 +138,7 @@ cave_spider.sounds = table.copy(spider.sounds) cave_spider.sounds.base_pitch = 1.25 cave_spider.dealt_effect = { name = "poison", - factor = 2.5, + level = 2, dur = 7, } mcl_mobs.register_mob("mobs_mc:cave_spider", cave_spider) diff --git a/mods/ENTITIES/mobs_mc/wither.lua b/mods/ENTITIES/mobs_mc/wither.lua index f1e1e6e78..252873629 100644 --- a/mods/ENTITIES/mobs_mc/wither.lua +++ b/mods/ENTITIES/mobs_mc/wither.lua @@ -349,7 +349,7 @@ mcl_mobs.register_mob("mobs_mc:wither", { mcl_util.deal_damage(objs[n], 8, {type = "magic"}) hit_some = true end - mcl_mobs.effect_functions["withering"](objs[n], 0.5, 10) + mcl_potions.give_effect("withering", objs[n], 2, 10) end if hit_some then mcl_mobs.effect(pos, 32, "mcl_particles_soul_fire_flame.png", 5, 10, self.reach, 1, 0) @@ -469,7 +469,7 @@ mcl_mobs.register_arrow("mobs_mc:wither_skull", { -- direct hit hit_player = function(self, player) local pos = vector.new(self.object:get_pos()) - mcl_mobs.effect_functions["withering"](player, 0.5, 10) + mcl_potions.give_effect("withering", player, 2, 10) player:punch(self.object, 1.0, { full_punch_interval = 0.5, damage_groups = {fleshy = 8}, @@ -484,7 +484,7 @@ mcl_mobs.register_arrow("mobs_mc:wither_skull", { hit_mob = function(self, mob) local pos = vector.new(self.object:get_pos()) - mcl_mobs.effect_functions["withering"](mob, 0.5, 10) + mcl_potions.give_effect("withering", mob, 2, 10) mob:punch(self.object, 1.0, { full_punch_interval = 0.5, damage_groups = {fleshy = 8}, @@ -522,7 +522,7 @@ mcl_mobs.register_arrow("mobs_mc:wither_skull_strong", { -- direct hit hit_player = function(self, player) local pos = vector.new(self.object:get_pos()) - mcl_mobs.effect_functions["withering"](player, 0.5, 10) + mcl_potions.give_effect("withering", player, 2, 10) player:punch(self.object, 1.0, { full_punch_interval = 0.5, damage_groups = {fleshy = 12}, @@ -541,7 +541,7 @@ mcl_mobs.register_arrow("mobs_mc:wither_skull_strong", { hit_mob = function(self, mob) local pos = vector.new(self.object:get_pos()) - mcl_mobs.effect_functions["withering"](mob, 0.5, 10) + mcl_potions.give_effect("withering", mob, 2, 10) mob:punch(self.object, 1.0, { full_punch_interval = 0.5, damage_groups = {fleshy = 12}, diff --git a/mods/ITEMS/mcl_potions/init.lua b/mods/ITEMS/mcl_potions/init.lua index d70e14f36..cdc095203 100644 --- a/mods/ITEMS/mcl_potions/init.lua +++ b/mods/ITEMS/mcl_potions/init.lua @@ -633,19 +633,6 @@ function mcl_potions.get_alchemy(ingr, pot) return false end --- TODO replace all calls to the old API with new API calls in other mods --- mcl_mobs.effect_functions["poison"] = mcl_potions.poison_func --- mcl_mobs.effect_functions["regeneration"] = mcl_potions.regeneration_func --- mcl_mobs.effect_functions["invisibility"] = mcl_potions.invisiblility_func --- mcl_mobs.effect_functions["fire_resistance"] = mcl_potions.fire_resistance_func --- mcl_mobs.effect_functions["night_vision"] = mcl_potions.night_vision_func --- mcl_mobs.effect_functions["water_breathing"] = mcl_potions.water_breathing_func --- mcl_mobs.effect_functions["leaping"] = mcl_potions.leaping_func --- mcl_mobs.effect_functions["swiftness"] = mcl_potions.swiftness_func --- mcl_mobs.effect_functions["heal"] = mcl_potions.healing_func --- mcl_mobs.effect_functions["bad_omen"] = mcl_potions.bad_omen_func --- mcl_mobs.effect_functions["withering"] = mcl_potions.withering_func - -- give withering to players in a wither rose local etime = 0 minetest.register_globalstep(function(dtime)