diff --git a/asm/battle_anim_80A9C70.s b/asm/battle_anim_80A9C70.s index 7556531563..3515b973ee 100644 --- a/asm/battle_anim_80A9C70.s +++ b/asm/battle_anim_80A9C70.s @@ -623,8 +623,8 @@ _080AA186: bx r0 thumb_func_end sub_80AA124 - thumb_func_start sub_80AA18C -sub_80AA18C: @ 80AA18C + thumb_func_start AnimTask_StatsChange +AnimTask_StatsChange: @ 80AA18C push {r4,r5,lr} lsls r0, 24 lsrs r4, r0, 24 @@ -853,7 +853,7 @@ _080AA352: pop {r0} bx r0 .pool - thumb_func_end sub_80AA18C + thumb_func_end AnimTask_StatsChange thumb_func_start LaunchStatusAnimation LaunchStatusAnimation: @ 80AA364 diff --git a/data/battle_anim_scripts.s b/data/battle_anim_scripts.s index 727a62f3d6..624a5c69f5 100644 --- a/data/battle_anim_scripts.s +++ b/data/battle_anim_scripts.s @@ -10484,7 +10484,7 @@ AnimScript_82D7ECA: end Anim_StatChange: - createvisualtask sub_80AA18C, 0x5 + createvisualtask AnimTask_StatsChange, 0x5 waitforvisualfinish end diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 0487199b53..959258ea0b 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -2240,34 +2240,34 @@ BattleScript_EffectMemento:: setatkhptozero attackanimation waitanimation - jumpifstatus2 BS_TARGET, STATUS2_SUBSTITUTE, BattleScript_82DA148 - setbyte sFIELD_1B, 0x0 - playstatchangeanimation BS_TARGET, 0x12, 0x7 - playstatchangeanimation BS_TARGET, 0x2, 0x3 + jumpifstatus2 BS_TARGET, STATUS2_SUBSTITUTE, BattleScript_EffectMementoPrintNoEffect + setbyte sSTAT_ANIM_PLAYED, FALSE + playstatchangeanimation BS_TARGET, BIT_ATK | BIT_SPATK, ATK48_STAT_NEGATIVE | ATK48_STAT_BY_TWO | ATK48_ONLY_MULTIPLE + playstatchangeanimation BS_TARGET, BIT_ATK, ATK48_STAT_NEGATIVE | ATK48_STAT_BY_TWO setstatchanger STAT_ATK, 2, TRUE - statbuffchange 0x1, BattleScript_82DA119 - jumpifbyte CMP_GREATER_THAN, cMULTISTRING_CHOOSER, 0x1, BattleScript_82DA119 + statbuffchange 0x1, BattleScript_EffectMementoTrySpAtk + jumpifbyte CMP_GREATER_THAN, cMULTISTRING_CHOOSER, 0x1, BattleScript_EffectMementoTrySpAtk printfromtable gStatDownStringIds waitmessage 0x40 -BattleScript_82DA119:: - playstatchangeanimation BS_TARGET, 0x10, 0x3 +BattleScript_EffectMementoTrySpAtk: + playstatchangeanimation BS_TARGET, BIT_SPATK, ATK48_STAT_NEGATIVE | ATK48_STAT_BY_TWO setstatchanger STAT_SPATK, 2, TRUE - statbuffchange 0x1, BattleScript_82DA13C - jumpifbyte CMP_GREATER_THAN, cMULTISTRING_CHOOSER, 0x1, BattleScript_82DA13C + statbuffchange 0x1, BattleScript_EffectMementoTryFaint + jumpifbyte CMP_GREATER_THAN, cMULTISTRING_CHOOSER, 0x1, BattleScript_EffectMementoTryFaint printfromtable gStatDownStringIds waitmessage 0x40 -BattleScript_82DA13C:: +BattleScript_EffectMementoTryFaint: tryfaintmon BS_ATTACKER, FALSE, NULL goto BattleScript_MoveEnd -BattleScript_82DA148:: +BattleScript_EffectMementoPrintNoEffect: printstring STRINGID_BUTNOEFFECT waitmessage 0x40 - goto BattleScript_82DA13C -BattleScript_82DA153:: + goto BattleScript_EffectMementoTryFaint +BattleScript_82DA153: attackstring ppreduce jumpifattackandspecialattackcannotfall BattleScript_82DA15A -BattleScript_82DA15A:: +BattleScript_82DA15A: setatkhptozero pause 0x40 effectivenesssound @@ -2688,16 +2688,16 @@ BattleScript_TickleDoMoveAnim:: accuracycheck BattleScript_ButItFailed, ACC_CURR_MOVE attackanimation waitanimation - setbyte sFIELD_1B, 0x0 - playstatchangeanimation BS_TARGET, 0x6, 0x5 - playstatchangeanimation BS_TARGET, 0x2, 0x1 + setbyte sSTAT_ANIM_PLAYED, FALSE + playstatchangeanimation BS_TARGET, BIT_ATK | BIT_DEF, ATK48_STAT_NEGATIVE | ATK48_ONLY_MULTIPLE + playstatchangeanimation BS_TARGET, BIT_ATK, ATK48_STAT_NEGATIVE setstatchanger STAT_ATK, 1, TRUE statbuffchange 0x1, BattleScript_TickleTryLowerDef jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_TickleTryLowerDef printfromtable gStatDownStringIds waitmessage 0x40 BattleScript_TickleTryLowerDef:: - playstatchangeanimation BS_TARGET, 0x4, 0x1 + playstatchangeanimation BS_TARGET, BIT_DEF, ATK48_STAT_NEGATIVE setstatchanger STAT_DEF, 1, TRUE statbuffchange 0x1, BattleScript_TickleEnd jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_TickleEnd @@ -2722,8 +2722,8 @@ BattleScript_EffectCosmicPower:: BattleScript_CosmicPowerDoMoveAnim:: attackanimation waitanimation - setbyte sFIELD_1B, 0x0 - playstatchangeanimation BS_ATTACKER, 0x24, 0x0 + setbyte sSTAT_ANIM_PLAYED, FALSE + playstatchangeanimation BS_ATTACKER, BIT_DEF | BIT_SPDEF, 0x0 setstatchanger STAT_DEF, 1, FALSE statbuffchange MOVE_EFFECT_AFFECTS_USER | 0x1, BattleScript_CosmicPowerTrySpDef jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_CosmicPowerTrySpDef @@ -2751,8 +2751,8 @@ BattleScript_EffectBulkUp:: BattleScript_BulkUpDoMoveAnim:: attackanimation waitanimation - setbyte sFIELD_1B, 0x0 - playstatchangeanimation BS_ATTACKER, 0x6, 0x0 + setbyte sSTAT_ANIM_PLAYED, FALSE + playstatchangeanimation BS_ATTACKER, BIT_ATK | BIT_DEF, 0x0 setstatchanger STAT_ATK, 1, FALSE statbuffchange MOVE_EFFECT_AFFECTS_USER | 0x1, BattleScript_BulkUpTryDef jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_BulkUpTryDef @@ -2776,8 +2776,8 @@ BattleScript_EffectCalmMind:: BattleScript_CalmMindDoMoveAnim:: attackanimation waitanimation - setbyte sFIELD_1B, 0x0 - playstatchangeanimation BS_ATTACKER, 0x30, 0x0 + setbyte sSTAT_ANIM_PLAYED, FALSE + playstatchangeanimation BS_ATTACKER, BIT_SPATK | BIT_SPDEF, 0x0 setstatchanger STAT_SPATK, 1, FALSE statbuffchange MOVE_EFFECT_AFFECTS_USER | 0x1, BattleScript_CalmMindTrySpDef jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_CalmMindTrySpDef @@ -2808,8 +2808,8 @@ BattleScript_EffectDragonDance:: BattleScript_DragonDanceDoMoveAnim:: attackanimation waitanimation - setbyte sFIELD_1B, 0x0 - playstatchangeanimation BS_ATTACKER, 0xA, 0x0 + setbyte sSTAT_ANIM_PLAYED, FALSE + playstatchangeanimation BS_ATTACKER, BIT_ATK | BIT_SPEED, 0x0 setstatchanger STAT_ATK, 1, FALSE statbuffchange MOVE_EFFECT_AFFECTS_USER | 0x1, BattleScript_DragonDanceTrySpeed jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_DragonDanceTrySpeed @@ -3487,8 +3487,8 @@ BattleScript_AllStatsUp:: jumpifstat BS_ATTACKER, CMP_LESS_THAN, STAT_SPATK, 0xC, BattleScript_AllStatsUpAtk jumpifstat BS_ATTACKER, CMP_EQUAL, STAT_SPDEF, 0xC, BattleScript_AllStatsUpRet BattleScript_AllStatsUpAtk:: - setbyte sFIELD_1B, 0x0 - playstatchangeanimation BS_ATTACKER, 0x3E, 0x0 + setbyte sSTAT_ANIM_PLAYED, FALSE + playstatchangeanimation BS_ATTACKER, BIT_ATK | BIT_DEF | BIT_SPEED | BIT_SPATK | BIT_SPDEF, 0x0 setstatchanger STAT_ATK, 1, FALSE statbuffchange MOVE_EFFECT_AFFECTS_USER | 0x1, BattleScript_AllStatsUpDef printfromtable gStatUpStringIds @@ -3655,16 +3655,16 @@ BattleScript_PrintMonIsRooted:: goto BattleScript_MoveEnd BattleScript_AtkDefDown:: - setbyte sFIELD_1B, 0x0 - playstatchangeanimation BS_ATTACKER, 0x6, 0xD - playstatchangeanimation BS_ATTACKER, 0x2, 0x9 + setbyte sSTAT_ANIM_PLAYED, FALSE + playstatchangeanimation BS_ATTACKER, BIT_DEF | BIT_ATK, ATK48_DONT_CHECK_LOWER | ATK48_STAT_NEGATIVE | ATK48_ONLY_MULTIPLE + playstatchangeanimation BS_ATTACKER, BIT_ATK, ATK48_DONT_CHECK_LOWER | ATK48_STAT_NEGATIVE setstatchanger STAT_ATK, 1, TRUE statbuffchange MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN | 0x1, BattleScript_82DB144 jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_82DB144 printfromtable gStatDownStringIds waitmessage 0x40 BattleScript_82DB144:: - playstatchangeanimation BS_ATTACKER, 0x4, 0x9 + playstatchangeanimation BS_ATTACKER, BIT_DEF, ATK48_DONT_CHECK_LOWER | ATK48_STAT_NEGATIVE setstatchanger STAT_DEF, 1, TRUE statbuffchange MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN | 0x1, BattleScript_82DB167 jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_82DB167 @@ -3729,14 +3729,14 @@ BattleScript_OneHitKOMsg:: return BattleScript_SAtkDown2:: - setbyte sFIELD_1B, 0x0 - playstatchangeanimation BS_ATTACKER, 0x10, 0xB + setbyte sSTAT_ANIM_PLAYED, FALSE + playstatchangeanimation BS_ATTACKER, BIT_SPATK, ATK48_DONT_CHECK_LOWER | ATK48_STAT_NEGATIVE | ATK48_STAT_BY_TWO setstatchanger STAT_SPATK, 2, TRUE - statbuffchange MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN | 0x1, BattleScript_82DB1FE - jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_82DB1FE + statbuffchange MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN | 0x1, BattleScript_SAtkDown2End + jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_SAtkDown2End printfromtable gStatDownStringIds waitmessage 0x40 -BattleScript_82DB1FE:: +BattleScript_SAtkDown2End:: return BattleScript_FocusPunchSetUp:: diff --git a/include/battle.h b/include/battle.h index f6c50ea8a2..fae21908b3 100644 --- a/include/battle.h +++ b/include/battle.h @@ -568,10 +568,11 @@ struct BattleStruct } #define GET_STAT_BUFF_ID(n)((n & 0xF)) // first four bits 0x1, 0x2, 0x4, 0x8 +#define GET_STAT_BUFF_VALUE2(n)((n & 0xF0)) #define GET_STAT_BUFF_VALUE(n)(((n >> 4) & 7)) // 0x10, 0x20, 0x40 #define STAT_BUFF_NEGATIVE 0x80 // 0x80, the sign bit -#define SET_STAT_BUFF_VALUE(n)(((s8)(((s8)(n) << 4)) & 0xF0)) +#define SET_STAT_BUFF_VALUE(n)((((n) << 4) & 0xF0)) #define SET_STATCHANGER(statId, stage, goesDown)(gBattleScripting.statChanger = (statId) + (stage << 4) + (goesDown << 7)) @@ -592,7 +593,7 @@ struct BattleScripting u8 animTurn; u8 animTargetsHit; u8 statChanger; - u8 field_1B; + bool8 statAnimPlayed; u8 atk23_state; u8 battleStyle; u8 atk6C_state; diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index c820a1114d..84ec9d5125 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -17,7 +17,7 @@ #define sB_ANIM_TURN gBattleScripting + 0x18 #define sB_ANIM_TARGETS_HIT gBattleScripting + 0x19 #define sSTATCHANGER gBattleScripting + 0x1A -#define sFIELD_1B gBattleScripting + 0x1B +#define sSTAT_ANIM_PLAYED gBattleScripting + 0x1B #define sGIVEEXP_STATE gBattleScripting + 0x1C #define sBATTLE_STYLE gBattleScripting + 0x1D #define sLVLBOX_STATE gBattleScripting + 0x1E @@ -91,7 +91,16 @@ // atk48 #define ATK48_STAT_NEGATIVE 0x1 #define ATK48_STAT_BY_TWO 0x2 -#define ATK48_BIT_x4 0x4 +#define ATK48_ONLY_MULTIPLE 0x4 #define ATK48_DONT_CHECK_LOWER 0x8 +#define BIT_HP 0x1 +#define BIT_ATK 0x2 +#define BIT_DEF 0x4 +#define BIT_SPEED 0x8 +#define BIT_SPATK 0x10 +#define BIT_SPDEF 0x20 +#define BIT_ACC 0x40 +#define BIT_EVASION 0x80 + #endif // GUARD_CONSTANTS_BATTLE_SCRIPT_COMMANDS_H diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 3af03a5e0f..e688d0b409 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -4378,22 +4378,22 @@ static void atk46_playanimation2(void) // animation Id is stored in the first po static void atk47_setgraphicalstatchangevalues(void) { u8 value = 0; - switch (gBattleScripting.statChanger & 0xF0) + switch (GET_STAT_BUFF_VALUE2(gBattleScripting.statChanger)) { - case 0x10: // +1 + case SET_STAT_BUFF_VALUE(1): // +1 value = 0xF; break; - case 0x20: // +2 + case SET_STAT_BUFF_VALUE(2): // +2 value = 0x27; break; - case 0x90: // -1 + case SET_STAT_BUFF_VALUE(1) | STAT_BUFF_NEGATIVE: // -1 value = 0x16; break; - case 0xA0: // -2 + case SET_STAT_BUFF_VALUE(2) | STAT_BUFF_NEGATIVE: // -2 value = 0x2E; break; } - gBattleScripting.animArg1 = (gBattleScripting.statChanger & 0xF) + value - 1; + gBattleScripting.animArg1 = GET_STAT_BUFF_ID(gBattleScripting.statChanger) + value - 1; gBattleScripting.animArg2 = 0; gBattlescriptCurrInstr++; } @@ -4479,16 +4479,16 @@ static void atk48_playstatchangeanimation(void) } } - if (gBattlescriptCurrInstr[3] & ATK48_BIT_x4 && changeableStatsCount < 2) + if (gBattlescriptCurrInstr[3] & ATK48_ONLY_MULTIPLE && changeableStatsCount < 2) { gBattlescriptCurrInstr += 4; } - else if (changeableStatsCount != 0 && gBattleScripting.field_1B == 0) + else if (changeableStatsCount != 0 && !gBattleScripting.statAnimPlayed) { BtlController_EmitBattleAnimation(0, B_ANIM_STATS_CHANGE, statAnimId); MarkBattlerForControllerExec(gActiveBattler); - if (gBattlescriptCurrInstr[3] & ATK48_BIT_x4 && changeableStatsCount > 1) - gBattleScripting.field_1B = 1; + if (gBattlescriptCurrInstr[3] & ATK48_ONLY_MULTIPLE && changeableStatsCount > 1) + gBattleScripting.statAnimPlayed = TRUE; gBattlescriptCurrInstr += 4; } else