TrinityCore
Loading...
Searching...
No Matches
utgarde_keep.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 "ScriptedCreature.h"
23#include "SpellInfo.h"
24#include "SpellScript.h"
25#include "utgarde_keep.h"
26
33
35{
37 {
38 _instance = creature->GetInstanceScript();
39 _forgeId = 0;
40 }
41
42 void Reset() override
43 {
44 if (!_forgeId)
46
47 if (!me->IsAlive())
48 return;
49
50 if (_forgeId)
52 }
53
54 void JustDied(Unit* /*killer*/) override
55 {
56 if (!_forgeId)
58
59 if (_forgeId)
61 }
62
63 void JustEngagedWith(Unit* /*who*/) override
64 {
65 if (!_forgeId)
67
68 if (_forgeId)
70
72 }
73
74 void UpdateAI(uint32 /*diff*/) override
75 {
76 if (!_forgeId)
78
79 if (!UpdateVictim())
80 return;
81
83 }
84
85private:
87 {
88 float diff = 30.0f;
89 uint8 id = 0;
90
91 for (uint8 i = 0; i < 3; ++i)
92 {
94 {
95 if (me->IsWithinDist(go, diff, false))
96 {
97 id = i + 1;
98 diff = me->GetDistance2d(go);
99 }
100 }
101 }
102 return id > 0 && id < 4 ? id : 0;
103 }
104
107};
108
110{
113
114// 40414 - Fixate
116{
118
119 bool Validate(SpellInfo const* /*spellInfo*/) override
120 {
122 }
123
125 {
127 }
128
133};
134
139
140// 42770 - Second Wind
142{
144
145 bool Validate(SpellInfo const* /*spellInfo*/) override
146 {
148 }
149
150 bool CheckProc(ProcEventInfo& eventInfo)
151 {
152 SpellInfo const* spellInfo = eventInfo.GetSpellInfo();
153 if (!spellInfo)
154 return false;
155
156 return (spellInfo->GetAllEffectsMechanicMask() & ((1 << MECHANIC_ROOT) | (1 << MECHANIC_STUN))) != 0;
157 }
158
159 void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
160 {
162 Unit* caster = eventInfo.GetActionTarget();
163 caster->CastSpell(caster, SPELL_SECOND_WIND_TRIGGER, aurEff);
164 }
165
171};
172
190
191const Position protodrakeCheckPos = {206.24f, -190.28f, 200.11f, 0.f};
192
194{
196 {
197 _setData = false;
198 }
199
200 void Reset() override
201 {
202 _events.Reset();
206 }
207
208 void MovementInform(uint32 type, uint32 id) override
209 {
210 if (type == WAYPOINT_MOTION_TYPE && id == POINT_LAST)
211 {
213 }
214 }
215
216 void SetData(uint32 type, uint32 data) override
217 {
219 {
220 _setData = true;
223 }
224 }
225
226 void UpdateAI(uint32 diff) override
227 {
228 if (!UpdateVictim())
229 return;
230
231 _events.Update(diff);
232
234 return;
235
236 while (uint32 eventid = _events.ExecuteEvent())
237 {
238 switch (eventid)
239 {
240 case EVENT_REND:
243 break;
247 break;
248 case EVENT_KNOCKAWAY:
251 break;
252 default:
253 break;
254 }
255 }
256
258 }
259
260private:
263};
264
uint8_t uint8
Definition Define.h:135
uint32_t uint32
Definition Define.h:133
@ IN_PROGRESS
@ DONE
@ NOT_STARTED
@ WAYPOINT_MOTION_TYPE
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1128
SpellEffIndex
@ EFFECT_0
@ EFFECT_2
@ SPELL_EFFECT_SCRIPT_EFFECT
@ EMOTE_ONESHOT_NONE
@ MECHANIC_STUN
@ MECHANIC_ROOT
@ SPELL_AURA_DUMMY
#define AuraEffectProcFn(F, I, N)
#define SpellEffectFn(F, I, N)
#define AuraCheckProcFn(F)
@ UNIT_STATE_CASTING
Definition Unit.h:235
void PreventDefaultAction()
HookList< CheckProcHandler > DoCheckProc
HookList< EffectProcHandler > OnEffectProc
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
void Update(uint32 time)
Definition EventMap.h:67
EventId ExecuteEvent()
Definition EventMap.cpp:73
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:36
void Reset()
Definition EventMap.cpp:21
void MovePath(uint32 pathId, bool repeatable)
Unit * GetActionTarget() const
Definition Unit.h:509
SpellInfo const * GetSpellInfo() const
Definition Unit.cpp:268
uint32 GetAllEffectsMechanicMask() const
Unit * GetCaster() const
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:106
Definition Unit.h:769
void SetAnimTier(AnimTier animTier)
Definition Unit.cpp:10391
MotionMaster * GetMotionMaster()
Definition Unit.h:1667
bool IsAlive() const
Definition Unit.h:1234
void SetEmoteState(Emote emote)
Definition Unit.h:967
bool HasUnitState(const uint32 f) const
Definition Unit.h:876
GameObject * FindNearestGameObject(uint32 entry, float range, bool spawnedOnly=true) const
Definition Object.cpp:2121
InstanceScript * GetInstanceScript() const
Definition Object.cpp:1087
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2832
float GetDistance2d(WorldObject const *obj) const
Definition Object.cpp:1141
float GetDistance(WorldObject const *obj) const
Definition Object.cpp:1123
bool IsWithinDist(WorldObject const *obj, float dist2compare, bool is3D=true) const
Definition Object.cpp:1187
virtual void SetData(uint32, uint32)
Definition ZoneScript.h:56
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
void Register() override
void HandleScriptEffect(SpellEffIndex)
PrepareSpellScript(spell_fixate)
bool Validate(SpellInfo const *) override
void Register() override
PrepareAuraScript(spell_uk_second_wind)
void HandleProc(AuraEffect const *aurEff, ProcEventInfo &eventInfo)
bool CheckProc(ProcEventInfo &eventInfo)
bool Validate(SpellInfo const *) override
void JustEngagedWith(Unit *) override
void UpdateAI(uint32) override
npc_dragonflayer_forge_master(Creature *creature)
void JustDied(Unit *) override
void UpdateAI(uint32 diff) override
void SetData(uint32 type, uint32 data) override
void MovementInform(uint32 type, uint32 id) override
npc_enslaved_proto_drake(Creature *creature)
const Position protodrakeCheckPos
void AddSC_utgarde_keep()
EnslavedProtoDrake
@ EVENT_FLAME_BREATH
@ EVENT_REND
@ SPELL_FLAME_BREATH
@ TYPE_PROTODRAKE_AT
@ DATA_PROTODRAKE_MOVE
@ POINT_LAST
@ PATH_PROTODRAKE
@ SPELL_KNOCK_AWAY
@ SPELL_REND
@ EVENT_KNOCKAWAY
uint32 ForgeSearch[3]
SecondWind
@ SPELL_SECOND_WIND_TRIGGER
@ SPELL_FIXATE_TRIGGER
@ DATA_FORGE_1
#define RegisterUtgardeKeepCreatureAI(ai_name)
@ GO_GLOWING_ANVIL_1
@ GO_GLOWING_ANVIL_2
@ GO_GLOWING_ANVIL_3