TrinityCore
boss_fankriss.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_Fankriss
20SD%Complete: 100
21SDComment: sound not implemented
22SDCategory: Temple of Ahn'Qiraj
23EndScriptData */
24
25#include "ScriptMgr.h"
26#include "ScriptedCreature.h"
27#include "temple_of_ahnqiraj.h"
28#include "TemporarySummon.h"
29
30#define SOUND_SENTENCE_YOU 8588
31#define SOUND_SERVE_TO 8589
32#define SOUND_LAWS 8590
33#define SOUND_TRESPASS 8591
34#define SOUND_WILL_BE 8592
35
37{
39 SPELL_ROOT = 28858,
40
41 // Enrage for his spawns
42 SPELL_ENRAGE = 28798
43};
44
46{
47public:
48 boss_fankriss() : CreatureScript("boss_fankriss") { }
49
50 CreatureAI* GetAI(Creature* creature) const override
51 {
52 return GetAQ40AI<boss_fankrissAI>(creature);
53 }
54
55 struct boss_fankrissAI : public BossAI
56 {
58 {
59 Initialize();
60 }
61
63 {
64 MortalWound_Timer = urand(10000, 15000);
65 SpawnHatchlings_Timer = urand(6000, 12000);
66 SpawnSpawns_Timer = urand(15000, 45000);
67 }
68
72
73 void Reset() override
74 {
75 Initialize();
76 _Reset();
77 }
78
79 void SummonSpawn(Unit* victim)
80 {
81 if (!victim)
82 return;
83
84 int Rand = 10 + (rand32() % 10);
85 float RandX = 0.f;
86 float RandY = 0.f;
87
88 switch (rand32() % 2)
89 {
90 case 0: RandX = 0.0f - Rand; break;
91 case 1: RandX = 0.0f + Rand; break;
92 }
93
94 Rand = 10 + (rand32() % 10);
95 switch (rand32() % 2)
96 {
97 case 0: RandY = 0.0f - Rand; break;
98 case 1: RandY = 0.0f + Rand; break;
99 }
100 Rand = 0;
101 Creature* Spawn = DoSpawnCreature(15630, RandX, RandY, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30s);
102 if (Spawn)
103 Spawn->AI()->AttackStart(victim);
104 }
105
106 void UpdateAI(uint32 diff) override
107 {
108 //Return since we have no target
109 if (!UpdateVictim())
110 return;
111
112 //MortalWound_Timer
113 if (MortalWound_Timer <= diff)
114 {
116 MortalWound_Timer = urand(10000, 20000);
117 } else MortalWound_Timer -= diff;
118
119 //Summon 1-3 Spawns of Fankriss at random time.
120 if (SpawnSpawns_Timer <= diff)
121 {
122 switch (urand(0, 2))
123 {
124 case 0:
126 break;
127 case 1:
130 break;
131 case 2:
135 break;
136 }
137 SpawnSpawns_Timer = urand(30000, 60000);
138 } else SpawnSpawns_Timer -= diff;
139
140 // Teleporting Random Target to one of the three tunnels and spawn 4 hatchlings near the gamer.
141 //We will only telport if fankriss has more than 3% of hp so teleported gamers can always loot.
142 if (HealthAbovePct(3))
143 {
144 if (SpawnHatchlings_Timer <= diff)
145 {
146 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 0.0f, true))
147 {
148 DoCast(target, SPELL_ROOT);
149
150 if (GetThreat(target))
151 ModifyThreatByPercent(target, -100);
152
153 Creature* Hatchling = nullptr;
154 switch (urand(0, 2))
155 {
156 case 0:
157 DoTeleportPlayer(target, -8106.0142f, 1289.2900f, -74.419533f, 5.112f);
158 Hatchling = me->SummonCreature(15962, target->GetPositionX()-3, target->GetPositionY()-3, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15s);
159 if (Hatchling)
160 Hatchling->AI()->AttackStart(target);
161 Hatchling = me->SummonCreature(15962, target->GetPositionX()-3, target->GetPositionY()+3, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15s);
162 if (Hatchling)
163 Hatchling->AI()->AttackStart(target);
164 Hatchling = me->SummonCreature(15962, target->GetPositionX()-5, target->GetPositionY()-5, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15s);
165 if (Hatchling)
166 Hatchling->AI()->AttackStart(target);
167 Hatchling = me->SummonCreature(15962, target->GetPositionX()-5, target->GetPositionY()+5, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15s);
168 if (Hatchling)
169 Hatchling->AI()->AttackStart(target);
170 break;
171 case 1:
172 DoTeleportPlayer(target, -7990.135354f, 1155.1907f, -78.849319f, 2.608f);
173 Hatchling = me->SummonCreature(15962, target->GetPositionX() - 3, target->GetPositionY() - 3, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15s);
174 if (Hatchling)
175 Hatchling->AI()->AttackStart(target);
176 Hatchling = me->SummonCreature(15962, target->GetPositionX()-3, target->GetPositionY()+3, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15s);
177 if (Hatchling)
178 Hatchling->AI()->AttackStart(target);
179 Hatchling = me->SummonCreature(15962, target->GetPositionX()-5, target->GetPositionY()-5, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15s);
180 if (Hatchling)
181 Hatchling->AI()->AttackStart(target);
182 Hatchling = me->SummonCreature(15962, target->GetPositionX()-5, target->GetPositionY()+5, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15s);
183 if (Hatchling)
184 Hatchling->AI()->AttackStart(target);
185 break;
186 case 2:
187 DoTeleportPlayer(target, -8159.7753f, 1127.9064f, -76.868660f, 0.675f);
188 Hatchling = me->SummonCreature(15962, target->GetPositionX() - 3, target->GetPositionY() - 3, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15s);
189 if (Hatchling)
190 Hatchling->AI()->AttackStart(target);
191 Hatchling = me->SummonCreature(15962, target->GetPositionX()-3, target->GetPositionY()+3, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15s);
192 if (Hatchling)
193 Hatchling->AI()->AttackStart(target);
194 Hatchling = me->SummonCreature(15962, target->GetPositionX()-5, target->GetPositionY()-5, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15s);
195 if (Hatchling)
196 Hatchling->AI()->AttackStart(target);
197 Hatchling = me->SummonCreature(15962, target->GetPositionX()-5, target->GetPositionY()+5, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15s);
198 if (Hatchling)
199 Hatchling->AI()->AttackStart(target);
200 break;
201 }
202 }
203 SpawnHatchlings_Timer = urand(45000, 60000);
204 } else SpawnHatchlings_Timer -= diff;
205 }
206 }
207 };
208
209};
210
212{
213 new boss_fankriss();
214}
uint32_t uint32
Definition: Define.h:142
@ TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT
Definition: ObjectDefines.h:66
Spells
Definition: PlayerAI.cpp:32
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:42
uint32 rand32()
Definition: Random.cpp:70
@ SPELL_ROOT
@ SPELL_ENRAGE
@ SPELL_MORTAL_WOUND
void AddSC_boss_fankriss()
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
CreatureAI * AI() const
Definition: Creature.h:214
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.cpp:180
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
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
CreatureAI * GetAI(Creature *creature) const override
bool HealthAbovePct(uint32 pct) const
float GetThreat(Unit const *victim, Unit const *who=nullptr)
void DoTeleportPlayer(Unit *unit, float x, float y, float z, float o)
void ModifyThreatByPercent(Unit *victim, int32 pct, Unit *who=nullptr)
Creature * DoSpawnCreature(uint32 entry, float offsetX, float offsetY, float offsetZ, float angle, uint32 type, Milliseconds despawntime)
void UpdateAI(uint32 diff) override
boss_fankrissAI(Creature *creature)
void SummonSpawn(Unit *victim)
@ DATA_FRANKRIS