public void BaseInit(DiaObject nativeObject) { DiaUnit = nativeObject; ActorSNO = DiaUnit.ActorSNO; Name = nativeObject.Name; ACDGuid = nativeObject.ACDGuid; }
private static ActorMeta CreateActorMeta(DiaObject diaObject, ACD acd, int actorSNO, ActorType actorType) { using (new PerformanceLogger("CreateActorMeta")) { ActorMeta actorMeta; // We only care about having accurate information on Units and Gizmos. // Everything else can just return the default. //if (actorType == ActorType.Monster && diaObject is DiaUnit || // actorType == ActorType.Gizmo && diaObject is DiaGizmo || // actorType == ActorType.Player) //{ actorMeta = new ActorMeta(diaObject, acd, actorSNO, actorType); if (Trinity.Settings.Advanced.ExportNewActorMeta && actorMeta.IsValid && !actorMeta.IsPartial) { Logger.Log("Exporting ActorMeta for {0} ({1})", acd.Name, actorSNO); WriteToLog(actorMeta); } //} //else if (actorType == ActorType.Player) //{ // actorMeta = new ActorMeta(diaObject, acd, actorSNO, actorType); //} //else //{ // actorMeta = new ActorMeta(); //} ReferenceActorMeta.Add(actorSNO, actorMeta); return actorMeta; } }
public bool Update(DiaObject actor) { if (actor == null) return false; if (!actor.IsValid) return false; RActor = actor; RActorGuid = actor.RActorGuid; ACDGuid = actor.ACDGuid; ActorSNO = actor.ActorSNO; Name = actor.Name; Position = actor.Position; Distance = actor.Distance; Radius = actor.CollisionSphere.Radius; RadiusDistance = Distance - Radius; if (actor.ActorType == Zeta.Game.Internals.SNO.ActorType.Gizmo) IsReturnPortal = actor.ActorInfo.GizmoType == Zeta.Game.Internals.SNO.GizmoType.ReturnPortal; if (actor.ActorType == Zeta.Game.Internals.SNO.ActorType.Monster) IsMonster = true; return true; }
public void Reset() { _isDone = false; _state = States.NotStarted; _actor = null; _attackSkill = SNOPower.None; _attackRange = 10; }
private static double GetAttribute(DiaObject o, ActorAttributeType aType) { try { return o.CommonData.GetAttribute<double>(aType); } catch { return (double)(-1); } }
private static List<DiaObject> GetUnitsChainWillJumpTo(DiaObject target, List<DiaObject> otherUnits, float chainRange) { var targetLoc = target.Position; var targetGuid = target.ACDGuid; for (int i = otherUnits.Count - 1; i >= 0; i--) { if (otherUnits[i].ACDGuid == targetGuid || otherUnits[i].Position.DistanceSqr(targetLoc) > chainRange) otherUnits.RemoveAt(i); } return otherUnits; }
private static double GetAttribute(double iType, DiaObject o, ActorAttributeType aType) { try { iType = (double)o.CommonData.GetAttribute<ActorAttributeType>(aType); } catch { iType = -1; } return iType; }
public static ActorMeta GetOrCreateActorMeta(DiaObject diaObject, ACD acd, int actorSNO, ActorType actorType) { using (new PerformanceLogger("GetOrCreateActorMeta")) { ActorMeta actorMeta; if (!ReferenceActorMeta.TryGetValue(actorSNO, out actorMeta)) { actorMeta = CreateActorMeta(diaObject, acd, actorSNO, actorType); } return actorMeta; } }
internal static void LogUnknown(DiaObject diaObject) { if (!LogCategoryEnabled(LogCategory.UnknownObjects) || !diaObject.IsValid || !diaObject.CommonData.IsValid) return; // Log Object if (!_seenUnknownCache.ContainsKey(diaObject.ActorSNO)) { Logger.Log(LogCategory.UnknownObjects, "{0} ({1}) Type={2}", diaObject.Name, diaObject.ActorSNO, diaObject.ActorType); _seenUnknownCache.Add(diaObject.ActorSNO, DateTime.UtcNow); } CacheMaintenance(); }
public Interactable(DiaObject obj) { InternalName = obj.Name; BaseInternalName = Common.GetBaseInternalName(obj.Name); ActorPosition = obj.Position; ActorSnoId = obj.ActorSnoId; AcdId = obj.ACDId; TimeFirstSeen = DateTime.UtcNow; LastTimeCloseTo = DateTime.UtcNow; GizmoType = obj.CommonData.GizmoType; WorldSnoId = ZetaDia.CurrentWorldSnoId; var marker = ZetaDia.Minimap.Markers.AllMarkers.FirstOrDefault(m => m.Position.Distance(ActorPosition) < 15f); if (marker != null) MarkerHash = marker.NameHash; }
public Target(DiaObject actor) { if (!Data.IsValid(actor)) return; Id = actor.ActorSnoId; AcdId = actor.ACDId; Name = actor.Name; WorldSnoId = Player.CurrentWorldSnoId; var quality = actor.CommonData.MonsterQualityLevel; if (!Enum.IsDefined(typeof(MonsterQuality), quality) || (int) quality == -1) quality = MonsterQuality.Normal; Quality = quality; Position = actor.Position; }
public static async Task<bool> MoveToAndInteract(DiaObject obj, float range = -1f) { if (obj == null) return false; if (!obj.IsFullyValid()) return false; if (range == -1f) range = obj.CollisionSphere.Radius; if (obj.Position.Distance2D(ZetaDia.Me.Position) > range) await MoveTo(obj.Position, obj.Name); if (obj.Position.Distance2D(ZetaDia.Me.Position) < range) obj.Interact(); return true; }
/// <summary> /// Moves to something and interacts with it /// </summary> /// <param name="obj">object to interact with</param> /// <param name="range">how close to get</param> /// <param name="interactLimit">maximum number of times to interact</param> public static async Task<bool> Execute(DiaObject obj, float range = -1f, int interactLimit = 5) { if (obj == null) return false; if (!obj.IsFullyValid()) return false; if (interactLimit < 1) interactLimit = 5; if (range < 0) range = obj.CollisionSphere.Radius; if (obj.Position.Distance(ZetaDia.Me.Position) > range) { if (!await MoveTo.Execute(obj.Position, obj.Name)) { Logger.Log("MoveTo Failed for {0} ({1}) Distance={2}", obj.Name, obj.ActorSNO, obj.Distance); return false; } } var distance = obj.Position.Distance(ZetaDia.Me.Position); if (distance <= range || distance - obj.CollisionSphere.Radius <= range) { for (int i = 1; i <= interactLimit; i++) { Logger.LogVerbose("Interacting with {0} ({1}) Attempt={2}", obj.Name, obj.ActorSNO, i); if (obj.Interact() && i > 1) break; await Coroutine.Sleep(500); await Coroutine.Yield(); } } // Better to be redundant than failing to interact. Navigator.PlayerMover.MoveTowards(obj.Position); await Coroutine.Sleep(500); obj.Interact(); Navigator.PlayerMover.MoveStop(); await Coroutine.Sleep(1000); await Interact(obj); return true; }
private static void MonitorActors(DiaObject testunit, Dictionary<int, HashSet<ActorAttributeType>> unitAtts) { var existingAtts = unitAtts.GetOrCreateValue(testunit.ACDGuid, new HashSet<ActorAttributeType>()); var atts = Enum.GetValues(typeof (ActorAttributeType)).Cast<ActorAttributeType>().ToList(); foreach (var att in atts) { try { var attiResult = testunit.CommonData.GetAttribute<int>(att); var attfResult = testunit.CommonData.GetAttribute<float>(att); var hasValue = attiResult > 0 || !float.IsNaN(attfResult) && attfResult > 0; if (hasValue) { if (!existingAtts.Contains(att)) { Logger.Log("Unit {0} has gained {1} (i:{2} f:{3:00.00000})", testunit.Name, att.ToString(), attiResult, attfResult); existingAtts.Add(att); } } else { if (existingAtts.Contains(att)) { Logger.Log("Unit {0} has lost {1} (i:{2} f:{3:00.00000})", testunit.Name, att.ToString(), attiResult, attfResult); existingAtts.Remove(att); } } } catch (Exception) { } } var allpowers = Enum.GetValues(typeof (SNOPower)).Cast<SNOPower>().ToList(); var allBuffAttributes = Enum.GetValues(typeof (ActorAttributeType)).Cast<ActorAttributeType>().Where(a => a.ToString().Contains("Power")).ToList(); var checkpowers = new HashSet<SNOPower> { SNOPower.MonsterAffix_ReflectsDamage, SNOPower.MonsterAffix_ReflectsDamageCast, SNOPower.Monk_ExplodingPalm }; foreach (var power in allpowers) { foreach (var buffattr in allBuffAttributes) { try { if (testunit.CommonData.GetAttribute<int>(((int) power << 12) + ((int) buffattr & 0xFFF)) == 1) { Logger.Log("Unit {0} has {1} ({2})", testunit.Name, power, buffattr); } } catch (Exception) { } } } }
private async Task<bool> Interact(DiaObject actor) { Logger.Debug("[Interaction] Attempting to interact with {0} at distance {1}", ((SNOActor)actor.ActorSNO).ToString(), actor.Distance); bool retVal = false; switch (actor.ActorType) { case ActorType.Gizmo: switch (actor.ActorInfo.GizmoType) { case GizmoType.BossPortal: case GizmoType.Portal: case GizmoType.ReturnPortal: retVal = ZetaDia.Me.UsePower(SNOPower.GizmoOperatePortalWithAnimation, actor.Position); break; default: retVal = ZetaDia.Me.UsePower(SNOPower.Axe_Operate_Gizmo, actor.Position); break; } break; case ActorType.Monster: retVal = ZetaDia.Me.UsePower(SNOPower.Axe_Operate_NPC, actor.Position); break; } // Doubly-make sure we interact actor.Interact(); await Coroutine.Sleep(_sleepTime); return retVal; }
public TrinityItem(DiaObject rActor) : base(rActor) { }
public TrinityUnit(DiaObject rActor) : base(rActor) { }
public TrinityGizmo(DiaObject rActor) : base(rActor) { }
public CacheGizmo(DiaObject dia) : base(dia) { CacheType = CacheType.Gizmo; }
public GilesObject(DiaObject _DiaObject = null) { DiaObject = _DiaObject; }
private static bool CacheDiaObject(DiaObject freshObject) { if (!freshObject.IsValid) { c_IgnoreReason = "InvalidRActor"; return false; } if (freshObject.CommonData == null) { c_IgnoreReason = "ACDNull"; return false; } if (!freshObject.CommonData.IsValid) { c_IgnoreReason = "InvalidACD"; return false; } /* * Initialize Variables */ bool AddToCache = true; RefreshStepInit(); /* * Get primary reference objects and keys */ CurrentCacheObject.Object = c_diaObject = freshObject; try { // RActor GUID CurrentCacheObject.RActorGuid = freshObject.RActorGuid; // Check to see if we've already looked at this GUID CurrentCacheObject.ACDGuid = freshObject.ACDGuid; // Get Name CurrentCacheObject.InternalName = NameNumberTrimRegex.Replace(freshObject.Name, ""); CurrentCacheObject.ActorSNO = freshObject.ActorSNO; CurrentCacheObject.ActorType = freshObject.ActorType; CurrentCacheObject.ACDGuid = freshObject.ACDGuid; } catch (Exception) { c_IgnoreReason = "Error reading IDs"; return false; } if (CurrentCacheObject.ActorType == ActorType.Item && ItemDropper.DroppedItems.Contains(freshObject.CommonData.DynamicId)) { c_IgnoreReason = "DroppedThisItem"; return false; } CurrentCacheObject.LastSeenTime = DateTime.UtcNow; // Position CurrentCacheObject.Position = c_diaObject.Position; // Distance CurrentCacheObject.Distance = Player.Position.Distance2D(CurrentCacheObject.Position); float radius; if (!DataDictionary.CustomObjectRadius.TryGetValue(CurrentCacheObject.ActorSNO, out radius)) { try { radius = c_diaObject.CollisionSphere.Radius; } catch (Exception ex) { Logger.LogError(LogCategory.CacheManagement, "Error refreshing Radius: {0}", ex.Message); } } // Radius Distance CurrentCacheObject.Radius = radius; // Have ActorSNO Check for SNO based navigation obstacle hashlist c_IsObstacle = DataDictionary.NavigationObstacleIds.Contains(CurrentCacheObject.ActorSNO); var isGizmo = CurrentCacheObject.Object is DiaGizmo; if (isGizmo) { //var isBreakableDoor = CurrentCacheObject.CommonData.GizmoType == GizmoType.BreakableDoor; //if (isBreakableDoor && CurrentCacheObject.CommonData.GetAttribute<int>(ActorAttributeType.DamageStateCurrent) == CurrentCacheObject.CommonData.GetAttribute<int>(ActorAttributeType.DamageStateMax)) //{ // c_IgnoreSubStep = "MaxDamageState"; // return false; //} var isShrine = CurrentCacheObject.Object is GizmoShrine; if (isShrine) { if (CurrentCacheObject.CommonData.GetAttribute<int>(ActorAttributeType.GizmoState) > 0) { c_IgnoreSubStep = "GizmoState1"; return false; } if (CurrentCacheObject.CommonData.GetAttribute<int>(ActorAttributeType.GizmoHasBeenOperated) > 0) { c_IgnoreSubStep = "GizmoHasBeenOperated "; return false; } if (CurrentCacheObject.CommonData.GetAttribute<int>(ActorAttributeType.GizmoOperatorACDID) > 0) { c_IgnoreSubStep = "GizmoHasBeenOperated "; return false; } } } //if (Math.Abs(CurrentCacheObject.CommonData.GetAttribute<int>(ActorAttributeType.HitpointsCur)) < float.Epsilon) //{ // c_IgnoreSubStep = "Dead (Hitpoints)"; // return false; //} //if (CurrentCacheObject.CommonData.GetAttribute<int>(ActorAttributeType.DeletedOnServer) > 0 || CurrentCacheObject.CommonData.GetAttribute<int>(ActorAttributeType.CouldHaveRagdolled) > 1) //{ // c_IgnoreSubStep = "DeletedOnServer"; // return false; //} //if (CurrentCacheObject.CommonData.IsDisposed) //{ // c_IgnoreSubStep = "Disposed"; // return false; //} //if (CurrentCacheObject.CommonData.AnimationState == AnimationState.Dead) //{ // c_IgnoreSubStep = "Dead"; // return false; //} //CurrentCacheObject.Animation = CurrentCacheObject.CommonData.CurrentAnimation; //var lowerAnim = CurrentCacheObject.Animation.ToString().ToLowerInvariant(); //if (lowerAnim.Contains("_dead") || (lowerAnim.Contains("_death") && !lowerAnim.Contains("deathmaiden"))) //{ // c_IgnoreSubStep = "Dead"; // return false; //} // Add Cell Weight for Obstacle if (c_IsObstacle) { Vector3 pos; if (!CacheData.Position.TryGetValue(CurrentCacheObject.RActorGuid, out pos)) { CurrentCacheObject.Position = c_diaObject.Position; //CacheData.Position.Add(CurrentCacheObject.RActorGuid, CurrentCacheObject.Position); } if (pos != Vector3.Zero) CurrentCacheObject.Position = pos; CacheData.NavigationObstacles.Add(new CacheObstacleObject() { ActorSNO = CurrentCacheObject.ActorSNO, Name = CurrentCacheObject.InternalName, Position = CurrentCacheObject.Position, Radius = CurrentCacheObject.Radius, ObjectType = CurrentCacheObject.Type, }); // Forge Still being walked into, increasing radius. // [228D379C] Type: Monster Name: a3_Battlefield_demonic_forge-661599 ActorSNO: 174900, Distance: 9.246254 var forceIds = new HashSet<int> {174900, 185391}; var r = forceIds.Contains(CurrentCacheObject.ActorSNO) ? 25f : CurrentCacheObject.Radius; MainGridProvider.AddCellWeightingObstacle(CurrentCacheObject.ActorSNO, r); c_IgnoreReason = "NavigationObstacle"; AddToCache = false; return AddToCache; } using (new PerformanceLogger("RefreshDiaObject.CachedType")) { /* * Set Object Type */ AddToCache = RefreshStepCachedObjectType(AddToCache); if (!AddToCache) { c_IgnoreReason = "CachedObjectType"; return AddToCache; } } // Summons by the player AddToCache = RefreshStepCachedSummons(); if (!AddToCache) { c_IgnoreReason = "CachedPlayerSummons"; return false; } CurrentCacheObject.Type = CurrentCacheObject.Type; if (CurrentCacheObject.Type != TrinityObjectType.Item) { CurrentCacheObject.ObjectHash = HashGenerator.GenerateWorldObjectHash(CurrentCacheObject.ActorSNO, CurrentCacheObject.Position, CurrentCacheObject.Type.ToString(), CurrentWorldDynamicId); } // Check Blacklists AddToCache = RefreshStepCheckBlacklists(AddToCache); if (!AddToCache) { c_IgnoreReason = "CheckBlacklists"; return AddToCache; } if (CurrentCacheObject.Type == TrinityObjectType.Item) { if (GenericBlacklist.ContainsKey(CurrentCacheObject.ObjectHash)) { AddToCache = false; c_IgnoreReason = "GenericBlacklist"; return AddToCache; } } // Always Refresh ZDiff for every object AddToCache = RefreshStepObjectTypeZDiff(AddToCache); if (!AddToCache) { c_IgnoreReason = "ZDiff"; return AddToCache; } using (new PerformanceLogger("RefreshDiaObject.MainObjectType")) { /* * Main Switch on Object Type - Refresh individual object types (Units, Items, Gizmos) */ RefreshStepMainObjectType(ref AddToCache); if (!AddToCache) { c_IgnoreReason = "MainObjectType"; return AddToCache; } } if (CurrentCacheObject.ObjectHash != String.Empty && GenericBlacklist.ContainsKey(CurrentCacheObject.ObjectHash)) { AddToCache = false; c_IgnoreSubStep = "GenericBlacklist"; return AddToCache; } // Ignore anything unknown AddToCache = RefreshStepIgnoreUnknown(AddToCache); if (!AddToCache) { c_IgnoreReason = "IgnoreUnknown"; return AddToCache; } using (new PerformanceLogger("RefreshDiaObject.LoS")) { // Ignore all LoS AddToCache = RefreshStepIgnoreLoS(AddToCache); if (!AddToCache) { c_IgnoreReason = "IgnoreLoS"; return AddToCache; } } string extraData = ""; switch (CurrentCacheObject.Type) { case TrinityObjectType.Unit: { if (c_IsEliteRareUnique) extraData += " IsElite " + c_MonsterAffixes; if (c_unit_HasShieldAffix) extraData += " HasAffixShielded"; if (c_HasDotDPS) extraData += " HasDotDPS"; if (c_HasBeenInLoS) extraData += " HasBeenInLoS"; if (CurrentCacheObject.IsUnit) extraData += " HP=" + c_HitPoints.ToString("0") + " (" + c_HitPointsPct.ToString("0.00") + ")"; } break; case TrinityObjectType.Avoidance: { extraData += _standingInAvoidance ? "InAoE " : ""; break; } } CurrentCacheObject.ExtraInfo = extraData; // If it's a unit, add it to the monster cache AddUnitToMonsterObstacleCache(); c_IgnoreReason = "None"; CurrentCacheObject.ACDGuid = CurrentCacheObject.ACDGuid; CurrentCacheObject.ActorSNO = CurrentCacheObject.ActorSNO; CurrentCacheObject.Animation = c_CurrentAnimation; CurrentCacheObject.DBItemBaseType = c_DBItemBaseType; CurrentCacheObject.DBItemType = c_DBItemType; CurrentCacheObject.Distance = CurrentCacheObject.Distance; CurrentCacheObject.DynamicID = CurrentCacheObject.DynamicID; CurrentCacheObject.FollowerType = c_item_tFollowerType; CurrentCacheObject.GameBalanceID = CurrentCacheObject.GameBalanceID; CurrentCacheObject.GoldAmount = c_GoldStackSize; CurrentCacheObject.HasAffixShielded = c_unit_HasShieldAffix; CurrentCacheObject.HasBeenInLoS = c_HasBeenInLoS; CurrentCacheObject.HasBeenNavigable = c_HasBeenNavigable; CurrentCacheObject.HasBeenRaycastable = c_HasBeenRaycastable; CurrentCacheObject.HasDotDPS = c_HasDotDPS; CurrentCacheObject.HitPoints = c_HitPoints; CurrentCacheObject.HitPointsPct = c_HitPointsPct; CurrentCacheObject.InternalName = CurrentCacheObject.InternalName; CurrentCacheObject.IsAttackable = c_unit_IsAttackable; CurrentCacheObject.IsElite = c_unit_IsElite; CurrentCacheObject.IsEliteRareUnique = c_IsEliteRareUnique; CurrentCacheObject.IsMinion = c_unit_IsMinion; CurrentCacheObject.IsRare = c_unit_IsRare; CurrentCacheObject.IsTreasureGoblin = c_unit_IsTreasureGoblin; CurrentCacheObject.IsUnique = c_unit_IsUnique; CurrentCacheObject.ItemLevel = c_ItemLevel; CurrentCacheObject.ItemLink = c_ItemLink; CurrentCacheObject.ItemQuality = c_ItemQuality; CurrentCacheObject.MonsterAffixes = c_MonsterAffixes; CurrentCacheObject.MonsterSize = c_unit_MonsterSize; CurrentCacheObject.OneHanded = c_IsOneHandedItem; CurrentCacheObject.RActorGuid = CurrentCacheObject.RActorGuid; CurrentCacheObject.Radius = CurrentCacheObject.Radius; CurrentCacheObject.TrinityItemType = _cItemTinityItemType; CurrentCacheObject.TwoHanded = c_IsTwoHandedItem; CurrentCacheObject.Type = CurrentCacheObject.Type; CurrentCacheObject.IsAncient = c_IsAncient; return true; }
/// <summary> /// Refreshes the actor information. /// </summary> private void RefreshActorInfo() { Vector3 myPos = ZetaDia.Me.Position; if (_objectiveObject != null && _objectiveObject.IsValid) { if (QuestTools.EnableDebugLogging) { Logger.Log("Found actor {0} {1} {2} of distance {3} from point {4}", _objectiveObject.ActorSNO, _objectiveObject.Name, _objectiveObject.ActorType, _objectiveObject.Position.Distance(_mapMarkerLastPosition), _mapMarkerLastPosition); } } else if (_mapMarkerLastPosition.Distance2D(myPos) <= 200) { try { // Monsters are the actual objective marker _objectiveObject = ZetaDia.Actors.GetActorsOfType <DiaUnit>(true) .Where(a => a.IsFullyValid() && a.Position.Distance2D(_mapMarkerLastPosition) <= PathPrecision && a.IsAlive && a.CommonData.GetAttribute <int>(ActorAttributeType.BountyObjective) != 0) .OrderBy(a => a.Position.Distance2D(_mapMarkerLastPosition)) .FirstOrDefault(); if (_objectiveObject == null) { // Portals are not the actual objective but at the marker location _objectiveObject = ZetaDia.Actors.GetActorsOfType <DiaObject>(true) .Where(o => o != null && o.IsValid && o.IsValid && o is GizmoPortal && o.Position.Distance2DSqr(_mapMarkerLastPosition) <= 9f) .OrderBy(o => o.Distance) .FirstOrDefault(); } } catch (Exception ex) { Logger.Debug("Failed trying to find actor {0}", ex); _mapMarkerLastPosition = Vector3.Zero; } } else if (_mapMarkerLastPosition != Vector3.Zero && _mapMarkerLastPosition.Distance2D(myPos) <= 90) { _objectiveObject = ZetaDia.Actors.GetActorsOfType <DiaObject>(true).Where(a => a.IsFullyValid()) .OrderBy(a => a.Position.Distance2D(_mapMarkerLastPosition)).FirstOrDefault(); if (_objectiveObject != null && _objectiveObject.IsValid) { InteractRange = _objectiveObject.CollisionSphere.Radius; Logger.Log("Found Actor from Objective Marker! mapMarkerPos={0} actor={1} {2} {3} {4}", _mapMarkerLastPosition, _objectiveObject.ActorSNO, _objectiveObject.Name, _objectiveObject.ActorType, _objectiveObject.Position); } } if (_objectiveObject != null && _objectiveObject.IsValid) { if (IsValidObjective()) { // need to lock on to a specific actor or we'll just keep finding other things near the marker. Logger.Log("Found our Objective Actor! mapMarkerPos={0} actor={1} {2} {3} {4}", _mapMarkerLastPosition, _objectiveObject.ActorSNO, _objectiveObject.Name, _objectiveObject.ActorType, _objectiveObject.Position); } } if (_objectiveObject is GizmoPortal && !IsPortal) { IsPortal = true; } }
/// <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; }
public TrinityPlayer(DiaObject rActor) : base(rActor) { }
///<summary> ///Updates SNO Cache Values ///</summary> public virtual bool UpdateData(DiaObject thisObj, int raguid) { bool failureDuringUpdate=false; if (this.InternalName==null) { try { this.InternalName=thisObj.Name; } catch (NullReferenceException) { Logging.WriteVerbose("Failure to get internal name on object, SNO {0}", this.SNOID); return false; } } if (!this.Actortype.HasValue) { #region ActorType try { this.Actortype=thisObj.ActorType; } catch (NullReferenceException ) { Logging.WriteVerbose("Failure to get actorType for object, SNO: {0}", this.SNOID); return false; } #endregion } //Ignored actor types.. if (ObjectCache.IgnoredActorTypes.Contains(this.Actortype.Value))//||!LootBehaviorEnabled&&this.Actortype.Value==ActorType.Item) { ObjectCache.IgnoreThisObject(this, raguid, true, true); return false; } if (!this.targetType.HasValue) { #region EvaluateTargetType try { //Evaluate Target Type.. // See if it's an avoidance first from the SNO if (this.IsAvoidance||this.IsObstacle) { this.targetType=TargetType.None; if (this.IsAvoidance) { if (this.IsProjectileAvoidance) this.Obstacletype=ObstacleType.MovingAvoidance; else this.Obstacletype=ObstacleType.StaticAvoidance; AvoidanceType AT=CacheIDLookup.FindAvoidanceUsingSNOID(this.SNOID); //Check if avoidance is enabled or if the avoidance type is set to 0 if (!Bot.SettingsFunky.AttemptAvoidanceMovements||AT!=AvoidanceType.Unknown&&Bot.IgnoringAvoidanceType(AT)) { ObjectCache.AddObjectToBlacklist(raguid, BlacklistType.Temporary); return false; } // Avoidance isn't disabled, so set this object type to avoidance this.targetType=TargetType.Avoidance; } else this.Obstacletype=ObstacleType.ServerObject; } else { // Calculate the object type of this object if (this.Actortype.Value==ActorType.Unit|| CacheIDLookup.hashActorSNOForceTargetUnit.Contains(this.SNOID)) { this.targetType=TargetType.Unit; this.Obstacletype=ObstacleType.Monster; if (CacheIDLookup.hashActorSNOForceTargetUnit.Contains(this.SNOID)) { //Fill in monster data? this.Actortype=ActorType.Unit; } } else if (this.Actortype.Value==ActorType.Item|| CacheIDLookup.hashForceSNOToItemList.Contains(this.SNOID)) { string testname=this.InternalName.ToLower(); //Check if this item is gold/globe.. if (testname.StartsWith("gold")) this.targetType=TargetType.Gold; else if (testname.StartsWith("healthglobe")) this.targetType=TargetType.Globe; else this.targetType=TargetType.Item; //Gold/Globe? } else if (this.Actortype.Value==ActorType.Gizmo) { GizmoType thisGizmoType=GizmoType.None; try { thisGizmoType=thisObj.ActorInfo.GizmoType; } catch (NullReferenceException ) { Logging.WriteVerbose("Failure to get actor Gizmo Type!"); return false; } if (thisGizmoType==GizmoType.DestructibleLootContainer) this.targetType=TargetType.Destructible; else if (thisGizmoType==GizmoType.Shrine||thisGizmoType==GizmoType.Healthwell) { this.targetType=TargetType.Shrine; } else if (thisGizmoType==GizmoType.LootContainer) this.targetType=TargetType.Container; else if (thisGizmoType==GizmoType.Destructible||thisGizmoType==GizmoType.Barricade) this.targetType=TargetType.Barricade; else if (thisGizmoType==GizmoType.Door) this.targetType=TargetType.Door; else {//All other gizmos should be ignored! ObjectCache.IgnoreThisObject(this, raguid, true, true); return false; } if (this.targetType.HasValue) { if (this.targetType.Value==TargetType.Destructible||this.targetType.Value==TargetType.Barricade||this.targetType.Value==TargetType.Door) this.Obstacletype=ObstacleType.Destructable; else if (this.targetType.Value==TargetType.Shrine||this.IsChestContainer) this.Obstacletype=ObstacleType.ServerObject; } if (!this.Gizmotype.HasValue) this.Gizmotype=thisGizmoType; } else if (CacheIDLookup.hashSNOInteractWhitelist.Contains(this.SNOID)) this.targetType=TargetType.Interactable; else if (this.Actortype.Value==ActorType.ServerProp) { string TestString=this.InternalName.ToLower(); //Server props with Base in name are the destructibles "remains" which is considered an obstacle! if (TestString.Contains("base")||TestString.Contains("fence")) { //Add this to the obstacle navigation cache if (!this.IsObstacle) CacheIDLookup.hashSNONavigationObstacles.Add(this.SNOID); this.Obstacletype=ObstacleType.ServerObject; //Use unknown since we lookup SNO ID for server prop related objects. this.targetType=TargetType.None; } else if (TestString.StartsWith("monsteraffix_")) { AvoidanceType T=CacheIDLookup.FindAvoidanceUsingName(TestString); if (T==AvoidanceType.Wall) { Bot.Combat.bCheckGround=true; //Add this to the obstacle navigation cache if (!this.IsObstacle) CacheIDLookup.hashSNONavigationObstacles.Add(this.SNOID); this.Obstacletype=ObstacleType.ServerObject; //Use unknown since we lookup SNO ID for server prop related objects. this.targetType=TargetType.None; } else if (Bot.AvoidancesHealth.ContainsKey(T)) { Logging.WriteVerbose("Found Avoidance not recongized by SNO! Name {0} SNO {1}", TestString, this.SNOID); CacheIDLookup.hashAvoidanceSNOList.Add(this.SNOID); this.targetType=TargetType.Avoidance; } else { //Blacklist all other monster affixes ObjectCache.IgnoreThisObject(this, raguid, true, true); return false; } } else { ObjectCache.IgnoreThisObject(this, raguid, true, true); return false; } } else {//Misc?? Ignore it! ObjectCache.IgnoreThisObject(this, raguid, true, true); return false; } } } catch (NullReferenceException ) { Logging.WriteVerbose("Failure to get actorType for object, SNO: {0}", this.SNOID); return false; } #endregion } if (!this.Obstacletype.HasValue) this.Obstacletype=ObstacleType.None; if (this.targetType.Value==TargetType.Unit) { SNORecordMonster monsterInfo=null; try { monsterInfo=thisObj.CommonData.MonsterInfo; } catch (Exception) { Logging.WriteDiagnostic("Safely Handled MonsterInfo Exception for Object {0}", this.InternalName); return false; } if (!this.Monstertype.HasValue||this.ShouldRefreshMonsterType) { #region MonsterType try { this.Monstertype=monsterInfo.MonsterType; } catch (NullReferenceException ) { Logging.WriteVerbose("Failure to get MonsterType for SNO: {0}", this.SNOID); failureDuringUpdate=true; } #endregion } if (!this.Monstersize.HasValue) { #region MonsterSize try { this.Monstersize=monsterInfo.MonsterSize; } catch (NullReferenceException ) { Logging.WriteVerbose("Failure to get MonsterSize for SNO: {0}", this.SNOID); failureDuringUpdate=true; } #endregion } /* if (!this.RunningRate.HasValue) { #region RunningRate try { this.RunningRate=thisObj.CommonData.GetAttribute<double>(ActorAttributeType.); } catch { Logging.WriteVerbose("Failure to get RunningRate for SNO: {0}", this.SNOID); return false; } #endregion } */ } if (this.Actortype.HasValue&&this.targetType.HasValue&& (this.Actortype.Value!=ActorType.Item&&this.targetType.Value!=TargetType.Avoidance)) { //Validate sphere info Sphere sphereInfo=thisObj.CollisionSphere; if (sphereInfo.Center==null) return false; if (!this.CollisionRadius.HasValue) { #region CollisionRadius try { this.CollisionRadius=sphereInfo.Radius; } catch (NullReferenceException ) { Logging.WriteVerbose("Failure to get CollisionRadius for SNO: {0}", this.SNOID); failureDuringUpdate=true; } #endregion if (this.InternalName=="monsterAffix_waller_model") this.CollisionRadius/=2.5f; } if (!this.ActorSphereRadius.HasValue) { #region ActorSphereRadius try { this.ActorSphereRadius=thisObj.ActorInfo.Sphere.Radius; } catch (NullReferenceException ) { Logging.WriteVerbose("Safely handled getting attribute Sphere radius for gizmo {0}", this.InternalName); failureDuringUpdate=true; } #endregion } #region GizmoProperties if (this.targetType.Value==TargetType.Destructible||this.targetType.Value==TargetType.Barricade||this.targetType.Value==TargetType.Interactable) { //No Loot if (!this.DropsNoLoot.HasValue) { #region DropsNoLoot try { this.DropsNoLoot=thisObj.CommonData.GetAttribute<float>(ActorAttributeType.DropsNoLoot)<=0; } catch (NullReferenceException ) { Logging.WriteVerbose("Safely handled reading DropsNoLoot for gizmo {0}", this.InternalName); failureDuringUpdate=true; } #endregion } //No XP if (!this.GrantsNoXP.HasValue) { #region GrantsNoXP try { this.GrantsNoXP=thisObj.CommonData.GetAttribute<float>(ActorAttributeType.GrantsNoXP)<=0; } catch (NullReferenceException ) { Logging.WriteVerbose("Safely handled reading GrantsNoXp for gizmo {0}", this.InternalName); failureDuringUpdate=true; } #endregion } //Barricade flag if (!this.IsBarricade.HasValue) { #region Barricade try { this.IsBarricade=((DiaGizmo)thisObj).IsBarricade; } catch (NullReferenceException ) { Logging.WriteVerbose("Safely handled getting attribute IsBarricade for gizmo {0}", this.InternalName); failureDuringUpdate=true; } #endregion } } #endregion } if (failureDuringUpdate) return false; return true; }
private static int GetChainedClusterCount(DiaObject target, IEnumerable<DiaObject> otherUnits, float chainRange) { var unitCounters = otherUnits.Select(u => GetUnitsChainWillJumpTo(target, otherUnits.ToList(), chainRange).Count); return unitCounters.Max() + 1; }
private bool RemoveThisItem(DiaObject thisobject) { bool bRemoveThis = false; bool bLogThis = true; string thisname = thisobject.Name; if (thisname.StartsWith("Gold") && thisobject is DiaItem) { var thisitem = (DiaItem)thisobject; if (thisitem.CommonData.ItemStackQuantity < 300) { bRemoveThis = true; } bLogThis = false; } if (thisname.StartsWith("LootType2_", true, null) || thisname.StartsWith("LootType3_", true, null) || thisname.StartsWith("Blacksmith_Apprentice_Corpse", true, null) || thisname.StartsWith("Shrine_Global_Enlightened", true, null) || thisname.StartsWith("trOut_", true, null) || thisname.StartsWith("Goatman_Tree_Knot", true, null) || thisname.StartsWith("a1dun_Cath_chest", true, null)) { bRemoveThis = true; bLogThis = false; } //if (bLogThis) Log(thisname); return bRemoveThis; }
//private static int GetConeClusterCount(RActorUnit target, IEnumerable<RActorUnit> otherUnits, float distance) //{ // var targetLoc = target.Position; // return otherUnits.Count(u => target.IsSafelyFacing(u, 90f) && u.Position.Distance(targetLoc) <= distance); // most (if not all) cone spells are 90 degrees //} private static int GetRadiusClusterCount(DiaObject target, IEnumerable<DiaObject> otherUnits, float radius) { var targetLoc = target.Position; return otherUnits.Count(u => u.Position.DistanceSqr(targetLoc) <= radius * radius); }
public CacheAvoidance(DiaObject dia) : base(dia) { CacheType = CacheType.Avoidance; }
/// <summary> /// This is a "psuedo" hash, and used just to compare objects which might have a shifting RActorGUID /// </summary> /// <param name="obj"></param> /// <returns></returns> public static string GenerateWorldObjectHash(DiaObject obj) { return GenerateWorldObjectHash(obj.ActorSNO, obj.Position, obj.GetType().ToString(), obj.WorldDynamicId); }
// Lootable Actors public TrinityItem(DiaObject seed) : base(seed) { }
/// <summary> /// Returns if a DiaObject is not null, is valid, and it's ACD is not null, and is valid /// </summary> /// <param name="diaObject">The dia object.</param> /// <returns><c>true</c> if [is fully valid] [the specified dia object]; otherwise, <c>false</c>.</returns> public static bool IsFullyValid(this DiaObject diaObject) { return(diaObject != null && diaObject.IsValid && diaObject.CommonData != null && diaObject.CommonData.IsValid && !diaObject.CommonData.IsDisposed); }
public bool Interact(DiaObject u) { return ZetaDia.Me.UsePower(u.ActorType == Zeta.Internals.SNO.ActorType.Gizmo || u.ActorType == Zeta.Internals.SNO.ActorType.Item ? SNOPower.Axe_Operate_Gizmo : SNOPower.Axe_Operate_NPC, u.Position); }
public ActorMeta(DiaObject diaObject, ACD acd, int actorSNO, ActorType actorType) { _isValid = false; _isPartial = false; if (diaObject == null || acd == null) return; // We need to really really really make sure that we only export from valid objects var actorInfo = acd.ActorInfo; var monsterInfo = acd.MonsterInfo; var unit = diaObject as DiaUnit; var gizmo = diaObject as DiaGizmo; var item = diaObject as DiaItem; ActorSNO = actorSNO; ActorType = actorType; try { _isValid = acd.IsValid && !acd.IsDisposed && actorInfo != null && actorInfo.IsValid && !actorInfo.IsDisposed && (actorInfo.SNOMonster == -1 || unit != null && unit.IsValid && monsterInfo.IsValid && !monsterInfo.IsDisposed); } catch (Exception) { } try { _isPartial = (gizmo != null && !gizmo.IsValid) || (unit != null && !unit.IsValid) || (item != null && !item.IsValid); } catch (Exception) { } if (!_isValid) return; if (acd.IsValid && !acd.IsDisposed) { InternalName = Trinity.NameNumberTrimRegex.Replace(acd.Name, ""); } if (actorInfo == null) { _isValid = false; } else { var actorSNOSources = new HashSet<int> { acd.ActorSNO, diaObject.ActorSNO, diaObject.CommonData.ActorSNO, acd.ActorInfo.SNOId, }; if (actorInfo.SNOMonster != -1) actorSNOSources.Add(acd.MonsterInfo.SNOActor); if (actorSNOSources.Any(o => o != actorSNO)) { Logger.Log("Detected ActorSNO Mismatch ({0} / {1} / {2} / {3} / {4} / {5})", actorSNO, acd.ActorSNO, diaObject.ActorSNO, diaObject.CommonData.ActorSNO, acd.ActorInfo.SNOId, acd.MonsterInfo.SNOActor); _isValid = false; } var internalNameSources = new HashSet<string> { Trinity.NameNumberTrimRegex.Replace(diaObject.Name, ""), ((SNOActor) actorSNO).ToString(), ((SNOActor) acd.ActorSNO).ToString(), ((SNOActor) acd.ActorInfo.SNOId).ToString(), }; if (internalNameSources.Any(o => o != InternalName)) { Logger.Log("Detected InternalName Mismatch ({0} / {1} / {2} / {3} / {4})", InternalName, Trinity.NameNumberTrimRegex.Replace(diaObject.Name, ""), ((SNOActor) actorSNO).ToString(), ((SNOActor) acd.ActorSNO).ToString(), ((SNOActor) acd.ActorInfo.SNOId).ToString()); _isValid = false; } if (acd.ActorType != ActorType.Monster && acd.ActorInfo.SNOMonster != -1) { Logger.Log("MonsterSNO on non-monster type."); _isValid = false; } } if (TrinityItemManager.DetermineItemType(InternalName, ItemType.Unknown) != TrinityItemType.Unknown) { _isValid = false; Logger.Log("Detected Item Mis-classified as Gizmo or Monster. InternalName={0} IsGizmo={1} IsUnit={2}", InternalName, gizmo != null, unit != null); } if (actorInfo != null && (int)actorInfo.GizmoType == 5) { _isValid = false; Logger.Log("Detected Invalid GizmoType 5", InternalName, gizmo != null, unit != null); } if (_isValid) { if (actorInfo != null && actorInfo.IsValid && !actorInfo.IsDisposed) { MonsterSNO = actorInfo.SNOMonster; Radius = acd.ActorInfo.Sphere.Radius; PhysMeshSNO = actorInfo.SNOPhysMesh; ApperanceSNO = actorInfo.SNOApperance; AnimSetSNO = actorInfo.SNOAnimSet; IsMerchant = actorInfo.IsMerchant; } if (MonsterSNO != -1 && unit != null && unit.IsValid && monsterInfo.IsValid && !monsterInfo.IsDisposed) { IsMonster = true; MonsterType = monsterInfo.MonsterType; MonsterRace = monsterInfo.MonsterRace; MonsterSize = monsterInfo.MonsterSize; } if (unit != null && unit.IsValid) { IsUnit = true; GizmoType = GizmoType.None; try { IsHostile = unit.IsHostile; } catch (Exception) { } try { IsNPC = unit.IsNPC; } catch (Exception) { } try { PetType = unit.PetType; } catch (Exception) { } try { IsSalvageShortcut = unit.IsSalvageShortcut; } catch (Exception) { } try { HirelingType = unit.HirelingType; } catch (Exception) { } try { IsHelper = unit.IsHelper; } catch (Exception) { } try { IsDefaultHidden = unit.IsHidden; } catch (Exception) { } try { IsQuestGiver = unit.IsQuestGiver; } catch (Exception) { } try { IsSummoned = unit.Summoner != null || unit.SummonedBySNO != -1 || unit.SummonedByACDId != -1; } catch (Exception) { } try { IsSummoner = acd.Name.ToLower().Contains("summoner") || CacheManager.Units.Any(u => u.SummonedByACDId == acd.DynamicId); } catch (Exception) { } } if (gizmo != null && gizmo.IsValid) { IsGizmo = true; try { GizmoType = acd.GizmoType; } catch (Exception) { } try { GizmoIsBarracade = gizmo.IsBarricade; } catch (Exception) { } try { GizmoIsDestructible = gizmo.IsDestructibleObject; } catch (Exception) { } try { GizmoIsDisabledByScript = gizmo.IsGizmoDisabledByScript; } catch (Exception) { } try { GizmoIsPortal = gizmo.IsPortal; } catch (Exception) { } try { GizmoIsTownPortal = gizmo.IsTownPortal; } catch (Exception) { } try { GizmoDefaultCharges = gizmo.GizmoCharges; } catch (Exception) { } try { GizmoDefaultState = gizmo.GizmoState; } catch (Exception) { } try { GizmoGrantsNoXp = gizmo.GrantsNoXp; } catch (Exception) { } try { GizmoDropNoLoot = gizmo.DropsNoLoot; } catch (Exception) { } try { GizmoIsOperatable = gizmo.Operatable; } catch (Exception) { } } } }
private static async Task<bool> Interact(DiaObject actor) { bool retVal = false; switch (actor.ActorType) { case ActorType.Gizmo: switch (actor.ActorInfo.GizmoType) { case GizmoType.BossPortal: case GizmoType.Portal: case GizmoType.ReturnPortal: retVal = ZetaDia.Me.UsePower(SNOPower.GizmoOperatePortalWithAnimation, actor.Position); break; default: retVal = ZetaDia.Me.UsePower(SNOPower.Axe_Operate_Gizmo, actor.Position); break; } break; case ActorType.Monster: retVal = ZetaDia.Me.UsePower(SNOPower.Axe_Operate_NPC, actor.Position); break; } // Doubly-make sure we interact actor.Interact(); await Coroutine.Sleep(100); return retVal; }
public static bool IsDeathGate(DiaObject o) => o != null && o.IsValid && o.ActorSnoId == 328830;
/// <summary> /// This is a "psuedo" hash, and used just to compare objects which might have a shifting RActorGUID /// </summary> /// <param name="obj"></param> /// <returns></returns> public static string GenerateWorldObjectHash(DiaObject obj) { return(GenerateWorldObjectHash(obj.ActorSNO, obj.Position, obj.GetType().ToString(), obj.WorldDynamicId)); }
public void Dispose() { DiaUnit = null; Name = null; }
/// <summary> /// Moves to something and interacts with it. /// (blocks execution, avoid using while in combat) /// </summary> /// <param name="obj">object to interact with</param> /// <param name="range">how close to get</param> /// <param name="interactLimit">maximum number of times to interact</param> public static async Task <bool> MoveToAndInteract(DiaObject obj, float range = -1f, int interactLimit = 5) { if (!Data.IsValid(obj)) { return(false); } var startWorldSnoId = ZetaDia.Globals.WorldSnoId; if (interactLimit < 1) { interactLimit = 5; } if (range < 0) { range = obj.CollisionSphere.Radius - 2; } if (obj.Position == default(Vector3)) { Log.Verbose("Destination is invalid (Vector3.Zero)"); } if (obj.Position.Distance(ZetaDia.Me.Position) > 600f) { Log.Verbose("Destination is too far away"); } if (obj.Position.Distance(ZetaDia.Me.Position) > range) { if (!await MoveTo(obj.Position, obj.Name, range)) { return(false); } } var distance = obj.Position.Distance(ZetaDia.Me.Position); if (distance <= range || distance - obj.CollisionSphere.Radius <= range) { for (int i = 1; i <= interactLimit; i++) { Log.Verbose("Interacting with {0} ({1}) Attempt={2}", obj.Name, obj.ActorSnoId, i); if (obj.Interact()) { break; } await Coroutine.Sleep(1000); await Coroutine.Yield(); } } Navigator.PlayerMover.MoveTowards(obj.Position); await Coroutine.Sleep(250); if (!ZetaDia.Globals.IsLoadingWorld && Data.IsValid(obj)) { obj.Interact(); } await Coroutine.Sleep(1000); if (obj is GizmoPortal && ZetaDia.Globals.IsLoadingWorld || ZetaDia.Globals.WorldSnoId != startWorldSnoId) { Log.Verbose("A portal was successfully interacted with"); } return(true); }