STAT_ANIM constant usage

This commit is contained in:
GriffinR 2023-08-04 16:27:45 -04:00
parent da238562f0
commit 41847cd5aa
5 changed files with 71 additions and 60 deletions

View File

@ -192,14 +192,26 @@ u8 GetBattlerSpriteDefault_Y(u8 battlerId);
u8 GetSubstituteSpriteDefault_Y(u8 battlerId); u8 GetSubstituteSpriteDefault_Y(u8 battlerId);
// battle_anim_status_effects.c // battle_anim_status_effects.c
#define STAT_ANIM_PLUS1 15 #define STAT_ANIM_PLUS1 14
#define STAT_ANIM_PLUS2 39 #define STAT_ANIM_PLUS2 38
#define STAT_ANIM_MINUS1 22 #define STAT_ANIM_MINUS1 21
#define STAT_ANIM_MINUS2 46 #define STAT_ANIM_MINUS2 45
#define STAT_ANIM_MULTIPLE_PLUS1 55 #define STAT_ANIM_MULTIPLE_PLUS1 55
#define STAT_ANIM_MULTIPLE_PLUS2 56 #define STAT_ANIM_MULTIPLE_PLUS2 56
#define STAT_ANIM_MULTIPLE_MINUS1 57 #define STAT_ANIM_MULTIPLE_MINUS1 57
#define STAT_ANIM_MULTIPLE_MINUS2 58 #define STAT_ANIM_MULTIPLE_MINUS2 58
enum {
STAT_ANIM_PAL_ATK,
STAT_ANIM_PAL_DEF,
STAT_ANIM_PAL_ACC,
STAT_ANIM_PAL_SPEED,
STAT_ANIM_PAL_EVASION,
STAT_ANIM_PAL_SPATK,
STAT_ANIM_PAL_SPDEF,
STAT_ANIM_PAL_MULTIPLE = 0xFF
};
void LaunchStatusAnimation(u8 battlerId, u8 statusAnimId); void LaunchStatusAnimation(u8 battlerId, u8 statusAnimId);
// battle_anim_ground.c // battle_anim_ground.c

View File

