From 46a80fdb6aa5d2e1f02c8873738f1dedfaa5db25 Mon Sep 17 00:00:00 2001 From: NovaRain Date: Tue, 13 Jun 2023 11:31:53 +0800 Subject: [PATCH] Added get_tile_fid and macros to function notes Some misc edits to documents. --- artifacts/ddraw.ini | 4 ++-- artifacts/scripting/functions.yml | 16 +++++++++------- artifacts/scripting/headers/lib.inven.h | 3 +-- artifacts/scripting/headers/sfall.h | 7 ++++--- artifacts/scripting/hooks.yml | 6 ++++-- artifacts/scripting/hookscripts.md | 6 ++++-- artifacts/scripting/sfall function notes.md | 20 +++++++++++++++++--- artifacts/scripting/sfall opcode list.md | 2 +- artifacts/scripting/sfall opcode list.txt | 4 ++-- 9 files changed, 44 insertions(+), 24 deletions(-) diff --git a/artifacts/ddraw.ini b/artifacts/ddraw.ini index 95f112d1..352963e4 100644 --- a/artifacts/ddraw.ini +++ b/artifacts/ddraw.ini @@ -22,7 +22,7 @@ UseCommandLine=0 ;Starting from 4.2.6, the game will automatically search and load custom .dat files (or folders named as .dat files) from \mods\ ;The load order of files in the folder will be in reverse alphabetical order of the filenames ;Autoloaded files will have a higher priority than the files specified in the PatchFileXX options -;The complete data load order is: +;The complete order of how the engine finds game data is: ;master_patches > critter_patches > mods > PatchFile99..PatchFile0 > patchXXX.dat > sfall.dat > critter_dat > f2_res_patches > f2_res_dat > master_dat ;PatchFile0=mods\RP_data ;PatchFile1= @@ -286,7 +286,7 @@ UseFileSystemOverride=0 ;If you want to load multiple patch files (up to 1000) at once, you can include a %d in the file name (sprintf syntax) ;PatchFile=patch%03d.dat -;Set to 1 to use the modified data load order for the engine to find game data +;Set to 1 to change the order of how the engine finds game data ;Original: patchXXX.dat > critter_patches > critter_dat > f2_res_patches > f2_res_dat > master_patches > master_dat ;Modified: master_patches > critter_patches > extra_patches > patchXXX.dat > sfall.dat > critter_dat > f2_res_patches > f2_res_dat > master_dat ;This option is always enabled in 4.3/3.8.30 or later. The information is left for reference only diff --git a/artifacts/scripting/functions.yml b/artifacts/scripting/functions.yml index 9804d1b8..bb4fbf32 100644 --- a/artifacts/scripting/functions.yml +++ b/artifacts/scripting/functions.yml @@ -791,7 +791,7 @@ opcode: 0x825f - name: reg_anim_turn_towards detail: void reg_anim_turn_towards(ObjectPtr, int tile/target, delay) - doc: Makes object change its direction to face given tile num or target object. + doc: Makes object change its direction to face given tile number or target object. opcode: 0x8260 - name: reg_anim_callback detail: void reg_anim_callback(procedure proc) @@ -825,9 +825,9 @@ - name: get_tile_fid detail: int get_tile_fid(int tileData) doc: | - - returns FID information about the square under the given tile at elevation 0 - - pass elevation as 4-bit number in bits 25-28 to access other elevations - - pass result mode in bits 29-32: 0 - Ground FID, 1 - Roof FID, 2 - Raw data. + - Returns FID information about the square under the given tile at elevation 0 + - Pass elevation as 4-bit number in bits 25-28 to access other elevations + - Pass result mode in bits 29-32: 0 - ground FID, 1 - roof FID, 2 - raw data. opcode: 0x823a - name: tile_under_cursor detail: int tile_under_cursor @@ -856,11 +856,11 @@ macro: sfall.h - name: get_tile_ground_fid detail: int get_tile_ground_fid(int tileNum, int elevation) - doc: Returns FID of a ground tile at given tileNum and elevation. + doc: Returns FID of a ground tile at given tile number and elevation. macro: sfall.h - name: get_tile_roof_fid detail: int get_tile_roof_fid(int tileNum, int elevation) - doc: Returns FID of a roof tile at given tileNum and elevation. Note that FID of 1 is used when there is no actual roof. + doc: Returns FID of a roof tile at given tile number and elevation. Note that FID of 1 is used when there is no actual roof. macro: sfall.h - name: obj_blocking_line @@ -1110,7 +1110,9 @@ opcode: 0x8251 - name: get_string_pointer detail: int get_string_pointer(string text) - doc: Returns a pointer to a string variable or to a text. DEPRECATED, just use normal strings instead. + doc: | + (DEPRECATED) Returns a pointer to a string variable or to a text + - __NOTE:__ this function is intended for use only in `HOOK_DESCRIPTIONOBJ`. Starting from sfall 4.3.9/3.8.39, you can return normal strings directly in the hook without calling the function macro: sfall.h - name: string_format detail: string string_format(string format, any val1, any val2, ...) diff --git a/artifacts/scripting/headers/lib.inven.h b/artifacts/scripting/headers/lib.inven.h index 33ac2ede..74429bcb 100644 --- a/artifacts/scripting/headers/lib.inven.h +++ b/artifacts/scripting/headers/lib.inven.h @@ -51,10 +51,9 @@ procedure remove_items_pid(variable invenObj, variable itemPid, variable quantit variable begin item; toRemoveQty; - numRemoved; end if (not(invenObj)) then return; - toRemoveQty := obj_is_carrying_obj_pid(invenObj,itemPid); + toRemoveQty := obj_is_carrying_obj_pid(invenObj, itemPid); if (quantity < toRemoveQty and quantity != -1) then begin toRemoveQty := quantity; end diff --git a/artifacts/scripting/headers/sfall.h b/artifacts/scripting/headers/sfall.h index ef9c36a8..8c9b8200 100644 --- a/artifacts/scripting/headers/sfall.h +++ b/artifacts/scripting/headers/sfall.h @@ -275,6 +275,10 @@ #define weapon_attack_mode2(pid) ((get_proto_data(pid, PROTO_FLAG_EXT) bwand 0x000000F0) / 0x10) #define weapon_attack_mode(pid, attackType) (weapon_attack_mode1(pid) if (attackType == ATKTYPE_LWEP1 or attackType == ATKTYPE_RWEP1) else weapon_attack_mode2(pid)) +#define get_tile_fid_ext(tile, elev, mode) get_tile_fid(((mode bwand 0xF) * 0x10000000) bwor ((elev bwand 0xF) * 0x1000000) bwor (tile bwand 0xFFFFFF)) +#define get_tile_ground_fid(tile, elev) get_tile_fid_ext(tile, elev, 0) +#define get_tile_roof_fid(tile, elev) get_tile_fid_ext(tile, elev, 1) + /* SFALL_FUNCX MACROS */ @@ -321,9 +325,6 @@ #define get_npc_stat_max(stat) sfall_func2("get_stat_max", stat, 1) #define get_npc_stat_min(stat) sfall_func2("get_stat_min", stat, 1) #define get_sfall_arg_at(argNum) sfall_func1("get_sfall_arg_at", argNum) -#define get_tile_fid_ext(tile, elev, mode) get_tile_fid(((mode bwand 0xF) * 0x10000000) bwor ((elev bwand 0xF) * 0x1000000) bwor (tile bwand 0xFFFFFF)) -#define get_tile_ground_fid(tile, elev) get_tile_fid_ext(tile, elev, 0) -#define get_tile_roof_fid(tile, elev) get_tile_fid_ext(tile, elev, 1) #define get_terrain_name(x, y) sfall_func2("get_terrain_name", x, y) #define get_text_width(text) sfall_func1("get_text_width", text) #define has_fake_perk_npc(npc, perk) sfall_func2("has_fake_perk_npc", npc, perk) diff --git a/artifacts/scripting/hooks.yml b/artifacts/scripting/hooks.yml index 984e9e1c..b8b9ddba 100644 --- a/artifacts/scripting/hooks.yml +++ b/artifacts/scripting/hooks.yml @@ -607,10 +607,12 @@ Does not run if the script of the object overrides the description. + __NOTE:__ Returning a pointer to the new text received from the `get_string_pointer` function is still valid, but the method is DEPRECATED and is left for backward compatibility only. + ``` Obj arg0 - the object - str ret0 - new description text to use + String ret0 - the new description text to use ``` - name: UseSkillOn @@ -809,7 +811,7 @@ Critter arg0 - the critter doing the check Item arg1 - the weapon being checked int arg2 - attack type (see ATKTYPE_* constants) - int arg3 - original result of engine function: 1 - can use, 0 - can't use + int arg3 - original result of engine function: 1 - can use, 0 - cannot use int ret0 - overrides the result of engine function. Any non-zero value allows using the weapon ``` diff --git a/artifacts/scripting/hookscripts.md b/artifacts/scripting/hookscripts.md index bf94c189..07c2eb64 100644 --- a/artifacts/scripting/hookscripts.md +++ b/artifacts/scripting/hookscripts.md @@ -691,10 +691,12 @@ An example usage would be to add an additional description to the item based on Does not run if the script of the object overrides the description. +__NOTE:__ Returning a pointer to the new text received from the `get_string_pointer` function is still valid, but the method is DEPRECATED and is left for backward compatibility only. + ``` Obj arg0 - the object -str ret0 - new description text to use +String ret0 - the new description text to use ``` ------------------------------------------- @@ -926,7 +928,7 @@ For the player, this happens when the game updates the item data for active item Critter arg0 - the critter doing the check Item arg1 - the item being checked int arg2 - attack type (see ATKTYPE_* constants), or -1 for dude_obj -int arg3 - original result of engine function: 1 - can use, 0 - can't use +int arg3 - original result of engine function: 1 - can use, 0 - cannot use int ret0 - overrides the result of engine function. Any non-zero value allows using the weapon ``` diff --git a/artifacts/scripting/sfall function notes.md b/artifacts/scripting/sfall function notes.md index ad9690bb..07b2d7d4 100644 --- a/artifacts/scripting/sfall function notes.md +++ b/artifacts/scripting/sfall function notes.md @@ -230,6 +230,20 @@ FUNCTION REFERENCE ##### `void set_critter_pickpocket_mod(object critter, int max, int mod)` - The same as above, but applies only to specific critter. +----- +##### `int get_tile_fid(int tileData)` +- Returns FID information about the square under the given tile at elevation 0. +- Pass elevation as 4-bit number in bits 25-28 to access other elevations. +- Pass result mode in bits 29-32: 0 - ground FID, 1 - roof FID, 2 - raw data. Following macros are available in **sfall.h**: + +----- +##### `int get_tile_ground_fid(int tileNum, int elevation)` +- Returns FID of a ground tile at given tile number and elevation. + +----- +##### `int get_tile_roof_fid(int tileNum, int elevation)` +- Returns FID of a roof tile at given tile number and elevation. Note that FID of 1 is used when there is no actual roof. + ----- ##### `void reg_anim_combat_check` - Allows enabling all `reg_anim_*` functions in combat (including vanilla functions) if set to 0. It is automatically reset at the end of each frame, so you need to call it before `reg_anim_begin() ... reg_anim_end()` code block. @@ -257,7 +271,7 @@ FUNCTION REFERENCE ----- ##### `void reg_anim_turn_towards(object, tile/target, delay)` -- Makes object change its direction to face given tile num or target object. +- Makes object change its direction to face given tile number or target object. ----- ##### `void reg_anim_callback(procedure proc)` @@ -706,8 +720,8 @@ sfall_funcX metarule functions ---- #### get_string_pointer `int sfall_func1("get_string_pointer", string text)` -- DEPRECATED, use normal strings -- Returns a pointer to a string variable or to a text +- (DEPRECATED) Returns a pointer to a string variable or to a text +- __NOTE:__ this function is intended for use only in `HOOK_DESCRIPTIONOBJ`. Starting from sfall 4.3.9/3.8.39, you can return normal strings directly in the hook without calling the function ---- #### dialog_message diff --git a/artifacts/scripting/sfall opcode list.md b/artifacts/scripting/sfall opcode list.md index a1c14a97..2a058807 100644 --- a/artifacts/scripting/sfall opcode list.md +++ b/artifacts/scripting/sfall opcode list.md @@ -310,7 +310,7 @@ _^ - These functions require AllowUnsafeScripting to be enabled in ddraw.ini_ 0x8251 - `int charcode(string string)`\ 0x8253 - `int typeof(any value)` -0x823a - `int get_tile_fid(int tile)` +0x823a - `int get_tile_fid(int tileData)` 0x823b - `int modified_ini()` diff --git a/artifacts/scripting/sfall opcode list.txt b/artifacts/scripting/sfall opcode list.txt index f0d6656a..11e93ce5 100644 --- a/artifacts/scripting/sfall opcode list.txt +++ b/artifacts/scripting/sfall opcode list.txt @@ -310,9 +310,9 @@ 0x8251 - int charcode(string string) 0x8253 - int typeof(any value) -0x823a - int get_tile_fid(int tile) +0x823a - int get_tile_fid(int tileData) -0x823b - int modified_ini +0x823b - int modified_ini() 0x823e - void force_aimed_shots(int pid) 0x823f - void disable_aimed_shots(int pid)