Fix probabilities in CVehicle::InflictDamage incorrectly assuming a random range from 0 to 100.000

This commit is contained in:
Silent 2024-03-17 18:15:56 +01:00
parent 56ac3b8795
commit d72a0cb7a0
No known key found for this signature in database
GPG Key ID: AE53149BB0C45AF1
2 changed files with 18 additions and 0 deletions

View File

@ -1393,6 +1393,16 @@ void Patch_III_Common()
Nop(setEvasiveDive.get<void>(), 1);
InjectHook(setEvasiveDive.get<void>(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<uint16_t>(probability_do_nothing, 35000u * 32767u / 100000u);
Patch<uint32_t>(probability_flee, 75000u * 32767u / 100000u);
}
}
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)

View File

@ -1289,6 +1289,14 @@ void Patch_VC_Common()
Patch<uint8_t>(forAllAtomics.get<void>(), 0x53);
InterceptCall(forAllAtomics.get<void>(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<uint16_t>(probability, 35000u / 2u);
}
}
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)