diff --git a/artifacts/example_mods/UIHotkeys/gl_uihotkeys.int b/artifacts/example_mods/UIHotkeys/gl_uihotkeys.int index f00771f4..492d08a2 100644 Binary files a/artifacts/example_mods/UIHotkeys/gl_uihotkeys.int 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 index 60336c17..8600570f 100644 --- a/artifacts/example_mods/UIHotkeys/gl_uihotkeys.ssl +++ b/artifacts/example_mods/UIHotkeys/gl_uihotkeys.ssl @@ -44,7 +44,7 @@ procedure start begin tap_key(DIK_CAPITAL); tap_key(DIK_A); tap_key(DIK_CAPITAL); - end else if (mode == (BARTER + DIALOG)) then begin + end else if (mode bwand BARTER) then begin tap_key(DIK_M); end end diff --git a/artifacts/scripting/hookscripts.txt b/artifacts/scripting/hookscripts.txt index f838ed17..43ca985a 100644 --- a/artifacts/scripting/hookscripts.txt +++ b/artifacts/scripting/hookscripts.txt @@ -47,7 +47,7 @@ Used from a normal global script if you want to run it at the same point a full 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" by default). 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!). > void register_hook_proc_spec(int hook, procedure proc) -Works very similar to register_hook_proc, except that it registers the current script at the end of the hook script execution chain (i.e. the script will be executed after all previously registered scripts for the same hook, including the hs_*.int script.) All scripts hooked to a single hook point with this function are executed in exact order of how they were registered, as opposed to the description below, which refers to using register_hook/register_hook_proc functions. +Works very similar to register_hook_proc, except that it registers the current script at the end of the hook script execution chain (i.e. the script will be executed after all previously registered scripts for the same hook, including the hs_*.int script). All scripts hooked to a single hook point with this function are executed in exact order of how they were registered, as opposed to the description below, which refers to using register_hook/register_hook_proc functions. 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. Example: let's say we have a Mod A which reduces all "to hit" chances by 50%. The code might look like this: diff --git a/sfall/BugFixes.cpp b/sfall/BugFixes.cpp index 4b1691bf..c2415ec6 100644 --- a/sfall/BugFixes.cpp +++ b/sfall/BugFixes.cpp @@ -2875,4 +2875,7 @@ void BugFixesInit() // Place the player on a nearby empty tile if the entrance tile is blocked by another object when entering a map HookCall(0x4836F8, map_check_state_hook); + + // Remove duplicate code from intface_redraw_ engine function + BlockCall(0x45EBBF); } diff --git a/sfall/dinput.cpp b/sfall/dinput.cpp index 60b460cd..d98bf881 100644 --- a/sfall/dinput.cpp +++ b/sfall/dinput.cpp @@ -249,26 +249,26 @@ public: return 0; } - // Only called for the keyboard - HRESULT _stdcall GetDeviceData(DWORD a, DIDEVICEOBJECTDATA* b, DWORD* c, DWORD d) { + // Only called for the keyboard (dxinput_read_keyboard_buffer_ called at 0x4E06AB) + HRESULT _stdcall GetDeviceData(DWORD a, DIDEVICEOBJECTDATA* buf, DWORD* count, DWORD d) { // buf - DirectInputKeyboardBuffer (0x6B2560) if (DeviceType != kDeviceType_KEYBOARD) { - return RealDevice->GetDeviceData(a, b, c, d); + return RealDevice->GetDeviceData(a, buf, count, d); } RunGlobalScripts2(); - if (!b || bufferedPresses.empty() || (d & DIGDD_PEEK)) { - HRESULT hr = RealDevice->GetDeviceData(a, b, c, d); - if (FAILED(hr) || !b || !(*c)) return hr; + if (!buf || bufferedPresses.empty() || (d & DIGDD_PEEK)) { + HRESULT hr = RealDevice->GetDeviceData(a, buf, count, d); + if (FAILED(hr) || !buf || !(*count)) return hr; DWORD keyOverride, oldState; - for (DWORD i = 0; i < *c; i++) { - oldState = KeysDown[b[i].dwOfs]; - KeysDown[b[i].dwOfs] = b[i].dwData & 0x80; - keyOverride = KeyPressHook(b[i].dwOfs, (b[i].dwData & 0x80) > 0, MapVirtualKeyEx(b[i].dwOfs, MAPVK_VSC_TO_VK, keyboardLayout)); + for (DWORD i = 0; i < *count; i++) { + oldState = KeysDown[buf[i].dwOfs]; + KeysDown[buf[i].dwOfs] = buf[i].dwData & 0x80; + keyOverride = KeyPressHook(buf[i].dwOfs, (buf[i].dwData & 0x80) > 0, MapVirtualKeyEx(buf[i].dwOfs, MAPVK_VSC_TO_VK, keyboardLayout)); if (keyOverride != 0) { - KeysDown[b[i].dwOfs] = oldState; - b[i].dwOfs = keyOverride; - KeysDown[b[i].dwOfs] = b[i].dwData & 0x80; + KeysDown[buf[i].dwOfs] = oldState; + buf[i].dwOfs = keyOverride; + KeysDown[buf[i].dwOfs] = buf[i].dwData & 0x80; } } if (KeysDown[DebugEditorKey]) RunDebugEditor(); @@ -278,9 +278,9 @@ public: //TODO: Fallouts behaviour when passing multiple keypresses makes it appear like it's expecting the DIDEVICEOBJECTDATA struct to be // something other than 16 bytes. afaik, fallout uses DX3 for input, which is before the appData field was added, but it could // be worth checking anyway. - *b = bufferedPresses.front(); + *buf = bufferedPresses.front(); bufferedPresses.pop(); - *c = 1; + *count = 1; return DI_OK; }