Updated Copyright year to 2013
[getmangos.git] / src / game / BattleGround / BattleGroundRL.cpp
blob04686a91ccf374f3a83dfff5f442bf75726fb3d4
1 /*
2 * Copyright (C) 2005-2013 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 "BattleGroundRL.h"
23 #include "ObjectMgr.h"
24 #include "Language.h"
25 #include "WorldPacket.h"
27 BattleGroundRL::BattleGroundRL()
29 m_StartDelayTimes[BG_STARTING_EVENT_FIRST] = BG_START_DELAY_1M;
30 m_StartDelayTimes[BG_STARTING_EVENT_SECOND] = BG_START_DELAY_30S;
31 m_StartDelayTimes[BG_STARTING_EVENT_THIRD] = BG_START_DELAY_15S;
32 m_StartDelayTimes[BG_STARTING_EVENT_FOURTH] = BG_START_DELAY_NONE;
33 // we must set messageIds
34 m_StartMessageIds[BG_STARTING_EVENT_FIRST] = LANG_ARENA_ONE_MINUTE;
35 m_StartMessageIds[BG_STARTING_EVENT_SECOND] = LANG_ARENA_THIRTY_SECONDS;
36 m_StartMessageIds[BG_STARTING_EVENT_THIRD] = LANG_ARENA_FIFTEEN_SECONDS;
37 m_StartMessageIds[BG_STARTING_EVENT_FOURTH] = LANG_ARENA_HAS_BEGUN;
40 BattleGroundRL::~BattleGroundRL()
44 void BattleGroundRL::Update(uint32 diff)
46 BattleGround::Update(diff);
48 /*if (GetStatus() == STATUS_IN_PROGRESS)
50 // update something
51 }*/
54 void BattleGroundRL::StartingEventCloseDoors()
58 void BattleGroundRL::StartingEventOpenDoors()
60 OpenDoorEvent(BG_EVENT_DOOR);
63 void BattleGroundRL::AddPlayer(Player* plr)
65 BattleGround::AddPlayer(plr);
66 // create score and add it to map, default values are set in constructor
67 BattleGroundRLScore* sc = new BattleGroundRLScore;
69 m_PlayerScores[plr->GetObjectGuid()] = sc;
71 UpdateWorldState(0xbb8, GetAlivePlayersCountByTeam(ALLIANCE));
72 UpdateWorldState(0xbb9, GetAlivePlayersCountByTeam(HORDE));
75 void BattleGroundRL::RemovePlayer(Player* /*plr*/, ObjectGuid /*guid*/)
77 if (GetStatus() == STATUS_WAIT_LEAVE)
78 return;
80 UpdateWorldState(0xbb8, GetAlivePlayersCountByTeam(ALLIANCE));
81 UpdateWorldState(0xbb9, GetAlivePlayersCountByTeam(HORDE));
83 CheckArenaWinConditions();
86 void BattleGroundRL::HandleKillPlayer(Player* player, Player* killer)
88 if (GetStatus() != STATUS_IN_PROGRESS)
89 return;
91 if (!killer)
93 sLog.outError("Killer player not found");
94 return;
97 BattleGround::HandleKillPlayer(player, killer);
99 UpdateWorldState(0xbb8, GetAlivePlayersCountByTeam(ALLIANCE));
100 UpdateWorldState(0xbb9, GetAlivePlayersCountByTeam(HORDE));
102 CheckArenaWinConditions();
105 bool BattleGroundRL::HandlePlayerUnderMap(Player* player)
107 player->TeleportTo(GetMapId(), 1285.810547f, 1667.896851f, 39.957642f, player->GetOrientation(), false);
108 return true;
111 void BattleGroundRL::HandleAreaTrigger(Player* source, uint32 trigger)
113 // this is wrong way to implement these things. On official it done by gameobject spell cast.
114 if (GetStatus() != STATUS_IN_PROGRESS)
115 return;
117 // uint32 spellId = 0;
118 // uint64 buff_guid = 0;
119 switch (trigger)
121 case 4696: // buff trigger?
122 case 4697: // buff trigger?
123 break;
124 default:
125 sLog.outError("WARNING: Unhandled AreaTrigger in Battleground: %u", trigger);
126 source->GetSession()->SendAreaTriggerMessage("Warning: Unhandled AreaTrigger in Battleground: %u", trigger);
127 break;
130 // if (buff_guid)
131 // HandleTriggerBuff(buff_guid, source);
134 void BattleGroundRL::FillInitialWorldStates(WorldPacket& data, uint32& count)
136 FillInitialWorldState(data, count, 0xbb8, GetAlivePlayersCountByTeam(ALLIANCE));
137 FillInitialWorldState(data, count, 0xbb9, GetAlivePlayersCountByTeam(HORDE));
138 FillInitialWorldState(data, count, 0xbba, 1);
141 void BattleGroundRL::Reset()
143 // call parent's reset
144 BattleGround::Reset();
147 bool BattleGroundRL::SetupBattleGround()
149 return true;
153 Packet S->C, id 600, SMSG_INIT_WORLD_STATES (706), len 86
154 0000: 3C 02 00 00 80 0F 00 00 00 00 00 00 09 00 BA 0B | <...............
155 0010: 00 00 01 00 00 00 B9 0B 00 00 02 00 00 00 B8 0B | ................
156 0020: 00 00 00 00 00 00 D8 08 00 00 00 00 00 00 D7 08 | ................
157 0030: 00 00 00 00 00 00 D6 08 00 00 00 00 00 00 D5 08 | ................
158 0040: 00 00 00 00 00 00 D3 08 00 00 00 00 00 00 D4 08 | ................
159 0050: 00 00 00 00 00 00 | ......