summaryrefslogtreecommitdiff
path: root/src/battle_script_commands.c
diff options
context:
space:
mode:
authorhuderlem <huderlem@gmail.com>2019-09-25 16:31:53 -0500
committerGitHub <noreply@github.com>2019-09-25 16:31:53 -0500
commit886f043025b97a8879e80db949ff61ae677c32d5 (patch)
treeea857668e7de8375dc4a0d2d7b6e4560dedfbd7b /src/battle_script_commands.c
parent9d4fc9234be10ccad76987e08512373bb097d8e0 (diff)
parent4f9052cb96ac591e2e4759a978f95a31a467b4aa (diff)
Merge pull request #816 from jiangzhengwenjz/ptch-3
get rid of goto in battle_script_commands
Diffstat (limited to 'src/battle_script_commands.c')
-rw-r--r--src/battle_script_commands.c136
1 files changed, 58 insertions, 78 deletions
diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c
index 4002852b7..35d47fa82 100644
--- a/src/battle_script_commands.c
+++ b/src/battle_script_commands.c
@@ -1681,29 +1681,22 @@ 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;
-
- gBattleMoveDamage = gBattleMons[gBattlerTarget].hp - 1;
-
- if (gProtectStructs[gBattlerTarget].endured)
+ if (!(gBattleMons[gBattlerTarget].status2 & STATUS2_SUBSTITUTE)
+ && (gBattleMoves[gCurrentMove].effect == EFFECT_FALSE_SWIPE || gProtectStructs[gBattlerTarget].endured || gSpecialStatuses[gBattlerTarget].focusBanded)
+ && gBattleMons[gBattlerTarget].hp <= gBattleMoveDamage)
{
- gMoveResultFlags |= MOVE_RESULT_FOE_ENDURED;
- }
- else if (gSpecialStatuses[gBattlerTarget].focusBanded)
- {
- gMoveResultFlags |= MOVE_RESULT_FOE_HUNG_ON;
- gLastUsedItem = gBattleMons[gBattlerTarget].item;
+ gBattleMoveDamage = gBattleMons[gBattlerTarget].hp - 1;
+ if (gProtectStructs[gBattlerTarget].endured)
+ {
+ gMoveResultFlags |= MOVE_RESULT_FOE_ENDURED;
+ }
+ else if (gSpecialStatuses[gBattlerTarget].focusBanded)
+ {
+ gMoveResultFlags |= MOVE_RESULT_FOE_HUNG_ON;
+ gLastUsedItem = gBattleMons[gBattlerTarget].item;
+ }
}
-
- END:
- gBattlescriptCurrInstr++;
+ gBattlescriptCurrInstr++;
}
static void atk08_adjustnormaldamage2(void) // The same as 0x7 except it doesn't check for false swipe move effect.
@@ -1730,27 +1723,22 @@ 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;
-
- gBattleMoveDamage = gBattleMons[gBattlerTarget].hp - 1;
-
- if (gProtectStructs[gBattlerTarget].endured)
- {
- gMoveResultFlags |= MOVE_RESULT_FOE_ENDURED;
- }
- else if (gSpecialStatuses[gBattlerTarget].focusBanded)
+ if (!(gBattleMons[gBattlerTarget].status2 & STATUS2_SUBSTITUTE)
+ && (gProtectStructs[gBattlerTarget].endured || gSpecialStatuses[gBattlerTarget].focusBanded)
+ && gBattleMons[gBattlerTarget].hp <= gBattleMoveDamage)
{
- gMoveResultFlags |= MOVE_RESULT_FOE_HUNG_ON;
- gLastUsedItem = gBattleMons[gBattlerTarget].item;
+ gBattleMoveDamage = gBattleMons[gBattlerTarget].hp - 1;
+ if (gProtectStructs[gBattlerTarget].endured)
+ {
+ gMoveResultFlags |= MOVE_RESULT_FOE_ENDURED;
+ }
+ else if (gSpecialStatuses[gBattlerTarget].focusBanded)
+ {
+ gMoveResultFlags |= MOVE_RESULT_FOE_HUNG_ON;
+ gLastUsedItem = gBattleMons[gBattlerTarget].item;
+ }
}
-
- END:
- gBattlescriptCurrInstr++;
+ gBattlescriptCurrInstr++;
}
static void atk09_attackanimation(void)
@@ -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 (gChosenMove == MOVE_BATON_PASS && !(gMoveResultFlags & MOVE_RESULT_FAILED))
+ if (gHitMarker & HITMARKER_OBEYS
+ && holdEffectAtk == HOLD_EFFECT_CHOICE_BAND
+ && gChosenMove != MOVE_STRUGGLE
+ && (*choicedMoveAtk == 0 || *choicedMoveAtk == 0xFFFF))
{
- gBattleScripting.atk49_state++;
- break;
- }
- *choicedMoveAtk = gChosenMove;
- LOOP:
- {
- for (i = 0; i < MAX_MON_MOVES; i++)
+ if (gChosenMove == MOVE_BATON_PASS && !(gMoveResultFlags & MOVE_RESULT_FAILED))
{
- if (gBattleMons[gBattlerAttacker].moves[i] == *choicedMoveAtk)
- break;
+ ++gBattleScripting.atk49_state;
+ break;
}
- if (i == MAX_MON_MOVES)
- *choicedMoveAtk = 0;
-
- gBattleScripting.atk49_state++;
+ *choicedMoveAtk = gChosenMove;
+ }
+ 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;
break;
case ATK49_CHANGED_ITEMS: // changed held items
for (i = 0; i < gBattlersCount; i++)
@@ -6152,29 +6139,22 @@ 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;
-
- gBattleMoveDamage = gBattleMons[gBattlerTarget].hp - 1;
-
- if (gProtectStructs[gBattlerTarget].endured)
- {
- gMoveResultFlags |= MOVE_RESULT_FOE_ENDURED;
- }
- else if (gSpecialStatuses[gBattlerTarget].focusBanded)
+ if (!(gBattleMons[gBattlerTarget].status2 & STATUS2_SUBSTITUTE)
+ && (gBattleMoves[gCurrentMove].effect == EFFECT_FALSE_SWIPE || gProtectStructs[gBattlerTarget].endured || gSpecialStatuses[gBattlerTarget].focusBanded)
+ && gBattleMons[gBattlerTarget].hp <= gBattleMoveDamage)
{
- gMoveResultFlags |= MOVE_RESULT_FOE_HUNG_ON;
- gLastUsedItem = gBattleMons[gBattlerTarget].item;
+ gBattleMoveDamage = gBattleMons[gBattlerTarget].hp - 1;
+ if (gProtectStructs[gBattlerTarget].endured)
+ {
+ gMoveResultFlags |= MOVE_RESULT_FOE_ENDURED;
+ }
+ else if (gSpecialStatuses[gBattlerTarget].focusBanded)
+ {
+ gMoveResultFlags |= MOVE_RESULT_FOE_HUNG_ON;
+ gLastUsedItem = gBattleMons[gBattlerTarget].item;
+ }
}
-
- END:
- gBattlescriptCurrInstr++;
+ gBattlescriptCurrInstr++;
}
static void atk6A_removeitem(void)