Implement Quick Transform from Rando

This commit is contained in:
PJB3005
2026-04-01 18:11:49 +02:00
parent c3516c368a
commit 73ace77163
6 changed files with 164 additions and 0 deletions
+1
View File
@@ -1332,6 +1332,7 @@ set(DOLPHIN_FILES
set(DUSK_FILES
include/dusk/endian_gx.hpp
src/d/actor/d_a_alink_quicktransform.cpp
src/dusk/asserts.cpp
src/dusk/logging.cpp
src/dusk/stubs.cpp
+5
View File
@@ -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 {
@@ -8428,6 +8432,7 @@ inline daAlink_c* daAlink_getAlinkActorClass() {
#if TARGET_PC
namespace dusk::tweaks {
extern bool FastIronBoots;
extern bool QuickTransform;
}
#endif
+6
View File
@@ -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;
+74
View File
@@ -0,0 +1,74 @@
#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"
bool dusk::tweaks::QuickTransform = false;
void daAlink_c::handleQuickTransform() {
if (!dusk::tweaks::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();
}
+1
View File
@@ -78,6 +78,7 @@ namespace dusk {
if (ImGui::BeginMenu("Tweaks")) {
ImGui::MenuItem("Fast iron boots", nullptr, &tweaks::FastIronBoots);
ImGui::MenuItem("Quick Transform (R+Y)", nullptr, &tweaks::QuickTransform);
ImGui::EndMenu();
}
+77
View File
@@ -721,6 +721,67 @@ void fapGm_After() {
fopCamM_Management();
}
#if TARGET_PC
// Analog L is currently not being used, so commented out
// static f32 prevFrameAnalogL = 0.f;
static f32 prevFrameAnalogR = 0.f;
static bool DuskCheckButtonCombo(u32 combo, bool checkAnalog) {
const auto& padInfo = mDoCPd_c::getCpadInfo(PAD_1);
// Get the buttons that are currently held and were pressed this frame
uint32_t buttonsHeld = padInfo.mButtonFlags;
uint32_t buttonsPressedThisFrame = padInfo.mPressedButtonFlags;
if (checkAnalog) {
// Get the threshold for the analog buttons
constexpr float analogThreshold = 0.7f; // 70%
// Check if L is included in the button combo
// Analog L is currently not being used, so commented out
/*
if ( combo & PadInputs::Button_L )
{
// Check if analog L is at 70% or more
if ( padInfo->mTriggerLeft >= analogThreshold )
{
// Manually set the bit for L being pressed
buttonsHeld |= PadInputs::Button_L;
// If prevFrameAnalogL is less than 70%, then 70% was reached this frame
if ( prevFrameAnalogL < analogThreshold )
{
buttonsPressedThisFrame |= PadInputs::Button_L;
}
}
}
*/
// Check if R is included in the button combo
if (combo & PAD_TRIGGER_R) {
// Check if analog R is at 70% or more
if (padInfo.mTriggerRight >= analogThreshold) {
// Manually set the bit for R being pressed
buttonsHeld |= PAD_TRIGGER_R;
// If prevFrameAnalogR is less than 70%, then 70% was reached this frame
if (prevFrameAnalogR < analogThreshold) {
buttonsPressedThisFrame |= PAD_TRIGGER_R;
}
}
}
}
// Check if the button combo is held
if ((buttonsHeld & combo) != combo) {
return false;
}
// Check if at least one button in the combo was pressed this frame
return buttonsPressedThisFrame & combo;
}
#endif
void fapGm_Execute() {
static u32 sExecCount = 0;
if (sExecCount < 10 || (sExecCount % 300 == 0)) {
@@ -732,8 +793,24 @@ void fapGm_Execute() {
JUTDbPrint::getManager()->setCharColor(g_HIO.mColor);
#endif
#if TARGET_PC
const auto& padInfo = mDoCPd_c::getCpadInfo(PAD_1);
if (DuskCheckButtonCombo(PAD_TRIGGER_R | PAD_BUTTON_Y, true)) {
if (const auto link = g_dComIfG_gameInfo.play.getPlayer(0)) {
dynamic_cast<daAlink_c*>(link)->handleQuickTransform();
}
}
#endif
fpcM_Management(NULL, fapGm_After);
cCt_Counter(0);
#if TARGET_PC
// Main code has ran, so update previous frame variables
// Analog L is currently not being used, so commented out
// prevFrameAnalogL = padInfo.mTriggerLeft;
prevFrameAnalogR = padInfo.mTriggerRight;
#endif
}
fapGm_HIO_c g_HIO;