Skip to content

Commit

Permalink
Eldridge: a workaround to make sure .223 Pistol don't get wiped by wi…
Browse files Browse the repository at this point in the history
…pe_inventory setting

- Spawn one if it's not there for existing saves, but only once
  • Loading branch information
phobos2077 committed Jul 6, 2024
1 parent 2666ab6 commit d4aea7e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
13 changes: 13 additions & 0 deletions scripts_src/newreno/nceldrid.ssl
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ procedure Node030;
#define dude_touched_door_bit bit_15
#define back_room_bit bit_16
#define closed_warning_bit bit_17
// pbs:
#define pistol_blyat_bit bit_24

#define module lvar_bit(LVAR_Flags, module_bit)
#define set_module set_lvar_bit_on(LVAR_Flags, module_bit)
Expand All @@ -134,6 +136,9 @@ procedure Node030;
#define closed_warning lvar_bit(LVAR_Flags, closed_warning_bit)
#define set_closed_warning set_lvar_bit_on(LVAR_Flags, closed_warning_bit)

#define pistol_blyat lvar_bit(LVAR_Flags, pistol_blyat_bit)
#define set_pistol_blyat set_lvar_bit_on(LVAR_Flags, pistol_blyat_bit)

#define give_eldridge_box(x) if (x != current_box) then begin \
if (current_box != 0) then begin \
move_obj_inven_to_obj(self_obj, current_box); \
Expand Down Expand Up @@ -328,6 +333,14 @@ procedure talk_p_proc begin
gdialog_set_barter_mod(-10);
//added by killap

// pbs: workaround for overly-aggressive wipe_inventory: restore pistol, but only once (potentially grants a second one)
if (not pistol_blyat) then begin
if (obj_is_carrying_obj_pid(new_reno_eldridge_box_2, PID_223_PISTOL) == 0) then begin
ndebug("restoring deleted .223 Pistol!");
call add_item_pid(new_reno_eldridge_box_2, PID_223_PISTOL);
end
set_pistol_blyat;
end
if (eldridge_bed_time) then begin
call Node030;
end else begin
Expand Down
8 changes: 8 additions & 0 deletions scripts_src/newreno/nieldbx2.ssl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ procedure map_enter_p_proc begin
if (is_loading_game == false) then begin
restock_fix
if (local_var(LVAR_Restock_Time) < game_time) then begin
variable pistol_blyat := obj_carrying_pid_obj(self_obj, PID_223_PISTOL);
if (pistol_blyat) then begin
ndebug("preserving .223 Pistol from inventory wipe...");
rm_obj_from_inven(self_obj, pistol_blyat);
end

variable tmp_box := move_critical_items();
if (map_first_run) then begin
give_pid_qty(self_obj, PID_223_PISTOL, 1)
Expand All @@ -69,6 +75,8 @@ procedure map_enter_p_proc begin
call check_restock_craft_schematic(PID_PBS_CRAFT_SCHEMA_T2, PID_IMPROVED_FLAMETHROWER, 100);
call check_restock_craft_schematic(PID_PBS_CRAFT_SCHEMA_T2, PID_FLAMETHROWER_FUEL_MK_II, 100);
call restore_critical_items(tmp_box);
if (pistol_blyat) then
add_obj_to_inven(self_obj, pistol_blyat);
set_local_var(LVAR_Restock_Time, (random(2,4) * ONE_GAME_DAY) + game_time);
end
end
Expand Down

0 comments on commit d4aea7e

Please sign in to comment.