예제 #1
0
        public bool IsBetter(IWowItem current, IWowItem item)
        {
            double scoreCurrent = GearscoreFactory.Calculate(current);
            double scoreNew     = GearscoreFactory.Calculate(item);

            return(scoreCurrent < scoreNew);
        }
예제 #2
0
        public void Update()
        {
            string resultJson = WowInterface.HookManager.GetEquipmentItems();

            if (resultJson.Length > 1 && resultJson.Substring(resultJson.Length - 2, 2).Equals(",]"))
            {
                resultJson.Remove(resultJson.Length - 2);
            }

            try
            {
                List <WowBasicItem> rawEquipment = ItemFactory.ParseItemList(resultJson);

                if (rawEquipment != null && rawEquipment.Count > 0)
                {
                    lock (queryLock)
                    {
                        Items.Clear();
                        foreach (WowBasicItem rawItem in rawEquipment)
                        {
                            IWowItem item = ItemFactory.BuildSpecificItem(rawItem);
                            Items.Add(item.EquipSlot, item);
                        }
                    }
                }

                AverageItemLevel = GetAverageItemLevel();
            }
            catch (Exception e)
            {
                AmeisenLogger.Instance.Log("CharacterManager", $"Failed to parse Equipment JSON:\n{resultJson}\n{e}", LogLevel.Error);
            }
        }
예제 #3
0
        public void Update()
        {
            string resultJson = HookManager.GetEquipmentItems();

            if (resultJson.Length > 1 && resultJson.Substring(resultJson.Length - 2, 2).Equals(",]"))
            {
                resultJson.Remove(resultJson.Length - 2);
            }

            try
            {
                List <WowBasicItem> rawEquipment = ItemFactory.ParseItemList(resultJson);

                Equipment.Clear();
                foreach (WowBasicItem rawItem in rawEquipment)
                {
                    IWowItem item = ItemFactory.BuildSpecificItem(rawItem);
                    Equipment.Add(item.EquipSlot, item);
                }
            }
            catch (Exception e)
            {
                AmeisenLogger.Instance.Log($"Failed to parse Equipment JSON:\n{resultJson}\n{e.ToString()}", LogLevel.Error);
            }
        }
예제 #4
0
        private double GetRating(IWowItem item, EquipmentSlot slot)
        {
            double rating = 0;

            if (slot.Equals(EquipmentSlot.INVSLOT_OFFHAND))
            {
                // don't use shields or 2nd weapons
                return(0);
            }
            else if (slot.Equals(EquipmentSlot.INVSLOT_MAINHAND))
            {
                // axes
                if (item.GetType() == typeof(WowWeapon) && (((WowWeapon)item).WeaponType.Equals(WeaponType.TWOHANDED_AXES) || ((WowWeapon)item).WeaponType.Equals(WeaponType.ONEHANDED_AXES)))
                {
                    if (item.Stats.TryGetValue("ITEM_MOD_ATTACK_POWER_SHORT", out string attackString) && double.TryParse(attackString, out double attack))
                    {
                        rating += 0.5f * attack;
                    }
                    if (item.Stats.TryGetValue("ITEM_MOD_DAMAGE_PER_SECOND_SHORT", out string dpsString) && double.TryParse(dpsString, out double dps))
                    {
                        rating += 2f * dps;
                    }
                    if (item.Stats.TryGetValue("ITEM_MOD_STRENGTH_SHORT", out string strengthString) && double.TryParse(strengthString, out double strength))
                    {
                        rating += 1f * strength;
                    }
                }
            }
            else if (slot.Equals(EquipmentSlot.INVSLOT_NECK) || slot.Equals(EquipmentSlot.INVSLOT_RING1) ||
                     slot.Equals(EquipmentSlot.INVSLOT_RING2) || slot.Equals(EquipmentSlot.INVSLOT_TRINKET1) ||
                     slot.Equals(EquipmentSlot.INVSLOT_TRINKET2))
            {
                // jewelry stats
                if (item.Stats.TryGetValue("ITEM_MOD_ATTACK_POWER_SHORT", out string attackString) && double.TryParse(attackString, out double attack))
                {
                    rating += 0.5f * attack;
                }
                if (item.Stats.TryGetValue("ITEM_MOD_STRENGTH_SHORT", out string strengthString) && double.TryParse(strengthString, out double strength))
                {
                    rating += 1f * strength;
                }
            }
            else
            {
                // armor stats
                if (item.Stats.TryGetValue("RESISTANCE0_NAME", out string armorString) && double.TryParse(armorString, out double armor))
                {
                    rating += 0.5f * armor;
                }
                if (item.Stats.TryGetValue("ITEM_MOD_ATTACK_POWER_SHORT", out string attackString) && double.TryParse(attackString, out double attack))
                {
                    rating += 0.5f * attack;
                }
                if (item.Stats.TryGetValue("ITEM_MOD_STRENGTH_SHORT", out string strengthString) && double.TryParse(strengthString, out double strength))
                {
                    rating += 1f * strength;
                }
            }
            return(rating);
        }
