TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
BattlefieldWG Class Reference

#include <BattlefieldWG.h>

Public Member Functions

 ~BattlefieldWG ()
 
void OnBattleStart () override
 Called when the battle start. More...
 
void OnBattleEnd (bool endByTimer) override
 Called when battle end. More...
 
void OnStartGrouping () override
 Called when grouping starts (15 minutes before battlestart) More...
 
void OnPlayerJoinWar (Player *player) override
 Called when player accept invite to join battle. More...
 
void OnPlayerLeaveWar (Player *player) override
 Called when player left the battle. More...
 
void OnPlayerLeaveZone (Player *player) override
 Called when player left the WG zone. More...
 
void OnPlayerEnterZone (Player *player) override
 Called when player enters in WG zone. More...
 
bool Update (uint32 diff) override
 Called for update battlefield data. More...
 
void OnCreatureCreate (Creature *creature) override
 Called when a creature is created. More...
 
void OnCreatureRemove (Creature *creature) override
 Called when a creature is removed. More...
 
void OnGameObjectCreate (GameObject *go) override
 Called when a gameobject is created. More...
 
void BrokenWallOrTower (TeamId team)
 Called when a wall/tower is broken. More...
 
void UpdateDamagedTowerCount (TeamId team)
 Called when a tower is damaged. More...
 
void UpdatedDestroyedTowerCount (TeamId team)
 Called when tower is broken. More...
 
void DoCompleteOrIncrementAchievement (uint32 achievement, Player *player, uint8 incrementNumber=1) override
 
void RemoveAurasFromPlayer (Player *player)
 
bool SetupBattlefield () override
 Called when battlefield is setup, at server start. More...
 
GameObjectGetRelic ()
 Return pointer to relic object. More...
 
void SetRelic (ObjectGuid relicGUID)
 Define relic object. More...
 
bool CanInteractWithRelic ()
 Check if players can interact with the relic (Only if the last door has been broken) More...
 
void SetRelicInteractible (bool allow)
 Define if player can interact with the relic. More...
 
void UpdateVehicleCountWG ()
 
void UpdateCounterVehicle (bool init)
 
void SendInitWorldStatesTo (Player *player)
 
void SendInitWorldStatesToAll () override
 Send all worldstate data to all player in zone. More...
 
void FillInitialWorldStates (WorldPackets::WorldState::InitWorldStates &packet) override
 
void HandleKill (Player *killer, Unit *victim) override
 Called when a Unit is kill in battlefield zone. More...
 
void OnUnitDeath (Unit *unit) override
 
void PromotePlayer (Player *killer)
 
void UpdateTenacity ()
 
void ProcessEvent (WorldObject *obj, uint32 eventId) override
 
bool FindAndRemoveVehicleFromList (Unit *vehicle)
 
uint8 GetSpiritGraveyardId (uint32 areaId) const
 
uint32 GetData (uint32 data) const override
 
- Public Member Functions inherited from Battlefield
 Battlefield ()
 Constructor. More...
 
virtual ~Battlefield ()
 Destructor. More...
 
void SendUpdateWorldState (uint32 variable, uint32 value, bool hidden=false)
 Update data of a worldstate to all players present in zone. More...
 
void InvitePlayersInZoneToQueue ()
 Invite all players in zone to join the queue, called x minutes before battle start in Update() More...
 
void InvitePlayersInQueueToWar ()
 Invite all players in queue to join battle on battle start. More...
 
void InvitePlayersInZoneToWar ()
 Invite all players in zone to join battle on battle start. More...
 
uint32 GetTypeId () const
 
uint32 GetZoneId () const
 
uint64 GetQueueId () const
 
void TeamApplyBuff (TeamId team, uint32 spellId, uint32 spellId2=0)
 
bool IsWarTime () const
 Return true if battle is start, false if battle is not started. More...
 
int8 GetState () const
 
void ToggleBattlefield (bool enable)
 Enable or Disable battlefield. More...
 
bool IsEnabled () const
 Return if battlefield is enable. More...
 
void KickPlayerFromBattlefield (ObjectGuid guid)
 Kick player from battlefield and teleport him to kick-point location. More...
 
void HandlePlayerEnterZone (Player *player, uint32 zone)
 Called when player (player) enter in zone. More...
 
void HandlePlayerLeaveZone (Player *player, uint32 zone)
 Called when player (player) leave the zone. More...
 
virtual uint64 GetData64 (uint32 dataId) const override
 
virtual void SetData64 (uint32 dataId, uint64 value) override
 
virtual void SetData (uint32 dataId, uint32 value) override
 
virtual void UpdateData (uint32 index, int32 pad)
 
TeamId GetDefenderTeam () const
 
TeamId GetAttackerTeam () const
 
TeamId GetOtherTeam (TeamId team) const
 
void SetDefenderTeam (TeamId team)
 
GroupGetFreeBfRaid (TeamId TeamId)
 Find a not full battlefield group, if there is no, create one. More...
 
GroupGetGroupPlayer (ObjectGuid guid, TeamId TeamId)
 Return battlefield group where player is. More...
 
bool AddOrSetPlayerToCorrectBfGroup (Player *player)
 Force player to join a battlefield group. More...
 
WorldSafeLocsEntry constGetClosestGraveYard (Player *player)
 
virtual void AddPlayerToResurrectQueue (ObjectGuid npc_guid, ObjectGuid player_guid)
 
void RemovePlayerFromResurrectQueue (ObjectGuid player_guid)
 
void SetGraveyardNumber (uint32 number)
 
BfGraveyardGetGraveyardById (uint32 id) const
 
virtual CreatureSpawnCreature (uint32 entry, float x, float y, float z, float o, TeamId)
 
CreatureSpawnCreature (uint32 entry, Position const &pos, TeamId)
 
GameObjectSpawnGameObject (uint32 entry, float x, float y, float z, float o)
 
CreatureGetCreature (ObjectGuid guid)
 
GameObjectGetGameObject (ObjectGuid guid)
 
void SendWarning (uint8 id, WorldObject const *target=nullptr)
 
void PlayerAcceptInviteToQueue (Player *player)
 
void PlayerAcceptInviteToWar (Player *player)
 
uint32 GetBattleId () const
 
void AskToLeaveQueue (Player *player)
 
bool CanFlyIn ()
 Return if we can use mount in battlefield. More...
 
void SendAreaSpiritHealerQueryOpcode (Player *player, ObjectGuid const &guid)
 
void StartBattle ()
 
void EndBattle (bool endByTimer)
 
void HideNpc (Creature *creature)
 
void ShowNpc (Creature *creature, bool aggressive)
 
GraveyardVect GetGraveyardVector () const
 
uint32 GetTimer () const
 
void SetTimer (uint32 timer)
 
void DoPlaySoundToAll (uint32 SoundID)
 
void InvitePlayerToQueue (Player *player)
 
void InvitePlayerToWar (Player *player)
 
void InitStalker (uint32 entry, Position const &pos)
 
- Public Member Functions inherited from ZoneScript
 ZoneScript ()
 
virtual ~ZoneScript ()
 
virtual uint32 GetCreatureEntry (ObjectGuid::LowType, CreatureData const *data)
 
virtual uint32 GetGameObjectEntry (ObjectGuid::LowType, uint32 entry)
 
virtual void OnGameObjectRemove (GameObject *)
 
virtual ObjectGuid GetGuidData (uint32) const
 
virtual void SetGuidData (uint32, ObjectGuid)
 

Protected Attributes

bool m_isRelicInteractible
 
WorkshopSet Workshops
 
GuidSet DefenderPortalList
 
GuidSet m_KeepGameObject [BG_TEAMS_COUNT]
 
GameObjectBuildingSet BuildingsInZone
 
GuidSet m_vehicles [BG_TEAMS_COUNT]
 
GuidSet CanonList
 
GuidSet KeepCreature [BG_TEAMS_COUNT]
 
GuidSet OutsideCreature [BG_TEAMS_COUNT]
 
uint32 m_tenacityStack
 
uint32 m_saveTimer
 
ObjectGuid m_titansRelicGUID
 
- Protected Attributes inherited from Battlefield
ObjectGuid StalkerGuid
 
uint32 m_Timer
 
bool m_IsEnabled
 
bool m_isActive
 
TeamId m_DefenderTeam
 
BfCapturePointMap m_capturePoints
 
GuidSet m_players [BG_TEAMS_COUNT]
 
GuidSet m_PlayersInQueue [BG_TEAMS_COUNT]
 
GuidSet m_PlayersInWar [BG_TEAMS_COUNT]
 
PlayerTimerMap m_InvitedPlayers [BG_TEAMS_COUNT]
 
PlayerTimerMap m_PlayersWillBeKick [BG_TEAMS_COUNT]
 
uint32 m_TypeId
 
uint32 m_BattleId
 
uint32 m_ZoneId
 
uint32 m_MapId
 
Mapm_Map
 
uint32 m_MaxPlayer
 
uint32 m_MinPlayer
 
uint32 m_MinLevel
 
uint32 m_BattleTime
 
uint32 m_NoWarBattleTime
 
uint32 m_RestartAfterCrash
 
uint32 m_TimeForAcceptInvite
 
uint32 m_uiKickDontAcceptTimer
 
WorldLocation KickPosition
 
uint32 m_uiKickAfkPlayersTimer
 
GraveyardVect m_GraveyardList
 
uint32 m_LastResurrectTimer
 
uint32 m_StartGroupingTimer
 
bool m_StartGrouping
 
GuidSet m_Groups [BG_TEAMS_COUNT]
 
std::vector< uint64m_Data64
 
std::vector< uint32m_Data32
 

Additional Inherited Members

- Public Types inherited from Battlefield
typedef std::map< uint32,
BfCapturePoint * > 
BfCapturePointMap
 typedef of map witch store capturepoint and the associate gameobject entry More...
 
- Protected Member Functions inherited from Battlefield
void KickAfkPlayers ()
 
virtual void SendRemoveWorldStates (Player *)
 
void BroadcastPacketToZone (WorldPacket const *data) const
 
