From 35f46bea57c12be2e9adae55bd6149116debed77 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Mon, 5 Feb 2024 13:31:24 -0500 Subject: [PATCH] Core/Battleground: Changed HandleKillUnit hook to accept any Unit as killer Port From (https://github.com/TrinityCore/TrinityCore/commit/bf107e0581c58f767b21f15fe7f75cb7eac95d97) --- Source/Game/BattleGrounds/BattleGround.cs | 3 ++- .../BattleGrounds/Zones/StrandofAncients.cs | 7 ++++-- Source/Game/Entities/Unit/Unit.Combat.cs | 22 +++++++++++-------- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/Source/Game/BattleGrounds/BattleGround.cs b/Source/Game/BattleGrounds/BattleGround.cs index 947a873b5..6950820c4 100644 --- a/Source/Game/BattleGrounds/BattleGround.cs +++ b/Source/Game/BattleGrounds/BattleGround.cs @@ -1614,7 +1614,8 @@ namespace Game.BattleGrounds RewardXPAtKill(killer, victim); } } - public virtual void HandleKillUnit(Creature creature, Player killer) { } + + public virtual void HandleKillUnit(Creature creature, Unit killer) { } // Return the player's team based on Battlegroundplayer info // Used in same faction arena matches mainly diff --git a/Source/Game/BattleGrounds/Zones/StrandofAncients.cs b/Source/Game/BattleGrounds/Zones/StrandofAncients.cs index 0453a4675..346120d88 100644 --- a/Source/Game/BattleGrounds/Zones/StrandofAncients.cs +++ b/Source/Game/BattleGrounds/Zones/StrandofAncients.cs @@ -580,11 +580,14 @@ namespace Game.BattleGrounds.Zones } } - public override void HandleKillUnit(Creature creature, Player killer) + public override void HandleKillUnit(Creature creature, Unit killer) { if (creature.GetEntry() == SACreatureIds.Demolisher) { - UpdatePvpStat(killer, (uint)StrandOfTheAncientsPvpStats.DemolishersDestroyed, 1); + Player killerPlayer = killer.GetCharmerOrOwnerPlayerOrPlayerItself(); + if (killerPlayer != null) + UpdatePvpStat(killerPlayer, (uint)StrandOfTheAncientsPvpStats.DemolishersDestroyed, 1); + uint worldStateId = Attackers == BatttleGroundTeamId.Horde ? SAWorldStateIds.DestroyedHordeVehicles : SAWorldStateIds.DestroyedAllianceVehicles; int currentDestroyedVehicles = Global.WorldStateMgr.GetValue((int)worldStateId, GetBgMap()); UpdateWorldState(worldStateId, currentDestroyedVehicles + 1); diff --git a/Source/Game/Entities/Unit/Unit.Combat.cs b/Source/Game/Entities/Unit/Unit.Combat.cs index 5b4fc287c..13299b363 100644 --- a/Source/Game/Entities/Unit/Unit.Combat.cs +++ b/Source/Game/Entities/Unit/Unit.Combat.cs @@ -998,17 +998,21 @@ namespace Game.Entities bf.HandleKill(player, victim); } - // Battlegroundthings (do this at the end, so the death state flag will be properly set to handle in the bg.handlekill) - if (player != null && player.InBattleground()) + // battleground things (do this at the end, so the death state flag will be properly set to handle in the bg->handlekill) + if (attacker != null) { - Battleground bg = player.GetBattleground(); - if (bg != null) + BattlegroundMap bgMap = victim.GetMap().ToBattlegroundMap(); + if (bgMap != null) { - Player playerVictim = victim.ToPlayer(); - if (playerVictim != null) - bg.HandleKillPlayer(playerVictim, player); - else - bg.HandleKillUnit(victim.ToCreature(), player); + Battleground bg = bgMap.GetBG(); + if (bg != null) + { + Player playerVictim = victim.ToPlayer(); + if (playerVictim != null) + bg.HandleKillPlayer(playerVictim, player); + else + bg.HandleKillUnit(victim.ToCreature(), player); + } } }