Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
OutdoorPvPSI.cpp
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6#include "ScriptMgr.h"
7#include "OutdoorPvPSI.h"
8#include "WorldPacket.h"
9#include "Player.h"
10#include "GameObject.h"
11#include "MapManager.h"
12#include "ObjectMgr.h"
13#include "OutdoorPvPMgr.h"
14#include "ReputationMgr.h"
15#include "Language.h"
16#include "World.h"
17
25
32
39
46
48{
49 for (uint8 i = 0; i < OutdoorPvPSIBuffZonesNum; ++i)
51 return true;
52}
53
55{
56 return false;
57}
58
60{
61 if (player->GetTeam() == m_LastController)
62 player->CastSpell(player, SI_CENARION_FAVOR, true);
64}
65
67{
68 // remove buffs
71}
72
74{
75 switch (trigger)
76 {
78 if (player->GetTeam() == ALLIANCE && player->HasAura(SI_SILITHYST_FLAG))
79 {
80 // remove aura
82 ++ m_Gathered_A;
84 {
86 sWorld->SendZoneText(OutdoorPvPSIBuffZones[0], sObjectMgr->GetSkyFireStringForDBCLocale(LANG_OPVP_SI_CAPTURE_A));
88 m_Gathered_A = 0;
89 m_Gathered_H = 0;
90 }
92 // reward player
93 player->CastSpell(player, SI_TRACES_OF_SILITHYST, true);
94 // add 19 honor
95 player->RewardHonor(NULL, 1, 19);
96 // add 20 cenarion circle repu
97 player->GetReputationMgr().ModifyReputation(sFactionStore.LookupEntry(609), 20);
98 // complete quest
100 }
101 return true;
102 case SI_AREATRIGGER_H:
103 if (player->GetTeam() == HORDE && player->HasAura(SI_SILITHYST_FLAG))
104 {
105 // remove aura
107 ++ m_Gathered_H;
109 {
111 sWorld->SendZoneText(OutdoorPvPSIBuffZones[0], sObjectMgr->GetSkyFireStringForDBCLocale(LANG_OPVP_SI_CAPTURE_H));
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(NULL, 1, 19);
121 // add 20 cenarion circle repu
122 player->GetReputationMgr().ModifyReputation(sFactionStore.LookupEntry(609), 20);
123 // complete quest
125 }
126 return true;
127 }
128 return false;
129}
130
132{
133 if (spellId == SI_SILITHYST_FLAG)
134 {
135 // 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
136 switch (player->GetTeam())
137 {
138 case ALLIANCE:
139 {
140 AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(SI_AREATRIGGER_A);
141 if (atEntry)
142 {
143 // 5.0f is safe-distance
144 if (player->GetDistance(atEntry->x, atEntry->y, atEntry->z) > 5.0f + atEntry->radius)
145 {
146 // he dropped it further, summon mound
147 GameObject* go = new GameObject;
148 Map* map = player->GetMap();
149 if (!map)
150 {
151 delete go;
152 return true;
153 }
154
155 if (!go->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT), SI_SILITHYST_MOUND, map, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetOrientation(), 0, 0, 0, 0, 100, GOState::GO_STATE_READY))
156 {
157 delete go;
158 return true;
159 }
160
161 for (auto phase : player->GetPhases())
162 go->SetPhased(phase, false, true);
163
164 go->SetRespawnTime(0);
165
166 if (!map->AddToMap(go))
167 {
168 delete go;
169 return true;
170 }
171 }
172 }
173 }
174 break;
175 case HORDE:
176 {
177 AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(SI_AREATRIGGER_H);
178 if (atEntry)
179 {
180 // 5.0f is safe-distance
181 if (player->GetDistance(atEntry->x, atEntry->y, atEntry->z) > 5.0f + atEntry->radius)
182 {
183 // he dropped it further, summon mound
184 GameObject* go = new GameObject;
185 Map* map = player->GetMap();
186 if (!map)
187 {
188 delete go;
189 return true;
190 }
191
192 if (!go->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT), SI_SILITHYST_MOUND, map, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetOrientation(), 0, 0, 0, 0, 100, GOState::GO_STATE_READY))
193 {
194 delete go;
195 return true;
196 }
197
198 for (auto phase : player->GetPhases())
199 go->SetPhased(phase, false, true);
200
201 go->SetRespawnTime(0);
202
203 if (!map->AddToMap(go))
204 {
205 delete go;
206 return true;
207 }
208 }
209 }
210 }
211 break;
212 }
213 return true;
214 }
215 return false;
216}
217
219{
220 if (!go || spellId != SI_SILITHYST_FLAG_GO_SPELL)
221 return false;
222 player->CastSpell(player, SI_SILITHYST_FLAG, true);
223 if (go->GetGOInfo()->entry == SI_SILITHYST_MOUND)
224 {
225 // despawn go
226 go->SetRespawnTime(0);
227 go->Delete();
228 }
229 return true;
230}
231
233{
234 public:
235 OutdoorPvP_silithus() : OutdoorPvPScript("outdoorpvp_si") { }
236
238 {
239 return new OutdoorPvPSI();
240 }
241};
242
244{
246}
DBCStorage< FactionEntry > sFactionStore(FactionEntryfmt)
DBCStorage< AreaTriggerEntry > sAreaTriggerStore(AreaTriggerEntryfmt)
std::uint8_t uint8
Definition Define.h:79
std::uint32_t uint32
Definition Define.h:77
#define OVERRIDE
Definition Define.h:60
@ GO_STATE_READY
Definition GameObject.h:577
@ LANG_OPVP_SI_CAPTURE_A
Definition Language.h:1208
@ LANG_OPVP_SI_CAPTURE_H
Definition Language.h:1207
@ HIGHGUID_GAMEOBJECT
#define sObjectMgr
Definition ObjectMgr.h:1617
@ OUTDOOR_PVP_SI
Definition OutdoorPvP.h:22
void AddSC_outdoorpvp_si()
const uint32 OutdoorPvPSIBuffZones[OutdoorPvPSIBuffZonesNum]
const uint32 SI_TURNIN_QUEST_CM_A
const uint32 SI_SILITHYST_MOUND
@ SI_CENARION_FAVOR
@ SI_SILITHYST_FLAG
@ SI_TRACES_OF_SILITHYST
@ SI_SILITHYST_FLAG_GO_SPELL
const uint32 SI_MAX_RESOURCES
const uint8 OutdoorPvPSIBuffZonesNum
const uint32 SI_AREATRIGGER_H
const uint32 SI_AREATRIGGER_A
@ SI_GATHERED_H
@ SI_SILITHYST_MAX
@ SI_GATHERED_A
const uint32 SI_TURNIN_QUEST_CM_H
@ TEAM_ALLIANCE
@ TEAM_HORDE
@ ALLIANCE
@ HORDE
GameObjectTemplate const * GetGOInfo() const
Definition GameObject.h:643
void Delete()
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)
void SetRespawnTime(int32 respawn)
Definition GameObject.h:699
bool SetPhased(uint32 id, bool update, bool apply) OVERRIDE
Definition Map.h:238
bool AddToMap(T *)
Definition Map.cpp:504
OutdoorPvP * GetOutdoorPvP() const OVERRIDE
virtual void HandlePlayerEnterZone(Player *player, uint32 zone)
uint32 m_TypeId
Definition OutdoorPvP.h:242
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)
bool HandleDropFlag(Player *player, uint32 spellId) OVERRIDE
uint32 m_LastController
void FillInitialWorldStates(WorldStateBuilder &builder) OVERRIDE
bool SetupOutdoorPvP() OVERRIDE
void SendRemoveWorldStates(Player *player) OVERRIDE
void UpdateWorldState()
void HandlePlayerLeaveZone(Player *player, uint32 zone) OVERRIDE
bool Update(uint32 diff) OVERRIDE
uint32 m_Gathered_A
uint32 m_Gathered_H
bool HandleAreaTrigger(Player *player, uint32 trigger) OVERRIDE
bool HandleCustomSpell(Player *player, uint32 spellId, GameObject *go) OVERRIDE
void HandlePlayerEnterZone(Player *player, uint32 zone) OVERRIDE
OutdoorPvPScript(const char *name)
uint32 GetTeam() const
Definition Player.h:2527
void KilledMonsterCredit(uint32 entry, uint64 guid=0)
void SendUpdateWorldState(uint32 Field, uint32 Value)
Definition Player.cpp:9734
bool RewardHonor(Unit *victim, uint32 groupsize, int32 honor=-1, bool pvptoken=false)
Definition Player.cpp:7316
ReputationMgr & GetReputationMgr()
Definition Player.h:2555
bool ModifyReputation(FactionEntry const *factionEntry, int32 standing)
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, uint64 originalCaster=0)
void RemoveAurasDueToSpell(uint32 spellId, uint64 casterGUID=0, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
bool HasAura(uint32 spellId, uint64 casterGUID=0, uint64 itemCasterGUID=0, uint32 reqEffMask=0) const
Map * GetMap() const
Definition Object.h:740
std::set< uint32 > const & GetPhases() const
Definition Object.h:647
float GetDistance(WorldObject const *obj) const
Definition Object.cpp:1666
void AppendState(uint32 worldstate, uint32 value)
#define sWorld
Definition World.h:910
float radius
float z
float y
float x
float GetPositionZ() const
Definition Object.h:330
float GetOrientation() const
Definition Object.h:331
float GetPositionX() const
Definition Object.h:328
float GetPositionY() const
Definition Object.h:329