void BroadcastPacketToQueue (WorldPacket const *data) const
 
void BroadcastPacketToWar (WorldPacket const *data) const
 
void AddCapturePoint (BfCapturePoint *cp)
 
BfCapturePointGetCapturePoint (uint32 entry) const
 
void RegisterZone (uint32 zoneid)
 
bool HasPlayer (Player *player) const
 
void TeamCastSpell (TeamId team, int32 spellId)
 

Constructor & Destructor Documentation

BattlefieldWG::~BattlefieldWG ( )
Todo:

Implement proper support for vehicle+player teleportation

Use spell victory/defeat in wg instead of RewardMarkOfHonor() && RewardHonor

Add proper implement of achievement

35 {
36  for (WintergraspWorkshop* workshop : Workshops)
37  delete workshop;
38 
39  for (BfWGGameObjectBuilding* building : BuildingsInZone)
40  delete building;
41 }
GameObjectBuildingSet BuildingsInZone
Definition: BattlefieldWG.h:422
Definition: BattlefieldWG.h:1101
Definition: BattlefieldWG.h:1153
WorkshopSet Workshops
Definition: BattlefieldWG.h:418

Member Function Documentation

void BattlefieldWG::BrokenWallOrTower ( TeamId  team)

Called when a wall/tower is broken.

  • Update quest
854 {
855 // might be some use for this in the future. old code commented out below. KL
856 /* if (team == GetDefenderTeam())
857  {
858  for (GuidSet::const_iterator itr = m_PlayersInWar[GetAttackerTeam()].begin(); itr != m_PlayersInWar[GetAttackerTeam()].end(); ++itr)
859  {
860  if (Player* player = ObjectAccessor::FindPlayer(*itr))
861  IncrementQuest(player, WGQuest[player->GetTeamId()][2], true);
862  }
863  }*/
864 }

+ Here is the caller graph for this function:

bool BattlefieldWG::CanInteractWithRelic ( )
inline

Check if players can interact with the relic (Only if the last door has been broken)

389 { return m_isRelicInteractible; }
bool m_isRelicInteractible
Definition: BattlefieldWG.h:416

+ Here is the caller graph for this function:

void BattlefieldWG::DoCompleteOrIncrementAchievement ( uint32  achievement,
Player player,
uint8  incrementNumber = 1 
)
overridevirtual

Reimplemented from Battlefield.

416 {
417  AchievementEntry const* achievementEntry = sAchievementMgr->GetAchievement(achievement);
418 
419  if (!achievementEntry)
420  return;
421 
422  switch (achievement)
423  {
425  {
426  // player->UpdateAchievementCriteria();
427  }
428  default:
429  {
430  if (player)
431  player->CompletedAchievement(achievementEntry);
432  break;
433  }
434  }
435 
436 }
Definition: BattlefieldWG.h:102
Definition: DB2Structure.h:27
#define sAchievementMgr
Definition: AchievementMgr.h:501

+ Here is the caller graph for this function:

void BattlefieldWG::FillInitialWorldStates ( WorldPackets::WorldState::InitWorldStates packet)
overridevirtual

Implements Battlefield.

811 {
814  // Note: cleanup these two, their names look awkward
815  packet.Worldstates.emplace_back(uint32(BATTLEFIELD_WG_WORLD_STATE_ACTIVE), int32(IsWarTime() ? 0 : 1));
817 
818  for (uint32 i = 0; i < 2; ++i)
819  packet.Worldstates.emplace_back(ClockWorldState[i], int32(time(NULL) + (m_Timer / 1000)));
820 
825 
826  for (BfWGGameObjectBuilding* building : BuildingsInZone)
827  building->FillInitialWorldStates(packet);
828 
829  for (WintergraspWorkshop* workshop : Workshops)
830  workshop->FillInitialWorldStates(packet);
831 }
Definition: BattlefieldWG.h:128
std::list< WorldStateInfo > Worldstates
Definition: WorldStatePackets.h:47
GameObjectBuildingSet BuildingsInZone
Definition: BattlefieldWG.h:422
Definition: BattlefieldWG.h:126
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: BattlefieldWG.h:121
Definition: BattlefieldWG.h:127
Definition: BattlefieldWG.h:1101
Definition: BattlefieldWG.h:125
Definition: BattlefieldWG.h:94
uint32 m_Timer
Definition: Battlefield.h:359
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
bool IsWarTime() const
Return true if battle is start, false if battle is not started.
Definition: Battlefield.h:241
Definition: BattlefieldWG.h:122
Definition: BattlefieldWG.h:1153
Definition: BattlefieldWG.h:93
TeamId GetAttackerTeam() const
Definition: Battlefield.h:272
Definition: BattlefieldWG.h:124
uint32 const ClockWorldState[]
Definition: BattlefieldWG.h:437
uint32 GetData(uint32 data) const override
Definition: BattlefieldWG.cpp:788
int32_t int32
Definition: g3dmath.h:167
Definition: BattlefieldWG.h:92
Definition: BattlefieldWG.h:123
uint32_t uint32
Definition: g3dmath.h:168
TeamId GetDefenderTeam() const
Definition: Battlefield.h:271
Definition: BattlefieldWG.h:95
WorkshopSet Workshops
Definition: BattlefieldWG.h:418

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool BattlefieldWG::FindAndRemoveVehicleFromList ( Unit vehicle)
648 {
649  for (uint32 itr = 0; itr < 2; ++itr)
650  {
651  if (m_vehicles[itr].find(vehicle->GetGUID()) != m_vehicles[itr].end())
652  {
653  m_vehicles[itr].erase(vehicle->GetGUID());
654  if (itr == TEAM_HORDE)
656  else
658  return true;
659  }
660  }
661  return false;
662 }
Definition: BattlefieldWG.h:94
GuidSet m_vehicles[BG_TEAMS_COUNT]
Definition: BattlefieldWG.h:424
uint32_t uint32
Definition: Define.h:150
virtual void UpdateData(uint32 index, int32 pad)
Definition: Battlefield.h:268
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: BattlefieldWG.h:95
Definition: SharedDefines.h:993

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 BattlefieldWG::GetData ( uint32  data) const
overridevirtual

Reimplemented from Battlefield.

789 {
790  switch (data)
791  {
792  // Used to determine when the phasing spells must be cast
793  // See: SpellArea::IsFitToRequirements
798  // Graveyards and Workshops are controlled by the same team.
799  if (BfGraveyard const* graveyard = GetGraveyardById(GetSpiritGraveyardId(data)))
800  return graveyard->GetControlTeamId();
801  break;
802  default:
803  break;
804  }
805 
806  return Battlefield::GetData(data);
807 }
virtual uint32 GetData(uint32 dataId) const override
Definition: Battlefield.h:266
Definition: BattlefieldWG.h:135
Definition: BattlefieldWG.h:136
Definition: BattlefieldWG.h:137
uint8 GetSpiritGraveyardId(uint32 areaId) const
Definition: BattlefieldWG.cpp:443
Definition: BattlefieldWG.h:134
BfGraveyard * GetGraveyardById(uint32 id) const
Definition: Battlefield.cpp:556
Definition: Battlefield.h:149

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

GameObject* BattlefieldWG::GetRelic ( )
inline

Return pointer to relic object.

383 { return GetGameObject(m_titansRelicGUID); }
ObjectGuid m_titansRelicGUID
Definition: BattlefieldWG.h:432
GameObject * GetGameObject(ObjectGuid guid)
Definition: Battlefield.cpp:852

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint8 BattlefieldWG::GetSpiritGraveyardId ( uint32  areaId) const
444 {
445  switch (areaId)
446  {
448  return BATTLEFIELD_WG_GY_KEEP;
457  case AREA_WINTERGRASP:
461  default:
462  TC_LOG_ERROR("bg.battlefield", "BattlefieldWG::GetSpiritGraveyardId: Unexpected Area Id %u", areaId);
463  break;
464  }
465 
466  return 0;
467 }
Definition: BattlefieldWG.h:163
Definition: BattlefieldWG.h:135
Definition: BattlefieldWG.h:136
Definition: BattlefieldWG.h:166
Definition: BattlefieldWG.h:137
Definition: BattlefieldWG.h:139
Definition: BattlefieldWG.h:160
Definition: BattlefieldWG.h:134
Definition: BattlefieldWG.h:138
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: BattlefieldWG.h:164
Definition: BattlefieldWG.h:133
Definition: BattlefieldWG.h:162
Definition: BattlefieldWG.h:165
Definition: BattlefieldWG.h:161

+ Here is the caller graph for this function:

void BattlefieldWG::HandleKill ( Player ,
Unit  
)
overridevirtual

Called when a Unit is kill in battlefield zone.

PvP activity worldstate

Reimplemented from Battlefield.

613 {
614  if (killer == victim)
615  return;
616 
617  bool again = false;
618  TeamId killerTeam = killer->GetTeamId();
619 
620  if (victim->GetTypeId() == TYPEID_PLAYER)
621  {
622  for (GuidSet::const_iterator itr = m_PlayersInWar[killerTeam].begin(); itr != m_PlayersInWar[killerTeam].end(); ++itr)
623  if (Player* player = ObjectAccessor::FindPlayer(*itr))
624  if (player->GetDistance2d(killer) < 40)
625  PromotePlayer(player);
626  return;
627  }
628 
629  for (GuidSet::const_iterator itr = KeepCreature[GetOtherTeam(killerTeam)].begin();
630  itr != KeepCreature[GetOtherTeam(killerTeam)].end(); ++itr)
631  {
632  if (Creature* creature = GetCreature(*itr))
633  {
634  if (victim->GetEntry() == creature->GetEntry() && !again)
635  {
636  again = true;
637  for (GuidSet::const_iterator iter = m_PlayersInWar[killerTeam].begin(); iter != m_PlayersInWar[killerTeam].end(); ++iter)
638  if (Player* player = ObjectAccessor::FindPlayer(*iter))
639  if (player->GetDistance2d(killer) < 40.0f)
640  PromotePlayer(player);
641  }
642  }
643  }
645 }
TeamId GetOtherTeam(TeamId team) const
Definition: Battlefield.h:273
Definition: Creature.h:467
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
GuidSet m_PlayersInWar[BG_TEAMS_COUNT]
Definition: Battlefield.h:370
Creature * GetCreature(ObjectGuid guid)
Definition: Battlefield.cpp:845
TeamId
Definition: SharedDefines.h:990
void PromotePlayer(Player *killer)
Definition: BattlefieldWG.cpp:673
Definition: ObjectGuid.h:33
GuidSet KeepCreature[BG_TEAMS_COUNT]
Definition: BattlefieldWG.h:426