예제 #5
0
        public static void Run(WowInterface wowInterface, AmeisenBotConfig config)
        {
            // create a copy here to prevent updates while selling
            foreach (IWowItem item in wowInterface.CharacterManager.Inventory.Items.Where(e => e.Price > 0).ToList())
            {
                IWowItem itemToSell = item;

                if (config.ItemSellBlacklist.Any(e => e.Equals(item.Name, StringComparison.OrdinalIgnoreCase)) ||
                    (!config.SellGrayItems && item.ItemQuality == WowItemQuality.Poor) ||
                    (!config.SellWhiteItems && item.ItemQuality == WowItemQuality.Common) ||
                    (!config.SellGreenItems && item.ItemQuality == WowItemQuality.Uncommon) ||
                    (!config.SellBlueItems && item.ItemQuality == WowItemQuality.Rare) ||
                    (!config.SellPurpleItems && item.ItemQuality == WowItemQuality.Epic))
                {
                    continue;
                }

                if (wowInterface.CharacterManager.IsItemAnImprovement(item, out IWowItem itemToReplace))
                {
                    // equip item and sell the other after
                    itemToSell = itemToReplace;
                    wowInterface.HookManager.LuaEquipItem(item, itemToReplace);
                }

                if (itemToSell != null &&
                    (wowInterface.ObjectManager.Player.Class != WowClass.Hunter || itemToSell.GetType() != typeof(WowProjectile)))
                {
                    wowInterface.HookManager.LuaUseContainerItem(itemToSell.BagId, itemToSell.BagSlot);
                    wowInterface.HookManager.LuaCofirmStaticPopup();
                }
            }
        }
예제 #6
0
        public override void Execute()
        {
            if (WowInterface.HookManager.GetFreeBagSlotCount() > 4 ||
                !WowInterface.CharacterManager.Inventory.Items.Any(e => e.Price > 0))
            {
                WowInterface.CharacterManager.Inventory.Update();
                StateMachine.SetState(BotState.Idle);
                return;
            }

            WowUnit selectedUnit = WowInterface.ObjectManager.WowObjects.OfType <WowUnit>()
                                   .OrderBy(e => e.Position.GetDistance(WowInterface.ObjectManager.Player.Position))
                                   .FirstOrDefault(e => e.GetType() != typeof(WowPlayer) &&
                                                   WowInterface.HookManager.GetUnitReaction(WowInterface.ObjectManager.Player, e) == WowUnitReaction.Friendly &&
                                                   e.IsRepairVendor &&
                                                   e.Position.GetDistance(WowInterface.ObjectManager.Player.Position) < 50);

            if (selectedUnit != null && !selectedUnit.IsDead)
            {
                if (!IsAtNpc)
                {
                    double distance = WowInterface.ObjectManager.Player.Position.GetDistance(selectedUnit.Position);
                    if (distance < 3.0)
                    {
                        WowInterface.HookManager.UnitOnRightClick(selectedUnit);
                        SellActionGo = DateTime.Now + TimeSpan.FromSeconds(1);
                        IsAtNpc      = true;
                    }
                    else
                    {
                        WowInterface.MovementEngine.SetState(MovementEngineState.Moving, selectedUnit.Position);
                        WowInterface.MovementEngine.Execute();
                    }
                }
                else if (DateTime.Now > SellActionGo)
                {
                    WowInterface.HookManager.SellAllGrayItems();
                    WowInterface.HookManager.RepairAllItems();

                    foreach (IWowItem item in WowInterface.CharacterManager.Inventory.Items.Where(e => e.Price > 0))
                    {
                        IWowItem itemToSell = item;
                        if (WowInterface.CharacterManager.IsItemAnImprovement(item, out IWowItem itemToReplace))
                        {
                            itemToSell = itemToReplace;
                            WowInterface.HookManager.ReplaceItem(null, item);
                        }

                        WowInterface.HookManager.UseItemByBagAndSlot(itemToSell.BagId, itemToSell.BagSlot);
                        WowInterface.HookManager.CofirmBop();
                    }
                }
            }
            else
            {
                WowInterface.CharacterManager.Inventory.Update();
                StateMachine.SetState(BotState.Idle);
            }
        }
