From 78c03005fe7c00d49c835ccc3ec1dee0cff786c4 Mon Sep 17 00:00:00 2001 From: Silent Date: Wed, 10 Apr 2024 20:23:20 +0200 Subject: [PATCH] Fixed multiple issues with pickups in VC: * Asset money pickup now initializes the text color to red correctly * minigun2 doesn't emit a secondary white glow anymore * bomb pickup doesn't have the grenade inside the detonator anymore Fixes #8 --- SilentPatchVC/SilentPatchVC.cpp | 74 +++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/SilentPatchVC/SilentPatchVC.cpp b/SilentPatchVC/SilentPatchVC.cpp index 0275ba0..99710fb 100644 --- a/SilentPatchVC/SilentPatchVC.cpp +++ b/SilentPatchVC/SilentPatchVC.cpp @@ -600,6 +600,53 @@ namespace MouseSensNewGame } +// ============= Fixed pickup effects colors ============= +namespace PickupEffectsFixes +{ + __declspec(naked) static void PickUpEffects_BigDollarColor() + { + _asm + { + mov byte ptr [esp+184h-170h], 0 + mov dword ptr [esp+184h-174h], 37 + retn + } + } + + __declspec(naked) static void PickUpEffects_Minigun2Glow() + { + _asm + { + cmp ecx, 294 // minigun2 + jnz NotMinigun2 + mov byte ptr [esp+184h-170h], 0 + xor eax, eax + jmp Return + + NotMinigun2: + lea eax, [ecx+1] + + Return: + mov ebx, ecx + retn + } + } + + __declspec(naked) static void PickUpEffects_GiveUsAnObject() + { + _asm + { + jnz GiveUsAnObject_NotEqual + mov si, [eax+58h] + retn + + GiveUsAnObject_NotEqual: + mov si, -1 + retn + } + } +} + void InjectDelayedPatches_VC_Common( bool bHasDebugMenu, const wchar_t* wcModulePath ) { using namespace Memory; @@ -1393,6 +1440,33 @@ void Patch_VC_Common() Nop(cameraInit.get(20), 10); InterceptCall(setDirMyDocuments, orgSetDirMyDocuments, SetDirMyDocuments_ResetMouse); } + + + // Fixed pickup effects + { + using namespace PickupEffectsFixes; + + // Give money pickups color ID 37, like most other "generic" pickups + // Coincidentally, it's also the most likely color to be "randomly" assigned to them now + auto bigDollarColor = get_pattern("C6 44 24 ? 00 E9 ? ? ? ? 8D 80 00 00 00 00 0F B7 1D ? ? ? ? 39 CB 75 0C"); + + // Remove the glow from minigun2 + auto minigun2Glow = get_pattern("8D 41 01 89 CB"); + + // Don't spawn the grenade together with the detonator in the pickup + // FLA might be altering this due to the usage of 16-bit IDs? Just in case allow for graceful failure + auto pickupExtraObject = pattern("75 04 66 8B 70 58").count_hint(1); + if (pickupExtraObject.size() == 1) + { + auto match = pickupExtraObject.get_one(); + + Nop(match.get(), 1); + InjectHook(match.get(1), &PickUpEffects_GiveUsAnObject, HookType::Call); + } + + InjectHook(bigDollarColor, &PickUpEffects_BigDollarColor, HookType::Call); + InjectHook(minigun2Glow, &PickUpEffects_Minigun2Glow, HookType::Call); + } } BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)