Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ermaccer committed May 6, 2021
1 parent fd26405 commit 6531f64
Show file tree
Hide file tree
Showing 10 changed files with 780 additions and 49 deletions.
Binary file modified MK11Hook/MK11Hook.aps
Binary file not shown.
Binary file modified MK11Hook/MK11Hook.rc
Binary file not shown.
7 changes: 6 additions & 1 deletion MK11Hook/MK11Hook.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@
<PreprocessorDefinitions>NDEBUG;_CRT_SECURE_NO_WARNINGS;MK11HOOK_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>false</ConformanceMode>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<LanguageStandard>stdcpplatest</LanguageStandard>
<LanguageStandard>stdcpp17</LanguageStandard>
<AdditionalOptions>
</AdditionalOptions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -155,6 +157,9 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalDependencies>crypt32.lib;secur32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<RandomizedBaseAddress>true</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions MK11Hook/code/eSettingsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ void eSettingsManager::Init()

iHookMenuOpenKey = ini.ReadInteger("Settings", "iHookMenuOpenKey", VK_F1);

bUseLegacyCharacterModifier = ini.ReadBoolean("Settings", "bUseLegacyCharacterModifier", false);

iFreeCameraKeyXPlus = ini.ReadInteger("Settings", "iFreeCameraKeyXPlus", 0);
iFreeCameraKeyXMinus = ini.ReadInteger("Settings", "iFreeCameraKeyXMinus", 0);

Expand Down
3 changes: 3 additions & 0 deletions MK11Hook/code/eSettingsManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ class eSettingsManager {
bool bGlobalCameraHook;

int iHookMenuOpenKey;

bool bUseLegacyCharacterModifier;

// free camera keys
int iFreeCameraKeyXPlus;
int iFreeCameraKeyXMinus;
Expand Down
137 changes: 102 additions & 35 deletions MK11Hook/code/mk11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ void __fastcall MK11Hooks::HookProcessStuff()
if (MK11::GetCharacterObject(PLAYER1))
MK11::SetCharacterLife(MK11::GetCharacterObject(PLAYER1), 0.0f);

}
if (TheMenu->b1HealthPlayer1)
{
if (MK11::GetCharacterObject(PLAYER1))
MK11::SetCharacterLife(MK11::GetCharacterObject(PLAYER1), 0.01f);

}
if (TheMenu->bInfiniteHealthPlayer2)
{
Expand All @@ -72,6 +78,11 @@ void __fastcall MK11Hooks::HookProcessStuff()
if (MK11::GetCharacterObject(PLAYER2))
MK11::SetCharacterLife(MK11::GetCharacterObject(PLAYER2), 0.0f);
}
if (TheMenu->b1HealthPlayer2)
{
if (MK11::GetCharacterObject(PLAYER2))
MK11::SetCharacterLife(MK11::GetCharacterObject(PLAYER2), 0.01f);
}
if (TheMenu->bFreeCameraMovement)
{
if (GetAsyncKeyState(SettingsMgr->iFreeCameraKeyXPlus))
Expand Down Expand Up @@ -119,6 +130,16 @@ void __fastcall MK11Hooks::HookStartupFightRecording(int64 eventID, int64 a2, in
TheMenu->bCustomCameraRot = false;
TheMenu->bYObtained = false;

if (TheMenu->iCharacterModifierMode == MODIFIER_FIGHT)
{
if (TheMenu->bPlayer1ModifierEnabled)
MK11::SetCharacterMKX(PLAYER1, TheMenu->szPlayer1ModifierCharacter);
if (TheMenu->bPlayer2ModifierEnabled)
MK11::SetCharacterMKX(PLAYER2, TheMenu->szPlayer2ModifierCharacter);
}


printf("MK11Hook::Info() | %s VS %s\n", MK11::GetCharacterName(PLAYER1), MK11::GetCharacterName(PLAYER2));

((void(__fastcall*)(int64,int64,int64,int64))_mk11addr(0x141159BE0))(eventID,a2,a3,a4);

Expand Down Expand Up @@ -490,49 +511,53 @@ void __fastcall MK11Hooks::HookActorCamSetRot(int64 ptr, FRotator * rot)

int64 __fastcall MK11Hooks::HookLoadCharacter(int64 ptr, char * name)
{
if (name)
if (TheMenu->iCharacterModifierMode == MODIFIER_SCREEN)
{
if (!MK11::IsDLC(name))
if (name)
{
if (TheMenu->bPlayer1ModifierEnabled)
if (!MK11::IsDLC(name))
{
if (ptr == MK11::GetPlayerData(PLAYER1))
if (TheMenu->bPlayer1ModifierEnabled)
{
if (ptr == MK11::GetPlayerData(PLAYER1))
{

char* original_name = name;
printf("MK11Hook::Info() | Setting Player %d as %s\n", MK11::GetPlayerIDFromData(ptr), TheMenu->szPlayer1ModifierCharacter);
strcpy((char*)(int64)&original_name[0], TheMenu->szPlayer1ModifierCharacter);
strcpy((char*)(int64)&original_name[0], original_name);

// crash fix
TheMenu->bPlayer1ModifierEnabled = false;
char* original_name = name;
printf("MK11Hook::Info() | Setting Player %d as %s\n", MK11::GetPlayerIDFromData(ptr), TheMenu->szPlayer1ModifierCharacter);
strcpy((char*)(int64)&original_name[0], TheMenu->szPlayer1ModifierCharacter);
strcpy((char*)(int64)&original_name[0], original_name);

// crash fix
TheMenu->bPlayer1ModifierEnabled = false;
}
}
}
if (TheMenu->bPlayer2ModifierEnabled)
{
if (ptr == MK11::GetPlayerData(PLAYER2))
if (TheMenu->bPlayer2ModifierEnabled)
{
char* original_name = name;
printf("MK11Hook::Info() | Setting Player %d as %s\n", MK11::GetPlayerIDFromData(ptr), TheMenu->szPlayer2ModifierCharacter);
strcpy((char*)(int64)&original_name[0], TheMenu->szPlayer2ModifierCharacter);
strcpy((char*)(int64)&original_name[0], original_name);
TheMenu->bPlayer2ModifierEnabled = false;
if (ptr == MK11::GetPlayerData(PLAYER2))
{
char* original_name = name;
printf("MK11Hook::Info() | Setting Player %d as %s\n", MK11::GetPlayerIDFromData(ptr), TheMenu->szPlayer2ModifierCharacter);
strcpy((char*)(int64)&original_name[0], TheMenu->szPlayer2ModifierCharacter);
strcpy((char*)(int64)&original_name[0], original_name);
TheMenu->bPlayer2ModifierEnabled = false;
}
}
}
}
}



}
return ((int64(__fastcall*)(int64, char*))_mk11addr(0x1408F8830))(ptr, name);

}

int64 __fastcall MK11Hooks::HookLoadAssets(char * name)
void MK11Hooks::HookSetCharacter(int64 chr, char * name, int64 ptr, int64 unk)
{
strcpy((char*)(int64)&name[0], "CHAR_Spawn");
printf("Loading %s", name);
return ((int64(__fastcall*)(char*))_mk11addr(0x1408F8620))(name);
MK11::SetCharacter(chr, name, ptr, unk);

if (TheMenu->bPlayer1ModifierEnabled)
MK11::SetCharacterMKX(PLAYER1, TheMenu->szPlayer1ModifierCharacter);
if (TheMenu->bPlayer2ModifierEnabled)
MK11::SetCharacterMKX(PLAYER2, TheMenu->szPlayer2ModifierCharacter);
}

void __fastcall MK11Hooks::UpdatePauseState(int64 ptr)
Expand All @@ -541,6 +566,8 @@ void __fastcall MK11Hooks::UpdatePauseState(int64 ptr)
}




int64 MK11::GetCharacterObject(PLAYER_NUM plr)
{
return ((int64(__fastcall*)(PLAYER_NUM))_mk11addr(0x1408F8B00))(plr);
Expand All @@ -566,14 +593,6 @@ PLAYER_NUM MK11::GetPlayerIDFromData(int64 data)
return PLAYER1;
}

void MK11::GetCharacterDefinition(PLAYER_NUM plr)
{
int64 object = GetCharacterObject(plr);
int64 ptr = *(int64*)(object + 216);



}

void MK11::GetCharacterPosition(FVector * vec, PLAYER_NUM plr)
{
Expand Down Expand Up @@ -638,6 +657,42 @@ void MK11::SetCharacterScale(PLAYER_NUM plr, FVector* scale)
((void(__fastcall*)(int64, FVector*))_mk11addr(0x141161920))(MK11::GetCharacterObject(plr), scale);
}

void MK11::SetCharacterMKX(PLAYER_NUM plr,char * name)
{

int64 ptr = GetCharacterInfo(plr);
int64 chr = (ptr + 216);
printf("Setting character %d as %s\n", plr, name);
MK11::SetCharacter(chr, name, 0,0);
((void(__fastcall*)(int64, const char*, int64, int64))_mk11addr(0x1405982F0))(chr,name,0,0);

}

