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 "DB2Stores.h"
20#include "GameObject.h"
21#include "Language.h"
22#include "Map.h"
23#include "ObjectMgr.h"
24#include "PhasingHandler.h"
25#include "Player.h"
26#include "ReputationMgr.h"
27#include "ScriptMgr.h"
28#include "World.h"
29#include "WorldStatePackets.h"
30
31constexpr int32 SI_MAX_RESOURCES = 200;
39
45
47{
49 initWorldStates.MapID = player->GetMapId();
50 initWorldStates.AreaID = player->GetZoneId();
51 initWorldStates.SubareaID = player->GetAreaId();
52 initWorldStates.Worldstates.emplace_back(SI_GATHERED_A, 0);
53 initWorldStates.Worldstates.emplace_back(SI_GATHERED_H, 0);
54 initWorldStates.Worldstates.emplace_back(SI_SILITHYST_MAX, 0);
55 player->SendDirectMessage(initWorldStates.Write());
56}
57
68
70{
71}
72
74{
75 if (player->GetTeam() == m_LastController)
76 player->CastSpell(player, SI_CENARION_FAVOR, true);
78}
79
81{
82 // remove buffs
85}
86
87bool OutdoorPvPSI::HandleAreaTrigger(Player* player, uint32 trigger, bool /*entered*/)
88{
89 switch (trigger)
90 {
92 if (player->GetTeam() == ALLIANCE && player->HasAura(SI_SILITHYST_FLAG))
93 {
94 // remove aura
96 int32 newScore = GetWorldState(SI_GATHERED_A) + 1;
97 if (newScore >= SI_MAX_RESOURCES)
98 {
101 sWorld->SendZoneText(OutdoorPvPSIBuffZones[0], sObjectMgr->GetTrinityStringForDBCLocale(LANG_OPVP_SI_CAPTURE_A));
103 newScore = 0;
105 }
106 SetWorldState(SI_GATHERED_A, newScore);
107 // reward player
108 player->CastSpell(player, SI_TRACES_OF_SILITHYST, true);
109 // add 19 honor
110 player->RewardHonor(nullptr, 1, 19, HonorGainSource::TeamContribution);
111 // add 20 cenarion circle repu
112 player->GetReputationMgr().ModifyReputation(sFactionStore.LookupEntry(609), 20);
113 // complete quest
115 }
116 return true;
117 case SI_AREATRIGGER_H:
118 if (player->GetTeam() == HORDE && player->HasAura(SI_SILITHYST_FLAG))
119 {
120 // remove aura
122 int32 newScore = GetWorldState(SI_GATHERED_H) + 1;
123 if (newScore >= SI_MAX_RESOURCES)
124 {
127 sWorld->SendZoneText(OutdoorPvPSIBuffZones[0], sObjectMgr->GetTrinityStringForDBCLocale(LANG_OPVP_SI_CAPTURE_H));
130 newScore = 0;
131 }
132 SetWorldState(SI_GATHERED_H, newScore);
133 // reward player
134 player->CastSpell(player, SI_TRACES_OF_SILITHYST, true);
135 // add 19 honor
136 player->RewardHonor(nullptr, 1, 19, HonorGainSource::TeamContribution);
137 // add 20 cenarion circle repu
138 player->GetReputationMgr().ModifyReputation(sFactionStore.LookupEntry(609), 20);
139 // complete quest
141 }
142 return true;
143 }
144 return false;
145}
146
148{
149 if (spellId == SI_SILITHYST_FLAG)
150 {
151 // 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
152 if (AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(player->GetTeam() == ALLIANCE ? SI_AREATRIGGER_A : SI_AREATRIGGER_H))
153 {
154 // 5.0f is safe-distance
155 if (player->GetDistance(atEntry->Pos.X, atEntry->Pos.Y, atEntry->Pos.Z) > 5.0f + atEntry->Radius)
156 {
157 // he dropped it further, summon mound
158 Map* map = player->GetMap();
160 {
162 go->SetRespawnTime(0);
163
164 if (!map->AddToMap(go))
165 {
166 delete go;
167 return true;
168 }
169 }
170 }
171 }
172 return true;
173 }
174 return false;
175}
176
178{
179 if (!go || spellId != SI_SILITHYST_FLAG_GO_SPELL)
180 return false;
181 player->CastSpell(player, SI_SILITHYST_FLAG, true);
182 if (go->GetGOInfo()->entry == SI_SILITHYST_MOUND)
183 {
184 // despawn go
185 go->SetRespawnTime(0);
186 go->Delete();
187 }
188 return true;
189}
190
192{
193 public:
194 OutdoorPvP_silithus() : OutdoorPvPScript("outdoorpvp_si") { }
195
196 OutdoorPvP* GetOutdoorPvP(Map* map) const override
197 {
198 return new OutdoorPvPSI(map);
199 }
200};
201
203{
205}
DB2Storage< AreaTriggerEntry > sAreaTriggerStore("AreaTrigger.db2", &AreaTriggerLoadInfo::Instance)
DB2Storage< FactionEntry > sFactionStore("Faction.db2", &FactionLoadInfo::Instance)
uint8_t uint8
Definition Define.h:156
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
@ LANG_OPVP_SI_CAPTURE_A
Definition Language.h:1212
@ LANG_OPVP_SI_CAPTURE_H
Definition Language.h:1211
#define sObjectMgr
Definition ObjectMgr.h:1885
uint32 const SI_SILITHYST_MOUND
uint32 const SI_AREATRIGGER_H
uint32 const SI_AREATRIGGER_A
uint32 const SI_TURNIN_QUEST_CM_A
void AddSC_outdoorpvp_si()
uint32 const SI_TURNIN_QUEST_CM_H
uint8 const OutdoorPvPSIBuffZonesNum
uint32 const OutdoorPvPSIBuffZones[OutdoorPvPSIBuffZonesNum]
constexpr int32 SI_MAX_RESOURCES
@ 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:34
@ TEAM_ALLIANCE
@ TEAM_HORDE
@ TEAM_OTHER
@ ALLIANCE
@ HORDE
@ GO_STATE_READY
GameObjectTemplate const * GetGOInfo() const
Definition GameObject.h:203
static GameObject * CreateGameObject(uint32 entry, Map *map, Position const &pos, QuaternionData const &rotation, uint32 animProgress, GOState goState, uint32 artKit=0)
void SetRespawnTime(int32 respawn)
Definition Map.h:225
bool AddToMap(T *)
Definition Map.cpp:517
bool HandleCustomSpell(Player *player, uint32 spellId, GameObject *go) override
bool HandleAreaTrigger(Player *player, uint32 trigger, bool entered) override
bool SetupOutdoorPvP() override
bool HandleDropFlag(Player *player, uint32 spellId) override
void Update(uint32 diff) override
void HandlePlayerLeaveZone(Player *player, uint32 zone) override
void SendRemoveWorldStates(Player *player) override
OutdoorPvPSI(Map *map)
void HandlePlayerEnterZone(Player *player, uint32 zone) override
Team m_LastController
OutdoorPvP * GetOutdoorPvP(Map *map) const override
virtual void HandlePlayerEnterZone(Player *player, uint32 zone)
uint32 m_TypeId
Definition OutdoorPvP.h:208
int32 GetWorldState(int32 worldStateId) const
void TeamApplyBuff(TeamId team, uint32 spellId, uint32 spellId2=0)
void RegisterZone(uint32 zoneid)
void SetWorldState(int32 worldStateId, int32 value)
virtual void HandlePlayerLeaveZone(Player *player, uint32 zone)
static void InheritPhaseShift(WorldObject *target, WorldObject const *source)
void KilledMonsterCredit(uint32 entry, ObjectGuid guid=ObjectGuid::Empty)
Definition Player.cpp:16679
bool RewardHonor(Unit *victim, uint32 groupsize, int32 honor=-1, HonorGainSource source=HonorGainSource::Kill)
Definition Player.cpp:6763
void SendDirectMessage(WorldPacket const *data) const
Definition Player.cpp:6283
ReputationMgr & GetReputationMgr()
Definition Player.h:2439
Team GetTeam() const
Definition Player.h:2423
bool ModifyReputation(FactionEntry const *factionEntry, int32 standing, bool spillOverOnly=false, bool noSpillover=false)
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition Unit.cpp:4804
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3974
constexpr uint32 GetMapId() const
Definition Position.h:216
Map * GetMap() const
Definition Object.h:411
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2217
float GetDistance(WorldObject const *obj) const
Definition Object.cpp:432
uint32 GetAreaId() const
Definition Object.h:333
uint32 GetZoneId() const
Definition Object.h:332
std::vector< WorldStateInfo > Worldstates
#define sWorld
Definition World.h:916
constexpr float GetOrientation() const
Definition Position.h:90
static QuaternionData fromEulerAnglesZYX(float Z, float Y, float X)