feat(Core/Battlefield): Add OnBattlefieldPlayerKill script hook (#25871)

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Andrew
2026-05-17 01:12:04 -03:00
committed by GitHub
parent ac12f5d27c
commit 5f5c287cd3
4 changed files with 28 additions and 6 deletions
@@ -49,6 +49,11 @@ void ScriptMgr::OnBattlefieldWarEnd(Battlefield* bf, bool endByTimer)
CALL_ENABLED_HOOKS(BattlefieldScript, BATTLEFIELDHOOK_ON_WAR_END, script->OnBattlefieldWarEnd(bf, endByTimer));
}
void ScriptMgr::OnBattlefieldPlayerKill(Battlefield* bf, Player* killer, Player* victim)
{
CALL_ENABLED_HOOKS(BattlefieldScript, BATTLEFIELDHOOK_ON_PLAYER_KILL, script->OnBattlefieldPlayerKill(bf, killer, victim));
}
BattlefieldScript::BattlefieldScript(char const* name, std::vector<uint16> enabledHooks) :
ScriptObject(name, BATTLEFIELDHOOK_END)
{
@@ -29,6 +29,7 @@ enum BattlefieldHook
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_ON_WAR_END, // 5 - fires in EndBattle after OnBattleEnd(), before timer reset
BATTLEFIELDHOOK_ON_PLAYER_KILL, // 6 - fires in HandleKill for every player-kills-player event
BATTLEFIELDHOOK_END
};
@@ -99,6 +100,17 @@ public:
* @param endByTimer True if the war ended by the countdown timer expiring
*/
virtual void OnBattlefieldWarEnd(Battlefield* /*bf*/, bool /*endByTimer*/) { }
/**
* @brief Called inside BattlefieldWG::HandleKill for every player-kills-player event,
* regardless of the victim's WG rank. Fired before the core's own lieutenant-gated
* quest-credit loop so modules may grant credit for non-lieutenant kills.
*
* @param bf The Battlefield instance
* @param killer The player who landed the killing blow
* @param victim The player who was killed
*/
virtual void OnBattlefieldPlayerKill(Battlefield* /*bf*/, Player* /*killer*/, Player* /*victim*/) { }
};
#endif // SCRIPT_OBJECT_BATTLEFIELD_SCRIPT_H_