JuniorDjjr / SA-MixSets

https://www.mixmods.com.br/2019/08/mod-mixsets.html
MIT License
43 stars 6 forks source link

"Broken parachute after dying with one in your inventory" fix #6

Open Lordmau5 opened 2 years ago

Lordmau5 commented 2 years ago

Hey there!

First off, thank you guys for this mod, it definitely brings in lots of fantastic fixes and makes the game more enjoyable :)

2nd off, I was working on one of my own mods that adds some Chaos Mod related fixes as well and ended up finding a solution to the bug where the parachute doesn't work properly after you die with one in your inventory.

In the external PLCHUTE script there are 2 variables: FREEFALL_STAGE and PARACHUTE_CREATION_STAGE.

These 2 variables aren't reset to 0 when the player spawns.

The fix I found is to hook a method within CGameLogic::Update (in my case, the call for CReferences::RemoveReferencesToPlayer) and just reset those to 0 in there.

Working code from my mod:

static void
Hooked_BrokenParachuteFix ()
{
    CReferences::RemoveReferencesToPlayer ();

    // GetGlobalVariable is getting the corresponding value from the CTheScripts::ScriptSpace
    int &parachuteCreationStage = GetGlobalVariable<int> (1497);
    int &freefallStage          = GetGlobalVariable<int> (1513);

    parachuteCreationStage = 0;
    freefallStage          = 0;
}

I thought I'd share it with you guys so you can implement it yourself :)

JuniorDjjr commented 2 years ago

Interesting, but what does "doesn't work properly" means?

Lordmau5 commented 2 years ago

Instead of trying to explain it in words, check out this short video: https://streamable.com/3j4nfe

I have a parachute on me, then I die with the suicide cheat. If I try to open the parachute in the air after this death it won't work as the parachute script is not reset properly.

Basically, the controls don't work and you will just fall to your death as the game thinks you don't have a parachute on.

JuniorDjjr commented 2 years ago

This is a very serious bug, are you sure it's vanilla and mods like SilentPatch don't fix it already? Anyway, I will add, thanks.

Lordmau5 commented 2 years ago

Yes, this is a very long-standing vanilla bug that surprisingly isn't already fixed by SilentPatch (I would've contacted him and asked him if he would like to add it as well, but he's not working on any mods for R* games anymore for obvious reasons)

Either way, I'd assume this just never came up during testing at R*. Who get's a parachute, then dies with it, only to get another one and go skydiving with it right after? 😁

But yes, good to hear it's getting added - I also have it in my Chaos Mod but it's nice to have for everyone else, too :)