Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion src/CFBG_SC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,20 @@ 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:
CFBG_Battlefield() : BattlefieldScript("CFBG_Battlefield", {
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
Expand Down Expand Up @@ -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())
Expand Down
Loading