TrinityCore
chapter2.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#include "ScriptedGossip.h"
19#include "ScriptMgr.h"
20#include "GameObject.h"
21#include "MotionMaster.h"
22#include "ObjectAccessor.h"
23#include "Player.h"
24#include "ScriptedCreature.h"
25#include "SpellScript.h"
26
28{
40
45
46 TEXT_ID_EVENT = 13425
47};
48
50{
58
63
69
71};
72
74{
79
84
86
88 NPC_VALROTH = 29001,
89 NPC_ACOLYTE = 29007,
90 NPC_KOLTIRA = 28912,
92
95 SPELL_HERO_AGGRO = 53627
96};
97
99{
100 { 1653.36f, -6038.34f, 127.584f },
101 { 1653.765f, -6035.075f, 127.5844f },
102 { 1651.89f, -6037.101f, 127.5844f }
103};
104
106{
108 {
109 _eventGossip = false;
110 }
111
112 bool OnGossipHello(Player* player) override
113 {
114 ObjectGuid const guid = me->GetGUID();
115 _playerGUID = player->GetGUID();
116
117 if (me->IsQuestGiver())
118 player->PrepareQuestMenu(guid);
119
120 // override default gossip
121 if (_eventGossip)
122 {
123 SendGossipMenuFor(player, TEXT_ID_EVENT, guid);
124 return true;
125 }
126
127 return false;
128 }
129
130 void OnQuestAccept(Player* /* player */, Quest const* quest) override
131 {
132 if (quest->GetQuestId() == QUEST_BLOODY_BREAKOUT)
133 {
136 }
137 }
138
139 void Reset() override
140 {
141 me->SetImmuneToNPC(true);
145
146 _events.Reset();
149 _eventGossip = false;
150 }
151
153 {
155 fakeValroth->AI()->Talk(id);
156 }
157
158 void UpdateAI(uint32 diff) override
159 {
160 _events.Update(diff);
161
162 while (uint32 eventId = _events.ExecuteEvent())
163 {
164 switch (eventId)
165 {
166 case EVENT_INTRO_0:
170
172 break;
173 case EVENT_INTRO_1:
176
178 break;
179 case EVENT_INTRO_2:
180 me->GetMotionMaster()->MoveJump(koltiraPos[0], 25.0f, 15.0f);
181
183 break;
184
185 case EVENT_INTRO_3:
186 me->SetWalk(true);
188
189 break;
190 case EVENT_INTRO_4:
194 me->GetMotionMaster()->MovePoint(POINT_ID_2, koltiraPos[2], true, 3.839724f);
195
196 break;
197 case EVENT_INTRO_5:
200
202 break;
203 case EVENT_INTRO_6:
207 _eventGossip = true;
208
209 break;
212
214 break;
219
221 break;
226
228 break;
233
235 break;
239
240 break;
241 case EVENT_OUTRO_1:
246
249 break;
250 case EVENT_OUTRO_2:
252
254 break;
255 case EVENT_OUTRO_3:
257
259 break;
260 case EVENT_OUTRO_4:
261 me->SetWalk(false);
262 me->SetImmuneToNPC(false);
264 me->GetMotionMaster()->MovePath(NPC_KOLTIRA << 3, false);
265
266 break;
268 if (!_playerGUID)
269 return;
270
272 {
273 if (!player->IsAlive() || !player->IsWithinDist(me, INTERACTION_DISTANCE * 6))
274 {
277 player->FailQuest(QUEST_BLOODY_BREAKOUT);
278 }
279 }
280
282 break;
283 }
284 }
285 }
286
287 void MovementInform(uint32 type, uint32 pointId) override
288 {
289 if (type == POINT_MOTION_TYPE)
290 {
291 if (pointId == POINT_ID_1)
292 {
295
298 }
299 else if (pointId == POINT_ID_2)
301 }
302 else
303 {
304 if (pointId == POINT_ID_6)
306 }
307 }
308
309 void JustSummoned(Creature* summon) override
310 {
311 _summons.Summon(summon);
312 }
313
314 void SummonedCreatureDespawn(Creature* summon) override
315 {
316 if (summon->GetEntry() == NPC_VALROTH)
318
319 _summons.Despawn(summon);
320 }
321
322private:
326
327 bool _eventGossip = false;
328};
329
330//Scarlet courier
332{
335 SPELL_SHOOT = 52818,
337 NPC_SCARLET_COURIER = 29076
339
341{
342public:
343 npc_scarlet_courier() : CreatureScript("npc_scarlet_courier") { }
344
345 CreatureAI* GetAI(Creature* creature) const override
346 {
347 return new npc_scarlet_courierAI(creature);
348 }
349
351 {
353 {
354 Initialize();
355 }
356
358 {
359 uiStage = 1;
360 uiStage_timer = 3000;
361 }
362
365
366 void Reset() override
367 {
368 me->Mount(14338); // not sure about this id
369 Initialize();
370 }
371
372 void JustEngagedWith(Unit* /*who*/) override
373 {
375 me->Dismount();
376 uiStage = 0;
377 }
378
379 void MovementInform(uint32 type, uint32 id) override
380 {
381 if (type != POINT_MOTION_TYPE)
382 return;
383
384 if (id == 1)
385 uiStage = 2;
386 }
387
388 void UpdateAI(uint32 diff) override
389 {
390 if (uiStage && !me->IsInCombat())
391 {
392 if (uiStage_timer <= diff)
393 {
394 switch (uiStage)
395 {
396 case 1:
397 me->SetWalk(true);
399 {
401 float x, y, z;
402 tree->GetContactPoint(me, x, y, z);
403 me->GetMotionMaster()->MovePoint(1, x, y, z);
404 }
405 break;
406 case 2:
408 if (Unit* unit = tree->GetOwner())
409 AttackStart(unit);
410 break;
411 }
412 uiStage_timer = 3000;
413 uiStage = 0;
414 } else uiStage_timer -= diff;
415 }
416
417 if (!UpdateVictim())
418 return;
419 }
420 };
421
422};
423
424/*######
425## npc_a_special_surprise
426######*/
427//used by 29032, 29061, 29065, 29067, 29068, 29070, 29074, 29072, 29073, 29071 but signed for 29032
429{
440
442 NPC_PLAGUEFIST = 29053
444
446{
447public:
448 npc_a_special_surprise() : CreatureScript("npc_a_special_surprise") { }
449
450 CreatureAI* GetAI(Creature* creature) const override
451 {
452 return new npc_a_special_surpriseAI(creature);
453 }
454
456 {
458 {
459 Initialize();
460 }
461
463 {
467 }
468
472
473 void Reset() override
474 {
475 Initialize();
476
477 me->SetImmuneToPC(true);
478 }
479
481 {
482 switch (me->GetEntry())
483 {
484 case 29061: // Ellen Stanbridge
485 if (player->GetQuestStatus(12742) == QUEST_STATUS_INCOMPLETE)
486 return true;
487 break;
488 case 29072: // Kug Ironjaw
489 if (player->GetQuestStatus(12748) == QUEST_STATUS_INCOMPLETE)
490 return true;
491 break;
492 case 29067: // Donovan Pulfrost
493 if (player->GetQuestStatus(12744) == QUEST_STATUS_INCOMPLETE)
494 return true;
495 break;
496 case 29065: // Yazmina Oakenthorn
497 if (player->GetQuestStatus(12743) == QUEST_STATUS_INCOMPLETE)
498 return true;
499 break;
500 case 29071: // Antoine Brack
501 if (player->GetQuestStatus(12750) == QUEST_STATUS_INCOMPLETE)
502 return true;
503 break;
504 case 29032: // Malar Bravehorn
505 if (player->GetQuestStatus(12739) == QUEST_STATUS_INCOMPLETE)
506 return true;
507 break;
508 case 29068: // Goby Blastenheimer
509 if (player->GetQuestStatus(12745) == QUEST_STATUS_INCOMPLETE)
510 return true;
511 break;
512 case 29073: // Iggy Darktusk
513 if (player->GetQuestStatus(12749) == QUEST_STATUS_INCOMPLETE)
514 return true;
515 break;
516 case 29074: // Lady Eonys
517 if (player->GetQuestStatus(12747) == QUEST_STATUS_INCOMPLETE)
518 return true;
519 break;
520 case 29070: // Valok the Righteous
521 if (player->GetQuestStatus(12746) == QUEST_STATUS_INCOMPLETE)
522 return true;
523 break;
524 }
525
526 return false;
527 }
528
529 void MoveInLineOfSight(Unit* who) override
530
531 {
533 return;
534
535 if (MeetQuestCondition(who->ToPlayer()))
536 PlayerGUID = who->GetGUID();
537 }
538
539 void UpdateAI(uint32 diff) override
540 {
541 if (!PlayerGUID.IsEmpty() && !me->GetVictim() && me->IsAlive())
542 {
543 if (ExecuteSpeech_Timer <= diff)
544 {
546
547 if (!player)
548 {
549 Reset();
550 return;
551 }
552
553 switch (ExecuteSpeech_Counter)
554 {
555 case 0:
556 Talk(SAY_EXEC_START, player);
557 break;
558 case 1:
560 break;
561 case 2:
562 Talk(SAY_EXEC_PROG, player);
563 break;
564 case 3:
565 Talk(SAY_EXEC_NAME, player);
566 break;
567 case 4:
568 Talk(SAY_EXEC_RECOG, player);
569 break;
570 case 5:
571 Talk(SAY_EXEC_NOREM, player);
572 break;
573 case 6:
574 Talk(SAY_EXEC_THINK, player);
575 break;
576 case 7:
577 Talk(SAY_EXEC_LISTEN, player);
578 break;
579 case 8:
580 if (Creature* Plaguefist = GetClosestCreatureWithEntry(me, NPC_PLAGUEFIST, 85.0f))
581 Plaguefist->AI()->Talk(SAY_PLAGUEFIST, player);
582 break;
583 case 9:
584 Talk(SAY_EXEC_TIME, player);
586 me->SetImmuneToPC(false);
587 break;
588 case 10:
589 Talk(SAY_EXEC_WAITING, player);
590 break;
591 case 11:
594 me->SetHealth(0);
595 return;
596 }
597
598 if (ExecuteSpeech_Counter >= 9)
599 ExecuteSpeech_Timer = 15000;
600 else
601 ExecuteSpeech_Timer = 7000;
602
604 }
605 else
606 ExecuteSpeech_Timer -= diff;
607 }
608 }
609 };
610};
611
612// 53110 - Devour Humanoid
614{
616 {
618 }
619
620 void Register() override
621 {
623 }
624};
625
627{
632}
uint32_t uint32
Definition: Define.h:142
@ POINT_MOTION_TYPE
#define INTERACTION_DISTANCE
Definition: ObjectDefines.h:24
#define INSPECT_DISTANCE
Definition: ObjectDefines.h:26
@ TYPEID_PLAYER
Definition: ObjectGuid.h:41
@ QUEST_STATUS_INCOMPLETE
Definition: QuestDef.h:145
#define RegisterCreatureAI(ai_name)
Definition: ScriptMgr.h:1380
#define RegisterSpellScript(spell_script)
Definition: ScriptMgr.h:1369
Creature * GetClosestCreatureWithEntry(WorldObject *source, uint32 entry, float maxSearchRange, bool alive=true)
void SendGossipMenuFor(Player *player, uint32 npcTextID, ObjectGuid const &guid)
SpellEffIndex
Definition: SharedDefines.h:29
@ EFFECT_0
Definition: SharedDefines.h:30
@ SPELL_EFFECT_SCRIPT_EFFECT
#define SpellEffectFn(F, I, N)
Definition: SpellScript.h:842
@ UNIT_STAND_STATE_DEAD
Definition: UnitDefines.h:49
@ UNIT_STAND_STATE_KNEEL
Definition: UnitDefines.h:50
@ UNIT_STAND_STATE_STAND
Definition: UnitDefines.h:42
@ UNIT_STAND_STATE_SIT
Definition: UnitDefines.h:43
@ UNIT_NPC_FLAG_GOSSIP
Definition: UnitDefines.h:297
@ JUST_DIED
Definition: Unit.h:247
SpecialSurprise
Definition: chapter2.cpp:429
@ EMOTE_DIES
Definition: chapter2.cpp:439
@ SAY_EXEC_PROG
Definition: chapter2.cpp:431
@ SAY_EXEC_NAME
Definition: chapter2.cpp:432
@ SAY_EXEC_TIME
Definition: chapter2.cpp:437
@ NPC_PLAGUEFIST
Definition: chapter2.cpp:442
@ SAY_EXEC_THINK
Definition: chapter2.cpp:435
@ SAY_EXEC_NOREM
Definition: chapter2.cpp:434
@ SAY_PLAGUEFIST
Definition: chapter2.cpp:441
@ SAY_EXEC_WAITING
Definition: chapter2.cpp:438
@ SAY_EXEC_LISTEN
Definition: chapter2.cpp:436
@ SAY_EXEC_START
Definition: chapter2.cpp:430
@ SAY_EXEC_RECOG
Definition: chapter2.cpp:433
ScarletCourierEnum
Definition: chapter2.cpp:332
@ SPELL_SHOOT
Definition: chapter2.cpp:335
@ SAY_TREE1
Definition: chapter2.cpp:333
@ NPC_SCARLET_COURIER
Definition: chapter2.cpp:337
@ GO_INCONSPICUOUS_TREE
Definition: chapter2.cpp:336
@ SAY_TREE2
Definition: chapter2.cpp:334
BloodyBreakoutTexts
Definition: chapter2.cpp:28
@ SAY_KOLTIRA_4
Definition: chapter2.cpp:33
@ SAY_KOLTIRA_2
Definition: chapter2.cpp:31
@ SAY_VALROTH_0
Definition: chapter2.cpp:41
@ SAY_KOLTIRA_0
Definition: chapter2.cpp:29
@ SAY_KOLTIRA_6
Definition: chapter2.cpp:35
@ SAY_KOLTIRA_5
Definition: chapter2.cpp:34
@ SAY_KOLTIRA_1
Definition: chapter2.cpp:30
@ SAY_VALROTH_1
Definition: chapter2.cpp:42
@ SAY_KOLTIRA_10
Definition: chapter2.cpp:39
@ SAY_KOLTIRA_3
Definition: chapter2.cpp:32
@ TEXT_ID_EVENT
Definition: chapter2.cpp:46
@ SAY_VALROTH_2
Definition: chapter2.cpp:43
@ SAY_KOLTIRA_8
Definition: chapter2.cpp:37
@ SAY_VALROTH_3
Definition: chapter2.cpp:44
@ SAY_KOLTIRA_9
Definition: chapter2.cpp:38
@ SAY_KOLTIRA_7
Definition: chapter2.cpp:36
Position const koltiraPos[3]
Definition: chapter2.cpp:98
void AddSC_the_scarlet_enclave_c2()
Definition: chapter2.cpp:626
BloodyBreakout
Definition: chapter2.cpp:74
@ SPELL_ANTI_MAGIC_ZONE
Definition: chapter2.cpp:94
@ SPELL_HERO_AGGRO
Definition: chapter2.cpp:95
@ SUMMON_ACOLYTES_2
Definition: chapter2.cpp:82
@ SPELL_KOLTIRA_TRANSFORM
Definition: chapter2.cpp:93
@ SUMMON_ACOLYTES_0
Definition: chapter2.cpp:80
@ NPC_FAKE_VALROTH
Definition: chapter2.cpp:87
@ POINT_ID_6
Definition: chapter2.cpp:77
@ NPC_ACOLYTE
Definition: chapter2.cpp:89
@ NPC_KOLTIRA
Definition: chapter2.cpp:90
@ POINT_ID_2
Definition: chapter2.cpp:76
@ SUMMON_ACOLYTES_1
Definition: chapter2.cpp:81
@ SUMMON_VALROTH
Definition: chapter2.cpp:83
@ NPC_VALROTH
Definition: chapter2.cpp:88
@ POINT_ID_1
Definition: chapter2.cpp:75
@ POINT_ID_10
Definition: chapter2.cpp:78
@ NPC_KOLTIRA_MOUNT
Definition: chapter2.cpp:91
@ QUEST_BLOODY_BREAKOUT
Definition: chapter2.cpp:85
BloodyBreakoutEvents
Definition: chapter2.cpp:50
@ EVENT_INTRO_4
Definition: chapter2.cpp:55
@ EVENT_SPAWN_WAVE_2
Definition: chapter2.cpp:60
@ EVENT_OUTRO_2
Definition: chapter2.cpp:66
@ EVENT_INTRO_1
Definition: chapter2.cpp:52
@ EVENT_OUTRO_3
Definition: chapter2.cpp:67
@ EVENT_INTRO_2
Definition: chapter2.cpp:53
@ EVENT_INTRO_5
Definition: chapter2.cpp:56
@ EVENT_CHECK_PLAYER
Definition: chapter2.cpp:70
@ EVENT_SPAWN_WAVE_3
Definition: chapter2.cpp:61
@ EVENT_KOLTIRA_ADVICE
Definition: chapter2.cpp:64
@ EVENT_INTRO_6
Definition: chapter2.cpp:57
@ EVENT_SPAWN_WAVE_1
Definition: chapter2.cpp:59
@ EVENT_INTRO_0
Definition: chapter2.cpp:51
@ EVENT_OUTRO_1
Definition: chapter2.cpp:65
@ EVENT_INTRO_3
Definition: chapter2.cpp:54
@ EVENT_OUTRO_4
Definition: chapter2.cpp:68
@ EVENT_SPAWN_VALROTH
Definition: chapter2.cpp:62
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 setDeathState(DeathState s) override
Definition: Creature.cpp:2197
void SetImmuneToPC(bool apply) override
Definition: Creature.h:170
void LoadEquipment(int8 id=1, bool force=false)
Definition: Creature.cpp:1946
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
Definition: Creature.cpp:2415
void SetImmuneToNPC(bool apply) override
Definition: Creature.h:173
uint32 ExecuteEvent()
Definition: EventMap.cpp:73
void Update(uint32 time)
Definition: EventMap.h:56
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition: EventMap.cpp:36
void CancelEvent(uint32 eventId)
Definition: EventMap.cpp:131
void Reset()
Definition: EventMap.cpp:21
void MoveJump(Position const &pos, float speedXY, float speedZ, uint32 id=EVENT_JUMP, bool hasOrientation=false, JumpArrivalCastArgs const *arrivalCast=nullptr, Movement::SpellEffectExtraData const *spellEffectExtraData=nullptr)
void MovePath(uint32 pathId, bool repeatable, Optional< Milliseconds > duration={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< std::pair< Milliseconds, Milliseconds > > waitTimeRangeAtPathEnd={}, Optional< float > wanderDistanceAtPathEnds={}, Optional< bool > followPathBackwardsFromEndToStart={}, bool generatePath=true)
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< float > closeEnoughDistance={})
bool IsEmpty() const
Definition: ObjectGuid.h:319
void Clear()
Definition: ObjectGuid.h:286
TypeID GetTypeId() const
Definition: Object.h:173
uint32 GetEntry() const
Definition: Object.h:161
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
static Player * ToPlayer(Object *o)
Definition: Object.h:213
void PrepareQuestMenu(ObjectGuid guid)
Definition: Player.cpp:14474
QuestStatus GetQuestStatus(uint32 quest_id) const
Definition: Player.cpp:16050
uint32 GetQuestId() const
Definition: QuestDef.h:587
Unit * GetCaster() const
Unit * GetHitUnit() const
int32 GetEffectValue() const
HookList< EffectHandler > OnEffectHitTarget
Definition: SpellScript.h:840
bool HasEntry(uint32 entry) const
void Despawn(Creature const *summon)
void Summon(Creature const *summon)
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.h:159
Definition: Unit.h:627
void SetHealth(uint64 val)
Definition: Unit.cpp:9346
void SetStandState(UnitStandStateType state, uint32 animKitID=0)
Definition: Unit.cpp:10100
MotionMaster * GetMotionMaster()
Definition: Unit.h:1652
void Dismount()
Definition: Unit.cpp:7920
bool IsAlive() const
Definition: Unit.h:1164
void RemoveNpcFlag(NPCFlags flags)
Definition: Unit.h:983
bool IsQuestGiver() const
Definition: Unit.h:994
void Mount(uint32 mount, uint32 vehicleId=0, uint32 creatureEntry=0)
Definition: Unit.cpp:7887
void SetNpcFlag(NPCFlags flags)
Definition: Unit.h:982
bool SetWalk(bool enable)
Definition: Unit.cpp:12707
Unit * GetVictim() const
Definition: Unit.h:715
void RemoveAllAuras()
Definition: Unit.cpp:4242
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3831
bool IsInCombat() const
Definition: Unit.h:1043
GameObject * FindNearestGameObject(uint32 entry, float range, bool spawnedOnly=true) const
Definition: Object.cpp:2170
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2896
Unit * GetOwner() const
Definition: Object.cpp:2229
Creature * FindNearestCreature(uint32 entry, float range, bool alive=true) const
Definition: Object.cpp:2148
bool IsWithinDist(WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=true) const
Definition: Object.cpp:1142
void SummonCreatureGroup(uint8 group, std::list< TempSummon * > *list=nullptr)
Definition: Object.cpp:2131
CreatureAI * GetAI(Creature *creature) const override
Definition: chapter2.cpp:450
CreatureAI * GetAI(Creature *creature) const override
Definition: chapter2.cpp:345
void HandleScriptEffect(SpellEffIndex)
Definition: chapter2.cpp:615
TC_GAME_API Player * GetPlayer(Map const *, ObjectGuid const &guid)
void AttackStart(Unit *) override
== Triggered Actions Requested ==================
bool OnGossipHello(Player *player) override
Definition: chapter2.cpp:112
void UpdateAI(uint32 diff) override
Definition: chapter2.cpp:158
npc_koltira_deathweaver(Creature *creature)
Definition: chapter2.cpp:107
void Reset() override
Definition: chapter2.cpp:139
void JustSummoned(Creature *summon) override
Definition: chapter2.cpp:309
void OnQuestAccept(Player *, Quest const *quest) override
Definition: chapter2.cpp:130
void SummonedCreatureDespawn(Creature *summon) override
Definition: chapter2.cpp:314
void MovementInform(uint32 type, uint32 pointId) override
Definition: chapter2.cpp:287
void FakeValrothTalk(uint32 id)
Definition: chapter2.cpp:152
void UpdateAI(uint32 diff) override
Definition: chapter2.cpp:388
void MovementInform(uint32 type, uint32 id) override
Definition: chapter2.cpp:379