root/trunk/src/game/BattleGroundAV.cpp @ 2

Revision 2, 3.5 kB (checked in by yumileroy, 17 years ago)

[svn] * Proper SVN structure

Original author: Neo2003
Date: 2008-10-02 16:23:55-05:00

RevLine 
[2]1/*
2 * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
3 *
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.
8 *
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.
13 *
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
17 */
18
19#include "Object.h"
20#include "Player.h"
21#include "BattleGround.h"
22#include "BattleGroundAV.h"
23#include "Creature.h"
24#include "MapManager.h"
25#include "Language.h"
26
27BattleGroundAV::BattleGroundAV()
28{
29
30}
31
32BattleGroundAV::~BattleGroundAV()
33{
34
35}
36
37void BattleGroundAV::Update(time_t diff)
38{
39    BattleGround::Update(diff);
40}
41
42void BattleGroundAV::AddPlayer(Player *plr)
43{
44    BattleGround::AddPlayer(plr);
45    //create score and add it to map, default values are set in constructor
46    BattleGroundAVScore* sc = new BattleGroundAVScore;
47
48    m_PlayerScores[plr->GetGUID()] = sc;
49}
50
51void BattleGroundAV::RemovePlayer(Player* /*plr*/,uint64 /*guid*/)
52{
53
54}
55
56void BattleGroundAV::HandleAreaTrigger(Player *Source, uint32 Trigger)
57{
58    // this is wrong way to implement these things. On official it done by gameobject spell cast.
59    if(GetStatus() != STATUS_IN_PROGRESS)
60        return;
61
62    uint32 SpellId = 0;
63    switch(Trigger)
64    {
65        case 95:
66        case 2606:
67        case 2608:
68        case 3326:
69        case 3327:
70        case 3328:
71        case 3329:
72        case 3330:
73        case 3331:
74            break;
75        default:
76            sLog.outError("WARNING: Unhandled AreaTrigger in Battleground: %u", Trigger);
77            Source->GetSession()->SendAreaTriggerMessage("Warning: Unhandled AreaTrigger in Battleground: %u", Trigger);
78            break;
79    }
80
81    if(SpellId)
82        Source->CastSpell(Source, SpellId, true);
83}
84
85void BattleGroundAV::UpdatePlayerScore(Player* Source, uint32 type, uint32 value)
86{
87
88    std::map<uint64, BattleGroundScore*>::iterator itr = m_PlayerScores.find(Source->GetGUID());
89
90    if(itr == m_PlayerScores.end())                         // player not found...
91        return;
92
93    switch(type)
94    {
95        case SCORE_GRAVEYARDS_ASSAULTED:
96            ((BattleGroundAVScore*)itr->second)->GraveyardsAssaulted += value;
97            break;
98        case SCORE_GRAVEYARDS_DEFENDED:
99            ((BattleGroundAVScore*)itr->second)->GraveyardsDefended += value;
100            break;
101        case SCORE_TOWERS_ASSAULTED:
102            ((BattleGroundAVScore*)itr->second)->TowersAssaulted += value;
103            break;
104        case SCORE_TOWERS_DEFENDED:
105            ((BattleGroundAVScore*)itr->second)->TowersDefended += value;
106            break;
107        case SCORE_MINES_CAPTURED:
108            ((BattleGroundAVScore*)itr->second)->MinesCaptured += value;
109            break;
110        case SCORE_LEADERS_KILLED:
111            ((BattleGroundAVScore*)itr->second)->LeadersKilled += value;
112            break;
113        case SCORE_SECONDARY_OBJECTIVES:
114            ((BattleGroundAVScore*)itr->second)->SecondaryObjectives += value;
115            break;
116        default:
117            BattleGround::UpdatePlayerScore(Source,type,value);
118            break;
119    }
120}
Note: See TracBrowser for help on using the browser.