From 5c7bee3c1feed3306edb6c60f8d472740bb4669c Mon Sep 17 00:00:00 2001 From: MowFord <131182600+MowFord@users.noreply.github.com> Date: Sun, 14 Apr 2024 14:06:27 -0500 Subject: [PATCH] Update rand deal bonus to unused modifier ID --- scripts/enum/mod.lua | 2 +- sql/item_mods.sql | 12 ++++++------ src/map/lua/lua_baseentity.cpp | 6 ++++++ src/map/modifier.h | 4 ++-- src/map/utils/battleutils.cpp | 30 +++++++++++++++--------------- 5 files changed, 30 insertions(+), 24 deletions(-) diff --git a/scripts/enum/mod.lua b/scripts/enum/mod.lua index 61eb659b0d1..6bd72fd7ae4 100644 --- a/scripts/enum/mod.lua +++ b/scripts/enum/mod.lua @@ -759,7 +759,7 @@ xi.mod = DAY_NUKE_BONUS = 565, -- Bonus damage from "Elemental magic affected by day" (Sorc. Tonban) IRIDESCENCE = 566, -- Iridescence trait (additional weather damage/penalty) BARSPELL_AMOUNT = 567, -- Additional elemental resistance granted by bar- spells - RANDOM_DEAL_BONUS = 573, -- % chance to reset 2 abilities + RANDOM_DEAL_BONUS = 220, -- % chance to reset 2 abilities BARSPELL_MDEF_BONUS = 827, -- Extra magic defense bonus granted to the bar- spell effect RAPTURE_AMOUNT = 568, -- Bonus amount added to Rapture effect EBULLIENCE_AMOUNT = 569, -- Bonus amount added to Ebullience effect diff --git a/sql/item_mods.sql b/sql/item_mods.sql index ffee65f92e5..0a70fc111c6 100644 --- a/sql/item_mods.sql +++ b/sql/item_mods.sql @@ -2625,7 +2625,7 @@ INSERT INTO `item_mods` VALUES (10686,8,5); -- STR: 5 INSERT INTO `item_mods` VALUES (10686,11,5); -- AGI: 5 INSERT INTO `item_mods` VALUES (10686,24,12); -- RATT: 12 INSERT INTO `item_mods` VALUES (10686,25,12); -- ACC: 12 -INSERT INTO `item_mods` VALUES (10686,573,5); -- RANDOM_DEAL_BONUS: 5 +INSERT INTO `item_mods` VALUES (10686,220,5); -- RANDOM_DEAL_BONUS: 5 -- Pantin Tobe +2 INSERT INTO `item_mods` VALUES (10687,1,59); -- DEF: 59 @@ -6158,14 +6158,14 @@ INSERT INTO `item_mods` VALUES (11295,1,45); -- DEF: 45 INSERT INTO `item_mods` VALUES (11295,8,3); -- STR: 3 INSERT INTO `item_mods` VALUES (11295,24,8); -- RATT: 8 INSERT INTO `item_mods` VALUES (11295,25,8); -- ACC: 8 -INSERT INTO `item_mods` VALUES (11295,573,5); -- RANDOM_DEAL_BONUS: 5 +INSERT INTO `item_mods` VALUES (11295,220,5); -- RANDOM_DEAL_BONUS: 5 -- Commodore Frac +1 INSERT INTO `item_mods` VALUES (11296,1,46); -- DEF: 46 INSERT INTO `item_mods` VALUES (11296,8,3); -- STR: 3 INSERT INTO `item_mods` VALUES (11296,24,10); -- RATT: 10 INSERT INTO `item_mods` VALUES (11296,25,10); -- ACC: 10 -INSERT INTO `item_mods` VALUES (11296,573,5); -- RANDOM_DEAL_BONUS: 5 +INSERT INTO `item_mods` VALUES (11296,220,5); -- RANDOM_DEAL_BONUS: 5 -- Puppetry Tobe +1 INSERT INTO `item_mods` VALUES (11297,1,37); -- DEF: 37 @@ -48694,7 +48694,7 @@ INSERT INTO `item_mods` VALUES (23146,31,74); -- MEVA: 74 INSERT INTO `item_mods` VALUES (23146,68,59); -- EVA: 59 INSERT INTO `item_mods` VALUES (23146,161,-500); -- DMGPHYS: -5% INSERT INTO `item_mods` VALUES (23146,384,400); -- HASTE_GEAR: 4% -INSERT INTO `item_mods` VALUES (23146,573,50); -- RANDOM_DEAL_BONUS: 50 +INSERT INTO `item_mods` VALUES (23146,220,50); -- RANDOM_DEAL_BONUS: 50 -- Pitre Tobe +2 INSERT INTO `item_mods` VALUES (23147,1,143); -- DEF: 143 @@ -64325,7 +64325,7 @@ INSERT INTO `item_mods` VALUES (26832,31,43); -- MEVA: 43 INSERT INTO `item_mods` VALUES (26832,68,23); -- EVA: 23 INSERT INTO `item_mods` VALUES (26832,161,-300); -- DMGPHYS: -300 INSERT INTO `item_mods` VALUES (26832,384,400); -- HASTE_GEAR: 400 -INSERT INTO `item_mods` VALUES (26832,573,50); -- RANDOM_DEAL_BONUS: 50 +INSERT INTO `item_mods` VALUES (26832,220,50); -- RANDOM_DEAL_BONUS: 50 -- Lanun Frac +1 INSERT INTO `item_mods` VALUES (26833,1,131); -- DEF: 131 @@ -64346,7 +64346,7 @@ INSERT INTO `item_mods` VALUES (26833,31,64); -- MEVA: 64 INSERT INTO `item_mods` VALUES (26833,68,49); -- EVA: 49 INSERT INTO `item_mods` VALUES (26833,161,-400); -- DMGPHYS: -400 INSERT INTO `item_mods` VALUES (26833,384,400); -- HASTE_GEAR: 400 -INSERT INTO `item_mods` VALUES (26833,573,50); -- RANDOM_DEAL_BONUS: 50 +INSERT INTO `item_mods` VALUES (26833,220,50); -- RANDOM_DEAL_BONUS: 50 -- Pitre Tobe INSERT INTO `item_mods` VALUES (26834,1,94); -- DEF: 94 diff --git a/src/map/lua/lua_baseentity.cpp b/src/map/lua/lua_baseentity.cpp index 3522389d805..f631af59a76 100644 --- a/src/map/lua/lua_baseentity.cpp +++ b/src/map/lua/lua_baseentity.cpp @@ -13077,6 +13077,12 @@ bool CLuaBaseEntity::doRandomDeal(CLuaBaseEntity* PTarget) return false; } + if (!PTarget || !PTarget->m_PBaseEntity) + { + ShowWarning("Invalid entity type passed as target (%s).", m_PBaseEntity->getName()); + return false; + } + return battleutils::DoRandomDealToEntity(static_cast(m_PBaseEntity), static_cast(PTarget->m_PBaseEntity)); } diff --git a/src/map/modifier.h b/src/map/modifier.h index 4929a3d410a..b6dda0aa66f 100644 --- a/src/map/modifier.h +++ b/src/map/modifier.h @@ -601,7 +601,7 @@ enum class Mod EXP_BONUS = 382, // ROLL_RANGE = 528, // Additional range for COR roll abilities. JOB_BONUS_CHANCE = 542, // Chance to apply job bonus to COR roll without having the job in the party. - RANDOM_DEAL_BONUS = 573, // % chance to reset 2 abilities + RANDOM_DEAL_BONUS = 220, // % chance to reset 2 abilities TRIPLE_SHOT_RATE = 999, // Percent increase to Triple Shot Rate QUICK_DRAW_RECAST = 1060, // Quick Draw Charge Reduction (seconds) @@ -1013,7 +1013,7 @@ enum class Mod // 570 through 825 used by WS DMG mods these are not spares. // // SPARE IDs: - // 220 to 222 + // 221 to 222 // 274 to 276 // // SPARE = 1082 and onward diff --git a/src/map/utils/battleutils.cpp b/src/map/utils/battleutils.cpp index a2c8b7a658d..11cae619c6e 100644 --- a/src/map/utils/battleutils.cpp +++ b/src/map/utils/battleutils.cpp @@ -5872,8 +5872,8 @@ namespace battleutils ************************************************************************/ bool DoRandomDealToEntity(CCharEntity* PChar, CCharEntity* PTarget) { - std::vector ResetCandidateList; - std::vector ActiveCooldownList; + std::vector resetCandidateList; + std::vector activeCooldownList; if (PChar == nullptr || PTarget == nullptr) { @@ -5891,15 +5891,15 @@ namespace battleutils // Do not reset 2hrs or Random Deal if (recast->ID != 0 && recast->ID != 196) { - ResetCandidateList.push_back(i); + resetCandidateList.push_back(i); if (recast->RecastTime > 0) { - ActiveCooldownList.push_back(i); + activeCooldownList.push_back(i); } } } - if (ResetCandidateList.size() == 0 || ActiveCooldownList.size() == 0) + if (resetCandidateList.size() == 0 || activeCooldownList.size() == 0) { // Evade because we have no abilities that can be reset return false; @@ -5911,21 +5911,21 @@ namespace battleutils if (loadedDeck > 0) // Loaded Deck Merit Version { - if (ActiveCooldownList.size() > 1) + if (activeCooldownList.size() > 1) { // Shuffle active cooldowns and take first (loaded deck) - std::shuffle(std::begin(ActiveCooldownList), std::end(ActiveCooldownList), xirand::rng()); + std::shuffle(std::begin(activeCooldownList), std::end(activeCooldownList), xirand::rng()); loadedDeckChance = 100; } if (loadedDeckChance >= xirand::GetRandomNumber(100)) { - PTarget->PRecastContainer->DeleteByIndex(RECAST_ABILITY, ActiveCooldownList.at(0)); + PTarget->PRecastContainer->DeleteByIndex(RECAST_ABILITY, activeCooldownList.at(0)); // Reset 2 abilities by chance - if (ActiveCooldownList.size() > 1 && resetTwoChance >= xirand::GetRandomNumber(100)) + if (activeCooldownList.size() > 1 && resetTwoChance >= xirand::GetRandomNumber(100)) { - PTarget->PRecastContainer->DeleteByIndex(RECAST_ABILITY, ActiveCooldownList.at(1)); + PTarget->PRecastContainer->DeleteByIndex(RECAST_ABILITY, activeCooldownList.at(1)); } if (PChar != PTarget) { @@ -5940,19 +5940,19 @@ namespace battleutils } else // Standard Version { - if (ResetCandidateList.size() > 1) + if (resetCandidateList.size() > 1) { // Shuffle if more than 1 ability - std::shuffle(std::begin(ResetCandidateList), std::end(ResetCandidateList), xirand::rng()); + std::shuffle(std::begin(resetCandidateList), std::end(resetCandidateList), xirand::rng()); } // Reset first ability (shuffled or only) - PTarget->PRecastContainer->DeleteByIndex(RECAST_ABILITY, ResetCandidateList.at(0)); + PTarget->PRecastContainer->DeleteByIndex(RECAST_ABILITY, resetCandidateList.at(0)); // Reset 2 abilities by chance (could be 2 abilitie that don't need resets) - if (ResetCandidateList.size() > 1 && ActiveCooldownList.size() > 1 && resetTwoChance >= xirand::GetRandomNumber(1, 100)) + if (resetCandidateList.size() > 1 && activeCooldownList.size() > 1 && resetTwoChance >= xirand::GetRandomNumber(1, 100)) { - PTarget->PRecastContainer->DeleteByIndex(RECAST_ABILITY, ResetCandidateList.at(1)); + PTarget->PRecastContainer->DeleteByIndex(RECAST_ABILITY, resetCandidateList.at(1)); } if (PChar != PTarget)