Jump to content

[BUG] [PARTY] Bot d'ont regen if "ressurect when dead" is disabled


Evaexe

Recommended Posts

try with this code

using System;
using robotManager.Events;
using robotManager.FiniteStateMachine;
using robotManager.Helpful;
using wManager.Plugin;
using wManager.Wow.Bot.States;

public class Main : IPlugin
{
    private bool _stateAdded;

    public void Initialize()
    {
        FiniteStateMachineEvents.OnStartEngine += StateAddEventHandler;
        FiniteStateMachineEvents.OnAfterRunState += AfterStateAddEventHandler;
    }

    private void AfterStateAddEventHandler(Engine engine, State state)
    {
        AddState(engine);
    }

    private void StateAddEventHandler(Engine engine)
    {
        AddState(engine);
    }

    public void Dispose()
    {
        FiniteStateMachineEvents.OnStartEngine -= StateAddEventHandler;
        FiniteStateMachineEvents.OnAfterRunState -= AfterStateAddEventHandler;
    }

    public void Settings()
    {
    }

    private void AddState(Engine engine)
    {
        if (!_stateAdded && engine != null)
        {
            try
            {
                State resState = engine.States.Find(state => state.GetType() == typeof(IsAttacked));
                engine.AddState(new Regeneration() {Priority = resState.Priority - 1});
                engine.States.Sort();
                _stateAdded = true;
                Logging.Write("Adding Regen State");
            }
            catch (Exception e)
            {
                //Logging.WriteError("" + e);
            }
        }
    }
}

 

Link to comment
Share on other sites

  • 10 months later...

That error happens once, in WRobot's code. Next iteration it does, it now has your states in it and everything works without error.
Edit: These are 5 years old, but the code is still applicable as far as I know. No guarantee PartyBot Helper still works with HMP.

 

 

Edited by Matenia
Link to comment
Share on other sites

Look at what I linked. The error happens ONCE after you add your state. This code works fine - wRobot's FiniteStateMachine that iterates the states throws the error.

Since you only modify the collection ONCE to add your state(s), the very next iteration across all states works just fine. I'm telling you, you can ignore the error.

Link to comment
Share on other sites

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