Skip to content

Commit

Permalink
Re-add back old plugin functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Archie-osu committed Mar 15, 2022
1 parent 4c95b18 commit 499fea3
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 21 deletions.
44 changes: 27 additions & 17 deletions Plugins/ExamplePlugin/Src/DllMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ YYRValue EasyGMLCall(YYTKPlugin* pPlugin, const std::string& Name, const std::ve
return Result;
}

// I have to do this because there's some misalignment between older and newer DR versions
CCode* GetCodeFromScript(CScript* pScript)
{
// If the script is invalid
Expand All @@ -35,7 +36,6 @@ CCode* GetCodeFromScript(CScript* pScript)

return nullptr;
}

// Handles all events that happen inside the game.
// Previously, callbacks served this purpose, however in 0.0.3, an object-oriented design was implemented.
// If you want to modify a code entry, you're gonna need this function.
Expand All @@ -48,34 +48,44 @@ YYTKStatus PluginEventHandler(YYTKPlugin* pPlugin, YYTKEventBase* pEvent)
// Tip: Use dynamic_cast to catch issues with exceptions!
YYTKScriptEvent* pCodeEvent = dynamic_cast<YYTKScriptEvent*>(pEvent);

// Unpack the pScript variable from the tuple, ignore the rest.
CScript* pScript = nullptr;

// Extract arguments from the tuple into individual objects. C++ rules apply.
std::tie(pScript, std::ignore, std::ignore, std::ignore, std::ignore, std::ignore) = pCodeEvent->Arguments();
auto& [Script, v2, v3, v4, v5, v6] = pCodeEvent->Arguments();

// Check if values are valid
if (pScript)
if (Script)
{
if (CCode* pCode = GetCodeFromScript(pScript))
if (CCode* pCode = GetCodeFromScript(Script))
{
if (strcmp(pCode->i_pName, "gml_Script_scr_debug"))
if (strcmp(pCode->i_pName, "gml_Script_scr_debug") == 0 ||
strcmp(pCode->i_pName, "gml_Script_scr_debug_ch1") == 0)
{

// By doing it this way, we avoid the crash with the cutscenes
// which is something that UMT's Ch2 Debug.csx is currently suffering from.
pCode->i_pVM = nullptr;
YYRValue* pReturn = (YYRValue*)pCodeEvent->Call(Script, v2, v3, v4, v5, v6);
*pReturn = 1.0;
}
else if (strcmp(pCode->i_pName, "gml_Script_scr_dogcheck") == 0 ||
strcmp(pCode->i_pName, "gml_Script_scr_dogcheck_ch1") == 0)
{
// Run GML: variable_global_set("debug", 1.00)
EasyGMLCall(pPlugin, "variable_global_set", { "debug", 1.00 });
// Just say we called it LOL
pCode->i_pVM = nullptr;
YYRValue* pReturn = (YYRValue*)pCodeEvent->Call(Script, v2, v3, v4, v5, v6);
*pReturn = 0.0;
}
}
}
}

// Go To Room port
if (GetAsyncKeyState(VK_F3) & 1)
{
YYRValue CurrentRoom = 30.0;
// Go To Room port
if (GetAsyncKeyState(VK_F3) & 1)
{
YYRValue CurrentRoom = 30.0;

YYRValue Result = EasyGMLCall(pPlugin, "get_integer", { "Go to room (ported by Archie from UMT to YYToolkit).\nEnter the room ID you wish to teleport to.", CurrentRoom });
YYRValue Result = EasyGMLCall(pPlugin, "get_integer", { "Go to room (ported by Archie from UMT to YYToolkit).\nEnter the room ID you wish to teleport to.", CurrentRoom });

EasyGMLCall(pPlugin, "room_goto", { Result });
}
EasyGMLCall(pPlugin, "room_goto", { Result });
}
return YYTK_OK;
}
Expand Down
6 changes: 3 additions & 3 deletions Plugins/ExamplePlugin/Src/SDK/Enums/Enums.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,18 @@ enum Color : int
{
CLR_BLACK = 0,
CLR_DARKBLUE = 1,
CLR_MATRIXGREEN = 2,
CLR_GREEN = 2,
CLR_AQUA = 3,
CLR_RED = 4,
CLR_PURPLE = 5,
CLR_GOLD = 6,
CLR_DEFAULT = 7,
CLR_GRAY = 8,
CLR_BLUE = 9,
CLR_GREEN = 10,
CLR_MATRIXGREEN = 10,
CLR_LIGHTBLUE = 11,
CLR_TANGERINE = 12,
CLR_PINK = 13,
CLR_BRIGHTPURPLE = 13,
CLR_YELLOW = 14,
CLR_WHITE = 15
};
Expand Down
2 changes: 1 addition & 1 deletion Plugins/ExamplePlugin/Src/SDK/FwdDecls/FwdDecls.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ typedef bool (*FNCodeExecute)(YYObjectBase* Self, YYObjectBase* Other, CCode* co
#define WIN32_LEAN_AND_MEAN 1
#define YYTK_MAGIC 'TFSI'

static const char* YYSDK_VERSION = "0.1-rc1";
static const char* YYSDK_VERSION = "0.1-rc2";

// Macros, but complicated
#ifdef _MSC_VER
Expand Down

0 comments on commit 499fea3

Please sign in to comment.