Esempio 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);
        }
Esempio n. 2
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);
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
        public Building(int id)
        {
            Id    = id;
            Type  = GetBuildingTypeUsingId(Id);
            Level = GetBuildingUpgradeLevel(Id);
            Plot  = GetBuildingPlotSize(Type);
            HasFollowerWorking = GarrisonManager.BuildingIdsWithFollowerWorking.Contains(Id);

            WorkOrderType = WorkOrder.GetWorkorderType(Type);

            if (WorkOrderType != WorkOrderType.None)
            {
                WorkOrderObjectEntryId = WorkOrder.WorkOrderPickupEntryIds[WorkOrderType];
                WorkOrderObjectName    = WorkOrder.WorkOrderPickupNames[WorkOrderType];
                if (WorkOrderType == WorkOrderType.WarMillDwarvenBunker && Player.IsAlliance)
                {
                    WorkOrderObjectName = WorkOrder.WorkOrderPickupNames[WorkOrderType.DwarvenBunker];
                }
            }
            else
            {
                WorkOrderObjectEntryId = -1;
                WorkOrderObjectName    = String.Empty;
            }

            WorkOrderNpcEntryId = WorkOrder.GetWorkOrderNpcEntryId(Type, Player.IsAlliance);


            if (GarrisonManager.BuildingIDs.Contains(Id))
            {
                string plotid;
                bool   canActivate, isBuilding;
                int    shipTotal, shipCap, shipReady;

                LuaCommands.GetBuildingInfo(id, out plotid, out canActivate, out shipCap, out shipReady, out shipTotal, out isBuilding);
                if (WorkOrderType != WorkOrderType.None)
                {
                    _workorder = new WorkOrder(Id, Type, WorkOrderType, shipCap,
                                               WorkOrder.GetWorkOrderItemAndQuanityRequired(WorkOrderType), shipReady, shipTotal);
                }

                PlotId      = plotid.ToInt32();
                CanActivate = canActivate;
                IsBuilding  = isBuilding;

                SafeMovementPoint     = MovementCache.GetBuildingSafeMovementPoint(PlotId);
                EntranceMovementPoint = MovementCache.GetBuildingEntranceMovementPoint(PlotId);
            }
            else if (Type == BuildingType.HerbGarden || Type == BuildingType.Mines)
            {//if not completed first quest than we must insert temp info.
                PlotId                = Type == BuildingType.HerbGarden ? 63 : 59;
                SafeMovementPoint     = MovementCache.GetBuildingSafeMovementPoint(PlotId);
                EntranceMovementPoint = MovementCache.GetBuildingEntranceMovementPoint(PlotId);
                _workorder            = new WorkOrder(Id, Type, WorkOrderType, 0,
                                                      WorkOrder.GetWorkOrderItemAndQuanityRequired(WorkOrderType));
            }

            SpecialMovementPoints = MovementCache.GetSpecialMovementPoints(Type, PlotId, Level, Player.IsAlliance);

            int firstquestID = GetBuildingFirstQuestId(Type, Player.IsAlliance);

            if (firstquestID > 0)
            {
                FirstQuestId        = Convert.ToUInt32(firstquestID);
                FirstQuestCompleted = LuaCommands.IsQuestFlaggedCompleted(FirstQuestId.ToString());

                if (Type == BuildingType.TradingPost)
                {
                    FirstQuestNpcId = WorkOrderNpcEntryId;
                }
                else
                {
                    FirstQuestNpcId = GetBuildingFirstQuestNpcId(Type, Player.IsAlliance);
                }
            }
            else
            {
                FirstQuestId        = 0;
                FirstQuestNpcId     = 0;
                FirstQuestCompleted = true;
            }
        }