TrinityCore
Loading...
Searching...
No Matches
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
40
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
69
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
244 }
245
246private:
248};
249
250// 68786, 70336 - Permafrost
252{
254
255public:
257 {
258 prevented = false;
259 }
260
261private:
263 {
264 if (missInfo != SPELL_MISS_NONE)
265 return;
266
267 if (Unit* target = GetHitUnit())
268 {
269 Unit* caster = GetCaster();
270 //Temporary Line of Sight Check
271 std::list<GameObject*> blockList;
272 caster->GetGameObjectListWithEntryInGrid(blockList, GO_SARONITE_ROCK, 100.0f);
273 if (!blockList.empty())
274 {
275 for (std::list<GameObject*>::const_iterator itr = blockList.begin(); itr != blockList.end(); ++itr)
276 {
277 if (!(*itr)->IsInvisibleDueToDespawn())
278 {
279 if ((*itr)->IsInBetween(caster, target, 4.0f))
280 {
281 prevented = true;
282 target->ApplySpellImmune(GetSpellInfo()->Id, IMMUNITY_ID, GetSpellInfo()->Id, true);
287 break;
288 }
289 }
290 }
291 }
292 }
293 }
294
296 {
297 if (Unit* target = GetHitUnit())
298 {
299 target->ApplySpellImmune(GetSpellInfo()->Id, IMMUNITY_ID, GetSpellInfo()->Id, false);
300 if (prevented)
302 }
303 }
304
310
312};
313
315{
316 public:
317 achievement_doesnt_go_to_eleven() : AchievementCriteriaScript("achievement_doesnt_go_to_eleven") { }
318
319 bool OnCheck(Player* /*source*/, Unit* target) override
320 {
321 if (target)
322 if (Creature* garfrost = target->ToCreature())
323 if (garfrost->AI()->GetData(ACHIEV_DOESNT_GO_TO_ELEVEN) <= 10)
324 return true;
325
326 return false;
327 }
328};
329
uint32_t uint32
Definition Define.h:133
@ EFFECT_MOTION_TYPE
@ TYPEID_PLAYER
Definition ObjectGuid.h:39
Spells
Definition PlayerAI.cpp:32
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1128
@ EFFECT_1
@ EFFECT_0
@ EFFECT_2
@ IMMUNITY_ID
SpellMissInfo
@ SPELL_MISS_NONE
#define BeforeSpellHitFn(F)
#define SpellHitFn(F)
@ UNIT_STATE_CASTING
Definition Unit.h:235
DamageEffectType
Definition Unit.h:352
@ ACHIEV_DOESNT_GO_TO_ELEVEN
#define SPELL_PERMAFROST_HELPER
Position const northForgePos
#define SPELL_FORGE_BLADE_HELPER
void AddSC_boss_garfrost()
Position const southForgePos
Yells
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
EventMap events
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
void CallForHelp(float fRadius)
void Update(uint32 time)
Definition EventMap.h:67
void DelayEvents(Milliseconds delay)
Definition EventMap.cpp:95
EventId ExecuteEvent()
Definition EventMap.cpp:73
bool IsInPhase(PhaseIndex phase) const
Definition EventMap.h:236
void SetPhase(PhaseIndex phase)
Definition EventMap.cpp:28
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:36
virtual ObjectGuid GetGuidData(uint32 type) const override
void MoveJump(Position const &pos, float speedXY, float speedZ, uint32 id=EVENT_JUMP, bool hasOrientation=false)
static Creature * ToCreature(Object *o)
Definition Object.h:186
static Unit * ToUnit(Object *o)
Definition Object.h:192
TypeID GetTypeId() const
Definition Object.h:93
uint32 Id
Definition SpellInfo.h:289
Unit * GetCaster() const
HookList< HitHandler > AfterHit
void PreventHitDamage()
void PreventHitDefaultEffect(SpellEffIndex effIndex)
Unit * GetHitUnit() const
HookList< BeforeHitHandler > BeforeHit
void PreventHitAura()
SpellInfo const * GetSpellInfo() const
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition UnitAI.cpp:96
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:106
Definition Unit.h:769
Aura * GetAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition Unit.cpp:4439
void RemoveAllGameObjects()
Definition Unit.cpp:5172
MotionMaster * GetMotionMaster()
Definition Unit.h:1667
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3784
Unit * GetVictim() const
Definition Unit.h:859
bool HasUnitState(const uint32 f) const
Definition Unit.h:876
bool AttackStop()
Definition Unit.cpp:5645
void GetGameObjectListWithEntryInGrid(Container &gameObjectContainer, uint32 entry, float maxSearchRange=250.0f) const
Definition Object.cpp:3133
bool OnCheck(Player *, Unit *target) override
PrepareSpellScript(spell_garfrost_permafrost)
void PreventHitByLoS(SpellMissInfo missInfo)
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
#define RegisterPitOfSaronCreatureAI(ai_name)
@ DATA_GARFROST
@ DATA_TYRANNUS
@ GO_SARONITE_ROCK
void SetEquipmentSlots(bool loadDefault, int32 mainHand=EQUIP_NO_CHANGE, int32 offHand=EQUIP_NO_CHANGE, int32 ranged=EQUIP_NO_CHANGE)
void AttackStart(Unit *) override
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