TrinityCore
Loading...
Searching...
No Matches
boss_ormorok.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 "GameObject.h"
20#include "nexus.h"
21#include "ScriptedCreature.h"
22#include "SpellScript.h"
23
46
54
56{
57 public:
58 OrmorokTanglerPredicate(Unit* unit) : me(unit) { }
59
60 bool operator() (WorldObject* object) const
61 {
62 return object->GetDistance2d(me) >= 5.0f;
63 }
64
65 private:
67};
68
69struct boss_ormorok : public BossAI
70{
71 boss_ormorok(Creature* creature) : BossAI(creature, DATA_ORMOROK)
72 {
73 Initialize();
74 }
75
77 {
78 frenzy = false;
79 }
80
81 void Reset() override
82 {
84 Initialize();
85 }
86
99
100 void DamageTaken(Unit* /*attacker*/, uint32& /*damage*/, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
101 {
102 if (!frenzy && HealthBelowPct(25))
103 {
106 frenzy = true;
107 }
108 }
109
110 void JustDied(Unit* /*killer*/) override
111 {
112 _JustDied();
114 }
115
116 void KilledUnit(Unit* who) override
117 {
118 if (who->GetTypeId() == TYPEID_PLAYER)
119 Talk(SAY_KILL);
120 }
121
122 void UpdateAI(uint32 diff) override
123 {
124 if (!UpdateVictim())
125 return;
126
127 events.Update(diff);
128
130 return;
131
132 while (uint32 eventId = events.ExecuteEvent())
133 {
134 switch (eventId)
135 {
136 case EVENT_TRAMPLE:
139 break;
144 break;
149 break;
154 break;
155 default:
156 break;
157 }
158
160 return;
161 }
162
164 }
165
166private:
167 bool frenzy;
168
169};
170
184
186{
187 47936,
188 47942,
189 47943
190};
191
193{
195 {
196 _count = 0;
197 _despawntimer = 0;
198 }
199
200 void IsSummonedBy(WorldObject* owner) override
201 {
202 switch (me->GetEntry())
203 {
205 _count = 0;
206 me->SetFacingToObject(owner);
208 break;
211 if (Creature* trigger = owner->ToCreature())
212 _count = trigger->AI()->GetData(DATA_COUNT) + 1;
213 break;
214 default:
216 break;
217 }
218
221 trap->Use(me);
222
223 _despawntimer = 2000;
224 }
225
226 uint32 GetData(uint32 type) const override
227 {
228 return type == DATA_COUNT ? _count : 0;
229 }
230
231 void UpdateAI(uint32 diff) override
232 {
233 if (_despawntimer <= diff)
234 {
237 trap->Delete();
238
240 }
241 else
242 _despawntimer -= diff;
243 }
244
245private:
248
249};
250
255
256// 47958, 57082 - Crystal Spikes
258{
260
261 bool Validate(SpellInfo const* /*spellInfo*/) override
262 {
264 }
265
266 void HandleScript(SpellEffIndex /*effIndex*/)
267 {
268 Unit* caster = GetCaster();
269 for (uint32 spells : SummonSpells)
270 caster->CastSpell(caster, spells);
271 }
272
277};
278
279// 47941 - Crystal Spike
281{
283
284 void HandlePeriodic(AuraEffect const* /*aurEff*/)
285 {
286 Unit* target = GetTarget();
288 if (Creature* trigger = target->ToCreature())
289 {
291 if (trigger->AI()->GetData(DATA_COUNT) < MAX_COUNT)
292 trigger->CastSpell(trigger, spell, true);
293 }
294 }
295
300};
301
uint32_t uint32
Definition Define.h:133
@ TYPEID_PLAYER
Definition ObjectGuid.h:39
Spells
Definition PlayerAI.cpp:32
uint32 urand(uint32 min, uint32 max)
Definition Random.cpp:42
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1128
SpellEffIndex
@ EFFECT_0
@ SPELL_EFFECT_SCRIPT_EFFECT
@ SPELL_AURA_PERIODIC_DUMMY
#define SpellEffectFn(F, I, N)
#define AuraEffectPeriodicFn(F, I, N)
@ UNIT_STATE_CASTING
Definition Unit.h:235
DamageEffectType
Definition Unit.h:352
@ SAY_DEATH
@ SAY_CRYSTAL_SPIKES
@ SAY_REFLECT
@ SAY_AGGRO
@ SAY_KILL
@ SAY_FRENZY
@ SPELL_TRAMPLE
@ SPELL_CRYSTAL_SPIKES
@ SPELL_SUMMON_CRYSTAL_SPIKE_2
@ SPELL_SUMMON_CRYSTAL_SPIKE_3
@ SPELL_SUMMON_CRYSTAL_SPIKE_1
@ SPELL_SUMMON_CRYSTAL_SPIKE_4
@ SPELL_FRENZY
@ SPELL_SPELL_REFLECTION
@ SPELL_SUMMON_CRYSTALLINE_TANGLER
std::array< uint32, 4 > const SummonSpells
void AddSC_boss_ormorok()
uint32 const crystalSpikeSummon[3]
CrystalSpikes
@ NPC_CRYSTAL_SPIKE_INITIAL
@ SPELL_CRYSTAL_SPIKE_AURA
@ NPC_CRYSTAL_SPIKE_TRIGGER
@ GO_CRYSTAL_SPIKE_TRAP
@ DATA_COUNT
@ MAX_COUNT
@ SPELL_CRYSTAL_SPIKE_DAMAGE
@ EVENT_CRYSTALLINE_TANGLER
@ EVENT_SPELL_REFLECTION
@ EVENT_CRYSTAL_SPIKES
@ EVENT_TRAMPLE
Yells
HookList< EffectPeriodicHandler > OnEffectPeriodic
Unit * GetTarget() const
void JustEngagedWith(Unit *who) override
EventMap events
void Reset() override
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
void Update(uint32 time)
Definition EventMap.h:67
EventId ExecuteEvent()
Definition EventMap.cpp:73
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:36
static Creature * ToCreature(Object *o)
Definition Object.h:186
TypeID GetTypeId() const
Definition Object.h:93
uint32 GetEntry() const
Definition Object.h:81
bool operator()(WorldObject *object) const
OrmorokTanglerPredicate(Unit *unit)
Unit * GetCaster() const
HookList< EffectHandler > OnEffectHit
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
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
void SetFacingToObject(WorldObject const *object, bool force=true, uint32 movementId=EVENT_FACE)
Definition Unit.cpp:13259
bool HasUnitState(const uint32 f) const
Definition Unit.h:876
GameObject * FindNearestGameObject(uint32 entry, float range, bool spawnedOnly=true) const
Definition Object.cpp:2121
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2832
float GetDistance2d(WorldObject const *obj) const
Definition Object.cpp:1141
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
PrepareAuraScript(spell_ormorok_crystal_spike)
void HandlePeriodic(AuraEffect const *)
PrepareSpellScript(spell_ormorok_summon_crystal_spikes)
bool Validate(SpellInfo const *) override
@ DATA_ORMOROK
Definition nexus.h:33
#define RegisterNexusCreatureAI(ai_name)
Definition nexus.h:74
bool IsHeroic() const
bool HealthBelowPct(uint32 pct) const
void UpdateAI(uint32 diff) override
void JustEngagedWith(Unit *who) override
void KilledUnit(Unit *who) override
void Reset() override
boss_ormorok(Creature *creature)
void DamageTaken(Unit *, uint32 &, DamageEffectType, SpellInfo const *) override
void JustDied(Unit *) override
void UpdateAI(uint32 diff) override
uint32 GetData(uint32 type) const override
npc_crystal_spike_trigger(Creature *creature)
void IsSummonedBy(WorldObject *owner) override