예제 #7
0
        private double CalculateGearscore(IWowItem item)
        {
            double baseScore  = item.ItemLevel;
            double finalScore = 0;



            return(0.0);
        }
예제 #8
0
        private double GetRating(IWowItem item, EquipmentSlot slot)
        {
            double rating = 0;

            if (item.Stats.TryGetValue("ITEM_MOD_CRIT_MELEE_RATING_SHORT", out string meleeCritString) && double.TryParse(meleeCritString, System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out double meleeCrit))
            {
                rating += 0.5f * meleeCrit;
            }

            if (item.Stats.TryGetValue("ITEM_MOD_CRIT_RATING_SHORT", out string critString) && double.TryParse(critString, System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out double crit))
            {
                rating += 0.5f * crit;
            }

            if (item.Stats.TryGetValue("ITEM_MOD_AGILITY_SHORT", out string agilityString) && double.TryParse(agilityString, System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out double agility))
            {
                rating += 0.5f * agility;
            }

            if (item.Stats.TryGetValue("ITEM_MOD_ATTACK_POWER_SHORT", out string attackString) && double.TryParse(attackString, System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out double attack))
            {
                rating += 0.5f * attack;
            }

            if (item.Stats.TryGetValue("ITEM_MOD_STRENGTH_SHORT", out string strengthString) && double.TryParse(strengthString, System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out double strength))
            {
                rating += 1f * strength;
            }

            if (slot.Equals(EquipmentSlot.INVSLOT_OFFHAND) || slot.Equals(EquipmentSlot.INVSLOT_MAINHAND))
            {
                // also 2nd weapons
                if (item.GetType() == typeof(WowWeapon) && ((WowWeapon)item).WeaponType.Equals(WeaponType.ONEHANDED_SWORDS))
                {
                    if (item.Stats.TryGetValue("ITEM_MOD_DAMAGE_PER_SECOND_SHORT", out string dpsString) && double.TryParse(dpsString, System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out double dps))
                    {
                        rating += 2f * dps;
                    }
                }
            }
            else if (!(slot.Equals(EquipmentSlot.INVSLOT_NECK) || slot.Equals(EquipmentSlot.INVSLOT_RING1) ||
                       slot.Equals(EquipmentSlot.INVSLOT_RING2) || slot.Equals(EquipmentSlot.INVSLOT_TRINKET1) ||
                       slot.Equals(EquipmentSlot.INVSLOT_TRINKET2)))
            {
                // armor stats
                if (item.Stats.TryGetValue("RESISTANCE0_NAME", out string armorString) && double.TryParse(armorString, System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out double armor))
                {
                    rating += 0.1f * armor;
                }
            }

            return(rating);
        }
예제 #9
0
        public bool IsBetter(IWowItem current, IWowItem item)
        {
            if (!CharacterManager.IsAbleToUseItem(item))
            {
                return(false);
            }

            double scoreCurrent = GearscoreFactory.Calculate(current);
            double scoreNew     = GearscoreFactory.Calculate(item);

            return(scoreCurrent < scoreNew);
        }
예제 #10
0
        public override void Execute()
        {
            if (HookManager.GetFreeBagSlotCount() > 4 ||
                !CharacterManager.Inventory.Items.Any(e => e.Price > 0))
            {
                AmeisenBotStateMachine.SetState(AmeisenBotState.Idle);
                return;
            }

            WowUnit selectedUnit = ObjectManager.WowObjects.OfType <WowUnit>()
                                   .OrderBy(e => e.Position.GetDistance(ObjectManager.Player.Position))
                                   .FirstOrDefault(e => e.GetType() != typeof(WowPlayer) && e.IsRepairVendor && e.Position.GetDistance(ObjectManager.Player.Position) < 50);

            if (selectedUnit != null && !selectedUnit.IsDead)
            {
                double distance = ObjectManager.Player.Position.GetDistance(selectedUnit.Position);
                if (distance > 5.0)
                {
                    MovementEngine.SetState(MovementEngineState.Moving, selectedUnit.Position);
                    MovementEngine.Execute();
                }
                else
                {
                    if (distance > 4)
                    {
                        CharacterManager.InteractWithUnit(selectedUnit, 20.9f, 2f);
                    }
                    else
                    {
                        HookManager.RightClickUnit(selectedUnit);
                        Task.Delay(1000).GetAwaiter().GetResult();

                        HookManager.SellAllGrayItems();
                        foreach (IWowItem item in CharacterManager.Inventory.Items.Where(e => e.Price > 0))
                        {
                            IWowItem itemToSell = item;
                            if (CharacterManager.IsItemAnImprovement(item, out IWowItem itemToReplace))
                            {
                                itemToSell = itemToReplace;
                                HookManager.ReplaceItem(null, item);
                            }

                            HookManager.UseItemByBagAndSlot(itemToSell.BagId, itemToSell.BagSlot);
                        }
                    }
                }
            }
            else
            {
                AmeisenBotStateMachine.SetState(AmeisenBotState.Idle);
            }
        }
예제 #11
0
        public bool IsBlacklistedItem(IWowItem item)
        {
            if (ArmorTypeBlacklist != null && string.Equals(item.Type, "Armor", StringComparison.OrdinalIgnoreCase) && ArmorTypeBlacklist.Contains(((WowArmor)item).ArmorType))
            {
                return(true);
            }
            else if (WeaponTypeBlacklist != null && string.Equals(item.Type, "Weapon", StringComparison.OrdinalIgnoreCase) && WeaponTypeBlacklist.Contains(((WowWeapon)item).WeaponType))
            {
                return(true);
            }

            return(false);
        }
예제 #12
0
        public bool IsBetter(IWowItem current, IWowItem item)
        {
            if ((ArmorTypeBlacklist != null && item.GetType() == typeof(WowArmor) && ArmorTypeBlacklist.Contains(((WowArmor)item).ArmorType)) ||
                (WeaponTypeBlacklist != null && item.GetType() == typeof(WowWeapon) && WeaponTypeBlacklist.Contains(((WowWeapon)item).WeaponType)))
            {
                return(false);
            }

            double scoreCurrent = GearscoreFactory.Calculate(current);
            double scoreNew     = GearscoreFactory.Calculate(item);

            return(scoreCurrent < scoreNew);
        }
예제 #13
0
        public void ReplaceItem(IWowItem currentItem, IWowItem newItem)
        {
            if (currentItem == null)
            {
                LuaDoString($"EquipItemByName(\"{newItem.Name}\");");
            }
            else
            {
                LuaDoString($"EquipItemByName(\"{newItem.Name}\", {(int)currentItem.EquipSlot});");
            }

            CofirmBop();
        }
        public void Execute()
        {
            if (Finished || WowInterface.ObjectManager.Player.IsCasting)
            {
                return;
            }

            IWowItem item = WowInterface.CharacterManager.Inventory.Items.FirstOrDefault(e => e.Id == ItemId);

            if (item != null)
            {
                WowInterface.HookManager.UseItemByBagAndSlot(item.BagId, item.BagSlot);
            }
        }
예제 #15
0
        public void Execute()
        {
            ExecuteCC();

            if (WowInterface.ObjectManager.Player.Race == WowRace.Human &&
                (WowInterface.ObjectManager.Player.IsDazed ||
                 WowInterface.ObjectManager.Player.IsFleeing ||
                 WowInterface.ObjectManager.Player.IsInfluenced ||
                 WowInterface.ObjectManager.Player.IsPossessed))
            {
                if (IsSpellReady(EveryManforHimselfSpell))
                {
                    WowInterface.HookManager.LuaCastSpell(EveryManforHimselfSpell);
                }
            }

            if (WowInterface.ObjectManager.Player.HealthPercentage < 50.0 &&
                (WowInterface.ObjectManager.Player.Race == WowRace.Dwarf))
            {
                if (IsSpellReady(StoneformSpell))
                {
                    WowInterface.HookManager.LuaCastSpell(StoneformSpell);
                }
            }

            // Useable items, potions, etc.
            // ---------------------------- >

            if (WowInterface.ObjectManager.Player.HealthPercentage < 20)
            {
                IWowItem healthItem = WowInterface.CharacterManager.Inventory.Items.FirstOrDefault(e => useableHealingItems.Contains(e.Id));

                if (healthItem != null)
                {
                    WowInterface.HookManager.LuaUseItemByName(healthItem.Name);
                }
            }

            if (WowInterface.ObjectManager.Player.ManaPercentage < 20)
            {
                IWowItem manaItem = WowInterface.CharacterManager.Inventory.Items.FirstOrDefault(e => useableManaItems.Contains(e.Id));

                if (manaItem != null)
                {
                    WowInterface.HookManager.LuaUseItemByName(manaItem.Name);
                }
            }
        }
