TrinityCore
pit_of_saron.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 "InstanceScript.h"
20#include "ObjectAccessor.h"
21#include "PassiveAI.h"
22#include "pit_of_saron.h"
23#include "Player.h"
24#include "ScriptedCreature.h"
25#include "SpellScript.h"
26#include "Vehicle.h"
27
29{
30 SPELL_FIREBALL = 69583, //Ymirjar Flamebearer
33 SPELL_FROST_BREATH = 69527, //Iceborn Proto-Drake
34 SPELL_LEAPING_FACE_MAUL = 69504, // Geist Ambusher
35};
36
38{
39 // Ymirjar Flamebearer
42};
43
45{
46 if (roll_chance_i(12))
47 {
50 }
51 else
53
54 return true;
55}
56
58{
60 {
61 }
62
63 void Reset() override
64 {
65 _events.Reset();
66 }
67
68 void JustEngagedWith(Unit* /*who*/) override
69 {
72 }
73
74 void UpdateAI(uint32 diff) override
75 {
76 if (!UpdateVictim())
77 return;
78
79 _events.Update(diff);
80
82 return;
83
84 while (uint32 eventId = _events.ExecuteEvent())
85 {
86 switch (eventId)
87 {
88 case EVENT_FIREBALL:
90 DoCast(target, SPELL_FIREBALL);
92 break;
98 break;
99 default:
100 break;
101 }
102 }
103 }
104
105private:
107};
108
110{
112 {
113 Initialize();
114 }
115
117 {
119 }
120
121 void Reset() override
122 {
123 Initialize();
124 }
125
126 void JustEngagedWith(Unit* /*who*/) override
127 {
128 if (Vehicle* _vehicle = me->GetVehicleKit())
129 _vehicle->RemoveAllPassengers();
130 }
131
132 void UpdateAI(uint32 diff) override
133 {
134 if (!UpdateVictim())
135 return;
136
137 if (_frostBreathCooldown < diff)
138 {
140 _frostBreathCooldown = 10000;
141 }
142 else
143 _frostBreathCooldown -= diff;
144 }
145
146private:
148};
149
151{
153 {
154 Initialize();
155 }
156
158 {
160 }
161
162 void Reset() override
163 {
164 Initialize();
165 }
166
167 void JustEngagedWith(Unit* who) override
168 {
169 if (who->GetTypeId() != TYPEID_PLAYER)
170 return;
171
172 // the max range is determined by aggro range
173 if (me->GetDistance(who) > 5.0f)
175 }
176
177 void UpdateAI(uint32 diff) override
178 {
179 if (!UpdateVictim())
180 return;
181
182 if (_leapingFaceMaulCooldown < diff)
183 {
184 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 5.0f, true))
186 _leapingFaceMaulCooldown = urand(9000, 14000);
187 }
188 else
190 }
191
192private:
194};
195
197{
199 {
201 }
202
203 void IsSummonedBy(WorldObject* summoner) override
204 {
205 _summonerGUID = summoner->GetGUID();
206
207 _scheduler.Schedule(Milliseconds(3650), [this](TaskContext /*context*/)
208 {
211
213 caster->RemoveDynObject(SPELL_ICICLE_SUMMON);
214 });
215 }
216
217 void UpdateAI(uint32 diff) override
218 {
219 _scheduler.Update(diff);
220 }
221
222private:
225};
226
227// 70827 - Ice Shards
229{
230 bool Load() override
231 {
232 // This script should execute only in Pit of Saron
234 }
235
237 {
238 if (GetHitPlayer())
240 }
241
242 void Register() override
243 {
245 }
246};
247
249{
252
254{
255 public:
256 at_pit_cavern_entrance() : AreaTriggerScript("at_pit_cavern_entrance") { }
257
258 bool OnTrigger(Player* player, AreaTriggerEntry const* /*areaTrigger*/) override
259 {
260 if (InstanceScript* instance = player->GetInstanceScript())
261 {
262 if (instance->GetData(DATA_CAVERN_ACTIVE))
263 return true;
264
265 instance->SetData(DATA_CAVERN_ACTIVE, 1);
266
267 if (Creature* tyrannus = ObjectAccessor::GetCreature(*player, instance->GetGuidData(DATA_TYRANNUS_EVENT)))
268 tyrannus->AI()->Talk(SAY_TYRANNUS_CAVERN_ENTRANCE);
269 }
270 return true;
271 }
272};
273
275{
276public:
277 at_pit_cavern_end() : AreaTriggerScript("at_pit_cavern_end") { }
278
279 bool OnTrigger(Player* player, AreaTriggerEntry const* /*areaTrigger*/) override
280 {
281 if (InstanceScript* instance = player->GetInstanceScript())
282 {
283 instance->SetData(DATA_CAVERN_ACTIVE, 0);
284
285 if (!instance->GetData(DATA_ICE_SHARDS_HIT))
286 instance->DoUpdateCriteria(CriteriaType::BeSpellTarget, SPELL_DONT_LOOK_UP_ACHIEV_CREDIT, 0, player);
287 }
288
289 return true;
290 }
291};
292
294{
301 new at_pit_cavern_end();
302}
TC_GAME_API bool InstanceHasScript(WorldObject const *obj, char const *scriptName)
uint64_t uint64
Definition: Define.h:141
uint32_t uint32
Definition: Define.h:142
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition: Duration.h:29
@ TYPEID_PLAYER
Definition: ObjectGuid.h:41
Spells
Definition: PlayerAI.cpp:32
Milliseconds randtime(Milliseconds min, Milliseconds max)
Definition: Random.cpp:62
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:42
bool roll_chance_i(int chance)
Definition: Random.h:59
#define RegisterSpellScript(spell_script)
Definition: ScriptMgr.h:1369
SpellEffIndex
Definition: SharedDefines.h:29
@ EFFECT_0
Definition: SharedDefines.h:30
@ SPELL_EFFECT_SCHOOL_DAMAGE
#define SpellEffectFn(F, I, N)
Definition: SpellScript.h:842
@ UNIT_STATE_CASTING
Definition: Unit.h:270
bool UpdateVictim()
Definition: CreatureAI.cpp:245
Creature *const me
Definition: CreatureAI.h:61
void SetDisplayFromModel(uint32 modelIdx)
Definition: Creature.cpp:3413
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 RescheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition: EventMap.cpp:52
void Reset()
Definition: EventMap.cpp:21
void AddEvent(BasicEvent *event, Milliseconds e_time, bool set_addtime=true)
Milliseconds CalculateTime(Milliseconds t_offset) const
TypeID GetTypeId() const
Definition: Object.h:173
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
ScheduledIcicleSummons(Creature *trigger)
Definition: pit_of_saron.h:118
bool Execute(uint64, uint32) override
Player * GetHitPlayer() const
Unit * GetCaster() const
HookList< EffectHandler > OnEffectHitTarget
Definition: SpellScript.h:840
TaskScheduler & Schedule(std::chrono::duration< Rep, Period > time, task_handler_t task)
TaskScheduler & Update(success_t const &callback=nullptr)
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.h:159
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.cpp:180
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition: UnitAI.cpp:79
SpellCastResult DoCast(uint32 spellId)
Definition: UnitAI.cpp:89
Definition: Unit.h:627
bool HasUnitState(const uint32 f) const
Definition: Unit.h:732
Vehicle * GetVehicleKit() const
Definition: Unit.h:1711
InstanceScript * GetInstanceScript() const
Definition: Object.cpp:1042
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2896
EventProcessor m_Events
Definition: Object.h:777
float GetDistance(WorldObject const *obj) const
Definition: Object.cpp:1078
virtual void SetData(uint32, uint32)
Definition: ZoneScript.h:92
bool OnTrigger(Player *player, AreaTriggerEntry const *) override
bool OnTrigger(Player *player, AreaTriggerEntry const *) override
void Register() override
void HandleScriptEffect(SpellEffIndex)
bool Load() override
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
TyrannusEventCavernEmote
@ SAY_TYRANNUS_CAVERN_ENTRANCE
@ SPELL_FROST_BREATH
@ SPELL_HELLFIRE
@ SPELL_TACTICAL_BLINK
@ SPELL_FIREBALL
@ SPELL_LEAPING_FACE_MAUL
void AddSC_pit_of_saron()
@ EVENT_FIREBALL
@ EVENT_TACTICAL_BLINK
#define RegisterPitOfSaronCreatureAI(ai_name)
Definition: pit_of_saron.h:132
#define PoSScriptName
Definition: pit_of_saron.h:24
@ DATA_CAVERN_ACTIVE
Definition: pit_of_saron.h:44
@ DATA_ICE_SHARDS_HIT
Definition: pit_of_saron.h:43
@ DATA_TYRANNUS_EVENT
Definition: pit_of_saron.h:41
@ SPELL_DONT_LOOK_UP_ACHIEV_CREDIT
Definition: pit_of_saron.h:110
@ SPELL_ICICLE_FALL_VISUAL
Definition: pit_of_saron.h:109
@ SPELL_ICICLE_FALL_TRIGGER
Definition: pit_of_saron.h:108
@ SPELL_ICICLE_SUMMON
Definition: pit_of_saron.h:107
npc_geist_ambusher(Creature *creature)
void Reset() override
void JustEngagedWith(Unit *who) override
void UpdateAI(uint32 diff) override
uint32 _leapingFaceMaulCooldown
void JustEngagedWith(Unit *) override
void Reset() override
npc_iceborn_protodrake(Creature *creature)
void UpdateAI(uint32 diff) override
void IsSummonedBy(WorldObject *summoner) override
npc_pit_of_saron_icicle(Creature *creature)
void UpdateAI(uint32 diff) override
void UpdateAI(uint32 diff) override
void Reset() override
void JustEngagedWith(Unit *) override
npc_ymirjar_flamebearer(Creature *creature)