|
| 1 | +#include <stdafx.h> |
| 2 | + |
| 3 | +#include "TextOutlineHook.h" |
| 4 | + |
| 5 | +#include "Memory/Hooks/Hook.h" |
| 6 | + |
| 7 | +#include "Memory.h" |
| 8 | +#include "game.h" |
| 9 | + |
| 10 | +#include "Memory/Allocator/MemoryBuffer.h" |
| 11 | + |
| 12 | +#include "Memory/Rain.h" |
| 13 | + |
| 14 | +static std::optional<float> desiredRotation; |
| 15 | +static std::optional<ChaosVector3> desiredPosition; |
| 16 | + |
| 17 | +static float (*OG_GetMinimapRotation)(); |
| 18 | +static float HK_GetMinimapRotation() |
| 19 | +{ |
| 20 | + return OG_GetMinimapRotation() + desiredRotation.value_or(0.f); |
| 21 | +} |
| 22 | + |
| 23 | +static void (*OG_GetMinimapPosition)(ChaosVector3 *out); |
| 24 | +static void HK_GetMinimapPosition(ChaosVector3 *out) |
| 25 | +{ |
| 26 | + OG_GetMinimapPosition(out); |
| 27 | + |
| 28 | + if (desiredPosition.has_value()) |
| 29 | + { |
| 30 | + LOG(out->x << " " << desiredPosition.value().x << " " << (*out + desiredPosition.value()).x); |
| 31 | + *out = *out + desiredPosition.value(); |
| 32 | + } |
| 33 | +} |
| 34 | + |
| 35 | +static bool OnHook() |
| 36 | +{ |
| 37 | + auto handle = Memory::FindPattern("E8 ?? ?? ?? ?? F3 0F 59 05 ?? ?? ?? ?? F3 0F 2C E8 8B C5", |
| 38 | + "E8 ?? ?? ?? ?? F3 0F 59 05 ?? ?? ?? ?? F3 0F 2C E8 41 81 FF"); |
| 39 | + |
| 40 | + if (!handle.IsValid()) |
| 41 | + return false; |
| 42 | + |
| 43 | + Memory::AddHook(handle.Into().Get<void>(), HK_GetMinimapRotation, &OG_GetMinimapRotation); |
| 44 | + |
| 45 | + handle = Memory::FindPattern("E8 ?? ?? ?? ?? 33 C9 E8 ?? ?? ?? ?? 0F 57 F6", |
| 46 | + "E8 ?? ?? ?? ?? 31 C9 E8 ?? ?? ?? ?? 84 C0 74 0B 0F B6 05 ?? ?? ?? ?? 24 01 75 36"); |
| 47 | + |
| 48 | + if (!handle.IsValid()) |
| 49 | + return false; |
| 50 | + |
| 51 | + Memory::AddHook(handle.Into().Get<void>(), HK_GetMinimapPosition, &OG_GetMinimapPosition); |
| 52 | + |
| 53 | + return true; |
| 54 | +} |
| 55 | + |
| 56 | +static void OnCleanup() |
| 57 | +{ |
| 58 | + desiredRotation = std::nullopt; |
| 59 | +} |
| 60 | + |
| 61 | +namespace Hooks |
| 62 | +{ |
| 63 | + void SetMinimapRotation(float rotation) |
| 64 | + { |
| 65 | + desiredRotation = rotation; |
| 66 | + } |
| 67 | + |
| 68 | + void ResetMinimapRotation() |
| 69 | + { |
| 70 | + desiredRotation = std::nullopt; |
| 71 | + } |
| 72 | + |
| 73 | + void SetMinimapPosition(Vector3 position) |
| 74 | + { |
| 75 | + desiredPosition = ChaosVector3(position); |
| 76 | + } |
| 77 | + |
| 78 | + void ResetMinimapPosition() |
| 79 | + { |
| 80 | + desiredPosition = std::nullopt; |
| 81 | + } |
| 82 | +} |
| 83 | + |
| 84 | +static RegisterHook registerHook(OnHook, OnCleanup, "_MinimapParams"); |
0 commit comments