TrinityCore
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 "ScriptMgr.h"
19#include "BattlegroundAV.h"
20#include "GameObject.h"
21#include "GameObjectAI.h"
22#include "Player.h"
23#include "ScriptedCreature.h"
24
25#include <chrono>
26
28{
29 SPELL_CHARGE = 22911,
30 SPELL_CLEAVE = 40504,
33 SPELL_WHIRLWIND = 13736
34};
35
37{
46};
47
49{
56};
57
59{
61
62 void Reset() override
63 {
64 events.Reset();
71 }
72
73 void JustAppeared() override
74 {
75 Reset();
76 }
77
78 void UpdateAI(uint32 diff) override
79 {
80 if (!UpdateVictim())
81 return;
82
83 events.Update(diff);
84
86 return;
87
88 while (uint32 eventId = events.ExecuteEvent())
89 {
90 switch (eventId)
91 {
95 break;
96 case EVENT_CLEAVE:
99 break;
103 break;
104 case EVENT_WHIRLWIND:
107 break;
108 case EVENT_ENRAGE:
111 break;
113 {
114 Position const& _homePosition = me->GetHomePosition();
115 if (me->GetDistance2d(_homePosition.GetPositionX(), _homePosition.GetPositionY()) > 50.0f)
116 {
118 return;
119 }
121 break;
122 }
123 }
125 return;
126 }
127 }
128
129private:
131};
132
134{
136
137 void Reset() override
138 {
139 me->setActive(true);
140 }
141
142 bool OnGossipHello(Player* player) override
143 {
144 if (me->GetGoState() != GO_STATE_READY)
145 return true;
146
147 if (ZoneScript* zonescript = me->GetZoneScript())
148 {
149 zonescript->DoAction(ACTION_AV_INTERACT_CAPTURABLE_OBJECT, player, me);
150 return false;
151 }
152
153 return true;
154 }
155};
156
158{
160
161 void Reset() override
162 {
165 {
166 if (ZoneScript* zonescript = me->GetZoneScript())
167 zonescript->DoAction(ACTION_AV_CAPTURE_CAPTURABLE_OBJECT, me, me);
168 });
169 }
170
171 void UpdateAI(uint32 diff) override
172 {
173 _scheduler.Update(diff);
174 }
175
176private:
178};
179
181{
182public:
183 at_av_exploit() : AreaTriggerScript("at_av_exploit") { }
184
185 bool OnTrigger(Player* player, AreaTriggerEntry const* /*trigger*/) override
186 {
187 if (Battleground* battleground = player->GetBattleground())
188 if (battleground->GetStatus() == STATUS_WAIT_JOIN)
189 battleground->TeleportPlayerToExploitLocation(player);
190
191 return true;
192 }
193};
194
196{
200 new at_av_exploit();
201}
@ ACTION_AV_INTERACT_CAPTURABLE_OBJECT
@ ACTION_AV_CAPTURE_CAPTURABLE_OBJECT
@ STATUS_WAIT_JOIN
Definition: Battleground.h:166
uint32_t uint32
Definition: Define.h:142
Spells
Definition: PlayerAI.cpp:32
#define RegisterCreatureAI(ai_name)
Definition: ScriptMgr.h:1380
#define RegisterGameObjectAI(ai_name)
Definition: ScriptMgr.h:1398
@ EVENT_CHARGE
@ GO_STATE_READY
@ UNIT_STATE_CASTING
Definition: Unit.h:270
@ 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
virtual void EnterEvadeMode(EvadeReason why=EvadeReason::Other)
Definition: CreatureAI.cpp:219
bool UpdateVictim()
Definition: CreatureAI.cpp:245
Creature *const me
Definition: CreatureAI.h:61
void GetHomePosition(float &x, float &y, float &z, float &ori) const
Definition: Creature.h:373
uint32 ExecuteEvent()
Definition: EventMap.cpp:73
void Update(uint32 time)
Definition: EventMap.h:56
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition: EventMap.cpp:36
void Reset()
Definition: EventMap.cpp:21
GameObject *const me
Definition: GameObjectAI.h:50
GOState GetGoState() const
Definition: GameObject.h:281
Battleground * GetBattleground() const
Definition: Player.cpp:24976
TaskScheduler & Schedule(std::chrono::duration< Rep, Period > time, task_handler_t task)
TaskScheduler & Update(success_t const &callback=nullptr)
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:732
ZoneScript * GetZoneScript() const
Definition: Object.h:630
void setActive(bool isActiveObject)
Definition: Object.cpp:922
float GetDistance2d(WorldObject const *obj) const
Definition: Object.cpp:1096
bool OnTrigger(Player *player, AreaTriggerEntry const *) override
constexpr float GetPositionX() const
Definition: Position.h:76
constexpr float GetPositionY() const
Definition: Position.h:77
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)