Skip to content

Commit

Permalink
mash bar -> meter consistent terminology
Browse files Browse the repository at this point in the history
  • Loading branch information
z64a committed Oct 20, 2024
1 parent 509d75a commit 6dea1ab
Show file tree
Hide file tree
Showing 27 changed files with 503 additions and 503 deletions.
2 changes: 1 addition & 1 deletion include/enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -1643,7 +1643,7 @@ enum SoundIDs {
SOUND_LOOP_TIK_UNUSED3_FLOW3 = 0x8000003E, // #unused
SOUND_LOOP_TIK_UNUSED3_FLOW2 = 0x8000003F, // #unused
SOUND_LOOP_SAM_STAIRS_RISE = 0x80000040,
SOUND_LOOP_CHARGE_BAR = 0x80000041,
SOUND_LOOP_CHARGE_METER = 0x80000041,
SOUND_LOOP_CRYSTAL_BALL_GLOW = 0x80000042,
SOUND_LOOP_TIK18_WATER = 0x80000043,
SOUND_LOOP_TIK19_WATER = 0x80000044,
Expand Down
2 changes: 1 addition & 1 deletion src/audio/sfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ s32 LoopingSounds[] = {
[SOUND_LOOP_IDX(SOUND_LOOP_TIK_UNUSED3_FLOW3)] SOUND_LRAW_WATER_FLOWING_3,
[SOUND_LOOP_IDX(SOUND_LOOP_TIK_UNUSED3_FLOW2)] SOUND_LRAW_WATER_FLOWING_2,
[SOUND_LOOP_IDX(SOUND_LOOP_SAM_STAIRS_RISE)] SOUND_LRAW_SAM_STAIRS_RISE,
[SOUND_LOOP_IDX(SOUND_LOOP_CHARGE_BAR)] SOUND_LRAW_CHARGE_BAR,
[SOUND_LOOP_IDX(SOUND_LOOP_CHARGE_METER)] SOUND_LRAW_CHARGE_BAR,
[SOUND_LOOP_IDX(SOUND_LOOP_CRYSTAL_BALL_GLOW)] SOUND_LRAW_CRYSTAL_BALL_GLOW,
[SOUND_LOOP_IDX(SOUND_LOOP_TIK18_WATER)] SOUND_LRAW_TIK_WATER,
[SOUND_LOOP_IDX(SOUND_LOOP_TIK19_WATER)] SOUND_LRAW_TIK_WATER,
Expand Down
10 changes: 5 additions & 5 deletions src/battle/action_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,11 @@ void draw_mash_meter(s32 posX, s32 posY, s32 fillValue, s32 colorMode) {
}

//difference between current and previous filled value
offsetX = width - acs->barFillWidth;
offsetX = width - acs->meterFillWidth;
if (abs(offsetX) >= MashMeterSmoothDivisor * 100) {
acs->barFillWidth += offsetX / MashMeterSmoothDivisor;
acs->meterFillWidth += offsetX / MashMeterSmoothDivisor;
} else {
acs->barFillWidth = width;
acs->meterFillWidth = width;
}

offsetX = 0;
Expand Down Expand Up @@ -202,7 +202,7 @@ void draw_mash_meter(s32 posX, s32 posY, s32 fillValue, s32 colorMode) {
}

filledWidth = cutOff * 60 / maxCutOff - offsetX;
width = acs->barFillWidth / 100 - offsetX;
width = acs->meterFillWidth / 100 - offsetX;

if (width < 0) {
break;
Expand Down Expand Up @@ -737,7 +737,7 @@ API_CALLABLE(InterruptActionCommand) {
}
}

sfx_stop_sound(SOUND_LOOP_CHARGE_BAR);
sfx_stop_sound(SOUND_LOOP_CHARGE_METER);
close_action_command_instruction_popup();

return ApiStatus_DONE2;
Expand Down
22 changes: 11 additions & 11 deletions src/battle/action_cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ enum {
AC_STATE_DISPOSE = 12, // delay and disappear
};

enum {
enum ActionCommandDifficulty {
AC_DIFFICULTY_0 = 0, // easiest
AC_DIFFICULTY_1 = 1, // very easy
AC_DIFFICULTY_2 = 2, // easy
Expand Down Expand Up @@ -81,13 +81,13 @@ enum ActionCommandModes {
typedef struct ActionCommandStatus {
/* 0x00 */ s32 workerID;
/* 0x04 */ s32 hudElements[16];
/* 0x44 */ s16 barFillLevel; // 0 to MAX_MASH_UNITS
/* 0x44 */ s16 meterFillLevel; // 0 to MAX_MASH_UNITS
/* 0x46 */ s16 escapeThreshold;
/* 0x48 */ s16 barFillWidth; // X100
/* 0x48 */ s16 meterFillWidth; // X100
/* 0x4A */ s16 actionCommandID;
/* 0x4C */ s16 state;
/* 0x4E */ s16 prepareTime;
/* 0x50 */ s16 difficulty; // values from 0 to 7
/* 0x50 */ s16 difficulty; // see enum: ActionCommandDifficulty
/* 0x52 */ s16 duration;
/* 0x54 */ s16 stateTimer;
/* 0x56 */ s16 hudPosX;
Expand Down Expand Up @@ -133,20 +133,20 @@ typedef struct ActionCommandStatus {
} tidalWave;
};
/* 0x5E */ s8 autoSucceed;
/* 0x5F */ s8 hammerMissedStart;
/* 0x60 */ s8 wrongButtonPressed;
/* 0x61 */ s8 showHud;
/* 0x62 */ s8 playHammerSounds;
/* 0x5F */ b8 hammerMissedStart;
/* 0x60 */ b8 wrongButtonPressed;
/* 0x61 */ b8 showHud;
/* 0x62 */ b8 playHammerSounds;
/* 0x63 */ char pad_63[1];
/* 0x64 */ union {
s16 variation; // used to select different variants of an action command
s16 statusChance; // chance of applying special status; higher values make mashing easier
};
/* 0x66 */ s16 thresholdMoveDir;
/* 0x68 */ s16 isBarFilled;
/* 0x6A */ s16 berserkerEnabled;
/* 0x68 */ b16 isMeterFilled;
/* 0x6A */ b16 berserkerEnabled;
/* 0x6C */ s16 hudPrepareTime;
/* 0x6E */ s16 hitsTakenIsMax;
/* 0x6E */ b16 hitsTakenIsMax;
/* 0x70 */ s16 lookBackCounter;
/* 0x72 */ s16 wrongInputFrameCounter;
/* 0x74 */ s16 mashMeterCutoffs[6]; // upper bounds for each interval
Expand Down
64 changes: 32 additions & 32 deletions src/battle/action_cmd/air_lift.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ API_CALLABLE(N(init)) {
acs->showHud = TRUE;
acs->state = AC_STATE_INIT;
acs->wrongButtonPressed = FALSE;
acs->barFillLevel = 0;
acs->barFillWidth = 0;
acs->isBarFilled = FALSE;
acs->meterFillLevel = 0;
acs->meterFillWidth = 0;
acs->isMeterFilled = FALSE;
battleStatus->actionQuality = 0;
battleStatus->actionProgress = 0;

Expand Down Expand Up @@ -154,59 +154,59 @@ void N(update)(void) {
hud_element_set_script(acs->hudElements[HIDX_BUTTON], &HES_MashAButton);
N(HasStarted) = TRUE;
acs->stateTimer = acs->duration;
sfx_play_sound_with_params(SOUND_LOOP_CHARGE_BAR, 0, 0, 0);
sfx_play_sound_with_params(SOUND_LOOP_CHARGE_METER, 0, 0, 0);
acs->state = AC_STATE_ACTIVE;

// fallthrough
case AC_STATE_ACTIVE:
btl_set_popup_duration(POPUP_MSG_ON);

// bar can drain if it hasn't been fully filled
if (!acs->isBarFilled) {
// meter can drain if it hasn't been fully filled
if (!acs->isMeterFilled) {
if (acs->escapeChance != 0) {
s32 maxFillLevel = acs->mashMeterCutoffs[acs->mashMeterNumIntervals];
acs->barFillLevel -= GET_DRAIN_RATE(acs->barFillLevel / maxFillLevel);
if (acs->barFillLevel < 0) {
acs->barFillLevel = 0;
acs->meterFillLevel -= GET_DRAIN_RATE(acs->meterFillLevel / maxFillLevel);
if (acs->meterFillLevel < 0) {
acs->meterFillLevel = 0;
}
} else {
acs->barFillLevel -= 10;
if (acs->barFillLevel < 0) {
acs->barFillLevel = 0;
acs->meterFillLevel -= 10;
if (acs->meterFillLevel < 0) {
acs->meterFillLevel = 0;
}
}
}

// check for bar-filling input
// check for meter-filling input
if (battleStatus->actionCommandMode != AC_MODE_NOT_LEARNED && (battleStatus->curButtonsPressed & BUTTON_A)) {
if (acs->escapeChance != 0) {
// fill rate = 820 multiplied by two values expressed as percentages
s32 difficultyPct = battleStatus->actionCmdDifficultyTable[acs->difficulty];
s32 effectivenessPct = METER_FILL_RATE * acs->escapeChance;
// divide by 100 for each percent-based multiplier
acs->barFillLevel += (difficultyPct * effectivenessPct) / (100 * 100);
acs->meterFillLevel += (difficultyPct * effectivenessPct) / (100 * 100);
} else {
acs->barFillLevel += ONE_PCT_MASH;
if (acs->barFillLevel >= 5 * ONE_PCT_MASH) {
acs->barFillLevel = 5 * ONE_PCT_MASH;
acs->meterFillLevel += ONE_PCT_MASH;
if (acs->meterFillLevel >= 5 * ONE_PCT_MASH) {
acs->meterFillLevel = 5 * ONE_PCT_MASH;
}
}
}

// handle bar reaching 100%
if (acs->barFillLevel > MAX_MASH_UNITS) {
acs->barFillLevel = MAX_MASH_UNITS;
acs->isBarFilled = TRUE;
// handle meter reaching 100%
if (acs->meterFillLevel > MAX_MASH_UNITS) {
acs->meterFillLevel = MAX_MASH_UNITS;
acs->isMeterFilled = TRUE;
hid = acs->hudElements[HIDX_100_PCT];
hud_element_set_render_pos(hid, acs->hudPosX + 50, acs->hudPosY + 28);
hud_element_clear_flags(hid, HUD_ELEMENT_FLAG_DISABLED);
}

battleStatus->actionQuality = acs->barFillLevel / ONE_PCT_MASH;
battleStatus->actionQuality = acs->meterFillLevel / ONE_PCT_MASH;
if (battleStatus->actionProgress < battleStatus->actionQuality) {
battleStatus->actionProgress = battleStatus->actionQuality;
}
sfx_adjust_env_sound_params(SOUND_LOOP_CHARGE_BAR, 0, 0, battleStatus->actionQuality * 12);
sfx_adjust_env_sound_params(SOUND_LOOP_CHARGE_METER, 0, 0, battleStatus->actionQuality * 12);

if (acs->stateTimer != 0) {
acs->stateTimer--;
Expand All @@ -217,7 +217,7 @@ void N(update)(void) {
battleStatus->actionProgress = 0;
}

// threshold for success is completely random, only guaranteed if the bar is 100% filled
// threshold for success is completely random, only guaranteed if the meter is 100% filled
battleStatus->actionQuality = battleStatus->actionProgress;
if (rand_int(99) < battleStatus->actionQuality) {
battleStatus->actionResult = ACTION_RESULT_SUCCESS;
Expand All @@ -232,15 +232,15 @@ void N(update)(void) {
}

btl_set_popup_duration(POPUP_MSG_OFF);
sfx_stop_sound(SOUND_LOOP_CHARGE_BAR);
sfx_stop_sound(SOUND_LOOP_CHARGE_METER);
acs->stateTimer = 20;
acs->state = AC_STATE_DISPOSE;
break;
case AC_STATE_DISPOSE:
if (acs->escapeChance == 0) {
acs->barFillLevel -= ONE_PCT_MASH;
if (acs->barFillLevel < 0) {
acs->barFillLevel = 0;
acs->meterFillLevel -= ONE_PCT_MASH;
if (acs->meterFillLevel < 0) {
acs->meterFillLevel = 0;
}
}
if (acs->stateTimer != 0) {
Expand All @@ -266,11 +266,11 @@ void N(draw)(void) {
hud_element_get_render_pos(hid, &hudX, &hudY);

if (!N(HasStarted)) {
draw_mash_meter_multicolor_with_divisor(hudX, hudY, acs->barFillLevel / ONE_PCT_MASH, 1);
} else if (!acs->isBarFilled) {
draw_mash_meter_multicolor_with_divisor(hudX, hudY, acs->barFillLevel / ONE_PCT_MASH, 4);
draw_mash_meter_multicolor_with_divisor(hudX, hudY, acs->meterFillLevel / ONE_PCT_MASH, 1);
} else if (!acs->isMeterFilled) {
draw_mash_meter_multicolor_with_divisor(hudX, hudY, acs->meterFillLevel / ONE_PCT_MASH, 4);
} else {
draw_mash_meter_blink_with_divisor(hudX, hudY, acs->barFillLevel / ONE_PCT_MASH, 4);
draw_mash_meter_blink_with_divisor(hudX, hudY, acs->meterFillLevel / ONE_PCT_MASH, 4);
}

hud_element_draw_clipped(acs->hudElements[HIDX_100_PCT]);
Expand Down
56 changes: 28 additions & 28 deletions src/battle/action_cmd/air_raid.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ API_CALLABLE(N(init)) {
acs->hudPrepareTime = 30;
acs->state = AC_STATE_INIT;
acs->wrongButtonPressed = FALSE;
acs->barFillLevel = 0;
acs->barFillWidth = 0;
acs->isBarFilled = FALSE;
acs->meterFillLevel = 0;
acs->meterFillWidth = 0;
acs->isMeterFilled = FALSE;
battleStatus->actionQuality = 0;
acs->hudPosX = -48;
acs->hudPosY = 80;
Expand Down Expand Up @@ -93,8 +93,8 @@ API_CALLABLE(N(start)) {
acs->statusChance = evt_get_variable(script, *args++); // unused

acs->wrongButtonPressed = FALSE;
acs->barFillLevel = 0;
acs->barFillWidth = 0;
acs->meterFillLevel = 0;
acs->meterFillWidth = 0;
battleStatus->actionQuality = 0;
battleStatus->actionResult = ACTION_RESULT_NONE;
battleStatus->maxActionQuality = acs->mashMeterCutoffs[(acs->mashMeterNumIntervals - 1)];
Expand Down Expand Up @@ -156,61 +156,61 @@ void N(update)(void) {
}

hud_element_set_script(acs->hudElements[HIDX_STICK], &HES_StickMashLeft);
acs->barFillLevel = 0;
acs->meterFillLevel = 0;
battleStatus->resultTier = 0;
acs->airRaid.holdingLeft = FALSE;
acs->stateTimer = acs->duration;
sfx_play_sound_with_params(SOUND_LOOP_CHARGE_BAR, 0, 0, 0);
sfx_play_sound_with_params(SOUND_LOOP_CHARGE_METER, 0, 0, 0);
acs->state = AC_STATE_ACTIVE;

// fallthrough
case AC_STATE_ACTIVE:
btl_set_popup_duration(POPUP_MSG_ON);

// bar can drain if it hasn't been fully filled
if (!acs->isBarFilled) {
// meter can drain if it hasn't been fully filled
if (!acs->isMeterFilled) {
cutoff = acs->mashMeterCutoffs[acs->mashMeterNumIntervals];
acs->barFillLevel -= GET_DRAIN_RATE(acs->barFillLevel / cutoff);
if (acs->barFillLevel < 0) {
acs->barFillLevel = 0;
acs->meterFillLevel -= GET_DRAIN_RATE(acs->meterFillLevel / cutoff);
if (acs->meterFillLevel < 0) {
acs->meterFillLevel = 0;
}
}

// check for bar-filling input
if (!acs->isBarFilled) {
// check for meter-filling input
if (!acs->isMeterFilled) {
if (battleStatus->curButtonsDown & BUTTON_STICK_LEFT) {
acs->airRaid.holdingLeft = TRUE;
}

if (!(battleStatus->curButtonsDown & BUTTON_STICK_LEFT)) {
if (acs->airRaid.holdingLeft) {
acs->barFillLevel += SCALE_BY_PCT(METER_FILL_RATE, battleStatus->actionCmdDifficultyTable[acs->difficulty]);
acs->meterFillLevel += SCALE_BY_PCT(METER_FILL_RATE, battleStatus->actionCmdDifficultyTable[acs->difficulty]);
acs->airRaid.holdingLeft = FALSE;
}
}

// right stick inputs actively drain the bar
// right stick inputs actively drain the meter
if (battleStatus->curButtonsPressed & BUTTON_STICK_RIGHT) {
acs->barFillLevel -= SCALE_BY_PCT(METER_FILL_RATE, battleStatus->actionCmdDifficultyTable[acs->difficulty]);
acs->meterFillLevel -= SCALE_BY_PCT(METER_FILL_RATE, battleStatus->actionCmdDifficultyTable[acs->difficulty]);
}
}


if (acs->barFillLevel < 0) {
acs->barFillLevel = 0;
if (acs->meterFillLevel < 0) {
acs->meterFillLevel = 0;
}

// handle bar reaching 100%
if (acs->barFillLevel > MAX_MASH_UNITS) {
acs->barFillLevel = MAX_MASH_UNITS;
acs->isBarFilled = TRUE;
// handle meter reaching 100%
if (acs->meterFillLevel > MAX_MASH_UNITS) {
acs->meterFillLevel = MAX_MASH_UNITS;
acs->isMeterFilled = TRUE;
hid = acs->hudElements[HIDX_100_PCT];
hud_element_set_render_pos(hid, acs->hudPosX + 50, acs->hudPosY + 28);
hud_element_clear_flags(hid, HUD_ELEMENT_FLAG_DISABLED);
}

battleStatus->actionProgress = acs->barFillLevel / ONE_PCT_MASH;
sfx_adjust_env_sound_params(SOUND_LOOP_CHARGE_BAR, 0, 0, battleStatus->actionProgress * 12);
battleStatus->actionProgress = acs->meterFillLevel / ONE_PCT_MASH;
sfx_adjust_env_sound_params(SOUND_LOOP_CHARGE_METER, 0, 0, battleStatus->actionProgress * 12);

// resultTier is not used by this move; uses actionProgress instead via the move script
switch (partner->actorBlueprint->level) {
Expand Down Expand Up @@ -246,10 +246,10 @@ void N(update)(void) {
break;
}

if (acs->barFillLevel == 0) {
if (acs->meterFillLevel == 0) {
battleStatus->actionQuality = AC_QUALITY_FAILED;
} else {
battleStatus->actionQuality = acs->barFillLevel / ONE_PCT_MASH;
battleStatus->actionQuality = acs->meterFillLevel / ONE_PCT_MASH;
}

cutoff = acs->mashMeterCutoffs[acs->mashMeterNumIntervals - 1];
Expand All @@ -265,7 +265,7 @@ void N(update)(void) {
}

btl_set_popup_duration(POPUP_MSG_OFF);
sfx_stop_sound(SOUND_LOOP_CHARGE_BAR);
sfx_stop_sound(SOUND_LOOP_CHARGE_METER);
acs->stateTimer = 5;
acs->state = AC_STATE_DISPOSE;
break;
Expand Down
Loading

0 comments on commit 6dea1ab

Please sign in to comment.