Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lara: add responsive jumping #864

Merged
merged 4 commits into from
Jun 5, 2023

Conversation

lahm86
Copy link
Collaborator

@lahm86 lahm86 commented Jun 2, 2023

Resolves #157.

Checklist

  • I have read the coding conventions
  • I have added a changelog entry about what my pull request accomplishes, or it is an internal change

Description

The new injection file here will amend the relevant anim range low/high frames as detailed in the issue. It wasn't possible to combine this with the lara_animations.bin file as that is always injected, whereas this one needs to be tied to the config option.

Demo: https://www.youtube.com/watch?v=mqi9EDz0FYU

A bit more detail on the jump lock workings. It's effectively to allow animation 0 to behave differently the first time compared to subsequent times during continuous running jumps.

  1. Lara wants to run so enters animation 6 (RUN_START)
  2. The game sets a lock saying jumping is not allowed
  3. Animation 6 completes and moves to animation 0 (RUN)
  4. Lara wants to jump immediately
    • The jump lock is still in force, so frames 0, 1, 2, 3 play out as normal
    • Frame 4 is reached, the jump lock is lifted
    • Lara can jump from her left foot if frame < 11
    • Lara can jump from her right foot if frame >= 11
  5. The jump animation completes and she (via a few other interim animations) returns to animation 0 (RUN) frame 1
  6. The jump lock is lifted this time around, so she is free to jump on any frame
  7. Lara stops, or grabs a ledge, or anything else
  8. She wants to run again, GOTO 1

@lahm86 lahm86 added Feature New functionality Data Requires injecting content / files that are not a part of the original game labels Jun 2, 2023
@lahm86 lahm86 added this to the 2.15 milestone Jun 2, 2023
@lahm86 lahm86 self-assigned this Jun 2, 2023
@lahm86 lahm86 force-pushed the issue-157-tr2-jumping branch 2 times, most recently from 7130485 to 2d163a5 Compare June 2, 2023 17:49
@lahm86 lahm86 requested review from rr- and walkawayy June 2, 2023 17:51
Copy link
Collaborator

@walkawayy walkawayy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a style comment from me.

src/game/lara/lara_state.c Outdated Show resolved Hide resolved
@lahm86
Copy link
Collaborator Author

lahm86 commented Jun 2, 2023

I just realised that this broke the Lost Valley demo - Lara ends up not leaving the pool. I've gone for the same approach as disabling enable_enhanced_look temporarily while in the demo.

} else {
jump_permitted = true;
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this boolean logic can be simplified, I'll follow up tomorrow

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this work?

    if (g_Config.enable_tr2_jumping) {
        int16_t anim = item->anim_number - g_Objects[item->object_number].anim_index;
        if (anim == LA_RUN_START) {
            m_JumpPermitted = false;
        } else if (anim != LA_RUN || item->frame_number == LF_JUMP_READY) {
            m_JumpPermitted = true;
        }
    }

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks much better - I'll test it out tomorrow. Thanks.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An ideal outcome would be to forgo introducing a new global variable and set it always in the local scope. But I don't think that's possible since frame number resets to 0 and cycles, so even comparing it with >= will work in an unintended way.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is a shame but thankfully this is a short snippet of code now so looks much tidier. I've tested it out and all is good 👍

@lahm86 lahm86 requested review from rr- and walkawayy June 5, 2023 08:37
@lahm86 lahm86 force-pushed the issue-157-tr2-jumping branch from b90de6d to adfc476 Compare June 5, 2023 09:03
@lahm86
Copy link
Collaborator Author

lahm86 commented Jun 5, 2023

Sorry, just remembered to rebase following #867 (for the changelog).

@lahm86 lahm86 requested a review from rr- June 5, 2023 09:08
Copy link
Collaborator

@walkawayy walkawayy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lahm86 lahm86 merged commit fc1a70c into LostArtefacts:develop Jun 5, 2023
@lahm86 lahm86 deleted the issue-157-tr2-jumping branch June 5, 2023 18:40
@rr- rr- added the TR1 label Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Data Requires injecting content / files that are not a part of the original game Feature New functionality TR1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: TR2+ Jump Mechanics
3 participants