コード例 #1
0
        public static Mod Consolidate(this IReadOnlyCollection <Mod> p, string pName)
        {
            Percent     CritChance   = Percent.Zero;
            Percent     CritDamage   = Percent.Zero;
            Percent     MagazineSize = Percent.Zero;
            Percent     Multishot    = Percent.Zero;
            Percent     Damage       = Percent.Zero;
            Percent     Impact       = Percent.Zero;
            Percent     Puncture     = Percent.Zero;
            Percent     Slash        = Percent.Zero;
            Percent     FireRate     = Percent.Zero;
            Percent     Reload       = Percent.Zero;
            Percent     Cold         = Percent.Zero;
            Percent     Heat         = Percent.Zero;
            Percent     Electric     = Percent.Zero;
            Percent     Toxin        = Percent.Zero;
            Percent     AugmentBonus = Percent.Zero;
            WeaponClass WeaponClass  = 0;

            foreach (var mod in p)
            {
                CritChance   += mod.CritChance;
                CritDamage   += mod.CritDamage;
                MagazineSize += mod.MagazineSize;
                Multishot    += mod.Multishot;
                Damage       += mod.Damage;
                Impact       += mod.Impact;
                Puncture     += mod.Puncture;
                Slash        += mod.Slash;
                FireRate     += mod.FireRate;
                Reload       += mod.Reload;
                Cold         += mod.Cold;
                Heat         += mod.Heat;
                Electric     += mod.Electric;
                Toxin        += mod.Toxin;
                AugmentBonus += mod.AugmentBonus;
                WeaponClass  |= mod.WeaponClass;
            }

            return(new Mod(
                       pName,
                       WeaponClass,
                       CritChance,
                       CritDamage,
                       MagazineSize,
                       Multishot,
                       Damage,
                       Impact,
                       Puncture,
                       Slash,
                       FireRate,
                       Reload,
                       Cold,
                       Heat,
                       Electric,
                       Toxin,
                       AugmentBonus));
        }
コード例 #2
0
 public Mod(
     string pName,
     WeaponClass pWeaponClass,
     Percent pCritChance,
     Percent pCritDamage,
     Percent pMagazineSize,
     Percent pMultishot,
     Percent pDamage,
     Percent pImpact,
     Percent pPuncture,
     Percent pSlash,
     Percent pFireRate,
     Percent pReload,
     Percent pCold,
     Percent pHeat,
     Percent pElectric,
     Percent pToxin,
     Percent pAugmentBonus)
 {
     this.Name         = pName;
     this.WeaponClass  = pWeaponClass;
     this.CritChance   = pCritChance;
     this.CritDamage   = pCritDamage;
     this.MagazineSize = pMagazineSize;
     this.Multishot    = pMultishot;
     this.Damage       = pDamage;
     this.Impact       = pImpact;
     this.Puncture     = pPuncture;
     this.Slash        = pSlash;
     this.FireRate     = pFireRate;
     this.Reload       = pReload;
     this.Cold         = pCold;
     this.Heat         = pHeat;
     this.Electric     = pElectric;
     this.Toxin        = pToxin;
     this.AugmentBonus = pAugmentBonus;
 }
