示例#1
0
        /// <summary>
        /// Returns the top layers in each spell category for a StatMod type
        /// </summary>
        public List <BiotaPropertiesEnchantmentRegistry> GetEnchantments(EnchantmentTypeFlags statModType)
        {
            var enchantments = WorldObject.Biota.GetEnchantmentsByStatModType((uint)statModType, WorldObject.BiotaDatabaseLock);

            var results = from e in enchantments
                          group e by e.SpellCategory
                          into categories
                          select categories.OrderByDescending(c => c.LayerId).First();

            return(results.ToList());
        }
示例#2
0
        /// <summary>
        /// Returns the sum of the StatModValues for an EnchantmentTypeFlag
        /// </summary>
        public int GetModifier(EnchantmentTypeFlags type)
        {
            var enchantments = GetEnchantments_TopLayer(type);

            var modifier = 0;

            foreach (var enchantment in enchantments)
            {
                modifier += (int)enchantment.StatModValue;
            }

            return(modifier);
        }
示例#3
0
 public void InitCooldown(WorldObject target, BiotaPropertiesEnchantmentRegistry entry)
 {
     SpellID          = (ushort)entry.SpellId;
     Layer            = entry.LayerId;
     SpellCategory    = entry.SpellCategory;
     StartTime        = entry.StartTime;
     Duration         = entry.Duration;
     CasterGuid       = entry.CasterObjectId;
     DegradeModifier  = entry.DegradeModifier;
     DegradeLimit     = entry.DegradeLimit;
     LastTimeDegraded = entry.LastTimeDegraded;
     StatModType      = (EnchantmentTypeFlags)entry.StatModType;
     StatModKey       = entry.StatModKey;
     StatModValue     = entry.StatModValue;
 }
示例#4
0
        public void Init(Spell spell)
        {
            Spell           = spell;
            SpellID         = (ushort)spell.Id;
            SpellCategory   = (ushort)spell.Category;
            PowerLevel      = spell.Power;
            Duration        = spell.Duration;
            DegradeModifier = spell.DegradeModifier;
            DegradeLimit    = spell.DegradeLimit;

            if (spell._spell != null)
            {
                StatModType = spell.StatModType;
                StatModKey  = spell.StatModKey;
            }
        }
示例#5
0
        /// <summary>
        /// Returns the sum of the StatModValues for an EnchantmentTypeFlag
        /// </summary>
        public int GetModifier(EnchantmentTypeFlags type)
        {
            var enchantments = WorldObject.Biota.BiotaPropertiesEnchantmentRegistry.Where(e => ((EnchantmentTypeFlags)e.StatModType).HasFlag(type));

            if (enchantments == null)
            {
                return(0);
            }

            var modifier = 0;

            foreach (var enchantment in enchantments)
            {
                modifier += (int)enchantment.StatModValue;
            }

            return(modifier);
        }
示例#6
0
 /// <summary>
 /// Returns the top layers in each spell category for a StatMod type + key
 /// </summary>
 public List <BiotaPropertiesEnchantmentRegistry> GetEnchantments_TopLayer(EnchantmentTypeFlags statModType, uint statModKey)
 {
     return(GetEnchantments_TopLayer(WorldObject.Biota.GetEnchantmentsByStatModType((uint)statModType, WorldObject.BiotaDatabaseLock).Where(e => e.StatModKey == statModKey).ToList()));
 }
示例#7
0
 /// <summary>
 /// Returns the top layers in each spell category for a StatMod type
 /// </summary>
 public List <BiotaPropertiesEnchantmentRegistry> GetEnchantments_TopLayer(EnchantmentTypeFlags statModType)
 {
     return(GetEnchantments_TopLayer(WorldObject.Biota.GetEnchantmentsByStatModType((uint)statModType, WorldObject.BiotaDatabaseLock)));
 }
示例#8
0
        public static List <PropertiesEnchantmentRegistry> GetEnchantmentsByStatModType(this ICollection <PropertiesEnchantmentRegistry> value, EnchantmentTypeFlags statModType, ReaderWriterLockSlim rwLock)
        {
            if (value == null)
            {
                return(null);
            }

            rwLock.EnterReadLock();
            try
            {
                return(value.Where(e => (e.StatModType & statModType) == statModType).ToList());
            }
            finally
            {
                rwLock.ExitReadLock();
            }
        }
