Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
zulfarrak.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/* ScriptData
7SDName: Zulfarrak
8SD%Complete: 50
9SDComment: Consider it temporary, no instance script made for this instance yet.
10SDCategory: Zul'Farrak
11EndScriptData */
12
13/* ContentData
14npc_sergeant_bly
15npc_weegli_blastfuse
16EndContentData */
17
18#include "ScriptMgr.h"
19#include "ScriptedCreature.h"
20#include "ScriptedGossip.h"
21#include "zulfarrak.h"
22#include "Player.h"
23
24/*######
25## npc_sergeant_bly
26######*/
27
29{
31 FACTION_FRIENDLY = 35, //while in cages (so the trolls won't attack them while they're caged)
32 FACTION_FREED = 250 //after release (so they'll be hostile towards trolls)
33};
34
36{
37 SAY_1 = 0,
39};
40
42{
45};
46
47#define GOSSIP_BLY "[PH] In that case, I will take my reward!"
48
50{
51public:
52 npc_sergeant_bly() : CreatureScript("npc_sergeant_bly") { }
53
54 bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) OVERRIDE
55 {
56 player->PlayerTalkClass->ClearMenus();
57 if (action == GOSSIP_ACTION_INFO_DEF+1)
58 {
59 player->CLOSE_GOSSIP_MENU();
60 CAST_AI(npc_sergeant_bly::npc_sergeant_blyAI, creature->AI())->PlayerGUID = player->GetGUID();
61 creature->AI()->DoAction(0);
62 }
63 return true;
64 }
65
66 bool OnGossipHello(Player* player, Creature* creature) OVERRIDE
67 {
68 if (InstanceScript* instance = creature->GetInstanceScript())
69 {
70 if (instance->GetData(EVENT_PYRAMID) == PYRAMID_KILLED_ALL_TROLLS)
71 {
73 player->SEND_GOSSIP_MENU(1517, creature->GetGUID());
74 }
75 else
76 if (instance->GetData(EVENT_PYRAMID) == PYRAMID_NOT_STARTED)
77 player->SEND_GOSSIP_MENU(1515, creature->GetGUID());
78 else
79 player->SEND_GOSSIP_MENU(1516, creature->GetGUID());
80 return true;
81 }
82 return false;
83 }
84
86 {
87 return new npc_sergeant_blyAI(creature);
88 }
89
91 {
92 npc_sergeant_blyAI(Creature* creature) : ScriptedAI(creature)
93 {
94 instance = creature->GetInstanceScript();
96 }
97
99
103 uint32 Revenge_Timer; //this is wrong, spell should never be used unless me->GetVictim() dodge, parry or block attack. Skyfire support required.
105
107 {
108 ShieldBash_Timer = 5000;
109 Revenge_Timer = 8000;
110
111 me->setFaction(FACTION_FRIENDLY);
112 }
113
115 {
117 {
118 if (Text_Timer<diff)
119 {
120 switch (postGossipStep)
121 {
122 case 1:
123 //weegli doesn't fight - he goes & blows up the door
124 if (Creature* pWeegli = instance->instance->GetCreature(instance->GetData64(ENTRY_WEEGLI)))
125 pWeegli->AI()->DoAction(0);
126 Talk(SAY_1);
127 Text_Timer = 5000;
128 break;
129 case 2:
130 Talk(SAY_2);
131 Text_Timer = 5000;
132 break;
133 case 3:
134 me->setFaction(FACTION_HOSTILE);
136 AttackStart(target);
137
138 if (instance)
139 {
143 }
144 }
146 }
147 else Text_Timer -= diff;
148 }
149
150 if (!UpdateVictim())
151 return;
152
153 if (ShieldBash_Timer <= diff)
154 {
156 ShieldBash_Timer = 15000;
157 }
158 else
159 ShieldBash_Timer -= diff;
160
161 if (Revenge_Timer <= diff)
162 {
164 Revenge_Timer = 10000;
165 }
166 else
167 Revenge_Timer -= diff;
168
170 }
171
172 void DoAction(int32 /*param*/) OVERRIDE
173 {
175 Text_Timer = 0;
176 }
177
179 {
180 if (Creature* crew = instance->instance->GetCreature(instance->GetData64(entry)))
181 if (crew->IsAlive())
182 crew->setFaction(FACTION_HOSTILE);
183 }
184 };
185};
186
187/*######
188+## go_troll_cage
189+######*/
190
192{
193public:
194 go_troll_cage() : GameObjectScript("go_troll_cage") { }
195
197 {
198 if (InstanceScript* instance = go->GetInstanceScript())
199 {
200 instance->SetData(EVENT_PYRAMID, PYRAMID_CAGES_OPEN);
201 //set bly & co to aggressive & start moving to top of stairs
202 initBlyCrewMember(instance, ENTRY_BLY, 1884.99f, 1263, 41.52f);
203 initBlyCrewMember(instance, ENTRY_RAVEN, 1882.5f, 1263, 41.52f);
204 initBlyCrewMember(instance, ENTRY_ORO, 1886.47f, 1270.68f, 41.68f);
205 initBlyCrewMember(instance, ENTRY_WEEGLI, 1890, 1263, 41.52f);
206 initBlyCrewMember(instance, ENTRY_MURTA, 1891.19f, 1272.03f, 41.60f);
207 }
208 return false;
209 }
210
211private:
212 void initBlyCrewMember(InstanceScript* instance, uint32 entry, float x, float y, float z)
213 {
214 if (Creature* crew = instance->instance->GetCreature(instance->GetData64(entry)))
215 {
216 crew->SetReactState(REACT_AGGRESSIVE);
217 crew->SetWalk(true);
218 crew->SetHomePosition(x, y, z, 0);
219 crew->GetMotionMaster()->MovePoint(1, x, y, z);
220 crew->setFaction(FACTION_FREED);
221 }
222 }
223};
224
225/*######
226## npc_weegli_blastfuse
227######*/
228
236
242
243#define GOSSIP_WEEGLI "[PH] Please blow up the door."
244
246{
247public:
248 npc_weegli_blastfuse() : CreatureScript("npc_weegli_blastfuse") { }
249
250 bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) OVERRIDE
251 {
252 player->PlayerTalkClass->ClearMenus();
253 if (action == GOSSIP_ACTION_INFO_DEF+1)
254 {
255 player->CLOSE_GOSSIP_MENU();
256 //here we make him run to door, set the charge and run away off to nowhere
257 creature->AI()->DoAction(0);
258 }
259 return true;
260 }
261
262 bool OnGossipHello(Player* player, Creature* creature) OVERRIDE
263 {
264 if (InstanceScript* instance = creature->GetInstanceScript())
265 {
266 switch (instance->GetData(EVENT_PYRAMID))
267 {
270 player->SEND_GOSSIP_MENU(1514, creature->GetGUID()); //if event can proceed to end
271 break;
273 player->SEND_GOSSIP_MENU(1511, creature->GetGUID()); //if event not started
274 break;
275 default:
276 player->SEND_GOSSIP_MENU(1513, creature->GetGUID()); //if event are in progress
277 }
278 return true;
279 }
280 return false;
281 }
282
284 {
285 return new npc_weegli_blastfuseAI(creature);
286 }
287
289 {
291 {
292 instance = creature->GetInstanceScript();
293 destroyingDoor=false;
294 Bomb_Timer = 10000;
295 LandMine_Timer = 30000;
296 }
297
302
304 {
305 /*if (instance)
306 instance->SetData(0, NOT_STARTED);*/
307 }
308
310 {
311 AttackStartCaster(victim, 10);//keep back & toss bombs/shoot
312 }
313
314 void JustDied(Unit* /*killer*/) OVERRIDE
315 {
316 /*if (instance)
317 instance->SetData(0, DONE);*/
318 }
319
321 {
322 if (!UpdateVictim())
323 return;
324
325 if (Bomb_Timer < diff)
326 {
328 Bomb_Timer = 10000;
329 }
330 else
331 Bomb_Timer -= diff;
332
333 if (me->isAttackReady() && !me->IsWithinMeleeRange(me->GetVictim()))
334 {
336 me->SetSheath(SHEATH_STATE_RANGED);
337 }
338 else
339 {
340 me->SetSheath(SHEATH_STATE_MELEE);
342 }
343 }
344
345 void MovementInform(uint32 /*type*/, uint32 /*id*/) OVERRIDE
346 {
347 if (instance)
348 {
350 {
353 me->SetHomePosition(1882.69f, 1272.28f, 41.87f, 0);
354 }
355 else
356 if (destroyingDoor)
357 {
358 instance->DoUseDoorOrButton(instance->GetData64(GO_END_DOOR));
360 me->DespawnOrUnsummon();
361 };
362 }
363 }
364
365 void DoAction(int32 /*param*/) OVERRIDE
366 {
367 DestroyDoor();
368 }
369
371 {
372 if (me->IsAlive())
373 {
374 me->setFaction(FACTION_FRIENDLY);
375 me->GetMotionMaster()->MovePoint(0, 1858.57f, 1146.35f, 14.745f);
376 me->SetHomePosition(1858.57f, 1146.35f, 14.745f, 3.85f); // in case he gets interrupted
378 destroyingDoor=true;
379 }
380 }
381 };
382};
383
384/*######
385## go_shallow_grave
386######*/
387
395
397{
398public:
399 go_shallow_grave() : GameObjectScript("go_shallow_grave") { }
400
402 {
403 // randomly summon a zombie or dead hero the first time a grave is used
404 if (go->GetUseCount() == 0)
405 {
406 uint32 randomchance = urand(0, 100);
407 if (randomchance < CHANCE_ZOMBIE)
408 go->SummonCreature(NPC_ZOMBIE, go->GetPositionX(), go->GetPositionY(), go->GetPositionZ(), 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 30000);
409 else
410 if ((randomchance - CHANCE_ZOMBIE) < CHANCE_DEAD_HERO)
411 go->SummonCreature(NPC_DEAD_HERO, go->GetPositionX(), go->GetPositionY(), go->GetPositionZ(), 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 30000);
412 }
413 go->AddUse();
414 return false;
415 }
416};
417
418/*######
419## at_zumrah
420######*/
421
427
429{
430public:
431 at_zumrah() : AreaTriggerScript("at_zumrah") { }
432
433 bool OnTrigger(Player* player, const AreaTriggerEntry* /*at*/) OVERRIDE
434 {
435 Creature* pZumrah = player->FindNearestCreature(ZUMRAH_ID, 30.0f);
436
437 if (!pZumrah)
438 return false;
439
441 return true;
442 }
443};
444
446{
447 new npc_sergeant_bly();
449 new go_shallow_grave();
450 new at_zumrah();
451 new go_troll_cage();
452}
std::int32_t int32
Definition Define.h:73
std::uint32_t uint32
Definition Define.h:77
#define OVERRIDE
Definition Define.h:60
std::uint64_t uint64
Definition Define.h:76
static constexpr TempSummonType TEMPSUMMON_CORPSE_TIMED_DESPAWN
@ GOSSIP_ICON_CHAT
Definition GossipDef.h:46
#define CAST_AI(a, b)
@ GOSSIP_SENDER_MAIN
@ GOSSIP_ACTION_INFO_DEF
@ SHEATH_STATE_MELEE
Definition Unit.h:246
@ SHEATH_STATE_RANGED
Definition Unit.h:247
@ REACT_AGGRESSIVE
Definition Unit.h:1158
@ FACTION_HOSTILE
AreaTriggerScript(const char *name)
void Talk(uint8 id, WorldObject const *whisperTarget=NULL)
bool UpdateVictim()
CreatureScript(const char *name)
GameObjectScript(const char *name)
Creature * GetCreature(uint64 guid)
Definition Map.cpp:3179
static Player * GetPlayer(WorldObject const &, uint64 guid)
void AttackStartCaster(Unit *victim, float dist)
Definition UnitAI.cpp:22
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:28
void DoCastVictim(uint32 spellId, bool triggered=false)
Definition UnitAI.cpp:168
Definition Unit.h:1367
void setFaction(uint32 faction)
Definition Unit.h:1699
InstanceScript * GetInstanceScript()
Definition Object.cpp:1612
Creature * FindNearestCreature(uint32 entry, float range, bool alive=true) const
Definition Object.cpp:2801
virtual uint64 GetData64(uint32) const
Definition ZoneScript.h:32
bool OnTrigger(Player *player, const AreaTriggerEntry *) OVERRIDE
bool OnGossipHello(Player *, GameObject *go) OVERRIDE
bool OnGossipHello(Player *, GameObject *go) OVERRIDE
void initBlyCrewMember(InstanceScript *instance, uint32 entry, float x, float y, float z)
CreatureAI * GetAI(Creature *creature) const OVERRIDE
Definition zulfarrak.cpp:85
bool OnGossipSelect(Player *player, Creature *creature, uint32, uint32 action) OVERRIDE
Definition zulfarrak.cpp:54
bool OnGossipHello(Player *player, Creature *creature) OVERRIDE
Definition zulfarrak.cpp:66
bool OnGossipHello(Player *player, Creature *creature) OVERRIDE
bool OnGossipSelect(Player *player, Creature *creature, uint32, uint32 action) OVERRIDE
CreatureAI * GetAI(Creature *creature) const OVERRIDE
#define SAY_1
#define SAY_2
Creature * me
ScriptedAI(Creature *creature)
void AttackStart(Unit *) OVERRIDE
npc_sergeant_blyAI(Creature *creature)
Definition zulfarrak.cpp:92
void UpdateAI(uint32 diff) OVERRIDE
== Triggered Actions Requested ==================
void switchFactionIfAlive(InstanceScript *instance, uint32 entry)
void AttackStart(Unit *victim) OVERRIDE
void MovementInform(uint32, uint32) OVERRIDE
void UpdateAI(uint32 diff) OVERRIDE
== Triggered Actions Requested ==================
@ FACTION_FRIENDLY
blySays
Definition zulfarrak.cpp:36
@ SAY_1
Definition zulfarrak.cpp:37
@ SAY_2
Definition zulfarrak.cpp:38
weegliSays
@ SAY_WEEGLI_OHNO
@ SAY_WEEGLI_OK_I_GO
void AddSC_zulfarrak()
ShallowGrave
@ NPC_DEAD_HERO
@ NPC_ZOMBIE
@ CHANCE_DEAD_HERO
@ CHANCE_ZOMBIE
zumrahConsts
@ ZUMRAH_ID
@ ZUMRAH_HOSTILE_FACTION
blyAndCrewFactions
Definition zulfarrak.cpp:29
@ FACTION_FREED
Definition zulfarrak.cpp:32
@ FACTION_FRIENDLY
Definition zulfarrak.cpp:31
@ FACTION_HOSTILE
Definition zulfarrak.cpp:30
weegliSpells
@ SPELL_GOBLIN_LAND_MINE
@ SPELL_SHOOT
@ SPELL_WEEGLIS_BARREL
@ SPELL_BOMB
#define GOSSIP_WEEGLI
blySpells
Definition zulfarrak.cpp:42
@ SPELL_SHIELD_BASH
Definition zulfarrak.cpp:43
@ SPELL_REVENGE
Definition zulfarrak.cpp:44
#define GOSSIP_BLY
Definition zulfarrak.cpp:47
@ PYRAMID_NOT_STARTED
Definition zulfarrak.h:31
@ PYRAMID_ARRIVED_AT_STAIR
Definition zulfarrak.h:33
@ PYRAMID_CAGES_OPEN
Definition zulfarrak.h:32
@ PYRAMID_KILLED_ALL_TROLLS
Definition zulfarrak.h:39
@ GO_END_DOOR
Definition zulfarrak.h:18
@ ENTRY_RAVEN
Definition zulfarrak.h:13
@ ENTRY_MURTA
Definition zulfarrak.h:16
@ ENTRY_WEEGLI
Definition zulfarrak.h:15
@ ENTRY_ORO
Definition zulfarrak.h:14
@ ENTRY_BLY
Definition zulfarrak.h:12
@ EVENT_PYRAMID
Definition zulfarrak.h:20