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 // setup here, only when at least one player has ported to the map
53 if(!SetupBattleGround())
59 // for(uint32 i = WS_SPIRIT_MAIN_ALLIANCE; i <= WS_SPIRIT_MAIN_HORDE; i++)
60 // SpawnBGCreature(i, RESPAWN_IMMEDIATELY);
62 for(uint32 i
= BG_WS_OBJECT_DOOR_A_1
; i
<= BG_WS_OBJECT_DOOR_H_4
; i
++)
64 SpawnBGObject(i
, RESPAWN_IMMEDIATELY
);
67 for(uint32 i
= BG_WS_OBJECT_A_FLAG
; i
<= BG_WS_OBJECT_BERSERKBUFF_2
; i
++)
68 SpawnBGObject(i
, RESPAWN_ONE_DAY
);
70 SetStartDelayTime(START_DELAY0
);
72 // After 1 minute, warning is signalled
73 else if(GetStartDelayTime() <= START_DELAY1
&& !(m_Events
& 0x04))
76 SendMessageToAll(GetMangosString(LANG_BG_WS_ONE_MINUTE
));
78 // After 1,5 minute, warning is signalled
79 else if(GetStartDelayTime() <= START_DELAY2
&& !(m_Events
& 0x08))
82 SendMessageToAll(GetMangosString(LANG_BG_WS_HALF_MINUTE
));
84 // After 2 minutes, gates OPEN ! x)
85 else if(GetStartDelayTime() < 0 && !(m_Events
& 0x10))
88 for(uint32 i
= BG_WS_OBJECT_DOOR_A_1
; i
<= BG_WS_OBJECT_DOOR_A_4
; i
++)
90 for(uint32 i
= BG_WS_OBJECT_DOOR_H_1
; i
<= BG_WS_OBJECT_DOOR_H_2
; i
++)
93 SpawnBGObject(BG_WS_OBJECT_DOOR_A_5
, RESPAWN_ONE_DAY
);
94 SpawnBGObject(BG_WS_OBJECT_DOOR_A_6
, RESPAWN_ONE_DAY
);
95 SpawnBGObject(BG_WS_OBJECT_DOOR_H_3
, RESPAWN_ONE_DAY
);
96 SpawnBGObject(BG_WS_OBJECT_DOOR_H_4
, RESPAWN_ONE_DAY
);
98 for(uint32 i
= BG_WS_OBJECT_A_FLAG
; i
<= BG_WS_OBJECT_BERSERKBUFF_2
; i
++)
99 SpawnBGObject(i
, RESPAWN_IMMEDIATELY
);
101 SendMessageToAll(GetMangosString(LANG_BG_WS_BEGIN
));
103 PlaySoundToAll(SOUND_BG_START
);
104 SetStatus(STATUS_IN_PROGRESS
);
106 for(BattleGroundPlayerMap::const_iterator itr
= GetPlayers().begin(); itr
!= GetPlayers().end(); ++itr
)
107 if(Player
* plr
= objmgr
.GetPlayer(itr
->first
))
108 plr
->RemoveAurasDueToSpell(SPELL_PREPARATION
);
111 else if(GetStatus() == STATUS_IN_PROGRESS
)
113 if(m_FlagState
[BG_TEAM_ALLIANCE
] == BG_WS_FLAG_STATE_WAIT_RESPAWN
)
115 m_FlagsTimer
[BG_TEAM_ALLIANCE
] -= diff
;
117 if(m_FlagsTimer
[BG_TEAM_ALLIANCE
] < 0)
119 m_FlagsTimer
[BG_TEAM_ALLIANCE
] = 0;
120 RespawnFlag(ALLIANCE
, true);
123 if(m_FlagState
[BG_TEAM_ALLIANCE
] == BG_WS_FLAG_STATE_ON_GROUND
)
125 m_FlagsDropTimer
[BG_TEAM_ALLIANCE
] -= diff
;
127 if(m_FlagsDropTimer
[BG_TEAM_ALLIANCE
] < 0)
129 m_FlagsDropTimer
[BG_TEAM_ALLIANCE
] = 0;
130 RespawnFlagAfterDrop(ALLIANCE
);
133 if(m_FlagState
[BG_TEAM_HORDE
] == BG_WS_FLAG_STATE_WAIT_RESPAWN
)
135 m_FlagsTimer
[BG_TEAM_HORDE
] -= diff
;
137 if(m_FlagsTimer
[BG_TEAM_HORDE
] < 0)
139 m_FlagsTimer
[BG_TEAM_HORDE
] = 0;
140 RespawnFlag(HORDE
, true);
143 if(m_FlagState
[BG_TEAM_HORDE
] == BG_WS_FLAG_STATE_ON_GROUND
)
145 m_FlagsDropTimer
[BG_TEAM_HORDE
] -= diff
;
147 if(m_FlagsDropTimer
[BG_TEAM_HORDE
] < 0)
149 m_FlagsDropTimer
[BG_TEAM_HORDE
] = 0;
150 RespawnFlagAfterDrop(HORDE
);
156 void BattleGroundWS::AddPlayer(Player
*plr
)
158 BattleGround::AddPlayer(plr
);
159 //create score and add it to map, default values are set in constructor
160 BattleGroundWGScore
* sc
= new BattleGroundWGScore
;
162 m_PlayerScores
[plr
->GetGUID()] = sc
;
165 void BattleGroundWS::RespawnFlag(uint32 Team
, bool captured
)
169 sLog
.outDebug("Respawn Alliance flag");
170 m_FlagState
[BG_TEAM_ALLIANCE
] = BG_WS_FLAG_STATE_ON_BASE
;
174 sLog
.outDebug("Respawn Horde flag");
175 m_FlagState
[BG_TEAM_HORDE
] = BG_WS_FLAG_STATE_ON_BASE
;
180 //when map_update will be allowed for battlegrounds this code will be useless
181 SpawnBGObject(BG_WS_OBJECT_H_FLAG
, RESPAWN_IMMEDIATELY
);
182 SpawnBGObject(BG_WS_OBJECT_A_FLAG
, RESPAWN_IMMEDIATELY
);
183 SendMessageToAll(GetMangosString(LANG_BG_WS_F_PLACED
));
184 PlaySoundToAll(BG_WS_SOUND_FLAGS_RESPAWNED
); // flag respawned sound...
188 void BattleGroundWS::RespawnFlagAfterDrop(uint32 team
)
190 if(GetStatus() != STATUS_IN_PROGRESS
)
193 RespawnFlag(team
,false);
196 SpawnBGObject(BG_WS_OBJECT_A_FLAG
, RESPAWN_IMMEDIATELY
);
197 SendMessageToAll(GetMangosString(LANG_BG_WS_ALLIANCE_FLAG_RESPAWNED
));
201 SpawnBGObject(BG_WS_OBJECT_H_FLAG
, RESPAWN_IMMEDIATELY
);
202 SendMessageToAll(GetMangosString(LANG_BG_WS_HORDE_FLAG_RESPAWNED
));
205 PlaySoundToAll(BG_WS_SOUND_FLAGS_RESPAWNED
);
207 GameObject
*obj
= HashMapHolder
<GameObject
>::Find(GetDroppedFlagGUID(team
));
211 sLog
.outError("unknown droped flag bg, guid: %u",GUID_LOPART(GetDroppedFlagGUID(team
)));
213 SetDroppedFlagGUID(0,team
);
216 void BattleGroundWS::EventPlayerCapturedFlag(Player
*Source
)
218 if(GetStatus() != STATUS_IN_PROGRESS
)
223 const char *message
= "";
225 //TODO FIX reputation and honor gains for low level players!
227 Source
->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT
);
228 if(Source
->GetTeam() == ALLIANCE
)
230 if (!IsHordeFlagPickedup())
232 SetHordeFlagPicker(0); // must be before aura remove to prevent 2 events (drop+capture) at the same time
233 // horde flag in base (but not respawned yet)
234 m_FlagState
[BG_TEAM_HORDE
] = BG_WS_FLAG_STATE_WAIT_RESPAWN
;
235 // Drop Horde Flag from Player
236 Source
->RemoveAurasDueToSpell(BG_WS_SPELL_WARSONG_FLAG
);
237 message
= GetMangosString(LANG_BG_WS_CAPTURED_HF
);
238 type
= CHAT_MSG_BG_SYSTEM_ALLIANCE
;
239 if(GetTeamScore(ALLIANCE
) < BG_WS_MAX_TEAM_SCORE
)
240 AddPoint(ALLIANCE
, 1);
241 PlaySoundToAll(BG_WS_SOUND_FLAG_CAPTURED_ALLIANCE
);
242 RewardReputationToTeam(890, 35, ALLIANCE
); // +35 reputation
243 RewardHonorToTeam(40, ALLIANCE
); // +40 bonushonor
247 if (!IsAllianceFlagPickedup())
249 SetAllianceFlagPicker(0); // must be before aura remove to prevent 2 events (drop+capture) at the same time
250 // alliance flag in base (but not respawned yet)
251 m_FlagState
[BG_TEAM_ALLIANCE
] = BG_WS_FLAG_STATE_WAIT_RESPAWN
;
252 // Drop Alliance Flag from Player
253 Source
->RemoveAurasDueToSpell(BG_WS_SPELL_SILVERWING_FLAG
);
254 message
= GetMangosString(LANG_BG_WS_CAPTURED_AF
);
255 type
= CHAT_MSG_BG_SYSTEM_HORDE
;
256 if(GetTeamScore(HORDE
) < BG_WS_MAX_TEAM_SCORE
)
258 PlaySoundToAll(BG_WS_SOUND_FLAG_CAPTURED_HORDE
);
259 RewardReputationToTeam(889, 35, HORDE
); // +35 reputation
260 RewardHonorToTeam(40, HORDE
); // +40 bonushonor
263 SpawnBGObject(BG_WS_OBJECT_H_FLAG
, BG_WS_FLAG_RESPAWN_TIME
);
264 SpawnBGObject(BG_WS_OBJECT_A_FLAG
, BG_WS_FLAG_RESPAWN_TIME
);
267 ChatHandler::FillMessageData(&data
, Source
->GetSession(), type
, LANG_UNIVERSAL
, NULL
, Source
->GetGUID(), message
, NULL
);
268 SendPacketToAll(&data
);
270 UpdateFlagState(Source
->GetTeam(), 1); // flag state none
271 UpdateTeamScore(Source
->GetTeam());
272 // only flag capture should be updated
273 UpdatePlayerScore(Source
, SCORE_FLAG_CAPTURES
, 1); // +1 flag captures...
275 if(GetTeamScore(ALLIANCE
) == BG_WS_MAX_TEAM_SCORE
)
278 if(GetTeamScore(HORDE
) == BG_WS_MAX_TEAM_SCORE
)
283 UpdateWorldState(BG_WS_FLAG_UNK_ALLIANCE
, 0);
284 UpdateWorldState(BG_WS_FLAG_UNK_HORDE
, 0);
285 UpdateWorldState(BG_WS_FLAG_STATE_ALLIANCE
, 1);
286 UpdateWorldState(BG_WS_FLAG_STATE_HORDE
, 1);
288 EndBattleGround(winner
);
292 m_FlagsTimer
[GetTeamIndexByTeamId(Source
->GetTeam()) ? 0 : 1] = BG_WS_FLAG_RESPAWN_TIME
;
296 void BattleGroundWS::EventPlayerDroppedFlag(Player
*Source
)
298 if(GetStatus() != STATUS_IN_PROGRESS
)
300 // if not running, do not cast things at the dropper player (prevent spawning the "dropped" flag), neither send unnecessary messages
301 // just take off the aura
302 if(Source
->GetTeam() == ALLIANCE
)
304 if(!this->IsHordeFlagPickedup())
306 if(GetHordeFlagPickerGUID() == Source
->GetGUID())
308 SetHordeFlagPicker(0);
309 Source
->RemoveAurasDueToSpell(BG_WS_SPELL_WARSONG_FLAG
);
314 if(!this->IsAllianceFlagPickedup())
316 if(GetAllianceFlagPickerGUID() == Source
->GetGUID())
318 SetAllianceFlagPicker(0);
319 Source
->RemoveAurasDueToSpell(BG_WS_SPELL_SILVERWING_FLAG
);
325 const char *message
= "";
329 if(Source
->GetTeam() == ALLIANCE
)
331 if(!IsHordeFlagPickedup())
333 if(GetHordeFlagPickerGUID() == Source
->GetGUID())
335 SetHordeFlagPicker(0);
336 Source
->RemoveAurasDueToSpell(BG_WS_SPELL_WARSONG_FLAG
);
337 m_FlagState
[BG_TEAM_HORDE
] = BG_WS_FLAG_STATE_ON_GROUND
;
338 message
= GetMangosString(LANG_BG_WS_DROPPED_HF
);
339 type
= CHAT_MSG_BG_SYSTEM_HORDE
;
340 Source
->CastSpell(Source
, BG_WS_SPELL_WARSONG_FLAG_DROPPED
, true);
346 if(!IsAllianceFlagPickedup())
348 if(GetAllianceFlagPickerGUID() == Source
->GetGUID())
350 SetAllianceFlagPicker(0);
351 Source
->RemoveAurasDueToSpell(BG_WS_SPELL_SILVERWING_FLAG
);
352 m_FlagState
[BG_TEAM_ALLIANCE
] = BG_WS_FLAG_STATE_ON_GROUND
;
353 message
= GetMangosString(LANG_BG_WS_DROPPED_AF
);
354 type
= CHAT_MSG_BG_SYSTEM_ALLIANCE
;
355 Source
->CastSpell(Source
, BG_WS_SPELL_SILVERWING_FLAG_DROPPED
, true);
362 Source
->CastSpell(Source
, SPELL_RECENTLY_DROPPED_FLAG
, true);
363 UpdateFlagState(Source
->GetTeam(), 1);
366 ChatHandler::FillMessageData(&data
, Source
->GetSession(), type
, LANG_UNIVERSAL
, NULL
, Source
->GetGUID(), message
, NULL
);
367 SendPacketToAll(&data
);
369 if(Source
->GetTeam() == ALLIANCE
)
370 UpdateWorldState(BG_WS_FLAG_UNK_HORDE
, uint32(-1));
372 UpdateWorldState(BG_WS_FLAG_UNK_ALLIANCE
, uint32(-1));
374 m_FlagsDropTimer
[GetTeamIndexByTeamId(Source
->GetTeam()) ? 0 : 1] = BG_WS_FLAG_DROP_TIME
;
378 void BattleGroundWS::EventPlayerClickedOnFlag(Player
*Source
, GameObject
* target_obj
)
380 if(GetStatus() != STATUS_IN_PROGRESS
)
383 const char *message
= NULL
;
386 //alliance flag picked up from base
387 if(Source
->GetTeam() == HORDE
&& GetFlagState(ALLIANCE
) == BG_WS_FLAG_STATE_ON_BASE
388 && m_BgObjects
[BG_WS_OBJECT_A_FLAG
] == target_obj
->GetGUID())
390 message
= GetMangosString(LANG_BG_WS_PICKEDUP_AF
);
391 type
= CHAT_MSG_BG_SYSTEM_HORDE
;
392 PlaySoundToAll(BG_WS_SOUND_ALLIANCE_FLAG_PICKED_UP
);
393 SpawnBGObject(BG_WS_OBJECT_A_FLAG
, RESPAWN_ONE_DAY
);
394 SetAllianceFlagPicker(Source
->GetGUID());
395 m_FlagState
[BG_TEAM_ALLIANCE
] = BG_WS_FLAG_STATE_ON_PLAYER
;
396 //update world state to show correct flag carrier
397 UpdateFlagState(HORDE
, BG_WS_FLAG_STATE_ON_PLAYER
);
398 UpdateWorldState(BG_WS_FLAG_UNK_ALLIANCE
, 1);
399 Source
->CastSpell(Source
, BG_WS_SPELL_SILVERWING_FLAG
, true);
402 //horde flag picked up from base
403 if (Source
->GetTeam() == ALLIANCE
&& GetFlagState(HORDE
) == BG_WS_FLAG_STATE_ON_BASE
404 && m_BgObjects
[BG_WS_OBJECT_H_FLAG
] == target_obj
->GetGUID())
406 message
= GetMangosString(LANG_BG_WS_PICKEDUP_HF
);
407 type
= CHAT_MSG_BG_SYSTEM_ALLIANCE
;
408 PlaySoundToAll(BG_WS_SOUND_HORDE_FLAG_PICKED_UP
);
409 SpawnBGObject(BG_WS_OBJECT_H_FLAG
, RESPAWN_ONE_DAY
);
410 SetHordeFlagPicker(Source
->GetGUID());
411 m_FlagState
[BG_TEAM_HORDE
] = BG_WS_FLAG_STATE_ON_PLAYER
;
412 //update world state to show correct flag carrier
413 UpdateFlagState(ALLIANCE
, BG_WS_FLAG_STATE_ON_PLAYER
);
414 UpdateWorldState(BG_WS_FLAG_UNK_HORDE
, 1);
415 Source
->CastSpell(Source
, BG_WS_SPELL_WARSONG_FLAG
, true);
418 //Alliance flag on ground(not in base) (returned or picked up again from ground!)
419 if(GetFlagState(ALLIANCE
) == BG_WS_FLAG_STATE_ON_GROUND
&& Source
->IsWithinDistInMap(target_obj
, 10))
421 if(Source
->GetTeam() == ALLIANCE
)
423 message
= GetMangosString(LANG_BG_WS_RETURNED_AF
);
424 type
= CHAT_MSG_BG_SYSTEM_ALLIANCE
;
425 UpdateFlagState(HORDE
, BG_WS_FLAG_STATE_WAIT_RESPAWN
);
426 RespawnFlag(ALLIANCE
, false);
427 SpawnBGObject(BG_WS_OBJECT_A_FLAG
, RESPAWN_IMMEDIATELY
);
428 PlaySoundToAll(BG_WS_SOUND_FLAG_RETURNED
);
429 UpdatePlayerScore(Source
, SCORE_FLAG_RETURNS
, 1);
433 message
= GetMangosString(LANG_BG_WS_PICKEDUP_AF
);
434 type
= CHAT_MSG_BG_SYSTEM_HORDE
;
435 PlaySoundToAll(BG_WS_SOUND_ALLIANCE_FLAG_PICKED_UP
);
436 SpawnBGObject(BG_WS_OBJECT_A_FLAG
, RESPAWN_ONE_DAY
);
437 SetAllianceFlagPicker(Source
->GetGUID());
438 Source
->CastSpell(Source
, BG_WS_SPELL_SILVERWING_FLAG
, true);
439 m_FlagState
[BG_TEAM_ALLIANCE
] = BG_WS_FLAG_STATE_ON_PLAYER
;
440 UpdateFlagState(HORDE
, BG_WS_FLAG_STATE_ON_PLAYER
);
441 UpdateWorldState(BG_WS_FLAG_UNK_ALLIANCE
, 1);
443 //called in HandleGameObjectUseOpcode:
444 //target_obj->Delete();
447 //Horde flag on ground(not in base) (returned or picked up again)
448 if(GetFlagState(HORDE
) == BG_WS_FLAG_STATE_ON_GROUND
&& Source
->IsWithinDistInMap(target_obj
, 10))
450 if(Source
->GetTeam() == HORDE
)
452 message
= GetMangosString(LANG_BG_WS_RETURNED_HF
);
453 type
= CHAT_MSG_BG_SYSTEM_HORDE
;
454 UpdateFlagState(ALLIANCE
, BG_WS_FLAG_STATE_WAIT_RESPAWN
);
455 RespawnFlag(HORDE
, false);
456 SpawnBGObject(BG_WS_OBJECT_H_FLAG
, RESPAWN_IMMEDIATELY
);
457 PlaySoundToAll(BG_WS_SOUND_FLAG_RETURNED
);
458 UpdatePlayerScore(Source
, SCORE_FLAG_RETURNS
, 1);
462 message
= GetMangosString(LANG_BG_WS_PICKEDUP_HF
);
463 type
= CHAT_MSG_BG_SYSTEM_ALLIANCE
;
464 PlaySoundToAll(BG_WS_SOUND_HORDE_FLAG_PICKED_UP
);
465 SpawnBGObject(BG_WS_OBJECT_H_FLAG
, RESPAWN_ONE_DAY
);
466 SetHordeFlagPicker(Source
->GetGUID());
467 Source
->CastSpell(Source
, BG_WS_SPELL_WARSONG_FLAG
, true);
468 m_FlagState
[BG_TEAM_HORDE
] = BG_WS_FLAG_STATE_ON_PLAYER
;
469 UpdateFlagState(ALLIANCE
, BG_WS_FLAG_STATE_ON_PLAYER
);
470 UpdateWorldState(BG_WS_FLAG_UNK_HORDE
, 1);
472 //called in HandleGameObjectUseOpcode:
473 //target_obj->Delete();
480 ChatHandler::FillMessageData(&data
, Source
->GetSession(), type
, LANG_UNIVERSAL
, NULL
, Source
->GetGUID(), message
, NULL
);
481 SendPacketToAll(&data
);
482 Source
->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT
);
485 void BattleGroundWS::RemovePlayer(Player
*plr
, uint64 guid
)
487 // sometimes flag aura not removed :(
488 if(IsAllianceFlagPickedup() && m_FlagKeepers
[BG_TEAM_ALLIANCE
] == guid
)
492 sLog
.outError("BattleGroundWS: Removing offline player who has the FLAG!!");
493 SetAllianceFlagPicker(0);
494 RespawnFlag(ALLIANCE
, false);
497 EventPlayerDroppedFlag(plr
);
499 if(IsHordeFlagPickedup() && m_FlagKeepers
[BG_TEAM_HORDE
] == guid
)
503 sLog
.outError("BattleGroundWS: Removing offline player who has the FLAG!!");
504 SetHordeFlagPicker(0);
505 RespawnFlag(HORDE
, false);
508 EventPlayerDroppedFlag(plr
);
512 void BattleGroundWS::UpdateFlagState(uint32 team
, uint32 value
)
515 UpdateWorldState(BG_WS_FLAG_STATE_ALLIANCE
, value
);
517 UpdateWorldState(BG_WS_FLAG_STATE_HORDE
, value
);
520 void BattleGroundWS::UpdateTeamScore(uint32 team
)
523 UpdateWorldState(BG_WS_FLAG_CAPTURES_ALLIANCE
, GetTeamScore(team
));
525 UpdateWorldState(BG_WS_FLAG_CAPTURES_HORDE
, GetTeamScore(team
));
528 void BattleGroundWS::HandleAreaTrigger(Player
*Source
, uint32 Trigger
)
530 // this is wrong way to implement these things. On official it done by gameobject spell cast.
531 if(GetStatus() != STATUS_IN_PROGRESS
)
534 //uint32 SpellId = 0;
535 //uint64 buff_guid = 0;
538 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().
539 //buff_guid = m_BgObjects[BG_WS_OBJECT_SPEEDBUFF_1];
541 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().
542 //buff_guid = m_BgObjects[BG_WS_OBJECT_SPEEDBUFF_2];
544 case 3706: // Alliance elixir of regeneration spawn
545 //buff_guid = m_BgObjects[BG_WS_OBJECT_REGENBUFF_1];
547 case 3708: // Horde elixir of regeneration spawn
548 //buff_guid = m_BgObjects[BG_WS_OBJECT_REGENBUFF_2];
550 case 3707: // Alliance elixir of berserk spawn
551 //buff_guid = m_BgObjects[BG_WS_OBJECT_BERSERKBUFF_1];
553 case 3709: // Horde elixir of berserk spawn
554 //buff_guid = m_BgObjects[BG_WS_OBJECT_BERSERKBUFF_2];
556 case 3646: // Alliance Flag spawn
557 if(m_FlagState
[BG_TEAM_HORDE
] && !m_FlagState
[BG_TEAM_ALLIANCE
])
558 if(GetHordeFlagPickerGUID() == Source
->GetGUID())
559 EventPlayerCapturedFlag(Source
);
561 case 3647: // Horde Flag spawn
562 if(m_FlagState
[BG_TEAM_ALLIANCE
] && !m_FlagState
[BG_TEAM_HORDE
])
563 if(GetAllianceFlagPickerGUID() == Source
->GetGUID())
564 EventPlayerCapturedFlag(Source
);
572 sLog
.outError("WARNING: Unhandled AreaTrigger in Battleground: %u", Trigger
);
573 Source
->GetSession()->SendAreaTriggerMessage("Warning: Unhandled AreaTrigger in Battleground: %u", Trigger
);
578 // HandleTriggerBuff(buff_guid,Source);
581 bool BattleGroundWS::SetupBattleGround()
584 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)
585 || !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)
587 || !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
)
588 || !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
)
589 || !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
)
590 || !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
)
591 || !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
)
592 || !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
)
594 || !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
)
595 || !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
)
596 || !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
)
597 || !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
)
598 || !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
)
599 || !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
)
601 || !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
)
602 || !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
)
603 || !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
)
604 || !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
)
607 sLog
.outErrorDb("BatteGroundWS: Failed to spawn some object BattleGround not created!");
611 WorldSafeLocsEntry
const *sg
= sWorldSafeLocsStore
.LookupEntry(WS_GRAVEYARD_MAIN_ALLIANCE
);
612 if(!sg
|| !AddSpiritGuide(WS_SPIRIT_MAIN_ALLIANCE
, sg
->x
, sg
->y
, sg
->z
, 3.124139f
, ALLIANCE
))
614 sLog
.outErrorDb("BatteGroundWS: Failed to spawn Alliance spirit guide! BattleGround not created!");
618 sg
= sWorldSafeLocsStore
.LookupEntry(WS_GRAVEYARD_MAIN_HORDE
);
619 if(!sg
|| !AddSpiritGuide(WS_SPIRIT_MAIN_HORDE
, sg
->x
, sg
->y
, sg
->z
, 3.193953f
, HORDE
))
621 sLog
.outErrorDb("BatteGroundWS: Failed to spawn Horde spirit guide! BattleGround not created!");
625 sLog
.outDebug("BatteGroundWS: BG objects and spirit guides spawned");
630 void BattleGroundWS::ResetBGSubclass()
632 m_FlagKeepers
[BG_TEAM_ALLIANCE
] = 0;
633 m_FlagKeepers
[BG_TEAM_HORDE
] = 0;
634 m_DroppedFlagGUID
[BG_TEAM_ALLIANCE
] = 0;
635 m_DroppedFlagGUID
[BG_TEAM_HORDE
] = 0;
636 m_FlagState
[BG_TEAM_ALLIANCE
] = BG_WS_FLAG_STATE_ON_BASE
;
637 m_FlagState
[BG_TEAM_HORDE
] = BG_WS_FLAG_STATE_ON_BASE
;
638 m_TeamScores
[BG_TEAM_ALLIANCE
] = 0;
639 m_TeamScores
[BG_TEAM_HORDE
] = 0;
641 /* Spirit nodes is static at this BG and then not required deleting at BG reset.
642 if(m_BgCreatures[WS_SPIRIT_MAIN_ALLIANCE])
643 DelCreature(WS_SPIRIT_MAIN_ALLIANCE);
645 if(m_BgCreatures[WS_SPIRIT_MAIN_HORDE])
646 DelCreature(WS_SPIRIT_MAIN_HORDE);
650 void BattleGroundWS::HandleKillPlayer(Player
*player
, Player
*killer
)
652 if(GetStatus() != STATUS_IN_PROGRESS
)
655 EventPlayerDroppedFlag(player
);
657 BattleGround::HandleKillPlayer(player
, killer
);
660 void BattleGroundWS::UpdatePlayerScore(Player
*Source
, uint32 type
, uint32 value
)
663 std::map
<uint64
, BattleGroundScore
*>::iterator itr
= m_PlayerScores
.find(Source
->GetGUID());
665 if(itr
== m_PlayerScores
.end()) // player not found
670 case SCORE_FLAG_CAPTURES
: // flags captured
671 ((BattleGroundWGScore
*)itr
->second
)->FlagCaptures
+= value
;
673 case SCORE_FLAG_RETURNS
: // flags returned
674 ((BattleGroundWGScore
*)itr
->second
)->FlagReturns
+= value
;
677 BattleGround::UpdatePlayerScore(Source
, type
, value
);
682 void BattleGroundWS::FillInitialWorldStates(WorldPacket
& data
)
684 data
<< uint32(BG_WS_FLAG_CAPTURES_ALLIANCE
) << uint32(GetTeamScore(ALLIANCE
));
685 data
<< uint32(BG_WS_FLAG_CAPTURES_HORDE
) << uint32(GetTeamScore(HORDE
));
687 if(m_FlagState
[BG_TEAM_ALLIANCE
] == BG_WS_FLAG_STATE_ON_GROUND
)
688 data
<< uint32(BG_WS_FLAG_UNK_ALLIANCE
) << uint32(-1);
689 else if (m_FlagState
[BG_TEAM_ALLIANCE
] == BG_WS_FLAG_STATE_ON_PLAYER
)
690 data
<< uint32(BG_WS_FLAG_UNK_ALLIANCE
) << uint32(1);
692 data
<< uint32(BG_WS_FLAG_UNK_ALLIANCE
) << uint32(0);
694 if(m_FlagState
[BG_TEAM_HORDE
] == BG_WS_FLAG_STATE_ON_GROUND
)
695 data
<< uint32(BG_WS_FLAG_UNK_HORDE
) << uint32(-1);
696 else if (m_FlagState
[BG_TEAM_HORDE
] == BG_WS_FLAG_STATE_ON_PLAYER
)
697 data
<< uint32(BG_WS_FLAG_UNK_HORDE
) << uint32(1);
699 data
<< uint32(BG_WS_FLAG_UNK_HORDE
) << uint32(0);
701 data
<< uint32(BG_WS_FLAG_CAPTURES_MAX
) << uint32(BG_WS_MAX_TEAM_SCORE
);
703 if (m_FlagState
[BG_TEAM_HORDE
] == BG_WS_FLAG_STATE_ON_PLAYER
)
704 data
<< uint32(BG_WS_FLAG_STATE_HORDE
) << uint32(2);
706 data
<< uint32(BG_WS_FLAG_STATE_HORDE
) << uint32(1);
708 if (m_FlagState
[BG_TEAM_ALLIANCE
] == BG_WS_FLAG_STATE_ON_PLAYER
)
709 data
<< uint32(BG_WS_FLAG_STATE_ALLIANCE
) << uint32(2);
711 data
<< uint32(BG_WS_FLAG_STATE_ALLIANCE
) << uint32(1);