From ce918a1ac621c96f47e65199204751adc458f0b7 Mon Sep 17 00:00:00 2001 From: Skold <113406182+Skold177@users.noreply.github.com> Date: Thu, 30 Apr 2026 23:34:19 -0400 Subject: [PATCH] [lua] [sql] Barrage support to ranged attacks Adds Barrage support to mob ranged attacks --- scripts/actions/mobskills/barrage.lua | 39 +++++++++++++++++++++ scripts/actions/mobskills/ranged_attack.lua | 12 +++++++ scripts/globals/mobskills.lua | 7 +++- sql/mob_skills.sql | 2 +- 4 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 scripts/actions/mobskills/barrage.lua diff --git a/scripts/actions/mobskills/barrage.lua b/scripts/actions/mobskills/barrage.lua new file mode 100644 index 00000000000..fca0ed153d6 --- /dev/null +++ b/scripts/actions/mobskills/barrage.lua @@ -0,0 +1,39 @@ +----------------------------------- +-- Barrage +-- Family : Humanoid Job Ability +-- Description : Allows the next ranged attack to fire multiple shots at once. +-- Number of shots fired is determined by the power of the effect. +-- 4 shots at Lv. 30, 5 shots at Lv. 60, 6 shots at Lv. 75 and 7 shots at Lv. 90. +----------------------------------- +---@type TMobSkill +local mobskillObject = {} + +mobskillObject.onMobSkillCheck = function(target, mob, skill) + return 0 +end + +mobskillObject.onMobWeaponSkill = function(mob, target, skill, action) + action:setCategory(xi.action.category.JOBABILITY_FINISH) + + local level = mob:getMainLvl() + local projectileCount + if level >= 90 then + projectileCount = 7 + elseif level >= 75 then + projectileCount = 6 + elseif level >= 60 then + projectileCount = 5 + elseif level >= 30 then + projectileCount = 4 + else + projectileCount = 3 + end + + mob:addStatusEffect(xi.effect.BARRAGE, { power = projectileCount, duration = 60, origin = mob }) + + skill:setMsg(xi.msg.basic.USES) + + return xi.effect.BARRAGE +end + +return mobskillObject diff --git a/scripts/actions/mobskills/ranged_attack.lua b/scripts/actions/mobskills/ranged_attack.lua index 74246e6cbf5..e4381199345 100644 --- a/scripts/actions/mobskills/ranged_attack.lua +++ b/scripts/actions/mobskills/ranged_attack.lua @@ -32,6 +32,18 @@ mobskillObject.onMobWeaponSkill = function(mob, target, skill, action) -- TODO: Fomor type mobs that should use the player style ranged attacks are currently use this script. -- Their ranged attacks can crit. + -- TODO: When Humanoid style ranged attacks are implemented, this should probably be moved to that script. + if mob:hasStatusEffect(xi.effect.BARRAGE) then + local barrage = mob:getStatusEffect(xi.effect.BARRAGE) + + if barrage then + params.numHits = barrage:getPower() + params.terminateOnMiss = true + end + + mob:delStatusEffect(xi.effect.BARRAGE) + end + local info = xi.mobskills.mobRangedMove(mob, target, skill, action, params) if xi.mobskills.processDamage(mob, target, skill, action, info) then diff --git a/scripts/globals/mobskills.lua b/scripts/globals/mobskills.lua index af33e311bd3..0e2b4bb5a35 100644 --- a/scripts/globals/mobskills.lua +++ b/scripts/globals/mobskills.lua @@ -136,6 +136,7 @@ end --- @field skipParry boolean --- @field skipGuard boolean --- @field skipBlock boolean +--- @field terminateOnMiss boolean --- @field primaryMessage xi.msg.basic --- Table of default skill params shared by physical/ranged mobskills. @@ -171,6 +172,7 @@ local function normalizePhysicalSkillParams(skillParams) skipParry = false, skipGuard = false, skipBlock = false, + terminateOnMiss = false, primaryMessage = xi.msg.basic.DAMAGE, } @@ -640,6 +642,7 @@ xi.mobskills.mobRangedMove = function(mob, target, skill, action, skillParams) local hitAbsorbed = false local attackAnticipated = false local attackYaegasumi = false + local attackMissed = false ---------------------------------- -- Handle Utsusemi and Blink @@ -691,6 +694,7 @@ xi.mobskills.mobRangedMove = function(mob, target, skill, action, skillParams) else hitInfo = defaultHitInfo(hitNumber) hitInfo.missType = 'Evaded / Missed' + attackMissed = true end end @@ -707,7 +711,8 @@ xi.mobskills.mobRangedMove = function(mob, target, skill, action, skillParams) if hitAbsorbed or attackAnticipated or - attackYaegasumi + attackYaegasumi or + (params.terminateOnMiss and attackMissed) then break end diff --git a/sql/mob_skills.sql b/sql/mob_skills.sql index 9a2487a0c74..332730aa60c 100644 --- a/sql/mob_skills.sql +++ b/sql/mob_skills.sql @@ -1462,7 +1462,7 @@ INSERT INTO `mob_skills` VALUES (1427,1054,'marionette_dice_14',0,0.0,15.0,2000, INSERT INTO `mob_skills` VALUES (1431,803,'shield_bash',0,0.0,7.0,2000,1500,4,4,0,0,0,0,0); -- INSERT INTO `mob_skills` VALUES (1432,1176,'weapon_bash',0,0.0,7.0,2000,1500,4,0,0,0,0,0,0); -- INSERT INTO `mob_skills` VALUES (1433,1177,'sic',0,0.0,7.0,2000,1500,4,0,0,0,0,0,0); --- INSERT INTO `mob_skills` VALUES (1434,1178,'barrage',0,0.0,7.0,2000,1500,4,0,0,0,0,0,0); +INSERT INTO `mob_skills` VALUES (1434,23,'barrage',0,0.0,7.0,2000,0,1,0,0,0,0,0,0); -- INSERT INTO `mob_skills` VALUES (1435,1179,'.',0,0.0,7.0,2000,1500,4,0,0,0,0,0,0); -- INSERT INTO `mob_skills` VALUES (1436,1180,'meditate',0,0.0,7.0,2000,1500,4,0,0,0,0,0,0); -- INSERT INTO `mob_skills` VALUES (1437,1181,'jump',0,0.0,7.0,2000,1500,4,0,0,0,0,0,0);