Ejemplo n.º 1
0
        public async Task <bool> ClickToMove(bool allowDequeue = true)
        {
            if (CurrentMovementQueue.Count == 0)
            {
                return(false);
            }

            WoWPoint location        = CurrentLocation;
            WoWPoint playerPos       = Character.Player.Location;
            float    currentDistance = location.Distance(playerPos);

            if (currentDistance <= Distance)
            {
                if (allowDequeue)
                {
                    Log("ClickToMove", String.Format("has dequeued location - {0}", location.ToString()));

                    DequeuedPoints.Enqueue(CurrentMovementQueue.Dequeue());
                    DequeuedFinalPlayerPositionPoints.Add(playerPos);
                }

                if (CurrentMovementQueue.Count == 0 || CurrentMovementQueue.Count == 1 && !allowDequeue)
                {
                    Log("ClickToMove", "is finished");
                    WoWMovement.MoveStop();
                    return(false);
                }

                return(true);
            }

            if (!WoWMovement.ClickToMoveInfo.IsClickMoving)
            {
                Log("ClickToMove", location.ToString());
                WoWMovement.ClickToMove(location);
                // await Coroutine.Sleep(StyxWoW.Random.Next(525, 800));
            }

            if (!_didResetStuckChecker)
            {
                StuckChecker.Reset();
                _didResetStuckChecker = true;
            }
            else if (_checkStuck)
            {
                if (StuckChecker.CheckStuck())
                {
                    Log("ClickToMoveResult", "Stuck Checker returned true!");
                    return(false);
                }
            }

            if (MovementCache.ShouldRecord)
            {
                MovementCache.AddPosition(playerPos, Distance);
            }

            return(true);
        }
Ejemplo n.º 2
0
        public override void Initalize()
        {
            Movement.IgnoreTaxiCheck = true;
            _selectedTaxiNode        = null;
            _taxiMovement            = null;
            _taxiNpc           = null;
            _nonVisiblityCount = 0;

            GarrisonBase.Debug("UseFlightPath Destination {0}", _destination.ToString());

            _destinationFlightPathInfo = TaxiFlightHelper.NearestFlightPathFromLocation(_destination);
            if (_destinationFlightPathInfo != null)
            {
                GarrisonBase.Debug("Destination FlightPathInfo {0}", _destinationFlightPathInfo.ToString());

                if (_destinationFlightPathInfo.MasterId == TaxiFlightHelper.FlightPathInfo.FrostwallMasterEntry ||
                    _destinationFlightPathInfo.MasterId == TaxiFlightHelper.FlightPathInfo.LunarfallMasterEntry)
                {
                    GarrisonBase.Debug("Flight path destination is garrison, ignore hearth set to false!");
                    Common.PreChecks.IgnoreHearthing = false;
                }
            }

            _currentMapId     = TaxiFlightHelper.GetMapId(Player.Location);
            _destinationMapId = TaxiFlightHelper.GetMapId(_destination);
            GarrisonBase.Debug("Current Map Id {0} -- Destination Map Id {1}", _currentMapId, _destinationMapId);
            if (_currentMapId != _destinationMapId)
            {
                _shouldCheckMapId = true;
            }

            Common.CloseOpenFrames();
            Initalized = true;
        }
Ejemplo n.º 3
0
        private static WoWPoint findSafeFlightPoint(WoWPoint loc)
        {
            #region If multiple layers (heights), attempt to land somewhere nearby
            var _heights = Logic.Pathing.Navigator.FindHeights(loc.X, loc.Y);
            _heights.Sort();
            if (_heights.Count() > 1)
            {
                Random rand     = new Random();
                var    i        = 1;
                var    _newSpot = new WoWPoint(0, 0, 0);
                while (i < 100)
                {
                    _newSpot = new WoWPoint((loc.X + rand.Next(-i, i)), (loc.Y + rand.Next(-i, i)), 0);
                    while (Logic.Pathing.Navigator.FindHeights(_newSpot.X, _newSpot.Y).Count() > 1)
                    {
                        _newSpot = new WoWPoint((loc.X + rand.Next(-i, i)), (loc.Y + rand.Next(-i, i)), 0);
                        i        = i + 1;
                    }
                    Logic.Pathing.Navigator.FindHeight(_newSpot.X, _newSpot.Y, out _newSpot.Z);
                    if (Navigator.CanNavigateFully(_newSpot, loc) && clearSpot(_newSpot))
                    {
                        Log("Took {0} tries to find a safe(?) spot!", i);
                        Log("Landing spot: {0}", _newSpot.ToString());
                        return(_newSpot);
                    }
                }
                Log("No safe spot found :(");
                return(loc);
            }
            #endregion

            #region If 1 layer, but no LOS from above, attempt to land somewhere nearby
            else if (!WoWInternals.World.GameWorld.IsInLineOfSightOCD(new WoWPoint(loc.X, loc.Y, loc.Z + 50), loc))
            {
                Random rand     = new Random();
                var    i        = 1;
                var    _newSpot = new WoWPoint(0, 0, 0);
                while (i < 100)
                {
                    _newSpot = new WoWPoint((loc.X + rand.Next(-i, i)), (loc.Y + rand.Next(-i, i)), 0);
                    i        = i + 1;
                    Logic.Pathing.Navigator.FindHeight(_newSpot.X, _newSpot.Y, out _newSpot.Z);
                    if (Navigator.CanNavigateFully(_newSpot, loc) && clearSpot(_newSpot))
                    {
                        Log("Took {0} tries to find a safe(?) spot!", i);
                        Log("Landing point: {0}", _newSpot.ToString());
                        return(_newSpot);
                    }
                }
                Log("No safe spot found :(");
                return(loc);
            }
            #endregion
            else
            {
                return(loc);
            }
        }
Ejemplo n.º 4
0
        private string CreateBlackspotName(string preferredName, WoWPoint wowPoint)
        {
            if (string.IsNullOrEmpty(preferredName))
            {
                preferredName = string.Format("Blackspot({0})", wowPoint.ToString());
            }

            return(QbcoreNamePrefix + preferredName);
        }
Ejemplo n.º 5
0
        private static async Task <bool> TryNavigator(WoWPoint destination, string destinationName = null)
        {
            var activeMover = WoWMovement.ActiveMover;

            // If we can navigate to destination, use navigator...
            if (Navigator.CanNavigateFully(activeMover.Location, destination))
            {
                var moveResult = Navigator.MoveTo(destination);
                if (Navigator.GetRunStatusFromMoveResult(moveResult) == RunStatus.Success)
                {
                    return(true);
                }
            }
            if (destinationName == null)
            {
                destinationName = destination.ToString();
            }
            QBCLog.DeveloperInfo(
                "Navigator unable to move from {0} to destination({1}, {2}) on ground --try MovementBy=\"FlightorPreferred\".",
                activeMover.Location,
                destinationName,
                destination.ToString());
            return(false);
        }
