diff --git a/artifacts/scripting/headers/sfall.h b/artifacts/scripting/headers/sfall.h index 172ae18e..554b8643 100644 --- a/artifacts/scripting/headers/sfall.h +++ b/artifacts/scripting/headers/sfall.h @@ -228,6 +228,7 @@ #define display_stats sfall_func0("display_stats") #define exec_map_update_scripts sfall_func0("exec_map_update_scripts") #define floor2(value) sfall_func1("floor2", value) +#define get_current_inven_size(obj) sfall_func1("get_current_inven_size", obj) #define get_cursor_mode sfall_func0("get_cursor_mode") #define get_flags(obj) sfall_func1("get_flags", obj) #define get_ini_section(file, sect) sfall_func2("get_ini_section", file, sect) diff --git a/artifacts/scripting/sfall function notes.txt b/artifacts/scripting/sfall function notes.txt index f2e3ff02..36b0b54b 100644 --- a/artifacts/scripting/sfall function notes.txt +++ b/artifacts/scripting/sfall function notes.txt @@ -497,6 +497,9 @@ Some utility/math functions are available: > void sfall_func1("dialog_message", string text) - displays a message in the NPC response window in dialog or barter screen +> int sfall_func1("get_current_inven_size", object) +- returns the current inventory size of the container or the critter + ------------------------ ------ MORE INFO ------- ------------------------ diff --git a/sfall/Modules/Inventory.cpp b/sfall/Modules/Inventory.cpp index 1a8c98ae..ec769942 100644 --- a/sfall/Modules/Inventory.cpp +++ b/sfall/Modules/Inventory.cpp @@ -62,7 +62,7 @@ void InventoryKeyPressedHook(DWORD dxKey, bool pressed, DWORD vKey) { } ///////////////////////////////////////////////////////////////// -static DWORD __stdcall sf_item_total_size(fo::GameObject* critter) { +DWORD __stdcall sf_item_total_size(fo::GameObject* critter) { int totalSize = fo::func::item_c_curr_size(critter); if ((critter->artFid & 0xF000000) == (fo::OBJ_TYPE_CRITTER << 24)) { diff --git a/sfall/Modules/Inventory.h b/sfall/Modules/Inventory.h index 0688d07e..8854da26 100644 --- a/sfall/Modules/Inventory.h +++ b/sfall/Modules/Inventory.h @@ -34,5 +34,6 @@ public: }; void _stdcall SetInvenApCost(int a); +DWORD __stdcall sf_item_total_size(fo::GameObject* critter); } diff --git a/sfall/Modules/Scripting/Handlers/Metarule.cpp b/sfall/Modules/Scripting/Handlers/Metarule.cpp index 063ea876..6c17e347 100644 --- a/sfall/Modules/Scripting/Handlers/Metarule.cpp +++ b/sfall/Modules/Scripting/Handlers/Metarule.cpp @@ -84,6 +84,7 @@ static const SfallMetarule metarules[] = { {"display_stats", sf_display_stats, 0, 0}, {"exec_map_update_scripts", sf_exec_map_update_scripts, 0, 0}, {"floor2", sf_floor2, 1, 1, {ARG_NUMBER}}, + {"get_current_inven_size", sf_get_current_inven_size, 1, 1, {ARG_OBJECT}}, {"get_cursor_mode", sf_get_cursor_mode, 0, 0}, {"get_flags", sf_get_flags, 1, 1, {ARG_OBJECT}}, {"get_ini_section", sf_get_ini_section, 2, 2, {ARG_STRING, ARG_STRING}}, diff --git a/sfall/Modules/Scripting/Handlers/Objects.cpp b/sfall/Modules/Scripting/Handlers/Objects.cpp index 07c03374..d6ae9a82 100644 --- a/sfall/Modules/Scripting/Handlers/Objects.cpp +++ b/sfall/Modules/Scripting/Handlers/Objects.cpp @@ -18,6 +18,7 @@ #include "..\..\..\FalloutEngine\Fallout2.h" #include "..\..\Knockback.h" +#include "..\..\Inventory.h" #include "..\..\PartyControl.h" #include "..\..\ScriptExtender.h" #include "..\Arrays.h" @@ -426,5 +427,9 @@ void sf_set_unjam_locks_time(OpcodeContext& ctx) { } } +void sf_get_current_inven_size(OpcodeContext& ctx) { + ctx.setReturn(sf_item_total_size(ctx.arg(0).asObject())); +} + } } diff --git a/sfall/Modules/Scripting/Handlers/Objects.h b/sfall/Modules/Scripting/Handlers/Objects.h index b0f4832e..1ba732be 100644 --- a/sfall/Modules/Scripting/Handlers/Objects.h +++ b/sfall/Modules/Scripting/Handlers/Objects.h @@ -91,5 +91,7 @@ void sf_unjam_lock(OpcodeContext&); void sf_set_unjam_locks_time(OpcodeContext&); +void sf_get_current_inven_size(OpcodeContext&); + } }