Advertisement
Guest User

Untitled

a guest
Apr 1st, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 13.69 KB | None | 0 0
  1. #include "ScriptMgr.h"
  2. #include "ScriptedCreature.h"
  3. #include "molten_core.h"
  4.  
  5. enum Texts
  6. {
  7.     SAY_SUMMON_MAJ              = 0,
  8.     SAY_ARRIVAL1_RAG            = 1,
  9.     SAY_ARRIVAL2_MAJ            = 2,
  10.     SAY_ARRIVAL3_RAG            = 3,
  11.     SAY_ARRIVAL5_RAG            = 4,
  12.     SAY_REINFORCEMENTS1         = 5,
  13.     SAY_REINFORCEMENTS2         = 6,
  14.     SAY_HAND                    = 7,
  15.     SAY_WRATH                   = 8,
  16.     SAY_KILL                    = 9,
  17.     SAY_MAGMABURST              = 10
  18. };
  19.  
  20. enum Spells
  21. {
  22.     SPELL_HAND_OF_RAGNAROS      = 19780,
  23.     SPELL_WRATH_OF_RAGNAROS     = 20566,
  24.     SPELL_LAVA_BURST            = 21158,
  25.     SPELL_MAGMA_BLAST           = 20565,                   // Ranged attack
  26.     SPELL_SONS_OF_FLAME_DUMMY   = 21108,                   // Server side effect
  27.     SPELL_RAGSUBMERGE           = 21107,                   // Stealth aura
  28.     SPELL_RAGEMERGE             = 20568,
  29.     SPELL_MELT_WEAPON           = 21388,
  30.     SPELL_ELEMENTAL_FIRE        = 20564,
  31.     SPELL_ERRUPTION             = 17731
  32. };
  33.  
  34. enum Events
  35. {
  36.     EVENT_ERUPTION              = 1,
  37.     EVENT_WRATH_OF_RAGNAROS     = 2,
  38.     EVENT_HAND_OF_RAGNAROS      = 3,
  39.     EVENT_LAVA_BURST            = 4,
  40.     EVENT_ELEMENTAL_FIRE        = 5,
  41.     EVENT_MAGMA_BLAST           = 6,
  42.     EVENT_SUBMERGE              = 7,
  43.  
  44.     EVENT_INTRO_1               = 8,
  45.     EVENT_INTRO_2               = 9,
  46.     EVENT_INTRO_3               = 10,
  47.     EVENT_INTRO_4               = 11,
  48.     EVENT_INTRO_5               = 12
  49. };
  50.  
  51. class boss_ragnaros : public CreatureScript
  52. {
  53.     public:
  54.         boss_ragnaros() : CreatureScript("boss_ragnaros") { }
  55.  
  56.         struct boss_ragnarosAI : public BossAI
  57.         {
  58.             boss_ragnarosAI(Creature* creature) : BossAI(creature, BOSS_RAGNAROS)
  59.             {
  60.                 _introState = 0;
  61.                 me->SetReactState(REACT_PASSIVE);
  62.                 me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
  63.             }
  64.  
  65.             void Reset()
  66.             {
  67.                 BossAI::Reset();
  68.                 _emergeTimer = 90000;
  69.                 _hasYelledMagmaBurst = false;
  70.                 _hasSubmergedOnce = false;
  71.                 _isBanished = false;
  72.                 me->SetUInt32Value(UNIT_NPC_EMOTESTATE, 0);
  73.             }
  74.  
  75.             void EnterCombat(Unit* victim)
  76.             {
  77.                 BossAI::EnterCombat(victim);
  78.                 events.ScheduleEvent(EVENT_ERUPTION, 15000);
  79.                 events.ScheduleEvent(EVENT_WRATH_OF_RAGNAROS, 30000);
  80.                 events.ScheduleEvent(EVENT_HAND_OF_RAGNAROS, 25000);
  81.                 events.ScheduleEvent(EVENT_LAVA_BURST, 10000);
  82.                 events.ScheduleEvent(EVENT_ELEMENTAL_FIRE, 3000);
  83.                 events.ScheduleEvent(EVENT_MAGMA_BLAST, 2000);
  84.                 events.ScheduleEvent(EVENT_SUBMERGE, 180000);
  85.             }
  86.  
  87.             void KilledUnit(Unit* /*victim*/)
  88.             {
  89.                 if (urand(0, 99) < 25)
  90.                     Talk(SAY_KILL);
  91.             }
  92.  
  93.             void UpdateAI(const uint32 diff)
  94.             {
  95.                 if (_introState != 2)
  96.                 {
  97.                     if (!_introState)
  98.                     {
  99.                         me->HandleEmoteCommand(EMOTE_ONESHOT_EMERGE);
  100.                         events.ScheduleEvent(EVENT_INTRO_1, 4000);
  101.                         events.ScheduleEvent(EVENT_INTRO_2, 23000);
  102.                         events.ScheduleEvent(EVENT_INTRO_3, 42000);
  103.                         events.ScheduleEvent(EVENT_INTRO_4, 43000);
  104.                         events.ScheduleEvent(EVENT_INTRO_5, 53000);
  105.                         _introState = 1;
  106.                     }
  107.  
  108.                     events.Update(diff);
  109.  
  110.                     while (uint32 eventId = events.ExecuteEvent())
  111.                     {
  112.                         switch (eventId)
  113.                         {
  114.                         case EVENT_INTRO_1:
  115.                             Talk(SAY_ARRIVAL1_RAG);
  116.                             break;
  117.                         case EVENT_INTRO_2:
  118.                             Talk(SAY_ARRIVAL3_RAG);
  119.                             break;
  120.                         case EVENT_INTRO_3:
  121.                             me->HandleEmoteCommand(EMOTE_ONESHOT_ATTACK1H);
  122.                             break;
  123.                         case EVENT_INTRO_4:
  124.                             Talk(SAY_ARRIVAL5_RAG);
  125.                             if (instance)
  126.                                 if (Creature* executus = Unit::GetCreature(*me, instance->GetData64(BOSS_MAJORDOMO_EXECUTUS)))
  127.                                     me->Kill(executus);
  128.                             break;
  129.                         case EVENT_INTRO_5:
  130.                             me->SetReactState(REACT_AGGRESSIVE);
  131.                             me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
  132.                             _introState = 2;
  133.                             break;
  134.                         default:
  135.                             break;
  136.                         }
  137.                     }
  138.                 }
  139.                 else
  140.                 {
  141.                     if (instance)
  142.                     {
  143.                         if (_isBanished && ((_emergeTimer <= diff) || (instance->GetData(DATA_RAGNAROS_ADDS)) > 8))
  144.                         {
  145.                             //Become unbanished again
  146.                             me->SetReactState(REACT_AGGRESSIVE);
  147.                             me->setFaction(14);
  148.                             me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
  149.                             me->SetUInt32Value(UNIT_NPC_EMOTESTATE, 0);
  150.                             me->HandleEmoteCommand(EMOTE_ONESHOT_EMERGE);
  151.                             if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
  152.                                 AttackStart(target);
  153.                             instance->SetData(DATA_RAGNAROS_ADDS, 0);
  154.  
  155.                             //DoCast(me, SPELL_RAGEMERGE); //"phase spells" didnt worked correctly so Ive commented them and wrote solution witch doesnt need core support
  156.                             _isBanished = false;
  157.                         }
  158.                         else if (_isBanished)
  159.                         {
  160.                             _emergeTimer -= diff;
  161.                             //Do nothing while banished
  162.                             return;
  163.                         }
  164.                     }
  165.  
  166.                     //Return since we have no target
  167.                     if (!UpdateVictim())
  168.                         return;
  169.  
  170.                     events.Update(diff);
  171.  
  172.                     while (uint32 eventId = events.ExecuteEvent())
  173.                     {
  174.                         switch (eventId)
  175.                         {
  176.                             case EVENT_ERUPTION:
  177.                                 DoCastVictim(SPELL_ERRUPTION);
  178.                                 events.ScheduleEvent(EVENT_ERUPTION, urand(20000, 45000));
  179.                                 break;
  180.                             case EVENT_WRATH_OF_RAGNAROS:
  181.                                 DoCastVictim(SPELL_WRATH_OF_RAGNAROS);
  182.                                 if (urand(0, 1))
  183.                                     Talk(SAY_WRATH);
  184.                                 events.ScheduleEvent(EVENT_WRATH_OF_RAGNAROS, 25000);
  185.                                 break;
  186.                             case EVENT_HAND_OF_RAGNAROS:
  187.                                 DoCast(me, SPELL_HAND_OF_RAGNAROS);
  188.                                 if (urand(0, 1))
  189.                                     Talk(SAY_HAND);
  190.                                 events.ScheduleEvent(EVENT_HAND_OF_RAGNAROS, 20000);
  191.                                 break;
  192.                             case EVENT_LAVA_BURST:
  193.                                 DoCastVictim(SPELL_LAVA_BURST);
  194.                                 events.ScheduleEvent(EVENT_LAVA_BURST, 10000);
  195.                                 break;
  196.                             case EVENT_ELEMENTAL_FIRE:
  197.                                 DoCastVictim(SPELL_ELEMENTAL_FIRE);
  198.                                 events.ScheduleEvent(EVENT_ELEMENTAL_FIRE, urand(10000, 14000));
  199.                                 break;
  200.                             case EVENT_MAGMA_BLAST:
  201.                                 if (me->IsWithinMeleeRange(me->GetVictim()))
  202.                                 {
  203.                                     DoCastVictim(SPELL_MAGMA_BLAST);
  204.                                     if (!_hasYelledMagmaBurst)
  205.                                     {
  206.                                         //Say our dialog
  207.                                         Talk(SAY_MAGMABURST);
  208.                                         _hasYelledMagmaBurst = true;
  209.                                     }
  210.                                 }
  211.                                 events.ScheduleEvent(EVENT_MAGMA_BLAST, 2500);
  212.                                 break;
  213.                             case EVENT_SUBMERGE:
  214.                             {
  215.                                 if (instance && !_isBanished)
  216.                                 {
  217.                                     //Creature spawning and ragnaros becomming unattackable
  218.                                     //is not very well supported in the core //no it really isnt
  219.                                     //so added normaly spawning and banish workaround and attack again after 90 secs.
  220.                                     me->AttackStop();
  221.                                     DoResetThreat();
  222.                                     me->SetReactState(REACT_PASSIVE);
  223.                                     me->InterruptNonMeleeSpells(false);
  224.                                     //Root self
  225.                                     //DoCast(me, 23973);
  226.                                     me->setFaction(35);
  227.                                     me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
  228.                                     me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_SUBMERGED);
  229.                                     me->HandleEmoteCommand(EMOTE_ONESHOT_SUBMERGE);
  230.                                     instance->SetData(DATA_RAGNAROS_ADDS, 0);
  231.  
  232.                                     if (!_hasSubmergedOnce)
  233.                                     {
  234.                                         Talk(SAY_REINFORCEMENTS1);
  235.  
  236.                                         // summon 8 elementals
  237.                                         for (uint8 i = 0; i < 8; ++i)
  238.                                             if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
  239.                                                 if (Creature* summoned = me->SummonCreature(12143, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0.0f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 900000))
  240.                                                     summoned->AI()->AttackStart(target);
  241.  
  242.                                         _hasSubmergedOnce = true;
  243.                                         _isBanished = true;
  244.                                         //DoCast(me, SPELL_RAGSUBMERGE);
  245.                                         _emergeTimer = 90000;
  246.  
  247.                                     }
  248.                                     else
  249.                                     {
  250.                                         Talk(SAY_REINFORCEMENTS2);
  251.  
  252.                                         for (uint8 i = 0; i < 8; ++i)
  253.                                             if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
  254.                                                 if (Creature* summoned = me->SummonCreature(12143, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0.0f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 900000))
  255.                                                     summoned->AI()->AttackStart(target);
  256.  
  257.                                         _isBanished = true;
  258.                                         //DoCast(me, SPELL_RAGSUBMERGE);
  259.                                         _emergeTimer = 90000;
  260.                                     }
  261.                                 }
  262.                                 events.ScheduleEvent(EVENT_SUBMERGE, 180000);
  263.                                 break;
  264.                             }
  265.                             default:
  266.                                 break;
  267.                         }
  268.                     }
  269.  
  270.                     DoMeleeAttackIfReady();
  271.                 }
  272.             }
  273.  
  274.         private:
  275.             uint32 _emergeTimer;
  276.             uint8 _introState;
  277.             bool _hasYelledMagmaBurst;
  278.             bool _hasSubmergedOnce;
  279.             bool _isBanished;
  280.         };
  281.  
  282.         CreatureAI* GetAI(Creature* creature) const
  283.         {
  284.             return new boss_ragnarosAI(creature);
  285.         }
  286. };
  287.  
  288. class mob_son_of_flame : public CreatureScript
  289. {
  290.     public:
  291.         mob_son_of_flame() : CreatureScript("mob_SonOfFlame") { }
  292.  
  293.         struct mob_son_of_flameAI : public ScriptedAI //didnt work correctly in EAI for me...
  294.         {
  295.             mob_son_of_flameAI(Creature* creature) : ScriptedAI(creature)
  296.             {
  297.                 instance = me->GetInstanceScript();
  298.             }
  299.  
  300.             void JustDied(Unit* /*killer*/)
  301.             {
  302.                 if (instance)
  303.                     instance->SetData(DATA_RAGNAROS_ADDS, 1);
  304.             }
  305.  
  306.             void UpdateAI(const uint32 /*diff*/)
  307.             {
  308.                 if (!UpdateVictim())
  309.                     return;
  310.  
  311.                 DoMeleeAttackIfReady();
  312.             }
  313.  
  314.         private:
  315.             InstanceScript* instance;
  316.         };
  317.  
  318.         CreatureAI* GetAI(Creature* creature) const
  319.         {
  320.             return new mob_son_of_flameAI(creature);
  321.         }
  322. };
  323.  
  324. void AddSC_boss_ragnaros()
  325. {
  326.     new boss_ragnaros();
  327.     new mob_son_of_flame();
  328. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement