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
21 #include "BattleGround.h"
22 #include "BattleGroundBE.h"
23 #include "ObjectMgr.h"
24 #include "WorldPacket.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)
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
)
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
)
94 sLog
.outError("Killer player not found");
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);
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
)
118 //uint32 SpellId = 0;
119 //uint64 buff_guid = 0;
122 case 4538: // buff trigger?
123 //buff_guid = m_BgObjects[BG_BE_OBJECT_BUFF_1];
125 case 4539: // buff trigger?
126 //buff_guid = m_BgObjects[BG_BE_OBJECT_BUFF_2];
129 sLog
.outError("WARNING: Unhandled AreaTrigger in Battleground: %u", Trigger
);
130 Source
->GetSession()->SendAreaTriggerMessage("Warning: Unhandled AreaTrigger in Battleground: %u", Trigger
);
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()
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...
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