コード例 #3
0
        static MainMods()
        {
            var allMods = new Dictionary <string, Mod>();

            allMods.Add(Riven.Name, Riven);
            allMods.Add(HeavyCaliber.Name, HeavyCaliber);

            var ass  = System.Reflection.Assembly.GetEntryAssembly();
            var path = System.IO.Path.GetDirectoryName(ass.Location);

            var modFiles = System.IO.Directory.GetFiles(path, "Mods_*.ini", System.IO.SearchOption.TopDirectoryOnly);

            foreach (var modFile in modFiles)
            {
                foreach (var v in System.IO.File.ReadAllLines(modFile))
                {
                    string line = v;
                    if (line == null)
                    {
                        continue;
                    }
                    line = line.Trim();
                    if (string.IsNullOrWhiteSpace(line))
                    {
                        continue;
                    }
                    if (line.StartsWith("#"))
                    {
                        continue;
                    }

                    var    parts = line.Split(',').ToList();
                    string name  = parts[0].Trim();

                    if (string.IsNullOrWhiteSpace(name))
                    {
                        continue;
                    }
                    if (allMods.ContainsKey(name))
                    {
                        continue;
                    }

                    if (parts.Count != 17)
                    {
                        continue;
                    }

                    try
                    {
                        int ii = 0;
                        allMods.Add(name, new Mod(parts[ii++],
                                                  (WeaponClass)Enum.Parse(typeof(WeaponClass), parts[ii++]),
                                                  Percent.FromPercent0to100(double.Parse(parts[ii++])),
                                                  Percent.FromPercent0to100(double.Parse(parts[ii++])),
                                                  Percent.FromPercent0to100(double.Parse(parts[ii++])),
                                                  Percent.FromPercent0to100(double.Parse(parts[ii++])),
                                                  Percent.FromPercent0to100(double.Parse(parts[ii++])),
                                                  Percent.FromPercent0to100(double.Parse(parts[ii++])),
                                                  Percent.FromPercent0to100(double.Parse(parts[ii++])),
                                                  Percent.FromPercent0to100(double.Parse(parts[ii++])),
                                                  Percent.FromPercent0to100(double.Parse(parts[ii++])),
                                                  Percent.FromPercent0to100(double.Parse(parts[ii++])),
                                                  Percent.FromPercent0to100(double.Parse(parts[ii++])),
                                                  Percent.FromPercent0to100(double.Parse(parts[ii++])),
                                                  Percent.FromPercent0to100(double.Parse(parts[ii++])),
                                                  Percent.FromPercent0to100(double.Parse(parts[ii++])),
                                                  Percent.FromPercent0to100(double.Parse(parts[ii++]))
                                                  ));
                    }
                    catch (Exception ex)
                    {
                        var vv = ex;
                        if (Debugger.IsAttached)
                        {
                            Debugger.Break();
                        }
                    }
                }
            }

            var sorted = allMods.Values.ToList();

            sorted.Sort((a, b) => a.Name.CompareTo(b.Name));

            _AllMods = sorted;
        }
コード例 #4
0
 public static bool HasValue(this Percent p)
 {
     return(p.AsDecimal0to1 != 0.0);
 }
コード例 #5
0
 public static Percent operator +(Percent a, Percent b)
 {
     return(Percent.FromDecimal0to1(a.AsDecimal0to1 + b.AsDecimal0to1));
 }
