TrinityCore
stratholme.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/* ScriptData
19SDName: Stratholme
20SD%Complete: 100
21SDComment: Misc mobs for instance. go-script to apply aura and start event for quest 8945
22SDCategory: Stratholme
23EndScriptData */
24
25/* ContentData
26go_gauntlet_gate
27npc_freed_soul
28npc_restless_soul
29npc_spectral_ghostly_citizen
30EndContentData */
31
32#include "ScriptMgr.h"
33#include "GameObject.h"
34#include "GameObjectAI.h"
35#include "Group.h"
36#include "InstanceScript.h"
37#include "MotionMaster.h"
38#include "ObjectAccessor.h"
39#include "Player.h"
40#include "ScriptedCreature.h"
41#include "SpellInfo.h"
42#include "SpellScript.h"
43#include "SpellAuraEffects.h"
44#include "stratholme.h"
45
46/*######
47## go_gauntlet_gate (this is the _first_ of the gauntlet gates, two exist)
48######*/
49
51{
52 public:
53 go_gauntlet_gate() : GameObjectScript("go_gauntlet_gate") { }
54
56 {
57 go_gauntlet_gateAI(GameObject* go) : GameObjectAI(go), instance(go->GetInstanceScript()) { }
58
60
61 bool OnGossipHello(Player* player) override
62 {
64 return false;
65
66 if (Group* group = player->GetGroup())
67 {
68 for (GroupReference* itr = group->GetFirstMember(); itr != nullptr; itr = itr->next())
69 {
70 Player* pGroupie = itr->GetSource();
71 if (!pGroupie || !pGroupie->IsInMap(player))
72 continue;
73
75 !pGroupie->HasAura(SPELL_BARON_ULTIMATUM) &&
76 pGroupie->GetMap() == me->GetMap())
77 pGroupie->CastSpell(pGroupie, SPELL_BARON_ULTIMATUM, true);
78 }
79 }
82 player->GetMap() == me->GetMap())
83 player->CastSpell(player, SPELL_BARON_ULTIMATUM, true);
84
86 return false;
87 }
88 };
89
90 GameObjectAI* GetAI(GameObject* go) const override
91 {
92 return GetStratholmeAI<go_gauntlet_gateAI>(go);
93 }
94};
95
96/*######
97## npc_restless_soul
98######*/
99
101{
102 // Spells
105
106 // Quest
108
109 // Creatures
111 NPC_FREED = 11136
113
115{
116public:
117 npc_restless_soul() : CreatureScript("npc_restless_soul") { }
118
119 CreatureAI* GetAI(Creature* creature) const override
120 {
121 return GetStratholmeAI<npc_restless_soulAI>(creature);
122 }
123
125 {
127 {
128 Initialize();
129 }
130
132 {
133 Tagger.Clear();
134 Die_Timer = 5000;
135 Tagged = false;
136 }
137
140 bool Tagged;
141
142 void Reset() override
143 {
144 Initialize();
145 }
146
147 void JustEngagedWith(Unit* /*who*/) override { }
148
149 void SpellHit(WorldObject* caster, SpellInfo const* spellInfo) override
150 {
151 if (Tagged || spellInfo->Id != SPELL_EGAN_BLASTER)
152 return;
153
154 Player* player = caster->ToPlayer();
156 return;
157
158 Tagged = true;
159 Tagger = caster->GetGUID();
160 }
161
162 void JustSummoned(Creature* summoned) override
163 {
164 summoned->CastSpell(summoned, SPELL_SOUL_FREED, false);
165
166 if (Player* player = ObjectAccessor::GetPlayer(*me, Tagger))
167 summoned->GetMotionMaster()->MoveFollow(player, 0.0f, 0.0f);
168 }
169
170 void JustDied(Unit* /*killer*/) override
171 {
172 if (Tagged)
174 }
175
176 void UpdateAI(uint32 diff) override
177 {
178 if (Tagged)
179 {
180 if (Die_Timer <= diff)
181 {
182 if (Unit* temp = ObjectAccessor::GetUnit(*me, Tagger))
183 {
184 if (Player* player = temp->ToPlayer())
185 player->KilledMonsterCredit(NPC_RESTLESS, me->GetGUID());
186 me->KillSelf();
187 }
188 }
189 else
190 Die_Timer -= diff;
191 }
192 }
193 };
194
195};
196
197/*######
198## npc_spectral_ghostly_citizen
199######*/
200
202{
205 SPELL_SLAP = 6754
207
209{
210public:
211 npc_spectral_ghostly_citizen() : CreatureScript("npc_spectral_ghostly_citizen") { }
212
213 CreatureAI* GetAI(Creature* creature) const override
214 {
215 return GetStratholmeAI<npc_spectral_ghostly_citizenAI>(creature);
216 }
217
219 {
221 {
222 Initialize();
223 }
224
226 {
227 Die_Timer = 5000;
228 HauntingTimer = 8000;
229 TouchTimer = 2000;
230 Tagged = false;
231 }
232
236 bool Tagged;
237
238 void Reset() override
239 {
240 Initialize();
241 }
242
243 void JustEngagedWith(Unit* /*who*/) override { }
244
245 void SpellHit(WorldObject* /*caster*/, SpellInfo const* spellInfo) override
246 {
247 if (!Tagged && spellInfo->Id == SPELL_EGAN_BLASTER)
248 Tagged = true;
249 }
250
251 void JustDied(Unit* /*killer*/) override
252 {
253 if (Tagged)
254 {
255 for (uint32 i = 1; i <= 4; ++i)
256 {
257 //100%, 50%, 33%, 25% chance to spawn
258 if (urand(1, i) == 1)
259 DoSummon(NPC_RESTLESS, me, 20.0f, 10min);
260 }
261 }
262 }
263
264 void UpdateAI(uint32 diff) override
265 {
266 if (Tagged)
267 {
268 if (Die_Timer <= diff)
269 me->KillSelf();
270 else Die_Timer -= diff;
271 }
272
273 if (!UpdateVictim())
274 return;
275
276 //HauntingTimer
277 if (HauntingTimer <= diff)
278 {
281 HauntingTimer = 11000;
282 }
283 else HauntingTimer -= diff;
284
285 //TouchTimer
286 if (TouchTimer <= diff)
287 {
290 TouchTimer = 7000;
291 }
292 else TouchTimer -= diff;
293 }
294
295 void ReceiveEmote(Player* player, uint32 emote) override
296 {
297 switch (emote)
298 {
299 case TEXT_EMOTE_DANCE:
301 break;
302 case TEXT_EMOTE_RUDE:
303 if (me->IsWithinDistInMap(player, 5))
304 DoCast(player, SPELL_SLAP, false);
305 else
307 break;
308 case TEXT_EMOTE_WAVE:
310 break;
311 case TEXT_EMOTE_BOW:
313 break;
314 case TEXT_EMOTE_KISS:
316 break;
317 }
318 }
319 };
320
321};
322
323// 31912 - Ysida Saved Credit Trigger
325{
326 bool Validate(SpellInfo const* /*spell*/) override
327 {
329 }
330
331 void FilterTargets(std::list<WorldObject*>& targets)
332 {
333 targets.remove_if([](WorldObject* obj)
334 {
335 return obj->GetTypeId() != TYPEID_PLAYER;
336 });
337 }
338
339 void HandleScript(SpellEffIndex /*effIndex*/)
340 {
341 if (Player* player = GetHitUnit()->ToPlayer())
342 {
343 player->AreaExploredOrEventHappens(QUEST_DEAD_MAN_PLEA);
344 player->KilledMonsterCredit(NPC_YSIDA);
345 }
346 }
347
348 void Register() override
349 {
352 }
353};
354
356{
360
361// 16336 - Haunting Phantoms
363{
364 void CalcPeriodic(AuraEffect const* /*aurEff*/, bool& isPeriodic, int32& amplitude)
365 {
366 isPeriodic = true;
367 amplitude = irand(30, 90) * IN_MILLISECONDS;
368 }
369
370 void HandleDummyTick(AuraEffect const* /*aurEff*/)
371 {
372 if (roll_chance_i(50))
374 else
376 }
377
379 {
380 aurEff->CalculatePeriodic(GetCaster());
381 }
382
383 void Register() override
384 {
388 }
389};
390
392{
393 new go_gauntlet_gate();
394 new npc_restless_soul();
398}
@ IN_MILLISECONDS
Definition: Common.h:35
int32_t int32
Definition: Define.h:138
uint32_t uint32
Definition: Define.h:142
@ IN_PROGRESS
@ NOT_STARTED
@ TEMPSUMMON_TIMED_DESPAWN
Definition: ObjectDefines.h:65
@ TYPEID_PLAYER
Definition: ObjectGuid.h:41
@ QUEST_STATUS_INCOMPLETE
Definition: QuestDef.h:145
int32 irand(int32 min, int32 max)
Definition: Random.cpp:35
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:42
bool roll_chance_i(int chance)
Definition: Random.h:59
#define RegisterSpellScript(spell_script)
Definition: ScriptMgr.h:1369
SpellEffIndex
Definition: SharedDefines.h:29
@ EFFECT_0
Definition: SharedDefines.h:30
@ TARGET_UNIT_SRC_AREA_ENTRY
@ EMOTE_ONESHOT_FLEX
@ EMOTE_ONESHOT_BOW
@ EMOTE_ONESHOT_RUDE
@ EMOTE_ONESHOT_WAVE
@ TEXT_EMOTE_BOW
@ TEXT_EMOTE_DANCE
@ TEXT_EMOTE_RUDE
@ TEXT_EMOTE_KISS
@ TEXT_EMOTE_WAVE
@ SPELL_EFFECT_SCRIPT_EFFECT
@ SPELL_AURA_DUMMY
#define SpellEffectFn(F, I, N)
Definition: SpellScript.h:842
#define SpellObjectAreaTargetSelectFn(F, I, N)
Definition: SpellScript.h:864
#define AuraEffectPeriodicFn(F, I, N)
Definition: SpellScript.h:2046
#define AuraEffectUpdatePeriodicFn(F, I, N)
Definition: SpellScript.h:2052
#define AuraEffectCalcPeriodicFn(F, I, N)
Definition: SpellScript.h:2064
void CalculatePeriodic(Unit *caster, bool resetPeriodicTimer=true, bool load=false)
HookList< EffectCalcPeriodicHandler > DoEffectCalcPeriodic
Definition: SpellScript.h:2063
HookList< EffectPeriodicHandler > OnEffectPeriodic
Definition: SpellScript.h:2045
Unit * GetCaster() const
HookList< EffectUpdatePeriodicHandler > OnEffectUpdatePeriodic
Definition: SpellScript.h:2051
Unit * GetTarget() const
virtual void EnterEvadeMode(EvadeReason why=EvadeReason::Other)
Definition: CreatureAI.cpp:219
bool UpdateVictim()
Definition: CreatureAI.cpp:245
Creature *const me
Definition: CreatureAI.h:61
Creature * DoSummon(uint32 entry, Position const &pos, Milliseconds despawnTime=30s, TempSummonType summonType=TEMPSUMMON_CORPSE_TIMED_DESPAWN)
Definition: CreatureAI.cpp:464
GameObject *const me
Definition: GameObjectAI.h:50
GroupReference * next()
Definition: Group.h:197
void MoveFollow(Unit *target, float dist, ChaseAngle angle, Optional< Milliseconds > duration={}, MovementSlot slot=MOTION_SLOT_ACTIVE)
void Clear()
Definition: ObjectGuid.h:286
TypeID GetTypeId() const
Definition: Object.h:173
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
static Player * ToPlayer(Object *o)
Definition: Object.h:213
QuestStatus GetQuestStatus(uint32 quest_id) const
Definition: Player.cpp:16050
Group * GetGroup(Optional< uint8 > partyIndex)
Definition: Player.h:2606
uint32 const Id
Definition: SpellInfo.h:325
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Definition: SpellScript.h:162
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
Definition: SpellScript.h:840
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
Definition: SpellScript.h:863
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 DoCast(uint32 spellId)
Definition: UnitAI.cpp:89
Definition: Unit.h:627
MotionMaster * GetMotionMaster()
Definition: Unit.h:1652
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4664
void HandleEmoteCommand(Emote emoteId, Player *target=nullptr, Trinity::IteratorPair< int32 const * > spellVisualKitIds={}, int32 sequenceVariation=0)
Definition: Unit.cpp:1598
void KillSelf(bool durabilityLoss=true, bool skipSettingDeathState=false)
Definition: Unit.h:921
Map * GetMap() const
Definition: Object.h:624
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2896
TempSummon * SummonCreature(uint32 entry, Position const &pos, TempSummonType despawnType=TEMPSUMMON_MANUAL_DESPAWN, Milliseconds despawnTime=0s, uint32 vehId=0, uint32 spellId=0, ObjectGuid privateObjectOwner=ObjectGuid::Empty)
Definition: Object.cpp:2025
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=true) const
Definition: Object.cpp:1147
bool IsInMap(WorldObject const *obj) const
Definition: Object.cpp:1115
virtual uint32 GetData(uint32) const
Definition: ZoneScript.h:91
virtual void SetData(uint32, uint32)
Definition: ZoneScript.h:92
GameObjectAI * GetAI(GameObject *go) const override
Definition: stratholme.cpp:90
CreatureAI * GetAI(Creature *creature) const override
Definition: stratholme.cpp:119
CreatureAI * GetAI(Creature *creature) const override
Definition: stratholme.cpp:213
void CalcPeriodic(AuraEffect const *, bool &isPeriodic, int32 &amplitude)
Definition: stratholme.cpp:364
void HandleUpdatePeriodic(AuraEffect *aurEff)
Definition: stratholme.cpp:378
void HandleDummyTick(AuraEffect const *)
Definition: stratholme.cpp:370
bool Validate(SpellInfo const *) override
Definition: stratholme.cpp:326
void HandleScript(SpellEffIndex)
Definition: stratholme.cpp:339
void FilterTargets(std::list< WorldObject * > &targets)
Definition: stratholme.cpp:331
void Register() override
Definition: stratholme.cpp:348
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
TC_GAME_API Player * GetPlayer(Map const *, ObjectGuid const &guid)
HauntingPhantoms
Definition: stratholme.cpp:356
@ SPELL_SUMMON_WRATH_PHANTOM
Definition: stratholme.cpp:358
@ SPELL_SUMMON_SPITEFUL_PHANTOM
Definition: stratholme.cpp:357
GhostlyCitizenSpells
Definition: stratholme.cpp:202
@ SPELL_DEBILITATING_TOUCH
Definition: stratholme.cpp:204
@ SPELL_SLAP
Definition: stratholme.cpp:205
@ SPELL_HAUNTING_PHANTOM
Definition: stratholme.cpp:203
RestlessSoul
Definition: stratholme.cpp:101
@ SPELL_EGAN_BLASTER
Definition: stratholme.cpp:103
@ QUEST_RESTLESS_SOUL
Definition: stratholme.cpp:107
@ NPC_RESTLESS
Definition: stratholme.cpp:110
@ SPELL_SOUL_FREED
Definition: stratholme.cpp:104
@ NPC_FREED
Definition: stratholme.cpp:111
void AddSC_stratholme()
Definition: stratholme.cpp:391
@ NPC_YSIDA
Definition: stratholme.h:81
@ QUEST_DEAD_MAN_PLEA
Definition: stratholme.h:110
@ SPELL_YSIDA_SAVED
Definition: stratholme.h:117
@ SPELL_BARON_ULTIMATUM
Definition: stratholme.h:115
@ TYPE_BARON_RUN
Definition: stratholme.h:48
constexpr float GetPositionX() const
Definition: Position.h:76
constexpr float GetPositionY() const
Definition: Position.h:77
constexpr float GetOrientation() const
Definition: Position.h:79
constexpr float GetPositionZ() const
Definition: Position.h:78
bool OnGossipHello(Player *player) override
Definition: stratholme.cpp:61
void JustEngagedWith(Unit *) override
Definition: stratholme.cpp:147
void SpellHit(WorldObject *caster, SpellInfo const *spellInfo) override
Definition: stratholme.cpp:149
void UpdateAI(uint32 diff) override
Definition: stratholme.cpp:176
void JustSummoned(Creature *summoned) override
Definition: stratholme.cpp:162
void SpellHit(WorldObject *, SpellInfo const *spellInfo) override
Definition: stratholme.cpp:245
void ReceiveEmote(Player *player, uint32 emote) override
Definition: stratholme.cpp:295