TrinityCore
Loading...
Searching...
No Matches
boss_maexxna.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 "InstanceScript.h"
20#include "MotionMaster.h"
21#include "naxxramas.h"
22#include "ObjectAccessor.h"
23#include "PassiveAI.h"
24#include "ScriptedCreature.h"
25#include "SpellMgr.h"
26#include "SpellScript.h"
27
36#define SPELL_FRENZY_HELPER RAID_MODE(54123,54124)
37
44
46{
47 NPC_WEB_WRAP = 16486,
49};
50
51#define MAX_WRAP_POSITION 7
53{
54 {3453.818f, -3854.651f, 308.7581f, 4.362833f},
55 {3535.042f, -3842.383f, 300.795f, 3.179324f},
56 {3538.399f, -3846.088f, 299.964f, 4.310297f},
57 {3548.464f, -3854.676f, 298.6075f, 4.546609f},
58 {3557.663f, -3870.123f, 297.5027f, 3.756433f},
59 {3560.546f, -3879.353f, 297.4843f, 2.508937f},
60 {3562.535f, -3892.507f, 298.532f, 6.022466f},
61};
62
72
73const float WEB_WRAP_MOVE_SPEED = 20.0f;
74
76{
77 WebTargetSelector(Unit* maexxna) : _maexxna(maexxna) {}
78 bool operator()(Unit const* target) const
79 {
80 if (target->GetTypeId() != TYPEID_PLAYER) // never web nonplayers (pets, guardians, etc.)
81 return false;
82 if (_maexxna->GetVictim() == target) // never target tank
83 return false;
84 if (target->HasAura(SPELL_WEB_WRAP)) // never target targets that are already webbed
85 return false;
86 return true;
87 }
88
89 private:
90 Unit const* _maexxna;
91};
92
93struct boss_maexxna : public BossAI
94{
95 boss_maexxna(Creature* creature) : BossAI(creature, BOSS_MAEXXNA) { }
96
106
107 void Reset() override
108 {
109 _Reset();
111 }
112
113 void UpdateAI(uint32 diff) override
114 {
115 if (!UpdateVictim())
116 return;
117
119 {
121 }
122
123 events.Update(diff);
124
125 while (uint32 eventId = events.ExecuteEvent())
126 {
127 switch (eventId)
128 {
129 case EVENT_WRAP:
130 {
131 std::list<Unit*> targets;
133 if (!targets.empty())
134 {
136 int8 wrapPos = -1;
137 for (Unit* target : targets)
138 {
139 if (wrapPos == -1) // allow all positions on the first target
140 wrapPos = urand(0, MAX_WRAP_POSITION - 1);
141 else // on subsequent iterations, only allow positions that are not equal to the previous one (this is sufficient since we should only have two targets at most, ever)
142 wrapPos = (wrapPos + urand(1, MAX_WRAP_POSITION - 1)) % MAX_WRAP_POSITION;
143
144 target->RemoveAura(sSpellMgr->GetSpellIdForDifficulty(SPELL_WEB_SPRAY, me));
146 {
147 wrap->AI()->SetGUID(target->GetGUID()); // handles application of debuff
148 target->GetMotionMaster()->MoveJump(WrapPositions[wrapPos], WEB_WRAP_MOVE_SPEED, WEB_WRAP_MOVE_SPEED); // move after stun to avoid stun cancelling move
149 }
150 }
151 }
152 events.Repeat(Seconds(40));
153 break;
154 }
155 case EVENT_SPRAY:
158 events.Repeat(Seconds(40));
159 break;
160 case EVENT_SHOCK:
163 break;
164 case EVENT_POISON:
167 break;
168 case EVENT_SUMMON:
170 uint8 amount = urand(8, 10);
171 for (uint8 i = 0; i < amount; ++i)
173 events.Repeat(Seconds(40));
174 break;
175 }
176 }
177
179 }
180};
181
183{
184 npc_webwrap(Creature* creature) : NullCreatureAI(creature), visibleTimer(0) { }
185
188
189 void InitializeAI() override
190 {
191 me->SetVisible(false);
192 }
193
194 void SetGUID(ObjectGuid const& guid, int32 /*id*/) override
195 {
196 if (!guid)
197 return;
198 victimGUID = guid;
199 if (Unit* victim = ObjectAccessor::GetUnit(*me, victimGUID))
200 {
202 victim->CastSpell(victim, SPELL_WEB_WRAP, me->GetGUID());
203 }
204 }
205
206 void UpdateAI(uint32 diff) override
207 {
208 if (!visibleTimer)
209 return;
210
211 if (diff >= visibleTimer)
212 {
213 visibleTimer = 0;
214 me->SetVisible(true);
215 }
216 else
217 visibleTimer -= diff;
218 }
219
220 void JustDied(Unit* /*killer*/) override
221 {
222 if (!victimGUID.IsEmpty())
223 if (Unit* victim = ObjectAccessor::GetUnit(*me, victimGUID))
224 victim->RemoveAurasDueToSpell(SPELL_WEB_WRAP, me->GetGUID());
225
227 }
228};
229
@ IN_MILLISECONDS
Definition Common.h:35
uint8_t uint8
Definition Define.h:135
int8_t int8
Definition Define.h:131
int32_t int32
Definition Define.h:129
uint32_t uint32
Definition Define.h:133
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition Duration.h:27
@ TEMPSUMMON_TIMED_DESPAWN
@ TEMPSUMMON_CORPSE_TIMED_DESPAWN
@ TYPEID_PLAYER
Definition ObjectGuid.h:39
Spells
Definition PlayerAI.cpp:32
Milliseconds randtime(Milliseconds min, Milliseconds max)
Definition Random.cpp:62
uint32 urand(uint32 min, uint32 max)
Definition Random.cpp:42
#define sSpellMgr
Definition SpellMgr.h:738
constexpr std::underlying_type< E >::type AsUnderlyingType(E enumValue)
Definition Util.h:554
Creatures
const Position WrapPositions[MAX_WRAP_POSITION]
@ NPC_WEB_WRAP
@ NPC_SPIDERLING
@ EMOTE_WEB_WRAP
@ EMOTE_WEB_SPRAY
@ EMOTE_SPIDERS
#define SPELL_FRENZY_HELPER
@ SPELL_POISON_SHOCK
@ SPELL_WEB_WRAP
@ SPELL_NECROTIC_POISON
@ SPELL_FRENZY
@ SPELL_WEB_SPRAY
#define MAX_WRAP_POSITION
const float WEB_WRAP_MOVE_SPEED
void AddSC_boss_maexxna()
@ EVENT_SHOCK
@ EVENT_WRAP
@ EVENT_NONE
@ EVENT_SPRAY
@ EVENT_SUMMON
@ EVENT_POISON
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
EventMap events
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
Creature * DoSummon(uint32 entry, Position const &pos, Milliseconds despawnTime=30s, TempSummonType summonType=TEMPSUMMON_CORPSE_TIMED_DESPAWN)
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
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 DoRemoveAurasDueToSpellOnPlayers(uint32 spell, bool includePets=false, bool includeControlled=false)
bool IsEmpty() const
Definition ObjectGuid.h:172
TypeID GetTypeId() const
Definition Object.h:93
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:78
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.cpp:166
void SelectTargetList(std::list< Unit * > &targetList, uint32 num, SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition UnitAI.cpp:101
SpellCastResult DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:243
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:106
Definition Unit.h:769
void SetVisible(bool x)
Definition Unit.cpp:8513
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition Unit.cpp:4535
Unit * GetVictim() const
Definition Unit.h:859
float GetDistance2d(WorldObject const *obj) const
Definition Object.cpp:1141
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
@ BOSS_MAEXXNA
Definition naxxramas.h:32
#define RegisterNaxxramasCreatureAI(ai_name)
Definition naxxramas.h:221
T const & RAID_MODE(T const &normal10, T const &normal25) const
bool HealthBelowPct(uint32 pct) const
bool operator()(Unit const *target) const
WebTargetSelector(Unit *maexxna)
Unit const * _maexxna
boss_maexxna(Creature *creature)
void Reset() override
void UpdateAI(uint32 diff) override
void JustEngagedWith(Unit *who) override
npc_webwrap(Creature *creature)
void JustDied(Unit *) override
void SetGUID(ObjectGuid const &guid, int32) override
ObjectGuid victimGUID
void InitializeAI() override
uint32 visibleTimer
void UpdateAI(uint32 diff) override