コード例 #6
0
            public static DPSBreakdown FromPrimitives(Weapon pSniper, DPSCase pCase, Elements[] pElements, Health pHealthType, params Mod[] pMods)
            {
                //First do base damage mods (Serration, Heavy Caliber)
                double baseImpact   = pSniper.Impact;
                double basePuncture = pSniper.Puncture;
                double baseSlash    = pSniper.Slash;

                double baseElectric = pSniper.Electric;

                double baseCold      = pSniper.Cold;
                double baseHeat      = pSniper.Heat;
                double baseToxin     = pSniper.Toxin;
                double baseMagnetic  = pSniper.Magnetic;
                double baseBlast     = pSniper.Blast;
                double baseViral     = pSniper.Viral;
                double baseRadiation = pSniper.Radiation;
                double baseCorrosive = pSniper.Corrosive;
                double baseGas       = pSniper.Gas;



                foreach (var mod in pMods)
                {
                    baseImpact   += pSniper.Impact * mod.Damage.AsDecimal0to1;
                    basePuncture += pSniper.Puncture * mod.Damage.AsDecimal0to1;
                    baseSlash    += pSniper.Slash * mod.Damage.AsDecimal0to1;

                    baseElectric += pSniper.Electric * mod.Damage.AsDecimal0to1;
                    baseCold     += pSniper.Cold * mod.Damage.AsDecimal0to1;
                    baseHeat     += pSniper.Heat * mod.Damage.AsDecimal0to1;
                    baseToxin    += pSniper.Toxin * mod.Damage.AsDecimal0to1;

                    baseMagnetic  += pSniper.Magnetic * mod.Damage.AsDecimal0to1;
                    baseBlast     += pSniper.Blast * mod.Damage.AsDecimal0to1;
                    baseViral     += pSniper.Viral * mod.Damage.AsDecimal0to1;
                    baseRadiation += pSniper.Radiation * mod.Damage.AsDecimal0to1;
                    baseCorrosive += pSniper.Corrosive * mod.Damage.AsDecimal0to1;
                    baseGas       += pSniper.Gas * mod.Damage.AsDecimal0to1;
                }

                DPSBreakdown result = new DPSBreakdown();

                result.Impact   = baseImpact;
                result.Puncture = basePuncture;
                result.Slash    = baseSlash;

                result.Cold      = baseCold;
                result.Electric  = baseElectric;
                result.Heat      = baseHeat;
                result.Toxin     = baseToxin;
                result.Magnetic  = baseMagnetic;
                result.Blast     = baseBlast;
                result.Viral     = baseViral;
                result.Radiation = baseRadiation;
                result.Corrosive = baseCorrosive;
                result.Gas       = baseGas;

                result.TotalDamage_1_WithDamageMods = baseImpact
                                                      + basePuncture
                                                      + baseSlash
                                                      + baseElectric
                                                      + baseCold
                                                      + baseHeat
                                                      + baseToxin
                                                      + baseMagnetic
                                                      + baseBlast
                                                      + baseViral
                                                      + baseRadiation
                                                      + baseCorrosive
                                                      + baseGas;


                //Now do mods that can be calculated independent of each other
                double fMagazine = pSniper.Magazine;

                result.FireRate            = pSniper.FireRate;
                result.Reload              = pSniper.Reload;
                result.TotalMultishot      = 0.0;
                result.TotalCritChance     = pSniper.CritChance.AsDecimal0to1;
                result.TotalCritMultiplier = pSniper.CritMultiplier;
                result.AugmentBonusDamage  = Percent.Zero;

                double reloadModifierDecimal0to1 = 0.0;

                foreach (var mod in pMods)
                {
                    fMagazine                  += (pSniper.Magazine * mod.MagazineSize.AsDecimal0to1);
                    result.FireRate            += pSniper.FireRate * mod.FireRate.AsDecimal0to1;
                    reloadModifierDecimal0to1  += mod.Reload.AsDecimal0to1;
                    result.Reload              += pSniper.Reload * mod.Reload.AsDecimal0to1;
                    result.TotalMultishot      += mod.Multishot.AsDecimal0to1;
                    result.TotalCritChance     += pSniper.CritChance.AsDecimal0to1 * mod.CritChance.AsDecimal0to1;
                    result.TotalCritMultiplier += pSniper.CritMultiplier * mod.CritDamage.AsDecimal0to1;

                    result.Impact   += baseImpact * mod.Impact.AsDecimal0to1;
                    result.Puncture += basePuncture * mod.Puncture.AsDecimal0to1;
                    result.Slash    += baseSlash * mod.Slash.AsDecimal0to1;

                    result.Heat     += result.TotalDamage_1_WithDamageMods * mod.Heat.AsDecimal0to1;
                    result.Cold     += result.TotalDamage_1_WithDamageMods * mod.Cold.AsDecimal0to1;
                    result.Toxin    += result.TotalDamage_1_WithDamageMods * mod.Toxin.AsDecimal0to1;
                    result.Electric += result.TotalDamage_1_WithDamageMods * mod.Electric.AsDecimal0to1;

                    if (mod.AugmentBonus != null)
                    {
                        double abd = result.AugmentBonusDamage.AsDecimal0to1;
                        result.AugmentBonusDamage = Percent.FromDecimal0to1(abd + mod.AugmentBonus.AsDecimal0to1);
                    }
                }

                result.Magazine = (int)fMagazine;
                result.Reload   = pSniper.Reload / (1.0 + reloadModifierDecimal0to1);

                result.TotalDamage_2_WithElementMods  = result.Impact;
                result.TotalDamage_2_WithElementMods += result.Puncture;
                result.TotalDamage_2_WithElementMods += result.Slash;
                result.TotalDamage_2_WithElementMods += result.Heat;
                result.TotalDamage_2_WithElementMods += result.Cold;
                result.TotalDamage_2_WithElementMods += result.Toxin;
                result.TotalDamage_2_WithElementMods += result.Electric;

                result.TotalDamage_2_WithElementMods += result.Magnetic;
                result.TotalDamage_2_WithElementMods += result.Blast;
                result.TotalDamage_2_WithElementMods += result.Viral;
                result.TotalDamage_2_WithElementMods += result.Radiation;
                result.TotalDamage_2_WithElementMods += result.Corrosive;
                result.TotalDamage_2_WithElementMods += result.Gas;


                //Now combine multiple elements however the user has them arranged
                MergeElements(pElements.Contains(Elements.Magnetic), baseMagnetic, ref result.Cold, ref result.Electric, out result.Magnetic);
                MergeElements(pElements.Contains(Elements.Gas), baseGas, ref result.Heat, ref result.Toxin, out result.Gas);

                MergeElements(pElements.Contains(Elements.Viral), baseViral, ref result.Cold, ref result.Toxin, out result.Viral);
                MergeElements(pElements.Contains(Elements.Radiation), baseRadiation, ref result.Heat, ref result.Electric, out result.Radiation);

                MergeElements(pElements.Contains(Elements.Corrosive), baseCorrosive, ref result.Electric, ref result.Toxin, out result.Corrosive);
                MergeElements(pElements.Contains(Elements.Blast), baseBlast, ref result.Cold, ref result.Heat, out result.Blast);

                result.TotalCritChance += pSniper.ZoomBonusCC.AsDecimal0to1;

                int    CritChanceLevel     = 0;
                double CritChanceRemainder = result.TotalCritChance;

                while (CritChanceRemainder > 1.0)
                {
                    CritChanceRemainder -= 1.0;
                    CritChanceLevel++;
                }
                double CritChanceFloor   = 1.0 - CritChanceRemainder;
                double CritChanceCeiling = CritChanceRemainder;

                result.TotalCritMultiplier += pSniper.ZoomBonusCD.AsDecimal0to1 * pSniper.CritMultiplier;

                double CritMultiFloor   = CritChanceLevel * (result.TotalCritMultiplier - 1) + 1;
                double CritMultiCeiling = (CritChanceLevel + 1) * (result.TotalCritMultiplier - 1) + 1;

                result.TotalDamage_3_WithCriticalHits = 0.0;
                switch (pCase)
                {
                case DPSCase.Average:
                    result.TotalDamage_3_WithCriticalHits += CritMultiFloor * CritChanceFloor * result.TotalDamage_2_WithElementMods;
                    result.TotalDamage_3_WithCriticalHits += CritMultiCeiling * CritChanceCeiling * result.TotalDamage_2_WithElementMods;
                    break;

                case DPSCase.Best:
                    result.TotalDamage_3_WithCriticalHits = CritMultiCeiling * result.TotalDamage_2_WithElementMods;
                    break;

                case DPSCase.Worst:
                    result.TotalDamage_3_WithCriticalHits = CritMultiFloor * result.TotalDamage_2_WithElementMods;
                    break;

                default: throw new NotImplementedException("Unknown DPSCase: " + pCase.ToString());
                }

                result.TotalDamage_4_WithAugmentBonus = result.TotalDamage_3_WithCriticalHits * (1.0 + result.AugmentBonusDamage.AsDecimal0to1);

                switch (pCase)
                {
                case DPSCase.Average:
                    result.TotalDamage_5_WithMultishot = result.TotalDamage_4_WithAugmentBonus * (1.0 + result.TotalMultishot);
                    break;

                case DPSCase.Best:
                    result.TotalDamage_5_WithMultishot = result.TotalDamage_4_WithAugmentBonus * (1.0 + Math.Ceiling(result.TotalMultishot));
                    break;

                case DPSCase.Worst:
                    result.TotalDamage_5_WithMultishot = result.TotalDamage_4_WithAugmentBonus * (1.0 + Math.Floor(result.TotalMultishot));
                    break;

                default: throw new NotImplementedException("Unknown DPSCase: " + pCase.ToString());
                }

                result.TotalDamage_6_WithHealthTypeFactors = VsHealthType(result, pHealthType);


                return(result);
            }
