From c73fc24f0da2527f105eea6cb5c10bb41d76795c Mon Sep 17 00:00:00 2001 From: ermaccer <40604575+ermaccer@users.noreply.github.com> Date: Fri, 1 Jul 2022 13:08:18 +0200 Subject: [PATCH] free camera overhaul, mouse control --- MK11Hook/MK11Hook.rc | Bin 4524 -> 4524 bytes MK11Hook/MK11Hook.vcxproj | 16 +++ MK11Hook/MK11Hook.vcxproj.filters | 66 +++++++++-- MK11Hook/code/GameInfo.cpp | 15 +++ MK11Hook/code/GameInfo.h | 5 +- MK11Hook/code/MKCharacter.cpp | 16 +++ MK11Hook/code/MKCharacter.h | 6 +- MK11Hook/code/MKCommand.h | 10 ++ MK11Hook/code/MKStructs.h | 17 +-- MK11Hook/code/PlayerInfo.cpp | 22 +++- MK11Hook/code/PlayerInfo.h | 43 +++++++ MK11Hook/code/VMProc.cpp | 6 + MK11Hook/code/VMProc.h | 6 + MK11Hook/code/eSettingsManager.cpp | 15 ++- MK11Hook/code/eSettingsManager.h | 9 ++ MK11Hook/code/helper/eMath.cpp | 36 ++++++ MK11Hook/code/helper/eMath.h | 15 +++ MK11Hook/code/helper/eMouse.cpp | 69 +++++++++++ MK11Hook/code/helper/eMouse.h | 26 +++++ MK11Hook/code/mk11.cpp | 53 +++------ MK11Hook/code/mk11.h | 7 +- MK11Hook/code/mk11menu.cpp | 135 +++++++++++++++------- MK11Hook/code/mk11menu.h | 17 +-- MK11Hook/code/mkcamera.cpp | 7 ++ MK11Hook/code/mkcamera.h | 5 +- MK11Hook/code/plugin/ePluginInterface.cpp | 26 +++++ MK11Hook/code/plugin/ePluginInterface.h | 36 ++++++ MK11Hook/code/unreal/FMath.cpp | 13 +++ MK11Hook/code/unreal/FMath.h | 11 ++ MK11Hook/code/unreal/FMatrix.cpp | 71 ++++++++++++ MK11Hook/code/unreal/FMatrix.h | 15 +++ MK11Hook/code/unreal/FQuat.h | 8 ++ MK11Hook/code/unreal/FRotator.h | 7 ++ MK11Hook/code/unreal/FVector.h | 79 +++++++++++++ MK11Hook/dllmain.cpp | 5 +- MK11Hook/eDirectX11Hook.cpp | 2 +- 36 files changed, 761 insertions(+), 134 deletions(-) create mode 100644 MK11Hook/code/MKCommand.h create mode 100644 MK11Hook/code/VMProc.cpp create mode 100644 MK11Hook/code/VMProc.h create mode 100644 MK11Hook/code/helper/eMath.cpp create mode 100644 MK11Hook/code/helper/eMath.h create mode 100644 MK11Hook/code/helper/eMouse.cpp create mode 100644 MK11Hook/code/helper/eMouse.h create mode 100644 MK11Hook/code/plugin/ePluginInterface.cpp create mode 100644 MK11Hook/code/plugin/ePluginInterface.h create mode 100644 MK11Hook/code/unreal/FMath.cpp create mode 100644 MK11Hook/code/unreal/FMath.h create mode 100644 MK11Hook/code/unreal/FMatrix.cpp create mode 100644 MK11Hook/code/unreal/FMatrix.h create mode 100644 MK11Hook/code/unreal/FQuat.h create mode 100644 MK11Hook/code/unreal/FRotator.h create mode 100644 MK11Hook/code/unreal/FVector.h diff --git a/MK11Hook/MK11Hook.rc b/MK11Hook/MK11Hook.rc index 162442f011a2f87f3a0eb11f6076d05aca23bed3..fe37147cdcfdd2070950537ccb7adc0003459e05 100644 GIT binary patch delta 46 zcmZ3ZyheFL6$hj7M&r$EIesz$IsLrSlMirnOxEM!+kAt28zWGrpI4Rz0BA`L AlK=n! delta 46 zcmZ3ZyheFL6$hiyMx)JZIesz$IsLrSlMirnOxEM!+kAt28zWGrpI4Rz0B7V5 Aj{pDw diff --git a/MK11Hook/MK11Hook.vcxproj b/MK11Hook/MK11Hook.vcxproj index acbf40e..39fefdc 100644 --- a/MK11Hook/MK11Hook.vcxproj +++ b/MK11Hook/MK11Hook.vcxproj @@ -103,17 +103,27 @@ + + + + + + + + + + @@ -150,6 +160,8 @@ + + @@ -159,7 +171,11 @@ + + + + diff --git a/MK11Hook/MK11Hook.vcxproj.filters b/MK11Hook/MK11Hook.vcxproj.filters index ead0ac4..ce92973 100644 --- a/MK11Hook/MK11Hook.vcxproj.filters +++ b/MK11Hook/MK11Hook.vcxproj.filters @@ -28,15 +28,15 @@ {db46cdf8-7c42-4a12-a5f1-14ed4879f476} - - {7187d197-8447-41c0-9f40-8dcab7f80186} - {bb5a43a5-8836-46b1-9a85-18be7a5c70a3} {28f5b54e-93a3-4310-8370-b568866173c6} + + {625ccf99-cebc-4904-a474-5f92cefdad83} + @@ -129,9 +129,6 @@ Header Files\code - - Source Files\dx - Header Files\code @@ -174,6 +171,39 @@ Header Files\code\helper + + Header Files\code\plugin + + + Header Files\code + + + Header Files\code + + + Source Files + + + Header Files\code\unreal + + + Header Files\code\unreal + + + Header Files\code\unreal + + + Header Files\code\unreal + + + Header Files\code\unreal + + + Header Files\code\helper + + + Header Files\code\helper + @@ -242,9 +272,6 @@ Header Files\code - - Source Files\dx - Header Files\code @@ -281,6 +308,27 @@ Header Files\code\helper + + Header Files\code\plugin + + + Header Files\code + + + Source Files + + + Header Files\code\unreal + + + Header Files\code\unreal + + + Header Files\code\helper + + + Header Files\code\helper + diff --git a/MK11Hook/code/GameInfo.cpp b/MK11Hook/code/GameInfo.cpp index 020a7a1..8ed3858 100644 --- a/MK11Hook/code/GameInfo.cpp +++ b/MK11Hook/code/GameInfo.cpp @@ -24,6 +24,11 @@ FGGameInfo* GetGameInfo() return *(FGGameInfo**)_addr(GFG_GAME_INFO); } +int GetGameState() +{ + return *(int*)((*(int64*)_addr(GFG_GAME_INFO)) + 1944); +} + void FGGameInfo::SetStage(const char* stage) { ((void(__thiscall*)(FGGameInfo*, const char*))_addr(0x14059A460))(this, stage); @@ -47,3 +52,13 @@ int MKScript::GetFunctionID(int hash) { return ((int(__thiscall*)(MKScript*, int, int))_addr(0x14114C5F0))(this, hash, 0); } + +int64 MKScript::GetVar(const char* name) +{ + return ((int64(__fastcall*)(MKScript*, const char*, int))_addr(0x14114F750))(this, name, 1); +} + +unsigned int MKScript::GetCurrentFunc() +{ + return *(unsigned int*)(this + 360); +} diff --git a/MK11Hook/code/GameInfo.h b/MK11Hook/code/GameInfo.h index 7670958..c2af8b1 100644 --- a/MK11Hook/code/GameInfo.h +++ b/MK11Hook/code/GameInfo.h @@ -19,6 +19,8 @@ enum PLAYER_NUM class MKScript { public: int GetFunctionID(int hash); + int64 GetVar(const char* name); + unsigned int GetCurrentFunc(); }; class FGGameInfo { @@ -32,4 +34,5 @@ MKScript* GetScript(const char* name); int64 GetScriptVar(MKScript* script, const char* name); -FGGameInfo* GetGameInfo(); \ No newline at end of file +FGGameInfo* GetGameInfo(); +int GetGameState(); \ No newline at end of file diff --git a/MK11Hook/code/MKCharacter.cpp b/MK11Hook/code/MKCharacter.cpp index c088f87..65f9fdb 100644 --- a/MK11Hook/code/MKCharacter.cpp +++ b/MK11Hook/code/MKCharacter.cpp @@ -52,6 +52,11 @@ void MKCharacter::SetAbility(unsigned int id) *(int*)(this + 64304) = id; } +void MKCharacter::SetCombos(bool enable) +{ + ((void(__fastcall*)(MKCharacter*, int, int))_addr(0x1404C7300))(this, enable, 1); +} + float MKCharacter::GetLife() { return *(float*)(this + 3104); @@ -95,3 +100,14 @@ void MKCharacter::ExecuteScript(MKScript* script, int function) ((void(__thiscall*)(MKCharacter*, MKScript*, int, int))_addr(0x1404D1CC0))(this, script, function, 1); } +MKScript* MKCharacter::GetMyScript() +{ + return *(MKScript**)(this + 0xA7D8); +} + +VMProc* MKCharacter::GetMyProc() +{ + return *(VMProc**)(this + 0x10E0); +} + + diff --git a/MK11Hook/code/MKCharacter.h b/MK11Hook/code/MKCharacter.h index e897714..a02885e 100644 --- a/MK11Hook/code/MKCharacter.h +++ b/MK11Hook/code/MKCharacter.h @@ -2,7 +2,7 @@ #include "MKStructs.h" #include "mk10utils.h" #include "GameInfo.h" - +#include "VMProc.h" struct CharacterCAP { char* Name; @@ -50,6 +50,7 @@ class MKCharacter { void SetInfiniteKrushingBlows(bool enable); void SetFastUppercutRecovery(bool enable); void SetAbility(unsigned int id); + void SetCombos(bool enable); float GetLife(); @@ -69,6 +70,9 @@ class MKCharacter { void ExecuteScript(MKScript* script, int function); + + MKScript* GetMyScript(); + VMProc* GetMyProc(); }; diff --git a/MK11Hook/code/MKCommand.h b/MK11Hook/code/MKCommand.h new file mode 100644 index 0000000..3fd0873 --- /dev/null +++ b/MK11Hook/code/MKCommand.h @@ -0,0 +1,10 @@ +#pragma once + + +struct MKCommand { + char* name; + int air_ground; // or not + int action_key; + char pad[24]; // mk11 only + int* directions; // 4 max, close with -1 +}; \ No newline at end of file diff --git a/MK11Hook/code/MKStructs.h b/MK11Hook/code/MKStructs.h index 07bf280..73861ee 100644 --- a/MK11Hook/code/MKStructs.h +++ b/MK11Hook/code/MKStructs.h @@ -1,18 +1,7 @@ #pragma once - -struct FVector -{ - float X; - float Y; - float Z; -}; - -struct FRotator -{ - int Pitch; - int Yaw; - int Roll; -}; +#include "unreal/FVector.h" +#include "unreal/FQuat.h" +#include "unreal/FRotator.h" struct FLinearColor { diff --git a/MK11Hook/code/PlayerInfo.cpp b/MK11Hook/code/PlayerInfo.cpp index 2c13f0b..18d095a 100644 --- a/MK11Hook/code/PlayerInfo.cpp +++ b/MK11Hook/code/PlayerInfo.cpp @@ -11,7 +11,23 @@ void PlayerInfo::SetMeter(eMeterValues type, float value) void PlayerInfo::SetDamageMult(float value) { - *(float*)(this + 1000) = value; - *(float*)(this + 1004) = value; - *(float*)(this + 1008) = value; + *(float*)((int64)this + 1000) = value; + *(float*)((int64)this + 1004) = value; + *(float*)((int64)this + 1008) = value; +} + +void PlayerInfo::RefreshMeter(bool value) +{ + ((void(__fastcall*)(PlayerInfo*, bool))_addr(0x140602930))(this,value); +} + +float PlayerInfo::GetMeter(eMeterValues type) +{ + int64 meter_ptr = ((int64)this + 16 * (type + 24)); + return *(float*)(meter_ptr + 4); +} + +HitCounter PlayerInfo::GetHits() +{ + return *(HitCounter*)((int64)this + 0x430); } diff --git a/MK11Hook/code/PlayerInfo.h b/MK11Hook/code/PlayerInfo.h index 0c3e6ac..2d4d66c 100644 --- a/MK11Hook/code/PlayerInfo.h +++ b/MK11Hook/code/PlayerInfo.h @@ -6,8 +6,51 @@ enum eMeterValues { BAR_Defensive }; +enum eButton : int { + BUTTON_UP = 1, + BUTTON_DOWN = 2, + BUTTON_LEFT = 4, + BUTTON_RIGHT = 8, + BUTTON_BP = 16, + BUTTON_FK = 32, + BUTTON_FP = 64, + BUTTON_BK = 128, + BUTTON_UNK = 256, + BUTTON_RESET = 512, + BUTTON_ASSIST = 2048, + BUTTON_THROW = 4096, + BUTTON_INTERACT = 8192, + BUTTON_FLIP_STANCE = 16384, + BUTTON_BLOCK = 32768 +}; + +struct ButtonInfo { + eButton id; + int pad[3]; +}; + + +struct HitCounter { + int hits; + int airHits; + int combo; +}; + +struct Gamepad { + char pad[0x1C]; + ButtonInfo buttons; + ButtonInfo oldButtons; +}; + class PlayerInfo { public: + char _pad[48]; + Gamepad* pad; + void SetMeter(eMeterValues type, float value); void SetDamageMult(float value); + void RefreshMeter(bool value); + float GetMeter(eMeterValues type); + + HitCounter GetHits(); }; \ No newline at end of file diff --git a/MK11Hook/code/VMProc.cpp b/MK11Hook/code/VMProc.cpp new file mode 100644 index 0000000..6af2bee --- /dev/null +++ b/MK11Hook/code/VMProc.cpp @@ -0,0 +1,6 @@ +#include "VMProc.h" + +unsigned int VMProc::GetCurrentFunction() +{ + return *(unsigned int*)(this + 360); +} diff --git a/MK11Hook/code/VMProc.h b/MK11Hook/code/VMProc.h new file mode 100644 index 0000000..777ecee --- /dev/null +++ b/MK11Hook/code/VMProc.h @@ -0,0 +1,6 @@ +#pragma once + +class VMProc { +public: + unsigned int GetCurrentFunction(); +}; \ No newline at end of file diff --git a/MK11Hook/code/eSettingsManager.cpp b/MK11Hook/code/eSettingsManager.cpp index 85028e1..ad02ed7 100644 --- a/MK11Hook/code/eSettingsManager.cpp +++ b/MK11Hook/code/eSettingsManager.cpp @@ -12,6 +12,10 @@ void eSettingsManager::Init() // user first iToggleCustomCamKey = user.ReadInteger("Settings", "iToggleCustomCamKey", 0); + bEnableConsoleWindow = ini.ReadBoolean("Settings", "bEnableConsoleWindow", true); + bEnableGamepadSupport = ini.ReadBoolean("Settings", "bEnableGamepadSupport", true); + bUseLegacyCharacterModifier = ini.ReadBoolean("Settings", "bUseLegacyCharacterModifier", false); + bMakeAllAbilities1Slot = ini.ReadBoolean("Settings", "bMakeAllAbilities1Slot", false); iHookMenuOpenKey = user.ReadInteger("Settings", "iHookMenuOpenKey", 0xFF); @@ -94,11 +98,9 @@ void eSettingsManager::Init() if (fMenuScale < 1.0f) fMenuScale = 1.0f; - bEnableConsoleWindow = ini.ReadBoolean("Settings", "bEnableConsoleWindow", true); - bEnableGamepadSupport = ini.ReadBoolean("Settings", "bEnableGamepadSupport", true); - bUseLegacyCharacterModifier = ini.ReadBoolean("Settings", "bUseLegacyCharacterModifier", false); - bMakeAllAbilities1Slot = ini.ReadBoolean("Settings", "bMakeAllAbilities1Slot", false); - bDisableComboDamageScaling = false; + mouse.sens = user.ReadInteger("Mouse", "Sensitivity", 10); + mouse.invert_y = user.ReadBoolean("Mouse", "InvertY", false); + mouse.invert_x = user.ReadBoolean("Mouse", "InvertX", false); } @@ -126,6 +128,9 @@ void eSettingsManager::SaveSettings() user.WriteInteger("Settings", "iFreeCameraKeyFOVPlus", iFreeCameraKeyFOVPlus); user.WriteInteger("Settings", "iFreeCameraKeyFOVMinus", iFreeCameraKeyFOVMinus); user.WriteInteger("Settings", "iResetStageInteractablesKey", iResetStageInteractablesKey); + user.WriteInteger("Mouse", "Sensitivity", mouse.sens); + user.WriteBoolean("Mouse", "InvertY", mouse.invert_y); + user.WriteBoolean("Mouse", "InvertX", mouse.invert_x); CIniReader ini(""); ini.WriteBoolean("Settings", "bEnableGamepadSupport", bEnableGamepadSupport); diff --git a/MK11Hook/code/eSettingsManager.h b/MK11Hook/code/eSettingsManager.h index a75b720..7f14844 100644 --- a/MK11Hook/code/eSettingsManager.h +++ b/MK11Hook/code/eSettingsManager.h @@ -3,6 +3,13 @@ // as usual, pluginmh/mugenhook +struct eMouseSettings { + int sens; + bool invert_y; + bool invert_x; +}; + + class eSettingsManager { public: void Init(); @@ -44,6 +51,8 @@ class eSettingsManager { int iFreeCameraKeyFOVPlus; int iFreeCameraKeyFOVMinus; + eMouseSettings mouse; + float fMenuScale; void SaveSettings(); diff --git a/MK11Hook/code/helper/eMath.cpp b/MK11Hook/code/helper/eMath.cpp new file mode 100644 index 0000000..70e1a0f --- /dev/null +++ b/MK11Hook/code/helper/eMath.cpp @@ -0,0 +1,36 @@ +#include "eMath.h" + +FVector eMath::quat2vec(FQuat q) +{ + FVector result; + + float ysqr = q.Y * q.Y; + + float t0 = +2.0f * (q.W * q.X + q.Y * q.Z); + float t1 = +1.0f - 2.0f * (q.X * q.X + ysqr); + float roll = atan2(t0, t1); + + float t2 = +2.0f * (q.W * q.Y - q.Z * q.X); + t2 = ((t2 > 1.0f) ? 1.0f : t2); + t2 = ((t2 < -1.0f) ? -1.0f : t2); + + float pitch = asin(t2); + float t3 = +2.0f * (q.W * q.Z + q.X * q.Y); + float t4 = +1.0f - 2.0f * (ysqr + q.Z * q.Z); + float yaw = atan2(t3, t4); + + result.X = roll / M_PI * 180; + result.Y = pitch / M_PI * 180; + result.Z = yaw / M_PI * 180; + return result; +} + +bool eMath::areVecsEqual(FVector v1, FVector v2) +{ + if (fabs(v1.X - v2.X) < 0.1f && + (fabs(v1.Y - v2.Y) < 0.1f) && + (fabs(v1.Z - v2.Z) < 0.1f)) + return true; + else + return false; +} diff --git a/MK11Hook/code/helper/eMath.h b/MK11Hook/code/helper/eMath.h new file mode 100644 index 0000000..55d2203 --- /dev/null +++ b/MK11Hook/code/helper/eMath.h @@ -0,0 +1,15 @@ +#pragma once +#include "..\unreal\FVector.h" +#include "..\unreal\FQuat.h" + +#include +#define M_PI 3.14159265358979323846f + +#define degToRad(angleInDegrees) ((angleInDegrees) * M_PI / 180.0) +#define radToDeg(angleInRadians) ((angleInRadians) * 180.0 / M_PI) + +class eMath { +public: + static FVector quat2vec(FQuat q); + static bool areVecsEqual(FVector v1, FVector v2); +}; \ No newline at end of file diff --git a/MK11Hook/code/helper/eMouse.cpp b/MK11Hook/code/helper/eMouse.cpp new file mode 100644 index 0000000..891bdf7 --- /dev/null +++ b/MK11Hook/code/helper/eMouse.cpp @@ -0,0 +1,69 @@ +#include "eMouse.h" +#include +#include +#include "../../eDirectX11Hook.h" +#include "../mk11menu.h" +#include "../eSettingsManager.h" + +eMouse eMouse::mouse; + +eMouse::eMouse() +{ + Clear(); +} + +void eMouse::Clear() +{ + x = 0; + y = 0; + deltaX = 0; + deltaY = 0; + gotDelta = false; +} + +void eMouse::UpdateMouse() +{ + if (!TheMenu->m_bIsActive && TheMenu->m_bMouseControl && TheMenu->m_bIsFocused) + { + mouse.Clear(); + POINT point; + GetCursorPos(&point); + + if (!mouse.gotDelta) + { + eMouse::LockMouse(); + mouse.gotDelta = true; + } + + POINT center; + GetCursorPos(¢er); + + mouse.deltaX = point.x - center.x; + mouse.deltaY = point.y - center.y; + mouse.deltaX *= SettingsMgr->mouse.sens; + mouse.deltaY *= SettingsMgr->mouse.sens; + mouse.gotDelta = false; + } +} + + +int eMouse::GetDeltaX() +{ + return SettingsMgr->mouse.invert_x ? -mouse.deltaX : mouse.deltaX; +} + +int eMouse::GetDeltaY() +{ + return SettingsMgr->mouse.invert_y ? mouse.deltaY : -mouse.deltaY; +} + +void eMouse::LockMouse() +{ + if (eDirectX11Hook::ms_hWindow) + { + RECT rect; + GetWindowRect(eDirectX11Hook::ms_hWindow, &rect); + + SetCursorPos(rect.right / 2, rect.bottom / 2); + } +} diff --git a/MK11Hook/code/helper/eMouse.h b/MK11Hook/code/helper/eMouse.h new file mode 100644 index 0000000..22e10fb --- /dev/null +++ b/MK11Hook/code/helper/eMouse.h @@ -0,0 +1,26 @@ +#pragma once + +class eMouse { +public: + int x; + int y; + + int deltaX; + int deltaY; + bool gotDelta; + + eMouse(); + + void Clear(); + + static void UpdateMouse(); + + static eMouse mouse; + + + static int GetDeltaX(); + static int GetDeltaY(); + + static void LockMouse(); +}; + diff --git a/MK11Hook/code/mk11.cpp b/MK11Hook/code/mk11.cpp index 9fb2478..e8edeaa 100644 --- a/MK11Hook/code/mk11.cpp +++ b/MK11Hook/code/mk11.cpp @@ -11,6 +11,8 @@ #include "unreal/FName.h" #include "MKObject.h" #include "Krypt.h" +#include "MKCommand.h" +#include "helper/eMouse.h" int64 hud_property = 0; @@ -18,6 +20,7 @@ void __fastcall MK11Hooks::HookProcessStuff() { TheMenu->Process(); Notifications->Update(); + eMouse::UpdateMouse(); MKCharacter* p1 = GetObj(PLAYER1); MKCharacter* p2 = GetObj(PLAYER2); @@ -222,42 +225,7 @@ void __fastcall MK11Hooks::HookProcessStuff() } } - if (TheMenu->m_bFreeCam) - { - if (GetAsyncKeyState(SettingsMgr->iFreeCameraKeyXPlus)) - TheMenu->camPos.X += TheMenu->m_fFreeCameraSpeed; - if (GetAsyncKeyState(SettingsMgr->iFreeCameraKeyXMinus)) - TheMenu->camPos.X -= TheMenu->m_fFreeCameraSpeed; - if (GetAsyncKeyState(SettingsMgr->iFreeCameraKeyYPlus)) - TheMenu->camPos.Y += TheMenu->m_fFreeCameraSpeed; - if (GetAsyncKeyState(SettingsMgr->iFreeCameraKeyYMinus)) - TheMenu->camPos.Y -= TheMenu->m_fFreeCameraSpeed; - if (GetAsyncKeyState(SettingsMgr->iFreeCameraKeyZPlus)) - TheMenu->camPos.Z += TheMenu->m_fFreeCameraSpeed; - if (GetAsyncKeyState(SettingsMgr->iFreeCameraKeyZMinus)) - TheMenu->camPos.Z -= TheMenu->m_fFreeCameraSpeed; - - if (GetAsyncKeyState(SettingsMgr->iFreeCameraKeyYawMinus)) - TheMenu->camRot.Yaw -= TheMenu->m_nFreeCameraRotationSpeed; - if (GetAsyncKeyState(SettingsMgr->iFreeCameraKeyYawPlus)) - TheMenu->camRot.Yaw += TheMenu->m_nFreeCameraRotationSpeed; - - if (GetAsyncKeyState(SettingsMgr->iFreeCameraKeyRollMinus)) - TheMenu->camRot.Roll -= TheMenu->m_nFreeCameraRotationSpeed; - if (GetAsyncKeyState(SettingsMgr->iFreeCameraKeyRollPlus)) - TheMenu->camRot.Roll += TheMenu->m_nFreeCameraRotationSpeed; - - if (GetAsyncKeyState(SettingsMgr->iFreeCameraKeyPitchMinus)) - TheMenu->camRot.Pitch -= TheMenu->m_nFreeCameraRotationSpeed; - if (GetAsyncKeyState(SettingsMgr->iFreeCameraKeyPitchPlus)) - TheMenu->camRot.Pitch += TheMenu->m_nFreeCameraRotationSpeed; - - if (GetAsyncKeyState(SettingsMgr->iFreeCameraKeyFOVMinus)) - TheMenu->camFov -= 1.0f; - if (GetAsyncKeyState(SettingsMgr->iFreeCameraKeyFOVPlus)) - TheMenu->camFov += 1.0f; - } - + TheMenu->UpdateFreecam(); if (TheMenu->m_bForceCameraUpdate) { @@ -286,6 +254,8 @@ void __fastcall MK11Hooks::HookStartupFightRecording(int64 eventID, int64 a2, in TheMenu->m_bCustomCameraRot = false; TheMenu->m_bYObtained = false; + + if (TheMenu->m_bStageModifier) GetGameInfo()->SetStage(TheMenu->szStageModifierStage); @@ -333,6 +303,11 @@ void __fastcall MK11Hooks::HookStartupFightRecording(int64 eventID, int64 a2, in } +void MK11Hooks::HookPreFightStart() +{ + ((void(__fastcall*)())_addr(0x140CFBAB0))(); +} + int64 MK11Hooks::HookSetProperty(int64 ptr, char * name, int64 unk) { @@ -428,9 +403,9 @@ PlayerInfo* GetInfo(PLAYER_NUM plr) void GetCharacterPosition(FVector * vec, PLAYER_NUM plr) { - int64 object = (int64)GetInfo(plr); - int64 ptr = *(int64*)(object + 32); - ((int64(__fastcall*)(int64, FVector*))_addr(0x14114F8A0))(ptr, vec); + int64 object = (int64)GetObj(plr); + if (object) + ((int64(__fastcall*)(int64, FVector*))_addr(0x14114F8A0))(object, vec); } void HideHUD() diff --git a/MK11Hook/code/mk11.h b/MK11Hook/code/mk11.h index fe3d6e9..661d464 100644 --- a/MK11Hook/code/mk11.h +++ b/MK11Hook/code/mk11.h @@ -10,7 +10,7 @@ #define GFG_GAME_INFO 0x143498D90 -#define MK11HOOK_VERSION "0.5.2" +#define MK11HOOK_VERSION "0.5.3" #define TOTAL_ABILITIES 20 @@ -53,11 +53,12 @@ void LoadModifierAssets(); unsigned int HashString(const char* input); + namespace MK11Hooks { // hooks void HookProcessStuff(); void HookStartupFightRecording(int64 eventID, int64 a2, int64 a3, int64 a4); - + void HookPreFightStart(); void HookReadPropertyValue(int64 ptr, int* unk, int* value); int64 HookSetProperty(int64 ptr, char* name, int64 unk); @@ -66,6 +67,4 @@ namespace MK11Hooks { void HookSetSelectScreen(int64 ptr, PLAYER_NUM plr, int teamNo, char *name, int level, int64 loadout, bool altPalette); void HookSetLadderScreen(CharacterDefinition* chr, char* name, int64 ptr, int64 unk); - - } \ No newline at end of file diff --git a/MK11Hook/code/mk11menu.cpp b/MK11Hook/code/mk11menu.cpp index 780dc89..70b22f2 100644 --- a/MK11Hook/code/mk11menu.cpp +++ b/MK11Hook/code/mk11menu.cpp @@ -15,6 +15,7 @@ #include "GameInfo.h" #include "Krypt.h" #include "MKObject.h" +#include "helper/eMouse.h" static int64 timer = GetTickCount64(); static int64 func_timer = GetTickCount64(); @@ -748,9 +749,6 @@ static void ShowHelpMarker(const char* desc) void MK11Menu::Initialize() { - orgMouse.x = GetSystemMetrics(SM_CXSCREEN) / 2; - orgMouse.y = GetSystemMetrics(SM_CYSCREEN) / 2; - sprintf(szCurrentCameraOption, szCameraModes[0]); sprintf(szCurrentModifier, szModifierModes[0]); sprintf(szPlayer1ModifierCharacter, szCharacters[0]); @@ -859,9 +857,8 @@ void MK11Menu::Draw() void MK11Menu::Process() { + m_bIsFocused = IsWindowFocused(); UpdateControls(); - if (m_bFreeCamMouseControl) - UpdateMouse(); } void MK11Menu::UpdateControls() @@ -923,30 +920,67 @@ void MK11Menu::UpdateControls() } -void MK11Menu::UpdateMouse() +void MK11Menu::UpdateFreecam() { - if (m_bIsActive) return; + if (TheMenu->m_bFreeCam) + { + if (TheCamera) + { + FVector fwd = TheCamera->GetMatrix().GetForward(); + FVector strafe = TheCamera->GetMatrix().GetRight(); + FVector up = TheCamera->GetMatrix().GetUp(); - GetCursorPos(&curMouse); - mouseSpeedX = curMouse.x - orgMouse.x; - mouseSpeedY = curMouse.y - orgMouse.y; + // forward + if (GetAsyncKeyState(SettingsMgr->iFreeCameraKeyXPlus)) + TheMenu->camPos += fwd * TheMenu->m_fFreeCameraSpeed * 1; - if (m_bIsFocused) - { - if (TheMenu->m_bFreeCam) - { - int newVal = TheMenu->camRot.Yaw; - newVal += mouseSpeedX / mouseSens; - TheMenu->camRot.Yaw = newVal; + if (GetAsyncKeyState(SettingsMgr->iFreeCameraKeyXMinus)) + TheMenu->camPos += fwd * TheMenu->m_fFreeCameraSpeed * -1; + + // strafe + + if (GetAsyncKeyState(SettingsMgr->iFreeCameraKeyYPlus)) + TheMenu->camPos += strafe * TheMenu->m_fFreeCameraSpeed * 1; + if (GetAsyncKeyState(SettingsMgr->iFreeCameraKeyYMinus)) + TheMenu->camPos += strafe * TheMenu->m_fFreeCameraSpeed * -1; + + // up - int newValY = TheMenu->camRot.Pitch; + if (GetAsyncKeyState(SettingsMgr->iFreeCameraKeyZPlus)) + TheMenu->camPos += up * TheMenu->m_fFreeCameraSpeed * 1; + if (GetAsyncKeyState(SettingsMgr->iFreeCameraKeyZMinus)) + TheMenu->camPos += up * TheMenu->m_fFreeCameraSpeed * -1; - if (m_bFreeCamMouseInvertY) mouseSpeedY *= -1; + if (GetAsyncKeyState(SettingsMgr->iFreeCameraKeyYawMinus)) + TheMenu->camRot.Yaw -= TheMenu->m_nFreeCameraRotationSpeed; + if (GetAsyncKeyState(SettingsMgr->iFreeCameraKeyYawPlus)) + TheMenu->camRot.Yaw += TheMenu->m_nFreeCameraRotationSpeed; - newValY += mouseSpeedY / mouseSens; - TheMenu->camRot.Pitch = newValY; + if (GetAsyncKeyState(SettingsMgr->iFreeCameraKeyRollMinus)) + TheMenu->camRot.Roll -= TheMenu->m_nFreeCameraRotationSpeed; + if (GetAsyncKeyState(SettingsMgr->iFreeCameraKeyRollPlus)) + TheMenu->camRot.Roll += TheMenu->m_nFreeCameraRotationSpeed; + + if (GetAsyncKeyState(SettingsMgr->iFreeCameraKeyPitchMinus)) + TheMenu->camRot.Pitch -= TheMenu->m_nFreeCameraRotationSpeed; + if (GetAsyncKeyState(SettingsMgr->iFreeCameraKeyPitchPlus)) + TheMenu->camRot.Pitch += TheMenu->m_nFreeCameraRotationSpeed; + + if (GetAsyncKeyState(SettingsMgr->iFreeCameraKeyFOVMinus)) + TheMenu->camFov -= 1.0f; + if (GetAsyncKeyState(SettingsMgr->iFreeCameraKeyFOVPlus)) + TheMenu->camFov += 1.0f; + + // mouse + { + if (!TheMenu->m_bIsActive && TheMenu->m_bMouseControl) + { + TheMenu->camRot.Pitch += eMouse::GetDeltaY(); + TheMenu->camRot.Yaw += eMouse::GetDeltaX(); + } + } } } @@ -1382,16 +1416,7 @@ void MK11Menu::DrawCameraTab() ImGui::InputFloat("Freecam Speed", &m_fFreeCameraSpeed); ImGui::InputInt("Freecam Rotation Speed", &m_nFreeCameraRotationSpeed); - - ImGui::Separator(); - ImGui::Checkbox("Mouse Control", &m_bFreeCamMouseControl); - - if (m_bFreeCamMouseControl) - { - ImGui::SameLine(); ImGui::TextColored(ImVec4(1.f, 0.3f, 0.3f, 1.f), "This feature is not yet finished!"); - ImGui::Checkbox("Invert Y", &m_bFreeCamMouseInvertY); - ImGui::SliderInt("Mouse Smoothness", &mouseSens, 1, 15); - } + ImGui::Checkbox("Mouse Control", &m_bMouseControl); } @@ -1566,8 +1591,8 @@ void MK11Menu::DrawCheatsTab() void MK11Menu::DrawKryptTab() { - ImGui::Text("Make sure you match the character class! It's trial & error if a character doesn't work."); - ImGui::Text("Normal characters use Base class, while Sektor/Cyrax use NPCs. Some might not work at all."); + ImGui::TextWrapped("Make sure you match the character class! It's trial & error if a character doesn't work."); + ImGui::TextWrapped("Normal characters use Base class, while Sektor/Cyrax use NPCs. Some might not work at all."); ImGui::Separator(); ImGui::Checkbox("Change Krypt Character", &m_bKryptModifier); @@ -1588,7 +1613,7 @@ void MK11Menu::DrawKryptTab() if (ImGui::BeginCombo("Krypt Character", szCurrentKryptCharacter)) { - for (int n = 0; n < IM_ARRAYSIZE(szCharacters); n++) + for (int n = 0; n < IM_ARRAYSIZE(szKryptCharacters); n++) { bool is_selected = (szCurrentKryptCharacter == szKryptCharacters[n]); if (ImGui::Selectable(szKryptCharacters[n], is_selected)) @@ -1682,6 +1707,15 @@ void MK11Menu::DrawScriptTab() RunLastScript(); } + static char szScriptVariable[256] = {}; + static int64 test; + ImGui::InputText("Script Variable", szScriptVariable, sizeof(szScriptVariable)); + if (ImGui::Button("Get Var Ptr")) + { + test = GetScriptVar(m_pScript, szScriptVariable); + std::cout << std::hex << test << std::endl; + } + } else { @@ -1712,13 +1746,15 @@ void MK11Menu::DrawSettings() static const char* settingNames[] = { "Menu", "INI", - "Keys" + "Keys", + "Mouse" }; enum eSettings { MENU, INI, KEYS, + MOUSE }; ImGui::BeginChild("##settings", { 12 * ImGui::GetFontSize(), 0 }, true); @@ -1742,7 +1778,9 @@ void MK11Menu::DrawSettings() case MENU: ImGui::TextWrapped("All user settings are saved to mk11hook_user.ini."); ImGui::Text("Menu Scale"); + ImGui::PushItemWidth(-FLT_MIN); ImGui::InputFloat("", &SettingsMgr->fMenuScale); + ImGui::PopItemWidth(); break; case INI: ImGui::TextWrapped("These settings control MK11Hook.ini options. Any changes require game restart to take effect."); @@ -1807,6 +1845,15 @@ void MK11Menu::DrawSettings() } break; + case MOUSE: + ImGui::TextWrapped("All user settings are saved to mk11hook_user.ini."); + ImGui::Text("Sensitivity"); + ImGui::PushItemWidth(-FLT_MIN); + ImGui::SliderInt("", &SettingsMgr->mouse.sens, 1, 50); + ImGui::PopItemWidth(); + ImGui::Checkbox("Invert X", &SettingsMgr->mouse.invert_x); + ImGui::Checkbox("Invert Y", &SettingsMgr->mouse.invert_y); + break; default: break; } @@ -1954,10 +2001,12 @@ void MK11Menu::DrawDebug() ImGui::PopStyleVar(1); ImGui::Text("MK11Hook %s Debug (%.2f FPS)", MK11HOOK_VERSION, ImGui::GetIO().Framerate); ImGui::Text(""); - ImGui::Text("Player 1 Object: 0x%X Info: 0x%X",GetObj(PLAYER1), GetInfo(PLAYER1)); - ImGui::Text("Player 2 Object: 0x%X Info: 0x%X", GetObj(PLAYER2), GetInfo(PLAYER2)); - ImGui::Text("P1: %s", GetCharacterName(PLAYER1)); - ImGui::Text("P2: %s", GetCharacterName(PLAYER2)); + ImGui::Text("Player 1 Object: 0x%p Info: 0x%p",GetObj(PLAYER1), GetInfo(PLAYER1)); + ImGui::Text("Player 2 Object: 0x%p Info: 0x%p", GetObj(PLAYER2), GetInfo(PLAYER2)); + if (GetInfo(PLAYER1)->pad) + ImGui::Text("P1: %s Hits: %d %d Button: %d", GetCharacterName(PLAYER1), GetInfo(PLAYER1)->GetHits().hits, GetInfo(PLAYER1)->GetHits().airHits, GetInfo(PLAYER1)->pad->buttons.id); + if (GetInfo(PLAYER2)->pad) + ImGui::Text("P2: %s Hits: %d %d Button: %d", GetCharacterName(PLAYER2), GetInfo(PLAYER2)->GetHits().hits, GetInfo(PLAYER2)->GetHits().airHits, GetInfo(PLAYER2)->pad->buttons.id); ImGui::End(); } #endif @@ -2091,3 +2140,11 @@ char * GetMK11HookVersion() sprintf(buffer, "MK11Hook by ermaccer (%s)", MK11HOOK_VERSION); return buffer; } + +bool IsWindowFocused() +{ + if (eDirectX11Hook::ms_bInit) + return GetForegroundWindow() == eDirectX11Hook::ms_hWindow; + + return false; +} diff --git a/MK11Hook/code/mk11menu.h b/MK11Hook/code/mk11menu.h index 72621f5..01314a3 100644 --- a/MK11Hook/code/mk11menu.h +++ b/MK11Hook/code/mk11menu.h @@ -58,8 +58,6 @@ class MK11Menu { bool m_bCustomCameraPos = false; bool m_bCustomCameraRot = false; bool m_bCustomCameraFOV = false; - bool m_bFreeCamMouseControl = false; - bool m_bFreeCamMouseInvertY = false; bool m_bFreeCam = false; bool m_bCustomCameras = false; bool m_bDontFlipCamera = false; @@ -69,6 +67,8 @@ class MK11Menu { bool m_bStageModifier = false; bool m_bDisableHUD = false; bool m_bAutoHideHUD = false; + bool m_bMouseControl = false; + // cheats bool m_bInfiniteHealthP1 = false; bool m_bInfiniteHealthP2 = false; @@ -175,22 +175,13 @@ class MK11Menu { FVector kryptPos; - // cam mouse - - POINT orgMouse; - POINT curMouse; - int mouseSpeedX = 0; - int mouseSpeedY = 0; - int mouseSens = 5; - std::vector m_vKeyBinds; void Initialize(); void Draw(); void Process(); void UpdateControls(); - void UpdateMouse(); - + void UpdateFreecam(); void DrawCharacterTab(); void DrawStageTab(); @@ -227,3 +218,5 @@ char* GetMK11HookVersion(); extern MK11Menu* TheMenu; +bool IsWindowFocused(); + diff --git a/MK11Hook/code/mkcamera.cpp b/MK11Hook/code/mkcamera.cpp index db58e4a..6fcba6a 100644 --- a/MK11Hook/code/mkcamera.cpp +++ b/MK11Hook/code/mkcamera.cpp @@ -275,4 +275,11 @@ void MKCamera::HookedSetRotation(FRotator * rot) } +FMatrix MKCamera::GetMatrix() +{ + FRotator rot = camRot; + FMatrix mat(&rot); + return mat; +} + diff --git a/MK11Hook/code/mkcamera.h b/MK11Hook/code/mkcamera.h index 628acb0..84e9268 100644 --- a/MK11Hook/code/mkcamera.h +++ b/MK11Hook/code/mkcamera.h @@ -1,7 +1,7 @@ #pragma once #include "mk11.h" +#include "unreal/FMatrix.h" // generic layer for other plugins too - class MKCamera { private: char pad[0x6BC]; @@ -16,8 +16,7 @@ class MKCamera { void HookedSetPosition(FVector* pos); void HookedSetRotation(FRotator* rot); - - + FMatrix GetMatrix(); }; extern MKCamera* TheCamera; \ No newline at end of file diff --git a/MK11Hook/code/plugin/ePluginInterface.cpp b/MK11Hook/code/plugin/ePluginInterface.cpp new file mode 100644 index 0000000..d785c18 --- /dev/null +++ b/MK11Hook/code/plugin/ePluginInterface.cpp @@ -0,0 +1,26 @@ +#include "ePluginInterface.h" +#include + +ePlugin::ePlugin() +{ + sprintf(m_szPluginName, "Unknown"); + m_nProjectID = PROJECT_UNKNOWN; + m_bIsValid = false; + m_pPluginFunc = nullptr; + m_pHMod = 0; +} + +void ePlugin::Shutdown() +{ + m_pPluginFunc = nullptr; + m_bIsValid = false; + FreeModule(m_pHMod); +} + +void ePluginInterface::LoadPlugins() +{ +} + +void ePluginInterface::UnloadPlugins() +{ +} diff --git a/MK11Hook/code/plugin/ePluginInterface.h b/MK11Hook/code/plugin/ePluginInterface.h new file mode 100644 index 0000000..90a8fbd --- /dev/null +++ b/MK11Hook/code/plugin/ePluginInterface.h @@ -0,0 +1,36 @@ +#pragma once +#include +#include + +enum eProjectID { + PROJECT_UNKNOWN = -1, + PROJECT_MK9HOOK, + PROJECT_MKXHOOK, + PROJECT_MK11HOOK, + PROJECT_INJHOOK, + PROJECT_I2HOOK +}; + + +class ePlugin { + char m_szPluginName[128]; + int m_nProjectID; + + bool m_bIsValid; + + void (*m_pPluginFunc)(); + + HMODULE m_pHMod; + + ePlugin(); + void Shutdown(); +}; + + +class ePluginInterface { +public: + static std::vector m_pPlugins; + + static void LoadPlugins(); + static void UnloadPlugins(); +}; \ No newline at end of file diff --git a/MK11Hook/code/unreal/FMath.cpp b/MK11Hook/code/unreal/FMath.cpp new file mode 100644 index 0000000..745f65d --- /dev/null +++ b/MK11Hook/code/unreal/FMath.cpp @@ -0,0 +1,13 @@ +#include "FMath.h" +#include + +FMath GMath; + +FMath::FMath() +{ + for (int i = 0; i < 16384; ++i) + { + float value = i * 2.0 * 3.141592653589793 / 16384.0; + this->TrigFLOAT[i] = sinf(value); + } +} diff --git a/MK11Hook/code/unreal/FMath.h b/MK11Hook/code/unreal/FMath.h new file mode 100644 index 0000000..f559e06 --- /dev/null +++ b/MK11Hook/code/unreal/FMath.h @@ -0,0 +1,11 @@ +#pragma once + + +class FMath { +public: + float TrigFLOAT[16384]; + + FMath(); +}; + +extern FMath GMath; \ No newline at end of file diff --git a/MK11Hook/code/unreal/FMatrix.cpp b/MK11Hook/code/unreal/FMatrix.cpp new file mode 100644 index 0000000..68ecc95 --- /dev/null +++ b/MK11Hook/code/unreal/FMatrix.cpp @@ -0,0 +1,71 @@ +#include "FMatrix.h" +#include "..\mk11.h" +#include "FMath.h" + +FMatrix::FMatrix() +{ +} + +FMatrix::FMatrix(FRotator* Rot) +{ + float v2; + float v3; + float v4; + float v5; + float v6; + float v7; + float v8; + float v9; + float CR; + float v12; + float SY; + float CY; + float CP; + float SR; + + SR = GMath.TrigFLOAT[(Rot->Roll >> 2) & 0x3FFF]; + v12 = GMath.TrigFLOAT[(Rot->Pitch >> 2) & 0x3FFF]; + SY = GMath.TrigFLOAT[(Rot->Yaw >> 2) & 0x3FFF]; + CR = GMath.TrigFLOAT[((Rot->Roll + 0x4000) >> 2) & 0x3FFF]; + CP = GMath.TrigFLOAT[((Rot->Pitch + 0x4000) >> 2) & 0x3FFF]; + CY = GMath.TrigFLOAT[((Rot->Yaw + 0x4000) >> 2) & 0x3FFF]; + v2 = CP * CY; + this->M[0][0] = v2; + v3 = CP * SY; + this->M[0][1] = v3; + this->M[0][2] = v12; + this->M[0][3] = 0.0f; + v4 = SR * v12 * CY - CR * SY; + this->M[1][0] = v4; + v5 = SR * v12 * SY + CR * CY; + this->M[1][1] = v5; + v6 = (-0.0 - SR) * CP; + this->M[1][2] = v6; + this->M[1][3] = 0.0f; + v7 = -0.0 - (CR * v12 * CY + SR * SY); + this->M[2][0] = v7; + v8 = CY * SR - CR * v12 * SY; + this->M[2][1] = v8; + v9 = CR * CP; + this->M[2][2] = v9; + this->M[2][3] = 0.0f; + this->M[3][0] = 0.0f; + this->M[3][1] = 0.0f; + this->M[3][2] = 0.0f; + this->M[3][3] = 1.0f; +} + +FVector FMatrix::GetRight() +{ + return { M[1][0], M[1][1],M[1][2] }; +} + +FVector FMatrix::GetForward() +{ + return { M[0][0], M[0][1],M[0][2] }; +} + +FVector FMatrix::GetUp() +{ + return { M[2][0], M[2][1],M[2][2] }; +} \ No newline at end of file diff --git a/MK11Hook/code/unreal/FMatrix.h b/MK11Hook/code/unreal/FMatrix.h new file mode 100644 index 0000000..a07d3f5 --- /dev/null +++ b/MK11Hook/code/unreal/FMatrix.h @@ -0,0 +1,15 @@ +#pragma once +#include "FRotator.h" +#include "FVector.h" + +class FMatrix { +public: + float M[4][4] = {}; + + FMatrix(); + FMatrix(FRotator*); + + FVector GetRight(); + FVector GetForward(); + FVector GetUp(); +}; \ No newline at end of file diff --git a/MK11Hook/code/unreal/FQuat.h b/MK11Hook/code/unreal/FQuat.h new file mode 100644 index 0000000..a753e44 --- /dev/null +++ b/MK11Hook/code/unreal/FQuat.h @@ -0,0 +1,8 @@ +#pragma once +struct FQuat +{ + float X; + float Y; + float Z; + float W; +}; diff --git a/MK11Hook/code/unreal/FRotator.h b/MK11Hook/code/unreal/FRotator.h new file mode 100644 index 0000000..ee97cf0 --- /dev/null +++ b/MK11Hook/code/unreal/FRotator.h @@ -0,0 +1,7 @@ +#pragma once + +struct FRotator { + int Pitch; + int Yaw; + int Roll; +}; \ No newline at end of file diff --git a/MK11Hook/code/unreal/FVector.h b/MK11Hook/code/unreal/FVector.h new file mode 100644 index 0000000..858b482 --- /dev/null +++ b/MK11Hook/code/unreal/FVector.h @@ -0,0 +1,79 @@ +#pragma once +#include + +class FVector +{ +public: + float X,Y,Z; + FVector(void) {} + FVector(float a, float b, float c) + { + X = a; + Y = b; + Z = c; + } + + const FVector &operator+=(FVector const &right) { + X += right.X; + Y += right.Y; + Z += right.Z; + return *this; + } + + const FVector &operator+=(float const &right) { + X += right; + Y += right; + Z += right; + return *this; + } + + const FVector &operator-=(FVector const &right) { + X -= right.X; + Y -= right.Y; + Z -= right.Z; + return *this; + } + + const FVector &operator*=(float right) { + X *= right; + Y *= right; + Z *= right; + return *this; + } + + const FVector &operator/=(float right) { + X /= right; + Y /= right; + Z /= right; + return *this; + } + + FVector operator-() const { + return FVector(-X, -Y, -Z); + } +}; + +inline FVector operator+(const FVector &left, const FVector &right) +{ + return FVector(left.X + right.X, left.Y + right.Y, left.Z + right.Z); +} + +inline FVector operator-(const FVector &left, const FVector &right) +{ + return FVector(left.X - right.X, left.Y - right.Y, left.Z - right.Z); +} + +inline FVector operator*(const FVector &left, float right) +{ + return FVector(left.X * right, left.Y * right, left.Z * right); +} + +inline FVector operator*(float left, const FVector &right) +{ + return FVector(left * right.X, left * right.Y, left * right.Z); +} + +inline FVector operator/(const FVector &left, float right) +{ + return FVector(left.X / right, left.Y / right, left.Z / right); +} diff --git a/MK11Hook/dllmain.cpp b/MK11Hook/dllmain.cpp index 49fcdcf..ea02dbf 100644 --- a/MK11Hook/dllmain.cpp +++ b/MK11Hook/dllmain.cpp @@ -16,12 +16,11 @@ #include using namespace Memory::VP; - +int64 __fastcall GenericTrue2Return() { return 2; } int64 __fastcall GenericTrueReturn() { return 1; } int64 __fastcall GenericFalseReturn() { return 0; } void __fastcall GenericDummy() { } - void OnInitializeHook() { if (SettingsMgr->bEnableConsoleWindow) @@ -38,7 +37,7 @@ void OnInitializeHook() Trampoline* tramp = Trampoline::MakeTrampoline(GetModuleHandle(nullptr)); InjectHook(_addr(0x14092BC93), tramp->Jump(MK11Hooks::HookProcessStuff)); InjectHook(_addr(0x14090D3B3), tramp->Jump(MK11Hooks::HookStartupFightRecording)); - + InjectHook(_addr(0x14090E4D8), tramp->Jump(MK11Hooks::HookPreFightStart)); Nop(_addr(0x1419A88F3), 7); Nop(_addr(0x1419A8903), 8); diff --git a/MK11Hook/eDirectX11Hook.cpp b/MK11Hook/eDirectX11Hook.cpp index eb28764..1d426b4 100644 --- a/MK11Hook/eDirectX11Hook.cpp +++ b/MK11Hook/eDirectX11Hook.cpp @@ -147,7 +147,7 @@ void eDirectX11Hook::InitImGui() ImGui::CreateContext(); ImGui::GetIO().ConfigFlags = ImGuiConfigFlags_NoMouseCursorChange; ImGui::GetIO().ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; - + ImGui::GetIO().ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; ImGui_ImplWin32_Init(ms_hWindow); ImGui_ImplDX11_Init(pDevice, pContext); if (SettingsMgr->bEnableGamepadSupport)