Ejemplo n.º 1
0
        /// <summary>
        /// Adds Legendary & Set Minimap Markers to ObjectCache
        /// </summary>
        private static void RefreshCacheMarkers()
        {
            const int setItemMarkerTexture       = 404424;
            const int legendaryItemMarkerTexture = 275968;

            if (!BrainBehavior.IsVendoring && !WantToTownRun && !ForceVendorRunASAP && Settings.Loot.Pickup.PickupLegendaries)
            {
                var legendaryItemMarkers = ZetaDia.Minimap.Markers.CurrentWorldMarkers.Where(m => m.IsValid &&
                                                                                             m.Position.Distance2D(Player.Position) >= 45f && m.Position.Distance2D(Player.Position) < 300f &&
                                                                                             (m.MinimapTexture == setItemMarkerTexture || m.MinimapTexture == legendaryItemMarkerTexture) && !Blacklist60Seconds.Contains(m.NameHash)).ToList();

                foreach (var marker in legendaryItemMarkers)
                {
                    var name = (marker.MinimapTexture == setItemMarkerTexture ? "Set Item" : "Legendary Item") + " Minimap Marker";

                    var cacheObject = new TrinityCacheObject
                    {
                        Position     = new Vector3((float)Math.Floor(marker.Position.X), (float)Math.Floor(marker.Position.Y), (float)Math.Floor(marker.Position.Z)),
                        InternalName = name,
                        ActorSNO     = marker.NameHash,
                        RActorGuid   = marker.MinimapTexture,
                        Distance     = marker.Position.Distance(Player.Position),
                        ActorType    = ActorType.Item,
                        Type         = TrinityObjectType.Item,
                        ItemQuality  = ItemQuality.Legendary,
                        Radius       = 2f,
                        Weight       = 50,
                        IsMarker     = true
                    };
                    cacheObject.ObjectHash = HashGenerator.GenerateItemHash(cacheObject);

                    if (GenericBlacklist.ContainsKey(cacheObject.ObjectHash))
                    {
                        Logger.LogDebug(LogCategory.CacheManagement, "Ignoring Marker because it's blacklisted {0} {1} at {2} distance {3}", name, marker.MinimapTexture, marker.Position, marker.Position.Distance(Player.Position));
                        continue;
                    }

                    Logger.LogDebug(LogCategory.CacheManagement, "Adding {0} {1} at {2} distance {3}", name, marker.MinimapTexture, marker.Position, marker.Position.Distance(Player.Position));
                    ObjectCache.Add(cacheObject);
                }

                if (legendaryItemMarkers.Any() && TrinityItemManager.FindValidBackpackLocation(true) != new Vector2(-1, -1))
                {
                    var legendaryItems = ZetaDia.Actors.GetActorsOfType <DiaItem>().Where(i => i.IsValid && i.IsACDBased && i.Position.Distance2D(ZetaDia.Me.Position) < 5f &&
                                                                                          legendaryItemMarkers.Any(im => i.Position.Distance2D(i.Position) < 2f));

                    foreach (var diaItem in legendaryItems)
                    {
                        Logger.LogDebug(LogCategory.CacheManagement, "Adding Legendary Item from Marker {0} dist={1} ActorSNO={2} ACD={3} RActor={4}",
                                        diaItem.Name, diaItem.Distance, diaItem.ActorSNO, diaItem.ACDGuid, diaItem.RActorGuid);

                        ObjectCache.Add(new TrinityCacheObject()
                        {
                            Position         = diaItem.Position,
                            InternalName     = diaItem.Name,
                            RActorGuid       = diaItem.RActorGuid,
                            ActorSNO         = diaItem.ActorSNO,
                            ACDGuid          = diaItem.ACDGuid,
                            HasBeenNavigable = true,
                            HasBeenInLoS     = true,
                            Distance         = diaItem.Distance,
                            ActorType        = ActorType.Item,
                            Type             = TrinityObjectType.Item,
                            Radius           = 2f,
                            Weight           = 50,
                            ItemQuality      = ItemQuality.Legendary,
                        });
                    }
                }
            }

            bool isRiftGuardianQuestStep = ZetaDia.CurrentQuest.QuestSNO == 337492 && ZetaDia.CurrentQuest.StepId == 16;

            if (isRiftGuardianQuestStep)
            {
                // Add Rift Guardian POI's or Markers to ObjectCache
                const int riftGuardianMarkerTexture = 81058;
                Func <MinimapMarker, bool> riftGuardianMarkerFunc = m => m.IsValid && (m.IsPointOfInterest || m.MinimapTexture == riftGuardianMarkerTexture) &&
                                                                    !Blacklist60Seconds.Contains(m.NameHash);

                foreach (var marker in ZetaDia.Minimap.Markers.CurrentWorldMarkers.Where(riftGuardianMarkerFunc))
                {
                    Logger.LogDebug(LogCategory.CacheManagement, "Adding Rift Guardian POI, distance {0}", marker.Position.Distance2D(Player.Position));
                    ObjectCache.Add(new TrinityCacheObject()
                    {
                        Position     = marker.Position,
                        InternalName = "Rift Guardian",
                        Distance     = marker.Position.Distance(Player.Position),
                        RActorGuid   = marker.NameHash,
                        ActorType    = ActorType.Monster,
                        Type         = TrinityObjectType.Unit,
                        Radius       = 10f,
                        Weight       = 5000,
                    });
                }
            }

            if (isRiftGuardianQuestStep || Player.ParticipatingInTieredLootRun) // X1_LR_DungeonFinder
            {
                foreach (var marker in ZetaDia.Minimap.Markers.CurrentWorldMarkers.Where(m => m.IsPointOfInterest && !Blacklist60Seconds.Contains(m.NameHash)))
                {
                    ObjectCache.Add(new TrinityCacheObject()
                    {
                        Position     = marker.Position,
                        InternalName = "Rift Guardian",
                        Distance     = marker.Position.Distance(Player.Position),
                        RActorGuid   = marker.NameHash,
                        ActorType    = ActorType.Monster,
                        Type         = TrinityObjectType.Unit,
                        Radius       = 10f,
                        Weight       = 5000,
                    });
                }
            }
        }