public int GetNbEquipAttempts() { return(ItemEquipAttempts.FindAll(i => i == ItemLink).Count); }
public bool EquipSelectRoll(int slotId, string reason) { WAELootFilter.ProtectFromFilter(ItemLink); // ROLL if (RollId >= 0) { WAEGroupRoll.Roll(RollId, this, reason, RollType.NEED); HasBeenRolled = true; WAEContainers.AllItems.Clear(); return(true); } // SELECT REWARD if (RewardSlot >= 0) { Lua.LuaDoString($"GetQuestReward({RewardSlot})"); Logger.Log($"Selecting quest reward {Name} [{reason}]"); WAEContainers.AllItems.Clear(); return(true); } // EQUIP WAECharacterSheetSlot slot = WAECharacterSheet.AllSlots.Find(s => s.InventorySlotID == slotId); if (slot.Item?.ItemLink == ItemLink) { return(true); } if (ItemSubType != "Arrow" && ItemSubType != "Bullet") { if (ObjectManager.Me.InCombatFlagOnly || ObjectManager.Me.IsCast) { return(false); } } if (InBag < 0 || InBagSlot < 0) { Logger.LogError($"Item {Name} is not recorded as being in a bag. Can't use."); } else { Logger.Log($"Equipping {Name} ({WeightScore}) [{reason}]"); ItemEquipAttempts.Add(ItemLink); PickupFromBag(); DropInInventory(slotId); ToolBox.Sleep(100); Lua.LuaDoString($"EquipPendingItem(0);"); //Lua.LuaDoString($"StaticPopup1Button1:Click()"); ToolBox.Sleep(200); WAECharacterSheet.Scan(); WAEContainers.Scan(); WAECharacterSheetSlot updatedSlot = WAECharacterSheet.AllSlots.Find(s => s.InventorySlotID == slotId); if (updatedSlot.Item == null || updatedSlot.Item.ItemLink != ItemLink) { if (GetNbEquipAttempts() < _maxNbEquipAttempts) { Logger.LogError($"Failed to equip {Name}. Retrying soon ({GetNbEquipAttempts()})."); } else { Logger.LogError($"Failed to equip {Name} after {GetNbEquipAttempts()} attempts."); } Lua.LuaDoString($"ClearCursor()"); return(false); } ItemEquipAttempts.RemoveAll(i => i == ItemLink); WAELootFilter.AllowForFilter(ItemLink); return(true); } return(false); }