void MK11::SetCharacter(int64 chr, char * name, int64 ptr, int64 unk)
{
((void(__fastcall*)(int64, const char*, int64, int64))_mk11addr(0x1405982F0))(chr, name, ptr, unk);

}

PLAYER_NUM MK11::GetIDFromData(int64 data)
{
int64 plr1 = GetCharacterInfo(PLAYER1);
int64 plr2 = GetCharacterInfo(PLAYER2);

if (data == *(int64*)(plr1 + 216))
return PLAYER1;
else
return PLAYER2;
}

char * MK11::GetCharacterName(PLAYER_NUM plr)
{
int64 info = GetCharacterInfo(plr);
character_info* chr = *(character_info**)(info + 216);

return chr->name;
}


void MK11::SetControlScheme(int64 obj, int preset)
{
Expand Down Expand Up @@ -684,6 +739,18 @@ void MK11::SetCharacterEasyKB(int64 obj, int value)
((void(__fastcall*)(int64, int, int))_mk11addr(0x1404C71B0))(obj, value, 1);
}

int64 MK11::GetCharacterMovie(int64 chr, int unk, char * buffer, int id)
{
return ((int64(__fastcall*)(int64, int, char*, int))_mk11addr(0x14056AC80))(chr, unk, buffer, id);
}

int64 MK11::GetCinemaByName(char * a1, char * a2, char * a3, int id)
{
printf("cin - %s | %s | %s | %d\n", a1, a2, a3, id);
return ((int64(__fastcall*)(char*, char*, char*, int))_mk11addr(0x140CEE9B0))(a1,a2,a3,id);
}


void __fastcall MK11::CamSetPos(int64 ptr, FVector * pos)
{
((void(__fastcall*)(int64, FVector*))_mk11addr(0x140E49F80))(ptr, pos);
Expand Down
28 changes: 21 additions & 7 deletions MK11Hook/code/mk11.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#define PLAYER_STRUCTS 0x14348E558


#define MK11HOOK_VERSION "0.3.3"
#define MK11HOOK_VERSION "0.3.5"

enum PLAYER_NUM
{
Expand Down Expand Up @@ -51,6 +51,11 @@ struct MKCameraObj {
};


struct character_info {
char name[16];
};


namespace MK11 {

int64 GetCharacterObject(PLAYER_NUM plr);
Expand All @@ -60,17 +65,22 @@ namespace MK11 {
int64 GetPlayerData(PLAYER_NUM plr);
PLAYER_NUM GetPlayerIDFromData(int64 data);


void GetCharacterDefinition(PLAYER_NUM plr);
void GetCharacterPosition(FVector* vec, PLAYER_NUM plr);

void HideHUD();
void ShowHUD();
void PauseGame(bool enable);


void SetCharacterSpeed(PLAYER_NUM plr, float speed);
void SetCharacterScale(PLAYER_NUM plr, FVector* scale);

// mkx recreation
void SetCharacterMKX(PLAYER_NUM plr, char* name);

void SetCharacter(int64 chr, char* name, int64 ptr, int64 unk);

PLAYER_NUM GetIDFromData(int64 data);
char* GetCharacterName(PLAYER_NUM plr);

// todo
void SetControlScheme(int64 obj, int preset);

Expand All @@ -81,11 +91,16 @@ namespace MK11 {
void SetStage(const char* stage);


void SetCharacterSpeed(PLAYER_NUM plr, float speed);
void SetCharacterScale(PLAYER_NUM plr, FVector* scale);
void SetCharacterLife(int64 obj, float life);
void SetCharacterMeter(int64 obj, float meter);
void SetCharacterEnergy(int64 obj,int type, float energy);
void SetCharacterEasyKB(int64 obj, int value);

int64 GetCharacterMovie(int64 chr, int unk, char* buffer, int id);
int64 GetCinemaByName(char* a1, char* a2, char* a3, int id);


void __fastcall CamSetPos(int64 ptr, FVector* pos);
void __fastcall CamSetRot(int64 ptr, FRotator* rot);
Expand All @@ -107,8 +122,7 @@ namespace MK11Hooks {
void __fastcall HookActorCamSetRot(int64 ptr, FRotator* rot);

int64 __fastcall HookLoadCharacter(int64 ptr, char* name);
int64 __fastcall HookLoadAssets(char* name);

void HookSetCharacter(int64 chr, char* name, int64 ptr, int64 unk);
void __fastcall UpdatePauseState(int64 ptr);


Expand Down
Loading

0 comments on commit 6531f64

Please sign in to comment.