diff --git a/GameData/Aetheria.cc b/GameData/Aetheria.cc index 1d130d001..9fdde41a6 100644 --- a/GameData/Aetheria.cc +++ b/GameData/Aetheria.cc @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5e3b717b0c4dc5b2b9903ba472710719d27bb9c8d518559e607726e14916499f -size 12698849 +oid sha256:0a990c6e8c4b8cc90cd16b5cdb7d598e0ec5279bf0c0f2891d3918879ff4eb7d +size 12699064 diff --git a/tests/Aetheria.Shared.Tests/RunStartTests.cs b/tests/Aetheria.Shared.Tests/RunStartTests.cs index a17a7fe89..2f246dbb2 100644 --- a/tests/Aetheria.Shared.Tests/RunStartTests.cs +++ b/tests/Aetheria.Shared.Tests/RunStartTests.cs @@ -510,6 +510,19 @@ public sealed class RunStartTests : IDisposable Assert.True(Offered() > 0, "a hull that takes the Autocannon gives it a home"); } + // A sold weapon can be generated onto an NPC, whose combat state samples its damage at range, so every weapon a + // product sells carries a damage curve. + [Fact] + public void EverySoldWeaponHasADamageCurve() + { + var sold = _cache.GetAll().Select(product => product.Design.Key).ToHashSet(); + var missing = _cache.GetAll() + .Where(design => sold.Contains(_cache.RefOf(design).Key)) + .Where(design => design.Behaviors.OfType().Any(weapon => weapon.DamageCurve?.Keys == null || weapon.DamageCurve.Keys.Length == 0)) + .Select(design => design.Name).OrderBy(name => name, StringComparer.Ordinal).ToList(); + Assert.True(missing.Count == 0, $"sold weapons with no damage curve: {string.Join(", ", missing)}"); + } + // Q3, with the operator's 2026-09-30 ruling on the ten product-less designs: a design no product sells is a // scenario test design and nothing else. A test design is one a scenario places: its preset's hull or a slot of // it, or cargo it carries. These are the unsold designs no scenario places, by name. diff --git a/tools/AetherDb/Program.cs b/tools/AetherDb/Program.cs index 034bbfd6f..a94782379 100644 --- a/tools/AetherDb/Program.cs +++ b/tools/AetherDb/Program.cs @@ -36,8 +36,9 @@ public static class Program case "targeting-catalog": return TargetingCatalog(args.Contains("apply")); case "targeting-catalog-6c": return TargetingCatalog6c(args.Contains("apply")); case "targeting-catalog-6d": return TargetingCatalog6d(args.Contains("apply")); + case "damage-curves": return DamageCurves(args.Contains("apply")); default: - Console.WriteLine("commands: census, factions, station-fit, hardpoint-fit, loadout [seed], save, settings, settings-dump, dangling [clear ]... [apply], shield-migrate [apply], brownout-migrate [apply], roles-migrate [apply], firing-arc-migrate [apply], targeting-catalog [apply], targeting-catalog-6c [apply], targeting-catalog-6d [apply]"); + Console.WriteLine("commands: census, factions, station-fit, hardpoint-fit, loadout [seed], save, settings, settings-dump, dangling [clear ]... [apply], shield-migrate [apply], brownout-migrate [apply], roles-migrate [apply], firing-arc-migrate [apply], targeting-catalog [apply], targeting-catalog-6c [apply], targeting-catalog-6d [apply], damage-curves [apply]"); return 1; } } @@ -1471,4 +1472,48 @@ public static class Program Console.WriteLine($"\nLanded {precisionChanges.Length} Precision changes in Aetheria.cc"); return 0; } + + // Soul's F4 (scenarios batch 3): five sold weapons had no DamageCurve, and the first NPC to sample their damage + // at range threw. Each takes the curve of its nearest comparable weapon, same weapon class first, then closest + // range and damage. Every curve in the catalog was the same one (full damage at minimum range, falling to none + // at maximum), so what is copied is that curve; the source is named so the operator can tune from it. + private static int DamageCurves(bool apply) + { + var db = AetherDb.Open(catalogWritable: apply); + var cache = db.Cache; + var sources = new (string Weapon, string Source, string Why)[] + { + ("Autocannon", "DeathCluster", "auto-fire, Ballistic, 4 cells; the other auto-fire Ballistic whose range reaches 1000"), + ("LRMM72", "GT 3K", "the only other unguided launcher"), + ("SRMM72", "scorched void policy", "guided launcher; SRMM72's 750 range and 128 damage sit inside its 500-1250 and 128-512"), + ("pswarm", "scorched void policy", "guided launcher with identical damage, range and cooldown"), + ("plight", "ChargeBlast+-", "charged Energy weapon; nearest range (800-1900 against plight's 500-2000)"), + }; + WeaponData WeaponOf(string name) => + cache.GetAll().Single(d => d.Name == name).Behaviors.OfType().Single(); + var changed = new List<(EquippableItemData Design, CultRecordKey Key)>(); + foreach (var (weapon, source, why) in sources) + { + var target = WeaponOf(weapon); + if (target.DamageCurve != null) throw new InvalidOperationException($"{weapon} already has a DamageCurve."); + var curve = WeaponOf(source).DamageCurve; + target.DamageCurve = new BezierCurve { Keys = curve.Keys.ToArray() }; + var design = cache.GetAll().Single(d => d.Name == weapon); + changed.Add((design, cache.RefOf(design).Key)); + Console.WriteLine($"{weapon,-10} <- {source,-22} ({why}): keys {string.Join(" ", curve.Keys.Select(k => $"({k.x}, {k.y}, {k.z}, {k.w})"))}"); + } + + if (!apply) + { + Console.WriteLine("\nDry run. Pass \"apply\" to land it."); + return 0; + } + foreach (var (design, _) in changed) CultRecordRefs.Validate(design); + cache.Commit(batch => + { + foreach (var (design, key) in changed) batch.Upsert(design.GetType(), design, key); + }); + Console.WriteLine($"\nLanded {changed.Count} DamageCurves in Aetheria.cc"); + return 0; + } }