@ -480,8 +480,6 @@ static void AnimTask_FrozenIceCube_Step4(u8 taskId)
} }
} }
#define CASE(by, stat) case (STAT_ANIM_##by + stat - 1)
void AnimTask_StatsChange(u8 taskId) void AnimTask_StatsChange(u8 taskId)
{ {
bool16 goesDown = FALSE; bool16 goesDown = FALSE;
@ -490,42 +488,42 @@ void AnimTask_StatsChange(u8 taskId)
switch (gBattleSpritesDataPtr->animationData->animArg) switch (gBattleSpritesDataPtr->animationData->animArg)
{ {
CASE(PLUS1, STAT_ATK): goesDown = FALSE; animStatId = 0; break; case STAT_ANIM_PLUS1 + STAT_ATK: goesDown = FALSE; animStatId = STAT_ANIM_PAL_ATK; break;
CASE(PLUS1, STAT_DEF): goesDown = FALSE; animStatId = 1; break; case STAT_ANIM_PLUS1 + STAT_DEF: goesDown = FALSE; animStatId = STAT_ANIM_PAL_DEF; break;
CASE(PLUS1, STAT_SPEED): goesDown = FALSE; animStatId = 3; break; case STAT_ANIM_PLUS1 + STAT_SPEED: goesDown = FALSE; animStatId = STAT_ANIM_PAL_SPEED; break;
CASE(PLUS1, STAT_SPATK): goesDown = FALSE; animStatId = 5; break; case STAT_ANIM_PLUS1 + STAT_SPATK: goesDown = FALSE; animStatId = STAT_ANIM_PAL_SPATK; break;
CASE(PLUS1, STAT_SPDEF): goesDown = FALSE; animStatId = 6; break; case STAT_ANIM_PLUS1 + STAT_SPDEF: goesDown = FALSE; animStatId = STAT_ANIM_PAL_SPDEF; break;
CASE(PLUS1, STAT_ACC): goesDown = FALSE; animStatId = 2; break; case STAT_ANIM_PLUS1 + STAT_ACC: goesDown = FALSE; animStatId = STAT_ANIM_PAL_ACC; break;
CASE(PLUS1, STAT_EVASION): goesDown = FALSE; animStatId = 4; break; case STAT_ANIM_PLUS1 + STAT_EVASION: goesDown = FALSE; animStatId = STAT_ANIM_PAL_EVASION; break;
CASE(MINUS1, STAT_ATK): goesDown = TRUE; animStatId = 0; break; case STAT_ANIM_MINUS1 + STAT_ATK: goesDown = TRUE; animStatId = STAT_ANIM_PAL_ATK; break;
CASE(MINUS1, STAT_DEF): goesDown = TRUE; animStatId = 1; break; case STAT_ANIM_MINUS1 + STAT_DEF: goesDown = TRUE; animStatId = STAT_ANIM_PAL_DEF; break;
CASE(MINUS1, STAT_SPEED): goesDown = TRUE; animStatId = 3; break; case STAT_ANIM_MINUS1 + STAT_SPEED: goesDown = TRUE; animStatId = STAT_ANIM_PAL_SPEED; break;
CASE(MINUS1, STAT_SPATK): goesDown = TRUE; animStatId = 5; break; case STAT_ANIM_MINUS1 + STAT_SPATK: goesDown = TRUE; animStatId = STAT_ANIM_PAL_SPATK; break;
CASE(MINUS1, STAT_SPDEF): goesDown = TRUE; animStatId = 6; break; case STAT_ANIM_MINUS1 + STAT_SPDEF: goesDown = TRUE; animStatId = STAT_ANIM_PAL_SPDEF; break;
CASE(MINUS1, STAT_ACC): goesDown = TRUE; animStatId = 2; break; case STAT_ANIM_MINUS1 + STAT_ACC: goesDown = TRUE; animStatId = STAT_ANIM_PAL_ACC; break;
CASE(MINUS1, STAT_EVASION): goesDown = TRUE; animStatId = 4; break; case STAT_ANIM_MINUS1 + STAT_EVASION: goesDown = TRUE; animStatId = STAT_ANIM_PAL_EVASION; break;
CASE(PLUS2, STAT_ATK): goesDown = FALSE; animStatId = 0; sharply = TRUE; break; case STAT_ANIM_PLUS2 + STAT_ATK: goesDown = FALSE; animStatId = STAT_ANIM_PAL_ATK; sharply = TRUE; break;
CASE(PLUS2, STAT_DEF): goesDown = FALSE; animStatId = 1; sharply = TRUE; break; case STAT_ANIM_PLUS2 + STAT_DEF: goesDown = FALSE; animStatId = STAT_ANIM_PAL_DEF; sharply = TRUE; break;
CASE(PLUS2, STAT_SPEED): goesDown = FALSE; animStatId = 3; sharply = TRUE; break; case STAT_ANIM_PLUS2 + STAT_SPEED: goesDown = FALSE; animStatId = STAT_ANIM_PAL_SPEED; sharply = TRUE; break;
CASE(PLUS2, STAT_SPATK): goesDown = FALSE; animStatId = 5; sharply = TRUE; break; case STAT_ANIM_PLUS2 + STAT_SPATK: goesDown = FALSE; animStatId = STAT_ANIM_PAL_SPATK; sharply = TRUE; break;
CASE(PLUS2, STAT_SPDEF): goesDown = FALSE; animStatId = 6; sharply = TRUE; break; case STAT_ANIM_PLUS2 + STAT_SPDEF: goesDown = FALSE; animStatId = STAT_ANIM_PAL_SPDEF; sharply = TRUE; break;
CASE(PLUS2, STAT_ACC): goesDown = FALSE; animStatId = 2; sharply = TRUE; break; case STAT_ANIM_PLUS2 + STAT_ACC: goesDown = FALSE; animStatId = STAT_ANIM_PAL_ACC; sharply = TRUE; break;
CASE(PLUS2, STAT_EVASION): goesDown = FALSE; animStatId = 4; sharply = TRUE; break; case STAT_ANIM_PLUS2 + STAT_EVASION: goesDown = FALSE; animStatId = STAT_ANIM_PAL_EVASION; sharply = TRUE; break;
CASE(MINUS2, STAT_ATK): goesDown = TRUE; animStatId = 0; sharply = TRUE; break; case STAT_ANIM_MINUS2 + STAT_ATK: goesDown = TRUE; animStatId = STAT_ANIM_PAL_ATK; sharply = TRUE; break;
CASE(MINUS2, STAT_DEF): goesDown = TRUE; animStatId = 1; sharply = TRUE; break; case STAT_ANIM_MINUS2 + STAT_DEF: goesDown = TRUE; animStatId = STAT_ANIM_PAL_DEF; sharply = TRUE; break;
CASE(MINUS2, STAT_SPEED): goesDown = TRUE; animStatId = 3; sharply = TRUE; break; case STAT_ANIM_MINUS2 + STAT_SPEED: goesDown = TRUE; animStatId = STAT_ANIM_PAL_SPEED; sharply = TRUE; break;
CASE(MINUS2, STAT_SPATK): goesDown = TRUE; animStatId = 5; sharply = TRUE; break; case STAT_ANIM_MINUS2 + STAT_SPATK: goesDown = TRUE; animStatId = STAT_ANIM_PAL_SPATK; sharply = TRUE; break;
CASE(MINUS2, STAT_SPDEF): goesDown = TRUE; animStatId = 6; sharply = TRUE; break; case STAT_ANIM_MINUS2 + STAT_SPDEF: goesDown = TRUE; animStatId = STAT_ANIM_PAL_SPDEF; sharply = TRUE; break;
CASE(MINUS2, STAT_ACC): goesDown = TRUE; animStatId = 2; sharply = TRUE; break; case STAT_ANIM_MINUS2 + STAT_ACC: goesDown = TRUE; animStatId = STAT_ANIM_PAL_ACC; sharply = TRUE; break;
CASE(MINUS2, STAT_EVASION): goesDown = TRUE; animStatId = 4; sharply = TRUE; break; case STAT_ANIM_MINUS2 + STAT_EVASION: goesDown = TRUE; animStatId = STAT_ANIM_PAL_EVASION; sharply = TRUE; break;
case STAT_ANIM_MULTIPLE_PLUS1: goesDown = FALSE; animStatId = 0xFF; sharply = FALSE; break; case STAT_ANIM_MULTIPLE_PLUS1: goesDown = FALSE; animStatId = STAT_ANIM_PAL_MULTIPLE; sharply = FALSE; break;
case STAT_ANIM_MULTIPLE_PLUS2: goesDown = FALSE; animStatId = 0xFF; sharply = TRUE; break; case STAT_ANIM_MULTIPLE_PLUS2: goesDown = FALSE; animStatId = STAT_ANIM_PAL_MULTIPLE; sharply = TRUE; break;
case STAT_ANIM_MULTIPLE_MINUS1: goesDown = TRUE; animStatId = 0xFF; sharply = FALSE; break; case STAT_ANIM_MULTIPLE_MINUS1: goesDown = TRUE; animStatId = STAT_ANIM_PAL_MULTIPLE; sharply = FALSE; break;
case STAT_ANIM_MULTIPLE_MINUS2: goesDown = TRUE; animStatId = 0xFF; sharply = TRUE; break; case STAT_ANIM_MULTIPLE_MINUS2: goesDown = TRUE; animStatId = STAT_ANIM_PAL_MULTIPLE; sharply = TRUE; break;
default: default:
DestroyAnimVisualTask(taskId); DestroyAnimVisualTask(taskId);
@ -538,7 +536,7 @@ void AnimTask_StatsChange(u8 taskId)
gBattleAnimArgs[3] = 0; gBattleAnimArgs[3] = 0;
gBattleAnimArgs[4] = sharply; gBattleAnimArgs[4] = sharply;
gTasks[taskId].func = InitStatsChangeAnimation; gTasks[taskId].func = InitStatsChangeAnimation;
InitStatsChangeAnimation(taskId); gTasks[taskId].func(taskId);
} }
#undef CASE #undef CASE

View File

@ -393,7 +393,7 @@ void InitStatsChangeAnimation(u8 taskId)
u8 i; u8 i;
sAnimStatsChangeData = AllocZeroed(sizeof(struct AnimStatsChangeData)); sAnimStatsChangeData = AllocZeroed(sizeof(struct AnimStatsChangeData));
for (i = 0; i < 8; i++) for (i = 0; i < ARRAY_COUNT(sAnimStatsChangeData->data); i++)
sAnimStatsChangeData->data[i] = gBattleAnimArgs[i]; sAnimStatsChangeData->data[i] = gBattleAnimArgs[i];
gTasks[taskId].func = StatsChangeAnimation_Step1; gTasks[taskId].func = StatsChangeAnimation_Step1;
@ -477,28 +477,29 @@ static void StatsChangeAnimation_Step2(u8 taskId)
AnimLoadCompressedBgGfx(animBgData.bgId, gBattleStatMask_Gfx, animBgData.tilesOffset); AnimLoadCompressedBgGfx(animBgData.bgId, gBattleStatMask_Gfx, animBgData.tilesOffset);
switch (sAnimStatsChangeData->data[1]) switch (sAnimStatsChangeData->data[1])
{ {
case 0: case STAT_ANIM_PAL_ATK:
LoadCompressedPalette(gBattleStatMask2_Pal, BG_PLTT_ID(animBgData.paletteId), PLTT_SIZE_4BPP); LoadCompressedPalette(gBattleStatMask2_Pal, BG_PLTT_ID(animBgData.paletteId), PLTT_SIZE_4BPP);
break; break;
case 1: case STAT_ANIM_PAL_DEF:
LoadCompressedPalette(gBattleStatMask1_Pal, BG_PLTT_ID(animBgData.paletteId), PLTT_SIZE_4BPP); LoadCompressedPalette(gBattleStatMask1_Pal, BG_PLTT_ID(animBgData.paletteId), PLTT_SIZE_4BPP);
break; break;
case 2: case STAT_ANIM_PAL_ACC:
LoadCompressedPalette(gBattleStatMask3_Pal, BG_PLTT_ID(animBgData.paletteId), PLTT_SIZE_4BPP); LoadCompressedPalette(gBattleStatMask3_Pal, BG_PLTT_ID(animBgData.paletteId), PLTT_SIZE_4BPP);
break; break;
case 3: case STAT_ANIM_PAL_SPEED:
LoadCompressedPalette(gBattleStatMask4_Pal, BG_PLTT_ID(animBgData.paletteId), PLTT_SIZE_4BPP); LoadCompressedPalette(gBattleStatMask4_Pal, BG_PLTT_ID(animBgData.paletteId), PLTT_SIZE_4BPP);
break; break;
case 4: case STAT_ANIM_PAL_EVASION:
LoadCompressedPalette(gBattleStatMask6_Pal, BG_PLTT_ID(animBgData.paletteId), PLTT_SIZE_4BPP); LoadCompressedPalette(gBattleStatMask6_Pal, BG_PLTT_ID(animBgData.paletteId), PLTT_SIZE_4BPP);
break; break;
case 5: case STAT_ANIM_PAL_SPATK:
LoadCompressedPalette(gBattleStatMask7_Pal, BG_PLTT_ID(animBgData.paletteId), PLTT_SIZE_4BPP); LoadCompressedPalette(gBattleStatMask7_Pal, BG_PLTT_ID(animBgData.paletteId), PLTT_SIZE_4BPP);
break; break;
case 6: case STAT_ANIM_PAL_SPDEF:
LoadCompressedPalette(gBattleStatMask8_Pal, BG_PLTT_ID(animBgData.paletteId), PLTT_SIZE_4BPP); LoadCompressedPalette(gBattleStatMask8_Pal, BG_PLTT_ID(animBgData.paletteId), PLTT_SIZE_4BPP);
break; break;
default: default:
// case STAT_ANIM_PAL_MULTIPLE:
LoadCompressedPalette(gBattleStatMask5_Pal, BG_PLTT_ID(animBgData.paletteId), PLTT_SIZE_4BPP); LoadCompressedPalette(gBattleStatMask5_Pal, BG_PLTT_ID(animBgData.paletteId), PLTT_SIZE_4BPP);
break; break;
} }

View File

@ -4061,16 +4061,16 @@ static void Cmd_setgraphicalstatchangevalues(void)
switch (GET_STAT_BUFF_VALUE2(gBattleScripting.statChanger)) switch (GET_STAT_BUFF_VALUE2(gBattleScripting.statChanger))
{ {
case SET_STAT_BUFF_VALUE(1): // +1 case SET_STAT_BUFF_VALUE(1): // +1
value = STAT_ANIM_PLUS1; value = STAT_ANIM_PLUS1 + 1;
break; break;
case SET_STAT_BUFF_VALUE(2): // +2 case SET_STAT_BUFF_VALUE(2): // +2
value = STAT_ANIM_PLUS2; value = STAT_ANIM_PLUS2 + 1;
break; break;
case SET_STAT_BUFF_VALUE(1) | STAT_BUFF_NEGATIVE: // -1 case SET_STAT_BUFF_VALUE(1) | STAT_BUFF_NEGATIVE: // -1
value = STAT_ANIM_MINUS1; value = STAT_ANIM_MINUS1 + 1;
break; break;
case SET_STAT_BUFF_VALUE(2) | STAT_BUFF_NEGATIVE: // -2 case SET_STAT_BUFF_VALUE(2) | STAT_BUFF_NEGATIVE: // -2
value = STAT_ANIM_MINUS2; value = STAT_ANIM_MINUS2 + 1;
break; break;
} }
gBattleScripting.animArg1 = GET_STAT_BUFF_ID(gBattleScripting.statChanger) + value - 1; gBattleScripting.animArg1 = GET_STAT_BUFF_ID(gBattleScripting.statChanger) + value - 1;
@ -4092,9 +4092,9 @@ static void Cmd_playstatchangeanimation(void)
{ {
s16 startingStatAnimId; s16 startingStatAnimId;
if (gBattlescriptCurrInstr[3] & STAT_CHANGE_BY_TWO) if (gBattlescriptCurrInstr[3] & STAT_CHANGE_BY_TWO)
startingStatAnimId = STAT_ANIM_MINUS2 - 1; startingStatAnimId = STAT_ANIM_MINUS2;
else else
startingStatAnimId = STAT_ANIM_MINUS1 - 1; startingStatAnimId = STAT_ANIM_MINUS1;
while (statsToCheck != 0) while (statsToCheck != 0)
{ {
@ -4136,9 +4136,9 @@ static void Cmd_playstatchangeanimation(void)
{ {
s16 startingStatAnimId; s16 startingStatAnimId;
if (gBattlescriptCurrInstr[3] & STAT_CHANGE_BY_TWO) if (gBattlescriptCurrInstr[3] & STAT_CHANGE_BY_TWO)
startingStatAnimId = STAT_ANIM_PLUS2 - 1; startingStatAnimId = STAT_ANIM_PLUS2;
else else
startingStatAnimId = STAT_ANIM_PLUS1 - 1; startingStatAnimId = STAT_ANIM_PLUS1;
while (statsToCheck != 0) while (statsToCheck != 0)
{ {

View File

@ -374,7 +374,7 @@ void HandleAction_UseItem(void)
gBattleTextBuff1[2]++; gBattleTextBuff1[2]++;
} }
gBattleScripting.animArg1 = gBattleTextBuff1[2] + 14; gBattleScripting.animArg1 = gBattleTextBuff1[2] + STAT_ANIM_PLUS1;
gBattleScripting.animArg2 = 0; gBattleScripting.animArg2 = 0;
} }
break; break;
@ -2625,7 +2625,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
if (gBattleMons[battler].statStages[STAT_SPEED] < MAX_STAT_STAGE && gDisableStructs[battler].isFirstTurn != 2) if (gBattleMons[battler].statStages[STAT_SPEED] < MAX_STAT_STAGE && gDisableStructs[battler].isFirstTurn != 2)
{ {
gBattleMons[battler].statStages[STAT_SPEED]++; gBattleMons[battler].statStages[STAT_SPEED]++;
gBattleScripting.animArg1 = 14 + STAT_SPEED; gBattleScripting.animArg1 = STAT_ANIM_PLUS1 + STAT_SPEED;
gBattleScripting.animArg2 = 0; gBattleScripting.animArg2 = 0;
BattleScriptPushCursorAndCallback(BattleScript_SpeedBoostActivates); BattleScriptPushCursorAndCallback(BattleScript_SpeedBoostActivates);
gBattleScripting.battler = battler; gBattleScripting.battler = battler;
@ -3229,7 +3229,7 @@ enum
PREPARE_STAT_BUFFER(gBattleTextBuff1, stat); \ PREPARE_STAT_BUFFER(gBattleTextBuff1, stat); \
gEffectBattler = battlerId; \ gEffectBattler = battlerId; \
SET_STATCHANGER(stat, 1, FALSE); \ SET_STATCHANGER(stat, 1, FALSE); \
gBattleScripting.animArg1 = 14 + (stat); \ gBattleScripting.animArg1 = STAT_ANIM_PLUS1 + (stat); \
gBattleScripting.animArg2 = 0; \ gBattleScripting.animArg2 = 0; \
BattleScriptExecute(BattleScript_BerryStatRaiseEnd2); \ BattleScriptExecute(BattleScript_BerryStatRaiseEnd2); \
effect = ITEM_STATS_CHANGE; \ effect = ITEM_STATS_CHANGE; \
@ -3415,7 +3415,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
PREPARE_STRING_BUFFER(gBattleTextBuff2, STRINGID_STATROSE); // Only the Attack stat-up berry has this PREPARE_STRING_BUFFER(gBattleTextBuff2, STRINGID_STATROSE); // Only the Attack stat-up berry has this
gEffectBattler = battlerId; gEffectBattler = battlerId;
SET_STATCHANGER(STAT_ATK, 1, FALSE); SET_STATCHANGER(STAT_ATK, 1, FALSE);
gBattleScripting.animArg1 = 14 + STAT_ATK; gBattleScripting.animArg1 = STAT_ANIM_PLUS1 + STAT_ATK;
gBattleScripting.animArg2 = 0; gBattleScripting.animArg2 = 0;
BattleScriptExecute(BattleScript_BerryStatRaiseEnd2); BattleScriptExecute(BattleScript_BerryStatRaiseEnd2);
effect = ITEM_STATS_CHANGE; effect = ITEM_STATS_CHANGE;
@ -3470,7 +3470,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
gEffectBattler = battlerId; gEffectBattler = battlerId;
SET_STATCHANGER(i + 1, 2, FALSE); SET_STATCHANGER(i + 1, 2, FALSE);
gBattleScripting.animArg1 = 0x21 + i + 6; gBattleScripting.animArg1 = STAT_ANIM_PLUS2 + (i + 1);
gBattleScripting.animArg2 = 0; gBattleScripting.animArg2 = 0;
BattleScriptExecute(BattleScript_BerryStatRaiseEnd2); BattleScriptExecute(BattleScript_BerryStatRaiseEnd2);
effect = ITEM_STATS_CHANGE; effect = ITEM_STATS_CHANGE;