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};
50
59
61{
63 PHASE_2 = 2
64};
65
66enum Misc
67{
69};
70
71struct boss_bronjahm : public BossAI
72{
74 {
76 }
77
87
88 void JustReachedHome() override
89 {
92 }
93
100
101 void JustDied(Unit* /*killer*/) override
102 {
103 _JustDied();
105 }
106
107 void KilledUnit(Unit* who) override
108 {
109 if (who->GetTypeId() == TYPEID_PLAYER)
110 Talk(SAY_SLAY);
111 }
112
113 void DamageTaken(Unit* /*attacker*/, uint32& /*damage*/, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
114 {
116 {
119 events.ScheduleEvent(EVENT_FEAR, 12s, 16s, 0, PHASE_2);
121 me->SetCanMelee(false);
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 default:
202 break;
203 }
204
206 return;
207 }
208 }
209};
210
212{
214 {
216 }
217
218 void IsSummonedBy(WorldObject* /*summoner*/) override
219 {
221 bronjahm->AI()->JustSummoned(me);
222 }
223
224 void MovementInform(uint32 type, uint32 id) override
225 {
226 if (type != FOLLOW_MOTION_TYPE)
227 return;
228
230 return;
231
232 me->CastSpell(nullptr, SPELL_CONSUME_SOUL, true);
234 }
235
236private:
238};
239
240// 68793, 69050 - Magic's Bane
242{
243 void CalculateDamage(SpellEffectInfo const& /*spellEffectInfo*/, Unit const* victim, int32& damage, int32& /*flatMod*/, float& /*pctMod*/) const
244 {
245 if (victim->GetPowerType() != POWER_MANA)
246 return;
247
248 int32 const maxDamage = GetCaster()->GetMap()->IsHeroic() ? 15000 : 10000;
249 int32 newDamage = damage + (victim->GetMaxPower(POWER_MANA) / 2);
250 damage = std::min(maxDamage, newDamage);
251 }
252
257};
258
259// 68861 - Consume Soul
273
275{
276 68904,
277 68886,
278 68905,
279 68896,
280 68906,
281 68897,
282 68907,
283 68898
284};
285
299
300// 68921, 69049 - Soulstorm
302{
303 void FilterTargets(std::list<WorldObject*>& targets)
304 {
305 Unit* caster = GetCaster();
306 targets.remove_if([caster](WorldObject* target)
307 {
308 return caster->GetExactDist2d(target) <= 10.0f;
309 });
310 }
311
316};
317
319{
320 public:
321 achievement_bronjahm_soul_power() : AchievementCriteriaScript("achievement_bronjahm_soul_power") { }
322
323 bool OnCheck(Player* /*source*/, Unit* target) override
324 {
325 return target && target->GetAI()->GetData(DATA_SOUL_POWER) >= 4;
326 }
327};
328
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
@ FOLLOW_MOTION_TYPE
@ TYPEID_PLAYER
Definition ObjectGuid.h:44
Spells
Definition PlayerAI.cpp:32
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
#define RegisterSpellScriptWithArgs(spell_script, script_name,...)
Definition ScriptMgr.h:1382
SpellEffIndex
@ EFFECT_0
@ TARGET_UNIT_DEST_AREA_ENEMY
@ SPELL_EFFECT_SCRIPT_EFFECT
@ POWER_MANA
#define EFFECT_ALL
@ SPELL_AURA_PERIODIC_DUMMY
@ SPELLVALUE_MAX_TARGETS
#define SpellEffectFn(F, I, N)
#define SpellObjectAreaTargetSelectFn(F, I, N)
#define AuraEffectPeriodicFn(F, I, N)
#define SpellCalcDamageFn(F)
@ REACT_PASSIVE
DamageEffectType
@ UNIT_STATE_CASTING
Definition Unit.h:276
static uint32 const SoulstormVisualSpells[]
@ DATA_SOUL_POWER
@ SAY_DEATH
@ SAY_AGGRO
@ SAY_SLAY
@ SAY_CORRUPT_SOUL
@ SAY_SOUL_STORM
void AddSC_boss_bronjahm()
@ SPELL_CONSUME_SOUL
@ SPELL_PURPLE_BANISH_VISUAL
@ 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_FEAR
@ EVENT_MAGIC_BANE
@ EVENT_SOULSTORM
@ EVENT_SHADOW_BOLT
Yells
uint32 GetTickNumber() const
void PreventDefaultAction()
HookList< EffectPeriodicHandler > OnEffectPeriodic
Unit * GetTarget() const
TypeID GetTypeId() const
Definition BaseEntity.h:166
void _JustReachedHome()
void JustEngagedWith(Unit *who) override
SummonList summons
EventMap events
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:63
void SetCanMelee(bool canMelee, bool fleeFromMelee=false)
void SetReactState(ReactStates st)
Definition Creature.h:174
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
uint32 ExecuteEvent()
Definition EventMap.cpp:77
void Update(uint32 time)
Definition EventMap.h:61
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition EventMap.cpp:40
bool IsInPhase(uint8 phase) const
Definition EventMap.h:222
void SetPhase(uint8 phase)
Definition EventMap.cpp:32
virtual ObjectGuid GetGuidData(uint32 type) const override
bool IsHeroic() const
Definition Map.cpp:3311
void MoveFollow(Unit *target, float dist, Optional< ChaseAngle > angle={}, Optional< Milliseconds > duration={}, bool ignoreTargetWalk=false, MovementSlot slot=MOTION_SLOT_ACTIVE, Scripting::v2::ActionResultSetter< MovementStopReason > &&scriptResult={})
LowType GetCounter() const
Definition ObjectGuid.h:336
uint32 GetEntry() const
Definition Object.h:89
HookList< DamageAndHealingCalcHandler > CalcDamage
Unit * GetCaster() const
int32 GetEffectValueAsInt() const
void PreventHitDefaultEffect(SpellEffIndex effIndex)
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
void Summon(Creature const *summon)
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 DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:162
virtual uint32 GetData(uint32 id) const
Definition UnitAI.h:74
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:89
Definition Unit.h:635
bool IsWithinMeleeRange(Unit const *obj) const
Definition Unit.h:710
MotionMaster * GetMotionMaster()
Definition Unit.h:1723
Powers GetPowerType() const
Definition Unit.h:811
float GetCombatReach() const override
Definition Unit.h:705
int32 GetMaxPower(Powers power) const
Definition Unit.cpp:10037
UnitAI * GetAI() const
Definition Unit.h:668
Unit * GetVictim() const
Definition Unit.h:726
bool HasUnitState(const uint32 f) const
Definition Unit.h:743
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3974
Map * GetMap() const
Definition Object.h:411
InstanceScript * GetInstanceScript() const
Definition Object.cpp:396
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2217
bool OnCheck(Player *, Unit *target) override
void HandleScript(SpellEffIndex effIndex)
void CalculateDamage(SpellEffectInfo const &, Unit const *victim, int32 &damage, int32 &, float &) const
void FilterTargets(std::list< WorldObject * > &targets)
void HandlePeriodicTick(AuraEffect const *aurEff)
@ 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:117
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