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
@@ -21,6 +21,7 @@
#include "AreaDefines.h"
#include "BattlefieldWG.h"
#include "ScriptMgr.h"
#include "Chat.h"
#include "GameTime.h"
#include "MapMgr.h"
@@ -722,16 +723,19 @@ void BattlefieldWG::HandleKill(Player* killer, Unit* victim)
// xinef: tower cannons also grant rank
if (victim->IsPlayer() || IsKeepNpc(victim->GetEntry()) || victim->GetEntry() == NPC_WINTERGRASP_TOWER_CANNON)
{
if (victim->IsPlayer() && victim->HasAura(SPELL_LIEUTENANT))
if (Player* victimPlayer = victim->ToPlayer())
{
// Quest - Wintergrasp - PvP Kill - Horde/Alliance
for (ObjectGuid const& playerGuid : PlayersInWar[killerTeam])
sScriptMgr->OnBattlefieldPlayerKill(this, killer, victimPlayer);
if (victimPlayer->HasAura(SPELL_LIEUTENANT))
{
if (Player* player = ObjectAccessor::FindPlayer(playerGuid))
// Quest - Wintergrasp - PvP Kill - Horde/Alliance
for (ObjectGuid const& playerGuid : PlayersInWar[killerTeam])
{
if (player->GetDistance2d(killer) < 40)
if (Player* player = ObjectAccessor::FindPlayer(playerGuid))
{
player->KilledMonsterCredit(killerTeam == TEAM_HORDE ? NPC_QUEST_PVP_KILL_ALLIANCE : NPC_QUEST_PVP_KILL_HORDE);
if (player->GetDistance2d(killer) < 40)
player->KilledMonsterCredit(killerTeam == TEAM_HORDE ? NPC_QUEST_PVP_KILL_ALLIANCE : NPC_QUEST_PVP_KILL_HORDE);
}
}
}