Jump to content
  • Regeneration state events


    Hashira
    • Version: All Product: WRobot General Type: Suggestion Status: Added
     Share

    The `Regeneration` state should have event handlers (`Start`/`Loop`/`End`) in order to allow plugins / fight classes to execute rotations. The use case is as following:

     

    - The bot doesn't have food

    - The bot needs to regenerate HP but has mana

     

    In theory the FC could spam heals / potions if they are available, and it would be quite elegant to implement this if special events are added. I know that `FiniteStateMachineEvents.OnBeforeCheckIfNeedToRunState` / `FiniteStateMachineEvents.OnRunState` could be used but I think that native events would be cleaner (it also saves everyone from reinventing the wheel and building boiler plate around the FSM system).


     Share


    User Feedback

    Recommended Comments

    Hello,

    Start > robotManager.Events.FiniteStateMachineEvents.OnRunState

    Loop > robotManager.Events.FiniteStateMachineEvents.OnRunningLoopState (you need to wait next update)

    End > robotManager.Events.FiniteStateMachineEvents.OnAfterRunState

    robotManager.Events.FiniteStateMachineEvents.OnRunningLoopState += (state, cancel) =>
    {
        if (state.DisplayName == "Regeneration")
        {
            // ...
        }
    };
    
    // OR
    
    robotManager.Events.FiniteStateMachineEvents.OnRunningLoopState += (state, cancel) =>
    {
        if (state is wManager.Wow.Bot.States.Regeneration)
        {
            // ...
        }
    };
    
    // I also add OnCustomEvent, you can create your own event like that robotManager.Events.Events.CustomEventCancelable("Event Name", new object[] { "arg1", "arg2" });
    robotManager.Events.Events.OnCustomEvent += (name, args, cancelable) =>
    {
        if (name == "ItemsManager.UseItem")
        {
            var itemName = (string)args[0];
        }
        else if (name == "SpellManager.CastSpellByNameLUA")
        {
            var spellName = (string)args[0];
        }
        // ...
    };

     

    Link to comment
    Share on other sites

    Super cool. Is there a list of pre-registered events for `robotManager.Events.Events.CustomEventCancelable` or does it apply to any library function by default ?

    Link to comment
    Share on other sites



    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Add a comment...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...