コード例 #1
0
        private void ScanForBoss()
        {
            var portalMarker = AdvDia.CurrentWorldMarkers.FirstOrDefault(m => m.Id >= 0 && m.Id <= 200);

            if (portalMarker != null)
            {
                _bossLocation = portalMarker.Position;
            }
            if (_bossLocation == Vector3.Zero)
            {
                var boss =
                    ZetaDia.Actors.GetActorsOfType <DiaUnit>()
                    .FirstOrDefault(a => a.IsFullyValid() && a.CommonData.IsUnique);
                if (boss != null)
                {
                    if (boss.IsAlive)
                    {
                        _bossLocation = boss.Position;
                    }
                }
            }
            if (_bossLocation != Vector3.Zero)
            {
                Logger.Info("[Rift] The Boss is near.");
                State = States.MovingToBoss;
                Logger.Debug("[Rift] Found the boss at distance {0}", AdvDia.MyPosition.Distance2D(_bossLocation));
            }
        }
コード例 #2
0
        private void ScanForObjective()
        {
            if (_previouslyFoundLocation != Vector3.Zero && PluginTime.ReadyToUse(_returnTimeForPreviousLocation, 60000))
            {
                _objectiveLocation             = _previouslyFoundLocation;
                _previouslyFoundLocation       = Vector3.Zero;
                _returnTimeForPreviousLocation = PluginTime.CurrentMillisecond;
                Logger.Debug("[EnterLevelArea] Returning previous objective location.");

                return;
            }
            if (PluginTime.ReadyToUse(_lastScanTime, 250))
            {
                _lastScanTime = PluginTime.CurrentMillisecond;
                if (_portalMarker != 0)
                {
                    _objectiveLocation = BountyHelpers.ScanForMarkerLocation(_portalMarker, _objectiveScanRange);
                }
                // Belial
                if (_objectiveLocation == Vector3.Zero && _portalActorId == 159574)
                {
                    _objectiveLocation = BountyHelpers.ScanForActorLocation(_portalActorId, _objectiveScanRange);
                }
                //if (_objectiveLocation == Vector3.Zero && _portalActorId != 0)
                //{
                //    _objectiveLocation = BountyHelpers.ScanForActorLocation(_portalActorId, _objectiveScanRange);
                //}
                if (_objectiveLocation != Vector3.Zero)
                {
                    Logger.Info("[EnterLevelArea] Found the objective at distance {0}", AdvDia.MyPosition.Distance2D(_objectiveLocation));
                }
            }
        }
コード例 #3
0
        private async Task <bool> Interacting()
        {
            //if (_interactionCoroutine.State == InteractionCoroutine.States.NotStarted)
            //{
            //    var portalGizmo = BountyHelpers.GetPortalNearMarkerPosition(_markerPosition);
            //    if (portalGizmo == null)
            //    {
            //        Logger.Debug("[Bounty] No portal nearby, keep exploring .");
            //        State = States.SearchingForDestinationWorld;
            //        return false;
            //    }
            //    _interactionCoroutine.DiaObject = portalGizmo;
            //}

            if (await _interactionCoroutine.GetCoroutine())
            {
                ActorFinder.InteractWhitelist.Remove(_actorId);
                if (_interactionCoroutine.State == InteractionCoroutine.States.TimedOut)
                {
                    Logger.Debug("[Bounty] Couldn't interact with the unit, failing.");
                    State = States.Failed;
                    return(false);
                }
                State = States.Completed;
                _interactionCoroutine = null;
                return(false);
            }
            return(false);
        }
コード例 #4
0
 private bool TownRun()
 {
     Logger.Debug("[TownRun] BrainBehavior.IsVendoring is {0}", BrainBehavior.IsVendoring);
     Logger.Debug("[TownRun] ZetaDia.Me.IsParticipatingInTieredLootRun is {0}", ZetaDia.Me.IsParticipatingInTieredLootRun);
     Logger.Debug("[TownRun] AdvDia.RiftQuest.State is {0}", AdvDia.RiftQuest.State);
     Logger.Debug("[TownRun] AdvDia.RiftQuest.Step is {0}", AdvDia.RiftQuest.Step);
     DisablePulse();
     if (BrainBehavior.IsVendoring)
     {
         return(false);
     }
     if (!_townRunInitiated)
     {
         _townRunInitiated = true;
         BrainBehavior.ForceTownrun(" We need it.", true);
         return(false);
     }
     _townRunInitiated = false;
     if (AdvDia.RiftQuest.Step == RiftStep.Completed)
     {
         State = States.WaitForRiftCountdown;
         Logger.Info("[Rift] Tick tock, tick tock...");
     }
     else
     {
         State = States.NotStarted;
         _moveToRiftStoneCoroutine.Reset();
     }
     return(false);
 }
コード例 #5
0
        private async Task <bool> Searching()
        {
            if (_objectiveLocation == Vector3.Zero)
            {
                ScanForObjective();
            }
            if (_objectiveLocation != Vector3.Zero)
            {
                // Special case for cursed chest events.
                if (_objectiveLocation.Distance(AdvDia.MyPosition) < 16f && _actorId == 365097 && ActorFinder.FindGizmo(364559) != null)
                {
                    Logger.Debug("Target gizmo has transformed into invulnerable event gizmo. Ending.");
                    State = States.Failed;
                    return(false);
                }

                State = States.Moving;
                return(false);
            }
            if (!await ExplorationCoroutine.Explore(BountyData.LevelAreaIds))
            {
                return(false);
            }
            ScenesStorage.Reset();
            return(false);
        }
