From 0e8ae0846123f31e2e33c083213dba763dbd0329 Mon Sep 17 00:00:00 2001 From: MowFord <131182600+MowFord@users.noreply.github.com> Date: Fri, 12 Apr 2024 23:14:29 -0500 Subject: [PATCH] Give proper messages for random deal --- scripts/actions/abilities/random_deal.lua | 3 ++- scripts/enum/msg.lua | 1 + src/map/lua/lua_baseentity.cpp | 16 ++++++++-------- src/map/lua/lua_baseentity.h | 2 +- src/map/modifier.h | 2 +- src/map/utils/battleutils.cpp | 20 ++++++++------------ src/map/utils/battleutils.h | 4 ++-- 7 files changed, 23 insertions(+), 25 deletions(-) diff --git a/scripts/actions/abilities/random_deal.lua b/scripts/actions/abilities/random_deal.lua index 50e62537594..3d46041127a 100644 --- a/scripts/actions/abilities/random_deal.lua +++ b/scripts/actions/abilities/random_deal.lua @@ -12,8 +12,9 @@ abilityObject.onAbilityCheck = function(player, target, ability) end abilityObject.onUseAbility = function(caster, target, ability, action) + ability:setMsg(xi.msg.basic.JA_RECEIVES_EFFECT_3) if not caster:doRandomDeal(target) then - ability:setMsg(xi.msg.basic.EVADES) + ability:setMsg(xi.msg.basic.JA_MISS_2) end end diff --git a/scripts/enum/msg.lua b/scripts/enum/msg.lua index 931496ef4a4..2cec65dc1a3 100644 --- a/scripts/enum/msg.lua +++ b/scripts/enum/msg.lua @@ -148,6 +148,7 @@ xi.msg.basic = JA_REMOVE_EFFECT_2 = 321, -- uses . 's wears off. JA_NO_EFFECT_2 = 323, -- uses . No effect on . (2 line msg) JA_MISS_2 = 324, -- uses , but misses . (includes target name) + JA_RECEIVES_EFFECT_3 = 441, -- receives the effect of . JA_RECOVERS_MP = 451, -- uses . regains MP. JA_ATK_ENHANCED = 285, -- 's attacks are enhanced. STATUS_BOOST = 364, -- uses . All of 's status parameters are boosted. diff --git a/src/map/lua/lua_baseentity.cpp b/src/map/lua/lua_baseentity.cpp index f3be48574c8..3522389d805 100644 --- a/src/map/lua/lua_baseentity.cpp +++ b/src/map/lua/lua_baseentity.cpp @@ -13064,20 +13064,20 @@ void CLuaBaseEntity::doWildCard(CLuaBaseEntity* PEntity, uint8 total) } /************************************************************************ -* Function: doRandomDeal() -* Purpose : Executes the Random Deal job ability -* Example : player:doRandomDeal(target) -* Notes : Calls the DoRandomDealToEntity function of battleutils -************************************************************************/ -void CLuaBaseEntity::doRandomDeal(CLuaBaseEntity* PTarget) + * Function: doRandomDeal() + * Purpose : Executes the Random Deal job ability + * Example : player:doRandomDeal(target) + * Notes : Calls the DoRandomDealToEntity function of battleutils + ************************************************************************/ +bool CLuaBaseEntity::doRandomDeal(CLuaBaseEntity* PTarget) { if (m_PBaseEntity->objtype != TYPE_PC) { ShowWarning("Invalid entity type calling function (%s).", m_PBaseEntity->getName()); - return; + return false; } - battleutils::DoRandomDealToEntity(static_cast(m_PBaseEntity), static_cast(PTarget->m_PBaseEntity)); + return battleutils::DoRandomDealToEntity(static_cast(m_PBaseEntity), static_cast(PTarget->m_PBaseEntity)); } /************************************************************************ diff --git a/src/map/lua/lua_baseentity.h b/src/map/lua/lua_baseentity.h index 02d002a6ba1..87f3bf2bf31 100644 --- a/src/map/lua/lua_baseentity.h +++ b/src/map/lua/lua_baseentity.h @@ -660,7 +660,7 @@ class CLuaBaseEntity void fold(); void doWildCard(CLuaBaseEntity* PEntity, uint8 total); - void doRandomDeal(CLuaBaseEntity* PTarget); + bool doRandomDeal(CLuaBaseEntity* PTarget); bool addCorsairRoll(uint8 casterJob, uint8 bustDuration, uint16 effectID, uint16 power, uint32 tick, uint32 duration, sol::object const& arg6, sol::object const& arg7, sol::object const& arg8); bool hasCorsairEffect(); diff --git a/src/map/modifier.h b/src/map/modifier.h index 9ceab79c782..4929a3d410a 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 = 573, // % chance to reset 2 abilities TRIPLE_SHOT_RATE = 999, // Percent increase to Triple Shot Rate QUICK_DRAW_RECAST = 1060, // Quick Draw Charge Reduction (seconds) diff --git a/src/map/utils/battleutils.cpp b/src/map/utils/battleutils.cpp index 6da47218ea6..a2c8b7a658d 100644 --- a/src/map/utils/battleutils.cpp +++ b/src/map/utils/battleutils.cpp @@ -5866,10 +5866,10 @@ namespace battleutils } /************************************************************************ - * * - * Does the random deal effect to a specific character (reset ability) * - * * - ************************************************************************/ + * * + * Does the random deal effect to a specific character (reset ability) * + * * + ************************************************************************/ bool DoRandomDealToEntity(CCharEntity* PChar, CCharEntity* PTarget) { std::vector ResetCandidateList; @@ -5899,18 +5899,17 @@ namespace battleutils } } - if (ResetCandidateList.size() == 0) + if (ResetCandidateList.size() == 0 || ActiveCooldownList.size() == 0) { // Evade because we have no abilities that can be reset return false; } - uint8 loadedDeck = PChar->PMeritPoints->GetMeritValue(MERIT_LOADED_DECK, PChar); + uint8 loadedDeck = PChar->PMeritPoints->GetMeritValue(MERIT_LOADED_DECK, PChar); uint8 loadedDeckChance = 50 + loadedDeck; - uint8 resetTwoChance = std::min(PChar->getMod(Mod::RANDOM_DEAL_BONUS), 50); + uint8 resetTwoChance = std::min(PChar->getMod(Mod::RANDOM_DEAL_BONUS), 50); - // Loaded Deck Merit Version - if (loadedDeck && ActiveCooldownList.size() > 0) + if (loadedDeck > 0) // Loaded Deck Merit Version { if (ActiveCooldownList.size() > 1) { @@ -5964,9 +5963,6 @@ namespace battleutils return true; } - - // How did you get here!? - return false; } /************************************************************************ diff --git a/src/map/utils/battleutils.h b/src/map/utils/battleutils.h index 608624d1c7d..894c9fb44a5 100644 --- a/src/map/utils/battleutils.h +++ b/src/map/utils/battleutils.h @@ -250,8 +250,8 @@ namespace battleutils void DoWildCardToEntity(CCharEntity* PCaster, CCharEntity* PTarget, uint8 roll); bool DoRandomDealToEntity(CCharEntity* PChar, CCharEntity* PTarget); - void AddTraits(CBattleEntity* PEntity, TraitList_t* TraitList, uint8 level); - bool HasClaim(CBattleEntity* PEntity, CBattleEntity* PTarget); + void AddTraits(CBattleEntity* PEntity, TraitList_t* TraitList, uint8 level); + bool HasClaim(CBattleEntity* PEntity, CBattleEntity* PTarget); uint32 CalculateSpellCastTime(CBattleEntity*, CMagicState*); uint16 CalculateSpellCost(CBattleEntity*, CSpell*);