MichaelCrow

Untitled

Jul 12th, 2018
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 9.65 KB | None | 0 0
  1. #include "ScriptPCH.h"
  2. #include "CreatureAI.h"
  3. #include "ObjectAccessor.h"
  4. #include "Player.h"
  5.  
  6. class npc_cultist_boss : public CreatureScript
  7. {
  8. public: npc_cultist_boss() : CreatureScript("npc_cultist_boss") {}
  9.  
  10.         struct npc_cultist_bossAI : public ScriptedAI
  11.         {
  12.             npc_cultist_bossAI(Creature * c) : ScriptedAI(c), summons(me) { }
  13.  
  14.             bool checkStart = false;
  15.             uint32 loadTimer;
  16.             uint32 MainRandomVisuals;
  17.             uint32 MainShadowCleave;
  18.             uint32 MainTimeFreeze;
  19.             uint32 Growandstuff;
  20.             uint32 CheckForPhase2Main;
  21.             uint32 MainEndVisualFinal;
  22.             uint32 MainEndVisual;
  23.             uint32 BringItOnMainBoss;
  24.             uint32 MainDisorient;
  25.             uint32 MainShroudGuys;
  26.             uint32 MainDeathGrip;
  27.             uint32 CheckForNextMainPhase;
  28.             uint8 phase;
  29.             bool cancast;
  30.             bool canLoad;
  31.  
  32.             void Reset() override
  33.             {
  34.                 summons.DespawnAll();
  35.                 me->SetImmuneToPC(true);
  36.                 me->SetReactState(REACT_PASSIVE);
  37.                 me->CastSpell(me, 70358);
  38.                 checkStart = false;
  39.                 canLoad = false;
  40.                 phase = 1;
  41.  
  42.                 MainRandomVisuals = 7500;
  43.                 MainShadowCleave = 7000;
  44.                 MainTimeFreeze = 8000;
  45.                 Growandstuff = 10000;
  46.                 CheckForPhase2Main = 2000;
  47.                 loadTimer = 3000;
  48.                 me->SetObjectScale(1.0f);
  49.  
  50.             }
  51.  
  52.             void JustSummoned(Creature * summoned) override
  53.             {
  54.                 summons.Summon(summoned);
  55.             }
  56.  
  57.             void MovementInform(uint32 type, uint32 id) override
  58.             {
  59.                 if (type == POINT_MOTION_TYPE)
  60.                 {
  61.                     switch (id)
  62.                     {
  63.                     case 1:
  64.                         me->SetDisableGravity(true);
  65.                         break;
  66.                     case 2:
  67.                         me->SetDisableGravity(false);
  68.                         break;
  69.                     }
  70.                 }
  71.             }
  72.  
  73.             void MoveInLineOfSight(Unit * player)
  74.             {
  75.                 if (!checkStart)
  76.                 {
  77.                     if (!player || player->isDead() || player->GetTypeId() != TYPEID_PLAYER)
  78.                         return;
  79.  
  80.                     if (me->IsWithinDistInMap(player, 20.0f))
  81.                     {
  82.                         if (me->GetDistance(player) <= 20.0f)
  83.                         {
  84.                             corpseexplode = me->FindNearestCreature(5710, 30.0f, true);
  85.  
  86.                             me->CastStop();
  87.                             me->Talk("Life energy, to consume...", CHAT_MSG_SAY, LANG_UNIVERSAL, 80.0f, me);
  88.                             me->PlayDirectSound(11250, nullptr);
  89.                             DoCastSelf(60427);
  90.                             DoCastSelf(39947);
  91.                             DoCastSelf(51126);
  92.                             me->SetReactState(REACT_AGGRESSIVE);
  93.                             me->SetImmuneToPC(false);
  94.                             me->GetMotionMaster()->MoveChase(player);
  95.                             me->SetInCombatWith(player);
  96.  
  97.                             Position const coords = { corpseexplode->GetPositionX(), corpseexplode->GetPositionY(), corpseexplode->GetPositionZ() + 4.0f, corpseexplode->GetOrientation() };
  98.                             me->CastSpell(corpseexplode, 70572);
  99.                             corpseexplode->Talk("NONONONO WAI-GHHHHHHHH.", CHAT_MSG_YELL, LANG_UNIVERSAL, 80.0f, corpseexplode);
  100.                             corpseexplode->GetMotionMaster()->MoveTakeoff(1, coords);
  101.                             corpseexplode->SetImmuneToPC(true);
  102.                             corpseexplode->SetReactState(REACT_PASSIVE);
  103.                             corpseexplode->AddAura(70569, corpseexplode);
  104.  
  105.  
  106.                            
  107.                             checkStart = true;
  108.                             canLoad = true;
  109.                         }
  110.                     }
  111.                 }
  112.             }
  113.  
  114.             void EnterCombat(Unit * /* who */)
  115.             {
  116.                
  117.             }
  118.  
  119.             void JustDied(Unit* /*killer*/) override
  120.             {
  121.                 me->Talk("No more life...", CHAT_MSG_SAY, LANG_UNIVERSAL, 80.0f, me);
  122.                 me->PlayDirectSound(11252, nullptr);
  123.             }
  124.  
  125.             void UpdateAI(uint32 diff)
  126.             {
  127.                 if (!UpdateVictim())
  128.                     return;
  129.  
  130.                 if (loadTimer <= diff && canLoad)
  131.                 {
  132.                    
  133.                     corpseexplode = me->FindNearestCreature(5710, 30.0f, true);
  134.                     corpseexplode->CastSpell(corpseexplode, 49218);
  135.                     corpseexplode->CastSpell(corpseexplode, 30687);
  136.                     corpseexplode->DisappearAndDie();
  137.                     canLoad = false;
  138.                 }
  139.                 else
  140.                     loadTimer -= diff;
  141.  
  142.  
  143.                     if (Growandstuff <= diff)
  144.                     {
  145.                         if (cancast)
  146.                         {
  147.                             DoCast(72679);
  148.                             if (urand(0, 1) == 1)
  149.                             {
  150.                                 me->Talk("Darkness consumes all.", CHAT_MSG_SAY, LANG_UNIVERSAL, 80.0f, me);
  151.                                 me->PlayDirectSound(11254, nullptr);
  152.                             }
  153.                             else
  154.                             {
  155.                                 me->Talk("The shadow will engulf you.", CHAT_MSG_SAY, LANG_UNIVERSAL, 80.0f, me);
  156.                                 me->PlayDirectSound(11253, nullptr);
  157.                             }
  158.                         }
  159.                     }
  160.                     else
  161.                         Growandstuff -= diff;
  162.  
  163.                     if (MainRandomVisuals <= diff)
  164.                     {
  165.                        
  166.                             if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 40.0f, true))
  167.                                 DoCast(target, 73539);
  168.                        
  169.                             switch (phase)
  170.                             {
  171.                             case 1:
  172.                             case 2:
  173.                                 MainRandomVisuals = 7500;
  174.                                 break;
  175.                             case 3:
  176.                                 MainRandomVisuals = 9000;
  177.                                 break;
  178.                             case 4:
  179.                                 MainRandomVisuals = 1000;
  180.                                 break;
  181.                             }
  182.                     }
  183.                     else
  184.                         MainRandomVisuals -= diff;
  185.  
  186.                     if (MainShadowCleave <= diff)
  187.                     {
  188.                         if (cancast)
  189.                         {
  190.                             if (Unit* target = SelectTarget(SELECT_TARGET_MAXTHREAT, 0, 10.0f, true))
  191.                                 DoCast(target, 31629);
  192.                         }
  193.  
  194.                         if (phase < 3)
  195.                             MainShadowCleave = 7000;
  196.                         else
  197.                             MainShadowCleave = 8000;
  198.                            
  199.                     }
  200.                     else
  201.                         MainShadowCleave -= diff;
  202.  
  203.                     if (MainTimeFreeze <= diff)
  204.                     {
  205.                         if (cancast)
  206.                         {
  207.                             if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 60.0f, true))
  208.                                 DoCast(target, 40951);
  209.                         }
  210.                         if (phase < 3)
  211.                             MainTimeFreeze = 8000;
  212.                         else
  213.                             MainTimeFreeze = 10000;
  214.                         }
  215.                    
  216.                     else
  217.                         MainTimeFreeze -= diff;
  218.  
  219.                     if (CheckForPhase2Main <= diff)
  220.                     {
  221.                         if (me->GetHealthPct() < 75)
  222.                         {
  223.                             phase = 2;
  224.                             cancast = false;
  225.                             me->Talk("No More Life.", CHAT_MSG_SAY, LANG_UNIVERSAL, 80.0f, me);
  226.                             me->PlayDirectSound(11252, nullptr);
  227.                             me->SetImmuneToPC(true);
  228.                             me->StopMoving();
  229.                             me->CastStop();
  230.                             me->GetMotionMaster()->MovePoint(0, -424.966095f, -86.287300f, -88.224037f, true, 3.094177f);
  231.                             BringItOnMainBoss = 3000;
  232.                         }
  233.                         else
  234.                             CheckForPhase2Main = 2000;
  235.                     }
  236.                     else
  237.                         CheckForPhase2Main -= diff;
  238.            
  239.  
  240.  
  241.                     if (BringItOnMainBoss <= diff)
  242.                     {
  243.                         DoCast(me, 12380);
  244.                         MainRandomVisuals = 1000;
  245.                         phase = 4;
  246.  
  247.                         if (me->GetHealthPct() < 35)
  248.                         {
  249.                             MainEndVisualFinal = 15500;
  250.                         }
  251.                         else
  252.                             MainEndVisual = 15500;
  253.                     }
  254.  
  255.                     if (MainEndVisual <= diff)
  256.                     {
  257.                         cancast = true;
  258.                         me->CastStop();
  259.                         me->SetImmuneToPC(false);
  260.                         me->SetReactState(REACT_AGGRESSIVE);
  261.                         phase = 2;
  262.  
  263.                         if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 60.0f, true))
  264.                             DoCast(target, 40251);
  265.  
  266.                         if (Unit* target = SelectTarget(SELECT_TARGET_MINDISTANCE, 0, 80.0f, true))
  267.                             me->GetMotionMaster()->MoveChase(target);
  268.  
  269.                         MainDisorient = 12000;
  270.                         MainShroudGuys = 6000;
  271.                         MainDeathGrip = 8000;
  272.                         Growandstuff = 20000;
  273.                         CheckForNextMainPhase = 2000;
  274.                     }
  275.  
  276.                     if (MainDisorient <= diff)
  277.                     {
  278.                         if (cancast)
  279.                         {
  280.                             if (Unit* target = SelectTarget(SELECT_TARGET_MINDISTANCE, 0, -6.0f, true))
  281.                                 me->CastSpell(target, 26108);
  282.                         }
  283.  
  284.                         switch (phase)
  285.                         {
  286.                         case 2:
  287.                             MainDisorient = 12000;
  288.                             break;
  289.                         case 3:
  290.                             MainDisorient = 10000;
  291.                             break;
  292.                         }
  293.                     }
  294.                     else
  295.                         MainDisorient -= diff;
  296.  
  297.                     if (MainShroudGuys <= diff)
  298.                     {
  299.                         if (cancast)
  300.                         {
  301.                             if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 40.0f, true))
  302.                                 me->CastSpell(target, 40251);
  303.                         }
  304.                             MainShroudGuys = 6000;
  305.                     }
  306.                     else
  307.                         MainShroudGuys -= diff;
  308.  
  309.                     if (MainDeathGrip <= diff)
  310.                     {
  311.                         if (cancast)
  312.                         {
  313.                             std::list<Unit*> targets;
  314.                             SelectTargetList(targets, 2, SELECT_TARGET_RANDOM, 0, 40.0f, true);
  315.                             for (std::list<Unit*>::const_iterator i = targets.begin(); i != targets.end(); ++i)
  316.                             {
  317.                             DoCast(*i, 64429);
  318.                             DoCast(*i, 10689);
  319.  
  320.                                 for (Unit* target : targets)
  321.                                 {
  322.                                     if (Creature* reflection = me->SummonCreature(30768, *target, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 3000))
  323.                                     {
  324.                                         reflection->SetImmuneToPC(false);
  325.                                         target->CastSpell(reflection, 69828, true);
  326.                                         target->CastSpell(reflection, 69861, true);
  327.                                         target->CastSpell(reflection, 69960, true);
  328.                                         reflection->AI()->AttackStart(target);
  329.                                     }
  330.                                     break;
  331.                                 }
  332.                             break;
  333.                                
  334.                             }
  335.                         }
  336.                         if (phase < 3)
  337.                             MainDeathGrip = 8000;
  338.                         else
  339.                             MainDeathGrip = 6000;
  340.  
  341.                     }
  342.                     else
  343.                         MainDeathGrip -= diff;
  344.  
  345.                     if (CheckForNextMainPhase <= diff)
  346.                     {
  347.                         if (me->GetHealthPct() < 35)
  348.                         {
  349.                             cancast = false;
  350.                             me->Talk("No More Life.", CHAT_MSG_SAY, LANG_UNIVERSAL, 80.0f, me);
  351.                             me->PlayDirectSound(11252, nullptr);
  352.                             me->SetImmuneToPC(true);
  353.                             me->SetReactState(REACT_PASSIVE);
  354.                             me->CastStop();
  355.                             me->GetMotionMaster()->MovePoint(0, -424.966095f, -86.287300f, -88.224037f, true, 3.094177f);
  356.                             BringItOnMainBoss = 3000;
  357.                         }
  358.                         else
  359.                             CheckForNextMainPhase = 2000;
  360.                     }
  361.                     else
  362.                         CheckForNextMainPhase -= diff;
  363.  
  364.                     if (MainEndVisualFinal <= diff)
  365.                     {
  366.                         cancast = true;
  367.                         me->CastStop();
  368.                         me->SetImmuneToPC(false);
  369.                         me->SetReactState(REACT_AGGRESSIVE);
  370.                         phase = 3;
  371.                         Growandstuff = 10000;
  372.  
  373.                         if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 60.0f, true))
  374.                             DoCast(target, 40251);
  375.  
  376.                         if (Unit* target = SelectTarget(SELECT_TARGET_MINDISTANCE, 0, 80.0f, true))
  377.                             me->GetMotionMaster()->MoveChase(target);                      
  378.                     }
  379.  
  380.                     DoMeleeAttackIfReady();
  381.             }
  382.  
  383.         private:
  384.             SummonList summons;
  385.             Creature* corpseexplode;
  386.         };
  387.  
  388.         CreatureAI * GetAI(Creature * pCreature) const override
  389.         {
  390.             return new npc_cultist_bossAI(pCreature);
  391.         }
  392. };
  393.  
  394. void AddSC_npc_cultist_boss()
  395. {
  396.     new npc_cultist_boss;
  397. }
Advertisement
Add Comment
Please, Sign In to add comment