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 }
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
129};
130
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
165};
166
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
uint8_t uint8
Definition Define.h:156
uint32_t uint32
Definition Define.h:154
@ IN_PROGRESS
@ DONE
@ NOT_STARTED
@ WAYPOINT_MOTION_TYPE
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
SpellEffIndex
@ EFFECT_0
@ EFFECT_2
@ EMOTE_ONESHOT_NONE
@ SPELL_EFFECT_SCRIPT_EFFECT
@ 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:276
void PreventDefaultAction()
HookList< CheckProcHandler > DoCheckProc
HookList< EffectProcHandler > OnEffectProc
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:63
uint32 ExecuteEvent()
Definition EventMap.cpp:77
void Update(uint32 time)
Definition EventMap.h:61
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition EventMap.cpp:40
void Reset()
Definition EventMap.cpp:25
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={}, Optional< bool > exactSplinePath={}, bool generatePath=true, Optional< MovementFadeObject > fadeObject={}, Scripting::v2::ActionResultSetter< MovementStopReason > &&scriptResult={})
Unit * GetActionTarget() const
Definition Unit.h:500
SpellInfo const * GetSpellInfo() const
Definition Unit.cpp:281
uint64 GetAllEffectsMechanicMask() const
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Unit * GetCaster() const
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:89
Definition Unit.h:635
void SetAnimTier(AnimTier animTier, bool notifyClient=true)
Definition Unit.cpp:10745
MotionMaster * GetMotionMaster()
Definition Unit.h:1723
bool IsAlive() const
Definition Unit.h:1185
void SetEmoteState(Emote emote)
Definition Unit.h:865
bool HasUnitState(const uint32 f) const
Definition Unit.h:743
GameObject * FindNearestGameObject(uint32 entry, float range, bool spawnedOnly=true) const
Definition Object.cpp:1539
InstanceScript * GetInstanceScript() const
Definition Object.cpp:396
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2217
float GetDistance2d(WorldObject const *obj) const
Definition Object.cpp:450
float GetDistance(WorldObject const *obj) const
Definition Object.cpp:432
bool IsWithinDist(WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=true) const
Definition Object.cpp:496
virtual void SetData(uint32, uint32)
Definition ZoneScript.h:100
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
@ SPELL_FIXATE_TRIGGER
@ DATA_FORGE_1
#define RegisterUtgardeKeepCreatureAI(ai_name)
@ GO_GLOWING_ANVIL_1
@ GO_GLOWING_ANVIL_2
@ GO_GLOWING_ANVIL_3