TrinityCore
boss_warchief_kargath_bladefist.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: Boss_Warchief_Kargath_Bladefist
20SD%Complete: 90
21SDComment:
22SDCategory: Hellfire Citadel, Shattered Halls
23EndScriptData */
24
25/* ContentData
26boss_warchief_kargath_bladefist
27EndContentData */
28
29#include "ScriptMgr.h"
30#include "InstanceScript.h"
31#include "MotionMaster.h"
32#include "ObjectAccessor.h"
33#include "ScriptedCreature.h"
34#include "shattered_halls.h"
35
36enum Says
37{
41
44};
45
47{
49 H_SPELL_CHARGE = 25821
50};
51
53{
57 NPC_REAVER_GUARD = 17623
58};
59
60#define TARGET_NUM 5
61
62float AssassEntrance[3] = { 275.136f, -84.29f, 2.3f }; // y -8
63float AssassExit[3] = { 184.233f, -84.29f, 2.3f }; // y -8
64float AddsEntrance[3] = { 306.036f, -84.29f, 1.93f };
65
67{
68 public:
69 boss_warchief_kargath_bladefist() : CreatureScript("boss_warchief_kargath_bladefist") { }
70
72 {
74 {
75 Initialize();
76 target_num = 0;
77 }
78
80 {
81 summoned = 2;
82 InBlade = false;
83 Wait_Timer = 0;
84
85 Charge_timer = 0;
86 Blade_Dance_Timer = 45000;
88 Assassins_Timer = 5000;
89 resetcheck_timer = 5000;
90 }
91
92 void DoAction(int32 action) override
93 {
94 if (action == ACTION_EXECUTIONER_TAUNT)
95 {
97 {
98 case ALLIANCE:
100 break;
101 case HORDE:
103 break;
104 default:
105 break;
106 }
107 }
108 }
109
110 void Reset() override
111 {
112 removeAdds();
113 _Reset();
115 me->SetWalk(false);
116
117 Initialize();
118 }
119
120 void JustDied(Unit* /*killer*/) override
121 {
122 _JustDied();
124 removeAdds();
125 }
126
127 void JustEngagedWith(Unit* /*who*/) override
128 {
130 }
131
132 void JustSummoned(Creature* summon) override
133 {
134 switch (summon->GetEntry())
135 {
138 case NPC_REAVER_GUARD:
140 adds.push_back(summon->GetGUID());
141 break;
143 assassins.push_back(summon->GetGUID());
144 break;
145 }
146 }
147
148 void KilledUnit(Unit* victim) override
149 {
150 if (victim->GetTypeId() == TYPEID_PLAYER)
151 {
152 Talk(SAY_SLAY);
153 }
154 }
155
156 void MovementInform(uint32 type, uint32 id) override
157 {
158 if (InBlade)
159 {
160 if (type != POINT_MOTION_TYPE)
161 return;
162
163 if (id != 1)
164 return;
165
166 if (target_num > 0) // to prevent loops
167 {
168 Wait_Timer = 1;
170 target_num--;
171 }
172 }
173 }
174
176 {
177 for (GuidVector::const_iterator itr = adds.begin(); itr!= adds.end(); ++itr)
178 {
179 Creature* creature = ObjectAccessor::GetCreature(*me, *itr);
180 if (creature && creature->IsAlive())
181 creature->DespawnOrUnsummon();
182 }
183 adds.clear();
184
185 for (GuidVector::const_iterator itr = assassins.begin(); itr!= assassins.end(); ++itr)
186 {
187 Creature* creature = ObjectAccessor::GetCreature(*me, *itr);
188 if (creature && creature->IsAlive())
189 creature->DespawnOrUnsummon();
190 }
191 assassins.clear();
192 }
194 {
199 }
200
201 void UpdateAI(uint32 diff) override
202 {
203 //Return since we have no target
204 if (!UpdateVictim())
205 return;
206
207 if (Assassins_Timer)
208 {
209 if (Assassins_Timer <= diff)
210 {
212 Assassins_Timer = 0;
213 }
214 else
215 Assassins_Timer -= diff;
216 }
217
218 if (InBlade)
219 {
220 if (Wait_Timer)
221 {
222 if (Wait_Timer <= diff)
223 {
224 if (target_num <= 0)
225 {
226 // stop bladedance
227 InBlade = false;
230 Blade_Dance_Timer = 30000;
231 Wait_Timer = 0;
232 if (IsHeroic())
233 Charge_timer = 5000;
234 }
235 else
236 {
237 //move in bladedance
238 float x, y, randx, randy;
239 randx = 0.0f + rand32() % 40;
240 randy = 0.0f + rand32() % 40;
241 x = 210+ randx;
242 y = -60- randy;
243 me->GetMotionMaster()->MovePoint(1, x, y, me->GetPositionZ());
244 Wait_Timer = 0;
245 }
246 }
247 else
248 Wait_Timer -= diff;
249 }
250 }
251 else
252 {
254 {
255 if (Blade_Dance_Timer <= diff)
256 {
258 Wait_Timer = 1;
259 InBlade = true;
262 return;
263 }
264 else
265 Blade_Dance_Timer -= diff;
266 }
267
268 if (Charge_timer)
269 {
270 if (Charge_timer <= diff)
271 {
273 Charge_timer = 0;
274 }
275 else
276 Charge_timer -= diff;
277 }
278
279 if (Summon_Assistant_Timer <= diff)
280 {
281 for (uint8 i = 0; i < summoned; ++i)
282 {
283 switch (urand(0, 2))
284 {
285 case 0:
287 break;
288 case 1:
290 break;
291 case 2:
293 break;
294 }
295 }
296 if (urand(0, 9) < 2)
297 ++summoned;
298 Summon_Assistant_Timer = urand(25000, 35000);
299 }
300 else
302 }
303
304 if (resetcheck_timer <= diff)
305 {
306 uint32 tempx = uint32(me->GetPositionX());
307 if (tempx > 255 || tempx < 205)
308 {
310 return;
311 }
312 resetcheck_timer = 5000;
313 }
314 else
315 resetcheck_timer -= diff;
316 }
317
318 private:
330 };
331
332 CreatureAI* GetAI(Creature* creature) const override
333 {
334 return GetShatteredHallsAI<boss_warchief_kargath_bladefistAI>(creature);
335 }
336};
337
339{
341}
uint8_t uint8
Definition: Define.h:144
int32_t int32
Definition: Define.h:138
uint32_t uint32
Definition: Define.h:142
@ POINT_MOTION_TYPE
@ TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT
Definition: ObjectDefines.h:66
@ TYPEID_PLAYER
Definition: ObjectGuid.h:41
std::vector< ObjectGuid > GuidVector
Definition: ObjectGuid.h:395
Spells
Definition: PlayerAI.cpp:32
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:42
uint32 rand32()
Definition: Random.cpp:70
@ ALLIANCE
@ HORDE
@ MOVE_RUN
Definition: UnitDefines.h:118
Says
float AssassEntrance[3]
void AddSC_boss_warchief_kargath_bladefist()
InstanceScript *const instance
void _JustDied()
virtual void EnterEvadeMode(EvadeReason why=EvadeReason::Other)
Definition: CreatureAI.cpp:219
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:56
bool UpdateVictim()
Definition: CreatureAI.cpp:245
void AttackStart(Unit *victim) override
== Triggered Actions Requested ==================
Definition: CreatureAI.cpp:328
Creature *const me
Definition: CreatureAI.h:61
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
Definition: Creature.cpp:2415
CreatureAI * AI() const
Definition: Creature.h:214
void MoveChase(Unit *target, Optional< ChaseRange > dist={}, Optional< ChaseAngle > angle={})
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< float > closeEnoughDistance={})
TypeID GetTypeId() const
Definition: Object.h:173
uint32 GetEntry() const
Definition: Object.h:161
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition: UnitAI.cpp:79
SpellCastResult DoCast(uint32 spellId)
Definition: UnitAI.cpp:89
Definition: Unit.h:627
MotionMaster * GetMotionMaster()
Definition: Unit.h:1652
bool IsAlive() const
Definition: Unit.h:1164
bool SetWalk(bool enable)
Definition: Unit.cpp:12707
Unit * GetVictim() const
Definition: Unit.h:715
void SetSpeedRate(UnitMoveType mtype, float rate)
Definition: Unit.cpp:8525
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
CreatureAI * GetAI(Creature *creature) const override
@ DATA_TEAM_IN_INSTANCE
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
@ DATA_KARGATH
@ ACTION_EXECUTIONER_TAUNT
constexpr float GetPositionX() const
Definition: Position.h:76
constexpr float GetPositionZ() const
Definition: Position.h:78
bool IsHeroic() const