Skip to content

Commit

Permalink
[lua] add utils.GetCurrentJobLevel, use for Monk abilities
Browse files Browse the repository at this point in the history
Co-authored-by: Xaver-DaRed <[email protected]>
  • Loading branch information
WinterSolstice8 and Xaver-DaRed committed Nov 24, 2024
1 parent 52a29ed commit cab541a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 22 deletions.
8 changes: 1 addition & 7 deletions scripts/effects/dodge.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,7 @@ local effectObject = {}
effectObject.onEffectGain = function(target, effect)
local jpLevel = target:getJobPointLevel(xi.jp.DODGE_EFFECT)
local dodgeMod = target:getMod(xi.mod.DODGE_EFFECT)
local monkLevel = 0

if target:getMainJob() == xi.job.MNK then
monkLevel = target:getMainLvl()
else
monkLevel = target:getSubLvl()
end
local monkLevel = utils.getCurrentJobLevel(target, xi.job.MNK)

-- https://www.bg-wiki.com/ffxi/Dodge
effect:addMod(xi.mod.EVA, monkLevel + 1 + dodgeMod + jpLevel)
Expand Down
8 changes: 1 addition & 7 deletions scripts/effects/focus.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,7 @@ local effectObject = {}
effectObject.onEffectGain = function(target, effect)
local jpLevel = target:getJobPointLevel(xi.jp.FOCUS_EFFECT)
local focusMod = target:getMod(xi.mod.FOCUS_EFFECT)
local monkLevel = 0

if target:getMainJob() == xi.job.MNK then
monkLevel = target:getMainLvl()
else
monkLevel = target:getSubLvl()
end
local monkLevel = utils.getCurrentJobLevel(target, xi.job.MNK)

-- https://wiki.ffo.jp/html/2841.html
effect:addMod(xi.mod.ACC, monkLevel + 1 + focusMod + jpLevel)
Expand Down
9 changes: 1 addition & 8 deletions scripts/globals/job_utils/monk.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,8 @@ xi.job_utils.monk.useChakra = function(player, target, ability)
end
end

local monkLevel = 0

if target:getMainJob() == xi.job.MNK then
monkLevel = target:getMainLvl()
else
monkLevel = target:getSubLvl()
end

-- see https://www.bg-wiki.com/ffxi/Chakra
local monkLevel = utils.getCurrentJobLevel(target, xi.job.MNK)
local jpModifier = target:getJobPointLevel(xi.jp.CHAKRA_EFFECT) -- NOTE: Level is the modified value, so 10 per point spent
local hpModifier = ((monkLevel + 1) * 0.2 / 100) * player:getMaxHP()
local chakraMultiplier = 1 + player:getMod(xi.mod.CHAKRA_MULT) / 100
Expand Down
15 changes: 15 additions & 0 deletions scripts/globals/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,21 @@ function utils.getActiveJobLevel(actor, job)
return jobLevel
end

---@nodiscard
---@param actor CBaseEntity
---@param job xi.job
function utils.getCurrentJobLevel(actor, job)
local level = 0

if actor:getMainJob() == job then
level = actor:getMainLvl()
elseif actor:getSubJob() == job then
level = actor:getSubLvl()
end

return level
end

-----------------------------------
-- SKILL LEVEL CALCULATOR
-- Returns a skill level based on level and rating.
Expand Down

0 comments on commit cab541a

Please sign in to comment.