Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using VoidwalkerEngine.Framework.DataTypes;
- using VoidwalkerEngine.Framework.Game.Systems.GameItems;
- using VoidwalkerEngine.Framework.Logic;
- using VoidwalkerEngine.Framework.Maths;
- namespace VoidwalkerEngine.Framework.Algorithms
- {
- public static class GameItemScaling
- {
- public static List<ItemProperty> ScaleEquipmentAttributes(GameItem item)
- {
- return ScaleItemStats(item.ItemType, item.Quality, item.ItemLevel, item.BaseItemProperties);
- }
- public static List<ItemProperty> ScaleItemStats(GameItemType itemType, QualityType quality, int level, List<ItemPropertyType> baseStats)
- {
- if (quality.IsGreaterThanOrEqual(QualityType.Uncommon) && baseStats != null)
- {
- List<ItemProperty> results = new List<ItemProperty>();
- for (int i = 0; i < baseStats.Count; i++)
- {
- ItemPropertyType statType = baseStats[i];
- ItemProperty stat = new ItemProperty();
- stat.StatType = statType;
- if (statType.IsRange())
- {
- int maximum = ScaleAttribute(statType.ToBaseValue(), level, quality, itemType);
- if(maximum < 1)
- {
- maximum = 1;
- }
- int minimum = (int)Math.Floor(maximum * statType.ToRangeVariance());
- if(minimum < 1)
- {
- minimum = 1;
- }
- stat.Range = new Range(minimum, maximum);
- }
- else
- {
- int value = ScaleAttribute(statType.ToBaseValue(), level, quality, itemType);
- if(value < 1)
- {
- value = 1;
- }
- stat.Value = value;
- }
- results.Add(stat);
- }
- return results;
- }
- return null;
- }
- public static int ScaleAttribute(double baseStat, int level, QualityType quality, GameItemType itemType)
- {
- int result = (int)(((baseStat * quality.ToAttributeScalingMultiplier()) * level / 100D) * itemType.ToAttributeScalingMultiplier());
- return result < 0 ? 0 : result;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement