TrinityCore
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
28{
32};
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 }
82
83private:
85 {
86 float diff = 30.0f;
87 uint8 id = 0;
88
89 for (uint8 i = 0; i < 3; ++i)
90 {
92 {
93 if (me->IsWithinDist(go, diff, false))
94 {
95 id = i + 1;
96 diff = me->GetDistance2d(go);
97 }
98 }
99 }
100 return id > 0 && id < 4 ? id : 0;
101 }
102
105};
106
108{
111
112// 40414 - Fixate
114{
115 bool Validate(SpellInfo const* /*spellInfo*/) override
116 {
118 }
119
121 {
123 }
124
125 void Register() override
126 {
128 }
129};
130
132{
135
136// 42770 - Second Wind
138{
139 bool Validate(SpellInfo const* /*spellInfo*/) override
140 {
142 }
143
144 bool CheckProc(ProcEventInfo& eventInfo)
145 {
146 SpellInfo const* spellInfo = eventInfo.GetSpellInfo();
147 if (!spellInfo)
148 return false;
149
150 return (spellInfo->GetAllEffectsMechanicMask() & ((1 << MECHANIC_ROOT) | (1 << MECHANIC_STUN))) != 0;
151 }
152
153 void HandleProc(AuraEffect* aurEff, ProcEventInfo& eventInfo)
154 {
156 Unit* caster = eventInfo.GetActionTarget();
157 caster->CastSpell(caster, SPELL_SECOND_WIND_TRIGGER, aurEff);
158 }
159
160 void Register() override
161 {
164 }
165};
166
168{
171
173
177
178 SPELL_REND = 43931,
181
183};
184
185const Position protodrakeCheckPos = {206.24f, -190.28f, 200.11f, 0.f};
186
188{
190 {
191 _setData = false;
192 }
193
194 void Reset() override
195 {
196 _events.Reset();
200 }
201
202 void MovementInform(uint32 type, uint32 id) override
203 {
204 if (type == WAYPOINT_MOTION_TYPE && id == POINT_LAST)
205 {
207 }
208 }
209
210 void SetData(uint32 type, uint32 data) override
211 {
213 {
214 _setData = true;
217 }
218 }
219
220 void UpdateAI(uint32 diff) override
221 {
222 if (!UpdateVictim())
223 return;
224
225 _events.Update(diff);
226
228 return;
229
230 while (uint32 eventid = _events.ExecuteEvent())
231 {
232 switch (eventid)
233 {
234 case EVENT_REND:
237 break;
241 break;
242 case EVENT_KNOCKAWAY:
245 break;
246 default:
247 break;
248 }
249 }
250 }
251
252private:
255};
256
258{
263}
uint8_t uint8
Definition: Define.h:144
uint32_t uint32
Definition: Define.h:142
@ IN_PROGRESS
@ DONE
@ NOT_STARTED
@ WAYPOINT_MOTION_TYPE
#define RegisterSpellScript(spell_script)
Definition: ScriptMgr.h:1369
SpellEffIndex
Definition: SharedDefines.h:29
@ EFFECT_0
Definition: SharedDefines.h:30
@ EFFECT_2
Definition: SharedDefines.h:32
@ EMOTE_ONESHOT_NONE
@ SPELL_EFFECT_SCRIPT_EFFECT
@ MECHANIC_STUN
@ MECHANIC_ROOT
@ SPELL_AURA_DUMMY
#define AuraEffectProcFn(F, I, N)
Definition: SpellScript.h:2160
#define SpellEffectFn(F, I, N)
Definition: SpellScript.h:842
#define AuraCheckProcFn(F)
Definition: SpellScript.h:2130
@ UNIT_STATE_CASTING
Definition: Unit.h:270
void PreventDefaultAction()
HookList< CheckProcHandler > DoCheckProc
Definition: SpellScript.h:2129
HookList< EffectProcHandler > OnEffectProc
Definition: SpellScript.h:2155
bool UpdateVictim()
Definition: CreatureAI.cpp:245
Creature *const me
Definition: CreatureAI.h:61
uint32 ExecuteEvent()
Definition: EventMap.cpp:73
void Update(uint32 time)
Definition: EventMap.h:56
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition: EventMap.cpp:36
void Reset()
Definition: EventMap.cpp:21
void MovePath(uint32 pathId, bool repeatable, Optional< Milliseconds > duration={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< std::pair< Milliseconds, Milliseconds > > waitTimeRangeAtPathEnd={}, Optional< float > wanderDistanceAtPathEnds={}, Optional< bool > followPathBackwardsFromEndToStart={}, bool generatePath=true)
Unit * GetActionTarget() const
Definition: Unit.h:494
SpellInfo const * GetSpellInfo() const
Definition: Unit.cpp:280
uint64 GetAllEffectsMechanicMask() const
Definition: SpellInfo.cpp:2470
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Definition: SpellScript.h:162
Unit * GetCaster() const
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
Definition: SpellScript.h:840
SpellCastResult DoCast(uint32 spellId)
Definition: UnitAI.cpp:89
Definition: Unit.h:627
void SetAnimTier(AnimTier animTier, bool notifyClient=true)
Definition: Unit.cpp:10114
MotionMaster * GetMotionMaster()
Definition: Unit.h:1652
bool IsAlive() const
Definition: Unit.h:1164
void SetEmoteState(Emote emote)
Definition: Unit.h:852
bool HasUnitState(const uint32 f) const
Definition: Unit.h:732
GameObject * FindNearestGameObject(uint32 entry, float range, bool spawnedOnly=true) const
Definition: Object.cpp:2170
InstanceScript * GetInstanceScript() const
Definition: Object.cpp:1042
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2896
float GetDistance2d(WorldObject const *obj) const
Definition: Object.cpp:1096
float GetDistance(WorldObject const *obj) const
Definition: Object.cpp:1078
bool IsWithinDist(WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=true) const
Definition: Object.cpp:1142
virtual void SetData(uint32, uint32)
Definition: ZoneScript.h:92
void Register() override
void HandleScriptEffect(SpellEffIndex)
bool Validate(SpellInfo const *) override
void Register() override
bool CheckProc(ProcEventInfo &eventInfo)
void HandleProc(AuraEffect *aurEff, 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
Fixate
@ SPELL_FIXATE_TRIGGER
@ DATA_FORGE_1
Definition: utgarde_keep.h:39
#define RegisterUtgardeKeepCreatureAI(ai_name)
Definition: utgarde_keep.h:96
@ GO_GLOWING_ANVIL_1
Definition: utgarde_keep.h:71
@ GO_GLOWING_ANVIL_2
Definition: utgarde_keep.h:72
@ GO_GLOWING_ANVIL_3
Definition: utgarde_keep.h:73