fix(njhub): a built counterweight goes down by itself, and the scripts hear it arrive

Live (the Frakjaw battle captures, LOT 16141): when its quick build completes the simple mover is serialized waiting at waypoint 0 (9) and about 0.1 s later travelling (2); it stops at its end without a serialization. That is the client's LWOPlatform, active once the quick build is complete (SendMessage 0x00bdc930), waiting the shortest wait and setting off (RunPlatform 0x00c86e10). L_CAVE_PRISON_CAGE and L_MONASTERY_BOSS_INSTANCE_SERVER never send it: they ask to be told of its PlatformAtLastWaypoint, and act then.

So the simple mover sets off when it is built, the cave prison's button goes down when the counterweight arrives instead of when it is built, and Frakjaw is hit when it arrives (0.1 s and the row's 1 s after the build) instead of on a 0.5 s timer with a counterweight that never moved.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-11-10 13:39:48 -06:00
parent 11d7455cad
commit 7f62425456
5 changed files with 130 additions and 49 deletions

View File

@@ -390,3 +390,43 @@ TEST_F(MovingPlatformComponentTest, SetCurrentPathPutsTheMoverOnThePath) {
EXPECT_EQ(mover->mState, 28u);
EXPECT_EQ(mover->mCurrentWaypointIndex, 2u);
}
// The NJ counterweights in the live captures (LOT 16141, the Frakjaw battle): when the quick build completes the simple
// mover is serialized waiting at waypoint 0 (9), then travelling from it (2); it stops at its end without a
// serialization, where PlatformAtLastWaypoint tells the scripts
TEST_F(MovingPlatformComponentTest, BuiltSimpleMoverSetsOffLikeLive) {
info.lot = 16141;
info.pos = NiPoint3(10.0f, 20.0f, 30.0f);
info.rot = QuatUtils::IDENTITY;
Entity counterweight(288300744895900112, info);
counterweight.AddComponent<SimplePhysicsComponent>(-1);
auto* const platform = counterweight.AddComponent<MovingPlatformComponent>(41, "");
auto* const mover = platform->GetSimpleMoverSubComponent();
uint32_t atLastWaypoint = 0;
platform->AddPlatformAtLastWaypointCallback([&atLastWaypoint] { atLastWaypoint++; });
platform->OnCompleteQuickBuild();
RakNet::BitStream built;
platform->Serialize(built, false);
EXPECT_EQ(Bits(built), "101" "00000101000000000000000000000000" "0" "1" "00001001000000000000000000000000" "00000000000000000000000000000000" "0" "0");
counterweight.Update(0.0f); // timers added now start on the next update
counterweight.Update(0.11f);
EXPECT_EQ(mover->mState, 2u);
RakNet::BitStream travelling;
platform->Serialize(travelling, false);
EXPECT_EQ(Bits(travelling), "101" "00000101000000000000000000000000" "0" "1" "00000010000000000000000000000000" "00000000000000000000000000000000" "0" "0");
counterweight.Update(0.0f);
counterweight.Update(0.5f);
EXPECT_EQ(mover->mState, 2u);
EXPECT_EQ(atLastWaypoint, 0u);
counterweight.Update(0.6f);
EXPECT_EQ(mover->mState, 28u);
EXPECT_EQ(mover->mCurrentWaypointIndex, 1u);
EXPECT_EQ(atLastWaypoint, 1u);
EXPECT_EQ(counterweight.GetPosition(), NiPoint3(10.0f, 17.5f, 30.0f));
RakNet::BitStream arrived;
platform->Serialize(arrived, false);
EXPECT_EQ(Bits(arrived), "00");
}