예제 #16
0
        public void Execute()
        {
            if (Finished || WowInterface.ObjectManager.Player.IsCasting)
            {
                return;
            }

            IWowItem item = WowInterface.CharacterManager.Inventory.Items.FirstOrDefault(e => e.Id == ItemId);

            if (item != null)
            {
                WowInterface.MovementEngine.Reset();
                WowInterface.HookManager.WowStopClickToMove();
                WowInterface.HookManager.LuaUseContainerItem(item.BagId, item.BagSlot);
            }
        }
예제 #17
0
        public double Calculate(IWowItem item)
        {
            double score = 0;

            foreach (KeyValuePair <string, double> keyValuePair in StatMultiplicators)
            {
                if (item.Stats.TryGetValue(keyValuePair.Key, out string stat))
                {
                    if ((stat.Contains('.') || stat.Contains(',')) && double.TryParse(stat, NumberStyles.Any, CultureInfo.InvariantCulture, out double statDoubleValue))
                    {
                        score += statDoubleValue * keyValuePair.Value;
                    }
                    else if (int.TryParse(stat, out int statIntValue))
                    {
                        score += statIntValue * keyValuePair.Value;
                    }
                }
            }

            return(score);
        }
예제 #18
0
        public void Update()
        {
            string resultJson = WowInterface.HookManager.LuaGetEquipmentItems();

            if (string.IsNullOrWhiteSpace(resultJson))
            {
                return;
            }

            if (resultJson.Length > 1 && resultJson.Substring(resultJson.Length - 2, 2).Equals(",]", StringComparison.OrdinalIgnoreCase))
            {
                resultJson = resultJson.Remove(resultJson.Length - 2);
            }

            try
            {
                List <WowBasicItem> rawEquipment = ItemFactory.ParseItemList(resultJson);

                if (rawEquipment != null && rawEquipment.Any())
                {
                    lock (queryLock)
                    {
                        Items.Clear();

                        for (int i = 0; i < rawEquipment.Count; ++i)
                        {
                            IWowItem item = ItemFactory.BuildSpecificItem(rawEquipment[i]);
                            Items.Add(item.EquipSlot, item);
                        }
                    }
                }

                AverageItemLevel = GetAverageItemLevel();
            }
            catch (Exception e)
            {
                AmeisenLogger.I.Log("CharacterManager", $"Failed to parse Equipment JSON:\n{resultJson}\n{e}", LogLevel.Error);
            }
        }
예제 #19
0
        public bool IsBetter(IWowItem current, IWowItem item)
        {
            if (item == null)
            {
                return(false);
            }
            else if (current == null)
            {
                return(true);
            }
            else if (item.Stats == null)
            {
                return(false);
            }
            else if (current.Stats == null)
            {
                return(true);
            }
            double currentRating = GetRating(current, current.EquipSlot);
            double newItemRating = GetRating(item, current.EquipSlot);

            return(currentRating < newItemRating);
        }
 public bool IsBlacklistedItem(IWowItem item)
 {
     return(false);
 }
