TrinityCore
Loading...
Searching...
No Matches
OutdoorPvPSI.cpp
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#include "OutdoorPvPSI.h"
19#include "DBCStores.h"
20#include "GameObject.h"
21#include "Language.h"
22#include "Map.h"
23#include "ObjectMgr.h"
24#include "OutdoorPvPMgr.h"
25#include "Player.h"
26#include "ReputationMgr.h"
27#include "ScriptMgr.h"
28#include "World.h"
29#include "WorldStatePackets.h"
30
39
47
54
61
68
77
79{
80 return false;
81}
82
84{
85 if (player->GetTeam() == m_LastController)
86 player->CastSpell(player, SI_CENARION_FAVOR, true);
88}
89
91{
92 // remove buffs
95}
96
98{
99 switch (trigger)
100 {
101 case SI_AREATRIGGER_A:
102 if (player->GetTeam() == ALLIANCE && player->HasAura(SI_SILITHYST_FLAG))
103 {
104 // remove aura
106 ++ m_Gathered_A;
108 {
111 m_map->SendZoneText(OutdoorPvPSIBuffZones[0], sObjectMgr->GetTrinityStringForDBCLocale(LANG_OPVP_SI_CAPTURE_A));
113 m_Gathered_A = 0;
114 m_Gathered_H = 0;
115 }
117 // reward player
118 player->CastSpell(player, SI_TRACES_OF_SILITHYST, true);
119 // add 19 honor
120 player->RewardHonor(nullptr, 1, 19);
121 // add 20 cenarion circle repu
122 player->GetReputationMgr().ModifyReputation(sFactionStore.LookupEntry(609), 20);
123 // complete quest
125 }
126 return true;
127 case SI_AREATRIGGER_H:
128 if (player->GetTeam() == HORDE && player->HasAura(SI_SILITHYST_FLAG))
129 {
130 // remove aura
132 ++ m_Gathered_H;
134 {
137 m_map->SendZoneText(OutdoorPvPSIBuffZones[0], sObjectMgr->GetTrinityStringForDBCLocale(LANG_OPVP_SI_CAPTURE_H));
139 m_Gathered_A = 0;
140 m_Gathered_H = 0;
141 }
143 // reward player
144 player->CastSpell(player, SI_TRACES_OF_SILITHYST, true);
145 // add 19 honor
146 player->RewardHonor(nullptr, 1, 19);
147 // add 20 cenarion circle repu
148 player->GetReputationMgr().ModifyReputation(sFactionStore.LookupEntry(609), 20);
149 // complete quest
151 }
152 return true;
153 }
154 return false;
155}
156
158{
159 if (spellId == SI_SILITHYST_FLAG)
160 {
161 // if it was dropped away from the player's turn-in point, then create a silithyst mound, if it was dropped near the areatrigger, then it was dispelled by the outdoorpvp, so do nothing
162 switch (player->GetTeam())
163 {
164 case ALLIANCE:
165 {
166 AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(SI_AREATRIGGER_A);
167 if (atEntry)
168 {
169 // 5.0f is safe-distance
170 if (player->GetDistance(atEntry->Pos.X, atEntry->Pos.Y, atEntry->Pos.Z) > 5.0f + atEntry->Radius)
171 {
172 // he dropped it further, summon mound
173 GameObject* go = new GameObject;
174 Map* map = player->GetMap();
175
177 {
178 delete go;
179 return true;
180 }
181
182 go->SetRespawnTime(0);
183
184 if (!map->AddToMap(go))
185 {
186 delete go;
187 return true;
188 }
189 }
190 }
191 break;
192 }
193 case HORDE:
194 {
195 AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(SI_AREATRIGGER_H);
196 if (atEntry)
197 {
198 // 5.0f is safe-distance
199 if (player->GetDistance(atEntry->Pos.X, atEntry->Pos.Y, atEntry->Pos.Z) > 5.0f + atEntry->Radius)
200 {
201 // he dropped it further, summon mound
202 GameObject* go = new GameObject;
203 Map* map = player->GetMap();
204
206 {
207 delete go;
208 return true;
209 }
210
211 go->SetRespawnTime(0);
212
213 if (!map->AddToMap(go))
214 {
215 delete go;
216 return true;
217 }
218 }
219 }
220 break;
221 }
222 }
223 return true;
224 }
225 return false;
226}
227
229{
230 if (!go || spellId != SI_SILITHYST_FLAG_GO_SPELL)
231 return false;
232 player->CastSpell(player, SI_SILITHYST_FLAG, true);
233 if (go->GetGOInfo()->entry == SI_SILITHYST_MOUND)
234 {
235 // despawn go
236 go->SetRespawnTime(0);
237 go->Delete();
238 }
239 return true;
240}
241
243{
244 public:
245 OutdoorPvP_silithus() : OutdoorPvPScript("outdoorpvp_si") { }
246
247 OutdoorPvP* GetOutdoorPvP() const override
248 {
249 return new OutdoorPvPSI();
250 }
251};
252
254{
256}
DBCStorage< FactionEntry > sFactionStore(FactionEntryfmt)
DBCStorage< AreaTriggerEntry > sAreaTriggerStore(AreaTriggerEntryfmt)
uint8_t uint8
Definition Define.h:135
uint32_t uint32
Definition Define.h:133
@ LANG_OPVP_SI_CAPTURE_A
Definition Language.h:1206
@ LANG_OPVP_SI_CAPTURE_H
Definition Language.h:1205
#define sObjectMgr
Definition ObjectMgr.h:1721
uint32 const SI_SILITHYST_MOUND
uint32 const SI_AREATRIGGER_H
uint32 const SI_AREATRIGGER_A
uint32 const SI_TURNIN_QUEST_CM_A
uint32 const SI_MAX_RESOURCES
void AddSC_outdoorpvp_si()
uint32 const SI_TURNIN_QUEST_CM_H
uint8 const OutdoorPvPSIBuffZonesNum
uint32 const OutdoorPvPSIBuffZones[OutdoorPvPSIBuffZonesNum]
@ SI_CENARION_FAVOR
@ SI_SILITHYST_FLAG
@ SI_TRACES_OF_SILITHYST
@ SI_SILITHYST_FLAG_GO_SPELL
@ SI_GATHERED_H
@ SI_SILITHYST_MAX
@ SI_GATHERED_A
@ OUTDOOR_PVP_SI
Definition OutdoorPvP.h:33
@ TEAM_ALLIANCE
@ TEAM_HORDE
@ ALLIANCE
@ HORDE
@ GO_STATE_READY
GameObjectTemplate const * GetGOInfo() const
Definition GameObject.h:102
void Delete()
void SetRespawnTime(int32 respawn)
bool Create(ObjectGuid::LowType guidlow, uint32 name_id, Map *map, uint32 phaseMask, Position const &pos, QuaternionData const &rotation, uint32 animprogress, GOState go_state, uint32 artKit=0, bool dynamic=false, ObjectGuid::LowType spawnid=0)
Definition Map.h:281
void SendZoneText(uint32 zoneId, const char *text, WorldSession const *self=nullptr, uint32 team=0) const
Send a System Message to all players in the zone (except self if mentioned)
Definition Map.cpp:4757
bool AddToMap(T *)
Definition Map.cpp:630
ObjectGuid::LowType GenerateLowGuid()
Definition Map.h:587
bool HandleCustomSpell(Player *player, uint32 spellId, GameObject *go) override
uint32 m_LastController
bool SetupOutdoorPvP() override
bool Update(uint32 diff) override
void FillInitialWorldStates(WorldPackets::WorldState::InitWorldStates &packet) override
bool HandleAreaTrigger(Player *player, uint32 trigger) override
void UpdateWorldState()
bool HandleDropFlag(Player *player, uint32 spellId) override
void HandlePlayerLeaveZone(Player *player, uint32 zone) override
void SendRemoveWorldStates(Player *player) override
uint32 m_Gathered_A
uint32 m_Gathered_H
void HandlePlayerEnterZone(Player *player, uint32 zone) override
OutdoorPvP * GetOutdoorPvP() const override
virtual void HandlePlayerEnterZone(Player *player, uint32 zone)
uint32 m_TypeId
Definition OutdoorPvP.h:273
void TeamApplyBuff(TeamId team, uint32 spellId, uint32 spellId2=0)
void RegisterZone(uint32 zoneid)
virtual void HandlePlayerLeaveZone(Player *player, uint32 zone)
void SendUpdateWorldState(uint32 field, uint32 value)
void SetMapFromZone(uint32 zone)
Map * m_map
Definition OutdoorPvP.h:314
void KilledMonsterCredit(uint32 entry, ObjectGuid guid=ObjectGuid::Empty)
Definition Player.cpp:16140
uint32 GetTeam() const
Definition Player.h:1832
void SendUpdateWorldState(uint32 variable, uint32 value) const
Definition Player.cpp:8493
bool RewardHonor(Unit *victim, uint32 groupsize, int32 honor=-1, bool pvptoken=false)
Definition Player.cpp:6524
ReputationMgr & GetReputationMgr()
Definition Player.h:1848
bool ModifyReputation(FactionEntry const *factionEntry, int32 standing, bool spillOverOnly=false)
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition Unit.cpp:4535
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3784
uint32 GetPhaseMask() const
Definition Object.h:368
Map * GetMap() const
Definition Object.h:449
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2832
float GetDistance(WorldObject const *obj) const
Definition Object.cpp:1123
std::vector< WorldStateInfo > Worldstates
DBCPosition3D Pos