Skip to content

Commit

Permalink
tower modifiers, 9:16 camera, updated ability tab
Browse files Browse the repository at this point in the history
  • Loading branch information
ermaccer committed Dec 10, 2024
1 parent afd63c0 commit ec823ba
Show file tree
Hide file tree
Showing 23 changed files with 1,154 additions and 465 deletions.
Binary file modified MK11Hook/MK11Hook.rc
Binary file not shown.
1 change: 1 addition & 0 deletions MK11Hook/MK11Hook.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@
<ClCompile Include="plugin\API.cpp" />
<ClCompile Include="plugin\Hooks.cpp" />
<ClCompile Include="plugin\Menu.cpp" />
<ClCompile Include="plugin\ModifierList.cpp" />
<ClCompile Include="plugin\PatternSolver.cpp" />
<ClCompile Include="plugin\PluginInterface.cpp" />
<ClCompile Include="plugin\Settings.cpp" />
Expand Down
3 changes: 3 additions & 0 deletions MK11Hook/MK11Hook.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,9 @@
<ClCompile Include="mk\Scaleform.cpp">
<Filter>Header Files\mk</Filter>
</ClCompile>
<ClCompile Include="plugin\ModifierList.cpp">
<Filter>Header Files\plugin</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="MK11Hook.rc">
Expand Down
19 changes: 13 additions & 6 deletions MK11Hook/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void OnInitializeHook()
freopen("CONOUT$", "w", stderr);
}

eLog::Message(__FUNCTION__, "INFO: MK11Hook Begin!");
eLog::Message(__FUNCTION__, "INFO: MK11Hook (%s | %s) Begin!", MK11HOOK_VERSION, __DATE__);
eLog::Message(__FUNCTION__, "INFO: Is DirectX12 - %s", IsDX12() ? "Yes" : "No");

Notifications->Init();
Expand All @@ -71,25 +71,31 @@ void OnInitializeHook()
InjectHook(_pattern(PATID_CameraPositionHook), tramp->Jump(&MKCamera::HookedSetPosition));
InjectHook(_pattern(PATID_CameraRotationHook), tramp->Jump(&MKCamera::HookedSetRotation));

InjectHook(_pattern(PATID_SetSelectScreen_Hook), tramp->Jump(SetSelectScreen_Hook), PATCH_JUMP);
InjectHook(_pattern(PATID_SetSelectScreen_Hook), tramp->Jump(SetSelectScreen_Hook), HookType::Jump);
InjectHook(_pattern(PATID_SetCharacterLadder_Hook), tramp->Jump(SetCharacterLadder_Hook));

InjectHook(_pattern(PATID_ReadPropertyValue_Hook), tramp->Jump(ReadPropertyValue_Hook), PATCH_JUMP);
InjectHook(_pattern(PATID_ReadPropertyValue_Hook), tramp->Jump(ReadPropertyValue_Hook), HookType::Jump);
InjectHook(_pattern(PATID_SetProperty_Hook), tramp->Jump(SetProperty));


InjectHook(_pattern(PATID_Dispatch_Hook), tramp->Jump(Dispatch_Hook));

if (SettingsMgr->bMakeAllAbilities1Slot)
InjectHook(_pattern(PATID_1SlotAbilitiesHook), tramp->Jump(GenericTrueReturn), PATCH_JUMP);
InjectHook(_pattern(PATID_1SlotAbilitiesHook), tramp->Jump(GenericTrueReturn), HookType::Jump);

InjectHook(_pattern(PATID_SetKryptCharacter_Hook), tramp->Jump(SetKryptCharacter));
InjectHook(_pattern(PATID_SetKryptCharacterL_Hook), tramp->Jump(SetKryptCharacterL));
InjectHook(_pattern(PATID_SetKryptCharacterClass_Hook), tramp->Jump(SetKryptCharacterClass));


ReadCall(_pattern(PATID_ProcessDOFSettings), pProcessDOFSettings);
InjectHook(_pattern(PATID_ProcessDOFSettings), tramp->Jump(ProcessDOFSettings), PATCH_CALL);
InjectHook(_pattern(PATID_ProcessDOFSettings), tramp->Jump(ProcessDOFSettings));

ReadCall(_pattern(PATID_FightStartupAddModifiers), pPluginFightStartupAddModifiers);
InjectHook(_pattern(PATID_FightStartupAddModifiers), tramp->Jump(PluginFightStartupAddModifiers));

MH_CreateHook((void*)_pattern(PATID_FightStartupQueueModifiers), &PluginFightStartupQueueModifiers, (void**)&pPluginFightStartupQueueModifiers);
MH_EnableHook((void*)_pattern(PATID_FightStartupQueueModifiers));

//gamepad
if (SettingsMgr->bEnableGamepadSupport)
Expand All @@ -100,7 +106,7 @@ void OnInitializeHook()
uintptr_t xinput_addr = _pattern(PATID_XInputGetState_Hook);
xinput_addr += *(unsigned int*)(xinput_addr)+4;

