2 * Copyright (C) 2005-2013 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
19 #include "OutdoorPvPMgr.h"
20 #include "Policies/SingletonImp.h"
21 #include "OutdoorPvP.h"
24 #include "OutdoorPvPEP.h"
25 #include "OutdoorPvPGH.h"
26 #include "OutdoorPvPHP.h"
27 #include "OutdoorPvPNA.h"
28 #include "OutdoorPvPSI.h"
29 #include "OutdoorPvPTF.h"
30 #include "OutdoorPvPZM.h"
32 INSTANTIATE_SINGLETON_1(OutdoorPvPMgr
);
34 OutdoorPvPMgr::OutdoorPvPMgr()
36 m_updateTimer
.SetInterval(TIMER_OPVP_MGR_UPDATE
);
37 memset(&m_scripts
, 0, sizeof(m_scripts
));
40 OutdoorPvPMgr::~OutdoorPvPMgr()
42 for (uint8 i
= 0; i
< MAX_OPVP_ID
; ++i
)
46 #define LOAD_OPVP_ZONE(a) \
47 if (sWorld.getConfig(CONFIG_BOOL_OUTDOORPVP_##a##_ENABLED)) \
49 m_scripts[OPVP_ID_##a] = new OutdoorPvP##a(); \
53 Function which loads all outdoor pvp scripts
55 void OutdoorPvPMgr::InitOutdoorPvP()
68 sLog
.outString(">> Loaded %u Outdoor PvP zones", counter
);
71 OutdoorPvP
* OutdoorPvPMgr::GetScript(uint32 zoneId
)
75 case ZONE_ID_SILITHUS
:
76 return m_scripts
[OPVP_ID_SI
];
77 case ZONE_ID_EASTERN_PLAGUELANDS
:
78 return m_scripts
[OPVP_ID_EP
];
79 case ZONE_ID_HELLFIRE_PENINSULA
:
80 return m_scripts
[OPVP_ID_HP
];
81 case ZONE_ID_ZANGARMARSH
:
82 return m_scripts
[OPVP_ID_ZM
];
83 case ZONE_ID_TEROKKAR_FOREST
:
84 return m_scripts
[OPVP_ID_TF
];
86 return m_scripts
[OPVP_ID_NA
];
87 case ZONE_ID_GRIZZLY_HILLS
:
88 return m_scripts
[OPVP_ID_GH
];
94 OutdoorPvP
* OutdoorPvPMgr::GetScriptOfAffectedZone(uint32 zoneId
)
98 case ZONE_ID_TEMPLE_OF_AQ
:
99 case ZONE_ID_RUINS_OF_AQ
:
100 case ZONE_ID_GATES_OF_AQ
:
101 return m_scripts
[OPVP_ID_SI
];
102 case ZONE_ID_STRATHOLME
:
103 case ZONE_ID_SCHOLOMANCE
:
104 return m_scripts
[OPVP_ID_EP
];
105 case ZONE_ID_HELLFIRE_RAMPARTS
:
106 case ZONE_ID_HELLFIRE_CITADEL
:
107 case ZONE_ID_BLOOD_FURNACE
:
108 case ZONE_ID_SHATTERED_HALLS
:
109 case ZONE_ID_MAGTHERIDON_LAIR
:
110 return m_scripts
[OPVP_ID_HP
];
111 case ZONE_ID_SERPENTSHRINE_CAVERN
:
112 case ZONE_ID_STREAMVAULT
:
113 case ZONE_ID_UNDERBOG
:
114 case ZONE_ID_SLAVE_PENS
:
115 return m_scripts
[OPVP_ID_ZM
];
116 case ZONE_ID_SHADOW_LABYRINTH
:
117 case ZONE_ID_AUCHENAI_CRYPTS
:
118 case ZONE_ID_SETHEKK_HALLS
:
119 case ZONE_ID_MANA_TOMBS
:
120 return m_scripts
[OPVP_ID_TF
];
127 Function that handles the players which enters a specific zone
129 @param player to be handled in the event
130 @param zone id used for the current outdoor pvp script
132 void OutdoorPvPMgr::HandlePlayerEnterZone(Player
* player
, uint32 zoneId
)
134 if (OutdoorPvP
* script
= GetScript(zoneId
))
135 script
->HandlePlayerEnterZone(player
, true);
136 else if (OutdoorPvP
* script
= GetScriptOfAffectedZone(zoneId
))
137 script
->HandlePlayerEnterZone(player
, false);
141 Function that handles the player who leaves a specific zone
143 @param player to be handled in the event
144 @param zone id used for the current outdoor pvp script
146 void OutdoorPvPMgr::HandlePlayerLeaveZone(Player
* player
, uint32 zoneId
)
148 // teleport: called once from Player::CleanupsBeforeDelete, once from Player::UpdateZone
149 if (OutdoorPvP
* script
= GetScript(zoneId
))
150 script
->HandlePlayerLeaveZone(player
, true);
151 else if (OutdoorPvP
* script
= GetScriptOfAffectedZone(zoneId
))
152 script
->HandlePlayerLeaveZone(player
, false);
155 void OutdoorPvPMgr::Update(uint32 diff
)
157 m_updateTimer
.Update(diff
);
158 if (!m_updateTimer
.Passed())
161 for (uint8 i
= 0; i
< MAX_OPVP_ID
; ++i
)
163 m_scripts
[i
]->Update(m_updateTimer
.GetCurrent());
165 m_updateTimer
.Reset();
169 Function that gets the capture point slider value
171 @param capture point entry
172 @param default value being returned if no saved value for the capture point was found
174 float OutdoorPvPMgr::GetCapturePointSliderValue(uint32 entry
, float defaultValue
)
176 CapturePointSliderMap::const_iterator itr
= m_capturePointSlider
.find(entry
);
177 if (itr
!= m_capturePointSlider
.end())
180 // return default value if we can't find any