Skip to content

Commit

Permalink
Update composure.lua accuracy bonus, including onEffectTick check
Browse files Browse the repository at this point in the history
  • Loading branch information
lefneer311 authored Oct 7, 2024
1 parent 0b1ad5a commit 5db5d08
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions scripts/effects/composure.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,34 @@
local effectObject = {}

effectObject.onEffectGain = function(target, effect)
local jpValue = target:getJobPointLevel(xi.jp.COMPOSURE_EFFECT)
local cLevel = target:getMainLevel()
local accPower = math.floor(((24 * cLevel) + 74) / 49)
local player = target:getMaster() or target
local mLevel = player:getMainLvl()
local jpValue = player:getJobPointLevel(xi.jp.COMPOSURE_EFFECT)
local accPower = math.floor(((24 * mLevel) + 74) / 49)
effect:setPower(accPower + jpValue)

target:addMod(xi.mod.ACC, accPower + jpValue)
player:addMod(xi.mod.ACC, effect:getPower())
end

effectObject.onEffectTick = function(target, effect)
-- Recalculate accuracy every tick in case of level change
local player = target:getMaster() or target
local mLevel = player:getMainLvl()
local jpValue = player:getJobPointLevel(xi.jp.COMPOSURE_EFFECT)
local newAccPower = math.floor(((24 * mLevel) + 74) / 49)
local newPower = newAccPower + jpValue

if newPower ~= effect:getPower() then
player:delMod(xi.mod.ACC, effect:getPower()) -- Remove old bonus
effect:setPower(newPower) -- Update stored power
player:addMod(xi.mod.ACC, newPower) -- Apply new bonus
end
end

effectObject.onEffectLose = function(target, effect)
local jpValue = target:getJobPointLevel(xi.jp.COMPOSURE_EFFECT)
local cLevel = target:getMainLevel()
local accPower = math.floor(((24 * cLevel) + 74) / 49)
local player = target:getMaster() or target

target:delMod(xi.mod.ACC, accPower + jpValue)
player:delMod(xi.mod.ACC, effect:getPower())
end

return effectObject

0 comments on commit 5db5d08

Please sign in to comment.