Gyro: damage fan-out FUN_004b2980 -- the cockpit hit-BOUNCE is live (task #56)
Re-disassembled the unexported gap 0x4b2980-0x4b2d8b byte-exact (capstone over
section_dump.txt) and reconstructed Gyroscope::ApplyDamageResponse:
- zero-damage + Collision(type 0) no-op; hit direction = Damage::damageForce
or a RANDOM horizontal fallback when ~zero (per-component sign roll then
value roll -- binary-legal until senders fill damageForce)
- direction rotated by the yaw-only torso-twist frame (placeRot=(0,twist,0)
-> euler->matrix, the FUN_00408744 raw row-dot reproduced verbatim)
- per-type scaling amount / damageMultiplier[type] * damageResponse[type]
.{trans,pitchRoll,yaw,vibration}; Explosive alone multiplies burstCount;
each clamped at 1.3f
- four kicks: impulse(trans, dir), torque(pitchRoll, dir), impulse(vibration,
vibrationDirection@0x390) and verticalImpulse(yaw, dir)
Layout corrections (byte-verified): gyro+0x390 is ONE Vector3D vibration axis
init (0,1,0) -- was mis-split as scalars animationOffset/Scale/Phase; mech
+0x5c4 is a FLOAT rumble-period countdown (gyroRumbleTimer) -- was mis-typed
int clipLoadGuard.
Call sites wired (binary-gated):
- take-damage hub: mech.cpp TakeDamageMessageHandler, FIRST action (@0x4a0264
in hub FUN_004a0230) -- an invalid-zone hit still bounces
- crushable-icon crunch: mech4.cpp, torque 0.4 along the bounce delta-v + up
impulse 0.2 (@4aa81e/@4aa86c)
- firing recoil: projweap.cpp FireWeapon, damage>3 -> impulse (0,0.6,-1.5)
x damage/16 (@4bc136-4bc19c) via the new Mech::GetGyroSubsystem accessor
DEFERRED (recorded in KB with the byte recipe): the alternate-gait engage
jolt + 0.4s rumble (@4aa158-4aa365) -- its gates are [T3]-flagged and it
mutates the #49/#50-stabilized gait machine.
Verified live: [gyro-dmg] fires per hit with correct type scaling; eyePosition
shows the damped bounce (ramp to ~0.015u, oscillating Y, decay to zero); kill
chain un-regressed; no NaN.
Also recorded in KB: the OFFSET-COCKPIT verification -- Thor's authored
jointeye tranx=+1.13 matches its canopy X-center exactly AND our in-game eye
reproduces it to the hundredth (the placement model is correct per-mech); and
the playable roster is 8 models (strider/raptor/firstrtr/blkjack have assets
but no model resource -- BT_FORCE_MODEL with those names = NULL-resource AV,
cdb-verified, not a code bug).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
cb85517ede
commit
946323b696
+154
-3
@@ -177,6 +177,7 @@ struct GyroLayoutCheck
|
||||
static_assert(offsetof(Gyroscope, bodyWork) == 0x320, "bodyWork @0x320");
|
||||
static_assert(offsetof(Gyroscope, damageMultiplier) == 0x32C, "damageMultiplier @0x32C");
|
||||
static_assert(offsetof(Gyroscope, damageResponse) == 0x340, "damageResponse @0x340");
|
||||
static_assert(offsetof(Gyroscope, vibrationDirection) == 0x390, "vibrationDirection @0x390");
|
||||
static_assert(offsetof(Gyroscope, swayBias) == 0x3A8, "swayBias @0x3A8");
|
||||
static_assert(offsetof(Gyroscope, swayAngle) == 0x3BC, "swayAngle @0x3BC");
|
||||
static_assert(offsetof(Gyroscope, eyeJointNode) == 0x3C8, "eyeJointNode @0x3C8");
|
||||
@@ -306,9 +307,7 @@ Gyroscope::Gyroscope(
|
||||
externalPitchPtr = &spare0; // @0x258 self-pointer (:2933);
|
||||
// bt_mech tail re-points to &torso pitch
|
||||
}
|
||||
animationOffset = 0.0f; // @0x390
|
||||
animationScale = 1.0f; // @0x394
|
||||
animationPhase = 0.0f; // @0x398
|
||||
vibrationDirection = Vector3D(0.0f, 1.0f, 0.0f); // @0x390 the up vibration axis (:2921-2923)
|
||||
swayAngle = 0.0f; // @0x3BC
|
||||
swayVelocity = 0.0f; // @0x3C0
|
||||
swayActive = 0; // @0x3C4
|
||||
@@ -632,6 +631,18 @@ void
|
||||
DEBUG_STREAM << "[gyro] *** NaN DETECTED in integrator state ***\n" << std::flush;
|
||||
}
|
||||
++s_gc;
|
||||
// bounce visibility probe: log the first N frames where the eye is actually
|
||||
// displaced (the periodic sampler above misses short oscillations).
|
||||
static int s_bounceSeen = 0;
|
||||
if (s_glog && s_bounceSeen < 40
|
||||
&& (eyePosition.x > 1e-3f || eyePosition.x < -1e-3f
|
||||
|| eyePosition.y > 1e-3f || eyePosition.y < -1e-3f
|
||||
|| eyePosition.z > 1e-3f || eyePosition.z < -1e-3f))
|
||||
{
|
||||
++s_bounceSeen;
|
||||
DEBUG_STREAM << "[gyro-bounce] eyePos=(" << (float)eyePosition.x << ","
|
||||
<< (float)eyePosition.y << "," << (float)eyePosition.z << ")\n" << std::flush;
|
||||
}
|
||||
if (!NodeRotationEquals(mechJointNode, eyePosition, QuantiseEps)) // FUN_004084fc vs value+0
|
||||
{
|
||||
SetNodeRotation(mechJointNode, eyePosition); // FUN_0041d11c = SetTRANSLATION
|
||||
@@ -728,6 +739,124 @@ void
|
||||
bodyForce.y = bodyForce.x; // *(this+0x30C) = *(this+0x308)
|
||||
}
|
||||
|
||||
//
|
||||
// @004b2980 [T1 -- re-disassembled byte-exact, task #56] -- the damage->gyro
|
||||
// fan-out (the cockpit hit-BOUNCE). Constants from the dump: eps 1e-4
|
||||
// (@0x38d1b717), sign threshold 0.5f (@0x4b2d84), clamp 1.3f (@0x4b2d88).
|
||||
// Collision (type 0) and zero damage no-op. Direction: the Damage record's
|
||||
// damageForce, or a RANDOM horizontal direction when ~zero (per component a
|
||||
// sign roll then a value roll); rotated by the yaw-only torso-twist frame
|
||||
// (placeRot=(0, *externalPitchPtr, 0) -> matrix @workMatrix, the engine
|
||||
// euler->matrix conversion == the binary's euler->quat->matrix FUN_00409a00 +
|
||||
// FUN_0040ab44) then re-normalized. Per-type scaling: amount / multiplier *
|
||||
// response{trans,pitchRoll,yaw,vibration}; the Explosive case alone multiplies
|
||||
// by burstCount. Four kicks: directional impulse (trans), torque (pitchRoll),
|
||||
// a vibration shake along the FIXED member axis vibrationDirection@0x390 (up),
|
||||
// and the vertical impulse fed by the row's third field ("yaw").
|
||||
//
|
||||
void
|
||||
Gyroscope::ApplyDamageResponse(const Damage &damage)
|
||||
{
|
||||
if (damage.damageAmount == 0.0f) // @4b298c (0.0f @0x4b2d80)
|
||||
return;
|
||||
if (damage.damageType == Damage::CollisionDamageType) // @4b299e -- collisions never bounce here
|
||||
return;
|
||||
|
||||
Scalar trans = 0.0f; // ebp-0x10
|
||||
Scalar pitchRoll = 0.0f; // ebp-0x0C
|
||||
Scalar yaw = 0.0f; // ebp-0x08
|
||||
Scalar vibration = 0.0f; // ebp-0x04
|
||||
|
||||
Vector3D dir; // ebp-0x1C
|
||||
if (Close_Enough(damage.damageForce, Vector3D(0.0f, 0.0f, 0.0f), 1e-4f)) // @4b29bd FUN_004084fc
|
||||
{
|
||||
// random horizontal: sign roll (>= 0.5 keeps +) then value roll, y=0
|
||||
dir.x = (RandomUnit() >= 0.5f) ? RandomUnit() : -RandomUnit(); // @4b29d7
|
||||
dir.z = (RandomUnit() >= 0.5f) ? RandomUnit() : -RandomUnit(); // @4b2a0d
|
||||
dir.y = 0.0f; // @4b2a43
|
||||
}
|
||||
else
|
||||
{
|
||||
dir = damage.damageForce; // @4b2a4a FUN_00408440
|
||||
}
|
||||
dir.Normalize(dir); // @4b2a62 FUN_004087f4 (unguarded in the binary too)
|
||||
|
||||
// @4b2a67-4b2af5: yaw-only body frame from the torso twist; rotate the
|
||||
// WORLD hit direction into it (FUN_00408744 raw row-dot on entries[0..2]/
|
||||
// [4..6]/[8..10] -- reproduced verbatim below) and re-normalize. The
|
||||
// placement state @0x28C/0x298/0x2A8 is written for member fidelity.
|
||||
placeRot = Vector3D(0.0f, *externalPitchPtr, 0.0f); // gyro+0x2A8..0x2B0
|
||||
placePos = Vector3D(0.0f, 0.0f, 0.0f); // @4b2aa8
|
||||
{
|
||||
AffineMatrix m;
|
||||
m = EulerAngles(Radian(placeRot.x), Radian(placeRot.y), Radian(placeRot.z));
|
||||
for (int i = 0; i < 12; ++i) workMatrix[i] = m.entries[i]; // @4b2ac2 FUN_0040ab44
|
||||
Vector3D tmp = dir; // ebp-0x28 @4b2ac7
|
||||
dir.x = tmp.x*workMatrix[0] + tmp.y*workMatrix[1] + tmp.z*workMatrix[2]; // FUN_00408744
|
||||
dir.y = tmp.x*workMatrix[4] + tmp.y*workMatrix[5] + tmp.z*workMatrix[6];
|
||||
dir.z = tmp.x*workMatrix[8] + tmp.y*workMatrix[9] + tmp.z*workMatrix[10];
|
||||
}
|
||||
dir.Normalize(dir); // @4b2aed
|
||||
|
||||
// @4b2afd: per-type scaling (jump table @0x4b2b10; type > 4 leaves all
|
||||
// four at zero). Each term computed independently, matching the binary's
|
||||
// per-term fld/fdiv/fmul.
|
||||
switch (damage.damageType)
|
||||
{
|
||||
case Damage::BallisticDamageType: // @4b2b3d mult@0x330 resp@0x350
|
||||
trans = damage.damageAmount / damageMultiplier[1] * damageResponse[1].trans;
|
||||
pitchRoll = damage.damageAmount / damageMultiplier[1] * damageResponse[1].pitchRoll;
|
||||
yaw = damage.damageAmount / damageMultiplier[1] * damageResponse[1].yaw;
|
||||
vibration = damage.damageAmount / damageMultiplier[1] * damageResponse[1].vibration;
|
||||
break;
|
||||
case Damage::ExplosiveDamageType: // @4b2b8a the ONLY case reading burstCount
|
||||
trans = (Scalar)damage.burstCount * damage.damageAmount / damageMultiplier[2] * damageResponse[2].trans;
|
||||
pitchRoll = (Scalar)damage.burstCount * damage.damageAmount / damageMultiplier[2] * damageResponse[2].pitchRoll;
|
||||
yaw = (Scalar)damage.burstCount * damage.damageAmount / damageMultiplier[2] * damageResponse[2].yaw;
|
||||
vibration = (Scalar)damage.burstCount * damage.damageAmount / damageMultiplier[2] * damageResponse[2].vibration;
|
||||
break;
|
||||
case Damage::LaserDamageType: // @4b2be3 mult@0x338 resp@0x370
|
||||
trans = damage.damageAmount / damageMultiplier[3] * damageResponse[3].trans;
|
||||
pitchRoll = damage.damageAmount / damageMultiplier[3] * damageResponse[3].pitchRoll;
|
||||
yaw = damage.damageAmount / damageMultiplier[3] * damageResponse[3].yaw;
|
||||
vibration = damage.damageAmount / damageMultiplier[3] * damageResponse[3].vibration;
|
||||
break;
|
||||
case Damage::EnergyDamageType: // @4b2c2d mult@0x33C resp@0x380
|
||||
trans = damage.damageAmount / damageMultiplier[4] * damageResponse[4].trans;
|
||||
pitchRoll = damage.damageAmount / damageMultiplier[4] * damageResponse[4].pitchRoll;
|
||||
yaw = damage.damageAmount / damageMultiplier[4] * damageResponse[4].yaw;
|
||||
vibration = damage.damageAmount / damageMultiplier[4] * damageResponse[4].vibration;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// @4b2c75-4b2ce2: upper-clamp each at 1.3f; NO lower clamp.
|
||||
if (trans > 1.3f) trans = 1.3f;
|
||||
if (pitchRoll > 1.3f) pitchRoll = 1.3f;
|
||||
if (yaw > 1.3f) yaw = 1.3f;
|
||||
if (vibration > 1.3f) vibration = 1.3f;
|
||||
|
||||
if (getenv("BT_GYRO_LOG"))
|
||||
DEBUG_STREAM << "[gyro-dmg] type=" << (int)damage.damageType
|
||||
<< " amt=" << (float)damage.damageAmount << " burst=" << (int)damage.burstCount
|
||||
<< " dir=(" << (float)dir.x << "," << (float)dir.y << "," << (float)dir.z
|
||||
<< ") t/p/y/v=" << (float)trans << "/" << (float)pitchRoll << "/"
|
||||
<< (float)yaw << "/" << (float)vibration << "\n" << std::flush;
|
||||
|
||||
ApplyDamageImpulse (dir.x, dir.y, dir.z, trans); // @4b2d00 the directional knock
|
||||
ApplyDamageTorque (dir.x, dir.y, dir.z, pitchRoll); // @4b2d23
|
||||
ApplyDamageImpulse (vibrationDirection.x, vibrationDirection.y,
|
||||
vibrationDirection.z, vibration); // @4b2d4b the up-shake
|
||||
ApplyVerticalImpulse(dir.x, dir.y, dir.z, yaw); // @4b2d6e
|
||||
|
||||
if (getenv("BT_GYRO_LOG"))
|
||||
DEBUG_STREAM << "[gyro-dmg] post-kick exag=" << (float)exageration
|
||||
<< " eyeForce=(" << (float)eyeForce.x << "," << (float)eyeForce.y << "," << (float)eyeForce.z
|
||||
<< ") bodyForce=(" << (float)bodyForce.x << "," << (float)bodyForce.y << ","
|
||||
<< (float)bodyForce.z << ")\n" << std::flush;
|
||||
}
|
||||
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// CreateStreamedSubsystem -- Gyroscope
|
||||
@@ -905,3 +1034,25 @@ void GyroBindExternalPitch(Subsystem *gyro, Scalar *pitch)
|
||||
if (gyro != 0)
|
||||
static_cast<Gyroscope *>(gyro)->BindExternalPitch(pitch);
|
||||
}
|
||||
|
||||
//===========================================================================//
|
||||
// Damage->gyro bridges (task #56 fan-out; binary call sites: the take-damage
|
||||
// hub @0x4a02fb, the performance crunch/jolt/rumble kicks @0x4aa254/0x4aa288/
|
||||
// 0x4aa342/0x4aa81e/0x4aa86c, and the firing-recoil kick @0x4bc194).
|
||||
// Complete-type-TU pattern: callers hold only Subsystem*.
|
||||
//===========================================================================//
|
||||
void GyroApplyDamage(Subsystem *gyro, const Damage &damage)
|
||||
{
|
||||
if (gyro != 0)
|
||||
static_cast<Gyroscope *>(gyro)->ApplyDamageResponse(damage);
|
||||
}
|
||||
void GyroApplyDamageImpulse(Subsystem *gyro, Scalar x, Scalar y, Scalar z, Scalar magnitude)
|
||||
{
|
||||
if (gyro != 0)
|
||||
static_cast<Gyroscope *>(gyro)->ApplyDamageImpulse(x, y, z, magnitude);
|
||||
}
|
||||
void GyroApplyDamageTorque(Subsystem *gyro, Scalar x, Scalar y, Scalar z, Scalar magnitude)
|
||||
{
|
||||
if (gyro != 0)
|
||||
static_cast<Gyroscope *>(gyro)->ApplyDamageTorque(x, y, z, magnitude);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user