TrinityCore
Loading...
Searching...
No Matches
boss_bronjahm.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 "forge_of_souls.h"
20#include "InstanceScript.h"
21#include "Map.h"
22#include "MotionMaster.h"
23#include "ObjectAccessor.h"
24#include "ScriptedCreature.h"
25#include "SpellAuraEffects.h"
26#include "SpellScript.h"
27
36
38{
44 SPELL_FEAR = 68950,
46 SPELL_SOULSTORM_CHANNEL = 69008, // Pre-fight
47 SPELL_SOULSTORM_VISUAL = 68870, // Pre-cast Soulstorm
48 SPELL_PURPLE_BANISH_VISUAL = 68862, // Used by Soul Fragment (Aura)
49
52};
53
63
65{
67 PHASE_2 = 2
68};
69
70enum Misc
71{
73};
74
75struct boss_bronjahm : public BossAI
76{
78 {
80 }
81
90
91 void JustReachedHome() override
92 {
95 }
96
103
104 void JustDied(Unit* /*killer*/) override
105 {
106 _JustDied();
108 }
109
110 void KilledUnit(Unit* who) override
111 {
112 if (who->GetTypeId() == TYPEID_PLAYER)
113 Talk(SAY_SLAY);
114 }
115
116 void DamageTaken(Unit* /*attacker*/, uint32& /*damage*/, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
117 {
119 {
122 }
123 }
124
125 void JustSummoned(Creature* summon) override
126 {
127 if (summon->GetEntry() == NPC_CORRUPTED_SOUL_FRAGMENT)
128 {
129 summons.Summon(summon);
131 summon->GetMotionMaster()->MoveFollow(me, me->GetCombatReach(), 0.0f);
132 summon->CastSpell(summon, SPELL_PURPLE_BANISH_VISUAL, true);
133 }
134 }
135
136 uint32 GetData(uint32 type) const override
137 {
138 if (type == DATA_SOUL_POWER)
139 {
140 uint32 count = 0;
141 for (ObjectGuid const& guid : summons)
142 {
143 if (Creature* summon = ObjectAccessor::GetCreature(*me, guid))
144 if (summon->GetEntry() == NPC_CORRUPTED_SOUL_FRAGMENT && summon->IsAlive())
145 ++count;
146 }
147 return count;
148 }
149
150 return 0;
151 }
152
153 void UpdateAI(uint32 diff) override
154 {
155 if (!UpdateVictim())
156 return;
157
158 events.Update(diff);
159
161 return;
162
163 while (uint32 eventId = events.ExecuteEvent())
164 {
165 switch (eventId)
166 {
167 case EVENT_MAGIC_BANE:
170 break;
173 {
176 }
177 else
178 {
182 }
183 break;
185 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 0.0f, true))
186 {
188 DoCast(target, SPELL_CORRUPT_SOUL);
189 }
191 break;
192 case EVENT_SOULSTORM:
195 me->CastSpell(me, SPELL_SOULSTORM, false);
196 break;
197 case EVENT_FEAR:
200 break;
201 case EVENT_TELEPORT:
203 events.ScheduleEvent(EVENT_FEAR, 12s, 16s, 0, PHASE_2);
205 break;
206 default:
207 break;
208 }
209
211 return;
212 }
213
216 }
217};
218
220{
222 {
224 }
225
226 void IsSummonedBy(WorldObject* /*summoner*/) override
227 {
229 bronjahm->AI()->JustSummoned(me);
230 }
231
232 void MovementInform(uint32 type, uint32 id) override
233 {
234 if (type != FOLLOW_MOTION_TYPE)
235 return;
236
238 return;
239
240 me->CastSpell(nullptr, SPELL_CONSUME_SOUL, true);
242 }
243
244private:
246};
247
248// 68793, 69050 - Magic's Bane
250{
252
254 {
255 if (GetHitUnit()->GetPowerType() != POWER_MANA)
256 return;
257
258 int32 const maxDamage = GetCaster()->GetMap()->IsHeroic() ? 15000 : 10000;
259 int32 newDamage = GetEffectValue() + (GetHitUnit()->GetMaxPower(POWER_MANA) / 2);
260 SetEffectValue(std::min<int32>(maxDamage, newDamage));
261 }
262
267};
268
269// 68861 - Consume Soul
285
287{
288 68904,
289 68886,
290 68905,
291 68896,
292 68906,
293 68897,
294 68907,
295 68898
296};
297
313
314// 68921, 69049 - Soulstorm
316{
318
319 void FilterTargets(std::list<WorldObject*>& targets)
320 {
321 Unit* caster = GetCaster();
322 targets.remove_if([caster](WorldObject* target)
323 {
324 return caster->GetExactDist2d(target) <= 10.0f;
325 });
326 }
327
332};
333
334// 68839 - Corrupt Soul
336{
338
339 bool Validate(SpellInfo const* /*spellInfo*/) override
340 {
342 }
343
344 void AfterRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
345 {
346 Unit* target = GetTarget();
347 target->CastSpell(target, SPELL_KNOCKDOWN_STUN, true);
348 target->CastSpell(target, SPELL_DRAW_CORRUPTED_SOUL, true);
349 }
350
355};
356
358{
359 public:
360 achievement_bronjahm_soul_power() : AchievementCriteriaScript("achievement_bronjahm_soul_power") { }
361
362 bool OnCheck(Player* /*source*/, Unit* target) override
363 {
364 return target && target->GetAI()->GetData(DATA_SOUL_POWER) >= 4;
365 }
366};
367
int32_t int32
Definition Define.h:129
uint32_t uint32
Definition Define.h:133
@ FOLLOW_MOTION_TYPE
@ TYPEID_PLAYER
Definition ObjectGuid.h:39
Spells
Definition PlayerAI.cpp:32
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1128
#define RegisterSpellScriptWithArgs(spell_script, script_name,...)
Definition ScriptMgr.h:1127
SpellEffIndex
@ EFFECT_0
@ SPELL_EFFECT_SCRIPT_EFFECT
@ SPELL_EFFECT_SCHOOL_DAMAGE
@ TARGET_UNIT_DEST_AREA_ENEMY
@ POWER_MANA
#define EFFECT_ALL
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
@ SPELL_AURA_DUMMY
@ SPELL_AURA_PERIODIC_DUMMY
@ SPELLVALUE_MAX_TARGETS
#define SpellEffectFn(F, I, N)
#define SpellObjectAreaTargetSelectFn(F, I, N)
#define AuraEffectPeriodicFn(F, I, N)
#define AuraEffectRemoveFn(F, I, N, M)
@ REACT_PASSIVE
@ UNIT_STATE_CASTING
Definition Unit.h:235
DamageEffectType
Definition Unit.h:352
static uint32 const SoulstormVisualSpells[]
@ DATA_SOUL_POWER
@ SAY_DEATH
@ SAY_AGGRO
@ SAY_SLAY
@ SAY_CORRUPT_SOUL
@ SAY_SOUL_STORM
void AddSC_boss_bronjahm()
@ SPELL_DRAW_CORRUPTED_SOUL
@ SPELL_CONSUME_SOUL
@ SPELL_PURPLE_BANISH_VISUAL
@ SPELL_KNOCKDOWN_STUN
@ SPELL_FEAR
@ SPELL_SOULSTORM_CHANNEL
@ SPELL_TELEPORT
@ SPELL_SHADOW_BOLT
@ SPELL_MAGIC_S_BANE
@ SPELL_SOULSTORM
@ SPELL_SOULSTORM_VISUAL
@ SPELL_CORRUPT_SOUL
CombatPhases
@ PHASE_2
@ PHASE_1
@ EVENT_CORRUPT_SOUL
@ EVENT_TELEPORT
@ EVENT_FEAR
@ EVENT_MAGIC_BANE
@ EVENT_SOULSTORM
@ EVENT_SHADOW_BOLT
Yells
uint32 GetTickNumber() const
void PreventDefaultAction()
HookList< EffectApplyHandler > AfterEffectRemove
HookList< EffectPeriodicHandler > OnEffectPeriodic
Unit * GetTarget() const
void _JustReachedHome()
void JustEngagedWith(Unit *who) override
SummonList summons
EventMap events
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
void SetReactState(ReactStates st)
Definition Creature.h:119
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
void Update(uint32 time)
Definition EventMap.h:67
EventId ExecuteEvent()
Definition EventMap.cpp:73
bool IsInPhase(PhaseIndex phase) const
Definition EventMap.h:236
void SetPhase(PhaseIndex phase)
Definition EventMap.cpp:28
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:36
virtual ObjectGuid GetGuidData(uint32 type) const override
bool IsHeroic() const
Definition Map.cpp:4256
void MoveFollow(Unit *target, float dist, ChaseAngle angle, MovementSlot slot=MOTION_SLOT_ACTIVE)
LowType GetCounter() const
Definition ObjectGuid.h:156
TypeID GetTypeId() const
Definition Object.h:93
uint32 GetEntry() const
Definition Object.h:81
void SetEffectValue(int32 value)
Unit * GetCaster() const
void PreventHitDefaultEffect(SpellEffIndex effIndex)
Unit * GetHitUnit() const
int32 GetEffectValue() const
HookList< EffectHandler > OnEffectHitTarget
HookList< EffectHandler > OnEffectLaunchTarget
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
void Summon(Creature const *summon)
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:241
virtual uint32 GetData(uint32) const
Definition UnitAI.h:155
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 DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:243
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:106
Definition Unit.h:769
bool IsWithinMeleeRange(Unit const *obj) const
Definition Unit.h:844
MotionMaster * GetMotionMaster()
Definition Unit.h:1667
float GetCombatReach() const override
Definition Unit.h:839
UnitAI * GetAI() const
Definition Unit.h:800
uint32 GetMaxPower(Powers power) const
Definition Unit.h:936
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3784
Unit * GetVictim() const
Definition Unit.h:859
bool HasUnitState(const uint32 f) const
Definition Unit.h:876
Map * GetMap() const
Definition Object.h:449
InstanceScript * GetInstanceScript() const
Definition Object.cpp:1087
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2832
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
bool OnCheck(Player *, Unit *target) override
void HandleScript(SpellEffIndex effIndex)
PrepareSpellScript(spell_bronjahm_consume_soul)
void AfterRemove(AuraEffect const *, AuraEffectHandleModes)
bool Validate(SpellInfo const *) override
PrepareAuraScript(spell_bronjahm_corrupt_soul)
PrepareSpellScript(spell_bronjahm_magic_bane)
void RecalculateDamage(SpellEffIndex)
void FilterTargets(std::list< WorldObject * > &targets)
PrepareSpellScript(spell_bronjahm_soulstorm_targeting)
void HandlePeriodicTick(AuraEffect const *aurEff)
PrepareAuraScript(spell_bronjahm_soulstorm_visual)
@ DATA_BRONJAHM
@ NPC_CORRUPTED_SOUL_FRAGMENT
#define RegisterForgeOfSoulsCreatureAI(ai_name)
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
float GetExactDist2d(const float x, const float y) const
Definition Position.h:109
bool HealthAbovePct(uint32 pct) const
void Reset() override
boss_bronjahm(Creature *creature)
void JustSummoned(Creature *summon) override
uint32 GetData(uint32 type) const override
void UpdateAI(uint32 diff) override
void JustEngagedWith(Unit *who) override
void KilledUnit(Unit *who) override
void DamageTaken(Unit *, uint32 &, DamageEffectType, SpellInfo const *) override
void JustReachedHome() override
void JustDied(Unit *) override
void IsSummonedBy(WorldObject *) override
npc_corrupted_soul_fragment(Creature *creature)
void MovementInform(uint32 type, uint32 id) override