Apoc
Well-Known Member
- Joined
- Jan 16, 2010
- Messages
- 2,790
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.
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()
{
}
}
}