private void ClearGateDestination() { _deathGate = null; _deathGatePosition = Vector3.Zero; _deathGateIgnoreList.RemoveAll(dt => DateTime.UtcNow.Subtract(dt).TotalMinutes > 5); _interactionCoroutine = null; }
//SNO: 297813, 297814, 295415, 342675 internal static RunStatus IdenifyItemBookOfCainMovementBehavior(object ret) { if (FunkyGame.GameIsInvalid) { ActionsChecked = false; FunkyTownRunPlugin.DBLog.InfoFormat("[Funky] Town Run Behavior Failed! (Not In Game/Invalid Actor/misc)"); return(RunStatus.Failure); } BotMain.StatusText = "Town run: Idenify Movement"; DiaGizmo objBookOfCain = UpdateBookOfCainObject(); Vector3 vectorPlayerPosition = ZetaDia.Me.Position; Vector3 vectorBookOfCainLocation = Vector3.Zero; //Normal distance we use to move to specific location before moving to NPC float _distanceRequired = CurrentAct != Act.A5 ? 15f : 20f; //Act 5 we want short range only! if (objBookOfCain == null || objBookOfCain.Distance > _distanceRequired) { vectorBookOfCainLocation = SafetyIdenifyLocation; } else { vectorBookOfCainLocation = objBookOfCain.Position; } //if (vectorBookOfCainLocation == Vector3.Zero) //Character.FindActByLevelID(Bot.Character.Data.CurrentWorldDynamicID); //Wait until we are not moving if (FunkyGame.Hero.IsMoving) { return(RunStatus.Running); } float iDistanceFromSell = Vector3.Distance(vectorPlayerPosition, vectorBookOfCainLocation); //Out-Of-Range... if (objBookOfCain == null || iDistanceFromSell > 10f) { Navigator.PlayerMover.MoveTowards(vectorBookOfCainLocation); return(RunStatus.Running); } FunkyTownRunPlugin.DBLog.DebugFormat("[Funky] Idenify Behavior Book of Cain Movement Finished!"); return(RunStatus.Success); }
public static bool IsEntryPortal(DiaGizmo portal) { var sno = portal.ActorSnoId; var x = (int)portal.Position.X; var y = (int)portal.Position.Y; if (!EntryPortals.ContainsKey(AdvDia.CurrentWorldDynamicId)) { return(false); } var worldPortal = EntryPortals[AdvDia.CurrentWorldDynamicId]; return(worldPortal.ActorSNO == sno && worldPortal.X == x && worldPortal.Y == y); }
public CachedGizmo(DiaGizmo diaGizmo) { try { if (diaGizmo == null) { CachingFailed = true; return; } base.BaseInit(diaGizmo); } catch (Exception e) { CachingFailed = true; return; } }
internal static RunStatus IdenifyItemBookOfCainInteractionBehavior(object ret) { if (FunkyGame.GameIsInvalid) { ActionsChecked = false; FunkyTownRunPlugin.DBLog.InfoFormat("[Funky] Town Run Behavior Failed! (Not In Game/Invalid Actor/misc)"); return(RunStatus.Failure); } BotMain.StatusText = "Town run: Idenify Interaction"; //Check if we still have items to ID.. RefreshUnidList(); if (UnidentifiedItems.Count == 0) { FunkyTownRunPlugin.DBLog.DebugFormat("[Funky] Idenify Behavior Book of Cain Interaction Finished!"); return(RunStatus.Success); } //Make sure we have the object! DiaGizmo objBookOfCain = UpdateBookOfCainObject(); //Verify the object! if (objBookOfCain == null) { return(RunStatus.Failure); } //Precheck? if (!PreChecksBookOfCain()) { return(RunStatus.Running); } //Attempt Interaction! objBookOfCain.Interact(); castAttempt = true; castAttempts++; //counter for attempts.. lastCastTime = DateTime.Now; waitTime = RandomWaitTime(true); return(RunStatus.Running); }
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); }
private static bool RefreshStepCachedObjectType(bool AddToCache) { // Set the object type // begin with default... CurrentCacheObject.Type = TrinityObjectType.Unknown; var currentInternalName = CurrentCacheObject.InternalName.ToLower(); foreach (var ignoreName in DataDictionary.ActorIgnoreNames) { if (currentInternalName.StartsWith(ignoreName.ToLower(), StringComparison.InvariantCultureIgnoreCase)) { AddToCache = false; c_IgnoreSubStep = "IgnoreNames"; return AddToCache; } } // Either get the cached object type, or calculate it fresh if (!c_IsObstacle) { // See if it's an avoidance first from the SNO bool isAvoidanceSNO = DataDictionary.Avoidances.Contains(CurrentCacheObject.ActorSNO) || DataDictionary.ButcherFloorPanels.Contains(CurrentCacheObject.ActorSNO) || DataDictionary.AvoidanceProjectiles.Contains(CurrentCacheObject.ActorSNO); // Check if it's a unit with an animation we should avoid. We need to recheck this every time. if (c_diaObject is DiaUnit && Settings.Combat.Misc.AvoidAOE && DataDictionary.AvoidanceAnimations.Contains(new DoubleInt(CurrentCacheObject.ActorSNO, (int)c_diaObject.CommonData.CurrentAnimation))) { // The ActorSNO and Animation match a known pair, avoid this! // Example: "Grotesque" death animation AddToCache = true; CurrentCacheObject.Type = TrinityObjectType.Avoidance; isAvoidanceSNO = true; } if (CurrentCacheObject.Unit != null && CurrentCacheObject.Unit.Movement.IsValid) { CurrentCacheObject.Rotation = CurrentCacheObject.Unit.Movement.Rotation; CurrentCacheObject.DirectionVector = CurrentCacheObject.Unit.Movement.DirectionVector; // Check if it's a unit with an animation we should avoid. We need to recheck this every time. if (c_diaObject is DiaUnit && Settings.Combat.Misc.AvoidAOE && CurrentCacheObject.IsFacing(Player.Position) && DataDictionary.DirectionalAvoidanceAnimations.Contains(new DoubleInt(CurrentCacheObject.ActorSNO, (int)c_diaObject.CommonData.CurrentAnimation))) { // The ActorSNO and Animation match a known pair, avoid this! AddToCache = true; CurrentCacheObject.Type = TrinityObjectType.Avoidance; isAvoidanceSNO = true; } } // We're avoiding AoE and this is an AoE if (Settings.Combat.Misc.AvoidAOE && isAvoidanceSNO) { using (new PerformanceLogger("RefreshCachedType.0")) { // Checking for BuffVisualEffect - for Butcher, maybe useful other places? if (DataDictionary.ButcherFloorPanels.Contains(CurrentCacheObject.ActorSNO)) { bool hasBuff = false; try { hasBuff = c_diaObject.CommonData.GetAttribute<int>(ActorAttributeType.HasLookOverride) > 0; } catch { } if (hasBuff) { AddToCache = true; CurrentCacheObject.Type = TrinityObjectType.Avoidance; } else { AddToCache = false; c_IgnoreSubStep = "NoBuffVisualEffect"; } } else { // Avoidance isn't disabled, so set this object type to avoidance CurrentCacheObject.Type = TrinityObjectType.Avoidance; } } } else if (!Settings.Combat.Misc.AvoidAOE && isAvoidanceSNO) { AddToCache = false; c_IgnoreSubStep = "IgnoreAvoidance"; } // It's not an avoidance, so let's calculate it's object type "properly" else { // Calculate the object type of this object if (c_diaObject.ActorType == ActorType.Monster) //if (c_diaObject is DiaUnit) { using (new PerformanceLogger("RefreshCachedType.1")) { if (c_diaObject.CommonData == null) { c_IgnoreSubStep = "InvalidUnitCommonData"; AddToCache = false; } else if (c_diaObject.ACDGuid != c_diaObject.CommonData.ACDGuid) { c_IgnoreSubStep = "InvalidUnitACDGuid"; AddToCache = false; } else { CurrentCacheObject.Type = TrinityObjectType.Unit; } } } else if (c_diaObject.ActorType == ActorType.Player) { CurrentCacheObject.Type = TrinityObjectType.Player; } else if (DataDictionary.ForceToItemOverrideIds.Contains(CurrentCacheObject.ActorSNO) || (c_diaObject.ActorType == ActorType.Item)) { using (new PerformanceLogger("RefreshCachedType.2")) { CurrentCacheObject.Type = TrinityObjectType.Item; if (c_diaObject.CommonData == null) { AddToCache = false; } if (c_diaObject.CommonData != null && c_diaObject.ACDGuid != c_diaObject.CommonData.ACDGuid) { AddToCache = false; } if (CurrentCacheObject.InternalName.ToLower().StartsWith("gold")) { CurrentCacheObject.Type = TrinityObjectType.Gold; } } } else if (DataDictionary.InteractWhiteListIds.Contains(CurrentCacheObject.ActorSNO)) CurrentCacheObject.Type = TrinityObjectType.Interactable; else if (c_diaObject is DiaGizmo && c_diaObject.ActorType == ActorType.Gizmo && CurrentCacheObject.Distance <= 90) { c_diaGizmo = (DiaGizmo)c_diaObject; if (CurrentCacheObject.InternalName.Contains("CursedChest")) { CurrentCacheObject.Type = TrinityObjectType.CursedChest; return true; } if (CurrentCacheObject.InternalName.Contains("CursedShrine")) { CurrentCacheObject.Type = TrinityObjectType.CursedShrine; return true; } if (c_diaGizmo.IsBarricade) { CurrentCacheObject.Type = TrinityObjectType.Barricade; } else { switch (c_diaGizmo.ActorInfo.GizmoType) { case GizmoType.HealingWell: CurrentCacheObject.Type = TrinityObjectType.HealthWell; break; case GizmoType.Door: CurrentCacheObject.Type = TrinityObjectType.Door; break; case GizmoType.PoolOfReflection: case GizmoType.PowerUp: CurrentCacheObject.Type = TrinityObjectType.Shrine; break; case GizmoType.Chest: CurrentCacheObject.Type = TrinityObjectType.Container; break; case GizmoType.BreakableDoor: CurrentCacheObject.Type = TrinityObjectType.Barricade; break; case GizmoType.BreakableChest: CurrentCacheObject.Type = TrinityObjectType.Destructible; break; case GizmoType.DestroyableObject: CurrentCacheObject.Type = TrinityObjectType.Destructible; break; case GizmoType.PlacedLoot: case GizmoType.Switch: case GizmoType.Headstone: CurrentCacheObject.Type = TrinityObjectType.Interactable; break; default: CurrentCacheObject.Type = TrinityObjectType.Unknown; break; } } } else CurrentCacheObject.Type = TrinityObjectType.Unknown; } if (CurrentCacheObject.Type != TrinityObjectType.Unknown) { // Now cache the object type if it's on the screen and we know what it is //CacheData.ObjectType.Add(CurrentCacheObject.RActorGuid, CurrentCacheObject.Type); } } return AddToCache; }
/// <summary> /// Initializes variable set for single object refresh /// </summary> private static void RefreshStepInit() { CurrentCacheObject = new TrinityCacheObject(); // Start this object as off as unknown type CurrentCacheObject.Type = TrinityObjectType.Unknown; CurrentCacheObject.GizmoType = GizmoType.None; CurrentCacheObject.Distance = 0f; CurrentCacheObject.Radius = 0f; c_ZDiff = 0f; c_ItemDisplayName = ""; c_ItemLink = ""; CurrentCacheObject.InternalName = ""; c_IgnoreReason = ""; c_IgnoreSubStep = ""; CurrentCacheObject.ACDGuid = -1; CurrentCacheObject.RActorGuid = -1; CurrentCacheObject.DynamicID = -1; CurrentCacheObject.GameBalanceID = -1; CurrentCacheObject.ActorSNO = -1; c_ItemLevel = -1; c_GoldStackSize = -1; c_HitPointsPct = -1; c_HitPoints = -1; c_IsOneHandedItem = false; c_IsTwoHandedItem = false; c_unit_IsElite = false; c_unit_IsRare = false; c_unit_IsUnique = false; c_unit_IsMinion = false; c_unit_IsTreasureGoblin = false; c_unit_IsAttackable = false; c_unit_HasShieldAffix = false; c_IsEliteRareUnique = false; c_IsObstacle = false; c_HasBeenNavigable = false; c_HasBeenRaycastable = false; c_HasBeenInLoS = false; c_ItemMd5Hash = string.Empty; c_ItemQuality = ItemQuality.Invalid; c_DBItemBaseType = ItemBaseType.None; c_DBItemType = ItemType.Unknown; c_item_tFollowerType = FollowerType.None; _cItemTinityItemType = TrinityItemType.Unknown; c_unit_MonsterSize = MonsterSize.Unknown; c_diaObject = null; c_diaGizmo = null; c_CurrentAnimation = SNOAnim.Invalid; c_HasDotDPS = false; c_MonsterAffixes = MonsterAffixes.None; }
private static bool RefreshGizmo(bool AddToCache) { if (!Settings.WorldObject.AllowPlayerResurection && CurrentCacheObject.ActorSNO == DataDictionary.PLAYER_HEADSTONE_SNO) { c_IgnoreSubStep = "IgnoreHeadstones"; AddToCache = false; return(AddToCache); } // start as true, then set as false as we go. If nothing matches below, it will return true. AddToCache = true; bool openResplendentChest = CurrentCacheObject.InternalName.ToLower().Contains("chest_rare"); // Ignore it if it's not in range yet, except health wells and resplendent chests if we're opening chests if ((CurrentCacheObject.RadiusDistance > CurrentBotLootRange || CurrentCacheObject.RadiusDistance > 50) && CurrentCacheObject.Type != GObjectType.HealthWell && CurrentCacheObject.Type != GObjectType.Shrine && CurrentCacheObject.RActorGuid != LastTargetRactorGUID) { AddToCache = false; c_IgnoreSubStep = "NotInRange"; } // re-add resplendent chests if (openResplendentChest) { AddToCache = true; c_IgnoreSubStep = ""; } try { CurrentCacheObject.IsBountyObjective = (CurrentCacheObject.CommonData.GetAttribute <int>(ActorAttributeType.BountyObjective) > 0); } catch (Exception) { Logger.LogDebug("Error refreshing IsBountyObjective"); } try { CurrentCacheObject.IsQuestMonster = CurrentCacheObject.Object.CommonData.GetAttribute <int>(ActorAttributeType.QuestMonster) > 1; } catch (Exception ex) { Logger.LogDebug(LogCategory.CacheManagement, "Error reading IsQuestMonster for Unit sno:{0} raGuid:{1} name:{2} ex:{3}", CurrentCacheObject.ActorSNO, CurrentCacheObject.RActorGuid, CurrentCacheObject.InternalName, ex.Message); } try { CurrentCacheObject.IsMinimapActive = CurrentCacheObject.Object.CommonData.GetAttribute <int>(ActorAttributeType.MinimapActive) > 0; } catch (Exception ex) { Logger.LogDebug(LogCategory.CacheManagement, "Error reading MinimapActive for Gizmo sno:{0} raGuid:{1} name:{2} ex:{3}", CurrentCacheObject.ActorSNO, CurrentCacheObject.RActorGuid, CurrentCacheObject.InternalName, ex.Message); } try { CurrentCacheObject.IsQuestMonster = CurrentCacheObject.Object.CommonData.GetAttribute <int>(ActorAttributeType.QuestMonster) > 0; } catch (Exception ex) { Logger.LogDebug(LogCategory.CacheManagement, "Error reading IsQuestMonster for Gizmo sno:{0} raGuid:{1} name:{2} ex:{3}", CurrentCacheObject.ActorSNO, CurrentCacheObject.RActorGuid, CurrentCacheObject.InternalName, ex.Message); } if (CurrentCacheObject.Gizmo != null) { CurrentCacheObject.GizmoType = CurrentCacheObject.Gizmo.ActorInfo.GizmoType; } // Anything that's been disabled by a script bool isGizmoDisabledByScript = false; try { if (CurrentCacheObject.Object is DiaGizmo) { isGizmoDisabledByScript = CurrentCacheObject.Object.CommonData.GetAttribute <int>(ActorAttributeType.GizmoDisabledByScript) > 0; } } catch { CacheData.NavigationObstacles.Add(new CacheObstacleObject { ActorSNO = CurrentCacheObject.ActorSNO, Radius = CurrentCacheObject.Radius, Position = CurrentCacheObject.Position, RActorGUID = CurrentCacheObject.RActorGuid, ObjectType = CurrentCacheObject.Type, }); Logger.Log(TrinityLogLevel.Debug, LogCategory.CacheManagement, "Safely handled exception getting Gizmo-Disabled-By-Script attribute for object {0} [{1}]", CurrentCacheObject.InternalName, CurrentCacheObject.ActorSNO); c_IgnoreSubStep = "isGizmoDisabledByScriptException"; AddToCache = false; } if (isGizmoDisabledByScript) { MainGridProvider.AddCellWeightingObstacle(CurrentCacheObject.ActorSNO, CurrentCacheObject.Radius); CacheData.NavigationObstacles.Add(new CacheObstacleObject { ActorSNO = CurrentCacheObject.ActorSNO, Radius = CurrentCacheObject.Radius, Position = CurrentCacheObject.Position, RActorGUID = CurrentCacheObject.RActorGuid, ObjectType = CurrentCacheObject.Type, }); AddToCache = false; c_IgnoreSubStep = "GizmoDisabledByScript"; return(AddToCache); } // Anything that's Untargetable bool untargetable = false; try { if (CurrentCacheObject.Object is DiaGizmo) { untargetable = CurrentCacheObject.Object.CommonData.GetAttribute <int>(ActorAttributeType.Untargetable) > 0; } } catch { } // Anything that's Invulnerable bool invulnerable = false; try { if (CurrentCacheObject.Object is DiaGizmo) { invulnerable = CurrentCacheObject.Object.CommonData.GetAttribute <int>(ActorAttributeType.Invulnerable) > 0; } } catch { } bool noDamage = false; try { if (CurrentCacheObject.Object is DiaGizmo) { noDamage = CurrentCacheObject.Object.CommonData.GetAttribute <int>(ActorAttributeType.NoDamage) > 0; } } catch { CacheData.NavigationObstacles.Add(new CacheObstacleObject { ActorSNO = CurrentCacheObject.ActorSNO, Radius = CurrentCacheObject.Radius, Position = CurrentCacheObject.Position, RActorGUID = CurrentCacheObject.RActorGuid, ObjectType = CurrentCacheObject.Type, }); Logger.Log(TrinityLogLevel.Debug, LogCategory.CacheManagement, "Safely handled exception getting NoDamage attribute for object {0} [{1}]", CurrentCacheObject.InternalName, CurrentCacheObject.ActorSNO); c_IgnoreSubStep = "NoDamage"; AddToCache = false; } double minDistance; bool gizmoUsed = false; switch (CurrentCacheObject.Type) { case GObjectType.Door: { AddToCache = true; if (c_diaObject is DiaGizmo && ((DiaGizmo)c_diaObject).HasBeenOperated) { AddToCache = false; c_IgnoreSubStep = "Door has been operated"; return(AddToCache); } try { string currentAnimation = CurrentCacheObject.CommonData.CurrentAnimation.ToString().ToLower(); gizmoUsed = currentAnimation.EndsWith("open") || currentAnimation.EndsWith("opening"); // special hax for A3 Iron Gates if (currentAnimation.Contains("irongate") && currentAnimation.Contains("open")) { gizmoUsed = false; } if (currentAnimation.Contains("irongate") && currentAnimation.Contains("idle")) { gizmoUsed = true; } } catch { } if (gizmoUsed) { Blacklist3Seconds.Add(CurrentCacheObject.RActorGuid); AddToCache = false; c_IgnoreSubStep = "Door is Open or Opening"; return(AddToCache); } try { int gizmoState = CurrentCacheObject.CommonData.GetAttribute <int>(ActorAttributeType.GizmoState); if (gizmoState == 1) { AddToCache = false; c_IgnoreSubStep = "GizmoState=1"; return(AddToCache); } } catch { AddToCache = false; c_IgnoreSubStep = "GizmoStateException"; return(AddToCache); } if (untargetable) { MainGridProvider.AddCellWeightingObstacle(CurrentCacheObject.ActorSNO, CurrentCacheObject.Radius); CacheData.NavigationObstacles.Add(new CacheObstacleObject { ActorSNO = CurrentCacheObject.ActorSNO, Radius = CurrentCacheObject.Radius, Position = CurrentCacheObject.Position, RActorGUID = CurrentCacheObject.RActorGuid, ObjectType = CurrentCacheObject.Type, }); AddToCache = false; c_IgnoreSubStep = "Untargetable"; return(AddToCache); } if (AddToCache) { try { DiaGizmo door = null; if (c_diaObject is DiaGizmo) { door = (DiaGizmo)c_diaObject; if (door != null && door.IsGizmoDisabledByScript) { CacheData.NavigationObstacles.Add(new CacheObstacleObject { ActorSNO = CurrentCacheObject.ActorSNO, Radius = CurrentCacheObject.Radius, Position = CurrentCacheObject.Position, RActorGUID = CurrentCacheObject.RActorGuid, ObjectType = CurrentCacheObject.Type, }); Blacklist3Seconds.Add(CurrentCacheObject.RActorGuid); AddToCache = false; c_IgnoreSubStep = "DoorDisabledbyScript"; return(AddToCache); } } else { AddToCache = false; c_IgnoreSubStep = "InvalidCastToDoor"; } } catch { } } } break; case GObjectType.Interactable: { AddToCache = true; if (untargetable) { ((MainGridProvider)MainGridProvider).AddCellWeightingObstacle(CurrentCacheObject.ActorSNO, CurrentCacheObject.Radius); CacheData.NavigationObstacles.Add(new CacheObstacleObject() { ActorSNO = CurrentCacheObject.ActorSNO, Radius = CurrentCacheObject.Radius, Position = CurrentCacheObject.Position, RActorGUID = CurrentCacheObject.RActorGuid, ObjectType = CurrentCacheObject.Type, }); AddToCache = false; c_IgnoreSubStep = "Untargetable"; return(AddToCache); } int endAnimation; if (DataDictionary.InteractEndAnimations.TryGetValue(CurrentCacheObject.ActorSNO, out endAnimation)) { if (endAnimation == (int)CurrentCacheObject.Gizmo.CommonData.CurrentAnimation) { AddToCache = false; c_IgnoreSubStep = "EndAnimation"; return(AddToCache); } } if (CurrentCacheObject.Gizmo != null && CurrentCacheObject.Gizmo is GizmoLootContainer && CurrentCacheObject.Gizmo.HasBeenOperated) { AddToCache = false; c_IgnoreSubStep = "GizmoHasBeenOperated"; return(AddToCache); } CurrentCacheObject.Radius = c_diaObject.CollisionSphere.Radius; } break; case GObjectType.HealthWell: { AddToCache = true; try { gizmoUsed = (CurrentCacheObject.CommonData.GetAttribute <int>(ActorAttributeType.GizmoCharges) <= 0 && CurrentCacheObject.CommonData.GetAttribute <int>(ActorAttributeType.GizmoCharges) > 0); } catch { Logger.Log(TrinityLogLevel.Debug, LogCategory.CacheManagement, "Safely handled exception getting shrine-been-operated attribute for object {0} [{1}]", CurrentCacheObject.InternalName, CurrentCacheObject.ActorSNO); AddToCache = true; //return bWantThis; } try { int gizmoState = CurrentCacheObject.CommonData.GetAttribute <int>(ActorAttributeType.GizmoState); if (gizmoState == 1) { AddToCache = false; c_IgnoreSubStep = "GizmoState=1"; return(AddToCache); } } catch { AddToCache = false; c_IgnoreSubStep = "GizmoStateException"; return(AddToCache); } if (gizmoUsed) { c_IgnoreSubStep = "GizmoCharges"; AddToCache = false; return(AddToCache); } if (untargetable) { MainGridProvider.AddCellWeightingObstacle(CurrentCacheObject.ActorSNO, CurrentCacheObject.Radius); CacheData.NavigationObstacles.Add(new CacheObstacleObject { ActorSNO = CurrentCacheObject.ActorSNO, Radius = CurrentCacheObject.Radius, Position = CurrentCacheObject.Position, RActorGUID = CurrentCacheObject.RActorGuid, ObjectType = CurrentCacheObject.Type, }); AddToCache = false; c_IgnoreSubStep = "Untargetable"; return(AddToCache); } } break; case GObjectType.CursedShrine: case GObjectType.Shrine: { AddToCache = true; // Shrines // Check if either we want to ignore all shrines if (!Settings.WorldObject.UseShrine) { // We're ignoring all shrines, so blacklist this one c_IgnoreSubStep = "IgnoreAllShrinesSet"; AddToCache = false; return(AddToCache); } try { int gizmoState = CurrentCacheObject.CommonData.GetAttribute <int>(ActorAttributeType.GizmoState); if (gizmoState == 1) { AddToCache = false; c_IgnoreSubStep = "GizmoState=1"; return(AddToCache); } } catch { AddToCache = false; c_IgnoreSubStep = "GizmoStateException"; return(AddToCache); } if (untargetable) { MainGridProvider.AddCellWeightingObstacle(CurrentCacheObject.ActorSNO, CurrentCacheObject.Radius); CacheData.NavigationObstacles.Add(new CacheObstacleObject { ActorSNO = CurrentCacheObject.ActorSNO, Radius = CurrentCacheObject.Radius, Position = CurrentCacheObject.Position, RActorGUID = CurrentCacheObject.RActorGuid, ObjectType = CurrentCacheObject.Type, }); AddToCache = false; c_IgnoreSubStep = "Untargetable"; return(AddToCache); } // Determine what shrine type it is, and blacklist if the user has disabled it switch (CurrentCacheObject.ActorSNO) { case 176077: //Frenzy Shrine if (!Settings.WorldObject.UseFrenzyShrine) { Blacklist60Seconds.Add(CurrentCacheObject.RActorGuid); c_IgnoreSubStep = "IgnoreShrineOption"; AddToCache = false; } if (Player.ActorClass == ActorClass.Monk && Settings.Combat.Monk.TROption.HasFlag(TempestRushOption.MovementOnly) && Hotbar.Contains(SNOPower.Monk_TempestRush)) { // Frenzy shrines are a huge time sink for monks using Tempest Rush to move, we should ignore them. AddToCache = false; c_IgnoreSubStep = "IgnoreShrineOption"; return(AddToCache); } break; case 176076: //Fortune Shrine if (!Settings.WorldObject.UseFortuneShrine) { AddToCache = false; c_IgnoreSubStep = "IgnoreShrineOption"; return(AddToCache); } break; case 176074: //Protection Shrine if (!Settings.WorldObject.UseProtectionShrine) { AddToCache = false; c_IgnoreSubStep = "IgnoreShrineOption"; return(AddToCache); } break; case 260330: //Empowered Shrine if (!Settings.WorldObject.UseEmpoweredShrine) { AddToCache = false; c_IgnoreSubStep = "IgnoreShrineOption"; return(AddToCache); } break; case 176075: //Enlightened Shrine if (!Settings.WorldObject.UseEnlightenedShrine) { AddToCache = false; c_IgnoreSubStep = "IgnoreShrineOption"; return(AddToCache); } break; case 260331: //Fleeting Shrine if (!Settings.WorldObject.UseFleetingShrine) { AddToCache = false; c_IgnoreSubStep = "IgnoreShrineOption"; return(AddToCache); } break; } //end switch // Bag it! CurrentCacheObject.Radius = 4f; break; } case GObjectType.Barricade: { AddToCache = true; if (noDamage) { MainGridProvider.AddCellWeightingObstacle(CurrentCacheObject.ActorSNO, CurrentCacheObject.Radius); CacheData.NavigationObstacles.Add(new CacheObstacleObject { ActorSNO = CurrentCacheObject.ActorSNO, Radius = CurrentCacheObject.Radius, Position = CurrentCacheObject.Position, RActorGUID = CurrentCacheObject.RActorGuid, ObjectType = CurrentCacheObject.Type, }); AddToCache = false; c_IgnoreSubStep = "NoDamage"; return(AddToCache); } if (untargetable) { MainGridProvider.AddCellWeightingObstacle(CurrentCacheObject.ActorSNO, CurrentCacheObject.Radius); CacheData.NavigationObstacles.Add(new CacheObstacleObject { ActorSNO = CurrentCacheObject.ActorSNO, Radius = CurrentCacheObject.Radius, Position = CurrentCacheObject.Position, RActorGUID = CurrentCacheObject.RActorGuid, ObjectType = CurrentCacheObject.Type, }); AddToCache = false; c_IgnoreSubStep = "Untargetable"; return(AddToCache); } if (invulnerable) { MainGridProvider.AddCellWeightingObstacle(CurrentCacheObject.ActorSNO, CurrentCacheObject.Radius); CacheData.NavigationObstacles.Add(new CacheObstacleObject { ActorSNO = CurrentCacheObject.ActorSNO, Radius = CurrentCacheObject.Radius, Position = CurrentCacheObject.Position, RActorGUID = CurrentCacheObject.RActorGuid, ObjectType = CurrentCacheObject.Type, }); AddToCache = false; c_IgnoreSubStep = "Invulnerable"; return(AddToCache); } float maxRadiusDistance; if (DataDictionary.DestructableObjectRadius.TryGetValue(CurrentCacheObject.ActorSNO, out maxRadiusDistance)) { if (CurrentCacheObject.RadiusDistance < maxRadiusDistance) { AddToCache = true; c_IgnoreSubStep = ""; } } if (DateTime.UtcNow.Subtract(PlayerMover.LastGeneratedStuckPosition).TotalSeconds <= 1) { AddToCache = true; c_IgnoreSubStep = ""; break; } // Set min distance to user-defined setting minDistance = Settings.WorldObject.DestructibleRange + CurrentCacheObject.Radius; if (_forceCloseRangeTarget) { minDistance += 6f; } // This object isn't yet in our destructible desire range if (minDistance <= 0 || CurrentCacheObject.RadiusDistance > minDistance) { c_IgnoreSubStep = "NotInBarricadeRange"; AddToCache = false; return(AddToCache); } break; } case GObjectType.Destructible: { AddToCache = true; if (noDamage) { MainGridProvider.AddCellWeightingObstacle(CurrentCacheObject.ActorSNO, CurrentCacheObject.Radius); CacheData.NavigationObstacles.Add(new CacheObstacleObject { ActorSNO = CurrentCacheObject.ActorSNO, Radius = CurrentCacheObject.Radius, Position = CurrentCacheObject.Position, RActorGUID = CurrentCacheObject.RActorGuid, ObjectType = CurrentCacheObject.Type, }); AddToCache = false; c_IgnoreSubStep = "NoDamage"; return(AddToCache); } if (invulnerable) { MainGridProvider.AddCellWeightingObstacle(CurrentCacheObject.ActorSNO, CurrentCacheObject.Radius); CacheData.NavigationObstacles.Add(new CacheObstacleObject { ActorSNO = CurrentCacheObject.ActorSNO, Radius = CurrentCacheObject.Radius, Position = CurrentCacheObject.Position, RActorGUID = CurrentCacheObject.RActorGuid, ObjectType = CurrentCacheObject.Type, }); AddToCache = false; c_IgnoreSubStep = "Invulnerable"; return(AddToCache); } if (untargetable) { MainGridProvider.AddCellWeightingObstacle(CurrentCacheObject.ActorSNO, CurrentCacheObject.Radius); CacheData.NavigationObstacles.Add(new CacheObstacleObject { ActorSNO = CurrentCacheObject.ActorSNO, Radius = CurrentCacheObject.Radius, Position = CurrentCacheObject.Position, RActorGUID = CurrentCacheObject.RActorGuid, ObjectType = CurrentCacheObject.Type, }); AddToCache = false; c_IgnoreSubStep = "Untargetable"; return(AddToCache); } if (Player.ActorClass == ActorClass.Monk && Hotbar.Contains(SNOPower.Monk_TempestRush) && TimeSinceUse(SNOPower.Monk_TempestRush) <= 150) { AddToCache = false; c_IgnoreSubStep = "MonkTR"; break; } if (Player.ActorClass == ActorClass.Monk && Hotbar.Contains(SNOPower.Monk_SweepingWind) && GetHasBuff(SNOPower.Monk_SweepingWind)) { AddToCache = false; c_IgnoreSubStep = "MonkSW"; break; } if (CurrentCacheObject.IsQuestMonster || CurrentCacheObject.IsMinimapActive) { AddToCache = true; c_IgnoreSubStep = ""; break; } if (!DataDictionary.ForceDestructibles.Contains(CurrentCacheObject.ActorSNO) && Settings.WorldObject.DestructibleOption == DestructibleIgnoreOption.ForceIgnore) { AddToCache = false; c_IgnoreSubStep = "ForceIgnoreDestructibles"; break; } if (DateTime.UtcNow.Subtract(PlayerMover.LastGeneratedStuckPosition).TotalSeconds <= 1) { AddToCache = true; c_IgnoreSubStep = ""; break; } // Set min distance to user-defined setting minDistance = Settings.WorldObject.DestructibleRange; if (_forceCloseRangeTarget) { minDistance += 6f; } // Only break destructables if we're stuck and using IgnoreNonBlocking if (Settings.WorldObject.DestructibleOption == DestructibleIgnoreOption.DestroyAll) { minDistance += 12f; AddToCache = true; c_IgnoreSubStep = ""; } float maxRadiusDistance; if (DataDictionary.DestructableObjectRadius.TryGetValue(CurrentCacheObject.ActorSNO, out maxRadiusDistance)) { if (CurrentCacheObject.RadiusDistance < maxRadiusDistance) { AddToCache = true; c_IgnoreSubStep = ""; } } // Always add large destructibles within ultra close range if (!AddToCache && CurrentCacheObject.Radius >= 10f && CurrentCacheObject.RadiusDistance <= 5.9f) { AddToCache = true; c_IgnoreSubStep = ""; break; } // This object isn't yet in our destructible desire range if (AddToCache && (minDistance <= 1 || CurrentCacheObject.RadiusDistance > minDistance) && PlayerMover.GetMovementSpeed() >= 1) { AddToCache = false; c_IgnoreSubStep = "NotInDestructableRange"; } if (AddToCache && CurrentCacheObject.RadiusDistance <= 2f && DateTime.UtcNow.Subtract(PlayerMover.LastGeneratedStuckPosition).TotalMilliseconds > 500) { AddToCache = false; c_IgnoreSubStep = "NotStuck2"; } // Add if we're standing still and bumping into it if (CurrentCacheObject.RadiusDistance <= 2f && PlayerMover.GetMovementSpeed() <= 0) { AddToCache = true; c_IgnoreSubStep = ""; } if (CurrentCacheObject.RActorGuid == LastTargetRactorGUID) { AddToCache = true; c_IgnoreSubStep = ""; } break; } case GObjectType.CursedChest: case GObjectType.Container: { AddToCache = false; bool isRareChest = CurrentCacheObject.InternalName.ToLower().Contains("chest_rare") || DataDictionary.ResplendentChestIds.Contains(CurrentCacheObject.ActorSNO); bool isChest = (!isRareChest && CurrentCacheObject.InternalName.ToLower().Contains("chest")) || DataDictionary.ContainerWhiteListIds.Contains(CurrentCacheObject.ActorSNO); // We know it's a container but this is not a known rare chest bool isCorpse = CurrentCacheObject.InternalName.ToLower().Contains("corpse"); bool isWeaponRack = CurrentCacheObject.InternalName.ToLower().Contains("rack"); bool isGroundClicky = CurrentCacheObject.InternalName.ToLower().Contains("ground_clicky"); // We want to do some vendoring, so don't open anything new yet if (ForceVendorRunASAP) { AddToCache = false; c_IgnoreSubStep = "ForceVendorRunASAP"; } // Already open, blacklist it and don't look at it again bool chestOpen; try { chestOpen = (CurrentCacheObject.CommonData.GetAttribute <int>(ActorAttributeType.ChestOpen) > 0); } catch { Logger.Log(TrinityLogLevel.Debug, LogCategory.CacheManagement, "Safely handled exception getting container-been-opened attribute for object {0} [{1}]", CurrentCacheObject.InternalName, CurrentCacheObject.ActorSNO); c_IgnoreSubStep = "ChestOpenException"; AddToCache = false; return(AddToCache); } // Check if chest is open if (chestOpen) { // It's already open! AddToCache = false; c_IgnoreSubStep = "AlreadyOpen"; return(AddToCache); } if (untargetable) { MainGridProvider.AddCellWeightingObstacle(CurrentCacheObject.ActorSNO, CurrentCacheObject.Radius); CacheData.NavigationObstacles.Add(new CacheObstacleObject { ActorSNO = CurrentCacheObject.ActorSNO, Radius = CurrentCacheObject.Radius, Position = CurrentCacheObject.Position, RActorGUID = CurrentCacheObject.RActorGuid, ObjectType = CurrentCacheObject.Type, }); AddToCache = false; c_IgnoreSubStep = "Untargetable"; return(AddToCache); } // Resplendent chests have no range check if (isRareChest && Settings.WorldObject.OpenRareChests) { AddToCache = true; return(AddToCache); } // Regular container, check range if (CurrentCacheObject.RadiusDistance <= Settings.WorldObject.ContainerOpenRange) { if (isChest && Settings.WorldObject.OpenContainers) { return(true); } if (isCorpse && Settings.WorldObject.InspectCorpses) { return(true); } if (isGroundClicky && Settings.WorldObject.InspectGroundClicky) { return(true); } if (isWeaponRack && Settings.WorldObject.InspectWeaponRacks) { return(true); } } if (CurrentCacheObject.IsQuestMonster) { AddToCache = true; return(AddToCache); } if (Settings.WorldObject.OpenAnyContainer) { AddToCache = true; return(AddToCache); } if (!isChest && !isCorpse && !isRareChest) { c_IgnoreSubStep = "InvalidContainer"; } else { c_IgnoreSubStep = "IgnoreContainer"; } break; } } return(AddToCache); }
public static bool IsGizmoInteractable(DiaGizmo gizmo) { if (!gizmo.IsFullyValid()) { return(false); } if (GuardedGizmos.Contains(gizmo.ActorSnoId) && (gizmo.HasBeenOperated || gizmo.CommonData.ChestOpen > 0)) { return(false); } if (UsedGizmoAnimations.Contains(gizmo.CommonData.CurrentAnimation)) { return(false); } if (GuardedGizmos.Contains(gizmo.ActorSnoId) && !gizmo.HasBeenOperated && gizmo.CommonData.GetAttribute <int>(ActorAttributeType.Untargetable) != 1) { return(true); } if (gizmo is GizmoShrine && gizmo.CommonData.GizmoHasBeenOperated != 1 && gizmo.CommonData.GizmoState != 1) // Buggy Cursed Shrine { return(true); } switch (gizmo.CommonData.GizmoType) { case GizmoType.Chest: return(gizmo.CommonData.ChestOpen == 0); case GizmoType.Portal: case GizmoType.DungeonPortal: return (!AdvDia.CurrentWorldMarkers.Any( m => m.Position.Distance(gizmo.Position) < 10 && EntryPortals.IsEntryPortal(AdvDia.CurrentWorldDynamicId, m.NameHash))); case GizmoType.PortalDestination: case GizmoType.PoolOfReflection: case GizmoType.Headstone: case GizmoType.HealingWell: case GizmoType.PowerUp: return(false); case GizmoType.LootRunSwitch: case GizmoType.MultiClick: return(true); case GizmoType.Switch: if (gizmo.ActorSnoId == SNOActor.x1_Fortress_Portal_Switch) { return(true); } break; } if (GizmoInteractBlacklist.Contains(gizmo.ActorSnoId)) { return(false); } //if (GizmoInteractWhitelist.Contains(gizmo.ActorSnoId)) //{ // return true; //} if (gizmo.IsGizmoDisabledByScript || gizmo.CommonData.GetAttribute <int>(ActorAttributeType.Untargetable) == 1) { return(false); } if (gizmo.ActorSnoId == SNOActor.p43_AD_Valor_Pedestal && gizmo.CommonData?.MinimapActive == 1) { return(true); //p43_AD_Valor_Pedestal-19848 Special Valor Event in Diablo1 Area } if (gizmo.HasBeenOperated) { return(false); } //if (gizmo is GizmoLootContainer || gizmo is GizmoShrine || gizmo.CommonData.GizmoType == GizmoType.Switch) //{ // return true; //} if ((gizmo.CommonData.MinimapVisibilityFlags & 0x80) != 0) { return(true); } if (gizmo.CommonData.GetAttribute <int>(ActorAttributeType.MinimapActive) == 1) { return(true); } if (CursedGizmos.Contains(gizmo.ActorSnoId)) { return(true); } if (InteractWhitelist.Contains(gizmo.ActorSnoId)) { return(true); } return(false); }
public static bool IsEntryPortal(DiaGizmo portal) { var sno = portal.ActorSNO; var x = (int) portal.Position.X; var y = (int) portal.Position.Y; if (!EntryPortals.ContainsKey(AdvDia.CurrentWorldDynamicId)) { return false; } var worldPortal = EntryPortals[AdvDia.CurrentWorldDynamicId]; return worldPortal.ActorSNO == sno && worldPortal.X == x && worldPortal.Y == y; }
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; }
private async Task<bool> MovingToDeathGate() { if (_deathGate != null && _deathGate.IsFullyValid()) { if (AdvDia.MyPosition.Distance(_deathGate.Position) <= 7f) { Navigator.PlayerMover.MoveStop(); MoveResult = MoveResult.ReachedDestination; } else { _deathGate = ActorFinder.FindNearestDeathGate(_deathGateIgnoreList); if (_deathGate == null) { MoveResult = MoveResult.Failed; State = States.Failed; return false; } MoveResult = await CommonCoroutines.MoveTo(_deathGate.Position); } switch (MoveResult) { case MoveResult.ReachedDestination: var distance = AdvDia.MyPosition.Distance(_deathGate.Position); if (distance <= 7f) { _interactionCoroutine = new InteractionCoroutine(_deathGate.ActorSNO, new TimeSpan(0, 0, 1), new TimeSpan(0, 0, 3)); State = States.InteractingWithDeathGate; } else { _deathGateIgnoreList.Add(_deathGate.ACDGuid); State = States.Moving; } break; case MoveResult.Failed: case MoveResult.PathGenerationFailed: State = States.Failed; break; case MoveResult.PathGenerated: break; case MoveResult.UnstuckAttempt: if (_unstuckAttemps > 1) { State = States.Failed; return false; } _unstuckAttemps++; Logger.Debug("[Navigation] Unstuck attempt #{0}", _unstuckAttemps); break; case MoveResult.Moved: case MoveResult.PathGenerating: break; } return false; } State = States.Failed; return false; }
private async Task <bool> Moving() { if (_deathGateLocation != Vector3.Zero) { if (!await NavigationCoroutine.MoveTo(_deathGateLocation, 5)) { return(false); } _deathGateLocation = Vector3.Zero; } if (!await NavigationCoroutine.MoveTo(_objectiveLocation, 5)) { return(false); } if (NavigationCoroutine.LastMoveResult == MoveResult.UnstuckAttempt) { Core.Logger.Debug("Navigation ended with unstuck attempts last result."); Navigator.Clear(); } if (AdvDia.MyPosition.Distance(_objectiveLocation) > 50 && NavigationCoroutine.LastResult == CoroutineResult.Failure) { Core.Logger.Debug("[EnterLevelAreaCoroutine] Navigation ended, extending scan radius to continue searching."); NavigationCoroutine.Reset(); _previouslyFoundLocation = _objectiveLocation; _returnTimeForPreviousLocation = PluginTime.CurrentMillisecond; _objectiveLocation = Vector3.Zero; _objectiveScanRange = ActorFinder.LowerSearchRadius(_objectiveScanRange); if (_objectiveScanRange <= 0) { _objectiveScanRange = 50; } State = States.Searching; return(false); } DiaGizmo portal = null; if (_portalActorIds != null) { foreach (var portalid in _portalActorIds) { portal = ActorFinder.FindGizmo(portalid); if (portal != null) { _portalActorId = portal.ActorSnoId; break; } } } else { portal = ActorFinder.FindGizmo(_portalActorId); } if (portal == null) { portal = BountyHelpers.GetPortalNearPosition(_objectiveLocation); if (portal != null) { _discoveredPortalActorId = portal.ActorSnoId; } else if (_portalActorId == 0) { portal = ZetaDia.Actors.GetActorsOfType <GizmoPortal>().OrderBy(d => d.Distance).FirstOrDefault(); if (portal != null) { _discoveredPortalActorId = portal.ActorSnoId; Core.Logger.Log($"[EnterLevelArea] Unable to find the portal we needed, using this one instead {portal.Name} ({portal.ActorSnoId})"); } } } if (portal == null) { State = States.Searching; return(false); } _interactRange = portal.CollisionSphere.Radius; // Add some tolerance, sometimes the radius is pretty low and it will keep stuck trying to move to it even when it's right besides it. _interactRange += ZetaDia.Me.CollisionSphere.Radius; Core.Logger.Debug($"[EnterLevelArea] Using interact range from portal: {_interactRange}"); if (portal.Position.Distance(_objectiveLocation) > _interactRange) { Core.Logger.Debug($"[EnterLevelArea] Portal is still too far away, something went wrong with NavigationCoroutine"); await CommonCoroutines.MoveTo(portal.Position); State = States.Searching; return(false); } _objectiveLocation = portal.Position; State = States.Entering; _prePortalWorldDynamicId = AdvDia.CurrentWorldDynamicId; Core.PlayerMover.MoveTowards(portal.Position); await Coroutine.Sleep(1000); return(false); }
public static bool IsGizmoInteractable(DiaGizmo gizmo) { if (!gizmo.IsFullyValid()) { return(false); } if (GuardedGizmos.Contains(gizmo.ActorSNO) && gizmo.HasBeenOperated) { return(false); } if (GuardedGizmos.Contains(gizmo.ActorSNO) && !gizmo.HasBeenOperated && gizmo.CommonData.GetAttribute <int>(ActorAttributeType.Untargetable) != 1) { return(true); } switch (gizmo.CommonData.GizmoType) { case GizmoType.Portal: case GizmoType.DungeonPortal: return(!AdvDia.CurrentWorldMarkers.Any(m => m.Position.Distance2D(gizmo.Position) < 10 && EntryPortals.IsEntryPortal(AdvDia.CurrentWorldDynamicId, m.NameHash))); case GizmoType.PortalDestination: case GizmoType.PoolOfReflection: case GizmoType.Headstone: case GizmoType.HealingWell: case GizmoType.PowerUp: return(false); case GizmoType.LootRunSwitch: return(true); case GizmoType.Switch: if (gizmo.ActorSNO == 328830) { return(true); } break; } if (GizmoInteractBlacklist.Contains(gizmo.ActorSNO)) { return(false); } //if (GizmoInteractWhitelist.Contains(gizmo.ActorSNO)) //{ // return true; //} if (gizmo.IsGizmoDisabledByScript || gizmo.CommonData.GetAttribute <int>(ActorAttributeType.Untargetable) == 1) { return(false); } if (gizmo.HasBeenOperated) { return(false); } //if (gizmo is GizmoLootContainer || gizmo is GizmoShrine || gizmo.CommonData.GizmoType == GizmoType.Switch) //{ // return true; //} if ((gizmo.CommonData.MinimapVisibilityFlags & 0x80) != 0) { return(true); } if (gizmo.CommonData.GetAttribute <int>(ActorAttributeType.MinimapActive) == 1) { return(true); } if (CursedGizmos.Contains(gizmo.ActorSNO)) { return(true); } if (InteractWhitelist.Contains(gizmo.ActorSNO)) { return(true); } return(false); }
public static async Task <bool> OpenRift(RiftType riftType, int maxLevel, int maxEmpowerLevel, bool shouldEmpower, bool runNormalUntilXP) { if (IsRiftPortalOpen) { return(IsRiftPortalOpen); } var riftKeys = CurrentRiftKeyCount; if (riftType == RiftType.Greater && riftKeys <= PluginSettings.Current.MinimumKeys && !PluginSettings.Current.GreaterRiftRunNephalem) { s_logger.Error($"[{nameof(OpenRift)}] You have no Greater Rift Keys. Stopping the bot."); BotMain.Stop(); return(false); } s_logger.Debug($"[{nameof(OpenRift)}] I have {riftKeys} rift keys."); if (await EnsureIsInTown() == CoroutineResult.Running) { return(false); } if (riftKeys <= PluginSettings.Current.MinimumKeys) { riftType = RiftType.Nephalem; } // TODO: Figure out why there is that check against that magic. var maximizeXp = runNormalUntilXP && riftType == RiftType.Greater && ZetaDia.Me.RestExperience <5000000000 && ZetaDia.Me.RestExperience> -1; if (maximizeXp) { riftType = RiftType.Nephalem; } var level = Math.Min(riftType == RiftType.Greater ? RiftData.GetGreaterRiftLevel() : -1, maxLevel); var isEmpowered = riftType == RiftType.Greater && shouldEmpower && level <= maxEmpowerLevel && RiftData.EmpoweredRiftCost.TryGetValue(level, out var empoweredCost) && ZetaDia.Storage.PlayerDataManager.ActivePlayerData.Coinage >= (empoweredCost + PluginSettings.Current.MinimumGold); DiaGizmo lrs = LootRunSwitch; if (lrs == null) { await CommonCoroutines.MoveTo(ZetaDia.Actors.GetActorsOfType <DiaGizmo>() .Where(g => g.Distance > 10f) .OrderByDescending(g => g.Distance) .FirstOrDefault()); return(false); } if (!s_experienceTracker.IsStarted) { s_experienceTracker.Start(); } if (await CommonCoroutines.MoveAndInteract( lrs, () => UIElements.RiftDialog.IsVisible) == CoroutineResult.Running) { return(false); } ZetaDia.Me.OpenRift(level, isEmpowered); return(await Coroutine.Wait(TimeSpan.FromSeconds(2), () => IsRiftPortalOpen)); }
private async Task <bool> MovingToDeathGate() { if (_deathGate != null && _deathGate.IsFullyValid()) { if (AdvDia.MyPosition.Distance(_deathGate.Position) <= 7f) { Navigator.PlayerMover.MoveStop(); MoveResult = MoveResult.ReachedDestination; } else { _deathGate = ActorFinder.FindNearestDeathGate(_deathGateIgnoreList); if (_deathGate == null) { MoveResult = MoveResult.Failed; State = States.Failed; return(false); } MoveResult = await CommonCoroutines.MoveTo(_deathGate.Position); } switch (MoveResult) { case MoveResult.ReachedDestination: var distance = AdvDia.MyPosition.Distance(_deathGate.Position); if (distance <= 7f) { _interactionCoroutine = new InteractionCoroutine(_deathGate.ActorSnoId, new TimeSpan(0, 0, 1), new TimeSpan(0, 0, 3)); State = States.InteractingWithDeathGate; } else { _deathGateIgnoreList.Add(_deathGate.ACDId); State = States.Moving; } break; case MoveResult.Failed: case MoveResult.PathGenerationFailed: State = States.Failed; break; case MoveResult.PathGenerated: break; case MoveResult.UnstuckAttempt: if (_unstuckAttemps > 1) { State = States.Failed; return(false); } _unstuckAttemps++; Logger.Debug("[Navigation] Unstuck attempt #{0}", _unstuckAttemps); break; case MoveResult.Moved: case MoveResult.PathGenerating: break; } return(false); } State = States.Failed; return(false); }