feat(Core/Hooks) Adds hooks for BG and Arena systems. (#23543)
This commit is contained in:
parent
27a39dda66
commit
686aafd57b
9 changed files with 178 additions and 23 deletions
|
|
@ -104,6 +104,16 @@ void ScriptMgr::OnBattlegroundCreate(Battleground* bg)
|
|||
CALL_ENABLED_HOOKS(AllBattlegroundScript, ALLBATTLEGROUNDHOOK_ON_BATTLEGROUND_CREATE, script->OnBattlegroundCreate(bg));
|
||||
}
|
||||
|
||||
bool ScriptMgr::CanAddGroupToMatchingPool(BattlegroundQueue* queue, GroupQueueInfo* group, uint32 poolPlayerCount, Battleground* bg, BattlegroundBracketId bracketId)
|
||||
{
|
||||
CALL_ENABLED_BOOLEAN_HOOKS(AllBattlegroundScript, ALLBATTLEGROUNDHOOK_CAN_ADD_GROUP_TO_MATCHING_POOL, !script->CanAddGroupToMatchingPool(queue, group, poolPlayerCount, bg, bracketId));
|
||||
}
|
||||
|
||||
bool ScriptMgr::GetPlayerMatchmakingRating(ObjectGuid playerGuid, BattlegroundTypeId bgTypeId, float& outRating)
|
||||
{
|
||||
CALL_ENABLED_BOOLEAN_HOOKS_WITH_DEFAULT_FALSE(AllBattlegroundScript, ALLBATTLEGROUNDHOOK_GET_PLAYER_MATCHMAKING_RATING, script->GetPlayerMatchmakingRating(playerGuid, bgTypeId, outRating));
|
||||
}
|
||||
|
||||
AllBattlegroundScript::AllBattlegroundScript(char const* name, std::vector<uint16> enabledHooks) :
|
||||
ScriptObject(name, ALLBATTLEGROUNDHOOK_END)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
#ifndef SCRIPT_OBJECT_ALL_BATTLEGROUND_SCRIPT_H_
|
||||
#define SCRIPT_OBJECT_ALL_BATTLEGROUND_SCRIPT_H_
|
||||
|
||||
#include "ObjectGuid.h"
|
||||
#include "ScriptObject.h"
|
||||
#include <vector>
|
||||
|
||||
|
|
@ -40,6 +41,8 @@ enum AllBattlegroundHook
|
|||
ALLBATTLEGROUNDHOOK_ON_BATTLEGROUND_END,
|
||||
ALLBATTLEGROUNDHOOK_ON_BATTLEGROUND_DESTROY,
|
||||
ALLBATTLEGROUNDHOOK_ON_BATTLEGROUND_CREATE,
|
||||
ALLBATTLEGROUNDHOOK_CAN_ADD_GROUP_TO_MATCHING_POOL,
|
||||
ALLBATTLEGROUNDHOOK_GET_PLAYER_MATCHMAKING_RATING,
|
||||
ALLBATTLEGROUNDHOOK_END
|
||||
};
|
||||
|
||||
|
|
@ -47,6 +50,9 @@ enum BattlegroundBracketId : uint8;
|
|||
enum BattlegroundTypeId : uint8;
|
||||
enum TeamId : uint8;
|
||||
|
||||
class BattlegroundQueue;
|
||||
struct GroupQueueInfo;
|
||||
|
||||
class AllBattlegroundScript : public ScriptObject
|
||||
{
|
||||
protected:
|
||||
|
|
@ -132,6 +138,34 @@ public:
|
|||
* @param bg Contains information about the Battleground
|
||||
*/
|
||||
virtual void OnBattlegroundCreate(Battleground* /*bg*/) { }
|
||||
|
||||
/**
|
||||
* @brief This hook runs before adding a group to the battleground matching pool
|
||||
*
|
||||
* Allows modules to filter groups based on custom criteria (e.g., MMR matching).
|
||||
* Called during FillPlayersToBG before each group is added to the SelectionPool.
|
||||
*
|
||||
* @param queue The battleground queue
|
||||
* @param group The group being considered for addition
|
||||
* @param poolPlayerCount Current number of players already in the selection pool
|
||||
* @param bg The battleground instance
|
||||
* @param bracketId The bracket ID
|
||||
* @return True to allow adding this group, false to skip it
|
||||
*/
|
||||
[[nodiscard]] virtual bool CanAddGroupToMatchingPool(BattlegroundQueue* /*queue*/, GroupQueueInfo* /*group*/, uint32 /*poolPlayerCount*/, Battleground* /*bg*/, BattlegroundBracketId /*bracketId*/) { return true; }
|
||||
|
||||
/**
|
||||
* @brief This hook allows modules to provide matchmaking rating for a player
|
||||
*
|
||||
* Modules implementing MMR systems can use this hook to provide player ratings
|
||||
* for use in matchmaking algorithms.
|
||||
*
|
||||
* @param playerGuid The player's GUID
|
||||
* @param bgTypeId The battleground type
|
||||
* @param outRating Reference to store the rating value
|
||||
* @return True if rating was provided, false otherwise
|
||||
*/
|
||||
[[nodiscard]] virtual bool GetPlayerMatchmakingRating(ObjectGuid /*playerGuid*/, BattlegroundTypeId /*bgTypeId*/, float& /*outRating*/) { return false; }
|
||||
};
|
||||
|
||||
// Compatibility for old scripts
|
||||
|
|
|
|||
|
|
@ -44,6 +44,16 @@ void ScriptMgr::OnArenaStart(Battleground* bg)
|
|||
CALL_ENABLED_HOOKS(ArenaScript, ARENAHOOK_ON_ARENA_START, script->OnArenaStart(bg));
|
||||
}
|
||||
|
||||
bool ScriptMgr::OnBeforeArenaTeamMemberUpdate(ArenaTeam* team, Player* player, bool won, uint32 opponentMatchmakerRating, int32 matchmakerChange)
|
||||
{
|
||||
CALL_ENABLED_BOOLEAN_HOOKS(ArenaScript, ARENAHOOK_ON_BEFORE_TEAM_MEMBER_UPDATE, !script->OnBeforeArenaTeamMemberUpdate(team, player, won, opponentMatchmakerRating, matchmakerChange));
|
||||
}
|
||||
|
||||
bool ScriptMgr::CanSaveArenaStatsForMember(ArenaTeam* team, ObjectGuid playerGuid)
|
||||
{
|
||||
CALL_ENABLED_BOOLEAN_HOOKS(ArenaScript, ARENAHOOK_CAN_SAVE_ARENA_STATS_FOR_MEMBER, !script->CanSaveArenaStatsForMember(team, playerGuid));
|
||||
}
|
||||
|
||||
ArenaScript::ArenaScript(const char* name, std::vector<uint16> enabledHooks)
|
||||
: ScriptObject(name, ARENAHOOK_END)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ enum ArenaHook
|
|||
ARENAHOOK_CAN_SAVE_TO_DB,
|
||||
ARENAHOOK_ON_BEFORE_CHECK_WIN_CONDITION,
|
||||
ARENAHOOK_ON_ARENA_START,
|
||||
ARENAHOOK_ON_BEFORE_TEAM_MEMBER_UPDATE,
|
||||
ARENAHOOK_CAN_SAVE_ARENA_STATS_FOR_MEMBER,
|
||||
ARENAHOOK_END
|
||||
};
|
||||
|
||||
|
|
@ -51,6 +53,10 @@ public:
|
|||
[[nodiscard]] virtual bool CanSaveToDB(ArenaTeam* /*team*/) { return true; }
|
||||
|
||||
virtual void OnArenaStart(Battleground* /* bg */) { };
|
||||
|
||||
[[nodiscard]] virtual bool OnBeforeArenaTeamMemberUpdate(ArenaTeam* /*team*/, Player* /*player*/, bool /*won*/, uint32 /*opponentMatchmakerRating*/, int32 /*matchmakerChange*/) { return false; }
|
||||
|
||||
[[nodiscard]] virtual bool CanSaveArenaStatsForMember(ArenaTeam* /*team*/, ObjectGuid /*playerGuid*/) { return true; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue