Advertisement
Guest User

Netbus Script

a guest
Aug 28th, 2015
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.86 KB | None | 0 0
  1. #include "ScriptMgr.h"
  2. #include "ScriptedCreature.h"
  3. #include "SpellAuraEffects.h"
  4. #include "SpellScript.h"
  5.  
  6. enum Phases
  7. {
  8.     PHASE_ONE = 1,
  9.     PHASE_TWO = 2,
  10. };
  11.  
  12. enum Texts
  13. {
  14.     SAY_INTRO = 0,
  15.     SAY_AGGRO = 1,
  16.     SAY_KILL = 2,
  17.     SAY_DEATH = 3,
  18.     SAY_PHASE_TRANSITION = 4,
  19.     SAY_BERSERK = 5,
  20.     SAY_FEAR = 6,
  21.     SAY_RANDOM = 7,
  22.     SAY_CHAOS = 8,
  23. };
  24.  
  25. enum Spells
  26. {
  27.     SPELL_HOWL_OF_FEAR = 39048,
  28.     SPELL_CLEAVE = 31779,
  29.     SPELL_SHADOW_VOLLEY = 17228,
  30.     SPELL_BERSERK = 68378,
  31.     SPELL_CHAOS = 71904,
  32. };
  33.  
  34. enum Events
  35. {
  36.     EVENT_FEAR = 1,
  37.     EVENT_CLEAVE = 2,
  38.     EVENT_SHADOW_VOLLEY = 3,
  39.     EVENT_BERSERK = 4,
  40.     EVENT_RANDOM = 5,
  41.     EVENT_CHAOS = 6,
  42.     EVENT_FEL_FIRE = 7,
  43. };
  44.  
  45. class boss_netbus : public CreatureScript
  46. {
  47. public:
  48.     boss_netbus() : CreatureScript("boss_netbus") { }
  49.  
  50.     struct boss_netbusAI : public ScriptedAI
  51.     {
  52.         boss_netbusAI(Creature* creature) : ScriptedAI(creature), summons(me)
  53.         {
  54.         }
  55.  
  56.         void Reset() override
  57.         {
  58.             _events.Reset();
  59.             _events.ScheduleEvent(EVENT_CLEAVE, 15000, 0, 0);
  60.             _events.ScheduleEvent(EVENT_BERSERK, 360000, 0, 0);
  61.             _events.ScheduleEvent(EVENT_RANDOM, 60000, 0, 0);
  62.             _events.ScheduleEvent(EVENT_CHAOS, 50000, 0, PHASE_ONE);
  63.             _events.ScheduleEvent(EVENT_FEL_FIRE, 5000, 0, PHASE_ONE);
  64.  
  65.             summons.DespawnAll();
  66.         }
  67.  
  68.         void JustRespawned() override
  69.         {
  70.             Talk(SAY_INTRO);
  71.         }
  72.  
  73.         void EnterCombat(Unit* /*who*/) override
  74.         {
  75.             Talk(SAY_AGGRO);
  76.             _events.SetPhase(PHASE_ONE);
  77.         }
  78.  
  79.         void KilledUnit(Unit* victim) override
  80.         {
  81.             if (victim->GetTypeId() != TYPEID_PLAYER)
  82.                 return;
  83.  
  84.             Talk(SAY_KILL);
  85.         }
  86.  
  87.         void JustDied(Unit* victim) override
  88.         {
  89.             Talk(SAY_DEATH);
  90.             summons.DespawnAll();
  91.             ScriptedAI::JustDied(victim);
  92.         }
  93.  
  94.         void JustSummoned(Creature* summoned)
  95.         {
  96.             summons.Summon(summoned);
  97.  
  98.             if (Unit* bossTarget = me->SelectNearestPlayer())
  99.             {
  100.                 if (bossTarget && bossTarget->IsInWorld())
  101.                 {
  102.                     summoned->AddThreat(bossTarget, 100.0f);
  103.                     summoned->GetMotionMaster()->MoveChase(bossTarget, 300.0f);
  104.                 }
  105.             }
  106.         }
  107.  
  108.  
  109.         void UpdateAI(uint32 diff) override
  110.         {
  111.             // Return since we have no target
  112.             if (!UpdateVictim())
  113.                 return;
  114.  
  115.             _events.Update(diff);
  116.  
  117.             if (me->HasUnitState(UNIT_STATE_CASTING))
  118.                 return;
  119.  
  120.             if (_events.IsInPhase(PHASE_ONE) && HealthBelowPct(50))
  121.             {
  122.                 _events.SetPhase(PHASE_TWO);
  123.                 Talk(SAY_PHASE_TRANSITION);
  124.  
  125.                 _events.ScheduleEvent(EVENT_FEAR, urand(20000, 25000), 0, PHASE_TWO);
  126.                 _events.ScheduleEvent(EVENT_SHADOW_VOLLEY, urand(5000, 9000), 0, PHASE_TWO);
  127.             }
  128.  
  129.             while (uint32 eventId = _events.ExecuteEvent())
  130.             {
  131.                 switch (eventId)
  132.                 {
  133.                 case EVENT_FEAR:
  134.                     DoCastVictim(SPELL_HOWL_OF_FEAR);
  135.                     Talk(SAY_FEAR);
  136.                     _events.ScheduleEvent(EVENT_FEAR, urand(20000, 25000));
  137.                     break;
  138.  
  139.                 case EVENT_SHADOW_VOLLEY:
  140.                     DoCastVictim(SPELL_SHADOW_VOLLEY);
  141.                     _events.ScheduleEvent(EVENT_SHADOW_VOLLEY, urand(8000, 13000));
  142.                     break;
  143.  
  144.                 case EVENT_CLEAVE:
  145.                     DoCastVictim(SPELL_CLEAVE);
  146.                     _events.ScheduleEvent(EVENT_CLEAVE, urand(9000, 14000));
  147.                     break;
  148.  
  149.                 case EVENT_BERSERK:
  150.                     DoCast(me, SPELL_BERSERK);
  151.                     Talk(SAY_BERSERK);
  152.                     break;
  153.  
  154.                 case EVENT_RANDOM:
  155.                     Talk(SAY_RANDOM);
  156.                     _events.ScheduleEvent(EVENT_RANDOM, 40000);
  157.                     break;
  158.  
  159.                 case EVENT_CHAOS:
  160.                     Talk(SAY_CHAOS);
  161.                     DoCastVictim(SPELL_CHAOS);
  162.                     me->SummonCreature(100049, me->GetPositionX()+5.0f, me->GetPositionY(), me->GetPositionZ() + 3.0f, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
  163.                     me->SummonCreature(100049, me->GetPositionX()-5.0f, me->GetPositionY(), me->GetPositionZ() + 3.0f, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
  164.                     me->SummonCreature(100049, me->GetPositionX(), me->GetPositionY()+5.0f, me->GetPositionZ() + 3.0f, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
  165.                     me->SummonCreature(100049, me->GetPositionX(), me->GetPositionY()-5.0f, me->GetPositionZ() + 3.0f, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
  166.                     _events.ScheduleEvent(EVENT_CHAOS, 75000);
  167.                     break;
  168.  
  169.                 case EVENT_FEL_FIRE:
  170.                     for (uint64 i = 0; i < 5; i = i+1)
  171.                     {
  172.                         if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true))
  173.                             me->SummonGameObject(100050, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0);
  174.                     }
  175.                     me->SummonGameObject(100050, me->SelectNearestTarget()->GetPositionX(), me->SelectNearestTarget()->GetPositionY(), me->SelectNearestTarget()->GetPositionZ(), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 100);
  176.                     _events.ScheduleEvent(EVENT_FEL_FIRE, 20000);
  177.                     break;
  178.  
  179.                 default:
  180.                     break;
  181.                 }
  182.             }
  183.  
  184.             DoMeleeAttackIfReady();
  185.         }
  186.  
  187.     private:
  188.         EventMap _events;
  189.         SummonList summons;
  190.     };
  191.  
  192.     CreatureAI* GetAI(Creature* creature) const override
  193.     {
  194.         return new boss_netbusAI(creature);
  195.     }
  196. };
  197.  
  198. void AddSC_boss_netbus()
  199. {
  200.     new boss_netbus();
  201. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement