get rid of goto in battle_script_commands

This commit is contained in:
jiangzhengwenjz 2019-08-28 06:06:17 +08:00
parent 8e7abad720
commit 4f9052cb96

View file

@ -1681,17 +1681,11 @@ static void atk07_adjustnormaldamage(void)
RecordItemEffectBattle(gBattlerTarget, holdEffect);
gSpecialStatuses[gBattlerTarget].focusBanded = 1;
}
if (gBattleMons[gBattlerTarget].status2 & STATUS2_SUBSTITUTE)
goto END;
if (gBattleMoves[gCurrentMove].effect != EFFECT_FALSE_SWIPE && !gProtectStructs[gBattlerTarget].endured
&& !gSpecialStatuses[gBattlerTarget].focusBanded)
goto END;
if (gBattleMons[gBattlerTarget].hp > gBattleMoveDamage)
goto END;
if (!(gBattleMons[gBattlerTarget].status2 & STATUS2_SUBSTITUTE)
&& (gBattleMoves[gCurrentMove].effect == EFFECT_FALSE_SWIPE || gProtectStructs[gBattlerTarget].endured || gSpecialStatuses[gBattlerTarget].focusBanded)
&& gBattleMons[gBattlerTarget].hp <= gBattleMoveDamage)
{
gBattleMoveDamage = gBattleMons[gBattlerTarget].hp - 1;
if (gProtectStructs[gBattlerTarget].endured)
{
gMoveResultFlags |= MOVE_RESULT_FOE_ENDURED;
@ -1701,8 +1695,7 @@ static void atk07_adjustnormaldamage(void)
gMoveResultFlags |= MOVE_RESULT_FOE_HUNG_ON;
gLastUsedItem = gBattleMons[gBattlerTarget].item;
}
END:
}
gBattlescriptCurrInstr++;
}
@ -1730,15 +1723,11 @@ static void atk08_adjustnormaldamage2(void) // The same as 0x7 except it doesn't
RecordItemEffectBattle(gBattlerTarget, holdEffect);
gSpecialStatuses[gBattlerTarget].focusBanded = 1;
}
if (gBattleMons[gBattlerTarget].status2 & STATUS2_SUBSTITUTE)
goto END;
if (!gProtectStructs[gBattlerTarget].endured && !gSpecialStatuses[gBattlerTarget].focusBanded)
goto END;
if (gBattleMons[gBattlerTarget].hp > gBattleMoveDamage)
goto END;
if (!(gBattleMons[gBattlerTarget].status2 & STATUS2_SUBSTITUTE)
&& (gProtectStructs[gBattlerTarget].endured || gSpecialStatuses[gBattlerTarget].focusBanded)
&& gBattleMons[gBattlerTarget].hp <= gBattleMoveDamage)
{
gBattleMoveDamage = gBattleMons[gBattlerTarget].hp - 1;
if (gProtectStructs[gBattlerTarget].endured)
{
gMoveResultFlags |= MOVE_RESULT_FOE_ENDURED;
@ -1748,8 +1737,7 @@ static void atk08_adjustnormaldamage2(void) // The same as 0x7 except it doesn't
gMoveResultFlags |= MOVE_RESULT_FOE_HUNG_ON;
gLastUsedItem = gBattleMons[gBattlerTarget].item;
}
END:
}
gBattlescriptCurrInstr++;
}
@ -4564,27 +4552,26 @@ static void atk49_moveend(void)
gBattleScripting.atk49_state++;
break;
case ATK49_CHOICE_MOVE: // update choice band move
if (!(gHitMarker & HITMARKER_OBEYS) || holdEffectAtk != HOLD_EFFECT_CHOICE_BAND
|| gChosenMove == MOVE_STRUGGLE || (*choicedMoveAtk != 0 && *choicedMoveAtk != 0xFFFF))
goto LOOP;
if (gHitMarker & HITMARKER_OBEYS
&& holdEffectAtk == HOLD_EFFECT_CHOICE_BAND
&& gChosenMove != MOVE_STRUGGLE
&& (*choicedMoveAtk == 0 || *choicedMoveAtk == 0xFFFF))
{
if (gChosenMove == MOVE_BATON_PASS && !(gMoveResultFlags & MOVE_RESULT_FAILED))
{
gBattleScripting.atk49_state++;
++gBattleScripting.atk49_state;
break;
}
*choicedMoveAtk = gChosenMove;
LOOP:
{
for (i = 0; i < MAX_MON_MOVES; i++)
}
for (i = 0; i < MAX_MON_MOVES; ++i)
{
if (gBattleMons[gBattlerAttacker].moves[i] == *choicedMoveAtk)
break;
}
if (i == MAX_MON_MOVES)
*choicedMoveAtk = 0;
gBattleScripting.atk49_state++;
}
++gBattleScripting.atk49_state;
break;
case ATK49_CHANGED_ITEMS: // changed held items
for (i = 0; i < gBattlersCount; i++)
@ -6152,17 +6139,11 @@ static void atk69_adjustsetdamage(void) // The same as 0x7, except there's no ra
RecordItemEffectBattle(gBattlerTarget, holdEffect);
gSpecialStatuses[gBattlerTarget].focusBanded = 1;
}
if (gBattleMons[gBattlerTarget].status2 & STATUS2_SUBSTITUTE)
goto END;
if (gBattleMoves[gCurrentMove].effect != EFFECT_FALSE_SWIPE && !gProtectStructs[gBattlerTarget].endured
&& !gSpecialStatuses[gBattlerTarget].focusBanded)
goto END;
if (gBattleMons[gBattlerTarget].hp > gBattleMoveDamage)
goto END;
if (!(gBattleMons[gBattlerTarget].status2 & STATUS2_SUBSTITUTE)
&& (gBattleMoves[gCurrentMove].effect == EFFECT_FALSE_SWIPE || gProtectStructs[gBattlerTarget].endured || gSpecialStatuses[gBattlerTarget].focusBanded)
&& gBattleMons[gBattlerTarget].hp <= gBattleMoveDamage)
{
gBattleMoveDamage = gBattleMons[gBattlerTarget].hp - 1;
if (gProtectStructs[gBattlerTarget].endured)
{
gMoveResultFlags |= MOVE_RESULT_FOE_ENDURED;
@ -6172,8 +6153,7 @@ static void atk69_adjustsetdamage(void) // The same as 0x7, except there's no ra
gMoveResultFlags |= MOVE_RESULT_FOE_HUNG_ON;
gLastUsedItem = gBattleMons[gBattlerTarget].item;
}
END:
}
gBattlescriptCurrInstr++;
}