• Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Prevent CloseBlockingWindows

    Discussion in 'Archives' started by aujra1, Feb 3, 2016.

    1. aujra1

      aujra1 Member

      Joined:
      Oct 2, 2010
      Messages:
      38
      Likes Received:
      1
      Trophy Points:
      8
      I am writing a plugin that rerolls links sockets and link colors to what the user wants. However it is closing the stash all the time. Is there a way to prevent CloseBlockingWindows from being called by the bot?
       
    2. toNyx

      toNyx Well-Known Member

      Joined:
      Oct 29, 2011
      Messages:
      3,770
      Likes Received:
      35
      Trophy Points:
      48
      Prevent your task from returning and the problem is gone. :D

      Give us a snippet of your code and we might take a look
       
    3. darkbluefirefly

      darkbluefirefly Community Developer

      Joined:
      Nov 8, 2013
      Messages:
      1,927
      Likes Received:
      18
      Trophy Points:
      38
      Or be like me and remove the task all together, then add it again magically.
       
    4. aujra1

      aujra1 Member

      Joined:
      Oct 2, 2010
      Messages:
      38
      Likes Received:
      1
      Trophy Points:
      8
      Code:
      public void Tick()
              {
                  if (!LokiPoe.IsInGame || !LokiPoe.Me.IsInTown)
                      return;
      
                  Vector2i v = new Vector2i(0, 0);
                  if (_rollSockets)
                  {
                      if (Helpers.hasItem(_itemName).SocketCount < _socketCount)
                      {                    
                          Helpers.UseOrbOnItem(v, "Jeweller's Orb");
                      }
                  }
                  if (_rollLinks)
                  {
                      foreach (SocketColor[] a in Helpers.hasItem(_itemName).LinkedSocketColors)
                      {
                          if (a.Length >= _socketCount)
                          {
                              _linksDone = true;
                          }                
                      }
                      if (!_linksDone)
                      {
                          Log.Debug("need to roll links");
                          Helpers.UseOrbOnItem(v, "Orb of Fusing");
                      }
                  }
                  
              }
      
      This currently is my tick function in my main class.

      Is there a list of tasks. I have removed multiple tasks (thanks QuestPlugin) however, I am not finding a CloseBlockingWindows or CloseBlockingWindowsTask.

      Also thanks for the help this is a solid community!
       
    5. Tormiasz

      Tormiasz Community Developer

      Joined:
      Jun 16, 2014
      Messages:
      701
      Likes Received:
      5
      Trophy Points:
      18
      There's no task for that, the Tasks are calling Loki.Bot.Logic.Bots.OldGrindBot.Coroutines.CloseBlockingWindows() function.

      I would suggest doing a loop here instead of tick and don't return until you are done with your stuff or stop the bot.
       
    6. darkbluefirefly

      darkbluefirefly Community Developer

      Joined:
      Nov 8, 2013
      Messages:
      1,927
      Likes Received:
      18
      Trophy Points:
      38
      This is correct, async loop whatever you are trying to do in your task.
       
    7. toNyx

      toNyx Well-Known Member

      Joined:
      Oct 29, 2011
      Messages:
      3,770
      Likes Received:
      35
      Trophy Points:
      48
      As tormiasz says, it's a pretty bad idea to process in tick for that kind of things. Make your own task, and loop in it...
       
    8. darkbluefirefly

      darkbluefirefly Community Developer

      Joined:
      Nov 8, 2013
      Messages:
      1,927
      Likes Received:
      18
      Trophy Points:
      38
      Don't ever do a loop in tick(). You will freeze the game and Bot.

      The Logic async is where you want to loop things.

      call the async with an await YOURTASKNAME();
      inside the

      Code:
                  public async Task<bool> Logic(string type, params dynamic[] param)
      {
      
      Code:
      private static async Task YOURTASKNAME()
      {
      	if (!LokiPoe.IsInGame || !LokiPoe.Me.IsInTown)
      		return;
      	while(true)
      	{
      		Vector2i v = new Vector2i(0, 0);
      		if (_rollSockets)
      		{
      			if (Helpers.hasItem(_itemName).SocketCount < _socketCount)
      			{                    
      				Helpers.UseOrbOnItem(v, "Jeweller's Orb");
      			}
      		}
      		if (_rollLinks)
      		{
      			foreach (SocketColor[] a in Helpers.hasItem(_itemName).LinkedSocketColors)
      			{
      				if (a.Length >= _socketCount)
      				{
      					_linksDone = true;
      					break;
      				}                
      			}
      			if (!_linksDone)
      			{
      				Log.Debug("need to roll links");
      				Helpers.UseOrbOnItem(v, "Orb of Fusing");
      			}
      		}
      	}
      }
      This async has no return value, because one is not needed.
       
    9. aujra1

      aujra1 Member

      Joined:
      Oct 2, 2010
      Messages:
      38
      Likes Received:
      1
      Trophy Points:
      8
      Thank you for the advice. I learned about the POE crashing when I called a looped function from tick and crashed poe. Looks like logic is for loops while tick is there for things like log or logic updates and not actual execution loops.
       
    10. darkbluefirefly

      darkbluefirefly Community Developer

      Joined:
      Nov 8, 2013
      Messages:
      1,927
      Likes Received:
      18
      Trophy Points:
      38
      Yup, async takes turns running, Tick() always runs.
      Tick is used to update information, where as async does the logic.

      It gets a little getting used to, but once you start figuring things out, it makes a lot of sense. Good luck, and have fun.
       
    11. LajtStyle

      LajtStyle Community Developer

      Joined:
      Jan 5, 2015
      Messages:
      96
      Likes Received:
      5
      Trophy Points:
      8
      So i don't fully understand this Logic Task
      Is it same as Tick but it gives you option to use async code inside?

      Im working on currency logger thing that show me currency from each of my bot in one place.
      For now i save currency data into file each x time. Code is inside Tick.
      Everything is working as intended but if i wanna add functionality there is one problem.
      I want to send post request to my server but i wanna do it asynchronously so it won't block main loop/freeze bot when request will timeout for some reason.
      Is there way to solve this using Logic Task?
      For example in AlterterReleoded plugin every mobile notify request can freeze bot and i wanna avoid that.
       
    12. toNyx

      toNyx Well-Known Member

      Joined:
      Oct 29, 2011
      Messages:
      3,770
      Likes Received:
      35
      Trophy Points:
      48
      Nope, a task executes, Tick() is a pulse.

      Tick() is executed more than once per second, which is dangerous in some cases.

      a Task will allow you to process a whole behavior before returning, so the bot don't do anything else in the meantime
       

    Share This Page