Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ermaccer committed May 8, 2021
1 parent 6531f64 commit 705faaa
Show file tree
Hide file tree
Showing 11 changed files with 372 additions and 60 deletions.
Binary file modified MK11Hook/MK11Hook.aps
Binary file not shown.
Binary file modified MK11Hook/MK11Hook.rc
Binary file not shown.
2 changes: 2 additions & 0 deletions MK11Hook/MK11Hook.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="code\eNotifManager.h" />
<ClInclude Include="code\eSettingsManager.h" />
<ClInclude Include="code\mk10utils.h" />
<ClInclude Include="code\mk11.h" />
Expand Down Expand Up @@ -196,6 +197,7 @@
<ClInclude Include="utils\Trampoline.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="code\eNotifManager.cpp" />
<ClCompile Include="code\eSettingsManager.cpp" />
<ClCompile Include="code\mk10utils.cpp" />
<ClCompile Include="code\mk11.cpp" />
Expand Down
6 changes: 6 additions & 0 deletions MK11Hook/MK11Hook.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="code\eNotifManager.h">
<Filter>Header Files\code</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp">
Expand Down Expand Up @@ -188,6 +191,9 @@
<ClCompile Include="dllmain.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="code\eNotifManager.cpp">
<Filter>Header Files\code</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="MK11Hook.rc">
Expand Down
46 changes: 46 additions & 0 deletions MK11Hook/code/eNotifManager.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include "eNotifManager.h"
#include <iostream>
#include <Windows.h>
#include "..\imgui\imgui.h"

eNotificationManager* Notifications = new eNotificationManager();

void eNotificationManager::Init()
{
m_bIsNotificationActive = false;
m_tTimer = GetTickCount64();
}

void eNotificationManager::Update()
{
if (GetTickCount64() - m_tTimer <= m_nNotificationTime) return;
m_tTimer = GetTickCount64();

m_bIsNotificationActive = false;
}

void eNotificationManager::Draw()
{
if (m_bIsNotificationActive)
{
ImGui::SetNextWindowPos(ImVec2(5, 10));
ImGui::SetNextWindowSize(ImVec2(ImGui::GetIO().DisplaySize.x / 3, 0.0f));
ImGui::Begin("setup", nullptr, ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoInputs
| ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing);
ImGui::TextUnformatted(szMessageBuffer);
}
}

void eNotificationManager::SetNotificationTime(int time)
{
m_nNotificationTime = time;
}

void eNotificationManager::PushNotification(const char * format, ...)
{
va_list args;
va_start(args, format);
vsprintf(szMessageBuffer, format, args);
va_end(args);
m_bIsNotificationActive = true;
}
20 changes: 20 additions & 0 deletions MK11Hook/code/eNotifManager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#pragma once
#include "mk10utils.h"

class eNotificationManager {
public:
char szMessageBuffer[2048] = {};
bool m_bIsNotificationActive;
int m_nNotificationTime;
int64 m_tTimer;


void Init();

void Update();
void Draw();
void SetNotificationTime(int time);
void PushNotification(const char* format, ...);
};

extern eNotificationManager* Notifications;
77 changes: 72 additions & 5 deletions MK11Hook/code/mk11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
#include <Windows.h>
#include "mk11menu.h"
#include "eSettingsManager.h"
#include "eNotifManager.h"

void __fastcall MK11Hooks::HookProcessStuff()
{
TheMenu->Process();
Notifications->Update();

if (TheMenu->bSlowMotionEnabled)
MK11::SlowGameTimeForXTicks(TheMenu->fSlowMotionSpeed, 10);
Expand Down Expand Up @@ -130,6 +132,10 @@ void __fastcall MK11Hooks::HookStartupFightRecording(int64 eventID, int64 a2, in
TheMenu->bCustomCameraRot = false;
TheMenu->bYObtained = false;

if (TheMenu->bStageModifier)
MK11::SetStage(TheMenu->szStageModifierStage);


if (TheMenu->iCharacterModifierMode == MODIFIER_FIGHT)
{
if (TheMenu->bPlayer1ModifierEnabled)
Expand Down Expand Up @@ -560,6 +566,24 @@ void MK11Hooks::HookSetCharacter(int64 chr, char * name, int64 ptr, int64 unk)
MK11::SetCharacterMKX(PLAYER2, TheMenu->szPlayer2ModifierCharacter);
}


struct FString {
char* string;
};

void MK11Hooks::HookSetCharacterBloodColor(int64 obj, int64 name, FLinearColor * color)
{
printf("Decal [%x] color: R %f G %f B %f A %f\n", name, color->R, color->G, color->B, color->A);
MK11::SetCharacterDecalColor(obj, name, color);
}

void MK11Hooks::HookSetCharacterBloodColor2(int64 obj, int64 name, FVector * color)
{
printf("CALL2 - Decal [%x] color: R %f G %f B %f\n", name, color->X, color->Y, color->Z);
MK11::SetCharacterDecalColor2(obj, name, color);
}


void __fastcall MK11Hooks::UpdatePauseState(int64 ptr)
{

Expand All @@ -576,7 +600,6 @@ int64 MK11::GetCharacterObject(PLAYER_NUM plr)
int64 MK11::GetCharacterInfo(PLAYER_NUM plr)
{
int64 gameinfo = *(__int64*)_mk11addr(GFG_GAME_INFO);

return ((int64(__fastcall*)(int64, PLAYER_NUM))_mk11addr(0x14056F130))(gameinfo, plr);
}

Expand Down Expand Up @@ -659,10 +682,8 @@ void MK11::SetCharacterScale(PLAYER_NUM plr, FVector* 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);

Expand Down Expand Up @@ -716,7 +737,7 @@ void MK11::SetStage(const char * stage)
{
__int64 gameinfo = *(__int64*)_mk11addr(GFG_GAME_INFO);

((void(__fastcall*)(int64, const char*))_mk11addr(0x14049C360))(gameinfo, stage);
((void(__fastcall*)(int64, const char*))_mk11addr(0x140599CA0))(gameinfo, stage);
}

void MK11::SetCharacterLife(int64 obj, float life)
Expand All @@ -739,14 +760,27 @@ void MK11::SetCharacterEasyKB(int64 obj, int value)
((void(__fastcall*)(int64, int, int))_mk11addr(0x1404C71B0))(obj, value, 1);
}

void MK11::SetCharacterDecalColor(int64 obj, int64 name, FLinearColor * color)
{
((void(__fastcall*)(int64, int64, FLinearColor*))_mk11addr(0x1404CAB10))(obj, name, color);
}

void MK11::SetCharacterDecalColor2(int64 obj, int64 name, FVector * color)
{
((void(__fastcall*)(int64, int64, FVector*))_mk11addr(0x140DC1FD0))(obj, name, color);
}





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);
}

