[2] | 1 | /* |
---|
[44] | 2 | * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> |
---|
[2] | 3 | * |
---|
[44] | 4 | * Thanks to the original authors: MaNGOS <http://www.mangosproject.org/> |
---|
| 5 | * |
---|
[2] | 6 | * This program is free software; you can redistribute it and/or modify |
---|
| 7 | * it under the terms of the GNU General Public License as published by |
---|
| 8 | * the Free Software Foundation; either version 2 of the License, or |
---|
| 9 | * (at your option) any later version. |
---|
| 10 | * |
---|
| 11 | * This program is distributed in the hope that it will be useful, |
---|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
[44] | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
[2] | 14 | * GNU General Public License for more details. |
---|
| 15 | * |
---|
| 16 | * You should have received a copy of the GNU General Public License |
---|
| 17 | * along with this program; if not, write to the Free Software |
---|
[44] | 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
[2] | 19 | */ |
---|
| 20 | |
---|
| 21 | #include "Object.h" |
---|
| 22 | #include "Player.h" |
---|
| 23 | #include "BattleGround.h" |
---|
| 24 | #include "BattleGroundAV.h" |
---|
| 25 | #include "Creature.h" |
---|
| 26 | #include "MapManager.h" |
---|
| 27 | #include "Language.h" |
---|
| 28 | |
---|
| 29 | BattleGroundAV::BattleGroundAV() |
---|
| 30 | { |
---|
| 31 | |
---|
| 32 | } |
---|
| 33 | |
---|
| 34 | BattleGroundAV::~BattleGroundAV() |
---|
| 35 | { |
---|
| 36 | |
---|
| 37 | } |
---|
| 38 | |
---|
| 39 | void BattleGroundAV::Update(time_t diff) |
---|
| 40 | { |
---|
| 41 | BattleGround::Update(diff); |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | void BattleGroundAV::AddPlayer(Player *plr) |
---|
| 45 | { |
---|
| 46 | BattleGround::AddPlayer(plr); |
---|
| 47 | //create score and add it to map, default values are set in constructor |
---|
| 48 | BattleGroundAVScore* sc = new BattleGroundAVScore; |
---|
| 49 | |
---|
| 50 | m_PlayerScores[plr->GetGUID()] = sc; |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | void BattleGroundAV::RemovePlayer(Player* /*plr*/,uint64 /*guid*/) |
---|
| 54 | { |
---|
| 55 | |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | void BattleGroundAV::HandleAreaTrigger(Player *Source, uint32 Trigger) |
---|
| 59 | { |
---|
| 60 | // this is wrong way to implement these things. On official it done by gameobject spell cast. |
---|
| 61 | if(GetStatus() != STATUS_IN_PROGRESS) |
---|
| 62 | return; |
---|
| 63 | |
---|
| 64 | uint32 SpellId = 0; |
---|
| 65 | switch(Trigger) |
---|
| 66 | { |
---|
| 67 | case 95: |
---|
| 68 | case 2606: |
---|
| 69 | case 2608: |
---|
| 70 | case 3326: |
---|
| 71 | case 3327: |
---|
| 72 | case 3328: |
---|
| 73 | case 3329: |
---|
| 74 | case 3330: |
---|
| 75 | case 3331: |
---|
| 76 | break; |
---|
| 77 | default: |
---|
| 78 | sLog.outError("WARNING: Unhandled AreaTrigger in Battleground: %u", Trigger); |
---|
| 79 | Source->GetSession()->SendAreaTriggerMessage("Warning: Unhandled AreaTrigger in Battleground: %u", Trigger); |
---|
| 80 | break; |
---|
| 81 | } |
---|
| 82 | |
---|
| 83 | if(SpellId) |
---|
| 84 | Source->CastSpell(Source, SpellId, true); |
---|
| 85 | } |
---|
| 86 | |
---|
| 87 | void BattleGroundAV::UpdatePlayerScore(Player* Source, uint32 type, uint32 value) |
---|
| 88 | { |
---|
| 89 | |
---|
| 90 | std::map<uint64, BattleGroundScore*>::iterator itr = m_PlayerScores.find(Source->GetGUID()); |
---|
| 91 | |
---|
| 92 | if(itr == m_PlayerScores.end()) // player not found... |
---|
| 93 | return; |
---|
| 94 | |
---|
| 95 | switch(type) |
---|
| 96 | { |
---|
| 97 | case SCORE_GRAVEYARDS_ASSAULTED: |
---|
| 98 | ((BattleGroundAVScore*)itr->second)->GraveyardsAssaulted += value; |
---|
| 99 | break; |
---|
| 100 | case SCORE_GRAVEYARDS_DEFENDED: |
---|
| 101 | ((BattleGroundAVScore*)itr->second)->GraveyardsDefended += value; |
---|
| 102 | break; |
---|
| 103 | case SCORE_TOWERS_ASSAULTED: |
---|
| 104 | ((BattleGroundAVScore*)itr->second)->TowersAssaulted += value; |
---|
| 105 | break; |
---|
| 106 | case SCORE_TOWERS_DEFENDED: |
---|
| 107 | ((BattleGroundAVScore*)itr->second)->TowersDefended += value; |
---|
| 108 | break; |
---|
| 109 | case SCORE_MINES_CAPTURED: |
---|
| 110 | ((BattleGroundAVScore*)itr->second)->MinesCaptured += value; |
---|
| 111 | break; |
---|
| 112 | case SCORE_LEADERS_KILLED: |
---|
| 113 | ((BattleGroundAVScore*)itr->second)->LeadersKilled += value; |
---|
| 114 | break; |
---|
| 115 | case SCORE_SECONDARY_OBJECTIVES: |
---|
| 116 | ((BattleGroundAVScore*)itr->second)->SecondaryObjectives += value; |
---|
| 117 | break; |
---|
| 118 | default: |
---|
| 119 | BattleGround::UpdatePlayerScore(Source,type,value); |
---|
| 120 | break; |
---|
| 121 | } |
---|
| 122 | } |
---|