public static List <CustomAmmoCategory> getWeaponAmmoCategories(Weapon weapon) { List <CustomAmmoCategory> result = new List <CustomAmmoCategory>(); ExtWeaponDef extWeapon = CustomAmmoCategories.getExtWeaponDef(weapon.defId); if (weapon.AmmoCategory != AmmoCategory.NotSet) { if (extWeapon.AmmoCategory.BaseCategory == weapon.AmmoCategory) { result.Add(extWeapon.AmmoCategory); } else { result.Add(CustomAmmoCategories.find(weapon.AmmoCategory.ToString())); } } foreach (var mode in extWeapon.Modes) { if (mode.Value.AmmoCategory == null) { continue; } ; if (mode.Value.AmmoCategory.BaseCategory != AmmoCategory.NotSet) { result.Add(mode.Value.AmmoCategory); } ; } return(result); }
public static HashSet <string> getWeaponAvaibleAmmoForMode(Weapon weapon, string modeId) { HashSet <string> result = new HashSet <string>(); CustomAmmoCategory ammoCategory = CustomAmmoCategories.find(weapon.AmmoCategory.ToString()); ExtWeaponDef extWeapon = CustomAmmoCategories.getExtWeaponDef(weapon.defId); if (extWeapon.AmmoCategory.BaseCategory == weapon.AmmoCategory) { ammoCategory = extWeapon.AmmoCategory; } if (extWeapon.Modes.Count < 1) { CustomAmmoCategoriesLog.Log.LogWrite("WARNING! " + weapon.defId + " has no modes. Even base mode. This means something is very very wrong\n", true); return(result); } if (extWeapon.Modes.ContainsKey(modeId) == false) { CustomAmmoCategoriesLog.Log.LogWrite("WARNING! " + weapon.defId + " has no mode " + modeId + ".\n", true); return(result); } WeaponMode weaponMode = extWeapon.Modes[modeId]; if (weaponMode.AmmoCategory.Index != ammoCategory.Index) { ammoCategory = weaponMode.AmmoCategory; } ; if (ammoCategory.Index == CustomAmmoCategories.NotSetCustomAmmoCategoty.Index) { result.Add(""); return(result); } ; foreach (AmmunitionBox box in weapon.ammoBoxes) { if (box.IsFunctional == false) { continue; } if (box.CurrentAmmo <= 0) { continue; } CustomAmmoCategory boxAmmoCategory = CustomAmmoCategories.getAmmoAmmoCategory(box.ammoDef); if (boxAmmoCategory.Index == ammoCategory.Index) { if (result.Contains(box.ammoDef.Description.Id) == false) { result.Add(box.ammoDef.Description.Id); } } } return(result); }
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 CustomAmmoCategory getWeaponCustomAmmoCategory(Weapon weapon) { WeaponMode mode = CustomAmmoCategories.getWeaponMode(weapon); if (mode.AmmoCategory == null) { ExtWeaponDef extWeapon = CustomAmmoCategories.getExtWeaponDef(weapon.defId); if (extWeapon.AmmoCategory.BaseCategory != weapon.AmmoCategory) { return(CustomAmmoCategories.find(weapon.AmmoCategory.ToString())); } return(extWeapon.AmmoCategory); } return(mode.AmmoCategory); }
public void fromJSON(string json) { JObject jWeaponMode = JObject.Parse(json); if (jWeaponMode["Id"] != null) { this.Id = (string)jWeaponMode["Id"]; } if (jWeaponMode["UIName"] != null) { this.UIName = (string)jWeaponMode["UIName"]; } if (jWeaponMode["AccuracyModifier"] != null) { this.AccuracyModifier = (float)jWeaponMode["AccuracyModifier"]; } if (jWeaponMode["DamagePerShot"] != null) { this.DamagePerShot = (float)jWeaponMode["DamagePerShot"]; } if (jWeaponMode["HeatDamagePerShot"] != null) { this.HeatDamagePerShot = (float)jWeaponMode["HeatDamagePerShot"]; } if (jWeaponMode["HeatGenerated"] != null) { this.HeatGenerated = (int)jWeaponMode["HeatGenerated"]; } if (jWeaponMode["ProjectilesPerShot"] != null) { this.ProjectilesPerShot = (int)jWeaponMode["ProjectilesPerShot"]; } if (jWeaponMode["ShotsWhenFired"] != null) { this.ShotsWhenFired = (int)jWeaponMode["ShotsWhenFired"]; } if (jWeaponMode["CriticalChanceMultiplier"] != null) { this.CriticalChanceMultiplier = (float)jWeaponMode["CriticalChanceMultiplier"]; } if (jWeaponMode["AIBattleValue"] != null) { this.AIBattleValue = (int)jWeaponMode["AIBattleValue"]; } if (jWeaponMode["MinRange"] != null) { this.MinRange = (float)jWeaponMode["MinRange"]; } if (jWeaponMode["MaxRange"] != null) { this.MaxRange = (float)jWeaponMode["MaxRange"]; } if (jWeaponMode["ShortRange"] != null) { this.ShortRange = (float)jWeaponMode["ShortRange"]; } if (jWeaponMode["ForbiddenRange"] != null) { this.ForbiddenRange = (float)jWeaponMode["ForbiddenRange"]; } if (jWeaponMode["MediumRange"] != null) { this.MediumRange = (float)jWeaponMode["MediumRange"]; } if (jWeaponMode["LongRange"] != null) { this.LongRange = (float)jWeaponMode["LongRange"]; } if (jWeaponMode["RefireModifier"] != null) { this.RefireModifier = (int)jWeaponMode["RefireModifier"]; } if (jWeaponMode["isBaseMode"] != null) { this.isBaseMode = (bool)jWeaponMode["isBaseMode"]; } if (jWeaponMode["Instability"] != null) { this.Instability = (float)jWeaponMode["Instability"]; } if (jWeaponMode["AttackRecoil"] != null) { this.AttackRecoil = (int)jWeaponMode["AttackRecoil"]; } if (jWeaponMode["WeaponEffectID"] != null) { this.WeaponEffectID = (string)jWeaponMode["WeaponEffectID"]; } if (jWeaponMode["EvasivePipsIgnored"] != null) { this.EvasivePipsIgnored = (float)jWeaponMode["EvasivePipsIgnored"]; } if (jWeaponMode["IndirectFireCapable"] != null) { this.IndirectFireCapable = ((bool)jWeaponMode["IndirectFireCapable"] == true) ? TripleBoolean.True : TripleBoolean.False; } if (jWeaponMode["DirectFireModifier"] != null) { this.DirectFireModifier = (float)jWeaponMode["DirectFireModifier"]; } if (jWeaponMode["DistantVariance"] != null) { this.DistantVariance = (float)jWeaponMode["DistantVariance"]; } if (jWeaponMode["DamageMultiplier"] != null) { this.DamageMultiplier = (float)jWeaponMode["DamageMultiplier"]; } if (jWeaponMode["DistantVarianceReversed"] != null) { this.DistantVarianceReversed = ((bool)jWeaponMode["DistantVarianceReversed"] == true) ? TripleBoolean.True : TripleBoolean.False; } if (jWeaponMode["DamageVariance"] != null) { this.DamageVariance = (float)jWeaponMode["DamageVariance"]; } if (jWeaponMode["FlatJammingChance"] != null) { this.FlatJammingChance = (float)jWeaponMode["FlatJammingChance"]; } if (jWeaponMode["GunneryJammingBase"] != null) { this.GunneryJammingBase = (float)jWeaponMode["GunneryJammingBase"]; } if (jWeaponMode["GunneryJammingMult"] != null) { this.GunneryJammingMult = (float)jWeaponMode["GunneryJammingMult"]; } if (jWeaponMode["AIHitChanceCap"] != null) { this.AIHitChanceCap = (float)jWeaponMode["AIHitChanceCap"]; } if (jWeaponMode["Cooldown"] != null) { this.Cooldown = (int)jWeaponMode["Cooldown"]; } if (jWeaponMode["AmmoCategory"] != null) { this.AmmoCategory = CustomAmmoCategories.find((string)jWeaponMode["AmmoCategory"]); } if (jWeaponMode["DamageOnJamming"] != null) { this.DamageOnJamming = ((bool)jWeaponMode["DamageOnJamming"] == true) ? TripleBoolean.True : TripleBoolean.False; } if (jWeaponMode["AOECapable"] != null) { this.AOECapable = ((bool)jWeaponMode["AOECapable"] == true) ? TripleBoolean.True : TripleBoolean.False;; } if (jWeaponMode["AlwaysIndirectVisuals"] != null) { this.AlwaysIndirectVisuals = ((bool)jWeaponMode["AlwaysIndirectVisuals"] == true) ? TripleBoolean.True : TripleBoolean.False; } if (jWeaponMode["HitGenerator"] != null) { try { this.HitGenerator = (HitGeneratorType)Enum.Parse(typeof(HitGeneratorType), (string)jWeaponMode["HitGenerator"], true); } catch (Exception e) { this.HitGenerator = HitGeneratorType.NotSet; } jWeaponMode.Remove("HitGenerator"); } if (jWeaponMode["statusEffects"] != null) { if (jWeaponMode["statusEffects"].Type == JTokenType.Array) { this.statusEffects.Clear(); JToken statusEffects = jWeaponMode["statusEffects"]; foreach (JObject statusEffect in statusEffects) { EffectData effect = new EffectData(); JSONSerializationUtility.FromJSON <EffectData>(effect, statusEffect.ToString()); this.statusEffects.Add(effect); } } } }