Expand Down Expand Up @@ -811,10 +845,43 @@ bool MK11::IsDLC(const char * name)
if (strcmp(name, szCharactersDLC[i]) == 0)
{
printf("MK11Hook::Info() | Cannot swap DLC characters!\n");
if (TheMenu->bPlayer1ModifierEnabled)
{
Notifications->SetNotificationTime(5500);
Notifications->PushNotification("Cannot swap DLC characters!");
}

return true;
}
}
}

return false;
}

void MK11::SetKryptCharacter(int64 ptr, char * name)
{
if (TheMenu->bChangeKryptCharacter)
name = TheMenu->szCurrentKryptCharacter;

printf("MK11Hook::SetKryptCharacter() | Loading character %s\n", name);

((void(__fastcall*)(int64, char*))_mk11addr(0x140821CD0))(ptr, name);
}

void MK11::SetKryptCharacterL(int64 ptr, char * name, int unk)
{
//if (TheMenu->bChangeKryptCharacter)
// name = 0;
((void(__fastcall*)(int64, char*, int))_mk11addr(0x141A69CC0))(ptr, name, unk);
}

void MK11::SetKryptCharacterClass(int64 ptr, char * name, int unk)
{
if (TheMenu->bChangeKryptCharacter)
name = TheMenu->szCurrentKryptCharacterClass;
((void(__fastcall*)(int64, char*, int))_mk11addr(0x142395E20))(ptr, name, unk);
}



37 changes: 29 additions & 8 deletions MK11Hook/code/mk11.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
#include "mk10utils.h"

#define GFG_GAME_INFO 0x14348ED10
#define PLAYER_STRUCTS 0x14348E558
#define GALLERY_INFO 0x14348A610


#define MK11HOOK_VERSION "0.3.5"
#define MK11HOOK_VERSION "0.4"

enum PLAYER_NUM
{
Expand All @@ -31,8 +31,8 @@ struct FVector
struct FLinearColor
{
float A;
float B;
float G;
float B;
float R;
};

Expand All @@ -56,8 +56,16 @@ struct character_info {
};


namespace MK11 {
enum eCharacterClass {
Base,
TestCharacters,
Generated,
NPCs,
TOTAL_CHARACTER_CLASSES
};


namespace MK11 {
int64 GetCharacterObject(PLAYER_NUM plr);
int64 GetCharacterInfo(PLAYER_NUM plr);

Expand All @@ -75,39 +83,50 @@ namespace MK11 {

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

void SetStage(const char* stage);
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);

void SlowGameTimeForXTicks(float speed, int ticks);
void SetSpeed(float speed);


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);
void SetCharacterDecalColor(int64 obj,int64 name, FLinearColor* color);
void SetCharacterDecalColor2(int64 obj, int64 name, FVector* color);



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);

void __fastcall ActorCamSetPos(int64 ptr, FVector* pos);
void __fastcall ActorCamSetRot(int64 ptr, FRotator* rot);
bool IsDLC(const char* name);

void SetKryptCharacter(int64 ptr, char* name);
void SetKryptCharacterL(int64 ptr, char* name, int unk);
void SetKryptCharacterClass(int64 ptr, char* name, int unk);


}

namespace MK11Hooks {
Expand All @@ -123,6 +142,8 @@ namespace MK11Hooks {

int64 __fastcall HookLoadCharacter(int64 ptr, char* name);
void HookSetCharacter(int64 chr, char* name, int64 ptr, int64 unk);
void HookSetCharacterBloodColor(int64 obj, int64 name, FLinearColor* color);
void HookSetCharacterBloodColor2(int64 obj, int64 name, FVector* color);
void __fastcall UpdatePauseState(int64 ptr);


Expand Down
Loading

0 comments on commit 705faaa

Please sign in to comment.