Jump to content
This site uses cookies! Learn More

This site uses cookies!

By continuing to use this site, you agree to allow us to store cookies on your computer. :)

duthibaut

C# Stopfollowing Path [Gathering]

Recommended Posts

Hello @Droidz

I have do some C# code in a pluggin for check distance farming and stop go to the node by his ground Vector3 but.

But when i use my plugin i have a problem : The bot try to go the node AND to follow the path with gathering in the same time. You know how i can stop the following path, clean the node and restart the following path by the pluggin ?

 

Thx 😃

 

 

Share this post


Link to post
Share on other sites

Thanks for this reply, but ... Thread is an object ?  this line don"t compile, i need to create a object thread and .abort after ?

public void GoToFarm()
    {
        _isLaunched = true;
        wManager.Wow.Helpers.Chat.SendChatMessage("Initialize", wManager.Wow.Enums.ChatTypeId.SAY);
        glaurierId = 181279;
        var glaurierObject =  ObjectManager.GetNearestWoWGameObject(ObjectManager.GetWoWGameObjectByEntry(glaurierId)) ;
        while (_isLaunched)
        {
            try
                {
                    var distance = ObjectManager.GetNearestWoWGameObject(ObjectManager.GetWoWGameObjectByEntry(glaurierId)).GetDistance;
                    if (ObjectManager.GetNearestWoWGameObject(ObjectManager.GetWoWGameObjectByEntry(glaurierId)).GetDistance < 200)
                    {
                        robotManager.Events.FiniteStateMachineEvents.OnBeforeCheckIfNeedToRunState += (engine, state, cancelable) =>
                            {
                                if (state is wManager.Wow.Bot.States.Farming && !state.NeedToRun)
                                {
                                    wManager.Wow.Bot.Tasks.GoToTask.ToPositionAndIntecractWithGameObject(ObjectManager.GetNearestWoWGameObject(ObjectManager.GetWoWGameObjectByEntry(glaurierId)).Position, ObjectManager.GetNearestWoWGameObject(ObjectManager.GetWoWGameObjectByEntry(glaurierId)).Entry);             
                                    Thread.Sleep(5000);
                                    wManager.Wow.Helpers.Chat.SendChatMessage("In the new thread", wManager.Wow.Enums.ChatTypeId.SAY);
                                   
                                }
                            
                            };
                          
                    }
                   
                     
                //wManager.Wow.Helpers.Chat.SendChatMessage("Je suis sorti", wManager.Wow.Enums.ChatTypeId.SAY);
                }
                    
                //wManager.Wow.Bot.Tasks.GoToTask.ToPositionAndIntecractWithGameObject(ObjectManager.GetNearestWoWGameObject(ObjectManager.GetWoWGameObjectByEntry(glaurierId)).Position, ObjectManager.GetNearestWoWGameObject(ObjectManager.GetWoWGameObjectByEntry(glaurierId)).Entry);
                
                
                
                catch (Exception e)
                {
                    Logging.WriteError("[GatheringHelp]: " + e);
                }
        }    

    }


	public void Initialize()
	{
        Thread newThread = new Thread(new ThreadStart(GoToFarm));  
      
    }

 

Share this post


Link to post
Share on other sites

@Inaru

image.png.7e0af96b6b686f7d715a84e3142e5f43.png

Only an assignation, a call or an increment in wait and expressions of object "new" can be use like an instruction

 

@Droidz nothing change well i delete the while(_islaunched) {} , he skipp all the node 😕

Share this post


Link to post
Share on other sites
Posted (edited)

Try with.....

 

GoToFarm(){

new Thread(() =>

// Your code here

}).Start();

}

 

And in initialize just do GoToFarm()

Edited by Inaru

Share this post


Link to post
Share on other sites

I do like this : @Droidz

public void Initialize()
	{
        _isLaunched = true;
        wManager.Wow.Helpers.Chat.SendChatMessage("Initialize", wManager.Wow.Enums.ChatTypeId.SAY);
        glaurierId = 181279;
        var glaurierObject =  ObjectManager.GetNearestWoWGameObject(ObjectManager.GetWoWGameObjectByEntry(glaurierId)) ;
        
        GoToFarm(glaurierId);
    }

    public void GoToFarm(int glaurierId)
    {
        try
                {
                    var distance = ObjectManager.GetNearestWoWGameObject(ObjectManager.GetWoWGameObjectByEntry(glaurierId)).GetDistance;
                    if (ObjectManager.GetNearestWoWGameObject(ObjectManager.GetWoWGameObjectByEntry(glaurierId)).GetDistance < 200)
                    {
                        robotManager.Events.FiniteStateMachineEvents.OnBeforeCheckIfNeedToRunState += (engine, state, cancelable) =>
                            {
                                if (state is wManager.Wow.Bot.States.Farming && !state.NeedToRun)
                                {
                                    wManager.Wow.Bot.Tasks.GoToTask.ToPositionAndIntecractWithGameObject(ObjectManager.GetNearestWoWGameObject(ObjectManager.GetWoWGameObjectByEntry(glaurierId)).Position, ObjectManager.GetNearestWoWGameObject(ObjectManager.GetWoWGameObjectByEntry(glaurierId)).Entry);             
                                    Thread.Sleep(5000);
                                    wManager.Wow.Helpers.Chat.SendChatMessage("In the new thread", wManager.Wow.Enums.ChatTypeId.SAY);
                                   
                                }
                            
                            };
                          
                    } 
                }       
                catch (Exception e)
                {
                    Logging.WriteError("[GatheringHelp]: " + e);
                }

    }

He do as well but stay in "In the new thread" (say in chat).

I try this now @Inaru !!

Share this post


Link to post
Share on other sites

Thx @Inaru and @Droidz

I set some recusivity in my thread and it's working just fine as well 😃

public void Initialize()
	{
        _isLaunched = true;
        wManager.Wow.Helpers.Chat.SendChatMessage("Initialize", wManager.Wow.Enums.ChatTypeId.SAY);
        glaurierId = 181279;
        var glaurierObject =  ObjectManager.GetNearestWoWGameObject(ObjectManager.GetWoWGameObjectByEntry(glaurierId)) ;
        
        GoToFarm(glaurierId);
    }

    public void GoToFarm(int glaurierId)
    {
        robotManager.Events.FiniteStateMachineEvents.OnBeforeCheckIfNeedToRunState += (engine, state, cancelable) =>
        {
         try
                {
                    var distance = ObjectManager.GetNearestWoWGameObject(ObjectManager.GetWoWGameObjectByEntry(glaurierId)).GetDistance;
                    if (ObjectManager.GetNearestWoWGameObject(ObjectManager.GetWoWGameObjectByEntry(glaurierId)).GetDistance < 200)
                    
                        if (state is wManager.Wow.Bot.States.Farming && !state.NeedToRun)
                        {
                            glaurierId = 181279;
                            wManager.Wow.Bot.Tasks.GoToTask.ToPositionAndIntecractWithGameObject(ObjectManager.GetNearestWoWGameObject(ObjectManager.GetWoWGameObjectByEntry(glaurierId)).Position, ObjectManager.GetNearestWoWGameObject(ObjectManager.GetWoWGameObjectByEntry(glaurierId)).Entry);             
                            Thread.Sleep(5000);
                            wManager.Wow.Helpers.Chat.SendChatMessage("In the new thread", wManager.Wow.Enums.ChatTypeId.SAY);
                            GoToFarm(glaurierId);       
                        }     
                } 
                     
                catch (Exception e)
                {
                    Logging.WriteError("[GatheringHelp]: " + e);
                }

            };

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...