diff --git a/files.cmake b/files.cmake index 4806722f12..26cae0f1a9 100644 --- a/files.cmake +++ b/files.cmake @@ -1332,6 +1332,7 @@ set(DOLPHIN_FILES set(DUSK_FILES include/dusk/endian_gx.hpp + src/d/actor/d_a_alink_dusk.cpp src/dusk/asserts.cpp src/dusk/logging.cpp src/dusk/layout.cpp diff --git a/include/d/actor/d_a_alink.h b/include/d/actor/d_a_alink.h index 7c70ea54e5..f74aef4f0a 100644 --- a/include/d/actor/d_a_alink.h +++ b/include/d/actor/d_a_alink.h @@ -4547,6 +4547,10 @@ public: /* 0x03848 */ cXyz* field_0x3848; /* 0x0384C */ cXyz* field_0x384c; /* 0x03850 */ daAlink_procFunc mpProcFunc; + +#if TARGET_PC + void handleQuickTransform(); +#endif }; // Size: 0x385C class daAlinkHIO_data_c : public JORReflexible { diff --git a/include/d/d_meter2_draw.h b/include/d/d_meter2_draw.h index c11bd680bb..10cded803d 100644 --- a/include/d/d_meter2_draw.h +++ b/include/d/d_meter2_draw.h @@ -148,6 +148,12 @@ public: void setEmphasisB(u8 param_0) { field_0x762 = param_0; } u8 getInsideObjCheck() { return field_0x772; } +#if TARGET_PC + constexpr f32 getButtonZAlpha() const { + return mButtonZAlpha; + } +#endif + private: /* 0x004 */ item_params mItemParams[4]; /* 0x074 */ JKRExpHeap* heap; diff --git a/src/d/actor/d_a_alink_dusk.cpp b/src/d/actor/d_a_alink_dusk.cpp new file mode 100644 index 0000000000..47501d4f3d --- /dev/null +++ b/src/d/actor/d_a_alink_dusk.cpp @@ -0,0 +1,73 @@ +#include "d/actor/d_a_alink.h" +#include "d/actor/d_a_midna.h" +#include "d/d_meter2.h" +#include "d/d_meter2_draw.h" +#include "d/d_meter2_info.h" +#include "dusk/imgui/ImGuiMenuEnhancements.hpp" + +void daAlink_c::handleQuickTransform() { + if (!dusk::ImGuiMenuEnhancements::m_enhancements.quickTransform) { + return; + } + + // Ensure that link is not in a cutscene. + if (checkEventRun()) { + return; + } + + // Check to see if Link has the ability to transform. + if (!dComIfGs_isEventBit(dSv_event_flag_c::M_077)) { + return; + } + + // Make sure Link isn't riding anything (horse, boar, etc.) + if (checkRide()) { + return; + } + + switch (mProcID) { + // Make sure Link is not underwater or talking to someone. + case PROC_TALK: + case PROC_SWIM_UP: + case PROC_SWIM_DIVE: + return; + // If Link is targeting or pulling a chain, we don't want to remove the ability to use items in combat accidently. + case PROC_ATN_ACTOR_MOVE: + case PROC_ATN_ACTOR_WAIT: + case PROC_WOLF_ATN_AC_MOVE: + break; + default: + // Disable the input that was just pressed, as sometimes it could cause items to be used or Wolf Link to dig. + mDoCPd_c::getCpadInfo(PAD_1).mPressedButtonFlags = 0; + break; + } + + // Ensure there is a proper pointer to the mMeterClass and mpMeterDraw structs in g_meter2_info. + const auto meterClassPtr = g_meter2_info.getMeterClass(); + if (!meterClassPtr) { + return; + } + + const auto meterDrawPtr = meterClassPtr->getMeterDrawPtr(); + if (!meterDrawPtr) { + return; + } + + // Ensure that the Z Button is not dimmed + if (meterDrawPtr->getButtonZAlpha() != 1.f) { + return; + } + + // The game will crash if trying to quick transform while holding the Ball and Chain + if (mEquipItem == dItemNo_IRONBALL_e) { + return; + } + + // Use the game's default checks for if the player can currently transform + if (!m_midnaActor->checkMetamorphoseEnableBase()) { + return; + } + + OSReport("Running quick transform!"); + procCoMetamorphoseInit(); +} \ No newline at end of file diff --git a/src/dusk/imgui/ImGuiMenuEnhancements.cpp b/src/dusk/imgui/ImGuiMenuEnhancements.cpp index c2fb060f5b..9103c51fbd 100644 --- a/src/dusk/imgui/ImGuiMenuEnhancements.cpp +++ b/src/dusk/imgui/ImGuiMenuEnhancements.cpp @@ -22,6 +22,7 @@ namespace dusk { if (ImGui::BeginMenu("Quality of Life")) { ImGui::Checkbox("Fast Iron Boots", &m_enhancements.fastIronBoots); ImGui::Checkbox("Invert Camera X Axis", &m_enhancements.invertCameraXAxis); + ImGui::Checkbox("Quick Transform (R+Y)", &m_enhancements.quickTransform); ImGui::EndMenu(); } diff --git a/src/dusk/imgui/ImGuiMenuEnhancements.hpp b/src/dusk/imgui/ImGuiMenuEnhancements.hpp index 16ef0a1983..7b4775789b 100644 --- a/src/dusk/imgui/ImGuiMenuEnhancements.hpp +++ b/src/dusk/imgui/ImGuiMenuEnhancements.hpp @@ -11,6 +11,7 @@ namespace dusk { struct EnhancementsSettings { bool fastIronBoots; bool invertCameraXAxis; + bool quickTransform; bool restoreWiiGlitches; bool enableBloom; bool useWaterProjectionOffset; diff --git a/src/f_ap/f_ap_game.cpp b/src/f_ap/f_ap_game.cpp index 520d85d20f..1cbbb7449f 100644 --- a/src/f_ap/f_ap_game.cpp +++ b/src/f_ap/f_ap_game.cpp @@ -732,6 +732,14 @@ void fapGm_Execute() { JUTDbPrint::getManager()->setCharColor(g_HIO.mColor); #endif +#if TARGET_PC + if (mDoCPd_c::getHoldR(PAD_1) && mDoCPd_c::getTrigY(PAD_1)) { + if (const auto link = g_dComIfG_gameInfo.play.getPlayer(0)) { + dynamic_cast(link)->handleQuickTransform(); + } + } +#endif + fpcM_Management(NULL, fapGm_After); cCt_Counter(0); }