Skip to content

Commit

Permalink
Merge pull request #6181 from Xaver-DaRed/abyssea
Browse files Browse the repository at this point in the history
[Abyssea] Fix when Yellow weakness is chosen
  • Loading branch information
claywar authored Sep 1, 2024
2 parents 4fd5c52 + 367db07 commit 27dddda
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 20 deletions.
18 changes: 9 additions & 9 deletions scripts/enum/element.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
20 changes: 11 additions & 9 deletions scripts/globals/abyssea.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 5 additions & 2 deletions scripts/mixins/abyssea_weakness.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 27dddda

Please sign in to comment.