Skip to content

Commit 2afd35b

Browse files
committed
misc fixes/updates
- camo can't go past 95% - don't adjust camo if stealth is equipped - add CamoIndexValue config value
1 parent 1827755 commit 2afd35b

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

MGS3CrouchWalk/MGS3CrouchWalk.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@
118118
<ConformanceMode>true</ConformanceMode>
119119
<PrecompiledHeader>NotUsing</PrecompiledHeader>
120120
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
121+
<LanguageStandard>stdcpplatest</LanguageStandard>
121122
</ClCompile>
122123
<Link>
123124
<SubSystem>Windows</SubSystem>

MGS3CrouchWalk/dllmain.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ HMODULE GameModule = GetModuleHandleA("METAL GEAR SOLID3.exe");
77
uintptr_t GameBase = (uintptr_t)GameModule;
88
uintptr_t* CamoIndexData = NULL;
99
float CamoIndexModifier = 1.0f;
10+
int CamoIndexValue = 0;
1011
mINI::INIStructure Config;
1112

1213
typedef uintptr_t* __fastcall InitializeCamoIndexDelegate(uintptr_t a1, int a2);
@@ -24,11 +25,17 @@ uintptr_t __fastcall CalculateCamoIndexHook(uintptr_t a1, int a2)
2425
auto camoIndex = (int*)((char*)&CamoIndexData[4] + index + 4);
2526
auto movementState = (int*)((char*)&CamoIndexData[4] + index + 8);
2627

28+
if (*camoIndex >= 1000) // ignore if stealth is equipped
29+
{
30+
return result;
31+
}
32+
2733
if (*movementState == 0x6002)
2834
{
2935
*camoIndex = *camoIndex < 0 ? *camoIndex / CamoIndexModifier : *camoIndex * CamoIndexModifier;
36+
*camoIndex += CamoIndexValue;
3037

31-
if (*camoIndex > 1000) *camoIndex = 1000;
38+
if (*camoIndex > 950) *camoIndex = 950;
3239
if (*camoIndex < -1000) *camoIndex = -1000;
3340
}
3441
}
@@ -40,12 +47,12 @@ void InstallHooks()
4047
{
4148
int status = MH_Initialize();
4249

43-
uintptr_t CalcuateCamoIndexOffset = (uintptr_t)Memory::PatternScan(GameModule, "48 83 EC 30 0F 29 74 24 20 48 8B F9 48 63 F2 E8") - 0x10;
44-
uintptr_t InitializeCamoIndexOffset = (uintptr_t)Memory::PatternScan(GameModule, "85 D2 75 33 0F 57 C0 48 63 C2 48 C1 E0 07 48 8D");
50+
uintptr_t calcuateCamoIndexOffset = (uintptr_t)Memory::PatternScan(GameModule, "48 83 EC 30 0F 29 74 24 20 48 8B F9 48 63 F2 E8") - 0x10;
51+
uintptr_t initializeCamoIndexOffset = (uintptr_t)Memory::PatternScan(GameModule, "85 D2 75 33 0F 57 C0 48 63 C2 48 C1 E0 07 48 8D");
4552

46-
Memory::DetourFunction(CalcuateCamoIndexOffset, (LPVOID)CalculateCamoIndexHook, (LPVOID*)&CalculateCamoIndex);
53+
Memory::DetourFunction(calcuateCamoIndexOffset, (LPVOID)CalculateCamoIndexHook, (LPVOID*)&CalculateCamoIndex);
4754

48-
InitializeCamoIndex = (InitializeCamoIndexDelegate*)InitializeCamoIndexOffset;
55+
InitializeCamoIndex = (InitializeCamoIndexDelegate*)initializeCamoIndexOffset;
4956
CamoIndexData = InitializeCamoIndex(0, 0);
5057
}
5158

@@ -54,6 +61,7 @@ void ReadConfig()
5461
mINI::INIFile file("MGS3CrouchWalk.ini");
5562
file.read(Config);
5663
CamoIndexModifier = std::stof(Config["Settings"]["CamoIndexModifier"]);
64+
CamoIndexValue = std::stoi(Config["Settings"]["CamoIndexValue"]) * 10;
5765
}
5866

5967
DWORD WINAPI MainThread(LPVOID lpParam)

0 commit comments

Comments
 (0)