Skip to content

Commit

Permalink
blacklist: difficulty tweaks
Browse files Browse the repository at this point in the history
- more support for file overloads
  • Loading branch information
ThirteenAG committed Jul 26, 2024
1 parent f0359b8 commit 47f5df7
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/docs/scb.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

![](https://habrastorage.org/webt/d_/eg/ym/d_egymd6w_tem2erocab-e9ikna.png) Added an option to enable [Logitech G LIGHTSYNC RGB Lighting](https://www.logitechg.com/innovation/lightsync-rgb.html)

![](https://habrastorage.org/webt/d_/eg/ym/d_egymd6w_tem2erocab-e9ikna.png) Difficulty tweaks: **Mark and Execute** enabled on **Perfectionist**, unlimited ammo disabled on **Rookie**. To go back to original behavior, delete `update/difficultyconfiguration.ini`
![](https://habrastorage.org/webt/d_/eg/ym/d_egymd6w_tem2erocab-e9ikna.png) Difficulty tweaks: **Mark and Execute**, sonar(with decreased range) and drop crates enabled on **Perfectionist**, unlimited ammo disabled on **Rookie**. To go back to original behavior, delete `update/difficultyconfiguration.ini`

![](https://habrastorage.org/webt/d_/eg/ym/d_egymd6w_tem2erocab-e9ikna.png) Added an option to be able to run during forced walking sections

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ PlayerDamageSettings[3]=(m_fHeadDamageMultiplier = 20.0f, m_fTorsoDamageMultipli
PlayerWeaponSettings[0]=(m_bUnlimitedPistolMagazines = false, m_fInitialPrimaryAmmoCountMultiplier = 3.0f, m_fInitialSecondaryAmmoCountMultiplier = 3.0f, m_fAfterAIDroppedPrimaryAmmoCountMultiplier = 1.5f, m_fAfterAIDroppedSecondaryAmmoCountMultiplier = 1.5f, m_bDropCrateUseAllowed = true);
PlayerWeaponSettings[1]=(m_bUnlimitedPistolMagazines = false, m_fInitialPrimaryAmmoCountMultiplier = 2.0f, m_fInitialSecondaryAmmoCountMultiplier = 2.0f, m_fAfterAIDroppedPrimaryAmmoCountMultiplier = 1.0f, m_fAfterAIDroppedSecondaryAmmoCountMultiplier = 0.67f, m_bDropCrateUseAllowed = true);
PlayerWeaponSettings[2]=(m_bUnlimitedPistolMagazines = false, m_fInitialPrimaryAmmoCountMultiplier = 1.0f, m_fInitialSecondaryAmmoCountMultiplier = 1.0f, m_fAfterAIDroppedPrimaryAmmoCountMultiplier = 0.67f, m_fAfterAIDroppedSecondaryAmmoCountMultiplier = 0.5f, m_bDropCrateUseAllowed = true);
PlayerWeaponSettings[3]=(m_bUnlimitedPistolMagazines = false, m_fInitialPrimaryAmmoCountMultiplier = 1.0f, m_fInitialSecondaryAmmoCountMultiplier = 1.0f, m_fAfterAIDroppedPrimaryAmmoCountMultiplier = 0.5f, m_fAfterAIDroppedSecondaryAmmoCountMultiplier = 0.25f, m_bDropCrateUseAllowed = false);
PlayerWeaponSettings[3]=(m_bUnlimitedPistolMagazines = false, m_fInitialPrimaryAmmoCountMultiplier = 1.0f, m_fInitialSecondaryAmmoCountMultiplier = 1.0f, m_fAfterAIDroppedPrimaryAmmoCountMultiplier = 0.5f, m_fAfterAIDroppedSecondaryAmmoCountMultiplier = 0.25f, m_bDropCrateUseAllowed = true);

//-------------------------------------------------------------------------------------------------
// Player gadget settings
//-------------------------------------------------------------------------------------------------
PlayerGadgetSettings[0]=(m_bSonarPulseEnabled = true, m_fTechNPCArchetypeVisionModeDisruptionRange=1000.0f);
PlayerGadgetSettings[1]=(m_bSonarPulseEnabled = true, m_fTechNPCArchetypeVisionModeDisruptionRange=5000.0f);
PlayerGadgetSettings[2]=(m_bSonarPulseEnabled = true, m_fTechNPCArchetypeVisionModeDisruptionRange=10000.0f);
PlayerGadgetSettings[3]=(m_bSonarPulseEnabled = false, m_fTechNPCArchetypeVisionModeDisruptionRange=15000.0f);
PlayerGadgetSettings[3]=(m_bSonarPulseEnabled = true, m_fTechNPCArchetypeVisionModeDisruptionRange=15000.0f);

//-------------------------------------------------------------------------------------------------
// AI detection settings
Expand Down Expand Up @@ -87,7 +87,7 @@ PlayerStealthCombatSettings[3]=(m_fCombatDetectionThresholdTime=3.4f, m_fCombatD
PlayerWeaponStashSettings[0]=(m_bDisableWeaponStashUse=false);
PlayerWeaponStashSettings[1]=(m_bDisableWeaponStashUse=false);
PlayerWeaponStashSettings[2]=(m_bDisableWeaponStashUse=false);
PlayerWeaponStashSettings[3]=(m_bDisableWeaponStashUse=true);
PlayerWeaponStashSettings[3]=(m_bDisableWeaponStashUse=false);

//-------------------------------------------------------------------------------------------------
// Player inventory limit settings
Expand Down
112 changes: 99 additions & 13 deletions source/SplinterCellBlacklist.FusionMod/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,53 @@ namespace FFileManagerArc
}
}

namespace FFileManagerLinear
{
bool bLoadFromDisk = false;
SafetyHookInline shLookup1{};
void* __fastcall Lookup1(void* pFFileManagerLinear, void* edx, const char* path, int a3)
{
if (GetOverloadedFilePathA(path, nullptr/*s.data()*/, 0/*s.size()*/))
bLoadFromDisk = true;
return shLookup1.fastcall<void*>(pFFileManagerLinear, edx, path, a3);
}

SafetyHookInline shLookup2{};
void* __fastcall Lookup2(void* pFFileManagerLinear, void* edx, const char* path, int a3)
{
if (GetOverloadedFilePathA(path, nullptr/*s.data()*/, 0/*s.size()*/))
bLoadFromDisk = true;
return shLookup2.fastcall<void*>(pFFileManagerLinear, edx, path, a3);
}

SafetyHookInline shLookup3{};
void* __fastcall Lookup3(void* pFFileManagerLinear, void* edx, const char* path, int a3)
{
if (GetOverloadedFilePathA(path, nullptr/*s.data()*/, 0/*s.size()*/))
bLoadFromDisk = true;
return shLookup3.fastcall<void*>(pFFileManagerLinear, edx, path, a3);
}

SafetyHookInline shLookup4{};
void* __fastcall Lookup4(void* pFFileManagerLinear, void* edx, const char* path, int a3, int a4, int a5)
{
if (GetOverloadedFilePathA(path, nullptr/*s.data()*/, 0/*s.size()*/))
bLoadFromDisk = true;
return shLookup4.fastcall<void*>(pFFileManagerLinear, edx, path, a3, a4, a5);
}

SafetyHookInline shsub_4B9C80{};
int sub_4B9C80()
{
if (bLoadFromDisk)
{
bLoadFromDisk = false;
return true;
}
return shsub_4B9C80.ccall<int>();
}
}

namespace l3d
{
using LeadOptions = float*;
Expand Down Expand Up @@ -107,6 +154,17 @@ namespace UI
return shOnRadarChanged.fastcall<uint8_t>(ui, edx, a2, value);
}
}

SafetyHookInline shGetIsDifficultyLevelPerfectionist{};
bool GetIsDifficultyLevelPerfectionist()
{
return shGetIsDifficultyLevelPerfectionist.ccall<bool>();
}

bool GetIsDifficultyLevelPerfectionistHook()
{
return false;
}
}

namespace HudRadar
Expand All @@ -124,6 +182,17 @@ namespace UInputManager
};
}

namespace FThermalSonarVisionComponent
{
SafetyHookInline shSetCurrentActiveSonarWaveRange{};
void __fastcall SetCurrentActiveSonarWaveRange(void* _this, void* edx, float range)
{
if (UI::GetIsDifficultyLevelPerfectionist())
range /= 1.5f;
return shSetCurrentActiveSonarWaveRange.fastcall(_this, edx, range);
}
}

void Init()
{
CIniReader iniReader("");
Expand Down Expand Up @@ -208,6 +277,19 @@ void Init()
{
auto pattern = hook::pattern("55 8B EC 6A FF 68 ? ? ? ? 64 A1 ? ? ? ? 50 83 EC 1C 53 56 57 A1 ? ? ? ? 33 C5 50 8D 45 F4 64 A3 ? ? ? ? 8B F1 8B 45 08");
FFileManagerArc::shLookup = safetyhook::create_inline(pattern.get_first(), FFileManagerArc::Lookup);

pattern = hook::pattern("55 8B EC 6A FF 68 ? ? ? ? 64 A1 ? ? ? ? 50 83 EC 0C 56 57 A1 ? ? ? ? 33 C5 50 8D 45 F4 64 A3 ? ? ? ? 8B F1 8B 86 ? ? ? ? 83 7C 86 ? ? 8B 7D 08 0F 84 ? ? ? ? E8 ? ? ? ? 85 C0 0F 85 ? ? ? ? 8B 96 ? ? ? ? 6A 01 57 8D 4D E8 51 8B 4C 96 2C E8");
FFileManagerLinear::shLookup1 = safetyhook::create_inline(pattern.count(2).get(0).get<void*>(0), FFileManagerLinear::Lookup1);
FFileManagerLinear::shLookup2 = safetyhook::create_inline(pattern.count(2).get(1).get<void*>(0), FFileManagerLinear::Lookup2);

pattern = hook::pattern("55 8B EC 6A FF 68 ? ? ? ? 64 A1 ? ? ? ? 50 83 EC 0C 53 56 57 A1 ? ? ? ? 33 C5 50 8D 45 F4 64 A3 ? ? ? ? 8B F1 8B 86 ? ? ? ? 8B 5D 08 33 FF 39 7C 86 2C 0F 84 ? ? ? ? E8 ? ? ? ? 85 C0 0F 85 ? ? ? ? 8B 96 ? ? ? ? 6A 01 53 8D 4D E8 51 8B 4C 96 2C");
FFileManagerLinear::shLookup3 = safetyhook::create_inline(pattern.get_first(), FFileManagerLinear::Lookup3);

pattern = hook::pattern("55 8B EC 6A FF 68 ? ? ? ? 64 A1 ? ? ? ? 50 83 EC 20 53 56 57 A1 ? ? ? ? 33 C5 50 8D 45 F4 64 A3 ? ? ? ? 8B F1 8B 5D 08");
FFileManagerLinear::shLookup4 = safetyhook::create_inline(pattern.get_first(), FFileManagerLinear::Lookup4);

pattern = hook::pattern("E8 ? ? ? ? 85 C0 75 7F 53");
FFileManagerLinear::shsub_4B9C80 = safetyhook::create_inline(injector::GetBranchDestination(pattern.get_first()).as_int(), FFileManagerLinear::sub_4B9C80);
}
}

Expand Down Expand Up @@ -247,10 +329,21 @@ void Init()
pattern = hook::pattern("0F 84 ? ? ? ? 56 56 56 68 ? ? ? ? 68 ? ? ? ? 68 ? ? ? ? E8 ? ? ? ? 83 C4 18 50 8D 8D");
injector::WriteMemory<uint16_t>(pattern.get_first(), 0xE990, true); //jz -> jmp

//NetOnlineManager::NetOnlineManager
pattern = hook::pattern("C7 45 ? ? ? ? ? 8D 64 24 00 53");
injector::WriteMemory<uint32_t>(pattern.get_first(3), 4372, true);

//GameMode
pattern = hook::pattern("55 8B EC 83 3D ? ? ? ? ? 75 55");
shLead_SetCurrentGameMode = safetyhook::create_inline(pattern.get_first(), Lead_SetCurrentGameMode);

//Disable perfectionist checks
pattern = hook::pattern("53 32 DB E8 ? ? ? ? 85 C0 74 29");
UI::shGetIsDifficultyLevelPerfectionist = safetyhook::create_inline(pattern.get_first(), UI::GetIsDifficultyLevelPerfectionistHook);

pattern = hook::pattern("E8 ? ? ? ? F3 0F 10 46 ? 51 8B CE");
FThermalSonarVisionComponent::shSetCurrentActiveSonarWaveRange = safetyhook::create_inline(injector::GetBranchDestination(pattern.get_first()).as_int(), FThermalSonarVisionComponent::SetCurrentActiveSonarWaveRange);

if (bSkipIntro || bFullscreenAtStartup || bSkipPressAnyKeyScreen)
{
enum eWindowStyle
Expand Down Expand Up @@ -538,10 +631,6 @@ void Init()
regs.xmm1.f64[0] = 2.0;
});

//NetOnlineManager::NetOnlineManager
pattern = hook::pattern("C7 45 ? ? ? ? ? 8D 64 24 00 53");
injector::WriteMemory<uint32_t>(pattern.get_first(3), 4372, true);

//UD3DRenderDevice
pattern = hook::pattern("76 23 8B 06");
injector::WriteMemory<uint8_t>(pattern.get_first(0), 0xEB, true); //jbe -> jmp
Expand Down Expand Up @@ -616,16 +705,13 @@ void Init()
pattern = hook::pattern("F3 0F 11 04 24 52 8B 95");
static auto D3DRenderer__RenderHUD = safetyhook::create_mid(pattern.get_first(0), [](SafetyHookContext& regs)
{
if (GetAspectRatio() > fDefaultAspectRatio)
{
auto& a2 = regs.esi;
auto& x = *(uint32_t*)(regs.ebp - 0xB4);
auto& y = regs.ecx;
auto& w = regs.eax;
auto& h = regs.edx;
auto& a2 = regs.esi;
auto& x = *(uint32_t*)(regs.ebp - 0xB4);
auto& y = regs.ecx;
auto& w = regs.eax;
auto& h = regs.edx;

ScaleHUD(x, y, w, h);
}
ScaleHUD(x, y, w, h);
});
}

Expand Down

0 comments on commit 47f5df7

Please sign in to comment.