From 41c8722179a6840f73e0bdcfaf2efbba8d322131 Mon Sep 17 00:00:00 2001 From: NovaRain Date: Mon, 16 Jul 2018 09:14:01 +0800 Subject: [PATCH] Merged a couple of fixes and minor improvements for 4.0.x from the develop branch: * Fixed the game thinking you dropped an active explosive when the dropping is prevented with hs_inventorymove. * Added "inventory_redraw" script function (from Mr.Stalin) * NPC combat control mod now centers the screen on the controlled critter and has new options to display critter's name. * Removed obsoleted WIN2K preprocessor defines. Updated version number. --- artifacts/config_files/sfall-mods.ini | 14 ++++++++ artifacts/ddraw.ini | 2 +- artifacts/mods/gl_partycontrol.int | Bin 1760 -> 2346 bytes artifacts/mods/gl_partycontrol.ssl | 30 ++++++++++++++-- artifacts/scripting/headers/sfall.h | 1 + artifacts/scripting/hookscripts.txt | 2 +- artifacts/scripting/sfall function notes.txt | 4 +++ sfall/FalloutEngine/Functions_def.h | 2 ++ sfall/FalloutEngine/VariableOffsets.h | 1 + sfall/FalloutEngine/Variables_def.h | 1 + sfall/Modules/Graphics.cpp | 4 --- sfall/Modules/HookScripts/InventoryHs.cpp | 32 +++++++++++++++--- .../Modules/Scripting/Handlers/Interface.cpp | 27 +++++++++++++++ sfall/Modules/Scripting/Handlers/Interface.h | 2 ++ sfall/Modules/Scripting/Handlers/Metarule.cpp | 1 + sfall/version.h | 8 ++--- 16 files changed, 111 insertions(+), 20 deletions(-) diff --git a/artifacts/config_files/sfall-mods.ini b/artifacts/config_files/sfall-mods.ini index 90e051a4b..c478a1bf4 100644 --- a/artifacts/config_files/sfall-mods.ini +++ b/artifacts/config_files/sfall-mods.ini @@ -38,3 +38,17 @@ MotionScanner=0 ;If you want to control only specific critters, uncomment the PIDList line and set a comma delimited list of PIDs Mode=0 ;PIDList=62,89,97,107,160,161 + +;Displays the name of the controlled critter in a notification box above the interface bar. Must be between 5 and 9 +;Set to 0 to disable +DisplayName=0 + +;Set the color of display name, available colors: +;0 - green +;1 - red +;2 - white +;3 - yellow +;4 - dark yellow +;5 - blue +;6 - purple +DisplayNameColor=0 diff --git a/artifacts/ddraw.ini b/artifacts/ddraw.ini index b30c358af..6cb05f5c1 100644 --- a/artifacts/ddraw.ini +++ b/artifacts/ddraw.ini @@ -1,5 +1,5 @@ ;sfall configuration settings -;v4.0.6 +;v4.0.7 [Main] ;Change to 1 if you want to use command line args to tell sfall to use another ini file. diff --git a/artifacts/mods/gl_partycontrol.int b/artifacts/mods/gl_partycontrol.int index 6f4dc8a0fa7b38278950c35a6e2b6fe54a85efa4..59a4e14d3365814d18b22e568a58320a84678e2a 100644 GIT binary patch literal 2346 zcmbVNO>f*}5Pto!-VNGBtEGp~Rw6)(S_qqFlTz9Pij>lJ1+9?U8$ye->!fZsc4WJS zlpu{Q4jei00}w|fazLmj+5^7;

