Jump to content

Droidz

Administrators
  • Posts

    12581
  • Joined

  • Last visited

Posts posted by Droidz

  1. Hello, try this plugin :

    using wManager.Wow.Enums;
    using wManager.Wow.Helpers;
    using wManager.Wow.ObjectManager;
    
    public class Main : wManager.Plugin.IPlugin
    {
        public void Initialize()
        {
            var stopWatch = new System.Diagnostics.Stopwatch();
            wManager.Events.InteractEvents.OnInteractPulse += (target, cancelable) =>
            {
                if (stopWatch.ElapsedMilliseconds < 1000
                    && stopWatch.IsRunning)
                {
                    return;
                }
    
                var obj = ObjectManager.GetObjectByGuid(target);
                if (obj.IsValid &&
                    (obj.Type == WoWObjectType.Unit || obj.Type == WoWObjectType.GameObject))
                {
                    var isLootable = false;
                    if (obj.Type == WoWObjectType.Unit)
                    {
                        var unit = new WoWUnit(obj.GetBaseAddress);
                        isLootable = unit.IsLootable;
                    }
                    else if (obj.Type == WoWObjectType.GameObject)
                    {
                        isLootable = true;
                    }
    
                    if (isLootable)
                    {
                        stopWatch.Restart();
                        Interact.InteractGameObject(obj.GetBaseAddress);
                        cancelable.Cancel = true;
                    }
                }
            };
        }
    
        public void Dispose()
        {
        }
    
        public void Settings()
        {
        }
    }



     

    Main.cs

  2. Hi,

    Your code has several syntax problems (which I fixed), and some logic problems (which I did not correct), but I gave advice in the code comments (I did not test the code) :

    using System.Collections.Generic;
    using System.Linq;
    using wManager.Wow.Helpers;
    using wManager.Wow.ObjectManager;
    using wManager.Plugin;
    using robotManager.Helpful;
    using wManager.Wow.Bot.States;
    
    public class Main : IPlugin
    {
        private readonly List<ItemInfo> foodItems = new List<ItemInfo>
        {
            new ItemInfo(4540, 1, 5),
            new ItemInfo(4541, 5, 15),
            new ItemInfo(4542, 10, 20),
            new ItemInfo(4544, 15, 25),
            new ItemInfo(4601, 20, 30),
            new ItemInfo(8950, 25, 35),
            new ItemInfo(8076, 30, 40),
            new ItemInfo(4599, 35, 45),
            new ItemInfo(2287, 40, 50),
            new ItemInfo(8952, 45, 55),
            new ItemInfo(2679, 50, 60),
            new ItemInfo(2680, 55, 65),
            new ItemInfo(2681, 60, 70),
            new ItemInfo(2682, 65, 75),
            new ItemInfo(2684, 70, 75),
            new ItemInfo(2687, 75, 80),
            new ItemInfo(2683, 80, 80),
            new ItemInfo(2681, 55, 60),
            new ItemInfo(2685, 60, 65),
            new ItemInfo(3727, 65, 70),
            new ItemInfo(3726, 70, 75),
            new ItemInfo(3728, 75, 80),
            new ItemInfo(4594, 80, 80)
        };
    
        private readonly List<ItemInfo> waterItems = new List<ItemInfo>
        {
            new ItemInfo(159, 1, 5),
            new ItemInfo(1179, 5, 15),
            new ItemInfo(1205, 15, 25),
            new ItemInfo(1708, 25, 35),
            new ItemInfo(1645, 35, 45),
            new ItemInfo(8766, 45, 55),
            new ItemInfo(28399, 55, 65),
            new ItemInfo(33044, 65, 75),
            new ItemInfo(27860, 75, 80),
            new ItemInfo(33445, 80, 80),
            new ItemInfo(3356, 10, 20),
            new ItemInfo(2287, 20, 30),
            new ItemInfo(27422, 30, 40),
            new ItemInfo(33176, 40, 50),
            new ItemInfo(33177, 50, 60),
            new ItemInfo(33178, 60, 70),
            new ItemInfo(33179, 70, 80),
            new ItemInfo(33180, 80, 80),
            new ItemInfo(40731, 80, 80),
            new ItemInfo(19999, 40, 50),
            new ItemInfo(5469, 15, 25),
            new ItemInfo(13923, 30, 40),
            new ItemInfo(13443, 60, 70)
        };
    
        public void Initialize()
        {
            Logging.Write("[FoodWaterPlugin] Initialized.");
            /* Should better to do run your code in OnBeforeCheckIfNeedToRunState event of ToTown state
            robotManager.Events.FiniteStateMachineEvents.OnBeforeCheckIfNeedToRunState += (engine, state, cancelable) =>
            {
                if (Conditions.InGameAndConnectedAndAliveAndProductStartedNotInPause &&
                    !Conditions.IsAttackedAndCannotIgnore &&
                    state is ToTown)
                {
                    CheckAndBuyFoodWater();
                }
            };
             */
            EventsLuaWithArgs.OnEventsLuaStringWithArgs += OnSpellCastSucceeded;
            CheckAndBuyFoodWater();
        }
    
        public void Dispose()
        {
            EventsLuaWithArgs.OnEventsLuaStringWithArgs -= OnSpellCastSucceeded;
            Logging.Write("[FoodWaterPlugin] Disposed.");
        }
    
        public void Settings()
        {
        }
    
        private void OnSpellCastSucceeded(string luaEvent, List<string> args)
        {
            /* Maybe should be more strict with conditions
             if (!Conditions.InGameAndConnectedAndAliveAndProductStartedNotInPause ||
                Conditions.IsAttackedAndCannotIgnore)
                return;
            */
            
            if (luaEvent == "UNIT_SPELLCAST_SUCCEEDED" &&
                args.Count > 0 &&
                args[0] == "player")
            {
                CheckAndBuyFoodWater();
            }
        }
    
        private void CheckAndBuyFoodWater()
        {
            if (ObjectManager.Me.IsDead || ObjectManager.Me.InCombatFlagOnly)
                return;
    
            int foodCount = GetItemCount(GetBestFood());
            int waterCount = GetItemCount(GetBestWater());
    
            if (foodCount < 5 || waterCount < 5)
            {
                GoToVendorAndBuy();
            }
        }
    
        private uint GetBestFood()
        {
            var playerLevel = ObjectManager.Me.Level;
            return foodItems.Where(item => item.MinLevel <= playerLevel && item.MaxLevel >= playerLevel)
                            .OrderByDescending(item => item.MinLevel)
                            .Select(item => item.Entry)
                            .FirstOrDefault();
        }
    
        private uint GetBestWater()
        {
            var playerLevel = ObjectManager.Me.Level;
            return waterItems.Where(item => item.MinLevel <= playerLevel && item.MaxLevel >= playerLevel)
                             .OrderByDescending(item => item.MinLevel)
                             .Select(item => item.Entry)
                             .FirstOrDefault();
        }
    
        private int GetItemCount(uint itemId)
        {
            return ItemsManager.GetItemCountByIdLUA(itemId);
        }
    
        private void GoToVendorAndBuy()
        {
            /* Should use default totown state, don't forget to add vendor to npc db
            var foodName = ItemsManager.GetNameById(GetBestFood());
            var waterName = ItemsManager.GetNameById(GetBestWater());
            wManager.wManagerSetting.CurrentSetting.TryToUseBestBagFoodDrink = false;
            wManager.wManagerSetting.CurrentSetting.FoodAmount = 20;
            wManager.wManagerSetting.CurrentSetting.DrinkAmount = 20;
            wManager.wManagerSetting.CurrentSetting.FoodName = foodName;
            wManager.wManagerSetting.CurrentSetting.DrinkName = waterName;
            ToTown.ForceToTown = true;
            */
            
            // Ищем ближайшего вендора
            WoWUnit vendor = ObjectManager.GetNearestWoWUnit(ObjectManager.GetWoWUnitVendor());
            if (vendor != null)
            {
                // Идем к вендору и покупаем
                MovementManager.Go(PathFinder.FindPath(vendor.Position));
                Interact.InteractGameObject(vendor.GetBaseAddress);
                Lua.LuaDoString($"BuyItem({GetBestFood()}, 20)");
                Lua.LuaDoString($"BuyItem({GetBestWater()}, 20)");
                AddToDoNotSell(GetBestFood());
                AddToDoNotSell(GetBestWater());
            }
        }
    
        private void AddToDoNotSell(uint itemId)
        {
            var name = ItemsManager.GetNameById(itemId);
            if (!string.IsNullOrWhiteSpace(name) &&
                !wManager.wManagerSetting.CurrentSetting.DoNotSellList.Contains(name))
            {
                wManager.wManagerSetting.CurrentSetting.DoNotSellList.Add(name);
            }
        }
    
        private void RemoveFromDoNotSell(uint itemId)
        {
            var name = ItemsManager.GetNameById(itemId);
            if (!string.IsNullOrWhiteSpace(name) &&
                wManager.wManagerSetting.CurrentSetting.DoNotSellList.Contains(name))
            {
                wManager.wManagerSetting.CurrentSetting.DoNotSellList.Remove(name);
            }
        }
    
        private class ItemInfo
        {
            public uint Entry { get; }
            public int MinLevel { get; }
            public int MaxLevel { get; }
    
            public ItemInfo(uint entry, int minLevel, int maxLevel)
            {
                Entry = entry;
                MinLevel = minLevel;
                MaxLevel = maxLevel;
            }
        }
    }

     

  3. Hello,

    It looks like there might be a misunderstanding in how the food and drink settings are configured in WRobot. Currently, you have both set to activate when your health or mana is at 1% and to stop when it reaches 90%. This setting is not effective because it's waiting until your health or mana is almost completely depleted before beginning regeneration, which is why the bot is not stopping to heal or drink as expected.

    A more effective setting would be to adjust the ranges to something like 70% to 95%. This means the bot will start the regeneration process when your health or mana falls below 70% and will continue until it reaches 95%. This ensures that the bot heals and replenishes mana more proactively, avoiding situations where you enter the next fight with insufficient health or mana. Try adjusting these settings and see if the bot performs better.

  4. On 8/2/2024 at 12:30 PM, Weer36 said:

    But it was sample for behavior, problem is not in opened chatbox. Sometimes bot flyes "to the Moon" without opened chatbox

    Check the logs (and share them here) to see what the bot is doing. Enable 3D radar to watch where the bot is trying to go (maybe a profile position is outside the flyable area or an object to pick up).

  5. Hello,

    using System.Threading;
    using System.Windows.Forms;
    using robotManager.Helpful;
    using wManager.Wow.Helpers;
    
    public class Main : wManager.Plugin.IPlugin
    {
        bool _isLaunched;
        public void Initialize()
        {
            _isLaunched = true;
            while (_isLaunched)
            {
                if (Conditions.InGameAndConnectedAndProductStartedNotInPause)
                {
                    if (Usefuls.TextBoxActivated())
                    {
                        Logging.Write("Close chat box");
                        Keyboard.PressKey(wManager.Wow.Memory.WowMemory.Memory.WindowHandle, Keys.Enter);
                    }
                }
                Thread.Sleep(500);
            }
        }
    
        public void Dispose()
        {
            _isLaunched = false;
        }
    
        public void Settings()
        {
            
        }
    }

     

    Main.cs

  6. Hello,

    using System.Threading;
    using robotManager.Helpful;
    using wManager.Wow.Helpers;
    using wManager.Wow.ObjectManager;
    
    public class Main : wManager.Plugin.IPlugin
    {
        private bool _isStarted;
        public void Initialize()
        {
            _isStarted = true;
            var stopWatch = new System.Diagnostics.Stopwatch();
            while (_isStarted)
            {
                if (Conditions.InGameAndConnectedAndProductStartedNotInPause)
                {
                    if (ObjectManager.Me.IsDeadMe && stopWatch.Elapsed.TotalMinutes > 5)
                    {
                        Logging.Write("Bot is dead for more than 5 minutes, closing game.");
                        wManager.Wow.Memory.WowMemory.CloseHookedProcess();
                        _isStarted = false;
                    }
                    else if (ObjectManager.Me.IsDeadMe)
                    {
                        stopWatch.Start();
                    }
                    else
                    {
                        stopWatch.Reset();
                    }
                }
                Thread.Sleep(500);
            }
        }
    
        public void Dispose()
        {
            _isStarted = false;
        }
    
        public void Settings()
        {
        }
    }

     

×
×
  • Create New...