From d8e2b3fc6493fddc823cf6d51d165b262326e127 Mon Sep 17 00:00:00 2001 From: ermaccer <40604575+ermaccer@users.noreply.github.com> Date: Fri, 15 Oct 2021 23:51:34 +0200 Subject: [PATCH] abilities update --- MK11Hook/MK11Hook.rc | Bin 4742 -> 4742 bytes MK11Hook/code/MKCharacter.cpp | 16 ++++ MK11Hook/code/MKCharacter.h | 5 ++ MK11Hook/code/mk11.cpp | 29 +++++++ MK11Hook/code/mk11.h | 2 +- MK11Hook/code/mk11menu.cpp | 147 +++++++++++++++++++++++++++------- MK11Hook/code/mk11menu.h | 6 ++ 7 files changed, 174 insertions(+), 31 deletions(-) diff --git a/MK11Hook/MK11Hook.rc b/MK11Hook/MK11Hook.rc index f1f86c563c567410376eab09b44a01dfcf17d694..4944c90d66d496b1abfe975f14367c8d88b82c1f 100644 GIT binary patch delta 29 lcmZouZByOQz{6;|xsm5NBcti$Mjq+O)A)ooPviT*3;>i<3H1N~ delta 29 lcmZouZByOQz{6;=xsm5NBcsXWMjq+O)A)ooPviT*3;>ic3G)B| diff --git a/MK11Hook/code/MKCharacter.cpp b/MK11Hook/code/MKCharacter.cpp index 4b7cbfd..8a94daa 100644 --- a/MK11Hook/code/MKCharacter.cpp +++ b/MK11Hook/code/MKCharacter.cpp @@ -25,6 +25,22 @@ void MKCharacter::SetEasyKrushingBlows(bool enable) ((void(__fastcall*)(MKCharacter*, int, int))_addr(0x1404C71E0))(this, enable, 1); } +int MKCharacter::GetAbility() +{ + return *(int*)(this + 64304); +} + +void MKCharacter::SetAbility(unsigned int id) +{ + *(int*)(this + 64304) = id; + //((void(__fastcall*)(MKCharacter*, unsigned int))_addr(0x1404C3340))(this, id); +} + +void MKCharacter::ClearAbilities() +{ + ((void(__fastcall*)(MKCharacter*))_addr(0x14048D8A0))(this); +} + CharacterInfo * MKCharacter::GetCharacterData(int unk) { CharacterInfo* inf = ((CharacterInfo*(__fastcall*)(MKCharacter*,int))_addr(0x140C0E130))(this, unk); diff --git a/MK11Hook/code/MKCharacter.h b/MK11Hook/code/MKCharacter.h index f708d82..091da46 100644 --- a/MK11Hook/code/MKCharacter.h +++ b/MK11Hook/code/MKCharacter.h @@ -50,8 +50,13 @@ class MKCharacter { void SetSpeed(float speed); void SetEasyKrushingBlows(bool enable); + int GetAbility(); + void SetAbility(unsigned int id); + void ClearAbilities(); + CharacterInfo* GetCharacterData(int unk); bool IsCrouching(); }; + diff --git a/MK11Hook/code/mk11.cpp b/MK11Hook/code/mk11.cpp index 55eae0f..987e8ce 100644 --- a/MK11Hook/code/mk11.cpp +++ b/MK11Hook/code/mk11.cpp @@ -58,6 +58,20 @@ void __fastcall MK11Hooks::HookProcessStuff() if (TheMenu->m_bAutoHideHUD) HideHUD(); + if (TheMenu->m_bP1CustomAbilities) + { + TheMenu->m_nP1Abilities = 0; + for (int i = 0; i < sizeof(TheMenu->m_P1Abilities) / sizeof(TheMenu->m_P1Abilities[0]); i++) + { + if (TheMenu->m_P1Abilities[i]) + { + TheMenu->m_nP1Abilities += pow(2, i); + } + } + GetObj(PLAYER1)->SetAbility(TheMenu->m_nP1Abilities); + } + + } @@ -82,6 +96,19 @@ void __fastcall MK11Hooks::HookProcessStuff() if (GetInfo(PLAYER2)) SetCharacterEnergy(GetInfo(PLAYER2), BAR_Defensive, 1000.0f); } + + if (TheMenu->m_bP1CustomAbilities) + { + TheMenu->m_nP2Abilities = 0; + for (int i = 0; i < sizeof(TheMenu->m_P2Abilities) / sizeof(TheMenu->m_P2Abilities[0]); i++) + { + if (TheMenu->m_P2Abilities[i]) + { + TheMenu->m_nP2Abilities += pow(2, i); + } + } + GetObj(PLAYER2)->SetAbility(TheMenu->m_nP2Abilities); + } } @@ -201,6 +228,7 @@ void __fastcall MK11Hooks::HookStartupFightRecording(int64 eventID, int64 a2, in + ((void(__fastcall*)(int64, int64, int64, int64))_addr(0x141159CB0))(eventID, a2, a3, a4); } @@ -208,6 +236,7 @@ void __fastcall MK11Hooks::HookStartupFightRecording(int64 eventID, int64 a2, in void MK11Hooks::PostLoadHook() { + ((int64(__fastcall*)())_addr(0x14090F7A0))(); } diff --git a/MK11Hook/code/mk11.h b/MK11Hook/code/mk11.h index 3a16f23..ee3b20a 100644 --- a/MK11Hook/code/mk11.h +++ b/MK11Hook/code/mk11.h @@ -6,7 +6,7 @@ #define GFG_GAME_INFO 0x1434990A0 -#define MK11HOOK_VERSION "0.4.4" +#define MK11HOOK_VERSION "0.4.5" enum PLAYER_NUM { diff --git a/MK11Hook/code/mk11menu.cpp b/MK11Hook/code/mk11menu.cpp index 7c6b14b..e9b5162 100644 --- a/MK11Hook/code/mk11menu.cpp +++ b/MK11Hook/code/mk11menu.cpp @@ -8,6 +8,7 @@ #include "..\utils\MemoryMgr.h" #include "eNotifManager.h" #include "MKCamera.h" +#include static int64 timer = GetTickCount64(); @@ -630,7 +631,6 @@ const char* szKryptCharacters[] = { "CHAR_Sektor", "CHAR_FireGod", "CHAR_Kronika", - // rest of the cast "CHAR_Baraka", "CHAR_Cage", @@ -748,10 +748,15 @@ void MK11Menu::Initialize() m_bTagAssist = false; m_bTagAssistP2 = false; m_bSlowMotion = false; + m_bP1CustomAbilities = false; + m_bP2CustomAbilities = false; + m_nCurrentCharModifier = MODIFIER_SCREEN; m_nFreeCameraRotationSpeed = 120; m_nCurrentCustomCamera = -1; + m_nP1Abilities = 0; + m_nP2Abilities = 0; mouseSpeedX = 0; mouseSpeedY = 0; mouseSens = 5; @@ -885,43 +890,124 @@ void MK11Menu::Draw() } if (ImGui::BeginTabItem("Modifiers")) { - ImGui::Checkbox("Player 1 Tag Assist Modifier", &m_bTagAssist); - - - if (ImGui::BeginCombo("Player 1 Tag Assist Character", szPlayer1TagAssistCharacter)) + if (ImGui::BeginTabBar("##modifiers")) { - for (int n = 0; n < IM_ARRAYSIZE(szKryptCharacters); n++) + if (ImGui::BeginTabItem("Tag Assists")) { - bool is_selected = (szPlayer1TagAssistCharacter == szKryptCharacters[n]); - if (ImGui::Selectable(szKryptCharacters[n], is_selected)) - sprintf(szPlayer1TagAssistCharacter, szKryptCharacters[n]); - if (is_selected) - ImGui::SetItemDefaultFocus(); + ImGui::Checkbox("Player 1 Tag Assist Modifier", &m_bTagAssist); - } - ImGui::EndCombo(); - } - ImGui::Separator(); - ImGui::Checkbox("Player 2 Tag Assist Modifier", &m_bTagAssistP2); + if (ImGui::BeginCombo("Player 1 Tag Assist Character", szPlayer1TagAssistCharacter)) + { + for (int n = 0; n < IM_ARRAYSIZE(szKryptCharacters); n++) + { + bool is_selected = (szPlayer1TagAssistCharacter == szKryptCharacters[n]); + if (ImGui::Selectable(szKryptCharacters[n], is_selected)) + sprintf(szPlayer1TagAssistCharacter, szKryptCharacters[n]); + if (is_selected) + ImGui::SetItemDefaultFocus(); + + } + ImGui::EndCombo(); + } + ImGui::Separator(); + ImGui::Checkbox("Player 2 Tag Assist Modifier", &m_bTagAssistP2); - if (ImGui::BeginCombo("Player 2 Tag Assist Character", szPlayer2TagAssistCharacter)) - { - for (int n = 0; n < IM_ARRAYSIZE(szKryptCharacters); n++) + + if (ImGui::BeginCombo("Player 2 Tag Assist Character", szPlayer2TagAssistCharacter)) + { + for (int n = 0; n < IM_ARRAYSIZE(szKryptCharacters); n++) + { + bool is_selected = (szPlayer2TagAssistCharacter == szKryptCharacters[n]); + if (ImGui::Selectable(szKryptCharacters[n], is_selected)) + sprintf(szPlayer2TagAssistCharacter, szKryptCharacters[n]); + if (is_selected) + ImGui::SetItemDefaultFocus(); + + } + ImGui::EndCombo(); + } + ImGui::Separator(); + + ImGui::Text("NOTE: Scorpion will not work unless previously loaded (eg. P2).\nIf you get load crashes enable modifier in-game then restart or rematch (when online)."); + ImGui::Text("Restart match when you toggle these in game!"); + ImGui::EndTabItem(); + } + if (ImGui::BeginTabItem("Abilities")) { - bool is_selected = (szPlayer2TagAssistCharacter == szKryptCharacters[n]); - if (ImGui::Selectable(szKryptCharacters[n], is_selected)) - sprintf(szPlayer2TagAssistCharacter, szKryptCharacters[n]); - if (is_selected) - ImGui::SetItemDefaultFocus(); + ImGui::Checkbox("Player 1 Custom Abilities", &m_bP1CustomAbilities); + ImGui::SameLine(); ShowHelpMarker("Set these on select screen! Changing these in game might make moves locked. Hold L SHIFT to view numeric value."); + ImGui::Separator(); + + for (int i = 0; i < sizeof(m_P1Abilities) / sizeof(m_P1Abilities[0]); i++) + { + int val = pow(2, i); + if (GetAsyncKeyState(VK_LSHIFT)) + sprintf(textBuffer, "Ability %d (%d)", i + 1, val); + else + sprintf(textBuffer, "Ability %d", i + 1); + + ImGui::Checkbox(textBuffer, &m_P1Abilities[i]); + + if (i % 2 == 0) + ImGui::SameLine(); + } + + + if (GetObj(PLAYER1)) + { + if (ImGui::Button("Get##p1")) + { + int abilities = GetObj(PLAYER1)->GetAbility(); + + for (int i = 0; i < sizeof(m_P1Abilities) / sizeof(m_P1Abilities[0]); i++) + { + int id = pow(2, i); + m_P1Abilities[i] = abilities & id; + } + } + + } + ImGui::Separator(); + ImGui::Checkbox("Player 2 Custom Abilities", &m_bP2CustomAbilities); + ImGui::Separator(); + + for (int i = 0; i < sizeof(m_P2Abilities) / sizeof(m_P2Abilities[0]); i++) + { + int val = pow(2, i); + if (GetAsyncKeyState(VK_LSHIFT)) + sprintf(textBuffer, "Ability %d (%d)##p2", i + 1, val); + else + sprintf(textBuffer, "Ability %d##p2", i + 1); + + ImGui::Checkbox(textBuffer, &m_P2Abilities[i]); + + if (i % 2 == 0) + ImGui::SameLine(); + } + + + if (GetObj(PLAYER2)) + { + if (ImGui::Button("Get##p2")) + { + int abilities = GetObj(PLAYER2)->GetAbility(); + + for (int i = 0; i < sizeof(m_P2Abilities) / sizeof(m_P2Abilities[0]); i++) + { + int id = pow(2, i); + m_P2Abilities[i] = abilities & id; + } + } + + } + + ImGui::EndTabItem(); } - ImGui::EndCombo(); - } - ImGui::Separator(); - ImGui::Text("NOTE: Scorpion will not work unless previously loaded (eg. P2).\nIf you get load crashes enable modifier in-game then restart or rematch (when online)."); - ImGui::Text("Restart match when you toggle these in game!"); + ImGui::EndTabBar(); + } ImGui::EndTabItem(); } if (ImGui::BeginTabItem("Player Control")) @@ -1212,8 +1298,9 @@ void MK11Menu::Draw() ImGui::SameLine(); ShowHelpMarker("Only default loadouts will be used. Do not toggle this option when models are on screen."); ImGui::EndTabItem(); - } + } + ImGui::EndTabBar(); ImGui::End(); } diff --git a/MK11Hook/code/mk11menu.h b/MK11Hook/code/mk11menu.h index 906633e..35dc42a 100644 --- a/MK11Hook/code/mk11menu.h +++ b/MK11Hook/code/mk11menu.h @@ -79,7 +79,13 @@ class MK11Menu { int m_nFreeCameraRotationSpeed; int m_nCurrentCustomCamera; int m_nCurrentCharModifier; + int m_nP1Abilities; + int m_nP2Abilities; + bool m_bP1CustomAbilities; + bool m_P1Abilities[20] = {}; + bool m_bP2CustomAbilities; + bool m_P2Abilities[20] = {}; FVector m_vP1Scale; FVector m_vP2Scale;