Jump to content
  • Regeneration state events


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

    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).



    User Feedback

    Recommended Comments

    Droidz

    Posted

    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];
        }
        // ...
    };

     

    Hashira

    Posted

    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 ?

    Droidz

    Posted

    No, it is manual, it is current usage:

    devenv_gWDb83GqBr.png

    If you need event in other methods tell me I will add them



    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

×
×
  • Create New...