Skip to content

Commit

Permalink
Give proper messages for random deal
Browse files Browse the repository at this point in the history
  • Loading branch information
MowFord committed Apr 14, 2024
1 parent c92222c commit 0e8ae08
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 25 deletions.
3 changes: 2 additions & 1 deletion scripts/actions/abilities/random_deal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions scripts/enum/msg.lua
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ xi.msg.basic =
JA_REMOVE_EFFECT_2 = 321, -- <user> uses <ability>. <target>'s <status> wears off.
JA_NO_EFFECT_2 = 323, -- <user> uses <ability>. No effect on <target>. (2 line msg)
JA_MISS_2 = 324, -- <user> uses <ability>, but misses <target>. (includes target name)
JA_RECEIVES_EFFECT_3 = 441, -- <user> receives the effect of <ability>.
JA_RECOVERS_MP = 451, -- <user> uses <ability>. <target> regains <amount> MP.
JA_ATK_ENHANCED = 285, -- <target>'s attacks are enhanced.
STATUS_BOOST = 364, -- <user> uses <ability>. All of <target>'s status parameters are boosted.
Expand Down
16 changes: 8 additions & 8 deletions src/map/lua/lua_baseentity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<CCharEntity*>(m_PBaseEntity), static_cast<CCharEntity*>(PTarget->m_PBaseEntity));
return battleutils::DoRandomDealToEntity(static_cast<CCharEntity*>(m_PBaseEntity), static_cast<CCharEntity*>(PTarget->m_PBaseEntity));
}

/************************************************************************
Expand Down
2 changes: 1 addition & 1 deletion src/map/lua/lua_baseentity.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion 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 = 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)

Expand Down
20 changes: 8 additions & 12 deletions src/map/utils/battleutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint16> ResetCandidateList;
Expand Down Expand Up @@ -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<int8>(PChar->getMod(Mod::RANDOM_DEAL_BONUS), 50);
uint8 resetTwoChance = std::min<int8>(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)
{
Expand Down Expand Up @@ -5964,9 +5963,6 @@ namespace battleutils

return true;
}

// How did you get here!?
return false;
}

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

0 comments on commit 0e8ae08

Please sign in to comment.