TrinityCore
boss_ymiron.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 "MotionMaster.h"
20#include "ObjectAccessor.h"
21#include "ScriptedCreature.h"
22#include "SpellInfo.h"
23#include "SpellScript.h"
24#include "TemporarySummon.h"
25#include "utgarde_pinnacle.h"
26
28{
29 SPELL_BANE = 48294,
30 SPELL_BANE_HIT = 59203, // Checked for King's Bane achievement.
37
40
43
44 SPELL_SPIRIT_FOUNT = 48380
45};
46
48{
56};
57
59{
64 EVENT_RESUME_COMBAT, // Handles react state and schedules the next event after roleplay ends.
69};
70
72{
74};
75
77{
79};
80
82{
87};
88
90{
91 {NPC_BJORN_VISUAL, SAY_SUMMON_BJORN, 404.379f, -335.335f, 104.756f, 413.594f, -335.408f, 107.995f, 3.157f, EVENT_BJORN_SPIRIT_FOUNT},
92 {NPC_HALDOR_VISUAL, SAY_SUMMON_HALDOR, 380.813f, -335.069f, 104.756f, 369.994f, -334.771f, 107.995f, 6.232f, EVENT_HALDOR_SPIRIT_STRIKE},
93 {NPC_RANULF_VISUAL, SAY_SUMMON_RANULF, 381.546f, -314.362f, 104.756f, 370.841f, -314.426f, 107.995f, 6.232f, EVENT_RANULF_SPIRIT_BURST},
94 {NPC_TORGYN_VISUAL, SAY_SUMMON_TORGYN, 404.310f, -314.761f, 104.756f, 413.992f, -314.703f, 107.995f, 3.157f, EVENT_TORGYN_SUMMON_AVENGING_SPIRITS}
95};
96
97enum Misc
98{
99 DATA_KINGS_BANE = 2157
101
102struct boss_ymiron : public BossAI
103{
105 {
106 Initialize();
107 // This ensures a random sequence of ancestors. Not sure if the order should change on reset or not, reason why this is left out of Initialize().
108 for (int i = 0; i < 4; ++i)
109 ActiveOrder[i] = i;
110 for (int i = 0; i < 3; ++i)
111 {
112 int r = i + (rand32() % (4 - i));
113 int temp = ActiveOrder[i];
114 ActiveOrder[i] = ActiveOrder[r];
115 ActiveOrder[r] = temp;
116 }
117 }
118
120 {
121 kingsBane = true;
122 ActivedNumber = 0;
127 }
128
129 void Reset() override
130 {
131 _Reset();
132 Initialize();
134 }
135
136 void JustEngagedWith(Unit* who) override
137 {
144 }
145
146 void SpellHitTarget(WorldObject* target, SpellInfo const* spellInfo) override
147 {
148 if (target->GetTypeId() == TYPEID_PLAYER && spellInfo->Id == SPELL_BANE_HIT)
149 kingsBane = false;
150 }
151
152 uint32 GetData(uint32 type) const override
153 {
154 if (type == DATA_KINGS_BANE)
155 return kingsBane ? 1 : 0;
156
157 return 0;
158 }
159
160 void MovementInform(uint32 type, uint32 pointId) override
161 {
162 if (type != POINT_MOTION_TYPE)
163 return;
164
165 if (pointId == POINT_BOAT) // Check might not be needed.
166 {
169 {
171 ancestor->CastSpell(me, SPELL_CHANNEL_SPIRIT_TO_YMIRON, true);
172 ancestor->SetUnitFlag(UNIT_FLAG_NON_ATTACKABLE);
173 ancestor->SetUninteractible(true);
174 ancestor->SetDisableGravity(true);
175 ActiveAncestorGUID = ancestor->GetGUID();
176 }
178 }
179 }
180
181 void JustSummoned(Creature* summon) override
182 {
183 switch (summon->GetEntry())
184 {
185 case NPC_SPIRIT_FOUNT:
186 summon->CastSpell(summon, SPELL_SPIRIT_FOUNT, true);
187 summon->SetDisplayId(11686);
188 SpiritFountGUID = summon->GetGUID();
189 break;
192 {
193 AddThreat(target, 0.0f, summon);
194 summon->AI()->AttackStart(target);
195 }
196 break;
197 default:
198 break;
199 }
200
201 summons.Summon(summon);
202 }
203
204 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
205 {
206 if (me->HealthBelowPctDamaged(100 - HealthAmountMultipler * HealthAmountModifier, damage) && !(damage >= me->GetHealth()))
207 {
208 uint8 Order = HealthAmountModifier - 1;
210
213
214 me->AttackStop();
217
220
221 events.CancelEvent(ActiveBoat[ActiveOrder[ActivedNumber]].event); // Cancels the event started on the previous transition.
223
224 ActivedNumber = Order;
225 }
226 }
227
228 void ExecuteEvent(uint32 eventId) override
229 {
230 switch (eventId)
231 {
232 case EVENT_BANE:
235 break;
236 case EVENT_FETID_ROT:
239 break;
240 case EVENT_DARK_SLASH:
243 break;
247 break;
251 break;
254 break;
258 break;
262 break;
264 for (uint8 i = 0; i < 4; ++i)
267 break;
268 default:
269 break;
270 }
271 }
272
273 void JustDied(Unit* /*killer*/) override
274 {
275 _JustDied();
277 }
278
279 void KilledUnit(Unit* who) override
280 {
281 if (who->GetTypeId() == TYPEID_PLAYER)
282 Talk(SAY_SLAY);
283 }
284
285 void DespawnBoatGhosts(ObjectGuid& CreatureGUID)
286 {
287 // @todo: fire visual after ancestor despawns.
288 if (!CreatureGUID.IsEmpty())
289 if (Creature* temp = ObjectAccessor::GetCreature(*me, CreatureGUID))
290 temp->DisappearAndDie();
291
292 CreatureGUID.Clear();
293 }
294
295private:
296 bool kingsBane; // Achievement King's Bane
303};
304
305// 48292 - Dark Slash
307{
309 {
310 // Slashes the target with darkness, dealing damage equal to half the target's current health.
311 SetHitDamage(int32(ceil(GetHitUnit()->GetHealth() / 2.f)));
312 }
313
314 void Register() override
315 {
317 }
318};
319
321{
322 public:
323 achievement_kings_bane() : AchievementCriteriaScript("achievement_kings_bane") { }
324
325 bool OnCheck(Player* /*player*/, Unit* target) override
326 {
327 if (!target)
328 return false;
329
330 if (Creature* Ymiron = target->ToCreature())
331 if (Ymiron->AI()->GetData(DATA_KINGS_BANE))
332 return true;
333
334 return false;
335 }
336};
337
339{
343}
Texts
uint8_t uint8
Definition: Define.h:144
int32_t int32
Definition: Define.h:138
uint32_t uint32
Definition: Define.h:142
@ POINT_MOTION_TYPE
@ TEMPSUMMON_CORPSE_DESPAWN
Definition: ObjectDefines.h:67
@ TYPEID_PLAYER
Definition: ObjectGuid.h:41
Spells
Definition: PlayerAI.cpp:32
Milliseconds randtime(Milliseconds min, Milliseconds max)
Definition: Random.cpp:62
uint32 rand32()
Definition: Random.cpp:70
#define RegisterSpellScript(spell_script)
Definition: ScriptMgr.h:1369
#define SpellHitFn(F)
Definition: SpellScript.h:854
@ REACT_PASSIVE
Definition: UnitDefines.h:506
@ REACT_AGGRESSIVE
Definition: UnitDefines.h:508
DamageEffectType
Definition: UnitDefines.h:131
@ UNIT_FLAG_NON_ATTACKABLE
Definition: UnitDefines.h:145
MovePoints
@ EVENT_GROUP_BASE_SPELLS
Definition: boss_ymiron.cpp:73
@ DATA_KINGS_BANE
Definition: boss_ymiron.cpp:99
void AddSC_boss_ymiron()
static ActiveBoatStruct ActiveBoat[4]
Definition: boss_ymiron.cpp:89
@ SPELL_SPIRIT_BURST
Definition: boss_ymiron.cpp:34
@ SPELL_SCREAMS_OF_THE_DEAD
Definition: boss_ymiron.cpp:33
@ SPELL_SUMMON_AVENGING_SPIRIT
Definition: boss_ymiron.cpp:38
@ SPELL_CHANNEL_SPIRIT_TO_YMIRON
Definition: boss_ymiron.cpp:41
@ SPELL_BANE_HIT
Definition: boss_ymiron.cpp:30
@ SPELL_CHANNEL_YMIRON_TO_SPIRIT
Definition: boss_ymiron.cpp:42
@ SPELL_SPIRIT_FOUNT
Definition: boss_ymiron.cpp:44
@ SPELL_SUMMON_SPIRIT_FOUNT
Definition: boss_ymiron.cpp:39
@ SPELL_ANCESTORS_VENGEANCE
Definition: boss_ymiron.cpp:36
@ SPELL_SPIRIT_STRIKE
Definition: boss_ymiron.cpp:35
@ SPELL_DARK_SLASH
Definition: boss_ymiron.cpp:31
@ SPELL_BANE
Definition: boss_ymiron.cpp:29
@ SPELL_FETID_ROT
Definition: boss_ymiron.cpp:32
@ POINT_BOAT
Definition: boss_ymiron.cpp:78
@ SAY_DEATH
Definition: boss_ymiron.cpp:51
@ SAY_SUMMON_BJORN
Definition: boss_ymiron.cpp:52
@ SAY_SUMMON_RANULF
Definition: boss_ymiron.cpp:54
@ SAY_SUMMON_TORGYN
Definition: boss_ymiron.cpp:55
@ SAY_AGGRO
Definition: boss_ymiron.cpp:49
@ SAY_SLAY
Definition: boss_ymiron.cpp:50
@ SAY_SUMMON_HALDOR
Definition: boss_ymiron.cpp:53
@ EVENT_TORGYN_SUMMON_AVENGING_SPIRITS
Definition: boss_ymiron.cpp:68
@ EVENT_FETID_ROT
Definition: boss_ymiron.cpp:61
@ EVENT_BJORN_SPIRIT_FOUNT
Definition: boss_ymiron.cpp:65
@ EVENT_ANCESTORS_VENGEANCE
Definition: boss_ymiron.cpp:63
@ EVENT_RANULF_SPIRIT_BURST
Definition: boss_ymiron.cpp:67
@ EVENT_HALDOR_SPIRIT_STRIKE
Definition: boss_ymiron.cpp:66
@ EVENT_BANE
Definition: boss_ymiron.cpp:60
@ EVENT_RESUME_COMBAT
Definition: boss_ymiron.cpp:64
@ EVENT_DARK_SLASH
Definition: boss_ymiron.cpp:62
void JustEngagedWith(Unit *who) override
SummonList summons
EventMap events
void _JustDied()
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:56
void AttackStart(Unit *victim) override
== Triggered Actions Requested ==================
Definition: CreatureAI.cpp:328
Creature *const me
Definition: CreatureAI.h:61
void SetReactState(ReactStates st)
Definition: Creature.h:160
void SetDisplayId(uint32 displayId, bool setNative=false) override
Definition: Creature.cpp:3402
CreatureAI * AI() const
Definition: Creature.h:214
void DelayEvents(Milliseconds delay)
Definition: EventMap.cpp:96
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition: EventMap.cpp:36
void CancelEvent(uint32 eventId)
Definition: EventMap.cpp:131
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< float > closeEnoughDistance={})
bool IsEmpty() const
Definition: ObjectGuid.h:319
void Clear()
Definition: ObjectGuid.h:286
static Creature * ToCreature(Object *o)
Definition: Object.h:219
TypeID GetTypeId() const
Definition: Object.h:173
uint32 GetEntry() const
Definition: Object.h:161
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
uint32 const Id
Definition: SpellInfo.h:325
HookList< HitHandler > OnHit
Definition: SpellScript.h:850
Unit * GetHitUnit() const
void SetHitDamage(int32 damage)
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 DoCast(uint32 spellId)
Definition: UnitAI.cpp:89
Definition: Unit.h:627
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true)
Definition: Unit.cpp:3089
MotionMaster * GetMotionMaster()
Definition: Unit.h:1652
uint64 GetHealth() const
Definition: Unit.h:776
bool HealthBelowPctDamaged(int32 pct, uint32 damage) const
Definition: Unit.h:781
bool AttackStop()
Definition: Unit.cpp:5781
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
bool OnCheck(Player *, Unit *target) override
void Register() override
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
T const & DUNGEON_MODE(T const &normal5, T const &heroic10) const
void AddThreat(Unit *victim, float amount, Unit *who=nullptr)
uint32 GetData(uint32 type) const override
void JustSummoned(Creature *summon) override
void MovementInform(uint32 type, uint32 pointId) override
uint8 ActiveOrder[4]
void Reset() override
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
uint32 HealthAmountMultipler
void JustDied(Unit *) override
uint8 ActivedNumber
void Initialize()
boss_ymiron(Creature *creature)
void DespawnBoatGhosts(ObjectGuid &CreatureGUID)
void SpellHitTarget(WorldObject *target, SpellInfo const *spellInfo) override
ObjectGuid SpiritFountGUID
void ExecuteEvent(uint32 eventId) override
void JustEngagedWith(Unit *who) override
uint32 HealthAmountModifier
ObjectGuid ActiveAncestorGUID
void KilledUnit(Unit *who) override
#define RegisterUtgardePinnacleCreatureAI(ai_name)
@ DATA_KING_YMIRON
@ NPC_TORGYN_VISUAL
@ NPC_AVENGING_SPIRIT
@ NPC_SPIRIT_FOUNT
@ NPC_RANULF_VISUAL
@ NPC_HALDOR_VISUAL
@ NPC_BJORN_VISUAL