TrinityCore
Loading...
Searching...
No Matches
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
46
57
70
75
80
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
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
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
uint8_t uint8
Definition Define.h:156
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
@ POINT_MOTION_TYPE
@ TEMPSUMMON_CORPSE_DESPAWN
@ TYPEID_PLAYER
Definition ObjectGuid.h:44
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:1383
#define SpellHitFn(F)
@ REACT_PASSIVE
@ REACT_AGGRESSIVE
DamageEffectType
@ UNIT_FLAG_NON_ATTACKABLE
MovePoints
@ EVENT_GROUP_BASE_SPELLS
@ DATA_KINGS_BANE
void AddSC_boss_ymiron()
static ActiveBoatStruct ActiveBoat[4]
@ SPELL_SPIRIT_BURST
@ SPELL_SCREAMS_OF_THE_DEAD
@ SPELL_SUMMON_AVENGING_SPIRIT
@ SPELL_CHANNEL_SPIRIT_TO_YMIRON
@ SPELL_BANE_HIT
@ SPELL_CHANNEL_YMIRON_TO_SPIRIT
@ SPELL_SPIRIT_FOUNT
@ SPELL_SUMMON_SPIRIT_FOUNT
@ SPELL_ANCESTORS_VENGEANCE
@ SPELL_SPIRIT_STRIKE
@ SPELL_DARK_SLASH
@ SPELL_BANE
@ SPELL_FETID_ROT
@ POINT_BOAT
@ SAY_DEATH
@ SAY_SUMMON_BJORN
@ SAY_SUMMON_RANULF
@ SAY_SUMMON_TORGYN
@ SAY_AGGRO
@ SAY_SLAY
@ SAY_SUMMON_HALDOR
@ EVENT_TORGYN_SUMMON_AVENGING_SPIRITS
@ EVENT_FETID_ROT
@ EVENT_BJORN_SPIRIT_FOUNT
@ EVENT_ANCESTORS_VENGEANCE
@ EVENT_RANULF_SPIRIT_BURST
@ EVENT_HALDOR_SPIRIT_STRIKE
@ EVENT_BANE
@ EVENT_RESUME_COMBAT
@ EVENT_DARK_SLASH
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
TypeID GetTypeId() const
Definition BaseEntity.h:166
void JustEngagedWith(Unit *who) override
SummonList summons
EventMap events
void AttackStart(Unit *victim) override
== Triggered Actions Requested ==================
Creature *const me
Definition CreatureAI.h:63
void SetReactState(ReactStates st)
Definition Creature.h:174
void SetDisplayId(uint32 displayId, bool setNative=false) override
CreatureAI * AI() const
Definition Creature.h:228
void DelayEvents(Milliseconds delay)
Definition EventMap.cpp:100
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition EventMap.cpp:40
void CancelEvent(uint32 eventId)
Definition EventMap.cpp:135
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< float > closeEnoughDistance={}, Optional< MovementFadeObject > fadeObject={}, Scripting::v2::ActionResultSetter< MovementStopReason > &&scriptResult={})
bool IsEmpty() const
Definition ObjectGuid.h:362
void Clear()
Definition ObjectGuid.h:329
uint32 GetEntry() const
Definition Object.h:89
Creature * ToCreature()
Definition Object.h:121
uint32 const Id
Definition SpellInfo.h:328
HookList< HitHandler > OnHit
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:635
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true)
Definition Unit.cpp:3231
MotionMaster * GetMotionMaster()
Definition Unit.h:1723
uint64 GetHealth() const
Definition Unit.h:788
bool HealthBelowPctDamaged(float pct, uint32 damage) const
Definition Unit.h:793
bool AttackStop()
Definition Unit.cpp:5965
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2217
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:1398
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