Skip to content

Commit

Permalink
Fix Drive-By softlock
Browse files Browse the repository at this point in the history
If the player enters the very first marker too quickly (within 11 seconds) the mission variables aren't properly updated and the mission softlocks at the Pay N Spray section.
A casual player shouldn't ever experience this because the drive towards the marker takes around 30 seconds, if not more.
  • Loading branch information
Lordmau5 committed Jan 31, 2023
1 parent 8b4f92e commit 822c47a
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/gtasa/GameHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ class GameHandler
Hooked_RemoveCJFromCarBeforeDeletion, void (CVehicle *),
0x467B3C);

// Fix Drive-By mission flags not updating properly if player is too
// fast for the first marker
HOOK_METHOD_ARGS (GlobalHooksInstance::Get (),
Hooked_FixDriveBySpeedSoftlock,
char *(CRunningScript *, int), 0x46665C);

// Hook OPCodes 500-599
HOOK_METHOD_ARGS (GlobalHooksInstance::Get (), Hooked_OpCodes_500_599,
char (CRunningScript *, int), 0x47E090);
Expand Down Expand Up @@ -433,6 +439,22 @@ class GameHandler
cb ();
}

static char *
Hooked_FixDriveBySpeedSoftlock (auto &&cb, CRunningScript *script,
int count)
{
int offset = script->m_pCurrentIP - script->m_pBaseIP - 2;

char *result = cb ();

if (offset == 18096 && *result < 2)
{
*result = 2;
}

return result;
}

static char
Hooked_OpCodes_500_599 (auto &&cb, CRunningScript *script, int opcode)
{
Expand Down

0 comments on commit 822c47a

Please sign in to comment.