From d72a0cb7a039d211d87a91f1fce653733325edef Mon Sep 17 00:00:00 2001 From: Silent Date: Sun, 17 Mar 2024 18:15:56 +0100 Subject: [PATCH] Fix probabilities in CVehicle::InflictDamage incorrectly assuming a random range from 0 to 100.000 --- SilentPatchIII/SilentPatchIII.cpp | 10 ++++++++++ SilentPatchVC/SilentPatchVC.cpp | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/SilentPatchIII/SilentPatchIII.cpp b/SilentPatchIII/SilentPatchIII.cpp index 1838b7c..e3b40ba 100644 --- a/SilentPatchIII/SilentPatchIII.cpp +++ b/SilentPatchIII/SilentPatchIII.cpp @@ -1393,6 +1393,16 @@ void Patch_III_Common() Nop(setEvasiveDive.get(), 1); InjectHook(setEvasiveDive.get(1), &CalculateAngle_Hook, HookType::Call); } + + + // Fix probabilities in CVehicle::InflictDamage incorrectly assuming a random range from 0 to 100.000 + { + auto probability_do_nothing = get_pattern("66 81 7E 5A ? ? 73 50", 4); + auto probability_flee = get_pattern("0F B7 46 5A 3D ? ? ? ? 0F 8E", 4 + 1); + + Patch(probability_do_nothing, 35000u * 32767u / 100000u); + Patch(probability_flee, 75000u * 32767u / 100000u); + } } BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) diff --git a/SilentPatchVC/SilentPatchVC.cpp b/SilentPatchVC/SilentPatchVC.cpp index 3e921ed..6d0a1ea 100644 --- a/SilentPatchVC/SilentPatchVC.cpp +++ b/SilentPatchVC/SilentPatchVC.cpp @@ -1289,6 +1289,14 @@ void Patch_VC_Common() Patch(forAllAtomics.get(), 0x53); InterceptCall(forAllAtomics.get(1), orgRpClumpForAllAtomics, RpClumpForAllAtomics_ExtraComps); } + + + // Fix probabilities in CVehicle::InflictDamage incorrectly assuming a random range from 0 to 100.000 + { + auto probability = get_pattern("66 81 7B 5A ? ? 73 50", 4); + + Patch(probability, 35000u / 2u); + } } BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)