InjectHook(xinput_addr, tramp->Jump(XInputGetState_Hook), PATCH_JUMP);
InjectHook(xinput_addr, tramp->Jump(XInputGetState_Hook), HookType::Jump);
}

}
Expand Down Expand Up @@ -169,6 +175,7 @@ extern "C"
{
__declspec(dllexport) void InitializeASI()
{
MH_Initialize();
eLog::Initialize();

if (ValidateGameVersion())
Expand Down
27 changes: 21 additions & 6 deletions MK11Hook/helper/eAbilityNames.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -620,30 +620,45 @@ void eAbiltityNames::Init()

}

eAbilityNameEntry eAbiltityNames::Get(const char * chrName)
eAbilityNameEntry* eAbiltityNames::Get(const char * chrName)
{
std::string input = chrName;
eAbilityNameEntry result;
std::string inName(chrName);
std::transform(inName.begin(), inName.end(), inName.begin(), std::tolower);

eAbilityNameEntry* result = nullptr;

for (unsigned int i = 0; i < m_aAbilityNames.size(); i++)
{
if (m_aAbilityNames[i].chr == input)
std::string abilityName(m_aAbilityNames[i].chr);
std::transform(abilityName.begin(), abilityName.end(), abilityName.begin(), std::tolower);

if (abilityName == inName)
{
result = m_aAbilityNames[i];
result = &m_aAbilityNames[i];
break;
}
}

return result;
}

int eAbiltityNames::GetAmount(eAbilityNameEntry* ability)
{
int amount = 0;
for (int i = 0; i < TOTAL_ABILITIES; i++)
if (ability->abNames[i])
amount++;

return amount;
}

eAbilityNameEntry::eAbilityNameEntry()
{
chr = "char_null";

for (int i = 0; i < TOTAL_ABILITIES; i++)
{
abNames[i] = "";
abNames[i] = nullptr;
}

}
3 changes: 2 additions & 1 deletion MK11Hook/helper/eAbilityNames.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class eAbiltityNames {
public:
static std::vector<eAbilityNameEntry> m_aAbilityNames;
static void Init();
static eAbilityNameEntry Get(const char* chrName);
static eAbilityNameEntry* Get(const char* chrName);
static int GetAmount(eAbilityNameEntry* ability);

};
19 changes: 19 additions & 0 deletions MK11Hook/mk/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,22 @@ void SetCharacterMKX(PLAYER_NUM plr, char* name)
CharacterDefinition* chr = (CharacterDefinition*)(ptr + 216);
chr->Set(name, 0, 0);
}

void SetCharacterAI(PLAYER_NUM plr, char* script, int level)
{
PlayerInfo* info = GetInfo(plr);

if (!info)
return;

info->MakeDrone();

AIDrone* drone = info->GetDrone();

if (!drone)
return;

drone->Set(script, 0);
float difficultyLevel = level;
drone->SetLevel(difficultyLevel);
}
3 changes: 2 additions & 1 deletion MK11Hook/mk/Engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ unsigned int _hash(const char* input);
void GetCharacterPosition(FVector* vec, PLAYER_NUM plr);
char* GetCharacterName(PLAYER_NUM plr);

void SetCharacterMKX(PLAYER_NUM plr, char* name);
void SetCharacterMKX(PLAYER_NUM plr, char* name);
void SetCharacterAI(PLAYER_NUM plr, char* script, int level);
4 changes: 4 additions & 0 deletions MK11Hook/mk/MKCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,10 @@ void MKCamera::HookedSetRotation(FRotator * rot)
rot->Pitch += 1228;
TheMenu->camRot = *rot;
break;
case CAMERA_9_16:
rot->Roll += (int)(float)((float)(90.0 * 32767.0) / 180.0);
TheMenu->camRot = *rot;
break;
}
}
SetRotation(rot);
Expand Down
61 changes: 45 additions & 16 deletions MK11Hook/mk/MKModifier.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "MKModifier.h"
#include "Engine.h"


TagAssistModifier::TagAssistModifier(const char * character)
Expand All @@ -15,26 +16,26 @@ void TagAssistModifier::Activate(PlayerInfo* info)
((void(__fastcall*)(BaseModifier*, PlayerInfo*))pat)(this, info);
}

TagAssistModifierObject * TagAssistModifier::CreateObject()
Modifier* MKModifier::CreateModifier(const char* name)
{
static uintptr_t pat = _pattern(PATID_TagAssistModifier_CreateObject);
if (pat)
return ((TagAssistModifierObject*(__fastcall*)(BaseModifier*))pat)(this);
return nullptr;
return new Modifier(name);
}

