TrinityCore
shattered_halls.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 "ScriptMgr.h"
19#include "InstanceScript.h"
20#include "Map.h"
21#include "ObjectAccessor.h"
22#include "Player.h"
23#include "ScriptedCreature.h"
24#include "shattered_halls.h"
25#include "SpellScript.h"
26#include "TemporarySummon.h"
27
28Position const Executioner = { 152.8524f, -83.63912f, 2.021005f, 0.06981317f };
29
31{
32 public:
33 at_nethekurse_exit() : AreaTriggerScript("at_nethekurse_exit") { };
34
35 bool OnTrigger(Player* player, AreaTriggerEntry const*) override
36 {
37 if (InstanceScript* is = player->GetInstanceScript())
38 {
39 if (is->instance->IsHeroic())
40 {
41 Creature* executioner = nullptr;
42
43 is->instance->LoadGrid(Executioner.GetPositionX(), Executioner.GetPositionY());
44 if (Creature* kargath = ObjectAccessor::GetCreature(*player, is->GetGuidData(NPC_KARGATH_BLADEFIST)))
45 {
46 if (is->GetGuidData(NPC_SHATTERED_EXECUTIONER).IsEmpty())
47 {
50 }
51 }
52
53 if (executioner)
54 for (uint8 i = 0; i < VictimCount; ++i)
56 }
57 }
58
59 return false;
60 }
61};
62
64{
65 SPELL_CLEAVE = 15284
66};
67
69{
70 public:
71 boss_shattered_executioner() : CreatureScript("boss_shattered_executioner") { }
72
74 {
76 {
77 Initialize();
78 };
79
81 {
82 cleaveTimer = 500;
83 }
84
85 void Reset() override
86 {
87 _Reset();
88
89 // _Reset() resets the loot mode, so we add them again, if any
90 uint32 prisonersExecuted = instance->GetData(DATA_PRISONERS_EXECUTED);
91 if (prisonersExecuted == 0)
93 if (prisonersExecuted <= 1)
95 if (prisonersExecuted <= 2)
97
99 me->SetImmuneToPC(false);
100 else
101 me->SetImmuneToPC(true);
102
103 Initialize();
104 }
105
106 void JustSummoned(Creature*) override { } // avoid despawn of prisoners on death/reset
107
108 void JustDied(Unit* /*killer*/) override
109 {
110 _JustDied();
111
113 return;
114
115 Map::PlayerList const& players = instance->instance->GetPlayers();
116 for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
117 {
118 Player* pl = itr->GetSource();
121 pl->CompleteQuest(qId);
122 }
123 }
124
125 void SetData(uint32 type, uint32 data) override
126 {
127 if (type == DATA_PRISONERS_EXECUTED && data <= 3)
128 {
130 Unit::Kill(me, victim);
131
132 if (data == 1)
133 {
134 Map::PlayerList const& players = instance->instance->GetPlayers();
135 for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
136 {
137 Player* pl = itr->GetSource();
140 pl->FailQuest(qId);
141 }
142 }
143
144 switch (data)
145 {
146 case 3:
148 [[fallthrough]];
149 case 2:
151 [[fallthrough]];
152 case 1:
154 [[fallthrough]];
155 default:
156 break;
157 }
158 }
159 }
160
161 void UpdateAI(uint32 diff) override
162 {
163 if (!UpdateVictim())
164 return;
165
166 if (cleaveTimer <= diff)
167 {
169 cleaveTimer = urand(5000, 7000);
170 }
171 else
172 cleaveTimer -= diff;
173 }
174 private:
176 };
177
178 CreatureAI* GetAI(Creature* creature) const override
179 {
180 return GetShatteredHallsAI<boss_shattered_executionerAI>(creature);
181 }
182};
183
184// 39288, 39289, 39290 - Kargath's Executioner
186{
187 public:
188 spell_kargath_executioner() : SpellScriptLoader("spell_kargath_executioner") { }
189
191 {
192 bool AreaCheck(Unit* target)
193 {
194 if (target->GetMap()->GetId() != 540)
195 return false;
196
197 return true;
198 }
199
200 bool Load() override
201 {
202 return GetCaster()->GetTypeId() == TYPEID_PLAYER;
203 }
204
205 void Register() override
206 {
208 }
209 };
210
211 AuraScript* GetAuraScript() const override
212 {
214 }
215};
216
217// 39291 - Remove Kargath's Executioner
219{
220 public:
221 spell_remove_kargath_executioner() : SpellScriptLoader("spell_remove_kargath_executioner") { }
222
224 {
225 void HandleScript(SpellEffIndex /*effIndex*/)
226 {
227 Unit* target = GetCaster();
228
232 }
233
234 bool Load() override
235 {
236 return GetCaster()->GetTypeId() == TYPEID_PLAYER;
237 }
238
239 void Register() override
240 {
242 }
243 };
244
245 SpellScript* GetSpellScript() const override
246 {
248 }
249};
250
252{
253 new at_nethekurse_exit();
257}
uint8_t uint8
Definition: Define.h:144
uint32_t uint32
Definition: Define.h:142
@ DONE
@ TYPEID_PLAYER
Definition: ObjectGuid.h:41
Spells
Definition: PlayerAI.cpp:32
@ QUEST_STATUS_INCOMPLETE
Definition: QuestDef.h:145
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:42
SpellEffIndex
Definition: SharedDefines.h:29
@ EFFECT_0
Definition: SharedDefines.h:30
@ SPELL_EFFECT_SCRIPT_EFFECT
@ ALLIANCE
@ LOOT_MODE_HARD_MODE_3
Definition: SharedDefines.h:80
@ LOOT_MODE_HARD_MODE_1
Definition: SharedDefines.h:78
@ LOOT_MODE_HARD_MODE_2
Definition: SharedDefines.h:79
#define SpellEffectFn(F, I, N)
Definition: SpellScript.h:842
#define AuraCheckAreaTargetFn(F)
Definition: SpellScript.h:2008
Unit * GetCaster() const
HookList< CheckAreaTargetHandler > DoCheckAreaTarget
Definition: SpellScript.h:2007
InstanceScript *const instance
void _JustDied()
bool UpdateVictim()
Definition: CreatureAI.cpp:245
Creature *const me
Definition: CreatureAI.h:61
void RemoveLootMode(uint16 lootMode)
Definition: Creature.h:299
void SetImmuneToPC(bool apply) override
Definition: Creature.h:170
void AddLootMode(uint16 lootMode)
Definition: Creature.h:298
CreatureAI * AI() const
Definition: Creature.h:214
virtual ObjectGuid GetGuidData(uint32 type) const override
InstanceMap * instance
EncounterState GetBossState(uint32 id) const
iterator end()
Definition: MapRefManager.h:35
iterator begin()
Definition: MapRefManager.h:34
uint32 GetId() const
Definition: Map.cpp:3228
PlayerList const & GetPlayers() const
Definition: Map.h:367
TypeID GetTypeId() const
Definition: Object.h:173
void CompleteQuest(uint32 quest_id)
Definition: Player.cpp:15023
QuestStatus GetQuestStatus(uint32 quest_id) const
Definition: Player.cpp:16050
void FailQuest(uint32 quest_id)
Definition: Player.cpp:15446
Team GetTeam() const
Definition: Player.h:2235
Unit * GetCaster() const
HookList< EffectHandler > OnEffectHitTarget
Definition: SpellScript.h:840
virtual void DoAction(int32)
Definition: UnitAI.h:72
SpellCastResult DoCast(uint32 spellId)
Definition: UnitAI.cpp:89
Definition: Unit.h:627
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3831
static void Kill(Unit *attacker, Unit *victim, bool durabilityLoss=true, bool skipSettingDeathState=false)
Definition: Unit.cpp:10591
Map * GetMap() const
Definition: Object.h:624
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
virtual uint32 GetData(uint32) const
Definition: ZoneScript.h:91
bool OnTrigger(Player *player, AreaTriggerEntry const *) override
CreatureAI * GetAI(Creature *creature) const override
AuraScript * GetAuraScript() const override
SpellScript * GetSpellScript() const override
@ DATA_TEAM_IN_INSTANCE
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
@ SPELL_CLEAVE
Position const Executioner
void AddSC_shattered_halls()
@ DATA_KARGATH
@ DATA_SHATTERED_EXECUTIONER
@ DATA_PRISONERS_EXECUTED
@ DATA_FIRST_PRISONER
@ ACTION_EXECUTIONER_TAUNT
@ NPC_SHATTERED_EXECUTIONER
@ NPC_KARGATH_BLADEFIST
@ SPELL_KARGATH_EXECUTIONER_2
@ SPELL_KARGATH_EXECUTIONER_3
@ SPELL_KARGATH_EXECUTIONER_1
uint32 const VictimCount
FactionSpawnerHelper const executionerVictims[VictimCount]
@ QUEST_IMPRISONED_H
@ QUEST_IMPRISONED_A
Position const & GetPos() const
constexpr float GetPositionX() const
Definition: Position.h:76
constexpr float GetPositionY() const
Definition: Position.h:77
void SetData(uint32 type, uint32 data) override