LUA. Spells go off random time. menu

User Tag List

Results 1 to 2 of 2
  1. #1
    Performer's Avatar Contributor
    Reputation
    212
    Join Date
    Nov 2007
    Posts
    874
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    LUA. Spells go off random time.

    Okay Id like to know how to make my mobs spells go off at random times. Atm i only know how to do them every say "10000" milliseconds.

    Thanks

    Performer


    LUA. Spells go off random time.
  2. #2
    Twisted7's Avatar Active Member
    Reputation
    63
    Join Date
    Aug 2008
    Posts
    91
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've only recently started using Lua to script mobs, so I'm not 100% sure if this will work, but you could maybe try creating a sort of timer with a random "tick" interval using math.random.

    Kinda hard for me to explain what I mean, here's the code:

    Code:
    --begin timer code
    local timerInterval = 0;  --this is how many seconds it takes for the timer to run
    local currentCount = 0;   --this is the number of seconds we've waited so far
    
    function MobName_onEnterCombat(unit, event) --pick a number from 1-10, this will be the
      timerInterval = math.random(1,10) * 1000  --delay in seconds (multiply by 1000 for milliseconds)
      currentCount = 0;
      unit:RegisterEvent("MobName_Tick", 1000, 0) --our "timer" fires once per second
    end
    
    function MobName_Tick(unit, event)
      currentCount = currentCount + 1000      --increment the counter by 1 second
      if currentCount >= timerInterval then   --if the counter is equal to or greater than
        doStuffHere();                        --the interval, we cast our spell
        timerInterval = math.random(1,10) * 1000  --and then reinitialize our timer with another random interval.
        currentCount = 0;
      end
    end
    --end timer code

    Not the most graceful way to do it, sure, but it should get the job done :P

    Although, again, I'm not sure if it will work since I haven't used Lua outside of writing addons very much, so I don't know if you can define a local variable outside of a function.

Similar Threads

  1. Lua spells o.O
    By jay77 in forum WoW EMU Questions & Requests
    Replies: 13
    Last Post: 08-11-2009, 05:00 PM
  2. [LUA] Spells/Phases Not Occuring
    By trinityunit in forum WoW EMU Questions & Requests
    Replies: 6
    Last Post: 06-07-2009, 03:28 AM
  3. [Show Off] Past Time Work
    By TheFreak in forum Art & Graphic Design
    Replies: 8
    Last Post: 10-17-2008, 08:38 AM
  4. [Bug] Cut a few seconds off mounting time.
    By hoboonaparkbench in forum Age of Conan Exploits|Hacks
    Replies: 12
    Last Post: 06-24-2008, 10:42 PM
  5. [Show-off] First time I use photoshop, signature.
    By Disphotic in forum Art & Graphic Design
    Replies: 13
    Last Post: 02-23-2008, 06:58 PM
All times are GMT -5. The time now is 03:48 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