Ejemplo n.º 6
0
 public async static Task <bool> FlyTo(WoWPoint destination, string destinationName = null)
 {
     if (destination.DistanceSqr(_lastMoveTo) > 5 * 5)
     {
         if (MoveToLogTimer.IsFinished)
         {
             if (string.IsNullOrEmpty(destinationName))
             {
                 destinationName = destination.ToString();
             }
             AutoAnglerBot.Log("Flying to {0}", destinationName);
             MoveToLogTimer.Reset();
         }
         _lastMoveTo = destination;
     }
     Flightor.MoveTo(destination);
     return(true);
 }
Ejemplo n.º 7
0
        public async static Task <bool> MoveTo(WoWPoint destination, string destinationName = null)
        {
            if (destination.DistanceSqr(_lastMoveTo) > 5 * 5)
            {
                if (MoveToLogTimer.IsFinished)
                {
                    if (string.IsNullOrEmpty(destinationName))
                    {
                        destinationName = destination.ToString();
                    }
                    AutoAnglerBot.Log("Moving to {0}", destinationName);
                    MoveToLogTimer.Reset();
                }
                _lastMoveTo = destination;
            }
            var moveResult = Navigator.MoveTo(destination);

            return(moveResult != MoveResult.Failed && moveResult != MoveResult.PathGenerationFailed);
        }
