Skip to content
View in the app

A better way to browse. Learn more.

WRobot

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Execute code if in combat but no spells have been cast for x time

Featured Replies

Due to the MoP client continously breaking, I am looking for ways to reliably do a ReloadUI() to fix it, as a work around.

Unfortunately, when this occurs, sometimes my pet is enough to kill my targets, and the bot never dies. So a simple reload after dying isn't enough.

Therefore I'm looking for a more reliable way. One idea is to execute the Lua code, if combat has been going on for 5+ seconds, and no spell has been cast by the bot.
I wish there was a more reliable way, but I haven't really noticed anything, except that when I restart the bot without reloading the UI, it will say that all movement keys are unbound.

Any help (like code examples) is appreciated.

i would implent the check in a pulse method(runs every x seconds), add stopwatch and attach luaevents that reads your combat actions.

If a spell was cast it resets your stopwatch (maybe attach also "PLAYER_ENTER_COMBAT" & "PLAYER_LEAVE_COMBAT") to control itself.

Here how it could look like:

    private System.Diagnostics.Stopwatch ActionTimer;



    public void Initialize()
    {
        //...
        EventsLuaWithArgs.OnEventsLuaWithArgs += Events;
        EventsLua.AttachEventLua(LuaEventsId.PLAYER_ENTER_COMBAT, m => Event_PLAYER_ENTER_COMBAT());
        EventsLua.AttachEventLua(LuaEventsId.PLAYER_LEAVE_COMBAT, m => Event_PLAYER_LEAVE_COMBAT());
    }



    public void Events(LuaEventsId id, List<string> args)
    {
        //everytime something happens it will write it here
        //for e.g. try to cast a spell and lookup which args was used
        for (int i = 0; i < 11; i++)
        {
            Logging.Write("\nArg"+i+" contains: "+args[i]);
        }

        //example
        if (args[0] == "player" 
            && (args[2] == "SPELL1") || (args[2] == "SPELL2"))  //arg[0] is probably fine but check args[2] if it contains any spellname
        {
            if (ObjectManager.Me.InCombat)
            {
                Logging.Write("reset stopwatch");
                ActionTimer.Reset();
                if (!ActionTimer.IsRunning)
                    ActionTimer.Start();
            }
        }
    }


    public void Pulse()//or any other method thats ticks every x seconds
    {
        if (ActionTimer.ElapsedMilliseconds >= 5000)
        {
            ActionTimer.Reset();
            Lua.LuaDoString("RunMacroText('/reload')");
        }
    }


    public void Event_PLAYER_ENTER_COMBAT()
    {
        ActionTimer.Reset();
        ActionTimer.Start();
    }


    public void Event_PLAYER_LEAVE_COMBAT()
    {
        ActionTimer.Reset();
        ActionTimer.Stop();
    }

 

 

 

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.