예제 #21
0
 public ItemDisplay(IWowItem wowItem)
 {
     WowItem = wowItem;
     InitializeComponent();
 }
        public void Execute()
        {
            if ((CurrentSpot == default || SpotSelected + SpotDuration <= DateTime.UtcNow) &&
                !WowInterface.I.ObjectManager.Player.IsCasting &&
                WowInterface.I.Db.TryGetPointsOfInterest(WowInterface.I.ObjectManager.MapId, Data.Db.Enums.PoiType.FishingSpot, WowInterface.I.ObjectManager.Player.Position, 256.0, out IEnumerable <Vector3> pois))
            {
                CurrentSpot  = pois.ElementAt(Rnd.Next(0, pois.Count() - 1));
                SpotSelected = DateTime.UtcNow;
                SpotDuration = TimeSpan.FromSeconds(new Random().Next(MinDuration, MaxDuration));
            }

            if (CurrentSpot != default)
            {
                if (WowInterface.I.ObjectManager.Player.Position.GetDistance(CurrentSpot) > 3.5f)
                {
                    WowInterface.I.MovementEngine.SetMovementAction(MovementAction.Moving, CurrentSpot);
                    return;
                }
                else if (WowInterface.I.HookManager.WowIsClickToMoveActive())
                {
                    WowInterface.I.MovementEngine.StopMovement();
                    return;
                }

                if (!BotMath.IsFacing(WowInterface.I.ObjectManager.Player.Position, WowInterface.I.ObjectManager.Player.Rotation, CurrentSpot))
                {
                    WowInterface.I.HookManager.WowFacePosition(WowInterface.I.ObjectManager.Player, CurrentSpot);
                    return;
                }
            }

            if (!IsFishingRodEquipped())
            {
                IWowItem fishingRod = WowInterface.I.CharacterManager.Inventory.Items.OfType <WowWeapon>()
                                      .FirstOrDefault(e => e.WeaponType == WeaponType.FISHING_POLES);

                if (fishingRod != null)
                {
                    WowInterface.I.HookManager.LuaEquipItem(fishingRod);
                }
            }

            WowGameobject fishingBobber = WowInterface.I.ObjectManager.WowObjects.OfType <WowGameobject>()
                                          .FirstOrDefault(e => e.GameobjectType == WowGameobjectType.FishingBobber && e.CreatedBy == WowInterface.I.ObjectManager.Player.Guid);

            if (!Started)
            {
                Started       = true;
                CooldownStart = DateTime.UtcNow;
                Duration      = TimeSpan.FromSeconds(Rnd.Next(MinDuration, MaxDuration));
            }
            else if (CooldownStart + Duration <= DateTime.UtcNow)
            {
                Started       = false;
                CooldownStart = default;
                Duration      = default;
                CurrentSpot   = default;
                return;
            }

            if (!WowInterface.I.ObjectManager.Player.IsCasting || fishingBobber == null)
            {
                WowInterface.I.HookManager.LuaCastSpell("Fishing");
            }
            else if (fishingBobber.Flags[(int)WowGameobjectFlags.DoesNotDespawn])
            {
                WowInterface.I.HookManager.WowObjectRightClick(fishingBobber);
                WowInterface.I.HookManager.LuaLootEveryThing();
            }
        }
