38#include <G3D/g3dmath.h>
117 group->RemoveMember(player->
GetGUID());
124 itr->second->HandlePlayerLeave(player);
155 bool objective_changed =
false;
172 if (itr->second <= now)
178 if (itr->second <= now)
187 if (itr->second->Update(diff))
188 objective_changed =
true;
201 return objective_changed;
294 TC_LOG_ERROR(
"bg.battlefield",
"Battlefield::InitStalker: Could not spawn Stalker (Creature entry {}), zone messages will be unavailable!", entry);
383 player->
TeleportTo(571, 5804.1499f, 624.7710f, 647.7670f, 1.6400f);
411 player->CastSpell(player,
uint32(spellId),
true);
417 player->RemoveAuraFromStack(
uint32(-spellId));
426 player->SendDirectMessage(data);
434 player->SendDirectMessage(data);
442 player->SendDirectMessage(data);
466 worldstate.
Value = value;
508 if (!group->IsFull())
518 if (group->IsMember(guid))
568 TC_LOG_ERROR(
"bg.battlefield",
"Battlefield::GetGraveyardById Id:{} does not exist.",
id);
571 TC_LOG_ERROR(
"bg.battlefield",
"Battlefield::GetGraveyardById Id:{} could not be found.",
id);
588 if (dist < maxdist || maxdist < 0)
662 TC_LOG_ERROR(
"bg.battlefield",
"BfGraveyard::SetSpirit: Invalid Spirit.");
783 TC_LOG_ERROR(
"bg.battlefield",
"Battlefield::SpawnCreature: Can't create creature entry: {}, map not found.", entry);
790 TC_LOG_ERROR(
"bg.battlefield",
"Battlefield::SpawnCreature: Can't create creature entry: {}", entry);
817 TC_LOG_ERROR(
"bg.battlefield",
"Battlefield::SpawnGameObject: Gameobject template {} could not be found in the database! Battlefield has not been created!", entry);
818 TC_LOG_ERROR(
"bg.battlefield",
"Battlefield::SpawnGameObject: Could not create gameobject template {}! Battlefield has not been created!", entry);
958 capturePoint->Delete();
959 capturePoint =
nullptr;
974 float radius = capturePoint->GetGOInfo()->capturePoint.radius;
982 if (!capturePoint->IsWithinDistInMap(player, radius) || !player->IsOutdoorPvPActive())
992 std::list<Player*> players;
997 for (std::list<Player*>::iterator itr = players.begin(); itr != players.end(); ++itr)
998 if ((*itr)->IsOutdoorPvPActive())
999 if (
m_activePlayers[(*itr)->GetTeamId()].insert((*itr)->GetGUID()).second)
1005 if (G3D::fuzzyEq(fact_diff, 0.0f))
1017 if (fact_diff < -maxDiff)
1018 fact_diff = -maxDiff;
1028 if (fact_diff > maxDiff)
1029 fact_diff = maxDiff;
1055 else if (oldValue *
m_value <= 0)
1061 else if (Challenger ==
HORDE)
1075 if (G3D::fuzzyNe(
m_value, oldValue))
1094 player->SendUpdateWorldState(field, value);
1115 player->KilledMonsterCredit(
id, guid);
@ BATTLEFIELD_OBJECTIVE_UPDATE_INTERVAL
@ BF_CAPTUREPOINT_OBJECTIVESTATE_NEUTRAL_HORDE_CHALLENGE
@ BF_CAPTUREPOINT_OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE
@ BF_CAPTUREPOINT_OBJECTIVESTATE_HORDE
@ BF_CAPTUREPOINT_OBJECTIVESTATE_ALLIANCE_HORDE_CHALLENGE
@ BF_CAPTUREPOINT_OBJECTIVESTATE_ALLIANCE
@ BF_CAPTUREPOINT_OBJECTIVESTATE_HORDE_ALLIANCE_CHALLENGE
@ BF_CAPTUREPOINT_OBJECTIVESTATE_NEUTRAL
@ SPELL_RESURRECTION_VISUAL
@ SPELL_WAITING_FOR_RESURRECT
DBCStorage< WorldSafeLocsEntry > sWorldSafeLocsStore(WorldSafeLocsEntryfmt)
#define TC_LOG_DEBUG(filterType__,...)
#define TC_LOG_ERROR(filterType__,...)
@ GAMEOBJECT_TYPE_CAPTURE_POINT
uint8 constexpr PVP_TEAMS_COUNT
@ UNIT_FLAG_NON_ATTACKABLE
@ UNIT_FLAG_UNINTERACTIBLE
void Resurrect(Creature *target)
GameObject * SpawnGameObject(uint32 entry, Position const &pos, QuaternionData const &rot)
GraveyardVect m_GraveyardList
GameObject * GetGameObject(ObjectGuid guid)
void BroadcastPacketToWar(WorldPacket const *data) const
void DoPlaySoundToAll(uint32 soundID)
void ShowNpc(Creature *creature, bool aggressive)
Creature * GetCreature(ObjectGuid guid)
Creature * SpawnCreature(uint32 entry, Position const &pos)
void BroadcastPacketToZone(WorldPacket const *data) const
virtual ~Battlefield()
Destructor.
virtual void SendInitWorldStatesToAll()=0
Send all worldstate data to all player in zone.
void EndBattle(bool endByTimer)
virtual void OnBattleEnd(bool)
Called at the end of battle.
bool IsWarTime() const
Return true if battle is start, false if battle is not started.
void InitStalker(uint32 entry, Position const &pos)
void InvitePlayersInQueueToWar()
Invite all players in queue to join battle on battle start.
virtual void SendRemoveWorldStates(Player *)
uint32 m_StartGroupingTimer
virtual void FillInitialWorldStates(WorldPackets::WorldState::InitWorldStates &)=0
virtual bool Update(uint32 diff)
Called every time for update bf data and time.
void InvitePlayersInZoneToQueue()
Invite all players in zone to join the queue, called x minutes before battle start in Update()
void KickPlayerFromBattlefield(ObjectGuid guid)
Kick player from battlefield and teleport him to kick-point location.
void InvitePlayerToQueue(Player *player)
void RegisterZone(uint32 zoneid)
void SetDefenderTeam(TeamId team)
void InvitePlayerToWar(Player *player)
uint32 m_uiKickAfkPlayersTimer
void PlayerAcceptInviteToWar(Player *player)
void BroadcastPacketToQueue(WorldPacket const *data) const
void SendWarning(uint8 id, WorldObject const *target=nullptr)
Group * GetFreeBfRaid(TeamId TeamId)
Find a not full battlefield group, if there is no, create one.
void SendAreaSpiritHealerQueryOpcode(Player *player, ObjectGuid guid)
virtual void OnPlayerJoinWar(Player *)
Called when a player accept to join the battle.
uint32 m_TimeForAcceptInvite
BfGraveyard * GetGraveyardById(uint32 id) const
virtual void OnBattleStart()
Called on start.
GuidUnorderedSet m_PlayersInWar[PVP_TEAMS_COUNT]
void InvitePlayersInZoneToWar()
Invite all players in zone to join battle on battle start.
void HideNpc(Creature *creature)
PlayerTimerMap m_PlayersWillBeKick[PVP_TEAMS_COUNT]
uint32 m_RestartAfterCrash
void SendUpdateWorldState(uint32 variable, uint32 value)
Update data of a worldstate to all players present in zone.
virtual void AddPlayerToResurrectQueue(ObjectGuid npc_guid, ObjectGuid player_guid)
TeamId GetAttackerTeam() const
void SendInitWorldStatesTo(Player *player)
GuidUnorderedSet m_PlayersInQueue[PVP_TEAMS_COUNT]
bool AddOrSetPlayerToCorrectBfGroup(Player *player)
Force player to join a battlefield group.
void PlayerAskToLeave(Player *player)
void TeamCastSpell(TeamId team, int32 spellId)
uint32 m_LastResurrectTimer
virtual void OnPlayerLeaveZone(Player *)
Called when a player leave battlefield zone.
void PlayerAcceptInviteToQueue(Player *player)
void RemovePlayerFromResurrectQueue(ObjectGuid player_guid)
BfCapturePointMap m_capturePoints
Group * GetGroupPlayer(ObjectGuid guid, TeamId TeamId)
Return battlefield group where player is.
uint32 m_uiKickDontAcceptTimer
GuidUnorderedSet m_Groups[PVP_TEAMS_COUNT]
virtual void OnStartGrouping()
Called x minutes before battle start when player in zone are invite to join queue.
WorldLocation KickPosition
virtual void OnPlayerLeaveWar(Player *)
Called when a player leave the battle.
PlayerTimerMap m_InvitedPlayers[PVP_TEAMS_COUNT]
bool HasPlayer(Player *player) const
void AskToLeaveQueue(Player *player)
TeamId GetOtherTeam(TeamId team) const
WorldSafeLocsEntry const * GetClosestGraveyard(Player *player)
void HandlePlayerLeaveZone(Player *player, uint32 zone)
Called when player (player) leave the zone.
virtual void OnPlayerEnterZone(Player *)
Called when a player enter in battlefield zone.
Battlefield()
Constructor.
GuidUnorderedSet m_players[PVP_TEAMS_COUNT]
void HandlePlayerEnterZone(Player *player, uint32 zone)
Called when player (player) enter in zone.
virtual GuidSet::iterator HandlePlayerLeave(Player *player)
virtual bool HandlePlayerEnter(Player *player)
BfCapturePoint(Battlefield *bf)
virtual bool Update(uint32 diff)
BattlefieldObjectiveStates m_OldState
bool SetCapturePointData(GameObject *capturePoint)
virtual void ChangeTeam(TeamId)
bool IsInsideObjective(Player *player) const
GameObject * GetCapturePointGo()
virtual void SendChangePhase()
void SendUpdateWorldState(uint32 field, uint32 value)
uint32 m_capturePointEntry
ObjectGuid m_capturePointGUID
void SendObjectiveComplete(uint32 id, ObjectGuid guid)
GuidSet m_activePlayers[PVP_TEAMS_COUNT]
BattlefieldObjectiveStates m_State
virtual ~BfCapturePoint()
ObjectGuid m_SpiritGuide[PVP_TEAMS_COUNT]
BfGraveyard(Battlefield *bf)
bool HasNpc(ObjectGuid guid)
void GiveControlTo(TeamId team)
void SetSpirit(Creature *spirit, TeamId team)
uint32 GetGraveyardId() const
void Initialize(TeamId startcontrol, uint32 gy)
void AddPlayer(ObjectGuid player_guid)
void RelocateDeadPlayers()
float GetDistance(Player *player)
void RemovePlayer(ObjectGuid player_guid)
void SetPhaseMask(uint32 newPhaseMask, bool update) override
void SetHomePosition(float x, float y, float z, float o)
void Respawn(bool force=false)
void SetReactState(ReactStates st)
bool Create(ObjectGuid::LowType guidlow, Map *map, uint32 phaseMask, uint32 entry, Position const &pos, CreatureData const *data=nullptr, uint32 vehId=0, bool dynamic=false)
GameObjectTemplate const * GetGOInfo() const
void SetRespawnTime(int32 respawn)
bool Create(ObjectGuid::LowType guidlow, uint32 name_id, Map *map, uint32 phaseMask, Position const &pos, QuaternionData const &rotation, uint32 animprogress, GOState go_state, uint32 artKit=0, bool dynamic=false, ObjectGuid::LowType spawnid=0)
uint8 GetMemberGroup(ObjectGuid guid) const
void SetBattlefieldGroup(Battlefield *bf)
bool AddMember(Player *player)
ObjectGuid GetGUID() const
bool IsMember(ObjectGuid guid) const
bool RemoveMember(ObjectGuid guid, RemoveMethod const &method=GROUP_REMOVEMETHOD_DEFAULT, ObjectGuid kicker=ObjectGuid::Empty, char const *reason=nullptr)
bool Create(Player *leader)
ObjectGuid::LowType GenerateLowGuid()
GameObject * GetGameObject(ObjectGuid const &guid)
Creature * GetCreature(ObjectGuid const &guid)
static ObjectGuid GetGUID(Object const *o)
void SendUpdateWorldState(uint32 variable, uint32 value) const
void SendDirectMessage(WorldPacket const *data) const
void SpawnCorpseBones(bool triggerSave=true)
WorldSession * GetSession() const
Battleground * GetBattleground() const
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options=0)
void SetBattlegroundOrBattlefieldRaid(Group *group, int8 subgroup=-1)
void ResurrectPlayer(float restore_percent, bool applySickness=false)
void CombatStop(bool includingCast=false, bool mutualPvP=true)
void SetUnitFlag(UnitFlags flags)
void RemoveUnitFlag(UnitFlags flags)
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
void setActive(bool isActiveObject)
float GetDistance2d(WorldObject const *obj) const
void SetFarVisible(bool on)
WorldPacket const * Write() override
WorldPacket const * Write() override
WorldPacket const * Write() override
void SendBfLeaveMessage(uint32 battleId, BFLeaveReason reason=BF_LEAVE_REASON_EXITED)
This is call when player leave battlefield zone.
void SendBfQueueInviteResponse(uint32 battleId, uint32 zoneId, bool canQueue=true, bool full=false)
This send packet for inform player that he join queue.
void SendBfInvitePlayerToWar(uint32 battleId, uint32 zoneId, uint32 time)
This send to player windows for invite player to join the war.
void SendBfInvitePlayerToQueue(uint32 battleId)
This send invitation to player to join the queue.
void SendBfEntered(uint32 battleId)
This is call when player accept to join war.
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
static void VisitWorldObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
struct GameObjectTemplate::@191::@216 capturePoint
float GetOrientation() const