[6922] Whitespace and newline fixes
[getmangos.git] / src / game / BattleGroundNA.cpp
blob385de12110103b667079c75894ac9971e79acda2
1 /*
2 * Copyright (C) 2005-2008 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #include "Object.h"
20 #include "Player.h"
21 #include "BattleGround.h"
22 #include "BattleGroundNA.h"
23 #include "Creature.h"
24 #include "ObjectMgr.h"
25 #include "MapManager.h"
26 #include "Language.h"
28 BattleGroundNA::BattleGroundNA()
30 m_BgObjects.resize(BG_NA_OBJECT_MAX);
33 BattleGroundNA::~BattleGroundNA()
38 void BattleGroundNA::Update(time_t diff)
40 BattleGround::Update(diff);
42 // after bg start we get there
43 if (GetStatus() == STATUS_WAIT_JOIN && GetPlayersSize())
45 ModifyStartDelayTime(diff);
47 if (!(m_Events & 0x01))
49 m_Events |= 0x01;
50 // setup here, only when at least one player has ported to the map
51 if(!SetupBattleGround())
53 EndNow();
54 return;
56 for(uint32 i = BG_NA_OBJECT_DOOR_1; i <= BG_NA_OBJECT_DOOR_4; i++)
57 SpawnBGObject(i, RESPAWN_IMMEDIATELY);
59 SetStartDelayTime(START_DELAY1);
60 SendMessageToAll(LANG_ARENA_ONE_MINUTE);
62 // After 30 seconds, warning is signalled
63 else if (GetStartDelayTime() <= START_DELAY2 && !(m_Events & 0x04))
65 m_Events |= 0x04;
66 SendMessageToAll(LANG_ARENA_THIRTY_SECONDS);
68 // After 15 seconds, warning is signalled
69 else if (GetStartDelayTime() <= START_DELAY3 && !(m_Events & 0x08))
71 m_Events |= 0x08;
72 SendMessageToAll(LANG_ARENA_FIFTEEN_SECONDS);
74 // delay expired (1 minute)
75 else if (GetStartDelayTime() <= 0 && !(m_Events & 0x10))
77 m_Events |= 0x10;
79 for(uint32 i = BG_NA_OBJECT_DOOR_1; i <= BG_NA_OBJECT_DOOR_2; i++)
80 DoorOpen(i);
82 for(uint32 i = BG_NA_OBJECT_BUFF_1; i <= BG_NA_OBJECT_BUFF_2; i++)
83 SpawnBGObject(i, 60);
85 SendMessageToAll(LANG_ARENA_BEGUN);
86 SetStatus(STATUS_IN_PROGRESS);
87 SetStartDelayTime(0);
89 for(BattleGroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
90 if(Player *plr = objmgr.GetPlayer(itr->first))
91 plr->RemoveAurasDueToSpell(SPELL_ARENA_PREPARATION);
93 if(!GetPlayersCountByTeam(ALLIANCE) && GetPlayersCountByTeam(HORDE))
94 EndBattleGround(HORDE);
95 else if(GetPlayersCountByTeam(ALLIANCE) && !GetPlayersCountByTeam(HORDE))
96 EndBattleGround(ALLIANCE);
100 /*if(GetStatus() == STATUS_IN_PROGRESS)
102 // update something
106 void BattleGroundNA::AddPlayer(Player *plr)
108 BattleGround::AddPlayer(plr);
109 //create score and add it to map, default values are set in constructor
110 BattleGroundNAScore* sc = new BattleGroundNAScore;
112 m_PlayerScores[plr->GetGUID()] = sc;
114 UpdateWorldState(0xa0f, GetAlivePlayersCountByTeam(ALLIANCE));
115 UpdateWorldState(0xa10, GetAlivePlayersCountByTeam(HORDE));
118 void BattleGroundNA::RemovePlayer(Player* /*plr*/, uint64 /*guid*/)
120 if(GetStatus() == STATUS_WAIT_LEAVE)
121 return;
123 UpdateWorldState(0xa0f, GetAlivePlayersCountByTeam(ALLIANCE));
124 UpdateWorldState(0xa10, GetAlivePlayersCountByTeam(HORDE));
126 if(!GetAlivePlayersCountByTeam(ALLIANCE) && GetPlayersCountByTeam(HORDE))
127 EndBattleGround(HORDE);
128 else if(GetPlayersCountByTeam(ALLIANCE) && !GetAlivePlayersCountByTeam(HORDE))
129 EndBattleGround(ALLIANCE);
132 void BattleGroundNA::HandleKillPlayer(Player *player, Player *killer)
134 if(GetStatus() != STATUS_IN_PROGRESS)
135 return;
137 if(!killer)
139 sLog.outError("BattleGroundNA: Killer player not found");
140 return;
143 BattleGround::HandleKillPlayer(player,killer);
145 UpdateWorldState(0xa0f, GetAlivePlayersCountByTeam(ALLIANCE));
146 UpdateWorldState(0xa10, GetAlivePlayersCountByTeam(HORDE));
148 if(!GetAlivePlayersCountByTeam(ALLIANCE))
150 // all opponents killed
151 EndBattleGround(HORDE);
153 else if(!GetAlivePlayersCountByTeam(HORDE))
155 // all opponents killed
156 EndBattleGround(ALLIANCE);
160 bool BattleGroundNA::HandlePlayerUnderMap(Player *player)
162 player->TeleportTo(GetMapId(),4055.504395,2919.660645,13.611241,player->GetOrientation(),false);
163 return true;
166 void BattleGroundNA::HandleAreaTrigger(Player *Source, uint32 Trigger)
168 if(GetStatus() != STATUS_IN_PROGRESS)
169 return;
171 //uint32 SpellId = 0;
172 //uint64 buff_guid = 0;
173 switch(Trigger)
175 case 4536: // buff trigger?
176 case 4537: // buff trigger?
177 break;
178 default:
179 sLog.outError("WARNING: Unhandled AreaTrigger in Battleground: %u", Trigger);
180 Source->GetSession()->SendAreaTriggerMessage("Warning: Unhandled AreaTrigger in Battleground: %u", Trigger);
181 break;
184 //if(buff_guid)
185 // HandleTriggerBuff(buff_guid,Source);
188 void BattleGroundNA::FillInitialWorldStates(WorldPacket &data)
190 data << uint32(0xa0f) << uint32(GetAlivePlayersCountByTeam(ALLIANCE)); // 7
191 data << uint32(0xa10) << uint32(GetAlivePlayersCountByTeam(HORDE)); // 8
192 data << uint32(0xa11) << uint32(1); // 9
195 void BattleGroundNA::ResetBGSubclass()
200 bool BattleGroundNA::SetupBattleGround()
202 // gates
203 if( !AddObject(BG_NA_OBJECT_DOOR_1, BG_NA_OBJECT_TYPE_DOOR_1, 4031.854, 2966.833, 12.6462, -2.648788, 0, 0, 0.9697962, -0.2439165, RESPAWN_IMMEDIATELY)
204 || !AddObject(BG_NA_OBJECT_DOOR_2, BG_NA_OBJECT_TYPE_DOOR_2, 4081.179, 2874.97, 12.39171, 0.4928045, 0, 0, 0.2439165, 0.9697962, RESPAWN_IMMEDIATELY)
205 || !AddObject(BG_NA_OBJECT_DOOR_3, BG_NA_OBJECT_TYPE_DOOR_3, 4023.709, 2981.777, 10.70117, -2.648788, 0, 0, 0.9697962, -0.2439165, RESPAWN_IMMEDIATELY)
206 || !AddObject(BG_NA_OBJECT_DOOR_4, BG_NA_OBJECT_TYPE_DOOR_4, 4090.064, 2858.438, 10.23631, 0.4928045, 0, 0, 0.2439165, 0.9697962, RESPAWN_IMMEDIATELY)
207 // buffs
208 || !AddObject(BG_NA_OBJECT_BUFF_1, BG_NA_OBJECT_TYPE_BUFF_1, 4009.189941, 2895.250000, 13.052700, -1.448624, 0, 0, 0.6626201, -0.7489557, 120)
209 || !AddObject(BG_NA_OBJECT_BUFF_2, BG_NA_OBJECT_TYPE_BUFF_2, 4103.330078, 2946.350098, 13.051300, -0.06981307, 0, 0, 0.03489945, -0.9993908, 120))
211 sLog.outErrorDb("BatteGroundNA: Failed to spawn some object!");
212 return false;
215 return true;
219 20:12:14 id:036668 [S2C] SMSG_INIT_WORLD_STATES (706 = 0x02C2) len: 86
220 0000: 2f 02 00 00 72 0e 00 00 00 00 00 00 09 00 11 0a | /...r...........
221 0010: 00 00 01 00 00 00 0f 0a 00 00 00 00 00 00 10 0a | ................
222 0020: 00 00 00 00 00 00 d4 08 00 00 00 00 00 00 d8 08 | ................
223 0030: 00 00 00 00 00 00 d7 08 00 00 00 00 00 00 d6 08 | ................
224 0040: 00 00 00 00 00 00 d5 08 00 00 00 00 00 00 d3 08 | ................
225 0050: 00 00 00 00 00 00 | ......