예제 #23
0
        private double GetRating(IWowItem item, EquipmentSlot slot)
        {
            double rating = 0;

            if (slot.Equals(EquipmentSlot.INVSLOT_OFFHAND))
            {
                // shields
                if (item.GetType() == typeof(WowArmor) && ((WowArmor)item).ArmorType.Equals(ArmorType.SHIELDS))
                {
                    if (item.Stats.TryGetValue("RESISTANCE0_NAME", out string armorString) && double.TryParse(armorString, System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out double armor))
                    {
                        rating += 0.5 * armor;
                    }

                    if (item.Stats.TryGetValue("ITEM_MOD_STAMINA_SHORT", out string staminaString) && double.TryParse(staminaString, System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out double stamina))
                    {
                        rating += 1f * stamina;
                    }

                    if (item.Stats.TryGetValue("ITEM_MOD_DEFENSE_SKILL_RATING_SHORT", out string defenseString) && double.TryParse(defenseString, System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out double defense))
                    {
                        rating += 1f * defense;
                    }

                    if (item.Stats.TryGetValue("ITEM_MOD_BLOCK_VALUE_SHORT", out string blockString) && double.TryParse(blockString, System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out double blockValue))
                    {
                        rating += 5f * blockValue;
                    }

                    if (item.Stats.TryGetValue("ITEM_MOD_BLOCK_RATING_SHORT", out string blockChanceString) && double.TryParse(blockChanceString, System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out double blockChance))
                    {
                        rating += 10f * blockChance;
                    }
                }
            }
            else if (slot.Equals(EquipmentSlot.INVSLOT_MAINHAND))
            {
                // swords
                if (item.GetType() == typeof(WowWeapon) && ((WowWeapon)item).WeaponType.Equals(WeaponType.ONEHANDED_SWORDS))
                {
                    if (item.Stats.TryGetValue("ITEM_MOD_STRENGTH_SHORT", out string strengthString) && double.TryParse(strengthString, System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out double strength))
                    {
                        rating += 0.5f * strength;
                    }

                    if (item.Stats.TryGetValue("ITEM_MOD_DAMAGE_PER_SECOND_SHORT", out string dpsString) && double.TryParse(dpsString, System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out double dps))
                    {
                        rating += 1f * dps;
                    }

                    if (item.Stats.TryGetValue("ITEM_MOD_DEFENSE_SKILL_RATING_SHORT", out string defenseString) && double.TryParse(defenseString, System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out double defense))
                    {
                        rating += 5f * defense;
                    }

                    if (item.Stats.TryGetValue("ITEM_MOD_PARRY_RATING_SHORT", out string parryString) && double.TryParse(parryString, System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out double parry))
                    {
                        rating += 10f * parry;
                    }
                }
            }
            else if (slot.Equals(EquipmentSlot.INVSLOT_NECK) || slot.Equals(EquipmentSlot.INVSLOT_RING1) ||
                     slot.Equals(EquipmentSlot.INVSLOT_RING2) || slot.Equals(EquipmentSlot.INVSLOT_TRINKET1) ||
                     slot.Equals(EquipmentSlot.INVSLOT_TRINKET2))
            {
                // jewelry stats
                if (item.Stats.TryGetValue("ITEM_MOD_STRENGTH_SHORT", out string strengthString) && double.TryParse(strengthString, System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out double strength))
                {
                    rating += 0.5f * strength;
                }

                if (item.Stats.TryGetValue("ITEM_MOD_STAMINA_SHORT", out string staminaString) && double.TryParse(staminaString, System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out double stamina))
                {
                    rating += 1f * stamina;
                }
            }
            else
            {
                // armor stats
                if (item.Stats.TryGetValue("RESISTANCE0_NAME", out string armorString) && double.TryParse(armorString, System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out double armor))
                {
                    rating += 0.5f * armor;
                }

                if (item.Stats.TryGetValue("ITEM_MOD_STRENGTH_SHORT", out string strengthString) && double.TryParse(strengthString, System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out double strength))
                {
                    rating += 0.5f * strength;
                }

                if (item.Stats.TryGetValue("ITEM_MOD_PARRY_RATING_SHORT", out string parryString) && double.TryParse(parryString, System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out double parry))
                {
                    rating += 0.5f * parry;
                }

                if (item.Stats.TryGetValue("ITEM_MOD_BLOCK_RATING_SHORT", out string blockChanceString) && double.TryParse(blockChanceString, System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out double blockChance))
                {
                    rating += 0.5f * blockChance;
                }

                if (item.Stats.TryGetValue("ITEM_MOD_BLOCK_VALUE_SHORT", out string blockString) && double.TryParse(blockString, System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out double blockValue))
                {
                    rating += 0.5f * blockValue;
                }

                if (item.Stats.TryGetValue("ITEM_MOD_STAMINA_SHORT", out string staminaString) && double.TryParse(staminaString, System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out double stamina))
                {
                    rating += 1f * stamina;
                }

                if (item.Stats.TryGetValue("ITEM_MOD_DEFENSE_SKILL_RATING_SHORT", out string defenseString) && double.TryParse(defenseString, System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out double defense))
                {
                    rating += 1f * defense;
                }
            }

            return(rating);
        }
예제 #24
0
 public bool IsBlacklistedItem(IWowItem item)
 {
     return(!CharacterManager.IsAbleToUseItem(item));
 }
예제 #25
0
 public bool IsBetter(IWowItem current, IWowItem item)
 {
     return(false);
 }
