diff --git a/artifacts/example_mods/StealCheat/readme.txt b/artifacts/example_mods/StealCheat/readme.txt index f11409e0..e1ee2499 100644 --- a/artifacts/example_mods/StealCheat/readme.txt +++ b/artifacts/example_mods/StealCheat/readme.txt @@ -1,5 +1,5 @@ -Master Theif cheat for fallout 2 by phobos2077 ----------------------------------------- +Master Thief cheat for fallout 2 by phobos2077 +---------------------------------------------- - forces all steal attempts to succeed diff --git a/artifacts/example_mods/TakeAllHotkey/gl_takeallkey.int b/artifacts/example_mods/TakeAllHotkey/gl_takeallkey.int deleted file mode 100644 index 6e585781..00000000 Binary files a/artifacts/example_mods/TakeAllHotkey/gl_takeallkey.int and /dev/null differ diff --git a/artifacts/example_mods/TakeAllHotkey/gl_takeallkey.ssl b/artifacts/example_mods/TakeAllHotkey/gl_takeallkey.ssl deleted file mode 100644 index 657ce5c0..00000000 --- a/artifacts/example_mods/TakeAllHotkey/gl_takeallkey.ssl +++ /dev/null @@ -1,20 +0,0 @@ -procedure start; -// adjust include paths if needed -#include "..\..\scripting_docs\headers\sfall.h" -#include "..\..\scripting_docs\headers\dik.h" - -procedure start begin - if game_loaded then begin - register_hook(HOOK_KEYPRESS); - end else begin - variable - event := get_sfall_arg, - keyDX := get_sfall_arg; - - if (event == 1) and (keyDX == DIK_SEMICOLON) then begin - tap_key(DIK_CAPITAL); - tap_key(DIK_A); - tap_key(DIK_CAPITAL); - end - end -end diff --git a/artifacts/example_mods/TakeAllHotkey/readme.txt b/artifacts/example_mods/TakeAllHotkey/readme.txt deleted file mode 100644 index dedd0668..00000000 --- a/artifacts/example_mods/TakeAllHotkey/readme.txt +++ /dev/null @@ -1,9 +0,0 @@ -"Take All" Hotkey mod for Fallout 2 by NovaRain ----------------------------------------- - -- makes pressing the semicolon key send an uppercase A after a semicolon. -- Note: the uppercase A (shift + A if Caps Lock is off) is the built-in hotkey for the TAKE ALL button on the loot screen. - -To use, copy *.int file to your scripts folder. - -This mod is a simple example of how you can use HOOK_KEYPRESS hooks. diff --git a/artifacts/example_mods/UIHotkeys/gl_uihotkeys.int b/artifacts/example_mods/UIHotkeys/gl_uihotkeys.int new file mode 100644 index 00000000..4fab3d8a Binary files /dev/null and b/artifacts/example_mods/UIHotkeys/gl_uihotkeys.int differ diff --git a/artifacts/example_mods/UIHotkeys/gl_uihotkeys.ssl b/artifacts/example_mods/UIHotkeys/gl_uihotkeys.ssl new file mode 100644 index 00000000..0288b17b --- /dev/null +++ b/artifacts/example_mods/UIHotkeys/gl_uihotkeys.ssl @@ -0,0 +1,52 @@ +/* + +UI Hotkeys mod for Fallout 2 by NovaRain +---------------------------------------- + +- closes some game interfaces by pressing their hotkeys again: + * 'I' key for Inventory + * 'S' key for Skilldex + * 'Z' key for Pip-Boy + +- extends the functionality of the 'Space' key (Caps Lock must be off): + * takes all items in the loot screen + * makes the offer in the barter screen + +Requires sfall 3.5 or higher + +*/ + +#include "..\headers\sfall\sfall.h" +#include "..\headers\sfall\dik.h" + +procedure start; + +procedure start begin + if game_loaded then begin + register_hook(HOOK_KEYPRESS); + end else begin + variable + event := get_sfall_arg, + keyDX := get_sfall_arg, + mode; + + if (event) then begin + mode := get_game_mode; + if (keyDX == DIK_I and (mode bwand INVENTORY)) then begin + tap_key(DIK_ESCAPE); + end else if (keyDX == DIK_S and (mode bwand SKILLDEX)) then begin + tap_key(DIK_ESCAPE); + end else if (keyDX == DIK_Z and (mode bwand PIPBOY)) then begin + tap_key(DIK_ESCAPE); + end else if (keyDX == DIK_SPACE) then begin + if (mode bwand INTFACELOOT) then begin + tap_key(DIK_CAPITAL); + tap_key(DIK_A); + tap_key(DIK_CAPITAL); + end else if (mode bwand BARTER) then begin + tap_key(DIK_M); + end + end + end + end +end diff --git a/artifacts/example_mods/UIHotkeys/readme.txt b/artifacts/example_mods/UIHotkeys/readme.txt new file mode 100644 index 00000000..d530f482 --- /dev/null +++ b/artifacts/example_mods/UIHotkeys/readme.txt @@ -0,0 +1,22 @@ +UI Hotkeys mod for Fallout 2 by NovaRain +---------------------------------------- + +- closes some game interfaces by pressing their hotkeys again: + * 'I' key for Inventory + * 'S' key for Skilldex + * 'Z' key for Pip-Boy + +- extends the functionality of the 'Space' key (Caps Lock must be off): + * takes all items in the loot screen + * makes the offer in the barter screen + +- Note: + * the uppercase 'A' (shift + A if Caps Lock is off) is the built-in hotkey for the TAKE ALL button on the loot screen + * the lowercase 'm' is the built-in hotkey for the OFFER button on the barter screen + + +Requires sfall 3.5 or higher + +To use, copy gl_uihotkeys.int to your scripts folder. + +This mod is a simple example of how you can use HOOK_KEYPRESS hooks. diff --git a/artifacts/scripting/hookscripts.txt b/artifacts/scripting/hookscripts.txt index f11eeb6c..f4b1a9ba 100644 --- a/artifacts/scripting/hookscripts.txt +++ b/artifacts/scripting/hookscripts.txt @@ -47,7 +47,7 @@ Changes argument value. The argument number (argnum) is 0-indexed. This is usefu > void register_hook(int hooktype) Used from a normal global script if you want to run it at the same point a full hook script would normally run. In case of this function, "start" proc will be executed in a current global script. You can use all above functions like normal. -> void register_hook_proc(int hooktype, proc procedure) +> void register_hook_proc(int hook, procedure proc) The same as register_hook, except that you specifically define which procedure in the current script should be called as a hook (instead of "start"). Pass procedure the same as how you use dialog option functions. This IS the recommended way to use hook scripts, as it gives both modularity (each mod logic in a separate global script, no conflicts if you don't use "hs_*.int" scripts) and flexibility (you can place all related hook scripts for specific mod in a single script!). NOTE: you can hook several scripts to a single hook point, for example if it's different mods from different authors or just some different aspects of one larger mod. In this case scripts are executed in reverse order of how they were registered. When one of the scripts in a chain returns value with "set_sfall_return", the next script may override this value if calls "set_sfall_return" again. Sometimes you need to multiply certain value in a chain of hook scripts. diff --git a/sfall/HookScripts.h b/sfall/HookScripts.h index 7dfb5943..0f8177a2 100644 --- a/sfall/HookScripts.h +++ b/sfall/HookScripts.h @@ -54,6 +54,7 @@ DWORD _stdcall GetHSArg(); DWORD* _stdcall GetHSArgs(); void _stdcall SetHSArg(DWORD id, DWORD value); void _stdcall SetHSReturn(DWORD d); + // register hook by proc num (special values: -1 - use default (start) procedure, 0 - unregister) void _stdcall RegisterHook(DWORD script, DWORD id, DWORD procNum); diff --git a/sfall/ScriptExtender.cpp b/sfall/ScriptExtender.cpp index cd3ec2a9..51c74418 100644 --- a/sfall/ScriptExtender.cpp +++ b/sfall/ScriptExtender.cpp @@ -359,6 +359,9 @@ private: static OpcodeHandler opHandler; +static void OpcodeInvalidArgs(const char* opcodeName) { + opHandler.printOpcodeError("%s() - invalid arguments.", opcodeName); +} #include "ScriptOps\AsmMacros.h" @@ -495,7 +498,6 @@ TScript OverrideScriptStruct = {0}; //mov the value type to edx, mov the script pointer to eax, call interpretPushShort_ - static void __fastcall SetGlobalScriptRepeat2(DWORD script, DWORD frames) { for (DWORD d = 0; d < globalScripts.size(); d++) { if (globalScripts[d].prog.ptr == script) { diff --git a/sfall/ScriptExtender.h b/sfall/ScriptExtender.h index 97087368..2f349a0d 100644 --- a/sfall/ScriptExtender.h +++ b/sfall/ScriptExtender.h @@ -92,8 +92,6 @@ sScriptProgram* GetGlobalScriptProgram(DWORD scriptPtr); char* _stdcall mysubstr(char* str, int pos, int length); -void OpcodeInvalidArgs(const char* opcodeName); - // variables static char reg_anim_combat_check = 1; extern DWORD isGlobalScriptLoading; diff --git a/sfall/ScriptOps/FileSystemOps.hpp b/sfall/ScriptOps/FileSystemOps.hpp index d05530c7..54f0a4c9 100644 --- a/sfall/ScriptOps/FileSystemOps.hpp +++ b/sfall/ScriptOps/FileSystemOps.hpp @@ -22,10 +22,6 @@ #include "FileSystem.h" #include "ScriptExtender.h" -void OpcodeInvalidArgs(const char* opcodeName) { - opHandler.printOpcodeError("%s() - invalid arguments.", opcodeName); -} - //file system functions static void fs_create2() { const ScriptValue &pathArg = opHandler.arg(0), diff --git a/sfall/main.cpp b/sfall/main.cpp index 5d36ab71..ac481549 100644 --- a/sfall/main.cpp +++ b/sfall/main.cpp @@ -140,7 +140,7 @@ end: } } -// Remove master_patches from the load order +// Remove master_patches from the chain of paths static void __declspec(naked) game_init_databases_hack1() { __asm { call RemoveDatabase; @@ -149,7 +149,7 @@ static void __declspec(naked) game_init_databases_hack1() { } } -// Remove critter_patches from the load order +// Remove critter_patches from the chain of paths static void __declspec(naked) game_init_databases_hack2() { __asm { cmp eax, -1; @@ -168,7 +168,7 @@ end: } static void __declspec(naked) game_init_databases_hook() { -// eax = _master_db_handle + // eax = _master_db_handle __asm { mov ecx, ds:[_critter_db_handle]; mov edx, ds:[_paths];