You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I recently picked Random Deal from the WingsXI code base for use on our server.
We've been testing it for the past week with good results.
I'm sure there are areas for improvement before a formal PR is submitted.
I'd like to share the patch that I am using, to perhaps open a dialog with upstream about what those changes are, before formally submitting.
Thanks
diff --git a/scripts/enum/mod.lua b/scripts/enum/mod.lua
index 797dec3478..bf314a7379 100644
--- a/scripts/enum/mod.lua+++ b/scripts/enum/mod.lua@@ -743,6 +743,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
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/src/map/lua/lua_baseentity.cpp b/src/map/lua/lua_baseentity.cpp
index 3b0c9210bf..8e18c9a0a6 100644
--- a/src/map/lua/lua_baseentity.cpp+++ b/src/map/lua/lua_baseentity.cpp@@ -12980,6 +12980,23 @@ void CLuaBaseEntity::doWildCard(CLuaBaseEntity* PEntity, uint8 total)
battleutils::DoWildCardToEntity(static_cast<CCharEntity*>(m_PBaseEntity), static_cast<CCharEntity*>(PEntity->m_PBaseEntity), 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)+{+ if (m_PBaseEntity->objtype != TYPE_PC)+ {+ ShowWarning("Invalid entity type calling function (%s).", m_PBaseEntity->getName());+ return;+ }++ battleutils::DoRandomDealToEntity(static_cast<CCharEntity*>(m_PBaseEntity), static_cast<CCharEntity*>(PTarget->m_PBaseEntity));+}+
/************************************************************************
* Function: addCorsairRoll()
* Purpose : Adds the Corsair Roll to the Target's Status Effect Container
@@ -17737,6 +17754,7 @@ void CLuaBaseEntity::Register()
SOL_REGISTER("fold", CLuaBaseEntity::fold);
SOL_REGISTER("doWildCard", CLuaBaseEntity::doWildCard);
+ SOL_REGISTER("doRandomDeal", CLuaBaseEntity::doRandomDeal);
SOL_REGISTER("addCorsairRoll", CLuaBaseEntity::addCorsairRoll);
SOL_REGISTER("hasCorsairEffect", CLuaBaseEntity::hasCorsairEffect);
SOL_REGISTER("hasBustEffect", CLuaBaseEntity::hasBustEffect);
diff --git a/src/map/lua/lua_baseentity.h b/src/map/lua/lua_baseentity.h
index 6f606ffc52..88db8fc418 100644
--- a/src/map/lua/lua_baseentity.h+++ b/src/map/lua/lua_baseentity.h@@ -663,6 +663,7 @@ public:
void fold();
void doWildCard(CLuaBaseEntity* PEntity, uint8 total);
+ void 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 ba8e9e4a31..252f039170 100644
--- a/src/map/modifier.h+++ b/src/map/modifier.h@@ -570,6 +570,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
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 f5908b3318..435d96fde4 100644
--- a/src/map/utils/battleutils.cpp+++ b/src/map/utils/battleutils.cpp@@ -74,6 +74,33 @@+#include "packets/char_recast.h"@@ -6141,6 +6168,110 @@ namespace battleutils
}
}
+ /************************************************************************+ * *+ * Does the random deal effect to a specific character (reset ability) *+ * *+ ************************************************************************/+ bool DoRandomDealToEntity(CCharEntity* PChar, CCharEntity* PTarget)+ {+ std::vector<uint16> ResetCandidateList;+ std::vector<uint16> ActiveCooldownList;++ if (PChar == nullptr || PTarget == nullptr)+ {+ // Invalid User or Target+ return false;+ }++ RecastList_t* recastList = PTarget->PRecastContainer->GetRecastList(RECAST_ABILITY);++ // Get position of abilites and add to the 2 lists+ for (uint8 i = 0; i < recastList->size(); ++i)+ {+ Recast_t* recast = &recastList->at(i);++ // Do not reset 2hrs or Random Deal+ if (recast->ID != 0 && recast->ID != 196)+ {+ ResetCandidateList.push_back(i);+ if (recast->RecastTime > 0)+ {+ ActiveCooldownList.push_back(i);+ }+ }+ }++ if (ResetCandidateList.size() == 0)+ {+ // Evade because we have no abilities that can be reset+ return false;+ }++ 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);++ // Loaded Deck Merit Version+ if (loadedDeck && ActiveCooldownList.size() > 0)+ {+ if (ActiveCooldownList.size() > 1)+ {+ // Shuffle active cooldowns and take first (loaded deck)+ 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));++ // Reset 2 abilities by chance+ if (ActiveCooldownList.size() > 1 && resetTwoChance >= xirand::GetRandomNumber(100))+ {+ PTarget->PRecastContainer->DeleteByIndex(RECAST_ABILITY, ActiveCooldownList.at(1));+ }+ if (PChar != PTarget)+ {+ // Update target's recast state; caster's will be handled in CCharEntity::OnAbility.+ PTarget->pushPacket(new CCharRecastPacket(PTarget));+ }+ return true;+ }++ // Evade because we failed to reset with loaded deck+ return false;+ }+ else // Standard Version+ {+ if (ResetCandidateList.size() > 1)+ {+ // Shuffle if more than 1 ability+ std::shuffle(std::begin(ResetCandidateList), std::end(ResetCandidateList), xirand::rng());+ }++ // Reset first ability (shuffled or only)+ 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))+ {+ PTarget->PRecastContainer->DeleteByIndex(RECAST_ABILITY, ResetCandidateList.at(1));+ }++ if (PChar != PTarget)+ {+ // Update target's recast state; caster's will be handled in CCharEntity::OnAbility.+ PTarget->pushPacket(new CCharRecastPacket(PTarget));+ }++ return true;+ }++ // How did you get here!?+ return false;+ }+
/************************************************************************
* *
* Get the Snapshot shot time reduction *
diff --git a/src/map/utils/battleutils.h b/src/map/utils/battleutils.h
index 005672ad26..d10feac908 100644
--- a/src/map/utils/battleutils.h+++ b/src/map/utils/battleutils.h@@ -249,6 +249,8 @@ namespace battleutils
bool WeatherMatchesElement(WEATHER weather, uint8 element);
bool DrawIn(CBattleEntity* PEntity, CMobEntity* PMob, float offset);
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);
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I recently picked Random Deal from the WingsXI code base for use on our server.
We've been testing it for the past week with good results.
I'm sure there are areas for improvement before a formal PR is submitted.
I'd like to share the patch that I am using, to perhaps open a dialog with upstream about what those changes are, before formally submitting.
Thanks
Beta Was this translation helpful? Give feedback.
All reactions