TrinityCore
OutdoorPvPMgr.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef OUTDOOR_PVP_MGR_H_
19#define OUTDOOR_PVP_MGR_H_
20
21#define OUTDOORPVP_OBJECTIVE_UPDATE_INTERVAL 1000
22
23#include "OutdoorPvP.h"
24#include "Hash.h"
25#include <array>
26#include <memory>
27#include <unordered_map>
28#include <vector>
29
30class Player;
31class GameObject;
32class Creature;
33class Map;
34class ZoneScript;
35struct GossipMenuItems;
37
38// class to handle player enter / leave / areatrigger / GO use events
40{
41 private:
44
45 public:
46 OutdoorPvPMgr(OutdoorPvPMgr const&) = delete;
48
49 OutdoorPvPMgr& operator= (OutdoorPvPMgr const&) = delete;
50 OutdoorPvPMgr& operator= (OutdoorPvPMgr&&) = delete;
51
52 static OutdoorPvPMgr* instance();
53
54 // create outdoor pvp events
55 void InitOutdoorPvP();
56
57 // cleanup
58 void Die();
59
60 void CreateOutdoorPvPForMap(Map* map);
61
62 void DestroyOutdoorPvPForMap(Map* map);
63
64 // called when a player enters an outdoor pvp area
65 void HandlePlayerEnterZone(Player* player, uint32 areaflag);
66
67 // called when player leaves an outdoor pvp area
68 void HandlePlayerLeaveZone(Player* player, uint32 areaflag);
69
70 // called when player resurrects
71 void HandlePlayerResurrects(Player* player, uint32 areaflag);
72
73 // return assigned outdoor pvp
74 OutdoorPvP* GetOutdoorPvPToZoneId(Map* map, uint32 zoneid);
75
76 // handle custom (non-exist in dbc) spell if registered
77 bool HandleCustomSpell(Player* player, uint32 spellId, GameObject* go);
78
79 // handle custom go if registered
80 bool HandleOpenGo(Player* player, GameObject* go);
81
82 void AddZone(uint32 zoneid, OutdoorPvP* handle);
83
84 void Update(uint32 diff);
85
86 void HandleDropFlag(Player* player, uint32 spellId);
87
88 std::string GetDefenseMessage(uint32 zoneId, uint32 id, LocaleConstant locale) const;
89
90 private:
91 typedef std::unordered_map<std::pair<Map*, uint32 /*zoneid*/>, OutdoorPvP*> OutdoorPvPMap;
92 typedef std::array<uint32, MAX_OUTDOORPVP_TYPES> OutdoorPvPScriptIds;
93
94 // contains all initiated outdoor pvp events
95 // used when initing / cleaning up
96 std::unordered_map<Map*, std::vector<std::unique_ptr<OutdoorPvP>>> m_OutdoorPvPByMap;
97
98 // maps the zone ids to an outdoor pvp event
99 // used in player event handling
101
102 // Holds the outdoor PvP templates
103 OutdoorPvPScriptIds m_OutdoorMapIds = { 0, 530, 530, 530, 530, 1 };
104 OutdoorPvPScriptIds m_OutdoorPvPDatas = {};
105
106 // update interval
108};
109
110#define sOutdoorPvPMgr OutdoorPvPMgr::instance()
111
112#endif /*OUTDOOR_PVP_MGR_H_*/
LocaleConstant
Definition: Common.h:48
#define TC_GAME_API
Definition: Define.h:123
uint8_t uint8
Definition: Define.h:144
uint32_t uint32
Definition: Define.h:142
Definition: Map.h:189
OutdoorPvPMap m_OutdoorPvPMap
OutdoorPvPMgr(OutdoorPvPMgr const &)=delete
std::unordered_map< std::pair< Map *, uint32 >, OutdoorPvP * > OutdoorPvPMap
Definition: OutdoorPvPMgr.h:91
OutdoorPvPMgr(OutdoorPvPMgr &&)=delete
std::unordered_map< Map *, std::vector< std::unique_ptr< OutdoorPvP > > > m_OutdoorPvPByMap
Definition: OutdoorPvPMgr.h:96
std::array< uint32, MAX_OUTDOORPVP_TYPES > OutdoorPvPScriptIds
Definition: OutdoorPvPMgr.h:92
uint32 m_UpdateTimer
void Update(VignetteData &vignette, WorldObject const *owner)
Definition: Vignette.cpp:90