TrinityCore
Loading...
Searching...
No Matches
zulfarrak.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: Zulfarrak
20SD%Complete: 50
21SDComment: Consider it temporary, no instance script made for this instance yet.
22SDCategory: Zul'Farrak
23EndScriptData */
24
25/* ContentData
26npc_sergeant_bly
27npc_weegli_blastfuse
28EndContentData */
29
30#include "ScriptMgr.h"
31#include "GameObject.h"
32#include "GameObjectAI.h"
33#include "InstanceScript.h"
34#include "MotionMaster.h"
35#include "ObjectAccessor.h"
36#include "Player.h"
37#include "ScriptedCreature.h"
38#include "ScriptedGossip.h"
39#include "zulfarrak.h"
40
41/*######
42## npc_sergeant_bly
43######*/
44
46{
47 SAY_1 = 0,
48 SAY_2 = 1
49};
50
52{
55};
56
58{
59 GOSSIP_BLY_MID = 941, //That's it! I'm tired of helping you out. It's time we settled things on the battlefield!
61};
62
64{
65public:
66 npc_sergeant_bly() : CreatureScript("npc_sergeant_bly") { }
67
69 {
70 npc_sergeant_blyAI(Creature* creature) : ScriptedAI(creature)
71 {
72 Initialize();
73 instance = creature->GetInstanceScript();
75 Text_Timer = 0;
76 }
77
79 {
80 ShieldBash_Timer = 5000;
81 Revenge_Timer = 8000;
82 }
83
85
89 uint32 Revenge_Timer; //this is wrong, spell should never be used unless me->GetVictim() dodge, parry or block attack. Trinity support required.
91
92 void Reset() override
93 {
94 Initialize();
95
97 }
98
99 void UpdateAI(uint32 diff) override
100 {
102 {
103 if (Text_Timer<diff)
104 {
105 switch (postGossipStep)
106 {
107 case 1:
108 //weegli doesn't fight - he goes & blows up the door
110 pWeegli->AI()->DoAction(0);
111 Talk(SAY_1);
112 Text_Timer = 5000;
113 break;
114 case 2:
115 Talk(SAY_2);
116 Text_Timer = 5000;
117 break;
118 case 3:
121 AttackStart(target);
122
126 }
128 }
129 else Text_Timer -= diff;
130 }
131
132 if (!UpdateVictim())
133 return;
134
135 if (ShieldBash_Timer <= diff)
136 {
138 ShieldBash_Timer = 15000;
139 }
140 else
141 ShieldBash_Timer -= diff;
142
143 if (Revenge_Timer <= diff)
144 {
146 Revenge_Timer = 10000;
147 }
148 else
149 Revenge_Timer -= diff;
150
152 }
153
154 void DoAction(int32 /*param*/) override
155 {
157 Text_Timer = 0;
158 }
159
161 {
163 if (crew->IsAlive())
164 crew->SetFaction(FACTION_MONSTER);
165 }
166
167 bool OnGossipSelect(Player* player, uint32 /*menuId*/, uint32 gossipListId) override
168 {
169 uint32 const action = player->PlayerTalkClass->GetGossipOptionAction(gossipListId);
170 ClearGossipMenuFor(player);
171 if (action == GOSSIP_ACTION_INFO_DEF + 1)
172 {
173 CloseGossipMenuFor(player);
174 PlayerGUID = player->GetGUID();
175 DoAction(0);
176 }
177 return true;
178 }
179
180 bool OnGossipHello(Player* player) override
181 {
184 {
186 SendGossipMenuFor(player, 1517, me->GetGUID());
187 }
188 else
190 SendGossipMenuFor(player, 1515, me->GetGUID());
191 else
192 SendGossipMenuFor(player, 1516, me->GetGUID());
193 return true;
194 }
195 };
196
197 CreatureAI* GetAI(Creature* creature) const override
198 {
199 return GetZulFarrakAI<npc_sergeant_blyAI>(creature);
200 }
201};
202
203/*######
204+## go_troll_cage
205+######*/
206
208{
209public:
210 go_troll_cage() : GameObjectScript("go_troll_cage") { }
211
213 {
214 go_troll_cageAI(GameObject* go) : GameObjectAI(go), instance(go->GetInstanceScript()) { }
215
217
218 bool OnGossipHello(Player* /*player*/) override
219 {
221 //set bly & co to aggressive & start moving to top of stairs
222 initBlyCrewMember(ENTRY_BLY, 1884.99f, 1263, 41.52f);
223 initBlyCrewMember(ENTRY_RAVEN, 1882.5f, 1263, 41.52f);
224 initBlyCrewMember(ENTRY_ORO, 1886.47f, 1270.68f, 41.68f);
225 initBlyCrewMember(ENTRY_WEEGLI, 1890, 1263, 41.52f);
226 initBlyCrewMember(ENTRY_MURTA, 1891.19f, 1272.03f, 41.60f);
227 return false;
228 }
229
230 private:
231 void initBlyCrewMember(uint32 entry, float x, float y, float z)
232 {
234 {
235 crew->SetReactState(REACT_AGGRESSIVE);
236 crew->SetWalk(true);
237 crew->SetHomePosition(x, y, z, 0);
238 crew->GetMotionMaster()->MovePoint(1, x, y, z);
239 crew->SetFaction(FACTION_ESCORTEE_N_NEUTRAL_ACTIVE);
240 }
241 }
242 };
243
244 GameObjectAI* GetAI(GameObject* go) const override
245 {
246 return GetZulFarrakAI<go_troll_cageAI>(go);
247 }
248};
249
250/*######
251## npc_weegli_blastfuse
252######*/
253
261
267
269{
270 GOSSIP_WEEGLI_MID = 940, // Will you blow up that door now?
273
275{
276public:
277 npc_weegli_blastfuse() : CreatureScript("npc_weegli_blastfuse") { }
278
280 {
282 {
283 instance = creature->GetInstanceScript();
284 destroyingDoor = false;
285 Bomb_Timer = 10000;
286 LandMine_Timer = 30000;
287 }
288
293
294 void Reset() override
295 {
296 /*instance->SetData(0, NOT_STARTED);*/
297 }
298
299 void AttackStart(Unit* victim) override
300 {
301 AttackStartCaster(victim, 10);//keep back & toss bombs/shoot
302 }
303
304 void JustDied(Unit* /*killer*/) override
305 {
306 /*instance->SetData(0, DONE);*/
307 }
308
309 void UpdateAI(uint32 diff) override
310 {
311 if (!UpdateVictim())
312 return;
313
314 if (Bomb_Timer < diff)
315 {
317 Bomb_Timer = 10000;
318 }
319 else
320 Bomb_Timer -= diff;
321
323 {
326 }
327 else
328 {
331 }
332 }
333
334 void MovementInform(uint32 /*type*/, uint32 /*id*/) override
335 {
337 {
340 me->SetHomePosition(1882.69f, 1272.28f, 41.87f, 0);
341 }
342 else
343 if (destroyingDoor)
344 {
348 };
349 }
350
352 {
353 if (me->IsAlive())
354 {
356 me->GetMotionMaster()->MovePoint(0, 1858.57f, 1146.35f, 14.745f);
357 me->SetHomePosition(1858.57f, 1146.35f, 14.745f, 3.85f); // in case he gets interrupted
359 destroyingDoor = true;
360 }
361 }
362
363 bool OnGossipSelect(Player* player, uint32 /*menuId*/, uint32 gossipListId) override
364 {
365 uint32 const action = player->PlayerTalkClass->GetGossipOptionAction(gossipListId);
366 ClearGossipMenuFor(player);
367 if (action == GOSSIP_ACTION_INFO_DEF + 1)
368 {
369 CloseGossipMenuFor(player);
370 //here we make him run to door, set the charge and run away off to nowhere
371 DestroyDoor();
372 }
373 return true;
374 }
375
376 bool OnGossipHello(Player* player) override
377 {
380 {
383 SendGossipMenuFor(player, 1514, me->GetGUID()); //if event can proceed to end
384 break;
386 SendGossipMenuFor(player, 1511, me->GetGUID()); //if event not started
387 break;
388 default:
389 SendGossipMenuFor(player, 1513, me->GetGUID()); //if event are in progress
390 }
391 return true;
392 }
393 };
394
395 CreatureAI* GetAI(Creature* creature) const override
396 {
397 return GetZulFarrakAI<npc_weegli_blastfuseAI>(creature);
398 }
399};
400
401/*######
402## go_shallow_grave
403######*/
404
412
414{
415public:
416 go_shallow_grave() : GameObjectScript("go_shallow_grave") { }
417
419 {
421
422 bool OnGossipHello(Player* /*player*/) override
423 {
424 // randomly summon a zombie or dead hero the first time a grave is used
425 if (me->GetUseCount() == 0)
426 {
427 uint32 randomchance = urand(0, 100);
428 if (randomchance < CHANCE_ZOMBIE)
430 else
431 if ((randomchance - CHANCE_ZOMBIE) < CHANCE_DEAD_HERO)
433 }
434 me->AddUse();
435 return false;
436 }
437 };
438
439 GameObjectAI* GetAI(GameObject* go) const override
440 {
441 return GetZulFarrakAI<go_shallow_graveAI>(go);
442 }
443};
444
445/*######
446## at_zumrah
447######*/
448
450{
451 ZUMRAH_ID = 7271
453
455{
456public:
457 at_zumrah() : AreaTriggerScript("at_zumrah") { }
458
459 bool OnTrigger(Player* player, AreaTriggerEntry const* /*at*/) override
460 {
461 Creature* pZumrah = player->FindNearestCreature(ZUMRAH_ID, 30.0f);
462
463 if (!pZumrah)
464 return false;
465
467 return true;
468 }
469
470};
471
473{
474 new npc_sergeant_bly();
476 new go_shallow_grave();
477 new at_zumrah();
478 new go_troll_cage();
479}
int32_t int32
Definition Define.h:129
uint32_t uint32
Definition Define.h:133
@ TEMPSUMMON_CORPSE_TIMED_DESPAWN
uint32 urand(uint32 min, uint32 max)
Definition Random.cpp:42
void SendGossipMenuFor(Player *player, uint32 npcTextID, ObjectGuid const &guid)
void AddGossipItemFor(Player *player, GossipOptionIcon icon, std::string const &text, uint32 sender, uint32 action)
void ClearGossipMenuFor(Player *player)
void InitGossipMenuFor(Player *player, uint32 menuId)
void CloseGossipMenuFor(Player *player)
@ GOSSIP_SENDER_MAIN
@ GOSSIP_ACTION_INFO_DEF
@ FACTION_TROLL_FROSTMANE
@ FACTION_FRIENDLY
@ FACTION_MONSTER
@ FACTION_ESCORTEE_N_NEUTRAL_ACTIVE
@ REACT_AGGRESSIVE
@ SHEATH_STATE_MELEE
Definition UnitDefines.h:99
@ SHEATH_STATE_RANGED
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
void SetHomePosition(float x, float y, float z, float o)
Definition Creature.h:293
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
GameObject *const me
void AddUse()
Definition GameObject.h:214
uint32 GetUseCount() const
Definition GameObject.h:216
virtual ObjectGuid GetGuidData(uint32 type) const override
void DoUseDoorOrButton(ObjectGuid guid, uint32 withRestoreTime=0, bool useAlternativeState=false)
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={})
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:78
uint32 GetGossipOptionAction(uint32 selection) const
Definition GossipDef.h:269
PlayerMenu * PlayerTalkClass
Definition Player.h:1969
void AttackStartCaster(Unit *victim, float dist)
Definition UnitAI.cpp:48
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.cpp:166
Definition Unit.h:769
bool IsWithinMeleeRange(Unit const *obj) const
Definition Unit.h:844
void SetFaction(uint32 faction) override
Definition Unit.h:974
MotionMaster * GetMotionMaster()
Definition Unit.h:1667
bool IsAlive() const
Definition Unit.h:1234
virtual void SetSheath(SheathState sheathed)
Definition Unit.h:970
Unit * GetVictim() const
Definition Unit.h:859
bool isAttackReady(WeaponAttackType type=BASE_ATTACK) const
Definition Unit.h:835
InstanceScript * GetInstanceScript() const
Definition Object.cpp:1087
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:1992
Creature * FindNearestCreature(uint32 entry, float range, bool alive=true) const
Definition Object.cpp:2099
virtual uint32 GetData(uint32) const
Definition ZoneScript.h:55
virtual void SetData(uint32, uint32)
Definition ZoneScript.h:56
bool OnTrigger(Player *player, AreaTriggerEntry const *) override
GameObjectAI * GetAI(GameObject *go) const override
GameObjectAI * GetAI(GameObject *go) const override
CreatureAI * GetAI(Creature *creature) const override
CreatureAI * GetAI(Creature *creature) const override
TC_GAME_API Player * GetPlayer(Map const *, ObjectGuid const &guid)
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
float GetPositionZ() const
Definition Position.h:81
float GetPositionX() const
Definition Position.h:79
float GetPositionY() const
Definition Position.h:80
void AttackStart(Unit *) override
bool OnGossipHello(Player *) override
void initBlyCrewMember(uint32 entry, float x, float y, float z)
bool OnGossipHello(Player *) override
npc_sergeant_blyAI(Creature *creature)
Definition zulfarrak.cpp:70
void switchFactionIfAlive(uint32 entry)
bool OnGossipHello(Player *player) override
bool OnGossipSelect(Player *player, uint32, uint32 gossipListId) override
void UpdateAI(uint32 diff) override
Definition zulfarrak.cpp:99
void AttackStart(Unit *victim) override
bool OnGossipSelect(Player *player, uint32, uint32 gossipListId) override
bool OnGossipHello(Player *player) override
void MovementInform(uint32, uint32) override
blySays
Definition zulfarrak.cpp:46
@ SAY_1
Definition zulfarrak.cpp:47
@ SAY_2
Definition zulfarrak.cpp:48
weegliSays
@ SAY_WEEGLI_OHNO
@ SAY_WEEGLI_OK_I_GO
void AddSC_zulfarrak()
ShallowGrave
@ NPC_DEAD_HERO
@ NPC_ZOMBIE
@ CHANCE_DEAD_HERO
@ CHANCE_ZOMBIE
blygossip
Definition zulfarrak.cpp:58
@ GOSSIP_BLY_OID
Definition zulfarrak.cpp:60
@ GOSSIP_BLY_MID
Definition zulfarrak.cpp:59
zumrahConsts
@ ZUMRAH_ID
weegliSpells
@ SPELL_GOBLIN_LAND_MINE
@ SPELL_SHOOT
@ SPELL_WEEGLIS_BARREL
@ SPELL_BOMB
blySpells
Definition zulfarrak.cpp:52
@ SPELL_SHIELD_BASH
Definition zulfarrak.cpp:53
@ SPELL_REVENGE
Definition zulfarrak.cpp:54
weegligossip
@ GOSSIP_WEEGLI_OID
@ GOSSIP_WEEGLI_MID
@ GO_END_DOOR
Definition zulfarrak.h:35
@ ENTRY_RAVEN
Definition zulfarrak.h:30
@ ENTRY_MURTA
Definition zulfarrak.h:33
@ ENTRY_WEEGLI
Definition zulfarrak.h:32
@ ENTRY_ORO
Definition zulfarrak.h:31
@ ENTRY_BLY
Definition zulfarrak.h:29
@ EVENT_PYRAMID
Definition zulfarrak.h:37
@ PYRAMID_NOT_STARTED
Definition zulfarrak.h:48
@ PYRAMID_ARRIVED_AT_STAIR
Definition zulfarrak.h:50
@ PYRAMID_CAGES_OPEN
Definition zulfarrak.h:49
@ PYRAMID_KILLED_ALL_TROLLS
Definition zulfarrak.h:56