Skip to content

Commit

Permalink
Fix player shielding when CPU is set to shield during L frame advance
Browse files Browse the repository at this point in the history
A shotgun of changes here, basically we want to make sure that the
engine and master pads are disabled on L press when frame advance is
set to L. We also want to make sure that we're only removing inputs
if the frame advance is enabled in the first place. Additionally, we
want to make sure that the CPU is shielding if it's supposed to shield.
Some of these changes might not be necessary, I was working on this
one for a while...
  • Loading branch information
strabitz committed Sep 26, 2024
1 parent f65b740 commit dc47979
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/lab.c
Original file line number Diff line number Diff line change
Expand Up @@ -1094,7 +1094,10 @@ void LCancel_CPUThink(GOBJ *event, GOBJ *hmn, GOBJ *cpu)
case (CPUBEHAVE_SHIELD):
{
// hold R
cpu_data->cpu.held = PAD_TRIGGER_R;
cpu_data->cpu.held |= PAD_TRIGGER_R;
cpu_data->input.held |= PAD_TRIGGER_R;
cpu_data->input.trigger = 1.0f;
cpu_data->cpu.ai = 15; // Ensure AI doesn't override this input
break;
}

Expand Down Expand Up @@ -1831,13 +1834,14 @@ int Update_CheckAdvance()

// get their pad
HSD_Pad *pad = PadGet(controller, PADGET_MASTER);
HSD_Pad *engine_pad = PadGet(controller, PADGET_ENGINE);

// get their advance input
static int stc_advance_btns[] = {HSD_TRIGGER_L, HSD_TRIGGER_Z, HSD_BUTTON_X, HSD_BUTTON_Y};
int advance_btn = stc_advance_btns[LabOptions_General[OPTGEN_FRAMEBTN].option_val];

// check if holding L
if ((pad->held & advance_btn) || (advance_btn == HSD_TRIGGER_L && pad->triggerLeft >= LOW_ANALOG_TRIGGER_THRESHOLD))
if (!LabOptions_General[OPTGEN_FRAMEBTN].disable && (pad->held & advance_btn) || (advance_btn == HSD_TRIGGER_L && pad->triggerLeft >= LOW_ANALOG_TRIGGER_THRESHOLD))
{
timer++;

Expand All @@ -1849,12 +1853,16 @@ int Update_CheckAdvance()
// remove button input
pad->down &= ~advance_btn;
pad->held &= ~advance_btn;
engine_pad->down &= ~advance_btn;
engine_pad->held &= ~advance_btn;

// if using L, remove analog press too
if (LabOptions_CPU[OPTGEN_FRAMEBTN].option_val == 0)
if (advance_btn == HSD_TRIGGER_L)
{
pad->triggerLeft = 0;
pad->ftriggerLeft = 0;
engine_pad->triggerLeft = 0;
engine_pad->ftriggerLeft = 0;
}
}
}
Expand Down

0 comments on commit dc47979

Please sign in to comment.