Skip to content

Commit

Permalink
cleaning up some names
Browse files Browse the repository at this point in the history
  • Loading branch information
z64a committed Oct 19, 2024
1 parent e6ab4b9 commit a2db06f
Show file tree
Hide file tree
Showing 42 changed files with 624 additions and 479 deletions.
2 changes: 1 addition & 1 deletion include/common_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,7 @@ typedef struct BattleStatus {
/* 0x081 */ s8 actionSuccess; // degree of success for action command, -1 indicates failure, 0 is in progress, >0 is some degree of success
/* 0x082 */ s8 maxActionSuccess; // seems to indicate the maximum positive value for actionSuccess; never read and inconsistently used between various action commands
/* 0x083 */ s8 actionCommandMode;
/* 0x084 */ s8 actionQuality; // actionCommandVar1 ?
/* 0x084 */ s8 actionProgress; // actionCommandVar1 ?
/* 0x085 */ s8 resultTier;
/* 0x086 */ s8 actionResult; // see enum ActionResult
/* 0x087 */ s8 blockResult; // see enum BlockResult
Expand Down
30 changes: 15 additions & 15 deletions src/battle/action_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void* actionCommandDmaTable[] = {
AC_TBL_ENTRY(tidal_wave),
};

BSS s32 sMashMeterSmoothDivisor;
BSS s32 MashMeterSmoothDivisor;
BSS s32 D_8029FBC4_pad[3];
// TODO move to actor_api
BSS s32 IsGroupHeal;
Expand Down Expand Up @@ -151,8 +151,8 @@ void draw_mash_meter(s32 posX, s32 posY, s32 fillValue, s32 colorMode) {

//difference between current and previous filled value
offsetX = width - acs->barFillWidth;
if (abs(offsetX) >= sMashMeterSmoothDivisor * 100) {
acs->barFillWidth += offsetX / sMashMeterSmoothDivisor;
if (abs(offsetX) >= MashMeterSmoothDivisor * 100) {
acs->barFillWidth += offsetX / MashMeterSmoothDivisor;
} else {
acs->barFillWidth = width;
}
Expand Down Expand Up @@ -224,32 +224,32 @@ void draw_mash_meter(s32 posX, s32 posY, s32 fillValue, s32 colorMode) {
}

void draw_mash_meter_multicolor(s32 posX, s32 posY, s32 fillValue) {
sMashMeterSmoothDivisor = 2;
MashMeterSmoothDivisor = 2;
draw_mash_meter(posX, posY, fillValue, MASH_METER_MODE_MULTI_COLOR);
}

void draw_mash_meter_multicolor_with_divisor(s32 posX, s32 posY, s32 fillValue, s32 divisor) {
sMashMeterSmoothDivisor = divisor;
MashMeterSmoothDivisor = divisor;
draw_mash_meter(posX, posY, fillValue, MASH_METER_MODE_MULTI_COLOR);
}

void draw_mash_meter_mode(s32 posX, s32 posY, s32 fillValue, s32 colorMode) {
sMashMeterSmoothDivisor = 2;
MashMeterSmoothDivisor = 2;
draw_mash_meter(posX, posY, fillValue, colorMode);
}

void draw_mash_meter_mode_with_divisor(s32 posX, s32 posY, s32 fillValue, s32 divisor, s32 colorMode) {
sMashMeterSmoothDivisor = divisor;
MashMeterSmoothDivisor = divisor;
draw_mash_meter(posX, posY, fillValue, colorMode);
}

void draw_mash_meter_blink(s32 posX, s32 posY, s32 fillValue) {
sMashMeterSmoothDivisor = 2;
MashMeterSmoothDivisor = 2;
draw_mash_meter(posX, posY, fillValue, MASH_METER_MODE_BLINK);
}

void draw_mash_meter_blink_with_divisor(s32 posX, s32 posY, s32 fillValue, s32 divisor) {
sMashMeterSmoothDivisor = divisor;
MashMeterSmoothDivisor = divisor;
draw_mash_meter(posX, posY, fillValue, MASH_METER_MODE_BLINK);
}

Expand Down Expand Up @@ -784,22 +784,22 @@ API_CALLABLE(GetBlockResult) {
return ApiStatus_DONE2;
}

API_CALLABLE(GetActionQuality) {
evt_set_variable(script, *script->ptrReadPos, gBattleStatus.actionQuality);
API_CALLABLE(GetActionProgress) {
evt_set_variable(script, *script->ptrReadPos, gBattleStatus.actionProgress);
return ApiStatus_DONE2;
}

API_CALLABLE(SetActionQuality) {
gBattleStatus.actionQuality = evt_get_variable(script, *script->ptrReadPos);
API_CALLABLE(SetActionProgress) {
gBattleStatus.actionProgress = evt_get_variable(script, *script->ptrReadPos);
return ApiStatus_DONE2;
}

API_CALLABLE(func_80269600) {
API_CALLABLE(GetActionResultTier) {
evt_set_variable(script, *script->ptrReadPos, gBattleStatus.resultTier);
return ApiStatus_DONE2;
}

API_CALLABLE(func_8026962C) {
API_CALLABLE(SetActionResultTier) {
gBattleStatus.resultTier = evt_get_variable(script, *script->ptrReadPos);
return ApiStatus_DONE2;
}
18 changes: 9 additions & 9 deletions src/battle/action_cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,17 @@ typedef struct ActionCommandStatus {
/* 0x00 */ s32 workerID;
/* 0x04 */ s32 hudElements[16];
/* 0x44 */ s16 barFillLevel; // 0 to MAX_MASH_UNITS
/* 0x46 */ s16 thresholdLevel;
/* 0x46 */ s16 escapeThreshold;
/* 0x48 */ s16 barFillWidth; // X100
/* 0x4A */ s16 actionCommandID;
/* 0x4C */ s16 state;
/* 0x4E */ s16 prepareTime;
/* 0x50 */ s16 difficulty; // values from 0 to 7
/* 0x52 */ s16 duration;
/* 0x54 */ s16 frameCounter;
/* 0x54 */ s16 stateTimer;
/* 0x56 */ s16 hudPosX;
/* 0x58 */ s16 hudPosY;
/* 0x5A */ s16 effectiveness; // used by air_lift (via AirLiftChance), break_free (30), and flee (random 0-1).
/* 0x5A */ s16 escapeChance; // used by air_lift (via AirLiftChance), break_free (30), and flee (random 0-1).
/* 0x5C */ union {
struct {
s8 unk_5C;
Expand Down Expand Up @@ -139,8 +139,8 @@ typedef struct ActionCommandStatus {
/* 0x62 */ s8 playHammerSounds;
/* 0x63 */ char pad_63[1];
/* 0x64 */ union {
s16 variation;
s16 targetWeakness; // chance of applying special status; higher values make mashing easier
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;
Expand Down Expand Up @@ -220,9 +220,9 @@ API_CALLABLE(GetActionSuccessCopy);
API_CALLABLE(GetActionResult);
API_CALLABLE(SetActionResult);
API_CALLABLE(GetBlockResult);
API_CALLABLE(GetActionQuality);
API_CALLABLE(SetActionQuality);
API_CALLABLE(func_80269600);
API_CALLABLE(func_8026962C);
API_CALLABLE(GetActionProgress);
API_CALLABLE(SetActionProgress);
API_CALLABLE(GetActionResultTier);
API_CALLABLE(SetActionResultTier);

#endif
34 changes: 17 additions & 17 deletions src/battle/action_cmd/air_lift.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ API_CALLABLE(N(init)) {
// the target actor's HP and status. this value will ONLY be zero if the target actor
// is transparent, in which case a dummy version of the action command is played out
// which is guaranteed to fail.
acs->effectiveness = evt_get_variable(script, *args++);
acs->escapeChance = evt_get_variable(script, *args++);

acs->actionCommandID = ACTION_COMMAND_AIR_LIFT;
acs->showHud = TRUE;
Expand All @@ -48,7 +48,7 @@ API_CALLABLE(N(init)) {
acs->barFillWidth = 0;
acs->isBarFilled = FALSE;
battleStatus->actionSuccess = 0;
battleStatus->actionQuality = 0;
battleStatus->actionProgress = 0;

N(HasStarted) = FALSE;
acs->hudPrepareTime = 30;
Expand Down Expand Up @@ -153,7 +153,7 @@ void N(update)(void) {

hud_element_set_script(acs->hudElements[HIDX_BUTTON], &HES_MashAButton);
N(HasStarted) = TRUE;
acs->frameCounter = acs->duration;
acs->stateTimer = acs->duration;
sfx_play_sound_with_params(SOUND_LOOP_CHARGE_BAR, 0, 0, 0);
acs->state = AC_STATE_ACTIVE;

Expand All @@ -163,7 +163,7 @@ void N(update)(void) {

// bar can drain if it hasn't been fully filled
if (!acs->isBarFilled) {
if (acs->effectiveness != 0) {
if (acs->escapeChance != 0) {
s32 maxFillLevel = acs->mashMeterCutoffs[acs->mashMeterNumIntervals];
acs->barFillLevel -= GET_DRAIN_RATE(acs->barFillLevel / maxFillLevel);
if (acs->barFillLevel < 0) {
Expand All @@ -179,10 +179,10 @@ void N(update)(void) {

// check for bar-filling input
if (battleStatus->actionCommandMode != AC_MODE_NOT_LEARNED && (battleStatus->curButtonsPressed & BUTTON_A)) {
if (acs->effectiveness != 0) {
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->effectiveness;
s32 effectivenessPct = METER_FILL_RATE * acs->escapeChance;
// divide by 100 for each percent-based multiplier
acs->barFillLevel += (difficultyPct * effectivenessPct) / (100 * 100);
} else {
Expand All @@ -203,22 +203,22 @@ void N(update)(void) {
}

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

if (acs->frameCounter != 0) {
acs->frameCounter--;
if (acs->stateTimer != 0) {
acs->stateTimer--;
return;
}

if (acs->effectiveness == 0) {
battleStatus->actionQuality = 0;
if (acs->escapeChance == 0) {
battleStatus->actionProgress = 0;
}

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

btl_set_popup_duration(POPUP_MSG_OFF);
sfx_stop_sound(SOUND_LOOP_CHARGE_BAR);
acs->frameCounter = 20;
acs->stateTimer = 20;
acs->state = AC_STATE_DISPOSE;
break;
case AC_STATE_DISPOSE:
if (acs->effectiveness == 0) {
if (acs->escapeChance == 0) {
acs->barFillLevel -= ONE_PCT_MASH;
if (acs->barFillLevel < 0) {
acs->barFillLevel = 0;
}
}
if (acs->frameCounter != 0) {
acs->frameCounter--;
if (acs->stateTimer != 0) {
acs->stateTimer--;
return;
}
action_command_free();
Expand Down
62 changes: 46 additions & 16 deletions src/battle/action_cmd/air_raid.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,37 @@ API_CALLABLE(N(init)) {
return ApiStatus_DONE2;
}

#include "common/MashCommandStart.inc.c"
API_CALLABLE(N(start)) {
ActionCommandStatus* acs = &gActionCommandStatus;
BattleStatus* battleStatus = &gBattleStatus;
Bytecode* args = script->ptrReadPos;

if (battleStatus->actionCommandMode == AC_MODE_NOT_LEARNED) {
battleStatus->actionSuccess = 0;
return ApiStatus_DONE2;
}

action_command_init_status();

acs->prepareTime = evt_get_variable(script, *args++);
acs->duration = evt_get_variable(script, *args++);
acs->difficulty = evt_get_variable(script, *args++);
acs->difficulty = adjust_action_command_difficulty(acs->difficulty);
acs->statusChance = evt_get_variable(script, *args++); // unused

acs->wrongButtonPressed = FALSE;
acs->barFillLevel = 0;
acs->barFillWidth = 0;
battleStatus->actionSuccess = 0;
battleStatus->actionResult = ACTION_RESULT_NONE;
battleStatus->maxActionSuccess = acs->mashMeterCutoffs[(acs->mashMeterNumIntervals - 1)];
battleStatus->flags1 &= ~BS_FLAGS1_FREE_ACTION_COMMAND;
acs->state = AC_STATE_START;

increment_action_command_attempt_count();

return ApiStatus_DONE2;
}

void N(update)(void) {
ActionCommandStatus* acs = &gActionCommandStatus;
Expand Down Expand Up @@ -129,7 +159,7 @@ void N(update)(void) {
acs->barFillLevel = 0;
battleStatus->resultTier = 0;
acs->airRaid.holdingLeft = FALSE;
acs->frameCounter = acs->duration;
acs->stateTimer = acs->duration;
sfx_play_sound_with_params(SOUND_LOOP_CHARGE_BAR, 0, 0, 0);
acs->state = AC_STATE_ACTIVE;

Expand Down Expand Up @@ -179,40 +209,40 @@ void N(update)(void) {
hud_element_clear_flags(hid, HUD_ELEMENT_FLAG_DISABLED);
}

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

// resultTier is not used by this move; uses actionQuality instead via the move script
// resultTier is not used by this move; uses actionProgress instead via the move script
switch (partner->actorBlueprint->level) {
case PARTNER_RANK_NORMAL:
if (battleStatus->actionQuality >= N(BasicThresholds)[battleStatus->resultTier]) {
if (battleStatus->actionProgress >= N(BasicThresholds)[battleStatus->resultTier]) {
battleStatus->resultTier++;
}

if (battleStatus->resultTier > 0 && battleStatus->actionQuality < N(BasicThresholds)[battleStatus->resultTier - 1]) {
if (battleStatus->resultTier > 0 && battleStatus->actionProgress < N(BasicThresholds)[battleStatus->resultTier - 1]) {
battleStatus->resultTier--;
}
break;
case PARTNER_RANK_SUPER:
if (battleStatus->actionQuality >= N(SuperThresholds)[battleStatus->resultTier]) {
if (battleStatus->actionProgress >= N(SuperThresholds)[battleStatus->resultTier]) {
battleStatus->resultTier++;
}
if (battleStatus->resultTier > 0 && battleStatus->actionQuality < N(SuperThresholds)[battleStatus->resultTier - 1]) {
if (battleStatus->resultTier > 0 && battleStatus->actionProgress < N(SuperThresholds)[battleStatus->resultTier - 1]) {
battleStatus->resultTier--;
}
break;
case PARTNER_RANK_ULTRA:
if (battleStatus->actionQuality >= N(UltraThresholds)[battleStatus->resultTier]) {
if (battleStatus->actionProgress >= N(UltraThresholds)[battleStatus->resultTier]) {
battleStatus->resultTier++;
}
if (battleStatus->resultTier > 0 && battleStatus->actionQuality < N(UltraThresholds)[battleStatus->resultTier - 1]) {
if (battleStatus->resultTier > 0 && battleStatus->actionProgress < N(UltraThresholds)[battleStatus->resultTier - 1]) {
battleStatus->resultTier--;
}
break;
}

if (acs->frameCounter != 0) {
acs->frameCounter--;
if (acs->stateTimer != 0) {
acs->stateTimer--;
return;
}

Expand All @@ -236,12 +266,12 @@ void N(update)(void) {

btl_set_popup_duration(POPUP_MSG_OFF);
sfx_stop_sound(SOUND_LOOP_CHARGE_BAR);
acs->frameCounter = 5;
acs->stateTimer = 5;
acs->state = AC_STATE_DISPOSE;
break;
case AC_STATE_DISPOSE:
if (acs->frameCounter != 0) {
acs->frameCounter--;
if (acs->stateTimer != 0) {
acs->stateTimer--;
return;
}
action_command_free();
Expand Down
Loading

0 comments on commit a2db06f

Please sign in to comment.