Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
boss_maexxna.cpp
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6#include "ScriptMgr.h"
7#include "ScriptedCreature.h"
8#include "PassiveAI.h"
9#include "naxxramas.h"
10
23
25{
26 NPC_WEB_WRAP = 16486,
28};
29
30#define MAX_POS_WRAP 3
32{
33 {3546.796f, -3869.082f, 296.450f, 0.0f},
34 {3531.271f, -3847.424f, 299.450f, 0.0f},
35 {3497.067f, -3843.384f, 302.384f, 0.0f},
36};
37
48
50{
51public:
52 boss_maexxna() : CreatureScript("boss_maexxna") { }
53
55 {
56 return new boss_maexxnaAI(creature);
57 }
58
59 struct boss_maexxnaAI : public BossAI
60 {
61 boss_maexxnaAI(Creature* creature) : BossAI(creature, BOSS_MAEXXNA) { }
62
63 bool enraged;
64
65 void EnterCombat(Unit* /*who*/) OVERRIDE
66 {
68 enraged = false;
69 events.ScheduleEvent(EVENT_WRAP, 20000);
70 events.ScheduleEvent(EVENT_SPRAY, 40000);
71 events.ScheduleEvent(EVENT_SHOCK, std::rand() % 10000 + 5000);
72 events.ScheduleEvent(EVENT_POISON, std::rand() % 15000 + 10000);
73 events.ScheduleEvent(EVENT_SUMMON, 30000);
74 }
75
77 {
78 if (!UpdateVictim() || !CheckInRoom())
79 return;
80
81 if (!enraged && HealthBelowPct(30))
82 {
83 enraged = true;
84 events.ScheduleEvent(EVENT_FRENZY, 0); // will be cast immediately
85 }
86
87 events.Update(diff);
88
89 while (uint32 eventId = events.ExecuteEvent())
90 {
91 switch (eventId)
92 {
93 case EVENT_WRAP:
95 for (uint8 i = 0; i < RAID_MODE(1, 2); ++i)
96 {
97 if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, 0, true, -SPELL_WEB_WRAP))
98 {
100 uint8 pos = rand()%MAX_POS_WRAP;
101 target->GetMotionMaster()->MoveJump(PosWrap[pos].GetPositionX(), PosWrap[pos].GetPositionY(), PosWrap[pos].GetPositionZ(), 20, 20);
103 wrap->AI()->SetGUID(target->GetGUID());
104 }
105 }
106 events.ScheduleEvent(EVENT_WRAP, 40000);
107 break;
108 case EVENT_SPRAY:
110 events.ScheduleEvent(EVENT_SPRAY, 40000);
111 break;
112 case EVENT_SHOCK:
114 events.ScheduleEvent(EVENT_SHOCK, std::rand() % 20000 + 10000);
115 break;
116 case EVENT_POISON:
118 events.ScheduleEvent(EVENT_POISON, std::rand() % 20000 + 10000);
119 break;
120 case EVENT_FRENZY:
122 events.ScheduleEvent(EVENT_FRENZY, 600000);
123 break;
124 case EVENT_SUMMON:
126 uint8 amount = std::rand() % 10 + 8;
127 for (uint8 i = 0; i < amount; ++i)
129 events.ScheduleEvent(EVENT_SUMMON, 40000);
130 break;
131 }
132 }
133
135 }
136 };
137};
138
140{
141public:
142 npc_webwrap() : CreatureScript("npc_webwrap") { }
143
145 {
146 return new npc_webwrapAI(creature);
147 }
148
150 {
151 npc_webwrapAI(Creature* creature) : NullCreatureAI(creature), victimGUID(0) { }
152
154
155 void SetGUID(uint64 guid, int32 /*param*/) OVERRIDE
156 {
157 victimGUID = guid;
158 if (me->m_spells[0] && victimGUID)
159 if (Unit* victim = Unit::GetUnit(*me, victimGUID))
160 victim->CastSpell(victim, me->m_spells[0], true, NULL, NULL, me->GetGUID());
161 }
162
163 void JustDied(Unit* /*killer*/) OVERRIDE
164 {
165 if (me->m_spells[0] && victimGUID)
166 if (Unit* victim = Unit::GetUnit(*me, victimGUID))
167 victim->RemoveAurasDueToSpell(me->m_spells[0], me->GetGUID());
168 }
169 };
170};
171
173{
174 new boss_maexxna();
175 new npc_webwrap();
176}
std::int32_t int32
Definition Define.h:73
std::uint8_t uint8
Definition Define.h:79
std::uint32_t uint32
Definition Define.h:77
#define OVERRIDE
Definition Define.h:60
std::uint64_t uint64
Definition Define.h:76
@ TEMPSUMMON_CORPSE_DESPAWN
Definition Object.h:72
@ SELECT_TARGET_RANDOM
Definition UnitAI.h:23
Creatures
@ EVENT_POISON
@ EVENT_NONE
@ EVENT_SUMMON
@ NPC_WEB_WRAP
@ NPC_SPIDERLING
#define MAX_POS_WRAP
@ SPELL_FRENZY_10
@ SPELL_POISON_SHOCK_25
@ SPELL_WEB_SPRAY_25
@ SPELL_NECROTIC_POISON_25
@ SPELL_WEB_WRAP
@ SPELL_NECROTIC_POISON_10
@ SPELL_FRENZY_25
@ SPELL_WEB_SPRAY_10
@ SPELL_POISON_SHOCK_10
void AddSC_boss_maexxna()
const Position PosWrap[MAX_POS_WRAP]
@ EVENT_SHOCK
@ EVENT_WRAP
@ EVENT_SPRAY
@ EVENT_FRENZY
@ EVENT_SUMMON
@ EVENT_POISON
bool CheckInRoom()
EventMap events
BossAI(Creature *creature, uint32 bossId)
void _EnterCombat()
Creature * DoSummon(uint32 entry, Position const &pos, uint32 despawnTime=30000, TempSummonType summonType=TempSummonType::TEMPSUMMON_CORPSE_TIMED_DESPAWN)
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:56
CreatureScript(const char *name)
NullCreatureAI(Creature *c)
Definition PassiveAI.cpp:12
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:28
void DoCast(uint32 spellId)
Definition UnitAI.cpp:110
Unit * SelectTarget(SelectAggroTarget targetType, uint32 position=0, float dist=0.0f, bool playerOnly=false, int32 aura=0)
Definition UnitAI.cpp:66
void DoCastVictim(uint32 spellId, bool triggered=false)
Definition UnitAI.cpp:168
void DoCastAOE(uint32 spellId, bool triggered=false)
Definition UnitAI.cpp:176
Definition Unit.h:1367
static Unit * GetUnit(WorldObject &object, uint64 guid)
Definition Unit.cpp:4895
CreatureAI * GetAI(Creature *creature) const OVERRIDE
CreatureAI * GetAI(Creature *creature) const OVERRIDE
@ BOSS_MAEXXNA
Definition naxxramas.h:15
Creature * me
bool HealthBelowPct(uint32 pct) const
const T & RAID_MODE(const T &normal10, const T &normal25) const
void EnterCombat(Unit *) OVERRIDE
void UpdateAI(uint32 diff) OVERRIDE
== Triggered Actions Requested ==================
boss_maexxnaAI(Creature *creature)
void JustDied(Unit *) OVERRIDE
void SetGUID(uint64 guid, int32) OVERRIDE
npc_webwrapAI(Creature *creature)