コード例 #6
0
ファイル: RadarCanvas.cs プロジェクト: shmilyzxt/db-plugins
        /// <summary>
        /// Draw a Scene
        /// </summary>
        //private void DrawScenes2(DrawingContext dc, CanvasData canvas)
        //{
        //    try
        //    {
        //        if (Math.Abs(CenterActor.Point.X) < 0.01f && Math.Abs(CenterActor.Point.Y) < 0.01f)
        //            return;

        //        var worldId = AdvDia.CurrentWorldDynamicId;
        //        foreach (var adventurerScene in GridProvider.CachedScenes.Values.Where(s => s.WorldId == worldId
        //        //&&
        //        //centerActorPosition.X >= s.Min.X && centerActorPosition.Y >= s.Min.Y &&
        //        //centerActorPosition.X <= s.Max.X && centerActorPosition.Y <= s.Max.Y
        //        ).ToList())
        //        {
        //            // Combine navcells into one drawing and store it; because they don't change relative to each other
        //            // And because translating geometry for every navcell on every frame is waaaaay too slow.
        //            if (Drawings.Relative.ContainsKey(adventurerScene.NameHash)) continue;

        //            var drawing = new DrawingGroup();

        //            using (var groupdc = drawing.Open())
        //            {
        //                #region Terrain
        //                if (adventurerScene.SceneDefinition != null && adventurerScene.SceneDefinition.NavCellDefinitions != null)
        //                {
        //                    var figures = new List<PathFigure>();
        //                    foreach (var navCell in adventurerScene.SceneDefinition.NavCellDefinitions.Where(nc => nc.Flags.HasFlag(NavCellFlags.AllowWalk)))
        //                    {
        //                        var topLeft = new Vector3(adventurerScene.Min.X + navCell.Min.X, adventurerScene.Min.Y + navCell.Min.Y, 0);
        //                        var topRight = new Vector3(adventurerScene.Min.X + navCell.Max.X, adventurerScene.Min.Y + navCell.Min.Y, 0);
        //                        var bottomLeft = new Vector3(adventurerScene.Min.X + navCell.Min.X, adventurerScene.Min.Y + navCell.Max.Y, 0);
        //                        var bottomRight = new Vector3(adventurerScene.Min.X + navCell.Max.X, adventurerScene.Min.Y + navCell.Max.Y, 0);
        //                        var segments = new[]
        //                                       {
        //                                           new LineSegment(topLeft.ToCanvasPoint(), true),
        //                                           new LineSegment(topRight.ToCanvasPoint(), true),
        //                                           new LineSegment(bottomRight.ToCanvasPoint(), true)
        //                                       };

        //                        figures.Add(new PathFigure(bottomLeft.ToCanvasPoint(), segments, true));
        //                    }
        //                    var geo = new PathGeometry(figures, FillRule.Nonzero, null);
        //                    geo.GetOutlinedPathGeometry();
        //                    groupdc.DrawGeometry(RadarResources.WalkableTerrain, null, geo);
        //                }
        //                #endregion

        //                #region Scene Borders
        //                var sceneTopLeft = new Vector3(adventurerScene.Min.X, adventurerScene.Min.Y, 0);
        //                var sceneTopRight = new Vector3(adventurerScene.Max.X, adventurerScene.Min.Y, 0);
        //                var sceneBottomLeft = new Vector3(adventurerScene.Min.X, adventurerScene.Max.Y, 0);
        //                var sceneBottomRight = new Vector3(adventurerScene.Max.X, adventurerScene.Max.Y, 0);

        //                groupdc.DrawGeometry(null, RadarResources.WalkableTerrainBorder, new LineGeometry(sceneTopLeft.ToCanvasPoint(), sceneTopRight.ToCanvasPoint()));
        //                groupdc.DrawGeometry(null, RadarResources.WalkableTerrainBorder, new LineGeometry(sceneBottomLeft.ToCanvasPoint(), sceneBottomRight.ToCanvasPoint()));
        //                groupdc.DrawGeometry(null, RadarResources.WalkableTerrainBorder, new LineGeometry(sceneTopLeft.ToCanvasPoint(), sceneBottomLeft.ToCanvasPoint()));
        //                groupdc.DrawGeometry(null, RadarResources.WalkableTerrainBorder, new LineGeometry(sceneTopRight.ToCanvasPoint(), sceneBottomRight.ToCanvasPoint()));
        //                #endregion

        //                #region Scene Title
        //                var textPoint = adventurerScene.Center.ToVector3().ToCanvasPoint();
        //                var glyphRun = DrawingUtilities.CreateGlyphRun(adventurerScene.Name, 10, textPoint);
        //                groupdc.DrawGlyphRun(Brushes.Wheat, glyphRun);
        //                textPoint = adventurerScene.Center.ToVector3().ToCanvasPoint();
        //                textPoint.Y = textPoint.Y + 20;
        //                glyphRun = DrawingUtilities.CreateGlyphRun((adventurerScene.Max - adventurerScene.Min).ToString(), 8, textPoint);
        //                groupdc.DrawGlyphRun(Brushes.Wheat, glyphRun);
        //                #endregion

        //                #region Nodes
        //                //var sceneNodePen = new Pen { Brush = Brushes.Black, Thickness = 0.1f };
        //                //foreach (var cell in adventurerScene.GridCells)
        //                //{
        //                //    //if (node.HasEnoughNavigableCells)
        //                //    //{
        //                //    //    groupdc.DrawGeometry(null, sceneNodePen,
        //                //    //        new LineGeometry(node.TopLeft.ToVector3().ToCanvasPoint(),
        //                //    //            node.TopRight.ToVector3().ToCanvasPoint()));
        //                //    //    groupdc.DrawGeometry(null, sceneNodePen,
        //                //    //        new LineGeometry(node.TopLeft.ToVector3().ToCanvasPoint(),
        //                //    //            node.BottomLeft.ToVector3().ToCanvasPoint()));
        //                //    //    groupdc.DrawGeometry(null, sceneNodePen,
        //                //    //        new LineGeometry(node.BottomLeft.ToVector3().ToCanvasPoint(),
        //                //    //            node.BottomRight.ToVector3().ToCanvasPoint()));
        //                //    //    groupdc.DrawGeometry(null, sceneNodePen,
        //                //    //        new LineGeometry(node.TopRight.ToVector3().ToCanvasPoint(),
        //                //    //            node.BottomRight.ToVector3().ToCanvasPoint()));

        //                //    //    //var textPoint1 = node.Center.ToVector3().ToCanvasPoint();
        //                //    //    ////                                var glyphRun1 = DrawingUtilities.CreateGlyphRun(string.Format("{2} {0} ({1:P0})", node.NavigableCellCount, node.FillPercentage, node.LevelAreaId), 8, textPoint1);
        //                //    //    //var glyphRun1 = DrawingUtilities.CreateGlyphRun(node.LevelAreaId.ToString(), 8, textPoint1);
        //                //    //    //groupdc.DrawGlyphRun(Brushes.Wheat, glyphRun1);
        //                //    //}
        //                //    //foreach (var navPoint in node.Nodes.Where(n=>n.NodeFlags.HasFlag(NodeFlags.NearWall)))
        //                //    //{
        //                //    DrawNavNode(groupdc, canvas, cell);
        //                //    //    //groupdc.DrawEllipse(Brushes.LightSlateGray, sceneNodePen, navPoint.Center.ToVector3().ToCanvasPoint(), (float)GridSize / 2, (float)GridSize / 2);
        //                //    //}
        //                //}
        //                #endregion



        //            }

        //            // Have to use SceneHash as key because scenes can appear multiple times with the same name
        //            Drawings.Relative.TryAdd(adventurerScene.NameHash, new RelativeDrawing
        //            {
        //                Drawing = drawing,
        //                Origin = CenterActor.Morph,
        //                Center = adventurerScene.Center.ToVector3(),
        //                WorldId = adventurerScene.WorldId,
        //                //Image = new DrawingImage(drawing),
        //                //ImageRect = drawing.Bounds

        //            });
        //        }

        //        foreach (var pair in Drawings.Relative)
        //        {
        //            //if (pair.Value.WorldId != AdvDia.CurrentWorldDynamicId)
        //            //    continue;

        //            if (!pair.Value.Drawing.Bounds.IntersectsWith(CanvasData.ClipRegion.Rect))
        //                continue;
        //            dc.DrawDrawing(pair.Value.Drawing);

        //            //if (!pair.Value.ImageRect.IntersectsWith(CanvasData.ClipRegion.Rect))
        //            //    continue;
        //            //dc.DrawImage(pair.Value.Image, pair.Value.ImageRect);
        //        }

        //    }
        //    catch (Exception ex)
        //    {
        //        Logger.Debug("Exception in RadarUI.DrawScenes(). {0} {1} {2}", ex.Message, ex.InnerException, ex);
        //    }
        //}


        private void DrawActor(DrawingContext dc, CanvasData canvas, RadarObject radarObject)
        {
            try
            {
                var res = RadarResources.GetActorResourceSet(radarObject);

                // Draw a dot in the center of the actor;
                dc.DrawEllipse(res.Brush, null, radarObject.Point, MarkerSize / 2, MarkerSize / 2);

                // Draw a circle representing the size of the actor
                res.Brush.Opacity = 0.25;
                var gridRadius = radarObject.CachedActorRadius * GridSize;

                var pen = RadarResources.LineOfSightLightPen;

                dc.DrawEllipse(Brushes.Red, new Pen(Brushes.Black, 0.1), radarObject.Point, gridRadius, gridRadius);
                dc.DrawEllipse(Brushes.Transparent, RadarResources.LineOfSightLightPen, radarObject.Point, 45 * GridSize, 45 * GridSize);

                DrawActorLabel(dc, canvas, radarObject, res.Brush);
            }
            catch (Exception ex)
            {
                Logger.Debug("Exception in RadarUI.DrawActor(). {0} {1} {2}", ex.Message, ex.InnerException, ex);
            }
        }
