コード例 #1
0
    private void BackGroundPulse(object sender, DoWorkEventArgs args)
    {
        while (isLaunched)
        {
            try
            {
                if (Conditions.InGameAndConnectedAndProductStartedNotInPause)
                {
                    lock (WAELock)
                    {
                        Logger.LogPerformance("--------------------------------------");
                        DateTime dateBegin = DateTime.Now;

                        if (!ToolBox.WEEquipToolTipExists())
                        {
                            LUASetup();
                        }

                        WAECharacterSheet.Scan();
                        WAEContainers.Scan();

                        if (!ObjectManager.Me.InCombatFlagOnly &&
                            AutoEquipSettings.CurrentSettings.AutoEquipBags &&
                            ObjectManager.Me.IsAlive)
                        {
                            WAEContainers.BagEquip();
                        }

                        if (!ObjectManager.Me.InCombatFlagOnly &&
                            AutoEquipSettings.CurrentSettings.AutoEquipGear &&
                            ObjectManager.Me.IsAlive)
                        {
                            WAECharacterSheet.AutoEquip();
                        }

                        if (AutoEquipSettings.CurrentSettings.EquipAmmo &&
                            ObjectManager.Me.IsAlive)
                        {
                            WAECharacterSheet.AutoEquipAmmo(); // Allow ammo switch during fights
                        }
                        if (!ObjectManager.Me.InCombatFlagOnly &&
                            ObjectManager.Me.IsAlive)
                        {
                            WAELootFilter.FilterLoot();
                        }

                        WAEGroupRoll.CheckLootRoll();

                        Logger.LogPerformance($"Total Process time : {(DateTime.Now.Ticks - dateBegin.Ticks) / 10000} ms");
                    }
                }
            }
            catch (Exception arg)
            {
                Logger.LogError(string.Concat(arg));
            }
            ToolBox.Sleep(5000);
        }
    }
コード例 #2
0
    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);
    }