void MKModifier::ActivateModifier(BaseModifier * modifier, MKCharacter * obj)
void MKModifier::ActivateModifier(Modifier* mod, int playerFlags)
{
static uintptr_t pat = _pattern(PATID_MKModifier_ActivateModifier);
if (pat)
((void(__fastcall*)(MKModifier*, BaseModifier*, MKCharacter*))pat)(this, modifier, obj);
}
ModifierObject obj(mod, playerFlags);

void TagAssistModifierObject::Activate(MKCharacter* obj)
{
static uintptr_t pat = _pattern(PATID_TagAssistModifierObject_Activate);
if (pat)
((void(__fastcall*)(TagAssistModifierObject*, MKCharacter*))pat)(this, obj);
MKCharacter* p1 = GetObj(PLAYER1);

if (!p1)
return;

MKCharacter* p2 = GetObj(PLAYER2);

if (!p2)
return;

obj.Activate(p1, p2);
}

MKModifier* GetModifierManager()
Expand All @@ -58,4 +59,32 @@ void LoadModifierAssets()
static uintptr_t pat = _pattern(PATID_LoadModifierAssets);
if (pat)
((void(__fastcall*)(FGGameInfo*, bool))pat)(GetGameInfo(), 1);
}
}

Modifier::Modifier(const char* name)
{
static uintptr_t pat = _pattern(PATID_MKModifier_Constructor);
if (pat)
((void(__fastcall*)(BaseModifier*, const char*, int, int64, int64))pat)(this, name, 1, 0, 0);
}

void Modifier::GetAssetPath(TArray<char>& path)
{
static uintptr_t pat = _pattern(PATID_MKModifier_GetAssetPath);
if (pat)
((void(__fastcall*)(Modifier*, TArray<char>&))pat)(this, path);
}

ModifierObject::ModifierObject(Modifier* modifier, int flags)
{
static uintptr_t pat = _pattern(PATID_MKModifierObject_Constructor);
if (pat)
((void(__fastcall*)(ModifierObject*, BaseModifier*, int))pat)(this, modifier, flags);
}

void ModifierObject::Activate(MKCharacter* p1, MKCharacter* p2)
{
static uintptr_t pat = _pattern(PATID_MKModifierObject_Activate);
if (pat)
((void(__fastcall*)(ModifierObject*, MKCharacter*, MKCharacter*))pat)(this, p1, p2);
}
25 changes: 20 additions & 5 deletions MK11Hook/mk/MKModifier.h
Original file line number Diff line number Diff line change
@@ -1,28 +1,43 @@
#pragma once
#include "../mk/MKCharacter.h"
#include "../mk/PlayerInfo.h"
#include "../unreal/TArray.h"
#include "../utils.h"

class BaseModifier {
public:
char data[96] = {};
char data[112] = {};
};

class TagAssistModifierObject {
class Modifier : public BaseModifier {
public:
void Activate(MKCharacter* obj);
Modifier(const char* name);

void GetAssetPath(TArray<char>& path);
};

class ModifierObject {
public:
char data[512] = {};

ModifierObject(Modifier* modifier, int flags);

void Activate(MKCharacter* p1, MKCharacter* p2);
};




class TagAssistModifier : public BaseModifier {
public:
TagAssistModifier(const char* character);
void Activate(PlayerInfo* info);
TagAssistModifierObject* CreateObject();
};

class MKModifier {
public:
void ActivateModifier(BaseModifier* modifier, MKCharacter* obj);
static Modifier* CreateModifier(const char* name);
static void ActivateModifier(Modifier* mod, int playerFlags);
};


Expand Down
14 changes: 14 additions & 0 deletions MK11Hook/mk/PlayerInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ float PlayerInfo::GetMeter(eMeterValues type)
return *(float*)(meter_ptr + 4);
}

void PlayerInfo::MakeDrone()
{
static uintptr_t pat = _pattern(PATID_PlayerInfo_MakeDrone);
if (pat)
((void(__fastcall*)(PlayerInfo*))pat)(this);
}

HitCounter PlayerInfo::GetHits()
{
return *(HitCounter*)((int64)this + 0x430);
Expand All @@ -47,3 +54,10 @@ void AIDrone::Set(const char* script, int unk)
if (pat)
((void(__fastcall*)(AIDrone*, const char*, int))pat)(this, script, unk);
}

void AIDrone::SetLevel(float level)
{
static uintptr_t pat = _pattern(PATID_AIDrone_SetLevel);
if (pat)
((void(__fastcall*)(AIDrone*, float))pat)(this, level);
}
3 changes: 3 additions & 0 deletions MK11Hook/mk/PlayerInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ struct Gamepad {
class AIDrone {
public:
void Set(const char* script, int unk);
void SetLevel(float level);
};

class PlayerInfo {
Expand All @@ -58,6 +59,8 @@ class PlayerInfo {
void RefreshMeter(bool value);
float GetMeter(eMeterValues type);

void MakeDrone();

HitCounter GetHits();

AIDrone* GetDrone();
Expand Down
Loading

0 comments on commit ec823ba

Please sign in to comment.