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
21 #include "BattleGround.h"
22 #include "BattleGroundWS.h"
24 #include "GameObject.h"
26 #include "MapManager.h"
29 BattleGroundWS::BattleGroundWS()
31 m_BgObjects
.resize(BG_WS_OBJECT_MAX
);
32 m_BgCreatures
.resize(BG_CREATURES_MAX_WS
);
35 BattleGroundWS::~BattleGroundWS()
39 void BattleGroundWS::Update(time_t diff
)
41 BattleGround::Update(diff
);
43 // after bg start we get there (once)
44 if (GetStatus() == STATUS_WAIT_JOIN
&& GetPlayersSize())
46 ModifyStartDelayTime(diff
);
48 if(!(m_Events
& 0x01))
52 for(uint32 i
= BG_WS_OBJECT_DOOR_A_1
; i
<= BG_WS_OBJECT_DOOR_H_4
; i
++)
54 SpawnBGObject(i
, RESPAWN_IMMEDIATELY
);
57 for(uint32 i
= BG_WS_OBJECT_A_FLAG
; i
<= BG_WS_OBJECT_BERSERKBUFF_2
; i
++)
58 SpawnBGObject(i
, RESPAWN_ONE_DAY
);
60 SetStartDelayTime(START_DELAY0
);
62 // After 1 minute, warning is signalled
63 else if(GetStartDelayTime() <= START_DELAY1
&& !(m_Events
& 0x04))
66 SendMessageToAll(GetMangosString(LANG_BG_WS_ONE_MINUTE
));
68 // After 1,5 minute, warning is signalled
69 else if(GetStartDelayTime() <= START_DELAY2
&& !(m_Events
& 0x08))
72 SendMessageToAll(GetMangosString(LANG_BG_WS_HALF_MINUTE
));
74 // After 2 minutes, gates OPEN ! x)
75 else if(GetStartDelayTime() < 0 && !(m_Events
& 0x10))
78 for(uint32 i
= BG_WS_OBJECT_DOOR_A_1
; i
<= BG_WS_OBJECT_DOOR_A_4
; i
++)
80 for(uint32 i
= BG_WS_OBJECT_DOOR_H_1
; i
<= BG_WS_OBJECT_DOOR_H_2
; i
++)
83 SpawnBGObject(BG_WS_OBJECT_DOOR_A_5
, RESPAWN_ONE_DAY
);
84 SpawnBGObject(BG_WS_OBJECT_DOOR_A_6
, RESPAWN_ONE_DAY
);
85 SpawnBGObject(BG_WS_OBJECT_DOOR_H_3
, RESPAWN_ONE_DAY
);
86 SpawnBGObject(BG_WS_OBJECT_DOOR_H_4
, RESPAWN_ONE_DAY
);
88 for(uint32 i
= BG_WS_OBJECT_A_FLAG
; i
<= BG_WS_OBJECT_BERSERKBUFF_2
; i
++)
89 SpawnBGObject(i
, RESPAWN_IMMEDIATELY
);
91 SendMessageToAll(GetMangosString(LANG_BG_WS_BEGIN
));
93 PlaySoundToAll(SOUND_BG_START
);
94 SetStatus(STATUS_IN_PROGRESS
);
96 for(BattleGroundPlayerMap::const_iterator itr
= GetPlayers().begin(); itr
!= GetPlayers().end(); ++itr
)
97 if(Player
* plr
= objmgr
.GetPlayer(itr
->first
))
98 plr
->RemoveAurasDueToSpell(SPELL_PREPARATION
);
101 else if(GetStatus() == STATUS_IN_PROGRESS
)
103 if(m_FlagState
[BG_TEAM_ALLIANCE
] == BG_WS_FLAG_STATE_WAIT_RESPAWN
)
105 m_FlagsTimer
[BG_TEAM_ALLIANCE
] -= diff
;
107 if(m_FlagsTimer
[BG_TEAM_ALLIANCE
] < 0)
109 m_FlagsTimer
[BG_TEAM_ALLIANCE
] = 0;
110 RespawnFlag(ALLIANCE
, true);
113 if(m_FlagState
[BG_TEAM_ALLIANCE
] == BG_WS_FLAG_STATE_ON_GROUND
)
115 m_FlagsDropTimer
[BG_TEAM_ALLIANCE
] -= diff
;
117 if(m_FlagsDropTimer
[BG_TEAM_ALLIANCE
] < 0)
119 m_FlagsDropTimer
[BG_TEAM_ALLIANCE
] = 0;
120 RespawnFlagAfterDrop(ALLIANCE
);
123 if(m_FlagState
[BG_TEAM_HORDE
] == BG_WS_FLAG_STATE_WAIT_RESPAWN
)
125 m_FlagsTimer
[BG_TEAM_HORDE
] -= diff
;
127 if(m_FlagsTimer
[BG_TEAM_HORDE
] < 0)
129 m_FlagsTimer
[BG_TEAM_HORDE
] = 0;
130 RespawnFlag(HORDE
, true);
133 if(m_FlagState
[BG_TEAM_HORDE
] == BG_WS_FLAG_STATE_ON_GROUND
)
135 m_FlagsDropTimer
[BG_TEAM_HORDE
] -= diff
;
137 if(m_FlagsDropTimer
[BG_TEAM_HORDE
] < 0)
139 m_FlagsDropTimer
[BG_TEAM_HORDE
] = 0;
140 RespawnFlagAfterDrop(HORDE
);
146 void BattleGroundWS::AddPlayer(Player
*plr
)
148 BattleGround::AddPlayer(plr
);
149 //create score and add it to map, default values are set in constructor
150 BattleGroundWGScore
* sc
= new BattleGroundWGScore
;
152 m_PlayerScores
[plr
->GetGUID()] = sc
;
155 void BattleGroundWS::RespawnFlag(uint32 Team
, bool captured
)
159 sLog
.outDebug("Respawn Alliance flag");
160 m_FlagState
[BG_TEAM_ALLIANCE
] = BG_WS_FLAG_STATE_ON_BASE
;
164 sLog
.outDebug("Respawn Horde flag");
165 m_FlagState
[BG_TEAM_HORDE
] = BG_WS_FLAG_STATE_ON_BASE
;
170 //when map_update will be allowed for battlegrounds this code will be useless
171 SpawnBGObject(BG_WS_OBJECT_H_FLAG
, RESPAWN_IMMEDIATELY
);
172 SpawnBGObject(BG_WS_OBJECT_A_FLAG
, RESPAWN_IMMEDIATELY
);
173 SendMessageToAll(GetMangosString(LANG_BG_WS_F_PLACED
));
174 PlaySoundToAll(BG_WS_SOUND_FLAGS_RESPAWNED
); // flag respawned sound...
178 void BattleGroundWS::RespawnFlagAfterDrop(uint32 team
)
180 if(GetStatus() != STATUS_IN_PROGRESS
)
183 RespawnFlag(team
,false);
186 SpawnBGObject(BG_WS_OBJECT_A_FLAG
, RESPAWN_IMMEDIATELY
);
187 SendMessageToAll(GetMangosString(LANG_BG_WS_ALLIANCE_FLAG_RESPAWNED
));
191 SpawnBGObject(BG_WS_OBJECT_H_FLAG
, RESPAWN_IMMEDIATELY
);
192 SendMessageToAll(GetMangosString(LANG_BG_WS_HORDE_FLAG_RESPAWNED
));
195 PlaySoundToAll(BG_WS_SOUND_FLAGS_RESPAWNED
);
197 GameObject
*obj
= HashMapHolder
<GameObject
>::Find(GetDroppedFlagGUID(team
));
201 sLog
.outError("unknown droped flag bg, guid: %u",GUID_LOPART(GetDroppedFlagGUID(team
)));
203 SetDroppedFlagGUID(0,team
);
206 void BattleGroundWS::EventPlayerCapturedFlag(Player
*Source
)
208 if(GetStatus() != STATUS_IN_PROGRESS
)
213 const char *message
= "";
215 //TODO FIX reputation and honor gains for low level players!
217 Source
->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT
);
218 if(Source
->GetTeam() == ALLIANCE
)
220 if (!IsHordeFlagPickedup())
222 SetHordeFlagPicker(0); // must be before aura remove to prevent 2 events (drop+capture) at the same time
223 // horde flag in base (but not respawned yet)
224 m_FlagState
[BG_TEAM_HORDE
] = BG_WS_FLAG_STATE_WAIT_RESPAWN
;
225 // Drop Horde Flag from Player
226 Source
->RemoveAurasDueToSpell(BG_WS_SPELL_WARSONG_FLAG
);
227 message
= GetMangosString(LANG_BG_WS_CAPTURED_HF
);
228 type
= CHAT_MSG_BG_SYSTEM_ALLIANCE
;
229 if(GetTeamScore(ALLIANCE
) < BG_WS_MAX_TEAM_SCORE
)
230 AddPoint(ALLIANCE
, 1);
231 PlaySoundToAll(BG_WS_SOUND_FLAG_CAPTURED_ALLIANCE
);
232 RewardReputationToTeam(890, 35, ALLIANCE
); // +35 reputation
233 RewardHonorToTeam(40, ALLIANCE
); // +40 bonushonor
237 if (!IsAllianceFlagPickedup())
239 SetAllianceFlagPicker(0); // must be before aura remove to prevent 2 events (drop+capture) at the same time
240 // alliance flag in base (but not respawned yet)
241 m_FlagState
[BG_TEAM_ALLIANCE
] = BG_WS_FLAG_STATE_WAIT_RESPAWN
;
242 // Drop Alliance Flag from Player
243 Source
->RemoveAurasDueToSpell(BG_WS_SPELL_SILVERWING_FLAG
);
244 message
= GetMangosString(LANG_BG_WS_CAPTURED_AF
);
245 type
= CHAT_MSG_BG_SYSTEM_HORDE
;
246 if(GetTeamScore(HORDE
) < BG_WS_MAX_TEAM_SCORE
)
248 PlaySoundToAll(BG_WS_SOUND_FLAG_CAPTURED_HORDE
);
249 RewardReputationToTeam(889, 35, HORDE
); // +35 reputation
250 RewardHonorToTeam(40, HORDE
); // +40 bonushonor
253 SpawnBGObject(BG_WS_OBJECT_H_FLAG
, BG_WS_FLAG_RESPAWN_TIME
);
254 SpawnBGObject(BG_WS_OBJECT_A_FLAG
, BG_WS_FLAG_RESPAWN_TIME
);
257 ChatHandler::FillMessageData(&data
, Source
->GetSession(), type
, LANG_UNIVERSAL
, NULL
, Source
->GetGUID(), message
, NULL
);
258 SendPacketToAll(&data
);
260 UpdateFlagState(Source
->GetTeam(), 1); // flag state none
261 UpdateTeamScore(Source
->GetTeam());
262 // only flag capture should be updated
263 UpdatePlayerScore(Source
, SCORE_FLAG_CAPTURES
, 1); // +1 flag captures...
265 if(GetTeamScore(ALLIANCE
) == BG_WS_MAX_TEAM_SCORE
)
268 if(GetTeamScore(HORDE
) == BG_WS_MAX_TEAM_SCORE
)
273 UpdateWorldState(BG_WS_FLAG_UNK_ALLIANCE
, 0);
274 UpdateWorldState(BG_WS_FLAG_UNK_HORDE
, 0);
275 UpdateWorldState(BG_WS_FLAG_STATE_ALLIANCE
, 1);
276 UpdateWorldState(BG_WS_FLAG_STATE_HORDE
, 1);
278 EndBattleGround(winner
);
282 m_FlagsTimer
[GetTeamIndexByTeamId(Source
->GetTeam()) ? 0 : 1] = BG_WS_FLAG_RESPAWN_TIME
;
286 void BattleGroundWS::EventPlayerDroppedFlag(Player
*Source
)
288 // Drop allowed in any BG state
290 const char *message
= "";
294 if(Source
->GetTeam() == ALLIANCE
)
296 if(!IsHordeFlagPickedup())
298 if(GetHordeFlagPickerGUID() == Source
->GetGUID())
300 SetHordeFlagPicker(0);
301 Source
->RemoveAurasDueToSpell(BG_WS_SPELL_WARSONG_FLAG
);
302 m_FlagState
[BG_TEAM_HORDE
] = BG_WS_FLAG_STATE_ON_GROUND
;
303 message
= GetMangosString(LANG_BG_WS_DROPPED_HF
);
304 type
= CHAT_MSG_BG_SYSTEM_HORDE
;
305 Source
->CastSpell(Source
, BG_WS_SPELL_WARSONG_FLAG_DROPPED
, true);
311 if(!IsAllianceFlagPickedup())
313 if(GetAllianceFlagPickerGUID() == Source
->GetGUID())
315 SetAllianceFlagPicker(0);
316 Source
->RemoveAurasDueToSpell(BG_WS_SPELL_SILVERWING_FLAG
);
317 m_FlagState
[BG_TEAM_ALLIANCE
] = BG_WS_FLAG_STATE_ON_GROUND
;
318 message
= GetMangosString(LANG_BG_WS_DROPPED_AF
);
319 type
= CHAT_MSG_BG_SYSTEM_ALLIANCE
;
320 Source
->CastSpell(Source
, BG_WS_SPELL_SILVERWING_FLAG_DROPPED
, true);
327 Source
->CastSpell(Source
, SPELL_RECENTLY_DROPPED_FLAG
, true);
328 UpdateFlagState(Source
->GetTeam(), 1);
331 ChatHandler::FillMessageData(&data
, Source
->GetSession(), type
, LANG_UNIVERSAL
, NULL
, Source
->GetGUID(), message
, NULL
);
332 SendPacketToAll(&data
);
334 if(Source
->GetTeam() == ALLIANCE
)
335 UpdateWorldState(BG_WS_FLAG_UNK_HORDE
, uint32(-1));
337 UpdateWorldState(BG_WS_FLAG_UNK_ALLIANCE
, uint32(-1));
339 m_FlagsDropTimer
[GetTeamIndexByTeamId(Source
->GetTeam()) ? 0 : 1] = BG_WS_FLAG_DROP_TIME
;
343 void BattleGroundWS::EventPlayerClickedOnFlag(Player
*Source
, GameObject
* target_obj
)
345 if(GetStatus() != STATUS_IN_PROGRESS
)
348 const char *message
= NULL
;
351 //alliance flag picked up from base
352 if(Source
->GetTeam() == HORDE
&& GetFlagState(ALLIANCE
) == BG_WS_FLAG_STATE_ON_BASE
353 && m_BgObjects
[BG_WS_OBJECT_A_FLAG
] == target_obj
->GetGUID())
355 message
= GetMangosString(LANG_BG_WS_PICKEDUP_AF
);
356 type
= CHAT_MSG_BG_SYSTEM_HORDE
;
357 PlaySoundToAll(BG_WS_SOUND_ALLIANCE_FLAG_PICKED_UP
);
358 SpawnBGObject(BG_WS_OBJECT_A_FLAG
, RESPAWN_ONE_DAY
);
359 SetAllianceFlagPicker(Source
->GetGUID());
360 m_FlagState
[BG_TEAM_ALLIANCE
] = BG_WS_FLAG_STATE_ON_PLAYER
;
361 //update world state to show correct flag carrier
362 UpdateFlagState(HORDE
, BG_WS_FLAG_STATE_ON_PLAYER
);
363 UpdateWorldState(BG_WS_FLAG_UNK_ALLIANCE
, 1);
364 Source
->CastSpell(Source
, BG_WS_SPELL_SILVERWING_FLAG
, true);
367 //horde flag picked up from base
368 if (Source
->GetTeam() == ALLIANCE
&& GetFlagState(HORDE
) == BG_WS_FLAG_STATE_ON_BASE
369 && m_BgObjects
[BG_WS_OBJECT_H_FLAG
] == target_obj
->GetGUID())
371 message
= GetMangosString(LANG_BG_WS_PICKEDUP_HF
);
372 type
= CHAT_MSG_BG_SYSTEM_ALLIANCE
;
373 PlaySoundToAll(BG_WS_SOUND_HORDE_FLAG_PICKED_UP
);
374 SpawnBGObject(BG_WS_OBJECT_H_FLAG
, RESPAWN_ONE_DAY
);
375 SetHordeFlagPicker(Source
->GetGUID());
376 m_FlagState
[BG_TEAM_HORDE
] = BG_WS_FLAG_STATE_ON_PLAYER
;
377 //update world state to show correct flag carrier
378 UpdateFlagState(ALLIANCE
, BG_WS_FLAG_STATE_ON_PLAYER
);
379 UpdateWorldState(BG_WS_FLAG_UNK_HORDE
, 1);
380 Source
->CastSpell(Source
, BG_WS_SPELL_WARSONG_FLAG
, true);
383 //Alliance flag on ground(not in base) (returned or picked up again from ground!)
384 if(GetFlagState(ALLIANCE
) == BG_WS_FLAG_STATE_ON_GROUND
&& Source
->IsWithinDistInMap(target_obj
, 10))
386 if(Source
->GetTeam() == ALLIANCE
)
388 message
= GetMangosString(LANG_BG_WS_RETURNED_AF
);
389 type
= CHAT_MSG_BG_SYSTEM_ALLIANCE
;
390 UpdateFlagState(HORDE
, BG_WS_FLAG_STATE_WAIT_RESPAWN
);
391 RespawnFlag(ALLIANCE
, false);
392 SpawnBGObject(BG_WS_OBJECT_A_FLAG
, RESPAWN_IMMEDIATELY
);
393 PlaySoundToAll(BG_WS_SOUND_FLAG_RETURNED
);
394 UpdatePlayerScore(Source
, SCORE_FLAG_RETURNS
, 1);
398 message
= GetMangosString(LANG_BG_WS_PICKEDUP_AF
);
399 type
= CHAT_MSG_BG_SYSTEM_HORDE
;
400 PlaySoundToAll(BG_WS_SOUND_ALLIANCE_FLAG_PICKED_UP
);
401 SpawnBGObject(BG_WS_OBJECT_A_FLAG
, RESPAWN_ONE_DAY
);
402 SetAllianceFlagPicker(Source
->GetGUID());
403 Source
->CastSpell(Source
, BG_WS_SPELL_SILVERWING_FLAG
, true);
404 m_FlagState
[BG_TEAM_ALLIANCE
] = BG_WS_FLAG_STATE_ON_PLAYER
;
405 UpdateFlagState(HORDE
, BG_WS_FLAG_STATE_ON_PLAYER
);
406 UpdateWorldState(BG_WS_FLAG_UNK_ALLIANCE
, 1);
408 //called in HandleGameObjectUseOpcode:
409 //target_obj->Delete();
412 //Horde flag on ground(not in base) (returned or picked up again)
413 if(GetFlagState(HORDE
) == BG_WS_FLAG_STATE_ON_GROUND
&& Source
->IsWithinDistInMap(target_obj
, 10))
415 if(Source
->GetTeam() == HORDE
)
417 message
= GetMangosString(LANG_BG_WS_RETURNED_HF
);
418 type
= CHAT_MSG_BG_SYSTEM_HORDE
;
419 UpdateFlagState(ALLIANCE
, BG_WS_FLAG_STATE_WAIT_RESPAWN
);
420 RespawnFlag(HORDE
, false);
421 SpawnBGObject(BG_WS_OBJECT_H_FLAG
, RESPAWN_IMMEDIATELY
);
422 PlaySoundToAll(BG_WS_SOUND_FLAG_RETURNED
);
423 UpdatePlayerScore(Source
, SCORE_FLAG_RETURNS
, 1);
427 message
= GetMangosString(LANG_BG_WS_PICKEDUP_HF
);
428 type
= CHAT_MSG_BG_SYSTEM_ALLIANCE
;
429 PlaySoundToAll(BG_WS_SOUND_HORDE_FLAG_PICKED_UP
);
430 SpawnBGObject(BG_WS_OBJECT_H_FLAG
, RESPAWN_ONE_DAY
);
431 SetHordeFlagPicker(Source
->GetGUID());
432 Source
->CastSpell(Source
, BG_WS_SPELL_WARSONG_FLAG
, true);
433 m_FlagState
[BG_TEAM_HORDE
] = BG_WS_FLAG_STATE_ON_PLAYER
;
434 UpdateFlagState(ALLIANCE
, BG_WS_FLAG_STATE_ON_PLAYER
);
435 UpdateWorldState(BG_WS_FLAG_UNK_HORDE
, 1);
437 //called in HandleGameObjectUseOpcode:
438 //target_obj->Delete();
445 ChatHandler::FillMessageData(&data
, Source
->GetSession(), type
, LANG_UNIVERSAL
, NULL
, Source
->GetGUID(), message
, NULL
);
446 SendPacketToAll(&data
);
447 Source
->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT
);
450 void BattleGroundWS::RemovePlayer(Player
*plr
, uint64 guid
)
452 // sometimes flag aura not removed :(
453 if(IsAllianceFlagPickedup() && m_FlagKeepers
[BG_TEAM_ALLIANCE
] == guid
)
457 sLog
.outError("BattleGroundWS: Removing offline player who has the FLAG!!");
458 SetAllianceFlagPicker(0);
459 RespawnFlag(ALLIANCE
, false);
462 EventPlayerDroppedFlag(plr
);
464 if(IsHordeFlagPickedup() && m_FlagKeepers
[BG_TEAM_HORDE
] == guid
)
468 sLog
.outError("BattleGroundWS: Removing offline player who has the FLAG!!");
469 SetHordeFlagPicker(0);
470 RespawnFlag(HORDE
, false);
473 EventPlayerDroppedFlag(plr
);
477 void BattleGroundWS::UpdateFlagState(uint32 team
, uint32 value
)
480 UpdateWorldState(BG_WS_FLAG_STATE_ALLIANCE
, value
);
482 UpdateWorldState(BG_WS_FLAG_STATE_HORDE
, value
);
485 void BattleGroundWS::UpdateTeamScore(uint32 team
)
488 UpdateWorldState(BG_WS_FLAG_CAPTURES_ALLIANCE
, GetTeamScore(team
));
490 UpdateWorldState(BG_WS_FLAG_CAPTURES_HORDE
, GetTeamScore(team
));
493 void BattleGroundWS::HandleAreaTrigger(Player
*Source
, uint32 Trigger
)
495 // this is wrong way to implement these things. On official it done by gameobject spell cast.
496 if(GetStatus() != STATUS_IN_PROGRESS
)
499 //uint32 SpellId = 0;
500 //uint64 buff_guid = 0;
503 case 3686: // Alliance elixir of speed spawn. Trigger not working, because located inside other areatrigger, can be replaced by IsWithinDist(object, dist) in BattleGround::Update().
504 //buff_guid = m_BgObjects[BG_WS_OBJECT_SPEEDBUFF_1];
506 case 3687: // Horde elixir of speed spawn. Trigger not working, because located inside other areatrigger, can be replaced by IsWithinDist(object, dist) in BattleGround::Update().
507 //buff_guid = m_BgObjects[BG_WS_OBJECT_SPEEDBUFF_2];
509 case 3706: // Alliance elixir of regeneration spawn
510 //buff_guid = m_BgObjects[BG_WS_OBJECT_REGENBUFF_1];
512 case 3708: // Horde elixir of regeneration spawn
513 //buff_guid = m_BgObjects[BG_WS_OBJECT_REGENBUFF_2];
515 case 3707: // Alliance elixir of berserk spawn
516 //buff_guid = m_BgObjects[BG_WS_OBJECT_BERSERKBUFF_1];
518 case 3709: // Horde elixir of berserk spawn
519 //buff_guid = m_BgObjects[BG_WS_OBJECT_BERSERKBUFF_2];
521 case 3646: // Alliance Flag spawn
522 if(m_FlagState
[BG_TEAM_HORDE
] && !m_FlagState
[BG_TEAM_ALLIANCE
])
523 if(GetHordeFlagPickerGUID() == Source
->GetGUID())
524 EventPlayerCapturedFlag(Source
);
526 case 3647: // Horde Flag spawn
527 if(m_FlagState
[BG_TEAM_ALLIANCE
] && !m_FlagState
[BG_TEAM_HORDE
])
528 if(GetAllianceFlagPickerGUID() == Source
->GetGUID())
529 EventPlayerCapturedFlag(Source
);
537 sLog
.outError("WARNING: Unhandled AreaTrigger in Battleground: %u", Trigger
);
538 Source
->GetSession()->SendAreaTriggerMessage("Warning: Unhandled AreaTrigger in Battleground: %u", Trigger
);
543 // HandleTriggerBuff(buff_guid,Source);
546 bool BattleGroundWS::SetupBattleGround()
549 if( !AddObject(BG_WS_OBJECT_A_FLAG
, BG_OBJECT_A_FLAG_WS_ENTRY
, 1540.423f
, 1481.325f
, 351.8284f
, 3.089233f
, 0, 0, 0.9996573f
, 0.02617699f
, BG_WS_FLAG_RESPAWN_TIME
/1000)
550 || !AddObject(BG_WS_OBJECT_H_FLAG
, BG_OBJECT_H_FLAG_WS_ENTRY
, 916.0226f
, 1434.405f
, 345.413f
, 0.01745329f
, 0, 0, 0.008726535f
, 0.9999619f
, BG_WS_FLAG_RESPAWN_TIME
/1000)
552 || !AddObject(BG_WS_OBJECT_SPEEDBUFF_1
, BG_OBJECTID_SPEEDBUFF_ENTRY
, 1449.93f
, 1470.71f
, 342.6346f
, -1.64061f
, 0, 0, 0.7313537f
, -0.6819983f
, BUFF_RESPAWN_TIME
)
553 || !AddObject(BG_WS_OBJECT_SPEEDBUFF_2
, BG_OBJECTID_SPEEDBUFF_ENTRY
, 1005.171f
, 1447.946f
, 335.9032f
, 1.64061f
, 0, 0, 0.7313537f
, 0.6819984f
, BUFF_RESPAWN_TIME
)
554 || !AddObject(BG_WS_OBJECT_REGENBUFF_1
, BG_OBJECTID_REGENBUFF_ENTRY
, 1317.506f
, 1550.851f
, 313.2344f
, -0.2617996f
, 0, 0, 0.1305263f
, -0.9914448f
, BUFF_RESPAWN_TIME
)
555 || !AddObject(BG_WS_OBJECT_REGENBUFF_2
, BG_OBJECTID_REGENBUFF_ENTRY
, 1110.451f
, 1353.656f
, 316.5181f
, -0.6806787f
, 0, 0, 0.333807f
, -0.9426414f
, BUFF_RESPAWN_TIME
)
556 || !AddObject(BG_WS_OBJECT_BERSERKBUFF_1
, BG_OBJECTID_BERSERKERBUFF_ENTRY
, 1320.09f
, 1378.79f
, 314.7532f
, 1.186824f
, 0, 0, 0.5591929f
, 0.8290376f
, BUFF_RESPAWN_TIME
)
557 || !AddObject(BG_WS_OBJECT_BERSERKBUFF_2
, BG_OBJECTID_BERSERKERBUFF_ENTRY
, 1139.688f
, 1560.288f
, 306.8432f
, -2.443461f
, 0, 0, 0.9396926f
, -0.3420201f
, BUFF_RESPAWN_TIME
)
559 || !AddObject(BG_WS_OBJECT_DOOR_A_1
, BG_OBJECT_DOOR_A_1_WS_ENTRY
, 1503.335f
, 1493.466f
, 352.1888f
, 3.115414f
, 0, 0, 0.9999143f
, 0.01308903f
, RESPAWN_IMMEDIATELY
)
560 || !AddObject(BG_WS_OBJECT_DOOR_A_2
, BG_OBJECT_DOOR_A_2_WS_ENTRY
, 1492.478f
, 1457.912f
, 342.9689f
, 3.115414f
, 0, 0, 0.9999143f
, 0.01308903f
, RESPAWN_IMMEDIATELY
)
561 || !AddObject(BG_WS_OBJECT_DOOR_A_3
, BG_OBJECT_DOOR_A_3_WS_ENTRY
, 1468.503f
, 1494.357f
, 351.8618f
, 3.115414f
, 0, 0, 0.9999143f
, 0.01308903f
, RESPAWN_IMMEDIATELY
)
562 || !AddObject(BG_WS_OBJECT_DOOR_A_4
, BG_OBJECT_DOOR_A_4_WS_ENTRY
, 1471.555f
, 1458.778f
, 362.6332f
, 3.115414f
, 0, 0, 0.9999143f
, 0.01308903f
, RESPAWN_IMMEDIATELY
)
563 || !AddObject(BG_WS_OBJECT_DOOR_A_5
, BG_OBJECT_DOOR_A_5_WS_ENTRY
, 1492.347f
, 1458.34f
, 342.3712f
, -0.03490669f
, 0, 0, 0.01745246f
, -0.9998477f
, RESPAWN_IMMEDIATELY
)
564 || !AddObject(BG_WS_OBJECT_DOOR_A_6
, BG_OBJECT_DOOR_A_6_WS_ENTRY
, 1503.466f
, 1493.367f
, 351.7352f
, -0.03490669f
, 0, 0, 0.01745246f
, -0.9998477f
, RESPAWN_IMMEDIATELY
)
566 || !AddObject(BG_WS_OBJECT_DOOR_H_1
, BG_OBJECT_DOOR_H_1_WS_ENTRY
, 949.1663f
, 1423.772f
, 345.6241f
, -0.5756807f
, -0.01673368f
, -0.004956111f
, -0.2839723f
, 0.9586737f
, RESPAWN_IMMEDIATELY
)
567 || !AddObject(BG_WS_OBJECT_DOOR_H_2
, BG_OBJECT_DOOR_H_2_WS_ENTRY
, 953.0507f
, 1459.842f
, 340.6526f
, -1.99662f
, -0.1971825f
, 0.1575096f
, -0.8239487f
, 0.5073641f
, RESPAWN_IMMEDIATELY
)
568 || !AddObject(BG_WS_OBJECT_DOOR_H_3
, BG_OBJECT_DOOR_H_3_WS_ENTRY
, 949.9523f
, 1422.751f
, 344.9273f
, 0.0f
, 0, 0, 0, 1, RESPAWN_IMMEDIATELY
)
569 || !AddObject(BG_WS_OBJECT_DOOR_H_4
, BG_OBJECT_DOOR_H_4_WS_ENTRY
, 950.7952f
, 1459.583f
, 342.1523f
, 0.05235988f
, 0, 0, 0.02617695f
, 0.9996573f
, RESPAWN_IMMEDIATELY
)
572 sLog
.outErrorDb("BatteGroundWS: Failed to spawn some object BattleGround not created!");
576 WorldSafeLocsEntry
const *sg
= sWorldSafeLocsStore
.LookupEntry(WS_GRAVEYARD_MAIN_ALLIANCE
);
577 if(!sg
|| !AddSpiritGuide(WS_SPIRIT_MAIN_ALLIANCE
, sg
->x
, sg
->y
, sg
->z
, 3.124139f
, ALLIANCE
))
579 sLog
.outErrorDb("BatteGroundWS: Failed to spawn Alliance spirit guide! BattleGround not created!");
583 sg
= sWorldSafeLocsStore
.LookupEntry(WS_GRAVEYARD_MAIN_HORDE
);
584 if(!sg
|| !AddSpiritGuide(WS_SPIRIT_MAIN_HORDE
, sg
->x
, sg
->y
, sg
->z
, 3.193953f
, HORDE
))
586 sLog
.outErrorDb("BatteGroundWS: Failed to spawn Horde spirit guide! BattleGround not created!");
590 sLog
.outDebug("BatteGroundWS: BG objects and spirit guides spawned");
595 void BattleGroundWS::ResetBGSubclass()
597 m_FlagKeepers
[BG_TEAM_ALLIANCE
] = 0;
598 m_FlagKeepers
[BG_TEAM_HORDE
] = 0;
599 m_DroppedFlagGUID
[BG_TEAM_ALLIANCE
] = 0;
600 m_DroppedFlagGUID
[BG_TEAM_HORDE
] = 0;
601 m_FlagState
[BG_TEAM_ALLIANCE
] = BG_WS_FLAG_STATE_ON_BASE
;
602 m_FlagState
[BG_TEAM_HORDE
] = BG_WS_FLAG_STATE_ON_BASE
;
603 m_TeamScores
[BG_TEAM_ALLIANCE
] = 0;
604 m_TeamScores
[BG_TEAM_HORDE
] = 0;
606 /* Spirit nodes is static at this BG and then not required deleting at BG reset.
607 if(m_BgCreatures[WS_SPIRIT_MAIN_ALLIANCE])
608 DelCreature(WS_SPIRIT_MAIN_ALLIANCE);
610 if(m_BgCreatures[WS_SPIRIT_MAIN_HORDE])
611 DelCreature(WS_SPIRIT_MAIN_HORDE);
615 void BattleGroundWS::HandleKillPlayer(Player
*player
, Player
*killer
)
617 if(GetStatus() != STATUS_IN_PROGRESS
)
620 EventPlayerDroppedFlag(player
);
622 BattleGround::HandleKillPlayer(player
, killer
);
625 void BattleGroundWS::UpdatePlayerScore(Player
*Source
, uint32 type
, uint32 value
)
628 std::map
<uint64
, BattleGroundScore
*>::iterator itr
= m_PlayerScores
.find(Source
->GetGUID());
630 if(itr
== m_PlayerScores
.end()) // player not found
635 case SCORE_FLAG_CAPTURES
: // flags captured
636 ((BattleGroundWGScore
*)itr
->second
)->FlagCaptures
+= value
;
638 case SCORE_FLAG_RETURNS
: // flags returned
639 ((BattleGroundWGScore
*)itr
->second
)->FlagReturns
+= value
;
642 BattleGround::UpdatePlayerScore(Source
, type
, value
);
647 void BattleGroundWS::FillInitialWorldStates(WorldPacket
& data
)
649 data
<< uint32(BG_WS_FLAG_CAPTURES_ALLIANCE
) << uint32(GetTeamScore(ALLIANCE
));
650 data
<< uint32(BG_WS_FLAG_CAPTURES_HORDE
) << uint32(GetTeamScore(HORDE
));
652 if(m_FlagState
[BG_TEAM_ALLIANCE
] == BG_WS_FLAG_STATE_ON_GROUND
)
653 data
<< uint32(BG_WS_FLAG_UNK_ALLIANCE
) << uint32(-1);
654 else if (m_FlagState
[BG_TEAM_ALLIANCE
] == BG_WS_FLAG_STATE_ON_PLAYER
)
655 data
<< uint32(BG_WS_FLAG_UNK_ALLIANCE
) << uint32(1);
657 data
<< uint32(BG_WS_FLAG_UNK_ALLIANCE
) << uint32(0);
659 if(m_FlagState
[BG_TEAM_HORDE
] == BG_WS_FLAG_STATE_ON_GROUND
)
660 data
<< uint32(BG_WS_FLAG_UNK_HORDE
) << uint32(-1);
661 else if (m_FlagState
[BG_TEAM_HORDE
] == BG_WS_FLAG_STATE_ON_PLAYER
)
662 data
<< uint32(BG_WS_FLAG_UNK_HORDE
) << uint32(1);
664 data
<< uint32(BG_WS_FLAG_UNK_HORDE
) << uint32(0);
666 data
<< uint32(BG_WS_FLAG_CAPTURES_MAX
) << uint32(BG_WS_MAX_TEAM_SCORE
);
668 if (m_FlagState
[BG_TEAM_HORDE
] == BG_WS_FLAG_STATE_ON_PLAYER
)
669 data
<< uint32(BG_WS_FLAG_STATE_HORDE
) << uint32(2);
671 data
<< uint32(BG_WS_FLAG_STATE_HORDE
) << uint32(1);
673 if (m_FlagState
[BG_TEAM_ALLIANCE
] == BG_WS_FLAG_STATE_ON_PLAYER
)
674 data
<< uint32(BG_WS_FLAG_STATE_ALLIANCE
) << uint32(2);
676 data
<< uint32(BG_WS_FLAG_STATE_ALLIANCE
) << uint32(1);