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
21 #include "BattleGround.h"
22 #include "BattleGroundWS.h"
24 #include "GameObject.h"
25 #include "ObjectMgr.h"
26 #include "BattleGroundMgr.h"
27 #include "WorldPacket.h"
29 #include "MapManager.h"
31 BattleGroundWS::BattleGroundWS()
33 m_StartMessageIds
[BG_STARTING_EVENT_FIRST
] = 0;
34 m_StartMessageIds
[BG_STARTING_EVENT_SECOND
] = LANG_BG_WS_START_ONE_MINUTE
;
35 m_StartMessageIds
[BG_STARTING_EVENT_THIRD
] = LANG_BG_WS_START_HALF_MINUTE
;
36 m_StartMessageIds
[BG_STARTING_EVENT_FOURTH
] = LANG_BG_WS_HAS_BEGUN
;
39 BattleGroundWS::~BattleGroundWS()
43 void BattleGroundWS::Update(uint32 diff
)
45 BattleGround::Update(diff
);
47 if (GetStatus() == STATUS_IN_PROGRESS
)
49 if (m_FlagState
[BG_TEAM_ALLIANCE
] == BG_WS_FLAG_STATE_WAIT_RESPAWN
)
51 m_FlagsTimer
[BG_TEAM_ALLIANCE
] -= diff
;
53 if (m_FlagsTimer
[BG_TEAM_ALLIANCE
] < 0)
55 m_FlagsTimer
[BG_TEAM_ALLIANCE
] = 0;
56 RespawnFlag(ALLIANCE
, true);
59 if (m_FlagState
[BG_TEAM_ALLIANCE
] == BG_WS_FLAG_STATE_ON_GROUND
)
61 m_FlagsDropTimer
[BG_TEAM_ALLIANCE
] -= diff
;
63 if (m_FlagsDropTimer
[BG_TEAM_ALLIANCE
] < 0)
65 m_FlagsDropTimer
[BG_TEAM_ALLIANCE
] = 0;
66 RespawnFlagAfterDrop(ALLIANCE
);
69 if (m_FlagState
[BG_TEAM_HORDE
] == BG_WS_FLAG_STATE_WAIT_RESPAWN
)
71 m_FlagsTimer
[BG_TEAM_HORDE
] -= diff
;
73 if (m_FlagsTimer
[BG_TEAM_HORDE
] < 0)
75 m_FlagsTimer
[BG_TEAM_HORDE
] = 0;
76 RespawnFlag(HORDE
, true);
79 if (m_FlagState
[BG_TEAM_HORDE
] == BG_WS_FLAG_STATE_ON_GROUND
)
81 m_FlagsDropTimer
[BG_TEAM_HORDE
] -= diff
;
83 if (m_FlagsDropTimer
[BG_TEAM_HORDE
] < 0)
85 m_FlagsDropTimer
[BG_TEAM_HORDE
] = 0;
86 RespawnFlagAfterDrop(HORDE
);
92 void BattleGroundWS::StartingEventCloseDoors()
96 void BattleGroundWS::StartingEventOpenDoors()
98 OpenDoorEvent(BG_EVENT_DOOR
);
100 // TODO implement timer to despawn doors after a short while
102 SpawnEvent(WS_EVENT_SPIRITGUIDES_SPAWN
, 0, true);
103 SpawnEvent(WS_EVENT_FLAG_A
, 0, true);
104 SpawnEvent(WS_EVENT_FLAG_H
, 0, true);
107 void BattleGroundWS::AddPlayer(Player
*plr
)
109 BattleGround::AddPlayer(plr
);
110 //create score and add it to map, default values are set in constructor
111 BattleGroundWGScore
* sc
= new BattleGroundWGScore
;
113 m_PlayerScores
[plr
->GetGUID()] = sc
;
116 void BattleGroundWS::RespawnFlag(uint32 Team
, bool captured
)
118 if (Team
== ALLIANCE
)
120 sLog
.outDebug("Respawn Alliance flag");
121 m_FlagState
[BG_TEAM_ALLIANCE
] = BG_WS_FLAG_STATE_ON_BASE
;
122 SpawnEvent(WS_EVENT_FLAG_A
, 0, true);
126 sLog
.outDebug("Respawn Horde flag");
127 m_FlagState
[BG_TEAM_HORDE
] = BG_WS_FLAG_STATE_ON_BASE
;
128 SpawnEvent(WS_EVENT_FLAG_H
, 0, true);
133 //when map_update will be allowed for battlegrounds this code will be useless
134 SpawnEvent(WS_EVENT_FLAG_A
, 0, true);
135 SpawnEvent(WS_EVENT_FLAG_H
, 0, true);
136 SendMessageToAll(LANG_BG_WS_F_PLACED
, CHAT_MSG_BG_SYSTEM_NEUTRAL
);
137 PlaySoundToAll(BG_WS_SOUND_FLAGS_RESPAWNED
); // flag respawned sound...
141 void BattleGroundWS::RespawnFlagAfterDrop(uint32 team
)
143 if (GetStatus() != STATUS_IN_PROGRESS
)
146 RespawnFlag(team
, false);
147 if (team
== ALLIANCE
)
148 SendMessageToAll(LANG_BG_WS_ALLIANCE_FLAG_RESPAWNED
, CHAT_MSG_BG_SYSTEM_NEUTRAL
);
150 SendMessageToAll(LANG_BG_WS_HORDE_FLAG_RESPAWNED
, CHAT_MSG_BG_SYSTEM_NEUTRAL
);
152 PlaySoundToAll(BG_WS_SOUND_FLAGS_RESPAWNED
);
154 GameObject
*obj
= GetBgMap()->GetGameObject(GetDroppedFlagGUID(team
));
158 sLog
.outError("unknown droped flag bg, guid: %u",GUID_LOPART(GetDroppedFlagGUID(team
)));
160 SetDroppedFlagGUID(0,team
);
163 void BattleGroundWS::EventPlayerCapturedFlag(Player
*Source
)
165 if (GetStatus() != STATUS_IN_PROGRESS
)
170 Source
->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT
);
171 if (Source
->GetTeam() == ALLIANCE
)
173 if (!IsHordeFlagPickedup())
175 SetHordeFlagPicker(0); // must be before aura remove to prevent 2 events (drop+capture) at the same time
176 // horde flag in base (but not respawned yet)
177 m_FlagState
[BG_TEAM_HORDE
] = BG_WS_FLAG_STATE_WAIT_RESPAWN
;
178 // Drop Horde Flag from Player
179 Source
->RemoveAurasDueToSpell(BG_WS_SPELL_WARSONG_FLAG
);
180 if (GetTeamScore(ALLIANCE
) < BG_WS_MAX_TEAM_SCORE
)
181 AddPoint(ALLIANCE
, 1);
182 PlaySoundToAll(BG_WS_SOUND_FLAG_CAPTURED_ALLIANCE
);
183 RewardReputationToTeam(890, m_ReputationCapture
, ALLIANCE
);
187 if (!IsAllianceFlagPickedup())
189 SetAllianceFlagPicker(0); // must be before aura remove to prevent 2 events (drop+capture) at the same time
190 // alliance flag in base (but not respawned yet)
191 m_FlagState
[BG_TEAM_ALLIANCE
] = BG_WS_FLAG_STATE_WAIT_RESPAWN
;
192 // Drop Alliance Flag from Player
193 Source
->RemoveAurasDueToSpell(BG_WS_SPELL_SILVERWING_FLAG
);
194 if (GetTeamScore(HORDE
) < BG_WS_MAX_TEAM_SCORE
)
196 PlaySoundToAll(BG_WS_SOUND_FLAG_CAPTURED_HORDE
);
197 RewardReputationToTeam(889, m_ReputationCapture
, HORDE
);
199 //for flag capture is reward 2 honorable kills
200 RewardHonorToTeam(GetBonusHonorFromKill(2), Source
->GetTeam());
203 SpawnEvent(WS_EVENT_FLAG_A
, 0, false);
204 SpawnEvent(WS_EVENT_FLAG_H
, 0, false);
206 if (Source
->GetTeam() == ALLIANCE
)
207 SendMessageToAll(LANG_BG_WS_CAPTURED_HF
, CHAT_MSG_BG_SYSTEM_ALLIANCE
, Source
);
209 SendMessageToAll(LANG_BG_WS_CAPTURED_AF
, CHAT_MSG_BG_SYSTEM_HORDE
, Source
);
211 UpdateFlagState(Source
->GetTeam(), 1); // flag state none
212 UpdateTeamScore(Source
->GetTeam());
213 // only flag capture should be updated
214 UpdatePlayerScore(Source
, SCORE_FLAG_CAPTURES
, 1); // +1 flag captures
216 if (GetTeamScore(ALLIANCE
) == BG_WS_MAX_TEAM_SCORE
)
219 if (GetTeamScore(HORDE
) == BG_WS_MAX_TEAM_SCORE
)
224 UpdateWorldState(BG_WS_FLAG_UNK_ALLIANCE
, 0);
225 UpdateWorldState(BG_WS_FLAG_UNK_HORDE
, 0);
226 UpdateWorldState(BG_WS_FLAG_STATE_ALLIANCE
, 1);
227 UpdateWorldState(BG_WS_FLAG_STATE_HORDE
, 1);
229 EndBattleGround(winner
);
233 m_FlagsTimer
[GetTeamIndexByTeamId(Source
->GetTeam()) ? 0 : 1] = BG_WS_FLAG_RESPAWN_TIME
;
237 void BattleGroundWS::EventPlayerDroppedFlag(Player
*Source
)
239 if (GetStatus() != STATUS_IN_PROGRESS
)
241 // if not running, do not cast things at the dropper player (prevent spawning the "dropped" flag), neither send unnecessary messages
242 // just take off the aura
243 if (Source
->GetTeam() == ALLIANCE
)
245 if (!this->IsHordeFlagPickedup())
247 if (GetHordeFlagPickerGUID() == Source
->GetGUID())
249 SetHordeFlagPicker(0);
250 Source
->RemoveAurasDueToSpell(BG_WS_SPELL_WARSONG_FLAG
);
255 if (!this->IsAllianceFlagPickedup())
257 if (GetAllianceFlagPickerGUID() == Source
->GetGUID())
259 SetAllianceFlagPicker(0);
260 Source
->RemoveAurasDueToSpell(BG_WS_SPELL_SILVERWING_FLAG
);
268 if (Source
->GetTeam() == ALLIANCE
)
270 if (!IsHordeFlagPickedup())
272 if (GetHordeFlagPickerGUID() == Source
->GetGUID())
274 SetHordeFlagPicker(0);
275 Source
->RemoveAurasDueToSpell(BG_WS_SPELL_WARSONG_FLAG
);
276 m_FlagState
[BG_TEAM_HORDE
] = BG_WS_FLAG_STATE_ON_GROUND
;
277 Source
->CastSpell(Source
, BG_WS_SPELL_WARSONG_FLAG_DROPPED
, true);
283 if (!IsAllianceFlagPickedup())
285 if (GetAllianceFlagPickerGUID() == Source
->GetGUID())
287 SetAllianceFlagPicker(0);
288 Source
->RemoveAurasDueToSpell(BG_WS_SPELL_SILVERWING_FLAG
);
289 m_FlagState
[BG_TEAM_ALLIANCE
] = BG_WS_FLAG_STATE_ON_GROUND
;
290 Source
->CastSpell(Source
, BG_WS_SPELL_SILVERWING_FLAG_DROPPED
, true);
297 Source
->CastSpell(Source
, SPELL_RECENTLY_DROPPED_FLAG
, true);
298 UpdateFlagState(Source
->GetTeam(), 1);
300 if (Source
->GetTeam() == ALLIANCE
)
302 SendMessageToAll(LANG_BG_WS_DROPPED_HF
, CHAT_MSG_BG_SYSTEM_HORDE
, Source
);
303 UpdateWorldState(BG_WS_FLAG_UNK_HORDE
, uint32(-1));
307 SendMessageToAll(LANG_BG_WS_DROPPED_AF
, CHAT_MSG_BG_SYSTEM_ALLIANCE
, Source
);
308 UpdateWorldState(BG_WS_FLAG_UNK_ALLIANCE
, uint32(-1));
311 m_FlagsDropTimer
[GetTeamIndexByTeamId(Source
->GetTeam()) ? 0 : 1] = BG_WS_FLAG_DROP_TIME
;
315 void BattleGroundWS::EventPlayerClickedOnFlag(Player
*Source
, GameObject
* target_obj
)
317 if (GetStatus() != STATUS_IN_PROGRESS
)
320 int32 message_id
= 0;
323 uint8 event
= (sBattleGroundMgr
.GetGameObjectEventIndex(target_obj
->GetDBTableGUIDLow())).event1
;
325 //alliance flag picked up from base
326 if(Source
->GetTeam() == HORDE
&& GetFlagState(ALLIANCE
) == BG_WS_FLAG_STATE_ON_BASE
327 && event
== WS_EVENT_FLAG_A
)
329 message_id
= LANG_BG_WS_PICKEDUP_AF
;
330 type
= CHAT_MSG_BG_SYSTEM_HORDE
;
331 PlaySoundToAll(BG_WS_SOUND_ALLIANCE_FLAG_PICKED_UP
);
332 SpawnEvent(WS_EVENT_FLAG_A
, 0, false);
333 SetAllianceFlagPicker(Source
->GetGUID());
334 m_FlagState
[BG_TEAM_ALLIANCE
] = BG_WS_FLAG_STATE_ON_PLAYER
;
335 //update world state to show correct flag carrier
336 UpdateFlagState(HORDE
, BG_WS_FLAG_STATE_ON_PLAYER
);
337 UpdateWorldState(BG_WS_FLAG_UNK_ALLIANCE
, 1);
338 Source
->CastSpell(Source
, BG_WS_SPELL_SILVERWING_FLAG
, true);
341 //horde flag picked up from base
342 if (Source
->GetTeam() == ALLIANCE
&& GetFlagState(HORDE
) == BG_WS_FLAG_STATE_ON_BASE
343 && event
== WS_EVENT_FLAG_H
)
345 message_id
= LANG_BG_WS_PICKEDUP_HF
;
346 type
= CHAT_MSG_BG_SYSTEM_ALLIANCE
;
347 PlaySoundToAll(BG_WS_SOUND_HORDE_FLAG_PICKED_UP
);
348 SpawnEvent(WS_EVENT_FLAG_H
, 0, false);
349 SetHordeFlagPicker(Source
->GetGUID());
350 m_FlagState
[BG_TEAM_HORDE
] = BG_WS_FLAG_STATE_ON_PLAYER
;
351 //update world state to show correct flag carrier
352 UpdateFlagState(ALLIANCE
, BG_WS_FLAG_STATE_ON_PLAYER
);
353 UpdateWorldState(BG_WS_FLAG_UNK_HORDE
, 1);
354 Source
->CastSpell(Source
, BG_WS_SPELL_WARSONG_FLAG
, true);
357 //Alliance flag on ground(not in base) (returned or picked up again from ground!)
358 if (GetFlagState(ALLIANCE
) == BG_WS_FLAG_STATE_ON_GROUND
&& Source
->IsWithinDistInMap(target_obj
, 10))
360 if (Source
->GetTeam() == ALLIANCE
)
362 message_id
= LANG_BG_WS_RETURNED_AF
;
363 type
= CHAT_MSG_BG_SYSTEM_ALLIANCE
;
364 UpdateFlagState(HORDE
, BG_WS_FLAG_STATE_WAIT_RESPAWN
);
365 RespawnFlag(ALLIANCE
, false);
366 PlaySoundToAll(BG_WS_SOUND_FLAG_RETURNED
);
367 UpdatePlayerScore(Source
, SCORE_FLAG_RETURNS
, 1);
371 message_id
= LANG_BG_WS_PICKEDUP_AF
;
372 type
= CHAT_MSG_BG_SYSTEM_HORDE
;
373 PlaySoundToAll(BG_WS_SOUND_ALLIANCE_FLAG_PICKED_UP
);
374 SpawnEvent(WS_EVENT_FLAG_A
, 0, false);
375 SetAllianceFlagPicker(Source
->GetGUID());
376 Source
->CastSpell(Source
, BG_WS_SPELL_SILVERWING_FLAG
, true);
377 m_FlagState
[BG_TEAM_ALLIANCE
] = BG_WS_FLAG_STATE_ON_PLAYER
;
378 UpdateFlagState(HORDE
, BG_WS_FLAG_STATE_ON_PLAYER
);
379 UpdateWorldState(BG_WS_FLAG_UNK_ALLIANCE
, 1);
381 //called in HandleGameObjectUseOpcode:
382 //target_obj->Delete();
385 //Horde flag on ground(not in base) (returned or picked up again)
386 if (GetFlagState(HORDE
) == BG_WS_FLAG_STATE_ON_GROUND
&& Source
->IsWithinDistInMap(target_obj
, 10))
388 if (Source
->GetTeam() == HORDE
)
390 message_id
= LANG_BG_WS_RETURNED_HF
;
391 type
= CHAT_MSG_BG_SYSTEM_HORDE
;
392 UpdateFlagState(ALLIANCE
, BG_WS_FLAG_STATE_WAIT_RESPAWN
);
393 RespawnFlag(HORDE
, false);
394 PlaySoundToAll(BG_WS_SOUND_FLAG_RETURNED
);
395 UpdatePlayerScore(Source
, SCORE_FLAG_RETURNS
, 1);
399 message_id
= LANG_BG_WS_PICKEDUP_HF
;
400 type
= CHAT_MSG_BG_SYSTEM_ALLIANCE
;
401 PlaySoundToAll(BG_WS_SOUND_HORDE_FLAG_PICKED_UP
);
402 SpawnEvent(WS_EVENT_FLAG_H
, 0, false);
403 SetHordeFlagPicker(Source
->GetGUID());
404 Source
->CastSpell(Source
, BG_WS_SPELL_WARSONG_FLAG
, true);
405 m_FlagState
[BG_TEAM_HORDE
] = BG_WS_FLAG_STATE_ON_PLAYER
;
406 UpdateFlagState(ALLIANCE
, BG_WS_FLAG_STATE_ON_PLAYER
);
407 UpdateWorldState(BG_WS_FLAG_UNK_HORDE
, 1);
409 //called in HandleGameObjectUseOpcode:
410 //target_obj->Delete();
416 SendMessageToAll(message_id
, type
, Source
);
417 Source
->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT
);
420 void BattleGroundWS::RemovePlayer(Player
*plr
, uint64 guid
)
422 // sometimes flag aura not removed :(
423 if (IsAllianceFlagPickedup() && m_FlagKeepers
[BG_TEAM_ALLIANCE
] == guid
)
427 sLog
.outError("BattleGroundWS: Removing offline player who has the FLAG!!");
428 SetAllianceFlagPicker(0);
429 RespawnFlag(ALLIANCE
, false);
432 EventPlayerDroppedFlag(plr
);
434 if (IsHordeFlagPickedup() && m_FlagKeepers
[BG_TEAM_HORDE
] == guid
)
438 sLog
.outError("BattleGroundWS: Removing offline player who has the FLAG!!");
439 SetHordeFlagPicker(0);
440 RespawnFlag(HORDE
, false);
443 EventPlayerDroppedFlag(plr
);
447 void BattleGroundWS::UpdateFlagState(uint32 team
, uint32 value
)
449 if (team
== ALLIANCE
)
450 UpdateWorldState(BG_WS_FLAG_STATE_ALLIANCE
, value
);
452 UpdateWorldState(BG_WS_FLAG_STATE_HORDE
, value
);
455 void BattleGroundWS::UpdateTeamScore(uint32 team
)
457 if (team
== ALLIANCE
)
458 UpdateWorldState(BG_WS_FLAG_CAPTURES_ALLIANCE
, GetTeamScore(team
));
460 UpdateWorldState(BG_WS_FLAG_CAPTURES_HORDE
, GetTeamScore(team
));
463 void BattleGroundWS::HandleAreaTrigger(Player
*Source
, uint32 Trigger
)
465 // this is wrong way to implement these things. On official it done by gameobject spell cast.
466 if (GetStatus() != STATUS_IN_PROGRESS
)
469 //uint32 SpellId = 0;
470 //uint64 buff_guid = 0;
473 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().
474 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().
475 case 3706: // Alliance elixir of regeneration spawn
476 case 3708: // Horde elixir of regeneration spawn
477 case 3707: // Alliance elixir of berserk spawn
478 case 3709: // Horde elixir of berserk spawn
480 case 3646: // Alliance Flag spawn
481 if (m_FlagState
[BG_TEAM_HORDE
] && !m_FlagState
[BG_TEAM_ALLIANCE
])
482 if (GetHordeFlagPickerGUID() == Source
->GetGUID())
483 EventPlayerCapturedFlag(Source
);
485 case 3647: // Horde Flag spawn
486 if (m_FlagState
[BG_TEAM_ALLIANCE
] && !m_FlagState
[BG_TEAM_HORDE
])
487 if (GetAllianceFlagPickerGUID() == Source
->GetGUID())
488 EventPlayerCapturedFlag(Source
);
496 sLog
.outError("WARNING: Unhandled AreaTrigger in Battleground: %u", Trigger
);
497 Source
->GetSession()->SendAreaTriggerMessage("Warning: Unhandled AreaTrigger in Battleground: %u", Trigger
);
502 bool BattleGroundWS::SetupBattleGround()
507 void BattleGroundWS::Reset()
509 //call parent's class reset
510 BattleGround::Reset();
512 // spiritguides and flags not spawned at beginning
513 m_ActiveEvents
[WS_EVENT_SPIRITGUIDES_SPAWN
] = BG_EVENT_NONE
;
514 m_ActiveEvents
[WS_EVENT_FLAG_A
] = BG_EVENT_NONE
;
515 m_ActiveEvents
[WS_EVENT_FLAG_H
] = BG_EVENT_NONE
;
517 for(uint32 i
= 0; i
< BG_TEAMS_COUNT
; ++i
)
519 m_DroppedFlagGUID
[i
] = 0;
520 m_FlagKeepers
[i
] = 0;
521 m_FlagState
[i
] = BG_WS_FLAG_STATE_ON_BASE
;
524 bool isBGWeekend
= BattleGroundMgr::IsBGWeekend(GetTypeID());
525 m_ReputationCapture
= (isBGWeekend
) ? 45 : 35;
526 m_HonorWinKills
= (isBGWeekend
) ? 3 : 1;
527 m_HonorEndKills
= (isBGWeekend
) ? 4 : 2;
531 void BattleGroundWS::EndBattleGround(uint32 winner
)
534 if (winner
== ALLIANCE
)
535 RewardHonorToTeam(GetBonusHonorFromKill(m_HonorWinKills
), ALLIANCE
);
537 RewardHonorToTeam(GetBonusHonorFromKill(m_HonorWinKills
), HORDE
);
538 //complete map_end rewards (even if no team wins)
539 RewardHonorToTeam(GetBonusHonorFromKill(m_HonorEndKills
), ALLIANCE
);
540 RewardHonorToTeam(GetBonusHonorFromKill(m_HonorEndKills
), HORDE
);
542 BattleGround::EndBattleGround(winner
);
545 void BattleGroundWS::HandleKillPlayer(Player
*player
, Player
*killer
)
547 if (GetStatus() != STATUS_IN_PROGRESS
)
550 EventPlayerDroppedFlag(player
);
552 BattleGround::HandleKillPlayer(player
, killer
);
555 void BattleGroundWS::UpdatePlayerScore(Player
*Source
, uint32 type
, uint32 value
)
558 BattleGroundScoreMap::iterator itr
= m_PlayerScores
.find(Source
->GetGUID());
559 if(itr
== m_PlayerScores
.end()) // player not found
564 case SCORE_FLAG_CAPTURES
: // flags captured
565 ((BattleGroundWGScore
*)itr
->second
)->FlagCaptures
+= value
;
567 case SCORE_FLAG_RETURNS
: // flags returned
568 ((BattleGroundWGScore
*)itr
->second
)->FlagReturns
+= value
;
571 BattleGround::UpdatePlayerScore(Source
, type
, value
);
576 WorldSafeLocsEntry
const* BattleGroundWS::GetClosestGraveYard(Player
* player
)
578 //if status in progress, it returns main graveyards with spiritguides
579 //else it will return the graveyard in the flagroom - this is especially good
580 //if a player dies in preparation phase - then the player can't cheat
581 //and teleport to the graveyard outside the flagroom
582 //and start running around, while the doors are still closed
583 if (player
->GetTeam() == ALLIANCE
)
585 if (GetStatus() == STATUS_IN_PROGRESS
)
586 return sWorldSafeLocsStore
.LookupEntry(WS_GRAVEYARD_MAIN_ALLIANCE
);
588 return sWorldSafeLocsStore
.LookupEntry(WS_GRAVEYARD_FLAGROOM_ALLIANCE
);
592 if (GetStatus() == STATUS_IN_PROGRESS
)
593 return sWorldSafeLocsStore
.LookupEntry(WS_GRAVEYARD_MAIN_HORDE
);
595 return sWorldSafeLocsStore
.LookupEntry(WS_GRAVEYARD_FLAGROOM_HORDE
);
599 void BattleGroundWS::FillInitialWorldStates(WorldPacket
& data
)
601 data
<< uint32(BG_WS_FLAG_CAPTURES_ALLIANCE
) << uint32(GetTeamScore(ALLIANCE
));
602 data
<< uint32(BG_WS_FLAG_CAPTURES_HORDE
) << uint32(GetTeamScore(HORDE
));
604 if (m_FlagState
[BG_TEAM_ALLIANCE
] == BG_WS_FLAG_STATE_ON_GROUND
)
605 data
<< uint32(BG_WS_FLAG_UNK_ALLIANCE
) << uint32(-1);
606 else if (m_FlagState
[BG_TEAM_ALLIANCE
] == BG_WS_FLAG_STATE_ON_PLAYER
)
607 data
<< uint32(BG_WS_FLAG_UNK_ALLIANCE
) << uint32(1);
609 data
<< uint32(BG_WS_FLAG_UNK_ALLIANCE
) << uint32(0);
611 if (m_FlagState
[BG_TEAM_HORDE
] == BG_WS_FLAG_STATE_ON_GROUND
)
612 data
<< uint32(BG_WS_FLAG_UNK_HORDE
) << uint32(-1);
613 else if (m_FlagState
[BG_TEAM_HORDE
] == BG_WS_FLAG_STATE_ON_PLAYER
)
614 data
<< uint32(BG_WS_FLAG_UNK_HORDE
) << uint32(1);
616 data
<< uint32(BG_WS_FLAG_UNK_HORDE
) << uint32(0);
618 data
<< uint32(BG_WS_FLAG_CAPTURES_MAX
) << uint32(BG_WS_MAX_TEAM_SCORE
);
620 if (m_FlagState
[BG_TEAM_HORDE
] == BG_WS_FLAG_STATE_ON_PLAYER
)
621 data
<< uint32(BG_WS_FLAG_STATE_HORDE
) << uint32(2);
623 data
<< uint32(BG_WS_FLAG_STATE_HORDE
) << uint32(1);
625 if (m_FlagState
[BG_TEAM_ALLIANCE
] == BG_WS_FLAG_STATE_ON_PLAYER
)
626 data
<< uint32(BG_WS_FLAG_STATE_ALLIANCE
) << uint32(2);
628 data
<< uint32(BG_WS_FLAG_STATE_ALLIANCE
) << uint32(1);