Jump to content

Recommended Posts

Hello everyone,

I am developing an automation script related to "World of Warcraft" in C# and have encountered some difficulties. When a character dies and enters spirit form, I need to write code to automatically control the character to click the "Release Spirit" button and talk to a specific NPC after releasing the spirit.

At present, I am not clear on how to implement this function with C# code. Specifically, I need to achieve the following steps:

  1. Detect whether the character is dead and in spirit form.
  2. Automatically click the "Release Spirit" button.
  3. Move close to the NPC.
  4. Engage in dialogue with the NPC.

I have tried some basic API calls and event listening, but I have not been successful. I don't know if anyone has experience in this area or can provide some guidance and code examples?

If someone can help me, I would be very grateful. Any suggestions, guidance, or code examples would be greatly helpful to me.

Thank you!

This is my code:(ToPositionAndIncractWithNpc unsuccessful)

robotManager.Events.FiniteStateMachineEvents.OnRunState += (engine, state, cancelable) =>
        {
            if (state is wManager.Wow.Bot.States.Resurrect && ObjectManager.Me.IsDead)
            {
                if (ObjectManager.Me.Position.DistanceTo2D(new Vector3(-14284.96f, 288.4472f, 32.33204f)) < 2) {
                    var path = new Vector3(-14283.13f, 293.2209f, 31.98451f);
                    MovementManager.Go(PathFinder.FindPath(path),false);
                    MovementManager.StopMove();
                   
                    var position = new Vector3(-14283.13f, 293.2209f, 31.98451f);
                    int npcEntryId = 1000128;
                    wManager.Wow.Bot.Tasks.GoToTask.ToPositionAndIntecractWithNpc(position, npcEntryId);
                    System.Threading.Thread.Sleep(500);
                    Usefuls.SelectGossipOption(3);
                    System.Threading.Thread.Sleep(3000);
                }
                cancelable.Cancel = true;
            }
        };

Hello,

By default, GoToTask methods don't work when the character is dead.

No tested but code should look like:

robotManager.Events.FiniteStateMachineEvents.OnRunState += (engine, state, cancelable) =>
{
    if (state is wManager.Wow.Bot.States.Resurrect && ObjectManager.Me.IsDead)
    {
        if (ObjectManager.Me.Position.DistanceTo2D(new Vector3(-14284.96f, 288.4472f, 32.33204f)) < 2) {
            var destination = new Vector3(-14283.13f, 293.2209f, 31.98451f);
            int npcEntryId = 1000128;
            var goToSuccess = wManager.Wow.Bot.Tasks.GoToTask.ToPosition(
                destination, 
                3.5f, 
                false,
                c => Conditions.InGameAndConnectedAndProductStartedNotInPause);
            
            if (goToSuccess)
            {
                var npcs = ObjectManager.GetWoWUnitByEntry(npcEntryId);
                var npcUnit = npcs.Where(n => n.IsValid).OrderBy(n => n.GetDistance).FirstOrDefault();
                if (npcUnit != null)
                {
                    Interact.InteractGameObject(npcUnit.GetBaseAddress);
                    System.Threading.Thread.Sleep(500);
                    Usefuls.SelectGossipOption(3);
                    System.Threading.Thread.Sleep(3000);
                    cancelable.Cancel = true;
                }
            }
        }
    }
};

 

1 hour ago, Droidz said:

Hello,

By default, GoToTask methods don't work when the character is dead.

No tested but code should look like:

robotManager.Events.FiniteStateMachineEvents.OnRunState += (engine, state, cancelable) =>
{
    if (state is wManager.Wow.Bot.States.Resurrect && ObjectManager.Me.IsDead)
    {
        if (ObjectManager.Me.Position.DistanceTo2D(new Vector3(-14284.96f, 288.4472f, 32.33204f)) < 2) {
            var destination = new Vector3(-14283.13f, 293.2209f, 31.98451f);
            int npcEntryId = 1000128;
            var goToSuccess = wManager.Wow.Bot.Tasks.GoToTask.ToPosition(
                destination, 
                3.5f, 
                false,
                c => Conditions.InGameAndConnectedAndProductStartedNotInPause);
            
            if (goToSuccess)
            {
                var npcs = ObjectManager.GetWoWUnitByEntry(npcEntryId);
                var npcUnit = npcs.Where(n => n.IsValid).OrderBy(n => n.GetDistance).FirstOrDefault();
                if (npcUnit != null)
                {
                    Interact.InteractGameObject(npcUnit.GetBaseAddress);
                    System.Threading.Thread.Sleep(500);
                    Usefuls.SelectGossipOption(3);
                    System.Threading.Thread.Sleep(3000);
                    cancelable.Cancel = true;
                }
            }
        }
    }
};

 

I really appreciate your help, and I will give the code snippet you provided a try.

1 hour ago, Droidz said:

Hello,

By default, GoToTask methods don't work when the character is dead.

No tested but code should look like:

robotManager.Events.FiniteStateMachineEvents.OnRunState += (engine, state, cancelable) =>
{
    if (state is wManager.Wow.Bot.States.Resurrect && ObjectManager.Me.IsDead)
    {
        if (ObjectManager.Me.Position.DistanceTo2D(new Vector3(-14284.96f, 288.4472f, 32.33204f)) < 2) {
            var destination = new Vector3(-14283.13f, 293.2209f, 31.98451f);
            int npcEntryId = 1000128;
            var goToSuccess = wManager.Wow.Bot.Tasks.GoToTask.ToPosition(
                destination, 
                3.5f, 
                false,
                c => Conditions.InGameAndConnectedAndProductStartedNotInPause);
            
            if (goToSuccess)
            {
                var npcs = ObjectManager.GetWoWUnitByEntry(npcEntryId);
                var npcUnit = npcs.Where(n => n.IsValid).OrderBy(n => n.GetDistance).FirstOrDefault();
                if (npcUnit != null)
                {
                    Interact.InteractGameObject(npcUnit.GetBaseAddress);
                    System.Threading.Thread.Sleep(500);
                    Usefuls.SelectGossipOption(3);
                    System.Threading.Thread.Sleep(3000);
                    cancelable.Cancel = true;
                }
            }
        }
    }
};

 

It's working now, thank you again.

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