public static void AutoEquipTrinkets() { float trinket1Score = Trinket1.Item != null ? Trinket1.Item.WeightScore : 0; float trinket2Score = Trinket2.Item != null ? Trinket2.Item.WeightScore : 0; WAECharacterSheetSlot lowestScoreTrinketSlot = trinket1Score <= trinket2Score ? Trinket1 : Trinket2; // List potential replacement for this slot List <WAEItem> potentialTrinkets = WAEContainers.AllItems .FindAll(i => i.ItemEquipLoc == "INVTYPE_TRINKET" && i.CanEquip()) .OrderByDescending(i => i.WeightScore) .ToList(); foreach (WAEItem item in potentialTrinkets) { if (lowestScoreTrinketSlot.Item == null || lowestScoreTrinketSlot.Item.WeightScore < item.WeightScore) { string reason = lowestScoreTrinketSlot.Item == null ? "Nothing equipped in this slot" : $"Replacing {lowestScoreTrinketSlot.Item.Name} ({lowestScoreTrinketSlot.Item.WeightScore})"; if (item.EquipSelectRoll(lowestScoreTrinketSlot.InventorySlotID, reason)) { break; } } } }
private static List <WAEItem> GetEquipableWeaponsFromBags(WAECharacterSheetSlot slot) { return(WAEContainers.AllItems .FindAll(i => i.CanEquip() && (slot.InvTypes.Contains(i.ItemEquipLoc) || SuitableForTitansGrips(i))) .ToList()); }
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); }