f&NFc$DiUWt1d1vO`wWCz3aP)r6%;WiZX1oFW zfu)pc!?Zr_U%`bI9ECYtFW`C+*Gn)DC*Wm7)p2>aN{=%uf;mMby@SGh35-|g3*2m6 zD^VxD{W! z6-H4QVQ_V15O1yfS#~>#`ZxS&I12PzvzzE}3xf?%w;7ZyUYhwyrXJ&?ly#CAv^&_1 zEB^LLeA7F1e(qyD-ScyLU!Wb!N3K6Xt4MCncz|Pbk$& zH&Fc=W|4NnDAed(TnkwL?lo;f38RJ)T3Xi=KT1b_7RFK9yV}FLI*VnUc$itEYR8Ps zB!NHb4{r~He!PAYdyxiNNmNI)9B%l7pr84h{Ve!Mcf;d0sOE(V`z6V+-*~rofjXu6 zf(4pz^)x#;8dbjxF1*V4&-K^w0qqH#V;ywiTt#DPP5w1m9az$*vnx{ffkjy?!y;*H zKn?m79G+d6hUefFI0a2OPUrFe5&ci`PSM@@Ni2zeOl#Z*%)(o+2uF>b>hQp1CoC1q z<(w+mJH?r@t(q?($%lKFe^Hc@dXXdcBi?Fqa=yQjgj|TWTP(p@IBleZRwEaS#o3}` zBswkWlJM((1}^E5_ovBQ2?IH2q+m&I*7#;~hZRYW&5Nnh$vO0CwR5M$)i55h{r!l9+lv&u|I8{_(N9nw|V-!>%vi&`u;<42j4*? zN&CiDe8}_RT_jBn+A_PQhg@}!@wv@tWs&T{v-7~L)4 zuSPM)^*0J%KTblYth73%m z(AcLAc#+(uxbtR~l|ePWujD+>v1oUM4U4nI@3CF1XiMWCvMabxXAk~1^Gk9~@RX%; Oi*?dI&o+?`>F|FJkPlP< delta 552 zcmZ1_^nh2Of$0Dv0|SFl122eX@|q|hTh9g*0AVD+ln3QVAPEAQU~y(3Lj_Iz4M-A* zO;E*|=Rn0vP{mn7p!_Zd1~FtQ)=f}e&%|5Nlam>>CNF2?Wn%a+c^l&amEzQr_>|I= z)cE|QETA&JqSVA3Bmp+x{FKzmmzcCB^D(nAv2L0y#_YtzbZK%FbBz>p71-ZQ4MqnT z{{umTaf38SggI{V2j&bW<_nXfSacb!CU>wzFfreo{D>usiM3<0AFDVc+vGG>c_7)w zYRG6ec?YYkv0Z~igKL9+gA~|E<_4oi?*{z|pkO@$7GZ2KYAT1wvNk}hovgy9CdN9e zfd!%rOkQa!11Xzqz%IwbcA_x_;vm*5lcU&;1lXh+c)_Z+fXOG5=ddd= 4) then begin set_perk_ranks(PERK_gecko_skinning_perk, 1); set_perk_level(PERK_gecko_skinning_perk, 999); // prevent it from appearing in the perk selection window controlMode := GetConfig("CombatControl", "Mode", 0); + displayName := GetConfig("CombatControl", "DisplayName", 0); + displayNameColor := GetConfig("CombatControl", "DisplayNameColor", 0); if (controlMode > 2) then controlMode := 0; + if (displayName < 5 or displayName > 9) then displayName := 0; if (controlMode > 0) then begin pidList := GetConfigListInt("CombatControl", "PIDList"); fix_array(pidList); if has_trait(TRAIT_PERK, dude_obj, PERK_gecko_skinning_perk) then hasGeckoSkinning := true; register_hook_proc(HOOK_COMBATTURN, combatturn_handler); + register_hook_proc(HOOK_GAMEMODECHANGE, gamemodechange_handler); end end end diff --git a/artifacts/scripting/headers/sfall.h b/artifacts/scripting/headers/sfall.h index 7a50d7dc7..87912b91f 100644 --- a/artifacts/scripting/headers/sfall.h +++ b/artifacts/scripting/headers/sfall.h @@ -234,6 +234,7 @@ #define intface_is_hidden sfall_func0("intface_is_hidden") #define intface_redraw sfall_func0("intface_redraw") #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 outlined_object sfall_func0("outlined_object") diff --git a/artifacts/scripting/hookscripts.txt b/artifacts/scripting/hookscripts.txt index 44d6033e2..7bc0817bc 100644 --- a/artifacts/scripting/hookscripts.txt +++ b/artifacts/scripting/hookscripts.txt @@ -497,7 +497,7 @@ int arg2 - event type: 1 - when the resting ends normally, -1 - when pressin int arg3 - the hour part of the length of resting time int arg4 - the minute part of the length of resting time -int ret1 - pass 1 to interrupt the resting +int ret1 - pass 1 to interrupt the resting, pass 0 to continue the rest if it was interrupted by pressing ESC key ------------------------------------------- diff --git a/artifacts/scripting/sfall function notes.txt b/artifacts/scripting/sfall function notes.txt index 739fe8ed2..e9f554b83 100644 --- a/artifacts/scripting/sfall function notes.txt +++ b/artifacts/scripting/sfall function notes.txt @@ -486,6 +486,10 @@ Some utility/math functions are available: - The text is limited to 19 characters - available colors: 0 - green, 1 - red, 2 - white, 3 - yellow, 4 - dark yellow, 5 - blue, 6 - purple +> void sfall_func1("inventory_redraw", int invSide) +- redraws inventory list in the inventory/use inventory item on/loot/barter screens +- invSide specifies which side needs to be redrawn: 0 - the player, 1 - target (container/NPC in loot/barter screens) + ------------------------ ------ MORE INFO ------- ------------------------ diff --git a/sfall/FalloutEngine/Functions_def.h b/sfall/FalloutEngine/Functions_def.h index 0f96d09a2..7abe9ea70 100644 --- a/sfall/FalloutEngine/Functions_def.h +++ b/sfall/FalloutEngine/Functions_def.h @@ -31,6 +31,8 @@ WRAP_WATCOM_FUNC3(long, db_freadIntCount, DbFile*, file, DWORD*, dest, long, cou WRAP_WATCOM_FUNC2(long, db_fwriteByte, DbFile*, file, long, value) WRAP_WATCOM_FUNC2(long, db_fwriteInt, DbFile*, file, long, value) WRAP_WATCOM_FUNC0(void, display_stats) +WRAP_WATCOM_FUNC3(void, display_inventory, long, inventoryOffset, long, visibleOffset, long, mode) +WRAP_WATCOM_FUNC4(void, display_target_inventory, long, inventoryOffset, long, visibleOffset, DWORD*, targetInventory, long, mode) // perform combat turn for a given critter WRAP_WATCOM_FUNC2(long, combat_turn, GameObject*, critter, long, isDudeTurn) WRAP_WATCOM_FUNC1(long, critter_is_dead, GameObject*, critter) diff --git a/sfall/FalloutEngine/VariableOffsets.h b/sfall/FalloutEngine/VariableOffsets.h index b88fb3853..f74244ab8 100644 --- a/sfall/FalloutEngine/VariableOffsets.h +++ b/sfall/FalloutEngine/VariableOffsets.h @@ -40,6 +40,7 @@ #define FO_VAR_dialogue_switch_mode 0x518718 #define FO_VAR_dialog_target 0x518848 #define FO_VAR_dialog_target_is_party 0x51884C +#define FO_VAR_dropped_explosive 0x5190E0 #define FO_VAR_drugInfoList 0x5191CC #define FO_VAR_edit_win 0x57060C #define FO_VAR_Educated 0x57082C diff --git a/sfall/FalloutEngine/Variables_def.h b/sfall/FalloutEngine/Variables_def.h index 4fd1585d7..a152fee0e 100644 --- a/sfall/FalloutEngine/Variables_def.h +++ b/sfall/FalloutEngine/Variables_def.h @@ -37,6 +37,7 @@ VAR_(dialogue_state, DWORD) VAR_(dialogue_switch_mode, DWORD) VAR_(dialog_target, DWORD) VAR_(dialog_target_is_party, DWORD) +VAR_(dropped_explosive, DWORD) VAR_(drugInfoList, DWORD) VAR_(edit_win, DWORD) VAR_(Educated, DWORD) diff --git a/sfall/Modules/Graphics.cpp b/sfall/Modules/Graphics.cpp index a7ec1232b..f63d834bd 100644 --- a/sfall/Modules/Graphics.cpp +++ b/sfall/Modules/Graphics.cpp @@ -983,11 +983,7 @@ void Graphics::init() { } if (Graphics::mode == 4 || Graphics::mode == 5) { dlog("Applying dx9 graphics patch.", DL_INIT); -#ifdef WIN2K -#define _DLL_NAME "d3dx9_42.dll" -#else #define _DLL_NAME "d3dx9_43.dll" -#endif HMODULE h = LoadLibraryEx(_DLL_NAME, 0, LOAD_LIBRARY_AS_DATAFILE); if (!h) { MessageBoxA(0, "You have selected graphics mode 4 or 5, but " _DLL_NAME " is missing\nSwitch back to mode 0, or install an up to date version of DirectX", "Error", 0); diff --git a/sfall/Modules/HookScripts/InventoryHs.cpp b/sfall/Modules/HookScripts/InventoryHs.cpp index a920deff2..02acd7c06 100644 --- a/sfall/Modules/HookScripts/InventoryHs.cpp +++ b/sfall/Modules/HookScripts/InventoryHs.cpp @@ -53,7 +53,7 @@ static void __declspec(naked) MoveCostHook() { __asm { popad; cmp cRet, 1; - cmovge eax, rets[0]; + cmovge eax, dword ptr rets[0]; retn; } } @@ -165,10 +165,11 @@ static void _declspec(naked) MoveInventoryHook() { // - if 0 is returned while dropping caps, selected amount - 1 will still disappear from inventory (fixed) static DWORD nextHookDropSkip = 0; static int dropResult = -1; +static const DWORD InvenActionObjDropRet = 0x473874; static void __declspec(naked) InvenActionCursorObjDropHook() { if (nextHookDropSkip) { nextHookDropSkip = 0; - dropResult = -1; + goto skipHook; } else { __asm { pushad; @@ -183,6 +184,7 @@ static void __declspec(naked) InvenActionCursorObjDropHook() { } if (dropResult == -1) { +skipHook: _asm call fo::funcoffs::obj_drop_; } _asm retn; @@ -192,10 +194,28 @@ static void __declspec(naked) InvenActionCursorObjDropHook() { if (dropResult == -1) { nextHookDropSkip = 1; _asm call fo::funcoffs::item_remove_mult_; - } else { - _asm mov dword ptr [esp], 0x473874; // no caps drop + _asm retn; + } + _asm add esp, 4; + _asm jmp InvenActionObjDropRet; // no caps drop +} + +static void __declspec(naked) InvenActionExplosiveDropHack() { + __asm { + pushad; + xor ecx, ecx; // no itemReplace + push 6; // event: item drop ground + call InventoryMoveHook_Script; // edx - item + cmp eax, -1; // ret value + popad; + jnz noDrop; + mov dword ptr ds:[FO_VAR_dropped_explosive], ebp; // overwritten engine code (ebp = 1) + mov nextHookDropSkip, ebp; + retn; +noDrop: + add esp, 4; + jmp InvenActionObjDropRet; // no drop } - _asm retn; } static int __fastcall DropIntoContainer(DWORD ptrCont, DWORD item, DWORD addrCall) { @@ -373,6 +393,8 @@ void InitInventoryHookScripts() { 0x473851, 0x47386F, 0x47379A // caps multi drop }); + MakeCall(0x473807, InvenActionExplosiveDropHack); // drop active explosives + SafeWrite8(0x47380C, 0x90); LoadHookScript("hs_invenwield", HOOK_INVENWIELD); HookCalls(InvenWieldFuncHook, { 0x47275E, 0x495FDF }); diff --git a/sfall/Modules/Scripting/Handlers/Interface.cpp b/sfall/Modules/Scripting/Handlers/Interface.cpp index 3d503959a..203b40b72 100644 --- a/sfall/Modules/Scripting/Handlers/Interface.cpp +++ b/sfall/Modules/Scripting/Handlers/Interface.cpp @@ -460,5 +460,32 @@ void sf_set_iface_tag_text(OpcodeContext& ctx) { } } +void sf_inventory_redraw(OpcodeContext& ctx) { + int mode = -1; + DWORD loopFlag = GetLoopFlags(); + if (loopFlag & INVENTORY) { + mode = 0; + } else if (loopFlag & INTFACEUSE) { + mode = 1; + } else if (loopFlag & INTFACELOOT) { + mode = 2; + } else if (loopFlag & BARTER) { + mode = 3; + } else { + return; + } + + if (!ctx.arg(0).asBool()) { + int* stack_offset = (int*)FO_VAR_stack_offset; + stack_offset[fo::var::curr_stack * 4] = 0; + fo::func::display_inventory(0, -1, mode); + } else if (mode >= 2) { + int* target_stack_offset = (int*)FO_VAR_target_stack_offset; + target_stack_offset[fo::var::target_curr_stack * 4] = 0; + fo::func::display_target_inventory(0, -1, (DWORD*)fo::var::target_pud, mode); + fo::func::win_draw(fo::var::i_wid); + } +} + } } diff --git a/sfall/Modules/Scripting/Handlers/Interface.h b/sfall/Modules/Scripting/Handlers/Interface.h index 01afe81c2..099b78804 100644 --- a/sfall/Modules/Scripting/Handlers/Interface.h +++ b/sfall/Modules/Scripting/Handlers/Interface.h @@ -91,5 +91,7 @@ void sf_display_stats(OpcodeContext&); void sf_set_iface_tag_text(OpcodeContext&); +void sf_inventory_redraw(OpcodeContext&); + } } diff --git a/sfall/Modules/Scripting/Handlers/Metarule.cpp b/sfall/Modules/Scripting/Handlers/Metarule.cpp index 2414268dc..d149ee9de 100644 --- a/sfall/Modules/Scripting/Handlers/Metarule.cpp +++ b/sfall/Modules/Scripting/Handlers/Metarule.cpp @@ -94,6 +94,7 @@ static const SfallMetarule metarules[] = { {"intface_is_hidden", sf_intface_is_hidden, 0, 0}, {"intface_redraw", sf_intface_redraw, 0, 0}, {"intface_show", sf_intface_show, 0, 0}, + {"inventory_redraw", sf_inventory_redraw, 1, 1, {ARG_INT}}, {"item_weight", sf_item_weight, 1, 1, {ARG_OBJECT}}, {"lock_is_jammed", sf_lock_is_jammed, 1, 1, {ARG_OBJECT}}, {"outlined_object", sf_outlined_object, 0, 0}, diff --git a/sfall/version.h b/sfall/version.h index 04bf710e2..5b0be16ed 100644 --- a/sfall/version.h +++ b/sfall/version.h @@ -24,14 +24,10 @@ #define VERSION_MAJOR 4 #define VERSION_MINOR 0 -#define VERSION_BUILD 6 +#define VERSION_BUILD 7 #define VERSION_REV 0 -#ifdef WIN2K -#define VERSION_STRING "4.0.6 win2k" -#else -#define VERSION_STRING "4.0.6" -#endif +#define VERSION_STRING "4.0.7" #define CHECK_VAL (4)