Fix crashes with raids and bad omen effect (#4326)

Reviewed-on: https://git.minetest.land/VoxeLibre/VoxeLibre/pulls/4326
Reviewed-by: the-real-herowl <the-real-herowl@noreply.git.minetest.land>
Co-authored-by: teknomunk <teknomunk@protonmail.com>
Co-committed-by: teknomunk <teknomunk@protonmail.com>
This commit is contained in:
teknomunk 2024-05-26 15:21:43 +00:00 committed by the-real-herowl
parent 68e5c19df4
commit 8feecf2492

View File

@ -105,8 +105,6 @@ function mcl_raids.promote_to_raidcaptain(c) -- object
if cmi_cause and cmi_cause.type == "punch" and cmi_cause.puncher:is_player() then if cmi_cause and cmi_cause.type == "punch" and cmi_cause.puncher:is_player() then
awards.unlock(cmi_cause.puncher:get_player_name(), "mcl:voluntary_exile") awards.unlock(cmi_cause.puncher:get_player_name(), "mcl:voluntary_exile")
local lv = mcl_potions.get_effect_level(cmi_cause.puncher, "bad_omen") local lv = mcl_potions.get_effect_level(cmi_cause.puncher, "bad_omen")
if not lv then lv = 0
else lv = lv.factor end
lv = math.max(5,lv + 1) lv = math.max(5,lv + 1)
mcl_potions.give_effect_by_level("bad_omen", cmi_cause.puncher, lv, 6000) mcl_potions.give_effect_by_level("bad_omen", cmi_cause.puncher, lv, 6000)
end end
@ -311,7 +309,7 @@ mcl_events.register_event("raid",{
self.health_max = 1 self.health_max = 1
self.health = 0 self.health = 0
local lv = mcl_potions.get_effect_level(minetest.get_player_by_name(self.player), "bad_omen") local lv = mcl_potions.get_effect_level(minetest.get_player_by_name(self.player), "bad_omen")
if lv and lv.factor and lv.factor > 1 then self.max_stage = 6 end if lv > 1 then self.max_stage = 6 end
end, end,
cond_progress = function(self) cond_progress = function(self)
if not is_player_near(self) then return false end if not is_player_near(self) then return false end