Skip to content

Commit

Permalink
Added setting about Night Vision perk to perks.ini
Browse files Browse the repository at this point in the history
Updated version number.
  • Loading branch information
NovaRain committed Jan 5, 2025
1 parent 4255614 commit f5c7d3c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
7 changes: 6 additions & 1 deletion artifacts/config_files/Perks.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
16 changes: 16 additions & 0 deletions sfall/Modules/SubModules/EnginePerks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand All @@ -96,6 +108,10 @@ void ReadPerksBonuses(const char* perksFile) {
float floatValue = static_cast<float>(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);
}
Expand Down
4 changes: 2 additions & 2 deletions sfall/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit f5c7d3c

Please sign in to comment.