jack love 0 Posted May 30 Share Posted May 30 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: Detect whether the character is dead and in spirit form. Automatically click the "Release Spirit" button. Move close to the NPC. 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; } }; Link to comment https://wrobot.eu/forums/topic/15471-how-to-interact-with-npcs-in-spirit-form%EF%BC%9F/ Share on other sites More sharing options...
Droidz 2742 Posted June 2 Share Posted June 2 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; } } } } }; Link to comment https://wrobot.eu/forums/topic/15471-how-to-interact-with-npcs-in-spirit-form%EF%BC%9F/#findComment-69373 Share on other sites More sharing options...
jack love 0 Posted June 2 Author Share Posted June 2 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. Link to comment https://wrobot.eu/forums/topic/15471-how-to-interact-with-npcs-in-spirit-form%EF%BC%9F/#findComment-69374 Share on other sites More sharing options...
jack love 0 Posted June 2 Author Share Posted June 2 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. Link to comment https://wrobot.eu/forums/topic/15471-how-to-interact-with-npcs-in-spirit-form%EF%BC%9F/#findComment-69375 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now