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
33
34#define SPELL_WEB_SPRAY RAID_MODE(29484,54125)
35#define SPELL_FRENZY_HELPER RAID_MODE(54123,54124)
36
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
71
76
78{
79 WebTargetSelector(Unit* maexxna) : _maexxna(maexxna) {}
80 bool operator()(Unit const* target) const
81 {
82 if (target->GetTypeId() != TYPEID_PLAYER) // never web nonplayers (pets, guardians, etc.)
83 return false;
84 if (_maexxna->GetVictim() == target) // never target tank
85 return false;
86 if (target->HasAura(SPELL_WEB_WRAP)) // never target targets that are already webbed
87 return false;
88 return true;
89 }
90
91 private:
92 Unit const* _maexxna;
93};
94
95struct boss_maexxna : public BossAI
96{
97 boss_maexxna(Creature* creature) : BossAI(creature, BOSS_MAEXXNA) { }
98
108
109 void Reset() override
110 {
111 _Reset();
113 }
114
115 void UpdateAI(uint32 diff) override
116 {
117 if (!UpdateVictim())
118 return;
119
121 {
123 }
124
125 events.Update(diff);
126
127 while (uint32 eventId = events.ExecuteEvent())
128 {
129 switch (eventId)
130 {
131 case EVENT_WRAP:
132 {
133 std::list<Unit*> targets;
135 if (!targets.empty())
136 {
138 int8 wrapPos = -1;
139 for (Unit* target : targets)
140 {
141 if (wrapPos == -1) // allow all positions on the first target
142 wrapPos = urand(0, MAX_WRAP_POSITION - 1);
143 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)
144 wrapPos = (wrapPos + urand(1, MAX_WRAP_POSITION - 1)) % MAX_WRAP_POSITION;
145
146 target->RemoveAura(SPELL_WEB_SPRAY);
148 wrap->AI()->SetGUID(target->GetGUID(), DATA_WEBWRAP_VICTIM_GUID); // handles application of debuff
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 (id != DATA_WEBWRAP_VICTIM_GUID)
194 return;
195
196 if (!guid)
197 return;
198
199 victimGUID = guid;
200 if (Unit* victim = ObjectAccessor::GetUnit(*me, victimGUID))
201 {
202 uint32 spellId = 28621;
203 // TODO: not fully correct - should be using different set of script_effect spells first (29280, 29281, 29282, 29283, 29285, 29287)
204 float dist = me->GetDistance2d(victim);
205 float speed = 50.0f;
206 if (dist <= 20.0f)
207 {
208 spellId = 28618;
209 speed = 20.0f;
210 }
211 else if (dist <= 30.0f)
212 {
213 spellId = 28619;
214 speed = 30.0f;
215 }
216 else if (dist <= 40.0f)
217 {
218 spellId = 28620;
219 speed = 40.0f;
220 }
221
222 visibleTimer = (me->GetDistance2d(victim) / speed + 0.5f) * AsUnderlyingType(IN_MILLISECONDS);
223
224 victim->CastSpell(victim, spellId, CastSpellExtraArgs(TRIGGERED_FULL_MASK)
226 }
227 }
228
229 void UpdateAI(uint32 diff) override
230 {
231 if (!visibleTimer)
232 return;
233
234 if (diff >= visibleTimer)
235 {
236 visibleTimer = 0;
237 me->SetVisible(true);
238 }
239 else
240 visibleTimer -= diff;
241 }
242
243 void JustDied(Unit* /*killer*/) override
244 {
245 if (!victimGUID.IsEmpty())
246 if (Unit* victim = ObjectAccessor::GetUnit(*me, victimGUID))
247 victim->RemoveAurasDueToSpell(SPELL_WEB_WRAP, me->GetGUID());
248
250 }
251};
252
@ IN_MILLISECONDS
Definition Common.h:38
uint8_t uint8
Definition Define.h:156
int8_t int8
Definition Define.h:152
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition Duration.h:28
@ TEMPSUMMON_TIMED_DESPAWN
@ TEMPSUMMON_CORPSE_TIMED_DESPAWN
@ TYPEID_PLAYER
Definition ObjectGuid.h:44
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.
constexpr std::underlying_type< E >::type AsUnderlyingType(E enumValue)
Definition Util.h:565
Creatures
const Position WrapPositions[MAX_WRAP_POSITION]
@ NPC_WEB_WRAP
@ NPC_SPIDERLING
@ EMOTE_WEB_WRAP
@ EMOTE_WEB_SPRAY
@ EMOTE_SPIDERS
#define SPELL_FRENZY_HELPER
MaexxnaData
@ DATA_WEBWRAP_VICTIM_GUID
@ SPELL_POISON_SHOCK
@ SPELL_WEB_WRAP
@ SPELL_NECROTIC_POISON
@ SPELL_FRENZY
#define SPELL_WEB_SPRAY
#define MAX_WRAP_POSITION
void AddSC_boss_maexxna()
@ EVENT_SHOCK
@ EVENT_WRAP
@ EVENT_NONE
@ EVENT_SPRAY
@ EVENT_SUMMON
@ EVENT_POISON
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
TypeID GetTypeId() const
Definition BaseEntity.h:166
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
EventMap events
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:63
Creature * DoSummon(uint32 entry, Position const &pos, Milliseconds despawnTime=30s, TempSummonType summonType=TEMPSUMMON_CORPSE_TIMED_DESPAWN)
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
uint32 ExecuteEvent()
Definition EventMap.cpp:77
void Update(uint32 time)
Definition EventMap.h:61
void Repeat(Milliseconds time)
Definition EventMap.cpp:67
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition EventMap.cpp:40
void DoRemoveAurasDueToSpellOnPlayers(uint32 spell, bool includePets=false, bool includeControlled=false)
bool IsEmpty() const
Definition ObjectGuid.h:362
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:162
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:89
Definition Unit.h:635
void SetVisible(bool x)
Definition Unit.cpp:8768
Unit * GetVictim() const
Definition Unit.h:726
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition Unit.cpp:4804
float GetDistance2d(WorldObject const *obj) const
Definition Object.cpp:450
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)
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 id) override
ObjectGuid victimGUID
void InitializeAI() override
uint32 visibleTimer
void UpdateAI(uint32 diff) override