[9581] Fixed apply damage reduction to melee/ranged damage.
[getmangos.git] / src / game / BattleGroundRL.cpp
blobeb4232081dce0f6368d65d4dfa6e0e0225b6d1ab
1 /*
2 * Copyright (C) 2005-2010 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()
45 void BattleGroundRL::Update(uint32 diff)
47 BattleGround::Update(diff);
49 /*if (GetStatus() == STATUS_IN_PROGRESS)
51 // update something
52 }*/
55 void BattleGroundRL::StartingEventCloseDoors()
59 void BattleGroundRL::StartingEventOpenDoors()
61 OpenDoorEvent(BG_EVENT_DOOR);
64 void BattleGroundRL::AddPlayer(Player *plr)
66 BattleGround::AddPlayer(plr);
67 //create score and add it to map, default values are set in constructor
68 BattleGroundRLScore* sc = new BattleGroundRLScore;
70 m_PlayerScores[plr->GetGUID()] = sc;
72 UpdateWorldState(0xbb8, GetAlivePlayersCountByTeam(ALLIANCE));
73 UpdateWorldState(0xbb9, GetAlivePlayersCountByTeam(HORDE));
76 void BattleGroundRL::RemovePlayer(Player* /*plr*/, uint64 /*guid*/)
78 if (GetStatus() == STATUS_WAIT_LEAVE)
79 return;
81 UpdateWorldState(0xbb8, GetAlivePlayersCountByTeam(ALLIANCE));
82 UpdateWorldState(0xbb9, GetAlivePlayersCountByTeam(HORDE));
84 CheckArenaWinConditions();
87 void BattleGroundRL::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(0xbb8, GetAlivePlayersCountByTeam(ALLIANCE));
101 UpdateWorldState(0xbb9, GetAlivePlayersCountByTeam(HORDE));
103 CheckArenaWinConditions();
106 bool BattleGroundRL::HandlePlayerUnderMap(Player *player)
108 player->TeleportTo(GetMapId(),1285.810547f,1667.896851f,39.957642f,player->GetOrientation(),false);
109 return true;
112 void BattleGroundRL::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 4696: // buff trigger?
123 case 4697: // buff trigger?
124 break;
125 default:
126 sLog.outError("WARNING: Unhandled AreaTrigger in Battleground: %u", Trigger);
127 Source->GetSession()->SendAreaTriggerMessage("Warning: Unhandled AreaTrigger in Battleground: %u", Trigger);
128 break;
131 //if (buff_guid)
132 // HandleTriggerBuff(buff_guid,Source);
135 void BattleGroundRL::FillInitialWorldStates(WorldPacket &data)
137 data << uint32(0xbb8) << uint32(GetAlivePlayersCountByTeam(ALLIANCE)); // 7
138 data << uint32(0xbb9) << uint32(GetAlivePlayersCountByTeam(HORDE)); // 8
139 data << uint32(0xbba) << uint32(1); // 9
142 void BattleGroundRL::Reset()
144 //call parent's reset
145 BattleGround::Reset();
148 bool BattleGroundRL::SetupBattleGround()
150 return true;
154 Packet S->C, id 600, SMSG_INIT_WORLD_STATES (706), len 86
155 0000: 3C 02 00 00 80 0F 00 00 00 00 00 00 09 00 BA 0B | <...............
156 0010: 00 00 01 00 00 00 B9 0B 00 00 02 00 00 00 B8 0B | ................
157 0020: 00 00 00 00 00 00 D8 08 00 00 00 00 00 00 D7 08 | ................
158 0030: 00 00 00 00 00 00 D6 08 00 00 00 00 00 00 D5 08 | ................
159 0040: 00 00 00 00 00 00 D3 08 00 00 00 00 00 00 D4 08 | ................
160 0050: 00 00 00 00 00 00 | ......