From f68aaf98b651711eae21e5a7872fd1835d0a431d Mon Sep 17 00:00:00 2001 From: NovaRain Date: Tue, 7 Jan 2025 11:55:22 +0800 Subject: [PATCH] Added setting about Comprehension perk to perks.ini --- artifacts/config_files/Perks.ini | 4 ++++ sfall/Modules/SubModules/EnginePerks.cpp | 19 +++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/artifacts/config_files/Perks.ini b/artifacts/config_files/Perks.ini index 555760247..ec82ba145 100644 --- a/artifacts/config_files/Perks.ini +++ b/artifacts/config_files/Perks.ini @@ -68,6 +68,10 @@ VaultCityInoculationsRadBonus=10 ;valid range: -12..20, 3 - default bonus CautiousNatureBonus=3 +;Changes the percentage bonus for 'Comprehension' perk (ID 81) +;50 - default bonus +ComprehensionBonus=50 + ;Changes the damage bonus per level for 'Demolition Expert' perk (ID 82) ;999 - maximum bonus, 10 - default bonus DemolitionExpertBonus=10 diff --git a/sfall/Modules/SubModules/EnginePerks.cpp b/sfall/Modules/SubModules/EnginePerks.cpp index f384b14f9..f4b243f4e 100644 --- a/sfall/Modules/SubModules/EnginePerks.cpp +++ b/sfall/Modules/SubModules/EnginePerks.cpp @@ -30,6 +30,7 @@ namespace perk static long SalesmanBonus = 20; static long DemolitionExpertBonus = 10; static long NightVisionBonus = 13107; // 20% of max light +static long ComprehensionBonus = 150; // +50% of earned skill points static bool TryGetModifiedInt(const char* key, int defaultValue, int& outValue, const char* perksFile) { outValue = IniReader::GetInt("PerksTweak", key, defaultValue, perksFile); @@ -85,12 +86,23 @@ static __declspec(naked) void light_set_ambient_hack_night_vision() { } } +static __declspec(naked) void obj_use_book_hack_comprehension() { + __asm { + imul esi, [ComprehensionBonus]; + mov edx, esi; + pop ebx; + add ebx, 11; // skip code (to 0x49BADD) + jmp ebx; + } +} + void EnginePerkBonusInit() { - // Allows the current perk level to affect the calculation of its bonus value + // Allow 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); - // Allows customizable light level bonus + // Allow configurable bonuses MakeCall(0x47A91D, light_set_ambient_hack_night_vision); + MakeCall(0x49BACD, obj_use_book_hack_comprehension); } void ReadPerksBonuses(const char* perksFile) { @@ -120,6 +132,9 @@ void ReadPerksBonuses(const char* perksFile) { TryPatchSkillBonus8("PyromaniacBonus", 5, 0x424AB6, perksFile); TryPatchValue8("StonewallPercent", 50, 0, 100, 0x424B50, perksFile); TryPatchValue8("CautiousNatureBonus", 3, -12, 20, 0x4C1756, perksFile); // -12 - force distance to 0 + if (TryGetModifiedInt("ComprehensionBonus", 50, value, perksFile) && value >= 0) { + ComprehensionBonus = value + 100; + } if (TryGetModifiedInt("DemolitionExpertBonus", DemolitionExpertBonus, value, perksFile) && value >= 0) { DemolitionExpertBonus = min(value, 999); }