TrinityCore
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
27{
31 SPELL_FRENZY = 54123
32};
33
34#define SPELL_WEB_SPRAY RAID_MODE(29484,54125)
35#define SPELL_FRENZY_HELPER RAID_MODE(54123,54124)
36
38{
42};
43
45{
46 NPC_WEB_WRAP = 16486,
48};
49
50#define MAX_WRAP_POSITION 7
52{
53 {3453.818f, -3854.651f, 308.7581f, 4.362833f},
54 {3535.042f, -3842.383f, 300.795f, 3.179324f},
55 {3538.399f, -3846.088f, 299.964f, 4.310297f},
56 {3548.464f, -3854.676f, 298.6075f, 4.546609f},
57 {3557.663f, -3870.123f, 297.5027f, 3.756433f},
58 {3560.546f, -3879.353f, 297.4843f, 2.508937f},
59 {3562.535f, -3892.507f, 298.532f, 6.022466f},
60};
61
63{
70};
71
72const float WEB_WRAP_MOVE_SPEED = 20.0f;
73
75{
76 WebTargetSelector(Unit* maexxna) : _maexxna(maexxna) {}
77 bool operator()(Unit const* target) const
78 {
79 if (target->GetTypeId() != TYPEID_PLAYER) // never web nonplayers (pets, guardians, etc.)
80 return false;
81 if (_maexxna->GetVictim() == target) // never target tank
82 return false;
83 if (target->HasAura(SPELL_WEB_WRAP)) // never target targets that are already webbed
84 return false;
85 return true;
86 }
87
88 private:
89 Unit const* _maexxna;
90};
91
92struct boss_maexxna : public BossAI
93{
94 boss_maexxna(Creature* creature) : BossAI(creature, BOSS_MAEXXNA) { }
95
96 void JustEngagedWith(Unit* who) override
97 {
104 }
105
106 void Reset() override
107 {
108 _Reset();
110 }
111
112 void UpdateAI(uint32 diff) override
113 {
114 if (!UpdateVictim())
115 return;
116
118 {
120 }
121
122 events.Update(diff);
123
124 while (uint32 eventId = events.ExecuteEvent())
125 {
126 switch (eventId)
127 {
128 case EVENT_WRAP:
129 {
130 std::list<Unit*> targets;
132 if (!targets.empty())
133 {
135 int8 wrapPos = -1;
136 for (Unit* target : targets)
137 {
138 if (wrapPos == -1) // allow all positions on the first target
139 wrapPos = urand(0, MAX_WRAP_POSITION - 1);
140 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)
141 wrapPos = (wrapPos + urand(1, MAX_WRAP_POSITION - 1)) % MAX_WRAP_POSITION;
142
143 target->RemoveAura(SPELL_WEB_SPRAY);
145 {
146 wrap->AI()->SetGUID(target->GetGUID()); // handles application of debuff
147 target->GetMotionMaster()->MoveJump(WrapPositions[wrapPos], WEB_WRAP_MOVE_SPEED, WEB_WRAP_MOVE_SPEED); // move after stun to avoid stun cancelling move
148 }
149 }
150 }
151 events.Repeat(Seconds(40));
152 break;
153 }
154 case EVENT_SPRAY:
157 events.Repeat(Seconds(40));
158 break;
159 case EVENT_SHOCK:
162 break;
163 case EVENT_POISON:
166 break;
167 case EVENT_SUMMON:
169 uint8 amount = urand(8, 10);
170 for (uint8 i = 0; i < amount; ++i)
172 events.Repeat(Seconds(40));
173 break;
174 }
175 }
176 }
177};
178
180{
181 npc_webwrap(Creature* creature) : NullCreatureAI(creature), visibleTimer(0) { }
182
185
186 void InitializeAI() override
187 {
188 me->SetVisible(false);
189 }
190
191 void SetGUID(ObjectGuid const& guid, int32 /*id*/) override
192 {
193 if (!guid)
194 return;
195 victimGUID = guid;
196 if (Unit* victim = ObjectAccessor::GetUnit(*me, victimGUID))
197 {
199 victim->CastSpell(victim, SPELL_WEB_WRAP, CastSpellExtraArgs(TRIGGERED_FULL_MASK)
201 }
202 }
203
204 void UpdateAI(uint32 diff) override
205 {
206 if (!visibleTimer)
207 return;
208
209 if (diff >= visibleTimer)
210 {
211 visibleTimer = 0;
212 me->SetVisible(true);
213 }
214 else
215 visibleTimer -= diff;
216 }
217
218 void JustDied(Unit* /*killer*/) override
219 {
220 if (!victimGUID.IsEmpty())
221 if (Unit* victim = ObjectAccessor::GetUnit(*me, victimGUID))
222 victim->RemoveAurasDueToSpell(SPELL_WEB_WRAP, me->GetGUID());
223
225 }
226};
227
229{
232}
@ IN_MILLISECONDS
Definition: Common.h:35
uint8_t uint8
Definition: Define.h:144
int8_t int8
Definition: Define.h:140
int32_t int32
Definition: Define.h:138
uint32_t uint32
Definition: Define.h:142
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition: Duration.h:32
@ TEMPSUMMON_TIMED_DESPAWN
Definition: ObjectDefines.h:65
@ TEMPSUMMON_CORPSE_TIMED_DESPAWN
Definition: ObjectDefines.h:68
@ TYPEID_PLAYER
Definition: ObjectGuid.h:41
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
@ TRIGGERED_FULL_MASK
Used when doing CastSpell with triggered == true.
Definition: SpellDefines.h:266
constexpr std::underlying_type< E >::type AsUnderlyingType(E enumValue)
Definition: Util.h:491
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
#define 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
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:56
bool UpdateVictim()
Definition: CreatureAI.cpp:245
Creature *const me
Definition: CreatureAI.h:61
Creature * DoSummon(uint32 entry, Position const &pos, Milliseconds despawnTime=30s, TempSummonType summonType=TEMPSUMMON_CORPSE_TIMED_DESPAWN)
Definition: CreatureAI.cpp:464
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
Definition: Creature.cpp:2415
uint32 ExecuteEvent()
Definition: EventMap.cpp:73
void Update(uint32 time)
Definition: EventMap.h:56
void Repeat(Milliseconds time)
Definition: EventMap.cpp:63
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition: EventMap.cpp:36
void DoRemoveAurasDueToSpellOnPlayers(uint32 spell, bool includePets=false, bool includeControlled=false)
bool IsEmpty() const
Definition: ObjectGuid.h:319
TypeID GetTypeId() const
Definition: Object.h:173
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.cpp:180
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:84
SpellCastResult DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.h:161
SpellCastResult DoCast(uint32 spellId)
Definition: UnitAI.cpp:89
Definition: Unit.h:627
void SetVisible(bool x)
Definition: Unit.cpp:8351
Unit * GetVictim() const
Definition: Unit.h:715
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4664
float GetDistance2d(WorldObject const *obj) const
Definition: Object.cpp:1096
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
@ BOSS_MAEXXNA
Definition: naxxramas.h:32
#define RegisterNaxxramasCreatureAI(ai_name)
Definition: naxxramas.h:221
CastSpellExtraArgs & SetOriginalCaster(ObjectGuid const &guid)
Definition: SpellDefines.h:471
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