aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Battlegrounds
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2022-04-14 23:31:17 +0200
committerShauren <shauren.trinity@gmail.com>2022-04-16 12:15:37 +0200
commit84486ded67efc4e779412ff865c66ca8b9cee7ea (patch)
treea151ddae81c40c305f9540689ae9778d21b81d5b /src/server/game/Battlegrounds
parent15fe4e09d4dda16f23100412670dbdfbae5c5e61 (diff)
Core/Battlegrounds: Store mercenary status separately from the aura obtained from gossip as it can be removed at any time
Diffstat (limited to 'src/server/game/Battlegrounds')
-rw-r--r--src/server/game/Battlegrounds/Battleground.cpp29
-rw-r--r--src/server/game/Battlegrounds/Battleground.h7
-rw-r--r--src/server/game/Battlegrounds/BattlegroundQueue.cpp16
-rw-r--r--src/server/game/Battlegrounds/BattlegroundQueue.h2
4 files changed, 31 insertions, 23 deletions
diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp
index 1f7a3ce187c..b82061bdf93 100644
--- a/src/server/game/Battlegrounds/Battleground.cpp
+++ b/src/server/game/Battlegrounds/Battleground.cpp
@@ -1050,6 +1050,7 @@ void Battleground::AddPlayer(Player* player)
bp.OfflineRemoveTime = 0;
bp.Team = team;
bp.ActiveSpec = player->GetPrimarySpecialization();
+ bp.Mercenary = player->IsMercenaryForBattlegroundQueueType(GetQueueId());
bool const isInBattleground = IsPlayerInBattleground(player->GetGUID());
// Add to list/maps
@@ -1124,15 +1125,19 @@ void Battleground::AddPlayer(Player* player)
player->SendDirectMessage(startTimer.Write());
}
- if (player->HasAura(SPELL_MERCENARY_CONTRACT_HORDE))
+ if (bp.Mercenary)
{
- player->CastSpell(player, SPELL_MERCENARY_HORDE_1, true);
- player->CastSpell(player, SPELL_MERCENARY_HORDE_2, true);
- }
- else if (player->HasAura(SPELL_MERCENARY_CONTRACT_ALLIANCE))
- {
- player->CastSpell(player, SPELL_MERCENARY_ALLIANCE_1, true);
- player->CastSpell(player, SPELL_MERCENARY_ALLIANCE_2, true);
+ if (bp.Team == HORDE)
+ {
+ player->CastSpell(player, SPELL_MERCENARY_HORDE_1);
+ player->CastSpell(player, SPELL_MERCENARY_HORDE_REACTIONS);
+ }
+ else if (bp.Team == ALLIANCE)
+ {
+ player->CastSpell(player, SPELL_MERCENARY_ALLIANCE_1);
+ player->CastSpell(player, SPELL_MERCENARY_ALLIANCE_REACTIONS);
+ }
+ player->CastSpell(player, SPELL_MERCENARY_SHAPESHIFT);
}
}
@@ -1856,6 +1861,14 @@ bool Battleground::IsPlayerInBattleground(ObjectGuid guid) const
return false;
}
+bool Battleground::IsPlayerMercenaryInBattleground(ObjectGuid guid) const
+{
+ auto itr = m_Players.find(guid);
+ if (itr != m_Players.end())
+ return itr->second.Mercenary;
+ return false;
+}
+
void Battleground::PlayerAddedToBGCheckIfBGIsRunning(Player* player)
{
if (GetStatus() != STATUS_WAIT_LEAVE)
diff --git a/src/server/game/Battlegrounds/Battleground.h b/src/server/game/Battlegrounds/Battleground.h
index de1f632a145..c0dffbdea24 100644
--- a/src/server/game/Battlegrounds/Battleground.h
+++ b/src/server/game/Battlegrounds/Battleground.h
@@ -121,9 +121,10 @@ enum BattlegroundSpells
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_MERCENARY_HORDE_1 = 193864,
- SPELL_MERCENARY_HORDE_2 = 195838,
+ SPELL_MERCENARY_HORDE_REACTIONS = 195838,
SPELL_MERCENARY_ALLIANCE_1 = 193863,
- SPELL_MERCENARY_ALLIANCE_2 = 195843,
+ SPELL_MERCENARY_ALLIANCE_REACTIONS = 195843,
+ SPELL_MERCENARY_SHAPESHIFT = 193970,
};
enum BattlegroundTimeIntervals
@@ -175,6 +176,7 @@ struct BattlegroundPlayer
time_t OfflineRemoveTime; // for tracking and removing offline players from queue after 5 minutes
uint32 Team; // Player's team
int32 ActiveSpec; // Player's active spec
+ bool Mercenary;
};
struct BattlegroundObjectInfo
@@ -492,6 +494,7 @@ class TC_GAME_API Battleground
uint32 GetPlayerTeam(ObjectGuid guid) const;
uint32 GetOtherTeam(uint32 teamId) const;
bool IsPlayerInBattleground(ObjectGuid guid) const;
+ bool IsPlayerMercenaryInBattleground(ObjectGuid guid) const;
bool ToBeDeleted() const { return m_SetDeleteThis; }
void SetDeleteThis() { m_SetDeleteThis = true; }
diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.cpp b/src/server/game/Battlegrounds/BattlegroundQueue.cpp
index 10b10f805ee..103281c51fd 100644
--- a/src/server/game/Battlegrounds/BattlegroundQueue.cpp
+++ b/src/server/game/Battlegrounds/BattlegroundQueue.cpp
@@ -130,7 +130,7 @@ bool BattlegroundQueue::SelectionPool::AddGroup(GroupQueueInfo* ginfo, uint32 de
/*********************************************************/
// add group or player (grp == NULL) to bg queue with the given leader and bg specifications
-GroupQueueInfo* BattlegroundQueue::AddGroup(Player* leader, Group* grp, PVPDifficultyEntry const* bracketEntry, bool isPremade, uint32 ArenaRating, uint32 MatchmakerRating, uint32 arenateamid)
+GroupQueueInfo* BattlegroundQueue::AddGroup(Player const* leader, Group const* group, Team team, PVPDifficultyEntry const* bracketEntry, bool isPremade, uint32 ArenaRating, uint32 MatchmakerRating, uint32 arenateamid)
{
BattlegroundBracketId bracketId = bracketEntry->GetBracketId();
@@ -140,7 +140,7 @@ GroupQueueInfo* BattlegroundQueue::AddGroup(Player* leader, Group* grp, PVPDiffi
ginfo->IsInvitedToBGInstanceGUID = 0;
ginfo->JoinTime = GameTime::GetGameTimeMS();
ginfo->RemoveInviteTime = 0;
- ginfo->Team = leader->GetBgQueueTeam();
+ ginfo->Team = team;
ginfo->ArenaTeamRating = ArenaRating;
ginfo->ArenaMatchmakerRating = MatchmakerRating;
ginfo->OpponentsTeamRating = 0;
@@ -167,9 +167,9 @@ GroupQueueInfo* BattlegroundQueue::AddGroup(Player* leader, Group* grp, PVPDiffi
}
//add players from group to ginfo
- if (grp)
+ if (group)
{
- for (GroupReference* itr = grp->GetFirstMember(); itr != nullptr; itr = itr->next())
+ for (GroupReference const* itr = group->GetFirstMember(); itr != nullptr; itr = itr->next())
{
Player* member = itr->GetSource();
if (!member)
@@ -179,14 +179,6 @@ GroupQueueInfo* BattlegroundQueue::AddGroup(Player* leader, Group* grp, PVPDiffi
pl_info.GroupInfo = ginfo;
// add the pinfo to ginfo's list
ginfo->Players[member->GetGUID()] = &pl_info;
-
- if (ginfo->Team != member->GetTeam())
- {
- if (member->GetTeam() == ALLIANCE)
- member->CastSpell(member, SPELL_MERCENARY_CONTRACT_HORDE);
- else
- member->CastSpell(member, SPELL_MERCENARY_CONTRACT_ALLIANCE);
- }
}
}
else
diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.h b/src/server/game/Battlegrounds/BattlegroundQueue.h
index 3b8ac1a4d62..6d1c77999d9 100644
--- a/src/server/game/Battlegrounds/BattlegroundQueue.h
+++ b/src/server/game/Battlegrounds/BattlegroundQueue.h
@@ -79,7 +79,7 @@ class TC_GAME_API BattlegroundQueue
bool CheckPremadeMatch(BattlegroundBracketId bracket_id, uint32 MinPlayersPerTeam, uint32 MaxPlayersPerTeam);
bool CheckNormalMatch(Battleground* bg_template, BattlegroundBracketId bracket_id, uint32 minPlayers, uint32 maxPlayers);
bool CheckSkirmishForSameFaction(BattlegroundBracketId bracket_id, uint32 minPlayersPerTeam);
- GroupQueueInfo* AddGroup(Player* leader, Group* group, PVPDifficultyEntry const* bracketEntry, bool isPremade, uint32 ArenaRating, uint32 MatchmakerRating, uint32 ArenaTeamId = 0);
+ GroupQueueInfo* AddGroup(Player const* leader, Group const* group, Team team, PVPDifficultyEntry const* bracketEntry, bool isPremade, uint32 ArenaRating, uint32 MatchmakerRating, uint32 ArenaTeamId = 0);
void RemovePlayer(ObjectGuid guid, bool decreaseInvitedCount);
bool IsPlayerInvited(ObjectGuid pl_guid, const uint32 bgInstanceGuid, const uint32 removeTime);
bool GetPlayerGroupInfoData(ObjectGuid guid, GroupQueueInfo* ginfo);