+ Reply to Thread
Results 1 to 5 of 5

Thread: Problem with a Lua Script

  1. #1
    anasterion's Avatar
    Lazy Leecher
    anasterion is an unknown quantity at this point Rep Points: 1
    Join Date
    Feb 2010
    Posts
    2
    Points
    1
    Level
    1
    Points: 1, Level: 1
    Level completed: 0%, Points required for next Level: 1
    Overall activity: 0%
    Rep Power
    1

    Default Problem with a Lua Script

    Hey guys!
    made my first lua script today, iam not able to find errors in it but i cant get the phases working :/ could someone take a look at the script and tell me whats wrong? the npc casts the spells like i wanted, but the phases wont be registered

    Code:
    function Saurfang_OnCombat(Unit, Event)
    Unit:SendChatMessage(14, 0, "YOU CANNOT ESCAPE MY ANGER!!!")
    Unit:RegisterEvent("Saurfang_Berserk", 1, 1)
    Unit:RegisterEvent("Saurfang_Boilingblood", 60000, 20)
    Unit:RegisterEvent("Saurfang_Bloodlink", 60000, 10)
    Unit:RegisterEvent("Saurfang_Phase1", 5000, 1)
    Unit:RegisterEvent("Saurfang_Phase2", 5000, 1)
    end
    
    function Saurfang_Phase1(Unit, Event)
    if Unit:GetHealthPct() <= 75 then
    Unit:SendChatMessage(14, 0, "You are stronger than i thought you are!")
    Unit:CastSpell(72173)
    Unit:CastSpell(15578)
    end
    end
    
    function Saurfang_Phase2(Unit, Event)
    if Unit:GetHealthPct() <= 33 then
    Unit:SendChatMessage(14, 0, "That was nothing, take this!!!")
    Unit:CastSpell(46008)
    Unit:CastSpell(41185)
    Unit:SetScale(2)
    end
    end
    
    function Saurfang_Berserk(Unit, Event)
    Unit:CastSpell(26662)
    Unit:SendChatMessage(14, 0, "Feel the pain!!")
    end
    
    
    function Saurfang_Boilingblood(Unit, Event)
    Unit:FullCastSpellOnTarget(72178, Unit:GetClosestPlayer())
    end
    
    function Saurfang_Bloodlink(Unit, Event)
    Unit:CastSpell(72371)
    Unit:SendChatMessage(14, 0, "Your Hate makes me even STRONGER!!")
    end
    
    function Saurfang_OnLeaveCombat(Unit, Event)
    Unit:RemoveEvents() 
    end
    
    function Saurfang_OnKilledTarget(Unit, Event)
    Unit:SendChatMessage(14, 0, "Who expected this? hahaha!")
    Unit:CastSpell(72356)
    end
    
    function Saurfang_OnDied(Unit, Event)
    Unit:SendChatMessage(14, 0, "You...cannot...win against...the...Lich...King!")
    Unit:RemoveEvents()
    end
    
    RegisterUnitEvent(37813, 1, "Saurfang_OnCombat")
    RegisterUnitEvent(37813, 2, "Saurfang_OnLeaveCombat")
    RegisterUnitEvent(37813, 3, "Saurfang_OnKilledTarget")
    RegisterUnitEvent(37813, 4, "Saurfang_OnDied")
    Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on Facebook
    Reply With Quote Reply With Quote  
    Share with Facebook

  2. #2
    Sergeant Achievements:
    250 Experience Points100 Experience Points3 months registered31 days registered7 days registered
    mag1212 is an unknown quantity at this point Rep Points: 5
    Join Date
    Sep 2009
    Posts
    69
    Points
    999
    Level
    2
    Points: 999, Level: 2
    Level completed: 20%, Points required for next Level: 401
    Overall activity: 0%
    Rep Power
    1

    Default

    Code:
    function Saurfang_Phase1(Unit, Event)
    if Unit:GetHealthPct() <= 75 then
    Unit:SendChatMessage(14, 0, "You are stronger than i thought you are!")
    Unit:CastSpell(72173)
    Unit:CastSpell(15578)
    end
    end
    
    function Saurfang_Phase2(Unit, Event)
    if Unit:GetHealthPct() <= 33 then
    Unit:SendChatMessage(14, 0, "That was nothing, take this!!!")
    Unit:CastSpell(46008)
    Unit:CastSpell(41185)
    Unit:SetScale(2)
    end
    end
    u shall only use 1 end
    Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on Facebook
    Reply With Quote Reply With Quote  
    Share with Facebook

  3. #3
    anasterion's Avatar
    Lazy Leecher
    anasterion is an unknown quantity at this point Rep Points: 1
    Join Date
    Feb 2010
    Posts
    2
    Points
    1
    Level
    1
    Points: 1, Level: 1
    Level completed: 0%, Points required for next Level: 1
    Overall activity: 0%
    Rep Power
    1

    Default

    Quote Originally Posted by mag1212 View Post
    Code:
    function Saurfang_Phase1(Unit, Event)
    if Unit:GetHealthPct() <= 75 then
    Unit:SendChatMessage(14, 0, "You are stronger than i thought you are!")
    Unit:CastSpell(72173)
    Unit:CastSpell(15578)
    end
    end
    
    function Saurfang_Phase2(Unit, Event)
    if Unit:GetHealthPct() <= 33 then
    Unit:SendChatMessage(14, 0, "That was nothing, take this!!!")
    Unit:CastSpell(46008)
    Unit:CastSpell(41185)
    Unit:SetScale(2)
    end
    end
    u shall only use 1 end
    thought i have to end the if to, saw it in a tutorial, k i will try that ty
    Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on Facebook
    Reply With Quote Reply With Quote  
    Share with Facebook

  4. #4
    Sergeant Achievements:
    250 Experience Points100 Experience Points3 months registered31 days registered7 days registered
    mag1212 is an unknown quantity at this point Rep Points: 5
    Join Date
    Sep 2009
    Posts
    69
    Points
    999
    Level
    2
    Points: 999, Level: 2
    Level completed: 20%, Points required for next Level: 401
    Overall activity: 0%
    Rep Power
    1

    Default

    nope its 1 function so u only need 1 end
    Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on Facebook
    Reply With Quote Reply With Quote  
    Share with Facebook

  5. #5
    Bing's Avatar
    Senior Sergeant
    Bing is on a distinguished road Rep Points: 27
    Join Date
    Jul 2010
    Posts
    101
    Points
    1
    Level
    1
    Points: 1, Level: 1
    Level completed: 0%, Points required for next Level: 1
    Overall activity: 0%
    Rep Power
    1

    Default

    Mag is right, the reduction of those two ends should make the phases register!
    Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on Facebook
    Reply With Quote Reply With Quote  
    Share with Facebook

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts