Exemplo n.º 1
0
        internal static void InstallButtons()
        {
            Window mainWindow;

            Application.Current.Dispatcher.Invoke(
                () =>
            {
                try
                {
                    mainWindow = Application.Current.MainWindow;
                    var tabs   = mainWindow.FindName("tabControlMain") as TabControl;
                    if (tabs == null)
                    {
                        return;
                    }
                    var mainTab  = (TabItem)tabs.Items[0];
                    _mainTabGrid = (Grid)mainTab.Content;
                    if (_configureAdventurerButton == null)
                    {
                        //_toggleAdventurerStateButton = CreateToggleButton();
                        _configureAdventurerButton = CreateConfigureButton();
                        //_mainTabGrid.Children.Add(_toggleAdventurerStateButton);
                        _mainTabGrid.Children.Add(_configureAdventurerButton);
                    }
                }
                catch (Exception ex)
                {
                    Logger.Error("[MainUI][InstallButtons] " + ex.Message);
                }
            });
        }
Exemplo n.º 2
0
        private bool NotStarted()
        {
            State = States.Clearing;

            _currentDestination = ActorFinder.FindNearestHostileUnitInRadius(_center, _radius);
            if (_currentDestination == Vector3.Zero && !_forceMoveAround)
            {
                State = States.Completed;
                return(false);
            }

            if (_forceMoveAround)
            {
                // Desperate Measures
                _forceClearDestinations =
                    new ConcurrentBag <Vector3>(
                        ExplorationHelpers.GetFourPointsInEachDirection(_center, _radius).Where(d => d != Vector3.Zero));
                Logger.Debug("[ClearArea] No actors found in the area, using the desperate measures.");
                State = States.ForceClearing;
                if (_forceClearDestinations.TryTake(out _currentDestination))
                {
                    return(false);
                }
                Logger.Error("[ClearArea] Couldn't get force clear destinations, ending tag.");
                State = States.Completed;
                return(true);
            }


            return(false);
        }
Exemplo n.º 3
0
 private void CreateGrid()
 {
     if (InnerGrid == null)
     {
         Logger.Debug("[{0}] Creating grid [{1},{1}]", GetType().Name, GridBounds);
         InnerGrid = new GridNode[GridBounds, GridBounds];
     }
 }
        private async Task <bool> Failed()
        {
            Logger.Log(LogLevel.Overlay, "[ActBounties] Failed to completed {0} bounties", _act);
            _isDone = true;
            await Coroutine.Sleep(1000);

            return(true);
        }
        private async Task <bool> Completed()
        {
            Logger.Log(LogLevel.Overlay, "[ActBounties] Successfully completed {0} bounties", _act);
            _isDone = true;
            await Coroutine.Sleep(4000);

            return(true);
        }
Exemplo n.º 6
0
 private void EnablePulse()
 {
     if (!_isPulsing)
     {
         Logger.Debug("[GuardedGizmo] Registered to pulsator.");
         Pulsator.OnPulse += OnPulse;
         _isPulsing        = true;
     }
 }
Exemplo n.º 7
0
 public void DisablePulse()
 {
     if (_isPulsing)
     {
         Logger.Debug("[GuardedGizmo] Unregistered from pulsator.");
         Pulsator.OnPulse -= OnPulse;
         _isPulsing        = false;
     }
 }
Exemplo n.º 8
0
        private KeywardenData GetNext()
        {
            Logger.Info("[Keywarden] Current Machine Counts");
            Logger.Info("[Keywarden] Act 1: {0}", KeywardenDataFactory.Items[Act.A1].MachinesCount);
            Logger.Info("[Keywarden] Act 2: {0}", KeywardenDataFactory.Items[Act.A2].MachinesCount);
            Logger.Info("[Keywarden] Act 3: {0}", KeywardenDataFactory.Items[Act.A3].MachinesCount);
            Logger.Info("[Keywarden] Act 4: {0}", KeywardenDataFactory.Items[Act.A4].MachinesCount);
            var averageMachinesCount = KeywardenDataFactory.Items.Values.Average(kwd => kwd.MachinesCount);

            return(KeywardenDataFactory.Items.Values.OrderBy(kwd => kwd.MachinesCount).FirstOrDefault(kwd => kwd.IsAlive && kwd.MachinesCount <= averageMachinesCount + 1));
        }
