Jump to content

Herb nodes are getting ignored after unsuccessful attempt


falder

Recommended Posts

Hi,

On my plugin, i disabled combat completely with this code,

 Conditions.ForceIgnoreIsAttacked = true;

But when bot is trying to gather herb and a mob attacks it and interrupts gathering cast, bot assumes that gathering was successful and keeps move on. In real, gathering cast is interrupted and items are not looted. How can i force bot to  try gather herb again?

 

 

Link to comment
Share on other sites

Hmm, I have not tested this, and it's probably more or-less pseudo code:

Will use a list of objects from WRobot Settings - List Harvest objects and while the player is more than 1 yard (Distance may need tweaking) from the nearest object,
will disable all combat until the player distance is within the 1 yard. It will allow for combat if necessary, and while the object is not null and is valid, will interact with it.

In combat, you may move a lot or a little depending on your fight class, and other plugins, so the distance will most certainly need to played with.

There may be errors here, but it's just a thought.

var objectsHarvestIds = new List<WoWGameObject>();
objectsHarvestIds.AddRange(ObjectManager.GetWoWGameObjectById(wManager.wManagerSetting.CurrentSetting.ListHarvest).OrderByDescending(o => o.GetDistance));

if (objectsHarvestIds.Count <= 0) return;

try
{
    if (objectsHarvestIds != null)
    {
        var objectToHarvest = objectsHarvestIds.Where(o => o != null && o.IsValid).OrderBy(o => ObjectManager.Me.Position.DistanceTo(o.Position)).FirstOrDefault();

        if (objectToHarvest != null && objectToHarvest.IsValid)
        {
            while (Vector3.Distance(ObjectManager.Me.Position, objectToHarvest.Position) > 1.0f)
            {
                Conditions.ForceIgnoreIsAttacked = true;
            }

            while (Vector3.Distance(ObjectManager.Me.Position, objectToHarvest.Position) <= 1.0f)
            {
                Conditions.ForceIgnoreIsAttacked = false;

                while (objectToHarvest != null && objectToHarvest.IsValid)
                {
                    Interact.InteractGameObject(objectToHarvest.GetBaseAddress);
                }
            }
        }
    }
    Conditions.ForceIgnoreIsAttacked = false;
}
catch (Exception e)
{
    Logging.WriteError("HarvestGameObject Error!" + Environment.NewLine + e);
}

 

Link to comment
Share on other sites

So, your idea is that, we have to force for gathering until we loot the herb. I thought there might be a way to manipulate harvested object list so bot would try to gather again. If it is not the case, thank you for the example code, i will try to improve it.

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