From f5c7d3ccc638d0b99d7b33a12a7c6e66548768ee Mon Sep 17 00:00:00 2001 From: NovaRain Date: Sun, 5 Jan 2025 21:03:12 +0800 Subject: [PATCH] Added setting about Night Vision perk to perks.ini Updated version number. --- artifacts/config_files/Perks.ini | 7 ++++++- sfall/Modules/SubModules/EnginePerks.cpp | 16 ++++++++++++++++ sfall/version.h | 4 ++-- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/artifacts/config_files/Perks.ini b/artifacts/config_files/Perks.ini index 9cf3ca1eb..555760247 100644 --- a/artifacts/config_files/Perks.ini +++ b/artifacts/config_files/Perks.ini @@ -7,6 +7,10 @@ ; be used to remove their hardcoded effects, and add new stat/skill effects [PerksTweak] +;Changes the light level bonus for 'Night Vision' perk (ID 9) +;valid range: 0..100, 20 - default bonus +NightVisionBonus=20 + ;Changes the Outdoorsman skill bonus for 'Survivalist' perk (ID 16) ;125 - maximum bonus, 25 - default bonus SurvivalistBonus=25 @@ -77,8 +81,9 @@ GamblerBonus=20 HarmlessBonus=20 ;Changes the damage bonus and the Doctor skill bonus for 'Living Anatomy' perk (ID 97) -;125 - maximum bonus, 5 - default bonus, 10 - default skill bonus +;125 - maximum bonus, 5 - default damage bonus LivingAnatomyBonus=5 +;125 - maximum bonus, 10 - default skill bonus LivingAnatomyDoctorBonus=10 ;Changes the Speech and Barter skill bonus for 'Negotiator' perk (ID 99) diff --git a/sfall/Modules/SubModules/EnginePerks.cpp b/sfall/Modules/SubModules/EnginePerks.cpp index b3b943a3d..f384b14f9 100644 --- a/sfall/Modules/SubModules/EnginePerks.cpp +++ b/sfall/Modules/SubModules/EnginePerks.cpp @@ -29,6 +29,7 @@ namespace perk static long SalesmanBonus = 20; static long DemolitionExpertBonus = 10; +static long NightVisionBonus = 13107; // 20% of max light static bool TryGetModifiedInt(const char* key, int defaultValue, int& outValue, const char* perksFile) { outValue = IniReader::GetInt("PerksTweak", key, defaultValue, perksFile); @@ -75,10 +76,21 @@ static __declspec(naked) void queue_explode_exit_hack_demolition_expert() { } } +static __declspec(naked) void light_set_ambient_hack_night_vision() { + __asm { + imul eax, [NightVisionBonus]; + pop edx; + add edx, 16; // skip code (to 0x47A932) + jmp edx; + } +} + 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); + // Allows customizable light level bonus + MakeCall(0x47A91D, light_set_ambient_hack_night_vision); } void ReadPerksBonuses(const char* perksFile) { @@ -96,6 +108,10 @@ void ReadPerksBonuses(const char* perksFile) { float floatValue = static_cast(value); SafeWrite32(0x474BB3, *(DWORD*)&floatValue); // write float data } + if (TryGetModifiedInt("NightVisionBonus", 20, value, perksFile) && value >= 0) { + if (value > 100) value = 100; + NightVisionBonus = (65536 * value) / 100; + } if (TryGetModifiedInt("SalesmanBonus", SalesmanBonus, value, perksFile) && value >= 0) { SalesmanBonus = min(value, 999); } diff --git a/sfall/version.h b/sfall/version.h index 93fddabff..3c54324ad 100644 --- a/sfall/version.h +++ b/sfall/version.h @@ -25,6 +25,6 @@ #define VERSION_MAJOR 4 #define VERSION_MINOR 4 #define VERSION_BUILD 5 -#define VERSION_REV 1 +#define VERSION_REV 2 -#define VERSION_STRING "4.4.5.1" +#define VERSION_STRING "4.4.5.2"