From 3758ec9cc85f9b4639879921e0081acaada8be56 Mon Sep 17 00:00:00 2001 From: phobos2077 Date: Mon, 7 Aug 2023 21:33:06 +0200 Subject: [PATCH] car_charge_amount_fix - Override car charging calculation to take modified ammo pack size into account (e.g. 20 MFC refills 20%, 20 SEC refills 10%) --- .../_pbs_main/gl_car_charge_amount_fix.ssl | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 scripts_src/_pbs_main/gl_car_charge_amount_fix.ssl diff --git a/scripts_src/_pbs_main/gl_car_charge_amount_fix.ssl b/scripts_src/_pbs_main/gl_car_charge_amount_fix.ssl new file mode 100644 index 0000000..4a7c7eb --- /dev/null +++ b/scripts_src/_pbs_main/gl_car_charge_amount_fix.ssl @@ -0,0 +1,33 @@ +#include "../sfall/sfall.h" +#include "../sfall/lib.obj.h" +#include "../sfall/define_lite.h" + +#define PID_DRIVABLE_CAR (33555441) +#define PID_SMALL_ENERGY_CELL (38) +#define PID_MICRO_FUSION_CELL (39) +#define GAS_TANK_CAPACITY (80000) + +procedure useobjon_hook begin + variable + target := get_sfall_arg, + user := get_sfall_arg, + item := get_sfall_arg; + + //display_msg(string_format("useobjon: %s uses %s on %s", obj_name_safe(user), obj_name_safe(item), obj_name_safe(target))); + if (target and item and + obj_pid(target) == PID_DRIVABLE_CAR and + user == dude_obj and (obj_pid(item) == PID_MICRO_FUSION_CELL or obj_pid(item) == PID_SMALL_ENERGY_CELL) and + car_gas_amount < GAS_TANK_CAPACITY) then + begin + variable refillPercent := get_weapon_ammo_count(item); + if (obj_pid(item) == PID_SMALL_ENERGY_CELL) then + refillPercent /= 2; + car_give_gas(80000 * refillPercent / 100); + display_msg(mstr_proto(595)); + set_sfall_return(1); + end +end + +procedure start begin + register_hook_proc(HOOK_USEOBJON, useobjon_hook); +end