TrinityCore
stonecore.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 "ObjectMgr.h"
23#include "Player.h"
24#include "ScriptedCreature.h"
25#include "SpellScript.h"
26#include "stonecore.h"
27
29{
30 // Millhouse Manastorm
33};
34
36{
37 // Millhouse Manastorm
41 SPELL_FEAR = 81442,
42// SPELL_MILLHOUSE_SAFE_CHECK = 81213, // unknown purpose
44 SPELL_BLUR = 81216,
49
50// SPELL_PORTAL_VISUAL = 79754,
51};
52
54{
56
57 // Millhouse Manastorm
61
65};
66
68{
70
75
80};
81
83{
85
89};
90
91// Millhouse trash groups
92Position const MillhousePointGroup2 = { 977.3045f, 895.2347f, 306.3298f };
93Position const MillhousePointGroup3 = { 1049.823f, 871.4349f, 295.006f };
94Position const MillhousePointGroup4 = { 1149.04f, 884.431f, 284.9406f };
95
96// TO-DO:
97// - Millhouse Manastorm should face and cast SPELL_TIGULE_AND_FORORS_SPECIAL_BLEND, but he won't. :(
98
99// 43391 - Millhouse Manastorm
101{
102 public:
103 npc_sc_millhouse_manastorm() : CreatureScript("npc_sc_millhouse_manastorm") { }
104
106 {
108 _instance(creature->GetInstanceScript())
109 {
111 me->SetCanMelee(false); // DoSpellAttackIfReady
112 }
113
115 {
119 }
120
121 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
122 {
123 if (damage >= me->GetHealth())
124 damage = me->GetHealth() - 1;
125
126 if (!HealthBelowPct(50) || me->HasAura(SPELL_BLUR))
127 return;
128
129 switch (events.GetPhaseMask())
130 {
132 events.Reset();
140 break;
142 events.Reset();
150 break;
152 events.Reset();
159 break;
160 default:
161 break;
162 }
163
165 }
166
167 void MovementInform(uint32 type, uint32 pointId) override
168 {
169 if (type != POINT_MOTION_TYPE)
170 return;
171
172 if (pointId < POINT_MILLHOUSE_GROUP_2 || pointId > POINT_MILLHOUSE_GROUP_4)
173 return;
174
176 me->CombatStop(true);
178
179 switch (pointId)
180 {
184 if (Creature* worldtrigger = me->FindNearestCreature(NPC_WORLDTRIGGER, 200.0f))
185 me->SetFacingToObject(worldtrigger);
189 break;
193 me->SetFacingTo(5.931499f);
197 break;
199 me->SetFacingTo(3.455752f);
203 break;
204 default:
205 break;
206 }
207 }
208
209 void UpdateAI(uint32 diff) override
210 {
211 // Do not update events if Millhouse is aggressive and has no combat.
213 return;
214
215 events.Update(diff);
216
217 // Impending Doom is exception because it needs to be interrupted.
219 return;
220
221 while (uint32 eventId = events.ExecuteEvent())
222 {
223 switch (eventId)
224 {
228 break;
229 case EVENT_SHADOWFURY:
230 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 0.0f, true))
231 DoCast(target, SPELL_SHADOWFURY);
233 break;
234 case EVENT_FEAR:
235 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 0.0f, true))
236 DoCast(target, SPELL_FEAR);
238 break;
243 break;
248 break;
254 break;
255 default:
256 break;
257 }
258 }
259
261 }
262
263 private:
266 };
267
268 CreatureAI* GetAI(Creature* creature) const override
269 {
270 return GetStonecoreAI<npc_sc_millhouse_manastormAI>(creature);
271 }
272};
273
274// 81459 - Force of Earth
276{
277 public:
278 spell_force_of_earth() : SpellScriptLoader("spell_force_of_earth") { }
279
281 {
282 void DummyEffect(SpellEffIndex /*effIndex*/)
283 {
284 GetCaster()->SetDisplayId(26693); // can be moved to SAI part, need sniffs to see what this dummy does (note: npc 43552)
285 }
286
287 void Register() override
288 {
290 }
291 };
292
293 SpellScript* GetSpellScript() const override
294 {
296 }
297};
298
299// 93167 - Twilight Documents
301{
302 public:
303 spell_sc_twilight_documents() : SpellScriptLoader("spell_sc_twilight_documents") { }
304
306 {
307 bool Validate(SpellInfo const* /*spell*/) override
308 {
309 if (!sObjectMgr->GetGameObjectTemplate(GAMEOBJECT_TWILIGHT_DOCUMENTS))
310 return false;
311 return true;
312 }
313
315 {
316 if (WorldLocation* loc = GetHitDest())
317 GetCaster()->SummonGameObject(GAMEOBJECT_TWILIGHT_DOCUMENTS, *loc, QuaternionData::fromEulerAnglesZYX(loc->GetOrientation(), 0.0f, 0.0f), 2h);
318 }
319
320 void Register() override
321 {
323 }
324 };
325
326 SpellScript* GetSpellScript() const override
327 {
329 }
330};
331
332// 81008 - Quake
334{
335 public:
336 bool operator()(WorldObject* object) const
337 {
338 Player* player = object->ToPlayer();
339 return (player && (player->IsFalling() || player->HasUnitState(UNIT_STATE_JUMPING)));
340 }
341};
342
344{
345 public:
346 spell_sc_quake() : SpellScriptLoader("spell_sc_quake") { }
347
349 {
350 void FilterTargets(std::list<WorldObject*>& unitList)
351 {
352 unitList.remove_if(JumpCheck());
353 }
354
355 void Register() override
356 {
358 }
359 };
360
361 SpellScript* GetSpellScript() const override
362 {
363 return new spell_sc_quake_SpellScript();
364 }
365};
366
368{
369public:
370 at_sc_corborus_intro() : AreaTriggerScript("at_sc_corborus_intro") { }
371
372 bool OnTrigger(Player* player, AreaTriggerEntry const* /*areaTrigger*/) override
373 {
374 if (InstanceScript* instance = player->GetInstanceScript())
375 if (Creature* corborus = instance->GetCreature(DATA_CORBORUS))
376 corborus->AI()->DoAction(ACTION_CORBORUS_INTRO);
377 return true;
378 }
379};
380
382{
383public:
384 at_sc_slabhide_intro() : AreaTriggerScript("at_sc_slabhide_intro") { }
385
386 bool OnTrigger(Player* player, AreaTriggerEntry const* /*areaTrigger*/) override
387 {
388 if (InstanceScript* instance = player->GetInstanceScript())
389 if (Creature* slabhide = instance->GetCreature(DATA_SLABHIDE))
390 slabhide->AI()->DoAction(ACTION_SLABHIDE_INTRO);
391 return true;
392 }
393};
394
396{
400 new spell_sc_quake();
403}
Texts
uint32_t uint32
Definition: Define.h:142
@ POINT_MOTION_TYPE
#define sObjectMgr
Definition: ObjectMgr.h:1946
Spells
Definition: PlayerAI.cpp:32
SpellEffIndex
Definition: SharedDefines.h:29
@ EFFECT_0
Definition: SharedDefines.h:30
@ TARGET_UNIT_SRC_AREA_ENEMY
@ EMOTE_ONESHOT_KNOCKDOWN
@ SPELL_EFFECT_DUMMY
#define SpellEffectFn(F, I, N)
Definition: SpellScript.h:842
#define SpellObjectAreaTargetSelectFn(F, I, N)
Definition: SpellScript.h:864
@ REACT_PASSIVE
Definition: UnitDefines.h:506
@ REACT_AGGRESSIVE
Definition: UnitDefines.h:508
DamageEffectType
Definition: UnitDefines.h:131
@ UNIT_FLAG_IN_COMBAT
Definition: UnitDefines.h:163
@ UNIT_STATE_CASTING
Definition: Unit.h:270
@ UNIT_STATE_JUMPING
Definition: Unit.h:273
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 EngagementOver()
Definition: CreatureAI.cpp:287
void SetCanMelee(bool canMelee, bool fleeFromMelee=false)
Definition: Creature.cpp:2822
void SetReactState(ReactStates st)
Definition: Creature.h:160
ReactStates GetReactState() const
Definition: Creature.h:161
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
uint8 GetPhaseMask() const
Definition: EventMap.h:75
void SetPhase(uint8 phase)
Definition: EventMap.cpp:28
void Reset()
Definition: EventMap.cpp:21
bool operator()(WorldObject *object) const
Definition: stonecore.cpp:336
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< float > closeEnoughDistance={})
static Player * ToPlayer(Object *o)
Definition: Object.h:213
WorldLocation * GetHitDest() const
Unit * GetCaster() const
HookList< EffectHandler > OnEffectHit
Definition: SpellScript.h:839
HookList< EffectHandler > OnEffectLaunch
Definition: SpellScript.h:837
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
Definition: SpellScript.h:863
bool DoSpellAttackIfReady(uint32 spellId)
Definition: UnitAI.cpp:61
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 DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.h:161
SpellCastResult DoCast(uint32 spellId)
Definition: UnitAI.cpp:89
Definition: Unit.h:627
void CombatStop(bool includingCast=false, bool mutualPvP=true, bool(*unitFilter)(Unit const *otherUnit)=nullptr)
Definition: Unit.cpp:5827
Spell * FindCurrentSpellBySpellId(uint32 spell_id) const
Definition: Unit.cpp:3104
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true)
Definition: Unit.cpp:3089
MotionMaster * GetMotionMaster()
Definition: Unit.h:1652
void SetFacingToObject(WorldObject const *object, bool force=true)
Definition: Unit.cpp:12671
uint64 GetHealth() const
Definition: Unit.h:776
void SetFacingTo(float const ori, bool force=true)
Definition: Unit.cpp:12653
bool HasUnitState(const uint32 f) const
Definition: Unit.h:732
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4664
void RemoveAllAuras()
Definition: Unit.cpp:4242
void HandleEmoteCommand(Emote emoteId, Player *target=nullptr, Trinity::IteratorPair< int32 const * > spellVisualKitIds={}, int32 sequenceVariation=0)
Definition: Unit.cpp:1598
void SetUnitFlag(UnitFlags flags)
Definition: Unit.h:833
bool IsFalling() const
Definition: Unit.cpp:12308
virtual void SetDisplayId(uint32 displayId, bool setNative=false)
Definition: Unit.cpp:10148
void RemoveUnitFlag(UnitFlags flags)
Definition: Unit.h:834
InstanceScript * GetInstanceScript() const
Definition: Object.cpp:1042
GameObject * SummonGameObject(uint32 entry, Position const &pos, QuaternionData const &rot, Seconds respawnTime, GOSummonType summonType=GO_SUMMON_TIMED_OR_CORPSE_DESPAWN)
Definition: Object.cpp:2065
Creature * FindNearestCreature(uint32 entry, float range, bool alive=true) const
Definition: Object.cpp:2148
bool OnTrigger(Player *player, AreaTriggerEntry const *) override
Definition: stonecore.cpp:372
bool OnTrigger(Player *player, AreaTriggerEntry const *) override
Definition: stonecore.cpp:386
CreatureAI * GetAI(Creature *creature) const override
Definition: stonecore.cpp:268
SpellScript * GetSpellScript() const override
Definition: stonecore.cpp:293
void FilterTargets(std::list< WorldObject * > &unitList)
Definition: stonecore.cpp:350
SpellScript * GetSpellScript() const override
Definition: stonecore.cpp:361
SpellScript * GetSpellScript() const override
Definition: stonecore.cpp:326
MovementPoints
Position const MillhousePointGroup4
Definition: stonecore.cpp:94
@ SPELL_CLEAR_ALL_DEBUFFS
Definition: stonecore.cpp:43
@ SPELL_TIGULE_AND_FORORS_SPECIAL_BLEND
Definition: stonecore.cpp:46
@ SPELL_ANCHOR_HERE
Definition: stonecore.cpp:45
@ SPELL_FEAR
Definition: stonecore.cpp:41
@ SPELL_SHADOW_BOLT
Definition: stonecore.cpp:38
@ SPELL_FROSTBOLT_VOLLEY
Definition: stonecore.cpp:39
@ SPELL_IMPENDING_DOOM
Definition: stonecore.cpp:47
@ SPELL_SHADOWFURY
Definition: stonecore.cpp:40
@ SPELL_BLUR
Definition: stonecore.cpp:44
@ SPELL_IMPENDING_DOOM_CHANNEL
Definition: stonecore.cpp:48
Position const MillhousePointGroup3
Definition: stonecore.cpp:93
void AddSC_stonecore()
Definition: stonecore.cpp:395
@ POINT_MILLHOUSE_GROUP_4
Definition: stonecore.cpp:88
@ POINT_NONE
Definition: stonecore.cpp:84
@ POINT_MILLHOUSE_GROUP_3
Definition: stonecore.cpp:87
@ POINT_MILLHOUSE_GROUP_2
Definition: stonecore.cpp:86
@ SAY_MILLHOUSE_EVENT_1
Definition: stonecore.cpp:31
@ SAY_MILLHOUSE_EVENT_2
Definition: stonecore.cpp:32
Position const MillhousePointGroup2
Definition: stonecore.cpp:92
@ PHASE_MASK_MILLHOUSE_GROUP_2
Definition: stonecore.cpp:77
@ PHASE_MILLHOUSE_GROUP_2
Definition: stonecore.cpp:72
@ PHASE_NONE
Definition: stonecore.cpp:69
@ PHASE_MILLHOUSE_GROUP_1
Definition: stonecore.cpp:71
@ PHASE_MASK_MILLHOUSE_GROUP_4
Definition: stonecore.cpp:79
@ PHASE_MILLHOUSE_GROUP_3
Definition: stonecore.cpp:73
@ PHASE_MILLHOUSE_GROUP_4
Definition: stonecore.cpp:74
@ PHASE_MASK_MILLHOUSE_GROUP_1
Definition: stonecore.cpp:76
@ PHASE_MASK_MILLHOUSE_GROUP_3
Definition: stonecore.cpp:78
@ EVENT_FROSTBOLT_VOLLEY
Definition: stonecore.cpp:58
@ EVENT_CAST_IMPENDING_DOOM
Definition: stonecore.cpp:63
@ EVENT_READY_FOR_COMBAT
Definition: stonecore.cpp:62
@ EVENT_NONE
Definition: stonecore.cpp:55
@ EVENT_FEAR
Definition: stonecore.cpp:60
@ EVENT_SHADOWFURY
Definition: stonecore.cpp:59
@ EVENT_INTERRUPT_IMPENDING_DOOM
Definition: stonecore.cpp:64
@ DATA_CORBORUS
Definition: stonecore.h:29
@ DATA_SLABHIDE
Definition: stonecore.h:30
@ ACTION_SLABHIDE_INTRO
Definition: stonecore.h:52
@ ACTION_CORBORUS_INTRO
Definition: stonecore.h:51
@ NPC_WORLDTRIGGER
Definition: stonecore.h:54
@ GAMEOBJECT_TWILIGHT_DOCUMENTS
Definition: stonecore.h:68
static QuaternionData fromEulerAnglesZYX(float Z, float Y, float X)
Definition: GameObject.cpp:118
bool HealthBelowPct(uint32 pct) const
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
Definition: stonecore.cpp:121
void MovementInform(uint32 type, uint32 pointId) override
Definition: stonecore.cpp:167