PageRenderTime 53ms CodeModel.GetById 12ms app.highlight 37ms RepoModel.GetById 1ms app.codeStats 0ms

/RubySanctum/boss_ragefire.cpp

https://bitbucket.org/TCRC/patches/
C++ | 192 lines | 147 code | 23 blank | 22 comment | 14 complexity | cf90f3f7336a73f0cad8200a3b823fbe MD5 | raw file
  1/* Copyright (C) 2010 Easy for Trinity <http://trinity-core.ru/> 
  2 *
  3 * Copyright (C) 2008 - 2010 Trinity <http://www.trinitycore.org/>
  4 *
  5 * Copyright (C) 2010 Myth Project <http://bitbucket.org/sun/myth-core/>
  6 *
  7 * Copyright (C) 2006 - 2010 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
  8 *
  9 * This program is free software; you can redistribute it and/or modify
 10 * it under the terms of the GNU General Public License as published by
 11 * the Free Software Foundation; either version 2 of the License, or
 12 * (at your option) any later version.
 13 *
 14 * This program is distributed in the hope that it will be useful,
 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 17 * GNU General Public License for more details.
 18 *
 19 * You should have received a copy of the GNU General Public License
 20 * along with this program; if not, write to the Free Software
 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 22 */
 23
 24#include "ScriptPCH.h"
 25#include "ruby_sanctum.h"
 26
 27enum eScriptTexts
 28{
 29    SAY_AGGRO           = -1752022,
 30    SAY_SLAY1           = -1752023,
 31    SAY_SLAY2           = -1752024,
 32    SAY_DEATH           = -1752025
 33};
 34
 35enum eSpells
 36{
 37    SPELL_CONFLAGRATION     = 74456,
 38    SPELL_ENRAGE            = 78722,
 39    SPELL_FLAME_BREATH_10   = 74403,
 40    SPELL_FLAME_BREATH_25   = 74404,
 41    SPELL_FLAME_BEACON      = 74453
 42};
 43
 44enum eEvents
 45{
 46    EVENT_CAST_CONFLAGRATION      = 1,
 47    EVENT_CAST_ENRAGE             = 2,
 48    EVENT_CAST_FLAME_BREATH       = 3,
 49    EVENT_CAST_FLAME_BEACON       = 4,
 50    EVENT_CAST_CONFLAGRATION_FLY  = 5,
 51    EVENT_CAST_CONFLAGRATION_CAST = 6
 52};
 53
 54#define TARGETS_10 2
 55#define TARGETS_25 5
 56
 57class boss_ragefire : public CreatureScript
 58{
 59    public:
 60        boss_ragefire() : CreatureScript("boss_ragefire") { }
 61
 62        struct boss_ragefireAI : public BossAI
 63        {
 64            boss_ragefireAI(Creature *pCreature) : BossAI(pCreature, DATA_RAGEFIRE)
 65            {
 66                ASSERT(instance);
 67                me->SetUnitMovementFlags(MOVEMENTFLAG_CAN_FLY);
 68            }
 69
 70            void Reset()
 71            {
 72                instance->SetBossState(DATA_RAGEFIRE, NOT_STARTED);
 73                playerList.clear();
 74                bConflagration = false;
 75                events.Reset();
 76                events.ScheduleEvent(EVENT_CAST_CONFLAGRATION, urand(45000,55000));
 77                events.ScheduleEvent(EVENT_CAST_ENRAGE, urand(25000,35000));
 78                events.ScheduleEvent(EVENT_CAST_FLAME_BREATH, urand(10000,15000));
 79            }
 80
 81            void EnterCombat(Unit*)
 82            {
 83                instance->SetBossState(DATA_RAGEFIRE, IN_PROGRESS);
 84                DoScriptText(SAY_AGGRO, me);
 85            }
 86
 87            void KilledUnit(Unit* /*victim*/)
 88            {
 89                DoScriptText(RAND(SAY_SLAY1,SAY_SLAY2), me);
 90            }
 91
 92            void JustDied(Unit*)
 93            {
 94                _JustDied();
 95                DoScriptText(SAY_DEATH, me);
 96                instance->SetData(DATA_RAGEFIRE, DONE);
 97                instance->SetBossState(DATA_RAGEFIRE, DONE);
 98                if (instance->GetBossState(DATA_BALTHARUS)==DONE)
 99                {
100                   if (GameObject* flame = GetClosestGameObjectWithEntry(me, GO_FLAME_WALLS, 200.0f))
101                       flame->RemoveFromWorld();
102                }
103            }
104
105            void JustReachedHome()
106            {
107                instance->SetBossState(DATA_RAGEFIRE, FAIL);
108            }
109
110            void UpdateAI(const uint32 diff)
111            {
112                if (!UpdateVictim() || !CheckInRoom())
113                    return;
114
115                if (me->HasUnitState(UNIT_STAT_CASTING))
116                    return;
117
118                events.Update(diff);
119
120                if (!bConflagration)
121                {
122                    while (uint32 eventId = events.ExecuteEvent())
123                    {
124                        switch (eventId)
125                        {
126                            case EVENT_CAST_CONFLAGRATION:
127                                bConflagration = true;
128                                events.ScheduleEvent(EVENT_CAST_CONFLAGRATION_FLY, 1000);
129                                break;
130                            case EVENT_CAST_ENRAGE:
131                                DoCast(SPELL_ENRAGE);
132                                events.ScheduleEvent(EVENT_CAST_ENRAGE, urand(25000,35000));
133                                break;
134                            case EVENT_CAST_FLAME_BREATH:
135                                DoCast(RAID_MODE(SPELL_FLAME_BREATH_10,SPELL_FLAME_BREATH_25,SPELL_FLAME_BREATH_10,SPELL_FLAME_BREATH_25));
136                                events.ScheduleEvent(EVENT_CAST_FLAME_BREATH, urand(10000,15000));
137                                break;
138                        }
139                    }
140                }
141                else
142                {
143                    while (uint32 eventId = events.ExecuteEvent())
144                    {
145                        switch (eventId)
146                        {
147                            case EVENT_CAST_CONFLAGRATION_FLY:
148                                me->GetMotionMaster()->MovePoint(1, (float)3159.04, (float)676.08, (float)103.05);
149                                SelectTargetList(playerList, RAID_MODE(TARGETS_10,TARGETS_25,TARGETS_10,TARGETS_25), SELECT_TARGET_RANDOM, 0, true);
150                                for (std::list<Unit*>::const_iterator itr = playerList.begin(); itr != playerList.end(); ++itr)
151                                {
152                                    Unit *pTemp = (*itr);
153                                    me->CastSpell(pTemp, SPELL_FLAME_BEACON, true);
154                                }
155                                events.ScheduleEvent(EVENT_CAST_CONFLAGRATION_CAST, 5000);
156                                break;
157                            case EVENT_CAST_CONFLAGRATION_CAST:
158                                for (std::list<Unit*>::const_iterator itr = playerList.begin(); itr != playerList.end(); ++itr)
159                                {
160                                    Unit *pTemp = (*itr);
161                                    me->CastSpell(pTemp, SPELL_CONFLAGRATION, true);
162                                }
163                                playerList.clear();
164                                me->GetMotionMaster()->MoveTargetedHome();
165                                bConflagration = false;
166                                events.ScheduleEvent(EVENT_CAST_CONFLAGRATION, urand(45000,55000));
167                                break;
168                        }
169                    }
170                }
171
172                DoMeleeAttackIfReady();
173            }
174
175        private:
176            bool bConflagration;
177            std::list<Unit *> playerList;
178
179        };
180
181        CreatureAI* GetAI(Creature *pCreature) const
182        {
183            return new boss_ragefireAI(pCreature);
184        }
185
186};
187
188
189void AddSC_boss_ragefire()
190{
191    new boss_ragefire();
192}