[10781] Use BattleGround(AV)TeamIndex enum types in AV battleground code.

* Added BattleGroundAVTeamIndex enum type for 3-case special team list fo AV.
* Rename BattleGroundTeamId -> BattleGroundTeamIndex for clarify
* Some safe checks added and dropped bogus call RewardReputationToTeam in BattleGroundAV::HandleQuestComplete
  for BattleGroundTeamIndex as faction. Unclear for what it expected used so dropped.
This commit is contained in:
VladimirMangos 2010-11-24 17:27:10 +03:00
parent 26668c067b
commit c2331f58bc
7 changed files with 149 additions and 141 deletions

View file

@ -509,11 +509,11 @@ void BattleGround::Update(uint32 diff)
void BattleGround::SetTeamStartLoc(uint32 TeamID, float X, float Y, float Z, float O)
{
BattleGroundTeamId idx = GetTeamIndexByTeamId(TeamID);
m_TeamStartLocX[idx] = X;
m_TeamStartLocY[idx] = Y;
m_TeamStartLocZ[idx] = Z;
m_TeamStartLocO[idx] = O;
BattleGroundTeamIndex teamIdx = GetTeamIndexByTeamId(TeamID);
m_TeamStartLocX[teamIdx] = X;
m_TeamStartLocY[teamIdx] = Y;
m_TeamStartLocZ[teamIdx] = Z;
m_TeamStartLocO[teamIdx] = O;
}
void BattleGround::SendPacketToAll(WorldPacket *packet)
@ -1822,7 +1822,7 @@ WorldSafeLocsEntry const* BattleGround::GetClosestGraveYard( Player* player )
bool BattleGround::IsTeamScoreInRange(uint32 team, uint32 minScore, uint32 maxScore) const
{
BattleGroundTeamId team_idx = GetTeamIndexByTeamId(team);
BattleGroundTeamIndex team_idx = GetTeamIndexByTeamId(team);
uint32 score = (m_TeamScores[team_idx] < 0) ? 0 : uint32(m_TeamScores[team_idx]);
return score >= minScore && score <= maxScore;
}

View file

