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
80struct boss_novos : public BossAI
81{
82 boss_novos(Creature* creature) : BossAI(creature, DATA_NOVOS)
83 {
84 Initialize();
85 _bubbled = false;
86 }
87
89 {
90 _ohNovos = true;
92 }
93
94 void Reset() override
95 {
96 _Reset();
97
98 Initialize();
99 SetCrystalsStatus(false);
100 SetSummonerStatus(false);
101 SetBubbled(false);
102 }
103
104 void JustEngagedWith(Unit* who) override
105 {
108
109 SetCrystalsStatus(true);
110 SetSummonerStatus(true);
111 SetBubbled(true);
112 }
113
114 void AttackStart(Unit* target) override
115 {
116 if (!target)
117 return;
118
119 if (me->Attack(target, true))
120 DoStartNoMovement(target);
121 }
122
123 void KilledUnit(Unit* who) override
124 {
125 if (who->GetTypeId() == TYPEID_PLAYER)
126 Talk(SAY_KILL);
127 }
128
129 void JustDied(Unit* /*killer*/) override
130 {
131 _JustDied();
133 }
134
135 void UpdateAI(uint32 diff) override
136 {
137 if (!UpdateVictim() || _bubbled)
138 return;
139
140 events.Update(diff);
141
143 return;
144
145 if (uint32 eventId = events.ExecuteEvent())
146 {
147 switch (eventId)
148 {
152 break;
153 case EVENT_ATTACK:
157 break;
158 default:
159 break;
160 }
161
163 return;
164 }
165 }
166
167 void DoAction(int32 action) override
168 {
169 if (action == ACTION_CRYSTAL_HANDLER_DIED)
171 }
172
173 void MoveInLineOfSight(Unit* who) override
174 {
176
177 if (!_ohNovos || !who || who->GetTypeId() != TYPEID_UNIT || who->GetPositionY() > MAX_Y_COORD_OH_NOVOS)
178 return;
179
180 uint32 entry = who->GetEntry();
181 if (entry == NPC_HULKING_CORPSE || entry == NPC_RISEN_SHADOWCASTER || entry == NPC_FETID_TROLL_CORPSE)
182 _ohNovos = false;
183 }
184
185 uint32 GetData(uint32 type) const override
186 {
187 return type == DATA_NOVOS_ACHIEV && _ohNovos ? 1 : 0;
188 }
189
190 void JustSummoned(Creature* summon) override
191 {
192 summons.Summon(summon);
193 }
194
195private:
196 void SetBubbled(bool state)
197 {
198 _bubbled = state;
199 if (!state)
200 {
203 me->CastStop();
204 }
205 else
206 {
209 }
210 }
211
212 void SetSummonerStatus(bool active)
213 {
214 for (uint8 i = 0; i < 4; i++)
215 {
216 ObjectGuid guid = instance->GetGuidData(summoners[i].data);
217 if (!guid.IsEmpty())
218 {
219 if (Creature* crystalChannelTarget = ObjectAccessor::GetCreature(*me, guid))
220 {
221 if (active)
222 crystalChannelTarget->AI()->SetData(summoners[i].spell, summoners[i].timer);
223 else
224 crystalChannelTarget->AI()->Reset();
225 }
226 }
227 }
228 }
229
230 void SetCrystalsStatus(bool active)
231 {
232 for (uint8 i = 0; i < 4; i++)
233 {
235 if (!guid.IsEmpty())
236 if (GameObject* crystal = ObjectAccessor::GetGameObject(*me, guid))
237 SetCrystalStatus(crystal, active);
238 }
239 }
240
241 void SetCrystalStatus(GameObject* crystal, bool active)
242 {
243 crystal->SetGoState(active ? GO_STATE_ACTIVE : GO_STATE_READY);
244 if (Creature* crystalChannelTarget = crystal->FindNearestCreature(NPC_CRYSTAL_CHANNEL_TARGET, 5.0f))
245 {
246 if (active)
247 crystalChannelTarget->CastSpell(nullptr, SPELL_BEAM_CHANNEL);
248 else if (crystalChannelTarget->HasUnitState(UNIT_STATE_CASTING))
249 crystalChannelTarget->CastStop();
250 }
251 }
252
254 {
255 for (uint8 i = 0; i < 4; i++)
256 {
258 if (!guid.IsEmpty())
259 {
260 if (GameObject* crystal = ObjectAccessor::GetGameObject(*me, guid))
261 {
262 if (crystal->GetGoState() == GO_STATE_ACTIVE)
263 {
264 SetCrystalStatus(crystal, false);
265 break;
266 }
267 }
268 }
269 }
270
271 if (++_crystalHandlerCount >= 4)
272 {
274 SetSummonerStatus(false);
275 SetBubbled(false);
277 if (IsHeroic())
279 }
280 else
281 {
283 if (!guid.IsEmpty())
284 if (Creature* crystalChannelTarget = ObjectAccessor::GetCreature(*me, guid))
285 crystalChannelTarget->AI()->SetData(SPELL_SUMMON_CRYSTAL_HANDLER, 15000);
286 }
287 }
288
292};
293
295{
297 {
298 Initialize();
299 }
300
302 {
303 _spell = 0;
304 _timer = 0;
305 _temp = 0;
306 }
307
308 void Reset() override
309 {
310 Initialize();
311 }
312
313 void UpdateAI(uint32 diff) override
314 {
315 if (_spell)
316 {
317 if (_temp <= diff)
318 {
319 DoCast(_spell);
320 _temp = _timer;
321 }
322 else
323 _temp -= diff;
324 }
325 }
326
327 void SetData(uint32 id, uint32 value) override
328 {
329 _spell = id;
330 _timer = value;
331 _temp = value;
332 }
333
334 void JustSummoned(Creature* summon) override
335 {
336 if (InstanceScript* instance = me->GetInstanceScript())
337 {
338 ObjectGuid guid = instance->GetGuidData(DATA_NOVOS);
339 if (!guid.IsEmpty())
340 if (Creature* novos = ObjectAccessor::GetCreature(*me, guid))
341 novos->AI()->JustSummoned(summon);
342 }
343
344 if (summon)
345 summon->GetMotionMaster()->MovePath((summon->GetEntry() * 100) << 3, false);
346
348 Reset();
349 }
350
351private:
355};
356
358{
359public:
360 achievement_oh_novos() : AchievementCriteriaScript("achievement_oh_novos") { }
361
362 bool OnCheck(Player* /*player*/, Unit* target) override
363 {
364 return target && target->GetTypeId() == TYPEID_UNIT && target->ToCreature()->AI()->GetData(DATA_NOVOS_ACHIEV);
365 }
366};
367
368// 59910 - Summon Minions
370{
371 bool Validate(SpellInfo const* /*spellInfo*/) override
372 {
374 }
375
376 void HandleScript(SpellEffIndex /*effIndex*/)
377 {
378 for (uint8 i = 0; i < 2; ++i)
380 }
381
386};
387
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
Spells
Definition PlayerAI.cpp:32
#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:276
@ EVENT_SUMMON_MINIONS
@ EVENT_ATTACK
@ ACTION_DEACTIVATE
@ ACTION_ACTIVATE_CRYSTAL
@ ACTION_RESET_CRYSTALS
@ DATA_NOVOS_ACHIEV
@ SAY_DEATH
@ SAY_AGGRO
@ SAY_KILL
@ SAY_ARCANE_FIELD
@ EMOTE_SUMMONING_ADDS
@ SAY_SUMMONING_ADDS
@ 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
void AddSC_boss_novos()
Yells
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:228
uint32 ExecuteEvent()
Definition EventMap.cpp:77
void Update(uint32 time)
Definition EventMap.h:61
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
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:79
virtual uint32 GetData(uint32 id) const
Definition UnitAI.h:74
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:89
Definition Unit.h:635
void CastStop(uint32 except_spellid=0)
Definition Unit.cpp:1186
MotionMaster * GetMotionMaster()
Definition Unit.h:1723
bool Attack(Unit *victim, bool meleeAttack)
Definition Unit.cpp:5853
bool HasUnitState(const uint32 f) const
Definition Unit.h:743
void SetUnitFlag(UnitFlags flags)
Definition Unit.h:846
void RemoveUnitFlag(UnitFlags flags)
Definition Unit.h:847
InstanceScript * GetInstanceScript() const
Definition Object.cpp:396
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2217
Creature * FindNearestCreature(uint32 entry, float range, bool alive=true) const
Definition Object.cpp:1517
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)