From 4ae4d6dff0693c6de5c2bb796e3504405527ad48 Mon Sep 17 00:00:00 2001 From: NovaRain Date: Sun, 4 Nov 2018 09:06:31 +0800 Subject: [PATCH] Fixed broken return values in HOOK_FINDTARGET. Changed the two arguments for obj_under_cursor to bool. --- artifacts/scripting/sfall function notes.txt | 8 ++++---- sfall/Modules/HookScripts/CombatHs.cpp | 8 ++++---- sfall/Modules/Scripting/Handlers/Misc.cpp | 9 +-------- 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/artifacts/scripting/sfall function notes.txt b/artifacts/scripting/sfall function notes.txt index fac520c8..af2c136a 100644 --- a/artifacts/scripting/sfall function notes.txt +++ b/artifacts/scripting/sfall function notes.txt @@ -542,10 +542,10 @@ 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 +> object sfall_func2("obj_under_cursor", bool crSwitch, bool inclDude) +- returns the object under the cursor on the main game screen +- crSwitch: True - only checks critters and ignores their cover (roof tiles, walls, scenery, etc.), False - checks all objects (can't check critters under objects) +- passing False to the inclDude argument will ignore dude_obj ------------------------ ------ MORE INFO ------- diff --git a/sfall/Modules/HookScripts/CombatHs.cpp b/sfall/Modules/HookScripts/CombatHs.cpp index f4218bca..9269afe0 100644 --- a/sfall/Modules/HookScripts/CombatHs.cpp +++ b/sfall/Modules/HookScripts/CombatHs.cpp @@ -186,10 +186,10 @@ static void __fastcall FindTargetHook_Script(DWORD* target, DWORD attacker) { RunHookScript(HOOK_FINDTARGET); if (cRet >= 4) { - target[0] = args[1]; - target[1] = args[2]; - target[2] = args[3]; - target[3] = args[4]; + target[0] = rets[0]; + target[1] = rets[1]; + target[2] = rets[2]; + target[3] = rets[3]; } EndHook(); } diff --git a/sfall/Modules/Scripting/Handlers/Misc.cpp b/sfall/Modules/Scripting/Handlers/Misc.cpp index 777388b3..ff46960e 100644 --- a/sfall/Modules/Scripting/Handlers/Misc.cpp +++ b/sfall/Modules/Scripting/Handlers/Misc.cpp @@ -1723,14 +1723,7 @@ void sf_get_ini_section(OpcodeContext& ctx) { } 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)); - } + ctx.setReturn(fo::func::object_under_mouse(ctx.arg(0).asBool() ? 1 : -1, ctx.arg(1).rawValue(), fo::var::map_elevation)); } }