From 59a0b69ea292c5b497cba280b4d8d154679e6880 Mon Sep 17 00:00:00 2001 From: MowFord <131182600+MowFord@users.noreply.github.com> Date: Mon, 6 May 2024 18:57:00 -0500 Subject: [PATCH] Adjust accVaries to reduce accuracy not hitrate --- scripts/globals/job_utils/dancer.lua | 6 ++-- scripts/globals/weaponskills.lua | 42 +++++++++++++--------------- 2 files changed, 22 insertions(+), 26 deletions(-) diff --git a/scripts/globals/job_utils/dancer.lua b/scripts/globals/job_utils/dancer.lua index 4328477281c..050f2f10f05 100644 --- a/scripts/globals/job_utils/dancer.lua +++ b/scripts/globals/job_utils/dancer.lua @@ -246,7 +246,7 @@ xi.job_utils.dancer.useStepAbility = function(player, target, ability, action, s player:delTP(100 + player:getMod(xi.mod.STEP_TP_CONSUMED)) end - if math.random() <= xi.weaponskills.getHitRate(player, target, true, 10 + player:getMod(xi.mod.STEP_ACCURACY)) then + if math.random() <= xi.weaponskills.getHitRate(player, target, 10 + player:getMod(xi.mod.STEP_ACCURACY)) then local maxSteps = player:getMainJob() == xi.job.DNC and 10 or 5 local debuffEffect = target:getStatusEffect(stepEffect) local origDebuffStacks = 0 @@ -360,7 +360,7 @@ xi.job_utils.dancer.useDesperateFlourishAbility = function(player, target, abili setFinishingMoves(player, numMoves - 1) if - math.random() <= xi.weaponskills.getHitRate(player, target, true, player:getJobPointLevel(xi.jp.FLOURISH_I_EFFECT)) or + math.random() <= xi.weaponskills.getHitRate(player, target, player:getJobPointLevel(xi.jp.FLOURISH_I_EFFECT)) or (player:hasStatusEffect(xi.effect.SNEAK_ATTACK) and player:isBehind(target)) then local spell = GetSpell(xi.magic.spell.GRAVITY) @@ -397,7 +397,7 @@ xi.job_utils.dancer.useViolentFlourishAbility = function(player, target, ability setFinishingMoves(player, numMoves - 1) if - math.random() <= xi.weaponskills.getHitRate(player, target, true, 100) or + math.random() <= xi.weaponskills.getHitRate(player, target, 100) or (player:hasStatusEffect(xi.effect.SNEAK_ATTACK) and player:isBehind(target)) then local hitType = 3 diff --git a/scripts/globals/weaponskills.lua b/scripts/globals/weaponskills.lua index edd14c02181..5afdda70064 100644 --- a/scripts/globals/weaponskills.lua +++ b/scripts/globals/weaponskills.lua @@ -268,7 +268,7 @@ local function cRangedRatio(attacker, defender, params, ignoredDef, tp) return pdif, pdifcrit end -local function getRangedHitRate(attacker, target, capHitRate, bonus) +local function getRangedHitRate(attacker, target, bonus) local acc = attacker:getRACC() local eva = target:getEVA() @@ -300,11 +300,7 @@ local function getRangedHitRate(attacker, target, capHitRate, bonus) local hitrate = (75 + hitdiff) / 100 -- Applying hitrate caps - if capHitRate then -- this isn't capped for when acc varies with tp, as more penalties are due - hitrate = math.min(capHitRate, 0.95) - end - - hitrate = math.max(hitrate, 0.2) + hitrate = utils.clamp(hitrate, 0.2, 0.95) return hitrate end @@ -446,14 +442,6 @@ xi.weaponskills.calculateRawWSDmg = function(attacker, target, wsID, tp, action, local targetLvl = target:getMainLvl() local targetHp = target:getHP() + target:getMod(xi.mod.STONESKIN) - -- Recalculate accuracy if it varies with TP, applied to all hits (This is a penalty!) - if wsParams.accVaries then - local accLost = calcParams.accStat - calcParams.accStat * xi.weaponskills.fTP(tp, wsParams.accVaries) - calcParams.hitRate = calcParams.hitRate - accLost / 200 - end - - calcParams.hitRate = utils.clamp(calcParams.hitRate, 0.2, 0.95) - -- Calculate alpha, WSC, and our modifiers for our base per-hit damage calcParams.alpha = getAlpha(attacker:getMainLvl()) @@ -764,8 +752,14 @@ xi.weaponskills.doPhysicalWeaponskill = function(attacker, target, wsID, wsParam calcParams.bonusWSmods = wsParams.bonusWSmods or 0 end - calcParams.firstHitRate = xi.weaponskills.getHitRate(attacker, target, true, calcParams.bonusAcc + 100) - calcParams.hitRate = xi.weaponskills.getHitRate(attacker, target, false, calcParams.bonusAcc) + if wsParams.accVaries then + -- applied to all hits (This is a penalty!) + local accLost = calcParams.accStat * (1 - xi.weaponskills.fTP(tp, wsParams.accVaries)) + calcParams.bonusAcc = calcParams.bonusAcc - accLost + end + + calcParams.firstHitRate = xi.weaponskills.getHitRate(attacker, target, calcParams.bonusAcc + 100) + calcParams.hitRate = xi.weaponskills.getHitRate(attacker, target, calcParams.bonusAcc) calcParams.skillType = attack.weaponType -- Send our wsParams off to calculate our raw WS damage, hits landed, and shadows absorbed @@ -824,7 +818,13 @@ xi.weaponskills.doRangedWeaponskill = function(attacker, target, wsID, wsParams, bonusAcc = (gorgetBeltAcc or 0) + attacker:getMod(xi.mod.WSACC), bonusWSmods = wsParams.bonusWSmods or 0 } - calcParams.hitRate = getRangedHitRate(attacker, target, false, calcParams.bonusAcc) + if wsParams.accVaries then + -- applied to all hits (This is a penalty!) + local accLost = calcParams.accStat * (1 - xi.weaponskills.fTP(tp, wsParams.accVaries)) + calcParams.bonusAcc = calcParams.bonusAcc - accLost + end + + calcParams.hitRate = getRangedHitRate(attacker, target, calcParams.bonusAcc) -- Send our params off to calculate our raw WS damage, hits landed, and shadows absorbed calcParams = xi.weaponskills.calculateRawWSDmg(attacker, target, wsID, tp, action, wsParams, calcParams) @@ -1050,7 +1050,7 @@ xi.weaponskills.getMeleeDmg = function(attacker, weaponType, kick) return { mainhandDamage, offhandDamage } end -xi.weaponskills.getHitRate = function(attacker, target, capHitRate, bonus) +xi.weaponskills.getHitRate = function(attacker, target, bonus) local flourishEffect = attacker:getStatusEffect(xi.effect.BUILDING_FLOURISH) if flourishEffect ~= nil and flourishEffect:getPower() >= 1 then -- 1 or more Finishing moves used. @@ -1103,11 +1103,7 @@ xi.weaponskills.getHitRate = function(attacker, target, capHitRate, bonus) local hitrate = (75 + hitdiff) / 100 -- Applying hitrate caps - if capHitRate then -- this isn't capped for when acc varies with tp, as more penalties are due - hitrate = math.min(hitrate, 0.95) - end - - hitrate = math.max(hitrate, 0.2) + hitrate = utils.clamp(hitrate, 0.2, 0.95) return hitrate end