Skip to content

Instantly share code, notes, and snippets.

@phobos2077
Created May 12, 2024 00:56
Show Gist options
  • Save phobos2077/3cf6c87019557f23bfe2808082178639 to your computer and use it in GitHub Desktop.
Save phobos2077/3cf6c87019557f23bfe2808082178639 to your computer and use it in GitHub Desktop.
FO2 (sfall) car rebalancing script
#include "../sfall/sfall.h"
#include "../sfall/define_lite.h"
#include "../headers/global.h"
#define GAS_TANK_CAPACITY (80000)
/*
Runs continuously during worldmap travel on car.
```
int arg0 - vanilla car speed (between 3 and 8 "steps")
int arg1 - vanilla fuel consumption (100 and below)
int ret0 - car speed override (pass -1 if you just want to override fuel consumption)
int ret1 - fuel consumption override
*/
procedure cartravel_hook begin
variable steps, fuel,
origSteps := get_sfall_arg,
origFuel := get_sfall_arg;
debug_msg(string_format("car %d, %d", origSteps, origFuel));
steps := 3;
if (global_var(GVAR_CAR_BLOWER)) then steps += 1;
if (global_var(GVAR_NEW_RENO_CAR_UPGRADE)) then steps += 1;
if (global_var(GVAR_NEW_RENO_SUPER_CAR)) then steps += 3;
fuel := 100;
if (global_var(GVAR_NEW_RENO_SUPER_CAR)) then fuel -= fuel * 90 / 100;
if (global_var(GVAR_NEW_RENO_CAR_UPGRADE)) then fuel -= fuel * 10 / 100;
if (global_var(GVAR_CAR_UPGRADE_FUEL_CELL_REGULATOR)) then fuel /= 2;
set_sfall_return(steps);
set_sfall_return(fuel);
end
procedure start begin
register_hook_proc(HOOK_CARTRAVEL, cartravel_hook);
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment