Audio: in-game TRIGGERING works -- real StateIndicator attrs + audio-watcher databinding (task #50)

Enabling audio unlocked L4AudioRenderer::CreateEntityAudioObjects, which binds
AudioStateWatchers to entity/subsystem state attrs BY NAME (attribute-pointer
databinding) and calls AddAudioWatcher on them.  The reconstruction pointed the
Mech's state attrs at the scalar read-pad `attrPad` (fine for gauges that READ a
value, fatal for a state watcher that calls a METHOD) -> AV in SChainOf::Add on
0xCDCDCDCD.  Root-caused via cdb + a BT_ATTRBIND_LOG trace in AttributeWatcher.

Mech-level state audio now REAL + driven (verified: walking fires SetupPatch +
PlayNote/alSourcePlay, patches 78/80/116):
- AnimationState (0x1f) / ReplicantAnimationState (0x20): real StateIndicators
  (0x21 states covering MechAnimationState 0..0x20), driven from SetBodyAnimation
  so footstep/gait/transition sounds fire on animation change.
- CollisionState (0x16): real 4-state StateIndicator driven from ProcessCollision
  via collisionTemporaryState (the deferred @4aa741 per-frame zero + the
  part_012.c:15406-15413 contact tail, InitialHit accumulation; the 1-vs-2 Slide
  split awaits the 0x240/0x244 floats still stubbed by fieldAt()).
- @0x44c CORRECTED: "ammoState (0/1 leaking/2 dry)" was a mislabel -> it is
  collisionTemporaryState (never read as ammo).

Bring-up guards [T3, temporary, self-clearing] so audio-on is STABLE while the
subsystem state models are still stubs (Generators/Condensers/Myomers/Torso/
Avionics/Reservoir/ControlsMapper -- ~15 subsystems, ~40 attrs: GeneratorState,
CondenserState, ReportLeak, ...): a NULL subsystem attr redirects to an inert pad
(was a fatal Fail); an AudioStateWatcher on an unconstructed StateIndicator (null/
0xCDCDCDCD) skips instead of AV.  Both pass automatically once the subsystem is
reconstructed.  Those subsystem sounds stay silent until then (their audio wave).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
arcattack
2026-07-15 19:40:08 -05:00
co-authored by Claude Opus 4.8
parent c75abca857
commit 7b1e469ffa
6 changed files with 107 additions and 23 deletions
+16 -3
View File
@@ -703,7 +703,7 @@ const Mech::IndexEntry
Mech::AttributePointers[]=
{
ATTRIBUTE_ENTRY(Mech, MaxAcceleration, attrPad), // 0x15
ATTRIBUTE_ENTRY(Mech, CollisionState, attrPad), // 0x16
ATTRIBUTE_ENTRY(Mech, CollisionState, collisionState), // 0x16 real StateIndicator (audio impact/scrape watcher)
ATTRIBUTE_ENTRY(Mech, CollisionNormal, attrPad), // 0x17
ATTRIBUTE_ENTRY(Mech, CollisionSpeed, attrPad), // 0x18
ATTRIBUTE_ENTRY(Mech, CollisionMaterialType, attrPad), // 0x19
@@ -712,8 +712,8 @@ const Mech::IndexEntry
ATTRIBUTE_ENTRY(Mech, EyepointRotation, eyepointRotation), // 0x1c (real member -- the eye reads it per frame)
ATTRIBUTE_ENTRY(Mech, TargetReticle, targetReticle), // 0x1d (real Reticle struct -- task #36)
ATTRIBUTE_ENTRY(Mech, FootStep, attrPad), // 0x1e
ATTRIBUTE_ENTRY(Mech, AnimationState, attrPad), // 0x1f
ATTRIBUTE_ENTRY(Mech, ReplicantAnimationState, attrPad), // 0x20
ATTRIBUTE_ENTRY(Mech, AnimationState, animationState), // 0x1f real StateIndicator (audio state-watcher binds + AddAudioWatcher)
ATTRIBUTE_ENTRY(Mech, ReplicantAnimationState, replicantAnimationState), // 0x20 real StateIndicator
ATTRIBUTE_ENTRY(Mech, LinearSpeed, linearSpeed), // 0x21 (live forward speed)
ATTRIBUTE_ENTRY(Mech, ClimbRate, attrPad), // 0x22
ATTRIBUTE_ENTRY(Mech, AccelerationLastFrame, attrPad), // 0x23
@@ -910,6 +910,19 @@ Mech::Mech(
// emission so the window was never hit.) Standing = 0.
attrPad = 0.0f; // shared read pad for un-populated gauge attributes
linearSpeed = 0.0f; // live forward ground speed (LinearSpeed gauge); set per frame
// Size the animation StateIndicators to cover clips 0..0x20 (MechAnimationState,
// death variants past AnimationCount=0x1d included) so SetState(state) never trips
// Verify(state<stateCount). operator= copies only the counts (keeps the ctor-built
// watcher sockets); then seat the initial standing state. [T2]
animationState = StateIndicator(0x21);
animationState.SetState(0); // StandingAnimation
replicantAnimationState = StateIndicator(0x21);
replicantAnimationState.SetState(0);
// CollisionState: 4 states (NoCollision/InitialHit/Slide/Rest) driven per frame
// from the collision walk (ProcessCollision) so impact audio fires on contact.
collisionState = StateIndicator(4); // CollisionStateCount
collisionState.SetState(0); // NoCollisionState
collisionTemporaryState = 0;
radarRange = 1000.0f; // radar display scale (SetTargetRange is stubbed;
// 1km default zoom so contacts within ~500m show on
// the radar, vs the config maximum_range=4000 edge)