Exemplo n.º 9
0
        private async Task <bool> UsingWaypoint()
        {
            if (!_usedWaypoint)
            {
                Logger.Debug("[Waypoint] Using waypoint {0}", _waypointNumber);
                // Checking for near by waypoint gizmos.
                var gizmoWaypoint =
                    ZetaDia.Actors.GetActorsOfType <GizmoWaypoint>().OrderBy(g => g.Distance).FirstOrDefault();
                if (gizmoWaypoint != null && gizmoWaypoint.IsFullyValid())
                {
                    // Already there
                    if (gizmoWaypoint.WaypointNumber == _waypointNumber && gizmoWaypoint.Distance <= 150)
                    {
                        Logger.Info("[Waypoint] Already near the destination waypoint");
                        State = States.Completed;
                        return(false);
                    }

                    // To far away to interact
                    if (gizmoWaypoint.Distance < 10)
                    {
                        _usedWaypoint = true;
                        gizmoWaypoint.UseWaypoint(_waypointNumber);
                    }
                    else
                    {
                        gizmoWaypoint = null;
                    }
                }
                if (gizmoWaypoint == null)
                {
                    _usedWaypoint = true;
                    ZetaDia.Me.UseWaypoint(_waypointNumber);
                }
            }
            await Coroutine.Sleep(2000);

            if (UIElements.WaypointMap.IsVisible)
            {
                UIManager.ToggleWaypointMap();
            }
            await Coroutine.Sleep(1000);

            State = States.UsedWaypoint;
            return(false);
        }
Exemplo n.º 10
0
        public Vector3 FindNearestHostileUnitLocation()
        {
            if (!HostileSearchTimer.IsFinished)
            {
                return(_hostileLocation);
            }
            HostileSearchTimer.Stop();
            var actor = ZetaDia.Actors.GetActorsOfType <DiaUnit>(true).Where(o => o.IsValid && o.CommonData != null && o.CommonData.IsValid && o.IsAlive && o.CommonData.MinimapVisibilityFlags != 0).OrderBy(o => o.Distance).FirstOrDefault();

            HostileSearchTimer.Reset();

            if (actor == null)
            {
                return(Vector3.Zero);
            }
            Logger.Debug("[ClearLevelArea] Found a hostile unit {0} at {1} distance", ((SNOActor)actor.ActorSnoId).ToString(), actor.Distance);
            return(actor.Position);
        }
Exemplo n.º 11
0
 internal static void RemoveButtons()
 {
     Application.Current.Dispatcher.Invoke(
         () =>
     {
         try
         {
             if (_configureAdventurerButton != null)
             {
                 _configureAdventurerButton.Visibility = Visibility.Collapsed;
             }
         }
         catch (Exception ex)
         {
             Logger.Error("[MainUI][RemoveButtons] " + ex.Message);
         }
     });
 }
        private async Task <bool> NotStarted()
        {
            await Coroutine.Sleep(1000);

            if (!BountyHelpers.IsActTurninInProgress(_act))
            {
                State = States.AlreadyDone;
                return(false);
            }

            if (IsInZone)
            {
                State = States.TownRun;
                return(false);
            }
            State = States.ReturningToTown;
            Logger.Info("[CompleteActBounties] Time to return to the town and claim our prize, huzzah!");
            return(false);
        }
