sfall 3.8.2 is released on SourceForge, along with modders pack (only a document update) and win2k version.
When replacing a previously wielded armor or weapon, the unwielding hook will not be executed. You'll need to check if an armor/weapon is already equipped when wielding hook is executed; otherwise, the script could be exploitable or have unexpected side effects.
For example, I want to make party members gain 2 AP when wearing an armor and code hs_invenwield like this:
The logic is pretty straightforward: if wielding (hooktype == 1) an armor, +2 AP to the critter; else it should be unwielding (what else could happen?), so -2 AP from the critter.
But if I give a leather jacket to Sulik (or anyone) and wield on him with "Use Best Armor" button, then without telling him to remove the jacket, give him a leather armor and wield again - I will see him receiving an unplanned +2 AP. So as long as I keep replacing better armors for party members, they will gain more and more AP.
To fix the exploit and prevent party members from having too many AP, I need to check if there's an armor already equipped:
A note for any modder who wants to use hs_invenwield hook script:Changelog said:v3.8.2
>Fixed broken call_offset_* functions
>Fixed OverrideMusicDir not using the correct path string
>Fixed a bug in metarule2_explosions function that caused damage type change not to work
>Fixed a crash if calling reg_anim_obj_run_to_tile after reg_anim_combat_check
>Changed sfallgv.sav to be loaded before other save game files to make saved arrays available in the start procedure
>Changed BodyHit_Torso to BodyHit_Torso_Uncalled because it sets both body_torso and body_uncalled hit modifiers
Original engine bug fixes and various features based on the work by Crafty:
>Added a fix for display issues when calling gdialog_mod_barter with critters with no 'Barter' flag set
>Added a fix for the original engine issue that caused items to disappear from inventory when you try to drag them to bag/backpack in the inventory list and are overloaded
>Added a fix for the original engine issue that caused the game not to check player's inventory properly when putting items into the bag/backpack in the hands
>Added a fix for the original engine issue that caused the current carry weight and the range of equipped weapons being lowered temporarily when opening bag/backpack
>Added a fix for a crash when trying to open bag/backpack on the table in the bartering interface
>Added the ability to move items out of bag/backpack and back into the main inventory list by dragging them to character's image (similar to Fallout 1 behavior)
>Changed WorldMapEncounterFix/Rate to work independently of WorldMapFPSPatch
When replacing a previously wielded armor or weapon, the unwielding hook will not be executed. You'll need to check if an armor/weapon is already equipped when wielding hook is executed; otherwise, the script could be exploitable or have unexpected side effects.
For example, I want to make party members gain 2 AP when wearing an armor and code hs_invenwield like this:
Code:
// hs_invenwield.ssl
procedure start;
#include ".\HEADERS\DEFINE.H"
procedure start begin
if not init_hook then begin
variable critter := get_sfall_arg, item := get_sfall_arg, slot := get_sfall_arg, hooktype := get_sfall_arg;
if ((slot == INVEN_TYPE_WORN) and (party_member_obj(obj_pid(critter)) != 0)) then begin
if (hooktype == 1) then begin
set_critter_extra_stat(critter, STAT_max_move_points, get_critter_extra_stat(critter, STAT_max_move_points) + 2);
end else begin
set_critter_extra_stat(critter, STAT_max_move_points, get_critter_extra_stat(critter, STAT_max_move_points) - 2);
end
display_msg(hooktype + ", " + obj_name(item) + ", " + get_critter_extra_stat(critter, STAT_max_move_points));
end
end
end
But if I give a leather jacket to Sulik (or anyone) and wield on him with "Use Best Armor" button, then without telling him to remove the jacket, give him a leather armor and wield again - I will see him receiving an unplanned +2 AP. So as long as I keep replacing better armors for party members, they will gain more and more AP.
To fix the exploit and prevent party members from having too many AP, I need to check if there's an armor already equipped:
Code:
// hs_invenwield.ssl
procedure start;
#include ".\HEADERS\DEFINE.H"
procedure start begin
if not init_hook then begin
variable critter := get_sfall_arg, item := get_sfall_arg, slot := get_sfall_arg, hooktype := get_sfall_arg;
if ((slot == INVEN_TYPE_WORN) and (party_member_obj(obj_pid(critter)) != 0)) then begin
if ((hooktype == 1) and obj_pid(critter_inven_obj(critter, slot)) <= 0) then begin
set_critter_extra_stat(critter, STAT_max_move_points, get_critter_extra_stat(critter, STAT_max_move_points) + 2);
end else if (hooktype == 0) then begin
set_critter_extra_stat(critter, STAT_max_move_points, get_critter_extra_stat(critter, STAT_max_move_points) - 2);
end
display_msg(hooktype + ", " + obj_name(item) + ", " + get_critter_extra_stat(critter, STAT_max_move_points));
end
end
end
Last edited: