mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Battleground: Changed HandleKillUnit hook to accept any Unit* as killer
This commit is contained in:
@@ -413,7 +413,7 @@ class TC_GAME_API Battleground : public ZoneScript
|
||||
virtual void HandleAreaTrigger(Player* /*player*/, uint32 /*trigger*/, bool /*entered*/);
|
||||
// must be implemented in BG subclass if need AND call base class generic code
|
||||
virtual void HandleKillPlayer(Player* player, Player* killer);
|
||||
virtual void HandleKillUnit(Creature* /*creature*/, Player* /*killer*/) { }
|
||||
virtual void HandleKillUnit(Creature* /*creature*/, Unit* /*killer*/) { }
|
||||
|
||||
// Battleground events
|
||||
virtual void EventPlayerDroppedFlag(Player* /*player*/) { }
|
||||
|
||||
@@ -73,12 +73,15 @@ void BattlegroundAV::HandleKillPlayer(Player* player, Player* killer)
|
||||
UpdateScore(GetPlayerTeam(player->GetGUID()), -1);
|
||||
}
|
||||
|
||||
void BattlegroundAV::HandleKillUnit(Creature* unit, Player* killer)
|
||||
void BattlegroundAV::HandleKillUnit(Creature* unit, Unit* killer)
|
||||
{
|
||||
TC_LOG_DEBUG("bg.battleground", "bg_av HandleKillUnit {}", unit->GetEntry());
|
||||
if (GetStatus() != STATUS_IN_PROGRESS)
|
||||
return;
|
||||
|
||||
uint32 entry = unit->GetEntry();
|
||||
Player* killerPlayer = killer->GetCharmerOrOwnerPlayerOrPlayerItself();
|
||||
|
||||
/*
|
||||
uint32 triggerSpawnID = 0;
|
||||
if (creature->GetEntry() == BG_AV_CreatureInfo[AV_NPC_A_CAPTAIN][0])
|
||||
@@ -148,10 +151,10 @@ void BattlegroundAV::HandleKillUnit(Creature* unit, Player* killer)
|
||||
if (Creature* herold = GetBGCreature(AV_CPLACE_HERALD))
|
||||
herold->AI()->Talk(TEXT_FROSTWOLF_GENERAL_DEAD);
|
||||
}
|
||||
else if (entry == BG_AV_CreatureInfo[AV_NPC_N_MINE_N_4] || entry == BG_AV_CreatureInfo[AV_NPC_N_MINE_A_4] || entry == BG_AV_CreatureInfo[AV_NPC_N_MINE_H_4])
|
||||
ChangeMineOwner(AV_NORTH_MINE, GetPlayerTeam(killer->GetGUID()));
|
||||
else if (entry == BG_AV_CreatureInfo[AV_NPC_S_MINE_N_4] || entry == BG_AV_CreatureInfo[AV_NPC_S_MINE_A_4] || entry == BG_AV_CreatureInfo[AV_NPC_S_MINE_H_4])
|
||||
ChangeMineOwner(AV_SOUTH_MINE, GetPlayerTeam(killer->GetGUID()));
|
||||
else if ((entry == BG_AV_CreatureInfo[AV_NPC_N_MINE_N_4] || entry == BG_AV_CreatureInfo[AV_NPC_N_MINE_A_4] || entry == BG_AV_CreatureInfo[AV_NPC_N_MINE_H_4]) && killerPlayer)
|
||||
ChangeMineOwner(AV_NORTH_MINE, GetPlayerTeam(killerPlayer->GetGUID()));
|
||||
else if ((entry == BG_AV_CreatureInfo[AV_NPC_S_MINE_N_4] || entry == BG_AV_CreatureInfo[AV_NPC_S_MINE_A_4] || entry == BG_AV_CreatureInfo[AV_NPC_S_MINE_H_4]) && killerPlayer)
|
||||
ChangeMineOwner(AV_SOUTH_MINE, GetPlayerTeam(killerPlayer->GetGUID()));
|
||||
}
|
||||
|
||||
void BattlegroundAV::HandleQuestComplete(uint32 questid, Player* player)
|
||||
|
||||
@@ -1599,7 +1599,7 @@ class BattlegroundAV : public Battleground
|
||||
/*handlestuff*/ //these are functions which get called from extern
|
||||
void EventPlayerClickedOnFlag(Player* source, GameObject* target_obj) override;
|
||||
void HandleKillPlayer(Player* player, Player* killer) override;
|
||||
void HandleKillUnit(Creature* unit, Player* killer) override;
|
||||
void HandleKillUnit(Creature* unit, Unit* killer) override;
|
||||
void HandleQuestComplete(uint32 questid, Player* player) override;
|
||||
bool CanActivateGO(int32 GOId, uint32 team) const override;
|
||||
|
||||
|
||||
@@ -364,7 +364,7 @@ bool BattlegroundIC::SetupBattleground()
|
||||
return true;
|
||||
}
|
||||
|
||||
void BattlegroundIC::HandleKillUnit(Creature* unit, Player* killer)
|
||||
void BattlegroundIC::HandleKillUnit(Creature* unit, Unit* killer)
|
||||
{
|
||||
if (GetStatus() != STATUS_IN_PROGRESS)
|
||||
return;
|
||||
@@ -384,7 +384,9 @@ void BattlegroundIC::HandleKillUnit(Creature* unit, Player* killer)
|
||||
//Achievement Mowed Down
|
||||
// TO-DO: This should be done on the script of each vehicle of the BG.
|
||||
if (unit->IsVehicle())
|
||||
killer->CastSpell(killer, SPELL_DESTROYED_VEHICLE_ACHIEVEMENT, true);
|
||||
{
|
||||
if (Player* killerPlayer = killer->GetCharmerOrOwnerPlayerOrPlayerItself())
|
||||
killerPlayer->CastSpell(killerPlayer, SPELL_DESTROYED_VEHICLE_ACHIEVEMENT, true);
|
||||
}
|
||||
|
||||
void BattlegroundIC::HandleKillPlayer(Player* player, Player* killer)
|
||||
|
||||
@@ -929,7 +929,7 @@ class BattlegroundIC : public Battleground
|
||||
void HandleAreaTrigger(Player* player, uint32 trigger, bool entered) override;
|
||||
bool SetupBattleground() override;
|
||||
void SpawnLeader(uint32 teamid);
|
||||
void HandleKillUnit(Creature* unit, Player* killer) override;
|
||||
void HandleKillUnit(Creature* unit, Unit* killer) override;
|
||||
void HandleKillPlayer(Player* player, Player* killer) override;
|
||||
void EventPlayerClickedOnFlag(Player* source, GameObject* /*target_obj*/) override;
|
||||
|
||||
|
||||
@@ -592,11 +592,12 @@ void BattlegroundSA::ProcessEvent(WorldObject* obj, uint32 eventId, WorldObject*
|
||||
}
|
||||
}
|
||||
|
||||
void BattlegroundSA::HandleKillUnit(Creature* creature, Player* killer)
|
||||
void BattlegroundSA::HandleKillUnit(Creature* creature, Unit* killer)
|
||||
{
|
||||
if (creature->GetEntry() == NPC_DEMOLISHER_SA)
|
||||
{
|
||||
UpdatePvpStat(killer, PVP_STAT_DEMOLISHERS_DESTROYED, 1);
|
||||
if (Player* killerPlayer = killer->GetCharmerOrOwnerPlayerOrPlayerItself())
|
||||
UpdatePvpStat(killerPlayer, PVP_STAT_DEMOLISHERS_DESTROYED, 1);
|
||||
int32 worldStateId = Attackers == TEAM_HORDE ? BG_SA_DESTROYED_HORDE_VEHICLES : BG_SA_DESTROYED_ALLIANCE_VEHICLES;
|
||||
int32 currentDestroyedVehicles = sWorldStateMgr->GetValue(worldStateId, GetBgMap());
|
||||
UpdateWorldState(worldStateId, currentDestroyedVehicles + 1);
|
||||
|
||||
@@ -542,7 +542,7 @@ class BattlegroundSA : public Battleground
|
||||
bool SetupBattleground() override;
|
||||
void Reset() override;
|
||||
/// Called when a player kill a unit in bg
|
||||
void HandleKillUnit(Creature* creature, Player* killer) override;
|
||||
void HandleKillUnit(Creature* creature, Unit* killer) override;
|
||||
/// Return the nearest graveyard where player can respawn
|
||||
WorldSafeLocsEntry const* GetClosestGraveyard(Player* player) override;
|
||||
/// Called when someone activates an event
|
||||
|
||||
@@ -10950,14 +10950,17 @@ void Unit::SetMeleeAnimKitId(uint16 animKitId)
|
||||
// pvp->HandlePlayerActivityChangedpVictim->ToPlayer();
|
||||
|
||||
// battleground things (do this at the end, so the death state flag will be properly set to handle in the bg->handlekill)
|
||||
if (player && player->InBattleground())
|
||||
if (attacker)
|
||||
{
|
||||
if (Battleground* bg = player->GetBattleground())
|
||||
if (BattlegroundMap* bgMap = victim->GetMap()->ToBattlegroundMap())
|
||||
{
|
||||
if (Player* playerVictim = victim->ToPlayer())
|
||||
bg->HandleKillPlayer(playerVictim, player);
|
||||
else
|
||||
bg->HandleKillUnit(victim->ToCreature(), player);
|
||||
if (Battleground* bg = bgMap->GetBG())
|
||||
{
|
||||
if (Player* playerVictim = victim->ToPlayer())
|
||||
bg->HandleKillPlayer(playerVictim, player);
|
||||
else
|
||||
bg->HandleKillUnit(victim->ToCreature(), attacker);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user