コード例 #7
0
ファイル: RiftData.cs プロジェクト: dachidahu/AutoFollow
        public static void AddEntryPortal()
        {
            ZetaDia.Actors.Update();
            var portal =
                ZetaDia.Actors.GetActorsOfType <DiaGizmo>(true)
                .Where(g => g.IsFullyValid() && g.IsPortal && g.Distance < 100)
                .OrderBy(g => g.Position.Distance2DSqr(AdvDia.MyPosition))
                .FirstOrDefault();

            if (portal == null || EntryPortals.ContainsKey(AdvDia.CurrentWorldDynamicId))
            {
                return;
            }
            Logger.Debug("[Rift] Added entry portal {0} ({1})", (SNOActor)portal.ActorSnoId, portal.ActorSnoId);
            EntryPortals.Add(AdvDia.CurrentWorldDynamicId,
                             new RiftEntryPortal(portal.ActorSnoId, portal.Position.X, portal.Position.Y));

            var portalMarker =
                AdvDia.CurrentWorldMarkers.FirstOrDefault(m => m.Position.Distance2D(portal.Position) < 10);

            if (portalMarker != null)
            {
                FileUtils.AppendToLogFile("EntryPortals",
                                          string.Format("{0}\t{1}\t{2}\t{3}", portalMarker.Id, portalMarker.NameHash,
                                                        portalMarker.IsPortalEntrance, portalMarker.IsPortalExit));
            }
        }
コード例 #8
0
ファイル: RadarCanvas.cs プロジェクト: shmilyzxt/db-plugins
        private void DrawCurrentPath(DrawingContext dc, CanvasData canvas)
        {
            try
            {
                var currentPath = Navigator.GetNavigationProviderAs <DefaultNavigationProvider>().CurrentPath;
                //var currentPath = NavigationCoroutine.NavigationProvider.CurrentPath;

                for (int i = 1; i < currentPath.Count; i++)
                {
                    var to   = currentPath[i];
                    var from = currentPath[i - 1];

                    dc.DrawLine(RadarResources.CurrentPathPen, from.ToCanvasPoint(), to.ToCanvasPoint());
                }
                //if (currentPath.Count > 0)
                //{
                //    var newPath = NavigationGrid.Instance.GeneratePath(currentPath.First(),
                //        currentPath.Last());

                //    for (int i = 1; i < newPath.Count; i++)
                //    {
                //        var to = newPath[i];
                //        var from = newPath[i - 1];
                //        dc.DrawLine(RadarResources.NewPathPen, from.ToCanvasPoint(),
                //            to.ToCanvasPoint());
                //    }
                //}
            }
            catch (Exception ex)
            {
                Logger.Debug("Exception in RadarUI.DrawCurrentpath(). {0} {1} {2}", ex.Message, ex.InnerException, ex);
            }
        }
コード例 #9
0
 private void CreateGrid()
 {
     if (InnerGrid == null)
     {
         Logger.Debug("[{0}] Creating grid [{1},{1}]", GetType().Name, GridBounds);
         InnerGrid = new INode[GridBounds, GridBounds];
     }
 }
コード例 #10
0
 private void DisablePulse()
 {
     if (_isPulsing)
     {
         Logger.Debug("[Rift] Unregistered from pulsator.");
         Pulsator.OnPulse -= OnPulse;
         _isPulsing        = false;
     }
 }
コード例 #11
0
 private void EnablePulse()
 {
     if (!_isPulsing)
     {
         Logger.Debug("[Rift] Registered to pulsator.");
         Pulsator.OnPulse += OnPulse;
         _isPulsing        = true;
     }
 }
コード例 #12
0
ファイル: Grid.cs プロジェクト: dachidahu/AutoFollow
 private void CreateGrid()
 {
     if (InnerGrid == null)
     {
         Logger.Debug("[{0}] Creating grid [{1},{1}]", GetType().Name, GridBounds);
         //InnerGrid = new INode[GridBounds, GridBounds];
         InnerGrid      = new SplitArray <INode>(GridBounds, GridBounds);
         WorldDynamicId = AdvDia.CurrentWorldDynamicId;
     }
 }
コード例 #13
0
        private async Task <bool> UpgradingGems()
        {
            if (RiftData.VendorDialog.IsVisible && RiftData.ContinueButton.IsVisible && RiftData.ContinueButton.IsEnabled)
            {
                Logger.Debug("[Rift] Clicking to Continue button.");
                RiftData.ContinueButton.Click();
                RiftData.VendorCloseButton.Click();
                await Coroutine.Sleep(2000);

                return(false);
            }

            var gemToUpgrade = GetUpgradeTarget(_enableGemUpgradeLogs);

            if (gemToUpgrade == null)
            {
                Logger.Info("[Rift] I couldn't find any gems to upgrade, failing.");
                State = States.Failed;
                return(false);
            }
            _enableGemUpgradeLogs = false;
            if (AdvDia.RiftQuest.Step == RiftStep.Cleared)
            {
                Logger.Debug("[Rift] Rift Quest is completed, returning to town");
                State = States.Completed;
                return(false);
            }

            Logger.Debug("[Rift] Gem upgrades left before the attempt: {0}", ZetaDia.Me.JewelUpgradesLeft);
            if (!await CommonCoroutines.AttemptUpgradeGem(gemToUpgrade))
            {
                Logger.Debug("[Rift] Gem upgrades left after the attempt: {0}", ZetaDia.Me.JewelUpgradesLeft);
                return(false);
            }
            var gemUpgradesLeft = ZetaDia.Me.JewelUpgradesLeft;

            if (_gemUpgradesLeft != gemUpgradesLeft)
            {
                _gemUpgradesLeft      = gemUpgradesLeft;
                _enableGemUpgradeLogs = true;
            }
            if (gemUpgradesLeft == 0)
            {
                //TODO add await here by andrew
                await Coroutine.Sleep(8000);

                Logger.Debug("[Rift] Finished all upgrades, returning to town.");
                State = States.Completed;
                return(false);
            }


            return(false);
        }
