mirror of
https://github.com/araxiaonline/AzerothCore-wotlk-with-NPCBots.git
synced 2026-06-13 03:22:24 -04:00
feat(Core/Battlefield): Add OnBattlefieldPlayerKill script hook (#25871)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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_
|
||||
|
||||
@@ -588,6 +588,7 @@ public: /* BattlefieldScript */
|
||||
void OnBattlefieldPlayerLeaveWar(Battlefield* bf, Player* player);
|
||||
void OnBattlefieldBeforeInvitePlayerToWar(Battlefield* bf, Player* player);
|
||||
void OnBattlefieldWarEnd(Battlefield* bf, bool endByTimer);
|
||||
void OnBattlefieldPlayerKill(Battlefield* bf, Player* killer, Player* victim);
|
||||
|
||||
public: /* BGScript */
|
||||
void OnBattlegroundStart(Battleground* bg);
|
||||
|
||||
Reference in New Issue
Block a user