Skip to content

Commit

Permalink
Update rand deal bonus to unused modifier ID
Browse files Browse the repository at this point in the history
  • Loading branch information
MowFord committed Apr 14, 2024
1 parent 0e8ae08 commit 5c7bee3
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 24 deletions.
2 changes: 1 addition & 1 deletion scripts/enum/mod.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions sql/item_mods.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/map/lua/lua_baseentity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<CCharEntity*>(m_PBaseEntity), static_cast<CCharEntity*>(PTarget->m_PBaseEntity));
}

Expand Down
4 changes: 2 additions & 2 deletions src/map/modifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down
30 changes: 15 additions & 15 deletions src/map/utils/battleutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5872,8 +5872,8 @@ namespace battleutils
************************************************************************/
bool DoRandomDealToEntity(CCharEntity* PChar, CCharEntity* PTarget)
{
std::vector<uint16> ResetCandidateList;
std::vector<uint16> ActiveCooldownList;
std::vector<uint16> resetCandidateList;
std::vector<uint16> activeCooldownList;

if (PChar == nullptr || PTarget == nullptr)
{
Expand All @@ -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;
Expand All @@ -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)
{
Expand All @@ -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)
Expand Down

0 comments on commit 5c7bee3

Please sign in to comment.