[9033] Fixed percent mana regneration from spell 53228 and ranks buff.
[getmangos.git] / src / game / BattleGroundBE.cpp
blobfddc8bc4558180915624035fe79cb6978d77ee55
1 /*
2 * Copyright (C) 2005-2009 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 "BattleGroundBE.h"
23 #include "ObjectMgr.h"
24 #include "WorldPacket.h"
25 #include "Language.h"
27 BattleGroundBE::BattleGroundBE()
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 BattleGroundBE::~BattleGroundBE()
45 void BattleGroundBE::Update(uint32 diff)
47 BattleGround::Update(diff);
49 /*if (GetStatus() == STATUS_IN_PROGRESS)
51 // update something
52 }*/
55 void BattleGroundBE::StartingEventCloseDoors()
59 void BattleGroundBE::StartingEventOpenDoors()
61 OpenDoorEvent(BG_EVENT_DOOR);
64 void BattleGroundBE::AddPlayer(Player *plr)
66 BattleGround::AddPlayer(plr);
67 //create score and add it to map, default values are set in constructor
68 BattleGroundBEScore* sc = new BattleGroundBEScore;
70 m_PlayerScores[plr->GetGUID()] = sc;
72 UpdateWorldState(0x9f1, GetAlivePlayersCountByTeam(ALLIANCE));
73 UpdateWorldState(0x9f0, GetAlivePlayersCountByTeam(HORDE));
76 void BattleGroundBE::RemovePlayer(Player* /*plr*/, uint64 /*guid*/)
78 if (GetStatus() == STATUS_WAIT_LEAVE)
79 return;
81 UpdateWorldState(0x9f1, GetAlivePlayersCountByTeam(ALLIANCE));
82 UpdateWorldState(0x9f0, GetAlivePlayersCountByTeam(HORDE));
84 CheckArenaWinConditions();
87 void BattleGroundBE::HandleKillPlayer(Player *player, Player *killer)
89 if (GetStatus() != STATUS_IN_PROGRESS)
90 return;
92 if (!killer)
94 sLog.outError("Killer player not found");
95 return;
98 BattleGround::HandleKillPlayer(player,killer);
100 UpdateWorldState(0x9f1, GetAlivePlayersCountByTeam(ALLIANCE));
101 UpdateWorldState(0x9f0, GetAlivePlayersCountByTeam(HORDE));
103 CheckArenaWinConditions();
106 bool BattleGroundBE::HandlePlayerUnderMap(Player *player)
108 player->TeleportTo(GetMapId(),6238.930176,262.963470,0.889519,player->GetOrientation(),false);
109 return true;
112 void BattleGroundBE::HandleAreaTrigger(Player *Source, uint32 Trigger)
114 // this is wrong way to implement these things. On official it done by gameobject spell cast.
115 if (GetStatus() != STATUS_IN_PROGRESS)
116 return;
118 //uint32 SpellId = 0;
119 //uint64 buff_guid = 0;
120 switch(Trigger)
122 case 4538: // buff trigger?
123 //buff_guid = m_BgObjects[BG_BE_OBJECT_BUFF_1];
124 break;
125 case 4539: // buff trigger?
126 //buff_guid = m_BgObjects[BG_BE_OBJECT_BUFF_2];
127 break;
128 default:
129 sLog.outError("WARNING: Unhandled AreaTrigger in Battleground: %u", Trigger);
130 Source->GetSession()->SendAreaTriggerMessage("Warning: Unhandled AreaTrigger in Battleground: %u", Trigger);
131 break;
134 //if (buff_guid)
135 // HandleTriggerBuff(buff_guid,Source);
138 void BattleGroundBE::FillInitialWorldStates(WorldPacket &data)
140 data << uint32(0x9f1) << uint32(GetAlivePlayersCountByTeam(ALLIANCE)); // 7
141 data << uint32(0x9f0) << uint32(GetAlivePlayersCountByTeam(HORDE)); // 8
142 data << uint32(0x9f3) << uint32(1); // 9
145 void BattleGroundBE::Reset()
147 //call parent's class reset
148 BattleGround::Reset();
151 bool BattleGroundBE::SetupBattleGround()
153 return true;
156 void BattleGroundBE::UpdatePlayerScore(Player* Source, uint32 type, uint32 value)
159 BattleGroundScoreMap::iterator itr = m_PlayerScores.find(Source->GetGUID());
160 if(itr == m_PlayerScores.end()) // player not found...
161 return;
163 //there is nothing special in this score
164 BattleGround::UpdatePlayerScore(Source,type,value);
169 21:45:46 id:231310 [S2C] SMSG_INIT_WORLD_STATES (706 = 0x02C2) len: 86
170 0000: 32 02 00 00 76 0e 00 00 00 00 00 00 09 00 f3 09 | 2...v...........
171 0010: 00 00 01 00 00 00 f1 09 00 00 01 00 00 00 f0 09 | ................
172 0020: 00 00 02 00 00 00 d4 08 00 00 00 00 00 00 d8 08 | ................
173 0030: 00 00 00 00 00 00 d7 08 00 00 00 00 00 00 d6 08 | ................
174 0040: 00 00 00 00 00 00 d5 08 00 00 00 00 00 00 d3 08 | ................
175 0050: 00 00 00 00 00 00 | ......
177 spell 32724 - Gold Team
178 spell 32725 - Green Team
179 35774 Gold Team
180 35775 Green Team