From 48fc040c08f76bbe27fe92cc7b5ba9b64ce40ffd Mon Sep 17 00:00:00 2001 From: Skjalf <47818697+Nyeriah@users.noreply.github.com> Date: Sat, 16 May 2026 22:56:56 -0300 Subject: [PATCH] fix(WG): Grant quest credit for non-lieutenant WG kills in CFBG In CFBG Wintergrasp, quest credit for "No Mercy for the Merciless" / "Slay Them All" was silently lost for kills where the victim had not yet earned SPELL_LIEUTENANT (requiring 10 WG kills in the current session). Uses the new OnBattlefieldPlayerKill hook to grant KilledMonsterCredit to all nearby war-teammates of the killer for every player kill, bypassing the lieutenant gate. Double-credit on lieutenant kills is avoided by returning early when the victim already has SPELL_LIEUTENANT (the core's existing loop handles those). Credit NPC selection mirrors the core logic and correctly uses the killer's GetTeamId(), which reflects the CFBG-assigned fake team. Co-Authored-By: Claude Sonnet 4.6 --- src/CFBG_SC.cpp | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/CFBG_SC.cpp b/src/CFBG_SC.cpp index 733c08d..19539c2 100644 --- a/src/CFBG_SC.cpp +++ b/src/CFBG_SC.cpp @@ -210,6 +210,11 @@ class CFBG_Player : public PlayerScript uint32 timeCheck = 10000; }; +// WG constants duplicated here to avoid pulling in BattlefieldWG.h +static constexpr uint32 WG_SPELL_LIEUTENANT = 55629; +static constexpr uint32 WG_NPC_QUEST_PVP_KILL_ALLIANCE = 31086; +static constexpr uint32 WG_NPC_QUEST_PVP_KILL_HORDE = 39019; + class CFBG_Battlefield : public BattlefieldScript { public: @@ -217,7 +222,8 @@ class CFBG_Battlefield : public BattlefieldScript BATTLEFIELDHOOK_ON_PLAYER_JOIN_WAR, BATTLEFIELDHOOK_ON_PLAYER_LEAVE_WAR, BATTLEFIELDHOOK_ON_PLAYER_LEAVE_ZONE, - BATTLEFIELDHOOK_ON_WAR_END + BATTLEFIELDHOOK_ON_WAR_END, + BATTLEFIELDHOOK_ON_PLAYER_KILL }) {} void OnBattlefieldPlayerJoinWar(Battlefield* bf, Player* player) override @@ -282,6 +288,32 @@ class CFBG_Battlefield : public BattlefieldScript sCFBG->ClearFakePlayer(player); } + void OnBattlefieldPlayerKill(Battlefield* bf, Player* killer, Player* victim) override + { + if (!sCFBG->IsEnableSystem() || !sCFBG->IsEnableWGSystem()) + return; + + if (bf->GetTypeId() != BATTLEFIELD_WG) + return; + + // The core already grants credit when the victim has SPELL_LIEUTENANT (55629). + // This hook covers the remaining kills so that quest credit is not gated on + // victim rank, which would silently fail in short or low-population sessions. + if (victim->HasAura(WG_SPELL_LIEUTENANT)) + return; + + TeamId killerTeam = killer->GetTeamId(); + uint32 creditNpc = (killerTeam == TEAM_HORDE) ? WG_NPC_QUEST_PVP_KILL_ALLIANCE + : WG_NPC_QUEST_PVP_KILL_HORDE; + + for (ObjectGuid const& guid : bf->GetPlayersInWarSet(killerTeam)) + { + Player* ally = ObjectAccessor::FindPlayer(guid); + if (ally && ally->GetDistance2d(killer) < 40.0f) + ally->KilledMonsterCredit(creditNpc); + } + } + void OnBattlefieldWarEnd(Battlefield* bf, bool /*endByTimer*/) override { if (!sCFBG->IsEnableSystem() || !sCFBG->IsEnableWGSystem())