diff --git a/scripts/enum/element.lua b/scripts/enum/element.lua index 3f168d56c1d..0d69c87ffdb 100644 --- a/scripts/enum/element.lua +++ b/scripts/enum/element.lua @@ -3,13 +3,13 @@ xi = xi or {} ---@enum xi.element xi.element = { - NONE = 0, - FIRE = 1, - ICE = 2, - WIND = 3, - EARTH = 4, - THUNDER = 5, - WATER = 6, - LIGHT = 7, - DARK = 8, + NONE = 0, + FIRE = 1, + ICE = 2, + WIND = 3, + EARTH = 4, + THUNDER = 5, + WATER = 6, + LIGHT = 7, + DARK = 8, } diff --git a/scripts/globals/abyssea.lua b/scripts/globals/abyssea.lua index 50214bfa5f4..8876c453fe8 100644 --- a/scripts/globals/abyssea.lua +++ b/scripts/globals/abyssea.lua @@ -819,17 +819,19 @@ xi.abyssea.getDemiluneAbyssite = function(player) end xi.abyssea.getNewYellowWeakness = function(mob) - local day = VanadielDayOfTheWeek() - local weakness = math.random(day - 1, day + 1) - - if weakness < 0 then - weakness = 7 - elseif weakness > 7 then - weakness = 0 + local currentDay = VanadielDayOfTheWeek() -- Fetch current day. + local chosenDay = math.random(currentDay - 1, currentDay + 1) -- It can be the element of the same day, the day before or the day after. + + -- Acount for day element cycling. + if chosenDay < xi.day.FIRESDAY then + chosenDay = xi.day.DARKSDAY + elseif chosenDay > xi.day.DARKSDAY then + chosenDay = xi.day.FIRESDAY end - local element = xi.magic.dayElement[weakness] - return yellowWeakness[element][math.random(#yellowWeakness[element])] + local element = xi.magic.dayElement[chosenDay] + + return yellowWeakness[element][math.random(1, #yellowWeakness[element])] -- Choose an specific spell the mob is weak to. end xi.abyssea.getNewRedWeakness = function(mob) diff --git a/scripts/mixins/abyssea_weakness.lua b/scripts/mixins/abyssea_weakness.lua index a3abf4874c0..8e380354c63 100644 --- a/scripts/mixins/abyssea_weakness.lua +++ b/scripts/mixins/abyssea_weakness.lua @@ -12,12 +12,15 @@ g_mixins.abyssea_weakness = function(mob) mobArg:setLocalVar('[CanProc]', 1) mobArg:setLocalVar('[RedWeakness]', xi.abyssea.getNewRedWeakness(mobArg)) mobArg:setLocalVar('[AbysseaRedProc]', 0) - mobArg:setLocalVar('[YellowWeakness]', xi.abyssea.getNewYellowWeakness(mobArg)) - mobArg:setLocalVar('[AbysseaYellowProc]', 0) mobArg:setLocalVar('[BlueWeakness]', xi.abyssea.getNewBlueWeakness(mobArg)) mobArg:setLocalVar('[AbysseaBlueProc]', 0) end) + mob:addListener('ENGAGE', 'ABYSSEA_WEAKNESS_ENGAGE', function(mobArg, target) + mobArg:setLocalVar('[YellowWeakness]', xi.abyssea.getNewYellowWeakness(mobArg)) + mobArg:setLocalVar('[AbysseaYellowProc]', 0) + end) + mob:addListener('ATTACKED', 'ATTACKED_ABYSSEA_CHECK_CLAIM', function(mobArg, player, action) local claimed = mobArg:getLocalVar('[ClaimedBy]') if claimed == 0 then