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 "BattleGroundWS.h"
24 #include "GameObject.h"
26 #include "MapManager.h"
27 #include "ObjectMgr.h"
28 #include "WorldPacket.h"
31 BattleGroundWS::BattleGroundWS()
33 m_BgObjects
.resize(BG_WS_OBJECT_MAX
);
34 m_BgCreatures
.resize(BG_CREATURES_MAX_WS
);
37 BattleGroundWS::~BattleGroundWS()
41 void BattleGroundWS::Update(uint32 diff
)
43 BattleGround::Update(diff
);
45 // after bg start we get there (once)
46 if (GetStatus() == STATUS_WAIT_JOIN
&& GetPlayersSize())
48 ModifyStartDelayTime(diff
);
50 if(!(m_Events
& 0x01))
54 // setup here, only when at least one player has ported to the map
55 if(!SetupBattleGround())
61 // for(uint32 i = WS_SPIRIT_MAIN_ALLIANCE; i <= WS_SPIRIT_MAIN_HORDE; i++)
62 // SpawnBGCreature(i, RESPAWN_IMMEDIATELY);
64 for(uint32 i
= BG_WS_OBJECT_DOOR_A_1
; i
<= BG_WS_OBJECT_DOOR_H_4
; i
++)
66 SpawnBGObject(i
, RESPAWN_IMMEDIATELY
);
69 for(uint32 i
= BG_WS_OBJECT_A_FLAG
; i
<= BG_WS_OBJECT_BERSERKBUFF_2
; i
++)
70 SpawnBGObject(i
, RESPAWN_ONE_DAY
);
72 SetStartDelayTime(START_DELAY0
);
74 // After 1 minute, warning is signalled
75 else if(GetStartDelayTime() <= START_DELAY1
&& !(m_Events
& 0x04))
78 SendMessageToAll(GetMangosString(LANG_BG_WS_ONE_MINUTE
));
80 // After 1,5 minute, warning is signalled
81 else if(GetStartDelayTime() <= START_DELAY2
&& !(m_Events
& 0x08))
84 SendMessageToAll(GetMangosString(LANG_BG_WS_HALF_MINUTE
));
86 // After 2 minutes, gates OPEN ! x)
87 else if(GetStartDelayTime() < 0 && !(m_Events
& 0x10))
90 for(uint32 i
= BG_WS_OBJECT_DOOR_A_1
; i
<= BG_WS_OBJECT_DOOR_A_4
; i
++)
92 for(uint32 i
= BG_WS_OBJECT_DOOR_H_1
; i
<= BG_WS_OBJECT_DOOR_H_2
; i
++)
95 SpawnBGObject(BG_WS_OBJECT_DOOR_A_5
, RESPAWN_ONE_DAY
);
96 SpawnBGObject(BG_WS_OBJECT_DOOR_A_6
, RESPAWN_ONE_DAY
);
97 SpawnBGObject(BG_WS_OBJECT_DOOR_H_3
, RESPAWN_ONE_DAY
);
98 SpawnBGObject(BG_WS_OBJECT_DOOR_H_4
, RESPAWN_ONE_DAY
);
100 for(uint32 i
= BG_WS_OBJECT_A_FLAG
; i
<= BG_WS_OBJECT_BERSERKBUFF_2
; i
++)
101 SpawnBGObject(i
, RESPAWN_IMMEDIATELY
);
103 SendMessageToAll(GetMangosString(LANG_BG_WS_BEGIN
));
105 PlaySoundToAll(SOUND_BG_START
);
106 SetStatus(STATUS_IN_PROGRESS
);
108 for(BattleGroundPlayerMap::const_iterator itr
= GetPlayers().begin(); itr
!= GetPlayers().end(); ++itr
)
109 if(Player
* plr
= objmgr
.GetPlayer(itr
->first
))
110 plr
->RemoveAurasDueToSpell(SPELL_PREPARATION
);
113 else if(GetStatus() == STATUS_IN_PROGRESS
)
115 if(m_FlagState
[BG_TEAM_ALLIANCE
] == BG_WS_FLAG_STATE_WAIT_RESPAWN
)
117 m_FlagsTimer
[BG_TEAM_ALLIANCE
] -= diff
;
119 if(m_FlagsTimer
[BG_TEAM_ALLIANCE
] < 0)
121 m_FlagsTimer
[BG_TEAM_ALLIANCE
] = 0;
122 RespawnFlag(ALLIANCE
, true);
125 if(m_FlagState
[BG_TEAM_ALLIANCE
] == BG_WS_FLAG_STATE_ON_GROUND
)
127 m_FlagsDropTimer
[BG_TEAM_ALLIANCE
] -= diff
;
129 if(m_FlagsDropTimer
[BG_TEAM_ALLIANCE
] < 0)
131 m_FlagsDropTimer
[BG_TEAM_ALLIANCE
] = 0;
132 RespawnFlagAfterDrop(ALLIANCE
);
135 if(m_FlagState
[BG_TEAM_HORDE
] == BG_WS_FLAG_STATE_WAIT_RESPAWN
)
137 m_FlagsTimer
[BG_TEAM_HORDE
] -= diff
;
139 if(m_FlagsTimer
[BG_TEAM_HORDE
] < 0)
141 m_FlagsTimer
[BG_TEAM_HORDE
] = 0;
142 RespawnFlag(HORDE
, true);
145 if(m_FlagState
[BG_TEAM_HORDE
] == BG_WS_FLAG_STATE_ON_GROUND
)
147 m_FlagsDropTimer
[BG_TEAM_HORDE
] -= diff
;
149 if(m_FlagsDropTimer
[BG_TEAM_HORDE
] < 0)
151 m_FlagsDropTimer
[BG_TEAM_HORDE
] = 0;
152 RespawnFlagAfterDrop(HORDE
);
158 void BattleGroundWS::AddPlayer(Player
*plr
)
160 BattleGround::AddPlayer(plr
);
161 //create score and add it to map, default values are set in constructor
162 BattleGroundWGScore
* sc
= new BattleGroundWGScore
;
164 m_PlayerScores
[plr
->GetGUID()] = sc
;
167 void BattleGroundWS::RespawnFlag(uint32 Team
, bool captured
)
171 sLog
.outDebug("Respawn Alliance flag");
172 m_FlagState
[BG_TEAM_ALLIANCE
] = BG_WS_FLAG_STATE_ON_BASE
;
176 sLog
.outDebug("Respawn Horde flag");
177 m_FlagState
[BG_TEAM_HORDE
] = BG_WS_FLAG_STATE_ON_BASE
;
182 //when map_update will be allowed for battlegrounds this code will be useless
183 SpawnBGObject(BG_WS_OBJECT_H_FLAG
, RESPAWN_IMMEDIATELY
);
184 SpawnBGObject(BG_WS_OBJECT_A_FLAG
, RESPAWN_IMMEDIATELY
);
185 SendMessageToAll(GetMangosString(LANG_BG_WS_F_PLACED
));
186 PlaySoundToAll(BG_WS_SOUND_FLAGS_RESPAWNED
); // flag respawned sound...
190 void BattleGroundWS::RespawnFlagAfterDrop(uint32 team
)
192 if(GetStatus() != STATUS_IN_PROGRESS
)
195 RespawnFlag(team
,false);
198 SpawnBGObject(BG_WS_OBJECT_A_FLAG
, RESPAWN_IMMEDIATELY
);
199 SendMessageToAll(GetMangosString(LANG_BG_WS_ALLIANCE_FLAG_RESPAWNED
));
203 SpawnBGObject(BG_WS_OBJECT_H_FLAG
, RESPAWN_IMMEDIATELY
);
204 SendMessageToAll(GetMangosString(LANG_BG_WS_HORDE_FLAG_RESPAWNED
));
207 PlaySoundToAll(BG_WS_SOUND_FLAGS_RESPAWNED
);
209 GameObject
*obj
= HashMapHolder
<GameObject
>::Find(GetDroppedFlagGUID(team
));
213 sLog
.outError("unknown droped flag bg, guid: %u",GUID_LOPART(GetDroppedFlagGUID(team
)));
215 SetDroppedFlagGUID(0,team
);
218 void BattleGroundWS::EventPlayerCapturedFlag(Player
*Source
)
220 if(GetStatus() != STATUS_IN_PROGRESS
)
225 const char *message
= "";
227 //TODO FIX reputation and honor gains for low level players!
229 Source
->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT
);
230 if(Source
->GetTeam() == ALLIANCE
)
232 if (!IsHordeFlagPickedup())
234 SetHordeFlagPicker(0); // must be before aura remove to prevent 2 events (drop+capture) at the same time
235 // horde flag in base (but not respawned yet)
236 m_FlagState
[BG_TEAM_HORDE
] = BG_WS_FLAG_STATE_WAIT_RESPAWN
;
237 // Drop Horde Flag from Player
238 Source
->RemoveAurasDueToSpell(BG_WS_SPELL_WARSONG_FLAG
);
239 message
= GetMangosString(LANG_BG_WS_CAPTURED_HF
);
240 type
= CHAT_MSG_BG_SYSTEM_ALLIANCE
;
241 if(GetTeamScore(ALLIANCE
) < BG_WS_MAX_TEAM_SCORE
)
242 AddPoint(ALLIANCE
, 1);
243 PlaySoundToAll(BG_WS_SOUND_FLAG_CAPTURED_ALLIANCE
);
244 RewardReputationToTeam(890, 35, ALLIANCE
); // +35 reputation
245 RewardHonorToTeam(40, ALLIANCE
); // +40 bonushonor
249 if (!IsAllianceFlagPickedup())
251 SetAllianceFlagPicker(0); // must be before aura remove to prevent 2 events (drop+capture) at the same time
252 // alliance flag in base (but not respawned yet)
253 m_FlagState
[BG_TEAM_ALLIANCE
] = BG_WS_FLAG_STATE_WAIT_RESPAWN
;
254 // Drop Alliance Flag from Player
255 Source
->RemoveAurasDueToSpell(BG_WS_SPELL_SILVERWING_FLAG
);
256 message
= GetMangosString(LANG_BG_WS_CAPTURED_AF
);
257 type
= CHAT_MSG_BG_SYSTEM_HORDE
;
258 if(GetTeamScore(HORDE
) < BG_WS_MAX_TEAM_SCORE
)
260 PlaySoundToAll(BG_WS_SOUND_FLAG_CAPTURED_HORDE
);
261 RewardReputationToTeam(889, 35, HORDE
); // +35 reputation
262 RewardHonorToTeam(40, HORDE
); // +40 bonushonor
265 SpawnBGObject(BG_WS_OBJECT_H_FLAG
, BG_WS_FLAG_RESPAWN_TIME
);
266 SpawnBGObject(BG_WS_OBJECT_A_FLAG
, BG_WS_FLAG_RESPAWN_TIME
);
269 ChatHandler::FillMessageData(&data
, Source
->GetSession(), type
, LANG_UNIVERSAL
, NULL
, Source
->GetGUID(), message
, NULL
);
270 SendPacketToAll(&data
);
272 UpdateFlagState(Source
->GetTeam(), 1); // flag state none
273 UpdateTeamScore(Source
->GetTeam());
274 // only flag capture should be updated
275 UpdatePlayerScore(Source
, SCORE_FLAG_CAPTURES
, 1); // +1 flag captures...
277 if(GetTeamScore(ALLIANCE
) == BG_WS_MAX_TEAM_SCORE
)
280 if(GetTeamScore(HORDE
) == BG_WS_MAX_TEAM_SCORE
)
285 UpdateWorldState(BG_WS_FLAG_UNK_ALLIANCE
, 0);
286 UpdateWorldState(BG_WS_FLAG_UNK_HORDE
, 0);
287 UpdateWorldState(BG_WS_FLAG_STATE_ALLIANCE
, 1);
288 UpdateWorldState(BG_WS_FLAG_STATE_HORDE
, 1);
290 EndBattleGround(winner
);
294 m_FlagsTimer
[GetTeamIndexByTeamId(Source
->GetTeam()) ? 0 : 1] = BG_WS_FLAG_RESPAWN_TIME
;
298 void BattleGroundWS::EventPlayerDroppedFlag(Player
*Source
)
300 if(GetStatus() != STATUS_IN_PROGRESS
)
302 // if not running, do not cast things at the dropper player (prevent spawning the "dropped" flag), neither send unnecessary messages
303 // just take off the aura
304 if(Source
->GetTeam() == ALLIANCE
)
306 if(!this->IsHordeFlagPickedup())
308 if(GetHordeFlagPickerGUID() == Source
->GetGUID())
310 SetHordeFlagPicker(0);
311 Source
->RemoveAurasDueToSpell(BG_WS_SPELL_WARSONG_FLAG
);
316 if(!this->IsAllianceFlagPickedup())
318 if(GetAllianceFlagPickerGUID() == Source
->GetGUID())
320 SetAllianceFlagPicker(0);
321 Source
->RemoveAurasDueToSpell(BG_WS_SPELL_SILVERWING_FLAG
);
327 const char *message
= "";
331 if(Source
->GetTeam() == ALLIANCE
)
333 if(!IsHordeFlagPickedup())
335 if(GetHordeFlagPickerGUID() == Source
->GetGUID())
337 SetHordeFlagPicker(0);
338 Source
->RemoveAurasDueToSpell(BG_WS_SPELL_WARSONG_FLAG
);
339 m_FlagState
[BG_TEAM_HORDE
] = BG_WS_FLAG_STATE_ON_GROUND
;
340 message
= GetMangosString(LANG_BG_WS_DROPPED_HF
);
341 type
= CHAT_MSG_BG_SYSTEM_HORDE
;
342 Source
->CastSpell(Source
, BG_WS_SPELL_WARSONG_FLAG_DROPPED
, true);
348 if(!IsAllianceFlagPickedup())
350 if(GetAllianceFlagPickerGUID() == Source
->GetGUID())
352 SetAllianceFlagPicker(0);
353 Source
->RemoveAurasDueToSpell(BG_WS_SPELL_SILVERWING_FLAG
);
354 m_FlagState
[BG_TEAM_ALLIANCE
] = BG_WS_FLAG_STATE_ON_GROUND
;
355 message
= GetMangosString(LANG_BG_WS_DROPPED_AF
);
356 type
= CHAT_MSG_BG_SYSTEM_ALLIANCE
;
357 Source
->CastSpell(Source
, BG_WS_SPELL_SILVERWING_FLAG_DROPPED
, true);
364 Source
->CastSpell(Source
, SPELL_RECENTLY_DROPPED_FLAG
, true);
365 UpdateFlagState(Source
->GetTeam(), 1);
368 ChatHandler::FillMessageData(&data
, Source
->GetSession(), type
, LANG_UNIVERSAL
, NULL
, Source
->GetGUID(), message
, NULL
);
369 SendPacketToAll(&data
);
371 if(Source
->GetTeam() == ALLIANCE
)
372 UpdateWorldState(BG_WS_FLAG_UNK_HORDE
, uint32(-1));
374 UpdateWorldState(BG_WS_FLAG_UNK_ALLIANCE
, uint32(-1));
376 m_FlagsDropTimer
[GetTeamIndexByTeamId(Source
->GetTeam()) ? 0 : 1] = BG_WS_FLAG_DROP_TIME
;
380 void BattleGroundWS::EventPlayerClickedOnFlag(Player
*Source
, GameObject
* target_obj
)
382 if(GetStatus() != STATUS_IN_PROGRESS
)
385 const char *message
= NULL
;
388 //alliance flag picked up from base
389 if(Source
->GetTeam() == HORDE
&& GetFlagState(ALLIANCE
) == BG_WS_FLAG_STATE_ON_BASE
390 && m_BgObjects
[BG_WS_OBJECT_A_FLAG
] == target_obj
->GetGUID())
392 message
= GetMangosString(LANG_BG_WS_PICKEDUP_AF
);
393 type
= CHAT_MSG_BG_SYSTEM_HORDE
;
394 PlaySoundToAll(BG_WS_SOUND_ALLIANCE_FLAG_PICKED_UP
);
395 SpawnBGObject(BG_WS_OBJECT_A_FLAG
, RESPAWN_ONE_DAY
);
396 SetAllianceFlagPicker(Source
->GetGUID());
397 m_FlagState
[BG_TEAM_ALLIANCE
] = BG_WS_FLAG_STATE_ON_PLAYER
;
398 //update world state to show correct flag carrier
399 UpdateFlagState(HORDE
, BG_WS_FLAG_STATE_ON_PLAYER
);
400 UpdateWorldState(BG_WS_FLAG_UNK_ALLIANCE
, 1);
401 Source
->CastSpell(Source
, BG_WS_SPELL_SILVERWING_FLAG
, true);
404 //horde flag picked up from base
405 if (Source
->GetTeam() == ALLIANCE
&& GetFlagState(HORDE
) == BG_WS_FLAG_STATE_ON_BASE
406 && m_BgObjects
[BG_WS_OBJECT_H_FLAG
] == target_obj
->GetGUID())
408 message
= GetMangosString(LANG_BG_WS_PICKEDUP_HF
);
409 type
= CHAT_MSG_BG_SYSTEM_ALLIANCE
;
410 PlaySoundToAll(BG_WS_SOUND_HORDE_FLAG_PICKED_UP
);
411 SpawnBGObject(BG_WS_OBJECT_H_FLAG
, RESPAWN_ONE_DAY
);
412 SetHordeFlagPicker(Source
->GetGUID());
413 m_FlagState
[BG_TEAM_HORDE
] = BG_WS_FLAG_STATE_ON_PLAYER
;
414 //update world state to show correct flag carrier
415 UpdateFlagState(ALLIANCE
, BG_WS_FLAG_STATE_ON_PLAYER
);
416 UpdateWorldState(BG_WS_FLAG_UNK_HORDE
, 1);
417 Source
->CastSpell(Source
, BG_WS_SPELL_WARSONG_FLAG
, true);
420 //Alliance flag on ground(not in base) (returned or picked up again from ground!)
421 if(GetFlagState(ALLIANCE
) == BG_WS_FLAG_STATE_ON_GROUND
&& Source
->IsWithinDistInMap(target_obj
, 10))
423 if(Source
->GetTeam() == ALLIANCE
)
425 message
= GetMangosString(LANG_BG_WS_RETURNED_AF
);
426 type
= CHAT_MSG_BG_SYSTEM_ALLIANCE
;
427 UpdateFlagState(HORDE
, BG_WS_FLAG_STATE_WAIT_RESPAWN
);
428 RespawnFlag(ALLIANCE
, false);
429 SpawnBGObject(BG_WS_OBJECT_A_FLAG
, RESPAWN_IMMEDIATELY
);
430 PlaySoundToAll(BG_WS_SOUND_FLAG_RETURNED
);
431 UpdatePlayerScore(Source
, SCORE_FLAG_RETURNS
, 1);
435 message
= GetMangosString(LANG_BG_WS_PICKEDUP_AF
);
436 type
= CHAT_MSG_BG_SYSTEM_HORDE
;
437 PlaySoundToAll(BG_WS_SOUND_ALLIANCE_FLAG_PICKED_UP
);
438 SpawnBGObject(BG_WS_OBJECT_A_FLAG
, RESPAWN_ONE_DAY
);
439 SetAllianceFlagPicker(Source
->GetGUID());
440 Source
->CastSpell(Source
, BG_WS_SPELL_SILVERWING_FLAG
, true);
441 m_FlagState
[BG_TEAM_ALLIANCE
] = BG_WS_FLAG_STATE_ON_PLAYER
;
442 UpdateFlagState(HORDE
, BG_WS_FLAG_STATE_ON_PLAYER
);
443 UpdateWorldState(BG_WS_FLAG_UNK_ALLIANCE
, 1);
445 //called in HandleGameObjectUseOpcode:
446 //target_obj->Delete();
449 //Horde flag on ground(not in base) (returned or picked up again)
450 if(GetFlagState(HORDE
) == BG_WS_FLAG_STATE_ON_GROUND
&& Source
->IsWithinDistInMap(target_obj
, 10))
452 if(Source
->GetTeam() == HORDE
)
454 message
= GetMangosString(LANG_BG_WS_RETURNED_HF
);
455 type
= CHAT_MSG_BG_SYSTEM_HORDE
;
456 UpdateFlagState(ALLIANCE
, BG_WS_FLAG_STATE_WAIT_RESPAWN
);
457 RespawnFlag(HORDE
, false);
458 SpawnBGObject(BG_WS_OBJECT_H_FLAG
, RESPAWN_IMMEDIATELY
);
459 PlaySoundToAll(BG_WS_SOUND_FLAG_RETURNED
);
460 UpdatePlayerScore(Source
, SCORE_FLAG_RETURNS
, 1);
464 message
= GetMangosString(LANG_BG_WS_PICKEDUP_HF
);
465 type
= CHAT_MSG_BG_SYSTEM_ALLIANCE
;
466 PlaySoundToAll(BG_WS_SOUND_HORDE_FLAG_PICKED_UP
);
467 SpawnBGObject(BG_WS_OBJECT_H_FLAG
, RESPAWN_ONE_DAY
);
468 SetHordeFlagPicker(Source
->GetGUID());
469 Source
->CastSpell(Source
, BG_WS_SPELL_WARSONG_FLAG
, true);
470 m_FlagState
[BG_TEAM_HORDE
] = BG_WS_FLAG_STATE_ON_PLAYER
;
471 UpdateFlagState(ALLIANCE
, BG_WS_FLAG_STATE_ON_PLAYER
);
472 UpdateWorldState(BG_WS_FLAG_UNK_HORDE
, 1);
474 //called in HandleGameObjectUseOpcode:
475 //target_obj->Delete();
482 ChatHandler::FillMessageData(&data
, Source
->GetSession(), type
, LANG_UNIVERSAL
, NULL
, Source
->GetGUID(), message
, NULL
);
483 SendPacketToAll(&data
);
484 Source
->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT
);
487 void BattleGroundWS::RemovePlayer(Player
*plr
, uint64 guid
)
489 // sometimes flag aura not removed :(
490 if(IsAllianceFlagPickedup() && m_FlagKeepers
[BG_TEAM_ALLIANCE
] == guid
)
494 sLog
.outError("BattleGroundWS: Removing offline player who has the FLAG!!");
495 SetAllianceFlagPicker(0);
496 RespawnFlag(ALLIANCE
, false);
499 EventPlayerDroppedFlag(plr
);
501 if(IsHordeFlagPickedup() && m_FlagKeepers
[BG_TEAM_HORDE
] == guid
)
505 sLog
.outError("BattleGroundWS: Removing offline player who has the FLAG!!");
506 SetHordeFlagPicker(0);
507 RespawnFlag(HORDE
, false);
510 EventPlayerDroppedFlag(plr
);
514 void BattleGroundWS::UpdateFlagState(uint32 team
, uint32 value
)
517 UpdateWorldState(BG_WS_FLAG_STATE_ALLIANCE
, value
);
519 UpdateWorldState(BG_WS_FLAG_STATE_HORDE
, value
);
522 void BattleGroundWS::UpdateTeamScore(uint32 team
)
525 UpdateWorldState(BG_WS_FLAG_CAPTURES_ALLIANCE
, GetTeamScore(team
));
527 UpdateWorldState(BG_WS_FLAG_CAPTURES_HORDE
, GetTeamScore(team
));
530 void BattleGroundWS::HandleAreaTrigger(Player
*Source
, uint32 Trigger
)
532 // this is wrong way to implement these things. On official it done by gameobject spell cast.
533 if(GetStatus() != STATUS_IN_PROGRESS
)
536 //uint32 SpellId = 0;
537 //uint64 buff_guid = 0;
540 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().
541 //buff_guid = m_BgObjects[BG_WS_OBJECT_SPEEDBUFF_1];
543 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().
544 //buff_guid = m_BgObjects[BG_WS_OBJECT_SPEEDBUFF_2];
546 case 3706: // Alliance elixir of regeneration spawn
547 //buff_guid = m_BgObjects[BG_WS_OBJECT_REGENBUFF_1];
549 case 3708: // Horde elixir of regeneration spawn
550 //buff_guid = m_BgObjects[BG_WS_OBJECT_REGENBUFF_2];
552 case 3707: // Alliance elixir of berserk spawn
553 //buff_guid = m_BgObjects[BG_WS_OBJECT_BERSERKBUFF_1];
555 case 3709: // Horde elixir of berserk spawn
556 //buff_guid = m_BgObjects[BG_WS_OBJECT_BERSERKBUFF_2];
558 case 3646: // Alliance Flag spawn
559 if(m_FlagState
[BG_TEAM_HORDE
] && !m_FlagState
[BG_TEAM_ALLIANCE
])
560 if(GetHordeFlagPickerGUID() == Source
->GetGUID())
561 EventPlayerCapturedFlag(Source
);
563 case 3647: // Horde Flag spawn
564 if(m_FlagState
[BG_TEAM_ALLIANCE
] && !m_FlagState
[BG_TEAM_HORDE
])
565 if(GetAllianceFlagPickerGUID() == Source
->GetGUID())
566 EventPlayerCapturedFlag(Source
);
574 sLog
.outError("WARNING: Unhandled AreaTrigger in Battleground: %u", Trigger
);
575 Source
->GetSession()->SendAreaTriggerMessage("Warning: Unhandled AreaTrigger in Battleground: %u", Trigger
);
580 // HandleTriggerBuff(buff_guid,Source);
583 bool BattleGroundWS::SetupBattleGround()
586 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)
587 || !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)
589 || !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
)
590 || !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
)
591 || !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
)
592 || !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
)
593 || !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
)
594 || !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
)
596 || !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
)
597 || !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
)
598 || !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
)
599 || !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
)
600 || !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
)
601 || !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
)
603 || !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
)
604 || !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
)
605 || !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
)
606 || !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
)
609 sLog
.outErrorDb("BatteGroundWS: Failed to spawn some object BattleGround not created!");
613 WorldSafeLocsEntry
const *sg
= sWorldSafeLocsStore
.LookupEntry(WS_GRAVEYARD_MAIN_ALLIANCE
);
614 if(!sg
|| !AddSpiritGuide(WS_SPIRIT_MAIN_ALLIANCE
, sg
->x
, sg
->y
, sg
->z
, 3.124139f
, ALLIANCE
))
616 sLog
.outErrorDb("BatteGroundWS: Failed to spawn Alliance spirit guide! BattleGround not created!");
620 sg
= sWorldSafeLocsStore
.LookupEntry(WS_GRAVEYARD_MAIN_HORDE
);
621 if(!sg
|| !AddSpiritGuide(WS_SPIRIT_MAIN_HORDE
, sg
->x
, sg
->y
, sg
->z
, 3.193953f
, HORDE
))
623 sLog
.outErrorDb("BatteGroundWS: Failed to spawn Horde spirit guide! BattleGround not created!");
627 sLog
.outDebug("BatteGroundWS: BG objects and spirit guides spawned");
632 void BattleGroundWS::Reset()
634 //call parent's class reset
635 BattleGround::Reset();
637 m_FlagKeepers
[BG_TEAM_ALLIANCE
] = 0;
638 m_FlagKeepers
[BG_TEAM_HORDE
] = 0;
639 m_DroppedFlagGUID
[BG_TEAM_ALLIANCE
] = 0;
640 m_DroppedFlagGUID
[BG_TEAM_HORDE
] = 0;
641 m_FlagState
[BG_TEAM_ALLIANCE
] = BG_WS_FLAG_STATE_ON_BASE
;
642 m_FlagState
[BG_TEAM_HORDE
] = BG_WS_FLAG_STATE_ON_BASE
;
643 m_TeamScores
[BG_TEAM_ALLIANCE
] = 0;
644 m_TeamScores
[BG_TEAM_HORDE
] = 0;
646 /* Spirit nodes is static at this BG and then not required deleting at BG reset.
647 if(m_BgCreatures[WS_SPIRIT_MAIN_ALLIANCE])
648 DelCreature(WS_SPIRIT_MAIN_ALLIANCE);
650 if(m_BgCreatures[WS_SPIRIT_MAIN_HORDE])
651 DelCreature(WS_SPIRIT_MAIN_HORDE);
655 void BattleGroundWS::HandleKillPlayer(Player
*player
, Player
*killer
)
657 if(GetStatus() != STATUS_IN_PROGRESS
)
660 EventPlayerDroppedFlag(player
);
662 BattleGround::HandleKillPlayer(player
, killer
);
665 void BattleGroundWS::UpdatePlayerScore(Player
*Source
, uint32 type
, uint32 value
)
668 std::map
<uint64
, BattleGroundScore
*>::iterator itr
= m_PlayerScores
.find(Source
->GetGUID());
670 if(itr
== m_PlayerScores
.end()) // player not found
675 case SCORE_FLAG_CAPTURES
: // flags captured
676 ((BattleGroundWGScore
*)itr
->second
)->FlagCaptures
+= value
;
678 case SCORE_FLAG_RETURNS
: // flags returned
679 ((BattleGroundWGScore
*)itr
->second
)->FlagReturns
+= value
;
682 BattleGround::UpdatePlayerScore(Source
, type
, value
);
687 void BattleGroundWS::FillInitialWorldStates(WorldPacket
& data
)
689 data
<< uint32(BG_WS_FLAG_CAPTURES_ALLIANCE
) << uint32(GetTeamScore(ALLIANCE
));
690 data
<< uint32(BG_WS_FLAG_CAPTURES_HORDE
) << uint32(GetTeamScore(HORDE
));
692 if(m_FlagState
[BG_TEAM_ALLIANCE
] == BG_WS_FLAG_STATE_ON_GROUND
)
693 data
<< uint32(BG_WS_FLAG_UNK_ALLIANCE
) << uint32(-1);
694 else if (m_FlagState
[BG_TEAM_ALLIANCE
] == BG_WS_FLAG_STATE_ON_PLAYER
)
695 data
<< uint32(BG_WS_FLAG_UNK_ALLIANCE
) << uint32(1);
697 data
<< uint32(BG_WS_FLAG_UNK_ALLIANCE
) << uint32(0);
699 if(m_FlagState
[BG_TEAM_HORDE
] == BG_WS_FLAG_STATE_ON_GROUND
)
700 data
<< uint32(BG_WS_FLAG_UNK_HORDE
) << uint32(-1);
701 else if (m_FlagState
[BG_TEAM_HORDE
] == BG_WS_FLAG_STATE_ON_PLAYER
)
702 data
<< uint32(BG_WS_FLAG_UNK_HORDE
) << uint32(1);
704 data
<< uint32(BG_WS_FLAG_UNK_HORDE
) << uint32(0);
706 data
<< uint32(BG_WS_FLAG_CAPTURES_MAX
) << uint32(BG_WS_MAX_TEAM_SCORE
);
708 if (m_FlagState
[BG_TEAM_HORDE
] == BG_WS_FLAG_STATE_ON_PLAYER
)
709 data
<< uint32(BG_WS_FLAG_STATE_HORDE
) << uint32(2);
711 data
<< uint32(BG_WS_FLAG_STATE_HORDE
) << uint32(1);
713 if (m_FlagState
[BG_TEAM_ALLIANCE
] == BG_WS_FLAG_STATE_ON_PLAYER
)
714 data
<< uint32(BG_WS_FLAG_STATE_ALLIANCE
) << uint32(2);
716 data
<< uint32(BG_WS_FLAG_STATE_ALLIANCE
) << uint32(1);