TrinityCore
Loading...
Searching...
No Matches
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 "Map.h"
21#include "ObjectAccessor.h"
22#include "PassiveAI.h"
23#include "pit_of_saron.h"
24#include "Player.h"
25#include "ScriptedCreature.h"
26#include "SpellScript.h"
27#include "Vehicle.h"
28
30{
31 SPELL_FIREBALL = 69583, //Ymirjar Flamebearer
34 SPELL_FROST_BREATH = 69527, //Iceborn Proto-Drake
35 SPELL_LEAPING_FACE_MAUL = 69504, // Geist Ambusher
36};
37
39{
40 // Ymirjar Flamebearer
43};
44
57
59{
61 {
62 }
63
64 void Reset() override
65 {
66 _events.Reset();
67 }
68
74
75 void UpdateAI(uint32 diff) override
76 {
77 if (!UpdateVictim())
78 return;
79
80 _events.Update(diff);
81
83 return;
84
85 while (uint32 eventId = _events.ExecuteEvent())
86 {
87 switch (eventId)
88 {
89 case EVENT_FIREBALL:
91 DoCast(target, SPELL_FIREBALL);
93 break;
99 break;
100 default:
101 break;
102 }
103 }
104
106 }
107
108private:
110};
111
113{
115 {
116 Initialize();
117 }
118
120 {
122 }
123
124 void Reset() override
125 {
126 Initialize();
127 }
128
129 void JustEngagedWith(Unit* /*who*/) override
130 {
131 if (Vehicle* _vehicle = me->GetVehicleKit())
132 _vehicle->RemoveAllPassengers();
133 }
134
135 void UpdateAI(uint32 diff) override
136 {
137 if (!UpdateVictim())
138 return;
139
140 if (_frostBreathCooldown < diff)
141 {
143 _frostBreathCooldown = 10000;
144 }
145 else
146 _frostBreathCooldown -= diff;
147
149 }
150
151private:
153};
154
156{
158 {
159 Initialize();
160 }
161
163 {
165 }
166
167 void Reset() override
168 {
169 Initialize();
170 }
171
172 void JustEngagedWith(Unit* who) override
173 {
174 if (who->GetTypeId() != TYPEID_PLAYER)
175 return;
176
177 // the max range is determined by aggro range
178 if (me->GetDistance(who) > 5.0f)
180 }
181
182 void UpdateAI(uint32 diff) override
183 {
184 if (!UpdateVictim())
185 return;
186
187 if (_leapingFaceMaulCooldown < diff)
188 {
189 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 5.0f, true))
191 _leapingFaceMaulCooldown = urand(9000, 14000);
192 }
193 else
195
197 }
198
199private:
201};
202
204{
209
210 void IsSummonedBy(WorldObject* summoner) override
211 {
212 _summonerGUID = summoner->GetGUID();
213
214 _scheduler.Schedule(Milliseconds(3650), [this](TaskContext /*context*/)
215 {
218
220 caster->RemoveDynObject(SPELL_ICICLE_SUMMON);
221 });
222 }
223
224 void UpdateAI(uint32 diff) override
225 {
226 _scheduler.Update(diff);
227 }
228
229private:
232};
233
234// 70827 - Ice Shards
236{
238
239 bool Load() override
240 {
241 // This script should execute only in Pit of Saron
243 }
244
250
255};
256
261
263{
264 public:
265 at_pit_cavern_entrance() : AreaTriggerScript("at_pit_cavern_entrance") { }
266
267 bool OnTrigger(Player* player, AreaTriggerEntry const* /*areaTrigger*/) override
268 {
269 if (InstanceScript* instance = player->GetInstanceScript())
270 {
271 if (instance->GetData(DATA_CAVERN_ACTIVE))
272 return true;
273
274 instance->SetData(DATA_CAVERN_ACTIVE, 1);
275
276 if (Creature* tyrannus = ObjectAccessor::GetCreature(*player, instance->GetGuidData(DATA_TYRANNUS_EVENT)))
277 tyrannus->AI()->Talk(SAY_TYRANNUS_CAVERN_ENTRANCE);
278 }
279 return true;
280 }
281};
282
284{
285public:
286 at_pit_cavern_end() : AreaTriggerScript("at_pit_cavern_end") { }
287
288 bool OnTrigger(Player* player, AreaTriggerEntry const* /*areaTrigger*/) override
289 {
290 if (InstanceScript* instance = player->GetInstanceScript())
291 {
292 instance->SetData(DATA_CAVERN_ACTIVE, 0);
293
294 if (!instance->GetData(DATA_ICE_SHARDS_HIT))
295 instance->DoUpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, SPELL_DONT_LOOK_UP_ACHIEV_CREDIT, 0, player);
296 }
297
298 return true;
299 }
300};
301
TC_GAME_API bool InstanceHasScript(WorldObject const *obj, char const *scriptName)
@ ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET
Definition DBCEnums.h:154
uint64_t uint64
Definition Define.h:132
uint32_t uint32
Definition Define.h:133
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition Duration.h:24
@ TYPEID_PLAYER
Definition ObjectGuid.h:39
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:1128
SpellEffIndex
@ EFFECT_0
@ SPELL_EFFECT_SCHOOL_DAMAGE
#define SpellEffectFn(F, I, N)
@ UNIT_STATE_CASTING
Definition Unit.h:235
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
void SetDisplayId(uint32 modelId) override
CreatureTemplate const * GetCreatureTemplate() const
Definition Creature.h:186
void Update(uint32 time)
Definition EventMap.h:67
EventId ExecuteEvent()
Definition EventMap.cpp:73
void RescheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:52
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:36
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:93
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:78
bool Execute(uint64, uint32) override
Player * GetHitPlayer() const
Unit * GetCaster() const
HookList< EffectHandler > OnEffectHitTarget
TaskScheduler & Schedule(std::chrono::duration< _Rep, _Period > const &time, task_handler_t const &task)
TaskScheduler & Update(success_t const &callback=EmptyCallback)
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:241
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.cpp:166
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition UnitAI.cpp:96
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:106
Definition Unit.h:769
bool HasUnitState(const uint32 f) const
Definition Unit.h:876
Vehicle * GetVehicleKit() const
Definition Unit.h:1735
InstanceScript * GetInstanceScript() const
Definition Object.cpp:1087
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2832
EventProcessor m_Events
Definition Object.h:591
float GetDistance(WorldObject const *obj) const
Definition Object.cpp:1123
virtual void SetData(uint32, uint32)
Definition ZoneScript.h:56
bool OnTrigger(Player *player, AreaTriggerEntry const *) override
bool OnTrigger(Player *player, AreaTriggerEntry const *) override
void Register() override
PrepareSpellScript(spell_pos_ice_shards)
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)
@ SPELL_DONT_LOOK_UP_ACHIEV_CREDIT
@ SPELL_ICICLE_FALL_VISUAL
@ SPELL_ICICLE_FALL_TRIGGER
@ SPELL_ICICLE_SUMMON
#define PoSScriptName
@ DATA_CAVERN_ACTIVE
@ DATA_ICE_SHARDS_HIT
@ DATA_TYRANNUS_EVENT
npc_geist_ambusher(Creature *creature)
void Reset() override
void JustEngagedWith(Unit *who) override
void UpdateAI(uint32 diff) override
void JustEngagedWith(Unit *) 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 JustEngagedWith(Unit *) override
npc_ymirjar_flamebearer(Creature *creature)