diff options
author | PikalaxALT <pikalaxalt@gmail.com> | 2019-09-27 09:11:22 -0400 |
---|---|---|
committer | PikalaxALT <pikalaxalt@gmail.com> | 2019-09-27 09:11:22 -0400 |
commit | 7b8b5b5c8c02156d7cdaa76212ad68f01b1600c9 (patch) | |
tree | 32b1c3ce14f272708fdc4b5b944a8dc9c14d07e3 /src/battle_script_commands.c | |
parent | 27aae9da9a570b6787171e33fa29c43c507187c1 (diff) | |
parent | 208e1c968959c781562f0b94c03368385ce7012c (diff) |
Merge branch 'master' into gflib
Diffstat (limited to 'src/battle_script_commands.c')
-rw-r--r-- | src/battle_script_commands.c | 150 |
1 files changed, 65 insertions, 85 deletions
diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 5016a3a58..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) @@ -10184,7 +10164,7 @@ static void atkEF_handleballthrow(void) gBattlescriptCurrInstr = BattleScript_SuccessBallThrow; SetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_POKEBALL, &gLastUsedItem); - if (CalculatePlayerPartyCount() == 6) + if (CalculatePlayerPartyCount() == PARTY_SIZE) gBattleCommunication[MULTISTRING_CHOOSER] = 0; else gBattleCommunication[MULTISTRING_CHOOSER] = 1; @@ -10196,7 +10176,7 @@ static void atkEF_handleballthrow(void) odds = Sqrt(Sqrt(16711680 / odds)); odds = 1048560 / odds; - for (shakes = 0; shakes < 4 && Random() < odds; shakes++); + for (shakes = 0; shakes < BALL_3_SHAKES_SUCCESS && Random() < odds; shakes++); if (gLastUsedItem == ITEM_MASTER_BALL) shakes = BALL_3_SHAKES_SUCCESS; // why calculate the shakes before that check? @@ -10209,7 +10189,7 @@ static void atkEF_handleballthrow(void) gBattlescriptCurrInstr = BattleScript_SuccessBallThrow; SetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_POKEBALL, &gLastUsedItem); - if (CalculatePlayerPartyCount() == 6) + if (CalculatePlayerPartyCount() == PARTY_SIZE) gBattleCommunication[MULTISTRING_CHOOSER] = 0; else gBattleCommunication[MULTISTRING_CHOOSER] = 1; @@ -10227,17 +10207,17 @@ static void atkF0_givecaughtmon(void) { if (GiveMonToPlayer(&gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker ^ BIT_SIDE]]) != MON_GIVEN_TO_PARTY) { - if (!sub_813B21C()) + if (!ShouldShowBoxWasFullMessage()) { gBattleCommunication[MULTISTRING_CHOOSER] = 0; - StringCopy(gStringVar1, GetBoxNamePtr(VarGet(VAR_STORAGE_UNKNOWN))); + StringCopy(gStringVar1, GetBoxNamePtr(VarGet(VAR_PC_BOX_TO_SEND_MON))); GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker ^ BIT_SIDE]], MON_DATA_NICKNAME, gStringVar2); } else { - StringCopy(gStringVar1, GetBoxNamePtr(VarGet(VAR_STORAGE_UNKNOWN))); + StringCopy(gStringVar1, GetBoxNamePtr(VarGet(VAR_PC_BOX_TO_SEND_MON))); // box the mon was sent to GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker ^ BIT_SIDE]], MON_DATA_NICKNAME, gStringVar2); - StringCopy(gStringVar3, GetBoxNamePtr(get_unknown_box_id())); + StringCopy(gStringVar3, GetBoxNamePtr(GetPCBoxToSendMon())); //box the mon was going to be sent to gBattleCommunication[MULTISTRING_CHOOSER] = 2; } |