コード例 #14
0
 private void ScanForObjective()
 {
     if (_previouslyFoundLocation != Vector3.Zero && PluginTime.ReadyToUse(_returnTimeForPreviousLocation, 60000))
     {
         _objectiveLocation       = _previouslyFoundLocation;
         _previouslyFoundLocation = Vector3.Zero;
         Logger.Debug("[MoveToScenePosition] Returning previous objective location.");
         return;
     }
     if (PluginTime.ReadyToUse(_lastScanTime, 1000))
     {
         _lastScanTime = PluginTime.CurrentMillisecond;
         if (!string.IsNullOrEmpty(_sceneName))
         {
             var scene = ScenesStorage.CurrentWorldScenes.OrderBy(s => s.Center.DistanceSqr(AdvDia.MyPosition.ToVector2())).FirstOrDefault(s => s.Name.Contains(_sceneName));
             if (scene != null)
             {
                 _worldScene        = scene;
                 _objectiveLocation = _worldScene.GetWorldPosition(_position);
             }
         }
         else if (!string.IsNullOrEmpty(_tempSceneName))
         {
             var scene = ScenesStorage.CurrentWorldScenes.OrderBy(s => s.Center.DistanceSqr(AdvDia.MyPosition.ToVector2())).FirstOrDefault(s => s.Name == _tempSceneName);
             if (scene != null)
             {
                 _worldScene        = scene;
                 _objectiveLocation = _worldScene.GetWorldPosition(_position);
             }
         }
         //if (_objectiveLocation == Vector3.Zero && _actorId != 0)
         //{
         //    _objectiveLocation = BountyHelpers.ScanForActorLocation(_actorId, _objectiveScanRange);
         //}
         if (_objectiveLocation != Vector3.Zero)
         {
             using (new PerformanceLogger("[MoveToScenePosition] Path to Objective Check", true))
             {
                 //if ((Navigator.GetNavigationProviderAs<DefaultNavigationProvider>().CanFullyClientPathTo(_objectiveLocation)))
                 //{
                 Logger.Info("[MoveToScenePosition] Found the objective at distance {0}",
                             AdvDia.MyPosition.Distance2D(_objectiveLocation));
                 //}
                 //else
                 //{
                 //    Logger.Debug("[MoveToMapMarker] Found the objective at distance {0}, but cannot get a path to it.",
                 //        AdvDia.MyPosition.Distance2D(_objectiveLocation));
                 //    _objectiveLocation = Vector3.Zero;
                 //}
             }
         }
     }
 }
コード例 #15
0
        public static bool AreAllActBountiesSupported(Act act)
        {
            var result =
                ZetaDia.ActInfo.Bounties.Count(
                    b => b.Act == act && BountyDataFactory.GetBountyData((int)b.Quest) != null) == 5;

            if (!result)
            {
                Logger.Debug("[Bounties] Unsupported bounties are detected in {0}", act);
            }
            return(result);
        }
コード例 #16
0
ファイル: RadarCanvas.cs プロジェクト: shmilyzxt/db-plugins
        /// <summary>
        /// Go through the ItemSource collection and calculate their canvas positions
        /// </summary>
        public void UpdateData()
        {
            try
            {
                using (new PerformanceLogger("RadarUI UpdateData"))
                {
                    if (DesiredSize.Height <= 0 || DesiredSize.Width <= 0)
                    {
                        return;
                    }

                    if (!IsVisible || ZetaDia.Me == null || ZetaDia.IsLoadingWorld || !ZetaDia.IsInGame)
                    {
                        return;
                    }

                    Objects.Clear();

                    CanvasData.Update(DesiredSize, GridSize);

                    // Find the actor who should be in the center of the radar
                    // and whos position all other points should be plotted against.

                    var center = ZetaDia.Me;
                    if (center == null)
                    {
                        return;
                    }

                    CenterActor = new RadarObject(center, CanvasData);
                    CenterActor.CachedActorName   = "Player";
                    CenterActor.CachedActorRadius = 6;
                    if (CenterActor.IsValid)
                    {
                        CanvasData.CenterVector = CenterActor.Actor.Position;
                        CanvasData.CenterMorph  = CenterActor.Morph;

                        // Calculate locations for all actors positions
                        // on RadarObject ctor; or with .Update();

                        UpdateRelativeDrawings();
                    }
                }

                // Trigger Canvas to Render
                InvalidateVisual();
            }
            catch (Exception ex)
            {
                Logger.Debug("Exception in RadarUI.UpdateData(). {0} {1}", ex.Message, ex.InnerException);
            }
        }
コード例 #17
0
ファイル: RadarCanvas.cs プロジェクト: shmilyzxt/db-plugins
        private void DrawGridNodes(DrawingContext dc, CanvasData canvas)
        {
            var curX = 0;
            var curY = 0;

            try
            {
                if (!BotEvents.IsBotRunning)
                {
                    return;
                }
                for (var x = ExplorationGrid.Instance.MinX; x <= ExplorationGrid.Instance.MaxX; x++)
                {
                    for (var y = ExplorationGrid.Instance.MinY; y <= ExplorationGrid.Instance.MaxY; y++)
                    {
                        var node = ExplorationGrid.Instance.InnerGrid[x, y] as ExplorationNode;
                        if (node != null && node.HasEnoughNavigableCells)
                        {
                            Brush nodeBrush;
                            if (node.IsIgnored)
                            {
                                nodeBrush = Brushes.Black;
                            }
                            else if (node.IsVisited)
                            {
                                nodeBrush = Brushes.SpringGreen;
                            }
                            else if (node.IsCurrentDestination)
                            {
                                nodeBrush = Brushes.DeepSkyBlue;
                            }
                            else
                            {
                                nodeBrush = Brushes.DarkGray;
                            }

                            dc.DrawEllipse(nodeBrush, RadarResources.GridPen, node.NavigableCenter.ToCanvasPoint(), GridSize * 2, GridSize * 2);
                            //var textPoint = node.Center.ToVector3().ToCanvasPoint();
                            //var nodeTitle =
                            //    ((1/node.NavigableCenter.Distance(AdvDia.MyPosition))*node.UnvisitedWeight).ToString();
                            //var glyphRun = DrawingUtilities.CreateGlyphRun(nodeTitle, GridSize * 4, textPoint);
                            //dc.DrawGlyphRun(nodeBrush, glyphRun);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Debug("Exception in RadarUI.DrawGridNodes(). {0} {1} {2}", ex.Message, curX, curY);
            }
        }
コード例 #18
0
        private void ScanForObjective()
        {
            if (_previouslyFoundLocation != Vector3.Zero && PluginTime.ReadyToUse(_returnTimeForPreviousLocation, 60000))
            {
                _objectiveLocation             = _previouslyFoundLocation;
                _previouslyFoundLocation       = Vector3.Zero;
                _returnTimeForPreviousLocation = PluginTime.CurrentMillisecond;
                Logger.Debug("[MoveToMapMarker] Returning previous objective location.");

                return;
            }
            if (PluginTime.ReadyToUse(_lastScanTime, 1000))
            {
                _lastScanTime = PluginTime.CurrentMillisecond;
                if (_marker != 0)
                {
                    if (_marker == -1)
                    {
                        _objectiveLocation = BountyHelpers.ScanForMarkerLocation(0, _objectiveScanRange);
                    }
                    else
                    {
                        _objectiveLocation = BountyHelpers.ScanForMarkerLocation(_marker, _objectiveScanRange);
                    }
                }
                //if (_objectiveLocation == Vector3.Zero && _actorId != 0)
                //{
                //    _objectiveLocation = BountyHelpers.ScanForActorLocation(_actorId, _objectiveScanRange);
                //}
                if (_objectiveLocation != Vector3.Zero)
                {
                    using (new PerformanceLogger("[MoveToMapMarker] Path to Objective Check", true))
                    {
                        //if ((Navigator.GetNavigationProviderAs<DefaultNavigationProvider>().CanFullyClientPathTo(_objectiveLocation)))
                        //{
                        Logger.Info("[MoveToMapMarker] Found the objective at distance {0}",
                                    AdvDia.MyPosition.Distance2D(_objectiveLocation));
                        //}
                        //else
                        //{
                        //    Logger.Debug("[MoveToMapMarker] Found the objective at distance {0}, but cannot get a path to it.",
                        //        AdvDia.MyPosition.Distance2D(_objectiveLocation));
                        //    _objectiveLocation = Vector3.Zero;
                        //}
                    }
                }
            }
        }
コード例 #19
0
        private async Task <bool> MovingToExitScene()
        {
            if (!await NavigationCoroutine.MoveTo(_exitSceneLocation, 12))
            {
                return(false);
            }

            if (AdvDia.MyPosition.Distance2D(_exitSceneLocation) > 30 && NavigationCoroutine.LastResult == CoroutineResult.Failure)
            {
                Logger.Debug("[EnterLevelArea] Exit scene is unreachable, going back to the normal routine");
                _exitSceneLocation    = Vector3.Zero;
                _exitSceneUnreachable = true;
            }
            State = States.Searching;
            return(false);
        }
コード例 #20
0
        private void ScanForUrshi()
        {
            var urshi =
                ZetaDia.Actors.GetActorsOfType <DiaUnit>()
                .FirstOrDefault(a => a.IsFullyValid() && a.ActorSNO == RiftData.UrshiSNO);

            if (urshi != null)
            {
                _urshiLocation = urshi.Position;
            }
            if (_urshiLocation != Vector3.Zero)
            {
                Logger.Info("[Rift] Urshi is near.");
                State = States.MovingToUrshi;
                Logger.Debug("[Rift] Found Urshi at distance {0}", AdvDia.MyPosition.Distance2D(_urshiLocation));
            }
        }
コード例 #21
0
ファイル: AdvDia.cs プロジェクト: dachidahu/AutoFollow
 public static T SafeReadValue(Func <T> valueFactory)
 {
     try
     {
         return(valueFactory.Invoke());
     }
     catch (ACDAttributeLookupFailedException acdEx)
     {
         Logger.Debug("[AdvDia] {0}", acdEx.Message);
     }
     catch (Exception ex)
     {
         Logger.Debug("[AdvDia] {0}", ex.Message);
         if (!ex.Message.Contains("ReadProcessMemory"))
         {
             throw;
         }
     }
     return(default(T));
 }
コード例 #22
0
        private async Task <bool> Interacting()
        {
            //if (_interactionCoroutine.State == InteractionCoroutine.States.NotStarted)
            //{
            //    var portalGizmo = BountyHelpers.GetPortalNearMarkerPosition(_markerPosition);
            //    if (portalGizmo == null)
            //    {
            //        Logger.Debug("[Bounty] No portal nearby, keep exploring .");
            //        State = States.SearchingForDestinationWorld;
            //        return false;
            //    }
            //    _interactionCoroutine.DiaObject = portalGizmo;
            //}

            if (await _interactionCoroutine.GetCoroutine())
            {
                ActorFinder.InteractWhitelist.Remove(_actorId);
                if (_interactionCoroutine.State == InteractionCoroutine.States.TimedOut)
                {
                    Logger.Debug("[InteractWithGizmo] Interaction timed out.");
                    State = States.Failed;
                    return(false);
                }

                if (_useAll)
                {
                    var nextGizmo = ActorFinder.FindGizmo(_actorId, gizmo => gizmo.IsInteractableQuestObject());
                    if (nextGizmo != null)
                    {
                        Logger.Warn("Found another actor that needs some interaction. Dist={0}", nextGizmo.Distance);
                        State = States.Searching;
                        return(false);
                    }
                }

                State = States.Completed;
                _interactionCoroutine = null;
                return(false);
            }
            return(false);
        }
コード例 #23
0
ファイル: RiftCoroutine.cs プロジェクト: dachidahu/AutoFollow
        private bool TownRun()
        {
            Logger.Debug("[TownRun] BrainBehavior.IsVendoring is {0}", BrainBehavior.IsVendoring);
            Logger.Debug("[TownRun] ZetaDia.Me.IsParticipatingInTieredLootRun is {0}", ZetaDia.Me.IsParticipatingInTieredLootRun);
            Logger.Debug("[TownRun] AdvDia.RiftQuest.State is {0}", AdvDia.RiftQuest.State);
            Logger.Debug("[TownRun] AdvDia.RiftQuest.Step is {0}", AdvDia.RiftQuest.Step);
            DisablePulse();
            if (BrainBehavior.IsVendoring)
            {
                return(false);
            }
            if (!_townRunInitiated)
            {
                _townRunInitiated = true;
                BrainBehavior.ForceTownrun(" We need it.", true);
                return(false);
            }

            _riftCounter++;
            Logger.Info("Rifts Completed = {0}", _riftCounter);

            if (_options.RiftCount > 0 && _riftCounter >= _options.RiftCount)
            {
                Logger.Info("[Rift] Rift limit set on profile tag reached. ({0})", _options.RiftCount);
                State = States.Completed;
                return(Finished());
            }

            _townRunInitiated = false;
            if (AdvDia.RiftQuest.Step == RiftStep.Completed)
            {
                State = States.WaitForRiftCountdown;
                Logger.Info("[Rift] Tick tock, tick tock...");
            }
            else
            {
                State = States.NotStarted;
                _moveToRiftStoneCoroutine.Reset();
            }
            return(false);
        }
コード例 #24
0
        private async Task <bool> NotStarted()
        {
            var distanceToDestination = AdvDia.MyPosition.Distance(_destination);

            if (PluginEvents.CurrentProfileType == ProfileType.Rift &&
                distanceToDestination < 100 &&
                NavigationGrid.Instance.CanRayWalk(AdvDia.MyPosition, _destination))
            {
                _mover            = Mover.StraightLine;
                _lastRaywalkCheck = PluginTime.CurrentMillisecond;
                await Navigator.MoveTo(_destination);
            }
            else
            {
                _mover = Mover.Navigator;
            }
            Logger.Debug("[Navigation] {0} {1} (Distance: {2})", (_mover == Mover.StraightLine ? "Moving towards" : "Moving to"), _destination, distanceToDestination);
            State = States.Moving;
            _pathGenetionTimer.Reset();
            return(false);
        }
コード例 #25
0
ファイル: RadarCanvas.cs プロジェクト: shmilyzxt/db-plugins
        private void DrawPointsOfInterest(DrawingContext dc, CanvasData canvas)
        {
            try
            {
                foreach (var marker in AdvDia.CurrentWorldMarkers.Where(m => m.Id >= 0 && m.Id < 200))
                {
                    dc.DrawEllipse(Brushes.Yellow, RadarResources.GridPen, marker.Position.ToCanvasPoint(), 5, 5);
                    var textPoint = marker.Position.ToCanvasPoint();
                    textPoint.Y = textPoint.Y + 32;
                    var glyphRun = DrawingUtilities.CreateGlyphRun(marker.NameHash.ToString(), 8, textPoint);
                    dc.DrawGlyphRun(Brushes.Yellow, glyphRun);

                    var toObjectivePen = new Pen(Brushes.Yellow, 0.2);
                    dc.DrawLine(toObjectivePen, canvas.Center, marker.Position.ToCanvasPoint());
                }
            }
            catch (Exception ex)
            {
                Logger.Debug("Exception in RadarUI.DrawPointsOfInterest(). {0} {1} {2}", ex.Message, ex.InnerException, ex);
            }
        }
コード例 #26
0
        private async Task <bool> InteractingWithDeathGate()
        {
            if (await _interactionCoroutine.GetCoroutine())
            {
                if (_interactionCoroutine.State == InteractionCoroutine.States.TimedOut)
                {
                    Logger.Debug("[Bounty] Near death gate, but interaction timed out.");
                    State = States.Failed;
                    _interactionCoroutine = null;
                }
                else
                {
                    _deathGate           = null;
                    _deathGateIgnoreList = new List <int>();
                    State = States.Moving;
                    _interactionCoroutine = null;
                }
            }

            return(false);
        }
コード例 #27
0
 private async Task <bool> Entering()
 {
     if (_objectiveLocation.Distance(AdvDia.MyPosition) > 22)
     {
         State = States.Moving;
         return(false);
     }
     if (!await UsePortalCoroutine.UsePortal(_portalActorId != 0 ? _portalActorId : _discoveredPortalActorId, _prePortalWorldDynamicId))
     {
         return(false);
     }
     if (AdvDia.CurrentWorldId != DestinationWorldId)
     {
         Logger.Debug("[Bounty] We are not where we are supposed to be.");
         State = States.Searching;
         return(false);
     }
     _discoveredPortalActorId = 0;
     SafeZerg.Instance.DisableZerg();
     State = States.Completed;
     return(false);
 }
コード例 #28
0
        private void ScanForExitPortal()
        {
            if (_nextLevelPortalLocation != Vector3.Zero)
            {
                return;
            }
            var portal =
                ZetaDia.Actors.GetActorsOfType <DiaGizmo>(true)
                .Where(
                    g =>
                    g.IsFullyValid() && g.IsPortal && !RiftData.DungeonStoneSNOs.Contains(g.ActorSNO) &&
                    g.Distance < _portalScanRange && g.CommonData.GizmoType != GizmoType.HearthPortal)
                .OrderBy(g => g.Position.Distance2DSqr(AdvDia.MyPosition))
                .FirstOrDefault();

            if (portal != null)
            {
                _nextLevelPortalLocation = portal.Position;
                var currentWorldExitPortalHash = RiftData.GetRiftExitPortalHash(AdvDia.CurrentWorldId);
                var marker = AdvDia.CurrentWorldMarkers.FirstOrDefault(m => m.Position.Distance2D(_nextLevelPortalLocation) < 10);
                if (marker == null)
                {
                    _nextLevelPortalLocation = Vector3.Zero;
                }
                else
                {
                    if (marker.NameHash != currentWorldExitPortalHash)
                    {
                        _nextLevelPortalLocation = Vector3.Zero;
                    }
                }
            }
            if (_nextLevelPortalLocation != Vector3.Zero)
            {
                Logger.Info("[Rift] Oh look! There is a portal over there, let's see what's on the other side.");
                Logger.Debug("[Rift] Found the objective at distance {0}",
                             AdvDia.MyPosition.Distance2D(_nextLevelPortalLocation));
            }
        }
コード例 #29
0
ファイル: RadarCanvas.cs プロジェクト: shmilyzxt/db-plugins
        /// <summary>
        /// OnRender is a core part of Canvas, replace it with our render code. Can be manually triggered by InvalidateVisual();
        /// Its very important to minimize work in OnRender, use UpdateData() to cache whatever it is you need.
        /// </summary>
        protected override void OnRender(DrawingContext dc)
        {
            using (new PerformanceLogger("RadarUI Render"))
            {
                if (Math.Abs(CanvasData.CanvasSize.Width) < 0.001f && Math.Abs(CanvasData.CanvasSize.Height) < 0.001f || CanvasData.CenterVector == Vector3.Zero)
                {
                    return;
                }

                if (Math.Abs(CenterActor.Point.X) < 0.001f && Math.Abs(CenterActor.Point.Y) < 0.001f)
                {
                    return;
                }

                if (!ZetaDia.IsInGame || ZetaDia.IsLoadingWorld)
                {
                    return;
                }

                try
                {
                    DrawScenes(dc, CanvasData);
                    DrawGridNodes(dc, CanvasData);
                    DrawPointsOfInterest(dc, CanvasData);
                    DrawCurrentPath(dc, CanvasData);
                    //DrawNodesInRadius(dc, CanvasData);

                    if (CenterActor.IsValid)
                    {
                        DrawActor(dc, CanvasData, CenterActor);
                    }
                }
                catch (Exception ex)
                {
                    Logger.Debug("Exception in RadarUI.OnRender(). {0} {1}", ex.Message, ex.InnerException);
                }
            }
        }
コード例 #30
0
        private async Task <bool> InteractingWithUrshi()
        {
            DisablePulse();
            if (RiftData.VendorDialog.IsVisible)
            {
                State = States.UpgradingGems;
                return(false);
            }

            var urshi = ZetaDia.Actors.GetActorsOfType <DiaUnit>().FirstOrDefault(a => a.IsFullyValid() && a.ActorSnoId == RiftData.UrshiSNO);

            if (urshi == null)
            {
                Logger.Debug("[UpgradeGems] Can't find the Urshi lady :(");
                State = States.Failed;
                return(false);
            }

            if (!await _interactWithUrshiCoroutine.GetCoroutine())
            {
                return(false);
            }

            await Coroutine.Wait(2500, () => RiftData.VendorDialog.IsVisible);

            _interactWithUrshiCoroutine.Reset();

            if (!RiftData.VendorDialog.IsVisible)
            {
                return(false);
            }

            _gemUpgradesLeft      = 3;
            _enableGemUpgradeLogs = false;
            State = States.UpgradingGems;
            return(false);
        }