mirror of
https://github.com/liyunfan1223/azerothcore-wotlk.git
synced 2026-08-04 22:07:52 +00:00
feat(Core/Scripting): add OnBeforeArenaCheckWinConditions hook for mod-arena-replay compatibility (#19856)
This commit is contained in:
@@ -192,6 +192,9 @@ void Arena::RemovePlayerAtLeave(Player* player)
|
|||||||
|
|
||||||
void Arena::CheckWinConditions()
|
void Arena::CheckWinConditions()
|
||||||
{
|
{
|
||||||
|
if (!sScriptMgr->OnBeforeArenaCheckWinConditions(this))
|
||||||
|
return;
|
||||||
|
|
||||||
if (!GetAlivePlayersCountByTeam(TEAM_ALLIANCE) && GetPlayersCountByTeam(TEAM_HORDE))
|
if (!GetAlivePlayersCountByTeam(TEAM_ALLIANCE) && GetPlayersCountByTeam(TEAM_HORDE))
|
||||||
EndBattleground(TEAM_HORDE);
|
EndBattleground(TEAM_HORDE);
|
||||||
else if (GetPlayersCountByTeam(TEAM_ALLIANCE) && !GetAlivePlayersCountByTeam(TEAM_HORDE))
|
else if (GetPlayersCountByTeam(TEAM_ALLIANCE) && !GetAlivePlayersCountByTeam(TEAM_HORDE))
|
||||||
|
|||||||
@@ -34,6 +34,11 @@ bool ScriptMgr::CanSaveToDB(ArenaTeam* team)
|
|||||||
CALL_ENABLED_BOOLEAN_HOOKS(ArenaScript, ARENAHOOK_CAN_SAVE_TO_DB, !script->CanSaveToDB(team));
|
CALL_ENABLED_BOOLEAN_HOOKS(ArenaScript, ARENAHOOK_CAN_SAVE_TO_DB, !script->CanSaveToDB(team));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ScriptMgr::OnBeforeArenaCheckWinConditions(Battleground* const bg)
|
||||||
|
{
|
||||||
|
CALL_ENABLED_BOOLEAN_HOOKS(ArenaScript, ARENAHOOK_ON_BEFORE_CHECK_WIN_CONDITION, !script->OnBeforeArenaCheckWinConditions(bg));
|
||||||
|
}
|
||||||
|
|
||||||
ArenaScript::ArenaScript(const char* name, std::vector<uint16> enabledHooks)
|
ArenaScript::ArenaScript(const char* name, std::vector<uint16> enabledHooks)
|
||||||
: ScriptObject(name, ARENAHOOK_END)
|
: ScriptObject(name, ARENAHOOK_END)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ enum ArenaHook
|
|||||||
ARENAHOOK_CAN_ADD_MEMBER,
|
ARENAHOOK_CAN_ADD_MEMBER,
|
||||||
ARENAHOOK_ON_GET_POINTS,
|
ARENAHOOK_ON_GET_POINTS,
|
||||||
ARENAHOOK_CAN_SAVE_TO_DB,
|
ARENAHOOK_CAN_SAVE_TO_DB,
|
||||||
|
ARENAHOOK_ON_BEFORE_CHECK_WIN_CONDITION,
|
||||||
ARENAHOOK_END
|
ARENAHOOK_END
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -44,6 +45,8 @@ public:
|
|||||||
|
|
||||||
virtual void OnGetPoints(ArenaTeam* /*team*/, uint32 /*memberRating*/, float& /*points*/) { }
|
virtual void OnGetPoints(ArenaTeam* /*team*/, uint32 /*memberRating*/, float& /*points*/) { }
|
||||||
|
|
||||||
|
[[nodiscard]] virtual bool OnBeforeArenaCheckWinConditions(Battleground* const /* bg */) { return true; }
|
||||||
|
|
||||||
[[nodiscard]] virtual bool CanSaveToDB(ArenaTeam* /*team*/) { return true; }
|
[[nodiscard]] virtual bool CanSaveToDB(ArenaTeam* /*team*/) { return true; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -646,6 +646,7 @@ public: /* ArenaScript */
|
|||||||
bool CanAddMember(ArenaTeam* team, ObjectGuid PlayerGuid);
|
bool CanAddMember(ArenaTeam* team, ObjectGuid PlayerGuid);
|
||||||
void OnGetPoints(ArenaTeam* team, uint32 memberRating, float& points);
|
void OnGetPoints(ArenaTeam* team, uint32 memberRating, float& points);
|
||||||
bool CanSaveToDB(ArenaTeam* team);
|
bool CanSaveToDB(ArenaTeam* team);
|
||||||
|
bool OnBeforeArenaCheckWinConditions(Battleground* const bg);
|
||||||
|
|
||||||
public: /* MiscScript */
|
public: /* MiscScript */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user