From 97984d5bf30bc540bfff9bf7c947462d5c7c1fa9 Mon Sep 17 00:00:00 2001 From: "H. C. Kruse" Date: Sun, 10 Mar 2024 17:11:02 +0100 Subject: [PATCH] feat: Import ammunition falloff data --- Loader/ItemBuilder.cs | 21 ++++- Loader/Json/StandardisedAmmunition.cs | 7 ++ Loader/Json/StandardisedBulletElectron.cs | 9 ++ .../Json/StandardisedBulletImpulseFalloff.cs | 9 ++ .../Json/StandardisedBulletPierceability.cs | 10 +++ .../Entities/BulletProjectileParams.cs | 86 +++++++++++++++++++ 6 files changed, 141 insertions(+), 1 deletion(-) create mode 100644 Loader/Json/StandardisedBulletElectron.cs create mode 100644 Loader/Json/StandardisedBulletImpulseFalloff.cs create mode 100644 Loader/Json/StandardisedBulletPierceability.cs diff --git a/Loader/ItemBuilder.cs b/Loader/ItemBuilder.cs index 668c82e5f..b66fbbefb 100644 --- a/Loader/ItemBuilder.cs +++ b/Loader/ItemBuilder.cs @@ -547,7 +547,26 @@ StandardisedAmmunition BuildAmmunitionInfo(EntityClassDefinition item) Size = ammo.size, ImpactDamage = ConvertDamage(impactDamage), DetonationDamage = ConvertDamage(detonationDamage), - Capacity = item.Components.SAmmoContainerComponentParams?.maxAmmoCount ?? item.Components.SAmmoContainerComponentParams?.maxRestockCount + Capacity = item.Components.SAmmoContainerComponentParams?.maxAmmoCount ?? item.Components.SAmmoContainerComponentParams?.maxRestockCount, + BulletImpulseFalloff = new StandardisedBulletImpulseFalloff{ + MinDistance = projectiles?.impulseFalloffParams?.BulletImpulseFalloffParams?.minDistance, + DropFalloff = projectiles?.impulseFalloffParams?.BulletImpulseFalloffParams?.dropFalloff, + MaxFalloff = projectiles?.impulseFalloffParams?.BulletImpulseFalloffParams?.maxFalloff, + }, + BulletPierceability = new StandardisedBulletPierceability{ + DamageFalloffLevel1 = projectiles?.pierceabilityParams?.damageFalloffLevel1, + DamageFalloffLevel2 = projectiles?.pierceabilityParams?.damageFalloffLevel2, + DamageFalloffLevel3 = projectiles?.pierceabilityParams?.damageFalloffLevel3, + MaxPenetrationThickness = projectiles?.pierceabilityParams?.maxPenetrationThickness, + }, + BulletElectron = new StandardisedBulletElectron{ + JumpRange = projectiles?.electronParams?.BulletElectronParams?.jumpRange, + MaximumJumps = projectiles?.electronParams?.BulletElectronParams?.maximumJumps, + ResidualChargeMultiplier = projectiles?.electronParams?.BulletElectronParams?.residualChargeMultiplier, + }, + DamageDropMinDistance = ConvertDamage(Damage.FromDamageInfo(projectiles?.damageDropParams?.BulletDamageDropParams?.damageDropMinDistance?.DamageInfo ?? new DamageInfo())), + DamageDropPerMeter = ConvertDamage(Damage.FromDamageInfo(projectiles?.damageDropParams?.BulletDamageDropParams?.damageDropPerMeter?.DamageInfo ?? new DamageInfo())), + DamageDropMinDamage = ConvertDamage(Damage.FromDamageInfo(projectiles?.damageDropParams?.BulletDamageDropParams?.damageDropMinDamage?.DamageInfo ?? new DamageInfo())), }; } diff --git a/Loader/Json/StandardisedAmmunition.cs b/Loader/Json/StandardisedAmmunition.cs index 80a32d205..c0443a491 100644 --- a/Loader/Json/StandardisedAmmunition.cs +++ b/Loader/Json/StandardisedAmmunition.cs @@ -8,5 +8,12 @@ public class StandardisedAmmunition public double? Capacity { get; set; } public StandardisedDamage ImpactDamage { get; set; } public StandardisedDamage DetonationDamage { get; set; } + public StandardisedBulletImpulseFalloff BulletImpulseFalloff { get; set; } + public StandardisedBulletPierceability BulletPierceability { get; set; } + public StandardisedBulletElectron BulletElectron { get; set; } + + public StandardisedDamage DamageDropMinDistance { get; set; } + public StandardisedDamage DamageDropPerMeter { get; set; } + public StandardisedDamage DamageDropMinDamage { get; set; } } } diff --git a/Loader/Json/StandardisedBulletElectron.cs b/Loader/Json/StandardisedBulletElectron.cs new file mode 100644 index 000000000..9ddca59b8 --- /dev/null +++ b/Loader/Json/StandardisedBulletElectron.cs @@ -0,0 +1,9 @@ +namespace Loader +{ + public class StandardisedBulletElectron + { + public double? ResidualChargeMultiplier { get; set; } + public double? MaximumJumps { get; set; } + public double? JumpRange { get; set; } + } +} diff --git a/Loader/Json/StandardisedBulletImpulseFalloff.cs b/Loader/Json/StandardisedBulletImpulseFalloff.cs new file mode 100644 index 000000000..a236cc934 --- /dev/null +++ b/Loader/Json/StandardisedBulletImpulseFalloff.cs @@ -0,0 +1,9 @@ +namespace Loader +{ + public class StandardisedBulletImpulseFalloff + { + public double? MinDistance { get; set; } + public double? DropFalloff { get; set; } + public double? MaxFalloff { get; set; } + } +} diff --git a/Loader/Json/StandardisedBulletPierceability.cs b/Loader/Json/StandardisedBulletPierceability.cs new file mode 100644 index 000000000..bd30f1a42 --- /dev/null +++ b/Loader/Json/StandardisedBulletPierceability.cs @@ -0,0 +1,10 @@ +namespace Loader +{ + public class StandardisedBulletPierceability + { + public double? DamageFalloffLevel1 { get; set; } + public double? DamageFalloffLevel2 { get; set; } + public double? DamageFalloffLevel3 { get; set; } + public double? MaxPenetrationThickness { get; set; } + } +} diff --git a/Loader/scdb.Xml/Entities/BulletProjectileParams.cs b/Loader/scdb.Xml/Entities/BulletProjectileParams.cs index 3f8baeaa8..745cd5f75 100644 --- a/Loader/scdb.Xml/Entities/BulletProjectileParams.cs +++ b/Loader/scdb.Xml/Entities/BulletProjectileParams.cs @@ -4,8 +4,18 @@ namespace scdb.Xml.Entities { public class BulletProjectileParams { + [XmlAttribute] public double impactRadius; + [XmlAttribute] public double minImpactRadius; + [XmlAttribute] public double ignitionChanceOverride; + [XmlAttribute] public double keepAliveOnZeroDamage; + [XmlAttribute] public string hitType; + public DamageInfo[] damage; + public DamageDropParams damageDropParams; public DetonationParams detonationParams; + public ImpulseFalloffParams impulseFalloffParams; + public PierceabilityParams pierceabilityParams; + public ElectronParams electronParams; } public class DetonationParams @@ -13,6 +23,43 @@ public class DetonationParams public ProjectileDetonationParams ProjectileDetonationParams; } + public class ImpulseFalloffParams + { + public BulletImpulseFalloffParams BulletImpulseFalloffParams; + } + + public class ElectronParams + { + public BulletElectronParams BulletElectronParams; + } + + public class DamageDropParams + { + public BulletDamageDropParams BulletDamageDropParams; + } + + public class BulletDamageDropParams + { + public DamageDropMinDistance damageDropMinDistance; + public DamageDropPerMeter damageDropPerMeter; + public DamageDropMinDamage damageDropMinDamage; + } + + public class DamageDropMinDistance + { + public DamageInfo DamageInfo; + } + + public class DamageDropPerMeter + { + public DamageInfo DamageInfo; + } + + public class DamageDropMinDamage + { + public DamageInfo DamageInfo; + } + public class ProjectileDetonationParams { [XmlAttribute] @@ -38,4 +85,43 @@ public class ProjectileDetonationParams public ExplosionParams explosionParams; } + + public class BulletImpulseFalloffParams + { + [XmlAttribute] + public double minDistance; + + [XmlAttribute] + public double dropFalloff; + + [XmlAttribute] + public double maxFalloff; + } + + public class PierceabilityParams + { + [XmlAttribute] + public double damageFalloffLevel1; + + [XmlAttribute] + public double damageFalloffLevel2; + + [XmlAttribute] + public double damageFalloffLevel3; + + [XmlAttribute] + public double maxPenetrationThickness; + } + + public class BulletElectronParams + { + [XmlAttribute] + public double residualChargeMultiplier; + + [XmlAttribute] + public double maximumJumps; + + [XmlAttribute] + public double jumpRange; + } }