Migrated mobs to the new effects API

This commit is contained in:
the-real-herowl 2024-04-27 05:12:42 +02:00
parent 55ce6f0f4b
commit 747bf16a94
5 changed files with 9 additions and 25 deletions

View File

@ -21,8 +21,6 @@ local function atan(x)
end end
end end
mcl_mobs.effect_functions = {}
-- check if daytime and also if mob is docile during daylight hours -- check if daytime and also if mob is docile during daylight hours
function mob_class:day_docile() function mob_class:day_docile()
@ -1153,9 +1151,8 @@ function mob_class:do_states_attack (dtime)
damage_groups = {fleshy = self.damage} damage_groups = {fleshy = self.damage}
}, nil) }, nil)
if self.dealt_effect then if self.dealt_effect then
mcl_mobs.effect_functions[self.dealt_effect.name]( mcl_potions.give_effect_by_level(self.dealt_effect.name, self.attack,
self.attack, self.dealt_effect.factor, self.dealt_effect.dur self.dealt_effect.level, self.dealt_effect.dur)
)
end end
end end
else else

View File

@ -98,7 +98,7 @@ mcl_mobs.register_mob("mobs_mc:witherskeleton", {
fire_resistant = true, fire_resistant = true,
dealt_effect = { dealt_effect = {
name = "withering", name = "withering",
factor = 1, level = 1,
dur = 10, dur = 10,
}, },
}) })

View File

@ -138,7 +138,7 @@ cave_spider.sounds = table.copy(spider.sounds)
cave_spider.sounds.base_pitch = 1.25 cave_spider.sounds.base_pitch = 1.25
cave_spider.dealt_effect = { cave_spider.dealt_effect = {
name = "poison", name = "poison",
factor = 2.5, level = 2,
dur = 7, dur = 7,
} }
mcl_mobs.register_mob("mobs_mc:cave_spider", cave_spider) mcl_mobs.register_mob("mobs_mc:cave_spider", cave_spider)

View File

@ -349,7 +349,7 @@ mcl_mobs.register_mob("mobs_mc:wither", {
mcl_util.deal_damage(objs[n], 8, {type = "magic"}) mcl_util.deal_damage(objs[n], 8, {type = "magic"})
hit_some = true hit_some = true
end end
mcl_mobs.effect_functions["withering"](objs[n], 0.5, 10) mcl_potions.give_effect("withering", objs[n], 2, 10)
end end
if hit_some then if hit_some then
mcl_mobs.effect(pos, 32, "mcl_particles_soul_fire_flame.png", 5, 10, self.reach, 1, 0) 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 -- direct hit
hit_player = function(self, player) hit_player = function(self, player)
local pos = vector.new(self.object:get_pos()) 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, { player:punch(self.object, 1.0, {
full_punch_interval = 0.5, full_punch_interval = 0.5,
damage_groups = {fleshy = 8}, damage_groups = {fleshy = 8},
@ -484,7 +484,7 @@ mcl_mobs.register_arrow("mobs_mc:wither_skull", {
hit_mob = function(self, mob) hit_mob = function(self, mob)
local pos = vector.new(self.object:get_pos()) 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, { mob:punch(self.object, 1.0, {
full_punch_interval = 0.5, full_punch_interval = 0.5,
damage_groups = {fleshy = 8}, damage_groups = {fleshy = 8},
@ -522,7 +522,7 @@ mcl_mobs.register_arrow("mobs_mc:wither_skull_strong", {
-- direct hit -- direct hit
hit_player = function(self, player) hit_player = function(self, player)
local pos = vector.new(self.object:get_pos()) 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, { player:punch(self.object, 1.0, {
full_punch_interval = 0.5, full_punch_interval = 0.5,
damage_groups = {fleshy = 12}, damage_groups = {fleshy = 12},
@ -541,7 +541,7 @@ mcl_mobs.register_arrow("mobs_mc:wither_skull_strong", {
hit_mob = function(self, mob) hit_mob = function(self, mob)
local pos = vector.new(self.object:get_pos()) 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, { mob:punch(self.object, 1.0, {
full_punch_interval = 0.5, full_punch_interval = 0.5,
damage_groups = {fleshy = 12}, damage_groups = {fleshy = 12},

View File

@ -633,19 +633,6 @@ function mcl_potions.get_alchemy(ingr, pot)
return false return false
end 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 -- give withering to players in a wither rose
local etime = 0 local etime = 0
minetest.register_globalstep(function(dtime) minetest.register_globalstep(function(dtime)