TrinityCore
Loading...
Searching...
No Matches
boss_novos.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 "drak_tharon_keep.h"
20#include "GameObject.h"
21#include "InstanceScript.h"
22#include "MotionMaster.h"
23#include "ObjectAccessor.h"
24#include "ScriptedCreature.h"
25#include "SpellScript.h"
26
36
54
64
69
77
78#define MAX_Y_COORD_OH_NOVOS -771.95f
79
80// 26631 - Novos the Summoner
81struct boss_novos : public BossAI
82{
83 boss_novos(Creature* creature) : BossAI(creature, DATA_NOVOS)
84 {
85 Initialize();
86 _bubbled = false;
87 }
88
90 {
91 _ohNovos = true;
93 }
94
95 void Reset() override
96 {
97 _Reset();
98
99 Initialize();
100 SetCrystalsStatus(false);
101 SetSummonerStatus(false);
102 SetBubbled(false);
103 }
104
105 void JustEngagedWith(Unit* who) override
106 {
109
110 SetCrystalsStatus(true);
111 SetSummonerStatus(true);
112 SetBubbled(true);
113 }
114
115 void AttackStart(Unit* target) override
116 {
117 if (!target)
118 return;
119
120 if (me->Attack(target, true))
121 DoStartNoMovement(target);
122 }
123
124 void KilledUnit(Unit* who) override
125 {
126 if (who->GetTypeId() == TYPEID_PLAYER)
127 Talk(SAY_KILL);
128 }
129
130 void JustDied(Unit* /*killer*/) override
131 {
132 _JustDied();
134 }
135
136 void UpdateAI(uint32 diff) override
137 {
138 if (!UpdateVictim() || _bubbled)
139 return;
140
141 events.Update(diff);
142
144 return;
145
146 if (uint32 eventId = events.ExecuteEvent())
147 {
148 switch (eventId)
149 {
152 events.Repeat(15s);
153 break;
154 case EVENT_ATTACK:
157 events.Repeat(3s);
158 break;
159 default:
160 break;
161 }
162
164 return;
165 }
166 }
167
168 void DoAction(int32 action) override
169 {
170 if (action == ACTION_CRYSTAL_HANDLER_DIED)
172 }
173
174 void MoveInLineOfSight(Unit* who) override
175 {
177
178 if (!_ohNovos || !who || who->GetTypeId() != TYPEID_UNIT || who->GetPositionY() > MAX_Y_COORD_OH_NOVOS)
179 return;
180
181 uint32 entry = who->GetEntry();
182 if (entry == NPC_HULKING_CORPSE || entry == NPC_RISEN_SHADOWCASTER || entry == NPC_FETID_TROLL_CORPSE)
183 _ohNovos = false;
184 }
185
186 uint32 GetData(uint32 type) const override
187 {
188 return type == DATA_NOVOS_ACHIEV && _ohNovos ? 1 : 0;
189 }
190
191 void JustSummoned(Creature* summon) override
192 {
193 summons.Summon(summon);
194 }
195
196private:
197 void SetBubbled(bool state)
198 {
199 _bubbled = state;
200 if (!state)
201 {
205 me->CastStop();
206 }
207 else
208 {
212 }
213 }
214
215 void SetSummonerStatus(bool active)
216 {
217 for (uint8 i = 0; i < 4; i++)
218 {
219 ObjectGuid guid = instance->GetGuidData(summoners[i].data);
220 if (!guid.IsEmpty())
221 {
222 if (Creature* crystalChannelTarget = ObjectAccessor::GetCreature(*me, guid))
223 {
224 if (active)
225 crystalChannelTarget->AI()->SetData(summoners[i].spell, summoners[i].timer);
226 else
227 crystalChannelTarget->AI()->Reset();
228 }
229 }
230 }
231 }
232
233 void SetCrystalsStatus(bool active)
234 {
235 for (uint8 i = 0; i < 4; i++)
236 {
238 if (!guid.IsEmpty())
239 if (GameObject* crystal = ObjectAccessor::GetGameObject(*me, guid))
240 SetCrystalStatus(crystal, active);
241 }
242 }
243
244 void SetCrystalStatus(GameObject* crystal, bool active)
245 {
246 crystal->SetGoState(active ? GO_STATE_ACTIVE : GO_STATE_READY);
247 if (Creature* crystalChannelTarget = crystal->FindNearestCreature(NPC_CRYSTAL_CHANNEL_TARGET, 5.0f))
248 {
249 if (active)
250 crystalChannelTarget->CastSpell(nullptr, SPELL_BEAM_CHANNEL);
251 else if (crystalChannelTarget->HasUnitState(UNIT_STATE_CASTING))
252 crystalChannelTarget->CastStop();
253 }
254 }
255
257 {
258 for (uint8 i = 0; i < 4; i++)
259 {
261 if (!guid.IsEmpty())
262 {
263 if (GameObject* crystal = ObjectAccessor::GetGameObject(*me, guid))
264 {
265 if (crystal->GetGoState() == GO_STATE_ACTIVE)
266 {
267 SetCrystalStatus(crystal, false);
268 break;
269 }
270 }
271 }
272 }
273
274 if (++_crystalHandlerCount >= 4)
275 {
277 SetSummonerStatus(false);
278 SetBubbled(false);
280 if (IsHeroic())
282 }
283 else
284 {
286 if (!guid.IsEmpty())
287 if (Creature* crystalChannelTarget = ObjectAccessor::GetCreature(*me, guid))
288 crystalChannelTarget->AI()->SetData(SPELL_SUMMON_CRYSTAL_HANDLER, 15000);
289 }
290 }
291
295};
296
297// 26712 - Crystal Channel Target
299{
301 {
302 Initialize();
303 }
304
306 {
307 _spell = 0;
308 _timer = 0;
309 _temp = 0;
310 }
311
312 void Reset() override
313 {
314 Initialize();
315 }
316
317 void UpdateAI(uint32 diff) override
318 {
319 if (_spell)
320 {
321 if (_temp <= diff)
322 {
323 DoCast(_spell);
324 _temp = _timer;
325 }
326 else
327 _temp -= diff;
328 }
329 }
330
331 void SetData(uint32 id, uint32 value) override
332 {
333 _spell = id;
334 _timer = value;
335 _temp = value;
336 }
337
338 void JustSummoned(Creature* summon) override
339 {
340 if (InstanceScript* instance = me->GetInstanceScript())
341 {
342 ObjectGuid guid = instance->GetGuidData(DATA_NOVOS);
343 if (!guid.IsEmpty())
344 if (Creature* novos = ObjectAccessor::GetCreature(*me, guid))
345 novos->AI()->JustSummoned(summon);
346 }
347
348 if (summon)
349 summon->GetMotionMaster()->MovePath((summon->GetEntry() * 100) << 3, false);
350
352 Reset();
353 }
354
355private:
359};
360
361// 59910 - Summon Minions
363{
365
366 bool Validate(SpellInfo const* /*spellInfo*/) override
367 {
369 }
370
371 void HandleScript(SpellEffIndex /*effIndex*/)
372 {
373 for (uint8 i = 0; i < 2; ++i)
375 }
376
381};
382
384{
385public:
386 achievement_oh_novos() : AchievementCriteriaScript("achievement_oh_novos") { }
387
388 bool OnCheck(Player* /*player*/, Unit* target) override
389 {
390 return target && target->GetTypeId() == TYPEID_UNIT && target->ToCreature()->AI()->GetData(DATA_NOVOS_ACHIEV);
391 }
392};
393
First const & RAND(First const &first, Second const &second, Rest const &... rest)
uint8_t uint8
Definition Define.h:135
int32_t int32
Definition Define.h:129
uint32_t uint32
Definition Define.h:133
@ TYPEID_UNIT
Definition ObjectGuid.h:38
@ TYPEID_PLAYER
Definition ObjectGuid.h:39
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1128
SpellEffIndex
@ EFFECT_0
@ SPELL_EFFECT_SCRIPT_EFFECT
@ GO_STATE_READY
@ GO_STATE_ACTIVE
#define SpellEffectFn(F, I, N)
@ UNIT_FLAG_NON_ATTACKABLE
@ UNIT_STATE_CASTING
Definition Unit.h:235
NovosSpells
@ SPELL_FROSTBOLT
@ SPELL_SUMMON_CRYSTAL_HANDLER
@ SPELL_SUMMON_FETID_TROLL_CORPSE
@ SPELL_ARCANE_FIELD
@ SPELL_BLIZZARD
@ SPELL_BEAM_CHANNEL
@ SPELL_SUMMON_RISEN_SHADOWCASTER
@ SPELL_SUMMON_COPY_OF_MINIONS
@ SPELL_SUMMON_MINIONS
@ SPELL_ARCANE_BLAST
@ SPELL_WRATH_OF_MISERY
@ SPELL_SUMMON_HULKING_CORPSE
const SummonerInfo summoners[]
#define MAX_Y_COORD_OH_NOVOS
NovosTexts
@ SAY_DEATH
@ SAY_AGGRO
@ SAY_KILL
@ SAY_ARCANE_FIELD
@ EMOTE_SUMMONING_ADDS
@ SAY_SUMMONING_ADDS
NovosMisc
@ EVENT_SUMMON_MINIONS
@ EVENT_ATTACK
@ ACTION_DEACTIVATE
@ ACTION_ACTIVATE_CRYSTAL
@ ACTION_RESET_CRYSTALS
@ DATA_NOVOS_ACHIEV
void AddSC_boss_novos()
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
SummonList summons
EventMap events
virtual void MoveInLineOfSight(Unit *)
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
CreatureAI * AI() const
Definition Creature.h:154
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
void SetGoState(GOState state)
virtual ObjectGuid GetGuidData(uint32 type) const override
void MovePath(uint32 pathId, bool repeatable)
bool IsEmpty() const
Definition ObjectGuid.h:172
static Creature * ToCreature(Object *o)
Definition Object.h:186
TypeID GetTypeId() const
Definition Object.h:93
uint32 GetEntry() const
Definition Object.h:81
Unit * GetCaster() const
HookList< EffectHandler > OnEffectHitTarget
void Summon(Creature const *summon)
virtual uint32 GetData(uint32) const
Definition UnitAI.h:155
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 DoCast(uint32 spellId)
Definition UnitAI.cpp:106
Definition Unit.h:769
void CastStop(uint32 except_spellid=0)
Definition Unit.cpp:988
MotionMaster * GetMotionMaster()
Definition Unit.h:1667
bool HasUnitFlag(UnitFlags flags) const
Definition Unit.h:953
bool Attack(Unit *victim, bool meleeAttack)
Definition Unit.cpp:5535
bool HasUnitState(const uint32 f) const
Definition Unit.h:876
void SetUnitFlag(UnitFlags flags)
Definition Unit.h:954
void RemoveUnitFlag(UnitFlags flags)
Definition Unit.h:955
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
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
bool OnCheck(Player *, Unit *target) override
PrepareSpellScript(spell_novos_summon_minions)
bool Validate(SpellInfo const *) override
void HandleScript(SpellEffIndex)
#define RegisterDrakTharonKeepCreatureAI(ai_name)
@ NPC_RISEN_SHADOWCASTER
@ NPC_CRYSTAL_CHANNEL_TARGET
@ NPC_HULKING_CORPSE
@ NPC_FETID_TROLL_CORPSE
@ DATA_NOVOS_SUMMONER_4
@ DATA_NOVOS_SUMMONER_3
@ DATA_NOVOS_SUMMONER_1
@ DATA_NOVOS_SUMMONER_2
@ DATA_NOVOS
@ ACTION_CRYSTAL_HANDLER_DIED
@ DATA_NOVOS_CRYSTAL_1
TC_GAME_API GameObject * GetGameObject(WorldObject const &u, ObjectGuid const &guid)
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
float GetPositionY() const
Definition Position.h:80
bool IsHeroic() const
void DoStartNoMovement(Unit *target)
void UpdateAI(uint32 diff) override
void CrystalHandlerDied()
uint8 _crystalHandlerCount
void JustDied(Unit *) override
void KilledUnit(Unit *who) override
void Initialize()
void AttackStart(Unit *target) override
uint32 GetData(uint32 type) const override
void SetCrystalsStatus(bool active)
void JustSummoned(Creature *summon) override
void Reset() override
void DoAction(int32 action) override
void MoveInLineOfSight(Unit *who) override
void SetSummonerStatus(bool active)
void JustEngagedWith(Unit *who) override
boss_novos(Creature *creature)
void SetCrystalStatus(GameObject *crystal, bool active)
void SetBubbled(bool state)
void JustSummoned(Creature *summon) override
void SetData(uint32 id, uint32 value) override
void UpdateAI(uint32 diff) override
npc_crystal_channel_target(Creature *creature)