Skip to content

Commit de2d16c

Browse files
committed
restore 1 health cheat, head perspective
1 parent 3a38dca commit de2d16c

19 files changed

+371
-27
lines changed

MKXHook/MKXHook.rc

0 Bytes
Binary file not shown.

MKXHook/MKXHook.vcxproj

+5
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@
144144
<ClInclude Include="code\MKCamera.h" />
145145
<ClInclude Include="code\MKCharacter.h" />
146146
<ClInclude Include="code\MKStructs.h" />
147+
<ClInclude Include="code\unreal\FMatrix.h" />
148+
<ClInclude Include="code\unreal\FName.h" />
149+
<ClInclude Include="code\unreal\FVector.h" />
147150
<ClInclude Include="eDirectX11Hook.h" />
148151
<ClInclude Include="font.h" />
149152
<ClInclude Include="framework.h" />
@@ -178,6 +181,8 @@
178181
<ClCompile Include="code\mk10utils.cpp" />
179182
<ClCompile Include="code\MKCamera.cpp" />
180183
<ClCompile Include="code\MKCharacter.cpp" />
184+
<ClCompile Include="code\unreal\FMatrix.cpp" />
185+
<ClCompile Include="code\unreal\FName.cpp" />
181186
<ClCompile Include="dllmain.cpp" />
182187
<ClCompile Include="eDirectX11Hook.cpp" />
183188
<ClCompile Include="imgui\imgui.cpp" />

MKXHook/MKXHook.vcxproj.filters

+21
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@
2828
<Filter Include="Header Files\kiero\minhook">
2929
<UniqueIdentifier>{77352413-b25e-4627-8400-7b72a4eb9a38}</UniqueIdentifier>
3030
</Filter>
31+
<Filter Include="Header Files\unreal">
32+
<UniqueIdentifier>{ff86ea59-5f68-4d99-82e0-9248a939e439}</UniqueIdentifier>
33+
</Filter>
34+
<Filter Include="Header Files\code\unreal">
35+
<UniqueIdentifier>{e924cbb8-2234-400e-8771-aa3b86107f43}</UniqueIdentifier>
36+
</Filter>
3137
</ItemGroup>
3238
<ItemGroup>
3339
<ClInclude Include="framework.h">
@@ -129,6 +135,15 @@
129135
<ClInclude Include="code\eGamepadManager.h">
130136
<Filter>Header Files\code</Filter>
131137
</ClInclude>
138+
<ClInclude Include="code\unreal\FName.h">
139+
<Filter>Header Files\code\unreal</Filter>
140+
</ClInclude>
141+
<ClInclude Include="code\unreal\FMatrix.h">
142+
<Filter>Header Files\code\unreal</Filter>
143+
</ClInclude>
144+
<ClInclude Include="code\unreal\FVector.h">
145+
<Filter>Header Files\code\unreal</Filter>
146+
</ClInclude>
132147
</ItemGroup>
133148
<ItemGroup>
134149
<ClCompile Include="dllmain.cpp">
@@ -206,6 +221,12 @@
206221
<ClCompile Include="code\eGamepadManager.cpp">
207222
<Filter>Header Files\code</Filter>
208223
</ClCompile>
224+
<ClCompile Include="code\unreal\FName.cpp">
225+
<Filter>Header Files\code\unreal</Filter>
226+
</ClCompile>
227+
<ClCompile Include="code\unreal\FMatrix.cpp">
228+
<Filter>Header Files\code\unreal</Filter>
229+
</ClCompile>
209230
</ItemGroup>
210231
<ItemGroup>
211232
<ResourceCompile Include="MKXHook.rc">

MKXHook/MKXHook.vcxproj.user

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<PropertyGroup />
3+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
4+
<LocalDebuggerCommand>
5+
</LocalDebuggerCommand>
6+
<LocalDebuggerWorkingDirectory>
7+
</LocalDebuggerWorkingDirectory>
8+
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
9+
</PropertyGroup>
410
</Project>

MKXHook/code/MKCamera.cpp

