private float GetWeight(DiaUnit u)
        {
            ACD commonData = u.CommonData;
            int key        = commonData.DynamicId;

            if (!_weightCache.ContainsKey(key))
            {
                float weight  = GetPredeterminedWeight(u);
                float distPct = 1 - ((1 / (_killRadiusSqr)) * GetDistance(u, key));
                weight *= distPct;
                weight *= commonData.GetAttribute <float>(ActorAttributeType.HitpointsMaxTotal) /
                          commonData.GetAttribute <float>(ActorAttributeType.HitpointsCur);
                _weightCache.Add(key, weight);
            }
            return(_weightCache[key]);
        }
예제 #2
0
        // Attributes while flying.
        //295: PowerImmobilize(-3801) i: 1 f: 0 Value = 1
        //842: HasLookOverride(-3254) i: 1 f: 0 Value = 1
        //1058: PowerDisabled(-3038)[PowerSnoId: X1_Crusader_FallingSword: 239137] i: 1 f: 0 Value = 1


        internal bool CheckVisualEffectNoneForPower(ACD commonData, SNOPower power)
        {
            if (commonData.GetAttribute <int>(((int)power << 12) + ((int)ActorAttributeType.PowerBuff0VisualEffectNone & 0xFFF)) == 1)
            {
                return(true);
            }

            return(false);
        }
예제 #3
0
 /// <summary>
 /// Get an attribute, exceptions get swallowed and default returned
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="actorACD">The actor acd.</param>
 /// <param name="type">The type.</param>
 /// <returns>T.</returns>
 public static T GetAttributeOrDefault <T>(this ACD actorACD, ActorAttributeType type) where T : struct
 {
     try
     {
         actorACD.GetAttribute <T>(type);
     }
     catch (Exception ex)
     {
         Logger.LogDebug(LogCategory.CacheManagement, "Exception on {0} accessing {1} attribute: {2}", actorACD.Name, type, ex);
     }
     return(default(T));
 }
 private bool IsValid(ACD commonData)
 {
     if (!_isValidCache.ContainsKey(commonData.DynamicId))
     {
         _isValidCache.Add(commonData.DynamicId,
                           commonData.GetAttribute <int>(ActorAttributeType.Untargetable) == 0 &&
                           commonData.GetAttribute <int>(ActorAttributeType.Burrowed) == 0 &&
                           commonData.GetAttribute <int>(ActorAttributeType.SlowdownImmune) == 0 &&
                           commonData.GetAttribute <int>(ActorAttributeType.Uninterruptible) == 0 &&
                           commonData.GetAttribute <int>(ActorAttributeType.Invulnerable) == 0 &&
                           commonData.GetAttribute <int>(ActorAttributeType.StunImmune) == 0 &&
                           commonData.GetAttribute <int>(ActorAttributeType.RootImmune) == 0 &&
                           commonData.GetAttribute <float>(ActorAttributeType.HitpointsCur) > 0);
     }
     return(_isValidCache[commonData.DynamicId]);
 }
예제 #5
0
        public static T FindMultiAttributeValue <T>(this ACD acd, IEnumerable <SNOPower> powers, IEnumerable <ActorAttributeType> attributes, Func <T, bool> condition) where T : struct
        {
            if (condition == null)
            {
                return(default(T));
            }

            foreach (var power in powers)
            {
                foreach (var att in attributes)
                {
                    var newValue = acd.GetAttribute <T>((int)att & ((1 << 12) - 1) | ((int)power << 12));

                    Core.Logger.Log("Power: {0}  Att: {1} Val: {2}", power, att, newValue);

                    if (condition(newValue))
                    {
                        return(newValue);
                    }
                }
            }

            return(default(T));
        }
예제 #6
0
        private static int GetTeamId(ACD acd)
        {
            var overrideId = acd.GetAttribute <int>(ActorAttributeType.TeamOverride);

            return(overrideId == -1 ? acd.GetAttribute <int>(ActorAttributeType.TeamId) : overrideId);
        }
예제 #7
0
        private static bool CheckVisualEffectNoneForPower(ACD commonData, SNOPower power)
        {
            if (commonData.GetAttribute<int>(((int)power << 12) + ((int)ActorAttributeType.PowerBuff0VisualEffectNone & 0xFFF)) == 1)
                return true;

            return false;
        }
예제 #8
0
        public static void UpdateStash()
        {
            GameManager.Instance.GManager.GList.MainAccountData.GameData.StashItems.ResetList();

            foreach (ActorCommonData ACD in GameManager.Instance.GManager.GList.MainAccount.DiabloIII.ObjectManager.Storage.ActorCommonDataManager.Dereference().x00_ActorCommonData.Where(x => x.x114_ItemLocation == ItemLocation.Stash))
            {
                if (!Stash.Contains(ACD.x090_ActorSnoId))
                {
                    continue;
                }

                GameManager.Instance.GManager.GList.MainAccountData.GameData.StashItems.Items[ACD.x090_ActorSnoId].Quantity += (ushort)ACD.GetAttribute(AttributeId.ItemStackQuantityLo);
            }

            GameManager.Instance.GManager.GRef.D3OverlayControl.TryRefreshControl <Templates.Inventory.Inventory>();

            // GameManager.Instance.GManager.GRef.Attacher.TryUpdate();
        }
예제 #9
0
        public static void GetStash()
        {
            if ((Helpers.UIObjects.Stash.TryGetValue <UXItemsControl>()) || !GameManager.Instance.GManager.GList.MainAccountData.GameData.StashItems.Loaded)
            {
                StashOpen = true;
                GameManager.Instance.GManager.GList.MainAccountData.GameData.StashItems.Loaded = true;

                //UIObjects.InventoryTabs.GetItems();
            }

            else if ((StashOpen) && !Helpers.UIObjects.Stash.TryGetValue <UXItemsControl>())
            {
                GameManager.Instance.GManager.GList.MainAccountData.GameData.StashItems.ResetList();

                foreach (ActorCommonData ACD in GameManager.Instance.GManager.GList.MainAccount.DiabloIII.ObjectManager.Storage.ActorCommonDataManager.Dereference().x00_ActorCommonData.Where(x => x.x114_ItemLocation == ItemLocation.Stash))
                {
                    if (!Stash.Contains(ACD.x090_ActorSnoId))
                    {
                        continue;
                    }

                    GameManager.Instance.GManager.GList.MainAccountData.GameData.StashItems.Items[ACD.x090_ActorSnoId].Quantity += (ushort)ACD.GetAttribute(AttributeId.ItemStackQuantityLo);
                }

                GameManager.Instance.GManager.GRef.Attacher.TryUpdate();
                StashOpen = false;
            }
        }