Skip to content

Commit

Permalink
Merge pull request #1759 from WinterSolstice8/foil
Browse files Browse the repository at this point in the history
[RUN] Implement Foil; [lua] fix accuracy calculation for mob TP moves
  • Loading branch information
zach2good authored May 20, 2022
2 parents c5bf3e0 + 89e95cb commit bb569bc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
18 changes: 15 additions & 3 deletions scripts/globals/effects/foil.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,26 @@ require("scripts/globals/status")
local effect_object = {}

effect_object.onEffectGain = function(target, effect)
effect:addMod(xi.mod.SPECIAL_ATTACK_EVASION, effect:getPower())
target:addMod(xi.mod.SPECIAL_ATTACK_EVASION, effect:getPower())
end

effect_object.onEffectTick = function(target, effect) -- TODO: Determine how Foil ticks down? It's description indicates this.
-- https://www.ffxiah.com/forum/topic/56696/foil-potency-and-decay-testing/#3625559
effect_object.onEffectTick = function(target, effect)

local power = effect:getPower()

-- TODO: Verify Foil evasion floor when more enhancing magic duration+ gear is available or RDM can cast foil from Master Levels.
if power > 0 then -- don't go negative. but we don't know what the floor of Foil is currently.

local powerDecay = 3

effect:setPower(power-powerDecay)
target:delMod(xi.mod.SPECIAL_ATTACK_EVASION, powerDecay)
end
end

effect_object.onEffectLose = function(target, effect)
-- intentionally blank. mod removes itself in C++ due to being added to the effect.
target:delMod(xi.mod.SPECIAL_ATTACK_EVASION, effect:getPower())
end

return effect_object
6 changes: 3 additions & 3 deletions scripts/globals/mobskills.lua
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ xi.mobskills.mobPhysicalMove = function(mob, target, skill, numberofhits, accmod
local lvluser = mob:getMainLvl()
local lvltarget = target:getMainLvl()
local acc = mob:getACC()
local eva = target:getEVA()
local eva = target:getEVA() + target:getMod(xi.mod.SPECIAL_ATTACK_EVASION)

if target:hasStatusEffect(xi.effect.YONIN) and mob:isFacing(target, 23) then -- Yonin evasion boost if mob is facing target
eva = eva + target:getStatusEffect(xi.effect.YONIN):getPower()
Expand All @@ -184,8 +184,8 @@ xi.mobskills.mobPhysicalMove = function(mob, target, skill, numberofhits, accmod
ratio = ratio + lvldiff * 0.05
ratio = utils.clamp(ratio, 0, 4)

--work out hit rate for mobs (bias towards them)
local hitrate = (acc * accmod) - eva + (lvldiff * 2) + 75
--work out hit rate for mobs
local hitrate = ( (acc * accmod) - eva) / 2 + (lvldiff * 2) + 75

hitrate = utils.clamp(hitrate, 20, 95)

Expand Down
6 changes: 2 additions & 4 deletions scripts/globals/spells/white/foil.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ spell_object.onMagicCastingCheck = function(caster, target, spell)
return 0
end

-- TODO: determine mechanics of how Foil's "Special Attack" evasion works.
-- Martel has a post about it here: https://www.bluegartr.com/threads/115399-Rune-Fencer-Findings?p=5665305&viewfull=1#post5665305
-- More testing is required (such as determining accuracy of the target used for testing)
-- https://www.ffxiah.com/forum/topic/56696/foil-potency-and-decay-testing/#3625542
spell_object.onSpellCast = function(caster, target, spell)

if target:addStatusEffect(xi.effect.FOIL, 0, 0, 30) then -- power set to 0 because true mechanics are unknown as of now. The primary use of Foil is for enmity anyway.
if target:addStatusEffect(xi.effect.FOIL, 150, 3, 30) then
spell:setMsg(xi.msg.basic.MAGIC_GAIN_EFFECT)
else
spell:setMsg(xi.msg.basic.MAGIC_NO_EFFECT)
Expand Down

0 comments on commit bb569bc

Please sign in to comment.