III/VC: Corrected randomness of CPed::Chat

Makes pedestrians less likely to initiate a chat,
matching the PS2 odds (they were too chatty on PC).
This commit is contained in:
Silent 2024-05-17 19:34:38 +02:00
parent 96bc50ee26
commit ccf61157fb
No known key found for this signature in database
GPG key ID: AE53149BB0C45AF1

View file

@ -163,7 +163,8 @@ namespace Rand16bit
return bottomBits | topBit;
}
HOOK_EACH_FUNC(Rand, orgRand, rand16bit);
HOOK_EACH_FUNC_CTR(Rand_Script, 0, orgRand, rand16bit);
HOOK_EACH_FUNC_CTR(Rand_PedChat, 1, orgRand, rand16bit);
}
@ -329,19 +330,35 @@ namespace Common {
TXN_CATCH();
// Make script randomness 16-bit, like on PS2
try
// Fix various randomness factors expecting 16-bit rand()
{
// Treat each instance separately
using namespace Rand16bit;
// Script randomness
try
{
std::array<void*, 2> rands = {
get_pattern("E8 ? ? ? ? 0F B7 C0 89 06"),
get_pattern("E8 ? ? ? ? 25 FF FF 00 00 89 84 24 ? ? ? ? 30 C0"),
};
HookEach_Rand(rands, InterceptCall);
HookEach_Rand_Script(rands, InterceptCall);
}
TXN_CATCH();
// CPed::Chat
try
{
std::array<void*, 2> rands = {
get_pattern("E8 ? ? ? ? 66 3D 00 02"),
get_pattern("E8 ? ? ? ? 66 83 F8 14"),
};
HookEach_Rand_PedChat(rands, InterceptCall);
}
TXN_CATCH();
}
}
void III_VC_SetDelayedPatchesFunc( void(*func)() )