TrinityCore
Loading...
Searching...
No Matches
boss_omor_the_unscarred.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/*
19 * Combat timers requires to be revisited
20 */
21
22#include "ScriptMgr.h"
23#include "Containers.h"
24#include "hellfire_ramparts.h"
25#include "Player.h"
26#include "ScriptedCreature.h"
27#include "SpellAuraEffects.h"
28#include "SpellInfo.h"
29#include "SpellScript.h"
30
40
54
63
64// 17308 - Omor the Unscarred
66{
68
69 void Reset() override
70 {
71 _Reset();
72
73 _demonicShieldUsed = false;
74 }
75
87
88 void AttackStart(Unit* who) override
89 {
91 }
92
93 void OnSpellCast(SpellInfo const* spellInfo) override
94 {
95 switch (spellInfo->Id)
96 {
98 if (roll_chance(30))
100 break;
103 break;
104 default:
105 break;
106 }
107 }
108
109 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
110 {
111 if (!_demonicShieldUsed && me->HealthBelowPctDamaged(20, damage))
112 {
113 _demonicShieldUsed = true;
115 }
116 }
117
118 void JustSummoned(Creature* summoned) override
119 {
120 // Engage but don't despawn hounds
121 if (me->IsEngaged())
122 DoZoneInCombat(summoned);
123 }
124
125 void KilledUnit(Unit* /*victim*/) override
126 {
127 Talk(SAY_SLAY);
128 }
129
130 void JustDied(Unit* /*killer*/) override
131 {
132 _JustDied();
134 }
135
136 void UpdateAI(uint32 diff) override
137 {
138 if (!UpdateVictim())
139 return;
140
141 events.Update(diff);
142
144 return;
145
146 while (uint32 eventId = events.ExecuteEvent())
147 {
148 switch (eventId)
149 {
153 events.Repeat(6s, 10s);
154 else
155 events.Repeat(3s, 4s);
156 break;
160 events.Repeat(30s, 40s);
161 break;
164 events.Repeat(20s, 26s);
165 break;
168 events.Repeat(23s, 30s);
169 break;
172 break;
173 default:
174 break;
175 }
176
178 return;
179 }
180 }
181
182private:
184};
185
186// 35642 - Orbital Strike Target
188{
189 bool Validate(SpellInfo const* /*spellInfo*/) override
190 {
192 }
193
194 void FilterTargets(std::list<WorldObject*>& targets)
195 {
196 if (targets.size() <= 1)
197 return;
198
199 Unit* caster = GetCaster();
200 targets.remove_if([caster](WorldObject const* target)
201 {
202 return caster->GetExactDist2d(target) > 20.0f;
203 });
204
206 _canContinue = true;
207 }
208
209 void HandleDummy(SpellEffIndex /*effIndex*/)
210 {
211 if (!_canContinue)
212 return;
213
214 Unit* caster = GetCaster();
215 Unit* target = GetHitUnit();
216
217 caster->CastSpell(caster, SPELL_ORBITAL_STRIKE_WHIP, true);
218 caster->CastSpell(target, SPELL_ORBITAL_STRIKE_KNOCK, true);
219
220 if (Creature* creature = caster->ToCreature())
221 creature->AI()->Talk(SAY_KNOCK, target);
222
223 if (caster->CanHaveThreatList())
224 caster->GetThreatManager().ModifyThreatByPercent(target, -100);
225 }
226
232
233private:
234 bool _canContinue = false;
235};
236
237// 32185 - Orbital Strike
239{
240 bool Validate(SpellInfo const* spellInfo) override
241 {
242 return ValidateSpellInfo({ spellInfo->GetEffect(EFFECT_0).TriggerSpell });
243 }
244
245 void OnPeriodic(AuraEffect const* aurEff)
246 {
248
249 if (Creature* creature = GetTarget()->ToCreature())
250 {
251 for (ThreatReference const* ref : creature->GetThreatManager().GetUnsortedThreatList())
252 {
253 Unit* victim = ref->GetVictim();
254 if (victim->IsPlayer() && victim->IsFalling())
255 creature->CastSpell(victim, aurEff->GetSpellEffectInfo().TriggerSpell, aurEff);
256 }
257 }
258 }
259
264};
265
uint32_t uint32
Definition Define.h:154
bool roll_chance(float chance, PseudoRandomDistributionState &state)
Definition Random.cpp:131
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
SpellEffIndex
@ EFFECT_0
@ SPELL_EFFECT_DUMMY
@ TARGET_UNIT_SRC_AREA_ENEMY
@ SPELL_AURA_PERIODIC_TRIGGER_SPELL
#define SpellEffectFn(F, I, N)
#define SpellObjectAreaTargetSelectFn(F, I, N)
#define AuraEffectPeriodicFn(F, I, N)
DamageEffectType
@ UNIT_STATE_CASTING
Definition Unit.h:290
void AddSC_boss_omor_the_unscarred()
@ EVENT_SUMMON_FIENDISH_HOUND
@ EVENT_ORBITAL_STRIKE_TARGET
@ EVENT_TREACHEROUS_AURA
@ SPELL_ORBITAL_STRIKE_KNOCK
@ SPELL_ORBITAL_STRIKE_TARGET
@ SPELL_TREACHEROUS_AURA
@ SPELL_SUMMON_FIENDISH_HOUND
@ SPELL_ORBITAL_STRIKE_WHIP
SpellEffectInfo const & GetSpellEffectInfo() const
void PreventDefaultAction()
HookList< EffectPeriodicHandler > OnEffectPeriodic
Unit * GetTarget() const
bool IsPlayer() const
Definition BaseEntity.h:173
void JustEngagedWith(Unit *who) override
EventMap events
void DoZoneInCombat()
Definition CreatureAI.h:169
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:63
bool IsEngaged() const override
void Update(uint32 time)
Definition EventMap.h:77
void Repeat(Milliseconds time)
Definition EventMap.cpp:67
EventId ExecuteEvent()
Definition EventMap.cpp:77
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:40
Creature * ToCreature()
Definition Object.h:121
uint32 TriggerSpell
Definition SpellInfo.h:234
uint32 const Id
Definition SpellInfo.h:328
SpellEffectInfo const & GetEffect(SpellEffIndex index) const
Definition SpellInfo.h:590
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Unit * GetCaster() const
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
void ModifyThreatByPercent(Unit *target, float percent)
void AttackStartCaster(Unit *victim, float dist)
Definition UnitAI.cpp:47
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:160
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.cpp:172
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition UnitAI.cpp:71
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:81
Definition Unit.h:647
bool IsWithinMeleeRange(Unit const *obj) const
Definition Unit.h:722
bool CanHaveThreatList() const
====================== THREAT & COMBAT ====================
Definition Unit.h:1045
ThreatManager & GetThreatManager()
Definition Unit.h:1093
bool HealthBelowPctDamaged(float pct, uint32 damage) const
Definition Unit.h:805
Unit * GetVictim() const
Definition Unit.h:738
bool HasUnitState(const uint32 f) const
Definition Unit.h:755
bool IsFalling() const
Definition Unit.cpp:13035
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2222
void FilterTargets(std::list< WorldObject * > &targets)
bool Validate(SpellInfo const *spellInfo) override
@ DATA_OMOR_THE_UNSCARRED
#define RegisterHellfireRampartsCreatureAI(ai_name)
void RandomResize(C &container, std::size_t requestedSize)
Definition Containers.h:67
float GetExactDist2d(const float x, const float y) const
Definition Position.h:117
void JustEngagedWith(Unit *who) override
void JustSummoned(Creature *summoned) override
void AttackStart(Unit *who) override
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
void OnSpellCast(SpellInfo const *spellInfo) override
void UpdateAI(uint32 diff) override
boss_omor_the_unscarred(Creature *creature)