Skip to content

Commit

Permalink
character modifier crash fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ermaccer committed Apr 14, 2022
1 parent bf19cf0 commit bbec265
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 3 deletions.
Binary file modified I2Hook/I2Hook.rc
Binary file not shown.
16 changes: 15 additions & 1 deletion I2Hook/I2Hook.vcxproj.user
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LocalDebuggerCommand>
</LocalDebuggerCommand>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LocalDebuggerCommand>
</LocalDebuggerCommand>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-60|x64'">
<LocalDebuggerCommand>
</LocalDebuggerCommand>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
</Project>
5 changes: 5 additions & 0 deletions I2Hook/code/GameInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ MKScript* GetScript(const char* name)
return nullptr;
}

int64 GetScriptVar(MKScript* script, const char* name)
{
return ((int64(__fastcall*)(MKScript*, const char*, int))_addr(0x141721BB0))(script, name, 1);
}

FGGameInfo* GetGameInfo()
{
return *(FGGameInfo**)_addr(GFG_GAME_INFO);
Expand Down
3 changes: 3 additions & 0 deletions I2Hook/code/GameInfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once
#include "PlayerInfo.h"
#include "mk10utils.h"

enum PLAYER_NUM
{
Expand Down Expand Up @@ -28,4 +29,6 @@ class FGGameInfo {

MKScript* GetScript(const char* name);

int64 GetScriptVar(MKScript* script, const char* name);

FGGameInfo* GetGameInfo();
7 changes: 7 additions & 0 deletions I2Hook/code/MKCharacter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,10 @@ void MKCharacter::BloodEffect(int type, FName name, float x, float y, float z, f
{
((void(__thiscall*)(MKCharacter*, int, FName, float, float, float, float, float, float, int))_addr(0x1409BDEA0))(this, type, name, x, y, z, unk, size, speed, attach);
}

void MKCharacter::ExplodeHead()
{
SetBoneSize("Head", 0.0);
FName head("Head", FNAME_Add, -1);
BloodEffect(4, head, 0, 0, 0, 40, 2.0, 0.7, false);
}
3 changes: 3 additions & 0 deletions I2Hook/code/MKCharacter.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,8 @@ class MKCharacter {
void ExecuteScript(MKScript* script, int function);

void BloodEffect(int type, FName name, float x, float y, float z, float unk, float size, float speed, bool attach);

// custom
void ExplodeHead();
};

2 changes: 1 addition & 1 deletion I2Hook/code/dcf2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ PlayerInfo* GetInfo(PLAYER_NUM plr)
void SetCharacterMKX(PLAYER_NUM plr, char * name)
{
int64 ptr = (int64)GetInfo(plr);
CharacterDefinition* chr = (CharacterDefinition*)(ptr + 216);
CharacterDefinition* chr = (CharacterDefinition*)(ptr + 192);
chr->Set(name, 0, 0);
}

Expand Down
2 changes: 1 addition & 1 deletion I2Hook/code/dcf2.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#define GFG_GAME_INFO 0x14417DF30

#define I2HOOK_VERSION "0.4.6"
#define I2HOOK_VERSION "0.4.7"


MKCharacter* GetObj(PLAYER_NUM plr);
Expand Down
9 changes: 9 additions & 0 deletions I2Hook/code/dcf2menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -973,6 +973,15 @@ void DCF2Menu::DrawScriptTab()
RunLastScript();
}

/*static char szScriptVariable[256] = {};
static int64 test;
ImGui::InputText("Script Variable", szScriptVariable, sizeof(szScriptVariable));
if (ImGui::Button("Get Var Ptr"))
{
test = GetScriptVar(m_pScript, szScriptVariable);
std::cout << std::hex << test << std::endl;
}
*/
}
else
{
Expand Down

0 comments on commit bbec265

Please sign in to comment.