From a7c66685b9302dc6bf7b52bb5d06a83c0950504f Mon Sep 17 00:00:00 2001 From: NovaRain Date: Sun, 12 Aug 2018 19:07:52 +0800 Subject: [PATCH] Added QuestsScrollButtonsX/Y, DisplaySwiftLearnerExp, and additional note for the new mode of UseScrollingQuestsList to ddraw.ini. Changed a log message in BugFixes.cpp to be a bit more specific. Edited some comments in QuestList.cpp. --- artifacts/ddraw.ini | 11 +++++++- sfall/FalloutEngine/FunctionOffsets_def.h | 4 +-- sfall/FalloutEngine/Functions.h | 3 ++- sfall/FalloutEngine/VariableOffsets.h | 6 ++--- sfall/FalloutEngine/Variables_def.h | 6 ++--- sfall/Modules/BugFixes.cpp | 31 ++++++++++++----------- sfall/Modules/QuestList.cpp | 20 +++++++-------- 7 files changed, 46 insertions(+), 35 deletions(-) diff --git a/artifacts/ddraw.ini b/artifacts/ddraw.ini index 9bbafa22..a25d482e 100644 --- a/artifacts/ddraw.ini +++ b/artifacts/ddraw.ini @@ -369,9 +369,15 @@ Repair=293 ;Remove window position rounding RemoveWindowRounding=0 -;Set to 1 to add scroll buttons to the pip boy quest list, and remove the quests per area limit +;Set to 1 to add scroll buttons to the pipboy quest list, and remove the quests per area limit +;Set to 2 to use a different set of scroll buttons UseScrollingQuestsList=1 +;To change the location of quest list scroll buttons, uncomment the next two lines +;Defaults are 140 in the x direction and 334 in the y direction +;QuestsScrollButtonsX=140 +;QuestsScrollButtonsY=334 + ;Uncomment these lines to control the premade characters offered when starting a new game ;Multiple options should be separated by commas, and there must be the same number of entries in both lines ;PremadePaths=combat,diplomat,stealth @@ -581,6 +587,9 @@ KeepWeaponSelectMode=1 ;Set to 1 to display full item description for weapon/ammo in barter screen FullItemDescInBarter=0 +;Set to 1 to display experience points with the bonus from Swift Learner perk when gained from non-scripted situations +DisplaySwiftLearnerExp=1 + ;Set to 1 to display sfall built-in credits at the bottom of credits.txt contents instead of at the top CreditsAtBottom=0 diff --git a/sfall/FalloutEngine/FunctionOffsets_def.h b/sfall/FalloutEngine/FunctionOffsets_def.h index 705ea7c4..037ecd93 100644 --- a/sfall/FalloutEngine/FunctionOffsets_def.h +++ b/sfall/FalloutEngine/FunctionOffsets_def.h @@ -1562,6 +1562,8 @@ FUNC(gsound_internal_effect_callback_, 0x451AD0) FUNC(gsound_internal_speech_callback_, 0x451A90) FUNC(gsound_load_sound_, 0x4510DC) FUNC(gsound_load_sound_volume_, 0x45145C) +FUNC(gsound_med_butt_press_, 0x451988) +FUNC(gsound_med_butt_release_, 0x451990) FUNC(gsound_open_, 0x451A08) FUNC(gsound_play_sfx_file_, 0x4519A8) FUNC(gsound_play_sfx_file_volume_, 0x45108C) @@ -1569,8 +1571,6 @@ FUNC(gsound_play_sound_, 0x451510) FUNC(gsound_read_, 0x451A30) FUNC(gsound_red_butt_press_, 0x451970) FUNC(gsound_red_butt_release_, 0x451978) -FUNC(gsound_med_butt_release_, 0x451990) -FUNC(gsound_med_butt_press_, 0x451988) FUNC(gsound_reset_, 0x450164) FUNC(gsound_seek_, 0x451A4C) FUNC(gsound_set_master_volume_, 0x4502EC) diff --git a/sfall/FalloutEngine/Functions.h b/sfall/FalloutEngine/Functions.h index 30c76443..f3f3e941 100644 --- a/sfall/FalloutEngine/Functions.h +++ b/sfall/FalloutEngine/Functions.h @@ -33,10 +33,11 @@ namespace func Add functions here if they have non-trivial wrapper implementation (like vararg functions or too many arguments, etc.) Otherwise use Functions_def.h file (much easier). */ -long __fastcall _word_wrap(const char* text, int maxWidth, DWORD* buf, BYTE* count); bool __stdcall art_exists(long artFid); +long __fastcall _word_wrap(const char* text, int maxWidth, DWORD* buf, BYTE* count); + // Returns the name of the critter const char* __stdcall critter_name(GameObject* critter); diff --git a/sfall/FalloutEngine/VariableOffsets.h b/sfall/FalloutEngine/VariableOffsets.h index cc6006f1..2a41d1a2 100644 --- a/sfall/FalloutEngine/VariableOffsets.h +++ b/sfall/FalloutEngine/VariableOffsets.h @@ -127,11 +127,11 @@ #define FO_VAR_objectTable 0x639DA0 #define FO_VAR_objItemOutlineState 0x519798 #define FO_VAR_optionRect 0x58ECC0 -#define FO_VAR_optionsButtonDown1 0x570518 -#define FO_VAR_optionsButtonUp1 0x570514 #define FO_VAR_optionsButtonDown 0x59D400 -#define FO_VAR_optionsButtonUp 0x59D3FC +#define FO_VAR_optionsButtonDown1 0x570518 #define FO_VAR_optionsButtonDownKey 0x518F2C +#define FO_VAR_optionsButtonUp 0x59D3FC +#define FO_VAR_optionsButtonUp1 0x570514 #define FO_VAR_optionsButtonUpKey 0x518F28 #define FO_VAR_outlined_object 0x518D94 #define FO_VAR_partyMemberAIOptions 0x519DB8 diff --git a/sfall/FalloutEngine/Variables_def.h b/sfall/FalloutEngine/Variables_def.h index da5ef1df..395cdc89 100644 --- a/sfall/FalloutEngine/Variables_def.h +++ b/sfall/FalloutEngine/Variables_def.h @@ -120,11 +120,11 @@ VAR_(obj_dude, GameObject*) VAR_(objectTable, DWORD) VAR_(objItemOutlineState, DWORD) VAR_(optionRect, DWORD) -VAR_(optionsButtonDown1, DWORD) -VAR_(optionsButtonUp1, DWORD) VAR_(optionsButtonDown, DWORD) -VAR_(optionsButtonUp, DWORD) +VAR_(optionsButtonDown1, DWORD) VAR_(optionsButtonDownKey, DWORD) +VAR_(optionsButtonUp, DWORD) +VAR_(optionsButtonUp1, DWORD) VAR_(optionsButtonUpKey, DWORD) VAR_(outlined_object, GameObject*) VAR_(partyMemberAIOptions, DWORD) diff --git a/sfall/Modules/BugFixes.cpp b/sfall/Modules/BugFixes.cpp index c8eeb8af..d69b8985 100644 --- a/sfall/Modules/BugFixes.cpp +++ b/sfall/Modules/BugFixes.cpp @@ -57,6 +57,7 @@ static void __declspec(naked) PipStatus_hook() { retn; } } + // corrects saving script blocks (to *.sav file) by properly accounting for actual number of scripts to be saved static void __declspec(naked) scr_write_ScriptNode_hook() { __asm { @@ -631,7 +632,7 @@ static void __declspec(naked) action_melee_hack() { cmp ebx, OBJ_TYPE_CRITTER // check if object FID type flag is set to critter jne end // if object not a critter leave jump condition flags // set to skip dodge animation - test byte ptr [eax + damageFlags], DAM_KNOCKED_OUT or DAM_KNOCKED_DOWN // (original code) + test byte ptr [eax + damageFlags], DAM_KNOCKED_OUT or DAM_KNOCKED_DOWN // (original code) jnz end mov edx, 0x4113FE end: @@ -1252,7 +1253,7 @@ static void __declspec(naked) loot_container_exp_hack() { mov edx, [esp + 0x150 - 0x18]; // experience xchg edx, eax; call fo::funcoffs::stat_pc_add_experience_; - // engine code + // engine code cmp edx, 1; // from eax jnz skip; push expSwiftLearner; @@ -1277,7 +1278,7 @@ static void __declspec(naked) wmRndEncounterOccurred_hook() { cmp ecx, 110; jnb skip; push expSwiftLearner; - // engine code + // engine code push edx; lea eax, [esp + 0x08 + 4]; push eax; @@ -1291,6 +1292,7 @@ skip: } } + void BugFixes::init() { #ifndef NDEBUG @@ -1310,14 +1312,14 @@ void BugFixes::init() //} // Fixes for clickability issue in Pip-Boy and exploit that allows to rest in places where you shouldn't be able to rest - dlog("Applying fix for Pip-Boy rest exploit.", DL_INIT); + dlog("Applying fix for Pip-Boy clickability issues and rest exploit.", DL_INIT); MakeCall(0x4971C7, pipboy_hack); MakeCall(0x499530, PipAlarm_hack); - dlogr(" Done", DL_INIT); - // Fixes of clickability holodisk + // Fix for clickability issue of holodisk list HookCall(0x497E9F, PipStatus_hook); SafeWrite16(0x497E8C, 0xD389); // mov ebx, edx - SafeMemSet(0x497E8E, 0x90, 4); + SafeWrite32(0x497E8E, 0x90909090); + dlogr(" Done", DL_INIT); // Fix for "Too Many Items" bug //if (GetConfigInt("Misc", "TooManyItemsBugFix", 1)) { @@ -1613,12 +1615,12 @@ void BugFixes::init() // Fix for critters killed in combat by scripting still being able to move in their combat turn if the distance parameter // in their AI packages is set to stay_close/charge, or NPCsTryToSpendExtraAP is enabled HookCall(0x42A1A8, ai_move_steps_closer_hook); // 0x42B24D - + // Fix instant death critical dlog("Applying instant death fix.", DL_INIT); MakeJump(0x424BA2, compute_damage_hack); dlogr(" Done", DL_INIT); - + // Fix missing AC/DR mod stats when examining ammo in barter screen dlog("Applying fix for displaying ammo stats in barter screen.", DL_INIT); MakeCalls(obj_examine_func_hack_ammo0, {0x49B4AD, 0x49B504}); @@ -1636,17 +1638,16 @@ void BugFixes::init() dlogr(" Done", DL_INIT); } - // In derivation of number of experience points obtained, consider perk 'SwiftLearner' (Crafty) - if (GetConfigInt("Misc", "ExperienceSwiftLearnerFix", 1) != 0) { - dlog("Applying fix displayed experience points of Swift Learner perk.", DL_INIT); - HookCall(0x4221E2, combat_give_exps_hook); - HookCall(0x4C0AEB, wmRndEncounterOccurred_hook); + // Display experience points with the bonus from Swift Learner perk when gained from non-scripted situations + if (GetConfigInt("Misc", "DisplaySwiftLearnerExp", 1) != 0) { + dlog("Applying Swift Learner exp display patch.", DL_INIT); MakeCall(0x4AFAEF, statPCAddExperienceCheckPMs_hack); + HookCall(0x4221E2, combat_give_exps_hook); MakeJump(0x4745AE, loot_container_exp_hack); SafeWrite16(0x4C0AB1, 0x23EB); // jmps 0x4C0AD6 + HookCall(0x4C0AEB, wmRndEncounterOccurred_hook); dlogr(" Done", DL_INIT); } - } } diff --git a/sfall/Modules/QuestList.cpp b/sfall/Modules/QuestList.cpp index 8195c3ba..2c1aa74d 100644 --- a/sfall/Modules/QuestList.cpp +++ b/sfall/Modules/QuestList.cpp @@ -45,14 +45,14 @@ static bool calledflag = false; static DWORD called_quest_number = 0; static DWORD total_quests_pages = 0; static DWORD curent_quest_page = 0; -static DWORD look_quests = 0; // current check quest +static DWORD look_quests = 0; // check current quests static DWORD first_quest_page = 0; static DWORD last_quest_page = MAXINT; static std::vector pageQuest; -// Fixes a crash when the quest list is overfull +// Fix crash when the quest list is too long static void __declspec(naked) PipStatus_hook_printfix() { __asm { test outRangeFlag, 0xFF; @@ -67,7 +67,7 @@ static void __declspec(naked) PipStatus_hook_printfix() { jb skip; mov eax, dword ptr ds:[FO_VAR_quest_count]; sub eax, 2; - mov dword ptr [esp + 0x4BC - 0x24 + 8], eax; //set last counter + mov dword ptr [esp + 0x4BC - 0x24 + 8], eax; // set last counter mov outRangeFlag, 1; skip: pop eax; @@ -81,7 +81,7 @@ force: // ------------------------------------ // Add an unused bit for an additional text offset 60 pixels to the right -// maybe it might be needed outside the function to display the pages of the quest list +// it might be needed outside of the function to display quest list pages static void __declspec(naked) pip_print_hack() { __asm { test bh, 1; @@ -109,10 +109,10 @@ static void ResetPageValues() { last_quest_page = MAXINT; } -// Event of entering the list of quests and keystrokes up/down +// Event of entering the quest list and up/down keystrokes static void __declspec(naked) pipboy_hack_press0() { __asm { - // fixed vanilla bug, preventing display the listing of quests from other locations when clicking on the pipboy screen + // fixed vanilla bug, preventing displaying the quest list of other locations when clicking on the pipboy screen test InQuestsList, 0xFF; jz skip; test buttonsPressed, 0xFF; @@ -150,7 +150,7 @@ skip: } } -// Press back button +// Press back button static void __declspec(naked) pipboy_hack_back() { __asm { mov InQuestsList, 0; @@ -173,7 +173,7 @@ skip: static void AddPage(int lines) { total_quests_pages++; - pageQuest.push_back(look_quests); // add to array the quest number at top of page + pageQuest.push_back(look_quests); // add the quest number to array at top of page fo::var::cursor_line = 3 + lines; // reset current line to beginning, and add text lines outRangeFlag = true; } @@ -445,7 +445,7 @@ static void __declspec(naked) StartPipboy_hack() { } } -// Resets states on close pipboy +// Reset states when closing pipboy static void __declspec(naked) pipboy_hook() { __asm { call fo::funcoffs::EndPipboy_; @@ -497,7 +497,7 @@ void QuestList::init() { dlogr(" Done", DL_INIT); } else { - HookCall(0x498186, PipStatus_hook_printfix); //fix 'out-of-range' bug when printing a list of quests + HookCall(0x498186, PipStatus_hook_printfix); // fix "out of range" bug when printing a list of quests } }