Exemplo n.º 13
0
        private static void Configure_Click(object sender, RoutedEventArgs e)
        {
            var instance = ConfigWindow.Instance;

            if (instance != null)
            {
                Application.Current.Dispatcher.Invoke(() =>
                {
                    try
                    {
                        instance.ShowDialog();
                    }
                    catch (Exception ex)
                    {
                        Logger.Error("[MainUI][Configure] " + ex.Message);
                    }
                });
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Calculates Canvas position with a given game world position
        /// </summary>
        public void Update(Vector3 position)
        {
            try
            {
                WorldVector = position;

                var centerActorPosition = CanvasData.CenterVector;

                // Distance from Actor to Player
                RawWorldDistanceX = centerActorPosition.X - position.X;
                RawWorldDistanceY = centerActorPosition.Y - position.Y;

                // We want 1 yard of game distance to = Gridsize
                RawDrawDistanceX = RawWorldDistanceX * (float)CanvasData.GridSquareSize.Width;
                RawDrawDistanceY = RawWorldDistanceY * (float)CanvasData.GridSquareSize.Height;

                // Distance on canvas from center to actor
                RawDrawPositionX = (CanvasData.Center.X + RawDrawDistanceX);
                RawDrawPositionY = (CanvasData.Center.Y + RawDrawDistanceY);

                // Points in Canvas and Grid Scale
                RawPoint     = new Point(RawDrawPositionX, RawDrawPositionY);
                RawGridPoint = new Point(RawDrawPositionX / CanvasData.GridSquareSize.Width, RawDrawPositionY / CanvasData.GridSquareSize.Height);

                // Switched to manual calculations because WPF transforms are very slow
                // (0.0015ms+ each versus 0.0000ms for raw math).
                Point = RawPoint.Rotate(CanvasData.Center, CanvasData.GobalRotationAngle);
                Point = Point.FlipX(CanvasData.Center);

                GridPoint      = new Point((int)(Point.X / CanvasData.GridSquareSize.Width), (int)(Point.Y / CanvasData.GridSquareSize.Height));
                IsBeyondCanvas = Point.X <0 || Point.X> CanvasData.CanvasSize.Width || Point.Y <0 || Point.Y> CanvasData.CanvasSize.Height;
            }
            catch (Exception ex)
            {
                Logger.Debug("Exception in RadarUI.PointMorph.Update(). {0} {1}", ex.Message, ex.InnerException);
            }
        }
Exemplo n.º 15
0
        private async Task <bool> MovingToGizmo()
        {
            if (PluginSettings.Current.BountyZerg)
            {
                SafeZerg.Instance.EnableZerg();
            }
            EnablePulse();
            if (_currentGizmo == null)
            {
                State = States.SearchingForGizmo;
                return(false);
            }
            if (!await NavigationCoroutine.MoveTo(_currentGizmo.Position, _currentGizmo.InteractDistance))
            {
                return(false);
            }
            if (NavigationCoroutine.LastResult == CoroutineResult.Failure && AdvDia.MyPosition.Distance(_currentGizmo.Position) > _currentGizmo.InteractDistance + 20)
            {
                ObjectSearchRadius = 150;
                _guardedGizmos.Remove(_currentGizmo.Position);
                Logger.Info("[Bounty] Gizmo is out of reach, lowering the search radius to {0}", ObjectSearchRadius);
                State = States.SearchingForGizmo;
                return(false);
            }
            var gizmo =
                ZetaDia.Actors.GetActorsOfType <DiaGizmo>(true)
                .FirstOrDefault(g => g.ActorSNO == GizmoSNO && g.Position.Distance2D(_currentGizmo.Position) < 5);

            if (gizmo == null)
            {
                _currentGizmo.HasBeenOperated = true;
                State = States.SearchingForGizmo;
                return(false);
            }
            State = States.PreClearingGizmoArea;
            return(false);
        }
Exemplo n.º 16
0
        public override void OnStart()
        {
            if (!Adventurer.Enabled)
            {
                Logger.Error("Plugin is not enabled. Please enable Adventurer and try again.");
                _isDone = true;
                return;
            }

            PluginEvents.CurrentProfileType = ProfileType.Keywarden;
            if (_keywardenCoroutine == null)
            {
                var keywardenData = GetNext();
                if (keywardenData != null)
                {
                    _keywardenCoroutine = new KeywardenCoroutine(keywardenData);
                }
                else
                {
                    Logger.Info("[Keywardens] Uhm. No eligible keywardens to cook, remaking the game.");
                    _isDone = true;
                }
            }
        }
 private async Task <bool> InteractingWithTyrael()
 {
     if (await _interactionCoroutine.GetCoroutine())
     {
         if (!ZetaDia.ActInfo.AllQuests.Any(q => q.Quest == BountyHelpers.ActBountyFinishingQuests[_act] && q.State == QuestState.InProgress))
         {
             State = States.Completed;
             return(false);
         }
         var tyrael = ActorFinder.FindUnit(TYRAEL);
         if (tyrael == null)
         {
             Logger.Error("[CompleteActBounties] Couldn't detect Tyrael. Failing");
             State = States.Failed;
             return(false);
         }
         if (tyrael.IsFullyValid() && tyrael.CommonData.MarkerType == MarkerType.Exclamation)
         {
             return(false);
         }
         State = States.Completed;
     }
     return(false);
 }
 private bool AlreadyDone()
 {
     Logger.Debug("[CompleteActBounties] No active act {0} bounty finishing quest", _act);
     return(true);
 }