Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

lara_cheat: fix weapon issues #239

Merged
merged 2 commits into from
Sep 19, 2024

Conversation

lahm86
Copy link
Collaborator

@lahm86 lahm86 commented Sep 15, 2024

Resolves #237.

When Lara goes into an extra death animation, like HSH, her current gun status is lost, so I've introduced a caching mechanism to allow it be properly restored if TP or fly is used. I could not find another way to to do this otherwise, as her status is "hands busy" in the extra anim, and I couldn't find another way to work out what she was actually doing before the cutscene starts.

The other issue with the shotgun appearing in her hand after leaving the fly cheat quickly during undrawing should hopefully be resolved too.

@lahm86 lahm86 added TRX bug A bug with TR2X Unreleased labels Sep 15, 2024
@lahm86 lahm86 added this to the 0.3 milestone Sep 15, 2024
@lahm86 lahm86 self-assigned this Sep 15, 2024
@lahm86 lahm86 requested review from a team as code owners September 15, 2024 13:11
@lahm86 lahm86 requested review from rr-, walkawayy and aredfan and removed request for a team September 15, 2024 13:11
Copy link

@aredfan aredfan left a comment

Choose a reason for hiding this comment

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

Lara no longer retains the rifle type weapon in her hand when fly cheat lasts for a brief duration.

I've tested all the scenarios I could think of in HSH - whether Lara is armed/unarmed before the ending animation is triggered. I checked what happens when fly or teleport cheats are used, and what happens when Lara teleports to dry/water rooms. I also checked the start of HSH and the special animation in Offshore Rig too, just in case.

All LGTM, and thank you.

@rr-
Copy link
Collaborator

rr- commented Sep 15, 2024

What if we just remove this?

diff --git a/src/game/creature.c b/src/game/creature.c
index fb1b273b..26d48eaa 100644
--- a/src/game/creature.c
+++ b/src/game/creature.c
@@ -826,8 +826,6 @@ void __cdecl Creature_Kill(
     g_LaraItem->goal_anim_state = lara_kill_state;
     g_LaraItem->current_anim_state = lara_kill_state;
     g_Lara.extra_anim = 1;
-    g_Lara.gun_status = LGS_HANDS_BUSY;
-    g_Lara.gun_type = LGT_UNARMED;
     g_Lara.hit_direction = -1;
     g_Lara.air = -1;
 

https://home.wind.garden/serve/pub/TR2X-0.2-449-g6d3deb1-dirty-Windows.zip

It seems to help with the original issue all the while introducing no regressions to the special death animations. I know of the following cases, but I might've missed some:

  • Home Sweet Home final animation
  • T-Rex chomp
  • Xian spearman impaling
  • Shark bite

@lahm86
Copy link
Collaborator Author

lahm86 commented Sep 15, 2024

What if we just remove this?

diff --git a/src/game/creature.c b/src/game/creature.c
index fb1b273b..26d48eaa 100644
--- a/src/game/creature.c
+++ b/src/game/creature.c
@@ -826,8 +826,6 @@ void __cdecl Creature_Kill(
     g_LaraItem->goal_anim_state = lara_kill_state;
     g_LaraItem->current_anim_state = lara_kill_state;
     g_Lara.extra_anim = 1;
-    g_Lara.gun_status = LGS_HANDS_BUSY;
-    g_Lara.gun_type = LGT_UNARMED;
     g_Lara.hit_direction = -1;
     g_Lara.air = -1;
 

https://home.wind.garden/serve/pub/TR2X-0.2-449-g6d3deb1-dirty-Windows.zip

It seems to help with the original issue all the while introducing no regressions to the special death animations. I know of the following cases, but I might've missed some:

  • Home Sweet Home final animation
  • T-Rex chomp
  • Xian spearman impaling
  • Shark bite

This allows Lara to shoot during the special animations 😄

image

Sorry, I should have mentioned I tried this already. I also tried doing a check to exit gun control if .extra_anim is set, but she then doesn't fire the shotgun at the very end.

I also tried forcing her to be unarmed after using tp if the extra animation is set, but it generally ended in being unable to draw weapons again (or interact, climb etc).

@walkawayy
Copy link
Collaborator

Could we just "reset"/reinitialize Lara on fly or tp? Is it a huge loss if she doesn't retain her current weapon?

@rr-
Copy link
Collaborator

rr- commented Sep 15, 2024

Could we just "reset"/reinitialize Lara on fly or tp? Is it a huge loss if she doesn't retain her current weapon?

Yeah – I'd just force her to have no gun equipped if it interrupted a special animation.

@lahm86
Copy link
Collaborator Author

lahm86 commented Sep 19, 2024

The problem is, ideally we want to set request gun type to undraw, to trigger the animation of her putting the weapon away. But only if she is holding a weapon, and we can't originally know that because Creature_Kill nukes that information.

If I just set the following in TP, the original bug remains. It's because gun control sees no difference in the status and so doesn't force her to undraw/reset her arms.

g_Lara.gun_status = LGS_ARMLESS;
g_Lara.gun_type = LGT_UNARMED;

If I omit the gun type, her arms reset, but she then softlocks - can't interact, draw guns again etc.

We could maybe manually reset her arms?

@rr-
Copy link
Collaborator

rr- commented Sep 19, 2024

The problem is, ideally we want to set request gun type to undraw, to trigger the animation of her putting the weapon away. But only if she is holding a weapon, and we can't originally know that because Creature_Kill nukes that information.

If I just set the following in TP, the original bug remains. It's because gun control sees no difference in the status and so doesn't force her to undraw/reset her arms.

g_Lara.gun_status = LGS_ARMLESS;
g_Lara.gun_type = LGT_UNARMED;

If I omit the gun type, her arms reset, but she then softlocks - can't interact, draw guns again etc.

We could maybe manually reset her arms?

Yes, I'd say resetting Lara completely would be the best. (Maybe with the exception of holsters and the back gun.)

This allows the gun undrawing animation to complete fully, avoiding
mesh issues if the cheat is exited very quickly.

Part of LostArtefacts#237.
@lahm86
Copy link
Collaborator Author

lahm86 commented Sep 19, 2024

Ok, I think this is good now. We have to retain a flare check otherwise I couldn't get her left arm to reset, so currently if you a light a flare before an extra anim, then TP or fly, the flare will persist. Otherwise, if a gun is equipped, Lara will be unarmed after the anim, and her hands should be in the correct position.

@rr-
Copy link
Collaborator

rr- commented Sep 19, 2024

(I haven't tested – but the code LGTM.)

Copy link

@aredfan aredfan left a comment

Choose a reason for hiding this comment

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

I've tested all the scenarios I could think of in these extra anims. Everything looks good. 👍

@lahm86 lahm86 merged commit a562f5c into LostArtefacts:develop Sep 19, 2024
2 checks passed
@lahm86 lahm86 deleted the issue-237-gun-status-cheats branch September 19, 2024 16:45
@rr- rr- added the TR2 label Oct 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TR2X bug: couple of weapon issues when using cheats
4 participants