summaryrefslogtreecommitdiff
path: root/src/server/scripts/Outland/BlackTemple/boss_supremus.cpp
blob: c1d916de0bdb03a428278aee7f1f8c7ee7b741aa (plain)
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
/*
 * 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 "black_temple.h"

enum Supremus
{
    EMOTE_NEW_TARGET                = 0,
    EMOTE_PUNCH_GROUND              = 1,
    EMOTE_GROUND_CRACK              = 2,
    EMOTE_BERSERK                   = 3,

    SPELL_SNARE_SELF                = 41922,
    SPELL_MOLTEN_PUNCH              = 40126,
    SPELL_MOLTEN_FLAME              = 40980,
    SPELL_HATEFUL_STRIKE            = 41926,
    SPELL_VOLCANIC_ERUPTION         = 40276,
    SPELL_VOLCANIC_ERUPTION_TRIGGER = 40117,
    SPELL_VOLCANIC_GEYSER           = 42055,
    SPELL_BERSERK                   = 26662,
    SPELL_CHARGE                    = 41581,

    SPELL_SERVERSIDE_RANDOM_TARGET  = 41951,  // Found in 55261. Used for Fixate target

    NPC_SUPREMUS_VOLCANO            = 23085,

    GROUP_ABILITIES                 = 1,
    GROUP_MOLTEN_PUNCH              = 2,
    GROUP_PHASE_CHANGE              = 3
};

struct boss_supremus : public BossAI
{
    boss_supremus(Creature* creature) : BossAI(creature, DATA_SUPREMUS)
    {
        scheduler.SetValidator([this]
        {
            return !me->HasUnitState(UNIT_STATE_CASTING);
        });
    }

    void Reset() override
    {
        BossAI::Reset();
        me->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, false);
        me->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_ATTACK_ME, false);
    }

    void JustEngagedWith(Unit* who) override
    {
        BossAI::JustEngagedWith(who);

        SchedulePhase(true);

        ScheduleTimedEvent(15min, [&]
        {
            DoCastSelf(SPELL_BERSERK, true);
            Talk(EMOTE_BERSERK);
            scheduler.CancelGroup(GROUP_ABILITIES);  // Supremus stops all other abilities after berserking
            scheduler.CancelGroup(GROUP_MOLTEN_PUNCH);
            scheduler.CancelGroup(GROUP_PHASE_CHANGE);
        }, 5min);

        scheduler.Schedule(20s, [this](TaskContext context)
        {
            context.SetGroup(GROUP_MOLTEN_PUNCH);
            DoCastSelf(SPELL_MOLTEN_PUNCH);
            context.Repeat(15s, 20s);
        });
    }

    void SchedulePhase(bool isSnared)
    {
        scheduler.CancelGroup(GROUP_ABILITIES);

        scheduler.Schedule(1min, [this](TaskContext context)
        {
            context.SetGroup(GROUP_PHASE_CHANGE);
            SchedulePhase(me->HasAura(SPELL_SNARE_SELF));
        });

        DoResetThreatList();

        // Hateful Strike Phase
        if (isSnared)
        {
            scheduler.Schedule(8s, 15s, [this](TaskContext context)
            {
                context.SetGroup(GROUP_ABILITIES);

                if (Unit* target = FindHatefulStrikeTarget())
                    DoCast(target, SPELL_HATEFUL_STRIKE);

                context.Repeat(1500ms, 15s);
            });

            if (me->HasAura(SPELL_SNARE_SELF))
                Talk(EMOTE_PUNCH_GROUND);

            me->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, false);
            me->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_ATTACK_ME, false);
            me->RemoveAurasDueToSpell(SPELL_SNARE_SELF);
        }
        // Gaze Phase
        else
        {
            DoCastSelf(SPELL_SNARE_SELF, true);

            scheduler.Schedule(5s, [this](TaskContext context)
            {
                context.SetGroup(GROUP_ABILITIES);

                if (DoCastRandomTarget(SPELL_VOLCANIC_ERUPTION, 0, 100.f, true) == SPELL_CAST_OK)
                    Talk(EMOTE_GROUND_CRACK);

                context.Repeat(10s, 18s);
            }).Schedule(0s, [this](TaskContext context)
            {
                context.SetGroup(GROUP_ABILITIES);

                if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 100, true))
                {
                    DoResetThreatList();
                    me->AddThreat(target, 5000000.0f);
                    Talk(EMOTE_NEW_TARGET);
                    if (target->IsWithinDist(me, 40))
                        DoCast(target, SPELL_CHARGE);
                }

                context.Repeat(10s);
            });

            me->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, true);
            me->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_ATTACK_ME, true);
        }
    }

    void JustSummoned(Creature* summon) override
    {
        summons.Summon(summon);
        if (summon->GetEntry() == NPC_SUPREMUS_VOLCANO)
            summon->CastSpell(summon, SPELL_VOLCANIC_ERUPTION_TRIGGER, true);
        else
            summon->ToTempSummon()->InitStats(30000);
    }

    void SummonedCreatureDespawn(Creature* summon) override
    {
        summons.Despawn(summon);
    }

    Unit* FindHatefulStrikeTarget()
    {
        Unit* target = nullptr;
        ThreatContainer::StorageType const& threatlist = me->GetThreatMgr().GetThreatList();
        for (ThreatContainer::StorageType::const_iterator i = threatlist.begin(); i != threatlist.end(); ++i)
        {
            Unit* unit = ObjectAccessor::GetUnit(*me, (*i)->getUnitGuid());
            if (unit && me->IsWithinMeleeRange(unit))
                if (!target || unit->GetHealth() > target->GetHealth())
                    target = unit;
        }

        return target;
    }

    bool CheckEvadeIfOutOfCombatArea() const override
    {
        return me->GetPositionX() < 565 || me->GetPositionX() > 865 || me->GetPositionY() < 545 || me->GetPositionY() > 1000;
    }
};

struct npc_supremus_punch_invisible_stalker : public ScriptedAI
{
    npc_supremus_punch_invisible_stalker(Creature* creature) : ScriptedAI(creature) { }

    void IsSummonedBy(WorldObject* /*summoner*/) override
    {
        me->SetInCombatWithZone();
        if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 100.0f, true))
            me->AddThreat(target, 10000.f);

        DoCastSelf(SPELL_MOLTEN_FLAME, true);

        scheduler.Schedule(6s, 10s, [this](TaskContext /*context*/)
        {
            me->CombatStop();
            me->SetReactState(REACT_PASSIVE);
        });
    }

    void UpdateAI(uint32 diff) override
    {
        scheduler.Update(diff);

        if (!UpdateVictim())
            return;
    }
};

void AddSC_boss_supremus()
{
    RegisterBlackTempleCreatureAI(npc_supremus_punch_invisible_stalker);
    RegisterBlackTempleCreatureAI(boss_supremus);
}