TrinityCore
boss_kormok.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 "scholomance.h"
20#include "ScriptedCreature.h"
21#include "SpellScript.h"
22
24{
27
29
34
36};
37
39{
43};
44
46{
47public:
48 boss_kormok() : CreatureScript("boss_kormok") { }
49
50 struct boss_kormokAI : public ScriptedAI
51 {
52 boss_kormokAI(Creature* creature) : ScriptedAI(creature)
53 {
54 Initialize();
55 }
56
58 {
59 Mages = false;
60 }
61
62 void Reset() override
63 {
64 Initialize();
65 events.Reset();
66 }
67
68 void JustEngagedWith(Unit* /*who*/) override
69 {
73 }
74
75 void JustSummoned(Creature* summoned) override
76 {
77 summoned->AI()->AttackStart(me->GetVictim());
78 }
79
80 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
81 {
82 if (me->HealthBelowPctDamaged(25, damage) && !Mages)
83 {
85 Mages = true;
86 }
87 }
88
89 void UpdateAI(uint32 diff) override
90 {
91 if (!UpdateVictim())
92 return;
93
94 events.Update(diff);
95
97 return;
98
99 while (uint32 eventId = events.ExecuteEvent())
100 {
101 switch (eventId)
102 {
106 break;
110 break;
114 break;
115 default:
116 break;
117 }
118
120 return;
121 }
122 }
123
124 private:
126 bool Mages;
127 };
128
129 CreatureAI* GetAI(Creature* creature) const override
130 {
131 return GetScholomanceAI<boss_kormokAI>(creature);
132 }
133};
134
136{
141};
142
143// 27695 - Summon Bone Mages
145{
146 public:
147 spell_kormok_summon_bone_mages() : SpellScriptLoader("spell_kormok_summon_bone_mages") { }
148
150 {
151 bool Validate(SpellInfo const* /*spell*/) override
152 {
154 }
155
157 {
158 PreventHitDefaultEffect(effIndex);
159 for (uint32 i = 0; i < 2; ++i)
161 }
162
163 void Register() override
164 {
166 }
167 };
168
169 SpellScript* GetSpellScript() const override
170 {
172 }
173};
174
175// 27687 - Summon Bone Minions
177{
178 public:
179 spell_kormok_summon_bone_minions() : SpellScriptLoader("spell_kormok_summon_bone_minions") { }
180
182 {
183 bool Validate(SpellInfo const* /*spell*/) override
184 {
186 }
187
189 {
190 PreventHitDefaultEffect(effIndex);
191
192 // Possible spells to handle this not found.
193 for (uint32 i = 0; i < 4; ++i)
194 GetCaster()->SummonCreature(NPC_BONE_MINION, GetCaster()->GetPositionX() + float(irand(-7, 7)), GetCaster()->GetPositionY() + float(irand(-7, 7)), GetCaster()->GetPositionZ(), 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 2min);
195 }
196
197 void Register() override
198 {
200 }
201 };
202
203 SpellScript* GetSpellScript() const override
204 {
206 }
207};
208
210{
211 new boss_kormok();
214}
uint32_t uint32
Definition: Define.h:142
@ TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN
Definition: ObjectDefines.h:64
Spells
Definition: PlayerAI.cpp:32
int32 irand(int32 min, int32 max)
Definition: Random.cpp:35
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:42
SpellEffIndex
Definition: SharedDefines.h:29
@ EFFECT_0
Definition: SharedDefines.h:30
@ SPELL_EFFECT_SCRIPT_EFFECT
#define SpellEffectFn(F, I, N)
Definition: SpellScript.h:842
DamageEffectType
Definition: UnitDefines.h:131
@ UNIT_STATE_CASTING
Definition: Unit.h:270
@ SPELL_SUMMON_BONE_MAGES
Definition: boss_kormok.cpp:28
@ SPELL_BONE_SHIELD
Definition: boss_kormok.cpp:26
@ SPELL_SUMMON_BONE_MAGE_BACK_LEFT
Definition: boss_kormok.cpp:33
@ SPELL_SUMMON_BONE_MINIONS
Definition: boss_kormok.cpp:35
@ SPELL_SHADOWBOLT_VOLLEY
Definition: boss_kormok.cpp:25
@ SPELL_SUMMON_BONE_MAGE_FRONT_LEFT
Definition: boss_kormok.cpp:30
@ SPELL_SUMMON_BONE_MAGE_BACK_RIGHT
Definition: boss_kormok.cpp:32
@ SPELL_SUMMON_BONE_MAGE_FRONT_RIGHT
Definition: boss_kormok.cpp:31
void AddSC_boss_kormok()
@ EVENT_SUMMON_MINIONS
Definition: boss_kormok.cpp:42
@ EVENT_SHADOWBOLT_VOLLEY
Definition: boss_kormok.cpp:40
@ EVENT_BONE_SHIELD
Definition: boss_kormok.cpp:41
uint32 const SummonMageSpells[4]
bool UpdateVictim()
Definition: CreatureAI.cpp:245
void AttackStart(Unit *victim) override
== Triggered Actions Requested ==================
Definition: CreatureAI.cpp:328
Creature *const me
Definition: CreatureAI.h:61
CreatureAI * AI() const
Definition: Creature.h:214
uint32 ExecuteEvent()
Definition: EventMap.cpp:73
void Update(uint32 time)
Definition: EventMap.h:56
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition: EventMap.cpp:36
void Reset()
Definition: EventMap.cpp:21
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Definition: SpellScript.h:162
Unit * GetCaster() const
void PreventHitDefaultEffect(SpellEffIndex effIndex)
HookList< EffectHandler > OnEffectHitTarget
Definition: SpellScript.h:840
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.cpp:180
SpellCastResult DoCast(uint32 spellId)
Definition: UnitAI.cpp:89
Definition: Unit.h:627
Unit * GetVictim() const
Definition: Unit.h:715
bool HasUnitState(const uint32 f) const
Definition: Unit.h:732
bool HealthBelowPctDamaged(int32 pct, uint32 damage) const
Definition: Unit.h:781
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2896
TempSummon * SummonCreature(uint32 entry, Position const &pos, TempSummonType despawnType=TEMPSUMMON_MANUAL_DESPAWN, Milliseconds despawnTime=0s, uint32 vehId=0, uint32 spellId=0, ObjectGuid privateObjectOwner=ObjectGuid::Empty)
Definition: Object.cpp:2025
CreatureAI * GetAI(Creature *creature) const override
SpellScript * GetSpellScript() const override
SpellScript * GetSpellScript() const override
@ NPC_BONE_MINION
Definition: scholomance.h:50
void JustSummoned(Creature *summoned) override
Definition: boss_kormok.cpp:75
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
Definition: boss_kormok.cpp:80
boss_kormokAI(Creature *creature)
Definition: boss_kormok.cpp:52
void JustEngagedWith(Unit *) override
Definition: boss_kormok.cpp:68
void UpdateAI(uint32 diff) override
Definition: boss_kormok.cpp:89