Ejemplo n.º 8
0
 public override string ToString()
 {
     return(String.Format("{0}" +
                          "Guid {1}\r\n" +
                          "{2} ({3})\r\n" +
                          "LOS {4} ( {5} ) Tested {6}ms\r\n" +
                          "Collision {9} Tested {10}ms\r\n" +
                          "Valid {7}\r\n" +
                          "Update {8}\r\n" +
                          "IgnoreTime {11}",
                          base.ToString(), Guid,
                          Location, Distance,
                          LineofsightResult, _lineofsightPoint.ToString(), LineofSightWaitTimer.TimeLeft.TotalMilliseconds,
                          ObjectValidCheck,
                          RequiresUpdate,
                          CollisionResult,
                          CollisionWaitTimer.TimeLeft.TotalMilliseconds,
                          IgnoredTimer.IsFinished?"0":IgnoredTimer.TimeLeft.TotalMilliseconds + "ms"));
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Location is cached.
        /// </summary>
        /// <param name="location"></param>
        /// <param name="precision"></param>
        public MoveTo(WoWPoint location, float precision = 0.0f)
        {
            if (location == default(WoWPoint))
            {
                Status = new Result(ActionResult.Failed, "Location is equal to default value.");
                GarrisonButler.Diagnostic("Creating MoveTo Failed Location is equal to default value");
                return;
            }
            GarrisonButler.Diagnostic("Creating MoveTo at {0} (p={1})", location.ToString(), precision);

            Location.X = location.X;
            Location.Y = location.Y;
            Location.Z = location.Z;

            if (Math.Abs(precision) < Navigator.PathPrecision)
                _precision = Navigator.PathPrecision;
            else
                _precision = precision;
        }
Ejemplo n.º 10
0
        private bool TotemManagerUpdate()
        {
            int countTotems = 0;

            _ptTotems = new WoWPoint();
            _totem    = new WoWUnit[5];

#if USE_OLD_SEARCH
            List <WoWUnit> totemList = (from o in ObjectManager.ObjectList
                                        where o is WoWUnit
                                        let unit = o.ToUnit()
                                                   where unit.CreatedByUnitGuid == _me.Guid &&
                                                   unit.CreatureType == WoWCreatureType.Totem
                                                   select unit
                                        ).ToList();

            foreach (WoWUnit totem in totemList)
            {
                int indexTotem = 0;
                try
                {
                    countTotems++;
                    indexTotem         = _dictTotemSlot[(TotemId)totem.CreatedBySpellId];
                    _totem[indexTotem] = totem;
                    if (totem.Distance < _ptTotems.Distance(_me.Location))
                    {
                        _ptTotems = totem.Location;
                    }
                }
                catch
                {
                    Shaman.Wlog("NOTIFY SHAMWOW DEVELOPER:  Unknown totem: totem spell id={0}, totem name='{1}', index totem={2}", totem.CreatedBySpellId, totem.Name, indexTotem);
                }
            }
#else
            foreach (WoWTotemInfo ti in _me.Totems)
            {
                if (ti.WoWTotem != WoWTotem.None)
                {
                    countTotems++;

                    try
                    {
                        WoWUnit totem      = ObjectManager.GetObjectByGuid <WoWUnit>(ti.Guid);
                        int     indexTotem = _dictTotemSlot[(TotemId)totem.CreatedBySpellId];
                        _totem[indexTotem] = totem;
                        if (totem.Distance < _ptTotems.Distance(_me.Location))
                        {
                            _ptTotems = totem.Location;
                        }
                    }
                    catch
                    {
                        Shaman.Wlog("NOTIFY SHAMWOW DEVELOPER:  Unknown totem: totem spell id={0}, totem name='{1}'", ti.Spell.Id, ti.Name);
                    }
                }
            }
#endif

#if SHOW_TOTEM_COUNT
            if (countTotems > 0)
            {
                Shaman.Dlog("TotemManagerUpdate:  found {0} totems with closest {1:F1} yds away at {2}", countTotems, _ptTotems.Distance(_me.Location), _ptTotems.ToString());
            }
#endif

            return(countTotems > 0);
        }
Ejemplo n.º 11
0
        public static async Task <bool> MoveTo(
            WoWPoint destination,
            string destinationName,
            MovementByType movementBy = MovementByType.FlightorPreferred)
        {
            Contract.Requires(destinationName != null, context => "destinationName may not be null");

            if (movementBy == MovementByType.None)
            {
                return(false);
            }

            var activeMover = WoWMovement.ActiveMover;

            if (activeMover == null)
            {
                return(false);
            }

            if (!IsMoveToMessageThrottled)
            {
                if (string.IsNullOrEmpty(destinationName))
                {
                    destinationName = destination.ToString();
                }
                TreeRoot.StatusText = "Moving to " + destinationName;
            }

            switch (movementBy)
            {
            case MovementByType.FlightorPreferred:
                if (await TryFlightor(destination))
                {
                    return(true);
                }

                if (await TryNavigator(destination, destinationName))
                {
                    return(true);
                }

                if (await TryClickToMove(destination, NavType.Fly))
                {
                    return(true);
                }
                break;

            case MovementByType.NavigatorPreferred:
                if (await TryNavigator(destination, destinationName))
                {
                    return(true);
                }

                if (await TryClickToMove(destination, NavType.Run))
                {
                    return(true);
                }
                break;

            case MovementByType.NavigatorOnly:
                if (await TryNavigator(destination, destinationName))
                {
                    return(true);
                }
                break;

            case MovementByType.ClickToMoveOnly:
                var navType = activeMover.MovementInfo.CanFly ? NavType.Fly : NavType.Run;
                if (await TryClickToMove(destination, navType))
                {
                    return(true);
                }
                break;

            case MovementByType.None:
                break;

            default:
                QBCLog.MaintenanceError("Unhandled MovementByType of {0}", movementBy);
                break;
            }
            return(false);
        }
Ejemplo n.º 12
0
 public WoWPointNamed(WoWPoint location,
                      string name,
                      bool isStarting)
 {
     Location = location;
     Name = (!string.IsNullOrEmpty(name) ? name : location.ToString());
     IsStarting = isStarting;
 }
Ejemplo n.º 13
0
        public async Task <MoveResult> MoveTo_Result(bool allowDequeue = true)
        {
            if (CurrentMovementQueue.Count == 0)
            {
                return(MoveResult.ReachedDestination);
            }

            WoWPoint location        = CurrentLocation;
            WoWPoint playerPos       = Character.Player.Location;
            float    currentDistance = location.Distance(playerPos);

            if (currentDistance <= Distance)
            {
                if (allowDequeue)
                {
                    Log("MoveToResult", String.Format("has dequeued location - {0}", location.ToString()));

                    DequeuedPoints.Enqueue(CurrentMovementQueue.Dequeue());
                    DequeuedFinalPlayerPositionPoints.Add(playerPos);
                }

                if (CurrentMovementQueue.Count == 0 || CurrentMovementQueue.Count == 1 && !allowDequeue)
                {
                    Log("MoveToResult", "is finished");
                    WoWMovement.MoveStop();
                    return(MoveResult.ReachedDestination);
                }

                return(MoveResult.Moved);
            }

            if (!_didResetStuckChecker)
            {
                StuckChecker.Reset();
                _didResetStuckChecker = true;
            }
            else if (_checkStuck)
            {
                if (StuckChecker.CheckStuck())
                {
                    Log("MoveToResult", "Stuck Checker returned true!");
                    return(MoveResult.Failed);
                }
            }

            if (!CheckCanNavigate())
            {
                Log("MoveToResult", "Can Navigate Return False " + location.ToString());
                return(MoveResult.Failed);
            }


            var moveresult = MoveResult.Moved;

            try
            {
                moveresult = await CommonCoroutines.MoveTo(location);
            }
            catch (Exception ex)
            {
                Navigator.Clear();
                Log("MoveToResult", "Exception during movement attempt!! " + location.ToString());
                try
                {
                    Navigator.MoveTo(location);
                }
                catch
                {
                    Log("MoveToResult", "Double Exception during movement attempt!! " + location.ToString());
                    return(MoveResult.Failed);
                }
            }

            if (MovementCache.ShouldRecord)
            {
                MovementCache.AddPosition(playerPos, Distance);
            }

            //GarrisonBase.Log("[MoveTo] MoveResult: {0}", moveresult.ToString());
            return(moveresult);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// SetTotemsAsNeeded() - manages casting totems as called for by environment and
        /// user configuration values. This code uses:
        ///     http://www.yawb.info/2009/08/25/learning-about-totems-tips-to-aid-your-growing-shamanism/
        /// as a guideline for totem usage while leveling.
        /// </summary>
        private bool SetTotemsAsNeeded()
        {
            bool castTotem = false;

            try
            {
                if (!_me.Fleeing && (Shaman.cfg.FarmingLowLevel || _me.IsMoving))
                    return false;

                // limit how frequently we check totems.  needs to be often,
                // .. but not each loop.
                // .. 
                if (_TotemCheckTimer.ElapsedMilliseconds < 1500)
                {
                    // if this isn't first time here since reset, then wait for 2 seconds
                    if (!_me.Fleeing && _TotemCheckTimer.ElapsedMilliseconds > 0 && TotemsWereSet())
                        return false;

                    // otherwise, only 0 if first check after last .Reset
                    //  ..  so continue processing
                }

                if (TotemsWereSet() && _ptTotems.Distance(_me.Location) > Shaman.cfg.DistanceForTotemRecall)
                {
                    Shaman.Dlog("Recalling Totems that were set {0:F1} yds away at point {1}", _ptTotems.Distance(_me.Location), _ptTotems.ToString());
                    RecallTotemsForMana();
                }

                _TotemCheckTimer.Reset();
                _TotemCheckTimer.Start();

                //-----
                // if you make it past the following gate, only limited tests are needed for each totem
                //-----
                if (IsPVP() || Shaman.IsRAF())
                    ;
                else if (Shaman.IsFightStressful() || !Shaman.cfg.PVE_SaveForStress_TotemsSelected)
                    ;
                else
                {
                    
                    Shaman.Dlog("not setting totems until a stressful situation");
                    return false;
                }

                // check which totems exist
                bool bAnyTotemsUp = TotemExist(TOTEM_EARTH)
                                || TotemExist(TOTEM_FIRE)
                                || TotemExist(TOTEM_WATER)
                                || TotemExist(TOTEM_AIR);

                Shaman.Dlog("SetTotemsAsNeeded:  earth: " + BoolToYN(TotemExist(TOTEM_EARTH)) + "  fire: " + BoolToYN(TotemExist(TOTEM_FIRE)) + "  water: " + BoolToYN(TotemExist(TOTEM_WATER)) + "  air: " + BoolToYN(TotemExist(TOTEM_AIR)));

                _WereTotemsSet = bAnyTotemsUp;  // _WereTotemsSet || removed because only matters if they exist

                // Quick scan for mobs that cast fear (only in RAF)
                //////////////////////////////////////////////////////////////////////
                Shaman.foundMobsThatFear = _me.Fleeing;
                if (Shaman.foundMobsThatFear)
                    Shaman.Slog("Tremor Totem:  detected fear mob");

                // Totem Bar Set
                // -- add handling for changing totem bar setup temporarily if needed for tremor totem
                //////////////////////////////////////////////////////////////////////
                const string totemBar = "Call of the Elements";
                if (!bAnyTotemsUp && SpellManager.HasSpell(totemBar) )
                {
                    TotemId saveEarthTotemSetup = TotemId.TREMOR_TOTEM;

                    // if mobs that fear are found and tremor not in bar setup already, add temporarily just for cast
                    if (Shaman.foundMobsThatFear && _totemBar[TOTEM_EARTH] != TotemId.TREMOR_TOTEM)
                    {
                        saveEarthTotemSetup = _totemBar[TOTEM_EARTH];
                        TotemSelect(TOTEM_EARTH, TotemId.TREMOR_TOTEM);
                    }

                    if (Shaman.Safe_CastSpell(totemBar, Shaman.SpellRange.NoCheck, Shaman.SpellWait.Complete))
                    {
                        castTotem = true;
                        _WereTotemsSet = true;
                        _ptTotems = _me.Location;

                        if (IsRAF())
                            Dlog("SetTotemsAsNeeded: set totems at <{0}> {1:F1} yds from Leader", _ptTotems.ToString(), GroupTank.Distance);
                        else
                            Dlog("SetTotemsAsNeeded: set totems at <{0}>", _ptTotems.ToString());
                    }

                    // if we changed the earth totem on bar, restore back to configured value
                    if (saveEarthTotemSetup != TotemId.TREMOR_TOTEM)
                    {
                        TotemSelect(TOTEM_EARTH, saveEarthTotemSetup);
                    }
                }
                else
                {
                    // Earth Totems First
                    //////////////////////////////////////////////////////////////////////
                    if (foundMobsThatFear && HasTotemSpell(TotemId.TREMOR_TOTEM) && TotemId.TREMOR_TOTEM != (TotemId)_totem[TOTEM_EARTH].CreatedBySpellId)
                    {
                        castTotem = castTotem || TotemCast(TotemId.TREMOR_TOTEM);
                    }
                    else if (0 != _totemBar[TOTEM_EARTH])
                    {
                        if (!TotemExist(TOTEM_EARTH) && HasTotemSpell(_totemBar[TOTEM_EARTH]))
                            castTotem = castTotem || TotemCast(_totemBar[TOTEM_EARTH]);

                        if (!TotemExist(TOTEM_EARTH) && Shaman.typeShaman == Shaman.ShamanType.Enhance && HasTotemSpell(TotemId.STRENGTH_OF_EARTH_TOTEM))
                            castTotem = castTotem || TotemCast(TotemId.STRENGTH_OF_EARTH_TOTEM);

                        if (!TotemExist(TOTEM_EARTH) && Shaman.typeShaman != Shaman.ShamanType.Enhance && HasTotemSpell(TotemId.STONESKIN_TOTEM))
                            castTotem = castTotem || TotemCast(TotemId.STONESKIN_TOTEM);
                    }

                    // Fire Totems
                    //////////////////////////////////////////////////////////////////////
                    if (_countMeleeEnemy >= 3 && !IsHealerOnly())
                    {
                        if (!_me.GotTarget || !IsImmunneToFire(_me.CurrentTarget))
                        {
                            if (!TotemExist(TOTEM_FIRE) || (!TotemExist(TotemId.MAGMA_TOTEM) && !TotemExist(TotemId.FIRE_ELEMENTAL_TOTEM)))
                            {
                                if (HasTotemSpell(TotemId.MAGMA_TOTEM))
                                {
                                    castTotem = castTotem || TotemCast(TotemId.MAGMA_TOTEM);
                                }
                                else if (_countMeleeEnemy >= 4 && HasTotemSpell(TotemId.FLAMETONGUE_TOTEM) && !TotemExist(TotemId.FLAMETONGUE_TOTEM))
                                {
                                    Dlog("SetTotemsAsNeeded: 4 or more mobs and Magma not trained, using Flametongue to allow Fire Nova");
                                    castTotem = castTotem || TotemCast(TotemId.FLAMETONGUE_TOTEM);
                                }
                            }
                        }
                    }

                    if (0 != _totemBar[TOTEM_FIRE] && !TotemExist(TOTEM_FIRE))
                    {
                        if (!TotemExist(TOTEM_FIRE) && HasTotemSpell(_totemBar[TOTEM_FIRE]))
                            castTotem = castTotem || TotemCast(_totemBar[TOTEM_FIRE]);
                        if (!TotemExist(TOTEM_FIRE) && Shaman.typeShaman != Shaman.ShamanType.Resto && HasTotemSpell(TotemId.SEARING_TOTEM))
                            castTotem = castTotem || TotemCast(TotemId.SEARING_TOTEM);
                        if (!TotemExist(TOTEM_FIRE) && HasTotemSpell(TotemId.FLAMETONGUE_TOTEM))
                            castTotem = castTotem || TotemCast(TotemId.FLAMETONGUE_TOTEM);
                    }

                    // Water Totems
                    //////////////////////////////////////////////////////////////////////
                    if (0 != _totemBar[TOTEM_WATER])
                    {
                        if (!TotemExist(TOTEM_WATER) && HasTotemSpell(_totemBar[TOTEM_WATER]))
                            castTotem = castTotem || TotemCast(_totemBar[TOTEM_WATER]);

                        if (!TotemExist(TOTEM_WATER) && HasTotemSpell(TotemId.MANA_SPRING_TOTEM))
                            castTotem = castTotem || TotemCast(TotemId.MANA_SPRING_TOTEM);
                    }

                    // Air Totems
                    //////////////////////////////////////////////////////////////////////
                    if (0 != _totemBar[TOTEM_AIR])
                    {
                        if (!TotemExist(TOTEM_AIR) && HasTotemSpell(_totemBar[TOTEM_WATER]))
                            castTotem = castTotem || TotemCast(_totemBar[TOTEM_AIR]);
                        if (!TotemExist(TOTEM_AIR) && Shaman.typeShaman == Shaman.ShamanType.Resto && HasTotemSpell(TotemId.GROUNDING_TOTEM))
                            castTotem = castTotem || TotemCast(TotemId.GROUNDING_TOTEM);
                        if (!TotemExist(TOTEM_AIR) && Shaman.typeShaman == Shaman.ShamanType.Enhance && HasTotemSpell(TotemId.WINDFURY_TOTEM))
                            castTotem = castTotem || TotemCast(TotemId.WINDFURY_TOTEM);
                        if (!TotemExist(TOTEM_AIR) && Shaman.typeShaman == Shaman.ShamanType.Elemental && HasTotemSpell(TotemId.WRATH_OF_AIR_TOTEM))
                            castTotem = castTotem || TotemCast(TotemId.WRATH_OF_AIR_TOTEM);
                    }

                    _WereTotemsSet = _WereTotemsSet || TotemExist(TOTEM_EARTH) || TotemExist(TOTEM_FIRE) || TotemExist(TOTEM_WATER) || TotemExist(TOTEM_AIR);

                    if (!bAnyTotemsUp && _WereTotemsSet)
                        _ptTotems = _me.Location;
                }
            }
            catch (ThreadAbortException) { throw; }
            catch (Exception e)
            {
                Log(Color.Red, "An Exception occured. Check debug log for details.");
                Logging.WriteDebug("HB EXCEPTION in SetTotemsAsNeeded()");
                Logging.WriteException(e);
            }

            // would like to remove this code, but seeing duplicate totem sets
            if (castTotem)
            {
                ObjectManager.Update();
                TotemManagerUpdate();
            }

            return castTotem;
        }
        public override void Pulse()
        {
            if (!isInitialize)
            {
                updateList(true); isInitialize = true;
            }

            if (!complete && !Me.Combat)
            {
                List <WoWUnit> _Unit = ObjectManager.GetObjectsOfType <WoWUnit>();
                foreach (WoWUnit critterUnit in _Unit)
                {
                    bool achievementFound = false;

                    #region love Achievement
                    if (loveAchievement.Contains(critterUnit.Name))
                    {
                        slog("found: " + critterUnit.Name);
                        achievementFound = true;

                        while (achievementFound)
                        {
                            TreeRoot.StatusText = Name + ": " + Me.Name + " love " + critterUnit.Name;
                            WoWMovement.MoveStop();
                            RunMakro("/tar " + critterUnit.Name);
                            RunMakro("/love");
                            RunMakro("/cleartarget");
                            slog("{0} love {1}", Me.Name, critterUnit.Name);
                            loveAchievement.Remove(critterUnit.Name);
                            achievementFound = false;
                        }
                    }
                    #endregion

                    #region kill Achievement
                    while (killAchievement.Contains(critterUnit.Name) && critterUnit.IsAlive && !Completed(2556) && !Blacklist.Contains(critterUnit.Guid) && !Me.OnTaxi)
                    {
                        //System.Media.SystemSounds.Asterisk.Play();
                        WoWMovement.MoveStop();
                        if (!achievementFound)
                        {
                            slog("found: " + critterUnit.Name);
                        }
                        achievementFound = true;

                        while ((Me.IsFlying || !Navigator.CanNavigateFully(Me.Location, critterUnit.WorldLocation)) && critterUnit.IsIndoors)
                        {
                            WoWMovement.ClickToMove(StyxWoW.Me.Location.Add(0, 0, -10));
                        }
                        while ((Me.IsFlying || !Navigator.CanNavigateFully(Me.Location, critterUnit.WorldLocation)) && !critterUnit.IsIndoors)
                        {
                            WoWPoint critterPosi = critterUnit.Location;

                            while (critterPosi.Distance(Me.Location) >= 5)
                            {
                                WoWMovement.ClickToMove(critterPosi);
                                Thread.Sleep(100);
                            }
                        }
                        WoWMovement.MoveStop();

                        while (achievementFound && Navigator.CanNavigateFully(Me.Location, critterUnit.WorldLocation) && !Me.Combat && critterUnit.Distance >= 4)
                        {
                            critterUnit.Face();
                            Thread.Sleep(1500);
                            if (Me.Class == WoWClass.Druid && SpellManager.HasSpell(768))
                            {
                                slog("(Dismount) switch to {0}", WoWSpell.FromId(768).Name); WoWSpell.FromId(768).Cast(); Thread.Sleep(1500);
                            }
                            else if (Me.Mounted)
                            {
                                slog("Dismount!"); RunMakro("/dismount");
                            }

                            if (backPoint == WoWPoint.Empty && !Me.IsSwimming)
                            {
                                slog("set retreat position to " + Me.Location.ToString()); backPoint = Me.Location;
                            }

                            if (!retreatTimer.IsRunning)
                            {
                                retreatTimer.Start();
                            }

                            if (!Me.Combat && achievementFound)
                            {
                                int maxStuckTimer = (500 * ((int)critterUnit.Distance + 1));
                                //slog("maxStuckTimer: {0}", maxStuckTimer);
                                slog("Move to {0}, Distance: {1}yards", critterUnit.Name, (int)critterUnit.Distance);
                                stuckTimer.Reset(); stuckTimer.Start();

                                while (stuckTimer.ElapsedMilliseconds <= maxStuckTimer && !Me.Combat && critterUnit.Distance >= 2)
                                {
                                    if (backPoint == WoWPoint.Empty && !Me.IsSwimming)
                                    {
                                        slog("set retreat position to " + Me.Location.ToString()); backPoint = Me.Location;
                                    }
                                    TreeRoot.StatusText = (Name + ": Move to " + critterUnit.Name + ", Distance: " + (int)critterUnit.Distance + "yards");
                                    Navigator.MoveTo(critterUnit.Location);
                                    Thread.Sleep(100);
                                }
                                stuckTimer.Stop();

                                if (stuckTimer.ElapsedMilliseconds >= maxStuckTimer)
                                {
                                    Blacklist.Add(critterUnit.Guid, new TimeSpan(0, 5, 0));
                                    achievementFound = false; moveBack = true; stuckTimer.Stop(); Me.ClearTarget();
                                    retreatTimer.Stop(); retreatTime = (retreatTimer.ElapsedMilliseconds + 5000); retreatTimer.Reset();
                                    slog("we stuck! Blacklist - Name: {0} / GuId: {1} - After: {2}ms", critterUnit.Name, critterUnit.Guid, stuckTimer.ElapsedMilliseconds);
                                    TreeRoot.StatusText = Name + " we stuck! Blacklist - Name: " + critterUnit.Name + " / GuId: " + critterUnit.Guid.ToString() + " - After: " + stuckTimer.ElapsedMilliseconds + "ms";
                                    return;
                                }
                            }
                            retreatTimer.Stop(); retreatTime = (retreatTimer.ElapsedMilliseconds + 5000); retreatTimer.Reset();
                            //slog("set retreatTime to: " + retreatTime + "ms");

                            if (Me.Combat)
                            {
                                return;
                            }
                            WoWMovement.MoveStop();

                            while (!Me.Combat && achievementFound && critterUnit.Distance <= 5)
                            {
                                critterUnit.Target();
                                slog("slay {0}..", critterUnit.Name);

                                stuckTimer.Reset(); stuckTimer.Start();
                                while (critterUnit.IsAlive && stuckTimer.ElapsedMilliseconds <= 10000 && !Me.Combat)
                                {
                                    critterUnit.Interact(); TreeRoot.StatusText = Name + ": slay " + critterUnit.Name;
                                }
                                stuckTimer.Stop();

                                if (stuckTimer.ElapsedMilliseconds >= 10000)
                                {
                                    Blacklist.Add(critterUnit.Guid, new TimeSpan(0, 5, 0));
                                    moveBack = true; achievementFound = false; Me.ClearTarget();
                                    slog("we stuck! Blacklist Name: {0} / GuId: {1}", critterUnit.Name, critterUnit.Guid);
                                    TreeRoot.StatusText = Name + " we stuck! Blacklist Name: " + Name + " / GuId: " + critterUnit.Guid.ToString();
                                }
                                else
                                {
                                    //updateList(false);
                                    killAchievement.Remove(critterUnit.Name);
                                    moveBack         = true;
                                    achievementFound = false;
                                }
                            }
                        }
                    }
                    #endregion

                    #region back to retreat position
                    while (moveBack && !Me.Combat && backPoint != WoWPoint.Empty && !achievementFound && !Me.OnTaxi)
                    {
                        if (!IsOutdoors())
                        {
                            slog("Move back to retreat position: " + backPoint.ToString() + " / Distance: " + (int)backPoint.Distance(Me.Location) + "yards");
                            stuckTimer.Reset(); stuckTimer.Start();
                            while (Me.Location.Distance(backPoint) >= 5 && !Me.Combat && stuckTimer.ElapsedMilliseconds <= (retreatTime))
                            {
                                TreeRoot.StatusText = (Name + ": Move back to retreat. Distance: " + (double)backPoint.Distance(Me.Location) + "yards");
                                Navigator.MoveTo(backPoint);
                                Thread.Sleep(100);
                            }
                            stuckTimer.Stop();
                            WoWMovement.MoveStop();

                            if (Me.Combat)
                            {
                                return;
                            }
                            if (stuckTimer.ElapsedMilliseconds >= (retreatTime))
                            {
                                slog("sorry we stuck... logout...  :("); Thread.Sleep(2000); RunMakro("/logout"); Thread.Sleep(21000);
                            }
                        }
                        backPoint = WoWPoint.Empty; moveBack = false;
                    }
                    #endregion

                    if (moveBack && backPoint == WoWPoint.Empty)
                    {
                        moveBack = false;
                    }
                    //Logging.WriteDebug(Name + " Achievement done or blacklist!");
                }
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// SetTotemsAsNeeded() - manages casting totems as called for by environment and
        /// user configuration values. This code uses:
        ///     http://www.yawb.info/2009/08/25/learning-about-totems-tips-to-aid-your-growing-shamanism/
        /// as a guideline for totem usage while leveling.
        /// </summary>
        private bool SetTotemsAsNeeded()
        {
            bool castTotem = false;

            try
            {
                if (!_me.Fleeing && (Shaman.cfg.FarmingLowLevel || _me.IsMoving))
                {
                    return(false);
                }

                // limit how frequently we check totems.  needs to be often,
                // .. but not each loop.
                // ..
                if (_TotemCheckTimer.ElapsedMilliseconds < 1500)
                {
                    // if this isn't first time here since reset, then wait for 2 seconds
                    if (!_me.Fleeing && _TotemCheckTimer.ElapsedMilliseconds > 0 && TotemsWereSet())
                    {
                        return(false);
                    }

                    // otherwise, only 0 if first check after last .Reset
                    //  ..  so continue processing
                }

                if (TotemsWereSet() && _ptTotems.Distance(_me.Location) > Shaman.cfg.DistanceForTotemRecall)
                {
                    Shaman.Dlog("Recalling Totems that were set {0:F1} yds away at point {1}", _ptTotems.Distance(_me.Location), _ptTotems.ToString());
                    RecallTotemsForMana();
                }

                _TotemCheckTimer.Reset();
                _TotemCheckTimer.Start();

                //-----
                // if you make it past the following gate, only limited tests are needed for each totem
                //-----
                if (IsPVP() || Shaman.IsRAF())
                {
                    ;
                }
                else if (Shaman.IsFightStressful() || !Shaman.cfg.PVE_SaveForStress_TotemsSelected)
                {
                    ;
                }
                else
                {
                    Shaman.Dlog("not setting totems until a stressful situation");
                    return(false);
                }

                // check which totems exist
                bool bAnyTotemsUp = TotemExist(TOTEM_EARTH) ||
                                    TotemExist(TOTEM_FIRE) ||
                                    TotemExist(TOTEM_WATER) ||
                                    TotemExist(TOTEM_AIR);

                Shaman.Dlog("SetTotemsAsNeeded:  earth: " + BoolToYN(TotemExist(TOTEM_EARTH)) + "  fire: " + BoolToYN(TotemExist(TOTEM_FIRE)) + "  water: " + BoolToYN(TotemExist(TOTEM_WATER)) + "  air: " + BoolToYN(TotemExist(TOTEM_AIR)));

                _WereTotemsSet = bAnyTotemsUp;  // _WereTotemsSet || removed because only matters if they exist

                // Quick scan for mobs that cast fear (only in RAF)
                //////////////////////////////////////////////////////////////////////
                Shaman.foundMobsThatFear = _me.Fleeing;
                if (Shaman.foundMobsThatFear)
                {
                    Shaman.Slog("Tremor Totem:  detected fear mob");
                }

                // Totem Bar Set
                // -- add handling for changing totem bar setup temporarily if needed for tremor totem
                //////////////////////////////////////////////////////////////////////
                const string totemBar = "Call of the Elements";
                if (!bAnyTotemsUp && SpellManager.HasSpell(totemBar))
                {
                    TotemId saveEarthTotemSetup = TotemId.TREMOR_TOTEM;

                    // if mobs that fear are found and tremor not in bar setup already, add temporarily just for cast
                    if (Shaman.foundMobsThatFear && _totemBar[TOTEM_EARTH] != TotemId.TREMOR_TOTEM)
                    {
                        saveEarthTotemSetup = _totemBar[TOTEM_EARTH];
                        TotemSelect(TOTEM_EARTH, TotemId.TREMOR_TOTEM);
                    }

                    if (Shaman.Safe_CastSpell(totemBar, Shaman.SpellRange.NoCheck, Shaman.SpellWait.Complete))
                    {
                        castTotem      = true;
                        _WereTotemsSet = true;
                        _ptTotems      = _me.Location;

                        if (IsRAF())
                        {
                            Dlog("SetTotemsAsNeeded: set totems at <{0}> {1:F1} yds from Leader", _ptTotems.ToString(), GroupTank.Distance);
                        }
                        else
                        {
                            Dlog("SetTotemsAsNeeded: set totems at <{0}>", _ptTotems.ToString());
                        }
                    }

                    // if we changed the earth totem on bar, restore back to configured value
                    if (saveEarthTotemSetup != TotemId.TREMOR_TOTEM)
                    {
                        TotemSelect(TOTEM_EARTH, saveEarthTotemSetup);
                    }
                }
                else
                {
                    // Earth Totems First
                    //////////////////////////////////////////////////////////////////////
                    if (foundMobsThatFear && HasTotemSpell(TotemId.TREMOR_TOTEM) && TotemId.TREMOR_TOTEM != (TotemId)_totem[TOTEM_EARTH].CreatedBySpellId)
                    {
                        castTotem = castTotem || TotemCast(TotemId.TREMOR_TOTEM);
                    }
                    else if (0 != _totemBar[TOTEM_EARTH])
                    {
                        if (!TotemExist(TOTEM_EARTH) && HasTotemSpell(_totemBar[TOTEM_EARTH]))
                        {
                            castTotem = castTotem || TotemCast(_totemBar[TOTEM_EARTH]);
                        }

                        if (!TotemExist(TOTEM_EARTH) && Shaman.typeShaman == Shaman.ShamanType.Enhance && HasTotemSpell(TotemId.STRENGTH_OF_EARTH_TOTEM))
                        {
                            castTotem = castTotem || TotemCast(TotemId.STRENGTH_OF_EARTH_TOTEM);
                        }

                        if (!TotemExist(TOTEM_EARTH) && Shaman.typeShaman != Shaman.ShamanType.Enhance && HasTotemSpell(TotemId.STONESKIN_TOTEM))
                        {
                            castTotem = castTotem || TotemCast(TotemId.STONESKIN_TOTEM);
                        }
                    }

                    // Fire Totems
                    //////////////////////////////////////////////////////////////////////
                    if (_countMeleeEnemy >= 3 && !IsHealerOnly())
                    {
                        if (!_me.GotTarget || !IsImmunneToFire(_me.CurrentTarget))
                        {
                            if (!TotemExist(TOTEM_FIRE) || (!TotemExist(TotemId.MAGMA_TOTEM) && !TotemExist(TotemId.FIRE_ELEMENTAL_TOTEM)))
                            {
                                if (HasTotemSpell(TotemId.MAGMA_TOTEM))
                                {
                                    castTotem = castTotem || TotemCast(TotemId.MAGMA_TOTEM);
                                }
                                else if (_countMeleeEnemy >= 4 && HasTotemSpell(TotemId.FLAMETONGUE_TOTEM) && !TotemExist(TotemId.FLAMETONGUE_TOTEM))
                                {
                                    Dlog("SetTotemsAsNeeded: 4 or more mobs and Magma not trained, using Flametongue to allow Fire Nova");
                                    castTotem = castTotem || TotemCast(TotemId.FLAMETONGUE_TOTEM);
                                }
                            }
                        }
                    }

                    if (0 != _totemBar[TOTEM_FIRE] && !TotemExist(TOTEM_FIRE))
                    {
                        if (!TotemExist(TOTEM_FIRE) && HasTotemSpell(_totemBar[TOTEM_FIRE]))
                        {
                            castTotem = castTotem || TotemCast(_totemBar[TOTEM_FIRE]);
                        }
                        if (!TotemExist(TOTEM_FIRE) && Shaman.typeShaman != Shaman.ShamanType.Resto && HasTotemSpell(TotemId.SEARING_TOTEM))
                        {
                            castTotem = castTotem || TotemCast(TotemId.SEARING_TOTEM);
                        }
                        if (!TotemExist(TOTEM_FIRE) && HasTotemSpell(TotemId.FLAMETONGUE_TOTEM))
                        {
                            castTotem = castTotem || TotemCast(TotemId.FLAMETONGUE_TOTEM);
                        }
                    }

                    // Water Totems
                    //////////////////////////////////////////////////////////////////////
                    if (0 != _totemBar[TOTEM_WATER])
                    {
                        if (!TotemExist(TOTEM_WATER) && HasTotemSpell(_totemBar[TOTEM_WATER]))
                        {
                            castTotem = castTotem || TotemCast(_totemBar[TOTEM_WATER]);
                        }

                        if (!TotemExist(TOTEM_WATER) && HasTotemSpell(TotemId.MANA_SPRING_TOTEM))
                        {
                            castTotem = castTotem || TotemCast(TotemId.MANA_SPRING_TOTEM);
                        }
                    }

                    // Air Totems
                    //////////////////////////////////////////////////////////////////////
                    if (0 != _totemBar[TOTEM_AIR])
                    {
                        if (!TotemExist(TOTEM_AIR) && HasTotemSpell(_totemBar[TOTEM_WATER]))
                        {
                            castTotem = castTotem || TotemCast(_totemBar[TOTEM_AIR]);
                        }
                        if (!TotemExist(TOTEM_AIR) && Shaman.typeShaman == Shaman.ShamanType.Resto && HasTotemSpell(TotemId.GROUNDING_TOTEM))
                        {
                            castTotem = castTotem || TotemCast(TotemId.GROUNDING_TOTEM);
                        }
                        if (!TotemExist(TOTEM_AIR) && Shaman.typeShaman == Shaman.ShamanType.Enhance && HasTotemSpell(TotemId.WINDFURY_TOTEM))
                        {
                            castTotem = castTotem || TotemCast(TotemId.WINDFURY_TOTEM);
                        }
                        if (!TotemExist(TOTEM_AIR) && Shaman.typeShaman == Shaman.ShamanType.Elemental && HasTotemSpell(TotemId.WRATH_OF_AIR_TOTEM))
                        {
                            castTotem = castTotem || TotemCast(TotemId.WRATH_OF_AIR_TOTEM);
                        }
                    }

                    _WereTotemsSet = _WereTotemsSet || TotemExist(TOTEM_EARTH) || TotemExist(TOTEM_FIRE) || TotemExist(TOTEM_WATER) || TotemExist(TOTEM_AIR);

                    if (!bAnyTotemsUp && _WereTotemsSet)
                    {
                        _ptTotems = _me.Location;
                    }
                }
            }
            catch (ThreadAbortException) { throw; }
            catch (Exception e)
            {
                Log(Color.Red, "An Exception occured. Check debug log for details.");
                Logging.WriteDebug("HB EXCEPTION in SetTotemsAsNeeded()");
                Logging.WriteException(e);
            }

            // would like to remove this code, but seeing duplicate totem sets
            if (castTotem)
            {
                ObjectManager.Update();
                TotemManagerUpdate();
            }

            return(castTotem);
        }
Ejemplo n.º 17
0
        private static WoWPoint findSafeFlightPoint(WoWPoint loc)
        {
            #region If multiple layers (heights), attempt to land somewhere nearby
            var _heights = Logic.Pathing.Navigator.FindHeights(loc.X, loc.Y);
            _heights.Sort();
            if (_heights.Count() > 1)
            {
                Random rand = new Random();
                var i = 1;
                var _newSpot = new WoWPoint(0, 0, 0);
                while (i < 100)
                {
                    _newSpot = new WoWPoint((loc.X + rand.Next(-i, i)), (loc.Y + rand.Next(-i, i)), 0);
                    while (Logic.Pathing.Navigator.FindHeights(_newSpot.X, _newSpot.Y).Count() > 1)
                    {
                        _newSpot = new WoWPoint((loc.X + rand.Next(-i, i)), (loc.Y + rand.Next(-i, i)), 0);
                        i = i + 1;
                    }
                    Logic.Pathing.Navigator.FindHeight(_newSpot.X, _newSpot.Y, out _newSpot.Z);
                    if (Navigator.CanNavigateFully(_newSpot, loc) && clearSpot(_newSpot))
                    {
                        Log("Took {0} tries to find a safe(?) spot!", i);
                        Log("Landing spot: {0}", _newSpot.ToString());
                        return _newSpot;
                    }
                }
                Log("No safe spot found :(");
                return loc;
            }
            #endregion

            #region If 1 layer, but no LOS from above, attempt to land somewhere nearby
            else if (!WoWInternals.World.GameWorld.IsInLineOfSightOCD(new WoWPoint(loc.X, loc.Y, loc.Z+50), loc))
            {
                Random rand = new Random();
                var i = 1;
                var _newSpot = new WoWPoint(0, 0, 0);
                while (i < 100)
                {
                    _newSpot = new WoWPoint((loc.X + rand.Next(-i, i)), (loc.Y + rand.Next(-i, i)), 0);
                    i = i + 1;
                    Logic.Pathing.Navigator.FindHeight(_newSpot.X, _newSpot.Y, out _newSpot.Z);
                    if (Navigator.CanNavigateFully(_newSpot, loc) && clearSpot(_newSpot))
                    {
                        Log("Took {0} tries to find a safe(?) spot!", i);
                        Log("Landing point: {0}", _newSpot.ToString());
                        return _newSpot;
                    }
                }
                Log("No safe spot found :(");
                return loc;
            }
            #endregion
            else
            {
                return loc;
            }
        }
Ejemplo n.º 18
0
        public async Task <bool> MoveTo(bool allowDequeue = true)
        {
            if (CurrentMovementQueue.Count == 0)
            {
                return(false);
            }

            WoWPoint location        = CurrentLocation;
            WoWPoint playerPos       = Player.Location;
            float    currentDistance = location.Distance(playerPos);

            if (currentDistance <= Distance)
            {
                if (allowDequeue)
                {
                    Log("MoveTo", String.Format("has dequeued location - {0}", location.ToString()));

                    DequeuedPoints.Enqueue(CurrentMovementQueue.Dequeue());
                    DequeuedFinalPlayerPositionPoints.Add(playerPos);
                }

                if (CurrentMovementQueue.Count == 0 || CurrentMovementQueue.Count == 1 && !allowDequeue)
                {
                    Log("MoveTo", "is finished");
                    WoWMovement.MoveStop();
                    return(false);
                }

                return(true);
            }

            if (!IgnoreTaxiCheck && !_checkedShoulUseFlightPath)
            {
                _checkedShoulUseFlightPath = true;
                if (TaxiFlightHelper.ShouldTakeFlightPath(location))
                {
                    if (BehaviorManager.SwitchBehaviors.All(b => b.Type != BehaviorType.Taxi))
                    {
                        BehaviorManager.SwitchBehaviors.Add(new BehaviorUseFlightPath(location));
                    }

                    return(true);
                }
            }

            if (!_didResetStuckChecker)
            {
                StuckChecker.Reset();
                _didResetStuckChecker = true;
            }
            else if (_checkStuck)
            {
                if (StuckChecker.CheckStuck())
                {
                    Log("MoveTo", "Stuck Checker returned true!");
                    return(false);
                }
            }


            if (!CheckCanNavigate())
            {
                Log("MoveTo", "Can Navigate Return False " + location.ToString());
                return(false);
            }

            //if (StyxWoW.Me.IsMoving)
            //    return true;

            var moveresult = MoveResult.Moved;

            try
            {
                moveresult = await CommonCoroutines.MoveTo(location);
            }
            catch (Exception ex)
            {
                Navigator.Clear();
                Log("MoveTo", "Exception during movement attempt! " + location.ToString());

                try
                {
                    Navigator.MoveTo(location);
                }
                catch
                {
                    Log("MoveTo", "Double Exception during movement attempt!! " + location.ToString());
                    return(false);
                }
            }


            //Navigator.GetRunStatusFromMoveResult(moveresult);
            switch (moveresult)
            {
            case MoveResult.UnstuckAttempt:
                Log("MoveTo", "MoveResult: UnstuckAttempt " + location.ToString());
                await Buddy.Coroutines.Coroutine.Sleep(500);

                break;

            case MoveResult.Failed:
                Log("MoveTo", "MoveResult: Failed " + location.ToString());
                return(false);

            case MoveResult.ReachedDestination:
                Log("MoveTo", "MoveResult: ReachedDestination " + location.ToString());
                return(true);
            }

            if (MovementCache.ShouldRecord)
            {
                MovementCache.AddPosition(playerPos, Distance);
            }

            return(true);
        }
Ejemplo n.º 19
0
 private string GetDefaultName(WoWPoint wowPoint)
 {
     return(string.Format("Waypoint({0})", wowPoint.ToString()));
 }
Ejemplo n.º 20
0
        /// <summary>
        /// Uses the transport.
        /// </summary>
        /// <param name="transportId">The transport identifier.</param>
        /// <param name="transportStartLoc">The start location.</param>
        /// <param name="transportEndLoc">The end location.</param>
        /// <param name="waitAtLoc">The wait at location.</param>
        /// <param name="boardAtLoc">The stand at location.</param>
        /// <param name="getOffLoc">The get off location.</param>
        /// <param name="movement">The movement.</param>
        /// <param name="destination">The destination.</param>
        /// <param name="navigationFailedAction">
        ///     The action to take if <paramref name="waitAtLoc" /> cant be navigated to
        /// </param>
        /// <returns>returns <c>true</c> until done</returns>
        /// <exception cref="Exception">A delegate callback throws an exception. </exception>
        public static async Task <bool> UseTransport(
            int transportId,
            WoWPoint transportStartLoc,
            WoWPoint transportEndLoc,
            WoWPoint waitAtLoc,
            WoWPoint boardAtLoc,
            WoWPoint getOffLoc,
            MovementByType movement       = MovementByType.FlightorPreferred,
            string destination            = null,
            Action navigationFailedAction = null)
        {
            if (getOffLoc != WoWPoint.Empty && Me.Location.DistanceSqr(getOffLoc) < 2 * 2)
            {
                return(false);
            }

            var transportLocation = GetTransportLocation(transportId);

            if (transportLocation != WoWPoint.Empty &&
                transportLocation.DistanceSqr(transportStartLoc) < 1.5 * 1.5 &&
                waitAtLoc.DistanceSqr(Me.Location) < 2 * 2)
            {
                TreeRoot.StatusText = "Moving inside transport";
                Navigator.PlayerMover.MoveTowards(boardAtLoc);
                await CommonCoroutines.SleepForLagDuration();

                // wait for bot to get on boat.
                await Coroutine.Wait(12000, () => !Me.IsMoving || Navigator.AtLocation(boardAtLoc));
            }

            // loop while on transport to prevent bot from doing anything else
            while (Me.Transport != null && Me.Transport.Entry == transportId)
            {
                if (transportLocation != WoWPoint.Empty && transportLocation.DistanceSqr(transportEndLoc) < 1.5 * 1.5)
                {
                    TreeRoot.StatusText = "Moving out of transport";
                    Navigator.PlayerMover.MoveTowards(getOffLoc);
                    await CommonCoroutines.SleepForLagDuration();

                    // Sleep until we stop moving.
                    await Coroutine.Wait(12000, () => !Me.IsMoving || Navigator.AtLocation(getOffLoc));

                    return(true);
                }

                // Exit loop if in combat or dead.
                if (Me.Combat || !Me.IsAlive)
                {
                    return(false);
                }

                TreeRoot.StatusText = "Waiting for the end location";
                await Coroutine.Yield();

                // update transport location.
                transportLocation = GetTransportLocation(transportId);
            }

            if (waitAtLoc.DistanceSqr(Me.Location) > 2 * 2)
            {
                if (!await MoveTo(waitAtLoc, destination ?? waitAtLoc.ToString(), movement))
                {
                    if (navigationFailedAction != null)
                    {
                        navigationFailedAction();
                    }
                }
                return(true);
            }
            await CommonCoroutines.LandAndDismount();

            TreeRoot.StatusText = "Waiting for transport";
            return(true);
        }