atk 48 is really troublesome

This commit is contained in:
DizzyEggg 2017-09-23 00:06:52 +02:00
parent d5afb0c6e9
commit fc57c6c817
2 changed files with 39 additions and 33 deletions

View File

@ -784,6 +784,11 @@ extern struct BattleStruct* gBattleStruct;
#define B_ANIM_x1C 0x1C
#define B_ANIM_x1D 0x1D
#define ATK48_STAT_NEGATIVE 0x1
#define ATK48_STAT_BY_TWO 0x2
#define ATK48_BIT_x4 0x4
#define ATK48_LOWER_FAIL_CHECK 0x8
#define GET_STAT_BUFF_ID(n)((n & 0xF)) // first four bits 0x1, 0x2, 0x4, 0x8
#define GET_STAT_BUFF_VALUE(n)((n & 0xF0) >> 4) // 0x10, 0x20, 0x40
#define STAT_BUFF_NEGATIVE 0x80 // 0x80, the sign bit

View File

@ -4271,48 +4271,49 @@ void atk47_setgraphicalstatchangevalues(void)
void atk48_playstatchangeanimation(void)
{
s32 currStat = 0;
u32 currStat = 0;
s16 statAnimId = 0;
s32 checkingStatAnimId = 0;
s16 checkingStatAnimId = 0;
s32 changeableStats = 0;
u32 statsToCheck = 0;
gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1));
statsToCheck = BSScriptRead8(gBattlescriptCurrInstr + 2);
gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]);
statsToCheck = gBattlescriptCurrInstr[2];
if (gBattlescriptCurrInstr[3] & 1) // goes down
if (gBattlescriptCurrInstr[3] & ATK48_STAT_NEGATIVE) // goes down
{
for (checkingStatAnimId = (gBattlescriptCurrInstr[3] & 0x2) ? 0x2D : 0x15;
statsToCheck != 0;
statsToCheck >>= 1, checkingStatAnimId += 1, currStat++)
checkingStatAnimId = (gBattlescriptCurrInstr[3] & ATK48_STAT_BY_TWO) ? 0x2D : 0x15;
while (statsToCheck != 0)
{
if (!(statsToCheck & 1))
continue;
if (!(gBattlescriptCurrInstr[3] & 8))
if (statsToCheck & 1)
{
if (gBattleMons[gActiveBank].statStages[currStat] > 0)
if (!(gBattlescriptCurrInstr[3] & ATK48_LOWER_FAIL_CHECK))
{
statAnimId = checkingStatAnimId;
changeableStats++;
}
}
else if (!gSideTimers[GET_BANK_SIDE(gActiveBank)].mistTimer
&& gBattleMons[gActiveBank].ability != ABILITY_CLEAR_BODY
&& gBattleMons[gActiveBank].ability != ABILITY_WHITE_SMOKE
&& !(gBattleMons[gActiveBank].ability == ABILITY_KEEN_EYE && currStat == STAT_STAGE_ACC)
&& !(gBattleMons[gActiveBank].ability == ABILITY_HYPER_CUTTER && currStat == STAT_STAGE_ATK))
{
if (gBattleMons[gActiveBank].statStages[currStat] > 0)
{
statAnimId = checkingStatAnimId;
changeableStats++;
if (gBattleMons[gActiveBank].statStages[currStat] > 0)
{
statAnimId = checkingStatAnimId;
changeableStats++;
}
}
else if (!gSideTimers[GET_BANK_SIDE(gActiveBank)].mistTimer
&& gBattleMons[gActiveBank].ability != ABILITY_CLEAR_BODY
&& gBattleMons[gActiveBank].ability != ABILITY_WHITE_SMOKE
&& !(gBattleMons[gActiveBank].ability == ABILITY_KEEN_EYE && currStat == STAT_STAGE_ACC)
&& !(gBattleMons[gActiveBank].ability == ABILITY_HYPER_CUTTER && currStat == STAT_STAGE_ATK))
{
if (gBattleMons[gActiveBank].statStages[currStat] > 0)
{
statAnimId = checkingStatAnimId;
changeableStats++;
}
}
}
statsToCheck >>= 1, checkingStatAnimId++, currStat++;
}
if (changeableStats > 1) // more than one stat, so the color is gray
{
if (gBattlescriptCurrInstr[3] & 2)
if (gBattlescriptCurrInstr[3] & ATK48_STAT_BY_TWO)
statAnimId = 0x3A;
else
statAnimId = 0x39;
@ -4320,27 +4321,27 @@ void atk48_playstatchangeanimation(void)
}
else // goes up
{
for (checkingStatAnimId = (gBattlescriptCurrInstr[3] & 0x2) ? 0x26 : 0xE;
statsToCheck != 0;
statsToCheck >>= 1, checkingStatAnimId += 1, currStat++)
checkingStatAnimId = (gBattlescriptCurrInstr[3] & ATK48_STAT_BY_TWO) ? 0x26 : 0xE;
while (statsToCheck != 0)
{
if (statsToCheck & 1 && gBattleMons[gActiveBank].statStages[currStat] < 0xC)
{
statAnimId = checkingStatAnimId;
changeableStats++;
}
statsToCheck >>= 1, checkingStatAnimId += 1, currStat++;
}
if (changeableStats > 1) // more than one stat, so the color is gray
{
if (gBattlescriptCurrInstr[3] & 2)
if (gBattlescriptCurrInstr[3] & ATK48_STAT_BY_TWO)
statAnimId = 0x38;
else
statAnimId = 0x37;
}
}
if (gBattlescriptCurrInstr[3] & 4 && changeableStats < 2)
if (gBattlescriptCurrInstr[3] & ATK48_BIT_x4 && changeableStats < 2)
{
gBattlescriptCurrInstr += 4;
}
@ -4348,7 +4349,7 @@ void atk48_playstatchangeanimation(void)
{
EmitBattleAnimation(0, B_ANIM_STATS_CHANGE, statAnimId);
MarkBufferBankForExecution(gActiveBank);
if (gBattlescriptCurrInstr[3] & 4 && changeableStats > 1)
if (gBattlescriptCurrInstr[3] & ATK48_BIT_x4 && changeableStats > 1)
gBattleScripting.field_1B = 1;
gBattlescriptCurrInstr += 4;
}