Prevent charged weapon trigger bypass

This commit is contained in:
Meta Vens 2026-07-12 00:29:35 +01:00
commit d1c4e1caef
4 changed files with 54 additions and 2 deletions

View file

@ -13,6 +13,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks
YmirMovesProjectileAndReportsStableContact();
YmirBeamTraceReturnsFirstSpatialContact();
ConstantWeaponRunsOnDaemonThroughYmirBeamContact();
ChargedWeaponCannotBypassChargeLifecycle();
DaemonSimulationAppliesYmirHit();
ProjectileDeathEmitsOnce();
MissingPhysicsOwnerCannotAdvanceProjectiles();
@ -153,6 +154,51 @@ internal sealed class AetheriaDaemonYmirSmokeChecks
"Eve feedback stream must project continuous weapon transition chronology");
}
private static void ChargedWeaponCannotBypassChargeLifecycle()
{
var source = Entity(0, 0, "player");
source.DirectionX = 1;
source.TargetEntityIndex = 1;
source.WeaponGroups = [new[] { 0 }];
source.Equipment = [new AetheriaRuntimeLoadoutItemSlotCommit
{
Item = new AetheriaRuntimeLoadoutItemCommit
{ ItemKey = "test-charged", Quality = 1, Durability = 1, Enabled = true }
}];
var target = Entity(1, 80, "raider");
var zone = new AetheriaRuntimeZoneSnapshotCommit { ZoneIndex = 0, Entities = [source, target] };
var run = new AetheriaRuntimeRunCheckpointCommit
{
RunId = "charged-weapon-admission-smoke", CurrentZoneIndex = 0,
CurrentEntityKey = "zone.0.entity.0", Zones = [zone]
};
var payload = new AetheriaRuntimeBehaviorPayload(0, AetheriaRuntimeBehaviorKinds.ChargedWeapon, 0,
[
new AetheriaRuntimeBehaviorField(2, PerformanceStat(20)),
new AetheriaRuntimeBehaviorField(6, PerformanceStat(150)),
new AetheriaRuntimeBehaviorField(16, PerformanceStat(200)),
new AetheriaRuntimeBehaviorField(17, PerformanceStat(1)),
new AetheriaRuntimeBehaviorField(19, PerformanceStat(0.5)),
new AetheriaRuntimeBehaviorField(21, PerformanceStat(1)),
new AetheriaRuntimeBehaviorField(24, new AetheriaRuntimeBehaviorValue("bool", "", 0, true, "", "", [], [])),
new AetheriaRuntimeBehaviorField(27, Number(2))
]);
var intents = new AetheriaRuntimeDaemonIntentState();
intents.WeaponGroups.Add(new AetheriaRuntimeDaemonWeaponGroupIntent
{
ActorEntityKey = "zone.0.entity.0", WeaponGroup = 0, Fire = true, Active = true
});
AetheriaRuntimeDaemonSimulation.Step(run, intents, 0.1,
new AetheriaRuntimeDaemonSimulationSettings(), new AetheriaYmirProjectilePhysics(),
new AetheriaYmirWorldPhysics(),
new AetheriaRuntimeCatalogSnapshot([CatalogItem("test-charged", payload)], [], []), 0, 0);
Require(zone.Projectiles.Count == 0 && !run.GameEvents.Any(value => value.Kind == "projectile.launched"),
"pressing an authored ChargedWeapon must not bypass charging through the instant weapon resolver");
Require(Math.Abs(Stat(target, "hull") - 100) < 0.000001,
"charged weapon admission must not apply damage before a daemon-owned release commits the shot");
}
private static void AgentTowsStationIntoPersistentOrbit()
{
var tug = Entity(0, 0, "workers");

View file

@ -74,7 +74,12 @@ namespace GameCult.Aetheria.State.Verse
{
Behavior("AetherDrive", "", Stat("MaximumRpm", 3), Stat("CouplingEfficiency", 6), Stat("Torque", 7), Stat("EnergyDraw", 9), Stat("PassiveCoupling", 10)),
Behavior("Capacitor", "", Stat("Capacity", 1), Stat("Efficiency", 2)),
Behavior("ChargedWeapon", AetheriaRuntimeBehaviorKinds.InstantWeapon, With(InstantWeaponFields, Stat("ChargeTime", 21), Stat("ChargeEnergy", 22), Stat("ChargeHeat", 23))),
Behavior("ChargedWeapon", AetheriaRuntimeBehaviorKinds.InstantWeapon, With(InstantWeaponFields,
Stat("ChargeTime", 21), Stat("ChargeEnergy", 22), Stat("ChargeHeat", 23),
Boolean("CanFireEarly", 24), Number("FailureCharge", 25), Number("FailureDamage", 26),
Number("ChargeDamageMultiplier", 27), Number("ChargeSpreadMultiplier", 28),
Number("ChargeBurstCountMultiplier", 29), Number("ChargeVisibilityMultiplier", 30),
Number("ChargeVelocityMultiplier", 31), Number("ChargeHeatMultiplier", 32))),
Behavior("Cockpit", ""),
Behavior("ConstantWeapon", "Weapon", With(WeaponFields, Number("AmmoIntervalDuration", 17))),
Behavior(AetheriaRuntimeBehaviorKinds.GuidedWeapon, AetheriaRuntimeBehaviorKinds.InstantWeapon, With(InstantWeaponFields, Stat("MissileVelocity", 26))),

View file

@ -712,6 +712,7 @@ namespace GameCult.Aetheria.State.Verse
? entity.WeaponGroups[weaponGroup] ?? Array.Empty<int>()
: Array.Empty<int>();
var authored = AetheriaRuntimeEquippedBehaviorQueries.Find(entity, catalog, AetheriaRuntimeBehaviorKinds.InstantWeapon)
.Where(behavior => !string.Equals(behavior.Payload.Kind, AetheriaRuntimeBehaviorKinds.ChargedWeapon, StringComparison.Ordinal))
.Where(behavior => equipmentIndices.Contains(behavior.EquipmentIndex))
.Select(behavior => ResolveAuthoredWeapon(entity, behavior, settings))
.ToArray();

View file

@ -24,7 +24,7 @@ validation proves contract shape, not wiring, exclusivity, lowering, or parity.
| Projectile flight | weapon/projectile classes | Ymir | projectile entity/event projection | native projectile visual | Ymir.Core adapter wired for spawn/travel/contact/despawn; native presentation and broader weapon parity incomplete | prove every authored projectile family and runtime visual lifecycle |
| Shield/hull damage | energy-funded shield, armor cells, equipment and hull | daemon | entity status + damage events | meters, impacts, damage VFX | synthetic scalar owner wired; not parity | typed absorption, penetration, item damage and death causes |
| Thermal/energy | cell conduction and capacitor/reactor/radiator network | daemon | ship/equipment status and warnings | schematic/post effects | cell conduction/radiation wired; energy network and medical thresholds remain reference | capacitor/reactor/radiator ordering, shared energy and medical timelines |
| Weapons | ServerShared behaviors + Unity effects | daemon + Ymir where spatial | action capability, weapon state, attack events | effects/audio/HUD | selected weapon groups resolve equipped typed-catalog instant weapons for authored burst behavior and ConstantWeapon through a separate continuous lifecycle; constant fire persists across ticks, pays elapsed-time energy and heat, advances the fossil ammunition interval, consumes canonical magazine/cargo state, interrupts for daemon-owned reload, and emits start/stop/refusal/reload edges; Ymir's ordered circle cast owns first-contact beam occlusion and the daemon applies accepted continuous damage to that body rather than the selected target; every `world.entity3d` now contains generic repeated `weapon.state` children with authored item/behavior identity and complete firing, ammunition, reload, cooldown, charge, lock, and refusal state | charged/guided families, visibility/wear, penetration and damage curves, plus Unity continuous-effect reconciliation from generic state |
| Weapons | ServerShared behaviors + Unity effects | daemon + Ymir where spatial | action capability, weapon state, attack events | effects/audio/HUD | selected weapon groups resolve equipped typed-catalog instant weapons for authored burst behavior and ConstantWeapon through a separate continuous lifecycle; constant fire persists across ticks, pays elapsed-time energy and heat, advances the fossil ammunition interval, consumes canonical magazine/cargo state, interrupts for daemon-owned reload, and emits start/stop/refusal/reload edges; Ymir's ordered circle cast owns first-contact beam occlusion and the daemon applies accepted continuous damage to that body rather than the selected target; every `world.entity3d` now contains generic repeated `weapon.state` children with authored item/behavior identity and complete firing, ammunition, reload, cooldown, charge, lock, and refusal state; ChargedWeapon is explicitly excluded from the instant resolver, so pressing it cannot bypass charge, and its full fields 21-32 are typed for the dedicated lifecycle | implement charged press/hold/release/failure and committed-shot state, then guided families, visibility/wear, penetration and damage curves, plus Unity continuous-effect reconciliation from generic state |
| Destruction/drops | entity death and pickup paths | daemon | death/drop events and world entities | effects and pickups | fragments wired; chronology and original drop transaction absent | exactly-once drops and cleanup |
| Tractor/scoop | analog tractor and physical timed pickups | daemon + Ymir | tractor power, pickup body and receipt | beam/interaction feedback | fossil 2/s power ramp and authored forward radius/traction/distance feed pickup bodies into the shared Ymir world; shield contact collects exactly once when capacity permits or applies the fossil 25-unit rejection kick; 30s daemon lifetime; instant cargo teleport deleted | prove generic runtime beam, contact, success and rejection feedback |
| Dock/undock | wormhole-first interact; first eligible bay; component prerequisites | daemon + Ymir placement | dock commands/context | camera/UI transition | daemon path wired/projected; Ymir placement and parity unproven | priority, eligibility, placement and reconnect |