From 08a891a0fc9b45708d075419e1da96e27a9aaaf5 Mon Sep 17 00:00:00 2001 From: NovaRain Date: Sun, 4 Nov 2018 09:14:02 +0800 Subject: [PATCH] Added "obj_under_cursor" script function. Backported some script functions from 4.0: lock_is_jammed, unjam_lock. --- artifacts/scripting/headers/sfall.h | 3 +++ artifacts/scripting/sfall function notes.txt | 12 ++++++++++++ sfall/FalloutEngine.cpp | 3 +++ sfall/FalloutEngine.h | 3 +++ sfall/ScriptExtender.cpp | 3 +++ sfall/ScriptOps/MetaruleOp.hpp | 3 +++ sfall/ScriptOps/MiscOps.hpp | 15 +++++++++++++++ sfall/ScriptOps/ObjectsOps.hpp | 19 +++++++++++++++++++ 8 files changed, 61 insertions(+) diff --git a/artifacts/scripting/headers/sfall.h b/artifacts/scripting/headers/sfall.h index 38ce940d..482b179b 100644 --- a/artifacts/scripting/headers/sfall.h +++ b/artifacts/scripting/headers/sfall.h @@ -224,6 +224,8 @@ #define intface_show sfall_func0("intface_show") #define inventory_redraw(invSide) sfall_func1("inventory_redraw", invSide) #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 set_cursor_mode(mode) sfall_func1("set_cursor_mode", mode) #define set_flags(obj, flags) sfall_func2("set_flags", obj, flags) @@ -232,3 +234,4 @@ #define set_outline(obj, color) sfall_func2("set_outline", obj, color) #define spatial_radius(obj) sfall_func1("spatial_radius", obj) #define tile_refresh_display sfall_func0("tile_refresh_display") +#define unjam_lock(obj) sfall_func1("unjam_lock", obj) diff --git a/artifacts/scripting/sfall function notes.txt b/artifacts/scripting/sfall function notes.txt index 87383796..ba6d1845 100644 --- a/artifacts/scripting/sfall function notes.txt +++ b/artifacts/scripting/sfall function notes.txt @@ -424,6 +424,13 @@ Some utility/math functions are available: - displays player stats in the inventory screen display window - works only in opened inventory +> int sfall_func1("lock_is_jammed", object) +- returns 1 if the lock (container or scenery) is currently jammed, 0 otherwise + +> void sfall_func1("unjam_lock", object) +- unjams a lock immediately without having to wait until the next day, or leave the map and then return after 24 hours +- does not work in use_skill_on_p_proc procedure + > array sfall_func0("get_map_enter_position") - returns an array of the player's position data (index 0 - tile, 1 - elevation, 2 - rotation) when entering the map through exit grids - if entering from the world map, the tile value will be -1 @@ -449,6 +456,11 @@ Some utility/math functions are available: - works just like vanilla CreateWin function, but creates a window with MoveOnTop flag if the flags argument is not specified, and allows to set additional flags for the created window - MoveOnTop flag allows the created window to be placed on top of the game interface +> 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/FalloutEngine.cpp b/sfall/FalloutEngine.cpp index 3076e4bc..7293f72b 100644 --- a/sfall/FalloutEngine.cpp +++ b/sfall/FalloutEngine.cpp @@ -495,6 +495,7 @@ const DWORD obj_find_first_at_ = 0x48B48C; const DWORD obj_find_first_at_tile_ = 0x48B5A8; const DWORD obj_find_next_at_ = 0x48B510; const DWORD obj_find_next_at_tile_ = 0x48B608; +const DWORD obj_lock_is_jammed_ = 0x49D410; const DWORD obj_new_sid_inst_ = 0x49AAC0; const DWORD obj_outline_object_ = 0x48C2B4; const DWORD obj_pid_new_ = 0x489C9C; @@ -505,8 +506,10 @@ const DWORD obj_set_light_ = 0x48AC90; // (int aObj, signed int aDist< const DWORD obj_shoot_blocking_at_ = 0x48B930; // (EAX *obj, EDX hexNum, EBX level) const DWORD obj_sight_blocking_at_ = 0x48BB88; const DWORD obj_top_environment_ = 0x48B304; +const DWORD obj_unjam_lock_ = 0x49D480; const DWORD obj_use_book_ = 0x49B9F0; const DWORD obj_use_power_on_car_ = 0x49BDE8; +const DWORD object_under_mouse_ = 0x44CEC4; const DWORD OptionWindow_ = 0x437C08; const DWORD palette_set_to_ = 0x493B48; const DWORD partyMemberCopyLevelInfo_ = 0x495EA8; diff --git a/sfall/FalloutEngine.h b/sfall/FalloutEngine.h index 56ece31e..03fac587 100644 --- a/sfall/FalloutEngine.h +++ b/sfall/FalloutEngine.h @@ -694,6 +694,7 @@ extern const DWORD obj_find_first_at_; extern const DWORD obj_find_first_at_tile_; // (int elevation, int tile) extern const DWORD obj_find_next_at_; extern const DWORD obj_find_next_at_tile_; // no args +extern const DWORD obj_lock_is_jammed_; extern const DWORD obj_new_sid_inst_; extern const DWORD obj_outline_object_; extern const DWORD obj_pid_new_; @@ -704,8 +705,10 @@ extern const DWORD obj_set_light_; // (int aObj, signed int aDist extern const DWORD obj_shoot_blocking_at_; extern const DWORD obj_sight_blocking_at_; extern const DWORD obj_top_environment_; +extern const DWORD obj_unjam_lock_; extern const DWORD obj_use_book_; extern const DWORD obj_use_power_on_car_; +extern const DWORD object_under_mouse_; extern const DWORD OptionWindow_; extern const DWORD palette_set_to_; extern const DWORD partyMemberCopyLevelInfo_; diff --git a/sfall/ScriptExtender.cpp b/sfall/ScriptExtender.cpp index 80cffe97..ad938543 100644 --- a/sfall/ScriptExtender.cpp +++ b/sfall/ScriptExtender.cpp @@ -389,12 +389,15 @@ static const SfallOpcodeMetadata opcodeMetaArray[] = { {sf_get_outline, "get_outline", {DATATYPE_MASK_VALID_OBJ}}, {sf_inventory_redraw, "inventory_redraw", {DATATYPE_MASK_INT}}, {sf_item_weight, "item_weight", {DATATYPE_MASK_VALID_OBJ}}, + {sf_lock_is_jammed, "lock_is_jammed", {DATATYPE_MASK_VALID_OBJ}}, + {sf_obj_under_cursor, "obj_under_cursor", {DATATYPE_MASK_INT, DATATYPE_MASK_INT}}, {sf_set_cursor_mode, "set_cursor_mode", {DATATYPE_MASK_INT}}, {sf_set_flags, "set_flags", {DATATYPE_MASK_VALID_OBJ, DATATYPE_MASK_INT}}, {sf_set_ini_setting, "set_ini_setting", {DATATYPE_MASK_STR, DATATYPE_MASK_INT | DATATYPE_MASK_STR}}, {sf_set_map_enter_position, "set_map_enter_position", {DATATYPE_MASK_INT, DATATYPE_MASK_INT, DATATYPE_MASK_INT}}, {sf_set_outline, "set_outline", {DATATYPE_MASK_VALID_OBJ, DATATYPE_MASK_INT}}, {sf_spatial_radius, "spatial_radius", {DATATYPE_MASK_VALID_OBJ}}, + {sf_unjam_lock, "unjam_lock", {DATATYPE_MASK_VALID_OBJ}}, {sf_test, "validate_test", {DATATYPE_MASK_INT, DATATYPE_MASK_INT | DATATYPE_MASK_FLOAT, DATATYPE_MASK_STR, DATATYPE_NONE}}, //{op_message_str_game, {}} }; diff --git a/sfall/ScriptOps/MetaruleOp.hpp b/sfall/ScriptOps/MetaruleOp.hpp index b3d93209..d3412c4e 100644 --- a/sfall/ScriptOps/MetaruleOp.hpp +++ b/sfall/ScriptOps/MetaruleOp.hpp @@ -121,6 +121,8 @@ static const SfallMetarule metaruleArray[] = { {"intface_show", sf_intface_show, 0, 0}, {"inventory_redraw", sf_inventory_redraw, 1, 1}, {"item_weight", sf_item_weight, 1, 1}, + {"lock_is_jammed", sf_lock_is_jammed, 1, 1}, + {"obj_under_cursor", sf_obj_under_cursor, 2, 2}, {"outlined_object", sf_outlined_object, 0, 0}, {"set_cursor_mode", sf_set_cursor_mode, 1, 1}, {"set_flags", sf_set_flags, 2, 2}, @@ -129,6 +131,7 @@ static const SfallMetarule metaruleArray[] = { {"set_outline", sf_set_outline, 2, 2}, {"spatial_radius", sf_spatial_radius, 1, 1}, {"tile_refresh_display", sf_tile_refresh_display, 0, 0}, + {"unjam_lock", sf_unjam_lock, 1, 1}, {"validate_test", sf_test, 2, 5}, }; diff --git a/sfall/ScriptOps/MiscOps.hpp b/sfall/ScriptOps/MiscOps.hpp index 1909302d..867bfe3e 100644 --- a/sfall/ScriptOps/MiscOps.hpp +++ b/sfall/ScriptOps/MiscOps.hpp @@ -1693,3 +1693,18 @@ static void sf_set_ini_setting() { break; } } + +static void sf_obj_under_cursor() { + int crSwitch = opHandler.arg(0).asBool() ? 1 : -1, + inclDude = opHandler.arg(1).rawValue(), + obj; + + __asm { + mov ebx, dword ptr ds:[_map_elevation]; + mov edx, inclDude; + mov eax, crSwitch; + call object_under_mouse_; + mov obj, eax; + } + opHandler.setReturn(obj); +} diff --git a/sfall/ScriptOps/ObjectsOps.hpp b/sfall/ScriptOps/ObjectsOps.hpp index 7f52211c..4e6ace60 100644 --- a/sfall/ScriptOps/ObjectsOps.hpp +++ b/sfall/ScriptOps/ObjectsOps.hpp @@ -596,6 +596,25 @@ static void sf_item_weight() { opHandler.setReturn(weight); } +static void sf_lock_is_jammed() { + TGameObj* obj = opHandler.arg(0).asObject(); + int result; + __asm { + mov eax, obj; + call obj_lock_is_jammed_; + mov result, eax; + } + opHandler.setReturn(result); +} + +static void sf_unjam_lock() { + TGameObj* obj = opHandler.arg(0).asObject(); + __asm { + mov eax, obj; + call obj_unjam_lock_; + } +} + static void sf_get_current_inven_size() { opHandler.setReturn(sf_item_total_size(opHandler.arg(0).asObject()), DATATYPE_INT); }