Advertisement
Emulation

Untitled

Sep 21st, 2013
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.75 KB | None | 0 0
  1. #include "ScriptMgr.h"
  2. #include "ScriptedCreature.h"
  3. #include "SpellScripts.h"
  4. #include "SpellAuraEffects.h"
  5.  
  6. enum Spells
  7. {
  8.   SPELL_ARCANE_MISSILES               = 33031,
  9.     SPELL_WRATH_OF_THE_ASTROMANCER      = 42783,
  10.     SPELL_WRATH_OF_THE_ASTROMANCER_DOT  = 42784,
  11.     SPELL_BLINDING_LIGHT                = 33009,
  12.         SPELL_DRAIN_MANA                        = 25671,
  13.  
  14.         SPELL_SPOTLIGHT                     = 25824,
  15.     NPC_SPOTLIGHT  = 18928,
  16. };
  17.  
  18. const float CENTER_X                    = 297.673f;
  19. const float CENTER_Y                    = 11.665f;
  20. const float CENTER_Z                    = 25.386f;
  21. const float CENTER_O                    = 2.991229f;
  22. const float SMALL_PORTAL_RADIUS         = 10.0f;
  23. const float LARGE_PORTAL_RADIUS         = 20.0f;
  24. const float PORTAL_Z                    = 24.986f;
  25.  
  26. class Astro_Boss : public CreatureScript
  27. {
  28.     public:
  29.         Astro_Boss() : CreatureScript("Astro_Boss") { }
  30.        
  31.         struct Astro_BossAI : public ScriptedAI
  32. {
  33.     Astro_BossAI(Creature* creature) : ScriptedAI
  34.    
  35. (creature), Summons(me) {}
  36.  
  37. SummonList Summons;
  38.  
  39. uint8 Phase;
  40.  
  41.             uint32 arcanemissiletimer;
  42.             uint32 m_uiWrathOfTheAstromancer_Timer;
  43.             uint32 BlindingLight_Timer;
  44.             uint32 Phase1_Timer;
  45.             uint32 Phase2_Timer;
  46.             uint32 Phase3_Timer;
  47.             uint32 AppearDelay_Timer;
  48.             uint32 Wrath_Timer;
  49.             uint32 Drain_Mana;
  50.            
  51. float defaultsize;
  52. float Portals[3][3];
  53.  
  54. bool AppearDelay;
  55. bool BlindingLight;
  56.  
  57. void Reset()
  58. {
  59. arcanemissiletimer = 2000;
  60.                 m_uiWrathOfTheAstromancer_Timer = 15000;
  61.                 BlindingLight_Timer = 41000;
  62.                 Phase1_Timer = 50000;
  63.                 Phase2_Timer = 10000;
  64.                 Phase3_Timer = 15000;
  65.                 AppearDelay_Timer = 2000;
  66.                                 Drain_Mana = 31000;
  67.                 BlindingLight = false;
  68.                 AppearDelay = false;
  69.                 Wrath_Timer = 20000+rand()%5000;//twice in phase one
  70.                 Phase = 1;
  71.                
  72. me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
  73. me->SetVisible(true);
  74.  
  75. Summons.DespawnAll();
  76. }
  77.  
  78. void EnterCombat(Unit* /*who*/)
  79. {
  80.     DoZoneInCombat();
  81. }
  82.  
  83. void SummonMinion(uint32 entry, float x, float y, float z)
  84. {
  85.     Creature* Summoned = me->SummonCreature(entry, x, y, z, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
  86.     if(Summoned)
  87.     {
  88.         if(Unit* target = SelectTarger(SELECT_TARGET_RANDOM, 0))
  89.             Summoned->AI()->AttackStart(target);
  90.            
  91.             Summons.Summon(Summoned);
  92.             }
  93.     }
  94.    
  95.     float Portal_X(float radius)
  96.     {
  97.         if(urand(0, 1))
  98.             radius = -radius;
  99.            
  100.             return radius * (float)(rand()%100)/100.0f + CENTER_X;
  101.     }
  102.    
  103.     float Portal_Y(float x, float radius)
  104.     {
  105.         float z = RAND(1.0f, -1.0f);
  106.        
  107.         return (z*sqrt(radius*radius - (x - CENTER_X)*(X - CENTER_X)) + (CENTER_Y);
  108.     }
  109.    
  110.     void UpdateAI(uint32 diff)
  111.     {
  112.         if(!UpdateVictim())
  113.             return;
  114.         if(AppearDelay)
  115.         {
  116.             me->StopMoving();
  117.             me->AttackStop();
  118.             if(AppearDelay_Timer <= diff)
  119.             {
  120.                 AppearDelay = false;
  121.                 if(Phase == 2)
  122.                 {
  123.                     me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
  124.                     me->SetVisible(false);
  125.                 }
  126.                 AppearDelay_Timer = 2000;
  127.             }
  128.             else
  129.                 AppearDelay_Timer -= diff;
  130.             }
  131.             if(Phase == 1)
  132.             {
  133.            
  134.                 if(Drain_Mana <= diff)
  135.                 {
  136.                 std::list<Unit*> targetList;
  137.                
  138.                 const std::list<HostileReference*>& threatlist = me->getThreatManager().getThreatList();
  139.                     for (std::list<HostileReference*>::const_iterator
  140.                     itr = threatlist.begin(); itr != threatlist.end(); ++itr)
  141.                         if(((*itr)->getTarget()->GetTypeId() == TYPEID_PLAYER && (*itr)->getTarget->getPowerType() == POWER_MANA)
  142.                             targetList.push_back((*itr)->getTarget());
  143.                            
  144.                     }
  145.                    
  146.        
  147. Trinity::Containers::RandomResizeList(targetList, 5);
  148.  
  149. for(std::list<Unit*>::iterator itr = targetList.begin(); itr != targetList.end(); ++itr)
  150.     DoCast(*itr, SPELL_DRAIN_MANA);
  151.     Drain_Mana = 11000;
  152. }
  153. else
  154. Drain_Mana -= diff;
  155.  
  156. if(Wrath_Timer <= diff)
  157. {
  158. me->InterruptNonMeleeSpells(false);
  159. if(Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, 100, true))
  160.         DoCast(target, SPELL_WRATH_OF_THE_ASTROMANCER, true);
  161.         Wrath_Timer = 20000+rand()%5000;
  162.     }
  163.     else
  164.         Wrath_Timer -= diff;
  165.        
  166. if(arcanemissiletimer <= diff)
  167. {
  168.     if(BlindingLight)
  169. {
  170.     DoCastVictim(SPELL_BLINDING_LIGHT);
  171.     BlindingLight = false;
  172. }
  173. else
  174. {
  175.     if(Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
  176.         {
  177.             if(!me->HasInArc(2.5f, target))
  178.                 target = me->GetVictim();
  179.                
  180.             DoCast(target, SPELL_ARCANE_MISSILES);
  181.         }
  182.     }
  183.     arcanemissiletimer = 3000;
  184. }
  185. else
  186.     arcanemissiletimer -= diff;
  187.    
  188.     if(m_uiWrathOfTheAstromancer_Timer <= diff)
  189. {
  190.     me->InterruptNonMeleeSpells(false);
  191.    
  192.     if(Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1))
  193.     {
  194.         if(target->GetTypeId() == TYPEID_PLAYER)
  195.         {
  196.             DoCast(target, SPELL_WRATH_OF_THE_ASTROMANCER);
  197.             m_uiWrathOfTheAstromancer_Timer = 25000;
  198.         }
  199.         else
  200.             m_uiWrathOfTheAstromancer_Timer = 1000;
  201.         }
  202.     }
  203.     else
  204.     m_uiWrathOfTheAstromancer_Timer -= diff;
  205.    
  206. if(Phase1_Timer <= diff)
  207. {
  208.     Phase = 2;
  209.     Phase1_Timer = 50000;
  210.     me->GetMotionMaster()->Clear();
  211.     me->SetPosition(CENTER_X, CENTER_Y, CENTER_Z, CENTER_O_;
  212.     for(uint8 i=0; i <= 2; ++i)
  213.     {
  214.         if(!i)
  215.         {
  216.             Portals[i][0] = Portal_X(SMALL_PORTAL_RADIUS);
  217.             Portals[i][1] = Portal_Y(Portals[i][0], SMALL_PORTAL_RADIUS);
  218.            
  219.             Portals[i][2] = PORTAL_Z;
  220.            
  221.         }
  222.     }
  223.     if((abs(Portals[2][0] - Portals[1][0]) < 7) && (abs(Portals[2][1] - Portals[1][1]) < 7))
  224.     {
  225.         for i=1;
  226.         if(abs(CENTER_X + 26.0f - Portals[2][0]) < 7)
  227.             i = -1;
  228.             Portals[2][0] = Portals[2][0]+7*i;
  229.             Portals[2][1] = Portal_Y(Portals[2][0], LARGE_PORTAL_RADIUS);
  230.     }
  231.     for (int i = 0; i <= 2; ++i)
  232.     {
  233.        if (Creature* Summoned = me->SummonCreature(NPC_SPOTLIGHT, Portals[i][0], Portals[i][1], Portals[i][2], CENTER_O,
  234.  TEMPSUMMON_TIMED_DESPAWN, Phase2_Timer+Phase3_Timer+AppearDelay_Timer+1700))
  235.  {
  236.     Summon->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
  237.         Summoned->CastSpell(Summoned, SPELL_SPOTLIGHT, false)
  238.     }
  239. }
  240. AppearDelay = true;
  241. }
  242. else
  243.     Phase1_Timer -= diff;
  244. }
  245. else
  246.     if(Phase == 2)
  247.     {
  248.    
  249.     me->AttackStop();
  250.     me->StopMoving();
  251.     if(Phase2_Timer <= diff)
  252.     {
  253.         Phase = 3;
  254.         for(int i=0; i <= 2; ++i)
  255.             for(int j=1; j <= 4; j++)
  256.                 SummonMinion(15527, Portals[i][0], Portals[i][1], Portals[i][2]);
  257.                     Phase2_Timer = 10000;
  258.                 }
  259.                 else
  260.                     Phase2_Timer -= diff;
  261.         }
  262.         if(Phase == 3)
  263.         {
  264.             me->AttackStop();
  265.             me->StopMoving();
  266.            
  267.             if(Phase3_Timer <= diff)
  268.             {
  269.                 Phase = 1;
  270.                 int i = rand()%3;
  271.                 me->GetMotionMaster()->Clear();
  272.                 me->SetPosition(Portals[i][0], Portals[i][1], Portals[i][2], CENTER_O);
  273.                
  274.                     for(int j=0; j <= 2; j++)
  275.                         if(j != i)
  276.                             SummonMinion(15527, Portals[j][0], Portals[j][1], Portals[j][2]);
  277.                             me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
  278.                         me->SetVisible(true);
  279.                        
  280.                         AppearDelay = true;
  281.                         Phase3_Timer = 15000;
  282.                 }
  283.                 else
  284.                     Phase3_Timer -= diff;
  285.                 }
  286.                
  287.                 DoMeleeAttackIfReady();
  288.         }
  289.     };
  290.    
  291.     class Mana_Fiend : public CreatureScript
  292.     {
  293.     public:
  294.         Mana_Fiend() : CreatureScript("Mana_Fiend") {}
  295.        
  296.         struct Mana_FiendAI(Creature* creature) : ScriptedAI(creature) {}
  297.        
  298.         uint32 silenceTimer;
  299.        
  300.         void Reset()
  301.         {
  302.             silenceTimer = 15000;
  303.         }
  304.        
  305.         void JustDied(Unit* /*killer*/)
  306.         {
  307.             DoCastAOE(25672);
  308.         }
  309.        
  310.         void UpdateAI(uint32 diff)
  311.         {
  312.             if(!UpdateVictim())
  313.                 return;
  314.                
  315.         if(silenceTimer <= diff)
  316.         {
  317.             DoCastVictim(15122);
  318.             silenceTimer = 12000;
  319.         }
  320.         else
  321.             silenceTimer -= diff;
  322.            
  323.         DoMeleeAttackIfReady();
  324. }
  325. };
  326.  
  327. CreatureAI* GetAI(Creature* creature) const
  328. {
  329.     return new Mana_FiendAI(creature);
  330. }
  331. };
  332.  
  333. void AddSC_Astro_Boss()
  334. {
  335.     new Astro_Boxx();
  336.     new Mana_Fiend();
  337. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement