Skip to content

Commit

Permalink
Added setting about Comprehension perk to perks.ini
Browse files Browse the repository at this point in the history
  • Loading branch information
NovaRain committed Jan 7, 2025
1 parent ca90166 commit f68aaf9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 4 additions & 0 deletions artifacts/config_files/Perks.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 17 additions & 2 deletions sfall/Modules/SubModules/EnginePerks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit f68aaf9

Please sign in to comment.