TrinityCore/TrinityCore — Issue #4784: [Core][Fix] Achievement: Last standing
Author: Warpten
Created: 2012-01-12 04:49:54+00:00
State: open

```diff
diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp
index d8b5504..5000f62 100644
--- a/src/server/game/Battlegrounds/Battleground.cpp
+++ b/src/server/game/Battlegrounds/Battleground.cpp
@@ -1873,10 +1873,29 @@ void Battleground::CheckArenaAfterTimerConditions()

void Battleground::CheckArenaWinConditions()
{
+ uint32 winningTeam = 0;
+
if (!GetAlivePlayersCountByTeam(ALLIANCE) && GetPlayersCountByTeam(HORDE))
+ {
EndBattleground(HORDE);
+ winningTeam = HORDE;
+ }
else if (GetPlayersCountByTeam(ALLIANCE) && !GetAlivePlayersCountByTeam(HORDE))
+ {
+ winningTeam = ALLIANCE;
EndBattleground(ALLIANCE);
+ }
+
+ if (winningTeam && GetAlivePlayersCountByTeam(winningTeam) == 1 && isArena())
+ {
+ for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
+ {
+ if (itr->second.Team == winningTeam)
+ if (Player* player = ObjectAccessor::FindPlayer(itr->first))
+ if (player && player->isAlive() && !player->HasByteFlag(UNIT_FIELD_BYTES_2, 3, FORM_SPIRITOFREDEMPTION))
+ player->CastSpell(player, SPELL_LAST_STANDING, true);
+ }
+ }
}

void Battleground::UpdateArenaWorldState()
diff --git a/src/server/game/Battlegrounds/Battleground.h b/src/server/game/Battlegrounds/Battleground.h
index 6546ba6..8eedd7c 100644
--- a/src/server/game/Battlegrounds/Battleground.h
+++ b/src/server/game/Battlegrounds/Battleground.h
@@ -98,7 +98,8 @@ enum BattlegroundSpells
SPELL_RECENTLY_DROPPED_FLAG = 42792, // Recently Dropped Flag
SPELL_AURA_PLAYER_INACTIVE = 43681, // Inactive
SPELL_HONORABLE_DEFENDER_25Y = 68652, // +50% honor when standing at a capture point that you control, 25yards radius (added in 3.2)
- SPELL_HONORABLE_DEFENDER_60Y = 66157 // +50% honor when standing at a capture point that you control, 60yards radius (added in 3.2), probably for 40+ player battlegrounds
+ SPELL_HONORABLE_DEFENDER_60Y = 66157, // +50% honor when standing at a capture point that you control, 60yards radius (added in 3.2), probably for 40+ player battlegrounds
+ SPELL_LAST_STANDING = 26549, // Related to the achievement
};

enum BattlegroundTimeIntervals
```

Could not test, should be all fine. However this may look like an hacklike fix :/ I'm on IRC atm.

Closes #3637.