Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Mar 22nd, 2010 | Syntax: None | Size: 28.64 KB | Hits: 92 | Expires: Never
Copy text to clipboard
  1. /*
  2.  * Copyright (C) 2008 - 2009 Trinity <http://www.trinitycore.org/>
  3.  *
  4.  * This program is free software; you can redistribute it and/or modify
  5.  * it under the terms of the GNU General Public License as published by
  6.  * the Free Software Foundation; either version 2 of the License, or
  7.  * (at your option) any later version.
  8.  *
  9.  * This program is distributed in the hope that it will be useful,
  10.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12.  * GNU General Public License for more details.
  13.  *
  14.  * You should have received a copy of the GNU General Public License
  15.  * along with this program; if not, write to the Free Software
  16.  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17.  */
  18.  
  19.  
  20. /*
  21.     TODO:
  22.         Add achievments
  23.         Boombot explosion only hurt allies to the npc at the moment
  24.         Boombot explosion visual
  25.         Test the enrage timer
  26.         Fix gravity bomb - tractor beam.
  27.         Fix void zone spell
  28.         If the boss is to close to a scrap pile -> no summon
  29.         make the life sparks visible...
  30. */
  31.  
  32.  
  33. #include "ScriptedPch.h"
  34. #include "ulduar.h"
  35.  
  36.  
  37. enum Spells
  38. {
  39.     SPELL_TYMPANIC_TANTRUM                      = 62776,
  40.     SPELL_SEARING_LIGHT_10                      = 63018,
  41.     SPELL_SEARING_LIGHT_25                      = 65121,
  42.  
  43.  
  44.     SPELL_GRAVITY_BOMB_10                       = 63024,
  45.     SPELL_GRAVITY_BOMB_25                       = 63234,
  46.     SPELL_GRAVITY_BOMB_AURA_10                  = 63025,
  47.     SPELL_GRAVITY_BOMB_AURA_25                  = 63233,
  48.  
  49.  
  50.     SPELL_HEARTBREAK_10                         = 65737,
  51.     SPELL_HEARTBREAK_25                         = 64193,
  52.  
  53.  
  54.     SPELL_ENRAGE                                = 26662,
  55.  
  56.  
  57.     //------------------VOID ZONE--------------------
  58.     SPELL_VOID_ZONE_10                          = 64203,
  59.     SPELL_VOID_ZONE_25                          = 64235,
  60.  
  61.  
  62.     // Life Spark
  63.     SPELL_STATIC_CHARGED_10                     = 64227,
  64.     SPELL_STATIC_CHARGED_25                     = 64236,
  65.     SPELL_SHOCK                                 = 64230,
  66.  
  67.  
  68.     //----------------XT-002 HEART-------------------
  69.     SPELL_EXPOSED_HEART                         = 63849,
  70.  
  71.  
  72.     //---------------XM-024 PUMMELLER----------------
  73.     SPELL_ARCING_SMASH                          = 8374,
  74.     SPELL_TRAMPLE                               = 5568,
  75.     SPELL_UPPERCUT                              = 10966,
  76.  
  77.  
  78.     //------------------BOOMBOT-----------------------
  79.     SPELL_BOOM                                  = 62834,
  80. };
  81.  
  82.  
  83. enum Timers
  84. {
  85.     TIMER_TYMPANIC_TANTRUM_MIN                  = 32000,
  86.     TIMER_TYMPANIC_TANTRUM_MAX                  = 36000,
  87.     TIMER_SEARING_LIGHT                         = 20000,
  88.     TIMER_SPAWN_LIFE_SPARK                      = 9000,
  89.     TIMER_GRAVITY_BOMB                          = 20000,
  90.     TIMER_HEART_PHASE                           = 30000,
  91.     TIMER_ENRAGE                                = 600000,
  92.     TIMER_GRAVITY_BOMB_AURA                     = 8900,
  93.  
  94.  
  95.     TIMER_VOID_ZONE                             = 3000,
  96.  
  97.  
  98.     // Life Spark
  99.     TIMER_SHOCK                                 = 12000,
  100.  
  101.  
  102.     // Pummeller
  103.     // Timers may be off
  104.     TIMER_ARCING_SMASH                          = 27000,
  105.     TIMER_TRAMPLE                               = 22000,
  106.     TIMER_UPPERCUT                              = 17000,
  107.  
  108.  
  109.     TIMER_SPAWN_ADD                             = 12000,
  110. };
  111.  
  112.  
  113. enum Creatures
  114. {
  115.     NPC_VOID_ZONE                               = 34001,
  116.     NPC_LIFE_SPARK                              = 34004,
  117.     NPC_XT002_HEART                             = 33329,
  118.     NPC_XS013_SCRAPBOT                          = 33343,
  119.     NPC_XM024_PUMMELLER                         = 33344,
  120.     NPC_XE321_BOOMBOT                           = 33346,
  121. };
  122.  
  123.  
  124. enum Actions
  125. {
  126.     ACTION_ENTER_HARD_MODE                      = 0,
  127. };
  128.  
  129.  
  130. enum XT002Data
  131. {
  132.     DATA_TRANSFERED_HEALTH                      = 0,
  133. };
  134.  
  135.  
  136. enum Yells
  137. {
  138.     SAY_AGGRO                                   = -1603300,
  139.     SAY_HEART_OPENED                            = -1603301,
  140.     SAY_HEART_CLOSED                            = -1603302,
  141.     SAY_TYMPANIC_TANTRUM                        = -1603303,
  142.     SAY_SLAY_1                                  = -1603304,
  143.     SAY_SLAY_2                                  = -1603305,
  144.     SAY_BERSERK                                 = -1603306,
  145.     SAY_DEATH                                   = -1603307,
  146.     SAY_SUMMON                                  = -1603308,
  147. };
  148.  
  149.  
  150. //#define GRAVITY_BOMB_DMG_MIN_10                11700
  151. //#define GRAVITY_BOMB_DMG_MAX_10                12300
  152. //#define GRAVITY_BOMB_DMG_MIN_25                14625
  153. //#define GRAVITY_BOMB_DMG_MAX_25                15375
  154. //#define GRAVITY_BOMB_RADIUS                    12
  155.  
  156.  
  157. //#define VOID_ZONE_DMG_10                      5000
  158. //#define VOID_ZONE_DMG_25                      7500
  159. //#define VOID_ZONE_RADIUS                      
  160.  
  161.  
  162.  
  163.  
  164. /************************************************
  165. -----------------SPAWN LOCATIONS-----------------
  166. ************************************************/
  167. //Shared Z-level
  168. #define SPAWN_Z                                 412
  169. //Lower right
  170. #define LR_X                                    796
  171. #define LR_Y                                    -94
  172. //Lower left
  173. #define LL_X                                    796
  174. #define LL_Y                                    57
  175. //Upper right
  176. #define UR_X                                    890
  177. #define UR_Y                                    -82
  178. //Upper left
  179. #define UL_X                                    894
  180. #define UL_Y                                    62
  181.  
  182.  
  183. /*-------------------------------------------------------
  184.  *
  185.  *        XT-002 DECONSTRUCTOR
  186.  *
  187.  *///----------------------------------------------------
  188. struct boss_xt002_AI : public BossAI
  189. {
  190.     boss_xt002_AI(Creature *pCreature) : BossAI(pCreature, TYPE_XT002)
  191.     {
  192.     }
  193.  
  194.  
  195.     uint32 uiSearingLightTimer;
  196.     uint32 uiSpawnLifeSparkTimer;
  197.     uint32 uiGravityBombTimer;
  198.     uint32 uiGravityBombAuraTimer;
  199.     uint32 uiTympanicTantrumTimer;
  200.     uint32 uiHeartPhaseTimer;
  201.     uint32 uiSpawnAddTimer;
  202.     uint32 uiEnrageTimer;
  203.    
  204.     bool searing_light_active;
  205.     uint64 uiSearingLightTarget;
  206.  
  207.  
  208.     bool gravity_bomb_active;
  209.     uint64 uiGravityBombTarget;
  210.  
  211.  
  212.     uint8 phase;
  213.     uint8 heart_exposed;
  214.     bool enraged;
  215.  
  216.  
  217.     uint32 transferHealth;
  218.     bool enterHardMode;
  219.     bool hardMode;
  220.  
  221.  
  222.     void Reset()
  223.     {
  224.         m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_NOT_SELECTABLE);
  225.  
  226.  
  227.         //Makes XT-002 to cast a light bomb 10 seconds after aggro.
  228.         uiSearingLightTimer = TIMER_SEARING_LIGHT/2;
  229.         uiSpawnLifeSparkTimer = TIMER_SPAWN_LIFE_SPARK;
  230.         uiGravityBombTimer = TIMER_GRAVITY_BOMB;
  231.         uiGravityBombAuraTimer = TIMER_GRAVITY_BOMB_AURA;
  232.         uiHeartPhaseTimer = TIMER_HEART_PHASE;
  233.         uiSpawnAddTimer = TIMER_SPAWN_ADD;
  234.         uiEnrageTimer = TIMER_ENRAGE;
  235.  
  236.  
  237.         //Tantrum is casted a bit slower the first time.
  238.         uiTympanicTantrumTimer = urand(TIMER_TYMPANIC_TANTRUM_MIN, TIMER_TYMPANIC_TANTRUM_MAX) * 2;
  239.  
  240.  
  241.         searing_light_active = false;
  242.         gravity_bomb_active = false;
  243.         enraged = false;
  244.         hardMode = false;
  245.         enterHardMode = false;
  246.  
  247.  
  248.         phase = 1;
  249.         heart_exposed = 0;
  250.     }
  251.  
  252.  
  253.     void EnterCombat(Unit* who)
  254.     {
  255.         DoScriptText(SAY_AGGRO, m_creature);
  256.         _EnterCombat();
  257.     }
  258.  
  259.  
  260.     void DoAction(const int32 action)
  261.     {
  262.         switch (action)
  263.         {
  264.             case ACTION_ENTER_HARD_MODE:
  265.                 if (!hardMode)
  266.                 {
  267.                     hardMode = true;
  268.  
  269.  
  270.                     // Enter hard mode
  271.                     enterHardMode = true;
  272.  
  273.  
  274.                     // set max health
  275.                     m_creature->SetHealth(m_creature->GetMaxHealth());
  276.  
  277.  
  278.                     // Get his heartbreak buff
  279.                     m_creature->CastSpell(m_creature, RAID_MODE(SPELL_HEARTBREAK_10, SPELL_HEARTBREAK_25), true);
  280.                 }
  281.                 break;
  282.         }
  283.     }
  284.  
  285.  
  286.     void SetData(uint32 id, uint32 value)
  287.     {
  288.         switch(id)
  289.         {
  290.             case DATA_TRANSFERED_HEALTH:
  291.                 transferHealth = value;
  292.                 break;
  293.         }
  294.     }
  295.  
  296.  
  297.     void KilledUnit(Unit* victim)
  298.     {
  299.         DoScriptText(RAND(SAY_SLAY_1,SAY_SLAY_2), m_creature);
  300.     }
  301.  
  302.  
  303.     void JustDied(Unit *victim)
  304.     {
  305.         DoScriptText(SAY_DEATH, m_creature);
  306.         _JustDied();
  307.     }
  308.  
  309.  
  310.     void UpdateAI(const uint32 diff)
  311.     {
  312.         if (!UpdateVictim())
  313.             return;
  314.  
  315.  
  316.         if (enterHardMode)
  317.         {
  318.             SetPhaseOne();
  319.             enterHardMode = false;
  320.         }
  321.  
  322.  
  323.         // Handles spell casting. These spells only occur during phase 1 and hard mode
  324.         if (phase == 1 || hardMode)
  325.         {
  326.             if (uiSearingLightTimer <= diff)
  327.             {
  328.                 if (Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0))
  329.                 {
  330.                     DoCast(pTarget, RAID_MODE(SPELL_SEARING_LIGHT_10, SPELL_SEARING_LIGHT_25));
  331.                     uiSearingLightTarget = pTarget->GetGUID();
  332.                 }
  333.                 uiSpawnLifeSparkTimer = TIMER_SPAWN_LIFE_SPARK;
  334.                 if (hardMode)
  335.                     searing_light_active = true;
  336.                 uiSearingLightTimer = TIMER_SEARING_LIGHT;
  337.             } else uiSearingLightTimer -= diff;
  338.  
  339.  
  340.             if (uiGravityBombTimer <= diff)
  341.             {
  342.                 if (Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0))
  343.                 {
  344.                     DoCast(pTarget, RAID_MODE(SPELL_GRAVITY_BOMB_10,SPELL_GRAVITY_BOMB_25));
  345.                     uiGravityBombTarget = pTarget->GetGUID();
  346.                 }
  347.                 uiGravityBombTimer = TIMER_GRAVITY_BOMB;
  348.                 gravity_bomb_active = true;
  349.             } else uiGravityBombTimer -= diff;
  350.  
  351.  
  352.             if (uiTympanicTantrumTimer <= 0)
  353.             {
  354.                 DoScriptText(SAY_TYMPANIC_TANTRUM, m_creature);
  355.                 DoCast(SPELL_TYMPANIC_TANTRUM);
  356.                 uiTympanicTantrumTimer = urand(TIMER_TYMPANIC_TANTRUM_MIN, TIMER_TYMPANIC_TANTRUM_MAX);
  357.             } else uiTympanicTantrumTimer -= diff;
  358.         }
  359.  
  360.  
  361.         if (!hardMode)
  362.         {
  363.             if (phase == 1)
  364.             {
  365.                 if (HealthBelowPct(75) && heart_exposed == 0)
  366.                 {
  367.                     exposeHeart();
  368.                 }
  369.                 else if (HealthBelowPct(50) && heart_exposed == 1)
  370.                 {
  371.                     exposeHeart();
  372.                 }
  373.                 else if (HealthBelowPct(25) && heart_exposed == 2)
  374.                 {
  375.                     exposeHeart();
  376.                 }
  377.  
  378.  
  379.                 DoMeleeAttackIfReady();
  380.             }
  381.             else
  382.             {
  383.                 //Stop moving
  384.                 m_creature->StopMoving();
  385.  
  386.  
  387.                 //Start summoning adds
  388.                 if (uiSpawnAddTimer <= diff)
  389.                 {
  390.                     DoScriptText(SAY_SUMMON, m_creature);
  391.  
  392.  
  393.                     // Spawn Pummeller
  394.                     switch (rand() % 4)
  395.                     {
  396.                         case 0: m_creature->SummonCreature(NPC_XM024_PUMMELLER, LR_X, LR_Y, SPAWN_Z, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); break;
  397.                         case 1: m_creature->SummonCreature(NPC_XM024_PUMMELLER, LL_X, LL_Y, SPAWN_Z, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); break;
  398.                         case 2: m_creature->SummonCreature(NPC_XM024_PUMMELLER, UR_X, UR_Y, SPAWN_Z, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); break;
  399.                         case 3: m_creature->SummonCreature(NPC_XM024_PUMMELLER, UL_X, UL_Y, SPAWN_Z, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); break;
  400.                     }
  401.  
  402.  
  403.                     // Spawn 5 Bombs
  404.                     for (int8 n = 0; n < 5; n++)
  405.                     {
  406.                         //Some randomes are added so they wont spawn in a pile
  407.                         switch(rand() % 4)
  408.                         {
  409.                             case 0: m_creature->SummonCreature(NPC_XS013_SCRAPBOT, irand(LR_X - 3, LR_X + 3), irand(LR_Y - 3, LR_Y + 3), SPAWN_Z, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); break;
  410.                             case 1: m_creature->SummonCreature(NPC_XS013_SCRAPBOT, irand(LL_X - 3, LL_X + 3), irand(LL_Y - 3, LL_Y + 3), SPAWN_Z, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); break;
  411.                             case 2: m_creature->SummonCreature(NPC_XS013_SCRAPBOT, irand(UR_X - 3, UR_X + 3), irand(UR_Y - 3, UR_Y + 3), SPAWN_Z, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); break;
  412.                             case 3: m_creature->SummonCreature(NPC_XS013_SCRAPBOT, irand(UL_X - 3, UL_X + 3), irand(UL_Y - 3, UL_Y + 3), SPAWN_Z, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); break;
  413.                         }
  414.                     }
  415.            
  416.                     //Spawn 5 Scrapbots
  417.                     switch (rand() % 4)
  418.                     {
  419.                         case 0: m_creature->SummonCreature(NPC_XE321_BOOMBOT, LR_X, LR_Y, SPAWN_Z, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); break;
  420.                         case 1: m_creature->SummonCreature(NPC_XE321_BOOMBOT, LL_X, LL_Y, SPAWN_Z, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); break;
  421.                         case 2: m_creature->SummonCreature(NPC_XE321_BOOMBOT, UR_X, UR_Y, SPAWN_Z, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); break;
  422.                         case 3: m_creature->SummonCreature(NPC_XE321_BOOMBOT, UL_X, UL_Y, SPAWN_Z, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); break;
  423.                     }
  424.  
  425.  
  426.                     uiSpawnAddTimer = TIMER_SPAWN_ADD;
  427.                 } else uiSpawnAddTimer -= diff;
  428.  
  429.  
  430.                 // Is the phase over?
  431.                 if (uiHeartPhaseTimer <= diff)
  432.                 {
  433.                     DoScriptText(SAY_HEART_CLOSED, m_creature);
  434.                     SetPhaseOne();
  435.                 }
  436.                 else
  437.                     uiHeartPhaseTimer -= diff;
  438.             }
  439.         }
  440.         else
  441.         {
  442.             // Adding life sparks when searing light debuff runs out if hard mode
  443.             if (searing_light_active)
  444.             {
  445.                 if (uiSpawnLifeSparkTimer <= diff)
  446.                 {
  447.                     if (Unit *pSearingLightTarget = m_creature->GetUnit(*m_creature, uiSearingLightTarget))
  448.                         pSearingLightTarget->SummonCreature(NPC_LIFE_SPARK, pSearingLightTarget->GetPositionX(), pSearingLightTarget->GetPositionY(), pSearingLightTarget->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000);
  449.                     uiSpawnLifeSparkTimer = TIMER_SPAWN_LIFE_SPARK;
  450.                     searing_light_active = false;
  451.                 } else uiSpawnLifeSparkTimer -= diff;
  452.             }
  453.         }
  454.        
  455.         if (gravity_bomb_active)
  456.         {
  457.             if (uiGravityBombAuraTimer <= diff)
  458.             {
  459.                 if (Unit *pGravityBombTarget = m_creature->GetUnit(*m_creature, uiGravityBombTarget))
  460.                 {
  461.                     pGravityBombTarget->RemoveAurasDueToSpell(RAID_MODE(SPELL_GRAVITY_BOMB_10,SPELL_GRAVITY_BOMB_25));
  462.                     if (hardMode)
  463.                     {
  464.                         //Remains spawned for 3 minutes
  465.                         pGravityBombTarget->SummonCreature(NPC_VOID_ZONE, pGravityBombTarget->GetPositionX(), pGravityBombTarget->GetPositionY(), pGravityBombTarget->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 180000);
  466.                     }
  467.                 }
  468.  
  469.  
  470.                 gravity_bomb_active = false;
  471.                 uiGravityBombAuraTimer = TIMER_GRAVITY_BOMB_AURA;
  472.                 //gravityBomb();
  473.             } else uiGravityBombAuraTimer -= diff;
  474.         }
  475.  
  476.  
  477.         //Enrage stuff
  478.         if (!enraged)
  479.             if (uiEnrageTimer <= diff)
  480.             {
  481.                 DoScriptText(SAY_BERSERK, m_creature);
  482.                 DoCast(m_creature, SPELL_ENRAGE);
  483.                 enraged = true;
  484.             } else uiEnrageTimer -= diff;
  485.     }
  486.  
  487.  
  488.     void exposeHeart()
  489.     {
  490.         //Make untargetable
  491.         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE);
  492.  
  493.  
  494.         //Summon the heart npc
  495.         m_creature->SummonCreature(NPC_XT002_HEART, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ() + 7, 0, TEMPSUMMON_TIMED_DESPAWN, TIMER_HEART_PHASE);
  496.        
  497.         // Start "end of phase 2 timer"
  498.         uiHeartPhaseTimer = TIMER_HEART_PHASE;
  499.  
  500.  
  501.         //Phase 2 has offically started
  502.         phase = 2;
  503.         heart_exposed++;
  504.  
  505.  
  506.         //Reset the add spawning timer
  507.         uiSpawnAddTimer = TIMER_SPAWN_ADD;
  508.  
  509.  
  510.         DoScriptText(SAY_HEART_OPENED, m_creature);
  511.     }
  512.  
  513.  
  514.     void SetPhaseOne()
  515.     {
  516.         uiSearingLightTimer = TIMER_SEARING_LIGHT / 2;
  517.         uiGravityBombTimer = TIMER_GRAVITY_BOMB;
  518.         uiTympanicTantrumTimer = urand(TIMER_TYMPANIC_TANTRUM_MIN, TIMER_TYMPANIC_TANTRUM_MAX);
  519.         uiSpawnAddTimer = TIMER_SPAWN_ADD;
  520.  
  521.  
  522.         if (!hardMode)
  523.             m_creature->ModifyHealth(-transferHealth);
  524.  
  525.  
  526.         m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE);
  527.         phase = 1;
  528.     }
  529.  
  530.  
  531.     // TODO: put in comment and kept for reference. The spell should be fixed properly in spell system, if necessary.
  532.     ////Have to do this the custom way since the original spell messes up player movement
  533.     //void gravityBomb()
  534.     //{
  535.     //    uint32 maxDamage = RAID_MODE(GRAVITY_BOMB_DMG_MAX_10, GRAVITY_BOMB_DMG_MAX_25);
  536.     //    uint32 minDamage = RAID_MODE(GRAVITY_BOMB_DMG_MIN_10, GRAVITY_BOMB_DMG_MIN_25);
  537.     //    uint16 range = GRAVITY_BOMB_RADIUS;
  538.     //    Map* pMap = me->GetMap();
  539.     //    if (pMap && pMap->IsDungeon())
  540.     //    {
  541.     //        Map::PlayerList const &PlayerList = pMap->GetPlayers();
  542.     //        for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
  543.     //        {
  544.     //            //If a player is within the range of the spell
  545.     //            if (i->getSource() && i->getSource()->GetDistance2d(pGravityBombTarget) <= range)
  546.     //            {
  547.     //                //Deal damage to the victim
  548.     //                int32 damage = urand(minDamage, maxDamage);
  549.     //                i->getSource()->ModifyHealth(-damage);
  550.     //                m_creature->SendSpellNonMeleeDamageLog(i->getSource(), SPELL_GRAVITY_BOMB_AURA_10, damage, SPELL_SCHOOL_MASK_SHADOW, 0, 0, false, 0);
  551.  
  552.  
  553.     //                //Replacing the tractor beam effect
  554.     //                i->getSource()->JumpTo(pGravityBombTarget, 5);
  555.     //            }
  556.     //        }
  557.     //    }
  558.     //}
  559. };
  560.  
  561.  
  562. CreatureAI* GetAI_boss_xt002(Creature* pCreature)
  563. {
  564.     return new boss_xt002_AI(pCreature);
  565. }
  566.  
  567.  
  568. /*-------------------------------------------------------
  569.  *
  570.  *        XT-002 HEART
  571.  *
  572.  *///----------------------------------------------------
  573. struct mob_xt002_heartAI : public ScriptedAI
  574. {
  575.     mob_xt002_heartAI(Creature* pCreature) : ScriptedAI(pCreature)
  576.     {
  577.         m_pInstance = pCreature->GetInstanceData();
  578.         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_STUNNED);
  579.         m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE);
  580.         DoCast(m_creature, SPELL_EXPOSED_HEART);
  581.     }
  582.  
  583.  
  584.     ScriptedInstance* m_pInstance;
  585.  
  586.  
  587.     void JustDied(Unit *victim)
  588.     {
  589.         if (m_pInstance)
  590.             if (Creature* pXT002 = m_creature->GetCreature(*m_creature, m_pInstance->GetData64(TYPE_XT002)))
  591.                 if (pXT002->AI())
  592.                     pXT002->AI()->DoAction(ACTION_ENTER_HARD_MODE);
  593.  
  594.  
  595.         //removes the aura
  596.         m_creature->RemoveAurasDueToSpell(SPELL_EXPOSED_HEART);
  597.     }
  598.  
  599.  
  600.     void DamageTaken(Unit *pDone, uint32 &damage)
  601.     {
  602.         if (Creature* pXT002 = m_creature->GetCreature(*m_creature, m_pInstance->GetData64(TYPE_XT002)))
  603.             if (pXT002->AI())
  604.             {
  605.                 uint32 health = m_creature->GetHealth();
  606.                 health -= damage;
  607.                 if (health < 0)
  608.                     health = 0;
  609.  
  610.  
  611.                 pXT002->AI()->SetData(DATA_TRANSFERED_HEALTH, m_creature->GetMaxHealth() - health);
  612.             }
  613.     }
  614. };
  615.  
  616.  
  617. CreatureAI* GetAI_mob_xt002_heart(Creature* pCreature)
  618. {
  619.     return new mob_xt002_heartAI(pCreature);
  620. }
  621.  
  622.  
  623. /*-------------------------------------------------------
  624.  *
  625.  *        XS-013 SCRAPBOT
  626.  *
  627.  *///----------------------------------------------------
  628. struct mob_scrapbotAI : public ScriptedAI
  629. {
  630.     mob_scrapbotAI(Creature* pCreature) : ScriptedAI(pCreature)
  631.     {
  632.         m_pInstance = m_creature->GetInstanceData();
  633.     }
  634.  
  635.  
  636.     ScriptedInstance* m_pInstance;
  637.  
  638.  
  639.     void Reset()
  640.     {
  641.         m_creature->SetReactState(REACT_PASSIVE);
  642.  
  643.  
  644.         if (Creature* pXT002 = m_creature->GetCreature(*m_creature, m_pInstance->GetData64(TYPE_XT002)))
  645.             m_creature->GetMotionMaster()->MoveChase(pXT002);
  646.     }
  647.  
  648.  
  649.     void UpdateAI(const uint32 diff)
  650.     {
  651.         if (Creature* pXT002 = m_creature->GetCreature(*m_creature, m_pInstance->GetData64(TYPE_XT002)))
  652.         {
  653.             if (m_creature->GetDistance2d(pXT002) <= 0.5)
  654.             {
  655.                 // TODO Send raid message
  656.  
  657.  
  658.                 // Increase health with 1 percent
  659.                 pXT002->ModifyHealth(pXT002->GetMaxHealth() * 0.01);
  660.  
  661.  
  662.                 // Despawns the scrapbot
  663.                 m_creature->ForcedDespawn();
  664.             }
  665.         }
  666.     }
  667. };
  668.  
  669.  
  670. CreatureAI* GetAI_mob_scrapbot(Creature* pCreature)
  671. {
  672.     return new mob_scrapbotAI(pCreature);
  673. }
  674.  
  675.  
  676. /*-------------------------------------------------------
  677.  *
  678.  *        XM-024 PUMMELLER
  679.  *
  680.  *///----------------------------------------------------
  681. struct mob_pummellerAI : public ScriptedAI
  682. {
  683.     mob_pummellerAI(Creature* pCreature) : ScriptedAI(pCreature)
  684.     {
  685.         m_pInstance = pCreature->GetInstanceData();
  686.     }
  687.  
  688.  
  689.     ScriptedInstance* m_pInstance;
  690.     int32 uiArcingSmashTimer;
  691.     int32 uiTrampleTimer;
  692.     int32 uiUppercutTimer;
  693.  
  694.  
  695.     void Reset()
  696.     {
  697.         uiArcingSmashTimer = TIMER_ARCING_SMASH;
  698.         uiTrampleTimer = TIMER_TRAMPLE;
  699.         uiUppercutTimer = TIMER_UPPERCUT;
  700.     }
  701.  
  702.  
  703.     void UpdateAI(const uint32 diff)
  704.     {
  705.         if (!UpdateVictim())
  706.             return;
  707.        
  708.         if (m_creature->IsWithinMeleeRange(m_creature->getVictim()))
  709.         {
  710.             if (uiArcingSmashTimer <= diff)
  711.             {
  712.                 DoCast(m_creature->getVictim(), SPELL_ARCING_SMASH);
  713.                 uiArcingSmashTimer = TIMER_ARCING_SMASH;
  714.             } else uiArcingSmashTimer -= diff;
  715.  
  716.  
  717.             if (uiTrampleTimer <= diff)
  718.             {
  719.                 DoCast(m_creature->getVictim(), SPELL_TRAMPLE);
  720.                 uiTrampleTimer = TIMER_TRAMPLE;
  721.             } else uiTrampleTimer -= diff;
  722.  
  723.  
  724.             if (uiUppercutTimer <= diff)
  725.             {
  726.                 DoCast(m_creature->getVictim(), SPELL_UPPERCUT);
  727.                 uiUppercutTimer = TIMER_UPPERCUT;
  728.             } else uiUppercutTimer -= diff;
  729.         }
  730.  
  731.  
  732.         DoMeleeAttackIfReady();
  733.     }
  734. };
  735.  
  736.  
  737. CreatureAI* GetAI_mob_pummeller(Creature* pCreature)
  738. {
  739.     return new mob_pummellerAI(pCreature);
  740. }
  741.  
  742.  
  743. /*-------------------------------------------------------
  744.  *
  745.  *        XE-321 BOOMBOT
  746.  *
  747.  *///----------------------------------------------------
  748. struct mob_boombotAI : public ScriptedAI
  749. {
  750.     mob_boombotAI(Creature* pCreature) : ScriptedAI(pCreature)
  751.     {
  752.         m_pInstance = pCreature->GetInstanceData();
  753.     }
  754.  
  755.  
  756.     ScriptedInstance* m_pInstance;
  757.  
  758.  
  759.     void Reset()
  760.     {
  761.         m_creature->SetReactState(REACT_PASSIVE);
  762.  
  763.  
  764.         if (Creature* pXT002 = m_creature->GetCreature(*m_creature, m_pInstance->GetData64(TYPE_XT002)))
  765.             m_creature->GetMotionMaster()->MoveChase(pXT002);
  766.     }
  767.  
  768.  
  769.     void JustDied(Unit *killer)
  770.     {
  771.         DoCast(SPELL_BOOM);
  772.     }
  773.  
  774.  
  775.     void UpdateAI(const uint32 diff)
  776.     {
  777.         if (Creature* pXT002 = m_creature->GetCreature(*m_creature, m_pInstance->GetData64(TYPE_XT002)))
  778.         {
  779.             if (m_creature->GetDistance2d(pXT002) <= 0.5)
  780.             {
  781.                 //Explosion
  782.                 DoCast(m_creature, SPELL_BOOM);
  783.  
  784.  
  785.                 //Despawns the boombot
  786.                 m_creature->ForcedDespawn();
  787.             }
  788.         }
  789.     }
  790. };
  791.  
  792.  
  793. CreatureAI* GetAI_mob_boombot(Creature* pCreature)
  794. {
  795.     return new mob_boombotAI(pCreature);
  796. }
  797.  
  798.  
  799. /*-------------------------------------------------------
  800.  *
  801.  *        VOID ZONE
  802.  *
  803.  *///----------------------------------------------------
  804. struct mob_void_zoneAI : public ScriptedAI
  805. {
  806.     mob_void_zoneAI(Creature* pCreature) : ScriptedAI(pCreature)
  807.     {
  808.         m_pInstance = pCreature->GetInstanceData();
  809.         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE);
  810.     }
  811.  
  812.  
  813.     ScriptedInstance* m_pInstance;
  814.     uint32 uiVoidZoneTimer;
  815.  
  816.  
  817.     void Reset()
  818.     {
  819.         uiVoidZoneTimer = TIMER_VOID_ZONE;
  820.     }
  821.  
  822.  
  823.     void UpdateAI(const uint32 diff)
  824.     {
  825.         if (uiVoidZoneTimer <= diff)
  826.         {
  827.             //voidZone();
  828.             uiVoidZoneTimer = TIMER_VOID_ZONE;
  829.         } else uiVoidZoneTimer -= diff;
  830.     }
  831.  
  832.  
  833.     // TODO: put in comment and kept for reference. The spell should be fixed properly in spell system, if necessary.
  834.     //void voidZone()
  835.     //{
  836.     //    Map* pMap = me->GetMap();
  837.     //    if (pMap && pMap->IsDungeon())
  838.     //    {
  839.     //        Map::PlayerList const &PlayerList = pMap->GetPlayers();
  840.     //        for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
  841.     //        {
  842.     //            // If a player is within the range of the spell
  843.     //            if (i->getSource() && i->getSource()->GetDistance2d(m_creature) <= 16)
  844.     //            {
  845.     //                // Deal damage to the victim
  846.     //                int32 damage = RAID_MODE(VOID_ZONE_DMG_10, VOID_ZONE_DMG_25);
  847.     //                m_creature->DealDamage(i->getSource(), damage, NULL, SPELL_DIRECT_DAMAGE, SPELL_SCHOOL_MASK_SHADOW);
  848.     //            }
  849.     //        }
  850.     //    }
  851.     //}
  852. };
  853.  
  854.  
  855. CreatureAI* GetAI_mob_void_zone(Creature* pCreature)
  856. {
  857.     return new mob_void_zoneAI(pCreature);
  858. }
  859.  
  860.  
  861. /*-------------------------------------------------------
  862.  *
  863.  *        LIFE SPARK
  864.  *
  865.  *///----------------------------------------------------
  866. struct mob_life_sparkAI : public ScriptedAI
  867. {
  868.     mob_life_sparkAI(Creature* pCreature) : ScriptedAI(pCreature)
  869.     {
  870.         m_pInstance = pCreature->GetInstanceData();
  871.     }
  872.  
  873.  
  874.     ScriptedInstance* m_pInstance;
  875.     uint32 uiShockTimer;
  876.  
  877.  
  878.     void Reset()
  879.     {
  880.         DoCast(m_creature, RAID_MODE(SPELL_STATIC_CHARGED_10, SPELL_STATIC_CHARGED_25));
  881.         uiShockTimer = 0; // first one is immediate.
  882.     }
  883.  
  884.  
  885.     void UpdateAI(const uint32 diff)
  886.     {
  887.         if (!UpdateVictim())
  888.             return;
  889.  
  890.  
  891.         if (uiShockTimer <= diff)
  892.         {
  893.             if (m_creature->IsWithinMeleeRange(m_creature->getVictim()))
  894.             {
  895.                 DoCast(m_creature->getVictim(), SPELL_SHOCK);
  896.                 uiShockTimer = TIMER_SHOCK;
  897.             }
  898.         }
  899.         else uiShockTimer -= diff;
  900.     }
  901. };
  902.  
  903.  
  904. CreatureAI* GetAI_mob_life_spark(Creature* pCreature)
  905. {
  906.     return new mob_life_sparkAI(pCreature);
  907. }
  908.  
  909.  
  910. void AddSC_boss_xt002()
  911. {
  912.     Script *newscript;
  913.  
  914.  
  915.     newscript = new Script;
  916.     newscript->Name = "boss_xt002";
  917.     newscript->GetAI = &GetAI_boss_xt002;
  918.     newscript->RegisterSelf();
  919.  
  920.  
  921.     newscript = new Script;
  922.     newscript->Name = "mob_xt002_heart";
  923.     newscript->GetAI = &GetAI_mob_xt002_heart;
  924.     newscript->RegisterSelf();
  925.  
  926.  
  927.     newscript = new Script;
  928.     newscript->Name = "mob_scrapbot";
  929.     newscript->GetAI = &GetAI_mob_scrapbot;
  930.     newscript->RegisterSelf();
  931.  
  932.  
  933.     newscript = new Script;
  934.     newscript->Name = "mob_pummeller";
  935.     newscript->GetAI = &GetAI_mob_pummeller;
  936.     newscript->RegisterSelf();
  937.  
  938.  
  939.     newscript = new Script;
  940.     newscript->Name = "mob_boombot";
  941.     newscript->GetAI = &GetAI_mob_boombot;
  942.     newscript->RegisterSelf();
  943.  
  944.  
  945.     newscript = new Script;
  946.     newscript->Name = "mob_void_zone";
  947.     newscript->GetAI = &GetAI_mob_void_zone;
  948.     newscript->RegisterSelf();
  949.  
  950.  
  951.     newscript = new Script;
  952.     newscript->Name = "mob_life_spark";
  953.     newscript->GetAI = &GetAI_mob_life_spark;
  954.     newscript->RegisterSelf();
  955. }