@ -214,11 +214,12 @@ enum BattleGroundWinner
WINNER_NONE = 2
};
enum BattleGroundTeamId
enum BattleGroundTeamIndex
{
BG_TEAM_ALLIANCE = 0,
BG_TEAM_HORDE = 1
};
#define BG_TEAMS_COUNT 2
enum BattleGroundStartingEvents
@ -400,7 +401,7 @@ class BattleGround
void SetTeamStartLoc(uint32 TeamID, float X, float Y, float Z, float O);
void GetTeamStartLoc(uint32 TeamID, float &X, float &Y, float &Z, float &O) const
{
BattleGroundTeamId idx = GetTeamIndexByTeamId(TeamID);
BattleGroundTeamIndex idx = GetTeamIndexByTeamId(TeamID);
X = m_TeamStartLocX[idx];
Y = m_TeamStartLocY[idx];
Z = m_TeamStartLocZ[idx];
@ -445,7 +446,7 @@ class BattleGround
virtual void UpdatePlayerScore(Player *Source, uint32 type, uint32 value);
static BattleGroundTeamId GetTeamIndexByTeamId(uint32 Team) { return Team == ALLIANCE ? BG_TEAM_ALLIANCE : BG_TEAM_HORDE; }
static BattleGroundTeamIndex GetTeamIndexByTeamId(uint32 Team) { return Team == ALLIANCE ? BG_TEAM_ALLIANCE : BG_TEAM_HORDE; }
uint32 GetPlayersCountByTeam(uint32 Team) const { return m_PlayersCount[GetTeamIndexByTeamId(Team)]; }
uint32 GetAlivePlayersCountByTeam(uint32 Team) const; // used in arenas to correctly handle death in spirit of redemption / last stand etc. (killer = killed) cases
void UpdatePlayersCountByTeam(uint32 Team, bool remove)
@ -524,7 +525,8 @@ class BattleGround
// since arenas can be AvA or Hvh, we have to get the "temporary" team of a player
uint32 GetPlayerTeam(uint64 guid);
uint32 GetOtherTeam(uint32 teamId){ return (teamId) ? ((teamId == ALLIANCE) ? HORDE : ALLIANCE) : 0; }
static uint32 GetOtherTeam(uint32 teamId){ return (teamId) ? ((teamId == ALLIANCE) ? HORDE : ALLIANCE) : 0; }
static BattleGroundTeamIndex GetOtherTeamIndex(BattleGroundTeamIndex teamIdx){ return teamIdx == BG_TEAM_ALLIANCE ? BG_TEAM_HORDE : BG_TEAM_ALLIANCE; }
bool IsPlayerInBattleGround(uint64 guid);
/* virtual score-array - get's used in bg-subclasses */

View file

@ -340,7 +340,7 @@ void BattleGroundAB::EventPlayerClickedOnFlag(Player *source, GameObject* target
return;
BG_AB_Nodes node = BG_AB_Nodes(event);
BattleGroundTeamId teamIndex = GetTeamIndexByTeamId(source->GetTeam());
BattleGroundTeamIndex teamIndex = GetTeamIndexByTeamId(source->GetTeam());
// Check if player really could use this banner, not cheated
if (!(m_Nodes[node] == 0 || teamIndex == m_Nodes[node] % 2))
@ -500,7 +500,7 @@ void BattleGroundAB::EndBattleGround(uint32 winner)
WorldSafeLocsEntry const* BattleGroundAB::GetClosestGraveYard(Player* player)
{
BattleGroundTeamId teamIndex = GetTeamIndexByTeamId(player->GetTeam());
BattleGroundTeamIndex teamIndex = GetTeamIndexByTeamId(player->GetTeam());
// Is there any occupied node for this team?
std::vector<uint8> nodes;

View file

@ -89,10 +89,10 @@ void BattleGroundAV::HandleKillUnit(Creature *creature, Player *killer)
SpawnEvent(BG_AV_NodeEventCaptainDead_H, 0, true);
break;
case BG_AV_MINE_BOSSES_NORTH:
ChangeMineOwner(BG_AV_NORTH_MINE, GetTeamIndexByTeamId(killer->GetTeam()));
ChangeMineOwner(BG_AV_NORTH_MINE, GetAVTeamIndexByTeamId(killer->GetTeam()));
break;
case BG_AV_MINE_BOSSES_SOUTH:
ChangeMineOwner(BG_AV_SOUTH_MINE, GetTeamIndexByTeamId(killer->GetTeam()));
ChangeMineOwner(BG_AV_SOUTH_MINE, GetAVTeamIndexByTeamId(killer->GetTeam()));
break;
}
}
@ -101,7 +101,7 @@ void BattleGroundAV::HandleQuestComplete(uint32 questid, Player *player)
{
if (GetStatus() != STATUS_IN_PROGRESS)
return;
uint8 team = GetTeamIndexByTeamId(player->GetTeam());
BattleGroundTeamIndex teamIdx = GetTeamIndexByTeamId(player->GetTeam());
uint32 reputation = 0; // reputation for the whole team (other reputation must be done in db)
// TODO add events (including quest not available anymore, next quest availabe, go/npc de/spawning)
sLog.outError("BattleGroundAV: Quest %i completed", questid);
@ -111,90 +111,89 @@ void BattleGroundAV::HandleQuestComplete(uint32 questid, Player *player)
case BG_AV_QUEST_A_SCRAPS2:
case BG_AV_QUEST_H_SCRAPS1:
case BG_AV_QUEST_H_SCRAPS2:
m_Team_QuestStatus[team][0] += 20;
m_Team_QuestStatus[teamIdx][0] += 20;
reputation = 1;
if( m_Team_QuestStatus[team][0] == 500 || m_Team_QuestStatus[team][0] == 1000 || m_Team_QuestStatus[team][0] == 1500 ) //25,50,75 turn ins
if( m_Team_QuestStatus[teamIdx][0] == 500 || m_Team_QuestStatus[teamIdx][0] == 1000 || m_Team_QuestStatus[teamIdx][0] == 1500 ) //25,50,75 turn ins
{
DEBUG_LOG("BattleGroundAV: Quest %i completed starting with unit upgrading..", questid);
for (BG_AV_Nodes i = BG_AV_NODES_FIRSTAID_STATION; i <= BG_AV_NODES_FROSTWOLF_HUT; ++i)
if (m_Nodes[i].Owner == team && m_Nodes[i].State == POINT_CONTROLLED)
if (m_Nodes[i].Owner == teamIdx && m_Nodes[i].State == POINT_CONTROLLED)
PopulateNode(i);
}
break;
case BG_AV_QUEST_A_COMMANDER1:
case BG_AV_QUEST_H_COMMANDER1:
m_Team_QuestStatus[team][1]++;
m_Team_QuestStatus[teamIdx][1]++;
reputation = 1;
if (m_Team_QuestStatus[team][1] == 120)
if (m_Team_QuestStatus[teamIdx][1] == 120)
DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here", questid);
break;
case BG_AV_QUEST_A_COMMANDER2:
case BG_AV_QUEST_H_COMMANDER2:
m_Team_QuestStatus[team][2]++;
m_Team_QuestStatus[teamIdx][2]++;
reputation = 2;
if (m_Team_QuestStatus[team][2] == 60)
if (m_Team_QuestStatus[teamIdx][2] == 60)
DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here", questid);
break;
case BG_AV_QUEST_A_COMMANDER3:
case BG_AV_QUEST_H_COMMANDER3:
m_Team_QuestStatus[team][3]++;
m_Team_QuestStatus[teamIdx][3]++;
reputation = 5;
RewardReputationToTeam(team, 1, player->GetTeam());
if (m_Team_QuestStatus[team][1] == 30)
if (m_Team_QuestStatus[teamIdx][1] == 30)
DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here", questid);
break;
case BG_AV_QUEST_A_BOSS1:
case BG_AV_QUEST_H_BOSS1:
m_Team_QuestStatus[team][4] += 4; // there are 2 quests where you can turn in 5 or 1 item.. ( + 4 cause +1 will be done some lines below)
m_Team_QuestStatus[teamIdx][4] += 4; // there are 2 quests where you can turn in 5 or 1 item.. ( + 4 cause +1 will be done some lines below)
reputation = 4;
case BG_AV_QUEST_A_BOSS2:
case BG_AV_QUEST_H_BOSS2:
m_Team_QuestStatus[team][4]++;
m_Team_QuestStatus[teamIdx][4]++;
reputation += 1;
if (m_Team_QuestStatus[team][4] >= 200)
if (m_Team_QuestStatus[teamIdx][4] >= 200)
DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here", questid);
break;
case BG_AV_QUEST_A_NEAR_MINE:
case BG_AV_QUEST_H_NEAR_MINE:
m_Team_QuestStatus[team][5]++;
m_Team_QuestStatus[teamIdx][5]++;
reputation = 2;
if (m_Team_QuestStatus[team][5] == 28)
if (m_Team_QuestStatus[teamIdx][5] == 28)
{
DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here", questid);
if (m_Team_QuestStatus[team][6] == 7)
if (m_Team_QuestStatus[teamIdx][6] == 7)
DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here - ground assault ready", questid);
}
break;
case BG_AV_QUEST_A_OTHER_MINE:
case BG_AV_QUEST_H_OTHER_MINE:
m_Team_QuestStatus[team][6]++;
m_Team_QuestStatus[teamIdx][6]++;
reputation = 3;
if (m_Team_QuestStatus[team][6] == 7)
if (m_Team_QuestStatus[teamIdx][6] == 7)
{
DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here", questid);
if (m_Team_QuestStatus[team][5] == 20)
if (m_Team_QuestStatus[teamIdx][5] == 20)
DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here - ground assault ready", questid);
}
break;
case BG_AV_QUEST_A_RIDER_HIDE:
case BG_AV_QUEST_H_RIDER_HIDE:
m_Team_QuestStatus[team][7]++;
m_Team_QuestStatus[teamIdx][7]++;
reputation = 1;
if (m_Team_QuestStatus[team][7] == 25)
if (m_Team_QuestStatus[teamIdx][7] == 25)
{
DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here", questid);
if (m_Team_QuestStatus[team][8] == 25)
if (m_Team_QuestStatus[teamIdx][8] == 25)
DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here - rider assault ready", questid);
}
break;
case BG_AV_QUEST_A_RIDER_TAME:
case BG_AV_QUEST_H_RIDER_TAME:
m_Team_QuestStatus[team][8]++;
m_Team_QuestStatus[teamIdx][8]++;
reputation = 1;
if (m_Team_QuestStatus[team][8] == 25)
if (m_Team_QuestStatus[teamIdx][8] == 25)
{
DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here", questid);
if (m_Team_QuestStatus[team][7] == 25)
if (m_Team_QuestStatus[teamIdx][7] == 25)
DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here - rider assault ready", questid);
}
break;
@ -207,29 +206,29 @@ void BattleGroundAV::HandleQuestComplete(uint32 questid, Player *player)
RewardReputationToTeam((player->GetTeam() == ALLIANCE) ? BG_AV_FACTION_A : BG_AV_FACTION_H, reputation, player->GetTeam());
}
void BattleGroundAV::UpdateScore(BattleGroundTeamId team, int32 points )
void BattleGroundAV::UpdateScore(BattleGroundTeamIndex teamIdx, int32 points )
{
// note: to remove reinforcements points must be negative, for adding reinforcements points must be positive
MANGOS_ASSERT( team == BG_TEAM_ALLIANCE || team == BG_TEAM_HORDE);
m_TeamScores[team] += points; // m_TeamScores is int32 - so no problems here
MANGOS_ASSERT( teamIdx == BG_TEAM_ALLIANCE || teamIdx == BG_TEAM_HORDE);
m_TeamScores[teamIdx] += points; // m_TeamScores is int32 - so no problems here
if (points < 0)
{
if (m_TeamScores[team] < 1)
if (m_TeamScores[teamIdx] < 1)
{
m_TeamScores[team] = 0;
m_TeamScores[teamIdx] = 0;
// other team will win:
EndBattleGround((team == BG_TEAM_ALLIANCE)? HORDE : ALLIANCE);
EndBattleGround((teamIdx == BG_TEAM_ALLIANCE)? HORDE : ALLIANCE);
}
else if (!m_IsInformedNearLose[team] && m_TeamScores[team] < BG_AV_SCORE_NEAR_LOSE)
else if (!m_IsInformedNearLose[teamIdx] && m_TeamScores[teamIdx] < BG_AV_SCORE_NEAR_LOSE)
{
SendMessageToAll((team == BG_TEAM_HORDE) ? LANG_BG_AV_H_NEAR_LOSE : LANG_BG_AV_A_NEAR_LOSE, CHAT_MSG_BG_SYSTEM_NEUTRAL);
SendMessageToAll((teamIdx == BG_TEAM_HORDE) ? LANG_BG_AV_H_NEAR_LOSE : LANG_BG_AV_A_NEAR_LOSE, CHAT_MSG_BG_SYSTEM_NEUTRAL);
PlaySoundToAll(BG_AV_SOUND_NEAR_LOSE);
m_IsInformedNearLose[team] = true;
m_IsInformedNearLose[teamIdx] = true;
}
}
// must be called here, else it could display a negative value
UpdateWorldState(((team == BG_TEAM_HORDE) ? BG_AV_Horde_Score : BG_AV_Alliance_Score), m_TeamScores[team]);
UpdateWorldState(((teamIdx == BG_TEAM_HORDE) ? BG_AV_Horde_Score : BG_AV_Alliance_Score), m_TeamScores[teamIdx]);
}
void BattleGroundAV::Update(uint32 diff)
@ -241,19 +240,19 @@ void BattleGroundAV::Update(uint32 diff)
// add points from mine owning, and look if the neutral team can reclaim the mine
for(uint8 mine = 0; mine < BG_AV_MAX_MINES; mine++)
{
if (m_Mine_Owner[mine] == BG_TEAM_ALLIANCE || m_Mine_Owner[mine] == BG_TEAM_HORDE)
if (m_Mine_Owner[mine] != BG_AV_TEAM_NEUTRAL)
{
m_Mine_Timer[mine] -=diff;
if (m_Mine_Timer[mine] <= 0)
{
UpdateScore(BattleGroundTeamId(m_Mine_Owner[mine]), 1);
UpdateScore(BattleGroundTeamIndex(m_Mine_Owner[mine]), 1);
m_Mine_Timer[mine] = BG_AV_MINE_TICK_TIMER;
}
if (m_Mine_Reclaim_Timer[mine] > diff)
m_Mine_Reclaim_Timer[mine] -= diff;
else
ChangeMineOwner(mine, BG_AV_NEUTRAL_TEAM);
ChangeMineOwner(mine, BG_AV_TEAM_NEUTRAL);
}
}
@ -309,11 +308,11 @@ void BattleGroundAV::EndBattleGround(uint32 winner)
// graves all controlled
for(BG_AV_Nodes i = BG_AV_NODES_FIRSTAID_STATION; i < BG_AV_NODES_MAX; ++i)
if (m_Nodes[i].State == POINT_CONTROLLED)
if (m_Nodes[i].State == POINT_CONTROLLED && m_Nodes[i].Owner != BG_AV_TEAM_NEUTRAL)
++graves_owned[m_Nodes[i].Owner];
for (uint32 i = 0; i < BG_AV_MAX_MINES; ++i)
if (m_Mine_Owner[i] != BG_AV_NEUTRAL_TEAM)
if (m_Mine_Owner[i] != BG_AV_TEAM_NEUTRAL)
++mines_owned[m_Mine_Owner[i]];
// now we have the values give the honor/reputation to the teams:
@ -417,22 +416,24 @@ void BattleGroundAV::UpdatePlayerScore(Player* Source, uint32 type, uint32 value
void BattleGroundAV::EventPlayerDestroyedPoint(BG_AV_Nodes node)
{
MANGOS_ASSERT(m_Nodes[node].Owner != BG_AV_TEAM_NEUTRAL)
DEBUG_LOG("BattleGroundAV: player destroyed point node %i", node);
BattleGroundTeamIndex owner = BattleGroundTeamIndex(m_Nodes[node].Owner);
// despawn banner
DestroyNode(node);
PopulateNode(node);
UpdateNodeWorldState(node);
uint32 owner = m_Nodes[node].Owner;
if (IsTower(node))
{
uint8 tmp = node - BG_AV_NODES_DUNBALDAR_SOUTH;
// despawn marshal (one of those guys protecting the boss)
SpawnEvent(BG_AV_MARSHAL_A_SOUTH + tmp, 0, false);
UpdateScore(BattleGroundTeamId(owner^0x1), (-1) * BG_AV_RES_TOWER);
UpdateScore(GetOtherTeamIndex(owner), (-1) * BG_AV_RES_TOWER);
RewardReputationToTeam((owner == BG_TEAM_ALLIANCE) ? BG_AV_FACTION_A : BG_AV_FACTION_H, m_RepTowerDestruction, owner);
RewardHonorToTeam(GetBonusHonorFromKill(BG_AV_KILL_TOWER), owner);
SendYell2ToAll(LANG_BG_AV_TOWER_TAKEN, LANG_UNIVERSAL, GetSingleCreatureGuid(BG_AV_HERALD, 0), GetNodeName(node), ( owner == BG_TEAM_ALLIANCE ) ? LANG_BG_ALLY : LANG_BG_HORDE);
@ -443,33 +444,30 @@ void BattleGroundAV::EventPlayerDestroyedPoint(BG_AV_Nodes node)
}
}
void BattleGroundAV::ChangeMineOwner(uint8 mine, uint32 team)
void BattleGroundAV::ChangeMineOwner(uint8 mine, BattleGroundAVTeamIndex teamIdx)
{
m_Mine_Timer[mine] = BG_AV_MINE_TICK_TIMER;
// TODO implement quest 7122
// mine=0 northmine, mine=1 southmine
// TODO changing the owner should result in setting respawntime to infinite for current creatures (they should fight the new ones), spawning new mine owners creatures and changing the chest - objects so that the current owning team can use them
MANGOS_ASSERT(mine == BG_AV_NORTH_MINE || mine == BG_AV_SOUTH_MINE);
if (m_Mine_Owner[mine] == int8(team))
if (m_Mine_Owner[mine] == teamIdx)
return;
if (team != BG_TEAM_ALLIANCE && team != BG_TEAM_HORDE)
team = BG_AV_NEUTRAL_TEAM;
m_Mine_PrevOwner[mine] = m_Mine_Owner[mine];
m_Mine_Owner[mine] = team;
m_Mine_Owner[mine] = teamIdx;
SendMineWorldStates(mine);
SpawnEvent(BG_AV_MINE_EVENT + mine, team, true);
SpawnEvent(BG_AV_MINE_BOSSES + mine, team, true);
SpawnEvent(BG_AV_MINE_EVENT + mine, teamIdx, true);
SpawnEvent(BG_AV_MINE_BOSSES + mine, teamIdx, true);
if (team == BG_TEAM_ALLIANCE || team == BG_TEAM_HORDE)
if (teamIdx != BG_AV_TEAM_NEUTRAL)
{
PlaySoundToAll((team == BG_TEAM_ALLIANCE) ? BG_AV_SOUND_ALLIANCE_GOOD : BG_AV_SOUND_HORDE_GOOD);
PlaySoundToAll((teamIdx == BG_TEAM_ALLIANCE) ? BG_AV_SOUND_ALLIANCE_GOOD : BG_AV_SOUND_HORDE_GOOD);
m_Mine_Reclaim_Timer[mine] = BG_AV_MINE_RECLAIM_TIMER;
SendYell2ToAll(LANG_BG_AV_MINE_TAKEN , LANG_UNIVERSAL, GetSingleCreatureGuid(BG_AV_HERALD, 0),
(team == BG_TEAM_ALLIANCE ) ? LANG_BG_ALLY : LANG_BG_HORDE,
(teamIdx == BG_TEAM_ALLIANCE ) ? LANG_BG_ALLY : LANG_BG_HORDE,
(mine == BG_AV_NORTH_MINE) ? LANG_BG_AV_MINE_NORTH : LANG_BG_AV_MINE_SOUTH);
}
}
@ -487,25 +485,25 @@ bool BattleGroundAV::PlayerCanDoMineQuest(int32 GOId, uint32 team)
/// more a wrapper around spawnevent cause graveyards are special
void BattleGroundAV::PopulateNode(BG_AV_Nodes node)
{
uint32 team = m_Nodes[node].Owner;
if (IsGrave(node) && team != BG_AV_NEUTRAL_TEAM)
BattleGroundAVTeamIndex teamIdx = m_Nodes[node].Owner;
if (IsGrave(node) && teamIdx != BG_AV_TEAM_NEUTRAL)
{
uint32 graveDefenderType;
if (m_Team_QuestStatus[team][0] < 500 )
if (m_Team_QuestStatus[teamIdx][0] < 500 )
graveDefenderType = 0;
else if (m_Team_QuestStatus[team][0] < 1000 )
else if (m_Team_QuestStatus[teamIdx][0] < 1000 )
graveDefenderType = 1;
else if (m_Team_QuestStatus[team][0] < 1500 )
else if (m_Team_QuestStatus[teamIdx][0] < 1500 )
graveDefenderType = 2;
else
graveDefenderType = 3;
if (m_Nodes[node].State == POINT_CONTROLLED) // we can spawn the current owner event
SpawnEvent(BG_AV_NODES_MAX + node, team * BG_AV_MAX_GRAVETYPES + graveDefenderType, true);
SpawnEvent(BG_AV_NODES_MAX + node, teamIdx * BG_AV_MAX_GRAVETYPES + graveDefenderType, true);
else // we despawn the event from the prevowner
SpawnEvent(BG_AV_NODES_MAX + node, m_Nodes[node].PrevOwner * BG_AV_MAX_GRAVETYPES + graveDefenderType, false);
}
SpawnEvent(node, (team * BG_AV_MAX_STATES) + m_Nodes[node].State, true);
SpawnEvent(node, (teamIdx * BG_AV_MAX_STATES) + m_Nodes[node].State, true);
}
/// called when using a banner
@ -535,11 +533,11 @@ void BattleGroundAV::EventPlayerDefendsPoint(Player* player, BG_AV_Nodes node)
{
MANGOS_ASSERT(GetStatus() == STATUS_IN_PROGRESS);
uint32 team = GetTeamIndexByTeamId(player->GetTeam());
BattleGroundTeamIndex teamIdx = GetTeamIndexByTeamId(player->GetTeam());
if (m_Nodes[node].Owner == team || m_Nodes[node].State != POINT_ASSAULTED)
if (m_Nodes[node].Owner == teamIdx || m_Nodes[node].State != POINT_ASSAULTED)
return;
if( m_Nodes[node].TotalOwner == BG_AV_NEUTRAL_TEAM ) // initial snowfall capture
if( m_Nodes[node].TotalOwner == BG_AV_TEAM_NEUTRAL ) // initial snowfall capture
{
// until snowfall doesn't belong to anyone it is better handled in assault - code (best would be to have a special function
// for neutral nodes.. but doing this just for snowfall will be a bit to much i think
@ -547,14 +545,15 @@ void BattleGroundAV::EventPlayerDefendsPoint(Player* player, BG_AV_Nodes node)
EventPlayerAssaultsPoint(player, node);
return;
}
DEBUG_LOG("BattleGroundAV: player defends node: %i", node);
if (m_Nodes[node].PrevOwner != team)
if (m_Nodes[node].PrevOwner != teamIdx)
{
sLog.outError("BattleGroundAV: player defends point which doesn't belong to his team %i", node);
return;
}
DefendNode(node, team); // set the right variables for nodeinfo
DefendNode(node, teamIdx); // set the right variables for nodeinfo
PopulateNode(node); // spawn node-creatures (defender for example)
UpdateNodeWorldState(node); // send new mapicon to the player
@ -562,7 +561,7 @@ void BattleGroundAV::EventPlayerDefendsPoint(Player* player, BG_AV_Nodes node)
{
SendYell2ToAll( LANG_BG_AV_TOWER_DEFENDED, LANG_UNIVERSAL, GetSingleCreatureGuid(BG_AV_HERALD, 0),
GetNodeName(node),
( team == BG_TEAM_ALLIANCE ) ? LANG_BG_ALLY:LANG_BG_HORDE);
( teamIdx == BG_TEAM_ALLIANCE ) ? LANG_BG_ALLY:LANG_BG_HORDE);
UpdatePlayerScore(player, SCORE_TOWERS_DEFENDED, 1);
PlaySoundToAll(BG_AV_SOUND_BOTH_TOWER_DEFEND);
}
@ -570,22 +569,22 @@ void BattleGroundAV::EventPlayerDefendsPoint(Player* player, BG_AV_Nodes node)
{
SendYell2ToAll(LANG_BG_AV_GRAVE_DEFENDED, LANG_UNIVERSAL, GetSingleCreatureGuid(BG_AV_HERALD, 0),
GetNodeName(node),
( team == BG_TEAM_ALLIANCE ) ? LANG_BG_ALLY:LANG_BG_HORDE);
( teamIdx == BG_TEAM_ALLIANCE ) ? LANG_BG_ALLY:LANG_BG_HORDE);
UpdatePlayerScore(player, SCORE_GRAVEYARDS_DEFENDED, 1);
// update the statistic for the defending player
PlaySoundToAll((team == BG_TEAM_ALLIANCE)?BG_AV_SOUND_ALLIANCE_GOOD:BG_AV_SOUND_HORDE_GOOD);
PlaySoundToAll((teamIdx == BG_TEAM_ALLIANCE)?BG_AV_SOUND_ALLIANCE_GOOD:BG_AV_SOUND_HORDE_GOOD);
}
}
void BattleGroundAV::EventPlayerAssaultsPoint(Player* player, BG_AV_Nodes node)
{
// TODO implement quest 7101, 7081
uint32 team = GetTeamIndexByTeamId(player->GetTeam());
BattleGroundTeamIndex teamIdx = GetTeamIndexByTeamId(player->GetTeam());
DEBUG_LOG("BattleGroundAV: player assaults node %i", node);
if (m_Nodes[node].Owner == team || team == m_Nodes[node].TotalOwner)
if (m_Nodes[node].Owner == teamIdx || teamIdx == m_Nodes[node].TotalOwner)
return;
AssaultNode(node, team); // update nodeinfo variables
AssaultNode(node, teamIdx); // update nodeinfo variables
UpdateNodeWorldState(node); // send mapicon
PopulateNode(node);
@ -593,19 +592,19 @@ void BattleGroundAV::EventPlayerAssaultsPoint(Player* player, BG_AV_Nodes node)
{
SendYell2ToAll(LANG_BG_AV_TOWER_ASSAULTED, LANG_UNIVERSAL, GetSingleCreatureGuid(BG_AV_HERALD, 0),
GetNodeName(node),
( team == BG_TEAM_ALLIANCE ) ? LANG_BG_ALLY:LANG_BG_HORDE);
( teamIdx == BG_TEAM_ALLIANCE ) ? LANG_BG_ALLY:LANG_BG_HORDE);
UpdatePlayerScore(player, SCORE_TOWERS_ASSAULTED, 1);
}
else
{
SendYell2ToAll(LANG_BG_AV_GRAVE_ASSAULTED, LANG_UNIVERSAL, GetSingleCreatureGuid(BG_AV_HERALD, 0),
GetNodeName(node),
( team == BG_TEAM_ALLIANCE ) ? LANG_BG_ALLY:LANG_BG_HORDE);
( teamIdx == BG_TEAM_ALLIANCE ) ? LANG_BG_ALLY:LANG_BG_HORDE);
// update the statistic for the assaulting player
UpdatePlayerScore(player, SCORE_GRAVEYARDS_ASSAULTED, 1);
}
PlaySoundToAll((team == BG_TEAM_ALLIANCE) ? BG_AV_SOUND_ALLIANCE_ASSAULTS : BG_AV_SOUND_HORDE_ASSAULTS);
PlaySoundToAll((teamIdx == BG_TEAM_ALLIANCE) ? BG_AV_SOUND_ALLIANCE_ASSAULTS : BG_AV_SOUND_HORDE_ASSAULTS);
}
void BattleGroundAV::FillInitialWorldStates(WorldPacket& data, uint32& count)
@ -616,14 +615,14 @@ void BattleGroundAV::FillInitialWorldStates(WorldPacket& data, uint32& count)
for (uint8 j = 0; j < BG_AV_MAX_STATES; j++)
{
stateok = (m_Nodes[i].State == j);
FillInitialWorldState(data, count, BG_AV_NodeWorldStates[i][GetWorldStateType(j, BG_TEAM_ALLIANCE)],
FillInitialWorldState(data, count, BG_AV_NodeWorldStates[i][GetWorldStateType(j, BG_AV_TEAM_ALLIANCE)],
m_Nodes[i].Owner == BG_TEAM_ALLIANCE && stateok);
FillInitialWorldState(data, count, BG_AV_NodeWorldStates[i][GetWorldStateType(j, BG_TEAM_HORDE)],
FillInitialWorldState(data, count, BG_AV_NodeWorldStates[i][GetWorldStateType(j, BG_AV_TEAM_HORDE)],
m_Nodes[i].Owner == BG_TEAM_HORDE && stateok);
}
}
if( m_Nodes[BG_AV_NODES_SNOWFALL_GRAVE].Owner == BG_AV_NEUTRAL_TEAM ) // cause neutral teams aren't handled generic
if( m_Nodes[BG_AV_NODES_SNOWFALL_GRAVE].Owner == BG_AV_TEAM_NEUTRAL ) // cause neutral teams aren't handled generic
FillInitialWorldState(data, count, AV_SNOWFALL_N, 1);
FillInitialWorldState(data, count, BG_AV_Alliance_Score, m_TeamScores[BG_TEAM_ALLIANCE]);
@ -651,7 +650,7 @@ void BattleGroundAV::FillInitialWorldStates(WorldPacket& data, uint32& count)
void BattleGroundAV::UpdateNodeWorldState(BG_AV_Nodes node)
{
UpdateWorldState(BG_AV_NodeWorldStates[node][GetWorldStateType(m_Nodes[node].State,m_Nodes[node].Owner)], 1);
if( m_Nodes[node].PrevOwner == BG_AV_NEUTRAL_TEAM ) // currently only snowfall is supported as neutral node
if( m_Nodes[node].PrevOwner == BG_AV_TEAM_NEUTRAL ) // currently only snowfall is supported as neutral node
UpdateWorldState(AV_SNOWFALL_N, 0);
else
UpdateWorldState(BG_AV_NodeWorldStates[node][GetWorldStateType(m_Nodes[node].PrevState,m_Nodes[node].PrevOwner)], 0);
@ -660,8 +659,6 @@ void BattleGroundAV::UpdateNodeWorldState(BG_AV_Nodes node)
void BattleGroundAV::SendMineWorldStates(uint32 mine)
{
MANGOS_ASSERT(mine == BG_AV_NORTH_MINE || mine == BG_AV_SOUTH_MINE);
MANGOS_ASSERT(m_Mine_PrevOwner[mine] == BG_TEAM_ALLIANCE || m_Mine_PrevOwner[mine] == BG_TEAM_HORDE || m_Mine_PrevOwner[mine] == BG_AV_NEUTRAL_TEAM);
MANGOS_ASSERT(m_Mine_Owner[mine] == BG_TEAM_ALLIANCE || m_Mine_Owner[mine] == BG_TEAM_HORDE || m_Mine_Owner[mine] == BG_AV_NEUTRAL_TEAM);
UpdateWorldState(BG_AV_MineWorldStates[mine][m_Mine_Owner[mine]], 1);
if (m_Mine_Owner[mine] != m_Mine_PrevOwner[mine])
@ -672,7 +669,7 @@ WorldSafeLocsEntry const* BattleGroundAV::GetClosestGraveYard(Player *plr)
{
float x = plr->GetPositionX();
float y = plr->GetPositionY();
uint32 team = GetTeamIndexByTeamId(plr->GetTeam());
BattleGroundAVTeamIndex teamIdx = GetAVTeamIndexByTeamId(plr->GetTeam());
WorldSafeLocsEntry const* good_entry = NULL;
if (GetStatus() == STATUS_IN_PROGRESS)
{
@ -680,7 +677,7 @@ WorldSafeLocsEntry const* BattleGroundAV::GetClosestGraveYard(Player *plr)
float mindist = 9999999.0f;
for(uint8 i = BG_AV_NODES_FIRSTAID_STATION; i <= BG_AV_NODES_FROSTWOLF_HUT; ++i)
{
if (m_Nodes[i].Owner != team || m_Nodes[i].State != POINT_CONTROLLED)
if (m_Nodes[i].Owner != teamIdx || m_Nodes[i].State != POINT_CONTROLLED)
continue;
WorldSafeLocsEntry const * entry = sWorldSafeLocsStore.LookupEntry( BG_AV_GraveyardIds[i] );
if (!entry)
@ -695,7 +692,7 @@ WorldSafeLocsEntry const* BattleGroundAV::GetClosestGraveYard(Player *plr)
}
// If not, place ghost in the starting-cave
if (!good_entry)
good_entry = sWorldSafeLocsStore.LookupEntry( BG_AV_GraveyardIds[team + 7] );
good_entry = sWorldSafeLocsStore.LookupEntry( BG_AV_GraveyardIds[teamIdx + 7] );
return good_entry;
}
@ -723,17 +720,16 @@ uint32 BattleGroundAV::GetNodeName(BG_AV_Nodes node)
}
}
void BattleGroundAV::AssaultNode(BG_AV_Nodes node, uint32 team)
void BattleGroundAV::AssaultNode(BG_AV_Nodes node, BattleGroundTeamIndex teamIdx)
{
MANGOS_ASSERT(team < 3); // alliance:0, horde:1, neutral:2
MANGOS_ASSERT(m_Nodes[node].TotalOwner != team);
MANGOS_ASSERT(m_Nodes[node].Owner != team);
MANGOS_ASSERT(m_Nodes[node].TotalOwner != teamIdx);
MANGOS_ASSERT(m_Nodes[node].Owner != teamIdx);
// only assault an assaulted node if no totalowner exists:
MANGOS_ASSERT(m_Nodes[node].State != POINT_ASSAULTED || m_Nodes[node].TotalOwner == BG_AV_NEUTRAL_TEAM);
MANGOS_ASSERT(m_Nodes[node].State != POINT_ASSAULTED || m_Nodes[node].TotalOwner == BG_AV_TEAM_NEUTRAL);
// the timer gets another time, if the previous owner was 0 == Neutral
m_Nodes[node].Timer = (m_Nodes[node].PrevOwner != BG_AV_NEUTRAL_TEAM) ? BG_AV_CAPTIME : BG_AV_SNOWFALL_FIRSTCAP;
m_Nodes[node].Timer = (m_Nodes[node].PrevOwner != BG_AV_TEAM_NEUTRAL) ? BG_AV_CAPTIME : BG_AV_SNOWFALL_FIRSTCAP;
m_Nodes[node].PrevOwner = m_Nodes[node].Owner;
m_Nodes[node].Owner = team;
m_Nodes[node].Owner = BattleGroundAVTeamIndex(teamIdx);
m_Nodes[node].PrevState = m_Nodes[node].State;
m_Nodes[node].State = POINT_ASSAULTED;
}
@ -749,30 +745,28 @@ void BattleGroundAV::DestroyNode(BG_AV_Nodes node)
m_Nodes[node].Timer = 0;
}
void BattleGroundAV::InitNode(BG_AV_Nodes node, uint32 team, bool tower)
void BattleGroundAV::InitNode(BG_AV_Nodes node, BattleGroundAVTeamIndex teamIdx, bool tower)
{
MANGOS_ASSERT(team < 3); // alliance:0, horde:1, neutral:2
m_Nodes[node].TotalOwner = team;
m_Nodes[node].Owner = team;
m_Nodes[node].PrevOwner = team;
m_Nodes[node].TotalOwner = teamIdx;
m_Nodes[node].Owner = teamIdx;
m_Nodes[node].PrevOwner = teamIdx;
m_Nodes[node].State = POINT_CONTROLLED;
m_Nodes[node].PrevState = m_Nodes[node].State;
m_Nodes[node].State = POINT_CONTROLLED;
m_Nodes[node].Timer = 0;
m_Nodes[node].Tower = tower;
m_ActiveEvents[node] = team * BG_AV_MAX_STATES + m_Nodes[node].State;
m_ActiveEvents[node] = teamIdx * BG_AV_MAX_STATES + m_Nodes[node].State;
if (IsGrave(node)) // grave-creatures are special cause of a quest
m_ActiveEvents[node + BG_AV_NODES_MAX] = team * BG_AV_MAX_GRAVETYPES;
m_ActiveEvents[node + BG_AV_NODES_MAX] = teamIdx * BG_AV_MAX_GRAVETYPES;
}
void BattleGroundAV::DefendNode(BG_AV_Nodes node, uint32 team)
void BattleGroundAV::DefendNode(BG_AV_Nodes node, BattleGroundTeamIndex teamIdx)
{
MANGOS_ASSERT(team < 3); // alliance:0, horde:1, neutral:2
MANGOS_ASSERT(m_Nodes[node].TotalOwner == team);
MANGOS_ASSERT(m_Nodes[node].Owner != team);
MANGOS_ASSERT(m_Nodes[node].TotalOwner == teamIdx);
MANGOS_ASSERT(m_Nodes[node].Owner != teamIdx);
MANGOS_ASSERT(m_Nodes[node].State != POINT_CONTROLLED);
m_Nodes[node].PrevOwner = m_Nodes[node].Owner;
m_Nodes[node].Owner = team;
m_Nodes[node].Owner = BattleGroundAVTeamIndex(teamIdx);
m_Nodes[node].PrevState = m_Nodes[node].State;
m_Nodes[node].State = POINT_CONTROLLED;
m_Nodes[node].Timer = 0;
@ -804,10 +798,10 @@ void BattleGroundAV::Reset()
for(uint8 i = 0; i < BG_AV_MAX_MINES; i++)
{
m_Mine_Owner[i] = BG_AV_NEUTRAL_TEAM;
m_Mine_Owner[i] = BG_AV_TEAM_NEUTRAL;
m_Mine_PrevOwner[i] = m_Mine_Owner[i];
m_ActiveEvents[BG_AV_MINE_BOSSES+ i] = BG_AV_NEUTRAL_TEAM;
m_ActiveEvents[BG_AV_MINE_EVENT + i] = BG_AV_NEUTRAL_TEAM;
m_ActiveEvents[BG_AV_MINE_BOSSES+ i] = BG_AV_TEAM_NEUTRAL;
m_ActiveEvents[BG_AV_MINE_EVENT + i] = BG_AV_TEAM_NEUTRAL;
m_Mine_Timer[i] = BG_AV_MINE_TICK_TIMER;
}
@ -820,15 +814,15 @@ void BattleGroundAV::Reset()
m_ActiveEvents[BG_AV_MARSHAL_A_SOUTH + i - BG_AV_NODES_DUNBALDAR_SOUTH] = 0;
for(BG_AV_Nodes i = BG_AV_NODES_FIRSTAID_STATION; i <= BG_AV_NODES_STONEHEART_GRAVE; ++i) // alliance graves
InitNode(i, BG_TEAM_ALLIANCE, false);
InitNode(i, BG_AV_TEAM_ALLIANCE, false);
for(BG_AV_Nodes i = BG_AV_NODES_DUNBALDAR_SOUTH; i <= BG_AV_NODES_STONEHEART_BUNKER; ++i) // alliance towers
InitNode(i, BG_TEAM_ALLIANCE, true);
InitNode(i, BG_AV_TEAM_ALLIANCE, true);
for(BG_AV_Nodes i = BG_AV_NODES_ICEBLOOD_GRAVE; i <= BG_AV_NODES_FROSTWOLF_HUT; ++i) // horde graves
InitNode(i, BG_TEAM_HORDE, false);
InitNode(i, BG_AV_TEAM_HORDE, false);
for(BG_AV_Nodes i = BG_AV_NODES_ICEBLOOD_TOWER; i <= BG_AV_NODES_FROSTWOLF_WTOWER; ++i) // horde towers
InitNode(i, BG_TEAM_HORDE, true);
InitNode(i, BG_AV_TEAM_HORDE, true);
InitNode(BG_AV_NODES_SNOWFALL_GRAVE, BG_AV_NEUTRAL_TEAM, false); // give snowfall neutral owner
InitNode(BG_AV_NODES_SNOWFALL_GRAVE, BG_AV_TEAM_NEUTRAL, false); // give snowfall neutral owner
}

View file

@ -88,7 +88,6 @@ enum BG_AV_OTHER_VALUES
BG_AV_SOUTH_MINE = 1,
BG_AV_MINE_TICK_TIMER = 45000,
BG_AV_MINE_RECLAIM_TIMER = 1200000, // TODO: get the right value.. this is currently 20 minutes
BG_AV_NEUTRAL_TEAM = 2, // this is the neutral owner of snowfall
BG_AV_FACTION_A = 730,
BG_AV_FACTION_H = 729,
};
@ -202,8 +201,20 @@ enum BG_AV_WorldStates
AV_SNOWFALL_N = 1966,
};
// special version with more wide values range that BattleGroundTeamIndex
// BattleGroundAVTeamIndex <- BattleGroundTeamIndex cast safe
// BattleGroundAVTeamIndex -> BattleGroundTeamIndex cast safe and array with BG_TEAMS_COUNT elements must checked != BG_AV_TEAM_NEUTRAL before used
enum BattleGroundAVTeamIndex
{
BG_AV_TEAM_ALLIANCE = BG_TEAM_ALLIANCE,
BG_AV_TEAM_HORDE = BG_TEAM_HORDE,
BG_AV_TEAM_NEUTRAL = 2, // this is the neutral owner of snowfall
};
#define BG_AV_TEAMS_COUNT 3
// alliance_control horde_control neutral_control
const uint32 BG_AV_MineWorldStates[2][3] = {
const uint32 BG_AV_MineWorldStates[2][BG_AV_TEAMS_COUNT] = {
{1358, 1359, 1360},
{1355, 1356, 1357}
};
@ -272,9 +283,9 @@ enum BG_AV_QuestIds
struct BG_AV_NodeInfo
{
uint32 TotalOwner;
uint32 Owner;
uint32 PrevOwner;
BattleGroundAVTeamIndex TotalOwner;
BattleGroundAVTeamIndex Owner;
BattleGroundAVTeamIndex PrevOwner;
BG_AV_States State;
BG_AV_States PrevState;
uint32 Timer;
@ -320,7 +331,7 @@ class BattleGroundAV : public BattleGround
virtual void Reset();
/*general stuff*/
void UpdateScore(BattleGroundTeamId team, int32 points);
void UpdateScore(BattleGroundTeamIndex teamIdx, int32 points);
void UpdatePlayerScore(Player *Source, uint32 type, uint32 value);
/*handle stuff*/ // these are functions which get called from extern scripts
@ -334,16 +345,17 @@ class BattleGroundAV : public BattleGround
virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player *plr);
static BattleGroundAVTeamIndex GetAVTeamIndexByTeamId(uint32 Team) { return BattleGroundAVTeamIndex(GetTeamIndexByTeamId(Team)); }
private:
/* Nodes occupying */
void EventPlayerAssaultsPoint(Player* player, BG_AV_Nodes node);
void EventPlayerDefendsPoint(Player* player, BG_AV_Nodes node);
void EventPlayerDestroyedPoint(BG_AV_Nodes node);
void AssaultNode(BG_AV_Nodes node, uint32 team);
void AssaultNode(BG_AV_Nodes node, BattleGroundTeamIndex teamIdx);
void DestroyNode(BG_AV_Nodes node);
void InitNode(BG_AV_Nodes node, uint32 team, bool tower);
void DefendNode(BG_AV_Nodes node, uint32 team);
void InitNode(BG_AV_Nodes node, BattleGroundAVTeamIndex teamIdx, bool tower);
void DefendNode(BG_AV_Nodes node, BattleGroundTeamIndex teamIdx);
void PopulateNode(BG_AV_Nodes node);
@ -352,10 +364,10 @@ class BattleGroundAV : public BattleGround
const bool IsGrave(BG_AV_Nodes node) { return (node == BG_AV_NODES_ERROR)? false : !m_Nodes[node].Tower; }
/*mine*/
void ChangeMineOwner(uint8 mine, uint32 team);
void ChangeMineOwner(uint8 mine, BattleGroundAVTeamIndex teamIdx);
/*worldstates*/
uint8 GetWorldStateType(uint8 state, uint32 team) const { return team * BG_AV_MAX_STATES + state; }
uint8 GetWorldStateType(uint8 state, BattleGroundAVTeamIndex teamIdx) const { return teamIdx * BG_AV_MAX_STATES + state; }
void SendMineWorldStates(uint32 mine);
void UpdateNodeWorldState(BG_AV_Nodes node);
@ -364,13 +376,13 @@ class BattleGroundAV : public BattleGround
BG_AV_NodeInfo m_Nodes[BG_AV_NODES_MAX];
int8 m_Mine_Owner[BG_AV_MAX_MINES];
int8 m_Mine_PrevOwner[BG_AV_MAX_MINES]; // only for worldstates needed
// only for worldstates needed
BattleGroundAVTeamIndex m_Mine_Owner[BG_AV_MAX_MINES];
BattleGroundAVTeamIndex m_Mine_PrevOwner[BG_AV_MAX_MINES];
int32 m_Mine_Timer[BG_AV_MAX_MINES];
uint32 m_Mine_Reclaim_Timer[BG_AV_MAX_MINES];
bool m_IsInformedNearLose[BG_TEAMS_COUNT];
bool m_captainAlive[BG_TEAMS_COUNT];
uint32 m_HonorMapComplete;
uint32 m_RepTowerDestruction;

View file

@ -113,7 +113,7 @@ void BattleGroundEY::StartingEventOpenDoors()
void BattleGroundEY::AddPoints(uint32 Team, uint32 Points)
{
BattleGroundTeamId team_index = GetTeamIndexByTeamId(Team);
BattleGroundTeamIndex team_index = GetTeamIndexByTeamId(Team);
m_TeamScores[team_index] += Points;
m_HonorScoreTics[team_index] += Points;
if (m_HonorScoreTics[team_index] >= m_HonorTics )

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "10780"
#define REVISION_NR "10781"
#endif // __REVISION_NR_H__