+ Here is the call graph for this function:

void BattlefieldWG::OnBattleEnd ( bool  endByTimer)
overridevirtual

Called when battle end.

  • Remove relic and turret
  • Change banner/npc in keep if it needed
  • Saving battlestate
  • Reward honor/mark to player
  • Remove vehicle
    Parameters
    endByTimer: true if battle ended when timer is at 00:00, false if battle ended by clicking on relic

Reimplemented from Battlefield.

293 {
294  // Remove relic
295  if (!m_titansRelicGUID.IsEmpty())
297  relic->RemoveFromWorld();
299 
300  // Remove turret
301  for (GuidSet::const_iterator itr = CanonList.begin(); itr != CanonList.end(); ++itr)
302  {
303  if (Creature* creature = GetCreature(*itr))
304  {
305  if (!endByTimer)
306  creature->setFaction(WintergraspFaction[GetDefenderTeam()]);
307  HideNpc(creature);
308  }
309  }
310 
311  if (!endByTimer) // One player triggered the relic
312  {
313  // Change all npc in keep
314  for (GuidSet::const_iterator itr = KeepCreature[GetAttackerTeam()].begin(); itr != KeepCreature[GetAttackerTeam()].end(); ++itr)
315  if (Creature* creature = GetCreature(*itr))
316  HideNpc(creature);
317 
318  for (GuidSet::const_iterator itr = KeepCreature[GetDefenderTeam()].begin(); itr != KeepCreature[GetDefenderTeam()].end(); ++itr)
319  if (Creature* creature = GetCreature(*itr))
320  ShowNpc(creature, true);
321 
322  // Change all npc out of keep
323  for (GuidSet::const_iterator itr = OutsideCreature[GetDefenderTeam()].begin(); itr != OutsideCreature[GetDefenderTeam()].end(); ++itr)
324  if (Creature* creature = GetCreature(*itr))
325  HideNpc(creature);
326 
327  for (GuidSet::const_iterator itr = OutsideCreature[GetAttackerTeam()].begin(); itr != OutsideCreature[GetAttackerTeam()].end(); ++itr)
328  if (Creature* creature = GetCreature(*itr))
329  ShowNpc(creature, true);
330  }
331 
332  // Update all graveyard, control is to defender when no wartime
333  for (uint8 i = 0; i < BATTLEFIELD_WG_GY_HORDE; i++)
334  if (BfGraveyard* graveyard = GetGraveyardById(i))
335  graveyard->GiveControlTo(GetDefenderTeam());
336 
337  for (GuidSet::const_iterator itr = m_KeepGameObject[GetDefenderTeam()].begin(); itr != m_KeepGameObject[GetDefenderTeam()].end(); ++itr)
338  if (GameObject* object = GetGameObject(*itr))
339  object->SetRespawnTime(RESPAWN_IMMEDIATELY);
340 
341  for (GuidSet::const_iterator itr = m_KeepGameObject[GetAttackerTeam()].begin(); itr != m_KeepGameObject[GetAttackerTeam()].end(); ++itr)
342  if (GameObject* object = GetGameObject(*itr))
343  object->SetRespawnTime(RESPAWN_ONE_DAY);
344 
345  // Update portal defender faction
346  for (GuidSet::const_iterator itr = DefenderPortalList.begin(); itr != DefenderPortalList.end(); ++itr)
347  if (GameObject* portal = GetGameObject(*itr))
348  portal->SetFaction(WintergraspFaction[GetDefenderTeam()]);
349 
350  // Saving data
351  for (BfWGGameObjectBuilding* building : BuildingsInZone)
352  building->Save();
353 
354  for (WintergraspWorkshop* workshop : Workshops)
355  workshop->Save();
356 
357  for (GuidSet::const_iterator itr = m_PlayersInWar[GetDefenderTeam()].begin(); itr != m_PlayersInWar[GetDefenderTeam()].end(); ++itr)
358  {
359  if (Player* player = ObjectAccessor::FindPlayer(*itr))
360  {
361  player->CastSpell(player, SPELL_ESSENCE_OF_WINTERGRASP, true);
362  player->CastSpell(player, SPELL_VICTORY_REWARD, true);
363  // Send Wintergrasp victory achievement
365  // Award achievement for succeeding in Wintergrasp in 10 minutes or less
366  if (!endByTimer && GetTimer() <= 10000)
368  }
369  }
370 
371  for (GuidSet::const_iterator itr = m_PlayersInWar[GetAttackerTeam()].begin(); itr != m_PlayersInWar[GetAttackerTeam()].end(); ++itr)
372  if (Player* player = ObjectAccessor::FindPlayer(*itr))
373  player->CastSpell(player, SPELL_DEFEAT_REWARD, true);
374 
375  for (uint8 team = 0; team < 2; ++team)
376  {
377  for (GuidSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
378  if (Player* player = ObjectAccessor::FindPlayer(*itr))
379  RemoveAurasFromPlayer(player);
380 
381  m_PlayersInWar[team].clear();
382 
383  for (GuidSet::const_iterator itr = m_vehicles[team].begin(); itr != m_vehicles[team].end(); ++itr)
384  if (Creature* creature = GetCreature(*itr))
385  if (creature->IsVehicle())
386  creature->DespawnOrUnsummon();
387 
388  m_vehicles[team].clear();
389  }
390 
391  if (!endByTimer)
392  {
393  for (uint8 team = 0; team < 2; ++team)
394  {
395  for (GuidSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
396  {
397  if (Player* player = ObjectAccessor::FindPlayer(*itr))
398  {
399  player->RemoveAurasDueToSpell(m_DefenderTeam == TEAM_ALLIANCE ? SPELL_HORDE_CONTROL_PHASE_SHIFT : SPELL_ALLIANCE_CONTROL_PHASE_SHIFT, player->GetGUID());
400  player->AddAura(m_DefenderTeam == TEAM_HORDE ? SPELL_HORDE_CONTROL_PHASE_SHIFT : SPELL_ALLIANCE_CONTROL_PHASE_SHIFT, player);
401  }
402  }
403  }
404  }
405 
406  if (!endByTimer) // win alli/horde
408  else // defend alli/horde
410 }
Definition: BattlefieldWG.h:75
Definition: BattlefieldWG.h:545
Definition: Battleground.h:129
Definition: BattlefieldWG.h:548
void DoCompleteOrIncrementAchievement(uint32 achievement, Player *player, uint8 incrementNumber=1) override
Definition: BattlefieldWG.cpp:415
void HideNpc(Creature *creature)
Definition: Battlefield.cpp:472
Definition: BattlefieldWG.h:101
Definition: BattlefieldWG.h:60
GameObjectBuildingSet BuildingsInZone
Definition: BattlefieldWG.h:422
void RemoveAurasFromPlayer(Player *player)
Definition: BattlefieldWG.cpp:704
uint32 const WintergraspFaction[]
Definition: BattlefieldWG.h:438
Definition: Creature.h:467
Definition: BattlefieldWG.h:1101
Definition: BattlefieldWG.h:82
void SendWarning(uint8 id, WorldObject const *target=nullptr)
Definition: Battlefield.cpp:433
Definition: BattlefieldWG.h:108
void ShowNpc(Creature *creature, bool aggressive)
Definition: Battlefield.cpp:481
uint32 GetTimer() const
Definition: Battlefield.h:347
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
Definition: BattlefieldWG.h:83
GuidSet m_vehicles[BG_TEAMS_COUNT]
Definition: BattlefieldWG.h:424
GuidSet CanonList
Definition: BattlefieldWG.h:425
GuidSet m_PlayersInWar[BG_TEAMS_COUNT]
Definition: Battlefield.h:370
ObjectGuid m_titansRelicGUID
Definition: BattlefieldWG.h:432
Definition: BattlefieldWG.h:546
GuidSet OutsideCreature[BG_TEAMS_COUNT]
Definition: BattlefieldWG.h:427
BfGraveyard * GetGraveyardById(uint32 id) const
Definition: Battlefield.cpp:556
Creature * GetCreature(ObjectGuid guid)
Definition: Battlefield.cpp:845
GuidSet m_players[BG_TEAMS_COUNT]
Definition: Battlefield.h:368
Definition: BattlefieldWG.h:547
Definition: SharedDefines.h:992
Definition: GameObject.h:880
Definition: Battleground.h:128
GuidSet m_KeepGameObject[BG_TEAMS_COUNT]
Definition: BattlefieldWG.h:421
Definition: BattlefieldWG.h:61
Definition: BattlefieldWG.h:1153
void Clear()
Definition: ObjectGuid.h:215
TeamId GetAttackerTeam() const
Definition: Battlefield.h:272
uint8_t uint8
Definition: Define.h:152
GuidSet DefenderPortalList
Definition: BattlefieldWG.h:420
TeamId GetDefenderTeam() const
Definition: Battlefield.h:271
GuidSet KeepCreature[BG_TEAMS_COUNT]
Definition: BattlefieldWG.h:426
Definition: SharedDefines.h:993
Definition: BattlefieldWG.h:165
TeamId m_DefenderTeam
Definition: Battlefield.h:362
WorkshopSet Workshops
Definition: BattlefieldWG.h:418
GameObject * GetGameObject(ObjectGuid guid)
Definition: Battlefield.cpp:852
bool IsEmpty() const
Definition: ObjectGuid.h:242
Definition: Battlefield.h:149

+ Here is the call graph for this function:

void BattlefieldWG::OnBattleStart ( )
overridevirtual

Called when the battle start.

  • Spawn relic and turret
  • Rebuild tower and wall
  • Invite player to war

Reimplemented from Battlefield.

212 {
213  // Spawn titan relic
214  if (GameObject* relic = SpawnGameObject(GO_WINTERGRASP_TITAN_S_RELIC, 5440.0f, 2840.8f, 430.43f, 0))
215  {
216  // Update faction of relic, only attacker can click on
217  relic->SetFaction(WintergraspFaction[GetAttackerTeam()]);
218  // Set in use (not allow to click on before last door is broken)
219  relic->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE);
220  m_titansRelicGUID = relic->GetGUID();
221  }
222  else
223  TC_LOG_ERROR("bg.battlefield", "WG: Failed to spawn titan relic.");
224 
225 
226  // Update tower visibility and update faction
227  for (GuidSet::const_iterator itr = CanonList.begin(); itr != CanonList.end(); ++itr)
228  {
229  if (Creature* creature = GetCreature(*itr))
230  {
231  ShowNpc(creature, true);
232  creature->setFaction(WintergraspFaction[GetDefenderTeam()]);
233  }
234  }
235 
236  // Rebuild all wall
237  for (BfWGGameObjectBuilding* building : BuildingsInZone)
238  {
239  building->Rebuild();
240  building->UpdateTurretAttack(false);
241  }
242 
247 
248  // Update graveyard (in no war time all graveyard is to deffender, in war time, depend of base)
249  for (WintergraspWorkshop* workshop : Workshops)
250  workshop->UpdateGraveyardAndWorkshop();
251 
252  for (uint8 team = 0; team < 2; ++team)
253  for (GuidSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
254  {
255  // Kick player in orb room, TODO: offline player ?
256  if (Player* player = ObjectAccessor::FindPlayer(*itr))
257  {
258  float x, y, z;
259  player->GetPosition(x, y, z);
260  if (5500 > x && x > 5392 && y < 2880 && y > 2800 && z < 480)
261  player->TeleportTo(571, 5349.8686f, 2838.481f, 409.240f, 0.046328f);
262  SendInitWorldStatesTo(player);
263  }
264  }
265  // Initialize vehicle counter
266  UpdateCounterVehicle(true);
267  // Send start warning to all players
269 }
Definition: BattlefieldWG.h:91
void SendInitWorldStatesTo(Player *player)
Definition: BattlefieldWG.cpp:833
GameObjectBuildingSet BuildingsInZone
Definition: BattlefieldWG.h:422
uint32 const WintergraspFaction[]
Definition: BattlefieldWG.h:438
void UpdateCounterVehicle(bool init)
Definition: BattlefieldWG.cpp:271
Definition: Creature.h:467
Definition: BattlefieldWG.h:1101
Definition: SharedDefines.h:2121
GameObject * SpawnGameObject(uint32 entry, float x, float y, float z, float o)
Definition: Battlefield.cpp:812
void SendWarning(uint8 id, WorldObject const *target=nullptr)
Definition: Battlefield.cpp:433
void ShowNpc(Creature *creature, bool aggressive)
Definition: Battlefield.cpp:481
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
GuidSet CanonList
Definition: BattlefieldWG.h:425
Definition: BattlefieldWG.h:90
Definition: BattlefieldWG.h:566
G3D::int16 z
Definition: Vector3int16.h:46
ObjectGuid m_titansRelicGUID
Definition: BattlefieldWG.h:432
Creature * GetCreature(ObjectGuid guid)
Definition: Battlefield.cpp:845
GuidSet m_players[BG_TEAMS_COUNT]
Definition: Battlefield.h:368
G3D::int16 y
Definition: Vector2int16.h:38
Definition: GameObject.h:880
Definition: UpdateFields.h:319
Definition: BattlefieldWG.h:1153
TeamId GetAttackerTeam() const
Definition: Battlefield.h:272
Definition: BattlefieldWG.h:88
Definition: BattlefieldWG.h:89
virtual void SetData(uint32 dataId, uint32 value) override
Definition: Battlefield.h:267
uint8_t uint8
Definition: Define.h:152
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
TeamId GetDefenderTeam() const
Definition: Battlefield.h:271
G3D::int16 x
Definition: Vector2int16.h:37
Definition: BattlefieldWG.h:544
WorkshopSet Workshops
Definition: BattlefieldWG.h:418

+ Here is the call graph for this function:

void BattlefieldWG::OnCreatureCreate ( Creature creature)
overridevirtual

Called when a creature is created.

  • Update vehicle count

Reimplemented from ZoneScript.

470 {
471  // Accessing to db spawned creatures
472  switch (creature->GetEntry())
473  {
476  {
477  TeamId teamId = (creature->GetEntry() == NPC_DWARVEN_SPIRIT_GUIDE ? TEAM_ALLIANCE : TEAM_HORDE);
478  uint8 graveyardId = GetSpiritGraveyardId(creature->GetAreaId());
479  if (m_GraveyardList[graveyardId])
480  m_GraveyardList[graveyardId]->SetSpirit(creature, teamId);
481  break;
482  }
483  }
484 
485  // untested code - not sure if it is valid.
486  if (IsWarTime())
487  {
488  switch (creature->GetEntry())
489  {
494  {
495  if (!creature->ToTempSummon() || !creature->ToTempSummon()->GetSummonerGUID() || !ObjectAccessor::FindPlayer(creature->ToTempSummon()->GetSummonerGUID()))
496  {
497  creature->DespawnOrUnsummon();
498  return;
499  }
500 
502  TeamId team = creator->GetTeamId();
503 
504  if (team == TEAM_HORDE)
505  {
507  {
509  creature->AddAura(SPELL_HORDE_FLAG, creature);
510  m_vehicles[team].insert(creature->GetGUID());
512  }
513  else
514  {
515  creature->DespawnOrUnsummon();
516  return;
517  }
518  }
519  else
520  {
522  {
524  creature->AddAura(SPELL_ALLIANCE_FLAG, creature);
525  m_vehicles[team].insert(creature->GetGUID());
527  }
528  else
529  {
530  creature->DespawnOrUnsummon();
531  return;
532  }
533  }
534 
535  creature->CastSpell(creator, SPELL_GRAB_PASSENGER, true);
536  break;
537  }
538  }
539  }
540 }
void DespawnOrUnsummon(uint32 msTimeToDespawn=0)
Definition: Creature.cpp:1774
Definition: BattlefieldWG.h:207
Definition: BattlefieldWG.h:212
Definition: BattlefieldWG.h:211
Aura * AddAura(uint32 spellId, Unit *target)
Definition: Unit.cpp:14463
GraveyardVect m_GraveyardList
Definition: Battlefield.h:393
uint8 GetSpiritGraveyardId(uint32 areaId) const
Definition: BattlefieldWG.cpp:443
Definition: BattlefieldWG.h:210
Definition: BattlefieldWG.h:57
TempSummon * ToTempSummon()
Definition: Unit.h:2206
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
Definition: BattlefieldWG.h:94
GuidSet m_vehicles[BG_TEAMS_COUNT]
Definition: BattlefieldWG.h:424
bool IsWarTime() const
Return true if battle is start, false if battle is not started.
Definition: Battlefield.h:241
Definition: SharedDefines.h:992
virtual void UpdateData(uint32 index, int32 pad)
Definition: Battlefield.h:268
Definition: BattlefieldWG.h:55
uint32 GetAreaId() const
Definition: Object.cpp:1530
ObjectGuid GetSummonerGUID() const
Definition: TemporarySummon.h:54
TeamId
Definition: SharedDefines.h:990
Definition: BattlefieldWG.h:93
ObjectGuid const & GetGUID() const
Definition: Object.h:105
void UpdateVehicleCountWG()
Definition: BattlefieldWG.cpp:952
Definition: BattlefieldWG.h:56
uint32 GetData(uint32 data) const override
Definition: BattlefieldWG.cpp:788
uint8_t uint8
Definition: Define.h:152
Definition: BattlefieldWG.h:92
Definition: BattlefieldWG.h:208
uint32 GetEntry() const
Definition: Object.h:107
Definition: BattlefieldWG.h:95
Definition: SharedDefines.h:993
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:869
Definition: BattlefieldWG.h:213

+ Here is the call graph for this function:

void BattlefieldWG::OnCreatureRemove ( Creature creature)
overridevirtual

Called when a creature is removed.

  • Update vehicle count

Reimplemented from ZoneScript.

543 {
544 /* possibly can be used later
545  if (IsWarTime())
546  {
547  switch (creature->GetEntry())
548  {
549  case NPC_WINTERGRASP_SIEGE_ENGINE_ALLIANCE:
550  case NPC_WINTERGRASP_SIEGE_ENGINE_HORDE:
551  case NPC_WINTERGRASP_CATAPULT:
552  case NPC_WINTERGRASP_DEMOLISHER:
553  {
554  uint8 team;
555  if (creature->getFaction() == WintergraspFaction[TEAM_ALLIANCE])
556  team = TEAM_ALLIANCE;
557  else if (creature->getFaction() == WintergraspFaction[TEAM_HORDE])
558  team = TEAM_HORDE;
559  else
560  return;
561 
562  m_vehicles[team].erase(creature->GetGUID());
563  if (team == TEAM_HORDE)
564  UpdateData(BATTLEFIELD_WG_DATA_VEHICLE_H, -1);
565  else
566  UpdateData(BATTLEFIELD_WG_DATA_VEHICLE_A, -1);
567  UpdateVehicleCountWG();
568 
569  break;
570  }
571  }
572  }*/
573 }
void BattlefieldWG::OnGameObjectCreate ( GameObject go)
overridevirtual

Called when a gameobject is created.

Reimplemented from ZoneScript.

576 {
577  uint8 workshopId = 0;
578 
579  switch (go->GetEntry())
580  {
582  workshopId = BATTLEFIELD_WG_WORKSHOP_NE;
583  break;
585  workshopId = BATTLEFIELD_WG_WORKSHOP_NW;
586  break;
588  workshopId = BATTLEFIELD_WG_WORKSHOP_SE;
589  break;
591  workshopId = BATTLEFIELD_WG_WORKSHOP_SW;
592  break;
593  default:
594  return;
595  }
596 
597  for (WintergraspWorkshop* workshop : Workshops)
598  {
599  if (workshop->GetId() == workshopId)
600  {
602 
603  capturePoint->SetCapturePointData(go);
604  capturePoint->LinkToWorkshop(workshop);
605  AddCapturePoint(capturePoint);
606  break;
607  }
608  }
609 }
Definition: BattlefieldWG.h:561
Definition: BattlefieldWG.h:562
void LinkToWorkshop(WintergraspWorkshop *workshop)
Definition: BattlefieldWG.h:256
Definition: BattlefieldWG.h:491
bool SetCapturePointData(GameObject *capturePoint)
Definition: Battlefield.cpp:922
Definition: BattlefieldWG.h:490
Definition: BattlefieldWG.h:563
Definition: BattlefieldWG.h:488
Definition: BattlefieldWG.h:489
Definition: BattlefieldWG.h:251
Definition: BattlefieldWG.h:564
Definition: BattlefieldWG.h:1153
TeamId GetAttackerTeam() const
Definition: Battlefield.h:272
uint8_t uint8
Definition: Define.h:152
uint32 GetEntry() const
Definition: Object.h:107
WorkshopSet Workshops
Definition: BattlefieldWG.h:418
void AddCapturePoint(BfCapturePoint *cp)
Definition: Battlefield.cpp:448

+ Here is the call graph for this function:

void BattlefieldWG::OnPlayerEnterZone ( Player player)
overridevirtual

Called when player enters in WG zone.

  • Update aura
  • Update worldstate
    Parameters
    player: Player who enters the zone

Reimplemented from Battlefield.

779 {
780  if (!m_isActive)
781  RemoveAurasFromPlayer(player);
782 
784  // Send worldstate to player
785  SendInitWorldStatesTo(player);
786 }
void SendInitWorldStatesTo(Player *player)
Definition: BattlefieldWG.cpp:833
void RemoveAurasFromPlayer(Player *player)
Definition: BattlefieldWG.cpp:704
Definition: BattlefieldWG.h:82
Definition: BattlefieldWG.h:83
bool m_isActive
Definition: Battlefield.h:361
Definition: SharedDefines.h:993
TeamId m_DefenderTeam
Definition: Battlefield.h:362

+ Here is the call graph for this function:

void BattlefieldWG::OnPlayerJoinWar ( Player player)
overridevirtual

Called when player accept invite to join battle.

  • Update aura
  • Teleport if it needed
  • Update worldstate
  • Update tenacity
    Parameters
    playerPlayer who accepted invite

Reimplemented from Battlefield.

717 {
718  RemoveAurasFromPlayer(player);
719 
720  player->CastSpell(player, SPELL_RECRUIT, true);
721 
722  if (player->GetZoneId() != m_ZoneId)
723  {
724  if (player->GetTeamId() == GetDefenderTeam())
725  player->TeleportTo(571, 5345, 2842, 410, 3.14f);
726  else
727  {
728  if (player->GetTeamId() == TEAM_HORDE)
729  player->TeleportTo(571, 5025.857422f, 3674.628906f, 362.737122f, 4.135169f);
730  else
731  player->TeleportTo(571, 5101.284f, 2186.564f, 373.549f, 3.812f);
732  }
733  }
734 
735  UpdateTenacity();
736 
737  if (player->GetTeamId() == GetAttackerTeam())
738  {
740  player->SetAuraStack(SPELL_TOWER_CONTROL, player, 3 - GetData(BATTLEFIELD_WG_DATA_BROKEN_TOWER_ATT));
741  }
742  else
743  {
745  player->SetAuraStack(SPELL_TOWER_CONTROL, player, GetData(BATTLEFIELD_WG_DATA_BROKEN_TOWER_ATT));
746  }
747  SendInitWorldStatesTo(player);
748 }
Definition: BattlefieldWG.h:91
void SendInitWorldStatesTo(Player *player)
Definition: BattlefieldWG.cpp:833
void RemoveAurasFromPlayer(Player *player)
Definition: BattlefieldWG.cpp:704
Definition: BattlefieldWG.h:45
Definition: BattlefieldWG.h:50
uint32 m_ZoneId
Definition: Battlefield.h:377
void UpdateTenacity()
Definition: BattlefieldWG.cpp:960
TeamId GetAttackerTeam() const
Definition: Battlefield.h:272
uint32 GetData(uint32 data) const override
Definition: BattlefieldWG.cpp:788
TeamId GetDefenderTeam() const
Definition: Battlefield.h:271
Definition: SharedDefines.h:993

+ Here is the call graph for this function:

void BattlefieldWG::OnPlayerLeaveWar ( Player player)
overridevirtual

Called when player left the battle.

  • Update player aura
    Parameters
    player: Player who left the battle

Reimplemented from Battlefield.

751 {
752  // Remove all aura from WG /// @todo false we can go out of this zone on retail and keep Rank buff, remove on end of WG
753  if (!player->GetSession()->PlayerLogout())
754  {
755  if (Creature* vehicle = player->GetVehicleCreatureBase()) // Remove vehicle of player if he go out.
756  vehicle->DespawnOrUnsummon();
757 
758  RemoveAurasFromPlayer(player);
759  }
760 
761  player->RemoveAurasDueToSpell(SPELL_HORDE_CONTROLS_FACTORY_PHASE_SHIFT);
762  player->RemoveAurasDueToSpell(SPELL_ALLIANCE_CONTROLS_FACTORY_PHASE_SHIFT);
763  player->RemoveAurasDueToSpell(SPELL_HORDE_CONTROL_PHASE_SHIFT);
764  player->RemoveAurasDueToSpell(SPELL_ALLIANCE_CONTROL_PHASE_SHIFT);
765 }
void RemoveAurasFromPlayer(Player *player)
Definition: BattlefieldWG.cpp:704
Definition: Creature.h:467
Definition: BattlefieldWG.h:82
Definition: BattlefieldWG.h:83
Definition: BattlefieldWG.h:79
Definition: BattlefieldWG.h:80
Creature * GetVehicleCreatureBase() const
Definition: Unit.cpp:14346

+ Here is the call graph for this function:

void BattlefieldWG::OnPlayerLeaveZone ( Player player)
overridevirtual

Called when player left the WG zone.

Parameters
player: Player who left the zone

Reimplemented from Battlefield.

768 {
769  if (!m_isActive)
770  RemoveAurasFromPlayer(player);
771 
772  player->RemoveAurasDueToSpell(SPELL_HORDE_CONTROLS_FACTORY_PHASE_SHIFT);
773  player->RemoveAurasDueToSpell(SPELL_ALLIANCE_CONTROLS_FACTORY_PHASE_SHIFT);
774  player->RemoveAurasDueToSpell(SPELL_HORDE_CONTROL_PHASE_SHIFT);
775  player->RemoveAurasDueToSpell(SPELL_ALLIANCE_CONTROL_PHASE_SHIFT);
776 }
void RemoveAurasFromPlayer(Player *player)
Definition: BattlefieldWG.cpp:704
Definition: BattlefieldWG.h:82
Definition: BattlefieldWG.h:83
Definition: BattlefieldWG.h:79
Definition: BattlefieldWG.h:80
bool m_isActive
Definition: Battlefield.h:361

+ Here is the call graph for this function:

void BattlefieldWG::OnStartGrouping ( )
overridevirtual

Called when grouping starts (15 minutes before battlestart)

  • Invite all player in zone to join queue

Reimplemented from Battlefield.

439 {
441 }
Definition: BattlefieldWG.h:543
void SendWarning(uint8 id, WorldObject const *target=nullptr)
Definition: Battlefield.cpp:433

+ Here is the call graph for this function:

void BattlefieldWG::OnUnitDeath ( Unit unit)
overridevirtual

Reimplemented from ZoneScript.

665 {
666  if (IsWarTime())
667  if (unit->IsVehicle())
670 }
bool IsVehicle() const
Definition: Unit.h:1406
bool FindAndRemoveVehicleFromList(Unit *vehicle)
Definition: BattlefieldWG.cpp:647
bool IsWarTime() const
Return true if battle is start, false if battle is not started.
Definition: Battlefield.h:241
void UpdateVehicleCountWG()
Definition: BattlefieldWG.cpp:952

+ Here is the call graph for this function:

void BattlefieldWG::ProcessEvent ( WorldObject obj,
uint32  eventId 
)
overridevirtual

Reimplemented from ZoneScript.

907 {
908  if (!obj || !IsWarTime())
909  return;
910 
911  // We handle only gameobjects here
912  GameObject* go = obj->ToGameObject();
913  if (!go)
914  return;
915 
916  // On click on titan relic
918  {
919  if (CanInteractWithRelic())
920  EndBattle(false);
921  else if (GameObject* relic = GetRelic())
922  relic->SetRespawnTime(RESPAWN_IMMEDIATELY);
923  }
924 
925  // if destroy or damage event, search the wall/tower and update worldstate/send warning message
926  for (BfWGGameObjectBuilding* building : BuildingsInZone)
927  {
928  if (go->GetGUID() == building->GetGUID())
929  {
930  if (GameObject* buildingGo = GetGameObject(building->GetGUID()))
931  {
932  if (buildingGo->GetGOInfo()->destructibleBuilding.DamagedEvent == eventId)
933  building->Damaged();
934  else if (buildingGo->GetGOInfo()->destructibleBuilding.DestroyedEvent == eventId)
935  building->Destroyed();
936  break;
937  }
938  }
939  }
940 }
Definition: Battleground.h:129
GameObjectBuildingSet BuildingsInZone
Definition: BattlefieldWG.h:422
Definition: BattlefieldWG.h:1101
GameObject * ToGameObject()
Definition: Object.h:200
bool CanInteractWithRelic()
Check if players can interact with the relic (Only if the last door has been broken) ...
Definition: BattlefieldWG.h:389
void EndBattle(bool endByTimer)
Definition: Battlefield.cpp:329
Definition: BattlefieldWG.h:566
bool IsWarTime() const
Return true if battle is start, false if battle is not started.
Definition: Battlefield.h:241
Definition: GameObject.h:880
GameObject * GetRelic()
Return pointer to relic object.
Definition: BattlefieldWG.h:383
ObjectGuid const & GetGUID() const
Definition: Object.h:105
uint32 GetEntry() const
Definition: Object.h:107
GameObject * GetGameObject(ObjectGuid guid)
Definition: Battlefield.cpp:852

+ Here is the call graph for this function:

void BattlefieldWG::PromotePlayer ( Player killer)
674 {
675  if (!m_isActive)
676  return;
677  // Updating rank of player
678  if (Aura* auraRecruit = killer->GetAura(SPELL_RECRUIT))
679  {
680  if (auraRecruit->GetStackAmount() >= 5)
681  {
682  killer->RemoveAura(SPELL_RECRUIT);
683  killer->CastSpell(killer, SPELL_CORPORAL, true);
684  if (Creature* stalker = GetCreature(StalkerGuid))
686  }
687  else
688  killer->CastSpell(killer, SPELL_RECRUIT, true);
689  }
690  else if (Aura* auraCorporal = killer->GetAura(SPELL_CORPORAL))
691  {
692  if (auraCorporal->GetStackAmount() >= 5)
693  {
694  killer->RemoveAura(SPELL_CORPORAL);
695  killer->CastSpell(killer, SPELL_LIEUTENANT, true);
696  if (Creature* stalker = GetCreature(StalkerGuid))
698  }
699  else
700  killer->CastSpell(killer, SPELL_CORPORAL, true);
701  }
702 }
Definition: CreatureTextMgr.h:31
Definition: BattlefieldWG.h:556
Definition: BattlefieldWG.h:46
Definition: BattlefieldWG.h:555
Definition: BattlefieldWG.h:45
Definition: Creature.h:467
Definition: BattlefieldWG.h:47
#define sCreatureTextMgr
Definition: CreatureTextMgr.h:113
Creature * GetCreature(ObjectGuid guid)
Definition: Battlefield.cpp:845
Definition: SharedDefines.h:1006
Definition: SharedDefines.h:4230
ObjectGuid StalkerGuid
Definition: Battlefield.h:358
bool m_isActive
Definition: Battlefield.h:361
Definition: SpellAuras.h:116
Definition: SharedDefines.h:985

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void BattlefieldWG::RemoveAurasFromPlayer ( Player player)
705 {
706  player->RemoveAurasDueToSpell(SPELL_RECRUIT);
707  player->RemoveAurasDueToSpell(SPELL_CORPORAL);
708  player->RemoveAurasDueToSpell(SPELL_LIEUTENANT);
709  player->RemoveAurasDueToSpell(SPELL_TOWER_CONTROL);
710  player->RemoveAurasDueToSpell(SPELL_SPIRITUAL_IMMUNITY);
711  player->RemoveAurasDueToSpell(SPELL_TENACITY);
712  player->RemoveAurasDueToSpell(SPELL_ESSENCE_OF_WINTERGRASP);
713  player->RemoveAurasDueToSpell(SPELL_WINTERGRASP_RESTRICTED_FLIGHT_AREA);
714 }
Definition: BattlefieldWG.h:75
Definition: BattlefieldWG.h:46
Definition: BattlefieldWG.h:48
Definition: BattlefieldWG.h:45
Definition: BattlefieldWG.h:47
Definition: BattlefieldWG.h:50
Definition: BattlefieldWG.h:76
Definition: BattlefieldWG.h:51

+ Here is the caller graph for this function:

void BattlefieldWG::SendInitWorldStatesTo ( Player player)
834 {
836  packet.AreaID = m_ZoneId;
837  packet.MapID = m_MapId;
838  packet.SubareaID = 0;
839 
840  FillInitialWorldStates(packet);
841 
842  player->SendDirectMessage(packet.Write());
843 }
uint32 MapID
MapId.
Definition: WorldStatePackets.h:45
uint32 m_MapId
Definition: Battlefield.h:378
Definition: WorldStatePackets.h:27
uint32 m_ZoneId
Definition: Battlefield.h:377
uint32 SubareaID
AreaId.
Definition: WorldStatePackets.h:44
void FillInitialWorldStates(WorldPackets::WorldState::InitWorldStates &packet) override
Definition: BattlefieldWG.cpp:810
WorldPacket const * Write() override
Definition: WorldStatePackets.cpp:23
uint32 AreaID
ZoneId.
Definition: WorldStatePackets.h:43

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void BattlefieldWG::SendInitWorldStatesToAll ( )
overridevirtual

Send all worldstate data to all player in zone.

Implements Battlefield.

846 {
847  for (uint8 team = 0; team < 2; team++)
848  for (GuidSet::iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
849  if (Player* player = ObjectAccessor::FindPlayer(*itr))
850  SendInitWorldStatesTo(player);
851 }
void SendInitWorldStatesTo(Player *player)
Definition: BattlefieldWG.cpp:833
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
GuidSet m_players[BG_TEAMS_COUNT]
Definition: Battlefield.h:368
uint8_t uint8
Definition: Define.h:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void BattlefieldWG::SetRelic ( ObjectGuid  relicGUID)
inline

Define relic object.

386 { m_titansRelicGUID = relicGUID; }
ObjectGuid m_titansRelicGUID
Definition: BattlefieldWG.h:432
void BattlefieldWG::SetRelicInteractible ( bool  allow)
inline

Define if player can interact with the relic.

392 { m_isRelicInteractible = allow; }
bool m_isRelicInteractible
Definition: BattlefieldWG.h:416

+ Here is the caller graph for this function:

bool BattlefieldWG::SetupBattlefield ( )
overridevirtual

Called when battlefield is setup, at server start.

Reimplemented from Battlefield.

44 {
45  m_TypeId = BATTLEFIELD_WG; // See enum BattlefieldTypes
49  m_Map = sMapMgr->FindMap(m_MapId, 0);
50 
52 
60 
63  m_StartGrouping = false;
64 
65  m_tenacityStack = 0;
66 
67  KickPosition.Relocate(5728.117f, 2714.346f, 697.733f, 0);
69 
71 
73 
74  m_saveTimer = 60000;
75 
76  // Init GraveYards
78 
79  // Load from db
80  if ((sWorld->getWorldState(BATTLEFIELD_WG_WORLD_STATE_ACTIVE) == 0) && (sWorld->getWorldState(BATTLEFIELD_WG_WORLD_STATE_DEFENDER) == 0)
81  && (sWorld->getWorldState(ClockWorldState[0]) == 0))
82  {
83  sWorld->setWorldState(BATTLEFIELD_WG_WORLD_STATE_ACTIVE, uint64(false));
85  sWorld->setWorldState(ClockWorldState[0], uint64(m_NoWarBattleTime));
86  }
87 
90 
91  m_Timer = sWorld->getWorldState(ClockWorldState[0]);
92  if (m_isActive)
93  {
94  m_isActive = false;
95  m_Timer = m_RestartAfterCrash;
96  }
97 
98  for (uint8 i = 0; i < BATTLEFIELD_WG_GRAVEYARD_MAX; i++)
99  {
100  BfGraveyardWG* graveyard = new BfGraveyardWG(this);
101 
102  // When between games, the graveyard is controlled by the defending team
103  if (WGGraveYard[i].startcontrol == TEAM_NEUTRAL)
104  graveyard->Initialize(m_DefenderTeam, WGGraveYard[i].gyid);
105  else
106  graveyard->Initialize(WGGraveYard[i].startcontrol, WGGraveYard[i].gyid);
107 
108  graveyard->SetTextId(WGGraveYard[i].textid);
109  m_GraveyardList[i] = graveyard;
110  }
111 
112 
113  // Spawn workshop creatures and gameobjects
114  for (uint8 i = 0; i < WG_MAX_WORKSHOP; i++)
115  {
116  WintergraspWorkshop* workshop = new WintergraspWorkshop(this, i);
118  workshop->GiveControlTo(GetAttackerTeam(), true);
119  else
120  workshop->GiveControlTo(GetDefenderTeam(), true);
121 
122  // Note: Capture point is added once the gameobject is created.
123  Workshops.insert(workshop);
124  }
125 
126  // Spawn NPCs in the defender's keep, both Horde and Alliance
127  for (uint8 i = 0; i < WG_MAX_KEEP_NPC; i++)
128  {
129  // Horde npc
130  if (Creature* creature = SpawnCreature(WGKeepNPC[i].entryHorde, WGKeepNPC[i].x, WGKeepNPC[i].y, WGKeepNPC[i].z, WGKeepNPC[i].o, TEAM_HORDE))
131  KeepCreature[TEAM_HORDE].insert(creature->GetGUID());
132  // Alliance npc
133  if (Creature* creature = SpawnCreature(WGKeepNPC[i].entryAlliance, WGKeepNPC[i].x, WGKeepNPC[i].y, WGKeepNPC[i].z, WGKeepNPC[i].o, TEAM_ALLIANCE))
134  KeepCreature[TEAM_ALLIANCE].insert(creature->GetGUID());
135  }
136 
137  // Hide NPCs from the Attacker's team in the keep
138  for (GuidSet::const_iterator itr = KeepCreature[GetAttackerTeam()].begin(); itr != KeepCreature[GetAttackerTeam()].end(); ++itr)
139  if (Creature* creature = GetCreature(*itr))
140  HideNpc(creature);
141 
142  // Spawn Horde NPCs outside the keep
143  for (uint8 i = 0; i < WG_OUTSIDE_ALLIANCE_NPC; i++)
144  if (Creature* creature = SpawnCreature(WGOutsideNPC[i].entryHorde, WGOutsideNPC[i].x, WGOutsideNPC[i].y, WGOutsideNPC[i].z, WGOutsideNPC[i].o, TEAM_HORDE))
145  OutsideCreature[TEAM_HORDE].insert(creature->GetGUID());
146 
147  // Spawn Alliance NPCs outside the keep
148  for (uint8 i = WG_OUTSIDE_ALLIANCE_NPC; i < WG_MAX_OUTSIDE_NPC; i++)
149  if (Creature* creature = SpawnCreature(WGOutsideNPC[i].entryAlliance, WGOutsideNPC[i].x, WGOutsideNPC[i].y, WGOutsideNPC[i].z, WGOutsideNPC[i].o, TEAM_ALLIANCE))
150  OutsideCreature[TEAM_ALLIANCE].insert(creature->GetGUID());
151 
152  // Hide units outside the keep that are defenders
153  for (GuidSet::const_iterator itr = OutsideCreature[GetDefenderTeam()].begin(); itr != OutsideCreature[GetDefenderTeam()].end(); ++itr)
154  if (Creature* creature = GetCreature(*itr))
155  HideNpc(creature);
156 
157  // Spawn turrets and hide them per default
158  for (uint8 i = 0; i < WG_MAX_TURRET; i++)
159  {
160  Position towerCannonPos = WGTurret[i].GetPosition();
161  if (Creature* creature = SpawnCreature(NPC_WINTERGRASP_TOWER_CANNON, towerCannonPos, TEAM_ALLIANCE))
162  {
163  CanonList.insert(creature->GetGUID());
164  HideNpc(creature);
165  }
166  }
167 
168  // Spawn all gameobjects
169  for (uint8 i = 0; i < WG_MAX_OBJ; i++)
170  {
172  {
174  b->Init(go);
175  if (!IsEnabled() && go->GetEntry() == GO_WINTERGRASP_VAULT_GATE)
176  go->SetDestructibleState(GO_DESTRUCTIBLE_DESTROYED);
177  BuildingsInZone.insert(b);
178  }
179  }
180 
181  // Spawning portal defender
182  for (uint8 i = 0; i < WG_MAX_TELEPORTER; i++)
183  {
185  {
186  DefenderPortalList.insert(go->GetGUID());
187  go->SetFaction(WintergraspFaction[GetDefenderTeam()]);
188  }
189  }
190 
191  UpdateCounterVehicle(true);
192  return true;
193 }
Map * m_Map
Definition: Battlefield.h:379
Definition: Battlefield.h:27
uint8 const WG_MAX_OUTSIDE_NPC
Definition: BattlefieldWG.h:445
WorldLocation KickPosition
Definition: Battlefield.h:388
Definition: BattlefieldWG.h:185
Definition: World.h:350
Definition: BattlefieldWG.h:39
void HideNpc(Creature *creature)
Definition: Battlefield.cpp:472
Definition: BattlefieldWG.h:492
Position const WintergraspStalkerPos
Definition: BattlefieldWG.h:440
GameObjectBuildingSet BuildingsInZone
Definition: BattlefieldWG.h:422
Definition: BattlefieldWG.h:126
WintergraspObjectPositionData const WGKeepNPC[WG_MAX_KEEP_NPC]
Definition: BattlefieldWG.h:698
uint32 const WintergraspFaction[]
Definition: BattlefieldWG.h:438
void UpdateCounterVehicle(bool init)
Definition: BattlefieldWG.cpp:271
GraveyardVect m_GraveyardList
Definition: Battlefield.h:393
Definition: World.h:168
uint64_t uint64
Definition: g3dmath.h:170
Definition: BattlefieldWG.h:578
Definition: Creature.h:467
Definition: BattlefieldWG.h:1101
void GiveControlTo(TeamId teamId, bool init=false)
Definition: BattlefieldWG.cpp:1451
Definition: BattlefieldWG.h:214
Definition: BattlefieldWG.h:125
Position const WGTurret[WG_MAX_TURRET]
Definition: BattlefieldWG.h:678
#define sWorld
Definition: World.h:887
uint8 const WG_OUTSIDE_ALLIANCE_NPC
Definition: BattlefieldWG.h:446
GameObject * SpawnGameObject(uint32 entry, float x, float y, float z, float o)
Definition: Battlefield.cpp:812
WintergraspTeleporterData const WGPortalDefenderData[WG_MAX_TELEPORTER]
Definition: BattlefieldWG.h:776
uint32 m_saveTimer
Definition: BattlefieldWG.h:430
Definition: Common.h:97
uint32 m_BattleId
Definition: Battlefield.h:376
Definition: SharedDefines.h:994
virtual Creature * SpawnCreature(uint32 entry, float x, float y, float z, float o, TeamId)
Definition: Battlefield.cpp:777
BfWGCoordGY const WGGraveYard[BATTLEFIELD_WG_GRAVEYARD_MAX]
Definition: BattlefieldWG.h:236
uint32 m_mapId
Definition: Position.h:256
GuidSet CanonList
Definition: BattlefieldWG.h:425
void Relocate(float x, float y)
Definition: Position.h:67
uint8 const WG_MAX_TELEPORTER
Definition: BattlefieldWG.h:447
uint32 m_TimeForAcceptInvite
Definition: Battlefield.h:386
uint8 const WG_MAX_WORKSHOP
Definition: BattlefieldWG.h:448
uint32 m_StartGroupingTimer
Definition: Battlefield.h:396
Definition: SharedDefines.h:2146
G3D::int16 z
Definition: Vector3int16.h:46
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:45
uint32 m_Timer
Definition: Battlefield.h:359
uint32 m_MaxPlayer
Definition: Battlefield.h:380
void GetPosition(float &x, float &y) const
Definition: Position.h:109
uint32 m_MapId
Definition: Battlefield.h:378
Definition: World.h:353
GuidSet OutsideCreature[BG_TEAMS_COUNT]
Definition: BattlefieldWG.h:427
Creature * GetCreature(ObjectGuid guid)
Definition: Battlefield.cpp:845
G3D::int16 y
Definition: Vector2int16.h:38
Definition: SharedDefines.h:992
uint32 m_ZoneId
Definition: Battlefield.h:377
Definition: GameObject.h:880
void SetGraveyardNumber(uint32 number)
Definition: Battlefield.h:293
uint8 const WG_MAX_OBJ
Definition: BattlefieldWG.h:442
void InitStalker(uint32 entry, Position const &pos)
Definition: Battlefield.cpp:285
TeamId
Definition: SharedDefines.h:990
uint32 m_MinPlayer
Definition: Battlefield.h:381
Definition: BattlefieldWG.h:38
bool m_IsEnabled
Definition: Battlefield.h:360
Definition: BattlefieldWG.h:1153
Definition: BattlefieldWG.h:96
uint8 const WG_MAX_KEEP_NPC
Definition: BattlefieldWG.h:444
TeamId GetAttackerTeam() const
Definition: Battlefield.h:272
uint32 m_BattleTime
Definition: Battlefield.h:383
std::vector< uint32 > m_Data32
Definition: Battlefield.h:402
Definition: Battlefield.h:33
Definition: Common.h:103
#define sMapMgr
Definition: MapManager.h:194
uint32 const ClockWorldState[]
Definition: BattlefieldWG.h:437
uint8_t uint8
Definition: Define.h:152
Definition: Position.h:27
const WintergraspObjectPositionData WGOutsideNPC[WG_MAX_OUTSIDE_NPC]
Definition: BattlefieldWG.h:749
uint32 m_NoWarBattleTime
Definition: Battlefield.h:384
void RegisterZone(uint32 zoneid)
Definition: Battlefield.cpp:467
bool m_StartGrouping
Definition: Battlefield.h:397
Definition: BattlefieldWG.h:146
GuidSet DefenderPortalList
Definition: BattlefieldWG.h:420
void SetTextId(uint32 textId)
Definition: BattlefieldWG.h:151
bool m_isActive
Definition: Battlefield.h:361
Definition: World.h:351
TeamId GetDefenderTeam() const
Definition: Battlefield.h:271
uint32 m_TypeId
Definition: Battlefield.h:375
G3D::int16 x
Definition: Vector2int16.h:37
GuidSet KeepCreature[BG_TEAMS_COUNT]
Definition: BattlefieldWG.h:426
Definition: World.h:354
Definition: SharedDefines.h:993
uint32 m_RestartAfterCrash
Definition: Battlefield.h:385
uint32 m_MinLevel
Definition: Battlefield.h:382
TeamId m_DefenderTeam
Definition: Battlefield.h:362
WorkshopSet Workshops
Definition: BattlefieldWG.h:418
void Initialize(TeamId startcontrol, uint32 gy)
Definition: Battlefield.cpp:647
bool IsEnabled() const
Return if battlefield is enable.
Definition: Battlefield.h:248
uint8 const WG_MAX_TURRET
Definition: BattlefieldWG.h:443
uint32 m_tenacityStack
Definition: BattlefieldWG.h:429
Definition: BattlefieldWG.h:167
Definition: World.h:352
void Init(GameObject *go)
Definition: BattlefieldWG.cpp:1161
WintergraspBuildingSpawnData const WGGameObjectBuilding[WG_MAX_OBJ]
Definition: BattlefieldWG.h:608

+ Here is the call graph for this function:

bool BattlefieldWG::Update ( uint32  diff)
overridevirtual

Called for update battlefield data.

  • Save battle timer in database every minutes
  • Update imunity aura from graveyard
    Parameters
    diff: time elapsed since the last call (in ms)

Reimplemented from Battlefield.

196 {
197  bool m_return = Battlefield::Update(diff);
198  if (m_saveTimer <= diff)
199  {
202  sWorld->setWorldState(ClockWorldState[0], m_Timer);
204  }
205  else
206  m_saveTimer -= diff;
207 
208  return m_return;
209 }
Definition: BattlefieldWG.h:126
Definition: BattlefieldWG.h:125
#define sWorld
Definition: World.h:887
uint32 m_saveTimer
Definition: BattlefieldWG.h:430
uint32 m_Timer
Definition: Battlefield.h:359
Definition: Common.h:103
uint32 const ClockWorldState[]
Definition: BattlefieldWG.h:437
bool m_isActive
Definition: Battlefield.h:361
virtual bool Update(uint32 diff)
Called every time for update bf data and time.
Definition: Battlefield.cpp:128
TeamId m_DefenderTeam
Definition: Battlefield.h:362

+ Here is the call graph for this function:

void BattlefieldWG::UpdateCounterVehicle ( bool  init)
272 {
273  if (init)
274  {
277  }
280 
281  for (WintergraspWorkshop* workshop : Workshops)
282  {
283  if (workshop->GetTeamControl() == TEAM_ALLIANCE)
285  else if (workshop->GetTeamControl() == TEAM_HORDE)
287  }
288 
290 }
Definition: BattlefieldWG.h:94
Definition: SharedDefines.h:992
virtual void UpdateData(uint32 index, int32 pad)
Definition: Battlefield.h:268
Definition: BattlefieldWG.h:1153
Definition: BattlefieldWG.h:93
void UpdateVehicleCountWG()
Definition: BattlefieldWG.cpp:952
virtual void SetData(uint32 dataId, uint32 value) override
Definition: Battlefield.h:267
Definition: BattlefieldWG.h:92
Definition: BattlefieldWG.h:95
Definition: SharedDefines.h:993
WorkshopSet Workshops
Definition: BattlefieldWG.h:418

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void BattlefieldWG::UpdateDamagedTowerCount ( TeamId  team)

Called when a tower is damaged.

  • Update tower count (for reward calcul)
944 {
945  if (team == GetAttackerTeam())
947  else
949 }
Definition: BattlefieldWG.h:90
virtual void UpdateData(uint32 index, int32 pad)
Definition: Battlefield.h:268
TeamId GetAttackerTeam() const
Definition: Battlefield.h:272
Definition: BattlefieldWG.h:88

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void BattlefieldWG::UpdatedDestroyedTowerCount ( TeamId  team)

Called when tower is broken.

  • Update tower buff
  • check if three south tower is down for remove 10 minutes to wg
868 {
869  // Destroy an attack tower
870  if (team == GetAttackerTeam())
871  {
872  // Update counter
875 
876  // Remove buff stack on attackers
877  for (GuidSet::const_iterator itr = m_PlayersInWar[GetAttackerTeam()].begin(); itr != m_PlayersInWar[GetAttackerTeam()].end(); ++itr)
878  if (Player* player = ObjectAccessor::FindPlayer(*itr))
879  player->RemoveAuraFromStack(SPELL_TOWER_CONTROL);
880 
881  // Add buff stack to defenders
882  for (GuidSet::const_iterator itr = m_PlayersInWar[GetDefenderTeam()].begin(); itr != m_PlayersInWar[GetDefenderTeam()].end(); ++itr)
883  if (Player* player = ObjectAccessor::FindPlayer(*itr))
884  {
885  player->CastSpell(player, SPELL_TOWER_CONTROL, true);
887  }
888 
889  // If all three south towers are destroyed (ie. all attack towers), remove ten minutes from battle time
891  {
892  if (int32(m_Timer - 600000) < 0)
893  m_Timer = 0;
894  else
895  m_Timer -= 600000;
897  }
898  }
899  else
900  {
903  }
904 }
Definition: BattlefieldWG.h:91
void DoCompleteOrIncrementAchievement(uint32 achievement, Player *player, uint8 incrementNumber=1) override
Definition: BattlefieldWG.cpp:415
Definition: BattlefieldWG.h:104
Definition: BattlefieldWG.h:50
void SendInitWorldStatesToAll() override
Send all worldstate data to all player in zone.
Definition: BattlefieldWG.cpp:845
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
Definition: BattlefieldWG.h:90
GuidSet m_PlayersInWar[BG_TEAMS_COUNT]
Definition: Battlefield.h:370
uint32 m_Timer
Definition: Battlefield.h:359
virtual void UpdateData(uint32 index, int32 pad)
Definition: Battlefield.h:268
TeamId GetAttackerTeam() const
Definition: Battlefield.h:272
Definition: BattlefieldWG.h:88
Definition: BattlefieldWG.h:89
uint32 GetData(uint32 data) const override
Definition: BattlefieldWG.cpp:788
int32_t int32
Definition: g3dmath.h:167
TeamId GetDefenderTeam() const
Definition: Battlefield.h:271

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void BattlefieldWG::UpdateTenacity ( )
961 {
962  TeamId team = TEAM_NEUTRAL;
963  uint32 alliancePlayers = m_PlayersInWar[TEAM_ALLIANCE].size();
964  uint32 hordePlayers = m_PlayersInWar[TEAM_HORDE].size();
965  int32 newStack = 0;
966 
967  if (alliancePlayers && hordePlayers)
968  {
969  if (alliancePlayers < hordePlayers)
970  newStack = int32((float(hordePlayers / alliancePlayers) - 1) * 4); // positive, should cast on alliance
971  else if (alliancePlayers > hordePlayers)
972  newStack = int32((1 - float(alliancePlayers / hordePlayers)) * 4); // negative, should cast on horde
973  }
974 
975  if (newStack == int32(m_tenacityStack))
976  return;
977 
978  if (m_tenacityStack > 0 && newStack <= 0) // old buff was on alliance
979  team = TEAM_ALLIANCE;
980  else if (newStack >= 0) // old buff was on horde
981  team = TEAM_HORDE;
982 
983  m_tenacityStack = newStack;
984  // Remove old buff
985  if (team != TEAM_NEUTRAL)
986  {
987  for (GuidSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
988  if (Player* player = ObjectAccessor::FindPlayer(*itr))
989  if (player->getLevel() >= m_MinLevel)
990  player->RemoveAurasDueToSpell(SPELL_TENACITY);
991 
992  for (GuidSet::const_iterator itr = m_vehicles[team].begin(); itr != m_vehicles[team].end(); ++itr)
993  if (Creature* creature = GetCreature(*itr))
994  creature->RemoveAurasDueToSpell(SPELL_TENACITY_VEHICLE);
995  }
996 
997  // Apply new buff
998  if (newStack)
999  {
1000  team = newStack > 0 ? TEAM_ALLIANCE : TEAM_HORDE;
1001 
1002  if (newStack < 0)
1003  newStack = -newStack;
1004  if (newStack > 20)
1005  newStack = 20;
1006 
1007  uint32 buff_honor = SPELL_GREATEST_HONOR;
1008  if (newStack < 15)
1009  buff_honor = SPELL_GREATER_HONOR;
1010  if (newStack < 10)
1011  buff_honor = SPELL_GREAT_HONOR;
1012  if (newStack < 5)
1013  buff_honor = 0;
1014 
1015  for (GuidSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
1016  if (Player* player = ObjectAccessor::FindPlayer(*itr))
1017  player->SetAuraStack(SPELL_TENACITY, player, newStack);
1018 
1019  for (GuidSet::const_iterator itr = m_vehicles[team].begin(); itr != m_vehicles[team].end(); ++itr)
1020  if (Creature* creature = GetCreature(*itr))
1021  creature->SetAuraStack(SPELL_TENACITY_VEHICLE, creature, newStack);
1022 
1023  if (buff_honor != 0)
1024  {
1025  for (GuidSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
1026  if (Player* player = ObjectAccessor::FindPlayer(*itr))
1027  player->CastSpell(player, buff_honor, true);
1028  for (GuidSet::const_iterator itr = m_vehicles[team].begin(); itr != m_vehicles[team].end(); ++itr)
1029  if (Creature* creature = GetCreature(*itr))
1030  creature->CastSpell(creature, buff_honor, true);
1031  }
1032  }
1033 }
Definition: BattlefieldWG.h:49
Definition: BattlefieldWG.h:52
Definition: BattlefieldWG.h:48
Definition: Creature.h:467
Definition: SharedDefines.h:994
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
GuidSet m_vehicles[BG_TEAMS_COUNT]
Definition: BattlefieldWG.h:424
GuidSet m_PlayersInWar[BG_TEAMS_COUNT]
Definition: Battlefield.h:370
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
Creature * GetCreature(ObjectGuid guid)
Definition: Battlefield.cpp:845
GuidSet m_players[BG_TEAMS_COUNT]
Definition: Battlefield.h:368
Definition: SharedDefines.h:992
TeamId
Definition: SharedDefines.h:990
Definition: BattlefieldWG.h:54
int32_t int32
Definition: g3dmath.h:167
Definition: SharedDefines.h:993
uint32 m_MinLevel
Definition: Battlefield.h:382
uint32 m_tenacityStack
Definition: BattlefieldWG.h:429
Definition: BattlefieldWG.h:53

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void BattlefieldWG::UpdateVehicleCountWG ( )
953 {
958 }
Definition: BattlefieldWG.h:121
Definition: BattlefieldWG.h:94
Definition: BattlefieldWG.h:122
Definition: BattlefieldWG.h:93
Definition: BattlefieldWG.h:124
void SendUpdateWorldState(uint32 variable, uint32 value, bool hidden=false)
Update data of a worldstate to all players present in zone.
Definition: Battlefield.cpp:439
uint32 GetData(uint32 data) const override
Definition: BattlefieldWG.cpp:788
Definition: BattlefieldWG.h:92
Definition: BattlefieldWG.h:123
Definition: BattlefieldWG.h:95

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

GameObjectBuildingSet BattlefieldWG::BuildingsInZone
protected
GuidSet BattlefieldWG::CanonList
protected
GuidSet BattlefieldWG::DefenderPortalList
protected
GuidSet BattlefieldWG::KeepCreature[BG_TEAMS_COUNT]
protected
bool BattlefieldWG::m_isRelicInteractible
protected
GuidSet BattlefieldWG::m_KeepGameObject[BG_TEAMS_COUNT]
protected
uint32 BattlefieldWG::m_saveTimer
protected
uint32 BattlefieldWG::m_tenacityStack
protected
ObjectGuid BattlefieldWG::m_titansRelicGUID
protected
GuidSet BattlefieldWG::m_vehicles[BG_TEAMS_COUNT]
protected
GuidSet BattlefieldWG::OutsideCreature[BG_TEAMS_COUNT]
protected
WorkshopSet BattlefieldWG::Workshops
protected

The documentation for this class was generated from the following files: