From d493983159bfdadd86cc8a8754990b9ecc9b6364 Mon Sep 17 00:00:00 2001 From: WinterSolstice8 <60417494+wintersolstice8@users.noreply.github.com> Date: Mon, 4 May 2026 12:43:24 -0600 Subject: [PATCH 1/2] [sql] Add BARRAGE_COUNT item mods where applicable --- sql/item_mods.sql | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sql/item_mods.sql b/sql/item_mods.sql index 802d38819e7..bc9a0af17c3 100644 --- a/sql/item_mods.sql +++ b/sql/item_mods.sql @@ -24516,6 +24516,7 @@ INSERT INTO `item_mods` VALUES (14900,2,10); -- HP: 10 INSERT INTO `item_mods` VALUES (14900,9,6); -- DEX: 6 INSERT INTO `item_mods` VALUES (14900,11,6); -- AGI: 6 INSERT INTO `item_mods` VALUES (14900,425,10); -- SHADOW_BIND_EXT: 10 +INSERT INTO `item_mods` VALUES (14900,138,1); -- BARRAGE_COUNT: 1 -- Myochin Kote +1 INSERT INTO `item_mods` VALUES (14901,1,21); -- DEF: 21 @@ -34108,6 +34109,7 @@ INSERT INTO `item_mods` VALUES (17272,24,7); -- RATT: 7 -- Phineus Gun INSERT INTO `item_mods` VALUES (17273,11,5); -- AGI: 5 INSERT INTO `item_mods` VALUES (17273,359,1); -- RAPID_SHOT: 1 +INSERT INTO `item_mods` VALUES (17273,138,1); -- BARRAGE_COUNT: 1 -- Coffinmaker INSERT INTO `item_mods` VALUES (17275,26,9); -- RACC: 9 @@ -44338,6 +44340,7 @@ INSERT INTO `item_mods` VALUES (21311,24,30); -- RATT: 30 INSERT INTO `item_mods` VALUES (21311,26,30); -- RACC: 30 INSERT INTO `item_mods` VALUES (21311,28,30); -- MATT: 30 INSERT INTO `item_mods` VALUES (21311,30,20); -- MACC: 20 +INSERT INTO `item_mods` VALUES (21311,138,1); -- BARRAGE_COUNT: 1 -- Abrasion Bolt INSERT INTO `item_mods` VALUES (21314,278,5); -- ITEM_ADDEFFECT_LVADJUST: 5 @@ -50088,6 +50091,8 @@ INSERT INTO `item_mods` VALUES (23184,68,34); -- EVA: 34 INSERT INTO `item_mods` VALUES (23184,384,500); -- HASTE_GEAR: 500 INSERT INTO `item_mods` VALUES (23184,420,22); -- BARRAGE_ACC: 22 INSERT INTO `item_mods` VALUES (23184,425,14); -- SHADOW_BIND_EXT: 14 +INSERT INTO `item_mods` VALUES (23184,138,2); -- BARRAGE_COUNT: 2 + -- Wakido Kote +2 INSERT INTO `item_mods` VALUES (23185,1,113); -- DEF: 113 @@ -55245,6 +55250,8 @@ INSERT INTO `item_mods` VALUES (23519,68,44); -- EVA: 44 INSERT INTO `item_mods` VALUES (23519,384,500); -- HASTE_GEAR: 500 INSERT INTO `item_mods` VALUES (23519,420,32); -- BARRAGE_ACC: 32 INSERT INTO `item_mods` VALUES (23519,425,16); -- SHADOW_BIND_EXT: 16 +INSERT INTO `item_mods` VALUES (23519,138,2); -- BARRAGE_COUNT: 2 + -- Wakido Kote +3 INSERT INTO `item_mods` VALUES (23520,1,123); -- DEF: 123 @@ -77801,6 +77808,7 @@ INSERT INTO `item_mods` VALUES (27953,31,25); -- MEVA: 25 INSERT INTO `item_mods` VALUES (27953,68,11); -- EVA: 11 INSERT INTO `item_mods` VALUES (27953,384,400); -- HASTE_GEAR: 400 INSERT INTO `item_mods` VALUES (27953,425,6); -- SHADOW_BIND_EXT: 6 +INSERT INTO `item_mods` VALUES (27953,138,2); -- BARRAGE_COUNT: 2 -- Wakido Kote INSERT INTO `item_mods` VALUES (27954,1,74); -- DEF: 74 @@ -78172,6 +78180,7 @@ INSERT INTO `item_mods` VALUES (27974,31,37); -- MEVA: 37 INSERT INTO `item_mods` VALUES (27974,68,24); -- EVA: 24 INSERT INTO `item_mods` VALUES (27974,384,500); -- HASTE_GEAR: 500 INSERT INTO `item_mods` VALUES (27974,425,12); -- SHADOW_BIND_EXT: 12 +INSERT INTO `item_mods` VALUES (27974,138,2); -- BARRAGE_COUNT: 2 -- Wakido Kote +1 INSERT INTO `item_mods` VALUES (27975,1,103); -- DEF: 103 From 4a0bcae26f6fcf0ca869497bdd8654665a215860 Mon Sep 17 00:00:00 2001 From: WinterSolstice8 <60417494+wintersolstice8@users.noreply.github.com> Date: Mon, 4 May 2026 12:59:15 -0600 Subject: [PATCH 2/2] [core] Refactor getBarrageShotCount to allow trusts to use it --- sql/item_mods.sql | 2 - src/map/utils/battleutils.cpp | 71 +++++++++++++++-------------------- src/map/utils/battleutils.h | 2 +- 3 files changed, 31 insertions(+), 44 deletions(-) diff --git a/sql/item_mods.sql b/sql/item_mods.sql index bc9a0af17c3..52c3607c530 100644 --- a/sql/item_mods.sql +++ b/sql/item_mods.sql @@ -50093,7 +50093,6 @@ INSERT INTO `item_mods` VALUES (23184,420,22); -- BARRAGE_ACC: 22 INSERT INTO `item_mods` VALUES (23184,425,14); -- SHADOW_BIND_EXT: 14 INSERT INTO `item_mods` VALUES (23184,138,2); -- BARRAGE_COUNT: 2 - -- Wakido Kote +2 INSERT INTO `item_mods` VALUES (23185,1,113); -- DEF: 113 INSERT INTO `item_mods` VALUES (23185,2,40); -- HP: 40 @@ -55252,7 +55251,6 @@ INSERT INTO `item_mods` VALUES (23519,420,32); -- BARRAGE_ACC: 32 INSERT INTO `item_mods` VALUES (23519,425,16); -- SHADOW_BIND_EXT: 16 INSERT INTO `item_mods` VALUES (23519,138,2); -- BARRAGE_COUNT: 2 - -- Wakido Kote +3 INSERT INTO `item_mods` VALUES (23520,1,123); -- DEF: 123 INSERT INTO `item_mods` VALUES (23520,2,50); -- HP: 50 diff --git a/src/map/utils/battleutils.cpp b/src/map/utils/battleutils.cpp index f6dcf7d8cd7..d5a63111823 100644 --- a/src/map/utils/battleutils.cpp +++ b/src/map/utils/battleutils.cpp @@ -4296,13 +4296,7 @@ int32 getOverWhelmDamageBonus(CBattleEntity* PAttacker, CBattleEntity* PDefender return damage; } -/************************************************************************ - * * - * Calculate/Handle Barrage shot count * - * * - ************************************************************************/ - -uint8 getBarrageShotCount(CCharEntity* PChar) +uint8 getBarrageShotCount(CBattleEntity* PBattleEntity) { /* Ranger level 30, four shots. @@ -4312,29 +4306,9 @@ uint8 getBarrageShotCount(CCharEntity* PChar) Ranger level 99, eight shots. */ - // only archery + marksmanship can use barrage - CItemWeapon* PItem = (CItemWeapon*)PChar->getEquip(SLOT_RANGED); - - if (PItem && PItem->getSkillType() != 25 && PItem->getSkillType() != 26) - { - return 0; - } - - uint8 lvl = PChar->jobs.job[JOB_RNG]; // Get Ranger level of char - uint8 shotCount = 0; // the total number of extra hits - - if (PChar->GetSJob() == JOB_RNG) - { // if rng is sub then use the sub level - lvl = PChar->GetSLevel(); - } - - // Hunters bracers+1 will add an extra shot - CItemEquipment* PItemHands = PChar->getEquip(SLOT_HANDS); - - if (PItemHands && PItemHands->getID() == 14900) - { - shotCount++; - } + // TODO: verify all RNG trusts that use Barrage have RNG main job + uint16 lvl = PBattleEntity->GetMJob() == JOB_RNG ? PBattleEntity->GetMLevel() : PBattleEntity->GetSLevel(); + uint8 shotCount = 0; if (lvl < 30) { @@ -4342,33 +4316,48 @@ uint8 getBarrageShotCount(CCharEntity* PChar) } else if (lvl < 50) { - shotCount += 3; + shotCount = 3; } else if (lvl < 75) { - shotCount += 4; + shotCount = 4; } else if (lvl < 90) { - shotCount += 5; + shotCount = 5; } else if (lvl < 99) { - shotCount += 6; + shotCount = 6; } else { - shotCount += 7; + shotCount = 7; } - shotCount += PChar->getMod(Mod::BARRAGE_COUNT); - - // make sure we have enough ammo for all these shots - CItemWeapon* PAmmo = (CItemWeapon*)PChar->getEquip(SLOT_AMMO); + shotCount += PBattleEntity->getMod(Mod::BARRAGE_COUNT); - if (PAmmo && PAmmo->getQuantity() < shotCount) + // only archery + marksmanship can use barrage + if (PBattleEntity->objtype == TYPE_PC) { - shotCount = PAmmo->getQuantity() - 1; + if (auto* PChar = dynamic_cast(PBattleEntity); PChar) + { + CItemWeapon* PItem = dynamic_cast(PChar->getEquip(SLOT_RANGED)); + + if (PItem && PItem->getSkillType() != SKILL_ARCHERY && PItem->getSkillType() != SKILL_MARKSMANSHIP) + { + return 0; + } + + // make sure we have enough ammo for all these shots + CItemWeapon* PAmmo = dynamic_cast(PChar->getEquip(SLOT_AMMO)); + + // TODO: Check if this should be here. Recycle can proc and potentially allow more shots to land + if (PAmmo && PAmmo->getQuantity() < shotCount + 1u) // This function is additive to the first shot. So one ammo is already consumed before we get here + { + shotCount = PAmmo->getQuantity() - 1; + } + } } return shotCount; diff --git a/src/map/utils/battleutils.h b/src/map/utils/battleutils.h index c330cf1be0d..a8fd0d819d4 100644 --- a/src/map/utils/battleutils.h +++ b/src/map/utils/battleutils.h @@ -204,7 +204,7 @@ uint16 doConsumeManaEffect(CCharEntity* m_PChar); int32 getOverWhelmDamageBonus(CBattleEntity* PAttacker, CBattleEntity* PDefender, int32 damage); void TransferEnmity(CBattleEntity* PHateReceiver, CBattleEntity* PHateGiver, CMobEntity* PMob, uint8 percentToTransfer); -uint8 getBarrageShotCount(CCharEntity* PChar); +uint8 getBarrageShotCount(CBattleEntity* PBattleEntity); uint8 getStoreTPbonusFromMerit(CBattleEntity* PEntity); void ClaimMob(CBattleEntity* PDefender, CBattleEntity* PAttacker, bool passing = false);