Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
zone_storm_peaks.cpp
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6#include "ScriptMgr.h"
7#include "ScriptedCreature.h"
8#include "ScriptedGossip.h"
9#include "ScriptedEscortAI.h"
10#include "SpellScript.h"
11#include "SpellAuraEffects.h"
12#include "Vehicle.h"
13#include "CombatAI.h"
14#include "Player.h"
15#include "WorldSession.h"
16
20
29
31{
32public:
33 npc_injured_goblin() : CreatureScript("npc_injured_goblin") { }
34
36 {
37 npc_injured_goblinAI(Creature* creature) : npc_escortAI(creature) { }
38
40 {
41 Player* player = GetPlayerForEscort();
42 if (!player)
43 return;
44
45 switch (waypointId)
46 {
47 case 26:
48 Talk(SAY_END_WP_REACHED, player);
49 break;
50 case 27:
52 break;
53 }
54 }
55
56 void EnterCombat(Unit* /*who*/) OVERRIDE { }
57
58 void Reset() OVERRIDE { }
59
60 void JustDied(Unit* /*killer*/) OVERRIDE
61 {
62 Player* player = GetPlayerForEscort();
65 }
66
68 {
70 if (!UpdateVictim())
71 return;
73 }
74
75 void sGossipSelect(Player* player, uint32 sender, uint32 action) OVERRIDE
76 {
77 if (sender == GOSSIP_ID && action == GOSSIP_OPTION_ID)
78 {
79 player->CLOSE_GOSSIP_MENU();
80 me->setFaction(113);
81 npc_escortAI::Start(true, true, player->GetGUID());
82 }
83 }
84 };
85
87 {
88 return new npc_injured_goblinAI(creature);
89 }
90
91 bool OnQuestAccept(Player* /*player*/, Creature* creature, Quest const* quest) OVERRIDE
92 {
93 if (quest->GetQuestId() == QUEST_BITTER_DEPARTURE)
94 creature->AI()->Talk(SAY_QUEST_ACCEPT);
95
96 return false;
97 }
98};
99
100/*######
101## npc_roxi_ramrocket
102######*/
103
109
111{
112public:
113 npc_roxi_ramrocket() : CreatureScript("npc_roxi_ramrocket") { }
114
115 bool OnGossipHello(Player* player, Creature* creature) OVERRIDE
116 {
117 //Quest Menu
118 if (creature->IsQuestGiver())
119 player->PrepareQuestMenu(creature->GetGUID());
120
121 //Trainer Menu
122 if ( creature->IsTrainer() )
124
125 //Vendor Menu
126 if ( creature->IsVendor() )
127 if (player->HasSpell(SPELL_MECHANO_HOG) || player->HasSpell(SPELL_MEKGINEERS_CHOPPER))
129
130 player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID());
131 return true;
132 }
133
134 bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) OVERRIDE
135 {
136 player->PlayerTalkClass->ClearMenus();
137 switch (action)
138 {
140 player->GetSession()->SendTrainerList(creature->GetGUID());
141 break;
143 player->GetSession()->SendListInventory(creature->GetGUID());
144 break;
145 }
146 return true;
147 }
148};
149
150/*######
151## npc_brunnhildar_prisoner
152######*/
153
161
163{
164public:
165 npc_brunnhildar_prisoner() : CreatureScript("npc_brunnhildar_prisoner") { }
166
168 {
170
171 bool freed;
172
174 {
175 freed = false;
176 me->CastSpell(me, SPELL_ICE_PRISON, true);
177 }
178
180 {
181 Reset();
182 }
183
184 void UpdateAI(uint32 /*diff*/) OVERRIDE
185 {
186 if (!freed)
187 return;
188
189 if (!me->GetVehicle())
190 me->DespawnOrUnsummon();
191 }
192
193 void SpellHit(Unit* caster, const SpellInfo* spell) OVERRIDE
194 {
195 if (spell->Id != SPELL_ICE_LANCE)
196 return;
197
198 if (caster->GetVehicleKit()->GetAvailableSeatCount() != 0)
199 {
200 me->CastSpell(me, SPELL_FREE_PRISONER, true);
201 me->CastSpell(caster, SPELL_RIDE_DRAKE, true);
202 me->CastSpell(me, SPELL_SHARD_IMPACT, true);
203 freed = true;
204 }
205 }
206 };
207
209 {
210 return new npc_brunnhildar_prisonerAI(creature);
211 }
212};
213
214/*######
215## npc_freed_protodrake
216######*/
217
233
235{
236public:
237 npc_freed_protodrake() : CreatureScript("npc_freed_protodrake") { }
238
240 {
241 npc_freed_protodrakeAI(Creature* creature) : VehicleAI(creature) { }
242
244
246 {
247 events.ScheduleEvent(EVENT_CHECK_AREA, 5000);
248 }
249
251 {
252 if (type != WAYPOINT_MOTION_TYPE)
253 return;
254
255 if (id == 15)
256 // drake reached village
257 events.ScheduleEvent(EVENT_REACHED_HOME, 2000);
258 }
259
261 {
262 events.Update(diff);
263
264 switch (events.ExecuteEvent())
265 {
266 case EVENT_CHECK_AREA:
267 if (me->GetAreaId() == AREA_VALLEY_OF_ANCIENT_WINTERS)
268 {
269 if (Vehicle* vehicle = me->GetVehicleKit())
270 if (Unit* passenger = vehicle->GetPassenger(0))
271 {
272 Talk(TEXT_EMOTE, passenger);
273 me->GetMotionMaster()->MovePath(NPC_DRAKE, false);
274 }
275 }
276 else
277 events.ScheduleEvent(EVENT_CHECK_AREA, 5000);
278 break;
280 Unit* player = me->GetVehicleKit()->GetPassenger(0);
281 if (player && player->GetTypeId() == TypeID::TYPEID_PLAYER)
282 {
283 // for each prisoner on drake, give credit
284 for (uint8 i = 1; i < 4; ++i)
285 if (Unit* prisoner = me->GetVehicleKit()->GetPassenger(i))
286 {
287 if (prisoner->GetTypeId() != TypeID::TYPEID_UNIT)
288 return;
289 prisoner->CastSpell(player, SPELL_KILL_CREDIT_PRISONER, true);
290 prisoner->CastSpell(prisoner, SPELL_SUMMON_LIBERATED, true);
291 prisoner->ExitVehicle();
292 }
293 me->CastSpell(me, SPELL_KILL_CREDIT_DRAKE, true);
294 player->ExitVehicle();
295 }
296 break;
297 }
298 }
299 };
300
302 {
303 return new npc_freed_protodrakeAI(creature);
304 }
305};
306
308{
309public:
310 npc_icefang() : CreatureScript("npc_icefang") { }
311
313 {
314 npc_icefangAI(Creature* creature) : npc_escortAI(creature) { }
315
316 void AttackStart(Unit* /*who*/) OVERRIDE { }
317 void EnterCombat(Unit* /*who*/) OVERRIDE { }
319
320 void PassengerBoarded(Unit* who, int8 /*seatId*/, bool apply) OVERRIDE
321 {
322 if (who->GetTypeId() == TypeID::TYPEID_PLAYER)
323 {
324 if (apply)
325 Start(false, true, who->GetGUID());
326 }
327 }
328
329 void WaypointReached(uint32 /*waypointId*/) OVERRIDE
330 {
331 }
332
333 void JustDied(Unit* /*killer*/) OVERRIDE
334 {
335 }
336
337 void OnCharmed(bool /*apply*/) OVERRIDE
338 {
339 }
340
342 {
344
345 if (!UpdateVictim())
346 return;
347 }
348 };
349
351 {
352 return new npc_icefangAI(creature);
353 }
354};
355
357{
358 enum NPCs
359 {
361 };
362
363 public:
364 npc_hyldsmeet_protodrake() : CreatureScript("npc_hyldsmeet_protodrake") { }
365
367 {
368 public:
369 npc_hyldsmeet_protodrakeAI(Creature* creature) : CreatureAI(creature), _accessoryRespawnTimer(0), _vehicleKit(creature->GetVehicleKit()) { }
370
371 void PassengerBoarded(Unit* who, int8 /*seat*/, bool apply) OVERRIDE
372 {
373 if (apply)
374 return;
375
376 if (who->GetEntry() == NPC_HYLDSMEET_DRAKERIDER)
378 }
379
381 {
385 {
386 _vehicleKit->InstallAllAccessories(true);
388 }
389 else
391 }
392
393 private:
396 };
397
399 {
400 return new npc_hyldsmeet_protodrakeAI(creature);
401 }
402};
403
405{
407};
408
410{
411 public:
412 spell_close_rift() : SpellScriptLoader("spell_close_rift") { }
413
415 {
417
419 {
420 _counter = 0;
421 return true;
422 }
423
424 bool Validate(SpellInfo const* /*spell*/) OVERRIDE
425 {
426 return sSpellMgr->GetSpellInfo(SPELL_DESPAWN_RIFT);
427 }
428
429 void HandlePeriodic(AuraEffect const* /* aurEff */)
430 {
431 if (++_counter == 5)
432 GetTarget()->CastSpell((Unit*)NULL, SPELL_DESPAWN_RIFT, true);
433 }
434
439
440 private:
442 };
443
445 {
446 return new spell_close_rift_AuraScript();
447 }
448};
449
451{
452 new npc_injured_goblin();
453 new npc_roxi_ramrocket();
456 new npc_icefang();
458 new spell_close_rift();
459}
@ IN_MILLISECONDS
Definition Common.h:125
@ MINUTE
Definition Common.h:119
std::uint8_t uint8
Definition Define.h:79
std::uint32_t uint32
Definition Define.h:77
std::int8_t int8
Definition Define.h:75
#define OVERRIDE
Definition Define.h:60
@ GOSSIP_ICON_TRAINER
Definition GossipDef.h:49
@ GOSSIP_ICON_VENDOR
Definition GossipDef.h:47
@ WAYPOINT_MOTION_TYPE
@ TYPEID_PLAYER
Definition Object.h:55
@ TYPEID_UNIT
Definition Object.h:54
@ STATE_ESCORT_ESCORTING
#define GOSSIP_TEXT_TRAIN
#define GOSSIP_TEXT_BROWSE_GOODS
@ GOSSIP_SENDER_MAIN
@ GOSSIP_ACTION_TRADE
@ GOSSIP_ACTION_TRAIN
@ EFFECT_0
@ SPELL_AURA_PERIODIC_TRIGGER_SPELL
#define sSpellMgr
Definition SpellMgr.h:744
#define AuraEffectPeriodicFn(F, I, N)
@ GOSSIP_OPTION_ID
@ GOSSIP_ID
HookList< EffectPeriodicHandler > OnEffectPeriodic
Unit * GetTarget() const
CreatureAI(Creature *creature)
Definition CreatureAI.h:69
void Talk(uint8 id, WorldObject const *whisperTarget=NULL)
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:56
CreatureScript(const char *name)
TypeID GetTypeId() const
Definition Object.h:131
void GroupEventHappens(uint32 questId, WorldObject const *pEventObject)
void FailQuest(uint32 quest_id)
SpellScriptLoader(const char *name)
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:28
Definition Unit.h:1367
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, uint64 originalCaster=0)
void ExitVehicle(Position const *exitPosition=NULL)
Definition Unit.cpp:8306
CreatureAI * GetAI(Creature *creature) const OVERRIDE
CreatureAI * GetAI(Creature *creature) const OVERRIDE
void UpdateAI(uint32 diff) OVERRIDE
== Triggered Actions Requested ==================
void PassengerBoarded(Unit *who, int8, bool apply) OVERRIDE
== Fields =======================================
CreatureAI * GetAI(Creature *creature) const OVERRIDE
CreatureAI * GetAI(Creature *creature) const OVERRIDE
CreatureAI * GetAI(Creature *creature) const OVERRIDE
bool OnQuestAccept(Player *, Creature *creature, Quest const *quest) OVERRIDE
bool OnGossipHello(Player *player, Creature *creature) OVERRIDE
bool OnGossipSelect(Player *player, Creature *creature, uint32, uint32 action) OVERRIDE
PrepareAuraScript(spell_close_rift_AuraScript)
AuraScript * GetAuraScript() const OVERRIDE
Creature * me
ScriptedAI(Creature *creature)
VehicleAI(Creature *c)
Definition CombatAI.cpp:262
void SpellHit(Unit *caster, const SpellInfo *spell) OVERRIDE
void UpdateAI(uint32) OVERRIDE
== Triggered Actions Requested ==================
void UpdateAI(uint32 diff) OVERRIDE
== Triggered Actions Requested ==================
Player * GetPlayerForEscort()
bool HasEscortState(uint32 escortState) const
npc_escortAI(Creature *creature)
void Start(bool isActiveAttacker=true, bool run=false, uint64 playerGUID=0, Quest const *quest=NULL, bool instantRespawn=false, bool canLoopPath=false, bool resetWaypoints=true)
void UpdateAI(uint32 diff) OVERRIDE
== Triggered Actions Requested ==================
void MovementInform(uint32 type, uint32 id) OVERRIDE
void EnterCombat(Unit *) OVERRIDE
void PassengerBoarded(Unit *who, int8, bool apply) OVERRIDE
== Fields =======================================
void WaypointReached(uint32) OVERRIDE
void UpdateAI(uint32 diff) OVERRIDE
== Triggered Actions Requested ==================
void JustDied(Unit *) OVERRIDE
npc_icefangAI(Creature *creature)
void AttackStart(Unit *) OVERRIDE
void WaypointReached(uint32 waypointId) OVERRIDE
void UpdateAI(uint32 uiDiff) OVERRIDE
== Triggered Actions Requested ==================
void sGossipSelect(Player *player, uint32 sender, uint32 action) OVERRIDE
@ SAY_QUEST_ACCEPT
@ SPELL_MECHANO_HOG
@ SPELL_MEKGINEERS_CHOPPER
FreedProtoDrake
@ EVENT_CHECK_AREA
@ AREA_VALLEY_OF_ANCIENT_WINTERS
@ TEXT_EMOTE
@ SPELL_SUMMON_LIBERATED
@ NPC_DRAKE
@ SPELL_KILL_CREDIT_PRISONER
@ SPELL_KILL_CREDIT_DRAKE
@ EVENT_REACHED_HOME
BrunnhildarPrisoner
@ SPELL_FREE_PRISONER
@ SPELL_ICE_PRISON
@ SPELL_ICE_LANCE
@ SPELL_SHARD_IMPACT
@ SPELL_RIDE_DRAKE
InjuredGoblinMiner
npc_injured_goblin
@ GOSSIP_OPTION_ID
@ QUEST_BITTER_DEPARTURE
@ SAY_QUEST_ACCEPT
@ SAY_END_WP_REACHED
@ GOSSIP_ID
@ SPELL_DESPAWN_RIFT
void AddSC_storm_peaks()