コード例 #7
0
        public Weapon(
            string pName,
            WeaponClass pWeaponClass,
            double pImpact,
            double pPuncture,
            double pSlash,
            double pCold,
            double pElectric,
            double pHeat,
            double pToxin,
            double pMagnetic,
            double pBlast,
            double pViral,
            double pRadiation,
            double pCorrosive,
            double pGas,
            int pPelletsTillx15,
            double pFireRate,
            int pMagazine,
            double pReload,
            Percent pCritChance,
            double pCritMultiplier,
            Percent pZoomBonusCC,
            Percent pZoomBonusCD,
            bool pFireRateCappedAt10,
            IReadOnlyCollection <string> pAugmentNames)
        {
            this.Name        = pName;
            this.Impact      = pImpact;
            this.Puncture    = pPuncture;
            this.Slash       = pSlash;
            this.WeaponClass = pWeaponClass;

            this.Cold     = pCold;
            this.Electric = pElectric;
            this.Heat     = pHeat;
            this.Toxin    = pToxin;

            this.Magnetic  = pMagnetic;
            this.Blast     = pBlast;
            this.Viral     = pViral;
            this.Radiation = pRadiation;
            this.Corrosive = pCorrosive;
            this.Gas       = pGas;

            this.PelletsTillx15     = pPelletsTillx15;
            this.FireRate           = pFireRate;
            this.Magazine           = pMagazine;
            this.Reload             = pReload;
            this.CritChance         = pCritChance;
            this.CritMultiplier     = pCritMultiplier;
            this.ZoomBonusCC        = pZoomBonusCC;
            this.ZoomBonusCD        = pZoomBonusCD;
            this.FireRateCappedAt10 = pFireRateCappedAt10;
            this.AugmentNames       = new List <string>(pAugmentNames);

            if (this.PelletsTillx15 == 0)
            {
                this.PelletsTillx15 = int.MaxValue;
            }
        }