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 {
204 me->CastStop();
205 }
206 else
207 {
210 }
211 }
212
213 void SetSummonerStatus(bool active)
214 {
215 for (uint8 i = 0; i < 4; i++)
216 {
217 ObjectGuid guid = instance->GetGuidData(summoners[i].data);
218 if (!guid.IsEmpty())
219 {
220 if (Creature* crystalChannelTarget = ObjectAccessor::GetCreature(*me, guid))
221 {
222 if (active)
223 crystalChannelTarget->AI()->SetData(summoners[i].spell, summoners[i].timer);
224 else
225 crystalChannelTarget->AI()->Reset();
226 }
227 }
228 }
229 }
230
231 void SetCrystalsStatus(bool active)
232 {
233 for (uint8 i = 0; i < 4; i++)
234 {
236 if (!guid.IsEmpty())
237 if (GameObject* crystal = ObjectAccessor::GetGameObject(*me, guid))
238 SetCrystalStatus(crystal, active);
239 }
240 }
241
242 void SetCrystalStatus(GameObject* crystal, bool active)
243 {
244 crystal->SetGoState(active ? GO_STATE_ACTIVE : GO_STATE_READY);
245 if (Creature* crystalChannelTarget = crystal->FindNearestCreature(NPC_CRYSTAL_CHANNEL_TARGET, 5.0f))
246 {
247 if (active)
248 crystalChannelTarget->CastSpell(nullptr, SPELL_BEAM_CHANNEL);
249 else if (crystalChannelTarget->HasUnitState(UNIT_STATE_CASTING))
250 crystalChannelTarget->CastStop();
251 }
252 }
253
255 {
256 for (uint8 i = 0; i < 4; i++)
257 {
259 if (!guid.IsEmpty())
260 {
261 if (GameObject* crystal = ObjectAccessor::GetGameObject(*me, guid))
262 {
263 if (crystal->GetGoState() == GO_STATE_ACTIVE)
264 {
265 SetCrystalStatus(crystal, false);
266 break;
267 }
268 }
269 }
270 }
271
272 if (++_crystalHandlerCount >= 4)
273 {
275 SetSummonerStatus(false);
276 SetBubbled(false);
278 if (IsHeroic())
280 }
281 else
282 {
284 if (!guid.IsEmpty())
285 if (Creature* crystalChannelTarget = ObjectAccessor::GetCreature(*me, guid))
286 crystalChannelTarget->AI()->SetData(SPELL_SUMMON_CRYSTAL_HANDLER, 15000);
287 }
288 }
289
293};
294
295// 26712 - Crystal Channel Target
297{
299 {
300 Initialize();
301 }
302
304 {
305 _spell = 0;
306 _timer = 0;
307 _temp = 0;
308 }
309
310 void Reset() override
311 {
312 Initialize();
313 }
314
315 void UpdateAI(uint32 diff) override
316 {
317 if (_spell)
318 {
319 if (_temp <= diff)
320 {
321 DoCast(_spell);
322 _temp = _timer;
323 }
324 else
325 _temp -= diff;
326 }
327 }
328
329 void SetData(uint32 id, uint32 value) override
330 {
331 _spell = id;
332 _timer = value;
333 _temp = value;
334 }
335
336 void JustSummoned(Creature* summon) override
337 {
338 if (InstanceScript* instance = me->GetInstanceScript())
339 {
340 ObjectGuid guid = instance->GetGuidData(DATA_NOVOS);
341 if (!guid.IsEmpty())
342 if (Creature* novos = ObjectAccessor::GetCreature(*me, guid))
343 novos->AI()->JustSummoned(summon);
344 }
345
346 if (summon)
347 summon->GetMotionMaster()->MovePath((summon->GetEntry() * 100) << 3, false);
348
350 Reset();
351 }
352
353private:
357};
358
359// 59910 - Summon Minions
361{
362 bool Validate(SpellInfo const* /*spellInfo*/) override
363 {
365 }
366
367 void HandleScript(SpellEffIndex /*effIndex*/)
368 {
369 for (uint8 i = 0; i < 2; ++i)
371 }
372
377};
378
380{
381public:
382 achievement_oh_novos() : AchievementCriteriaScript("achievement_oh_novos") { }
383
384 bool OnCheck(Player* /*player*/, Unit* target) override
385 {
386 return target && target->GetTypeId() == TYPEID_UNIT && target->ToCreature()->AI()->GetData(DATA_NOVOS_ACHIEV);
387 }
388};
389
First const & RAND(First const &first, Second const &second, Rest const &... rest)
uint8_t uint8
Definition Define.h:156
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
@ TYPEID_UNIT
Definition ObjectGuid.h:43
@ TYPEID_PLAYER
Definition ObjectGuid.h:44
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
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:290
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()
TypeID GetTypeId() const
Definition BaseEntity.h:166
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
SummonList summons
EventMap events
virtual void MoveInLineOfSight(Unit *)
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:63
CreatureAI * AI() const
Definition Creature.h:235
void Update(uint32 time)
Definition EventMap.h:77
void Repeat(Milliseconds time)
Definition EventMap.cpp:67
EventId ExecuteEvent()
Definition EventMap.cpp:77
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:40
void SetGoState(GOState state)
virtual ObjectGuid GetGuidData(uint32 type) const override
void MovePath(uint32 pathId, bool repeatable, Optional< Milliseconds > duration={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< std::pair< Milliseconds, Milliseconds > > waitTimeRangeAtPathEnd={}, Optional< float > wanderDistanceAtPathEnds={}, Optional< bool > followPathBackwardsFromEndToStart={}, Optional< bool > exactSplinePath={}, bool generatePath=true, Optional< MovementFadeObject > fadeObject={}, Scripting::v2::ActionResultSetter< MovementStopReason > &&scriptResult={})
bool IsEmpty() const
Definition ObjectGuid.h:362
uint32 GetEntry() const
Definition Object.h:89
Creature * ToCreature()
Definition Object.h:121
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Unit * GetCaster() const
HookList< EffectHandler > OnEffectHitTarget
void Summon(Creature const *summon)
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition UnitAI.cpp:71
virtual uint32 GetData(uint32 id) const
Definition UnitAI.h:74
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:81
Definition Unit.h:647
void CastStop(uint32 except_spellid=0)
Definition Unit.cpp:1191
MotionMaster * GetMotionMaster()
Definition Unit.h:1750
bool Attack(Unit *victim, bool meleeAttack)
Definition Unit.cpp:5872
bool HasUnitState(const uint32 f) const
Definition Unit.h:755
void SetUnitFlag(UnitFlags flags)
Definition Unit.h:861
void RemoveUnitFlag(UnitFlags flags)
Definition Unit.h:862
InstanceScript * GetInstanceScript() const
Definition Object.cpp:394
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2222
Creature * FindNearestCreature(uint32 entry, float range, bool alive=true) const
Definition Object.cpp:1522
bool OnCheck(Player *, Unit *target) override
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)
constexpr float GetPositionY() const
Definition Position.h:88
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)