public static void LogProperties(this object obj)
        {
            var type     = obj.GetType();
            var typeName = type.Name;

            foreach (var p in obj.GetType().GetProperties())
            {
                GlobalLog.Info($"[{typeName}] {p.Name}: {p.GetValue(obj) ?? "null"}");
            }
        }
Esempio n. 2
0
        public static async Task DisableAlwaysHighlight()
        {
            if (!LokiPoe.ConfigManager.IsAlwaysHighlightEnabled)
            {
                return;
            }

            GlobalLog.Info("[DisableAlwaysHighlight] Now disabling always highlight.");
            LokiPoe.Input.SimulateKeyEvent(LokiPoe.Input.Binding.highlight_toggle, true, false, false);
            await Wait.Sleep(30);
        }
Esempio n. 3
0
 public static void Reset()
 {
     GlobalLog.Info("[ErrorManager] Error count has been reset.");
     ErrorCount = 0;
     SpecificErrors.Clear();
 }
Esempio n. 4
0
        public static async Task <bool> SellItems(List <Vector2i> itemPositions)
        {
            if (itemPositions == null)
            {
                GlobalLog.Error("[SellItems] Item list for sell is null.");
                return(false);
            }
            if (itemPositions.Count == 0)
            {
                GlobalLog.Error("[SellItems] Item list for sell is empty.");
                return(false);
            }

            var vendor = GetSellVendor();

            if (vendor == null)
            {
                return(false);
            }

            if (!await vendor.OpenSellPanel())
            {
                return(false);
            }

            itemPositions.Sort(Position.Comparer.Instance);

            var soldItems = new List <CachedItem>(itemPositions.Count);

            foreach (var itemPos in itemPositions)
            {
                var item = InventoryUi.InventoryControl_Main.Inventory.FindItemByPos(itemPos);
                if (item == null)
                {
                    GlobalLog.Error($"[SellItems] Fail to find item at {itemPos}. Skipping it.");
                    continue;
                }

                soldItems.Add(new CachedItem(item));

                if (!SellUi.TradeControl.InventoryControl_YourOffer.Inventory.CanFitItem(item.Size))
                {
                    break;
                }

                if (!await Inventories.FastMoveToVendor(itemPos))
                {
                    return(false);
                }
            }

            var gainedItems = new List <CachedItem>();

            foreach (var item in SellUi.TradeControl.InventoryControl_OtherOffer.Inventory.Items)
            {
                gainedItems.Add(new CachedItem(item));
            }

            var accepted = SellUi.TradeControl.Accept();

            if (accepted != TradeResult.None)
            {
                GlobalLog.Error($"[SellItems] Fail to accept sell. Error: \"{accepted}\".");
                return(false);
            }
            if (!await Wait.For(() => !SellUi.IsOpened, "sell panel closing"))
            {
                await Coroutines.CloseBlockingWindows();

                return(false);
            }

            // game needs some time do despawn sold items from inventory
            await Wait.SleepSafe(200);

            GlobalLog.Info($"[Events] Items sold ({soldItems.Count})");
            Utility.BroadcastMessage(null, Events.Messages.ItemsSoldEvent, soldItems, gainedItems);
            return(true);
        }
Esempio n. 5
0
        public static void Tick()
        {
            if (!LokiPoe.IsInGame)
            {
                return;
            }

            if (_checkStart)
            {
                _checkStart = false;
                GlobalLog.Info("[Events] Ingame bot start.");
                Utility.BroadcastMessage(null, Messages.IngameBotStart);
            }

            var newHash = LokiPoe.LocalData.AreaHash;

            if (newHash != _areaHash)
            {
                var oldArea = _area;
                var oldHash = _areaHash;
                _area     = World.CurrentArea;
                _areaHash = newHash;
                var areaName = _area.Name;

                GlobalLog.Info($"[Events] Area changed ({oldArea?.Name ?? "null"} -> {areaName})");
                Utility.BroadcastMessage(null, Messages.AreaChanged, oldHash, newHash, oldArea, _area);

                if (newHash != _combatAreaHash && _area.IsCombatArea)
                {
                    var oldCombatArea = _combatArea;
                    var oldCombatHash = _combatAreaHash;
                    _combatArea     = _area;
                    _combatAreaHash = newHash;

                    GlobalLog.Info($"[Events] Combat area changed ({oldCombatArea?.Name ?? "null"} -> {areaName})");
                    Utility.BroadcastMessage(null, Messages.CombatAreaChanged, oldCombatHash, newHash, oldCombatArea, _area);
                }
            }

            var me = LokiPoe.Me;

            if (me.IsDead)
            {
                if (!_isDead)
                {
                    _isDead = true;
                    var cache = CombatAreaCache.Current;
                    ++cache.DeathCount;
                    GlobalLog.Info($"[Events] Player died ({cache.DeathCount})");
                    Utility.BroadcastMessage(null, Messages.PlayerDied, cache.DeathCount);
                }
            }
            else
            {
                _isDead = false;
            }

            var name  = me.Name;
            var level = me.Level;

            if (name != _name)
            {
                _name  = name;
                _level = level;
            }
            else
            {
                if (level > _level)
                {
                    _level = level;
                    GlobalLog.Info($"[Events] Player leveled ({level})");
                    Utility.BroadcastMessage(null, Messages.PlayerLeveled, level);
                }
            }
        }
 public InputDelayOverride(int newDelay)
 {
     _oldDelay = LokiPoe.Input.InputEventDelayMs;
     GlobalLog.Info($"[InputDelayOverride] Setting input delay to {newDelay} ms.");
     LokiPoe.Input.InputEventDelayMs = newDelay;
 }
 public void Dispose()
 {
     GlobalLog.Info($"[InputDelayOverride] Restoring original input delay {_oldDelay} ms.");
     LokiPoe.Input.InputEventDelayMs = _oldDelay;
 }