• Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • [Example] Pick Up Visible Items

    Discussion in 'Archives' started by Apoc, Aug 17, 2017.

    1. Apoc

      Apoc Moderator Staff Member Moderator

      Joined:
      Jan 16, 2010
      Messages:
      2,790
      Likes Received:
      94
      Trophy Points:
      48
      So, I had this thought...

      The bot should basically pick up any items that are visible (leveraging PoE's built in item filtering). This is mostly for those of us who are really only interested in picking up items that our current in-game filters show. (This also makes switching between sets of filters very easy)

      That said, here's my stuff that I'm currently using. Please note; the sell requirements are pretty much my own, and I don't suggest using this as-is unless you can read and understand what it does.

      Code:
      using System;
      using System.Collections.Generic;
      using System.IO;
      using System.Linq;
      using System.Text;
      using System.Threading.Tasks;
      using System.Windows.Controls;
      using log4net;
      using Loki.Bot;
      using Loki.Common;
      using Loki.Game;
      using Loki.Game.GameData;
      using Loki.Game.Objects;
      using Newtonsoft.Json;
      
      namespace PathFilterToExileFilter
      {
          public class GameItemEvaluator : IItemEvaluator
          {
              private static readonly ILog Log = Logger.GetLoggerInstanceForType();
              public static GameItemEvaluator Instance = new GameItemEvaluator();
              /// <inheritdoc />
              public bool Match(Item item, EvaluationType type)
              {
                  switch (type)
                  {
                      case EvaluationType.None:
                          break;
                      case EvaluationType.PickUp:
                          if (item.HasWorldItemInformation && LokiPoe.Input.HasVisibleHighlightLabel(LokiPoe.ObjectManager.GetObjectById<WorldItem>(item.WorldItemId)))
                          {
                              Log.Info("[GameItemEvaluator] Picking up " + item.Name + " because it is visible!");
                              return true;
                          }
      
                          // Include all currency, because why not? Right?
                          if (item.Rarity == Loki.Game.GameData.Rarity.Currency)
                          {
                              Log.Info("[GameItemEvaluator] Picking up " + item.Name + " because it is currency!");
                              return true;
                          }
                          return false;
      
                      case EvaluationType.Save:
                          // Save everything by default?
                          return true;
      
                      case EvaluationType.Sell:
                          // Sell 6L shitty gear
                          var sockets = item.SocketCount;
                          var links = item.LinkedSocketColors;
      
                          // Pls no sell currency... kthx
                          if (item.Rarity == Loki.Game.GameData.Rarity.Currency)
                              return false;
      
                          // Don't sell any 6L items, ever. We always want to trade these off to people. 6L's are way too rare.
                          if (item.SocketLinks.Max() == 6)
                              return false;
      
                          // 6S low item level
                          if (item.Rarity <= Loki.Game.GameData.Rarity.Magic && item.ItemLevel < 74 && sockets == 6)
                              return true;
      
                          // RGB low item level
                          if (item.Rarity <= Loki.Game.GameData.Rarity.Magic && item.ItemLevel < 74 &&
                              LokiPoe.MatchesSocketColors("R-G-B", item.SocketColors, item.SocketLinks))
                              return true;
                         
      
                          break;
                      case EvaluationType.Buy:
                          break;
                      case EvaluationType.Id:
                          break;
                      default:
                          throw new ArgumentOutOfRangeException(nameof(type), type, null);
                  }
      
                  return false;
              }
      
              /// <inheritdoc />
              public string Name { get; } = "GameItemEvaluator";
          }
         
          public class GameItemEvaluatorPlugin : IPlugin, IStartStopEvents
          {
              /// <inheritdoc />
              public UserControl Control { get; }
      
              /// <inheritdoc />
              public JsonSettings Settings { get; }
      
              /// <inheritdoc />
              public MessageResult Message(Message message)
              {
                  return MessageResult.Unprocessed;
              }
      
              /// <inheritdoc />
              public string Name { get; } = "GameItemEvaluator";
      
              /// <inheritdoc />
              public string Author { get; } = "Apoc";
      
              /// <inheritdoc />
              public string Description { get; } = "A simple item evaluator that uses the in-game item filter to pick items, and some simple rules to sell items";
      
              /// <inheritdoc />
              public string Version { get; } = "1.0.0.1";
      
              /// <inheritdoc />
              public void Initialize()
              {
              }
      
              /// <inheritdoc />
              public void Deinitialize()
              {
              }
      
              /// <inheritdoc />
              public void Enable()
              {
                  ItemEvaluator.Instance = GameItemEvaluator.Instance;
              }
      
              /// <inheritdoc />
              public void Disable()
              {
              }
      
              /// <inheritdoc />
              public async Task<LogicResult> Logic(Logic logic)
              {
                  return LogicResult.Unprovided;
              }
      
              /// <inheritdoc />
              public void Start()
              {
                  ItemEvaluator.Instance = GameItemEvaluator.Instance;
              }
      
              /// <inheritdoc />
              public void Stop()
              {
              }
          }
      }
       
    2. danycv

      danycv Member

      Joined:
      Dec 11, 2012
      Messages:
      62
      Likes Received:
      0
      Trophy Points:
      6
      i want know how to use this?
       
    3. Tattoo

      Tattoo Member

      Joined:
      Dec 16, 2011
      Messages:
      133
      Likes Received:
      11
      Trophy Points:
      18
      apoc this sounds really cool, can you write a short approach how to utilize this? copy it as an plugin in an own folder?
       
    4. darkbluefirefly

      darkbluefirefly Community Developer

      Joined:
      Nov 8, 2013
      Messages:
      1,927
      Likes Received:
      18
      Trophy Points:
      38
      Code:
              public static readonly GameItemEvaluator ItemEvaluator = new GameItemEvaluator();
              Loki.Bot.ItemEvaluator.Instance = ItemEvaluator;
       
    5. g0dzix

      g0dzix Member

      Joined:
      Jul 3, 2014
      Messages:
      39
      Likes Received:
      2
      Trophy Points:
      8
      I understand right? That's addon, that pickups items based on thier visiblity with ingame itemfilter(like neversink)?
       
    6. IeU

      IeU Member

      Joined:
      Jul 20, 2010
      Messages:
      830
      Likes Received:
      11
      Trophy Points:
      18
      Yes.
       
    7. Tattoo

      Tattoo Member

      Joined:
      Dec 16, 2011
      Messages:
      133
      Likes Received:
      11
      Trophy Points:
      18
      looks like but i didn't manage to make it work - tried to copy it with a 3rdparty json, and it loads... but it doesn't seem to work what it should :(

      would be so perfect to have thing like this.

      Someone could explain a bit how to make use of it?
       
    8. Apoc

      Apoc Moderator Staff Member Moderator

      Joined:
      Jan 16, 2010
      Messages:
      2,790
      Likes Received:
      94
      Trophy Points:
      48
      You need to disable the other ItemFilterEditor plugin and enable this one to make it work.
       
    9. kalanikila

      kalanikila Member

      Joined:
      Nov 28, 2012
      Messages:
      293
      Likes Received:
      5
      Trophy Points:
      18
      Where do I paste the code?
       
    10. Eightbyte

      Eightbyte New Member

      Joined:
      Jul 11, 2017
      Messages:
      15
      Likes Received:
      0
      Trophy Points:
      1
      It has been added to the latest EB update afaik.
       
    11. Darox

      Darox Member

      Joined:
      Nov 7, 2014
      Messages:
      353
      Likes Received:
      2
      Trophy Points:
      18
      Using this with AIF... if possible might be a great solution. No idea if it would help, but might speed up bot looting to only look at visible items for evaluation (not sure how this works at all). Or just customize filter to only show what you want then add the chaos recipe. Could do a filter to just show ilevel 60+ and currency/maps/uniques etc.
       

    Share This Page