+82-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "mkcamera.h"
22
#include "mk10menu.h"
33
#include <iostream>
4+
#include "MKCharacter.h"
45
MKCamera* TheCamera;
56

67
void MKCamera::SetPosition(FVector * pos)
@@ -45,14 +46,19 @@ void MKCamera::HookedSetPosition(FVector * pos)
4546
oneTime = pos->Y;
4647
TheMenu->m_bYObtained = true;
4748
}
49+
4850
if (TheMenu->m_bCustomCameras)
4951
{
5052
if (GetObj(PLAYER1) && GetObj(PLAYER2))
5153
{
5254
FVector plrPos;
5355
FVector p2;
54-
GetCharacterPosition(&plrPos, PLAYER1);
55-
GetCharacterPosition(&p2, PLAYER2);
56+
FVector eyePos[2];
57+
FVector middle;
58+
if (GetObj(PLAYER1))
59+
GetCharacterPosition(&plrPos, PLAYER1);
60+
if (GetObj(PLAYER2))
61+
GetCharacterPosition(&p2, PLAYER2);
5662
switch (TheMenu->m_nCurrentCustomCamera)
5763
{
5864
case CAMERA_3RDPERSON:
@@ -110,6 +116,35 @@ void MKCamera::HookedSetPosition(FVector * pos)
110116
pos->Z = 134.0f + plrPos.Z;
111117

112118

119+
TheMenu->camPos = *pos;
120+
break;
121+
case CAMERA_HEAD_TRACKING:
122+
if (TheMenu->m_bUsePlayerTwoAsTracker)
123+
{
124+
if (GetObj(PLAYER2))
125+
{
126+
GetObj(PLAYER2)->GetBonePos("LeftEye", &eyePos[0]);
127+
GetObj(PLAYER2)->GetBonePos("RightEye", &eyePos[1]);
128+
}
129+
}
130+
131+
else
132+
{
133+
if (GetObj(PLAYER1))
134+
{
135+
GetObj(PLAYER1)->GetBonePos("LeftEye", &eyePos[0]);
136+
GetObj(PLAYER1)->GetBonePos("RightEye", &eyePos[1]);
137+
}
138+
}
139+
140+
middle = (eyePos[0] + eyePos[1]) / 2.0;
141+
142+
143+
pos->X = middle.X + TheMenu->m_fAdjustCustomHeadCameraX;
144+
pos->Y = middle.Y;
145+
pos->Z = middle.Z + TheMenu->m_fAdjustCustomHeadCameraZ;
146+
147+
113148
TheMenu->camPos = *pos;
114149
break;
115150
}
@@ -131,20 +166,25 @@ void MKCamera::HookedSetPosition(FVector * pos)
131166

132167
void MKCamera::HookedSetRotation(FRotator * rot)
133168
{
169+
134170
if (TheMenu->m_bCustomCameras)
135171
{
136172
if (GetObj(PLAYER1) && GetObj(PLAYER2))
137173
{
138174
FVector p1, p2;
175+
FRotator headRot;
176+
if (GetObj(PLAYER1))
177+
GetCharacterPosition(&p1,PLAYER1);
178+
if (GetObj(PLAYER2))
179+
GetCharacterPosition(&p2, PLAYER2);
180+
139181
switch (TheMenu->m_nCurrentCustomCamera)
140182
{
141183
case CAMERA_3RDPERSON:
142184
rot->Pitch = -900;
143185
rot->Yaw = 16000;
144186
rot->Roll = 0;
145187
TheMenu->camRot = *rot;
146-
GetCharacterPosition(&p1, PLAYER1);
147-
GetCharacterPosition(&p2, PLAYER2);
148188

149189
if (p2.Y < p1.Y)
150190
{
@@ -159,8 +199,6 @@ void MKCamera::HookedSetRotation(FRotator * rot)
159199
rot->Yaw = 16000;
160200
rot->Roll = 0;
161201
TheMenu->camRot = *rot;
162-
GetCharacterPosition(&p1, PLAYER1);
163-
GetCharacterPosition(&p2, PLAYER2);
164202

165203
if (p2.Y < p1.Y)
166204
{
@@ -175,8 +213,6 @@ void MKCamera::HookedSetRotation(FRotator * rot)
175213
rot->Yaw = 16000;
176214
rot->Roll = 0;
177215
TheMenu->camRot = *rot;
178-
GetCharacterPosition(&p1, PLAYER1);
179-
GetCharacterPosition(&p2, PLAYER2);
180216

181217
if (p2.Y < p1.Y)
182218
{
@@ -190,14 +226,50 @@ void MKCamera::HookedSetRotation(FRotator * rot)
190226
rot->Yaw = 16000;
191227
rot->Roll = 0;
192228
TheMenu->camRot = *rot;
193-
GetCharacterPosition(&p1, PLAYER1);
194-
GetCharacterPosition(&p2, PLAYER2);
195229

196230
if (p2.Y < p1.Y)
197231
{
198232
rot->Yaw = -16000;
199233
}
200234

235+
TheMenu->camRot = *rot;
236+
break;
237+
case CAMERA_HEAD_TRACKING:
238+
if (TheMenu->m_bUsePlayerTwoAsTracker)
239+
{
240+
if (GetObj(PLAYER2))
241+
GetObj(PLAYER2)->GetBoneRot("Head", &headRot);
242+
}
243+
else
244+
{
245+
if (GetObj(PLAYER1))
246+
GetObj(PLAYER1)->GetBoneRot("Head", &headRot);
247+
}
248+
249+
rot->Pitch = headRot.Pitch + TheMenu->m_fAdjustCustomHeadCameraY;
250+
rot->Yaw = 16000 + headRot.Yaw;
251+
rot->Roll = headRot.Roll / 100;
252+
TheMenu->camRot = *rot;
253+
254+
if (TheMenu->m_bUsePlayerTwoAsTracker)
255+
{
256+
if (GetObj(PLAYER1))
257+
GetCharacterPosition(&p2, PLAYER1);
258+
if (GetObj(PLAYER2))
259+
GetCharacterPosition(&p1, PLAYER2);
260+
}
261+
else
262+
{
263+
if (GetObj(PLAYER1))
264+
GetCharacterPosition(&p1, PLAYER1);
265+
if (GetObj(PLAYER2))
266+
GetCharacterPosition(&p2, PLAYER2);
267+
}
268+
269+
if (p2.Y < p1.Y && !TheMenu->m_bDontFlipCamera)
270+
{
271+
rot->Yaw = -16000 - headRot.Yaw;
272+
}
201273
TheMenu->camRot = *rot;
202274
break;
203275
}

MKXHook/code/MKCamera.h

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#pragma once
22
#include "mk10.h"
3+
34
// generic layer for other plugins too
45
class MKCamera {
56
public:

MKXHook/code/MKCharacter.cpp

+33-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include "MKCharacter.h"
22
#include "mk10utils.h"
33
#include "mk10.h"
4+
#include "unreal/FName.h"
5+
#include "unreal/FMatrix.h"
46

57
void MKCharacter::SetLife(float life)
68
{
@@ -22,7 +24,36 @@ void MKCharacter::SetMeter(float value)
2224
((void(__fastcall*)(MKCharacter*, float))_addr(0x14055EC40))(this, value);
2325
}
2426

25-
bool MKCharacter::IsCrouching()
27+
void MKCharacter::ActivateHeadTracking()
2628
{
27-
return ((bool(__fastcall*)(MKCharacter*))_addr(0x1401BBDB0))(this);
29+
((void(__fastcall*)(MKCharacter*, float))_addr(0x140978DF0))(this, 0.5);
2830
}
31+
32+
void MKCharacter::KillHeadTracking()
33+
{
34+
((void(__fastcall*)(MKCharacter*, float))_addr(0x140978D80))(this, 0.5);
35+
}
36+
37+
void MKCharacter::SetBoneSize(const char * name, float size)
38+
{
39+
//
40+
((void(__fastcall*)(MKCharacter*, const char*, float))_addr(0x14097a4b0))(this, name, size);
41+
((void(__fastcall*)(MKCharacter*, const char*, float))_addr(0x14097A520))(this, name, size);
42+
}
43+
44+
void MKCharacter::GetBonePos(const char * name, FVector * pos)
45+
{
46+
if (!(*(int64*)this + 568))
47+
return;
48+
FName fname(name, FNAME_Add, 1);
49+
((void(__fastcall*)(MKCharacter*, FName*, FVector*))_addr(0x1401DAC10))(this, &fname, pos);
50+
}
51+
52+
void MKCharacter::GetBoneRot(const char * name, FRotator * rot)
53+
{
54+
FName fname(name, FNAME_Add, 1);
55+
FMatrix mat;
56+
((void(__fastcall*)(MKCharacter*, FName*, FMatrix*))_addr(0x1401D9AF0))(this, &fname, &mat);
57+
mat.Rotator(rot);
58+
}
59+

MKXHook/code/MKCharacter.h

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#pragma once
22
#include "MKStructs.h"
3+
#include "unreal/FVector.h"
34

45
// wrapper for old functions
56
class MKCharacter {
@@ -9,5 +10,11 @@ class MKCharacter {
910
void SetSpeed(float speed);
1011
void SetMeter(float value);
1112

12-
bool IsCrouching();
13+
void ActivateHeadTracking();
14+
void KillHeadTracking();
15+
16+
void SetBoneSize(const char* name, float size);
17+
18+
void GetBonePos(const char* name, FVector* pos);
19+
void GetBoneRot(const char* name, FRotator* rot);
1320
};

MKXHook/code/MKStructs.h

-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
#pragma once
22

3-
struct FVector
4-
{
5-
float X;
6-
float Y;
7-
float Z;
8-
};
93

104
struct FRotator
115
{

MKXHook/code/mk10.cpp

+14-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ void __fastcall MK10Hooks::HookProcessStuff()
129129
if (TheMenu->m_bSlowMotion)
130130
SlowGameTimeForXTicks(TheMenu->m_fSlowMotionSpeed, 10);
131131

132-
133132
if (TheMenu->m_bChangePlayerScale)
134133
{
135134
if (GetObj(PLAYER1))
@@ -158,8 +157,20 @@ void __fastcall MK10Hooks::HookProcessStuff()
158157
if (TheMenu->m_bInfiniteMeterP1)
159158
SetCharacterMeter(GetInfo(PLAYER1), 1.0f);
160159

160+
if (TheMenu->m_bDisableHeadTracking)
161+
{
162+
GetObj(PLAYER1)->KillHeadTracking();
163+
}
164+
165+
161166
if (TheMenu->m_bAutoHideHUD)
162167
HideHUD();
168+
169+
if (TheMenu->m_nCurrentCustomCamera == CAMERA_HEAD_TRACKING && TheMenu->m_bCustomCameras)
170+
{
171+
TheMenu->m_bDisableHeadTracking = true;
172+
}
173+
163174
}
164175
if (GetObj(PLAYER2))
165176
{
@@ -238,6 +249,8 @@ void __fastcall MK10Hooks::HookStartupFightRecording()
238249
TheMenu->m_bCustomCameraPos = false;
239250
TheMenu->m_bCustomCameraRot = false;
240251
TheMenu->m_bYObtained = false;
252+
TheMenu->m_bCustomCameras = false;
253+
241254
// recording call
242255
((void(__fastcall*)())_addr(0x1403924C0))();
243256

MKXHook/code/mk10.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
#pragma once
22
#include "mk10utils.h"
33
#include "MKCharacter.h"
4+
#include "unreal/FVector.h"
45

56
#define GFG_GAME_INFO 0x1430DBA00
67

78

8-
#define MKXHOOK_VERSION "0.5.7"
9+
#define MKXHOOK_VERSION "0.5.8"
910

1011
enum PLAYER_NUM
1112
{

0 commit comments

Comments
 (0)