mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-29 13:22:48 +01:00
Core/Battlefield: move complex methods from BattlefieldWG.h to BattlefieldWG.cpp
This commit is contained in:
@@ -17,19 +17,18 @@
|
||||
|
||||
#include "Battlefield.h"
|
||||
#include "BattlefieldMgr.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "Map.h"
|
||||
#include "MapManager.h"
|
||||
#include "Group.h"
|
||||
#include "WorldPacket.h"
|
||||
#include "GridNotifiers.h"
|
||||
#include "GridNotifiersImpl.h"
|
||||
#include "GridNotifiers.h"
|
||||
#include "GridNotifiersImpl.h"
|
||||
#include "Battleground.h"
|
||||
#include "CellImpl.h"
|
||||
#include "CreatureTextMgr.h"
|
||||
#include "GridNotifiers.h"
|
||||
#include "GridNotifiersImpl.h"
|
||||
#include "Group.h"
|
||||
#include "GroupMgr.h"
|
||||
#include "Map.h"
|
||||
#include "MapManager.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "WorldPacket.h"
|
||||
|
||||
Battlefield::Battlefield()
|
||||
{
|
||||
@@ -201,7 +200,7 @@ void Battlefield::InvitePlayersInZoneToQueue()
|
||||
{
|
||||
for (uint8 team = 0; team < 2; ++team)
|
||||
for (GuidSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
|
||||
if (Player* player = sObjectAccessor->FindPlayer(*itr))
|
||||
if (Player* player = ObjectAccessor::FindPlayer(*itr))
|
||||
InvitePlayerToQueue(player);
|
||||
}
|
||||
|
||||
@@ -220,7 +219,7 @@ void Battlefield::InvitePlayersInQueueToWar()
|
||||
{
|
||||
for (GuidSet::const_iterator itr = m_PlayersInQueue[team].begin(); itr != m_PlayersInQueue[team].end(); ++itr)
|
||||
{
|
||||
if (Player* player = sObjectAccessor->FindPlayer(*itr))
|
||||
if (Player* player = ObjectAccessor::FindPlayer(*itr))
|
||||
{
|
||||
if (m_PlayersInWar[player->GetTeamId()].size() + m_InvitedPlayers[player->GetTeamId()].size() < m_MaxPlayer)
|
||||
InvitePlayerToWar(player);
|
||||
@@ -239,7 +238,7 @@ void Battlefield::InvitePlayersInZoneToWar()
|
||||
for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team)
|
||||
for (GuidSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
|
||||
{
|
||||
if (Player* player = sObjectAccessor->FindPlayer(*itr))
|
||||
if (Player* player = ObjectAccessor::FindPlayer(*itr))
|
||||
{
|
||||
if (m_PlayersInWar[player->GetTeamId()].count(player->GetGUID()) || m_InvitedPlayers[player->GetTeamId()].count(player->GetGUID()))
|
||||
continue;
|
||||
@@ -283,9 +282,9 @@ void Battlefield::InvitePlayerToWar(Player* player)
|
||||
player->GetSession()->SendBfInvitePlayerToWar(m_BattleId, m_ZoneId, m_TimeForAcceptInvite);
|
||||
}
|
||||
|
||||
void Battlefield::InitStalker(uint32 entry, float x, float y, float z, float o)
|
||||
void Battlefield::InitStalker(uint32 entry, Position const& pos)
|
||||
{
|
||||
if (Creature* creature = SpawnCreature(entry, x, y, z, o, TEAM_NEUTRAL))
|
||||
if (Creature* creature = SpawnCreature(entry, pos, TEAM_NEUTRAL))
|
||||
StalkerGuid = creature->GetGUID();
|
||||
else
|
||||
TC_LOG_ERROR("bg.battlefield", "Battlefield::InitStalker: could not spawn Stalker (Creature entry %u), zone messeges will be un-available", entry);
|
||||
@@ -295,14 +294,14 @@ void Battlefield::KickAfkPlayers()
|
||||
{
|
||||
for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team)
|
||||
for (GuidSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
|
||||
if (Player* player = sObjectAccessor->FindPlayer(*itr))
|
||||
if (Player* player = ObjectAccessor::FindPlayer(*itr))
|
||||
if (player->isAFK())
|
||||
KickPlayerFromBattlefield(*itr);
|
||||
}
|
||||
|
||||
void Battlefield::KickPlayerFromBattlefield(uint64 guid)
|
||||
{
|
||||
if (Player* player = sObjectAccessor->FindPlayer(guid))
|
||||
if (Player* player = ObjectAccessor::FindPlayer(guid))
|
||||
if (player->GetZoneId() == GetZoneId())
|
||||
player->TeleportTo(KickPosition);
|
||||
}
|
||||
@@ -361,8 +360,8 @@ void Battlefield::DoPlaySoundToAll(uint32 SoundID)
|
||||
|
||||
for (int team = 0; team < BG_TEAMS_COUNT; team++)
|
||||
for (GuidSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
|
||||
if (Player* player = sObjectAccessor->FindPlayer(*itr))
|
||||
player->GetSession()->SendPacket(&data);
|
||||
if (Player* player = ObjectAccessor::FindPlayer(*itr))
|
||||
player->SendDirectMessage(&data);
|
||||
}
|
||||
|
||||
bool Battlefield::HasPlayer(Player* player) const
|
||||
@@ -410,13 +409,13 @@ void Battlefield::TeamCastSpell(TeamId team, int32 spellId)
|
||||
if (spellId > 0)
|
||||
{
|
||||
for (GuidSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
|
||||
if (Player* player = sObjectAccessor->FindPlayer(*itr))
|
||||
if (Player* player = ObjectAccessor::FindPlayer(*itr))
|
||||
player->CastSpell(player, uint32(spellId), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (GuidSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
|
||||
if (Player* player = sObjectAccessor->FindPlayer(*itr))
|
||||
if (Player* player = ObjectAccessor::FindPlayer(*itr))
|
||||
player->RemoveAuraFromStack(uint32(-spellId));
|
||||
}
|
||||
}
|
||||
@@ -425,24 +424,24 @@ void Battlefield::BroadcastPacketToZone(WorldPacket& data) const
|
||||
{
|
||||
for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team)
|
||||
for (GuidSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
|
||||
if (Player* player = sObjectAccessor->FindPlayer(*itr))
|
||||
player->GetSession()->SendPacket(&data);
|
||||
if (Player* player = ObjectAccessor::FindPlayer(*itr))
|
||||
player->SendDirectMessage(&data);
|
||||
}
|
||||
|
||||
void Battlefield::BroadcastPacketToQueue(WorldPacket& data) const
|
||||
{
|
||||
for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team)
|
||||
for (GuidSet::const_iterator itr = m_PlayersInQueue[team].begin(); itr != m_PlayersInQueue[team].end(); ++itr)
|
||||
if (Player* player = sObjectAccessor->FindPlayer(*itr))
|
||||
player->GetSession()->SendPacket(&data);
|
||||
if (Player* player = ObjectAccessor::FindPlayer(*itr))
|
||||
player->SendDirectMessage(&data);
|
||||
}
|
||||
|
||||
void Battlefield::BroadcastPacketToWar(WorldPacket& data) const
|
||||
{
|
||||
for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team)
|
||||
for (GuidSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
|
||||
if (Player* player = sObjectAccessor->FindPlayer(*itr))
|
||||
player->GetSession()->SendPacket(&data);
|
||||
if (Player* player = ObjectAccessor::FindPlayer(*itr))
|
||||
player->SendDirectMessage(&data);
|
||||
}
|
||||
|
||||
void Battlefield::SendWarningToAllInZone(uint32 entry)
|
||||
@@ -463,7 +462,7 @@ void Battlefield::SendUpdateWorldState(uint32 field, uint32 value)
|
||||
{
|
||||
for (uint8 i = 0; i < BG_TEAMS_COUNT; ++i)
|
||||
for (GuidSet::iterator itr = m_players[i].begin(); itr != m_players[i].end(); ++itr)
|
||||
if (Player* player = sObjectAccessor->FindPlayer(*itr))
|
||||
if (Player* player = ObjectAccessor::FindPlayer(*itr))
|
||||
player->SendUpdateWorldState(field, value);
|
||||
}
|
||||
|
||||
@@ -635,8 +634,7 @@ void Battlefield::SendAreaSpiritHealerQueryOpcode(Player* player, uint64 guid)
|
||||
uint32 time = m_LastResurrectTimer; // resurrect every 30 seconds
|
||||
|
||||
data << guid << time;
|
||||
ASSERT(player && player->GetSession());
|
||||
player->GetSession()->SendPacket(&data);
|
||||
player->SendDirectMessage(&data);
|
||||
}
|
||||
|
||||
// ----------------------
|
||||
@@ -681,7 +679,7 @@ void BfGraveyard::AddPlayer(uint64 playerGuid)
|
||||
{
|
||||
m_ResurrectQueue.insert(playerGuid);
|
||||
|
||||
if (Player* player = sObjectAccessor->FindPlayer(playerGuid))
|
||||
if (Player* player = ObjectAccessor::FindPlayer(playerGuid))
|
||||
player->CastSpell(player, SPELL_WAITING_FOR_RESURRECT, true);
|
||||
}
|
||||
}
|
||||
@@ -690,7 +688,7 @@ void BfGraveyard::RemovePlayer(uint64 playerGuid)
|
||||
{
|
||||
m_ResurrectQueue.erase(m_ResurrectQueue.find(playerGuid));
|
||||
|
||||
if (Player* player = sObjectAccessor->FindPlayer(playerGuid))
|
||||
if (Player* player = ObjectAccessor::FindPlayer(playerGuid))
|
||||
player->RemoveAurasDueToSpell(SPELL_WAITING_FOR_RESURRECT);
|
||||
}
|
||||
|
||||
@@ -702,7 +700,7 @@ void BfGraveyard::Resurrect()
|
||||
for (GuidSet::const_iterator itr = m_ResurrectQueue.begin(); itr != m_ResurrectQueue.end(); ++itr)
|
||||
{
|
||||
// Get player object from his guid
|
||||
Player* player = sObjectAccessor->FindPlayer(*itr);
|
||||
Player* player = ObjectAccessor::FindPlayer(*itr);
|
||||
if (!player)
|
||||
continue;
|
||||
|
||||
@@ -743,7 +741,7 @@ void BfGraveyard::RelocateDeadPlayers()
|
||||
WorldSafeLocsEntry const* closestGrave = NULL;
|
||||
for (GuidSet::const_iterator itr = m_ResurrectQueue.begin(); itr != m_ResurrectQueue.end(); ++itr)
|
||||
{
|
||||
Player* player = sObjectAccessor->FindPlayer(*itr);
|
||||
Player* player = ObjectAccessor::FindPlayer(*itr);
|
||||
if (!player)
|
||||
continue;
|
||||
|
||||
@@ -776,19 +774,19 @@ bool BfGraveyard::HasNpc(uint64 guid)
|
||||
// ********************** Misc ***************************
|
||||
// *******************************************************
|
||||
|
||||
Creature* Battlefield::SpawnCreature(uint32 entry, const Position& pos, TeamId team)
|
||||
Creature* Battlefield::SpawnCreature(uint32 entry, Position const& pos, TeamId teamId)
|
||||
{
|
||||
return SpawnCreature(entry, pos.m_positionX, pos.m_positionY, pos.m_positionZ, pos.m_orientation, team);
|
||||
return SpawnCreature(entry, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), teamId);
|
||||
}
|
||||
|
||||
Creature* Battlefield::SpawnCreature(uint32 entry, float x, float y, float z, float o, TeamId /*team*/)
|
||||
Creature* Battlefield::SpawnCreature(uint32 entry, float x, float y, float z, float o, TeamId /*teamId*/)
|
||||
{
|
||||
//Get map object
|
||||
Map* map = sMapMgr->CreateBaseMap(m_MapId);
|
||||
if (!map)
|
||||
{
|
||||
TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnCreature: Can't create creature entry: %u map not found", entry);
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Creature* creature = new Creature();
|
||||
@@ -796,7 +794,7 @@ Creature* Battlefield::SpawnCreature(uint32 entry, float x, float y, float z, fl
|
||||
{
|
||||
TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnCreature: Can't create creature entry: %u", entry);
|
||||
delete creature;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
creature->SetHomePosition(x, y, z, o);
|
||||
@@ -805,7 +803,7 @@ Creature* Battlefield::SpawnCreature(uint32 entry, float x, float y, float z, fl
|
||||
if (!cinfo)
|
||||
{
|
||||
TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnCreature: entry %u does not exist.", entry);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Set creature in world
|
||||
@@ -987,7 +985,7 @@ bool BfCapturePoint::Update(uint32 diff)
|
||||
{
|
||||
for (GuidSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end();)
|
||||
{
|
||||
if (Player* player = sObjectAccessor->FindPlayer(*itr))
|
||||
if (Player* player = ObjectAccessor::FindPlayer(*itr))
|
||||
{
|
||||
if (!capturePoint->IsWithinDistInMap(player, radius) || !player->IsOutdoorPvPActive())
|
||||
itr = HandlePlayerLeave(player);
|
||||
@@ -1100,7 +1098,7 @@ void BfCapturePoint::SendUpdateWorldState(uint32 field, uint32 value)
|
||||
{
|
||||
for (uint8 team = 0; team < 2; ++team)
|
||||
for (GuidSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end(); ++itr) // send to all players present in the area
|
||||
if (Player* player = sObjectAccessor->FindPlayer(*itr))
|
||||
if (Player* player = ObjectAccessor::FindPlayer(*itr))
|
||||
player->SendUpdateWorldState(field, value);
|
||||
}
|
||||
|
||||
@@ -1121,7 +1119,7 @@ void BfCapturePoint::SendObjectiveComplete(uint32 id, uint64 guid)
|
||||
|
||||
// send to all players present in the area
|
||||
for (GuidSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end(); ++itr)
|
||||
if (Player* player = sObjectAccessor->FindPlayer(*itr))
|
||||
if (Player* player = ObjectAccessor::FindPlayer(*itr))
|
||||
player->KilledMonsterCredit(id, guid);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,13 +18,8 @@
|
||||
#ifndef BATTLEFIELD_H_
|
||||
#define BATTLEFIELD_H_
|
||||
|
||||
#include "Utilities/Util.h"
|
||||
#include "SharedDefines.h"
|
||||
#include "ZoneScript.h"
|
||||
#include "WorldPacket.h"
|
||||
#include "GameObject.h"
|
||||
#include "Battleground.h"
|
||||
#include "ObjectAccessor.h"
|
||||
|
||||
enum BattlefieldTypes
|
||||
{
|
||||
@@ -110,7 +105,7 @@ class BfCapturePoint
|
||||
bool DelCapturePoint();
|
||||
|
||||
// active Players in the area of the objective, 0 - alliance, 1 - horde
|
||||
GuidSet m_activePlayers[2];
|
||||
GuidSet m_activePlayers[BG_TEAMS_COUNT];
|
||||
|
||||
// Total shift needed to capture the objective
|
||||
float m_maxValue;
|
||||
@@ -182,7 +177,7 @@ class BfGraveyard
|
||||
protected:
|
||||
TeamId m_ControlTeam;
|
||||
uint32 m_GraveyardId;
|
||||
uint64 m_SpiritGuide[2];
|
||||
uint64 m_SpiritGuide[BG_TEAMS_COUNT];
|
||||
GuidSet m_ResurrectQueue;
|
||||
Battlefield* m_Bf;
|
||||
};
|
||||
@@ -285,8 +280,8 @@ class Battlefield : public ZoneScript
|
||||
BfGraveyard* GetGraveyardById(uint32 id) const;
|
||||
|
||||
// Misc methods
|
||||
virtual Creature* SpawnCreature(uint32 entry, float x, float y, float z, float o, TeamId team);
|
||||
Creature* SpawnCreature(uint32 entry, const Position& pos, TeamId team);
|
||||
virtual Creature* SpawnCreature(uint32 entry, float x, float y, float z, float o, TeamId /*teamId*/);
|
||||
Creature* SpawnCreature(uint32 entry, Position const& pos, TeamId /*teamId*/);
|
||||
GameObject* SpawnGameObject(uint32 entry, float x, float y, float z, float o);
|
||||
|
||||
Creature* GetCreature(uint64 GUID);
|
||||
@@ -344,7 +339,7 @@ class Battlefield : public ZoneScript
|
||||
void InvitePlayerToQueue(Player* player);
|
||||
void InvitePlayerToWar(Player* player);
|
||||
|
||||
void InitStalker(uint32 entry, float x, float y, float z, float o);
|
||||
void InitStalker(uint32 entry, Position const& pos);
|
||||
|
||||
protected:
|
||||
uint64 StalkerGuid;
|
||||
|
||||
@@ -21,13 +21,13 @@
|
||||
|
||||
#include "BattlefieldWG.h"
|
||||
#include "AchievementMgr.h"
|
||||
#include "Battleground.h"
|
||||
#include "MapManager.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "Opcodes.h"
|
||||
#include "Player.h"
|
||||
#include "SpellAuras.h"
|
||||
#include "TemporarySummon.h"
|
||||
#include "Vehicle.h"
|
||||
#include "WorldSession.h"
|
||||
|
||||
BattlefieldWG::~BattlefieldWG()
|
||||
@@ -47,7 +47,7 @@ bool BattlefieldWG::SetupBattlefield()
|
||||
m_MapId = BATTLEFIELD_WG_MAPID;
|
||||
m_Map = sMapMgr->FindMap(m_MapId, 0);
|
||||
|
||||
InitStalker(BATTLEFIELD_WG_NPC_STALKER, WintergraspStalkerPos[0], WintergraspStalkerPos[1], WintergraspStalkerPos[2], WintergraspStalkerPos[3]);
|
||||
InitStalker(BATTLEFIELD_WG_NPC_STALKER, WintergraspStalkerPos);
|
||||
|
||||
m_MaxPlayer = sWorld->getIntConfig(CONFIG_WINTERGRASP_PLR_MAX);
|
||||
m_IsEnabled = sWorld->getBoolConfig(CONFIG_WINTERGRASP_ENABLE);
|
||||
@@ -847,7 +847,7 @@ void BattlefieldWG::SendInitWorldStatesTo(Player* player)
|
||||
|
||||
FillInitialWorldStates(data);
|
||||
|
||||
player->GetSession()->SendPacket(&data);
|
||||
player->SendDirectMessage(&data);
|
||||
}
|
||||
|
||||
void BattlefieldWG::SendInitWorldStatesToAll()
|
||||
@@ -1060,3 +1060,572 @@ BfGraveyardWG::BfGraveyardWG(BattlefieldWG* battlefield) : BfGraveyard(battlefie
|
||||
m_Bf = battlefield;
|
||||
m_GossipTextId = 0;
|
||||
}
|
||||
|
||||
BfWGGameObjectBuilding::BfWGGameObjectBuilding(BattlefieldWG* wg)
|
||||
{
|
||||
m_WG = wg;
|
||||
m_Team = 0;
|
||||
m_BuildGUID = 0;
|
||||
m_Type = 0;
|
||||
m_WorldState = 0;
|
||||
m_State = 0;
|
||||
m_NameId = 0;
|
||||
}
|
||||
|
||||
void BfWGGameObjectBuilding::Rebuild()
|
||||
{
|
||||
switch (m_Type)
|
||||
{
|
||||
case BATTLEFIELD_WG_OBJECTTYPE_KEEP_TOWER:
|
||||
case BATTLEFIELD_WG_OBJECTTYPE_DOOR_LAST:
|
||||
case BATTLEFIELD_WG_OBJECTTYPE_DOOR:
|
||||
case BATTLEFIELD_WG_OBJECTTYPE_WALL:
|
||||
m_Team = m_WG->GetDefenderTeam(); // Objects that are part of the keep should be the defender's
|
||||
break;
|
||||
case BATTLEFIELD_WG_OBJECTTYPE_TOWER:
|
||||
m_Team = m_WG->GetAttackerTeam(); // The towers in the south should be the attacker's
|
||||
break;
|
||||
default:
|
||||
m_Team = TEAM_NEUTRAL;
|
||||
break;
|
||||
}
|
||||
|
||||
if (GameObject* build = m_WG->GetGameObject(m_BuildGUID))
|
||||
{
|
||||
// Rebuild gameobject
|
||||
if (build->IsDestructibleBuilding())
|
||||
{
|
||||
build->SetDestructibleState(GO_DESTRUCTIBLE_REBUILDING, NULL, true);
|
||||
if (build->GetEntry() == GO_WINTERGRASP_VAULT_GATE)
|
||||
if (GameObject* go = build->FindNearestGameObject(GO_WINTERGRASP_KEEP_COLLISION_WALL, 50.0f))
|
||||
go->SetGoState(GO_STATE_READY);
|
||||
|
||||
// Update worldstate
|
||||
m_State = BATTLEFIELD_WG_OBJECTSTATE_ALLIANCE_INTACT - (m_Team * 3);
|
||||
m_WG->SendUpdateWorldState(m_WorldState, m_State);
|
||||
}
|
||||
UpdateCreatureAndGo();
|
||||
build->SetFaction(WintergraspFaction[m_Team]);
|
||||
}
|
||||
}
|
||||
|
||||
void BfWGGameObjectBuilding::Damaged()
|
||||
{
|
||||
// Update worldstate
|
||||
m_State = BATTLEFIELD_WG_OBJECTSTATE_ALLIANCE_DAMAGE - (m_Team * 3);
|
||||
m_WG->SendUpdateWorldState(m_WorldState, m_State);
|
||||
|
||||
// Send warning message
|
||||
if (m_NameId) // tower damage + name
|
||||
m_WG->SendWarningToAllInZone(m_NameId);
|
||||
|
||||
for (uint64 guid : m_CreatureTopList[m_WG->GetAttackerTeam()])
|
||||
if (Creature* creature = m_WG->GetCreature(guid))
|
||||
m_WG->HideNpc(creature);
|
||||
|
||||
for (uint64 guid : m_TurretTopList)
|
||||
if (Creature* creature = m_WG->GetCreature(guid))
|
||||
m_WG->HideNpc(creature);
|
||||
|
||||
if (m_Type == BATTLEFIELD_WG_OBJECTTYPE_KEEP_TOWER)
|
||||
m_WG->UpdateDamagedTowerCount(m_WG->GetDefenderTeam());
|
||||
else if (m_Type == BATTLEFIELD_WG_OBJECTTYPE_TOWER)
|
||||
m_WG->UpdateDamagedTowerCount(m_WG->GetAttackerTeam());
|
||||
}
|
||||
|
||||
void BfWGGameObjectBuilding::Destroyed()
|
||||
{
|
||||
// Update worldstate
|
||||
m_State = BATTLEFIELD_WG_OBJECTSTATE_ALLIANCE_DESTROY - (m_Team * 3);
|
||||
m_WG->SendUpdateWorldState(m_WorldState, m_State);
|
||||
|
||||
// Warn players
|
||||
if (m_NameId)
|
||||
m_WG->SendWarningToAllInZone(m_NameId);
|
||||
|
||||
switch (m_Type)
|
||||
{
|
||||
// Inform the global wintergrasp script of the destruction of this object
|
||||
case BATTLEFIELD_WG_OBJECTTYPE_TOWER:
|
||||
case BATTLEFIELD_WG_OBJECTTYPE_KEEP_TOWER:
|
||||
m_WG->UpdatedDestroyedTowerCount(TeamId(m_Team));
|
||||
break;
|
||||
case BATTLEFIELD_WG_OBJECTTYPE_DOOR_LAST:
|
||||
if (GameObject* build = m_WG->GetGameObject(m_BuildGUID))
|
||||
if (GameObject* go = build->FindNearestGameObject(GO_WINTERGRASP_KEEP_COLLISION_WALL, 50.0f))
|
||||
go->SetGoState(GO_STATE_ACTIVE);
|
||||
m_WG->SetRelicInteractible(true);
|
||||
if (m_WG->GetRelic())
|
||||
m_WG->GetRelic()->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE);
|
||||
else
|
||||
TC_LOG_ERROR("misc", "BattlefieldWG: Relic not found.");
|
||||
break;
|
||||
}
|
||||
|
||||
m_WG->BrokenWallOrTower(TeamId(m_Team));
|
||||
}
|
||||
|
||||
void BfWGGameObjectBuilding::Init(GameObject* go, uint32 type, uint32 worldstate, uint32 nameId)
|
||||
{
|
||||
if (!go)
|
||||
return;
|
||||
|
||||
// GameObject associated to object
|
||||
m_BuildGUID = go->GetGUID();
|
||||
|
||||
// Type of building (WALL/TOWER/DOOR)
|
||||
m_Type = type;
|
||||
|
||||
// WorldState for client (icon on map)
|
||||
m_WorldState = worldstate;
|
||||
|
||||
// NameId for Warning text
|
||||
m_NameId = nameId;
|
||||
|
||||
switch (m_Type)
|
||||
{
|
||||
case BATTLEFIELD_WG_OBJECTTYPE_KEEP_TOWER:
|
||||
case BATTLEFIELD_WG_OBJECTTYPE_DOOR_LAST:
|
||||
case BATTLEFIELD_WG_OBJECTTYPE_DOOR:
|
||||
case BATTLEFIELD_WG_OBJECTTYPE_WALL:
|
||||
m_Team = m_WG->GetDefenderTeam(); // Objects that are part of the keep should be the defender's
|
||||
break;
|
||||
case BATTLEFIELD_WG_OBJECTTYPE_TOWER:
|
||||
m_Team = m_WG->GetAttackerTeam(); // The towers in the south should be the attacker's
|
||||
break;
|
||||
default:
|
||||
m_Team = TEAM_NEUTRAL;
|
||||
break;
|
||||
}
|
||||
|
||||
m_State = sWorld->getWorldState(m_WorldState);
|
||||
switch (m_State)
|
||||
{
|
||||
case BATTLEFIELD_WG_OBJECTSTATE_ALLIANCE_INTACT:
|
||||
case BATTLEFIELD_WG_OBJECTSTATE_HORDE_INTACT:
|
||||
go->SetDestructibleState(GO_DESTRUCTIBLE_REBUILDING, NULL, true);
|
||||
break;
|
||||
case BATTLEFIELD_WG_OBJECTSTATE_ALLIANCE_DESTROY:
|
||||
case BATTLEFIELD_WG_OBJECTSTATE_HORDE_DESTROY:
|
||||
go->SetDestructibleState(GO_DESTRUCTIBLE_DESTROYED);
|
||||
break;
|
||||
case BATTLEFIELD_WG_OBJECTSTATE_ALLIANCE_DAMAGE:
|
||||
case BATTLEFIELD_WG_OBJECTSTATE_HORDE_DAMAGE:
|
||||
go->SetDestructibleState(GO_DESTRUCTIBLE_DAMAGED);
|
||||
break;
|
||||
}
|
||||
|
||||
int32 towerId = -1;
|
||||
switch (go->GetEntry())
|
||||
{
|
||||
case GO_WINTERGRASP_FORTRESS_TOWER_1:
|
||||
towerId = 0;
|
||||
break;
|
||||
case GO_WINTERGRASP_FORTRESS_TOWER_2:
|
||||
towerId = 1;
|
||||
break;
|
||||
case GO_WINTERGRASP_FORTRESS_TOWER_3:
|
||||
towerId = 2;
|
||||
break;
|
||||
case GO_WINTERGRASP_FORTRESS_TOWER_4:
|
||||
towerId = 3;
|
||||
break;
|
||||
case GO_WINTERGRASP_SHADOWSIGHT_TOWER:
|
||||
towerId = 4;
|
||||
break;
|
||||
case GO_WINTERGRASP_WINTER_S_EDGE_TOWER:
|
||||
towerId = 5;
|
||||
break;
|
||||
case GO_WINTERGRASP_FLAMEWATCH_TOWER:
|
||||
towerId = 6;
|
||||
break;
|
||||
}
|
||||
|
||||
if (towerId > 3) // Attacker towers
|
||||
{
|
||||
// Spawn associate gameobjects
|
||||
for (uint8 i = 0; i < AttackTowers[towerId - 4].nbObject; i++)
|
||||
{
|
||||
WintergraspObjectPositionData const& gobData = AttackTowers[towerId - 4].GameObject[i];
|
||||
if (GameObject* goHorde = m_WG->SpawnGameObject(gobData.entryHorde, gobData.x, gobData.y, gobData.z, gobData.o))
|
||||
m_GameObjectList[TEAM_HORDE].insert(goHorde->GetGUID());
|
||||
if (GameObject* goAlliance = m_WG->SpawnGameObject(gobData.entryAlliance, gobData.x, gobData.y, gobData.z, gobData.o))
|
||||
m_GameObjectList[TEAM_ALLIANCE].insert(goAlliance->GetGUID());
|
||||
}
|
||||
|
||||
// Spawn associate npc bottom
|
||||
for (uint8 i = 0; i < AttackTowers[towerId - 4].nbCreatureBottom; i++)
|
||||
{
|
||||
WintergraspObjectPositionData const& creatureData = AttackTowers[towerId - 4].CreatureBottom[i];
|
||||
if (Creature* creature = m_WG->SpawnCreature(creatureData.entryHorde, creatureData.x, creatureData.y, creatureData.z, creatureData.o, TEAM_HORDE))
|
||||
m_CreatureBottomList[TEAM_HORDE].insert(creature->GetGUID());
|
||||
if (Creature* creature = m_WG->SpawnCreature(creatureData.entryAlliance, creatureData.x, creatureData.y, creatureData.z, creatureData.o, TEAM_ALLIANCE))
|
||||
m_CreatureBottomList[TEAM_ALLIANCE].insert(creature->GetGUID());
|
||||
}
|
||||
|
||||
// Spawn associate npc top
|
||||
for (uint8 i = 0; i < AttackTowers[towerId - 4].nbCreatureTop; i++)
|
||||
{
|
||||
WintergraspObjectPositionData const& creatureData = AttackTowers[towerId - 4].CreatureTop[i];
|
||||
if (Creature* creature = m_WG->SpawnCreature(creatureData.entryHorde, creatureData.x, creatureData.y, creatureData.z, creatureData.o, TEAM_HORDE))
|
||||
m_CreatureTopList[TEAM_HORDE].insert(creature->GetGUID());
|
||||
if (Creature* creature = m_WG->SpawnCreature(creatureData.entryAlliance, creatureData.x, creatureData.y, creatureData.z, creatureData.o, TEAM_ALLIANCE))
|
||||
m_CreatureTopList[TEAM_ALLIANCE].insert(creature->GetGUID());
|
||||
}
|
||||
}
|
||||
|
||||
if (towerId >= 0)
|
||||
{
|
||||
// Spawn Turret bottom
|
||||
for (uint8 i = 0; i < TowerCannon[towerId].nbTowerCannonBottom; i++)
|
||||
{
|
||||
Position const& turretPos = TowerCannon[towerId].TowerCannonBottom[i];
|
||||
if (Creature* turret = m_WG->SpawnCreature(NPC_WINTERGRASP_TOWER_CANNON, turretPos, TEAM_ALLIANCE))
|
||||
{
|
||||
m_TowerCannonBottomList.insert(turret->GetGUID());
|
||||
switch (go->GetEntry())
|
||||
{
|
||||
case GO_WINTERGRASP_FORTRESS_TOWER_1:
|
||||
case GO_WINTERGRASP_FORTRESS_TOWER_2:
|
||||
case GO_WINTERGRASP_FORTRESS_TOWER_3:
|
||||
case GO_WINTERGRASP_FORTRESS_TOWER_4:
|
||||
turret->setFaction(WintergraspFaction[m_WG->GetDefenderTeam()]);
|
||||
break;
|
||||
case GO_WINTERGRASP_SHADOWSIGHT_TOWER:
|
||||
case GO_WINTERGRASP_WINTER_S_EDGE_TOWER:
|
||||
case GO_WINTERGRASP_FLAMEWATCH_TOWER:
|
||||
turret->setFaction(WintergraspFaction[m_WG->GetAttackerTeam()]);
|
||||
break;
|
||||
}
|
||||
m_WG->HideNpc(turret);
|
||||
}
|
||||
}
|
||||
|
||||
// Spawn Turret top
|
||||
for (uint8 i = 0; i < TowerCannon[towerId].nbTurretTop; i++)
|
||||
{
|
||||
Position const& towerCannonPos = TowerCannon[towerId].TurretTop[i];
|
||||
if (Creature* turret = m_WG->SpawnCreature(NPC_WINTERGRASP_TOWER_CANNON, towerCannonPos, TeamId(0)))
|
||||
{
|
||||
m_TurretTopList.insert(turret->GetGUID());
|
||||
switch (go->GetEntry())
|
||||
{
|
||||
case GO_WINTERGRASP_FORTRESS_TOWER_1:
|
||||
case GO_WINTERGRASP_FORTRESS_TOWER_2:
|
||||
case GO_WINTERGRASP_FORTRESS_TOWER_3:
|
||||
case GO_WINTERGRASP_FORTRESS_TOWER_4:
|
||||
turret->setFaction(WintergraspFaction[m_WG->GetDefenderTeam()]);
|
||||
break;
|
||||
case GO_WINTERGRASP_SHADOWSIGHT_TOWER:
|
||||
case GO_WINTERGRASP_WINTER_S_EDGE_TOWER:
|
||||
case GO_WINTERGRASP_FLAMEWATCH_TOWER:
|
||||
turret->setFaction(WintergraspFaction[m_WG->GetAttackerTeam()]);
|
||||
break;
|
||||
}
|
||||
m_WG->HideNpc(turret);
|
||||
}
|
||||
}
|
||||
UpdateCreatureAndGo();
|
||||
}
|
||||
}
|
||||
|
||||
void BfWGGameObjectBuilding::UpdateCreatureAndGo()
|
||||
{
|
||||
for (uint64 guid : m_CreatureTopList[m_WG->GetDefenderTeam()])
|
||||
if (Creature* creature = m_WG->GetCreature(guid))
|
||||
m_WG->HideNpc(creature);
|
||||
|
||||
for (uint64 guid : m_CreatureTopList[m_WG->GetAttackerTeam()])
|
||||
if (Creature* creature = m_WG->GetCreature(guid))
|
||||
m_WG->ShowNpc(creature, true);
|
||||
|
||||
for (uint64 guid : m_CreatureBottomList[m_WG->GetDefenderTeam()])
|
||||
if (Creature* creature = m_WG->GetCreature(guid))
|
||||
m_WG->HideNpc(creature);
|
||||
|
||||
for (uint64 guid : m_CreatureBottomList[m_WG->GetAttackerTeam()])
|
||||
if (Creature* creature = m_WG->GetCreature(guid))
|
||||
m_WG->ShowNpc(creature, true);
|
||||
|
||||
for (uint64 guid : m_GameObjectList[m_WG->GetDefenderTeam()])
|
||||
if (GameObject* object = m_WG->GetGameObject(guid))
|
||||
object->SetRespawnTime(RESPAWN_ONE_DAY);
|
||||
|
||||
for (uint64 guid : m_GameObjectList[m_WG->GetAttackerTeam()])
|
||||
if (GameObject* object = m_WG->GetGameObject(guid))
|
||||
object->SetRespawnTime(RESPAWN_IMMEDIATELY);
|
||||
}
|
||||
|
||||
void BfWGGameObjectBuilding::UpdateTurretAttack(bool disable)
|
||||
{
|
||||
for (uint64 guid : m_TowerCannonBottomList)
|
||||
{
|
||||
if (Creature* creature = m_WG->GetCreature(guid))
|
||||
{
|
||||
if (GameObject* build = m_WG->GetGameObject(m_BuildGUID))
|
||||
{
|
||||
if (disable)
|
||||
m_WG->HideNpc(creature);
|
||||
else
|
||||
m_WG->ShowNpc(creature, true);
|
||||
|
||||
switch (build->GetEntry())
|
||||
{
|
||||
case GO_WINTERGRASP_FORTRESS_TOWER_1:
|
||||
case GO_WINTERGRASP_FORTRESS_TOWER_2:
|
||||
case GO_WINTERGRASP_FORTRESS_TOWER_3:
|
||||
case GO_WINTERGRASP_FORTRESS_TOWER_4:
|
||||
{
|
||||
creature->setFaction(WintergraspFaction[m_WG->GetDefenderTeam()]);
|
||||
break;
|
||||
}
|
||||
case GO_WINTERGRASP_SHADOWSIGHT_TOWER:
|
||||
case GO_WINTERGRASP_WINTER_S_EDGE_TOWER:
|
||||
case GO_WINTERGRASP_FLAMEWATCH_TOWER:
|
||||
{
|
||||
creature->setFaction(WintergraspFaction[m_WG->GetAttackerTeam()]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (uint64 guid : m_TurretTopList)
|
||||
{
|
||||
if (Creature* creature = m_WG->GetCreature(guid))
|
||||
{
|
||||
if (GameObject* build = m_WG->GetGameObject(m_BuildGUID))
|
||||
{
|
||||
if (disable)
|
||||
m_WG->HideNpc(creature);
|
||||
else
|
||||
m_WG->ShowNpc(creature, true);
|
||||
|
||||
switch (build->GetEntry())
|
||||
{
|
||||
case GO_WINTERGRASP_FORTRESS_TOWER_1:
|
||||
case GO_WINTERGRASP_FORTRESS_TOWER_2:
|
||||
case GO_WINTERGRASP_FORTRESS_TOWER_3:
|
||||
case GO_WINTERGRASP_FORTRESS_TOWER_4:
|
||||
{
|
||||
creature->setFaction(WintergraspFaction[m_WG->GetDefenderTeam()]);
|
||||
break;
|
||||
}
|
||||
case GO_WINTERGRASP_SHADOWSIGHT_TOWER:
|
||||
case GO_WINTERGRASP_WINTER_S_EDGE_TOWER:
|
||||
case GO_WINTERGRASP_FLAMEWATCH_TOWER:
|
||||
{
|
||||
creature->setFaction(WintergraspFaction[m_WG->GetAttackerTeam()]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BfWGGameObjectBuilding::Save()
|
||||
{
|
||||
sWorld->setWorldState(m_WorldState, m_State);
|
||||
}
|
||||
|
||||
WGWorkshop::WGWorkshop(BattlefieldWG* _bf, uint8 _workshopId)
|
||||
{
|
||||
ASSERT(_bf || _workshopId < WG_MAX_WORKSHOP);
|
||||
|
||||
bf = _bf;
|
||||
workshopId = _workshopId;
|
||||
teamControl = BATTLEFIELD_WG_TEAM_NEUTRAL;
|
||||
state = BATTLEFIELD_WG_OBJECTSTATE_NONE;
|
||||
}
|
||||
|
||||
void WGWorkshop::GiveControlTo(uint8 team, bool init)
|
||||
{
|
||||
switch (team)
|
||||
{
|
||||
case BATTLEFIELD_WG_TEAM_NEUTRAL:
|
||||
{
|
||||
// Send warning message to all player to inform a faction attack to a workshop
|
||||
// alliance / horde attacking a workshop
|
||||
bf->SendWarningToAllInZone(teamControl ? WorkshopsData[workshopId].text : WorkshopsData[workshopId].text + 1);
|
||||
break;
|
||||
}
|
||||
case BATTLEFIELD_WG_TEAM_ALLIANCE:
|
||||
case BATTLEFIELD_WG_TEAM_HORDE:
|
||||
{
|
||||
// Updating worldstate
|
||||
state = team == BATTLEFIELD_WG_TEAM_ALLIANCE ? BATTLEFIELD_WG_OBJECTSTATE_ALLIANCE_INTACT : BATTLEFIELD_WG_OBJECTSTATE_HORDE_INTACT;
|
||||
bf->SendUpdateWorldState(WorkshopsData[workshopId].worldstate, state);
|
||||
|
||||
// Warning message
|
||||
if (!init) // workshop taken - alliance
|
||||
bf->SendWarningToAllInZone(team == BATTLEFIELD_WG_TEAM_ALLIANCE ? WorkshopsData[workshopId].text : WorkshopsData[workshopId].text + 1);
|
||||
|
||||
// Found associate graveyard and update it
|
||||
if (workshopId < BATTLEFIELD_WG_WORKSHOP_KEEP_WEST)
|
||||
if (bf->GetGraveyardById(workshopId))
|
||||
bf->GetGraveyardById(workshopId)->GiveControlTo(team == BATTLEFIELD_WG_TEAM_ALLIANCE ? TEAM_ALLIANCE : TEAM_HORDE);
|
||||
|
||||
teamControl = team;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!init)
|
||||
bf->UpdateCounterVehicle(false);
|
||||
}
|
||||
|
||||
void WGWorkshop::UpdateGraveyardAndWorkshop()
|
||||
{
|
||||
if (workshopId < BATTLEFIELD_WG_WORKSHOP_KEEP_WEST)
|
||||
bf->GetGraveyardById(workshopId)->GiveControlTo(TeamId(teamControl));
|
||||
else
|
||||
GiveControlTo(bf->GetDefenderTeam(), true);
|
||||
}
|
||||
|
||||
void WGWorkshop::Save()
|
||||
{
|
||||
sWorld->setWorldState(WorkshopsData[workshopId].worldstate, state);
|
||||
}
|
||||
|
||||
WintergraspWorkshopData::WintergraspWorkshopData(BattlefieldWG* wg)
|
||||
{
|
||||
m_WG = wg;
|
||||
m_BuildGUID = 0;
|
||||
m_Type = 0;
|
||||
m_State = 0;
|
||||
m_WorldState = 0;
|
||||
m_TeamControl = 0;
|
||||
m_NameId = 0;
|
||||
}
|
||||
|
||||
void WintergraspWorkshopData::AddCreature(WintergraspObjectPositionData const& obj)
|
||||
{
|
||||
if (Creature* creature = m_WG->SpawnCreature(obj.entryHorde, obj.x, obj.y, obj.z, obj.o, TEAM_HORDE))
|
||||
m_CreatureOnPoint[TEAM_HORDE].insert(creature->GetGUID());
|
||||
|
||||
if (Creature* creature = m_WG->SpawnCreature(obj.entryAlliance, obj.x, obj.y, obj.z, obj.o, TEAM_ALLIANCE))
|
||||
m_CreatureOnPoint[TEAM_ALLIANCE].insert(creature->GetGUID());
|
||||
}
|
||||
|
||||
void WintergraspWorkshopData::AddGameObject(WintergraspObjectPositionData const& obj)
|
||||
{
|
||||
if (GameObject* gameobject = m_WG->SpawnGameObject(obj.entryHorde, obj.x, obj.y, obj.z, obj.o))
|
||||
m_GameObjectOnPoint[TEAM_HORDE].insert(gameobject->GetGUID());
|
||||
if (GameObject* gameobject = m_WG->SpawnGameObject(obj.entryAlliance, obj.x, obj.y, obj.z, obj.o))
|
||||
m_GameObjectOnPoint[TEAM_ALLIANCE].insert(gameobject->GetGUID());
|
||||
}
|
||||
|
||||
void WintergraspWorkshopData::Init(uint32 worldstate, uint32 type, uint32 nameId)
|
||||
{
|
||||
m_WorldState = worldstate;
|
||||
m_Type = type;
|
||||
m_NameId = nameId;
|
||||
}
|
||||
|
||||
void WintergraspWorkshopData::GiveControlTo(uint8 team, bool init)
|
||||
{
|
||||
switch (team)
|
||||
{
|
||||
case BATTLEFIELD_WG_TEAM_NEUTRAL:
|
||||
{
|
||||
// Send warning message to all player for inform a faction attack a workshop
|
||||
// alliance / horde attacking workshop
|
||||
m_WG->SendWarningToAllInZone(m_TeamControl ? m_NameId : m_NameId + 1);
|
||||
break;
|
||||
}
|
||||
case BATTLEFIELD_WG_TEAM_ALLIANCE:
|
||||
{
|
||||
// Show Alliance creature
|
||||
for (uint64 guid : m_CreatureOnPoint[TEAM_ALLIANCE])
|
||||
if (Creature* creature = m_WG->GetCreature(guid))
|
||||
m_WG->ShowNpc(creature, creature->GetEntry() != 30499);
|
||||
|
||||
// Hide Horde creature
|
||||
for (uint64 guid : m_CreatureOnPoint[TEAM_HORDE])
|
||||
if (Creature* creature = m_WG->GetCreature(guid))
|
||||
m_WG->HideNpc(creature);
|
||||
|
||||
// Show Alliance gameobject
|
||||
for (uint64 guid : m_GameObjectOnPoint[TEAM_ALLIANCE])
|
||||
if (GameObject* object = m_WG->GetGameObject(guid))
|
||||
object->SetRespawnTime(RESPAWN_IMMEDIATELY);
|
||||
|
||||
// Hide Horde gameobject
|
||||
for (uint64 guid : m_GameObjectOnPoint[TEAM_HORDE])
|
||||
if (GameObject* object = m_WG->GetGameObject(guid))
|
||||
object->SetRespawnTime(RESPAWN_ONE_DAY);
|
||||
|
||||
|
||||
// Updating worldstate
|
||||
m_State = BATTLEFIELD_WG_OBJECTSTATE_ALLIANCE_INTACT;
|
||||
m_WG->SendUpdateWorldState(m_WorldState, m_State);
|
||||
|
||||
// Warning message
|
||||
if (!init) // workshop taken - alliance
|
||||
m_WG->SendWarningToAllInZone(m_NameId);
|
||||
|
||||
// Found associate graveyard and update it
|
||||
if (m_Type < BATTLEFIELD_WG_WORKSHOP_KEEP_WEST)
|
||||
if (m_WG->GetGraveyardById(m_Type))
|
||||
m_WG->GetGraveyardById(m_Type)->GiveControlTo(TEAM_ALLIANCE);
|
||||
|
||||
m_TeamControl = team;
|
||||
break;
|
||||
}
|
||||
case BATTLEFIELD_WG_TEAM_HORDE:
|
||||
{
|
||||
// Show Horde creature
|
||||
for (uint64 guid : m_CreatureOnPoint[TEAM_HORDE])
|
||||
if (Creature* creature = m_WG->GetCreature(guid))
|
||||
m_WG->ShowNpc(creature, creature->GetEntry() != 30400);
|
||||
|
||||
// Hide Alliance creature
|
||||
for (uint64 guid : m_CreatureOnPoint[TEAM_ALLIANCE])
|
||||
if (Creature* creature = m_WG->GetCreature(guid))
|
||||
m_WG->HideNpc(creature);
|
||||
|
||||
// Hide Alliance gameobject
|
||||
for (uint64 guid : m_GameObjectOnPoint[TEAM_ALLIANCE])
|
||||
if (GameObject* object = m_WG->GetGameObject(guid))
|
||||
object->SetRespawnTime(RESPAWN_ONE_DAY);
|
||||
|
||||
// Show Horde gameobject
|
||||
for (uint64 guid : m_GameObjectOnPoint[TEAM_HORDE])
|
||||
if (GameObject* object = m_WG->GetGameObject(guid))
|
||||
object->SetRespawnTime(RESPAWN_IMMEDIATELY);
|
||||
|
||||
// Update worldstate
|
||||
m_State = BATTLEFIELD_WG_OBJECTSTATE_HORDE_INTACT;
|
||||
m_WG->SendUpdateWorldState(m_WorldState, m_State);
|
||||
|
||||
// Warning message
|
||||
if (!init) // workshop taken - horde
|
||||
m_WG->SendWarningToAllInZone(m_NameId + 1);
|
||||
|
||||
// Update graveyard control
|
||||
if (m_Type < BATTLEFIELD_WG_WORKSHOP_KEEP_WEST)
|
||||
if (m_WG->GetGraveyardById(m_Type))
|
||||
m_WG->GetGraveyardById(m_Type)->GiveControlTo(TEAM_HORDE);
|
||||
|
||||
m_TeamControl = team;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!init)
|
||||
m_WG->UpdateCounterVehicle(false);
|
||||
}
|
||||
|
||||
void WintergraspWorkshopData::UpdateGraveyardAndWorkshop()
|
||||
{
|
||||
if (m_Type < BATTLEFIELD_WG_WORKSHOP_KEEP_WEST)
|
||||
m_WG->GetGraveyardById(m_Type)->GiveControlTo(TeamId(m_TeamControl));
|
||||
else
|
||||
GiveControlTo(m_WG->GetDefenderTeam(), true);
|
||||
}
|
||||
|
||||
void WintergraspWorkshopData::Save()
|
||||
{
|
||||
sWorld->setWorldState(m_WorldState, m_State);
|
||||
}
|
||||
|
||||
@@ -18,10 +18,7 @@
|
||||
#ifndef BATTLEFIELD_WG_
|
||||
#define BATTLEFIELD_WG_
|
||||
|
||||
#include "ObjectAccessor.h"
|
||||
#include "WorldPacket.h"
|
||||
#include "Battlefield.h"
|
||||
#include "World.h"
|
||||
|
||||
class Group;
|
||||
class BattlefieldWG;
|
||||
@@ -151,10 +148,11 @@ class BfGraveyardWG : public BfGraveyard
|
||||
public:
|
||||
BfGraveyardWG(BattlefieldWG* Bf);
|
||||
|
||||
void SetTextId(int32 textid) { m_GossipTextId = textid; }
|
||||
int32 GetTextId() { return m_GossipTextId; }
|
||||
void SetTextId(uint32 textId) { m_GossipTextId = textId; }
|
||||
uint32 GetTextId() { return m_GossipTextId; }
|
||||
|
||||
protected:
|
||||
int32 m_GossipTextId;
|
||||
uint32 m_GossipTextId;
|
||||
};
|
||||
|
||||
enum WGGraveyardId
|
||||
@@ -233,6 +231,7 @@ uint32 const WGQuest[2][6] =
|
||||
{ 13186, 13181, 13222, 13538, 13177, 13179 },
|
||||
{ 13185, 13183, 13223, 13539, 13178, 13180 },
|
||||
};
|
||||
|
||||
// 7 in sql, 7 in header
|
||||
BfWGCoordGY const WGGraveYard[BATTLEFIELD_WG_GRAVEYARD_MAX] =
|
||||
{
|
||||
@@ -419,13 +418,13 @@ class BattlefieldWG : public Battlefield
|
||||
Workshop WorkshopsList;
|
||||
|
||||
GuidSet DefenderPortalList;
|
||||
GuidSet m_KeepGameObject[2];
|
||||
GuidSet m_KeepGameObject[BG_TEAMS_COUNT];
|
||||
GameObjectBuilding BuildingsInZone;
|
||||
|
||||
GuidSet m_vehicles[2];
|
||||
GuidSet m_vehicles[BG_TEAMS_COUNT];
|
||||
GuidSet CanonList;
|
||||
GuidSet KeepCreature[2];
|
||||
GuidSet OutsideCreature[2];
|
||||
GuidSet KeepCreature[BG_TEAMS_COUNT];
|
||||
GuidSet OutsideCreature[BG_TEAMS_COUNT];
|
||||
|
||||
uint32 m_tenacityStack;
|
||||
uint32 m_saveTimer;
|
||||
@@ -437,7 +436,8 @@ uint32 const VehNumWorldState[] = { 3680, 3490 };
|
||||
uint32 const MaxVehNumWorldState[] = { 3681, 3491 };
|
||||
uint32 const ClockWorldState[] = { 3781, 4354 };
|
||||
uint32 const WintergraspFaction[] = { 1732, 1735, 35 };
|
||||
float const WintergraspStalkerPos[] = { 4948.985f, 2937.789f, 550.5172f, 1.815142f };
|
||||
|
||||
Position const WintergraspStalkerPos = { 4948.985f, 2937.789f, 550.5172f, 1.815142f };
|
||||
|
||||
uint8 const WG_MAX_OBJ = 32;
|
||||
uint8 const WG_MAX_TURRET = 15;
|
||||
@@ -445,7 +445,7 @@ uint8 const WG_MAX_KEEP_NPC = 39;
|
||||
uint8 const WG_MAX_OUTSIDE_NPC = 14;
|
||||
uint8 const WG_OUTSIDE_ALLIANCE_NPC = 7;
|
||||
uint8 const WG_MAX_TELEPORTER = 12;
|
||||
uint8 const WG_MAX_WORKSHOP = 6;
|
||||
uint8 const WG_MAX_WORKSHOP = 6;
|
||||
|
||||
enum WintergraspGameObjectBuildingType
|
||||
{
|
||||
@@ -1059,16 +1059,7 @@ const WGWorkshopData WorkshopsData[WG_MAX_WORKSHOP] =
|
||||
// Structure for different buildings that can be destroyed during battle
|
||||
struct BfWGGameObjectBuilding
|
||||
{
|
||||
BfWGGameObjectBuilding(BattlefieldWG* WG)
|
||||
{
|
||||
m_WG = WG;
|
||||
m_Team = 0;
|
||||
m_BuildGUID = 0;
|
||||
m_Type = 0;
|
||||
m_WorldState = 0;
|
||||
m_State = 0;
|
||||
m_NameId = 0;
|
||||
}
|
||||
BfWGGameObjectBuilding(BattlefieldWG* wg);
|
||||
|
||||
// the team that controls this point
|
||||
uint8 m_Team;
|
||||
@@ -1100,365 +1091,21 @@ struct BfWGGameObjectBuilding
|
||||
GuidSet m_TowerCannonBottomList;
|
||||
GuidSet m_TurretTopList;
|
||||
|
||||
void Rebuild()
|
||||
{
|
||||
switch (m_Type)
|
||||
{
|
||||
case BATTLEFIELD_WG_OBJECTTYPE_KEEP_TOWER:
|
||||
case BATTLEFIELD_WG_OBJECTTYPE_DOOR_LAST:
|
||||
case BATTLEFIELD_WG_OBJECTTYPE_DOOR:
|
||||
case BATTLEFIELD_WG_OBJECTTYPE_WALL:
|
||||
m_Team = m_WG->GetDefenderTeam(); // Objects that are part of the keep should be the defender's
|
||||
break;
|
||||
case BATTLEFIELD_WG_OBJECTTYPE_TOWER:
|
||||
m_Team = m_WG->GetAttackerTeam(); // The towers in the south should be the attacker's
|
||||
break;
|
||||
default:
|
||||
m_Team = TEAM_NEUTRAL;
|
||||
break;
|
||||
}
|
||||
|
||||
if (GameObject* build = m_WG->GetGameObject(m_BuildGUID))
|
||||
{
|
||||
// Rebuild gameobject
|
||||
if (build->IsDestructibleBuilding())
|
||||
{
|
||||
build->SetDestructibleState(GO_DESTRUCTIBLE_REBUILDING, NULL, true);
|
||||
if (build->GetEntry() == GO_WINTERGRASP_VAULT_GATE)
|
||||
if (GameObject* go = build->FindNearestGameObject(GO_WINTERGRASP_KEEP_COLLISION_WALL, 50.0f))
|
||||
go->SetGoState(GO_STATE_READY);
|
||||
|
||||
// Update worldstate
|
||||
m_State = BATTLEFIELD_WG_OBJECTSTATE_ALLIANCE_INTACT - (m_Team * 3);
|
||||
m_WG->SendUpdateWorldState(m_WorldState, m_State);
|
||||
}
|
||||
UpdateCreatureAndGo();
|
||||
build->SetFaction(WintergraspFaction[m_Team]);
|
||||
}
|
||||
}
|
||||
void Rebuild();
|
||||
|
||||
// Called when associated gameobject is damaged
|
||||
void Damaged()
|
||||
{
|
||||
// Update worldstate
|
||||
m_State = BATTLEFIELD_WG_OBJECTSTATE_ALLIANCE_DAMAGE - (m_Team * 3);
|
||||
m_WG->SendUpdateWorldState(m_WorldState, m_State);
|
||||
|
||||
// Send warning message
|
||||
if (m_NameId) // tower damage + name
|
||||
m_WG->SendWarningToAllInZone(m_NameId);
|
||||
|
||||
for (GuidSet::const_iterator itr = m_CreatureTopList[m_WG->GetAttackerTeam()].begin(); itr != m_CreatureTopList[m_WG->GetAttackerTeam()].end(); ++itr)
|
||||
if (Creature* creature = m_WG->GetCreature(*itr))
|
||||
m_WG->HideNpc(creature);
|
||||
|
||||
for (GuidSet::const_iterator itr = m_TurretTopList.begin(); itr != m_TurretTopList.end(); ++itr)
|
||||
if (Creature* creature = m_WG->GetCreature(*itr))
|
||||
m_WG->HideNpc(creature);
|
||||
|
||||
if (m_Type == BATTLEFIELD_WG_OBJECTTYPE_KEEP_TOWER)
|
||||
m_WG->UpdateDamagedTowerCount(m_WG->GetDefenderTeam());
|
||||
else if (m_Type == BATTLEFIELD_WG_OBJECTTYPE_TOWER)
|
||||
m_WG->UpdateDamagedTowerCount(m_WG->GetAttackerTeam());
|
||||
}
|
||||
void Damaged();
|
||||
|
||||
// Called when associated gameobject is destroyed
|
||||
void Destroyed()
|
||||
{
|
||||
// Update worldstate
|
||||
m_State = BATTLEFIELD_WG_OBJECTSTATE_ALLIANCE_DESTROY - (m_Team * 3);
|
||||
m_WG->SendUpdateWorldState(m_WorldState, m_State);
|
||||
void Destroyed();
|
||||
|
||||
// Warn players
|
||||
if (m_NameId)
|
||||
m_WG->SendWarningToAllInZone(m_NameId);
|
||||
void Init(GameObject* go, uint32 type, uint32 worldstate, uint32 nameId);
|
||||
|
||||
switch (m_Type)
|
||||
{
|
||||
// Inform the global wintergrasp script of the destruction of this object
|
||||
case BATTLEFIELD_WG_OBJECTTYPE_TOWER:
|
||||
case BATTLEFIELD_WG_OBJECTTYPE_KEEP_TOWER:
|
||||
m_WG->UpdatedDestroyedTowerCount(TeamId(m_Team));
|
||||
break;
|
||||
case BATTLEFIELD_WG_OBJECTTYPE_DOOR_LAST:
|
||||
if (GameObject* build = m_WG->GetGameObject(m_BuildGUID))
|
||||
if (GameObject* go = build->FindNearestGameObject(GO_WINTERGRASP_KEEP_COLLISION_WALL, 50.0f))
|
||||
go->SetGoState(GO_STATE_ACTIVE);
|
||||
m_WG->SetRelicInteractible(true);
|
||||
if (m_WG->GetRelic())
|
||||
m_WG->GetRelic()->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE);
|
||||
else
|
||||
TC_LOG_ERROR("misc", "BattlefieldWG: Relic not found.");
|
||||
break;
|
||||
}
|
||||
void UpdateCreatureAndGo();
|
||||
|
||||
m_WG->BrokenWallOrTower(TeamId(m_Team));
|
||||
}
|
||||
void UpdateTurretAttack(bool disable);
|
||||
|
||||
void Init(GameObject* go, uint32 type, uint32 worldstate, uint32 nameid)
|
||||
{
|
||||
if (!go)
|
||||
return;
|
||||
|
||||
// GameObject associated to object
|
||||
m_BuildGUID = go->GetGUID();
|
||||
|
||||
// Type of building (WALL/TOWER/DOOR)
|
||||
m_Type = type;
|
||||
|
||||
// WorldState for client (icon on map)
|
||||
m_WorldState = worldstate;
|
||||
|
||||
// NameId for Warning text
|
||||
m_NameId = nameid;
|
||||
|
||||
switch (m_Type)
|
||||
{
|
||||
case BATTLEFIELD_WG_OBJECTTYPE_KEEP_TOWER:
|
||||
case BATTLEFIELD_WG_OBJECTTYPE_DOOR_LAST:
|
||||
case BATTLEFIELD_WG_OBJECTTYPE_DOOR:
|
||||
case BATTLEFIELD_WG_OBJECTTYPE_WALL:
|
||||
m_Team = m_WG->GetDefenderTeam(); // Objects that are part of the keep should be the defender's
|
||||
break;
|
||||
case BATTLEFIELD_WG_OBJECTTYPE_TOWER:
|
||||
m_Team = m_WG->GetAttackerTeam(); // The towers in the south should be the attacker's
|
||||
break;
|
||||
default:
|
||||
m_Team = TEAM_NEUTRAL;
|
||||
break;
|
||||
}
|
||||
|
||||
m_State = sWorld->getWorldState(m_WorldState);
|
||||
switch (m_State)
|
||||
{
|
||||
case BATTLEFIELD_WG_OBJECTSTATE_ALLIANCE_INTACT:
|
||||
case BATTLEFIELD_WG_OBJECTSTATE_HORDE_INTACT:
|
||||
go->SetDestructibleState(GO_DESTRUCTIBLE_REBUILDING, NULL, true);
|
||||
break;
|
||||
case BATTLEFIELD_WG_OBJECTSTATE_ALLIANCE_DESTROY:
|
||||
case BATTLEFIELD_WG_OBJECTSTATE_HORDE_DESTROY:
|
||||
go->SetDestructibleState(GO_DESTRUCTIBLE_DESTROYED);
|
||||
break;
|
||||
case BATTLEFIELD_WG_OBJECTSTATE_ALLIANCE_DAMAGE:
|
||||
case BATTLEFIELD_WG_OBJECTSTATE_HORDE_DAMAGE:
|
||||
go->SetDestructibleState(GO_DESTRUCTIBLE_DAMAGED);
|
||||
break;
|
||||
}
|
||||
|
||||
int32 towerid = -1;
|
||||
switch (go->GetEntry())
|
||||
{
|
||||
case GO_WINTERGRASP_FORTRESS_TOWER_1:
|
||||
towerid = 0;
|
||||
break;
|
||||
case GO_WINTERGRASP_FORTRESS_TOWER_2:
|
||||
towerid = 1;
|
||||
break;
|
||||
case GO_WINTERGRASP_FORTRESS_TOWER_3:
|
||||
towerid = 2;
|
||||
break;
|
||||
case GO_WINTERGRASP_FORTRESS_TOWER_4:
|
||||
towerid = 3;
|
||||
break;
|
||||
case GO_WINTERGRASP_SHADOWSIGHT_TOWER:
|
||||
towerid = 4;
|
||||
break;
|
||||
case GO_WINTERGRASP_WINTER_S_EDGE_TOWER:
|
||||
towerid = 5;
|
||||
break;
|
||||
case GO_WINTERGRASP_FLAMEWATCH_TOWER:
|
||||
towerid = 6;
|
||||
break;
|
||||
}
|
||||
|
||||
if (towerid > 3) // Attacker towers
|
||||
{
|
||||
// Spawn associate gameobjects
|
||||
for (uint8 i = 0; i < AttackTowers[towerid - 4].nbObject; i++)
|
||||
{
|
||||
WintergraspObjectPositionData gobData = AttackTowers[towerid - 4].GameObject[i];
|
||||
if (GameObject* goHorde = m_WG->SpawnGameObject(gobData.entryHorde, gobData.x, gobData.y, gobData.z, gobData.o))
|
||||
m_GameObjectList[TEAM_HORDE].insert(goHorde->GetGUID());
|
||||
if (GameObject* goAlliance = m_WG->SpawnGameObject(gobData.entryAlliance, gobData.x, gobData.y, gobData.z, gobData.o))
|
||||
m_GameObjectList[TEAM_ALLIANCE].insert(goAlliance->GetGUID());
|
||||
}
|
||||
|
||||
// Spawn associate npc bottom
|
||||
for (uint8 i = 0; i < AttackTowers[towerid - 4].nbCreatureBottom; i++)
|
||||
{
|
||||
WintergraspObjectPositionData creatureData = AttackTowers[towerid - 4].CreatureBottom[i];
|
||||
if (Creature* creature = m_WG->SpawnCreature(creatureData.entryHorde, creatureData.x, creatureData.y, creatureData.z, creatureData.o, TEAM_HORDE))
|
||||
m_CreatureBottomList[TEAM_HORDE].insert(creature->GetGUID());
|
||||
if (Creature* creature = m_WG->SpawnCreature(creatureData.entryAlliance, creatureData.x, creatureData.y, creatureData.z, creatureData.o, TEAM_ALLIANCE))
|
||||
m_CreatureBottomList[TEAM_ALLIANCE].insert(creature->GetGUID());
|
||||
}
|
||||
|
||||
// Spawn associate npc top
|
||||
for (uint8 i = 0; i < AttackTowers[towerid - 4].nbCreatureTop; i++)
|
||||
{
|
||||
WintergraspObjectPositionData creatureData = AttackTowers[towerid - 4].CreatureTop[i];
|
||||
if (Creature* creature = m_WG->SpawnCreature(creatureData.entryHorde, creatureData.x, creatureData.y, creatureData.z, creatureData.o, TEAM_HORDE))
|
||||
m_CreatureTopList[TEAM_HORDE].insert(creature->GetGUID());
|
||||
if (Creature* creature = m_WG->SpawnCreature(creatureData.entryAlliance, creatureData.x, creatureData.y, creatureData.z, creatureData.o, TEAM_ALLIANCE))
|
||||
m_CreatureTopList[TEAM_ALLIANCE].insert(creature->GetGUID());
|
||||
}
|
||||
}
|
||||
|
||||
if (towerid >= 0)
|
||||
{
|
||||
// Spawn Turret bottom
|
||||
for (uint8 i = 0; i < TowerCannon[towerid].nbTowerCannonBottom; i++)
|
||||
{
|
||||
Position turretPos = TowerCannon[towerid].TowerCannonBottom[i].GetPosition();
|
||||
if (Creature* turret = m_WG->SpawnCreature(NPC_WINTERGRASP_TOWER_CANNON, turretPos, TEAM_ALLIANCE))
|
||||
{
|
||||
m_TowerCannonBottomList.insert(turret->GetGUID());
|
||||
switch (go->GetEntry())
|
||||
{
|
||||
case GO_WINTERGRASP_FORTRESS_TOWER_1:
|
||||
case GO_WINTERGRASP_FORTRESS_TOWER_2:
|
||||
case GO_WINTERGRASP_FORTRESS_TOWER_3:
|
||||
case GO_WINTERGRASP_FORTRESS_TOWER_4:
|
||||
turret->setFaction(WintergraspFaction[m_WG->GetDefenderTeam()]);
|
||||
break;
|
||||
case GO_WINTERGRASP_SHADOWSIGHT_TOWER:
|
||||
case GO_WINTERGRASP_WINTER_S_EDGE_TOWER:
|
||||
case GO_WINTERGRASP_FLAMEWATCH_TOWER:
|
||||
turret->setFaction(WintergraspFaction[m_WG->GetAttackerTeam()]);
|
||||
break;
|
||||
}
|
||||
m_WG->HideNpc(turret);
|
||||
}
|
||||
}
|
||||
|
||||
// Spawn Turret top
|
||||
for (uint8 i = 0; i < TowerCannon[towerid].nbTurretTop; i++)
|
||||
{
|
||||
Position towerCannonPos = TowerCannon[towerid].TurretTop[i].GetPosition();
|
||||
if (Creature* turret = m_WG->SpawnCreature(NPC_WINTERGRASP_TOWER_CANNON, towerCannonPos, TeamId(0)))
|
||||
{
|
||||
m_TurretTopList.insert(turret->GetGUID());
|
||||
switch (go->GetEntry())
|
||||
{
|
||||
case GO_WINTERGRASP_FORTRESS_TOWER_1:
|
||||
case GO_WINTERGRASP_FORTRESS_TOWER_2:
|
||||
case GO_WINTERGRASP_FORTRESS_TOWER_3:
|
||||
case GO_WINTERGRASP_FORTRESS_TOWER_4:
|
||||
turret->setFaction(WintergraspFaction[m_WG->GetDefenderTeam()]);
|
||||
break;
|
||||
case GO_WINTERGRASP_SHADOWSIGHT_TOWER:
|
||||
case GO_WINTERGRASP_WINTER_S_EDGE_TOWER:
|
||||
case GO_WINTERGRASP_FLAMEWATCH_TOWER:
|
||||
turret->setFaction(WintergraspFaction[m_WG->GetAttackerTeam()]);
|
||||
break;
|
||||
}
|
||||
m_WG->HideNpc(turret);
|
||||
}
|
||||
}
|
||||
UpdateCreatureAndGo();
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateCreatureAndGo()
|
||||
{
|
||||
for (GuidSet::const_iterator itr = m_CreatureTopList[m_WG->GetDefenderTeam()].begin(); itr != m_CreatureTopList[m_WG->GetDefenderTeam()].end(); ++itr)
|
||||
if (Creature* creature = m_WG->GetCreature(*itr))
|
||||
m_WG->HideNpc(creature);
|
||||
|
||||
for (GuidSet::const_iterator itr = m_CreatureTopList[m_WG->GetAttackerTeam()].begin(); itr != m_CreatureTopList[m_WG->GetAttackerTeam()].end(); ++itr)
|
||||
if (Creature* creature = m_WG->GetCreature(*itr))
|
||||
m_WG->ShowNpc(creature, true);
|
||||
|
||||
for (GuidSet::const_iterator itr = m_CreatureBottomList[m_WG->GetDefenderTeam()].begin(); itr != m_CreatureBottomList[m_WG->GetDefenderTeam()].end(); ++itr)
|
||||
if (Creature* creature = m_WG->GetCreature(*itr))
|
||||
m_WG->HideNpc(creature);
|
||||
|
||||
for (GuidSet::const_iterator itr = m_CreatureBottomList[m_WG->GetAttackerTeam()].begin(); itr != m_CreatureBottomList[m_WG->GetAttackerTeam()].end(); ++itr)
|
||||
if (Creature* creature = m_WG->GetCreature(*itr))
|
||||
m_WG->ShowNpc(creature, true);
|
||||
|
||||
for (GuidSet::const_iterator itr = m_GameObjectList[m_WG->GetDefenderTeam()].begin(); itr != m_GameObjectList[m_WG->GetDefenderTeam()].end(); ++itr)
|
||||
if (GameObject* object = m_WG->GetGameObject(*itr))
|
||||
object->SetRespawnTime(RESPAWN_ONE_DAY);
|
||||
|
||||
for (GuidSet::const_iterator itr = m_GameObjectList[m_WG->GetAttackerTeam()].begin(); itr != m_GameObjectList[m_WG->GetAttackerTeam()].end(); ++itr)
|
||||
if (GameObject* object = m_WG->GetGameObject(*itr))
|
||||
object->SetRespawnTime(RESPAWN_IMMEDIATELY);
|
||||
}
|
||||
|
||||
void UpdateTurretAttack(bool disable)
|
||||
{
|
||||
for (GuidSet::const_iterator itr = m_TowerCannonBottomList.begin(); itr != m_TowerCannonBottomList.end(); ++itr)
|
||||
{
|
||||
if (Creature* creature = m_WG->GetCreature(*itr))
|
||||
{
|
||||
if (GameObject* build = m_WG->GetGameObject(m_BuildGUID))
|
||||
{
|
||||
if (disable)
|
||||
m_WG->HideNpc(creature);
|
||||
else
|
||||
m_WG->ShowNpc(creature, true);
|
||||
|
||||
switch (build->GetEntry())
|
||||
{
|
||||
case GO_WINTERGRASP_FORTRESS_TOWER_1:
|
||||
case GO_WINTERGRASP_FORTRESS_TOWER_2:
|
||||
case GO_WINTERGRASP_FORTRESS_TOWER_3:
|
||||
case GO_WINTERGRASP_FORTRESS_TOWER_4:
|
||||
{
|
||||
creature->setFaction(WintergraspFaction[m_WG->GetDefenderTeam()]);
|
||||
break;
|
||||
}
|
||||
case GO_WINTERGRASP_SHADOWSIGHT_TOWER:
|
||||
case GO_WINTERGRASP_WINTER_S_EDGE_TOWER:
|
||||
case GO_WINTERGRASP_FLAMEWATCH_TOWER:
|
||||
{
|
||||
creature->setFaction(WintergraspFaction[m_WG->GetAttackerTeam()]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (GuidSet::const_iterator itr = m_TurretTopList.begin(); itr != m_TurretTopList.end(); ++itr)
|
||||
{
|
||||
if (Creature* creature = m_WG->GetCreature(*itr))
|
||||
{
|
||||
if (GameObject* build = m_WG->GetGameObject(m_BuildGUID))
|
||||
{
|
||||
if (disable)
|
||||
m_WG->HideNpc(creature);
|
||||
else
|
||||
m_WG->ShowNpc(creature, true);
|
||||
|
||||
switch (build->GetEntry())
|
||||
{
|
||||
case GO_WINTERGRASP_FORTRESS_TOWER_1:
|
||||
case GO_WINTERGRASP_FORTRESS_TOWER_2:
|
||||
case GO_WINTERGRASP_FORTRESS_TOWER_3:
|
||||
case GO_WINTERGRASP_FORTRESS_TOWER_4:
|
||||
{
|
||||
creature->setFaction(WintergraspFaction[m_WG->GetDefenderTeam()]);
|
||||
break;
|
||||
}
|
||||
case GO_WINTERGRASP_SHADOWSIGHT_TOWER:
|
||||
case GO_WINTERGRASP_WINTER_S_EDGE_TOWER:
|
||||
case GO_WINTERGRASP_FLAMEWATCH_TOWER:
|
||||
{
|
||||
creature->setFaction(WintergraspFaction[m_WG->GetAttackerTeam()]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Save()
|
||||
{
|
||||
sWorld->setWorldState(m_WorldState, m_State);
|
||||
}
|
||||
void Save();
|
||||
};
|
||||
|
||||
struct WGWorkshop
|
||||
@@ -1472,64 +1119,13 @@ struct WGWorkshop
|
||||
// for worldstate
|
||||
uint32 state;
|
||||
|
||||
WGWorkshop(BattlefieldWG* _bf, uint8 _workshopId)
|
||||
{
|
||||
ASSERT(_bf || _workshopId < WG_MAX_WORKSHOP);
|
||||
WGWorkshop(BattlefieldWG* _bf, uint8 _workshopId);
|
||||
|
||||
bf = _bf;
|
||||
workshopId = _workshopId;
|
||||
teamControl = BATTLEFIELD_WG_TEAM_NEUTRAL;
|
||||
state = BATTLEFIELD_WG_OBJECTSTATE_NONE;
|
||||
}
|
||||
void GiveControlTo(uint8 team, bool init /*for first call in setup*/);
|
||||
|
||||
void GiveControlTo(uint8 team, bool init /* for first call in setup*/)
|
||||
{
|
||||
switch (team)
|
||||
{
|
||||
case BATTLEFIELD_WG_TEAM_NEUTRAL:
|
||||
{
|
||||
// Send warning message to all player to inform a faction attack to a workshop
|
||||
// alliance / horde attacking a workshop
|
||||
bf->SendWarningToAllInZone(teamControl ? WorkshopsData[workshopId].text : WorkshopsData[workshopId].text + 1);
|
||||
break;
|
||||
}
|
||||
case BATTLEFIELD_WG_TEAM_ALLIANCE:
|
||||
case BATTLEFIELD_WG_TEAM_HORDE:
|
||||
{
|
||||
// Updating worldstate
|
||||
state = team == BATTLEFIELD_WG_TEAM_ALLIANCE ? BATTLEFIELD_WG_OBJECTSTATE_ALLIANCE_INTACT : BATTLEFIELD_WG_OBJECTSTATE_HORDE_INTACT;
|
||||
bf->SendUpdateWorldState(WorkshopsData[workshopId].worldstate, state);
|
||||
void UpdateGraveyardAndWorkshop();
|
||||
|
||||
// Warning message
|
||||
if (!init) // workshop taken - alliance
|
||||
bf->SendWarningToAllInZone(team == BATTLEFIELD_WG_TEAM_ALLIANCE ? WorkshopsData[workshopId].text : WorkshopsData[workshopId].text+1);
|
||||
|
||||
// Found associate graveyard and update it
|
||||
if (workshopId < BATTLEFIELD_WG_WORKSHOP_KEEP_WEST)
|
||||
if (bf->GetGraveyardById(workshopId))
|
||||
bf->GetGraveyardById(workshopId)->GiveControlTo(team == BATTLEFIELD_WG_TEAM_ALLIANCE ? TEAM_ALLIANCE : TEAM_HORDE);
|
||||
|
||||
teamControl = team;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!init)
|
||||
bf->UpdateCounterVehicle(false);
|
||||
}
|
||||
|
||||
void UpdateGraveyardAndWorkshop()
|
||||
{
|
||||
if (workshopId < BATTLEFIELD_WG_WORKSHOP_KEEP_WEST)
|
||||
bf->GetGraveyardById(workshopId)->GiveControlTo(TeamId(teamControl));
|
||||
else
|
||||
GiveControlTo(bf->GetDefenderTeam(), true);
|
||||
}
|
||||
|
||||
void Save()
|
||||
{
|
||||
sWorld->setWorldState(WorkshopsData[workshopId].worldstate, state);
|
||||
}
|
||||
void Save();
|
||||
};
|
||||
|
||||
// Structure for the 6 workshop
|
||||
@@ -1542,153 +1138,26 @@ struct WintergraspWorkshopData
|
||||
uint32 m_WorldState;
|
||||
uint32 m_TeamControl; // Team witch control the workshop
|
||||
GuidSet m_CreatureOnPoint[2]; // Contain all Creature associate to this point
|
||||
GuidSet m_GameObjectOnPoint[2]; // Contain all Gameobject associate to this point
|
||||
GuidSet m_GameObjectOnPoint[2]; // Contain all Gameobject associate to this point
|
||||
uint32 m_NameId; // Id of trinity_string witch contain name of this node, using for alert message
|
||||
|
||||
WintergraspWorkshopData(BattlefieldWG* WG)
|
||||
{
|
||||
m_WG = WG;
|
||||
m_BuildGUID = 0;
|
||||
m_Type = 0;
|
||||
m_State = 0;
|
||||
m_WorldState = 0;
|
||||
m_TeamControl = 0;
|
||||
m_NameId = 0;
|
||||
}
|
||||
WintergraspWorkshopData(BattlefieldWG* wg);
|
||||
|
||||
// Spawning associate creature and store them
|
||||
void AddCreature(const WintergraspObjectPositionData& obj)
|
||||
{
|
||||
if (Creature* creature = m_WG->SpawnCreature(obj.entryHorde, obj.x, obj.y, obj.z, obj.o, TEAM_HORDE))
|
||||
m_CreatureOnPoint[TEAM_HORDE].insert(creature->GetGUID());
|
||||
|
||||
if (Creature* creature = m_WG->SpawnCreature(obj.entryAlliance, obj.x, obj.y, obj.z, obj.o, TEAM_ALLIANCE))
|
||||
m_CreatureOnPoint[TEAM_ALLIANCE].insert(creature->GetGUID());
|
||||
}
|
||||
void AddCreature(WintergraspObjectPositionData const& obj);
|
||||
|
||||
// Spawning Associate gameobject and store them
|
||||
void AddGameObject(const WintergraspObjectPositionData& obj)
|
||||
{
|
||||
if (GameObject* gameobject = m_WG->SpawnGameObject(obj.entryHorde, obj.x, obj.y, obj.z, obj.o))
|
||||
m_GameObjectOnPoint[TEAM_HORDE].insert(gameobject->GetGUID());
|
||||
if (GameObject* gameobject = m_WG->SpawnGameObject(obj.entryAlliance, obj.x, obj.y, obj.z, obj.o))
|
||||
m_GameObjectOnPoint[TEAM_ALLIANCE].insert(gameobject->GetGUID());
|
||||
}
|
||||
void AddGameObject(WintergraspObjectPositionData const& obj);
|
||||
|
||||
// Init method, setup variable
|
||||
void Init(uint32 worldstate, uint32 type, uint32 nameid)
|
||||
{
|
||||
m_WorldState = worldstate;
|
||||
m_Type = type;
|
||||
m_NameId = nameid;
|
||||
}
|
||||
void Init(uint32 worldstate, uint32 type, uint32 nameId);
|
||||
|
||||
// Called on change faction in CapturePoint class
|
||||
void GiveControlTo(uint8 team, bool init /* for first call in setup*/)
|
||||
{
|
||||
switch (team)
|
||||
{
|
||||
case BATTLEFIELD_WG_TEAM_NEUTRAL:
|
||||
{
|
||||
// Send warning message to all player for inform a faction attack a workshop
|
||||
// alliance / horde attacking workshop
|
||||
m_WG->SendWarningToAllInZone(m_TeamControl ? m_NameId : m_NameId + 1);
|
||||
break;
|
||||
}
|
||||
case BATTLEFIELD_WG_TEAM_ALLIANCE:
|
||||
{
|
||||
// Show Alliance creature
|
||||
for (GuidSet::const_iterator itr = m_CreatureOnPoint[TEAM_ALLIANCE].begin(); itr != m_CreatureOnPoint[TEAM_ALLIANCE].end(); ++itr)
|
||||
if (Creature* creature = m_WG->GetCreature(*itr))
|
||||
m_WG->ShowNpc(creature, creature->GetEntry() != 30499);
|
||||
void GiveControlTo(uint8 team, bool init /*for first call in setup*/);
|
||||
|
||||
// Hide Horde creature
|
||||
for (GuidSet::const_iterator itr = m_CreatureOnPoint[TEAM_HORDE].begin(); itr != m_CreatureOnPoint[TEAM_HORDE].end(); ++itr)
|
||||
if (Creature* creature = m_WG->GetCreature(*itr))
|
||||
m_WG->HideNpc(creature);
|
||||
void UpdateGraveyardAndWorkshop();
|
||||
|
||||
// Show Alliance gameobject
|
||||
for (GuidSet::const_iterator itr = m_GameObjectOnPoint[TEAM_ALLIANCE].begin(); itr != m_GameObjectOnPoint[TEAM_ALLIANCE].end(); ++itr)
|
||||
if (GameObject* object = m_WG->GetGameObject(*itr))
|
||||
object->SetRespawnTime(RESPAWN_IMMEDIATELY);
|
||||
|
||||
// Hide Horde gameobject
|
||||
for (GuidSet::const_iterator itr = m_GameObjectOnPoint[TEAM_HORDE].begin(); itr != m_GameObjectOnPoint[TEAM_HORDE].end(); ++itr)
|
||||
if (GameObject* object = m_WG->GetGameObject(*itr))
|
||||
object->SetRespawnTime(RESPAWN_ONE_DAY);
|
||||
|
||||
|
||||
// Updating worldstate
|
||||
m_State = BATTLEFIELD_WG_OBJECTSTATE_ALLIANCE_INTACT;
|
||||
m_WG->SendUpdateWorldState(m_WorldState, m_State);
|
||||
|
||||
// Warning message
|
||||
if (!init) // workshop taken - alliance
|
||||
m_WG->SendWarningToAllInZone(m_NameId);
|
||||
|
||||
// Found associate graveyard and update it
|
||||
if (m_Type < BATTLEFIELD_WG_WORKSHOP_KEEP_WEST)
|
||||
if (m_WG->GetGraveyardById(m_Type))
|
||||
m_WG->GetGraveyardById(m_Type)->GiveControlTo(TEAM_ALLIANCE);
|
||||
|
||||
m_TeamControl = team;
|
||||
break;
|
||||
}
|
||||
case BATTLEFIELD_WG_TEAM_HORDE:
|
||||
{
|
||||
// Show Horde creature
|
||||
for (GuidSet::const_iterator itr = m_CreatureOnPoint[TEAM_HORDE].begin(); itr != m_CreatureOnPoint[TEAM_HORDE].end(); ++itr)
|
||||
if (Creature* creature = m_WG->GetCreature(*itr))
|
||||
m_WG->ShowNpc(creature, creature->GetEntry() != 30400);
|
||||
|
||||
// Hide Alliance creature
|
||||
for (GuidSet::const_iterator itr = m_CreatureOnPoint[TEAM_ALLIANCE].begin(); itr != m_CreatureOnPoint[TEAM_ALLIANCE].end(); ++itr)
|
||||
if (Creature* creature = m_WG->GetCreature(*itr))
|
||||
m_WG->HideNpc(creature);
|
||||
|
||||
// Hide Alliance gameobject
|
||||
for (GuidSet::const_iterator itr = m_GameObjectOnPoint[TEAM_ALLIANCE].begin(); itr != m_GameObjectOnPoint[TEAM_ALLIANCE].end(); ++itr)
|
||||
if (GameObject* object = m_WG->GetGameObject(*itr))
|
||||
object->SetRespawnTime(RESPAWN_ONE_DAY);
|
||||
|
||||
// Show Horde gameobject
|
||||
for (GuidSet::const_iterator itr = m_GameObjectOnPoint[TEAM_HORDE].begin(); itr != m_GameObjectOnPoint[TEAM_HORDE].end(); ++itr)
|
||||
if (GameObject* object = m_WG->GetGameObject(*itr))
|
||||
object->SetRespawnTime(RESPAWN_IMMEDIATELY);
|
||||
|
||||
// Update worlstate
|
||||
m_State = BATTLEFIELD_WG_OBJECTSTATE_HORDE_INTACT;
|
||||
m_WG->SendUpdateWorldState(m_WorldState, m_State);
|
||||
|
||||
// Warning message
|
||||
if (!init) // workshop taken - horde
|
||||
m_WG->SendWarningToAllInZone(m_NameId + 1);
|
||||
|
||||
// Update graveyard control
|
||||
if (m_Type < BATTLEFIELD_WG_WORKSHOP_KEEP_WEST)
|
||||
if (m_WG->GetGraveyardById(m_Type))
|
||||
m_WG->GetGraveyardById(m_Type)->GiveControlTo(TEAM_HORDE);
|
||||
|
||||
m_TeamControl = team;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!init)
|
||||
m_WG->UpdateCounterVehicle(false);
|
||||
}
|
||||
|
||||
void UpdateGraveyardAndWorkshop()
|
||||
{
|
||||
if (m_Type < BATTLEFIELD_WG_WORKSHOP_KEEP_WEST)
|
||||
m_WG->GetGraveyardById(m_Type)->GiveControlTo(TeamId(m_TeamControl));
|
||||
else
|
||||
GiveControlTo(m_WG->GetDefenderTeam(), true);
|
||||
}
|
||||
|
||||
void Save()
|
||||
{
|
||||
sWorld->setWorldState(m_WorldState, m_State);
|
||||
}
|
||||
void Save();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -48,8 +48,8 @@
|
||||
#include "MovementPacketBuilder.h"
|
||||
#include "DynamicTree.h"
|
||||
#include "Group.h"
|
||||
#include "Battlefield.h"
|
||||
#include "BattlefieldMgr.h"
|
||||
#include "Battleground.h"
|
||||
#include "Chat.h"
|
||||
|
||||
uint32 GuidHigh2TypeId(uint32 guid_hi)
|
||||
|
||||
@@ -3309,6 +3309,15 @@ enum BanReturn
|
||||
BAN_NOTFOUND
|
||||
};
|
||||
|
||||
enum BattlegroundTeamId
|
||||
{
|
||||
BG_TEAM_HORDE = 0, // Battleground: Horde, Arena: Green
|
||||
BG_TEAM_ALLIANCE = 1, // Battleground: Alliance, Arena: Gold
|
||||
BG_TEAM_NEUTRAL = 2 // Battleground: Neutral, Arena: None
|
||||
};
|
||||
|
||||
#define BG_TEAMS_COUNT 2
|
||||
|
||||
// indexes of BattlemasterList.dbc
|
||||
enum BattlegroundTypeId
|
||||
{
|
||||
@@ -3448,6 +3457,7 @@ enum DuelCompleteType
|
||||
DUEL_WON = 1,
|
||||
DUEL_FLED = 2
|
||||
};
|
||||
|
||||
// handle the queue types and bg types separately to enable joining queue for different sized arenas at the same time
|
||||
enum BattlegroundQueueTypeId
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user