midoking

Boss Script

Jan 12th, 2013
605
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 12.23 KB | None | 0 0
  1. /*
  2.  * Copyright (C) 2011-2012 Project SkyFire <http://www.projectskyfire.org/>
  3.  * Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
  4.  *
  5.  * This program is free software; you can redistribute it and/or modify it
  6.  * under the terms of the GNU General Public License as published by the
  7.  * Free Software Foundation; either version 3 of the License, or (at your
  8.  * option) any later version.
  9.  *
  10.  * This program is distributed in the hope that it will be useful, but WITHOUT
  11.  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12.  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13.  * more details.
  14.  *
  15.  * You should have received a copy of the GNU General Public License along
  16.  * with this program. If not, see <http://www.gnu.org/licenses/>.
  17.  * Script general link on ac-web http://www.ac-web.org/forums/showthread.php?150953-C-Custom-boss-script
  18.  */
  19.  
  20. /* ScriptData
  21. SDCreator: frostI
  22. SDName: boss_maximus
  23. SD%Complete: 99
  24. SDComment: When Maximus dies the emote that he killed someone and that he dies trigger at the same moment, while none is actually killed.
  25. SDCategory: Custom script, optimal for Ragefire Chasm
  26. EndScriptData */
  27.  
  28. #include "ScriptPCH.h"
  29.  
  30. //Spells
  31. enum Spells
  32. {
  33.     //Phase one
  34.     SPELL_TWILIGHT_CHANNEL             = 57797,
  35.     SPELL_TWILIGHT_PORTAL_VISUAL       = 51807,
  36.     //Phase two  
  37.     SPELL_AURA_OF_DREAD                = 41142,
  38.     SPELL_SUNDER_ARMOR                 = 59350,
  39.     SPELL_UNHOLY_POWER                 = 69167,
  40.     SPELL_BURNING_FISTS                = 67333,
  41.     SPELL_PAIN_AND_SUFFERING           = 73790,
  42.     SPELL_FIERY_COMBUSTION             = 74562,
  43.     SPELL_MARK_OF_COMBUSTION           = 74567,
  44.     //Phase three
  45.     SPELL_HIGH_SECURITY_SHADOW_PRISON  = 45922,
  46.     SPELL_FINGER_OF_DEATH              = 31984,
  47.     SPELL_BERSERK                      = 41924,
  48. };
  49.  
  50. //Creatures
  51. enum Creatures
  52. {
  53.     NPC_ANCIENT_WISP         = 5000006,
  54.     NPC_TWILIGHT_PORTAL      = 5000007,
  55. };
  56.  
  57. //Creature sounds
  58. #define SOUND_ONAGGRO       8595
  59. #define SOUND_ONSLAY        8602
  60. #define SOUND_ONDEATH       8594
  61.  
  62. //Emotes
  63. #define EMOTE_ONAGGRO      "Assistance will arrive soon, stand tall!"
  64. #define EMOTE_STRENGTH     "Maximus' strength is increasing!"  
  65. #define EMOTE_FAIL         "The Twilight General begins to cast Finger of Death, we are lost..."
  66. #define EMOTE_WIN          "We did it! Help is seconds away!"
  67.  
  68. //Maximus AI:
  69. class boss_maximus : public CreatureScript
  70. {
  71. public:
  72.     boss_maximus() : CreatureScript("boss_maximus"){ }
  73.  
  74.     CreatureAI* GetAI(Creature* creature) const
  75.     {
  76.         return new boss_maximusAI (creature);
  77.     }
  78.  
  79.     struct boss_maximusAI : public ScriptedAI
  80.     {
  81.         boss_maximusAI(Creature* creature) : ScriptedAI(creature), summons(me){ }
  82.  
  83.         uint32 ChannelTwilight_Timer;
  84.  
  85.         uint32 AuraOfDread_Timer;
  86.         uint32 SunderArmor_Timer;
  87.         uint32 UnholyPower_Timer;
  88.         uint32 BurningFists_Timer;
  89.         uint32 PainAndSuffering_Timer;
  90.         uint32 FieryCombustion_Timer;
  91.      
  92.         uint32 SummonWisp_Timer;
  93.         uint32 WispCount;
  94.  
  95.         uint32 Enrage_Timer;
  96.         uint32 FingerOfDeath_Timer;
  97.  
  98.         bool IsChanneling;
  99.         bool Enraged;
  100.         bool BelowTwentyPercent;
  101.         bool HasProtected;
  102.  
  103.         SummonList summons;
  104.  
  105.         //When resetting:
  106.         void Reset()
  107.         {
  108.             ChannelTwilight_Timer = 0;
  109.  
  110.             AuraOfDread_Timer = 2000;
  111.             SunderArmor_Timer = 5000;
  112.             UnholyPower_Timer = 9750;
  113.             BurningFists_Timer = 10000;
  114.             PainAndSuffering_Timer = urand(10000, 17500);
  115.             FieryCombustion_Timer = urand(7500, 15000);
  116.  
  117.             FingerOfDeath_Timer = 1;
  118.             Enrage_Timer = 300000;
  119.  
  120.             SummonWisp_Timer = 5000;
  121.             WispCount = 0;
  122.  
  123.             IsChanneling = false;
  124.             Enraged = false;
  125.             BelowTwentyPercent = false;
  126.             HasProtected = false;
  127.             summons.DespawnAll();
  128.  
  129.             me->RemoveAllAuras();
  130.             me->SetFullHealth();
  131.         }
  132.  
  133.         //When entering combat:
  134.         void EnterCombat(Unit* who)
  135.         {
  136.             me->MonsterYell("My powers are renewed!", LANG_UNIVERSAL, me->GetGUID());
  137.             DoPlaySoundToSet(me, SOUND_ONAGGRO);
  138.             me->MonsterTextEmote(EMOTE_ONAGGRO, 0, true);
  139.  
  140.             me->InterruptSpell(CURRENT_CHANNELED_SPELL);
  141.             me->RemoveAllAuras();
  142.             DoZoneInCombat();
  143.             summons.DoZoneInCombat();
  144.         }
  145.  
  146.         //When summoned creature:
  147.         void JustSummoned(Creature* summoned)
  148.         {
  149.             if (summoned->GetEntry() == NPC_ANCIENT_WISP)
  150.                 summoned->AI()->AttackStart(me);
  151.             else
  152.             {
  153.                 summoned->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
  154.             }
  155.         }
  156.  
  157.         //When despawning summoned creature:
  158.         void SummonedCreatureDespawn(Creature* summon)
  159.         {
  160.             summons.Despawn(summon);
  161.         }
  162.  
  163.         //When reached home position:
  164.         void JustReachedHome()
  165.         {
  166.             DoCast(me, SPELL_TWILIGHT_CHANNEL);
  167.         }
  168.  
  169.         //When killed a unit:
  170.         void KilledUnit(Unit* /*who*/)
  171.         {
  172.             me->MonsterYell("You are terminated.", LANG_UNIVERSAL, me->GetGUID());
  173.             DoPlaySoundToSet(me, SOUND_ONSLAY);
  174.         }
  175.  
  176.         //When died:
  177.         void JustDied(Unit* /*killer*/)
  178.         {
  179.             me->MonsterYell("I have.. failed...", LANG_UNIVERSAL, me->GetGUID());
  180.             DoPlaySoundToSet(me, SOUND_ONDEATH);
  181.  
  182.             me->RemoveAllAuras();
  183.         }      
  184.  
  185.         //Stay up to date
  186.         void UpdateAI(const uint32 diff)
  187.         {
  188.             //Channel on Twilight Portal
  189.             if (ChannelTwilight_Timer <= diff)
  190.             {
  191.                 if (!IsChanneling)
  192.                 {
  193.                     DoCast(me, SPELL_TWILIGHT_CHANNEL);
  194.                     IsChanneling = true;
  195.                 }
  196.             } else ChannelTwilight_Timer -= diff;              
  197.        
  198.             if (!UpdateVictim())
  199.                 return;
  200.  
  201.             if (me->HealthBelowPct(20) && !BelowTwentyPercent && !Enraged)
  202.                 BelowTwentyPercent = true;
  203.  
  204.             //When enraged:
  205.             if (Enrage_Timer < diff && !Enraged)
  206.             {
  207.                 me->GetMotionMaster()->Clear(false);
  208.                 me->GetMotionMaster()->MoveIdle();
  209.                 me->RemoveAllAuras();
  210.                 me->MonsterTextEmote(EMOTE_FAIL, 0, true);
  211.                 Enraged = true;
  212.             } else Enrage_Timer -= diff;
  213.  
  214.             if (Enraged)
  215.             {
  216.                 DoCast(me, SPELL_BERSERK);
  217.  
  218.                 //Finger of Death timer
  219.                 if (FingerOfDeath_Timer <= diff)
  220.                 {
  221.                     if (Unit *Target = SelectTarget (SELECT_TARGET_RANDOM, 0))
  222.                     DoCast (Target, SPELL_FINGER_OF_DEATH);
  223.                     FingerOfDeath_Timer = 1000;
  224.                 } else FingerOfDeath_Timer -= diff;
  225.                 return;
  226.             }
  227.  
  228.             //When below 20% health:
  229.             if (BelowTwentyPercent && !Enraged)
  230.             {
  231.                 if (!HasProtected)
  232.                 {
  233.                     me->RemoveAllAuras();
  234.                     DoCast (me, SPELL_HIGH_SECURITY_SHADOW_PRISON);
  235.  
  236.                     me->MonsterTextEmote(EMOTE_WIN, 0, true);
  237.                     HasProtected = true;
  238.                 }
  239.  
  240.                 //Summon Wisp timer
  241.                 if (SummonWisp_Timer <= diff)
  242.                 {
  243.                     DoSpawnCreature(NPC_ANCIENT_WISP, float(rand()%40), float(rand()%40), 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
  244.                     SummonWisp_Timer = 2500;
  245.                     ++WispCount;
  246.                 } else SummonWisp_Timer -= diff;
  247.  
  248.                 if (WispCount >= 10)
  249.                     me->DealDamage(me, me->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);                   
  250.                    return;
  251.             }
  252.  
  253.                 //Aura of Dread Timer
  254.                 if (AuraOfDread_Timer <= diff)
  255.                 {
  256.                     DoCast (me->getVictim(), SPELL_AURA_OF_DREAD);
  257.                     AuraOfDread_Timer = 2500;
  258.                 } else AuraOfDread_Timer -= diff;
  259.  
  260.                 //Sunder Armor Timer
  261.                 if (SunderArmor_Timer <= diff)
  262.                 {
  263.                     DoCast (me->getVictim(), SPELL_SUNDER_ARMOR);
  264.                     SunderArmor_Timer = 15000;
  265.                 } else SunderArmor_Timer -= diff;
  266.  
  267.                 //Burning Fists Timer
  268.                 if (BurningFists_Timer <= diff)
  269.                 {
  270.                     DoCast (me->getVictim(), SPELL_BURNING_FISTS);
  271.                     BurningFists_Timer = 25001;
  272.                 } else BurningFists_Timer -= diff;
  273.  
  274.                 //Unholy Power Timer
  275.                 if (UnholyPower_Timer <= diff)
  276.                 {
  277.                     DoCast (me->getVictim(), SPELL_UNHOLY_POWER);
  278.                     UnholyPower_Timer = 25000;
  279.                     me->MonsterTextEmote(EMOTE_STRENGTH, 0, true);
  280.                 } else UnholyPower_Timer -= diff;
  281.  
  282.                 //Pain and Suffering Timer
  283.                 if (PainAndSuffering_Timer <= diff)
  284.                 {
  285.                     if (Unit *Target = SelectTarget (SELECT_TARGET_RANDOM, 0))
  286.                     DoCast (Target, SPELL_PAIN_AND_SUFFERING);
  287.                     PainAndSuffering_Timer = urand(10000, 17500);
  288.                 } else PainAndSuffering_Timer -= diff;
  289.  
  290.                 //Fiery Combustion Timer
  291.                 if (FieryCombustion_Timer <= diff)
  292.                 {
  293.                     if (Unit *Target = SelectTarget (SELECT_TARGET_RANDOM, 0))
  294.                     DoCast (Target, SPELL_FIERY_COMBUSTION);
  295.                     FieryCombustion_Timer = urand(12500, 20000);      
  296.                 } else FieryCombustion_Timer -= diff;          
  297.  
  298.             DoMeleeAttackIfReady();
  299.         }
  300.     };
  301. };
  302.  
  303. //Twilight Portal AI:
  304. class npc_twilight_portal : public CreatureScript
  305. {
  306. public:
  307.     npc_twilight_portal() : CreatureScript("npc_twilight_portal") { }
  308.  
  309.     CreatureAI* GetAI(Creature* creature) const
  310.     {
  311.         return new npc_twilight_portalAI(creature);
  312.     }
  313.  
  314.     struct npc_twilight_portalAI : public Scripted_NoMovementAI
  315.     {
  316.         npc_twilight_portalAI(Creature* creature) : Scripted_NoMovementAI(creature){ }
  317.  
  318.         //When resetting:
  319.         void Reset()
  320.         {
  321.             DoCast (me, SPELL_TWILIGHT_PORTAL_VISUAL);
  322.  
  323.             me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
  324.             me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
  325.         }
  326.  
  327.         //Stay up to date
  328.         void UpdateAI(const uint32 diff)
  329.         {
  330.             if (!UpdateVictim())
  331.                 return;
  332.         }
  333.     };
  334. };
  335.  
  336. //Ancient Wisp AI:
  337. class npc_ancient_wisp : public CreatureScript
  338. {
  339. public:
  340.     npc_ancient_wisp() : CreatureScript("npc_ancient_wisp") { }
  341.  
  342.     CreatureAI* GetAI(Creature* creature) const
  343.     {
  344.         return new npc_ancient_wispAI(creature);
  345.     }
  346.  
  347.     struct npc_ancient_wispAI : public ScriptedAI
  348.     {
  349.         npc_ancient_wispAI(Creature* creature) : ScriptedAI(creature)
  350.         {
  351.             MaximusGUID = 0;
  352.         }
  353.  
  354.         uint64 MaximusGUID;
  355.         uint32 Check_Timer;
  356.         uint64 TargetGUID;
  357.  
  358.         uint32 ChangeTarget_Timer;
  359.  
  360.         //When resetting:
  361.         void Reset()
  362.         {
  363.             Check_Timer = 1000;
  364.             ChangeTarget_Timer = 7500;
  365.  
  366.             TargetGUID = 0;
  367.         }
  368.  
  369.         //When moving in line of sight:
  370.         void MoveInLineOfSight(Unit* who)
  371.         {
  372.             if (!TargetGUID && who->GetTypeId() == TYPEID_PLAYER)
  373.                 TargetGUID = who->GetGUID();
  374.         }
  375.  
  376.         void EnterCombat(Unit* /*who*/)
  377.         {
  378.             me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
  379.         }
  380.  
  381.         //When taking damage:
  382.         void DamageTaken(Unit* /*done_by*/, uint32 &damage) { damage = 0; }
  383.  
  384.         //When reached waypoint:
  385.         void WaypointReached(uint32 /*i*/){ }
  386.  
  387.         //Stay up to date
  388.         void UpdateAI(const uint32 diff)
  389.         {
  390.             //Change target timer
  391.             if (ChangeTarget_Timer <= diff)
  392.             {
  393.                 if (Unit* temp = Unit::GetUnit(*me, TargetGUID))
  394.                 {
  395.                     me->GetMotionMaster()->MoveFollow(temp, 0.0f, 0.0f);
  396.                     TargetGUID = 0;
  397.                 }
  398.                 else
  399.                 {
  400.                     Position pos;
  401.                     me->GetRandomNearPosition(pos, 40);
  402.                     me->GetMotionMaster()->MovePoint(0, pos.m_positionX, pos.m_positionY, pos.m_positionZ);
  403.                 }
  404.  
  405.                 ChangeTarget_Timer = 5000;
  406.             } else ChangeTarget_Timer -= diff;
  407.         }
  408.     };
  409. };
  410.  
  411. void AddSC_boss_maximus()
  412. {
  413.     new boss_maximus();
  414.     new npc_ancient_wisp();
  415.     new npc_twilight_portal();
  416. }
Advertisement
Add Comment
Please, Sign In to add comment