TrinityCore
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 }
151
152 void DoAction(int32 /*param*/) override
153 {
155 Text_Timer = 0;
156 }
157
159 {
161 if (crew->IsAlive())
162 crew->SetFaction(FACTION_MONSTER);
163 }
164
165 bool OnGossipSelect(Player* player, uint32 /*menuId*/, uint32 gossipListId) override
166 {
167 uint32 const action = player->PlayerTalkClass->GetGossipOptionAction(gossipListId);
168 ClearGossipMenuFor(player);
169 if (action == GOSSIP_ACTION_INFO_DEF + 1)
170 {
171 CloseGossipMenuFor(player);
172 PlayerGUID = player->GetGUID();
173 DoAction(0);
174 }
175 return true;
176 }
177
178 bool OnGossipHello(Player* player) override
179 {
182 {
184 SendGossipMenuFor(player, 1517, me->GetGUID());
185 }
186 else
188 SendGossipMenuFor(player, 1515, me->GetGUID());
189 else
190 SendGossipMenuFor(player, 1516, me->GetGUID());
191 return true;
192 }
193 };
194
195 CreatureAI* GetAI(Creature* creature) const override
196 {
197 return GetZulFarrakAI<npc_sergeant_blyAI>(creature);
198 }
199};
200
201/*######
202+## go_troll_cage
203+######*/
204
206{
207public:
208 go_troll_cage() : GameObjectScript("go_troll_cage") { }
209
211 {
212 go_troll_cageAI(GameObject* go) : GameObjectAI(go), instance(go->GetInstanceScript()) { }
213
215
216 bool OnGossipHello(Player* /*player*/) override
217 {
219 //set bly & co to aggressive & start moving to top of stairs
220 initBlyCrewMember(ENTRY_BLY, 1884.99f, 1263, 41.52f);
221 initBlyCrewMember(ENTRY_RAVEN, 1882.5f, 1263, 41.52f);
222 initBlyCrewMember(ENTRY_ORO, 1886.47f, 1270.68f, 41.68f);
223 initBlyCrewMember(ENTRY_WEEGLI, 1890, 1263, 41.52f);
224 initBlyCrewMember(ENTRY_MURTA, 1891.19f, 1272.03f, 41.60f);
225 return false;
226 }
227
228 private:
229 void initBlyCrewMember(uint32 entry, float x, float y, float z)
230 {
232 {
233 crew->SetReactState(REACT_AGGRESSIVE);
234 crew->SetWalk(true);
235 crew->SetHomePosition(x, y, z, 0);
236 crew->GetMotionMaster()->MovePoint(1, x, y, z);
237 crew->SetFaction(FACTION_ESCORTEE_N_NEUTRAL_ACTIVE);
238 }
239 }
240 };
241
242 GameObjectAI* GetAI(GameObject* go) const override
243 {
244 return GetZulFarrakAI<go_troll_cageAI>(go);
245 }
246};
247
248/*######
249## npc_weegli_blastfuse
250######*/
251
253{
259
261{
265
267{
268 GOSSIP_WEEGLI_MID = 940, // Will you blow up that door now?
271
273{
274public:
275 npc_weegli_blastfuse() : CreatureScript("npc_weegli_blastfuse") { }
276
278 {
280 {
281 instance = creature->GetInstanceScript();
282 destroyingDoor = false;
283 Bomb_Timer = 10000;
284 LandMine_Timer = 30000;
285 }
286
291
292 void Reset() override
293 {
294 /*instance->SetData(0, NOT_STARTED);*/
295 }
296
297 void AttackStart(Unit* victim) override
298 {
299 AttackStartCaster(victim, 10);//keep back & toss bombs/shoot
300 }
301
302 void JustDied(Unit* /*killer*/) override
303 {
304 /*instance->SetData(0, DONE);*/
305 }
306
307 void UpdateAI(uint32 diff) override
308 {
309 if (!UpdateVictim())
310 return;
311
312 if (Bomb_Timer < diff)
313 {
315 Bomb_Timer = 10000;
316 }
317 else
318 Bomb_Timer -= diff;
319
321 {
324 }
325 else
326 {
328 }
329 }
330
331 void MovementInform(uint32 /*type*/, uint32 /*id*/) override
332 {
334 {
337 me->SetHomePosition(1882.69f, 1272.28f, 41.87f, 0);
338 }
339 else
340 if (destroyingDoor)
341 {
345 };
346 }
347
349 {
350 if (me->IsAlive())
351 {
353 me->GetMotionMaster()->MovePoint(0, 1858.57f, 1146.35f, 14.745f);
354 me->SetHomePosition(1858.57f, 1146.35f, 14.745f, 3.85f); // in case he gets interrupted
356 destroyingDoor = true;
357 }
358 }
359
360 bool OnGossipSelect(Player* player, uint32 /*menuId*/, uint32 gossipListId) override
361 {
362 uint32 const action = player->PlayerTalkClass->GetGossipOptionAction(gossipListId);
363 ClearGossipMenuFor(player);
364 if (action == GOSSIP_ACTION_INFO_DEF + 1)
365 {
366 CloseGossipMenuFor(player);
367 //here we make him run to door, set the charge and run away off to nowhere
368 DestroyDoor();
369 }
370 return true;
371 }
372
373 bool OnGossipHello(Player* player) override
374 {
377 {
380 SendGossipMenuFor(player, 1514, me->GetGUID()); //if event can proceed to end
381 break;
383 SendGossipMenuFor(player, 1511, me->GetGUID()); //if event not started
384 break;
385 default:
386 SendGossipMenuFor(player, 1513, me->GetGUID()); //if event are in progress
387 }
388 return true;
389 }
390 };
391
392 CreatureAI* GetAI(Creature* creature) const override
393 {
394 return GetZulFarrakAI<npc_weegli_blastfuseAI>(creature);
395 }
396};
397
398/*######
399## go_shallow_grave
400######*/
401
403{
409
411{
412public:
413 go_shallow_grave() : GameObjectScript("go_shallow_grave") { }
414
416 {
418
419 bool OnGossipHello(Player* /*player*/) override
420 {
421 // randomly summon a zombie or dead hero the first time a grave is used
422 if (me->GetUseCount() == 0)
423 {
424 uint32 randomchance = urand(0, 100);
425 if (randomchance < CHANCE_ZOMBIE)
427 else
428 if ((randomchance - CHANCE_ZOMBIE) < CHANCE_DEAD_HERO)
430 }
431 me->AddUse();
432 return false;
433 }
434 };
435
436 GameObjectAI* GetAI(GameObject* go) const override
437 {
438 return GetZulFarrakAI<go_shallow_graveAI>(go);
439 }
440};
441
442/*######
443## at_zumrah
444######*/
445
447{
448 ZUMRAH_ID = 7271
450
452{
453public:
454 at_zumrah() : AreaTriggerScript("at_zumrah") { }
455
456 bool OnTrigger(Player* player, AreaTriggerEntry const* /*areaTrigger*/) override
457 {
458 Creature* pZumrah = player->FindNearestCreature(ZUMRAH_ID, 30.0f);
459
460 if (!pZumrah)
461 return false;
462
464 return true;
465 }
466
467};
468
470{
471 new npc_sergeant_bly();
473 new go_shallow_grave();
474 new at_zumrah();
475 new go_troll_cage();
476}
int32_t int32
Definition: Define.h:138
uint32_t uint32
Definition: Define.h:142
@ TEMPSUMMON_CORPSE_TIMED_DESPAWN
Definition: ObjectDefines.h:68
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:42
void AddGossipItemFor(Player *player, GossipOptionNpc optionNpc, std::string text, uint32 sender, uint32 action)
void SendGossipMenuFor(Player *player, uint32 npcTextID, ObjectGuid const &guid)
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
Definition: UnitDefines.h:508
@ SHEATH_STATE_MELEE
Definition: UnitDefines.h:83
@ SHEATH_STATE_RANGED
Definition: UnitDefines.h:84
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 SetHomePosition(float x, float y, float z, float o)
Definition: Creature.h:371
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
Definition: Creature.cpp:2415
GameObject *const me
Definition: GameObjectAI.h:50
void AddUse()
Definition: GameObject.h:320
uint32 GetUseCount() const
Definition: GameObject.h:322
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={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< float > closeEnoughDistance={})
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
std::unique_ptr< PlayerMenu > PlayerTalkClass
Definition: Player.h:2380
void AttackStartCaster(Unit *victim, float dist)
Definition: UnitAI.cpp:55
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.cpp:180
Definition: Unit.h:627
bool IsWithinMeleeRange(Unit const *obj) const
Definition: Unit.h:699
void SetFaction(uint32 faction) override
Definition: Unit.h:859
MotionMaster * GetMotionMaster()
Definition: Unit.h:1652
bool IsAlive() const
Definition: Unit.h:1164
void SetSheath(SheathState sheathed)
Definition: Unit.cpp:5630
Unit * GetVictim() const
Definition: Unit.h:715
bool isAttackReady(WeaponAttackType type=BASE_ATTACK) const
Definition: Unit.h:690
InstanceScript * GetInstanceScript() const
Definition: Object.cpp:1042
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
Creature * FindNearestCreature(uint32 entry, float range, bool alive=true) const
Definition: Object.cpp:2148
virtual uint32 GetData(uint32) const
Definition: ZoneScript.h:91
virtual void SetData(uint32, uint32)
Definition: ZoneScript.h:92
bool OnTrigger(Player *player, AreaTriggerEntry const *) override
Definition: zulfarrak.cpp:456
GameObjectAI * GetAI(GameObject *go) const override
Definition: zulfarrak.cpp:436
GameObjectAI * GetAI(GameObject *go) const override
Definition: zulfarrak.cpp:242
CreatureAI * GetAI(Creature *creature) const override
Definition: zulfarrak.cpp:195
CreatureAI * GetAI(Creature *creature) const override
Definition: zulfarrak.cpp:392
TC_GAME_API Player * GetPlayer(Map const *, ObjectGuid const &guid)
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
constexpr float GetPositionX() const
Definition: Position.h:76
constexpr float GetPositionY() const
Definition: Position.h:77
constexpr float GetPositionZ() const
Definition: Position.h:78
void AttackStart(Unit *) override
== Triggered Actions Requested ==================
bool OnGossipHello(Player *) override
Definition: zulfarrak.cpp:419
void initBlyCrewMember(uint32 entry, float x, float y, float z)
Definition: zulfarrak.cpp:229
bool OnGossipHello(Player *) override
Definition: zulfarrak.cpp:216
go_troll_cageAI(GameObject *go)
Definition: zulfarrak.cpp:212
npc_sergeant_blyAI(Creature *creature)
Definition: zulfarrak.cpp:70
void switchFactionIfAlive(uint32 entry)
Definition: zulfarrak.cpp:158
bool OnGossipHello(Player *player) override
Definition: zulfarrak.cpp:178
bool OnGossipSelect(Player *player, uint32, uint32 gossipListId) override
Definition: zulfarrak.cpp:165
void UpdateAI(uint32 diff) override
Definition: zulfarrak.cpp:99
void AttackStart(Unit *victim) override
== Triggered Actions Requested ==================
Definition: zulfarrak.cpp:297
bool OnGossipSelect(Player *player, uint32, uint32 gossipListId) override
Definition: zulfarrak.cpp:360
bool OnGossipHello(Player *player) override
Definition: zulfarrak.cpp:373
void MovementInform(uint32, uint32) override
Definition: zulfarrak.cpp:331
blySays
Definition: zulfarrak.cpp:46
@ SAY_1
Definition: zulfarrak.cpp:47
@ SAY_2
Definition: zulfarrak.cpp:48
weegliSays
Definition: zulfarrak.cpp:261
@ SAY_WEEGLI_OHNO
Definition: zulfarrak.cpp:262
@ SAY_WEEGLI_OK_I_GO
Definition: zulfarrak.cpp:263
void AddSC_zulfarrak()
Definition: zulfarrak.cpp:469
ShallowGrave
Definition: zulfarrak.cpp:403
@ NPC_DEAD_HERO
Definition: zulfarrak.cpp:405
@ NPC_ZOMBIE
Definition: zulfarrak.cpp:404
@ CHANCE_DEAD_HERO
Definition: zulfarrak.cpp:407
@ CHANCE_ZOMBIE
Definition: zulfarrak.cpp:406
blygossip
Definition: zulfarrak.cpp:58
@ GOSSIP_BLY_OID
Definition: zulfarrak.cpp:60
@ GOSSIP_BLY_MID
Definition: zulfarrak.cpp:59
zumrahConsts
Definition: zulfarrak.cpp:447
@ ZUMRAH_ID
Definition: zulfarrak.cpp:448
weegliSpells
Definition: zulfarrak.cpp:253
@ SPELL_GOBLIN_LAND_MINE
Definition: zulfarrak.cpp:255
@ SPELL_SHOOT
Definition: zulfarrak.cpp:256
@ SPELL_WEEGLIS_BARREL
Definition: zulfarrak.cpp:257
@ SPELL_BOMB
Definition: zulfarrak.cpp:254
blySpells
Definition: zulfarrak.cpp:52
@ SPELL_SHIELD_BASH
Definition: zulfarrak.cpp:53
@ SPELL_REVENGE
Definition: zulfarrak.cpp:54
weegligossip
Definition: zulfarrak.cpp:267
@ GOSSIP_WEEGLI_OID
Definition: zulfarrak.cpp:269
@ GOSSIP_WEEGLI_MID
Definition: zulfarrak.cpp:268
@ GO_END_DOOR
Definition: zulfarrak.h:56
@ ENTRY_RAVEN
Definition: zulfarrak.h:48
@ ENTRY_MURTA
Definition: zulfarrak.h:51
@ ENTRY_WEEGLI
Definition: zulfarrak.h:50
@ ENTRY_ORO
Definition: zulfarrak.h:49
@ ENTRY_BLY
Definition: zulfarrak.h:47
@ EVENT_PYRAMID
Definition: zulfarrak.h:58
@ PYRAMID_NOT_STARTED
Definition: zulfarrak.h:64
@ PYRAMID_ARRIVED_AT_STAIR
Definition: zulfarrak.h:66
@ PYRAMID_CAGES_OPEN
Definition: zulfarrak.h:65
@ PYRAMID_KILLED_ALL_TROLLS
Definition: zulfarrak.h:72