Advertisement
Guest User

Mangos Lich King Test

a guest
Mar 29th, 2010
2,779
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.81 KB | None | 0 0
  1. // Script : 2010-03-29 14:11:20
  2. // Run this query on your world database
  3. // UPDATE `creature_template` SET ScriptName='npc_The Lich King' WHERE `entry`=36597;
  4. #include "precompiled.h"
  5.  
  6.  
  7. struct MANGOS_DLL_DECL The Lich KingAI : public ScriptedAI
  8. {
  9.     The Lich KingAI(Creature* pCreature) : ScriptedAI(pCreature)
  10.     {
  11.         Reset();
  12.         SetCombatMovement(false);
  13.     }
  14.  
  15.     uint32 spell1_phase1_Timer;
  16.     uint32 spell2_phase1_Timer;
  17.     uint32 spell3_phase1_Timer;
  18.     uint32 spell4_phase1_Timer;
  19.     uint32 spell5_phase1_Timer;
  20.     uint32 spell6_phase1_Timer;
  21.     uint32 spell1_phase2_Timer;
  22.     uint32 spell2_phase2_Timer;
  23.     uint32 spell3_phase2_Timer;
  24.     uint32 spell4_phase2_Timer;
  25.     uint32 spell5_phase2_Timer;
  26.     uint32 spell1_phase3_Timer;
  27.     uint32 spell2_phase3_Timer;
  28.     uint32 spell1_phase4_Timer;
  29.     uint32 spell2_phase4_Timer;
  30.     uint32 spell3_phase4_Timer;
  31.     uint32 phase1_Percent;
  32.     uint32 phase;
  33.  
  34.     bool enraged;
  35.  
  36.     void Aggro(Unit* pWho)
  37.     {
  38.     }
  39.  
  40.     void KilledUnit(Unit* pVictim)
  41.     {
  42.     }
  43.  
  44.     void JustDied(Unit* pKiller)
  45.     {
  46.     }
  47.  
  48.     void Reset()
  49.     {
  50.         spell1_phase1_Timer = 60000+rand()%40000;
  51.         spell2_phase1_Timer = 30000+rand()%20000;
  52.         spell3_phase1_Timer = 90000+rand()%10000;
  53.         spell4_phase1_Timer = 20000+rand()%20000;
  54.         spell5_phase1_Timer = 40000+rand()%60000;
  55.         spell6_phase1_Timer = 20000+rand()%20000;
  56.         spell1_phase2_Timer = 80000+rand()%20000;
  57.         spell2_phase2_Timer = 50000+rand()%50000;
  58.         spell3_phase2_Timer = 50000+rand()%50000;
  59.         spell4_phase2_Timer = 80000+rand()%20000;
  60.         spell5_phase2_Timer = 40000+rand()%20000;
  61.         spell1_phase3_Timer = 40000+rand()%20000;
  62.         spell2_phase3_Timer = 40000+rand()%20000;
  63.         spell1_phase4_Timer = 20000+rand()%40000;
  64.         spell2_phase4_Timer = 20000+rand()%20000;
  65.         spell3_phase4_Timer = 50000+rand()%10000;
  66.         phase1_Percent = 100;
  67.         phase = 0;
  68.         enraged = false;
  69.     }
  70.  
  71.     void UpdateAI(const uint32 diff)
  72.     {
  73.         if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
  74.             return;
  75.  
  76.         if ((m_creature->GetHealth() * 100 / m_creature->GetMaxHealth() <= 20) && !enraged)
  77.         {
  78.             enraged = true;
  79.             DoCastSpellIfCan(m_creature, 72143);
  80.             m_creature->MonsterYell("You Shall die!", LANG_UNIVERSAL, NULL);
  81.         }
  82.  
  83.         if ((m_creature->GetHealth() * 100 / m_creature->GetMaxHealth() <= 100) && phase == 0)
  84.         {
  85.             phase = 1;
  86.             m_creature->MonsterYell("You will regret this!", LANG_UNIVERSAL, NULL);
  87.         }
  88.  
  89.         if (phase == 1)
  90.         {
  91.  
  92.             if (spell1_phase1_Timer <= diff)
  93.             {
  94.                 DoCastSpellIfCan(SelectUnit(SELECT_TARGET_RANDOM, 0), 70372);
  95.                 spell1_phase1_Timer = 60000+rand()%40000;
  96.             } else spell1_phase1_Timer -= diff;
  97.  
  98.             if (spell2_phase1_Timer <= diff)
  99.             {
  100.                 DoCastSpellIfCan(m_creature->getVictim(), 72149);
  101.                 spell2_phase1_Timer = 30000+rand()%20000;
  102.             } else spell2_phase1_Timer -= diff;
  103.  
  104.             if (spell3_phase1_Timer <= diff)
  105.             {
  106.                 DoCastSpellIfCan(SelectUnit(SELECT_TARGET_RANDOM, 0), 70358);
  107.                 spell3_phase1_Timer = 90000+rand()%10000;
  108.             } else spell3_phase1_Timer -= diff;
  109.  
  110.             if (spell4_phase1_Timer <= diff)
  111.             {
  112.                 DoCastSpellIfCan(SelectUnit(SELECT_TARGET_RANDOM, 0), 70541);
  113.                 spell4_phase1_Timer = 20000+rand()%20000;
  114.             } else spell4_phase1_Timer -= diff;
  115.  
  116.             if (spell5_phase1_Timer <= diff)
  117.             {
  118.                 DoCastSpellIfCan(SelectUnit(SELECT_TARGET_RANDOM, 0), 70337);
  119.                 spell5_phase1_Timer = 40000+rand()%60000;
  120.             } else spell5_phase1_Timer -= diff;
  121.  
  122.             if (spell6_phase1_Timer <= diff)
  123.             {
  124.                 DoCastSpellIfCan(m_creature->getVictim(), 74074);
  125.                 spell6_phase1_Timer = 20000+rand()%20000;
  126.             } else spell6_phase1_Timer -= diff;
  127.         }
  128.  
  129.         if (phase == 2)
  130.         {
  131.  
  132.             if (spell1_phase2_Timer <= diff)
  133.             {
  134.                 DoCastSpellIfCan(SelectUnit(SELECT_TARGET_RANDOM, 0), 69037);
  135.                 spell1_phase2_Timer = 80000+rand()%20000;
  136.             } else spell1_phase2_Timer -= diff;
  137.  
  138.             if (spell2_phase2_Timer <= diff)
  139.             {
  140.                 DoCastSpellIfCan(SelectUnit(SELECT_TARGET_RANDOM, 0), 74352);
  141.                 spell2_phase2_Timer = 50000+rand()%50000;
  142.             } else spell2_phase2_Timer -= diff;
  143.  
  144.             if (spell3_phase2_Timer <= diff)
  145.             {
  146.                 DoCastSpellIfCan(SelectUnit(SELECT_TARGET_RANDOM, 0), 70541);
  147.                 spell3_phase2_Timer = 50000+rand()%50000;
  148.             } else spell3_phase2_Timer -= diff;
  149.  
  150.             if (spell4_phase2_Timer <= diff)
  151.             {
  152.                 DoCastSpellIfCan(m_creature->getVictim(), 69409);
  153.                 spell4_phase2_Timer = 80000+rand()%20000;
  154.             } else spell4_phase2_Timer -= diff;
  155.  
  156.             if (spell5_phase2_Timer <= diff)
  157.             {
  158.                 DoCastSpellIfCan(m_creature->getVictim(), 72754);
  159.                 spell5_phase2_Timer = 40000+rand()%20000;
  160.             } else spell5_phase2_Timer -= diff;
  161.         }
  162.  
  163.         if (phase == 3)
  164.         {
  165.  
  166.             if (spell1_phase3_Timer <= diff)
  167.             {
  168.                 DoCastSpellIfCan(m_creature->getVictim(), 72754);
  169.                 spell1_phase3_Timer = 40000+rand()%20000;
  170.             } else spell1_phase3_Timer -= diff;
  171.  
  172.             if (spell2_phase3_Timer <= diff)
  173.             {
  174.                 DoCastSpellIfCan(SelectUnit(SELECT_TARGET_RANDOM, 0), 69409);
  175.                 spell2_phase3_Timer = 40000+rand()%20000;
  176.             } else spell2_phase3_Timer -= diff;
  177.         }
  178.  
  179.         if (phase == 4)
  180.         {
  181.  
  182.             if (spell1_phase4_Timer <= diff)
  183.             {
  184.                 DoCastSpellIfCan(SelectUnit(SELECT_TARGET_RANDOM, 0), 68980);
  185.                 spell1_phase4_Timer = 20000+rand()%40000;
  186.             } else spell1_phase4_Timer -= diff;
  187.  
  188.             if (spell2_phase4_Timer <= diff)
  189.             {
  190.                 DoCastSpellIfCan(SelectUnit(SELECT_TARGET_RANDOM, 0), 70498);
  191.                 spell2_phase4_Timer = 20000+rand()%20000;
  192.             } else spell2_phase4_Timer -= diff;
  193.  
  194.             if (spell3_phase4_Timer <= diff)
  195.             {
  196.                 DoCastSpellIfCan(m_creature->getVictim(), 70503);
  197.                 spell3_phase4_Timer = 50000+rand()%10000;
  198.             } else spell3_phase4_Timer -= diff;
  199.         }
  200.  
  201.         DoMeleeAttackIfReady();
  202.     }
  203. };
  204.  
  205. CreatureAI* GetAIThe Lich King(Creature* pCreature)
  206. {
  207.     return new The Lich KingAI (pCreature);
  208. }
  209.  
  210. void AddSC_The Lich King()
  211. {
  212.     Script *newscript;
  213.     newscript = new Script;
  214.     newscript->Name = "npc_The Lich King";
  215.     newscript->GetAI = &GetAIThe Lich King;
  216.     newscript->RegisterSelf();
  217. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement