TrinityCore
boss_keleseth.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/* ScriptData
19SDName: Boss_Prince_Keleseth
20SD%Complete: 100
21SDComment:
22SDCategory: Utgarde Keep
23EndScriptData */
24
25#include "ScriptMgr.h"
26#include "InstanceScript.h"
27#include "MotionMaster.h"
28#include "ObjectAccessor.h"
29#include "ScriptedCreature.h"
30#include "SpellAuras.h"
31#include "SpellScript.h"
32#include "utgarde_keep.h"
33
35{
40
45
47 NPC_SKELETON = 23970,
48
49 NPC_RUNEMAGE = 23960,
51
57
61
66
68};
69
70#define SKELETONSPAWN_Z 42.8668f
71
72float const SkeletonSpawnPoint[1][2] =
73{
74 {156.2559f, 259.2093f},
75};
76
77float AttackLoc[3]= {197.636f, 194.046f, 40.8164f};
78
80{
81 npc_frost_tomb(Creature* creature) : ScriptedAI(creature)
82 {
83 _instance = creature->GetInstanceScript();
84 }
85
86 void IsSummonedBy(WorldObject* summonerWO) override
87 {
88 Unit* summoner = summonerWO->ToUnit();
89 if (!summoner)
90 return;
91 DoCast(summoner, SPELL_FROST_TOMB, true);
92 }
93
94 void UpdateAI(uint32 /*diff*/) override { }
95
96 void JustDied(Unit* /*killer*/) override
97 {
99 keleseth->AI()->SetData(DATA_ON_THE_ROCKS, false);
100 }
101
102private:
104};
105
106struct boss_keleseth : public BossAI
107{
109 {
110 Initialize();
111 }
112
114 {
115 onTheRocks = true;
116 }
117
118 void Reset() override
119 {
120 _Reset();
124
125 Initialize();
126 }
127
128 void JustEngagedWith(Unit* who) override
129 {
132
133 if (!who)
134 return;
135
136 std::list<Creature*> guards;
139 if (!guards.empty())
140 {
141 for (std::list<Creature*>::iterator itr = guards.begin(); itr != guards.end(); ++itr)
142 {
143 if ((*itr)->IsAlive() && (*itr)->IsWithinLOSInMap(me))
144 (*itr)->AI()->AttackStart(who);
145 }
146 }
147 }
148
149 void JustDied(Unit* /*killer*/) override
150 {
151 _JustDied();
153 }
154
155 void SetData(uint32 data, uint32 value) override
156 {
157 if (data == DATA_ON_THE_ROCKS)
158 onTheRocks = value != 0;
159 }
160
161 uint32 GetData(uint32 data) const override
162 {
163 if (data == DATA_ON_THE_ROCKS)
164 return onTheRocks;
165
166 return 0;
167 }
168
169 void UpdateAI(uint32 diff) override
170 {
171 if (!UpdateVictim())
172 return;
173
174 events.Update(diff);
175
177 return;
178
179 while (uint32 eventId = events.ExecuteEvent())
180 {
181 switch (eventId)
182 {
186 break;
187 case EVENT_SHADOWBOLT:
190 break;
191 case EVENT_FROST_TOMB:
192 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 100.0f, true, true, -SPELL_FROST_TOMB))
193 {
195 Talk(SAY_FROST_TOMB_EMOTE, target);
196
197 DoCast(target, SPELL_FROST_TOMB_STUN, true);
198 // checked from sniffs - the player casts the spell
199 target->CastSpell(target, SPELL_FROST_TOMB_SUMMON, true);
200 }
202 break;
203 default:
204 break;
205 }
206
208 return;
209 }
210 }
211
213 {
214 // I could not found any spell cast for this
215 for (uint8 i = 0; i < 4; ++i)
217 }
218
219private:
221};
222
224{
225 npc_vrykul_skeleton(Creature* creature) : ScriptedAI(creature) { }
226
227 void Reset() override
228 {
229 events.Reset();
231 }
232
233 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
234 {
235 if (damage >= me->GetHealth())
236 {
237 damage = 0;
238
239 // There are some issues with pets
240 // they will still attack. I would say it is a PetAI bug
241 if (!me->IsUninteractible())
242 {
243 // from sniffs
244 me->SetUninteractible(true);
245 me->SetCanMelee(false);
247
248 events.Reset();
250
253 }
254 }
255 }
256
257 void UpdateAI(uint32 diff) override
258 {
259 if (!UpdateVictim())
260 return;
261
262 events.Update(diff);
263
265 return;
266
267 while (uint32 eventId = events.ExecuteEvent())
268 {
269 switch (eventId)
270 {
271 case EVENT_DECREPIFY:
272 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 0.0f, true, true, -SPELL_DECREPIFY))
273 DoCast(target, SPELL_DECREPIFY);
275 break;
276 case EVENT_RESURRECT:
279 break;
280 case EVENT_FULL_HEAL:
281 DoCast(me, SPELL_FULL_HEAL, true);
282 break;
286 me->SetUninteractible(false);
287 me->SetCanMelee(true);
291 break;
292 default:
293 break;
294 }
295
297 return;
298 }
299 }
300
301private:
303};
304
305// 48400 - Frost Tomb
307{
308 void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
309 {
310 if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_DEATH)
311 if (Unit* caster = GetCaster())
312 if (caster->IsAlive())
313 if (Creature* creature = caster->ToCreature())
314 creature->DespawnOrUnsummon(1s);
315 }
316
317 void Register() override
318 {
320 }
321};
322
324{
325 public:
326 achievement_on_the_rocks() : AchievementCriteriaScript("achievement_on_the_rocks") { }
327
328 bool OnCheck(Player* /*source*/, Unit* target) override
329 {
330 return target && target->GetAI() && target->GetAI()->GetData(DATA_ON_THE_ROCKS);
331 }
332};
333
335{
341}
uint8_t uint8
Definition: Define.h:144
uint32_t uint32
Definition: Define.h:142
#define RegisterSpellScript(spell_script)
Definition: ScriptMgr.h:1369
@ EFFECT_0
Definition: SharedDefines.h:30
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
@ AURA_REMOVE_BY_DEATH
@ SPELL_AURA_MOD_STUN
#define AuraEffectRemoveFn(F, I, N, M)
Definition: SpellScript.h:2040
@ UNIT_STAND_STATE_DEAD
Definition: UnitDefines.h:49
@ UNIT_STAND_STATE_STAND
Definition: UnitDefines.h:42
DamageEffectType
Definition: UnitDefines.h:131
@ UNIT_STATE_CASTING
Definition: Unit.h:270
KelsethEncounter
@ SAY_DEATH
@ NPC_FROSTTOMB
@ SPELL_SHADOW_FISSURE
@ SPELL_FROST_TOMB
@ EVENT_SHADOWBOLT
@ SPELL_FROST_TOMB_STUN
@ DATA_ON_THE_ROCKS
@ EVENT_FROST_TOMB
@ EVENT_DECREPIFY
@ NPC_RUNEMAGE
@ NPC_STRATEGIST
@ EVENT_SUMMON_SKELETONS
@ EVENT_FULL_HEAL
@ SAY_FROST_TOMB
@ SPELL_SHADOWBOLT
@ SPELL_DECREPIFY
@ SAY_START_COMBAT
@ EVENT_RESURRECT
@ SPELL_BONE_ARMOR
@ SAY_FROST_TOMB_EMOTE
@ SPELL_FROST_TOMB_SUMMON
@ SAY_SUMMON_SKELETONS
@ EVENT_SHADOW_FISSURE
@ SPELL_FULL_HEAL
@ NPC_SKELETON
float AttackLoc[3]
float const SkeletonSpawnPoint[1][2]
void AddSC_boss_keleseth()
#define SKELETONSPAWN_Z
AuraApplication const * GetTargetApplication() const
HookList< EffectApplyHandler > AfterEffectRemove
Definition: SpellScript.h:2039
Unit * GetCaster() const
void JustEngagedWith(Unit *who) override
EventMap events
void _JustDied()
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:56
bool UpdateVictim()
Definition: CreatureAI.cpp:245
Creature *const me
Definition: CreatureAI.h:61
void SetCanMelee(bool canMelee, bool fleeFromMelee=false)
Definition: Creature.cpp:2822
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
virtual ObjectGuid GetGuidData(uint32 type) const override
void MoveChase(Unit *target, Optional< ChaseRange > dist={}, Optional< ChaseAngle > angle={})
static Creature * ToCreature(Object *o)
Definition: Object.h:219
static Unit * ToUnit(Object *o)
Definition: Object.h:225
virtual uint32 GetData(uint32) const
Definition: UnitAI.h:73
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:161
SpellCastResult DoCast(uint32 spellId)
Definition: UnitAI.cpp:89
Definition: Unit.h:627
void SetStandState(UnitStandStateType state, uint32 animKitID=0)
Definition: Unit.cpp:10100
MotionMaster * GetMotionMaster()
Definition: Unit.h:1652
UnitAI * GetAI() const
Definition: Unit.h:660
void SetUninteractible(bool apply)
Definition: Unit.cpp:8147
uint64 GetHealth() const
Definition: Unit.h:776
Unit * GetVictim() const
Definition: Unit.h:715
bool HasUnitState(const uint32 f) const
Definition: Unit.h:732
bool IsUninteractible() const
Definition: Unit.h:1037
InstanceScript * GetInstanceScript() const
Definition: Object.cpp:1042
void GetCreatureListWithEntryInGrid(Container &creatureContainer, uint32 entry, float maxSearchRange=250.0f) const
Definition: Object.cpp:3312
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
bool OnCheck(Player *, Unit *target) override
void OnRemove(AuraEffect const *, AuraEffectHandleModes)
void Register() override
@ DATA_PRINCE_KELESETH
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
void UpdateAI(uint32 diff) override
void SetData(uint32 data, uint32 value) override
void Reset() override
void JustEngagedWith(Unit *who) override
void SummonSkeletons()
uint32 GetData(uint32 data) const override
void JustDied(Unit *) override
boss_keleseth(Creature *creature)
InstanceScript * _instance
void IsSummonedBy(WorldObject *summonerWO) override
void JustDied(Unit *) override
npc_frost_tomb(Creature *creature)
void UpdateAI(uint32) override
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
void UpdateAI(uint32 diff) override
npc_vrykul_skeleton(Creature *creature)
void Reset() override
#define RegisterUtgardeKeepCreatureAI(ai_name)
Definition: utgarde_keep.h:96