示例#9
0
        /// <summary>
        /// Returns the top layers in each spell category for a StatMod type + key
        /// </summary>
        public static List <PropertiesEnchantmentRegistry> GetEnchantmentsTopLayerByStatModType(this ICollection <PropertiesEnchantmentRegistry> value, EnchantmentTypeFlags statModType, uint statModKey, ReaderWriterLockSlim rwLock, HashSet <int> setSpells, bool handleMultiple = false)
        {
            if (value == null)
            {
                return(null);
            }

            rwLock.EnterReadLock();
            try
            {
                var multipleStat = EnchantmentTypeFlags.Undef;

                if (handleMultiple)
                {
                    // todo: this is starting to get a bit messy here, EnchantmentTypeFlags handling should be more adaptable
                    // perhaps the enchantment registry in acclient should be investigated for reference logic

                    multipleStat = statModType | EnchantmentTypeFlags.MultipleStat;

                    statModType |= EnchantmentTypeFlags.SingleStat;
                }

                var valuesByStatModTypeAndKey = value.Where(e => (e.StatModType & statModType) == statModType && e.StatModKey == statModKey || (handleMultiple && (e.StatModType & multipleStat) == multipleStat && (e.StatModType & EnchantmentTypeFlags.Vitae) == 0 && e.StatModKey == 0));

                // 3rd spell id sort added for Gauntlet Damage Boost I / Gauntlet Damage Boost II, which is contained in multiple sets, and can overlap
                // without this sorting criteria, it's already matched up to the client, but produces logically incorrect results for server spell stacking
                // confirmed this bug still exists in acclient Enchantment.Duel(), unknown if it existed in retail server

                var results = from e in valuesByStatModTypeAndKey
                              group e by e.SpellCategory
                              into categories
                              //select categories.OrderByDescending(c => c.LayerId).First();
                              select categories.OrderByDescending(c => c.PowerLevel)
                              .ThenByDescending(c => Level8AuraSelfSpells.Contains(c.SpellId))
                              .ThenByDescending(c => setSpells.Contains(c.SpellId) ? c.SpellId : c.StartTime).First();

                return(results.ToList());
            }
            finally
            {
                rwLock.ExitReadLock();
            }
        }
示例#10
0
        /// <summary>
        /// Returns the top layers in each spell category for a StatMod type
        /// </summary>
        public static List <PropertiesEnchantmentRegistry> GetEnchantmentsTopLayerByStatModType(this ICollection <PropertiesEnchantmentRegistry> value, EnchantmentTypeFlags statModType, ReaderWriterLockSlim rwLock, HashSet <int> setSpells)
        {
            if (value == null)
            {
                return(null);
            }

            rwLock.EnterReadLock();
            try
            {
                var valuesByStatModType = value.Where(e => (e.StatModType & statModType) == statModType);

                var results = from e in valuesByStatModType
                              group e by e.SpellCategory
                              into categories
                              //select categories.OrderByDescending(c => c.LayerId).First();
                              select categories.OrderByDescending(c => c.PowerLevel)
                              .ThenByDescending(c => Level8AuraSelfSpells.Contains(c.SpellId))
                              .ThenByDescending(c => setSpells.Contains(c.SpellId) ? c.SpellId : c.StartTime).First();

                return(results.ToList());
            }
            finally
            {
                rwLock.ExitReadLock();
            }
        }
        /// <summary>
        /// Returns the top layers in each spell category for a StatMod type + key
        /// </summary>
        public static List <PropertiesEnchantmentRegistry> GetEnchantmentsTopLayerByStatModType(this ICollection <PropertiesEnchantmentRegistry> value, EnchantmentTypeFlags statModType, uint statModKey, ReaderWriterLockSlim rwLock, bool handleMultiple = false)
        {
            if (value == null)
            {
                return(null);
            }

            rwLock.EnterReadLock();
            try
            {
                var multipleStat = EnchantmentTypeFlags.Undef;

                if (handleMultiple)
                {
                    if (statModType == EnchantmentTypeFlags.Attribute)
                    {
                        multipleStat = MultiAttribute;
                    }
                    else if (statModType == EnchantmentTypeFlags.Skill)
                    {
                        multipleStat = MultiSkill;
                    }
                }

                var valuesByStatModTypeAndKey = value.Where(e => (e.StatModType & statModType) == statModType && e.StatModKey == statModKey || (handleMultiple && (e.StatModType & multipleStat) == multipleStat && e.StatModKey == 0));

                // 3rd spell id sort added for Gauntlet Damage Boost I / Gauntlet Damage Boost II, which is contained in multiple sets, and can overlap
                // without this sorting criteria, it's already matched up to the client, but produces logically incorrect results for server spell stacking
                // confirmed this bug still exists in acclient Enchantment.Duel(), unknown if it existed in retail server

                var results = from e in valuesByStatModTypeAndKey
                              group e by e.SpellCategory
                              into categories
                              //select categories.OrderByDescending(c => c.LayerId).First();
                              select categories.OrderByDescending(c => c.PowerLevel).ThenByDescending(c => Level8AuraSelfSpells.Contains(c.SpellId)).ThenByDescending(c => c.SpellId).First();

                return(results.ToList());
            }
            finally
            {
                rwLock.ExitReadLock();
            }
        }
        /// <summary>
        /// Returns the top layers in each spell category for a StatMod type + key
        /// </summary>
        public static List <PropertiesEnchantmentRegistry> GetEnchantmentsTopLayerByStatModType(this ICollection <PropertiesEnchantmentRegistry> value, EnchantmentTypeFlags statModType, uint statModKey, ReaderWriterLockSlim rwLock, bool handleMultiple = false)
        {
            if (value == null)
            {
                return(null);
            }

            rwLock.EnterReadLock();
            try
            {
                var valuesByStatModTypeAndKey = value.Where(e => (e.StatModType & statModType) == statModType && e.StatModKey == statModKey || (handleMultiple && (e.StatModType & MultiSkill) == MultiSkill && e.StatModKey == 0));

                var results = from e in valuesByStatModTypeAndKey
                              group e by e.SpellCategory
                              into categories
                              //select categories.OrderByDescending(c => c.LayerId).First();
                              select categories.OrderByDescending(c => c.PowerLevel).ThenByDescending(c => Level8AuraSelfSpells.Contains(c.SpellId)).First();

                return(results.ToList());
            }
            finally
            {
                rwLock.ExitReadLock();
            }
        }