Kel'thuzad Lua menu

User Tag List

Results 1 to 10 of 10
  1. #1
    goldpaw's Avatar Member
    Reputation
    2
    Join Date
    Feb 2009
    Posts
    19
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Kel'thuzad Lua

    I have a question.... why Kel'thuzad when attacked doesn't spawn anyone? He only says: minions, servants of the cold dark.... .I am using VictoRo's script.

    Code:
    ----------[Minion Scripts]-----------------
    
    
    ~~~Soilder of the Frozen Wastes~~~
    
    
    function SoilderoftheFrozenWastes_OnEnterCombat(pUnit,Event)
        pUnit:RegisterEvent("SoilderoftheFrozenWastes_Spell", 5000,1)
    end
    
    
    function SoilderoftheFrozenWastes_Spell(pUnit,Event)
        pUnit:FullCastSpellOnTarget(28457,pUnit:GetClosestPlayer())
     end
    
    
    
    RegisterUnitEvent(16427, 1, "SoilderoftheFrozenWastes_OnEnterCombat")
    
    
    ~~~Unstoppable Abomination~~~
    
    
    function UnstoppableAbomination_OnEnterCombat(pUnit,Event)
        pUnit:RegisterEvent("UnstoppableAbomination_Spell1", 5000,1)
    end
    
    
    function UnstoppableAbomination_Spell1(pUnit,Event)
        pUnit:FullCastSpellOnTarget(25646,pUnit:GetClosestPlayer())
     end
    
    
    
    RegisterUnitEvent(16428, 1, "UnstoppableAbomination_OnEnterCombat")
    
    
    ~~~Soul Weaver~~~
    
    
    function SoulWeaver_OnEnterCombat(pUnit,Event)
        pUnit:RegisterEvent("SoulWeaver_Spell2", 25000,1)
    end
    
    
    function SoulWeaver_Spell2(pUnit,Event)
        pUnit:FullCastSpellOnTarget(28459,pUnit:GetClosestPlayer())
     end
    
    
    
    RegisterUnitEvent(16429, 1, "SoulWeaver_OnEnterCombat")
    
    
    
    ~~~Guardian of Icecrown~~~
    
    function GuardianofIcecrown_OnEnterCombat(pUnit,Event)
        pUnit:RegisterEvent("GuardianofIcecrown_Spell3", 25000,1)
    end
    
    
    function GuardianofIcecrown_Spell3(pUnit,Event)
        pUnit:FullCastSpellOnTarget(28470,pUnit:GetClosestPlayer())
     end
    
    
    
    RegisterUnitEvent(16441, 1, "GuardianofIcecrown_OnEnterCombat")
    
    ----------------------Kel'Thuzad Script iteslf-------------------------------
    
    
    function KelThuzad_Died (pUnit, Event)
    pUnit:RegisterEvent("KelThuzad_Died", 10000,4)
    pUnit:SendChatMessage(5, 0, "AAAAGHHH!... Do not rejoice... your victory is a hollow one... for I shall return with powers beyond your imagining! ")
    
    function KelThuzad_Phase1 (pUnit, Event)
    pUnit:SendBroadcastMessage(You have engaged the Kel'Thuzad fight!)
    pUnit:SendChatMessage(5, 0, "Minions, servants, soldiers of the cold dark, obey the call of Kel'Thuzad!")
    pUnit:SetCombatCapable(1)
    pUnit:Despawn(0, 280000)
    pUnit:RegisterEvent("O'Brien_Phase2")
    pUnit:RegisterEvent("O'Brien_Phase3")
    end
    
    
    function KelThuzad_KilledTarget (pUnit, Event)
    pUnit:SendChatMessage(5, 0, "The dark void awaits you!")
    end
    
    
    -------------Phase 1------------------
    
    Kel'Thuzad is invulnerable, and you need kill adds which come from the seven cubbies.
    
        * Soldier of the Frozen Wastes - Casts Dark Blast when it touches an enemy unit causing 3063 to 3937 shadow damage to the raid and will kill the Soldier itself. Dark Blast is not partially resistible. Surprisingly, these are able to be shackled. Slow move speed. 1,600 hit points. 71 will attack through phase one, though more may be pulled accidentally. 
    
        * Unstoppable Abomination - Periodically applies Mortal Wound, a stacking "-10% healing received" debuff to its target. It will randomly choose one melee range target, so multiple tanks work best for this mob. They spawn progressively faster as phase 2 approaches, they must be killed as fast as possible to avoid having multiple abominations up when Kel'Thuzad becomes active. ~75,000 hit points. Normal run speed. Eight will attack through phase one, though more may be pulled accidentally or intentionally for achievements. Hits for ~4,000 on plate, mortal wounds for 6,000. 
    
        * Soul Weaver - Wail of Souls Inflicts 6375–8625 shadow damage and does a 30 yard knock-back that hits 3 players. It will only do this attack when it is near its primary aggro target. ~55,000 hit points. Slow movement speed. Eight will attack through phase one, though more may be pulled accidentally. 
    
    function KelThuzad_Phase1 (pUnit, Event)
    pUnit:SendBroadcastMessage(The battle for Azeroth has begun!)
    pUnit:SendChatMessage(5, 0, "Minions, servants, soldiers of the cold dark, obey the call of Kel'Thuzad!")
    pUnit:SetCombatCapable(1)
    pUnit:Despawn(0, 280000)
         x=GetX();
         y=GetY();
         z=GetZ();
         o=GetO();
      pUnit:SpawnCreature(16427, x,+7 y+1, z, 0, 20, 0)
      pUnit:SpawnCreature(16427, x+6, y,+1 z, 0, 20, 0)
      pUnit:SpawnCreature(16427, x-10, y+1, z, 0, 20, 0)
      pUnit:SpawnCreature(16427, x-8, y+1, z, 0, 20, 0)
      pUnit:SpawnCreature(16427, x-2, y+1, z, 0, 20, 0)
      pUnit:SpawnCreature(16427, x,+7 y+1, z, 0, 20, 0)
      pUnit:SpawnCreature(16427, x+6, y,+1 z, 0, 20, 0)
      pUnit:SpawnCreature(16427, x-10, y+1, z, 0, 20, 0)
      pUnit:SpawnCreature(16427, x-8, y+1, z, 0, 20, 0)
      pUnit:SpawnCreature(16427, x-2, y+1, z, 0, 20, 0)
      pUnit:SpawnCreature(16428, x+13, y+1, z, 0, 20, 0)
      pUnit:SpawnCreature(16428, x-10, y+1, z, 0, 20, 0)
      pUnit:SpawnCreature(16428, x+13, y+1, z, 0, 20, 0)
      pUnit:SpawnCreature(16428, x-13, y+1, z, 0, 20, 0)
      pUnit:SpawnCreature(16428, x-14, y+1, z, 0, 20, 0)
      pUnit:SpawnCreature(16428, x+9, y+1, z, 0, 20, 0)
      pUnit:SpawnCreature(16428, x-15, y+1, z, 0, 20, 0)
      pUnit:SpawnCreature(16428, x-14, y+1, z, 0, 20, 0)
      pUnit:SpawnCreature(16428, x+11, y+1, z, 0, 20, 0)
      pUnit:SpawnCreature(16429, x+13, y+1, z, 0, 20, 0)
      pUnit:SpawnCreature(16429, x+12, y+1, z, 0, 20, 0)
      pUnit:SpawnCreature(16429, x+25, y+1, z, 0, 20, 0)
      pUnit:SpawnCreature(16429, x+16, y+1, z, 0, 20, 0)
      pUnit:SpawnCreature(16429, x+27, y+1, z, 0, 20, 0)
      pUnit:SpawnCreature(16429, x+14, y+1, z, 0, 20, 0)
    pUnit:RegisterEvent("O'Brien_Phase2")
    pUnit:RegisterEvent("O'Brien_Phase3")
    end
    
    
    ------------------------Phase 2--------------------------
    
    ~Stage 2 begins 3 minutes and 48 seconds after you engage Kel'Thuzad. He becomes active, and has approximately 5,660,000 hit points.
    
        * Frost bolt single 2 second cast. Inflicts 10063–12937 Frost damage to primary aggro target and reduces its movement speed for 4 sec. This spell is not reflectable via Warrior Spell Reflection. 
    
        * Frost bolt multiple Inflicts 4500–5500 Frost damage and reduces the targets' movement speed for 4 sec. Hits everyone in the room and cannot be interrupted - it is instant cast. Used every 15 secs. Fully resistible. 
    
        * Mana Detonation A debuff randomly applied to a mana using player. The player will explode after 5 seconds, burn 2000 mana and deal 10,000 damage to all players within 10 yards of him (not to himself). 
    
        * Shadow Fissure Summons a very noticeable red fissure around the targeted player which does 62500–137500 shadow damage after 5 seconds as Void Blast. Easily avoidable by running out of the fissure. 
    
        * Frost Blast Places an Ice Block effect on the targeted player, and all players within 10 yards, rendering them unable to perform any action. This effect will continue to chain to anyone within 10 yards of anyone affected as with C'thun's Eye Beam. It will deal 104% of their maximum HP in damage over 4 seconds. If those affected are not healed within 4 seconds they will die. ~
    
    
    function KelThuzad_Phase2(pUnit,Event)
    pUnit:RegisterEvent("KelThuzad_Frostbolt1", 30000,1)
    pUnit:RegisterEvent("KelThuzad_frostbolt2", 15000,1)
    pUnit:RegisterEvent("KelThuzad_ManaDetonation", 22500,1)
    pUnit:RegisterEvent("KelThuzad_"ShadowFissure", 17500,1)
    pUnit:RegisterEvent("KelThuzad_FrostBlast", 53500,1)
    pUnit:RegisterEvent("KelThuzad_ChainsofKelthuzad", 105000,1)
     Choice=math.random(1,3)
    if Choice==1 then
      pUnit:SendChatMessage(14, 0, "Pray for mercy!")
     end
    if Choice==2 then
      pUnit:SendChatMessage(14, 0, "Scream your dying breath!")
     end
    if Choice==3 then
      pUnit:SendChatMessage(14, 0, "The end is upon you!")
     end
    end
    end
    
    function KelThuzad_frostbolt2(pUnit,Event)
        pUnit:FullCastSpellOnTarget(28479,pUnit:GetClosestPlayer())
    end
    
    function KelThuzad_Frostbolt1(pUnit,Event)
        pUnit:FullCastSpellOnTarget(28478,pUnit:GetMainTank())
    end
    
    function KelThuzad_ManaDetonation(pUnit,Event)
        pUnit:FullCastSpellOnTarget(27819,pUnit:GetClosestPlayer())
     Choice=math.random(1,2)
    if Choice==1 then
      pUnit:SendChatMessage(14, 0, "Your petty magics ar no challenge to the might of the Scourge!")
     end
    if Choice==2 then
      pUnit:SendChatMessage(14, 0, "Enoug! I grow tired of these distractions!")
    end
    end
    
    function KelThuzad_ShadowFissure(pUnit,Event)
        pUnit:FullCastSpellOnTarget(27810,pUnit:GetClosestPlayer())
    end
    
    function KelThuzad_FrostBlast(pUnit,Event)
        pUnit:FullCastSpellOnTarget(27808,pUnit:GetClosestPlayer())
        pUnit:SendChatMessage(14, 0, "I will freeze the blood in your veins!")
    end
    
    function KelThuzad_ChainsofKelthuzad(pUnit,Event)
        pUnit:FullCastSpellOnTarget(28410,pUnit:GetClosestPlayer())
     Choice=math.random(1,3)
    if Choice==1 then
      pUnit:SendChatMessage(14, 0, "Your soul, is bound to me now!")
     end
    if Choice==2 then
      pUnit:SendChatMessage(14, 0, "There will be no escape!")
    end
    end
    
    
    -----------------Phase 3-----------------------------------
    ~At 45% health, Phase Three will begin as Kel'Thuzad calls for aid and the Lich King sends two Nerubian Crypt Lords known as the Guardians of Icecrown to attack the raid.
    
        * Guardian of Icecrown - These have as much HP as Kel'Thuzad (combined) with the ability: Blood Tap. Which is a self buff that does +15% all damage, + 10% size and can stack up to 99 times. The Guardians will flee when Kel'Thuzad dies. Immune to CC. The Guardians stack Blood Tap every ~15 seconds and it hits their aggro target for ~3,000. They hit for ~2,000 on plate to start but this increases rapidly over time.~
    
    
    function KelThuzad_Phase3 (pUnit, Event)
    if pUnit:GetHealthPct() < 45 then
    pUnit:SendChatMessage(5, 0, "Master! I require aid!")
    pUnit:SendBroadcastMessage(Very well... warriors of the frozen wastes, rise up! I command you to fight, kill, and die for your master. Let none survive...")
         x=GetX();
         y=GetY();
         z=GetZ();
         o=GetO();
      pUnit:SpawnCreature(16441, x,+7 y+1, z, 0, 20, 0)
      pUnit:SpawnCreature(16441, x,+7 y+1, z, 0, 20, 0)
    end
    end
    
    
    RegisterUnitEvent(15990, 1, "KelThuzad_OnEnterCombat")
    RegisterUnitEvent(15990, 4, "KelThuzad_Died")
    RegisterUnitEvent(15990, 3, "KelThuzad_KilledTarget")
    RegisterUnitEvent(15990, 2, "KelThuzad_OnLeaveCombat")

    Kel'thuzad Lua
  2. #2
    gotiefan's Avatar Sergeant
    Reputation
    1
    Join Date
    Jan 2008
    Posts
    54
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've got the same problem.. Does anyone know a fix for this?

    Edit: It worked after I waited 15 min...

    And I've just checked inside my ArcEmu raid script source. And there is a script inside for Kel'thuzad.

    So I removed the lua one, and started again. And it did exactly the same... So I do not think it's the LUA but the script inside the source.

    Code:
    // -- Kel'thuzad Encounter by M4ksiu -- //
    
    // Encounter mobs
    
    #define CN_THE_LICH_KING 30002
    #define CN_SOLDIER_OF_THE_FROZEN_WASTES 16427
    #define CN_UNSTOPPABLE_ABOMINATION 16428
    #define CN_SOUL_WEAVER 16429
    #define CN_GUARDIAN_OF_ICECROWN 16441
    
    /*
      _____
     /  K  \
    /1     4\
    |       |
    |2     5|
    |       |
    \3     6/
     \_ 7 _/
       | |
    
    */
    
    static Spawns SFrozenWastes[] =	// Soldier of the Frozen Wastes (no idea about those :| )
    {
    	{ 3759.149902f, -5074.879883f, 143.175003f, 1.203640f },	// 1
    	{ 3762.959961f, -5067.399902f, 143.453003f, 0.893413f },
    	{ 3772.419922f, -5076.379883f, 143.466995f, 3.606970f },
    	{ 3779.699951f, -5078.180176f, 143.764008f, 4.038940f },
    	{ 3770.219971f, -5065.740234f, 143.477005f, 0.630304f },
    	{ 3765.709961f, -5060.799805f, 143.748001f, 1.608120f },
    	{ 3776.909912f, -5066.100098f, 143.550003f, 5.130640f },
    	{ 3782.659912f, -5069.529785f, 143.757004f, 5.150280f },
    	{ 3773.909912f, -5059.589844f, 143.774002f, 6.257680f },
    	{ 3780.260010f, -5061.580078f, 143.742996f, 5.169910f },
    	{ 3721.429932f, -5052.759766f, 143.442993f, 1.457330f },	// 2
    	{ 3732.149902f, -5051.589844f, 143.444000f, 1.017500f },
    	{ 3741.889893f, -5047.439941f, 143.886002f, 3.075250f },
    	{ 3726.229980f, -5043.410156f, 143.455994f, 6.150070f },
    	{ 3718.679932f, -5042.520020f, 143.768005f, 1.614410f },
    	{ 3733.060059f, -5040.979980f, 143.557007f, 1.669380f },
    	{ 3741.860107f, -5038.410156f, 143.917999f, 4.410420f },
    	{ 3736.189941f, -5032.810059f, 143.847000f, 5.026970f },
    	{ 3723.219971f, -5035.770020f, 143.764999f, 4.701020f },
    	{ 3728.760010f, -5031.759766f, 143.785995f, 3.723200f },
    	{ 3683.189941f, -5062.419922f, 143.175995f, 0.559623f },	// 3
    	{ 3687.739990f, -5057.779785f, 143.175995f, 1.345020f },
    	{ 3674.040039f, -5067.899902f, 143.524994f, 0.005909f },
    	{ 3688.340088f, -5052.009766f, 143.473007f, 2.299280f },
    	{ 3681.659912f, -5052.549805f, 143.263000f, 3.343860f },
    	{ 3678.840080f, -5055.529785f, 143.332993f, 3.512720f },
    	{ 3685.800049f, -5045.779785f, 143.615997f, 6.253750f },
    	{ 3673.479980f, -5053.350098f, 143.554993f, 1.945840f },
    	{ 3670.649902f, -5061.149902f, 143.820007f, 4.266700f },
    	{ 3688.018311f, -5061.541992f, 143.178223f, 0.512497f },
    	{ 3742.659912f, -5157.009766f, 143.171005f, 0.773261f },	// 4
    	{ 3750.310059f, -5153.779785f, 143.179993f, 5.603460f },
    	{ 3739.770020f, -5163.000000f, 143.662994f, 1.095270f },
    	{ 3746.649902f, -5164.560059f, 143.520004f, 1.970990f },
    	{ 3748.479980f, -5169.109863f, 143.649002f, 2.591460f },
    	{ 3744.560059f, -5173.520020f, 143.895996f, 1.370160f },
    	{ 3758.260010f, -5156.299805f, 143.570999f, 6.192510f },
    	{ 3762.620117f, -5159.149902f, 143.712997f, 4.433220f },
    	{ 3760.840088f, -5162.959961f, 143.649002f, 4.280060f },
    	{ 3756.580078f, -5170.060059f, 143.623001f, 3.031280f },
    	{ 3705.229980f, -5163.189941f, 143.266998f, 5.692200f },	// 5
    	{ 3696.949951f, -5163.370117f, 143.608002f, 0.901274f },
    	{ 3710.080078f, -5168.709961f, 143.585999f, 4.675110f },
    	{ 3697.030029f, -5170.220215f, 143.606003f, 0.343642f },
    	{ 3692.030029f, -5170.020020f, 143.815994f, 0.932691f },
    	{ 3710.320068f, -5175.319824f, 143.705002f, 4.639770f },
    	{ 3694.550049f, -5177.540039f, 143.839005f, 1.549230f },
    	{ 3705.830078f, -5179.120117f, 143.729996f, 3.956480f },
    	{ 3712.800049f, -5179.109863f, 143.891006f, 3.855950f },
    	{ 3701.669922f, -5181.859863f, 143.804001f, 1.380370f },
    	{ 3676.590088f, -5144.899902f, 143.186005f, 3.575550f },	// 6
    	{ 3670.649902f, -5142.629883f, 143.173996f, 4.313820f },
    	{ 3665.689941f, -5136.279785f, 143.177994f, 1.176150f },
    	{ 3664.870117f, -5132.330078f, 143.205002f, 3.249600f },
    	{ 3662.120117f, -5144.299805f, 143.320007f, 2.256080f },
    	{ 3658.979980f, -5139.490234f, 143.421997f, 6.077040f },
    	{ 3651.850098f, -5137.140137f, 143.764999f, 0.799161f },
    	{ 3654.689941f, -5144.009766f, 143.546997f, 2.519180f },
    	{ 3666.020020f, -5149.500000f, 143.587006f, 3.359560f },
    	{ 3667.959961f, -5153.120117f, 143.791000f, 4.015380f },
    	{ 3659.979980f, -5100.450195f, 143.453003f, 5.168254f },	// 7
    	{ 3662.800049f, -5088.189941f, 143.557999f, 4.409650f },
    	{ 3658.439941f, -5090.649902f, 143.470001f, 5.528840f },
    	{ 3652.810059f, -5090.450195f, 143.475998f, 1.362310f },
    	{ 3651.780029f, -5095.339844f, 143.388000f, 0.981387f },
    	{ 3652.629883f, -5098.970215f, 143.544998f, 2.799580f },
    	{ 3652.679932f, -5083.479980f, 143.774994f, 0.482659f },
    	{ 3647.189941f, -5085.490234f, 143.570999f, 1.919940f },
    	{ 3645.120117f, -5097.240234f, 143.487000f, 0.765403f },
    	{ 3646.360107f, -5101.200195f, 143.681000f, 2.909540f }
    };
    
    static Spawns Abomination[] =	// Unstoppable Abomination
    {
    	{ 3776.229980f, -5081.439941f, 143.779999f, 4.043730f },	// 1
    	{ 3774.419922f, -5071.490234f, 143.423996f, 4.214940f },
    	{ 3759.850098f, -5064.479980f, 143.636002f, 6.255410f },
    	{ 3740.899902f, -5052.740234f, 143.785995f, 1.836760f },	// 2
    	{ 3726.919922f, -5040.020020f, 143.535995f, 2.481570f },
    	{ 3715.010010f, -5049.259766f, 143.632004f, 5.071810f },
    	{ 3695.060059f, -5052.160156f, 143.548004f, 3.792400f },	// 3
    	{ 3678.129883f, -5048.060059f, 143.436996f, 5.363980f },
    	{ 3676.120117f, -5061.359863f, 143.492004f, 5.726840f },
    	{ 3756.780029f, -5149.419922f, 143.460007f, 2.774530f },	// 4
    	{ 3752.262695f, -5164.782227f, 143.409119f, 0.383768f },
    	{ 3740.669922f, -5168.600098f, 143.873993f, 1.051360f },
    	{ 3714.020020f, -5171.129883f, 143.776993f, 1.742510f },	// 5
    	{ 3702.185303f, -5174.303711f, 143.532303f, 5.443298f },
    	{ 3693.739990f, -5162.149902f, 143.748001f, 5.696990f },
    	{ 3673.189941f, -5150.500000f, 143.751999f, 3.030570f },	// 6
    	{ 3658.570068f, -5147.799805f, 143.494003f, 1.230440f },
    	{ 3659.560059f, -5132.129883f, 143.677002f, 5.988380f },
    	{ 3651.130859f, -5104.800293f, 143.798248f, 5.374194f },	// 7
    	{ 3646.947021f, -5092.266113f, 143.305878f, 5.005841f },
    	{ 3658.618408f, -5083.832031f, 143.778641f, 5.951464f }
    };
    
    static Spawns SoulWeaver[] =	// Soul Weaver
    {
    	{ 3768.540039f, -5075.140137f, 143.203995f, 5.096160f },
    	{ 3728.030029f, -5047.359863f, 143.306000f, 5.230460f },
    	{ 3682.929932f, -5055.819824f, 143.184006f, 5.368690f },
    	{ 3749.429932f, -5160.419922f, 143.283997f, 4.723090f },
    	{ 3706.120117f, -5169.250000f, 143.436996f, 2.682630f },
    	{ 3665.310059f, -5142.339844f, 143.220001f, 1.147180f },
    	{ 3656.365234f, -5094.724121f, 143.306641f, 6.203571f }
    };
    
    static Spawns Guardians[] =		// Guardians of Icecrown
    {
    	{ 3778.371582f, -5065.141113f, 143.614639f, 3.700061f },
    	{ 3731.733398f, -5032.681152f, 143.775040f, 4.485459f },
    	{ 3758.592285f, -5170.157715f, 143.667297f, 2.144972f },
    	{ 3700.936279f, -5183.230469f, 143.858582f, 1.314648f }
    };
    
    static Spawns Waves[] =			// Spawn positions of units that attack circle
    {
    	{ 3756.380615f, -5080.560059f, 142.906921f, 3.762599f },
    	{ 3726.448242f, -5058.546387f, 142.467331f, 4.262112f },
    	{ 3690.084229f, -5066.993164f, 142.705917f, 5.245427f },
    	{ 3742.711670f, -5146.786133f, 142.964890f, 2.178441f },
    	{ 3706.024902f, -5155.362793f, 142.655304f, 1.294868f },
    	{ 3676.363281f, -5133.007324f, 142.806168f, 0.615499f },
    	{ 3668.310303f, -5096.927246f, 142.307312f, 6.128994f }
    };
    
    // Kel'thuzad AI
    // each ~10-20 sec new mob
    
    #define CN_KELTHUZAD 15990
    
    #define SFROSTBOLT 28478
    #define MFROSTBOLT 28479
    #define CHAINS_OF_KELTHUZAD 28410
    #define DETONATE_MANA 27819
    #define SHADOW_FISSURE 27810
    #define FROST_BLAST 27808
    
    #define KELTHUZAD_CHANNEL 29423
    
    class KelthuzadAI : public CreatureAIScript
    {
    public:
    	ADD_CREATURE_FACTORY_FUNCTION(KelthuzadAI);
    	SP_AI_Spell spells[7];
    	bool m_spellcheck[7];
    	bool FrozenWastes[7];
    	bool Abominations[7];
    	bool SoulWeavers[7];
    
        KelthuzadAI(Creature* pCreature) : CreatureAIScript(pCreature)
        {
    		nrspells = 6;
    
    		for(int i=0;i<nrspells;i++)
    		{
    			m_spellcheck[i] = false;
    			spells[i].casttime = 0;
    		}
    
    		for (int i = 0; i < 7; i++)
    		{
    			FrozenWastes[i] = false;
    			Abominations[i] = false;
    			SoulWeavers[i] = false;
    		}
    		
            spells[0].info = dbcSpell.LookupEntry(SFROSTBOLT);
    		spells[0].targettype = TARGET_ATTACKING;
    		spells[0].instant = false;
    		spells[0].perctrigger = 7.0f;
    		spells[0].cooldown = 0;
    		spells[0].attackstoptimer = 2000;
    
    		spells[1].info = dbcSpell.LookupEntry(MFROSTBOLT);
    		spells[1].targettype = TARGET_VARIOUS;
    		spells[1].instant = true;
    		spells[1].perctrigger = 0.1f;
    		spells[1].cooldown = 15;			// it's casted after 15 sec anyway, so it does need additional perctrigger
    		spells[1].attackstoptimer = 1000;
    
    		spells[2].info = dbcSpell.LookupEntry(CHAINS_OF_KELTHUZAD);
    		spells[2].targettype = TARGET_RANDOM_SINGLE;
    		spells[2].instant = true;
    		spells[2].perctrigger = 5.0f;
    		spells[2].cooldown = 20;
    		spells[2].attackstoptimer = 1000;
    		spells[2].mindist2cast = 0.0f;
    		spells[2].maxdist2cast = 40.0f;
    		spells[2].minhp2cast = 0;
    		spells[2].maxhp2cast = 100;
    
    		spells[3].info = dbcSpell.LookupEntry(DETONATE_MANA);
    		spells[3].targettype = TARGET_RANDOM_SINGLE;
    		spells[3].instant = true;
    		spells[3].perctrigger = 6.0f;
    		spells[3].cooldown = 7;
    		spells[3].attackstoptimer = 2000;
    		spells[3].mindist2cast = 0.0f;
    		spells[3].maxdist2cast = 40.0f;
    		spells[3].minhp2cast = 0;
    		spells[3].maxhp2cast = 100;
    
    		spells[4].info = dbcSpell.LookupEntry(SHADOW_FISSURE);
    		spells[4].targettype = TARGET_ATTACKING;
    		spells[4].instant = true;
    		spells[4].perctrigger = 5.0f;
    		spells[4].cooldown = 10;
    		spells[4].attackstoptimer = 2000;
    
    		spells[5].info = dbcSpell.LookupEntry(FROST_BLAST);
    		spells[5].targettype = TARGET_RANDOM_SINGLE;
    		spells[5].instant = true;
    		spells[5].perctrigger = 6.0f;
    		spells[5].cooldown = 10;
    		spells[5].attackstoptimer = 2000;
    		spells[5].soundid = 8815;
    		spells[5].speech = "I shall freeze the blood in your veins!";	// not sure if it's to this one or to one of bolt spells
    		spells[5].mindist2cast = 0.0f;
    		spells[5].maxdist2cast = 40.0f;
    		spells[5].minhp2cast = 0;
    		spells[5].maxhp2cast = 100;
    
    		spells[6].info = dbcSpell.LookupEntry(KELTHUZAD_CHANNEL);
    		spells[6].targettype = TARGET_SELF;
    		spells[6].instant = false;
    		spells[6].perctrigger = 0.0f;
    		spells[6].cooldown = 0;
    		spells[6].attackstoptimer = 1000;
    
    		_unit->GetAIInterface()->disable_melee = false;
    		_unit->SetUInt64Value(UNIT_FIELD_FLAGS, 0);
    		_unit->GetAIInterface()->m_canMove = true;
    
    		DespawnTrash = false;
    		EventStart = false;
    		SpawnCounter = 0;
    		PhaseTimer = 310;
    		SpawnTimer = 0;
    		GCounter = 0;
    		m_phase = 0;
        }
        
        void OnCombatStart(Unit* mTarget)
        {
    		_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "Minions, servants, soldiers of the cold dark, obey the call of Kel'Thuzad!");
    		_unit->PlaySoundToSet(8819);
    
    		Unit* TheLichKing = NULL;
    		TheLichKing = _unit->GetMapMgr()->GetInterface()->GetCreatureNearestCoords(3767.58f, -5117.15f, 174.49f, CN_THE_LICH_KING);
    		if (TheLichKing != NULL)
    		{
    			_unit->SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT, TheLichKing->GetGUID());
    			_unit->SetUInt32Value(UNIT_CHANNEL_SPELL, 29423);
    		}
    
    		GameObject* KelGate  = _unit->GetMapMgr()->GetInterface()->GetGameObjectNearestCoords(3635.44f, -5090.33f, 143.205f, 181228);
    					
    		if (KelGate)
    			KelGate->SetByte(GAMEOBJECT_BYTES_1, 0, 1);
    
    		_unit->SetUInt64Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
    		_unit->GetAIInterface()->disable_melee = true;
    		_unit->GetAIInterface()->m_canMove = false;
    		
            RegisterAIUpdateEvent(1000);
    		CastTime();
    
    		DespawnTrash = false;
    		EventStart = true;
    		SpawnCounter = 0;
    		PhaseTimer = 310;
    		SpawnTimer = 0;
    		GCounter = 0;
    		m_phase = 1;
        }
    
        void OnCombatStop(Unit *mTarget)
        {
    		GameObject* KelGate  = _unit->GetMapMgr()->GetInterface()->GetGameObjectNearestCoords(3635.44f, -5090.33f, 143.205f, 181228);
    		if (KelGate != NULL)
    			KelGate->SetByte(GAMEOBJECT_BYTES_1, 0, 0);
    
    		for (int i = 0; i < 4; i++)
    		{
    			GameObject* WindowGate  = _unit->GetMapMgr()->GetInterface()->GetGameObjectNearestCoords(Guardians[i].x, Guardians[i].y, Guardians[i].z, 200002);		
    			if (WindowGate != NULL)
    				WindowGate->SetByte(GAMEOBJECT_BYTES_1, 0, 1);
    		}
    
    		_unit->SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT, 0);
    		_unit->SetUInt32Value(UNIT_CHANNEL_SPELL, 0);
            _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL);
            _unit->GetAIInterface()->SetAIState(STATE_IDLE);
    		_unit->GetAIInterface()->disable_melee = false;
    		_unit->SetUInt64Value(UNIT_FIELD_FLAGS, 0);
    		_unit->GetAIInterface()->m_canMove = true;
            RemoveAIUpdateEvent();
    
    		DespawnTrash = true;
    		EventStart = false;
    		SpawnCounter = 0;
    		PhaseTimer = 310;
    		SpawnTimer = 0;
    		GCounter = 0;
    		m_phase = 0;
        }
    
    	void CastTime()
    	{
    		for(int i=0;i<nrspells;i++)
    			spells[i].casttime = 0;
    	}
    
    	void OnTargetDied(Unit* mTarget)
    	{
    		if (_unit->GetHealthPct() == 0) return;
    
    		uint32 RandomSpeach = rand()%2;
    		switch (RandomSpeach)
    		{
    		case 0:
    			_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "The dark void awaits you!");
    			_unit->PlaySoundToSet(8817);
    			break;
    		case 1:
    			//_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "");	// no text?
    			_unit->PlaySoundToSet(8818);
    			break;
    		}
    	}
    
        void OnDied(Unit * mKiller)
        {
    		GameObject* KelGate  = _unit->GetMapMgr()->GetInterface()->GetGameObjectNearestCoords(3635.44f, -5090.33f, 143.205f, 181228);	
    		if (KelGate != NULL)
    			KelGate->SetByte(GAMEOBJECT_BYTES_1, 0, 0);
    
    		for (int i = 0; i < 4; i++)
    		{
    			GameObject* WindowGate  = _unit->GetMapMgr()->GetInterface()->GetGameObjectNearestCoords(Guardians[i].x, Guardians[i].y, Guardians[i].z, 200002);
    			if (WindowGate != NULL)
    				WindowGate->SetByte(GAMEOBJECT_BYTES_1, 0, 1);
    		}
    
    		_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "Do not rejoice... your victory is a hollow one... for I shall return with powers beyond your imagining!");
    		_unit->PlaySoundToSet(8814);
    
    		_unit->GetAIInterface()->disable_melee = false;
    		_unit->SetUInt64Value(UNIT_FIELD_FLAGS, 0);
    		_unit->GetAIInterface()->m_canMove = true;
    		RemoveAIUpdateEvent();
    
    		EventStart = false;
    		SpawnCounter = 0;
    		PhaseTimer = 310;
    		SpawnTimer = 0;
    		GCounter = 0;
    		m_phase = 0;
        }
    
        void AIUpdate()
        {
    		switch (m_phase)
    		{
    		case 1:
    			PhaseOne();
    			break;
    		case 2:
    			PhaseTwo();
    			break;
    		case 3:
    			PhaseThree();
    			break;
    		default:
    			{
    			}
    		}
        }
    
    	void PhaseOne()
    	{
    		if (EventStart == true)
    		{
    			SpawnTimer++;
    			if (SpawnTimer == 5 || SpawnTimer == 10)
    			{
    				for (int i = 0; i < 7; i++)
    				{
    					int Counter = 0;
    
    					while (Counter == 0)
    					{
    						if (FrozenWastes[i] == false && (rand()%3 == 0 || SpawnCounter > 0))
    						{
    							for (int x = 0; x < 10; x++)
    							{
    								uint32 SpawnID = 10*i + x;
    								_unit->GetMapMgr()->GetInterface()->SpawnCreature(CN_SOLDIER_OF_THE_FROZEN_WASTES, SFrozenWastes[SpawnID].x, SFrozenWastes[SpawnID].y, SFrozenWastes[SpawnID].z, SFrozenWastes[SpawnID].o, false, false, 0, 0);
    							}
    
    							FrozenWastes[i] = true;
    							Counter++;
    						}
    
    						if (Abominations[i] == false && (rand()%3 == 0 || SpawnCounter > 0))
    						{
    							for (int x = 0; x < 3; x++)
    							{
    								uint32 SpawnID = 3*i + x;
    								_unit->GetMapMgr()->GetInterface()->SpawnCreature(CN_UNSTOPPABLE_ABOMINATION, Abomination[SpawnID].x, Abomination[SpawnID].y, Abomination[SpawnID].z, Abomination[SpawnID].o, false, false, 0, 0);
    							}
    
    							Abominations[i] = true;
    							Counter++;
    						}
    
    						if (SoulWeavers[i] == false && ((rand()%3 == 0 && Counter < 2) || Counter == 0 || SpawnCounter > 0))
    						{
    							uint32 SpawnID = i;
    							_unit->GetMapMgr()->GetInterface()->SpawnCreature(CN_SOUL_WEAVER, SoulWeaver[SpawnID].x, SoulWeaver[SpawnID].y, SoulWeaver[SpawnID].z, SoulWeaver[SpawnID].o, false, false, 0, 0);
    						
    							SoulWeavers[i] = true;
    							Counter++;
    						}
    
    						if (SoulWeavers[i] == true && Abominations[i] == true && FrozenWastes[i] == true)
    							Counter = 1;
    					}
    				}
    
    				SpawnCounter++;
    			}
    
    			if (SpawnCounter == 2)
    			{
    				for (int i = 0; i < 7; i++)
    				{
    					FrozenWastes[i] = false;
    					Abominations[i] = false;
    					SoulWeavers[i] = false;
    				}
    
    				WaveTimer = rand()%6+10;
    				EventStart = false;
    				SpawnCounter = 0;
    				PhaseTimer = 310;
    				SpawnTimer = 0;
    			}
    		}
    
    		else
    		{
    			PhaseTimer--;
    			WaveTimer--;
    
    			if (PhaseTimer == 5)
    			{
    				uint32 RandomSpeach = rand()%3;
    				switch (RandomSpeach)
    				{
    				case 0:
    					_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "Pray for mercy!");
    					_unit->PlaySoundToSet(8809);
    					break;
    				case 1:
    					_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "Scream your dying breath!");
    					_unit->PlaySoundToSet(8810);
    					break;
    				case 2:
    					_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "The end is upon you!");
    					_unit->PlaySoundToSet(8811);
    					break;
    				}
    			}
    
    			if (PhaseTimer == 3)
    				DespawnTrash = true;
    
    			if (!PhaseTimer)
    			{
    				_unit->SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT, 0);
    				_unit->SetUInt32Value(UNIT_CHANNEL_SPELL, 0);
    				_unit->GetAIInterface()->disable_melee = false;
    				_unit->SetUInt64Value(UNIT_FIELD_FLAGS, 0);
    				_unit->GetAIInterface()->m_canMove = true;
    				
    				DespawnTrash = false;
    				HelpDialog = 0;
    				GCounter = 0;
    				m_phase = 2;
    				return;
    			}
    
    			else if (!WaveTimer && PhaseTimer > 5)
    			{
    				uint32 SpawnPoint = RandomUInt(7);
    				uint32 RandomSU;
    				if (PhaseTimer > 250)
    					RandomSU = RandomUInt(4);
    				if (PhaseTimer <= 250 && PhaseTimer >= 150)
    					RandomSU = RandomUInt(5);
    				if (PhaseTimer <= 150 && PhaseTimer > 100)
    					RandomSU = RandomUInt(6);
    				if (PhaseTimer <= 100)
    					RandomSU = RandomUInt(7);
    
    				uint32 UnitType;
    
    				switch (RandomSU)
    				{
    					case 0:
    					case 1: UnitType = CN_SOLDIER_OF_THE_FROZEN_WASTES; break;
    					case 2:
    					case 4: UnitType = CN_SOUL_WEAVER; break;
    					case 3:
    					case 5:
    					case 6: UnitType = CN_UNSTOPPABLE_ABOMINATION; break;
    					default:
    						{
    							UnitType = CN_UNSTOPPABLE_ABOMINATION;
    						}
    				}
    
    				_unit->GetMapMgr()->GetInterface()->SpawnCreature(UnitType, Waves[SpawnPoint].x, Waves[SpawnPoint].y, Waves[SpawnPoint].z, Waves[SpawnPoint].o, false, false, 0, 0);
    				WaveTimer = rand()%11+10;
    			}
    		}
    	}
    
    	void PhaseTwo()
    	{
    		if (_unit->GetHealthPct() <= 40)
    		{
    			HelpDialog++;
    			if (HelpDialog == 1)
    			{
    				_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "Master! I require aid!");
    				_unit->PlaySoundToSet(8816);
    			}
    
    			if (HelpDialog == 4)
    			{
    				Unit* TheLichKing = NULL;
    				TheLichKing = _unit->GetMapMgr()->GetInterface()->GetCreatureNearestCoords(3767.58f, -5117.15f, 174.49f, CN_THE_LICH_KING);
    				if (TheLichKing != NULL)
    				{
    					TheLichKing->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "Very well... warriors of the frozen wastes, rise up, I command you to fight, kill, and die for your master. Let none survive...");
    					TheLichKing->PlaySoundToSet(8824);
    				}
    
    				else
    				{
    					_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "Very well... warriors of the frozen wastes, rise up, I command you to fight, kill, and die for your master. Let none survive...");
    					_unit->PlaySoundToSet(8824);
    				}
    
    				for (int i = 0; i < 4; i++)
    				{
    					GameObject* WindowGate  = _unit->GetMapMgr()->GetInterface()->GetGameObjectNearestCoords(Guardians[i].x, Guardians[i].y, Guardians[i].z, 200002);
    					if (WindowGate)
    						WindowGate->SetByte(GAMEOBJECT_BYTES_1, 0, 0);
    				}
    			}
    
    			if (HelpDialog == 10 || HelpDialog == 12 || HelpDialog == 14 || HelpDialog == 16 || HelpDialog == 18)
    			{
    				Unit *Guardian = NULL;
    				uint32 i = RandomUInt(4);
    				Guardian =_unit->GetMapMgr()->GetInterface()->SpawnCreature(CN_GUARDIAN_OF_ICECROWN, Guardians[i].x, Guardians[i].y, Guardians[i].z, Guardians[i].o, false, false, 0, 0);
    				if (Guardian  != NULL)
    				{
    					if (Guardian->GetAIInterface()->GetNextTarget() != NULL)
    						Guardian->GetAIInterface()->AttackReaction(Guardian->GetAIInterface()->GetNextTarget(), 1, 0);
    				}
    
    				GCounter++;
    				if (GCounter == 5)
    				{
    					GCounter = 0;
    					m_phase = 3;
    				}
    			}
    		}
    
    		float val = (float)RandomFloat(100.0f);
            SpellCast(val);
    	}
    
    	void PhaseThree()
    	{
    		float val = (float)RandomFloat(100.0f);
            SpellCast(val);
    	}
    
    	void SpellCast(float val)
        {
            if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget())
            {
    			float comulativeperc = 0;
    		    Unit *target = NULL;
    			for(int i=0;i<nrspells;i++)
    			{
    				if(!spells[i].perctrigger) continue;
    				
    				if(m_spellcheck[i])
    				{
    					target = _unit->GetAIInterface()->GetNextTarget();
    					switch(spells[i].targettype)
    					{
    						case TARGET_SELF:
    						case TARGET_VARIOUS:
    							_unit->CastSpell(_unit, spells[i].info, spells[i].instant); break;
    						case TARGET_ATTACKING:
    							_unit->CastSpell(target, spells[i].info, spells[i].instant); break;
    						case TARGET_DESTINATION:
    							_unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break;
    						case TARGET_RANDOM_FRIEND:
    						case TARGET_RANDOM_SINGLE:
    						case TARGET_RANDOM_DESTINATION:
    							CastSpellOnRandomTarget(i, spells[i].mindist2cast, spells[i].maxdist2cast, spells[i].minhp2cast, spells[i].maxhp2cast); break;
    					}
    
    					if (i == 2)
    						ChainSound();
    
    					if (spells[i].speech != "")
    					{
    						_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, spells[i].speech.c_str());
    						_unit->PlaySoundToSet(spells[i].soundid); 
    					}
    
    					m_spellcheck[i] = false;
    					return;
    				}
    
    				uint32 t = (uint32)time(NULL);
    				if(((val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) || i == 1) && t > spells[i].casttime)
    				{
    					_unit->setAttackTimer(spells[i].attackstoptimer, false);
    					spells[i].casttime = t + spells[i].cooldown;
    					m_spellcheck[i] = true;
    				}
    				comulativeperc += spells[i].perctrigger;
    			}
            }
        }
    
    	void CastSpellOnRandomTarget(uint32 i, float mindist2cast, float maxdist2cast, int minhp2cast, int maxhp2cast)
    	{
    		if (!maxdist2cast) maxdist2cast = 100.0f;
    		if (!maxhp2cast) maxhp2cast = 100;
    
    		if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget())
            {
    			std::vector<Unit*> TargetTable;		/* From M4ksiu - Big THX to Capt who helped me with std stuff to make it simple and fully working <3 */
    												/* If anyone wants to use this function, then leave this note!										 */
    			for(set<Object*>::iterator itr = _unit->GetInRangeSetBegin(); itr != _unit->GetInRangeSetEnd(); ++itr) 
    			{ 
    				if (((spells[i].targettype == TARGET_RANDOM_FRIEND && isFriendly(_unit, (*itr))) || (spells[i].targettype != TARGET_RANDOM_FRIEND && isHostile(_unit, (*itr)) && (*itr) != _unit)) && ((*itr)->GetTypeId()== TYPEID_UNIT || (*itr)->GetTypeId() == TYPEID_PLAYER) && (*itr)->GetInstanceID() == _unit->GetInstanceID()) // isAttackable(_unit, (*itr)) && 
    				{
    					Unit* RandomTarget = NULL;
    					RandomTarget = (Unit*)(*itr);
    
    					if (RandomTarget->isAlive() && _unit->GetDistance2dSq(RandomTarget) >= mindist2cast*mindist2cast && _unit->GetDistance2dSq(RandomTarget) <= maxdist2cast*maxdist2cast && ((RandomTarget->GetHealthPct() >= minhp2cast && RandomTarget->GetHealthPct() <= maxhp2cast && spells[i].targettype == TARGET_RANDOM_FRIEND) || (_unit->GetAIInterface()->getThreatByPtr(RandomTarget) > 0 && isHostile(_unit, RandomTarget))))
    					{
    						TargetTable.push_back(RandomTarget);
    					} 
    				} 
    			}
    
    			if (_unit->GetHealthPct() >= minhp2cast && _unit->GetHealthPct() <= maxhp2cast && spells[i].targettype == TARGET_RANDOM_FRIEND)
    				TargetTable.push_back(_unit);
    
    			if (!TargetTable.size())
    				return;
    
    			size_t RandTarget = rand()%TargetTable.size();
    
    			Unit * RTarget = TargetTable[RandTarget];
    
    			if (!RTarget)
    				return;
    
    			switch (spells[i].targettype)
    			{
    			case TARGET_RANDOM_FRIEND:
    			case TARGET_RANDOM_SINGLE:
    				_unit->CastSpell(RTarget, spells[i].info, spells[i].instant); break;
    			case TARGET_RANDOM_DESTINATION:
    				_unit->CastSpellAoF(RTarget->GetPositionX(), RTarget->GetPositionY(), RTarget->GetPositionZ(), spells[i].info, spells[i].instant); break;
    			}
    
    			TargetTable.clear();
    		}
    	}
    
    	void ChainSound()
    	{
    		uint32 RandomSpeach = rand()%2;
    		switch (RandomSpeach)
    		{
    		case 0:
    			_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "Your soul is bound to me now!");
    			_unit->PlaySoundToSet(8812);
    			break;
    		case 1:
    			_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "There will be no escape!");
    			_unit->PlaySoundToSet(8813);
    			break;
    		}
    	}
    
    	bool GetDespawnTrash() { return DespawnTrash; }
    
    protected:
    
    	bool DespawnTrash, EventStart;
    	uint32 SpawnCounter;
    	uint32 HelpDialog;
    	uint32 SpawnTimer;
    	uint32 PhaseTimer;
    	uint32 WaveTimer;
    	uint32 GCounter;
    	uint32 m_phase;
    	int nrspells;
    };
    
    // The Lich KingAI
    
    class TheLichKingAI : public CreatureAIScript
    {
    public:
        ADD_CREATURE_FACTORY_FUNCTION(TheLichKingAI);
    
        TheLichKingAI(Creature* pCreature) : CreatureAIScript(pCreature)
        {
    		_unit->SetUInt64Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
        }
    };
    
    // Soldier of the Frozen WastesAI
    
    #define DARK_BLAST 28457 // 28458
    
    class SoldierOfTheFrozenWastesAI : public CreatureAIScript
    {
    public:
        ADD_CREATURE_FACTORY_FUNCTION(SoldierOfTheFrozenWastesAI);
        SoldierOfTheFrozenWastesAI(Creature* pCreature) : CreatureAIScript(pCreature)
        {
    		_unit->m_noRespawn = true;
    
    		OnStart = false;
    
    		RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME));
        }
        
        void OnCombatStart(Unit* mTarget)
        {
    		LastPosX = _unit->GetPositionX();
    		LastPosY = _unit->GetPositionY();
    		LastPosZ = _unit->GetPositionZ();
    
    		//RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME));
        }
    
        void OnCombatStop(Unit *mTarget)
        {
            _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL);
            _unit->GetAIInterface()->SetAIState(STATE_IDLE);
    
    		//RemoveAIUpdateEvent();
        }
    
        void OnDied(Unit * mKiller)
        {
           RemoveAIUpdateEvent();
        }
    
        void AIUpdate()
        {
    		Creature* Kelthuzad = NULL;
    		Kelthuzad = _unit->GetMapMgr()->GetInterface()->GetCreatureNearestCoords(3749.950195f, -5113.451660f, 141.288635f, 15990);
    		if (Kelthuzad == NULL || !Kelthuzad->isAlive())
    		{
    			_unit->Despawn(0,0);
    			return;
    		}
    		else if (Kelthuzad->GetScript())
    		{
    			CreatureAIScript *pScript = Kelthuzad->GetScript();
    			if (static_cast<KelthuzadAI*>(pScript)->GetDespawnTrash())
    			{
    				_unit->Despawn(0,0);
    				return;
    			}
    		}
    		if (_unit->GetPositionX() == LastPosX && _unit->GetPositionY() == LastPosY && _unit->GetPositionZ() == LastPosZ)
    		{
    			_unit->GetAIInterface()->MoveTo(newposx, newposy, 141.290451f, _unit->GetOrientation());
    		}
    		if (OnStart == false)
    		{
    			for (int i = 0; i < 7; i++)
    			{
    				if (_unit->GetPositionX() == Waves[i].x && _unit->GetPositionY() == Waves[i].y && _unit->GetPositionZ() == Waves[i].z)
    				{
    					float xchange  = (float)RandomFloat(10.0f);
    					float distance = 10.0f;
    
    					float ychange = sqrt(distance*distance - xchange*xchange);
    
    					if (rand()%2 == 1)
    						xchange *= -1;
    					if (rand()%2 == 1)
    						ychange *= -1;
    
    					newposx = 3715.845703f + xchange;
    					newposy = -5106.928223f + ychange;
    
    					_unit->GetAIInterface()->MoveTo(newposx, newposy, 141.290451f, _unit->GetOrientation());
    				}
    			}
    
    			OnStart = true;
    		}
    
    		if (_unit->GetAIInterface()->GetNextTarget() != NULL)
    		{
    			Unit *target = _unit->GetAIInterface()->GetNextTarget();
    			if (_unit->GetDistance2dSq(target) <= 49.0f)
    				_unit->CastSpell(_unit, DARK_BLAST, true);
    		}
        }
    
    protected:
    
    	float LastPosX, LastPosY, LastPosZ;
    	float newposx;
    	float newposy;
    	bool OnStart;
    };
    
    // Unstoppable Abomination AI
    
    #define UA_MORTAL_WOUND 25646	// 36814
    
    class UnstoppableAbominationAI : public CreatureAIScript
    {
    public:
        ADD_CREATURE_FACTORY_FUNCTION(UnstoppableAbominationAI);
    	SP_AI_Spell spells[1];
    	bool m_spellcheck[1];
    
        UnstoppableAbominationAI(Creature* pCreature) : CreatureAIScript(pCreature)
        {
    		nrspells = 1;
    		for(int i=0;i<nrspells;i++)
    		{
    			m_spellcheck[i] = false;
    			spells[i].casttime = 0;
    		}
    
    		spells[0].info = dbcSpell.LookupEntry(UA_MORTAL_WOUND);
    		spells[0].targettype = TARGET_ATTACKING;
    		spells[0].instant = true;
    		spells[0].cooldown = 10;
    		spells[0].perctrigger = 15.0f;
    		spells[0].attackstoptimer = 1000;
    
    		_unit->m_noRespawn = true;
    
    		OnStart = false;
    
    		RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME));
        }
        
        void OnCombatStart(Unit* mTarget)
        {
    		LastPosX = _unit->GetPositionX();
    		LastPosY = _unit->GetPositionY();
    		LastPosZ = _unit->GetPositionZ();
    
    		//RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME));
    
    		for (int i = 0; i < nrspells; i++)
    			spells[i].casttime = 0;
        }
    
        void OnCombatStop(Unit *mTarget)
        {
            _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL);
            _unit->GetAIInterface()->SetAIState(STATE_IDLE);
    
    		//RemoveAIUpdateEvent();
        }
    
        void OnDied(Unit * mKiller)
        {
           RemoveAIUpdateEvent();
        }
    
        void AIUpdate()
        {
    		Creature* Kelthuzad = NULL;
    		Kelthuzad = _unit->GetMapMgr()->GetInterface()->GetCreatureNearestCoords(3749.950195f, -5113.451660f, 141.288635f, 15990);
    		if (Kelthuzad == NULL || !Kelthuzad->isAlive())
    		{
    			_unit->Despawn(0,0);
    			return;
    		}
    		else if (Kelthuzad->GetScript())
    		{
    			CreatureAIScript *pScript = Kelthuzad->GetScript();
    			if (static_cast<KelthuzadAI*>(pScript)->GetDespawnTrash())
    			{
    				_unit->Despawn(0,0);
    				return;
    			}
    		}
    		if (_unit->GetPositionX() == LastPosX && _unit->GetPositionY() == LastPosY && _unit->GetPositionZ() == LastPosZ)
    		{
    			_unit->GetAIInterface()->MoveTo(newposx, newposy, 141.290451f, _unit->GetOrientation());
    		}
    		if (OnStart == false)
    		{
    			for (int i = 0; i < 7; i++)
    			{
    				if (_unit->GetPositionX() == Waves[i].x && _unit->GetPositionY() == Waves[i].y && _unit->GetPositionZ() == Waves[i].z)
    				{
    					float xchange  = (float)RandomFloat(10.0f);
    					float distance = 10.0f;
    
    					float ychange = sqrt(distance*distance - xchange*xchange);
    
    					if (rand()%2 == 1)
    						xchange *= -1;
    					if (rand()%2 == 1)
    						ychange *= -1;
    
    					newposx = 3715.845703f + xchange;
    					newposy = -5106.928223f + ychange;
    
    					_unit->GetAIInterface()->MoveTo(newposx, newposy, 141.290451f, _unit->GetOrientation());
    				}
    			}
    
    			OnStart = true;
    		}
    
    		float val = (float)RandomFloat(100.0f);
    		SpellCast(val);
        }
    
    	void SpellCast(float val)
        {
            if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget())
            {
    			float comulativeperc = 0;
    		    Unit *target = NULL;
    			for(int i=0;i<nrspells;i++)
    			{
    				if(!spells[i].perctrigger) continue;
    				
    				if(m_spellcheck[i])
    				{
    					target = _unit->GetAIInterface()->GetNextTarget();
    
    					if (i == 0 && _unit->GetDistance2dSq(target) > 25.0f) return;
    
    					switch(spells[i].targettype)
    					{
    						case TARGET_SELF:
    						case TARGET_VARIOUS:
    							_unit->CastSpell(_unit, spells[i].info, spells[i].instant); break;
    						case TARGET_ATTACKING:
    							_unit->CastSpell(target, spells[i].info, spells[i].instant); break;
    						case TARGET_DESTINATION:
    							_unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break;
    					}
    					m_spellcheck[i] = false;
    					return;
    				}
    
    				uint32 t = (uint32)time(NULL);
    				if(val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger) && t > spells[i].casttime)
    				{
    					_unit->setAttackTimer(spells[i].attackstoptimer, false);
    					spells[i].casttime = t + spells[i].cooldown;
    					m_spellcheck[i] = true;
    				}
    				comulativeperc += spells[i].perctrigger;
    			}
            }
        }
    
    protected:
    
    	float LastPosX, LastPosY, LastPosZ;
    	float newposx;
    	float newposy;
    	bool OnStart;
    	int nrspells;
    };
    
    // Soul Weaver AI
    
    #define WAIL_OF_SOULS 28459
    
    class SoulWeaverAI : public CreatureAIScript
    {
    public:
        ADD_CREATURE_FACTORY_FUNCTION(SoulWeaverAI);
    	SP_AI_Spell spells[1];
    	bool m_spellcheck[1];
    
        SoulWeaverAI(Creature* pCreature) : CreatureAIScript(pCreature)
        {
    		nrspells = 1;
    		for(int i=0;i<nrspells;i++)
    		{
    			m_spellcheck[i] = false;
    			spells[i].casttime = 0;
    		}
    
    		spells[0].info = dbcSpell.LookupEntry(WAIL_OF_SOULS);
    		spells[0].targettype = TARGET_VARIOUS;
    		spells[0].instant = true;
    		spells[0].cooldown = 10;
    		spells[0].perctrigger = 15.0f;
    		spells[0].attackstoptimer = 1000;
    
    		_unit->m_noRespawn = true;
    
    		OnStart = false;
    
    		RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME));
        }
        
        void OnCombatStart(Unit* mTarget)
        {
    		LastPosX = _unit->GetPositionX();
    		LastPosY = _unit->GetPositionY();
    		LastPosZ = _unit->GetPositionZ();
    
    		//RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME));
    
    		for (int i = 0; i < nrspells; i++)
    			spells[i].casttime = 0;
        }
    
        void OnCombatStop(Unit *mTarget)
        {
            _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL);
            _unit->GetAIInterface()->SetAIState(STATE_IDLE);
    
    		//RemoveAIUpdateEvent();
        }
    
        void OnDied(Unit * mKiller)
        {
           RemoveAIUpdateEvent();
        }
    
        void AIUpdate()
        {
    		Creature* Kelthuzad = NULL;
    		Kelthuzad = _unit->GetMapMgr()->GetInterface()->GetCreatureNearestCoords(3749.950195f, -5113.451660f, 141.288635f, 15990);
    		if (Kelthuzad == NULL || !Kelthuzad->isAlive())
    		{
    			_unit->Despawn(0,0);
    			return;
    		}
    		else if (Kelthuzad->GetScript())
    		{
    			CreatureAIScript *pScript = Kelthuzad->GetScript();
    			if (static_cast<KelthuzadAI*>(pScript)->GetDespawnTrash())
    			{
    				_unit->Despawn(0,0);
    				return;
    			}
    		}
    		if (_unit->GetPositionX() == LastPosX && _unit->GetPositionY() == LastPosY && _unit->GetPositionZ() == LastPosZ)
    		{
    			_unit->GetAIInterface()->MoveTo(newposx, newposy, 141.290451f, _unit->GetOrientation());
    		}
    		if (OnStart == false)
    		{
    			for (int i = 0; i < 7; i++)
    			{
    				if (_unit->GetPositionX() == Waves[i].x && _unit->GetPositionY() == Waves[i].y && _unit->GetPositionZ() == Waves[i].z)
    				{
    					float xchange  = (float)RandomFloat(10.0f);
    					float distance = 10.0f;
    
    					float ychange = sqrt(distance*distance - xchange*xchange);
    
    					if (rand()%2 == 1)
    						xchange *= -1;
    					if (rand()%2 == 1)
    						ychange *= -1;
    
    					newposx = 3715.845703f + xchange;
    					newposy = -5106.928223f + ychange;
    
    					_unit->GetAIInterface()->MoveTo(newposx, newposy, 141.290451f, _unit->GetOrientation());
    				}
    			}
    
    			OnStart = true;
    		}
    
    		float val = (float)RandomFloat(100.0f);
    		SpellCast(val);
        }
    
    	void SpellCast(float val)
        {
            if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget())
            {
    			float comulativeperc = 0;
    		    Unit *target = NULL;
    			for(int i=0;i<nrspells;i++)
    			{
    				if(!spells[i].perctrigger) continue;
    				
    				if(m_spellcheck[i])
    				{
    					target = _unit->GetAIInterface()->GetNextTarget();
    
    					if (i == 0 && _unit->GetDistance2dSq(target) > 64.0f) return;	// 8yards
    
    					switch(spells[i].targettype)
    					{
    						case TARGET_SELF:
    						case TARGET_VARIOUS:
    							_unit->CastSpell(_unit, spells[i].info, spells[i].instant); break;
    						case TARGET_ATTACKING:
    							_unit->CastSpell(target, spells[i].info, spells[i].instant); break;
    						case TARGET_DESTINATION:
    							_unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break;
    					}
    					m_spellcheck[i] = false;
    					return;
    				}
    
    				uint32 t = (uint32)time(NULL);
    				if(val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger) && t > spells[i].casttime)
    				{
    					_unit->setAttackTimer(spells[i].attackstoptimer, false);
    					spells[i].casttime = t + spells[i].cooldown;
    					m_spellcheck[i] = true;
    				}
    				comulativeperc += spells[i].perctrigger;
    			}
            }
        }
    
    protected:
    
    	float LastPosX, LastPosY, LastPosZ;
    	float newposx;
    	float newposy;
    	bool OnStart;
    	int nrspells;
    };
    
    // Guardian of Icecrown AI
    
    #define BLOOD_TAP 28459
    
    class GuardianOfIcecrownAI : public CreatureAIScript
    {
    public:
        ADD_CREATURE_FACTORY_FUNCTION(GuardianOfIcecrownAI);
    	SP_AI_Spell spells[1];
    	bool m_spellcheck[1];
    
        GuardianOfIcecrownAI(Creature* pCreature) : CreatureAIScript(pCreature)
        {
    		nrspells = 1;
    		for(int i=0;i<nrspells;i++)
    		{
    			m_spellcheck[i] = false;
    		}
    
    		spells[0].info = dbcSpell.LookupEntry(BLOOD_TAP);
    		spells[0].targettype = TARGET_SELF;
    		spells[0].instant = true;
    		spells[0].cooldown = 0;
    		spells[0].perctrigger = 0.0f;
    		spells[0].attackstoptimer = 1000;
    
    		_unit->GetAIInterface()->m_moveRun = true;
    		_unit->m_noRespawn = true;
    
    		OnStart = false;
    
    		RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME));
        }
        
        void OnCombatStart(Unit* mTarget)
        {
    		if (_unit->GetAIInterface()->GetNextTarget())
    			LastTarget = _unit->GetAIInterface()->GetNextTarget();
    
    		LastPosX = _unit->GetPositionX();
    		LastPosY = _unit->GetPositionY();
    		LastPosZ = _unit->GetPositionZ();
    		
    		//RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME));
        }
    
        void OnCombatStop(Unit *mTarget)
        {
            _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL);
            _unit->GetAIInterface()->SetAIState(STATE_IDLE);
    
    		//RemoveAIUpdateEvent();
        }
    
        void OnDied(Unit * mKiller)
        {
           RemoveAIUpdateEvent();
        }
    
        void AIUpdate()
        {
    		Unit* Kelthuzad = NULL;
    		Kelthuzad = _unit->GetMapMgr()->GetInterface()->GetCreatureNearestCoords(3715.950195f, -5106.451660f, 141.288635f, 15990);
    		if (Kelthuzad && !Kelthuzad->isAlive())
    		{
    			_unit->Despawn(0,0);
    		}
    		if (_unit->GetPositionX() == LastPosX && _unit->GetPositionY() == LastPosY && _unit->GetPositionZ() == LastPosZ)
    		{
    			_unit->GetAIInterface()->MoveTo(newposx, newposy, 141.290451f, _unit->GetOrientation());
    		}
    		if (OnStart == false)
    		{
    			for (int i = 0; i < 7; i++)
    			{
    				if (_unit->GetPositionX() == Guardians[i].x && _unit->GetPositionY() == Guardians[i].y && _unit->GetPositionZ() == Guardians[i].z)
    				{
    					float xchange  = (float)RandomFloat(10.0f);
    					float distance = 10.0f;
    
    					float ychange = sqrt(distance*distance - xchange*xchange);
    
    					if (rand()%2 == 1)
    						xchange *= -1;
    					if (rand()%2 == 1)
    						ychange *= -1;
    
    					newposx = 3715.845703f + xchange;
    					newposy = -5106.928223f + ychange;
    
    					_unit->GetAIInterface()->MoveTo(newposx, newposy, 141.290451f, _unit->GetOrientation());
    				}
    			}
    
    			OnStart = true;
    		}
    
    		if (_unit->GetAIInterface()->GetNextTarget())
    		{
    			Unit* target = NULL;
    			target = _unit->GetAIInterface()->GetNextTarget();
    
    			if (!LastTarget) { LastTarget = target; return; }
    
    			if (LastTarget != target)
    				_unit->CastSpell(_unit, spells[0].info, spells[0].instant);
    
    			LastTarget = target;
    		}
        }
    
    protected:
    
    	float LastPosX, LastPosY, LastPosZ;
    	Unit* LastTarget;
    	float newposx;
    	float newposy;
    	bool OnStart;
    	int nrspells;
    };
    
    void SetupNaxxramas(ScriptMgr * mgr)
    {
    	// ---- Spider Wing ----
        mgr->register_creature_script(CN_CARRION_SPINNER, &CarrionSpinnerAI::Create);
    	mgr->register_creature_script(CN_DREAD_CREEPER, &DreadCreeperAI::Create);
        mgr->register_creature_script(CN_NAXX_CULTIST, &NaxxCultistAI::Create);
    	mgr->register_creature_script(CN_NECRO_STALKER, &NecroStalkerAI::Create);
    	mgr->register_creature_script(VENOM_STALKER, &NecroStalkerAI::Create);
    	mgr->register_creature_script(CN_TOMB_HORROR, &TombHorrorAI::Create);
        mgr->register_creature_script(CN_NECRO_ACOLYTE, &NecroAcolyteAI::Create);
    	// BOSS'S
    	mgr->register_creature_script(CN_MAEXXNA, &MaexxnaAI::Create);
    	mgr->register_creature_script(CN_WIDOW_FAERLINA, &WidowFaerlinaAI::Create);
    	mgr->register_creature_script(CN_ANUB, &AnubAI::Create);
    
    	// ---- Abomination Wing ----
    	mgr->register_creature_script(CN_BILE_RETCHER, &BileRetcherAI::Create);
    	mgr->register_creature_script(CN_PATCHWORK_GOLEM, &PatchworkGolemAI::Create);
    	mgr->register_creature_script(STICKED_SPEWER, &StickedSpewerAI::Create);
    	mgr->register_creature_script(CN_SURGICAL_ASSISTANT, &SurgicalAssistantAI::Create);
    	mgr->register_creature_script(CN_SLUDGE_BELCHER, &StickedSpewerAI::Create);
    	// BOSS'S
    	mgr->register_creature_script(CN_PATCHWREK, &PatchwerkAI::Create);
    	mgr->register_creature_script(CN_GROBBULUS, &GrobbulusAI::Create);
    	mgr->register_creature_script(CN_GLUTH, &GluthAI::Create);
    
    	// ---- Plague Wing ----
    	mgr->register_creature_script(CN_INFECTIOUS_GHOUL, &InfGhoulAI::Create);
    	mgr->register_creature_script(CN_STONEKIN_GARGOYLE, &StonekinGargoyleAI::Create);
    	mgr->register_creature_script(16446, &StonekinGargoyleAI::Create);
    	mgr->register_creature_script(CN_EYE_STALK, &EyeStalkAI::Create);
    	// BOSS'S
    
    	// ---- Deathknight Wing ----
    	mgr->register_creature_script(CN_BONY_CONSTRUCT, &BonyConstructAI::Create);
    	mgr->register_creature_script(CN_DEATH_LORD, &DeathLordAI::Create);
    	mgr->register_creature_script(16163, &DeathLordAI::Create);
    	mgr->register_creature_script(DEATHKNIGHT_CAPTAIN, &DeathknightCaptainAI::Create);
    	mgr->register_creature_script(CN_BONY_CONSTRUCT, &BonyConstructAI::Create);
    	// BOSS'S
    	mgr->register_creature_script(CN_INSTRUCTOR_RAZUVIOUS, &RazuviousAI::Create);
    	// The Four Horsemen:
    	mgr->register_creature_script(CN_HIGHLORD_MOGRAINE, &MograineAI::Create);
    	mgr->register_creature_script(CN_THANE_KORTHAZZ, &KorthazzAI::Create);
    	mgr->register_creature_script(CN_LADY_BLAUMEUX, &BlaumeuxAI::Create);
    	mgr->register_creature_script(CN_SIR_ZELIEK, &ZeliekAI::Create);
    
    	// ---- Frostwyrm Lair ---- > Sapphiron Encounter:
    	mgr->register_creature_script(CN_FROST_BREATH_TRIGGER, &FrostBreathTriggerAI::Create);
    	mgr->register_creature_script(CN_FROST_BREATH_TRIGGER2, &FrostBreathTrigger2AI::Create);
    	mgr->register_creature_script(CN_FROST_BREATH_TRIGGER3, &FrostBreathTrigger3AI::Create);
    	mgr->register_creature_script(CN_CHILL_TRIGGER, &ChillTriggerAI::Create);
    	mgr->register_creature_script(CN_SAPPHIRON, &SapphironAI::Create);
    
    	// ---- Frostwyrm Lair ---- > Kel'thuzad Encounter:
    	mgr->register_creature_script(CN_THE_LICH_KING ,&TheLichKingAI::Create);
    	mgr->register_creature_script(CN_SOLDIER_OF_THE_FROZEN_WASTES ,&SoldierOfTheFrozenWastesAI::Create);
    	mgr->register_creature_script(CN_UNSTOPPABLE_ABOMINATION ,&UnstoppableAbominationAI::Create);
    	mgr->register_creature_script(CN_SOUL_WEAVER ,&SoulWeaverAI::Create);
    	mgr->register_creature_script(CN_GUARDIAN_OF_ICECROWN ,&GuardianOfIcecrownAI::Create);
    	mgr->register_creature_script(CN_KELTHUZAD, &KelthuzadAI::Create);
    }
    Last edited by gotiefan; 04-05-2009 at 10:20 AM.

  3. #3
    Vindicated's Avatar Contributor
    Reputation
    226
    Join Date
    Aug 2008
    Posts
    1,067
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    gotiefan your problem really isn't the same seeing as that is a C++ script...


    And goldpaw, clean your script up first please! You cannot just have text comments. If you want a line to be able to have normal text, it must start with a "--"


  4. #4
    goldpaw's Avatar Member
    Reputation
    2
    Join Date
    Feb 2009
    Posts
    19
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well i removed all the comments and still doesn't work. Now it looks like this.

    function SoilderoftheFrozenWastes_OnEnterCombat(pUnit,Event)
    pUnit:RegisterEvent("SoilderoftheFrozenWastes_Spell", 5000,1)
    end


    function SoilderoftheFrozenWastes_Spell(pUnit,Event)
    pUnit:FullCastSpellOnTarget(28457,pUnit:GetClosestPlayer())
    end



    RegisterUnitEvent(16427, 1, "SoilderoftheFrozenWastes_OnEnterCombat")

    function UnstoppableAbomination_OnEnterCombat(pUnit,Event)
    pUnit:RegisterEvent("UnstoppableAbomination_Spell1", 5000,1)
    end


    function UnstoppableAbomination_Spell1(pUnit,Event)
    pUnit:FullCastSpellOnTarget(25646,pUnit:GetClosestPlayer())
    end



    RegisterUnitEvent(16428, 1, "UnstoppableAbomination_OnEnterCombat")

    function SoulWeaver_OnEnterCombat(pUnit,Event)
    pUnit:RegisterEvent("SoulWeaver_Spell2", 25000,1)
    end


    function SoulWeaver_Spell2(pUnit,Event)
    pUnit:FullCastSpellOnTarget(28459,pUnit:GetClosestPlayer())
    end



    RegisterUnitEvent(16429, 1, "SoulWeaver_OnEnterCombat")

    function GuardianofIcecrown_OnEnterCombat(pUnit,Event)
    pUnit:RegisterEvent("GuardianofIcecrown_Spell3", 25000,1)
    end


    function GuardianofIcecrown_Spell3(pUnit,Event)
    pUnit:FullCastSpellOnTarget(28470,pUnit:GetClosestPlayer())
    end

    RegisterUnitEvent(16441, 1, "GuardianofIcecrown_OnEnterCombat")

    function KelThuzad_Died (pUnit, Event)
    pUnit:RegisterEvent("KelThuzad_Died", 10000,4)
    pUnit:SendChatMessage(5, 0, "AAAAGHHH!... Do not rejoice... your victory is a hollow one... for I shall return with powers beyond your imagining! ")

    function KelThuzad_Phase1 (pUnit, Event)
    pUnit:SendBroadcastMessage(You have engaged the Kel'Thuzad fight!)
    pUnit:SendChatMessage(5, 0, "Minions, servants, soldiers of the cold dark, obey the call of Kel'Thuzad!")
    pUnit:SetCombatCapable(1)
    pUnitespawn(0, 280000)
    pUnit:RegisterEvent("O'Brien_Phase2")
    pUnit:RegisterEvent("O'Brien_Phase3")
    end


    function KelThuzad_KilledTarget (pUnit, Event)
    pUnit:SendChatMessage(5, 0, "The dark void awaits you!")
    end

    function KelThuzad_Phase1 (pUnit, Event)
    pUnit:SendBroadcastMessage(The battle for Azeroth has begun!)
    pUnit:SendChatMessage(5, 0, "Minions, servants, soldiers of the cold dark, obey the call of Kel'Thuzad!")
    pUnit:SetCombatCapable(1)
    pUnitespawn(0, 280000)
    x=GetX();
    y=GetY();
    z=GetZ();
    o=GetO();
    pUnit:SpawnCreature(16427, x,+7 y+1, z, 0, 20, 0)
    pUnit:SpawnCreature(16427, x+6, y,+1 z, 0, 20, 0)
    pUnit:SpawnCreature(16427, x-10, y+1, z, 0, 20, 0)
    pUnit:SpawnCreature(16427, x-8, y+1, z, 0, 20, 0)
    pUnit:SpawnCreature(16427, x-2, y+1, z, 0, 20, 0)
    pUnit:SpawnCreature(16427, x,+7 y+1, z, 0, 20, 0)
    pUnit:SpawnCreature(16427, x+6, y,+1 z, 0, 20, 0)
    pUnit:SpawnCreature(16427, x-10, y+1, z, 0, 20, 0)
    pUnit:SpawnCreature(16427, x-8, y+1, z, 0, 20, 0)
    pUnit:SpawnCreature(16427, x-2, y+1, z, 0, 20, 0)
    pUnit:SpawnCreature(16428, x+13, y+1, z, 0, 20, 0)
    pUnit:SpawnCreature(16428, x-10, y+1, z, 0, 20, 0)
    pUnit:SpawnCreature(16428, x+13, y+1, z, 0, 20, 0)
    pUnit:SpawnCreature(16428, x-13, y+1, z, 0, 20, 0)
    pUnit:SpawnCreature(16428, x-14, y+1, z, 0, 20, 0)
    pUnit:SpawnCreature(16428, x+9, y+1, z, 0, 20, 0)
    pUnit:SpawnCreature(16428, x-15, y+1, z, 0, 20, 0)
    pUnit:SpawnCreature(16428, x-14, y+1, z, 0, 20, 0)
    pUnit:SpawnCreature(16428, x+11, y+1, z, 0, 20, 0)
    pUnit:SpawnCreature(16429, x+13, y+1, z, 0, 20, 0)
    pUnit:SpawnCreature(16429, x+12, y+1, z, 0, 20, 0)
    pUnit:SpawnCreature(16429, x+25, y+1, z, 0, 20, 0)
    pUnit:SpawnCreature(16429, x+16, y+1, z, 0, 20, 0)
    pUnit:SpawnCreature(16429, x+27, y+1, z, 0, 20, 0)
    pUnit:SpawnCreature(16429, x+14, y+1, z, 0, 20, 0)
    pUnit:RegisterEvent("O'Brien_Phase2")
    pUnit:RegisterEvent("O'Brien_Phase3")
    end

    ~Stage 2 begins 3 minutes and 48 seconds after you engage Kel'Thuzad. He becomes active, and has approximately 5,660,000 hit points.

    * Frost bolt single 2 second cast. Inflicts 10063–12937 Frost damage to primary aggro target and reduces its movement speed for 4 sec. This spell is not reflectable via Warrior Spell Reflection.

    * Frost bolt multiple Inflicts 4500–5500 Frost damage and reduces the targets' movement speed for 4 sec. Hits everyone in the room and cannot be interrupted - it is instant cast. Used every 15 secs. Fully resistible.

    * Mana Detonation A debuff randomly applied to a mana using player. The player will explode after 5 seconds, burn 2000 mana and deal 10,000 damage to all players within 10 yards of him (not to himself).

    * Shadow Fissure Summons a very noticeable red fissure around the targeted player which does 62500–137500 shadow damage after 5 seconds as Void Blast. Easily avoidable by running out of the fissure.

    * Frost Blast Places an Ice Block effect on the targeted player, and all players within 10 yards, rendering them unable to perform any action. This effect will continue to chain to anyone within 10 yards of anyone affected as with C'thun's Eye Beam. It will deal 104% of their maximum HP in damage over 4 seconds. If those affected are not healed within 4 seconds they will die. ~


    function KelThuzad_Phase2(pUnit,Event)
    pUnit:RegisterEvent("KelThuzad_Frostbolt1", 30000,1)
    pUnit:RegisterEvent("KelThuzad_frostbolt2", 15000,1)
    pUnit:RegisterEvent("KelThuzad_ManaDetonation", 22500,1)
    pUnit:RegisterEvent("KelThuzad_"ShadowFissure", 17500,1)
    pUnit:RegisterEvent("KelThuzad_FrostBlast", 53500,1)
    pUnit:RegisterEvent("KelThuzad_ChainsofKelthuzad", 105000,1)
    Choice=math.random(1,3)
    if Choice==1 then
    pUnit:SendChatMessage(14, 0, "Pray for mercy!")
    end
    if Choice==2 then
    pUnit:SendChatMessage(14, 0, "Scream your dying breath!")
    end
    if Choice==3 then
    pUnit:SendChatMessage(14, 0, "The end is upon you!")
    end
    end
    end

    function KelThuzad_frostbolt2(pUnit,Event)
    pUnit:FullCastSpellOnTarget(28479,pUnit:GetClosestPlayer())
    end

    function KelThuzad_Frostbolt1(pUnit,Event)
    pUnit:FullCastSpellOnTarget(28478,pUnit:GetMainTank())
    end

    function KelThuzad_ManaDetonation(pUnit,Event)
    pUnit:FullCastSpellOnTarget(27819,pUnit:GetClosestPlayer())
    Choice=math.random(1,2)
    if Choice==1 then
    pUnit:SendChatMessage(14, 0, "Your petty magics ar no challenge to the might of the Scourge!")
    end
    if Choice==2 then
    pUnit:SendChatMessage(14, 0, "Enoug! I grow tired of these distractions!")
    end
    end

    function KelThuzad_ShadowFissure(pUnit,Event)
    pUnit:FullCastSpellOnTarget(27810,pUnit:GetClosestPlayer())
    end

    function KelThuzad_FrostBlast(pUnit,Event)
    pUnit:FullCastSpellOnTarget(27808,pUnit:GetClosestPlayer())
    pUnit:SendChatMessage(14, 0, "I will freeze the blood in your veins!")
    end

    function KelThuzad_ChainsofKelthuzad(pUnit,Event)
    pUnit:FullCastSpellOnTarget(28410,pUnit:GetClosestPlayer())
    Choice=math.random(1,3)
    if Choice==1 then
    pUnit:SendChatMessage(14, 0, "Your soul, is bound to me now!")
    end
    if Choice==2 then
    pUnit:SendChatMessage(14, 0, "There will be no escape!")
    end
    end

    ~At 45% health, Phase Three will begin as Kel'Thuzad calls for aid and the Lich King sends two Nerubian Crypt Lords known as the Guardians of Icecrown to attack the raid.

    * Guardian of Icecrown - These have as much HP as Kel'Thuzad (combined) with the ability: Blood Tap. Which is a self buff that does +15% all damage, + 10% size and can stack up to 99 times. The Guardians will flee when Kel'Thuzad dies. Immune to CC. The Guardians stack Blood Tap every ~15 seconds and it hits their aggro target for ~3,000. They hit for ~2,000 on plate to start but this increases rapidly over time.~


    function KelThuzad_Phase3 (pUnit, Event)
    if pUnit:GetHealthPct() < 45 then
    pUnit:SendChatMessage(5, 0, "Master! I require aid!")
    pUnit:SendBroadcastMessage(Very well... warriors of the frozen wastes, rise up! I command you to fight, kill, and die for your master. Let none survive...")
    x=GetX();
    y=GetY();
    z=GetZ();
    o=GetO();
    pUnit:SpawnCreature(16441, x,+7 y+1, z, 0, 20, 0)
    pUnit:SpawnCreature(16441, x,+7 y+1, z, 0, 20, 0)
    end
    end


    RegisterUnitEvent(15990, 1, "KelThuzad_OnEnterCombat")
    RegisterUnitEvent(15990, 4, "KelThuzad_Died")
    RegisterUnitEvent(15990, 3, "KelThuzad_KilledTarget")
    RegisterUnitEvent(15990, 2, "KelThuzad_OnLeaveCombat")

  5. #5
    HenkSpenk's Avatar Member
    Reputation
    3
    Join Date
    Apr 2009
    Posts
    7
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    With that command your server should crash :S

  6. #6
    Kcquipor's Avatar Member
    Reputation
    12
    Join Date
    Dec 2007
    Posts
    85
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by HenkSpenk View Post
    With that command your server should crash :S
    Well thats not true , he can easly turn it on , only it will take some CPU and Broadband but not a Server crash if he got preformes

  7. #7
    gotiefan's Avatar Sergeant
    Reputation
    1
    Join Date
    Jan 2008
    Posts
    54
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)


    I'm getting that error when I run your LUA script.

    As you can see it's kinda late here, and I will look into that tomorrow.

    But if someone can help us before I try it, I'd appreciate that.

  8. #8
    Kcquipor's Avatar Member
    Reputation
    12
    Join Date
    Dec 2007
    Posts
    85
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try To do it that the end of your full command this

    End IF
    End Sub

  9. #9
    gotiefan's Avatar Sergeant
    Reputation
    1
    Join Date
    Jan 2008
    Posts
    54
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Kcquipor View Post
    Try To do it that the end of your full command this

    End IF
    End Sub
    I don't get it? What will the LUA script be then?

    Code:
    function SoilderoftheFrozenWastes_OnEnterCombat(pUnit,Event)
        pUnit:RegisterEvent("SoilderoftheFrozenWastes_Spell", 5000,1)
    end
    
    
    function SoilderoftheFrozenWastes_Spell(pUnit,Event)
        pUnit:FullCastSpellOnTarget(28457,pUnit:GetClosestPlayer())
     end
    
    
    
    RegisterUnitEvent(16427, 1, "SoilderoftheFrozenWastes_OnEnterCombat")
    
    
    function UnstoppableAbomination_OnEnterCombat(pUnit,Event)
        pUnit:RegisterEvent("UnstoppableAbomination_Spell1", 5000,1)
    end
    
    
    function UnstoppableAbomination_Spell1(pUnit,Event)
        pUnit:FullCastSpellOnTarget(25646,pUnit:GetClosestPlayer())
     end
    
    
    
    RegisterUnitEvent(16428, 1, "UnstoppableAbomination_OnEnterCombat")
    
    
    
    function SoulWeaver_OnEnterCombat(pUnit,Event)
        pUnit:RegisterEvent("SoulWeaver_Spell2", 25000,1)
    end
    
    
    function SoulWeaver_Spell2(pUnit,Event)
        pUnit:FullCastSpellOnTarget(28459,pUnit:GetClosestPlayer())
     end
    
    
    
    RegisterUnitEvent(16429, 1, "SoulWeaver_OnEnterCombat")
    
    
    
    
    function GuardianofIcecrown_OnEnterCombat(pUnit,Event)
        pUnit:RegisterEvent("GuardianofIcecrown_Spell3", 25000,1)
    end
    
    
    function GuardianofIcecrown_Spell3(pUnit,Event)
        pUnit:FullCastSpellOnTarget(28470,pUnit:GetClosestPlayer())
     end
    
    
    
    RegisterUnitEvent(16441, 1, "GuardianofIcecrown_OnEnterCombat")
    
    
    
    function KelThuzad_Died (pUnit, Event)
    pUnit:RegisterEvent("KelThuzad_Died", 10000,4)
    pUnit:SendChatMessage(5, 0, "AAAAGHHH!... Do not rejoice... your victory is a hollow one... for I shall return with powers beyond your imagining! ")
    
    function KelThuzad_Phase1 (pUnit, Event)
    pUnit:SendBroadcastMessage(You have engaged the Kel'Thuzad fight!)
    pUnit:SendChatMessage(5, 0, "Minions, servants, soldiers of the cold dark, obey the call of Kel'Thuzad!")
    pUnit:SetCombatCapable(1)
    pUnit:Despawn(0, 280000)
    pUnit:RegisterEvent("O'Brien_Phase2")
    pUnit:RegisterEvent("O'Brien_Phase3")
    end
    
    
    function KelThuzad_KilledTarget (pUnit, Event)
    pUnit:SendChatMessage(5, 0, "The dark void awaits you!")
    end
    
    
    function KelThuzad_Phase1 (pUnit, Event)
    pUnit:SendBroadcastMessage(The battle for Azeroth has begun!)
    pUnit:SendChatMessage(5, 0, "Minions, servants, soldiers of the cold dark, obey the call of Kel'Thuzad!")
    pUnit:SetCombatCapable(1)
    pUnit:Despawn(0, 280000)
         x=GetX();
         y=GetY();
         z=GetZ();
         o=GetO();
      pUnit:SpawnCreature(16427, x,+7 y+1, z, 0, 20, 0)
      pUnit:SpawnCreature(16427, x+6, y,+1 z, 0, 20, 0)
      pUnit:SpawnCreature(16427, x-10, y+1, z, 0, 20, 0)
      pUnit:SpawnCreature(16427, x-8, y+1, z, 0, 20, 0)
      pUnit:SpawnCreature(16427, x-2, y+1, z, 0, 20, 0)
      pUnit:SpawnCreature(16427, x,+7 y+1, z, 0, 20, 0)
      pUnit:SpawnCreature(16427, x+6, y,+1 z, 0, 20, 0)
      pUnit:SpawnCreature(16427, x-10, y+1, z, 0, 20, 0)
      pUnit:SpawnCreature(16427, x-8, y+1, z, 0, 20, 0)
      pUnit:SpawnCreature(16427, x-2, y+1, z, 0, 20, 0)
      pUnit:SpawnCreature(16428, x+13, y+1, z, 0, 20, 0)
      pUnit:SpawnCreature(16428, x-10, y+1, z, 0, 20, 0)
      pUnit:SpawnCreature(16428, x+13, y+1, z, 0, 20, 0)
      pUnit:SpawnCreature(16428, x-13, y+1, z, 0, 20, 0)
      pUnit:SpawnCreature(16428, x-14, y+1, z, 0, 20, 0)
      pUnit:SpawnCreature(16428, x+9, y+1, z, 0, 20, 0)
      pUnit:SpawnCreature(16428, x-15, y+1, z, 0, 20, 0)
      pUnit:SpawnCreature(16428, x-14, y+1, z, 0, 20, 0)
      pUnit:SpawnCreature(16428, x+11, y+1, z, 0, 20, 0)
      pUnit:SpawnCreature(16429, x+13, y+1, z, 0, 20, 0)
      pUnit:SpawnCreature(16429, x+12, y+1, z, 0, 20, 0)
      pUnit:SpawnCreature(16429, x+25, y+1, z, 0, 20, 0)
      pUnit:SpawnCreature(16429, x+16, y+1, z, 0, 20, 0)
      pUnit:SpawnCreature(16429, x+27, y+1, z, 0, 20, 0)
      pUnit:SpawnCreature(16429, x+14, y+1, z, 0, 20, 0)
    pUnit:RegisterEvent("O'Brien_Phase2")
    pUnit:RegisterEvent("O'Brien_Phase3")
    end
    
    function KelThuzad_Phase2(pUnit,Event)
    pUnit:RegisterEvent("KelThuzad_Frostbolt1", 30000,1)
    pUnit:RegisterEvent("KelThuzad_frostbolt2", 15000,1)
    pUnit:RegisterEvent("KelThuzad_ManaDetonation", 22500,1)
    pUnit:RegisterEvent("KelThuzad_"ShadowFissure", 17500,1)
    pUnit:RegisterEvent("KelThuzad_FrostBlast", 53500,1)
    pUnit:RegisterEvent("KelThuzad_ChainsofKelthuzad", 105000,1)
     Choice=math.random(1,3)
    if Choice==1 then
      pUnit:SendChatMessage(14, 0, "Pray for mercy!")
     end
    if Choice==2 then
      pUnit:SendChatMessage(14, 0, "Scream your dying breath!")
     end
    if Choice==3 then
      pUnit:SendChatMessage(14, 0, "The end is upon you!")
     end
    end
    end
    
    function KelThuzad_frostbolt2(pUnit,Event)
        pUnit:FullCastSpellOnTarget(28479,pUnit:GetClosestPlayer())
    end
    
    function KelThuzad_Frostbolt1(pUnit,Event)
        pUnit:FullCastSpellOnTarget(28478,pUnit:GetMainTank())
    end
    
    function KelThuzad_ManaDetonation(pUnit,Event)
        pUnit:FullCastSpellOnTarget(27819,pUnit:GetClosestPlayer())
     Choice=math.random(1,2)
    if Choice==1 then
      pUnit:SendChatMessage(14, 0, "Your petty magics ar no challenge to the might of the Scourge!")
     end
    if Choice==2 then
      pUnit:SendChatMessage(14, 0, "Enoug! I grow tired of these distractions!")
    end
    end
    
    function KelThuzad_ShadowFissure(pUnit,Event)
        pUnit:FullCastSpellOnTarget(27810,pUnit:GetClosestPlayer())
    end
    
    function KelThuzad_FrostBlast(pUnit,Event)
        pUnit:FullCastSpellOnTarget(27808,pUnit:GetClosestPlayer())
        pUnit:SendChatMessage(14, 0, "I will freeze the blood in your veins!")
    end
    
    function KelThuzad_ChainsofKelthuzad(pUnit,Event)
        pUnit:FullCastSpellOnTarget(28410,pUnit:GetClosestPlayer())
     Choice=math.random(1,3)
    if Choice==1 then
      pUnit:SendChatMessage(14, 0, "Your soul, is bound to me now!")
     end
    if Choice==2 then
      pUnit:SendChatMessage(14, 0, "There will be no escape!")
    end
    end
    
    
    function KelThuzad_Phase3 (pUnit, Event)
    if pUnit:GetHealthPct() < 45 then
    pUnit:SendChatMessage(5, 0, "Master! I require aid!")
    pUnit:SendBroadcastMessage(Very well... warriors of the frozen wastes, rise up! I command you to fight, kill, and die for your master. Let none survive...")
         x=GetX();
         y=GetY();
         z=GetZ();
         o=GetO();
      pUnit:SpawnCreature(16441, x,+7 y+1, z, 0, 20, 0)
      pUnit:SpawnCreature(16441, x,+7 y+1, z, 0, 20, 0)
    end
    end
    
    
    RegisterUnitEvent(15990, 1, "KelThuzad_OnEnterCombat")
    RegisterUnitEvent(15990, 4, "KelThuzad_Died")
    RegisterUnitEvent(15990, 3, "KelThuzad_KilledTarget")
    RegisterUnitEvent(15990, 2, "KelThuzad_OnLeaveCombat")

  10. #10
    Nymphx's Avatar Active Member
    Reputation
    83
    Join Date
    Sep 2008
    Posts
    212
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That script has so many errors... I'm gonna take a look at it.

Similar Threads

  1. [LUA Release] Arthas/Kel'thuzad
    By Pimpin_N0ob in forum WoW EMU General Releases
    Replies: 22
    Last Post: 01-11-2009, 10:06 AM
  2. [RELEASE] WOTLK Kel'Thuzad LUA Script!
    By VictoRo in forum WoW EMU General Releases
    Replies: 21
    Last Post: 01-01-2009, 06:46 AM
  3. Kel'Thuzad/Sapphiron Without Model Changing
    By Ensui in forum World of Warcraft Exploits
    Replies: 12
    Last Post: 11-18-2006, 06:41 AM
  4. Sapphiron/Kel'Thuzad/Instanced EPL
    By Ensui in forum World of Warcraft Model Editing
    Replies: 8
    Last Post: 11-17-2006, 06:58 PM
  5. Visit Sapphiron / Kel'Thuzad
    By GtR[MoÐ] in forum World of Warcraft Exploits
    Replies: 28
    Last Post: 09-08-2006, 03:38 PM
All times are GMT -5. The time now is 04:22 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search