From f0ec82923ddc2b81ba3e9938273c372c1441f6a8 Mon Sep 17 00:00:00 2001 From: phobos2077 Date: Sun, 30 Jul 2023 22:00:04 +0200 Subject: [PATCH] EnginePerks: fixes - Remove duplicate Salesman tweak - Decoupled hacks for multi-perk-level support for Salesman and Demolition Expert from the bonus value change - Renamed settings for consistency ("Bonus" when it has only one effect) --- artifacts/config_files/Perks.ini | 26 +++++++---------- sfall/Modules/SubModules/EnginePerks.cpp | 37 ++++++++++++------------ 2 files changed, 29 insertions(+), 34 deletions(-) diff --git a/artifacts/config_files/Perks.ini b/artifacts/config_files/Perks.ini index 1176265c..b8c8fec7 100644 --- a/artifacts/config_files/Perks.ini +++ b/artifacts/config_files/Perks.ini @@ -65,41 +65,37 @@ MedicDoctorBonus=10 VaultCityTrainingFirstAidBonus=5 VaultCityTrainingDoctorBonus=5 -;Changes the Sneak skill bonus for 'Ghost' perk (ID 38) +;Changes the Sneak skill bonus (when in darkness) for 'Ghost' perk (ID 38) ;125 - maximum bonus, 20 - default bonus -GhostSneakBonus=20 +GhostBonus=20 ;Changes the Lockpick, Steal and Traps skill bonus for 'Thief' perk (ID 105) ;125 - maximum bonus, 10 - default bonus -ThiefSkillsBonus=10 +ThiefBonus=10 ;Changes the Lockpick and Steal skill bonus for 'Master Thief' perk (ID 3) ;125 - maximum bonus, 15 - default bonus -MasterThiefSkillsBonus=15 +MasterThiefBonus=15 ;Changes the Steal skill bonus for 'Harmless' perk (ID 91) ;125 - maximum bonus, 20 - default bonus -HarmlessStealBonus=20 +HarmlessBonus=20 ;Changes the Speech skill bonus for 'Speaker' perk (ID 34) ;125 - maximum bonus, 20 - default bonus -SpeakerSpeechBonus=20 +SpeakerBonus=20 ;Changes the Speech skill bonus for 'Expert Excrement Expeditor' perk (ID 116) ;125 - maximum bonus, 5 - default bonus -ExpertExcrementExpeditorSpeechBonus=5 +ExpertExcrementExpeditorBonus=5 ;Changes the Speech and Barter skill bonus for 'Negotiator' perk (ID 99) ;125 - maximum bonus, 10 - default bonus -NegotiatorSkillsBonus=10 - -;Changes the Barter skill bonus for 'Salesman' perk (ID 103) -;125 - maximum bonus, 20 - default bonus -SalesmanBarterBonus=20 +NegotiatorBonus=10 ;Changes the Gambling skill bonus for 'Gambler' perk (ID 83) ;125 - maximum bonus, 20 - default bonus -GamblerGamblingBonus=20 +GamblerBonus=20 ;Changes the Outdoorsman skill bonus for 'Ranger' perk (ID 47) ;125 - maximum bonus, 15 - default bonus @@ -107,11 +103,11 @@ RangerOutdoorsmanBonus=15 ;Changes the Outdoorsman skill bonus for 'Survivalist' perk (ID 16) ;125 - maximum bonus, 25 - default bonus -SurvivalistOutdoorsmanBonus=25 +SurvivalistBonus=25 ;Changes the Science and Repair skill bonus for 'Mr.Fixit' perk (ID 31) ;125 - maximum bonus, 10 - default bonus -MrFixitSkillsBonus=10 +MrFixitBonus=10 ;############################################################################## [Perks] diff --git a/sfall/Modules/SubModules/EnginePerks.cpp b/sfall/Modules/SubModules/EnginePerks.cpp index a90f8976..9fbacf36 100644 --- a/sfall/Modules/SubModules/EnginePerks.cpp +++ b/sfall/Modules/SubModules/EnginePerks.cpp @@ -27,8 +27,8 @@ namespace sfall namespace perk { -static long SalesmanBonus; -static long DemolitionExpertBonus; +static long SalesmanBonus = 20; +static long DemolitionExpertBonus = 10; static bool TryGetModifiedInt(const char* key, int defaultValue, int& outValue, const char* perksFile) { outValue = IniReader::GetInt("PerksTweak", key, defaultValue, perksFile); @@ -76,8 +76,11 @@ static void __declspec(naked) queue_explode_exit_hack_demolition_expert() { } void EnginePerkBonusInit() { - + // Allows the current perk level to affect the calculation of its bonus value + MakeCall(0x496F5E, perk_adjust_skill_hack_salesman); + MakeCall(0x4A289C, queue_explode_exit_hack_demolition_expert, 1); } + void ReadPerksBonuses(const char* perksFile) { int value; TryPatchValue32("WeaponScopeRangePenalty", 8, 0, 100, 0x42448E, perksFile); @@ -93,18 +96,15 @@ void ReadPerksBonuses(const char* perksFile) { float floatValue = static_cast(value); SafeWrite32(0x474BB3, *(DWORD*)&floatValue); // write float data } - if (TryGetModifiedInt("SalesmanBonus", 20, value, perksFile) && value >= 0) { + if (TryGetModifiedInt("SalesmanBonus", SalesmanBonus, value, perksFile) && value >= 0) { SalesmanBonus = min(value, 999); - // Allows the current perk level to affect the calculation of its bonus value - MakeCall(0x496F5E, perk_adjust_skill_hack_salesman); } TryPatchSkillBonus8("LivingAnatomyBonus", 5, 0x424A91, perksFile); TryPatchSkillBonus8("LivingAnatomyDoctorBonus", 10, 0x496E66, perksFile); TryPatchSkillBonus8("PyromaniacBonus", 5, 0x424AB6, perksFile); TryPatchValue8("StonewallPercent", 50, 0, 100, 0x424B50, perksFile); - if (TryGetModifiedInt("DemolitionExpertBonus", 10, value, perksFile) && value >= 0) { + if (TryGetModifiedInt("DemolitionExpertBonus", DemolitionExpertBonus, value, perksFile) && value >= 0) { DemolitionExpertBonus = min(value, 999); - MakeCall(0x4A289C, queue_explode_exit_hack_demolition_expert, 1); } if (TryGetModifiedInt("VaultCityInoculationsPoisonBonus", 10, value, perksFile)) { SafeWrite8(0x4AF26A, static_cast(clamp(value, -100, 100))); @@ -117,18 +117,17 @@ void ReadPerksBonuses(const char* perksFile) { TryPatchSkillBonus32("MedicFirstAidBonus", 10, 0x496E19, perksFile); TryPatchSkillBonus32("MedicDoctorBonus", 10, 0x496E4E, perksFile); - TryPatchSkillBonus32("GhostSneakBonus", 20, 0x496EA9, perksFile); - TryPatchSkillBonus8("ThiefSkillsBonus", 10, 0x496EC1, perksFile); - TryPatchSkillBonus8("MasterThiefSkillsBonus", 15, 0x496EE0, perksFile); - TryPatchSkillBonus8("HarmlessStealBonus", 20, 0x496F02, perksFile); - TryPatchSkillBonus32("SpeakerSpeechBonus", 20, 0x496F1B, perksFile); - TryPatchSkillBonus8("ExpertExcrementExpeditorSpeechBonus", 5, 0x496F33, perksFile); - TryPatchSkillBonus8("NegotiatorSkillsBonus", 10, 0x496F48, perksFile); - TryPatchSkillBonus8("SalesmanBarterBonus", 20, 0x496F60, perksFile); - TryPatchSkillBonus32("GamblerGamblingBonus", 20, 0x496F79, perksFile); + TryPatchSkillBonus32("GhostBonus", 20, 0x496EA9, perksFile); + TryPatchSkillBonus8("ThiefBonus", 10, 0x496EC1, perksFile); + TryPatchSkillBonus8("MasterThiefBonus", 15, 0x496EE0, perksFile); + TryPatchSkillBonus8("HarmlessBonus", 20, 0x496F02, perksFile); + TryPatchSkillBonus32("SpeakerBonus", 20, 0x496F1B, perksFile); + TryPatchSkillBonus8("ExpertExcrementExpeditorBonus", 5, 0x496F33, perksFile); + TryPatchSkillBonus8("NegotiatorBonus", 10, 0x496F48, perksFile); + TryPatchSkillBonus32("GamblerBonus", 20, 0x496F79, perksFile); TryPatchSkillBonus32("RangerOutdoorsmanBonus", 15, 0x496F95, perksFile); - TryPatchSkillBonus8("SurvivalistOutdoorsmanBonus", 25, 0x496FAB, perksFile); - TryPatchSkillBonus8("MrFixitSkillsBonus", 10, 0x496E00, perksFile); + TryPatchSkillBonus8("SurvivalistBonus", 25, 0x496FAB, perksFile); + TryPatchSkillBonus8("MrFixitBonus", 10, 0x496E00, perksFile); } }