mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-23 13:46:24 +00:00
converted all tabs to 4 spaces
This commit is contained in:
@@ -20,12 +20,12 @@ BattlegroundAB::BattlegroundAB()
|
||||
BgObjects.resize(BG_AB_OBJECT_MAX);
|
||||
BgCreatures.resize(BG_AB_ALL_NODES_COUNT + BG_AB_DYNAMIC_NODES_COUNT); // xinef: +BG_AB_DYNAMIC_NODES_COUNT buff triggers
|
||||
|
||||
_controlledPoints[TEAM_ALLIANCE] = 0;
|
||||
_controlledPoints[TEAM_HORDE] = 0;
|
||||
_controlledPoints[TEAM_ALLIANCE] = 0;
|
||||
_controlledPoints[TEAM_HORDE] = 0;
|
||||
_teamScores500Disadvantage[TEAM_ALLIANCE] = false;
|
||||
_teamScores500Disadvantage[TEAM_HORDE] = false;
|
||||
_honorTics = 0;
|
||||
_reputationTics = 0;
|
||||
_teamScores500Disadvantage[TEAM_HORDE] = false;
|
||||
_honorTics = 0;
|
||||
_reputationTics = 0;
|
||||
|
||||
StartMessageIds[BG_STARTING_EVENT_FIRST] = LANG_BG_AB_START_TWO_MINUTES;
|
||||
StartMessageIds[BG_STARTING_EVENT_SECOND] = LANG_BG_AB_START_ONE_MINUTE;
|
||||
@@ -41,77 +41,77 @@ void BattlegroundAB::PostUpdateImpl(uint32 diff)
|
||||
{
|
||||
if (GetStatus() == STATUS_IN_PROGRESS)
|
||||
{
|
||||
_bgEvents.Update(diff);
|
||||
while (uint32 eventId =_bgEvents.ExecuteEvent())
|
||||
switch (eventId)
|
||||
{
|
||||
case BG_AB_EVENT_UPDATE_BANNER_STABLE:
|
||||
case BG_AB_EVENT_UPDATE_BANNER_FARM:
|
||||
case BG_AB_EVENT_UPDATE_BANNER_BLACKSMITH:
|
||||
case BG_AB_EVENT_UPDATE_BANNER_LUMBERMILL:
|
||||
case BG_AB_EVENT_UPDATE_BANNER_GOLDMINE:
|
||||
CreateBanner(eventId - BG_AB_EVENT_UPDATE_BANNER_STABLE, false);
|
||||
break;
|
||||
case BG_AB_EVENT_CAPTURE_STABLE:
|
||||
case BG_AB_EVENT_CAPTURE_FARM:
|
||||
case BG_AB_EVENT_CAPTURE_BLACKSMITH:
|
||||
case BG_AB_EVENT_CAPTURE_LUMBERMILL:
|
||||
case BG_AB_EVENT_CAPTURE_GOLDMINE:
|
||||
{
|
||||
uint8 node = eventId - BG_AB_EVENT_CAPTURE_STABLE;
|
||||
TeamId teamId = _capturePointInfo[node]._state == BG_AB_NODE_STATE_ALLY_CONTESTED ? TEAM_ALLIANCE : TEAM_HORDE;
|
||||
DeleteBanner(node);
|
||||
_capturePointInfo[node]._ownerTeamId = teamId;
|
||||
_capturePointInfo[node]._state = teamId == TEAM_ALLIANCE ? BG_AB_NODE_STATE_ALLY_OCCUPIED : BG_AB_NODE_STATE_HORDE_OCCUPIED;
|
||||
_capturePointInfo[node]._captured = true;
|
||||
_bgEvents.Update(diff);
|
||||
while (uint32 eventId =_bgEvents.ExecuteEvent())
|
||||
switch (eventId)
|
||||
{
|
||||
case BG_AB_EVENT_UPDATE_BANNER_STABLE:
|
||||
case BG_AB_EVENT_UPDATE_BANNER_FARM:
|
||||
case BG_AB_EVENT_UPDATE_BANNER_BLACKSMITH:
|
||||
case BG_AB_EVENT_UPDATE_BANNER_LUMBERMILL:
|
||||
case BG_AB_EVENT_UPDATE_BANNER_GOLDMINE:
|
||||
CreateBanner(eventId - BG_AB_EVENT_UPDATE_BANNER_STABLE, false);
|
||||
break;
|
||||
case BG_AB_EVENT_CAPTURE_STABLE:
|
||||
case BG_AB_EVENT_CAPTURE_FARM:
|
||||
case BG_AB_EVENT_CAPTURE_BLACKSMITH:
|
||||
case BG_AB_EVENT_CAPTURE_LUMBERMILL:
|
||||
case BG_AB_EVENT_CAPTURE_GOLDMINE:
|
||||
{
|
||||
uint8 node = eventId - BG_AB_EVENT_CAPTURE_STABLE;
|
||||
TeamId teamId = _capturePointInfo[node]._state == BG_AB_NODE_STATE_ALLY_CONTESTED ? TEAM_ALLIANCE : TEAM_HORDE;
|
||||
DeleteBanner(node);
|
||||
_capturePointInfo[node]._ownerTeamId = teamId;
|
||||
_capturePointInfo[node]._state = teamId == TEAM_ALLIANCE ? BG_AB_NODE_STATE_ALLY_OCCUPIED : BG_AB_NODE_STATE_HORDE_OCCUPIED;
|
||||
_capturePointInfo[node]._captured = true;
|
||||
|
||||
CreateBanner(node, false);
|
||||
NodeOccupied(node);
|
||||
SendNodeUpdate(node);
|
||||
|
||||
SendMessage2ToAll(LANG_BG_AB_NODE_TAKEN, teamId == TEAM_ALLIANCE ? CHAT_MSG_BG_SYSTEM_ALLIANCE : CHAT_MSG_BG_SYSTEM_HORDE, NULL, teamId == TEAM_ALLIANCE ? LANG_BG_AB_ALLY : LANG_BG_AB_HORDE, LANG_BG_AB_NODE_STABLES + node);
|
||||
PlaySoundToAll(teamId == TEAM_ALLIANCE ? BG_AB_SOUND_NODE_CAPTURED_ALLIANCE : BG_AB_SOUND_NODE_CAPTURED_HORDE);
|
||||
break;
|
||||
}
|
||||
case BG_AB_EVENT_ALLIANCE_TICK:
|
||||
case BG_AB_EVENT_HORDE_TICK:
|
||||
{
|
||||
TeamId teamId = TeamId(eventId - BG_AB_EVENT_ALLIANCE_TICK);
|
||||
uint8 controlledPoints = _controlledPoints[teamId];
|
||||
if (controlledPoints == 0)
|
||||
{
|
||||
_bgEvents.ScheduleEvent(eventId, 3000);
|
||||
break;
|
||||
}
|
||||
SendMessage2ToAll(LANG_BG_AB_NODE_TAKEN, teamId == TEAM_ALLIANCE ? CHAT_MSG_BG_SYSTEM_ALLIANCE : CHAT_MSG_BG_SYSTEM_HORDE, NULL, teamId == TEAM_ALLIANCE ? LANG_BG_AB_ALLY : LANG_BG_AB_HORDE, LANG_BG_AB_NODE_STABLES + node);
|
||||
PlaySoundToAll(teamId == TEAM_ALLIANCE ? BG_AB_SOUND_NODE_CAPTURED_ALLIANCE : BG_AB_SOUND_NODE_CAPTURED_HORDE);
|
||||
break;
|
||||
}
|
||||
case BG_AB_EVENT_ALLIANCE_TICK:
|
||||
case BG_AB_EVENT_HORDE_TICK:
|
||||
{
|
||||
TeamId teamId = TeamId(eventId - BG_AB_EVENT_ALLIANCE_TICK);
|
||||
uint8 controlledPoints = _controlledPoints[teamId];
|
||||
if (controlledPoints == 0)
|
||||
{
|
||||
_bgEvents.ScheduleEvent(eventId, 3000);
|
||||
break;
|
||||
}
|
||||
|
||||
uint8 honorRewards = uint8(m_TeamScores[teamId] / _honorTics);
|
||||
uint8 reputationRewards = uint8(m_TeamScores[teamId] / _reputationTics);
|
||||
uint8 information = uint8(m_TeamScores[teamId] / BG_AB_WARNING_NEAR_VICTORY_SCORE);
|
||||
m_TeamScores[teamId] += BG_AB_TickPoints[controlledPoints];
|
||||
if (m_TeamScores[teamId] > BG_AB_MAX_TEAM_SCORE)
|
||||
m_TeamScores[teamId] = BG_AB_MAX_TEAM_SCORE;
|
||||
uint8 honorRewards = uint8(m_TeamScores[teamId] / _honorTics);
|
||||
uint8 reputationRewards = uint8(m_TeamScores[teamId] / _reputationTics);
|
||||
uint8 information = uint8(m_TeamScores[teamId] / BG_AB_WARNING_NEAR_VICTORY_SCORE);
|
||||
m_TeamScores[teamId] += BG_AB_TickPoints[controlledPoints];
|
||||
if (m_TeamScores[teamId] > BG_AB_MAX_TEAM_SCORE)
|
||||
m_TeamScores[teamId] = BG_AB_MAX_TEAM_SCORE;
|
||||
|
||||
if (honorRewards < uint8(m_TeamScores[teamId] / _honorTics))
|
||||
RewardHonorToTeam(GetBonusHonorFromKill(1), teamId);
|
||||
if (reputationRewards < uint8(m_TeamScores[teamId] / _reputationTics))
|
||||
RewardReputationToTeam(teamId == TEAM_ALLIANCE ? 509 : 510, 10, teamId);
|
||||
if (information < uint8(m_TeamScores[teamId] / BG_AB_WARNING_NEAR_VICTORY_SCORE))
|
||||
{
|
||||
SendMessageToAll(teamId == TEAM_ALLIANCE ? LANG_BG_AB_A_NEAR_VICTORY : LANG_BG_AB_H_NEAR_VICTORY, CHAT_MSG_BG_SYSTEM_NEUTRAL);
|
||||
PlaySoundToAll(BG_AB_SOUND_NEAR_VICTORY);
|
||||
}
|
||||
if (honorRewards < uint8(m_TeamScores[teamId] / _honorTics))
|
||||
RewardHonorToTeam(GetBonusHonorFromKill(1), teamId);
|
||||
if (reputationRewards < uint8(m_TeamScores[teamId] / _reputationTics))
|
||||
RewardReputationToTeam(teamId == TEAM_ALLIANCE ? 509 : 510, 10, teamId);
|
||||
if (information < uint8(m_TeamScores[teamId] / BG_AB_WARNING_NEAR_VICTORY_SCORE))
|
||||
{
|
||||
SendMessageToAll(teamId == TEAM_ALLIANCE ? LANG_BG_AB_A_NEAR_VICTORY : LANG_BG_AB_H_NEAR_VICTORY, CHAT_MSG_BG_SYSTEM_NEUTRAL);
|
||||
PlaySoundToAll(BG_AB_SOUND_NEAR_VICTORY);
|
||||
}
|
||||
|
||||
UpdateWorldState(teamId == TEAM_ALLIANCE ? BG_AB_OP_RESOURCES_ALLY : BG_AB_OP_RESOURCES_HORDE, m_TeamScores[teamId]);
|
||||
if (m_TeamScores[teamId] > m_TeamScores[GetOtherTeamId(teamId)] + 500)
|
||||
_teamScores500Disadvantage[GetOtherTeamId(teamId)] = true;
|
||||
if (m_TeamScores[teamId] >= BG_AB_MAX_TEAM_SCORE)
|
||||
EndBattleground(teamId);
|
||||
UpdateWorldState(teamId == TEAM_ALLIANCE ? BG_AB_OP_RESOURCES_ALLY : BG_AB_OP_RESOURCES_HORDE, m_TeamScores[teamId]);
|
||||
if (m_TeamScores[teamId] > m_TeamScores[GetOtherTeamId(teamId)] + 500)
|
||||
_teamScores500Disadvantage[GetOtherTeamId(teamId)] = true;
|
||||
if (m_TeamScores[teamId] >= BG_AB_MAX_TEAM_SCORE)
|
||||
EndBattleground(teamId);
|
||||
|
||||
_bgEvents.ScheduleEvent(eventId, BG_AB_TickIntervals[controlledPoints]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
_bgEvents.ScheduleEvent(eventId, BG_AB_TickIntervals[controlledPoints]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BattlegroundAB::StartingEventCloseDoors()
|
||||
@@ -140,8 +140,8 @@ void BattlegroundAB::StartingEventOpenDoors()
|
||||
DoorOpen(BG_AB_OBJECT_GATE_A);
|
||||
DoorOpen(BG_AB_OBJECT_GATE_H);
|
||||
StartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, BG_AB_EVENT_START_BATTLE);
|
||||
_bgEvents.ScheduleEvent(BG_AB_EVENT_ALLIANCE_TICK, 3000);
|
||||
_bgEvents.ScheduleEvent(BG_AB_EVENT_HORDE_TICK, 3000);
|
||||
_bgEvents.ScheduleEvent(BG_AB_EVENT_ALLIANCE_TICK, 3000);
|
||||
_bgEvents.ScheduleEvent(BG_AB_EVENT_HORDE_TICK, 3000);
|
||||
}
|
||||
|
||||
void BattlegroundAB::AddPlayer(Player* player)
|
||||
@@ -152,7 +152,7 @@ void BattlegroundAB::AddPlayer(Player* player)
|
||||
|
||||
void BattlegroundAB::RemovePlayer(Player* player)
|
||||
{
|
||||
player->SetPhaseMask(1, false);
|
||||
player->SetPhaseMask(1, false);
|
||||
}
|
||||
|
||||
void BattlegroundAB::HandleAreaTrigger(Player* player, uint32 trigger)
|
||||
@@ -194,26 +194,26 @@ void BattlegroundAB::CreateBanner(uint8 node, bool delay)
|
||||
return;
|
||||
}
|
||||
|
||||
SpawnBGObject(node*BG_AB_OBJECTS_PER_NODE + _capturePointInfo[node]._state, RESPAWN_IMMEDIATELY);
|
||||
SpawnBGObject(node*BG_AB_OBJECTS_PER_NODE + BG_AB_OBJECT_AURA_ALLY + _capturePointInfo[node]._ownerTeamId, RESPAWN_IMMEDIATELY);
|
||||
SpawnBGObject(node*BG_AB_OBJECTS_PER_NODE + _capturePointInfo[node]._state, RESPAWN_IMMEDIATELY);
|
||||
SpawnBGObject(node*BG_AB_OBJECTS_PER_NODE + BG_AB_OBJECT_AURA_ALLY + _capturePointInfo[node]._ownerTeamId, RESPAWN_IMMEDIATELY);
|
||||
}
|
||||
|
||||
void BattlegroundAB::DeleteBanner(uint8 node)
|
||||
{
|
||||
SpawnBGObject(node*BG_AB_OBJECTS_PER_NODE + _capturePointInfo[node]._state, RESPAWN_ONE_DAY);
|
||||
SpawnBGObject(node*BG_AB_OBJECTS_PER_NODE + BG_AB_OBJECT_AURA_ALLY + _capturePointInfo[node]._ownerTeamId, RESPAWN_ONE_DAY);
|
||||
SpawnBGObject(node*BG_AB_OBJECTS_PER_NODE + _capturePointInfo[node]._state, RESPAWN_ONE_DAY);
|
||||
SpawnBGObject(node*BG_AB_OBJECTS_PER_NODE + BG_AB_OBJECT_AURA_ALLY + _capturePointInfo[node]._ownerTeamId, RESPAWN_ONE_DAY);
|
||||
}
|
||||
|
||||
void BattlegroundAB::FillInitialWorldStates(WorldPacket& data)
|
||||
{
|
||||
for (uint8 node = 0; node < BG_AB_DYNAMIC_NODES_COUNT; ++node)
|
||||
{
|
||||
if (_capturePointInfo[node]._state == BG_AB_NODE_STATE_NEUTRAL)
|
||||
data << uint32(_capturePointInfo[node]._iconNone) << uint32(1);
|
||||
{
|
||||
if (_capturePointInfo[node]._state == BG_AB_NODE_STATE_NEUTRAL)
|
||||
data << uint32(_capturePointInfo[node]._iconNone) << uint32(1);
|
||||
|
||||
for (uint8 i = BG_AB_NODE_STATE_ALLY_OCCUPIED; i <= BG_AB_NODE_STATE_HORDE_CONTESTED; ++i)
|
||||
data << uint32(_capturePointInfo[node]._iconCapture + i-1) << uint32(_capturePointInfo[node]._state == i);
|
||||
}
|
||||
for (uint8 i = BG_AB_NODE_STATE_ALLY_OCCUPIED; i <= BG_AB_NODE_STATE_HORDE_CONTESTED; ++i)
|
||||
data << uint32(_capturePointInfo[node]._iconCapture + i-1) << uint32(_capturePointInfo[node]._state == i);
|
||||
}
|
||||
|
||||
data << uint32(BG_AB_OP_OCCUPIED_BASES_ALLY) << uint32(_controlledPoints[TEAM_ALLIANCE]);
|
||||
data << uint32(BG_AB_OP_OCCUPIED_BASES_HORDE) << uint32(_controlledPoints[TEAM_HORDE]);
|
||||
@@ -226,9 +226,9 @@ void BattlegroundAB::FillInitialWorldStates(WorldPacket& data)
|
||||
|
||||
void BattlegroundAB::SendNodeUpdate(uint8 node)
|
||||
{
|
||||
UpdateWorldState(_capturePointInfo[node]._iconNone, 0);
|
||||
for (uint8 i = BG_AB_NODE_STATE_ALLY_OCCUPIED; i <= BG_AB_NODE_STATE_HORDE_CONTESTED; ++i)
|
||||
UpdateWorldState(_capturePointInfo[node]._iconCapture + i-1, _capturePointInfo[node]._state == i);
|
||||
UpdateWorldState(_capturePointInfo[node]._iconNone, 0);
|
||||
for (uint8 i = BG_AB_NODE_STATE_ALLY_OCCUPIED; i <= BG_AB_NODE_STATE_HORDE_CONTESTED; ++i)
|
||||
UpdateWorldState(_capturePointInfo[node]._iconCapture + i-1, _capturePointInfo[node]._state == i);
|
||||
|
||||
UpdateWorldState(BG_AB_OP_OCCUPIED_BASES_ALLY, _controlledPoints[TEAM_ALLIANCE]);
|
||||
UpdateWorldState(BG_AB_OP_OCCUPIED_BASES_HORDE, _controlledPoints[TEAM_HORDE]);
|
||||
@@ -236,16 +236,16 @@ void BattlegroundAB::SendNodeUpdate(uint8 node)
|
||||
|
||||
void BattlegroundAB::NodeOccupied(uint8 node)
|
||||
{
|
||||
ApplyPhaseMask();
|
||||
AddSpiritGuide(node, BG_AB_SpiritGuidePos[node][0], BG_AB_SpiritGuidePos[node][1], BG_AB_SpiritGuidePos[node][2], BG_AB_SpiritGuidePos[node][3], _capturePointInfo[node]._ownerTeamId);
|
||||
ApplyPhaseMask();
|
||||
AddSpiritGuide(node, BG_AB_SpiritGuidePos[node][0], BG_AB_SpiritGuidePos[node][1], BG_AB_SpiritGuidePos[node][2], BG_AB_SpiritGuidePos[node][3], _capturePointInfo[node]._ownerTeamId);
|
||||
|
||||
++_controlledPoints[_capturePointInfo[node]._ownerTeamId];
|
||||
++_controlledPoints[_capturePointInfo[node]._ownerTeamId];
|
||||
if (_controlledPoints[_capturePointInfo[node]._ownerTeamId] >= 5)
|
||||
CastSpellOnTeam(SPELL_AB_QUEST_REWARD_5_BASES, _capturePointInfo[node]._ownerTeamId);
|
||||
if (_controlledPoints[_capturePointInfo[node]._ownerTeamId] >= 4)
|
||||
CastSpellOnTeam(SPELL_AB_QUEST_REWARD_4_BASES, _capturePointInfo[node]._ownerTeamId);
|
||||
|
||||
Creature* trigger = GetBgMap()->GetCreature(BgCreatures[BG_AB_ALL_NODES_COUNT + node]);
|
||||
Creature* trigger = GetBgMap()->GetCreature(BgCreatures[BG_AB_ALL_NODES_COUNT + node]);
|
||||
if (!trigger)
|
||||
trigger = AddCreature(WORLD_TRIGGER, BG_AB_ALL_NODES_COUNT + node, BG_AB_NodePositions[node][0], BG_AB_NodePositions[node][1], BG_AB_NodePositions[node][2], BG_AB_NodePositions[node][3]);
|
||||
|
||||
@@ -258,10 +258,10 @@ void BattlegroundAB::NodeOccupied(uint8 node)
|
||||
|
||||
void BattlegroundAB::NodeDeoccupied(uint8 node)
|
||||
{
|
||||
--_controlledPoints[_capturePointInfo[node]._ownerTeamId];
|
||||
--_controlledPoints[_capturePointInfo[node]._ownerTeamId];
|
||||
|
||||
_capturePointInfo[node]._ownerTeamId = TEAM_NEUTRAL;
|
||||
RelocateDeadPlayers(BgCreatures[node]);
|
||||
_capturePointInfo[node]._ownerTeamId = TEAM_NEUTRAL;
|
||||
RelocateDeadPlayers(BgCreatures[node]);
|
||||
|
||||
DelCreature(node); // Delete spirit healer
|
||||
DelCreature(BG_AB_ALL_NODES_COUNT + node); // Delete aura trigger
|
||||
@@ -270,90 +270,90 @@ void BattlegroundAB::NodeDeoccupied(uint8 node)
|
||||
void BattlegroundAB::EventPlayerClickedOnFlag(Player* player, GameObject* gameObject)
|
||||
{
|
||||
if (GetStatus() != STATUS_IN_PROGRESS || !player->IsWithinDistInMap(gameObject, 10.0f))
|
||||
return;
|
||||
return;
|
||||
|
||||
uint8 node = BG_AB_NODE_STABLES;
|
||||
for (; node < BG_AB_DYNAMIC_NODES_COUNT; ++node)
|
||||
if (player->GetDistance2d(BG_AB_NodePositions[node][0], BG_AB_NodePositions[node][1]) < 10.0f)
|
||||
break;
|
||||
for (; node < BG_AB_DYNAMIC_NODES_COUNT; ++node)
|
||||
if (player->GetDistance2d(BG_AB_NodePositions[node][0], BG_AB_NodePositions[node][1]) < 10.0f)
|
||||
break;
|
||||
|
||||
if (node == BG_AB_DYNAMIC_NODES_COUNT || _capturePointInfo[node]._ownerTeamId == player->GetTeamId() ||
|
||||
(_capturePointInfo[node]._state == BG_AB_NODE_STATE_ALLY_CONTESTED && player->GetTeamId() == TEAM_ALLIANCE) ||
|
||||
(_capturePointInfo[node]._state == BG_AB_NODE_STATE_HORDE_CONTESTED && player->GetTeamId() == TEAM_HORDE))
|
||||
(_capturePointInfo[node]._state == BG_AB_NODE_STATE_ALLY_CONTESTED && player->GetTeamId() == TEAM_ALLIANCE) ||
|
||||
(_capturePointInfo[node]._state == BG_AB_NODE_STATE_HORDE_CONTESTED && player->GetTeamId() == TEAM_HORDE))
|
||||
return;
|
||||
|
||||
player->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT);
|
||||
|
||||
uint32 sound = 0;
|
||||
uint32 message = 0;
|
||||
uint32 message2 = 0;
|
||||
DeleteBanner(node);
|
||||
uint32 message = 0;
|
||||
uint32 message2 = 0;
|
||||
DeleteBanner(node);
|
||||
CreateBanner(node, true);
|
||||
|
||||
if (_capturePointInfo[node]._state == BG_AB_NODE_STATE_NEUTRAL)
|
||||
if (_capturePointInfo[node]._state == BG_AB_NODE_STATE_NEUTRAL)
|
||||
{
|
||||
player->KilledMonsterCredit(BG_AB_QUEST_CREDIT_BASE + node, 0);
|
||||
player->KilledMonsterCredit(BG_AB_QUEST_CREDIT_BASE + node, 0);
|
||||
UpdatePlayerScore(player, SCORE_BASES_ASSAULTED, 1);
|
||||
_capturePointInfo[node]._state = BG_AB_NODE_STATE_ALLY_CONTESTED + player->GetTeamId();
|
||||
_capturePointInfo[node]._ownerTeamId = TEAM_NEUTRAL;
|
||||
_bgEvents.RescheduleEvent(BG_AB_EVENT_CAPTURE_STABLE + node, BG_AB_FLAG_CAPTURING_TIME);
|
||||
_capturePointInfo[node]._state = BG_AB_NODE_STATE_ALLY_CONTESTED + player->GetTeamId();
|
||||
_capturePointInfo[node]._ownerTeamId = TEAM_NEUTRAL;
|
||||
_bgEvents.RescheduleEvent(BG_AB_EVENT_CAPTURE_STABLE + node, BG_AB_FLAG_CAPTURING_TIME);
|
||||
sound = BG_AB_SOUND_NODE_CLAIMED;
|
||||
message = LANG_BG_AB_NODE_CLAIMED;
|
||||
message2 = player->GetTeamId() == TEAM_ALLIANCE ? LANG_BG_AB_ALLY : LANG_BG_AB_HORDE;
|
||||
message = LANG_BG_AB_NODE_CLAIMED;
|
||||
message2 = player->GetTeamId() == TEAM_ALLIANCE ? LANG_BG_AB_ALLY : LANG_BG_AB_HORDE;
|
||||
}
|
||||
else if (_capturePointInfo[node]._state == BG_AB_NODE_STATE_ALLY_CONTESTED || _capturePointInfo[node]._state == BG_AB_NODE_STATE_HORDE_CONTESTED)
|
||||
{
|
||||
if (!_capturePointInfo[node]._captured)
|
||||
if (!_capturePointInfo[node]._captured)
|
||||
{
|
||||
player->KilledMonsterCredit(BG_AB_QUEST_CREDIT_BASE + node, 0);
|
||||
player->KilledMonsterCredit(BG_AB_QUEST_CREDIT_BASE + node, 0);
|
||||
UpdatePlayerScore(player, SCORE_BASES_ASSAULTED, 1);
|
||||
_capturePointInfo[node]._state = BG_AB_NODE_STATE_ALLY_CONTESTED + player->GetTeamId();
|
||||
_capturePointInfo[node]._ownerTeamId = TEAM_NEUTRAL;
|
||||
_bgEvents.RescheduleEvent(BG_AB_EVENT_CAPTURE_STABLE + node, BG_AB_FLAG_CAPTURING_TIME);
|
||||
_capturePointInfo[node]._state = BG_AB_NODE_STATE_ALLY_CONTESTED + player->GetTeamId();
|
||||
_capturePointInfo[node]._ownerTeamId = TEAM_NEUTRAL;
|
||||
_bgEvents.RescheduleEvent(BG_AB_EVENT_CAPTURE_STABLE + node, BG_AB_FLAG_CAPTURING_TIME);
|
||||
message = LANG_BG_AB_NODE_ASSAULTED;
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdatePlayerScore(player, SCORE_BASES_DEFENDED, 1);
|
||||
_capturePointInfo[node]._state = BG_AB_NODE_STATE_ALLY_OCCUPIED + player->GetTeamId();
|
||||
_capturePointInfo[node]._ownerTeamId = player->GetTeamId();
|
||||
_bgEvents.CancelEvent(BG_AB_EVENT_CAPTURE_STABLE + node);
|
||||
_capturePointInfo[node]._state = BG_AB_NODE_STATE_ALLY_OCCUPIED + player->GetTeamId();
|
||||
_capturePointInfo[node]._ownerTeamId = player->GetTeamId();
|
||||
_bgEvents.CancelEvent(BG_AB_EVENT_CAPTURE_STABLE + node);
|
||||
NodeOccupied(node); // after setting team owner
|
||||
message = LANG_BG_AB_NODE_DEFENDED;
|
||||
}
|
||||
sound = player->GetTeamId() == TEAM_ALLIANCE ? BG_AB_SOUND_NODE_ASSAULTED_ALLIANCE : BG_AB_SOUND_NODE_ASSAULTED_HORDE;
|
||||
sound = player->GetTeamId() == TEAM_ALLIANCE ? BG_AB_SOUND_NODE_ASSAULTED_ALLIANCE : BG_AB_SOUND_NODE_ASSAULTED_HORDE;
|
||||
}
|
||||
else
|
||||
{
|
||||
player->KilledMonsterCredit(BG_AB_QUEST_CREDIT_BASE + node, 0);
|
||||
player->KilledMonsterCredit(BG_AB_QUEST_CREDIT_BASE + node, 0);
|
||||
UpdatePlayerScore(player, SCORE_BASES_ASSAULTED, 1);
|
||||
NodeDeoccupied(node); // before setting team owner to neutral
|
||||
|
||||
_capturePointInfo[node]._state = BG_AB_NODE_STATE_ALLY_CONTESTED + player->GetTeamId();
|
||||
_capturePointInfo[node]._state = BG_AB_NODE_STATE_ALLY_CONTESTED + player->GetTeamId();
|
||||
|
||||
ApplyPhaseMask();
|
||||
_bgEvents.RescheduleEvent(BG_AB_EVENT_CAPTURE_STABLE + node, BG_AB_FLAG_CAPTURING_TIME);
|
||||
ApplyPhaseMask();
|
||||
_bgEvents.RescheduleEvent(BG_AB_EVENT_CAPTURE_STABLE + node, BG_AB_FLAG_CAPTURING_TIME);
|
||||
message = LANG_BG_AB_NODE_ASSAULTED;
|
||||
sound = player->GetTeamId() == TEAM_ALLIANCE ? BG_AB_SOUND_NODE_ASSAULTED_ALLIANCE : BG_AB_SOUND_NODE_ASSAULTED_HORDE;
|
||||
}
|
||||
|
||||
SendNodeUpdate(node);
|
||||
PlaySoundToAll(sound);
|
||||
SendMessage2ToAll(message, player->GetTeamId() == TEAM_ALLIANCE ? CHAT_MSG_BG_SYSTEM_ALLIANCE : CHAT_MSG_BG_SYSTEM_HORDE, player, LANG_BG_AB_NODE_STABLES + node, message2);
|
||||
SendMessage2ToAll(message, player->GetTeamId() == TEAM_ALLIANCE ? CHAT_MSG_BG_SYSTEM_ALLIANCE : CHAT_MSG_BG_SYSTEM_HORDE, player, LANG_BG_AB_NODE_STABLES + node, message2);
|
||||
}
|
||||
|
||||
TeamId BattlegroundAB::GetPrematureWinner()
|
||||
{
|
||||
if (_controlledPoints[TEAM_ALLIANCE] > _controlledPoints[TEAM_HORDE])
|
||||
return TEAM_ALLIANCE;
|
||||
return _controlledPoints[TEAM_HORDE] > _controlledPoints[TEAM_ALLIANCE] ? TEAM_HORDE : Battleground::GetPrematureWinner();
|
||||
return _controlledPoints[TEAM_HORDE] > _controlledPoints[TEAM_ALLIANCE] ? TEAM_HORDE : Battleground::GetPrematureWinner();
|
||||
}
|
||||
|
||||
bool BattlegroundAB::SetupBattleground()
|
||||
{
|
||||
for (uint32 i = 0; i < BG_AB_DYNAMIC_NODES_COUNT; ++i)
|
||||
{
|
||||
AddObject(BG_AB_OBJECT_BANNER_NEUTRAL + BG_AB_OBJECTS_PER_NODE*i, BG_AB_OBJECTID_NODE_BANNER_0 + i, BG_AB_NodePositions[i][0], BG_AB_NodePositions[i][1], BG_AB_NodePositions[i][2], BG_AB_NodePositions[i][3], 0, 0, sin(BG_AB_NodePositions[i][3]/2), cos(BG_AB_NodePositions[i][3]/2), RESPAWN_ONE_DAY);
|
||||
AddObject(BG_AB_OBJECT_BANNER_NEUTRAL + BG_AB_OBJECTS_PER_NODE*i, BG_AB_OBJECTID_NODE_BANNER_0 + i, BG_AB_NodePositions[i][0], BG_AB_NodePositions[i][1], BG_AB_NodePositions[i][2], BG_AB_NodePositions[i][3], 0, 0, sin(BG_AB_NodePositions[i][3]/2), cos(BG_AB_NodePositions[i][3]/2), RESPAWN_ONE_DAY);
|
||||
AddObject(BG_AB_OBJECT_BANNER_ALLY + BG_AB_OBJECTS_PER_NODE*i, BG_AB_OBJECTID_BANNER_A, BG_AB_NodePositions[i][0], BG_AB_NodePositions[i][1], BG_AB_NodePositions[i][2], BG_AB_NodePositions[i][3], 0, 0, sin(BG_AB_NodePositions[i][3]/2), cos(BG_AB_NodePositions[i][3]/2), RESPAWN_ONE_DAY);
|
||||
AddObject(BG_AB_OBJECT_BANNER_HORDE + BG_AB_OBJECTS_PER_NODE*i, BG_AB_OBJECTID_BANNER_H, BG_AB_NodePositions[i][0], BG_AB_NodePositions[i][1], BG_AB_NodePositions[i][2], BG_AB_NodePositions[i][3], 0, 0, sin(BG_AB_NodePositions[i][3]/2), cos(BG_AB_NodePositions[i][3]/2), RESPAWN_ONE_DAY);
|
||||
AddObject(BG_AB_OBJECT_BANNER_CONT_A + BG_AB_OBJECTS_PER_NODE*i, BG_AB_OBJECTID_BANNER_CONT_A, BG_AB_NodePositions[i][0], BG_AB_NodePositions[i][1], BG_AB_NodePositions[i][2], BG_AB_NodePositions[i][3], 0, 0, sin(BG_AB_NodePositions[i][3]/2), cos(BG_AB_NodePositions[i][3]/2), RESPAWN_ONE_DAY);
|
||||
@@ -373,22 +373,22 @@ bool BattlegroundAB::SetupBattleground()
|
||||
AddObject(BG_AB_OBJECT_SPEEDBUFF_STABLES + 3 * i + 2, Buff_Entries[2], BG_AB_BuffPositions[i][0], BG_AB_BuffPositions[i][1], BG_AB_BuffPositions[i][2], BG_AB_BuffPositions[i][3], 0, 0, sin(BG_AB_BuffPositions[i][3]/2), cos(BG_AB_BuffPositions[i][3]/2), RESPAWN_ONE_DAY);
|
||||
}
|
||||
|
||||
AddSpiritGuide(BG_AB_SPIRIT_ALIANCE, BG_AB_SpiritGuidePos[BG_AB_SPIRIT_ALIANCE][0], BG_AB_SpiritGuidePos[BG_AB_SPIRIT_ALIANCE][1], BG_AB_SpiritGuidePos[BG_AB_SPIRIT_ALIANCE][2], BG_AB_SpiritGuidePos[BG_AB_SPIRIT_ALIANCE][3], TEAM_ALLIANCE);
|
||||
AddSpiritGuide(BG_AB_SPIRIT_HORDE, BG_AB_SpiritGuidePos[BG_AB_SPIRIT_HORDE][0], BG_AB_SpiritGuidePos[BG_AB_SPIRIT_HORDE][1], BG_AB_SpiritGuidePos[BG_AB_SPIRIT_HORDE][2], BG_AB_SpiritGuidePos[BG_AB_SPIRIT_HORDE][3], TEAM_HORDE);
|
||||
AddSpiritGuide(BG_AB_SPIRIT_ALIANCE, BG_AB_SpiritGuidePos[BG_AB_SPIRIT_ALIANCE][0], BG_AB_SpiritGuidePos[BG_AB_SPIRIT_ALIANCE][1], BG_AB_SpiritGuidePos[BG_AB_SPIRIT_ALIANCE][2], BG_AB_SpiritGuidePos[BG_AB_SPIRIT_ALIANCE][3], TEAM_ALLIANCE);
|
||||
AddSpiritGuide(BG_AB_SPIRIT_HORDE, BG_AB_SpiritGuidePos[BG_AB_SPIRIT_HORDE][0], BG_AB_SpiritGuidePos[BG_AB_SPIRIT_HORDE][1], BG_AB_SpiritGuidePos[BG_AB_SPIRIT_HORDE][2], BG_AB_SpiritGuidePos[BG_AB_SPIRIT_HORDE][3], TEAM_HORDE);
|
||||
|
||||
for (uint32 i = BG_AB_OBJECT_BANNER_NEUTRAL; i < BG_AB_OBJECT_MAX; ++i)
|
||||
if (BgObjects[i] == 0)
|
||||
{
|
||||
sLog->outErrorDb("BatteGroundAB: Failed to spawn some object Battleground not created!");
|
||||
return false;
|
||||
}
|
||||
for (uint32 i = BG_AB_OBJECT_BANNER_NEUTRAL; i < BG_AB_OBJECT_MAX; ++i)
|
||||
if (BgObjects[i] == 0)
|
||||
{
|
||||
sLog->outErrorDb("BatteGroundAB: Failed to spawn some object Battleground not created!");
|
||||
return false;
|
||||
}
|
||||
|
||||
for (uint32 i = BG_AB_SPIRIT_ALIANCE; i <= BG_AB_SPIRIT_HORDE; ++i)
|
||||
if (BgCreatures[i] == 0)
|
||||
{
|
||||
sLog->outErrorDb("BatteGroundAB: Failed to spawn spirit guides Battleground not created!");
|
||||
return false;
|
||||
}
|
||||
for (uint32 i = BG_AB_SPIRIT_ALIANCE; i <= BG_AB_SPIRIT_HORDE; ++i)
|
||||
if (BgCreatures[i] == 0)
|
||||
{
|
||||
sLog->outErrorDb("BatteGroundAB: Failed to spawn spirit guides Battleground not created!");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -398,21 +398,21 @@ void BattlegroundAB::Init()
|
||||
//call parent's class reset
|
||||
Battleground::Init();
|
||||
|
||||
_bgEvents.Reset();
|
||||
_bgEvents.Reset();
|
||||
|
||||
_honorTics = BattlegroundMgr::IsBGWeekend(GetBgTypeID()) ? BG_AB_HONOR_TICK_WEEKEND : BG_AB_HONOR_TICK_NORMAL;
|
||||
_reputationTics = BattlegroundMgr::IsBGWeekend(GetBgTypeID()) ? BG_AB_REP_TICK_WEEKEND : BG_AB_REP_TICK_NORMAL;
|
||||
_honorTics = BattlegroundMgr::IsBGWeekend(GetBgTypeID()) ? BG_AB_HONOR_TICK_WEEKEND : BG_AB_HONOR_TICK_NORMAL;
|
||||
_reputationTics = BattlegroundMgr::IsBGWeekend(GetBgTypeID()) ? BG_AB_REP_TICK_WEEKEND : BG_AB_REP_TICK_NORMAL;
|
||||
|
||||
_capturePointInfo[BG_AB_NODE_STABLES]._iconNone = BG_AB_OP_STABLE_ICON;
|
||||
_capturePointInfo[BG_AB_NODE_FARM]._iconNone = BG_AB_OP_FARM_ICON;
|
||||
_capturePointInfo[BG_AB_NODE_BLACKSMITH]._iconNone = BG_AB_OP_BLACKSMITH_ICON;
|
||||
_capturePointInfo[BG_AB_NODE_LUMBER_MILL]._iconNone = BG_AB_OP_LUMBERMILL_ICON;
|
||||
_capturePointInfo[BG_AB_NODE_GOLD_MINE]._iconNone = BG_AB_OP_GOLDMINE_ICON;
|
||||
_capturePointInfo[BG_AB_NODE_STABLES]._iconCapture = BG_AB_OP_STABLE_STATE_ALIENCE;
|
||||
_capturePointInfo[BG_AB_NODE_FARM]._iconCapture = BG_AB_OP_FARM_STATE_ALIENCE;
|
||||
_capturePointInfo[BG_AB_NODE_BLACKSMITH]._iconCapture = BG_AB_OP_BLACKSMITH_STATE_ALIENCE;
|
||||
_capturePointInfo[BG_AB_NODE_LUMBER_MILL]._iconCapture = BG_AB_OP_LUMBERMILL_STATE_ALIENCE;
|
||||
_capturePointInfo[BG_AB_NODE_GOLD_MINE]._iconCapture = BG_AB_OP_GOLDMINE_STATE_ALIENCE;
|
||||
_capturePointInfo[BG_AB_NODE_STABLES]._iconNone = BG_AB_OP_STABLE_ICON;
|
||||
_capturePointInfo[BG_AB_NODE_FARM]._iconNone = BG_AB_OP_FARM_ICON;
|
||||
_capturePointInfo[BG_AB_NODE_BLACKSMITH]._iconNone = BG_AB_OP_BLACKSMITH_ICON;
|
||||
_capturePointInfo[BG_AB_NODE_LUMBER_MILL]._iconNone = BG_AB_OP_LUMBERMILL_ICON;
|
||||
_capturePointInfo[BG_AB_NODE_GOLD_MINE]._iconNone = BG_AB_OP_GOLDMINE_ICON;
|
||||
_capturePointInfo[BG_AB_NODE_STABLES]._iconCapture = BG_AB_OP_STABLE_STATE_ALIENCE;
|
||||
_capturePointInfo[BG_AB_NODE_FARM]._iconCapture = BG_AB_OP_FARM_STATE_ALIENCE;
|
||||
_capturePointInfo[BG_AB_NODE_BLACKSMITH]._iconCapture = BG_AB_OP_BLACKSMITH_STATE_ALIENCE;
|
||||
_capturePointInfo[BG_AB_NODE_LUMBER_MILL]._iconCapture = BG_AB_OP_LUMBERMILL_STATE_ALIENCE;
|
||||
_capturePointInfo[BG_AB_NODE_GOLD_MINE]._iconCapture = BG_AB_OP_GOLDMINE_STATE_ALIENCE;
|
||||
}
|
||||
|
||||
void BattlegroundAB::EndBattleground(TeamId winnerTeamId)
|
||||
@@ -421,23 +421,23 @@ void BattlegroundAB::EndBattleground(TeamId winnerTeamId)
|
||||
RewardHonorToTeam(GetBonusHonorFromKill(1), TEAM_HORDE);
|
||||
RewardHonorToTeam(GetBonusHonorFromKill(1), TEAM_ALLIANCE);
|
||||
Battleground::EndBattleground(winnerTeamId);
|
||||
_bgEvents.Reset();
|
||||
_bgEvents.Reset();
|
||||
}
|
||||
|
||||
WorldSafeLocsEntry const* BattlegroundAB::GetClosestGraveyard(Player* player)
|
||||
{
|
||||
WorldSafeLocsEntry const* entry = sWorldSafeLocsStore.LookupEntry(BG_AB_GraveyardIds[BG_AB_SPIRIT_ALIANCE + player->GetTeamId()]);
|
||||
WorldSafeLocsEntry const* entry = sWorldSafeLocsStore.LookupEntry(BG_AB_GraveyardIds[BG_AB_SPIRIT_ALIANCE + player->GetTeamId()]);
|
||||
WorldSafeLocsEntry const* nearestEntry = entry;
|
||||
|
||||
float pX = player->GetPositionX();
|
||||
float pY = player->GetPositionY();
|
||||
float dist = (entry->x - pX)*(entry->x - pX)+(entry->y - pY)*(entry->y - pY);
|
||||
float minDist = dist;
|
||||
float pX = player->GetPositionX();
|
||||
float pY = player->GetPositionY();
|
||||
float dist = (entry->x - pX)*(entry->x - pX)+(entry->y - pY)*(entry->y - pY);
|
||||
float minDist = dist;
|
||||
|
||||
for (uint8 i = BG_AB_NODE_STABLES; i < BG_AB_DYNAMIC_NODES_COUNT; ++i)
|
||||
if (_capturePointInfo[i]._ownerTeamId == player->GetTeamId())
|
||||
{
|
||||
entry = sWorldSafeLocsStore.LookupEntry(BG_AB_GraveyardIds[i]);
|
||||
for (uint8 i = BG_AB_NODE_STABLES; i < BG_AB_DYNAMIC_NODES_COUNT; ++i)
|
||||
if (_capturePointInfo[i]._ownerTeamId == player->GetTeamId())
|
||||
{
|
||||
entry = sWorldSafeLocsStore.LookupEntry(BG_AB_GraveyardIds[i]);
|
||||
dist = (entry->x - pX)*(entry->x - pX) + (entry->y - pY)*(entry->y - pY);
|
||||
if (dist < minDist)
|
||||
{
|
||||
@@ -478,15 +478,15 @@ bool BattlegroundAB::AllNodesConrolledByTeam(TeamId teamId) const
|
||||
|
||||
void BattlegroundAB::ApplyPhaseMask()
|
||||
{
|
||||
uint32 phaseMask = 1;
|
||||
for (uint32 i = BG_AB_NODE_STABLES; i < BG_AB_DYNAMIC_NODES_COUNT; ++i)
|
||||
if (_capturePointInfo[i]._ownerTeamId != TEAM_NEUTRAL)
|
||||
phaseMask |= 1 << (i*2+1 + _capturePointInfo[i]._ownerTeamId);
|
||||
uint32 phaseMask = 1;
|
||||
for (uint32 i = BG_AB_NODE_STABLES; i < BG_AB_DYNAMIC_NODES_COUNT; ++i)
|
||||
if (_capturePointInfo[i]._ownerTeamId != TEAM_NEUTRAL)
|
||||
phaseMask |= 1 << (i*2+1 + _capturePointInfo[i]._ownerTeamId);
|
||||
|
||||
const BattlegroundPlayerMap& bgPlayerMap = GetPlayers();
|
||||
for (BattlegroundPlayerMap::const_iterator itr = bgPlayerMap.begin(); itr != bgPlayerMap.end(); ++itr)
|
||||
{
|
||||
itr->second->SetPhaseMask(phaseMask, false);
|
||||
itr->second->UpdateObjectVisibility(true, false);
|
||||
}
|
||||
const BattlegroundPlayerMap& bgPlayerMap = GetPlayers();
|
||||
for (BattlegroundPlayerMap::const_iterator itr = bgPlayerMap.begin(); itr != bgPlayerMap.end(); ++itr)
|
||||
{
|
||||
itr->second->SetPhaseMask(phaseMask, false);
|
||||
itr->second->UpdateObjectVisibility(true, false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user