TrinityCore
Loading...
Searching...
No Matches
shadowfang_keep.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: Shadowfang_Keep
20SD%Complete: 75
21SDComment: npc_shadowfang_prisoner using escortAI for movement to door. Might need additional code in case being attacked. Add proper texts/say().
22SDCategory: Shadowfang Keep
23EndScriptData */
24
25/* ContentData
26npc_shadowfang_prisoner
27EndContentData */
28
29#include "ScriptMgr.h"
30#include "shadowfang_keep.h"
31#include "InstanceScript.h"
32#include "Player.h"
33#include "ScriptedEscortAI.h"
34#include "ScriptedGossip.h"
35#include "SpellAuraEffects.h"
36#include "SpellScript.h"
37
38/*######
39## npc_shadowfang_prisoner
40######*/
41
52
54{
57};
58
60{
61public:
62 npc_shadowfang_prisoner() : CreatureScript("npc_shadowfang_prisoner") { }
63
65 {
67 {
68 instance = creature->GetInstanceScript();
69 }
70
72
73 void WaypointReached(uint32 waypointId, uint32 /*pathId*/) override
74 {
75 if (Player* player = GetPlayerForEscort())
76 {
77 switch (waypointId)
78 {
79 case 0:
80 if (me->GetEntry() == NPC_ASH)
81 Talk(SAY_FREE_AS, player);
82 else
83 Talk(SAY_FREE_AD, player);
84 break;
85 case 10:
86 if (me->GetEntry() == NPC_ASH)
87 Talk(SAY_OPEN_DOOR_AS, player);
88 else
89 Talk(SAY_OPEN_DOOR_AD, player);
90 break;
91 case 11:
92 if (me->GetEntry() == NPC_ASH)
94 break;
95 case 12:
96 if (me->GetEntry() == NPC_ASH)
97 Talk(SAY_POST_DOOR_AS, player);
98 else
99 Talk(SAY_POST1_DOOR_AD, player);
100
102 break;
103 case 13:
104 if (me->GetEntry() != NPC_ASH)
105 Talk(SAY_POST2_DOOR_AD, player);
106 break;
107 }
108 }
109 }
110
111 void Reset() override { }
112 void JustEngagedWith(Unit* /*who*/) override { }
113
114 bool OnGossipSelect(Player* player, uint32 /*menuId*/, uint32 gossipListId) override
115 {
116 uint32 const action = player->PlayerTalkClass->GetGossipOptionAction(gossipListId);
117 ClearGossipMenuFor(player);
118 if (action == GOSSIP_ACTION_INFO_DEF + 1)
119 {
120 CloseGossipMenuFor(player);
121 LoadPath((me->GetEntry() << 3) | 2);
122 Start(false, player->GetGUID());
123 }
124 return true;
125 }
126
127 bool OnGossipHello(Player* player) override
128 {
130 InitGossipMenuFor(player, gossipMenuId);
132 AddGossipItemFor(player, gossipMenuId, 0, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
133
134 SendGossipMenuFor(player, player->GetGossipTextId(me), me->GetGUID());
135 return true;
136 }
137 };
138
139 CreatureAI* GetAI(Creature* creature) const override
140 {
141 return GetShadowfangKeepAI<npc_shadowfang_prisonerAI>(creature);
142 }
143};
144
146{
147public:
148 npc_arugal_voidwalker() : CreatureScript("npc_arugal_voidwalker") { }
149
150 CreatureAI* GetAI(Creature* creature) const override
151 {
152 return GetShadowfangKeepAI<npc_arugal_voidwalkerAI>(creature);
153 }
154
156 {
158 {
159 Initialize();
160 instance = creature->GetInstanceScript();
161 }
162
164 {
165 uiDarkOffering = urand(200, 1000);
166 }
167
169
171
172 void Reset() override
173 {
174 Initialize();
175 }
176
177 void UpdateAI(uint32 uiDiff) override
178 {
179 if (!UpdateVictim())
180 return;
181
182 if (uiDarkOffering <= uiDiff)
183 {
184 if (Creature* pFriend = me->FindNearestCreature(me->GetEntry(), 25.0f, true))
185 DoCast(pFriend, SPELL_DARK_OFFERING);
186 else
188 uiDarkOffering = urand(4400, 12500);
189 } else uiDarkOffering -= uiDiff;
190
192 }
193
194 void JustDied(Unit* /*killer*/) override
195 {
197 }
198 };
199
200};
201
212
214{
215 SAY_AGGRO = 1, // You, too, shall serve!
216 SAY_TRANSFORM = 2, // Release your rage!
217 SAY_SLAY = 3 // Another falls!
219
227
229{
230 public:
231 boss_archmage_arugal() : CreatureScript("boss_archmage_arugal") { }
232
234 {
236
243
244 void KilledUnit(Unit* who) override
245 {
246 if (who->GetTypeId() == TYPEID_PLAYER)
247 Talk(SAY_SLAY);
248 }
249
250 void SpellHitTarget(WorldObject* /*target*/, SpellInfo const* spellInfo) override
251 {
252 if (spellInfo->Id == SPELL_ARUGAL_CURSE)
254 }
255
265
266 void AttackStart(Unit* who) override
267 {
268 AttackStartCaster(who, 100.0f); // void bolt range is 100.f
269 }
270
271 void UpdateAI(uint32 diff) override
272 {
273 if (!UpdateVictim())
274 return;
275
276 events.Update(diff);
277
279 return;
280
281 while (uint32 eventId = events.ExecuteEvent())
282 {
283 switch (eventId)
284 {
285 case EVENT_CURSE:
286 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 30.0f, true))
287 DoCast(target, SPELL_ARUGAL_CURSE);
288 events.Repeat(Seconds(15));
289 break;
290 case EVENT_TELEPORT:
291 {
292 // ensure we never cast the same teleport twice in a row
293 uint8 spellIndex = urand(1, NUM_TELEPORT_SPELLS-1);
294 std::swap(teleportSpells[0], teleportSpells[spellIndex]);
296 events.Repeat(Seconds(20));
297 break;
298 }
301 events.Repeat(Seconds(30));
302 break;
303 case EVENT_VOID_BOLT:
306 break;
307 }
308 }
310 }
311 };
312
313 CreatureAI* GetAI(Creature* creature) const override
314 {
315 return GetShadowfangKeepAI<boss_archmage_arugalAI>(creature);
316 }
317};
318
319// 7057 - Haunting Spirits
358
@ IN_MILLISECONDS
Definition Common.h:35
uint8_t uint8
Definition Define.h:135
int32_t int32
Definition Define.h:129
uint32_t uint32
Definition Define.h:133
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition Duration.h:27
@ DONE
@ TYPEID_PLAYER
Definition ObjectGuid.h:39
Spells
Definition PlayerAI.cpp:32
int32 irand(int32 min, int32 max)
Definition Random.cpp:35
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
@ EFFECT_0
@ SPELL_AURA_DUMMY
#define AuraEffectPeriodicFn(F, I, N)
#define AuraEffectUpdatePeriodicFn(F, I, N)
#define AuraEffectCalcPeriodicFn(F, I, N)
@ UNIT_STATE_CASTING
Definition Unit.h:235
Yells
void CalculatePeriodic(Unit *caster, bool resetPeriodicTimer=true, bool load=false)
int32 GetAmount() const
HookList< EffectCalcPeriodicHandler > DoEffectCalcPeriodic
HookList< EffectPeriodicHandler > OnEffectPeriodic
Unit * GetCaster() const
HookList< EffectUpdatePeriodicHandler > OnEffectUpdatePeriodic
Unit * GetTarget() const
void JustEngagedWith(Unit *who) override
EventMap events
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
void Update(uint32 time)
Definition EventMap.h:67
void Repeat(Milliseconds time)
Definition EventMap.cpp:63
EventId ExecuteEvent()
Definition EventMap.cpp:73
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:36
TypeID GetTypeId() const
Definition Object.h:93
uint32 GetEntry() const
Definition Object.h:81
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:78
uint32 GetGossipOptionAction(uint32 selection) const
Definition GossipDef.h:269
static uint32 GetDefaultGossipMenuForSource(WorldObject *source)
Definition Player.cpp:14251
uint32 GetGossipTextId(uint32 menuId, WorldObject *source)
Definition Player.cpp:14233
PlayerMenu * PlayerTalkClass
Definition Player.h:1969
uint32 Id
Definition SpellInfo.h:289
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
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition UnitAI.cpp:96
SpellCastResult DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:243
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:106
Definition Unit.h:769
bool HasUnitState(const uint32 f) const
Definition Unit.h:876
InstanceScript * GetInstanceScript() const
Definition Object.cpp:1087
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2832
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
CreatureAI * GetAI(Creature *creature) const override
CreatureAI * GetAI(Creature *creature) const override
CreatureAI * GetAI(Creature *creature) const override
void CalcPeriodic(AuraEffect const *, bool &isPeriodic, int32 &amplitude)
AuraScript * GetAuraScript() const override
@ EVENT_CURSE
@ EVENT_THUNDERSHOCK
@ EVENT_TELEPORT
@ EVENT_VOID_BOLT
@ SAY_OPEN_DOOR_AS
@ SAY_OPEN_DOOR_AD
@ SAY_POST1_DOOR_AD
@ SAY_FREE_AD
@ SAY_FREE_AS
@ SAY_POST_DOOR_AS
@ SAY_POST2_DOOR_AD
@ SPELL_TELE_STAIRS
@ SPELL_ARUGAL_CURSE
@ SPELL_VOIDBOLT
@ SPELL_TELE_SPAWN
@ NUM_TELEPORT_SPELLS
@ SPELL_TELE_UPPER
@ SPELL_THUNDERSHOCK
@ SPELL_DARK_OFFERING
@ SPELL_UNLOCK
@ SAY_AGGRO
@ SAY_TRANSFORM
@ SAY_SLAY
void AddSC_shadowfang_keep()
@ BOSS_ARUGAL
@ TYPE_FENRUS
@ TYPE_RETHILGORE
@ TYPE_FREE_NPC
@ NPC_ASH
void Start(bool isActiveAttacker=true, ObjectGuid playerGUID=ObjectGuid::Empty, Quest const *quest=nullptr, bool instantRespawn=false, bool canLoopPath=false)
void LoadPath(uint32 pathId)
Player * GetPlayerForEscort()
void SpellHitTarget(WorldObject *, SpellInfo const *spellInfo) override
void WaypointReached(uint32 waypointId, uint32) override
bool OnGossipSelect(Player *player, uint32, uint32 gossipListId) override