1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "CreatureScript.h"
#include "ScriptedCreature.h"
#include "SpellScript.h"
#include "SpellScriptLoader.h"
#include "zulgurub.h"
enum Spells
{
SPELL_SLEEP = 24664,
SPELL_EARTH_SHOCK = 24685,
SPELL_CHAIN_BURN = 24684,
SPELL_SUMMON_NIGHTMARE_ILLUSION_LEFT = 24681,
SPELL_SUMMON_NIGHTMARE_ILLUSION_BACK = 24728,
SPELL_SUMMON_NIGHTMARE_ILLUSION_RIGHT = 24729
};
enum Events
{
EVENT_SLEEP = 1,
EVENT_EARTH_SHOCK = 2,
EVENT_CHAIN_BURN = 3,
EVENT_ILLUSIONS = 4
};
struct boss_hazzarah : public BossAI
{
boss_hazzarah(Creature* creature) : BossAI(creature, DATA_EDGE_OF_MADNESS) { }
void JustSummoned(Creature* summon) override
{
summons.Summon(summon);
summon->SetCorpseDelay(10);
summon->SetReactState(REACT_PASSIVE);
summon->SetUnitFlag(UNIT_FLAG_DISABLE_MOVE);
summon->SetVisible(false);
summon->m_Events.AddEventAtOffset([summon]()
{
summon->SetVisible(true);
}, 2s);
summon->m_Events.AddEventAtOffset([summon]()
{
summon->RemoveUnitFlag(UNIT_FLAG_DISABLE_MOVE);
summon->SetReactState(REACT_AGGRESSIVE);
summon->SetInCombatWithZone();
}, 5s);
}
void SummonedCreatureDies(Creature* summon, Unit* /*killer*/) override
{
summons.Despawn(summon);
summon->DespawnOrUnsummon();
}
void JustEngagedWith(Unit* /*who*/) override
{
_JustEngagedWith();
events.ScheduleEvent(EVENT_SLEEP, 12s, 15s);
events.ScheduleEvent(EVENT_EARTH_SHOCK, 8s, 18s);
events.ScheduleEvent(EVENT_CHAIN_BURN, 12s, 28s);
events.ScheduleEvent(EVENT_ILLUSIONS, 16s, 24s);
}
bool CanAIAttack(Unit const* target) const override
{
if (me->GetThreatMgr().GetThreatListSize() > 1)
{
ThreatContainer::StorageType::const_iterator lastRef = me->GetThreatMgr().GetOnlineContainer().GetThreatList().end();
--lastRef;
if (Unit* lastTarget = (*lastRef)->getTarget())
{
if (lastTarget != target)
{
return !target->HasAura(SPELL_SLEEP);
}
}
}
return true;
}
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())
return;
events.Update(diff);
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
while (uint32 eventId = events.ExecuteEvent())
{
switch (eventId)
{
case EVENT_SLEEP:
DoCastVictim(SPELL_SLEEP, true);
events.ScheduleEvent(EVENT_SLEEP, 24s, 32s);
return;
case EVENT_EARTH_SHOCK:
DoCastVictim(SPELL_EARTH_SHOCK);
events.ScheduleEvent(EVENT_EARTH_SHOCK, 8s, 18s);
break;
case EVENT_CHAIN_BURN:
if (me->GetPowerPct(POWER_MANA) > 5.f) // totally guessed
{
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, [&](Unit* u) { return u && !u->IsPet() && u->getPowerType() == POWER_MANA && u != me->GetVictim(); }))
{
DoCast(target, SPELL_CHAIN_BURN);
}
}
events.ScheduleEvent(EVENT_CHAIN_BURN, 12s, 28s);
break;
case EVENT_ILLUSIONS:
DoCastSelf(SPELL_SUMMON_NIGHTMARE_ILLUSION_LEFT, true);
DoCastSelf(SPELL_SUMMON_NIGHTMARE_ILLUSION_BACK, true);
DoCastSelf(SPELL_SUMMON_NIGHTMARE_ILLUSION_RIGHT, true);
events.ScheduleEvent(EVENT_ILLUSIONS, 15s, 25s);
break;
default:
break;
}
}
DoMeleeAttackIfReady();
}
};
class spell_chain_burn : public SpellScript
{
PrepareSpellScript(spell_chain_burn);
void FilterTargets(std::list<WorldObject*>& targets)
{
Unit* caster = GetCaster();
targets.remove_if([caster](WorldObject* target) -> bool
{
Unit* unit = target->ToUnit();
return !unit || unit->getPowerType() != POWER_MANA || caster->GetVictim() == unit;
});
}
void Register() override
{
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_chain_burn::FilterTargets, EFFECT_0, TARGET_UNIT_TARGET_ENEMY);
}
};
void AddSC_boss_hazzarah()
{
RegisterZulGurubCreatureAI(boss_hazzarah);
RegisterSpellScript(spell_chain_burn);
}
|