TrinityCore
Loading...
Searching...
No Matches
alterac_valley.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 "alterac_valley.h"
19#include "ScriptMgr.h"
20#include "Battleground.h"
21#include "GameObject.h"
22#include "GameObjectAI.h"
23#include "Player.h"
24#include "ScriptedCreature.h"
25
26#include <chrono>
27
36
48
58
60{
62
73
74 void JustAppeared() override
75 {
76 Reset();
77 }
78
79 void UpdateAI(uint32 diff) override
80 {
81 if (!UpdateVictim())
82 return;
83
84 events.Update(diff);
85
87 return;
88
89 while (uint32 eventId = events.ExecuteEvent())
90 {
91 switch (eventId)
92 {
96 break;
97 case EVENT_CLEAVE:
100 break;
104 break;
105 case EVENT_WHIRLWIND:
108 break;
109 case EVENT_ENRAGE:
112 break;
114 {
115 Position const& _homePosition = me->GetHomePosition();
116 if (me->GetDistance2d(_homePosition.GetPositionX(), _homePosition.GetPositionY()) > 50.0f)
117 {
119 return;
120 }
122 break;
123 }
124 }
126 return;
127 }
128 }
129
130private:
132};
133
135{
137
138 void Reset() override
139 {
140 me->setActive(true);
141 }
142
143 bool OnGossipHello(Player* player) override
144 {
145 if (me->GetGoState() != GO_STATE_READY)
146 return true;
147
148 if (ZoneScript* zonescript = me->GetZoneScript())
149 {
150 zonescript->DoAction(ACTION_AV_INTERACT_CAPTURABLE_OBJECT, player, me);
151 return false;
152 }
153
154 return true;
155 }
156};
157
159{
161
162 void Reset() override
163 {
165 _scheduler.Schedule(4min, [&](TaskContext const&)
166 {
167 if (ZoneScript* zonescript = me->GetZoneScript())
168 zonescript->DoAction(ACTION_AV_CAPTURE_CAPTURABLE_OBJECT, me, me);
169 });
170 }
171
172 void UpdateAI(uint32 diff) override
173 {
174 _scheduler.Update(diff);
175 }
176
177private:
179};
180
182{
183public:
184 at_av_exploit() : AreaTriggerScript("at_av_exploit") { }
185
186 bool OnTrigger(Player* player, AreaTriggerEntry const* /*trigger*/) override
187 {
188 if (Battleground* battleground = player->GetBattleground())
189 if (battleground->GetStatus() == STATUS_WAIT_JOIN)
190 battleground->TeleportPlayerToExploitLocation(player);
191
192 return true;
193 }
194};
195
196template<AlteracValleySharedActions ActionId>
198{
199public:
200 quest_alterac_valley(char const* scriptName) : QuestScript(scriptName) { }
201
202 void OnQuestStatusChange(Player* player, Quest const* /*quest*/, QuestStatus /*oldStatus*/, QuestStatus newStatus) override
203 {
204 if (newStatus != QUEST_STATUS_REWARDED)
205 return;
206
207 if (ZoneScript* zoneScript = player->FindZoneScript())
208 zoneScript->DoAction(ActionId, player, player);
209 }
210};
211
213{
217 new at_av_exploit();
218 new quest_alterac_valley<ACTION_TURN_IN_SCRAPS>("quest_alterac_valley_armor_scraps");
219 new quest_alterac_valley<ACTION_TURN_IN_COMMANDER_1>("quest_alterac_valley_call_of_air_slidore_guse");
220 new quest_alterac_valley<ACTION_TURN_IN_COMMANDER_2>("quest_alterac_valley_call_of_air_vipore_jeztor");
221 new quest_alterac_valley<ACTION_TURN_IN_COMMANDER_3>("quest_alterac_valley_call_of_air_ichman_mulverick");
222 new quest_alterac_valley<ACTION_TURN_IN_BOSS_1>("quest_alterac_valley_boss_5");
223 new quest_alterac_valley<ACTION_TURN_IN_BOSS_2>("quest_alterac_valley_boss_1");
224 new quest_alterac_valley<ACTION_TURN_IN_NEAR_MINE>("quest_alterac_valley_near_mine");
225 new quest_alterac_valley<ACTION_TURN_IN_OTHER_MINE>("quest_alterac_valley_other_mine");
226 new quest_alterac_valley<ACTION_TURN_IN_RIDER_HIDE>("quest_alterac_valley_ram_harnesses");
227 new quest_alterac_valley<ACTION_TURN_IN_RIDER_TAME>("quest_alterac_valley_empty_stables");
228}
@ STATUS_WAIT_JOIN
uint32_t uint32
Definition Define.h:154
Spells
Definition PlayerAI.cpp:32
QuestStatus
Definition QuestDef.h:146
@ QUEST_STATUS_REWARDED
Definition QuestDef.h:153
#define RegisterCreatureAI(ai_name)
Definition ScriptMgr.h:1392
#define RegisterGameObjectAI(ai_name)
Definition ScriptMgr.h:1410
@ EVENT_CHARGE
@ GO_STATE_READY
@ UNIT_STATE_CASTING
Definition Unit.h:276
Creatures
@ NPC_EAST_FROSTWOLF_WARMASTER
@ NPC_TOWER_POINT_WARMASTER
@ NPC_ICEWING_MARSHAL
@ NPC_ICEBLOOD_WARMASTER
@ NPC_SOUTH_MARSHAL
@ NPC_NORTH_MARSHAL
@ NPC_WEST_FROSTWOLF_WARMASTER
@ NPC_STONEHEARTH_MARSHAL
void AddSC_alterac_valley()
@ SPELL_CLEAVE
@ SPELL_ENRAGE
@ SPELL_CHARGE
@ SPELL_DEMORALIZING_SHOUT
@ SPELL_WHIRLWIND
@ EVENT_ENRAGE
@ EVENT_WHIRLWIND
@ EVENT_CHECK_RESET
@ EVENT_DEMORALIZING_SHOUT
@ EVENT_CLEAVE
@ EVENT_CHARGE_TARGET
@ ACTION_AV_INTERACT_CAPTURABLE_OBJECT
@ ACTION_AV_CAPTURE_CAPTURABLE_OBJECT
virtual void EnterEvadeMode(EvadeReason why=EvadeReason::Other)
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:63
void GetHomePosition(float &x, float &y, float &z, float &ori) const
Definition Creature.h:388
uint32 ExecuteEvent()
Definition EventMap.cpp:77
void Update(uint32 time)
Definition EventMap.h:61
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition EventMap.cpp:40
void Reset()
Definition EventMap.cpp:25
GameObject *const me
GOState GetGoState() const
Definition GameObject.h:284
Battleground * GetBattleground() const
Definition Player.cpp:25719
TaskScheduler & Schedule(duration_t time, task_handler_t task)
TaskScheduler & Update()
Update the scheduler to the current time.
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.cpp:180
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:89
bool HasUnitState(const uint32 f) const
Definition Unit.h:743
ZoneScript * FindZoneScript() const
Definition Object.cpp:1365
ZoneScript * GetZoneScript() const
Definition Object.h:417
void setActive(bool isActiveObject)
Definition Object.cpp:276
float GetDistance2d(WorldObject const *obj) const
Definition Object.cpp:450
bool OnTrigger(Player *player, AreaTriggerEntry const *) override
void OnQuestStatusChange(Player *player, Quest const *, QuestStatus, QuestStatus newStatus) override
quest_alterac_valley(char const *scriptName)
constexpr float GetPositionX() const
Definition Position.h:87
constexpr float GetPositionY() const
Definition Position.h:88
go_av_capturable_object(GameObject *go)
bool OnGossipHello(Player *player) override
void UpdateAI(uint32 diff) override
go_av_contested_object(GameObject *go)
void UpdateAI(uint32 diff) override
npc_av_marshal_or_warmaster(Creature *creature)