Merge pull request #816 from jiangzhengwenjz/ptch-3

get rid of goto in battle_script_commands
This commit is contained in:
huderlem 2019-09-25 16:31:53 -05:00 committed by GitHub
commit 886f043025
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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