From 310a0df8f62654d7cd50d0be9e019356784aa9fb Mon Sep 17 00:00:00 2001 From: NovaRain Date: Sun, 5 Jan 2020 09:55:28 +0800 Subject: [PATCH] Fixed the timing of setting DIALOG game mode flag (also fixed the issue of DialogGenderWords mentioned in previous commit) Fixed AI disposition values in define_extra.h. Minor code edits to world map travel markers. --- artifacts/scripting/headers/define_extra.h | 13 +++++------ sfall/FalloutEngine/Enums.h | 26 ++++++++++++++++++++++ sfall/Modules/Interface.cpp | 16 ++++++------- sfall/Modules/LoadGameHook.cpp | 11 ++++++++- sfall/Modules/Message.cpp | 2 -- 5 files changed, 50 insertions(+), 18 deletions(-) diff --git a/artifacts/scripting/headers/define_extra.h b/artifacts/scripting/headers/define_extra.h index 88e5c9d5..8702c8e9 100644 --- a/artifacts/scripting/headers/define_extra.h +++ b/artifacts/scripting/headers/define_extra.h @@ -334,7 +334,6 @@ #define ai_area_be_absolutely_sure (4) // AI attack who mode values -#define ai_attack_no_pref (-1) #define ai_attack_whomever_attacking_me (0) #define ai_attack_strongest (1) #define ai_attack_weakest (2) @@ -351,12 +350,12 @@ #define ai_run_away_never (7) // AI disposition values -#define ai_disposition_none (0) -#define ai_disposition_custom (1) -#define ai_disposition_coward (2) -#define ai_disposition_defensive (3) -#define ai_disposition_aggressive (4) -#define ai_disposition_berserk (5) +#define ai_disposition_none (-1) +#define ai_disposition_custom (0) +#define ai_disposition_coward (1) +#define ai_disposition_defensive (2) +#define ai_disposition_aggressive (3) +#define ai_disposition_berserk (4) // AI distance values #define ai_distance_stay_close (0) diff --git a/sfall/FalloutEngine/Enums.h b/sfall/FalloutEngine/Enums.h index d2b2c630..a7a3d298 100644 --- a/sfall/FalloutEngine/Enums.h +++ b/sfall/FalloutEngine/Enums.h @@ -646,6 +646,30 @@ enum BodyType : long Robotic = 2 }; +enum KillType : long +{ + men_type = 0, + women_type = 1, + children_type = 2, + super_mutant_type = 3, + ghoul_type = 4, + brahmin_type = 5, + radscorpion_type = 6, + rat_type = 7, + floater_type = 8, + centaur_type = 9, + robot_type = 10, + dog_type = 11, + manti_type = 12, + deathclaw_type = 13, + plant_type = 14, + gecko_type = 15, + alien_type = 16, + giant_ant_type = 17, + big_boss_type = 18, + count +}; + #define PLAYER_ID (18000) #define OBJFLAG_CAN_WEAR_ITEMS (0xF000000) @@ -662,6 +686,8 @@ enum BodyType : long #define AUTOMAP_MAX (160) +#define MSG_GENDER_CHECK_FLG (0x80) // bit 8 + enum TicksTime : unsigned long { ONE_GAME_YEAR = 315360000 diff --git a/sfall/Modules/Interface.cpp b/sfall/Modules/Interface.cpp index 1e369b9a..ce416d82 100644 --- a/sfall/Modules/Interface.cpp +++ b/sfall/Modules/Interface.cpp @@ -478,13 +478,15 @@ static bool backImageIsCopy = false; struct DotPosition { long x; long y; + + DotPosition(long x, long y) : x(x), y(y) {} }; static std::vector dots; static long optionLenDot = 1; static long optionSpaceDot = 2; -static unsigned char colorDot = 0; // color index in palette: R = 252, G = 0, B = 0 +static unsigned char colorDot = 0; static long spaceLen = 2; static long dotLen = 1; static long dot_xpos = 0; @@ -500,13 +502,9 @@ static void AddNewDot() { return; } dotLen--; - - DotPosition dot; - dot.x = dot_xpos; - dot.y = dot_ypos; - dots.push_back(std::move(dot)); - spaceLen = optionSpaceDot; + + dots.emplace_back(dot_xpos, dot_ypos); } static void __declspec(naked) DrawingDots() { @@ -692,9 +690,10 @@ static void WorldMapInterfacePatch() { } if (GetConfigInt("Interface", "WorldTravelMarkers", 0)) { + dlog("Applying world map travel markers patch.", DL_INIT); optionLenDot = GetConfigInt("Interface", "TravelMarkerLength", optionLenDot); optionSpaceDot = GetConfigInt("Interface", "TravelMarkerSpaces", optionSpaceDot); - int color = GetConfigInt("Interface", "TravelMarkerColor", 133); + int color = GetConfigInt("Interface", "TravelMarkerColor", 133); // color index in palette: R = 252, G = 0, B = 0 if (color > 255) color = 255; else if (color < 1) color = 1; colorDot = color; @@ -705,6 +704,7 @@ static void WorldMapInterfacePatch() { LoadGameHook::OnGameReset() += []() { dots.clear(); }; + dlogr(" Done", DL_INIT); } // Fallout 1 features, travel markers and displaying terrain type HookCall(0x4C3C7E, wmInterfaceRefresh_hook); // when calling wmDrawCursorStopped_ diff --git a/sfall/Modules/LoadGameHook.cpp b/sfall/Modules/LoadGameHook.cpp index 51ed2c0d..37706529 100644 --- a/sfall/Modules/LoadGameHook.cpp +++ b/sfall/Modules/LoadGameHook.cpp @@ -521,6 +521,14 @@ end: } } +static void __declspec(naked) DialogHookStart() { + __asm { + _InLoop2(1, DIALOG); + mov ebx, 1; + retn; + } +} + static void __declspec(naked) DialogHook() { __asm { test inLoop, DIALOG; // check byte flag @@ -711,7 +719,8 @@ void LoadGameHook::init() { HookCalls(OptionsMenuHook, {0x48FCE4, 0x48FD17, 0x48FD4D, 0x48FD6A, 0x48FD87, 0x48FDB3}); HookCalls(HelpMenuHook, {0x443A50}); HookCalls(CharacterHook, {0x443320}); // 0x4A73EB, 0x4A740A for character creation - HookCalls(DialogHook, {0x445748}); + MakeCall(0x445285, DialogHookStart); // gdialogInitFromScript_ + HookCall(0x445748, DialogHook); HookCalls(PipboyHook, {0x443463, 0x443605}); HookCalls(SkilldexHook, {0x4434AC, 0x44C7BD}); HookCalls(HandleInventoryHook, {0x443357}); diff --git a/sfall/Modules/Message.cpp b/sfall/Modules/Message.cpp index 6be597c4..d529a401 100644 --- a/sfall/Modules/Message.cpp +++ b/sfall/Modules/Message.cpp @@ -60,8 +60,6 @@ static long msgNumCounter = 0x3000; static long heroIsFemale = -1; -#define MSG_GENDER_CHECK_FLG (0x8) - // Searches the special character in the text and removes the word depending on the player's gender // example: MaleWord^FemaleWord static long __fastcall ReplaceGenderWord(fo::MessageNode* msgData, DWORD* msgFile) {