LUA Script help (proofread) menu

User Tag List

Results 1 to 6 of 6
  1. #1
    foamysquirl's Avatar Member
    Reputation
    5
    Join Date
    Aug 2006
    Posts
    80
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    LUA Script help (proofread)

    Yes, its another lua script needing to be proofread. I'm new and still learning LUA, but getting this proofread would definitely help me hone my skills. I have also looked at about every guide out there on LUA, and it has helped me to write this completely on my own. I just need a few pointers on what may have been wrong.

    Please also take note that ForcePunch is a 1sec cast, and HatefulStrike is an instant cast.


    Code:
    function Badass_OnCombat(Unit, Event)
    Unit:SendChatMessage(14, 0, "Get on the freakin' point, fatty!")
    Unit:RegisterEvent("Badass_Phase1, 5000, 1)
    Unit:RegisterEvent("Badass_Phase2, 5000, 1)
    Unit:RegisterEvent("Badass_HatefulStrike, 120000, 6)
    end
    
    function Badass_Phase1(Unit, Event)
    if Unit:GetHealthPct() <= 80 then
    Unit:FullCastSpellOnTarget(34771, Unit:GetMainTank())
    Unit:SendChatMessage(14, 0, "BONK!")
    end
    end
    
    function Badass_Phase2(Unit, Event)
    if Unit:GetHealthPct() <= 50 then
    Unit:SendChatMessage(14, 0, "I'm runnin' circles around ya!")
    Unit:SetScale(2)
    end
    end
    
    function Badass_HatefulStrike(Unit, Event)
    Unit:FullCastSpellOnTarget(41926 Unit:GetClosestPlayer())
    end
    
    function Badass_OnLeaveCombat(Unit, Event)
    Unit:SendChatMessage(12, 0, "Ha ha, ya can't touch me!")
    Unit:RemoveEvents()
    end
    
    function Badass_OnKilledTarget(Unit, Event)
    Unit:SendChatMessage(14, 0, "I broke your stupid crap moron!")
    end
    
    function Badass_OnDied(Unit, Event)
    Unit:RemoveEvents()
    end
    
    RegisterUnitEvent(700006, 1, "Badass_OnCombat")
    RegisterUnitEvent(700006, 2, "Badass_OnLeaveCombat")
    RegisterUnitEvent(700006, 3, "Badass_OnKilledTarget")
    RegisterUnitEvent(700006, 4, "Badass_OnDied")
    You mean you'll answer ALL of my butterfly questions????

    LUA Script help (proofread)
  2. #2
    Kaidos's Avatar Contributor
    Reputation
    148
    Join Date
    Jun 2008
    Posts
    324
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hm i fixxed it for you, test it and tell me the error, if you get one.

    Code:
    function Badass_OnCombat(Unit, Event)
    Unit:SendChatMessage(14, 0, "Get on the freakin' point, fatty!")
    Unit:RegisterEvent("Badass_Phase1, 1000, 0) -- checks every second if he get under 80%
    Unit:RegisterEvent("Badass_HatefulStrike, 120000, 6)
    end
    
    function Badass_Phase1(Unit, Event)
    if Unit:GetHealthPct() <= 80 then
    Unit:RemoveEvents()
    Unit:FullCastSpellOnTarget(34771, Unit:GetMainTank())
    Unit:SendChatMessage(14, 0, "BONK!")
    Unit:RegisterEvent("Badass_Phase2, 1000, 0) -- checks every second if he get under 50%
    end
    end
    
    function Badass_Phase2(Unit, Event)
    if Unit:GetHealthPct() <= 50 then
    Unit:RemoveEvents()
    Unit:SendChatMessage(14, 0, "I'm runnin' circles around ya!")
    Unit:SetScale(2)
    end
    end
    
    function Badass_HatefulStrike(Unit, Event)
    Unit:FullCastSpellOnTarget(41926, Unit:GetClosestPlayer())
    end
    
    function Badass_OnLeaveCombat(Unit, Event)
    Unit:SendChatMessage(12, 0, "Ha ha, ya can't touch me!")
    Unit:RemoveEvents()
    end
    
    function Badass_OnKilledTarget(Unit, Event)
    Unit:SendChatMessage(14, 0, "I broke your stupid crap moron!")
    end
    
    function Badass_OnDied(Unit, Event)
    Unit:RemoveEvents()
    end
    
    RegisterUnitEvent(700006, 1, "Badass_OnCombat")
    RegisterUnitEvent(700006, 2, "Badass_OnLeaveCombat")
    RegisterUnitEvent(700006, 3, "Badass_OnKilledTarget")
    RegisterUnitEvent(700006, 4, "Badass_OnDied")
    If you want that he casts Hateful Strike in Phase 1 and 2 you need to add:
    Code:
    Unit:RegisterEvent("Badass_HatefulStrike, 120000, 6)

    So:
    Code:
    function Badass_Phase1(Unit, Event)
    if Unit:GetHealthPct() <= 80 then
    Unit:RemoveEvents()
    Unit:FullCastSpellOnTarget(34771, Unit:GetMainTank())
    Unit:SendChatMessage(14, 0, "BONK!")
    Unit:RegisterEvent("Badass_HatefulStrike, 120000, 6)
    Unit:RegisterEvent("Badass_Phase2, 1000, 0) -- checks every second if he get under 50%
    end
    end
    Edit1: fixxed a comma <.<
    Last edited by Kaidos; 06-25-2009 at 03:54 PM.

  3. #3
    Vision1000's Avatar Member
    Reputation
    104
    Join Date
    Jun 2008
    Posts
    122
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    function Badass_OnCombat(Unit, Event)
    Unit:SendChatMessage(14, 0, "Get on the freakin' point, fatty!")
    Unit:RegisterEvent("Badass_Phase1, 5000, 1)
    Unit:RegisterEvent("Badass_Phase2, 5000, 1)
    Unit:RegisterEvent("Badass_HatefulStrike, 120000, 6)
    end
    When your boss enters combat, he only enters once, And it then registers phase one and phase two - Once. Since you can't generally get a bosses health to 85% in 5 seconds. It only checks his health Once, when he enters combat.

    When making a boss with different phases, where you want him to spam x spell every x seconds during a certain phase, but only say one chat message when he enters that phase, without spamming it. Try scripting your phases like this;

    Code:
    local intPhaseTwoCount = 0 -- Must declare variable otherwise when "intPhaseTwoCount = intPhaseTwoCount + 1" is executed, you'll get an error for trying to do addition on a nil value.
    
    function Creature_OnCombat(Unit, Event)
         Unit:SendChatMessage(14, 0, "insert oncombat chat message here")
         Unit:RegisterEvent("Creature_PhaseOne", 1000, 1)
    end
    
    function Creature_PhaseOne(Unit, Event)
    intPhaseTwoCount = intPhaseTwoCount + 1 -- Will increase by one everytime the event is looped (it will loop every 1 second - See blue highlight)
         
         if (intPhaseOneCount == 10 then)
              -- Every 10 seconds in phase One x cast will be spelt
         elseif (intPhaseOneCount == 15 then)
              -- Every 15 seconds in phase One x cast will be spelt
         intPhaseOneCount = 0 -- Reset the counter to start over. If you don't reset it intPhaseOneCount will never be equal to 10 or 15, meaning the code inside those if statements won't be executed again; (Will only cast the spells once).
         end
    
         if Unit:GetHealthPct() <= 85 then
               -- This is where you will execute any events you wish to only happen ONCE when the creature enters the next phase (Which would be phase two.)
              Unit:RegisterEvent("Creature_PhaseTwo", 1000, 1)
              Unit:SendChatMessage(14, 0, "Insert Phase 3 trigger message here")
         else
              Unit:RegisterEvent("Creature_PhaseOne", 1000, 1) -- Will continue looping this phase until the Units health % is less than or equal to 85.(Make sure to always have it loop One Time only
         end
    end
    
    function Creature_PhaseThree(Unit, Event)
     -- Next phase. Same thign as phase two except with different spells and a new healthpct value check.
    end
    
    RegisterUnitEvent([npcid], 1, "Creature_OnCombat")
    Hope this helps, that was just an exampe, makes for a lot more controlled Creature scripts.
    Last edited by Vision1000; 06-25-2009 at 04:10 PM.

  4. #4
    foamysquirl's Avatar Member
    Reputation
    5
    Join Date
    Aug 2006
    Posts
    80
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @Xendro

    Thank you for finding those errors and correcting my mistakes. You've actually helped me understand more the concept of scripting bosses in LUA (Registering Phases during another Phase to lead into the next). I'm going to run this script and see if it works. You get +Rep even if it doesn't, just for giving some much needed help.

    @Vision1000

    I am trying to get a grasp on what you are saying, I think I understand it. This method seems, albiet a bit more complex, more controlled. I'm going to give it a try in my next boss script I make-- and I do belive you deserve some +Rep too, and if I can I will give some (maybe enough to boost you out of leecher, you are indefinitely not one, thank you for your effort).
    You mean you'll answer ALL of my butterfly questions????

  5. #5
    foamysquirl's Avatar Member
    Reputation
    5
    Join Date
    Aug 2006
    Posts
    80
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks guys! Works like a charm! Now being the inquisitive and eager-to-learn person I am, I want to know about some things. I'm not satisfied with merely the script working-- I want to be able to script content and share it with members of this community. More importantly, I want to be able to do it myself. So, here are my inquiries:

    This is the finished script:
    Code:
    function Badass_OnCombat(Unit, Event)
    Unit:SendChatMessage(14, 0, "Get on the freakin' point, dumbass!")
    Unit:RegisterEvent("Badass_Phase1", 1000, 0)
    end
    
    function Badass_Phase1(Unit, Event)
    if Unit:GetHealthPct() <= 80 then
    Unit:RemoveEvents()
    Unit:FullCastSpellOnTarget(34771, Unit:GetMainTank())  -- I never registered this anywhere, why does it still work?
    Unit:SendChatMessage(14, 0, "BONK!")
    Unit:RegisterEvent("Badass_Phase2", 1000, 0)
    end
    end
    
    function Badass_Phase2(Unit, Event)
    if Unit:GetHealthPct() <= 50 then
    Unit:RemoveEvents()
    Unit:SendChatMessage(14, 0, "I'm runnin' circles around ya!")
    Unit:SetScale(2)
    Unit:RegisterEvent("Badass_HatefulStrike", 120000, 6)
    end
    end
    
    function Badass_HatefulStrike(Unit, Event)
    Unit:FullCastSpellOnTarget(41926, Unit:GetClosestPlayer()) -- I registered this spell, and it works. Why does the other not need to be registered?
    end
    
    function Badass_OnLeaveCombat(Unit, Event)
    Unit:SendChatMessage(12, 0, "That's right! Run along, Ladies")
    Unit:RemoveEvents()
    end
    
    function Badass_OnKilledTarget(Unit, Event)
    Unit:SendChatMessage(12, 0, "I broke your stupid crap, moron.")
    end
    
    function Badass_OnDied(Unit, Event)
    Unit:RemoveEvents()
    end
    
    RegisterUnitEvent(700006, 1, "Badass_OnCombat")
    RegisterUnitEvent(700006, 2, "Badass_OnLeaveCombat")
    RegisterUnitEvent(700006, 3, "Badass_OnKilledTarget")
    RegisterUnitEvent(700006, 4, "Badass_OnDied")
    You mean you'll answer ALL of my butterfly questions????

  6. #6
    Vision1000's Avatar Member
    Reputation
    104
    Join Date
    Jun 2008
    Posts
    122
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The first spell does not need to be registered becuase it is inside a function, and that function was registered from another event being;
    Code:
    function Badass_OnCombat(Unit, Event)
    Unit:SendChatMessage(14, 0, "Get on the freakin' point, dumbass!")
    Unit:RegisterEvent("Badass_Phase1", 1000, 0)
    end
    
    function Badass_Phase1(Unit, Event) This event is looping until his health is <= 80%, And when that happens the spell will go off. along with anything else in the 'if' statement. including your spell
    if Unit:GetHealthPct() <= 80 then
    Unit:RemoveEvents()
    Unit:FullCastSpellOnTarget(34771, Unit:GetMainTank())  -- I never registered this anywhere, why does it still work?
    Unit:SendChatMessage(14, 0, "BONK!")
    Unit:RegisterEvent("Badass_Phase2", 1000, 0)
    end
    end
    The only reason you would make a new function for a Spell, is if you want to call on it more than once during a fight, or if you want it to cast at x seconds intervals. Otherwise, if you just want to cast it once like above then you can just type it inside a phase, you do not need to make a separate function to use it.
    Last edited by Vision1000; 06-25-2009 at 08:11 PM.

Similar Threads

  1. Simple LUA Script Help
    By Wolfly in forum WoW EMU Questions & Requests
    Replies: 7
    Last Post: 09-02-2008, 04:22 PM
  2. LUA Script Help Thread
    By mager1794 in forum World of Warcraft Emulator Servers
    Replies: 0
    Last Post: 07-04-2008, 12:46 AM
  3. LuA Scripting Help
    By Jlp in forum World of Warcraft Emulator Servers
    Replies: 15
    Last Post: 06-27-2008, 03:33 AM
  4. Lua script help and general questions from beginner
    By WinKIller0 in forum World of Warcraft Emulator Servers
    Replies: 1
    Last Post: 02-23-2008, 04:38 AM
  5. Need LUA Scripting Help ?
    By Snailz in forum World of Warcraft Emulator Servers
    Replies: 2
    Last Post: 02-04-2008, 12:36 PM
All times are GMT -5. The time now is 01:34 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