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 "BattleGroundAV.h"
24 #include "MapManager.h"
27 BattleGroundAV::BattleGroundAV()
32 BattleGroundAV::~BattleGroundAV()
37 void BattleGroundAV::Update(time_t diff
)
39 BattleGround::Update(diff
);
42 void BattleGroundAV::AddPlayer(Player
*plr
)
44 BattleGround::AddPlayer(plr
);
45 //create score and add it to map, default values are set in constructor
46 BattleGroundAVScore
* sc
= new BattleGroundAVScore
;
48 m_PlayerScores
[plr
->GetGUID()] = sc
;
51 void BattleGroundAV::RemovePlayer(Player
* /*plr*/,uint64
/*guid*/)
56 void BattleGroundAV::HandleAreaTrigger(Player
*Source
, uint32 Trigger
)
58 // this is wrong way to implement these things. On official it done by gameobject spell cast.
59 if(GetStatus() != STATUS_IN_PROGRESS
)
76 sLog
.outError("WARNING: Unhandled AreaTrigger in Battleground: %u", Trigger
);
77 Source
->GetSession()->SendAreaTriggerMessage("Warning: Unhandled AreaTrigger in Battleground: %u", Trigger
);
82 Source
->CastSpell(Source
, SpellId
, true);
85 void BattleGroundAV::UpdatePlayerScore(Player
* Source
, uint32 type
, uint32 value
)
88 std::map
<uint64
, BattleGroundScore
*>::iterator itr
= m_PlayerScores
.find(Source
->GetGUID());
90 if(itr
== m_PlayerScores
.end()) // player not found...
95 case SCORE_GRAVEYARDS_ASSAULTED
:
96 ((BattleGroundAVScore
*)itr
->second
)->GraveyardsAssaulted
+= value
;
98 case SCORE_GRAVEYARDS_DEFENDED
:
99 ((BattleGroundAVScore
*)itr
->second
)->GraveyardsDefended
+= value
;
101 case SCORE_TOWERS_ASSAULTED
:
102 ((BattleGroundAVScore
*)itr
->second
)->TowersAssaulted
+= value
;
104 case SCORE_TOWERS_DEFENDED
:
105 ((BattleGroundAVScore
*)itr
->second
)->TowersDefended
+= value
;
107 case SCORE_MINES_CAPTURED
:
108 ((BattleGroundAVScore
*)itr
->second
)->MinesCaptured
+= value
;
110 case SCORE_LEADERS_KILLED
:
111 ((BattleGroundAVScore
*)itr
->second
)->LeadersKilled
+= value
;
113 case SCORE_SECONDARY_OBJECTIVES
:
114 ((BattleGroundAVScore
*)itr
->second
)->SecondaryObjectives
+= value
;
117 BattleGround::UpdatePlayerScore(Source
,type
,value
);