Exemple #1
0
        public void EatOrDrink(string itemName, bool isMana = false)
        {
            try
            {
                if (FishingTask.IsLaunched)
                {
                    FishingTask.StopLoopFish();
                }
                // isMana = false => Health
                if (ObjectManager.ObjectManager.Me.IsMounted)
                {
                    Usefuls.DisMount();
                }
                MovementManager.StopMove();
                Thread.Sleep(500);

                ObjectManager.ObjectManager.Me.ForceIsCasting = true; // Make the bot believe it's casting something. (we set it to false in Finally())
                ItemsManager.UseItem(itemName);
                for (int i = 0; i < 30; i++)
                {
                    if (ObjectManager.ObjectManager.Me.IsDeadMe || ObjectManager.ObjectManager.Me.InCombat)
                    {
                        return;
                    }
                    if (!isMana && ObjectManager.ObjectManager.Me.HealthPercent > 95 || isMana && ObjectManager.ObjectManager.Me.ManaPercentage > 95)
                    {
                        break;
                    }
                    Thread.Sleep(500);
                    // Eat/Drink for 15 seconds or until we get to high HP/Mana
                }
            }
            catch (Exception e)
            {
                Logging.WriteError("public void EatOrDrink(string itemName, bool isMana = false): " + e);
            }
            finally
            {
                ObjectManager.ObjectManager.Me.ForceIsCasting = false;
                // In case we set it to true and crash, prevent the bot from believing that its constantly casting.
            }
        }
Exemple #2
0
        public static void DismountMount(bool stopMove = true)
        {
            try
            {
                if (Products.Products.IsStarted)
                {
                    if (stopMove)
                    {
                        MovementManager.StopMove();
                    }
                    else
                    {
                        MovementManager.StopMoveTo();
                    }
                    Thread.Sleep(200);

                    if (ObjectManager.ObjectManager.Me.IsMounted)
                    {
                        Logging.Write("Dismount in progress.");
                        bool flying = Usefuls.IsFlying;
                        if (flying)
                        {
                            Land();
                        }
                        Usefuls.DisMount();
                        if (flying)
                        {
                            _flyDismountTimer = new Timer(5000);
                        }
                        Thread.Sleep(200 + Usefuls.Latency);
                    }
                }
            }
            catch (Exception ex)
            {
                Logging.WriteError("MountTask > DismountMount(): " + ex);
            }
        }
Exemple #3
0
        public override void Run()
        {
            #region Player

            try
            {
                if (!string.IsNullOrEmpty(nManagerSetting.CurrentSetting.FoodName) && ItemsManager.GetItemCount(nManagerSetting.CurrentSetting.FoodName) > 0)
                {
                    if (ObjectManager.ObjectManager.Me.HealthPercent <= nManagerSetting.CurrentSetting.EatFoodWhenHealthIsUnderXPercent)
                    {
                        Logging.Write("Health regeneration started: Food mode");
                        EatOrDrink(nManagerSetting.CurrentSetting.FoodName);
                        Logging.Write("Health regeneration done: Food mode");
                    }
                }

                // We check for Mana -after- we eat food, to make sure we still need it since most food now gives mana too.
                if (!string.IsNullOrEmpty(nManagerSetting.CurrentSetting.BeverageName) && ItemsManager.GetItemCount(nManagerSetting.CurrentSetting.BeverageName) > 0)
                {
                    if (nManagerSetting.CurrentSetting.DoRegenManaIfLow && ObjectManager.ObjectManager.Me.ManaPercentage <= nManagerSetting.CurrentSetting.DrinkBeverageWhenManaIsUnderXPercent)
                    {
                        Logging.Write("Mana regeneration started: Beverage mode");
                        EatOrDrink(nManagerSetting.CurrentSetting.BeverageName, true);
                        Logging.Write("Mana regeneration done: Beverage mode");
                    }
                }

                if (ObjectManager.ObjectManager.Me.WowClass == WoWClass.Mage && _mageConjureActive)
                {
                    int targetItem = GetBestMageFoodInBags();
                    while (targetItem <= 0)
                    {
                        if (!NeedToRun)
                        {
                            return;
                        }
                        if (_mageConjureSpell.IsSpellUsable)
                        {
                            _mageConjureCount++;
                            _mageConjureSpell.Cast(true);
                            Thread.Sleep(300);
                        }
                        Thread.Sleep(1000);
                        targetItem = GetBestMageFoodInBags();
                        if (_mageConjureCount > 4)
                        {
                            _mageConjureActive = false;
                        }
                        if (ObjectManager.ObjectManager.Me.InInevitableCombat)
                        {
                            return;
                        }
                    }
                    if (targetItem > 0)
                    {
                        _mageConjureCount = 0;
                        Logging.Write("Health regeneration started: Mage Food mode");
                        EatOrDrink(ItemsManager.GetItemNameById(targetItem));
                        Logging.Write("Health regeneration done: Mage Food mode");
                    }
                }

                if (CombatClass.GetLightHealingSpell == null)
                {
                    return;
                }
                // In case we did not use food/beverage, we check if we need to heal ourself.
                if (CombatClass.GetLightHealingSpell.IsSpellUsable && NeedToRun)
                {
                    Logging.Write("Regeneration started: Light Heal mode");
                    if (ObjectManager.ObjectManager.Me.IsMounted)
                    {
                        Usefuls.DisMount();
                    }
                    MovementManager.StopMove();
                    Thread.Sleep(500);
                    var timer = new Timer(10000);
                    while (CombatClass.GetLightHealingSpell.IsSpellUsable && NeedToRun)
                    {
                        Thread.Sleep(250);
                        if (ObjectManager.ObjectManager.Me.IsCasting)
                        {
                            continue;
                        }
                        if (Math.Abs(ObjectManager.ObjectManager.Me.HealthPercent) < 0.001f)
                        {
                            return;
                        }
                        if (ObjectManager.ObjectManager.Me.InCombat || ObjectManager.ObjectManager.Me.IsDeadMe)
                        {
                            return;
                        }
                        if (timer.IsReady)
                        {
                            break;
                        }
                        CombatClass.GetLightHealingSpell.CastOnSelf(true);
                    }

                    Logging.Write(!NeedToRun ? "Regeneration done (success): Light Heal mode" : "Regeneration done (timer): Light Heal mode");
                }
            }
            catch (Exception e)
            {
                Logging.WriteError("Regeneration.Run(): " + e);
            }

            #endregion
        }