diff --git a/artifacts/scripting/headers/define_extra.h b/artifacts/scripting/headers/define_extra.h index 9934983e..f3295abb 100644 --- a/artifacts/scripting/headers/define_extra.h +++ b/artifacts/scripting/headers/define_extra.h @@ -109,6 +109,7 @@ #define PROTO_IT_SIZE (112) #define PROTO_IT_WEIGHT (116) #define PROTO_IT_COST (120) +#define PROTO_IT_INV_FID (124) // weapons #define PROTO_WP_ANIM (36) diff --git a/sfall/FalloutEngine/Functions_def.h b/sfall/FalloutEngine/Functions_def.h index 417ed83c..5ff7b8aa 100644 --- a/sfall/FalloutEngine/Functions_def.h +++ b/sfall/FalloutEngine/Functions_def.h @@ -36,6 +36,7 @@ WRAP_WATCOM_FUNC0(void, intface_toggle_item_state) WRAP_WATCOM_FUNC0(void, intface_use_item) WRAP_WATCOM_FUNC1(long, item_w_max_ammo, GameObject*, item) WRAP_WATCOM_FUNC1(long, item_w_curr_ammo, GameObject*, item) +WRAP_WATCOM_FUNC1(long, item_weight, GameObject*, item) // returns light level at given tile WRAP_WATCOM_FUNC2(long, light_get_tile, long, elevation, long, tileNum) WRAP_WATCOM_FUNC2(void, mouse_get_position, long*, outX, long*, outY) diff --git a/sfall/Modules/Scripting/Handlers/Metarule.cpp b/sfall/Modules/Scripting/Handlers/Metarule.cpp index 4be7ef29..698236e6 100644 --- a/sfall/Modules/Scripting/Handlers/Metarule.cpp +++ b/sfall/Modules/Scripting/Handlers/Metarule.cpp @@ -123,6 +123,7 @@ static const SfallMetarule metaruleArray[] = { {"intface_show", sf_intface_show, 0, 0}, {"intface_hide", sf_intface_hide, 0, 0}, {"intface_is_hidden", sf_intface_is_hidden, 0, 0}, + {"item_weight", sf_item_weight, 1, 1, {ARG_OBJECT}}, {"exec_map_update_scripts", sf_exec_map_update_scripts, 0, 0}, {"set_outline", sf_set_outline, 2, 2, {ARG_OBJECT, ARG_INT}}, {"get_outline", sf_get_outline, 1, 1, {ARG_OBJECT}}, @@ -169,6 +170,8 @@ void HandleMetarule(OpcodeContext& ctx) { ctx.setArgShift(1); if (ValidateMetaruleArguments(ctx, currentMetarule)) { currentMetarule->func(ctx); + } else if (ctx.hasReturn()) { + ctx.setReturn(-1); } } else { ctx.printOpcodeError("sfall_funcX(name, ...) - name '%s' is unknown.", name); diff --git a/sfall/Modules/Scripting/Handlers/Objects.cpp b/sfall/Modules/Scripting/Handlers/Objects.cpp index 6b3caed5..a9558d40 100644 --- a/sfall/Modules/Scripting/Handlers/Objects.cpp +++ b/sfall/Modules/Scripting/Handlers/Objects.cpp @@ -423,5 +423,9 @@ void sf_outlined_object(OpcodeContext& ctx) { ctx.setReturn(fo::var::outlined_object); } +void sf_item_weight(OpcodeContext& ctx) { + ctx.setReturn(fo::func::item_weight(ctx.arg(0).asObject())); +} + } } diff --git a/sfall/Modules/Scripting/Handlers/Objects.h b/sfall/Modules/Scripting/Handlers/Objects.h index ec1b7d9c..098cf384 100644 --- a/sfall/Modules/Scripting/Handlers/Objects.h +++ b/sfall/Modules/Scripting/Handlers/Objects.h @@ -77,5 +77,7 @@ void sf_get_flags(OpcodeContext&); void sf_outlined_object(OpcodeContext&); +void sf_item_weight(OpcodeContext&); + } }