TrinityCore
boss_forgemaster_garfrost.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 "GameObject.h"
20#include "InstanceScript.h"
21#include "MotionMaster.h"
22#include "ObjectAccessor.h"
23#include "pit_of_saron.h"
24#include "ScriptedCreature.h"
25#include "SpellAuras.h"
26#include "SpellScript.h"
27
29{
37
39};
40
42{
49 SPELL_FORGE_BLADE = 68774
50};
51
52#define SPELL_PERMAFROST_HELPER RAID_MODE<uint32>(68786, 70336)
53#define SPELL_FORGE_BLADE_HELPER RAID_MODE<uint32>(68774, 70334)
54
56{
59 PHASE_THREE = 3
60};
61
63{
67 POINT_FORGE = 0
68};
69
71{
77};
78
79Position const northForgePos = { 722.5643f, -234.1615f, 527.182f, 2.16421f };
80Position const southForgePos = { 639.257f, -210.1198f, 529.015f, 0.523599f };
81
82struct boss_garfrost : public BossAI
83{
85 {
86 Initialize();
87 }
88
90 {
92 }
93
94 void Reset() override
95 {
96 _Reset();
99 Initialize();
100 }
101
102 void JustEngagedWith(Unit* who) override
103 {
107 me->CallForHelp(70.0f);
109 }
110
111 void KilledUnit(Unit* victim) override
112 {
113 if (victim->GetTypeId() == TYPEID_PLAYER)
114 Talk(SAY_SLAY);
115 }
116
117 void JustDied(Unit* /*killer*/) override
118 {
119 _JustDied();
122
124 tyrannus->AI()->Talk(SAY_TYRANNUS_DEATH);
125 }
126
127 void DamageTaken(Unit* /*attacker*/, uint32& /*damage*/, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
128 {
130 {
136 return;
137 }
138
140 {
146 return;
147 }
148 }
149
150 void MovementInform(uint32 type, uint32 id) override
151 {
152 if (type != EFFECT_MOTION_TYPE || id != POINT_FORGE)
153 return;
154
156 {
159 }
161 {
165 }
167 }
168
169 void SpellHitTarget(WorldObject* target, SpellInfo const* spellInfo) override
170 {
171 Unit* unitTarget = target->ToUnit();
172 if (!unitTarget)
173 return;
174
175 if (spellInfo->Id == SPELL_PERMAFROST_HELPER)
176 {
177 if (Aura* aura = unitTarget->GetAura(SPELL_PERMAFROST_HELPER))
178 _permafrostStack = std::max<uint32>(_permafrostStack, aura->GetStackAmount());
179 }
180 }
181
182 uint32 GetData(uint32 /*type*/) const override
183 {
184 return _permafrostStack;
185 }
186
187 void UpdateAI(uint32 diff) override
188 {
189 if (!UpdateVictim())
190 return;
191
192 events.Update(diff);
193
195 return;
196
197 while (uint32 eventId = events.ExecuteEvent())
198 {
199 switch (eventId)
200 {
202 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 0.0f, true))
203 {
204 Talk(SAY_THROW_SARONITE, target);
206 }
208 break;
212 break;
214 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 0.0f, true))
215 {
216 Talk(SAY_CAST_DEEP_FREEZE, target);
217 DoCast(target, SPELL_DEEP_FREEZE);
218 }
220 break;
221 case EVENT_FORGE_JUMP:
222 me->AttackStop();
225 else if (events.IsInPhase(PHASE_THREE))
227 break;
231 else if (events.IsInPhase(PHASE_THREE))
234 break;
235 default:
236 break;
237 }
238
240 return;
241 }
242 }
243
244private:
246};
247
248// 68786, 70336 - Permafrost
250{
251public:
253 {
254 prevented = false;
255 }
256
257private:
259 {
260 if (missInfo != SPELL_MISS_NONE)
261 return;
262
263 if (Unit* target = GetHitUnit())
264 {
265 Unit* caster = GetCaster();
266 //Temporary Line of Sight Check
267 std::list<GameObject*> blockList;
268 caster->GetGameObjectListWithEntryInGrid(blockList, GO_SARONITE_ROCK, 100.0f);
269 if (!blockList.empty())
270 {
271 for (std::list<GameObject*>::const_iterator itr = blockList.begin(); itr != blockList.end(); ++itr)
272 {
273 if (!(*itr)->IsInvisibleDueToDespawn(target))
274 {
275 if ((*itr)->IsInBetween(caster, target, 4.0f))
276 {
277 prevented = true;
278 target->ApplySpellImmune(GetSpellInfo()->Id, IMMUNITY_ID, GetSpellInfo()->Id, true);
283 break;
284 }
285 }
286 }
287 }
288 }
289 }
290
292 {
293 if (Unit* target = GetHitUnit())
294 {
295 target->ApplySpellImmune(GetSpellInfo()->Id, IMMUNITY_ID, GetSpellInfo()->Id, false);
296 if (prevented)
298 }
299 }
300
301 void Register() override
302 {
305 }
306
308};
309
311{
312 public:
313 achievement_doesnt_go_to_eleven() : AchievementCriteriaScript("achievement_doesnt_go_to_eleven") { }
314
315 bool OnCheck(Player* /*source*/, Unit* target) override
316 {
317 if (target)
318 if (Creature* garfrost = target->ToCreature())
319 if (garfrost->AI()->GetData(ACHIEV_DOESNT_GO_TO_ELEVEN) <= 10)
320 return true;
321
322 return false;
323 }
324};
325
327{
331}
uint32_t uint32
Definition: Define.h:142
@ EFFECT_MOTION_TYPE
@ TYPEID_PLAYER
Definition: ObjectGuid.h:41
Spells
Definition: PlayerAI.cpp:32
#define RegisterSpellScript(spell_script)
Definition: ScriptMgr.h:1369
@ EFFECT_1
Definition: SharedDefines.h:31
@ EFFECT_0
Definition: SharedDefines.h:30
@ EFFECT_2
Definition: SharedDefines.h:32
SpellMissInfo
@ SPELL_MISS_NONE
@ IMMUNITY_ID
#define BeforeSpellHitFn(F)
Definition: SpellScript.h:847
#define SpellHitFn(F)
Definition: SpellScript.h:854
DamageEffectType
Definition: UnitDefines.h:131
@ UNIT_STATE_CASTING
Definition: Unit.h:270
MiscData
@ ACHIEV_DOESNT_GO_TO_ELEVEN
#define SPELL_PERMAFROST_HELPER
Position const northForgePos
@ SPELL_THUNDERING_STOMP
#define SPELL_FORGE_BLADE_HELPER
void AddSC_boss_garfrost()
Position const southForgePos
Yells
InstanceScript *const instance
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 CallForHelp(float fRadius)
Definition: Creature.cpp:2563
uint32 ExecuteEvent()
Definition: EventMap.cpp:73
void Update(uint32 time)
Definition: EventMap.h:56
void DelayEvents(Milliseconds delay)
Definition: EventMap.cpp:96
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition: EventMap.cpp:36
bool IsInPhase(uint8 phase) const
Definition: EventMap.h:217
void SetPhase(uint8 phase)
Definition: EventMap.cpp:28
virtual ObjectGuid GetGuidData(uint32 type) const override
void MoveJump(Position const &pos, float speedXY, float speedZ, uint32 id=EVENT_JUMP, bool hasOrientation=false, JumpArrivalCastArgs const *arrivalCast=nullptr, Movement::SpellEffectExtraData const *spellEffectExtraData=nullptr)
static Creature * ToCreature(Object *o)
Definition: Object.h:219
static Unit * ToUnit(Object *o)
Definition: Object.h:225
TypeID GetTypeId() const
Definition: Object.h:173
uint32 const Id
Definition: SpellInfo.h:325
Unit * GetCaster() const
HookList< HitHandler > AfterHit
Definition: SpellScript.h:852
void PreventHitDamage()
Definition: SpellScript.h:979
void PreventHitDefaultEffect(SpellEffIndex effIndex)
Unit * GetHitUnit() const
HookList< BeforeHitHandler > BeforeHit
Definition: SpellScript.h:846
void PreventHitAura()
SpellInfo const * GetSpellInfo() const
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 RemoveAllGameObjects()
Definition: Unit.cpp:5302
MotionMaster * GetMotionMaster()
Definition: Unit.h:1652
Aura * GetAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4560
Unit * GetVictim() const
Definition: Unit.h:715
bool HasUnitState(const uint32 f) const
Definition: Unit.h:732
bool AttackStop()
Definition: Unit.cpp:5781
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3831
void GetGameObjectListWithEntryInGrid(Container &gameObjectContainer, uint32 entry, float maxSearchRange=250.0f) const
Definition: Object.cpp:3292
bool OnCheck(Player *, Unit *target) override
void PreventHitByLoS(SpellMissInfo missInfo)
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
#define RegisterPitOfSaronCreatureAI(ai_name)
Definition: pit_of_saron.h:132
@ DATA_GARFROST
Definition: pit_of_saron.h:32
@ DATA_TYRANNUS
Definition: pit_of_saron.h:34
@ GO_SARONITE_ROCK
Definition: pit_of_saron.h:100
void SetEquipmentSlots(bool loadDefault, int32 mainHand=EQUIP_NO_CHANGE, int32 offHand=EQUIP_NO_CHANGE, int32 ranged=EQUIP_NO_CHANGE)
void AttackStart(Unit *) override
== Triggered Actions Requested ==================
bool HealthAbovePct(uint32 pct) const
void JustEngagedWith(Unit *who) override
void DamageTaken(Unit *, uint32 &, DamageEffectType, SpellInfo const *) override
boss_garfrost(Creature *creature)
void UpdateAI(uint32 diff) override
void SpellHitTarget(WorldObject *target, SpellInfo const *spellInfo) override
void JustDied(Unit *) override
uint32 GetData(uint32) const override
void MovementInform(uint32 type, uint32 id) override
void KilledUnit(Unit *victim) override