public static bool isWeaponHasClusterAmmo(Weapon weapon)
        {
            if (weapon.ammoBoxes.Count == 0)
            {
                return(false);
            }
            int  ClusterCount  = 0;
            bool ClusterSetted = false;

            for (int index = 0; index < weapon.ammoBoxes.Count; ++index)
            {
                if (weapon.ammoBoxes[index].CurrentAmmo <= 0)
                {
                    continue;
                }
                if (weapon.ammoBoxes[index].IsFunctional == false)
                {
                    continue;
                }
                ExtAmmunitionDef extAmmo = CustomAmmoCategories.findExtAmmo(weapon.ammoBoxes[index].ammoDef.Description.Id);
                int ammoShots            = (weapon.weaponDef.ShotsWhenFired + extAmmo.ShotsWhenFired) * (weapon.weaponDef.ProjectilesPerShot + extAmmo.ProjectilesPerShot);
                if (ClusterSetted == false)
                {
                    ClusterSetted = true; ClusterCount = ammoShots; continue;
                }
                ;
                if (ClusterCount != ammoShots)
                {
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 2
0
        public static bool getWeaponAlwaysIndirectVisuals(Weapon weapon)
        {
            bool result = false;

            if (CustomAmmoCategories.checkExistance(weapon.StatCollection, CustomAmmoCategories.AmmoIdStatName) == true)
            {
                string           CurrentAmmoId = weapon.StatCollection.GetStatistic(CustomAmmoCategories.AmmoIdStatName).Value <string>();
                ExtAmmunitionDef extAmmoDef    = CustomAmmoCategories.findExtAmmo(CurrentAmmoId);
                if (extAmmoDef.AlwaysIndirectVisuals != TripleBoolean.NotSet)
                {
                    result = (extAmmoDef.AlwaysIndirectVisuals == TripleBoolean.True);
                }
            }
            if (CustomAmmoCategories.checkExistance(weapon.StatCollection, CustomAmmoCategories.WeaponModeStatisticName) == true)
            {
                ExtWeaponDef extWeapon = CustomAmmoCategories.getExtWeaponDef(weapon.defId);
                string       modeId    = weapon.StatCollection.GetStatistic(CustomAmmoCategories.WeaponModeStatisticName).Value <string>();
                if (extWeapon.Modes.ContainsKey(modeId))
                {
                    WeaponMode mode = extWeapon.Modes[modeId];
                    if (mode.AlwaysIndirectVisuals != TripleBoolean.NotSet)
                    {
                        result = (mode.AlwaysIndirectVisuals == TripleBoolean.True);
                    }
                }
            }
            return(result);
        }
        public static bool isWeaponHasHeatAmmo(Weapon weapon)
        {
            if (weapon.ammoBoxes.Count == 0)
            {
                return(false);
            }
            float HeatPerShot = 0;
            bool  HeatSetted  = false;

            for (int index = 0; index < weapon.ammoBoxes.Count; ++index)
            {
                if (weapon.ammoBoxes[index].CurrentAmmo <= 0)
                {
                    continue;
                }
                if (weapon.ammoBoxes[index].IsFunctional == false)
                {
                    continue;
                }
                ExtAmmunitionDef extAmmo = CustomAmmoCategories.findExtAmmo(weapon.ammoBoxes[index].ammoDef.Description.Id);
                if (HeatSetted == false)
                {
                    HeatSetted = true; HeatPerShot = extAmmo.HeatDamagePerShot; continue;
                }
                ;
                if (HeatPerShot != extAmmo.HeatDamagePerShot)
                {
                    return(true);
                }
            }
            return(false);
        }
        public static float getWeaponDistantVariance(Weapon weapon)
        {
            float result = 0;

            if (CustomAmmoCategories.checkExistance(weapon.StatCollection, CustomAmmoCategories.AmmoIdStatName) == true)
            {
                string           ammoId  = weapon.StatCollection.GetStatistic(CustomAmmoCategories.AmmoIdStatName).Value <string>();
                ExtAmmunitionDef extAmmo = CustomAmmoCategories.findExtAmmo(ammoId);
                result += extAmmo.DistantVariance;
            }
            ExtWeaponDef extWeapon = CustomAmmoCategories.getExtWeaponDef(weapon.defId);

            if (extWeapon.Modes.Count > 0)
            {
                string modeId = "";
                if (CustomAmmoCategories.checkExistance(weapon.StatCollection, CustomAmmoCategories.WeaponModeStatisticName) == true)
                {
                    modeId = weapon.StatCollection.GetStatistic(CustomAmmoCategories.WeaponModeStatisticName).Value <string>();
                }
                else
                {
                    modeId = extWeapon.baseModeId;
                }
                if (extWeapon.Modes.ContainsKey(modeId))
                {
                    result += extWeapon.Modes[modeId].DistantVariance;
                }
            }
            return(result);
        }
        public static bool getWeaponDistantVarianceReversed(Weapon weapon)
        {
            TripleBoolean result    = TripleBoolean.NotSet;
            ExtWeaponDef  extWeapon = CustomAmmoCategories.getExtWeaponDef(weapon.defId);

            if (extWeapon.Modes.Count > 0)
            {
                string modeId = "";
                if (CustomAmmoCategories.checkExistance(weapon.StatCollection, CustomAmmoCategories.WeaponModeStatisticName) == true)
                {
                    modeId = weapon.StatCollection.GetStatistic(CustomAmmoCategories.WeaponModeStatisticName).Value <string>();
                }
                else
                {
                    modeId = extWeapon.baseModeId;
                }
                if (extWeapon.Modes.ContainsKey(modeId))
                {
                    result = extWeapon.Modes[modeId].DistantVarianceReversed;
                }
            }
            if (result == TripleBoolean.NotSet)
            {
                if (CustomAmmoCategories.checkExistance(weapon.StatCollection, CustomAmmoCategories.AmmoIdStatName) == true)
                {
                    string           ammoId  = weapon.StatCollection.GetStatistic(CustomAmmoCategories.AmmoIdStatName).Value <string>();
                    ExtAmmunitionDef extAmmo = CustomAmmoCategories.findExtAmmo(ammoId);
                    result = extAmmo.DistantVarianceReversed;
                }
            }
            return(result == TripleBoolean.True);
        }
Esempio n. 6
0
        public static float getWeaponFlatJammingChance(Weapon weapon)
        {
            float result  = 0;
            float mult    = 0;
            float baseval = 0f;

            if (CustomAmmoCategories.checkExistance(weapon.StatCollection, CustomAmmoCategories.AmmoIdStatName) == true)
            {
                string           ammoId  = weapon.StatCollection.GetStatistic(CustomAmmoCategories.AmmoIdStatName).Value <string>();
                ExtAmmunitionDef extAmmo = CustomAmmoCategories.findExtAmmo(ammoId);
                result += extAmmo.FlatJammingChance;
                mult   += extAmmo.GunneryJammingMult;
                if (extAmmo.GunneryJammingBase > 0)
                {
                    baseval = extAmmo.GunneryJammingBase;
                }
                ;
            }
            ExtWeaponDef extWeapon = CustomAmmoCategories.getExtWeaponDef(weapon.defId);

            result += extWeapon.FlatJammingChance;
            mult   += extWeapon.GunneryJammingMult;
            if ((extWeapon.GunneryJammingBase > 0) && (baseval == 0f))
            {
                baseval = extWeapon.GunneryJammingBase;
            }
            ;
            if (extWeapon.Modes.Count > 0)
            {
                string modeId = "";
                if (CustomAmmoCategories.checkExistance(weapon.StatCollection, CustomAmmoCategories.WeaponModeStatisticName) == true)
                {
                    modeId = weapon.StatCollection.GetStatistic(CustomAmmoCategories.WeaponModeStatisticName).Value <string>();
                }
                else
                {
                    modeId = extWeapon.baseModeId;
                }
                if (extWeapon.Modes.ContainsKey(modeId))
                {
                    result += extWeapon.Modes[modeId].FlatJammingChance;
                    mult   += extWeapon.Modes[modeId].GunneryJammingMult;
                    if ((extWeapon.Modes[modeId].GunneryJammingBase > 0) && (baseval == 0f))
                    {
                        baseval = extWeapon.Modes[modeId].GunneryJammingBase;
                    }
                    ;
                }
            }
            if (weapon.parent != null)
            {
                if (baseval == 0f)
                {
                    baseval = 5f;
                }
                result += ((baseval - weapon.parent.SkillGunnery) * mult);
            }
            return(result);
        }
Esempio n. 7
0
        public static int getWeaponAttackRecoil(Weapon weapon)
        {
            CustomAmmoCategoriesLog.Log.LogWrite("getWeaponAttackRecoil " + weapon.UIName + "\n");
            if (CustomAmmoCategories.checkExistance(weapon.StatCollection, CustomAmmoCategories.AmmoIdStatName) == false)
            {
                CustomAmmoCategoriesLog.Log.LogWrite("  weapon has no ammo\n");
                return(weapon.weaponDef.AttackRecoil);
            }
            string           ammoId  = weapon.StatCollection.GetStatistic(CustomAmmoCategories.AmmoIdStatName).Value <string>();
            ExtAmmunitionDef extAmmo = CustomAmmoCategories.findExtAmmo(ammoId);

            CustomAmmoCategoriesLog.Log.LogWrite("  modified AttackRecoil\n");
            return(weapon.weaponDef.AttackRecoil + extAmmo.AttackRecoil);
        }
Esempio n. 8
0
        public static bool isWeaponCanUseAmmo(WeaponDef weaponDef, AmmunitionDef ammoDef)
        {
            ExtAmmunitionDef   extAmmo      = CustomAmmoCategories.findExtAmmo(ammoDef.Description.Id);
            CustomAmmoCategory ammoCategory = extAmmo.AmmoCategory;

            if (ammoCategory.BaseCategory == AmmoCategory.NotSet)
            {
                ammoCategory = CustomAmmoCategories.find(ammoDef.Category.ToString());
            }
            ;
            if (ammoCategory.BaseCategory == AmmoCategory.NotSet)
            {
                return(false);
            }
            ;
            ExtWeaponDef extWeapon = CustomAmmoCategories.getExtWeaponDef(weaponDef.Description.Id);

            if (extWeapon.AmmoCategory.BaseCategory != AmmoCategory.NotSet)
            {
                if (extWeapon.AmmoCategory.Index == ammoCategory.Index)
                {
                    return(true);
                }
                ;
            }
            else
            if (weaponDef.AmmoCategory != AmmoCategory.NotSet)
            {
                CustomAmmoCategory weaponAmmoCategory = CustomAmmoCategories.find(weaponDef.AmmoCategory.ToString());
                if ((weaponAmmoCategory.BaseCategory != AmmoCategory.NotSet) && (weaponAmmoCategory.Index == ammoCategory.Index))
                {
                    return(true);
                }
            }
            foreach (var mode in extWeapon.Modes)
            {
                if (mode.Value.AmmoCategory == null)
                {
                    continue;
                }
                ;
                if ((mode.Value.AmmoCategory.BaseCategory != AmmoCategory.NotSet) && (mode.Value.AmmoCategory.Index == ammoCategory.Index))
                {
                    return(true);
                }
                ;
            }
            return(false);
        }
        public static void switchToMostClusterAmmo(Weapon weapon)
        {
            if (weapon.ammoBoxes.Count == 0)
            {
                return;
            }
            int    ClusterShot = 0;
            string ammoId      = "";

            for (int index = 0; index < weapon.ammoBoxes.Count; ++index)
            {
                if (weapon.ammoBoxes[index].CurrentAmmo <= 0)
                {
                    continue;
                }
                if (weapon.ammoBoxes[index].IsFunctional == false)
                {
                    continue;
                }
                ExtAmmunitionDef extAmmo = CustomAmmoCategories.findExtAmmo(weapon.ammoBoxes[index].ammoDef.Description.Id);
                int ammoShots            = (weapon.weaponDef.ShotsWhenFired + extAmmo.ShotsWhenFired) * (weapon.weaponDef.ProjectilesPerShot + extAmmo.ProjectilesPerShot);
                if (string.IsNullOrEmpty(ammoId))
                {
                    ammoId      = weapon.ammoBoxes[index].ammoDef.Description.Id;
                    ClusterShot = ammoShots;
                    continue;
                }
                ;
                if (ClusterShot < ammoShots)
                {
                    ammoId      = weapon.ammoBoxes[index].ammoDef.Description.Id;
                    ClusterShot = ammoShots;
                }
            }
            if (string.IsNullOrEmpty(ammoId) == false)
            {
                if (CustomAmmoCategories.checkExistance(weapon.StatCollection, CustomAmmoCategories.AmmoIdStatName) == false)
                {
                    weapon.StatCollection.AddStatistic <string>(CustomAmmoCategories.AmmoIdStatName, ammoId);
                }
                else
                {
                    weapon.StatCollection.Set <string>(CustomAmmoCategories.AmmoIdStatName, ammoId);
                }
            }
        }
        public static void switchToMostHeatAmmo(Weapon weapon)
        {
            if (weapon.ammoBoxes.Count == 0)
            {
                return;
            }
            float  HeatPerShot = 0;
            string ammoId      = "";

            for (int index = 0; index < weapon.ammoBoxes.Count; ++index)
            {
                if (weapon.ammoBoxes[index].CurrentAmmo <= 0)
                {
                    continue;
                }
                if (weapon.ammoBoxes[index].IsFunctional == false)
                {
                    continue;
                }
                ExtAmmunitionDef extAmmo = CustomAmmoCategories.findExtAmmo(weapon.ammoBoxes[index].ammoDef.Description.Id);
                if (string.IsNullOrEmpty(ammoId))
                {
                    ammoId      = weapon.ammoBoxes[index].ammoDef.Description.Id;
                    HeatPerShot = extAmmo.HeatDamagePerShot;
                    continue;
                }
                ;
                if (HeatPerShot < extAmmo.HeatDamagePerShot)
                {
                    ammoId      = weapon.ammoBoxes[index].ammoDef.Description.Id;
                    HeatPerShot = extAmmo.HeatDamagePerShot;
                }
            }
            if (string.IsNullOrEmpty(ammoId) == false)
            {
                if (CustomAmmoCategories.checkExistance(weapon.StatCollection, CustomAmmoCategories.AmmoIdStatName) == false)
                {
                    weapon.StatCollection.AddStatistic <string>(CustomAmmoCategories.AmmoIdStatName, ammoId);
                }
                else
                {
                    weapon.StatCollection.Set <string>(CustomAmmoCategories.AmmoIdStatName, ammoId);
                }
            }
        }
Esempio n. 11
0
        public static float getWeaponEvasivePipsIgnored(Weapon weapon)
        {
            float result = weapon.weaponDef.EvasivePipsIgnored;

            //CustomAmmoCategoriesLog.Log.LogWrite("getWeaponEvasivePipsIgnored " + weapon.UIName + "\n");
            if (CustomAmmoCategories.checkExistance(weapon.StatCollection, CustomAmmoCategories.AmmoIdStatName) == true)
            {
                string           ammoId  = weapon.StatCollection.GetStatistic(CustomAmmoCategories.AmmoIdStatName).Value <string>();
                ExtAmmunitionDef extAmmo = CustomAmmoCategories.findExtAmmo(ammoId);
                result += extAmmo.EvasivePipsIgnored;
            }
            if (CustomAmmoCategories.checkExistance(weapon.StatCollection, CustomAmmoCategories.WeaponModeStatisticName) == true)
            {
                result += CustomAmmoCategories.getWeaponMode(weapon).EvasivePipsIgnored;
            }
            //CustomAmmoCategoriesLog.Log.LogWrite("  modified EvasivePipsIgnored\n");
            return(result);
        }