예제 #26
0
        public override void Execute()
        {
            if (InventoryUpdateEvent.Run())
            {
                WowInterface.CharacterManager.Inventory.Update();
            }

            if (!NeedToSell())
            {
                StateMachine.SetState(BotState.Idle);
                return;
            }

            if (IsVendorNpcNear(out WowUnit selectedUnit))
            {
                if (WowInterface.ObjectManager.Player.Position.GetDistance(selectedUnit.Position) > 1.5)
                {
                    WowInterface.MovementEngine.SetMovementAction(MovementAction.Moving, selectedUnit.Position);

                    if (WowInterface.MovementEngine.PathfindingStatus == PathfindingStatus.PathIncomplete)
                    {
                        ++BlacklistCounter;

                        if (BlacklistCounter > 2)
                        {
                            WowInterface.MovementEngine.StopMovement();
                            Blacklist.Add(selectedUnit.Guid);
                            BlacklistCounter = 0;
                            return;
                        }
                    }
                }
                else if (InteractionEvent.Run())
                {
                    if (WowInterface.ObjectManager.TargetGuid != selectedUnit.Guid)
                    {
                        WowInterface.HookManager.TargetGuid(selectedUnit.Guid);
                        return;
                    }

                    WowInterface.MovementEngine.StopMovement();

                    if (!BotMath.IsFacing(WowInterface.ObjectManager.Player.Position, WowInterface.ObjectManager.Player.Rotation, selectedUnit.Position))
                    {
                        WowInterface.HookManager.FacePosition(WowInterface.ObjectManager.Player, selectedUnit.Position);
                        return;
                    }

                    // WowInterface.HookManager.UnitOnRightClick(selectedUnit);
                    WowInterface.CharacterManager.ClickToMove(selectedUnit.Position, selectedUnit.Guid, Character.Enums.ClickToMoveType.Interact, 20.9f, 1.5f);

                    if (Config.AutoRepair && WowInterface.ObjectManager.Target.IsRepairVendor)
                    {
                        WowInterface.HookManager.RepairAllItems();
                    }

                    if (Config.AutoSell)
                    {
                        foreach (IWowItem item in WowInterface.CharacterManager.Inventory.Items.Where(e => e.Price > 0))
                        {
                            IWowItem itemToSell = item;

                            if (Config.ItemSellBlacklist.Any(e => e.Equals(item.Name, StringComparison.OrdinalIgnoreCase)) ||
                                (!Config.SellGrayItems && item.ItemQuality == ItemQuality.Poor) ||
                                (!Config.SellWhiteItems && item.ItemQuality == ItemQuality.Common) ||
                                (!Config.SellGreenItems && item.ItemQuality == ItemQuality.Uncommon) ||
                                (!Config.SellBlueItems && item.ItemQuality == ItemQuality.Rare) ||
                                (!Config.SellPurpleItems && item.ItemQuality == ItemQuality.Epic))
                            {
                                continue;
                            }

                            if (WowInterface.CharacterManager.IsItemAnImprovement(item, out IWowItem itemToReplace))
                            {
                                // equip item and sell the other after
                                itemToSell = itemToReplace;
                                WowInterface.HookManager.ReplaceItem(null, item);
                            }

                            if (itemToSell != null &&
                                (WowInterface.ObjectManager.Player.Class != WowClass.Hunter || itemToSell.GetType() != typeof(WowProjectile)))
                            {
                                WowInterface.HookManager.UseItemByBagAndSlot(itemToSell.BagId, itemToSell.BagSlot);
                                WowInterface.HookManager.CofirmBop();
                                Task.Delay(50).Wait();
                            }
                        }
                    }

                    foreach (IWowItem item in WowInterface.CharacterManager.Inventory.Items.Where(e => e.Price > 0))
                    {
                        IWowItem itemToSell = item;

                        if (Config.ItemSellBlacklist.Any(e => e.Equals(item.Name, StringComparison.OrdinalIgnoreCase)) ||
                            (!Config.SellGrayItems && item.ItemQuality == ItemQuality.Poor) ||
                            (!Config.SellWhiteItems && item.ItemQuality == ItemQuality.Common) ||
                            (!Config.SellGreenItems && item.ItemQuality == ItemQuality.Uncommon) ||
                            (!Config.SellBlueItems && item.ItemQuality == ItemQuality.Rare) ||
                            (!Config.SellPurpleItems && item.ItemQuality == ItemQuality.Epic))
                        {
                            continue;
                        }

                        if (WowInterface.CharacterManager.IsItemAnImprovement(item, out IWowItem itemToReplace))
                        {
                            // equip item and sell the other after
                            itemToSell = itemToReplace;
                            WowInterface.HookManager.ReplaceItem(null, item);
                        }

                        if (itemToSell != null &&
                            (WowInterface.ObjectManager.Player.Class != WowClass.Hunter || itemToSell.GetType() != typeof(WowProjectile)))
                        {
                            WowInterface.HookManager.UseItemByBagAndSlot(itemToSell.BagId, itemToSell.BagSlot);
                            WowInterface.HookManager.CofirmBop();
                        }
                    }

                    if (Config.AutoRepair && WowInterface.ObjectManager.Target.IsRepairVendor)
                    {
                        WowInterface.HookManager.RepairAllItems();
                    }
                }
            }
            else
            {
                StateMachine.SetState(BotState.Idle);
            }
        }
예제 #27
0
 public bool IsBetter(IWowItem current, IWowItem item)
 => current == null || current.ItemLevel < item.ItemLevel;
예제 #28
0
 public bool IsBetter(IWowItem current, IWowItem item)
 {
     return(current == null || current.ItemLevel < item.ItemLevel);
 }