OpenTrespasser / JurassicParkTrespasser

A git-based fork of the Jurassic Park: Trespasser source code.
101 stars 25 forks source link

Jump bug #13

Open meekee7 opened 4 years ago

meekee7 commented 4 years ago

The game has a bug: Jumping while the player is standing on an object only works sporadically. This was also present in the original game.

This was addressed in the official patch and in the CE mod. The jump bug should be resolved in OpenTrespasser as well.

Some more details: The cause of the issue is in Xob_bc.cpp, directly below the YIKES! comment: with the instruction OKtoJump = false;, which is executed basically every frame. A jump from an object often gets cancelled before it is performed.

A quick workaround is to execute OKtoJump = false; only in foot.cpp when a jump is performed. But this has a side effect: with good timing, the player can perform double jumps. Neither the official patch nor the CE mod had this double jump bug.

The monorail track at the end of the first level seems to be a good spot for testing.

meekee7 commented 4 years ago

For clarification, the double jump above means a second jump mid-air.

meekee7 commented 4 years ago

Upon further analysis, the cause of the jump bug seems to be something different than described above. The jump is triggered in the physics subsystem by "messages", which are evaluated in InfoSkeleton.cpp in CPhysicsInfoSkeleton::HandleMessage. When a message contains a jump request, some physics flags regarding jumping are activated, otherwise they are deactivated. Sometimes after evaluating a jump request message, another non-jump message is evaluated. This causes a reset of the jumping flags before the jump can be executed.

I have tried to do the reset only after a jump was executed. This makes jumping work consistently, but it also introduces a novel type of double jump: when the jump key is pressed while a jump is in progress, that new jump is performed immediately after landing. (This experiment did not involve the workaround mentioned above.)

A comprehensive solution remains difficult to find, because reliable indicators for "jump is in progress" or "player has ground contact" have not been identified yet.