diff --git a/artifacts/scripting/headers/sfall.h b/artifacts/scripting/headers/sfall.h index 57744323..74da1b5e 100644 --- a/artifacts/scripting/headers/sfall.h +++ b/artifacts/scripting/headers/sfall.h @@ -255,6 +255,7 @@ #define item_make_explosive(pid, aPid, min, max) sfall_func4("item_make_explosive", pid, aPid, min, max) #define item_weight(obj) sfall_func1("item_weight", obj) #define lock_is_jammed(obj) sfall_func1("lock_is_jammed", obj) +#define obj_under_cursor(crSwitch, inclDude) sfall_func2("obj_under_cursor", crSwitch, inclDude) #define outlined_object sfall_func0("outlined_object") #define real_dude_obj sfall_func0("real_dude_obj") #define set_can_rest_on_map(map, elev, value) sfall_func3("set_can_rest_on_map", map, elev, value) diff --git a/artifacts/scripting/sfall function notes.txt b/artifacts/scripting/sfall function notes.txt index ddb92292..fac520c8 100644 --- a/artifacts/scripting/sfall function notes.txt +++ b/artifacts/scripting/sfall function notes.txt @@ -542,6 +542,11 @@ Some utility/math functions are available: > object sfall_func0("dialog_obj") - returns the object (critter) the player is having a conversation or bartering with +> object sfall_func2("obj_under_cursor", int crSwitch, int inclDude) +- returns the object under the cursor +- crSwitch must be -1 or 1: -1 - checks items/critters/scenery/walls, 1 - only checks critters and ignores their cover (roof tiles, walls, scenery, etc.) +- passing 0 to the inclDude argument will ignore dude_obj + ------------------------ ------ MORE INFO ------- ------------------------ diff --git a/sfall/FalloutEngine/Functions_def.h b/sfall/FalloutEngine/Functions_def.h index 0bebefbe..12cebff9 100644 --- a/sfall/FalloutEngine/Functions_def.h +++ b/sfall/FalloutEngine/Functions_def.h @@ -73,6 +73,7 @@ WRAP_WATCOM_FUNC2(long, obj_pid_new, fo::GameObject*, object, long, pid) // checks/unjams jammed locks WRAP_WATCOM_FUNC1(long, obj_lock_is_jammed, GameObject*, object) WRAP_WATCOM_FUNC1(void, obj_unjam_lock, GameObject*, object) +WRAP_WATCOM_FUNC3(long, object_under_mouse, long, crSwitch, long, inclDude, long, elevation) WRAP_WATCOM_FUNC6(long, pick_death, GameObject*, attacker, GameObject*, target, GameObject*, weapon, long, amount, long, anim, long, hitFromBack) WRAP_WATCOM_FUNC2(long, queue_find_first, GameObject*, object, long, qType) WRAP_WATCOM_FUNC3(long, register_object_animate, GameObject*, object, long, anim, long, delay) diff --git a/sfall/Modules/Scripting/Handlers/Metarule.cpp b/sfall/Modules/Scripting/Handlers/Metarule.cpp index 8863bb26..725fff3f 100644 --- a/sfall/Modules/Scripting/Handlers/Metarule.cpp +++ b/sfall/Modules/Scripting/Handlers/Metarule.cpp @@ -104,6 +104,7 @@ static const SfallMetarule metarules[] = { {"item_make_explosive", sf_item_make_explosive, 3, 4, {ARG_INT, ARG_INT, ARG_INT, ARG_INT}}, {"item_weight", sf_item_weight, 1, 1, {ARG_OBJECT}}, {"lock_is_jammed", sf_lock_is_jammed, 1, 1, {ARG_OBJECT}}, + {"obj_under_cursor", sf_obj_under_cursor, 2, 2, {ARG_INT, ARG_INT}}, {"outlined_object", sf_outlined_object, 0, 0}, {"real_dude_obj", sf_real_dude_obj, 0, 0}, {"set_can_rest_on_map", sf_set_rest_on_map, 3, 3, {ARG_INT, ARG_INT, ARG_INT}}, diff --git a/sfall/Modules/Scripting/Handlers/Misc.cpp b/sfall/Modules/Scripting/Handlers/Misc.cpp index 4ae91248..777388b3 100644 --- a/sfall/Modules/Scripting/Handlers/Misc.cpp +++ b/sfall/Modules/Scripting/Handlers/Misc.cpp @@ -1722,5 +1722,16 @@ void sf_get_ini_section(OpcodeContext& ctx) { ctx.setReturn(arrayId); } +void sf_obj_under_cursor(OpcodeContext& ctx) { + int crSwitch = ctx.arg(0).asInt(), + inclDude = ctx.arg(1).asInt(); + + if (crSwitch != -1 && crSwitch != 1) { + ctx.printOpcodeError("obj_under_cursor() - crSwitch value must be -1 or 1."); + } else { + ctx.setReturn(fo::func::object_under_mouse(crSwitch, inclDude, fo::var::map_elevation)); + } +} + } } diff --git a/sfall/Modules/Scripting/Handlers/Misc.h b/sfall/Modules/Scripting/Handlers/Misc.h index 500f76ea..3a34f1a7 100644 --- a/sfall/Modules/Scripting/Handlers/Misc.h +++ b/sfall/Modules/Scripting/Handlers/Misc.h @@ -165,5 +165,7 @@ void sf_get_ini_sections(OpcodeContext&); void sf_get_ini_section(OpcodeContext&); +void sf_obj_under_cursor(OpcodeContext&); + } }