Lua spells o.O menu

Shout-Out

User Tag List

Results 1 to 14 of 14
  1. #1
    jay77's Avatar Member
    Reputation
    1
    Join Date
    Jan 2009
    Posts
    55
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Lua spells o.O

    Alright... I've got my adept in, and she casts the spell, perfect timing, (sometimes o.O) and it looks pretty good....

    Except for the fact she does no damage... She will sometimes hit you the entire time (Every cast of frostbolt, unless ofc you resist it) and sometimes the first time, then never again for the life of the mob. Or sometimes twice than never again. And sometimes, she'll just stand there like she's got no script, until she waits awhile, THEN starts casting on time again...

    My main issue is, this is coded correctly, and she casts the spell, and sometimes it works! But 95% of the time, the frostbolt does absolutely no damage (yet still applying the slow de-buff) and it's just really confusing to me... Things shouldn't be changing.

    We've added the spell to our own general spell book, casted it on a training dummy, and a character that was not getting hit by the monsters frostbolt (which was everybody, it also doesn't say resist, it just says nothing) and it worked on both, hitting the correct amount of damage each time...

    If you know any problems, or how to fix this, please tell me! +Rep!

    Code:
    function Adept_OnEnterCombat(pUnit,Event)
        pUnit:RegisterEvent("Frostbolt", 1, 1)
    end
    
    function Frostbolt(pUnit, Event)
        local plr = pUnit:GetRandomPlayer(0)
        if plr == nil then
        else
        pUnit:FullCastSpellOnTarget(39064, plr) 
        pUnit:RemoveEvents()
        pUnit:RegisterEvent("Frostbolt2", 2002, 0)
        pUnit:SetCombatMeleeCapable(1)
        end
    end
    
    function Frostbolt(pUnit, Event)
        local plr = pUnit:GetRandomPlayer(0)
        if plr == nil then
        else
        pUnit:FullCastSpellOnTarget(39064, plr) 
        pUnit:RemoveEvents()
        pUnit:RegisterEvent("Frostbolt", 2002, 0)
        pUnit:SetCombatMeleeCapable(1)
        end
    end
    
    function Adept_OnLeaveCombat(pUnit, event)
        pUnit:RemoveEvents()
    end
    
    function Adept_Death(pUnit)
        pUnit:RemoveEvents()
    end
    
    RegisterUnitEvent(80003, 1, "Adept_OnEnterCombat")
    RegisterUnitEvent(80003, 2, "Adept_OnLeaveCombat")
    RegisterUnitEvent(80003, 4, "Adept_Death")
    P.S. Some extra info, I'm running ArcEmu, 3.1.3, compiled myself, revision 2810. Also, this doesn't work for other spells either, I have a guy to cast fireball, same thing.
    P.S.S. If you find any un-necessary things in the script, or something I am doing wrong, or not correctly, tell me! And the reason why, etc! I'm still learning lua (loo-ah) by the hour!
    Last edited by jay77; 08-09-2009 at 11:24 PM.

    Lua spells o.O
  2. #2
    stoneharry's Avatar Moderator Harry


    Reputation
    1618
    Join Date
    Sep 2007
    Posts
    4,564
    Thanks G/R
    151/150
    Trade Feedback
    0 (0%)
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Both your Frostbolt functions are called the same thing, the second should be Frostbolt_Two (don't use 2) but you didn't even put the 2 in, thats looking at the register event anyway.
    In terms of damage done, it all depends on the level of the mob, if it's a boss and if it has enough mana to cast the spell properly.

  3. #3
    AngelSandy's Avatar Member
    Reputation
    19
    Join Date
    Jan 2009
    Posts
    330
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A good thing you can do is check your console when you engage the mob.
    Usually may reveal something even if the Script was loaded correctly.

  4. #4
    Meiya Stormsinger's Avatar Contributor

    Reputation
    163
    Join Date
    Mar 2009
    Posts
    196
    Thanks G/R
    0/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    function Adept_OnEnterCombat(pUnit,Event)
    pUnit:RegisterEvent("Frostbolt", 1, 1)
    end
     
    function Frostbolt(pUnit, Event)
    local plr = pUnit:GetRandomPlayer(0)
    if (plr ~= nil) then -- this text, the (plr ~= nil) that's how you actually do it, don't use if plr == nil, that doesnt work, just errors up :), atleast for me it does. also, remove this text before you start the script, it wont register but, just saying :)
    pUnit:FullCastSpellOnTarget(39064,plr)
    pUnit:RegisterEvent("Frostbolt2",2002,0)
    else
    end
     
    end
     
    function Frostbolt2(pUnit, Event)
    local plr = pUnit:GetRandomPlayer(0)
    if (plr ~= nil) then
    pUnit:FullCastSpellOnTarget(39064, plr) 
    pUnit:SetCombatMeleeCapable(1)
    else
    end
    end
     
    function Adept_OnLeaveCombat(pUnit, event)
    pUnit:RemoveEvents()
    end
     
    function Adept_Death(pUnit)
    pUnit:RemoveEvents()
    end
     
    RegisterUnitEvent(80003, 1, "Adept_OnEnterCombat")
    RegisterUnitEvent(80003, 2, "Adept_OnLeaveCombat")
    RegisterUnitEvent(80003, 4, "Adept_Death")

    Try using this one, it's the same.. Just removed some stuff that was not suppose to be there.

    The things that were wrong were that you added a :RemoveEvents() on the function, wich made it **** up.
    And when you register Frostbolt on the OnEnterCombat, you wrote 1,1, wich means it will cast directly, but only once.
    Tho i edited now, so it should work.

    The RemoveEvents() ****ed it all up, because it had no reason to be there

    Tho you could also do this, instead of making two frostbolts that are the same, you just do this.


    Code:
    function Adept_OnEnterCombat(pUnit,Event)
    pUnit:RegisterEvent("Frostbolt", 2002, 0)
    end
     
    function Frostbolt(pUnit, Event)
    local plr = pUnit:GetRandomPlayer(0)
    if (plr ~= nil) then
    pUnit:FullCastSpellOnTarget(39064,plr)
    pUnit:SetCombatMeleeCapable(1)
    else
    end 
    end
     
    function Adept_OnLeaveCombat(pUnit, event)
    pUnit:RemoveEvents()
    end
     
    function Adept_Death(pUnit)
    pUnit:RemoveEvents()
    end
     
    RegisterUnitEvent(80003, 1, "Adept_OnEnterCombat")
    RegisterUnitEvent(80003, 2, "Adept_OnLeaveCombat")
    RegisterUnitEvent(80003, 4, "Adept_Death")
    That makes it way more simple, instead of making two functions that are exactly the same, now she will just cast frostbolts all the time,
    Also, when you use nil values, you always place "else end end" after, i marked it in red... There are other ways to do, but if it's just a spell you can just do like i have done.

    A tip is, read some guides, tho the best way of learning is to read from other peoples scripts, take a look at some of mine, or maybe some of Stoneharrys, or halestormXV's, theres alot to learn
    Last edited by Meiya Stormsinger; 08-10-2009 at 11:02 AM.

  5. #5
    stoneharry's Avatar Moderator Harry


    Reputation
    1618
    Join Date
    Sep 2007
    Posts
    4,564
    Thanks G/R
    151/150
    Trade Feedback
    0 (0%)
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Explain to me how == errors? Your saying if it is equel to instead of if it is not equel to. Your obviously using it completly wrong if you get errors because in every single one of my scripts I use == as it makes a lot more sense to me than the opposit.

  6. #6
    Meiya Stormsinger's Avatar Contributor

    Reputation
    163
    Join Date
    Mar 2009
    Posts
    196
    Thanks G/R
    0/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It always errored for me, but i suppose it works aswell, jee harry i was only trying to help.. >.<

  7. #7
    stoneharry's Avatar Moderator Harry


    Reputation
    1618
    Join Date
    Sep 2007
    Posts
    4,564
    Thanks G/R
    151/150
    Trade Feedback
    0 (0%)
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    >_> Yeah sorry, I shouldn't get on the forums when I'm emotional. Makes you:


  8. #8
    jay77's Avatar Member
    Reputation
    1
    Join Date
    Jan 2009
    Posts
    55
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Firstly, thank you for all the replies. I'll use == if it works just like normal =].

    Also, I don't just copy and paste what other people script for me, if I don't UNDERSTAND it I'll ask more questions, I personally like to learn from when I get help, not use the other person to fix it.

    Secondly, does it have to end with the else end end.

    Code:
    function Frostbolt(pUnit, Event)
        local plr = pUnit:GetRandomPlayer(0)
        if plr == nil then
        pUnit:FullCastSpellOnTarget(39064, plr) 
        pUnit:RegisterEvent("Frostbolt2", 2002, 0)
        pUnit:SetCombatMeleeCapable(1)
        else
        end
    end
    I like to do the loop, so she immediately on combat starts casting frostbolt =] and thanks for catching my error harry, you've helped me a lot, I REALLY appreciate it. I'm sure when I get more errors I'll be back here.

  9. #9
    Meiya Stormsinger's Avatar Contributor

    Reputation
    163
    Join Date
    Mar 2009
    Posts
    196
    Thanks G/R
    0/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by jay77 View Post
    Firstly, thank you for all the replies. I'll use == if it works just like normal =].

    Also, I don't just copy and paste what other people script for me, if I don't UNDERSTAND it I'll ask more questions, I personally like to learn from when I get help, not use the other person to fix it.

    Secondly, does it have to end with the else end end.

    Code:
    function Frostbolt(pUnit, Event)
      local plr = pUnit:GetRandomPlayer(0)
      if plr == nil then
      pUnit:FullCastSpellOnTarget(39064, plr) 
      pUnit:RegisterEvent("Frostbolt2", 2002, 0)
      pUnit:SetCombatMeleeCapable(1)
      else
      end
    end
    I like to do the loop, so she immediately on combat starts casting frostbolt =] and thanks for catching my error harry, you've helped me a lot, I REALLY appreciate it. I'm sure when I get more errors I'll be back here.
    Yeah, there has to be an else end end when you do locals, not sure why, just part of the entire Lua, else the arcemu-world will give you an error, and i'm not saying you should copy paste, just saying look at how i did, just to learn and so

    And also, i was only trying to help, so theres no need to be rude , i took my time to help you out, so a simple thank you would do tbh

    Tho, hope it works for ya now

    Edit: You couldve thanked me aswell, you only thanked harry, that's what i meant by being rude, and yeah.. I am an attention whore

  10. #10
    Meiya Stormsinger's Avatar Contributor

    Reputation
    163
    Join Date
    Mar 2009
    Posts
    196
    Thanks G/R
    0/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by stoneharry View Post
    >_> Yeah sorry, I shouldn't get on the forums when I'm emotional. Makes you:


    No need to appologize, just saying

  11. #11
    Gastricpenguin's Avatar Legendary
    Reputation
    980
    Join Date
    Feb 2007
    Posts
    2,236
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually, you don't need the "else; end" to finish your function. Just like with any other programming language, an else case is not necessary when using an if() statement.

  12. #12
    Meiya Stormsinger's Avatar Contributor

    Reputation
    163
    Join Date
    Mar 2009
    Posts
    196
    Thanks G/R
    0/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh alright gastric, well when i tried doing it without the else it bugged, same with the == nil.. Ahwell, thanks for telling me

  13. #13
    jay77's Avatar Member
    Reputation
    1
    Join Date
    Jan 2009
    Posts
    55
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Firstly, thank you for all the replies. I'll use == if it works just like normal =].
    Firstly I did thank you, and I gave you +Rep. I thanked harry again later for catching my error.
    But if you didn't see that, I guess I'll thank you again =]
    And honestly I know what your talking about, because I'm running arcemu i made my script with == and it just would not work, it never gave me errors but the person would only cast the spell once, then sit there doing nothing, because i setmeleecapable(1)... then i changed it to a ~= and it worked fine... o.O I don't know, but it confuses me a little, my current script now is:

    Code:
    function Adept_OnEnterCombat(pUnit,Event)
        pUnit:SetCombatMeleeCapable(1)
        pUnit:RegisterEvent("Adept_Spell", 1, 1)
    end
    
    function Adept_Spell(pUnit, Event)
        local plr = pUnit:GetRandomPlayer(0)
        if plr ~= nil then
        pUnit:FullCastSpellOnTarget(39064, plr)
        pUnit:RegisterEvent("Adept_Spell2", 2002, 1)
        else
        end
    end
    
    function Adept_Spell2(pUnit, Event)
        local plr = pUnit:GetRandomPlayer(0)
        if plr ~= nil then
        pUnit:FullCastSpellOnTarget(39064, plr)
        pUnit:RegisterEvent("Adept_Spell", 2002, 1)
        else
        end
    end
    
    function Adept_OnLeaveCombat(pUnit, event)
        pUnit:RemoveEvents()
    end
    
    function Adept_Death(pUnit)
        pUnit:RemoveEvents()
    end
    
    RegisterUnitEvent(80003, 1, "Adept_OnEnterCombat")
    RegisterUnitEvent(80003, 2, "Adept_OnLeaveCombat")
    RegisterUnitEvent(80003, 4, "Adept_Death")
    Works fine, just like I wanted it to =].
    Thanks again everybody.


  14. #14
    Gastricpenguin's Avatar Legendary
    Reputation
    980
    Join Date
    Feb 2007
    Posts
    2,236
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    == means "is equal to"
    Where as ~= or != (in other languages) means "not equal to"

    so basically...
    "if plr is not nil(null) then proceed"

Similar Threads

  1. [Lua] Spell Guide
    By P1raten in forum WoW EMU Guides & Tutorials
    Replies: 13
    Last Post: 03-24-2010, 02:24 AM
  2. [Lua] Spell Problem
    By Sumething 2 r3member in forum WoW EMU Questions & Requests
    Replies: 2
    Last Post: 09-02-2009, 02:48 PM
  3. NPC lua spell commands [GUIDE]
    By thebigman in forum WoW EMU Guides & Tutorials
    Replies: 0
    Last Post: 08-12-2009, 06:11 PM
  4. [LUA] Spells/Phases Not Occuring
    By trinityunit in forum WoW EMU Questions & Requests
    Replies: 6
    Last Post: 06-07-2009, 03:28 AM
  5. LUA. Spells go off random time.
    By Performer in forum WoW EMU Questions & Requests
    Replies: 1
    Last Post: 08-27-2008, 09:27 PM
All times are GMT -5. The time now is 11:45 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