OregonCore  revision 3611e8a-git
Your Favourite TBC server
OutdoorPvPSI.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of the OregonCore 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 "WorldPacket.h"
20 #include "Player.h"
21 #include "GameObject.h"
22 #include "MapManager.h"
23 #include "ObjectMgr.h"
24 #include "OutdoorPvPMgr.h"
25 #include "Language.h"
26 #include "World.h"
27 
29 {
31  m_Gathered_A = 0;
32  m_Gathered_H = 0;
33  m_LastController = 0;
34 }
35 
37 {
38  data << SI_GATHERED_A << m_Gathered_A;
39  data << SI_GATHERED_H << m_Gathered_H;
41 }
42 
44 {
48 }
49 
51 {
55 }
56 
58 {
59  for (uint8 i = 0; i < OutdoorPvPSIBuffZonesNum; ++i)
61  return true;
62 }
63 
65 {
66  return false;
67 }
68 
70 {
71  if (plr->GetTeam() == m_LastController)
72  plr->CastSpell(plr, SI_CENARION_FAVOR, true);
74 }
75 
77 {
78  // remove buffs
81 }
82 
84 {
85  switch (trigger)
86  {
87  case SI_AREATRIGGER_A:
88  if (plr->GetTeam() == ALLIANCE && plr->HasAura(SI_SILITHYST_FLAG, 0))
89  {
90  // remove aura
92  ++ m_Gathered_A;
94  {
96  sWorld.SendZoneText(OutdoorPvPSIBuffZones[0], sObjectMgr.GetOregonStringForDBCLocale(LANG_OPVP_SI_CAPTURE_A));
98  m_Gathered_A = 0;
99  m_Gathered_H = 0;
100  }
102  // reward player
103  plr->CastSpell(plr, SI_TRACES_OF_SILITHYST, true);
104  // add 19 honor
105  plr->RewardHonor(NULL, 1, 19);
106  // add 20 cenarion circle repu
107  plr->GetReputationMgr().ModifyReputation(sFactionStore.LookupEntry(609), 20);
108  // complete quest
110  }
111  return true;
112  case SI_AREATRIGGER_H:
113  if (plr->GetTeam() == HORDE && plr->HasAura(SI_SILITHYST_FLAG, 0))
114  {
115  // remove aura
117  ++ m_Gathered_H;
119  {
121  sWorld.SendZoneText(OutdoorPvPSIBuffZones[0], sObjectMgr.GetOregonStringForDBCLocale(LANG_OPVP_SI_CAPTURE_H));
123  m_Gathered_A = 0;
124  m_Gathered_H = 0;
125  }
127  // reward player
128  plr->CastSpell(plr, SI_TRACES_OF_SILITHYST, true);
129  // add 19 honor
130  plr->RewardHonor(NULL, 1, 19);
131  // add 20 cenarion circle repu
132  plr->GetReputationMgr().ModifyReputation(sFactionStore.LookupEntry(609), 20);
133  // complete quest
135  }
136  return true;
137  }
138  return false;
139 }
140 
142 {
143  if (spellId == SI_SILITHYST_FLAG)
144  {
145  // 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
146  switch (plr->GetTeam())
147  {
148  case ALLIANCE:
149  {
150  AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(SI_AREATRIGGER_A);
151  if (atEntry)
152  {
153  // 5.0f is safe-distance
154  if (plr->GetDistance(atEntry->x, atEntry->y, atEntry->z) > 5.0f + atEntry->radius)
155  {
156  // he dropped it further, summon mound
157  GameObject* go = new GameObject;
158  Map* map = plr->GetMap();
159  if (!map)
160  {
161  delete go;
162  return true;
163  }
164 
165  if (!go->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), SI_SILITHYST_MOUND, map, plr->GetPositionX(), plr->GetPositionY(), plr->GetPositionZ(), plr->GetOrientation(), 0, 0, 0, 0, 100, GO_STATE_READY))
166  delete go;
167  else
168  {
169  go->SetRespawnTime(0);
170  map->AddToMap(go);
171  }
172  }
173  }
174  }
175  break;
176  case HORDE:
177  {
178  AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(SI_AREATRIGGER_H);
179  if (atEntry)
180  {
181  // 5.0f is safe-distance
182  if (plr->GetDistance(atEntry->x, atEntry->y, atEntry->z) > 5.0f + atEntry->radius)
183  {
184  // he dropped it further, summon mound
185  GameObject* go = new GameObject;
186  Map* map = plr->GetMap();
187  if (!map)
188  {
189  delete go;
190  return true;
191  }
192  if (!go->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), SI_SILITHYST_MOUND, map , plr->GetPositionX(), plr->GetPositionY(), plr->GetPositionZ(), plr->GetOrientation(), 0, 0, 0, 0, 100, GO_STATE_READY))
193  delete go;
194  else
195  {
196  go->SetRespawnTime(0);
197  map->AddToMap(go);
198  }
199  }
200  }
201  }
202  break;
203  }
204  return true;
205  }
206  return false;
207 }
208 
210 {
211  if (!go || spellId != SI_SILITHYST_FLAG_GO_SPELL)
212  return false;
213  plr->CastSpell(plr, SI_SILITHYST_FLAG, true);
214  if (go->GetGOInfo()->id == SI_SILITHYST_MOUND)
215  {
216  // despawn go
217  go->SetRespawnTime(0);
218  go->Delete();
219  }
220  return true;
221 }
222 
void TeamApplyBuff(TeamId team, uint32 spellId, uint32 spellId2=0)
Definition: OutdoorPvP.cpp:564
void HandlePlayerEnterZone(Player *plr, uint32 zone)
bool Update(uint32 diff)
virtual void HandlePlayerEnterZone(Player *plr, uint32 zone)
Definition: OutdoorPvP.cpp:237
void KilledMonsterCredit(uint32 entry, uint64 guid=0)
Definition: Player.cpp:13867
void SendUpdateWorldState(uint32 Field, uint32 Value)
Definition: Player.cpp:7713
Map * GetMap() const
Definition: Object.h:829
const uint32 SI_MAX_RESOURCES
Definition: OutdoorPvPSI.h:31
const uint8 OutdoorPvPSIBuffZonesNum
Definition: OutdoorPvPSI.h:33
uint32 m_Gathered_A
Definition: OutdoorPvPSI.h:81
DBCStorage< AreaTriggerEntry > sAreaTriggerStore(AreaTriggerEntryfmt)
void UpdateWorldState()
bool HandleAreaTrigger(Player *plr, uint32 trigger)
void SetRespawnTime(int32 respawn)
Definition: GameObject.h:691
#define sObjectMgr
Definition: ObjectMgr.h:1285
const uint32 SI_TURNIN_QUEST_CM_A
Definition: OutdoorPvPSI.h:41
bool Create(uint32 guidlow, uint32 name_id, Map *map, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 animprogress, GOState go_state, uint32 ArtKit=0)
Definition: GameObject.cpp:166
const uint32 SI_AREATRIGGER_A
Definition: OutdoorPvPSI.h:39
void RemoveAurasDueToSpell(uint32 spellId, Aura *except=NULL)
Definition: Unit.cpp:4316
ACE_UINT8 uint8
Definition: Define.h:73
float GetOrientation() const
Definition: Position.h:100
void FillInitialWorldStates(WorldPacket &data)
float GetDistance(const WorldObject *obj) const
Definition: Object.h:706
float GetPositionY() const
Definition: Position.h:98
bool SetupOutdoorPvP()
void CastSpell(Unit *Victim, uint32 spellId, bool triggered, Item *castItem=NULL, Aura *triggeredByAura=NULL, uint64 originalCaster=0)
Definition: Unit.cpp:1174
const uint32 OutdoorPvPSIBuffZones[OutdoorPvPSIBuffZonesNum]
Definition: OutdoorPvPSI.h:35
float GetPositionZ() const
Definition: Position.h:99
void RegisterZone(uint32 zoneid)
Definition: OutdoorPvP.cpp:544
void SendRemoveWorldStates(Player *plr)
Definition: Map.h:266
virtual void HandlePlayerLeaveZone(Player *plr, uint32 zone)
Definition: OutdoorPvP.cpp:242
uint32 m_Gathered_H
Definition: OutdoorPvPSI.h:82
ReputationMgr & GetReputationMgr()
Definition: Player.h:2091
bool RewardHonor(Unit *victim, uint32 groupsize, float honor=-1, bool pvptoken=false)
Definition: Player.cpp:6057
void HandlePlayerLeaveZone(Player *plr, uint32 zone)
const uint32 SI_SILITHYST_MOUND
Definition: OutdoorPvPSI.h:45
uint32 m_TypeId
Definition: OutdoorPvP.h:234
GameObjectInfo const * GetGOInfo() const
Definition: GameObject.h:591
bool HandleCustomSpell(Player *plr, uint32 spellId, GameObject *go)
DBCStorage< FactionEntry > sFactionStore(FactionEntryfmt)
uint32 GetTeam() const
Definition: Player.h:2075
#define sWorld
Definition: World.h:860
bool ModifyReputation(FactionEntry const *factionEntry, int32 standing)
ACE_UINT32 uint32
Definition: Define.h:71
float GetPositionX() const
Definition: Position.h:97
void SendUpdateWorldState(uint32 field, uint32 value)
Definition: OutdoorPvP.cpp:384
uint32 m_LastController
Definition: OutdoorPvPSI.h:84
Definition: Player.h:922
const uint32 SI_AREATRIGGER_H
Definition: OutdoorPvPSI.h:37
bool HandleDropFlag(Player *plr, uint32 spellId)
const uint32 SI_TURNIN_QUEST_CM_H
Definition: OutdoorPvPSI.h:43
void Delete()
Definition: GameObject.cpp:562
bool HasAura(uint32 spellId, uint8 effIndex=0) const
Definition: Unit.h:1342