Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Toggle main menu visibility
Loading...
Searching...
No Matches
BattlegroundTV.cpp
Go to the documentation of this file.
1
/*
2
* This file is part of Project SkyFire https://www.projectskyfire.org.
3
* See LICENSE.md file for Copyright information
4
*/
5
6
#include "
BattlegroundTV.h
"
7
#include "
Language.h
"
8
#include "
Object.h
"
9
#include "
ObjectMgr.h
"
10
#include "
Player.h
"
11
#include "
WorldPacket.h
"
12
13
BattlegroundTV::BattlegroundTV
()
14
{
15
BgObjects
.resize(
BG_TV_OBJECT_MAX
);
16
17
StartDelayTimes
[
BG_STARTING_EVENT_FIRST
] =
BG_START_DELAY_1M
;
18
StartDelayTimes
[
BG_STARTING_EVENT_SECOND
] =
BG_START_DELAY_30S
;
19
StartDelayTimes
[
BG_STARTING_EVENT_THIRD
] =
BG_START_DELAY_15S
;
20
StartDelayTimes
[
BG_STARTING_EVENT_FOURTH
] =
BG_START_DELAY_NONE
;
21
//we must set messageIds
22
StartMessageIds
[
BG_STARTING_EVENT_FIRST
] =
LANG_ARENA_ONE_MINUTE
;
23
StartMessageIds
[
BG_STARTING_EVENT_SECOND
] =
LANG_ARENA_THIRTY_SECONDS
;
24
StartMessageIds
[
BG_STARTING_EVENT_THIRD
] =
LANG_ARENA_FIFTEEN_SECONDS
;
25
StartMessageIds
[
BG_STARTING_EVENT_FOURTH
] =
LANG_ARENA_HAS_BEGUN
;
26
}
27
28
void
BattlegroundTV::StartingEventCloseDoors
()
29
{
30
for
(
uint32
i =
BG_TV_OBJECT_DOOR_1
; i <=
BG_TV_OBJECT_DOOR_2
; ++i)
31
SpawnBGObject
(i,
RESPAWN_IMMEDIATELY
);
32
33
for
(
uint32
i =
BG_TV_OBJECT_BUFF_1
; i <=
BG_TV_OBJECT_BUFF_2
; ++i)
34
SpawnBGObject
(i,
RESPAWN_ONE_DAY
);
35
}
36
37
void
BattlegroundTV::StartingEventOpenDoors
()
38
{
39
for
(
uint32
i =
BG_TV_OBJECT_DOOR_1
; i <=
BG_TV_OBJECT_DOOR_2
; ++i)
40
DoorOpen
(i);
41
42
for
(
uint32
i =
BG_TV_OBJECT_BUFF_1
; i <=
BG_TV_OBJECT_BUFF_2
; ++i)
43
SpawnBGObject
(i, 60);
44
}
45
46
void
BattlegroundTV::AddPlayer
(
Player
* player)
47
{
48
Battleground::AddPlayer
(player);
49
PlayerScores
[player->
GetGUID
()] =
new
BattlegroundScore
;
50
UpdateArenaWorldState
();
51
}
52
53
void
BattlegroundTV::RemovePlayer
(
Player
*
/*player*/
,
uint64
/*guid*/
,
uint32
/*team*/
)
54
{
55
if
(
GetStatus
() ==
STATUS_WAIT_LEAVE
)
56
return
;
57
58
UpdateArenaWorldState
();
59
CheckArenaWinConditions
();
60
}
61
62
void
BattlegroundTV::HandleKillPlayer
(
Player
* player,
Player
* killer)
63
{
64
if
(
GetStatus
() !=
STATUS_IN_PROGRESS
)
65
return
;
66
67
if
(!killer)
68
{
69
SF_LOG_ERROR
(
"bg.battleground"
,
"Killer player not found"
);
70
return
;
71
}
72
73
Battleground::HandleKillPlayer
(player, killer);
74
75
UpdateArenaWorldState
();
76
CheckArenaWinConditions
();
77
}
78
79
void
BattlegroundTV::HandleAreaTrigger
(
Player
* player,
uint32
trigger)
80
{
81
if
(
GetStatus
() !=
STATUS_IN_PROGRESS
)
82
return
;
83
84
switch
(trigger)
85
{
86
case
4536:
87
case
4537:
88
break
;
89
default
:
90
Battleground::HandleAreaTrigger
(player, trigger);
91
break
;
92
}
93
}
94
95
void
BattlegroundTV::FillInitialWorldStates
(
WorldStateBuilder
& builder)
96
{
97
builder.
AppendState
(0xE1A, 1);
98
UpdateArenaWorldState
();
99
}
100
101
void
BattlegroundTV::Reset
()
102
{
103
//call parent's class reset
104
Battleground::Reset
();
105
}
106
107
bool
BattlegroundTV::SetupBattleground
()
108
{
109
// gates
110
if
(!
AddObject
(
BG_TV_OBJECT_DOOR_1
,
BG_TV_OBJECT_TYPE_DOOR_1
, -10774.6f, 430.992f, 24.41076f, 0.0156f, 0.0f, 0.0f, 0.0078f,
RESPAWN_IMMEDIATELY
)
111
|| !
AddObject
(
BG_TV_OBJECT_DOOR_2
,
BG_TV_OBJECT_TYPE_DOOR_2
, -10655.0f, 428.117f, 24.416f, 3.148f, 0.0f, 0.0f, 1.0f,
RESPAWN_IMMEDIATELY
)
112
// buffs
113
|| !
AddObject
(
BG_TV_OBJECT_BUFF_1
,
BG_TV_OBJECT_TYPE_BUFF_1
, -10717.63f, 383.8223f, 24.412825f, 1.555f, 0.0f, 0.0f, 0.70154f, 120)
114
|| !
AddObject
(
BG_TV_OBJECT_BUFF_2
,
BG_TV_OBJECT_TYPE_BUFF_2
, -10716.6f, 475.364f, 24.4131f, 0.0f, 0.0f, 0.70068f, -0.713476f, 120))
115
{
116
SF_LOG_ERROR
(
"sql.sql"
,
"BatteGroundTV: Failed to spawn some object!"
);
117
return
false
;
118
}
119
120
return
true
;
121
}
122
123
void
BattlegroundTV::UpdatePlayerScore
(
Player
* Source,
uint32
type,
uint32
value,
bool
doAddHonor)
124
{
125
BattlegroundScoreMap::iterator itr =
PlayerScores
.find(Source->
GetGUID
());
126
if
(itr ==
PlayerScores
.end())
// player not found...
127
return
;
128
129
//there is nothing special in this score
130
Battleground::UpdatePlayerScore
(Source, type, value, doAddHonor);
131
}
RESPAWN_IMMEDIATELY
@ RESPAWN_IMMEDIATELY
Definition
Battleground.h:118
RESPAWN_ONE_DAY
@ RESPAWN_ONE_DAY
Definition
Battleground.h:117
BG_START_DELAY_1M
@ BG_START_DELAY_1M
Definition
Battleground.h:128
BG_START_DELAY_30S
@ BG_START_DELAY_30S
Definition
Battleground.h:129
BG_START_DELAY_NONE
@ BG_START_DELAY_NONE
Definition
Battleground.h:131
BG_START_DELAY_15S
@ BG_START_DELAY_15S
Definition
Battleground.h:130
STATUS_WAIT_LEAVE
@ STATUS_WAIT_LEAVE
Definition
Battleground.h:149
STATUS_IN_PROGRESS
@ STATUS_IN_PROGRESS
Definition
Battleground.h:148
BG_STARTING_EVENT_THIRD
@ BG_STARTING_EVENT_THIRD
Definition
Battleground.h:236
BG_STARTING_EVENT_SECOND
@ BG_STARTING_EVENT_SECOND
Definition
Battleground.h:235
BG_STARTING_EVENT_FIRST
@ BG_STARTING_EVENT_FIRST
Definition
Battleground.h:234
BG_STARTING_EVENT_FOURTH
@ BG_STARTING_EVENT_FOURTH
Definition
Battleground.h:237
BattlegroundTV.h
BG_TV_OBJECT_TYPE_BUFF_2
@ BG_TV_OBJECT_TYPE_BUFF_2
Definition
BattlegroundTV.h:25
BG_TV_OBJECT_TYPE_BUFF_1
@ BG_TV_OBJECT_TYPE_BUFF_1
Definition
BattlegroundTV.h:24
BG_TV_OBJECT_TYPE_DOOR_1
@ BG_TV_OBJECT_TYPE_DOOR_1
Definition
BattlegroundTV.h:22
BG_TV_OBJECT_TYPE_DOOR_2
@ BG_TV_OBJECT_TYPE_DOOR_2
Definition
BattlegroundTV.h:23
BG_TV_OBJECT_DOOR_2
@ BG_TV_OBJECT_DOOR_2
Definition
BattlegroundTV.h:14
BG_TV_OBJECT_BUFF_2
@ BG_TV_OBJECT_BUFF_2
Definition
BattlegroundTV.h:16
BG_TV_OBJECT_BUFF_1
@ BG_TV_OBJECT_BUFF_1
Definition
BattlegroundTV.h:15
BG_TV_OBJECT_DOOR_1
@ BG_TV_OBJECT_DOOR_1
Definition
BattlegroundTV.h:13
BG_TV_OBJECT_MAX
@ BG_TV_OBJECT_MAX
Definition
BattlegroundTV.h:17
uint32
std::uint32_t uint32
Definition
Define.h:77
uint64
std::uint64_t uint64
Definition
Define.h:76
Language.h
LANG_ARENA_FIFTEEN_SECONDS
@ LANG_ARENA_FIFTEEN_SECONDS
Definition
Language.h:681
LANG_ARENA_HAS_BEGUN
@ LANG_ARENA_HAS_BEGUN
Definition
Language.h:682
LANG_ARENA_THIRTY_SECONDS
@ LANG_ARENA_THIRTY_SECONDS
Definition
Language.h:680
LANG_ARENA_ONE_MINUTE
@ LANG_ARENA_ONE_MINUTE
Definition
Language.h:679
SF_LOG_ERROR
#define SF_LOG_ERROR(filterType__,...)
Definition
Log.h:143
Object.h
ObjectMgr.h
Player.h
WorldPacket.h
Battleground::AddPlayer
virtual void AddPlayer(Player *player)
Definition
Battleground.cpp:1139
Battleground::HandleKillPlayer
virtual void HandleKillPlayer(Player *player, Player *killer)
Definition
Battleground.cpp:1824
Battleground::DoorOpen
void DoorOpen(uint32 type)
Definition
Battleground.cpp:1557
Battleground::SpawnBGObject
void SpawnBGObject(uint32 type, uint32 respawntime)
Definition
Battleground.cpp:1587
Battleground::Reset
virtual void Reset()
Definition
Battleground.cpp:1097
Battleground::CheckArenaWinConditions
void CheckArenaWinConditions()
Definition
Battleground.cpp:1944
Battleground::BgObjects
BGObjects BgObjects
Definition
Battleground.h:508
Battleground::StartDelayTimes
BattlegroundStartTimeIntervals StartDelayTimes[BG_STARTING_EVENT_COUNT]
Definition
Battleground.h:575
Battleground::PlayerScores
BattlegroundScoreMap PlayerScores
Definition
Battleground.h:564
Battleground::GetStatus
BattlegroundStatus GetStatus() const
Definition
Battleground.h:305
Battleground::HandleAreaTrigger
virtual void HandleAreaTrigger(Player *, uint32)
Definition
Battleground.cpp:2001
Battleground::UpdateArenaWorldState
void UpdateArenaWorldState()
Definition
Battleground.cpp:1952
Battleground::UpdatePlayerScore
virtual void UpdatePlayerScore(Player *player, uint32 type, uint32 value, bool doAddHonor=true)
Definition
Battleground.cpp:1388
Battleground::AddObject
bool AddObject(uint32 type, uint32 entry, float x, float y, float z, float o, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime=0)
Definition
Battleground.cpp:1482
Battleground::StartMessageIds
uint32 StartMessageIds[BG_STARTING_EVENT_COUNT]
Definition
Battleground.h:577
BattlegroundTV::Reset
void Reset() OVERRIDE
Definition
BattlegroundTV.cpp:101
BattlegroundTV::FillInitialWorldStates
void FillInitialWorldStates(WorldStateBuilder &builder) OVERRIDE
Definition
BattlegroundTV.cpp:95
BattlegroundTV::HandleKillPlayer
void HandleKillPlayer(Player *player, Player *killer) OVERRIDE
Definition
BattlegroundTV.cpp:62
BattlegroundTV::UpdatePlayerScore
void UpdatePlayerScore(Player *Source, uint32 type, uint32 value, bool doAddHonor=true) OVERRIDE
Definition
BattlegroundTV.cpp:123
BattlegroundTV::StartingEventCloseDoors
void StartingEventCloseDoors() OVERRIDE
Definition
BattlegroundTV.cpp:28
BattlegroundTV::RemovePlayer
void RemovePlayer(Player *player, uint64 guid, uint32 team) OVERRIDE
Definition
BattlegroundTV.cpp:53
BattlegroundTV::BattlegroundTV
BattlegroundTV()
Definition
BattlegroundTV.cpp:13
BattlegroundTV::HandleAreaTrigger
void HandleAreaTrigger(Player *Source, uint32 Trigger) OVERRIDE
Definition
BattlegroundTV.cpp:79
BattlegroundTV::SetupBattleground
bool SetupBattleground() OVERRIDE
Definition
BattlegroundTV.cpp:107
BattlegroundTV::StartingEventOpenDoors
void StartingEventOpenDoors() OVERRIDE
Definition
BattlegroundTV.cpp:37
BattlegroundTV::AddPlayer
void AddPlayer(Player *player) OVERRIDE
Definition
BattlegroundTV.cpp:46
Object::GetGUID
uint64 GetGUID() const
Definition
Object.h:119
Player
Definition
Player.h:1289
WorldStateBuilder
Definition
WorldStateBuilder.h:16
WorldStateBuilder::AppendState
void AppendState(uint32 worldstate, uint32 value)
Definition
WorldStateBuilder.h:42
BattlegroundScore
Definition
Battleground.h:249
src
server
game
Battlegrounds
Zones
BattlegroundTV.cpp
Generated on
for Project SkyFire Core by
1.17.0