/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. #include "ScriptPCH.h"
  24. #include "ruby_sanctum.h"
  25. enum eScriptTexts
  26. {
  27. SAY_AGGRO = -1752022,
  28. SAY_SLAY1 = -1752023,
  29. SAY_SLAY2 = -1752024,
  30. SAY_DEATH = -1752025
  31. };
  32. enum eSpells
  33. {
  34. SPELL_CONFLAGRATION = 74456,
  35. SPELL_ENRAGE = 78722,
  36. SPELL_FLAME_BREATH_10 = 74403,
  37. SPELL_FLAME_BREATH_25 = 74404,
  38. SPELL_FLAME_BEACON = 74453
  39. };
  40. enum eEvents
  41. {
  42. EVENT_CAST_CONFLAGRATION = 1,
  43. EVENT_CAST_ENRAGE = 2,
  44. EVENT_CAST_FLAME_BREATH = 3,
  45. EVENT_CAST_FLAME_BEACON = 4,
  46. EVENT_CAST_CONFLAGRATION_FLY = 5,
  47. EVENT_CAST_CONFLAGRATION_CAST = 6
  48. };
  49. #define TARGETS_10 2
  50. #define TARGETS_25 5
  51. class boss_ragefire : public CreatureScript
  52. {
  53. public:
  54. boss_ragefire() : CreatureScript("boss_ragefire") { }
  55. struct boss_ragefireAI : public BossAI
  56. {
  57. boss_ragefireAI(Creature *pCreature) : BossAI(pCreature, DATA_RAGEFIRE)
  58. {
  59. ASSERT(instance);
  60. me->SetUnitMovementFlags(MOVEMENTFLAG_CAN_FLY);
  61. }
  62. void Reset()
  63. {
  64. instance->SetBossState(DATA_RAGEFIRE, NOT_STARTED);
  65. playerList.clear();
  66. bConflagration = false;
  67. events.Reset();
  68. events.ScheduleEvent(EVENT_CAST_CONFLAGRATION, urand(45000,55000));
  69. events.ScheduleEvent(EVENT_CAST_ENRAGE, urand(25000,35000));
  70. events.ScheduleEvent(EVENT_CAST_FLAME_BREATH, urand(10000,15000));
  71. }
  72. void EnterCombat(Unit*)
  73. {
  74. instance->SetBossState(DATA_RAGEFIRE, IN_PROGRESS);
  75. DoScriptText(SAY_AGGRO, me);
  76. }
  77. void KilledUnit(Unit* /*victim*/)
  78. {
  79. DoScriptText(RAND(SAY_SLAY1,SAY_SLAY2), me);
  80. }
  81. void JustDied(Unit*)
  82. {
  83. _JustDied();
  84. DoScriptText(SAY_DEATH, me);
  85. instance->SetData(DATA_RAGEFIRE, DONE);
  86. instance->SetBossState(DATA_RAGEFIRE, DONE);
  87. if (instance->GetBossState(DATA_BALTHARUS)==DONE)
  88. {
  89. if (GameObject* flame = GetClosestGameObjectWithEntry(me, GO_FLAME_WALLS, 200.0f))
  90. flame->RemoveFromWorld();
  91. }
  92. }
  93. void JustReachedHome()
  94. {
  95. instance->SetBossState(DATA_RAGEFIRE, FAIL);
  96. }
  97. void UpdateAI(const uint32 diff)
  98. {
  99. if (!UpdateVictim() || !CheckInRoom())
  100. return;
  101. if (me->HasUnitState(UNIT_STAT_CASTING))
  102. return;
  103. events.Update(diff);
  104. if (!bConflagration)
  105. {
  106. while (uint32 eventId = events.ExecuteEvent())
  107. {
  108. switch (eventId)
  109. {
  110. case EVENT_CAST_CONFLAGRATION:
  111. bConflagration = true;
  112. events.ScheduleEvent(EVENT_CAST_CONFLAGRATION_FLY, 1000);
  113. break;
  114. case EVENT_CAST_ENRAGE:
  115. DoCast(SPELL_ENRAGE);
  116. events.ScheduleEvent(EVENT_CAST_ENRAGE, urand(25000,35000));
  117. break;
  118. case EVENT_CAST_FLAME_BREATH:
  119. DoCast(RAID_MODE(SPELL_FLAME_BREATH_10,SPELL_FLAME_BREATH_25,SPELL_FLAME_BREATH_10,SPELL_FLAME_BREATH_25));
  120. events.ScheduleEvent(EVENT_CAST_FLAME_BREATH, urand(10000,15000));
  121. break;
  122. }
  123. }
  124. }
  125. else
  126. {
  127. while (uint32 eventId = events.ExecuteEvent())
  128. {
  129. switch (eventId)
  130. {
  131. case EVENT_CAST_CONFLAGRATION_FLY:
  132. me->GetMotionMaster()->MovePoint(1, (float)3159.04, (float)676.08, (float)103.05);
  133. SelectTargetList(playerList, RAID_MODE(TARGETS_10,TARGETS_25,TARGETS_10,TARGETS_25), SELECT_TARGET_RANDOM, 0, true);
  134. for (std::list<Unit*>::const_iterator itr = playerList.begin(); itr != playerList.end(); ++itr)
  135. {
  136. Unit *pTemp = (*itr);
  137. me->CastSpell(pTemp, SPELL_FLAME_BEACON, true);
  138. }
  139. events.ScheduleEvent(EVENT_CAST_CONFLAGRATION_CAST, 5000);
  140. break;
  141. case EVENT_CAST_CONFLAGRATION_CAST:
  142. for (std::list<Unit*>::const_iterator itr = playerList.begin(); itr != playerList.end(); ++itr)
  143. {
  144. Unit *pTemp = (*itr);
  145. me->CastSpell(pTemp, SPELL_CONFLAGRATION, true);
  146. }
  147. playerList.clear();
  148. me->GetMotionMaster()->MoveTargetedHome();
  149. bConflagration = false;
  150. events.ScheduleEvent(EVENT_CAST_CONFLAGRATION, urand(45000,55000));
  151. break;
  152. }
  153. }
  154. }
  155. DoMeleeAttackIfReady();
  156. }
  157. private:
  158. bool bConflagration;
  159. std::list<Unit *> playerList;
  160. };
  161. CreatureAI* GetAI(Creature *pCreature) const
  162. {
  163. return new boss_ragefireAI(pCreature);
  164. }
  165. };
  166. void AddSC_boss_ragefire()
  167. {
  168. new boss_ragefire();
  169. }