mirror of
https://github.com/liyunfan1223/azerothcore-wotlk.git
synced 2026-08-07 15:28:02 +00:00
feat(Core/Scripting): Add OnBattlefieldWarEnd script hook (#25754)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -364,6 +364,7 @@ void Battlefield::EndBattle(bool endByTimer)
|
|||||||
DoPlaySoundToAll(BF_HORDE_WINS);
|
DoPlaySoundToAll(BF_HORDE_WINS);
|
||||||
|
|
||||||
OnBattleEnd(endByTimer);
|
OnBattleEnd(endByTimer);
|
||||||
|
sScriptMgr->OnBattlefieldWarEnd(this, endByTimer);
|
||||||
|
|
||||||
// Reset battlefield timer
|
// Reset battlefield timer
|
||||||
Timer = NoWarBattleTime;
|
Timer = NoWarBattleTime;
|
||||||
|
|||||||
@@ -44,6 +44,11 @@ void ScriptMgr::OnBattlefieldBeforeInvitePlayerToWar(Battlefield* bf, Player* pl
|
|||||||
CALL_ENABLED_HOOKS(BattlefieldScript, BATTLEFIELDHOOK_BEFORE_INVITE_PLAYER_TO_WAR, script->OnBattlefieldBeforeInvitePlayerToWar(bf, player));
|
CALL_ENABLED_HOOKS(BattlefieldScript, BATTLEFIELDHOOK_BEFORE_INVITE_PLAYER_TO_WAR, script->OnBattlefieldBeforeInvitePlayerToWar(bf, player));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScriptMgr::OnBattlefieldWarEnd(Battlefield* bf, bool endByTimer)
|
||||||
|
{
|
||||||
|
CALL_ENABLED_HOOKS(BattlefieldScript, BATTLEFIELDHOOK_ON_WAR_END, script->OnBattlefieldWarEnd(bf, endByTimer));
|
||||||
|
}
|
||||||
|
|
||||||
BattlefieldScript::BattlefieldScript(char const* name, std::vector<uint16> enabledHooks) :
|
BattlefieldScript::BattlefieldScript(char const* name, std::vector<uint16> enabledHooks) :
|
||||||
ScriptObject(name, BATTLEFIELDHOOK_END)
|
ScriptObject(name, BATTLEFIELDHOOK_END)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ enum BattlefieldHook
|
|||||||
BATTLEFIELDHOOK_ON_PLAYER_JOIN_WAR, // 2 - fires after player is added to the active war
|
BATTLEFIELDHOOK_ON_PLAYER_JOIN_WAR, // 2 - fires after player is added to the active war
|
||||||
BATTLEFIELDHOOK_ON_PLAYER_LEAVE_WAR, // 3 - fires after player is removed from the active war
|
BATTLEFIELDHOOK_ON_PLAYER_LEAVE_WAR, // 3 - fires after player is removed from the active war
|
||||||
BATTLEFIELDHOOK_BEFORE_INVITE_PLAYER_TO_WAR, // 4 - fires in InvitePlayerToWar before InvitedPlayers insert
|
BATTLEFIELDHOOK_BEFORE_INVITE_PLAYER_TO_WAR, // 4 - fires in InvitePlayerToWar before InvitedPlayers insert
|
||||||
|
BATTLEFIELDHOOK_ON_WAR_END, // 5 - fires in EndBattle after OnBattleEnd(), before timer reset
|
||||||
BATTLEFIELDHOOK_END
|
BATTLEFIELDHOOK_END
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -87,6 +88,17 @@ public:
|
|||||||
* @param player The player being invited to war
|
* @param player The player being invited to war
|
||||||
*/
|
*/
|
||||||
virtual void OnBattlefieldBeforeInvitePlayerToWar(Battlefield* /*bf*/, Player* /*player*/) { }
|
virtual void OnBattlefieldBeforeInvitePlayerToWar(Battlefield* /*bf*/, Player* /*player*/) { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Called in EndBattle() after OnBattleEnd() completes, before the timer is reset.
|
||||||
|
* All core PlayersInWar/InvitedPlayers structures have already been cleared.
|
||||||
|
* Modules that maintain their own per-war player tracking should use this hook
|
||||||
|
* to perform end-of-war cleanup (e.g. restoring cross-faction disguises).
|
||||||
|
*
|
||||||
|
* @param bf The Battlefield instance
|
||||||
|
* @param endByTimer True if the war ended by the countdown timer expiring
|
||||||
|
*/
|
||||||
|
virtual void OnBattlefieldWarEnd(Battlefield* /*bf*/, bool /*endByTimer*/) { }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SCRIPT_OBJECT_BATTLEFIELD_SCRIPT_H_
|
#endif // SCRIPT_OBJECT_BATTLEFIELD_SCRIPT_H_
|
||||||
|
|||||||
@@ -587,6 +587,7 @@ public: /* BattlefieldScript */
|
|||||||
void OnBattlefieldPlayerJoinWar(Battlefield* bf, Player* player);
|
void OnBattlefieldPlayerJoinWar(Battlefield* bf, Player* player);
|
||||||
void OnBattlefieldPlayerLeaveWar(Battlefield* bf, Player* player);
|
void OnBattlefieldPlayerLeaveWar(Battlefield* bf, Player* player);
|
||||||
void OnBattlefieldBeforeInvitePlayerToWar(Battlefield* bf, Player* player);
|
void OnBattlefieldBeforeInvitePlayerToWar(Battlefield* bf, Player* player);
|
||||||
|
void OnBattlefieldWarEnd(Battlefield* bf, bool endByTimer);
|
||||||
|
|
||||||
public: /* BGScript */
|
public: /* BGScript */
|
||||||
void OnBattlegroundStart(Battleground* bg);
|
void OnBattlegroundStart(Battleground* bg);
|
||||||
|
|||||||
Reference in New Issue
Block a user