Fixed the lost car bug with using the Town/World button

(http://www.nma-fallout.com/threads/fallout-2-vehicle-bug.217993/)
This commit is contained in:
NovaRain
2019-08-13 13:53:41 +08:00
parent da864c9789
commit 8855326e41
3 changed files with 28 additions and 1 deletions
+5 -1
View File
@@ -650,10 +650,14 @@ UseWalkDistance=3
;Set to 1 to fix the bug of being unable to sell used geiger counters or stealth boys
CanSellUsedGeiger=1
;Set to 1 to fix the issue with being able to charge the car by using cells on other scenary/critters
;Set to 1 to fix the issue with being able to charge the car by using cells on other scenery/critters
;Set to 0 if another mod you're using has custom vehicles
CarChargingFix=1
;Set to 1 to prevent the car from being lost when entering a location via the Town/World button and then leaving on foot
;Note that the global variable 633 (GVAR_CAR_PLACED_TILE) will be set to -1 when the player leaves a location
CarPlacedTileFix=1
;Set to 1 to skip weapon equip/unequip animations when performing various actions
InstantWeaponEquip=0
+1
View File
@@ -159,6 +159,7 @@ enum GlobalVar : long
GVAR_NEW_RENO_SUPER_CAR = 456,
GVAR_MODOC_SHITTY_DEATH = 491,
GVAR_FALLOUT_2 = 494,
GVAR_CAR_PLACED_TILE = 633,
};
// Physical material type, used for items and tiles.
+22
View File
@@ -2252,6 +2252,20 @@ break:
}
}
static void __declspec(naked) wmInterfaceInit_hack() {
__asm {
mov eax, GVAR_CAR_PLACED_TILE;
cmp eax, dword ptr ds:[FO_VAR_num_game_global_vars];
jge skip;
mov edx, ds:[FO_VAR_game_global_vars];
lea edx, [edx + eax * 4];
mov dword ptr [edx], -1; // set gvar
skip:
mov edx, 12;
retn;
}
}
void BugFixes::init()
{
#ifndef NDEBUG
@@ -2841,6 +2855,14 @@ void BugFixes::init()
// Fix for combat not ending automatically when there are no hostile critters
MakeCall(0x422CF3, combat_should_end_hack);
SafeWrite16(0x422CEA, 0x0C74); // jz 0x422CF8 (skip party members)
// Fix for the car being lost when entering a location via the Town/World button and then leaving on foot
// (sets GVAR_CAR_PLACED_TILE (633) to -1 on exit to the world map)
if (GetConfigInt("Misc", "CarPlacedTileFix", 1)) {
dlog("Applying car placed tile fix.", DL_INIT);
MakeCall(0x4C2367, wmInterfaceInit_hack);
dlogr(" Done", DL_INIT);
}
}
}