From c8ea079e837a689468d94e187f535f6c8ca7453c Mon Sep 17 00:00:00 2001 From: Alex <93446519+AlexOn1ine@users.noreply.github.com> Date: Thu, 25 Jun 2026 15:10:07 +0200 Subject: [PATCH] Remove end2 (merge end and end2) (#10311) --- asm/macros/battle_script.inc | 6 +- data/battle_scripts_1.s | 82 ++++++++++------------ data/battle_scripts_2.s | 24 +++---- docs/tutorials/how_to_new_trainer_slide.md | 8 +-- include/battle_arena.h | 2 +- include/battle_scripts.h | 6 +- include/constants/battle_script_commands.h | 2 +- src/battle_arena.c | 41 ++++++----- src/battle_main.c | 6 +- src/battle_move_resolution.c | 7 +- src/battle_script_commands.c | 26 ++----- 11 files changed, 99 insertions(+), 111 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 2aa932bc33..3c3444a7ef 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -343,10 +343,6 @@ .byte B_SCR_OP_END .endm - .macro end2 - .byte B_SCR_OP_END2 - .endm - .macro end3 .byte B_SCR_OP_END3 .endm @@ -2124,7 +2120,7 @@ .macro catchornot callnative BS_CatchOrNot .endm - + .macro showitempopup battler:req callnative BS_ShowItemPopup .byte \battler diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 4b8640478d..a9236fe9a1 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -272,7 +272,7 @@ BattleScript_EffectShedTail:: waitstate switchineffects BS_ATTACKER switchinevents - end + goto BattleScript_MoveEnd BattleScript_MoveEffectPsychicNoise:: savetarget @@ -2741,7 +2741,7 @@ BattleScript_FaintBattler:: BattleScript_GiveExp:: setbyte sGIVEEXP_STATE, 0 getexp BS_TARGET - end2 + end BattleScript_HandleFaintedMon:: setbyte sSHIFT_SWITCHED, 0 @@ -2819,7 +2819,7 @@ BattleScript_FaintedMonSendOutNewEnd: jumpifbattletype BATTLE_TYPE_DOUBLE, BattleScript_FaintedMonEnd cancelallactions BattleScript_FaintedMonEnd:: - end2 + end BattleScript_FaintedMonShiftSwitched: copybyte sSAVED_BATTLER, gBattlerTarget switchineffects BS_ATTACKER @@ -2853,7 +2853,7 @@ BattleScript_HandleFaintedMonMultipleEnd:: switchinevents trytrainerslidemsglaston BS_FAINTED_MULTIPLE_2 trytrainerslidemsglaston BS_FAINTED_MULTIPLE_1 - end2 + end BattleScript_FirstTurnSwitchInEvents:: switchinevents @@ -2861,7 +2861,7 @@ BattleScript_FirstTurnSwitchInEvents:: BattleScript_EndTurnEvents:: endturnevents - end2 + end BattleScript_LocalTrainerBattleWon:: jumpifbattletype BATTLE_TYPE_TWO_OPPONENTS, BattleScript_LocalTwoTrainersDefeated @@ -2886,7 +2886,7 @@ BattleScript_LocalBattleWonReward:: BattleScript_PayDayMoneyAndPickUpItems:: givepaydaymoney pickup - end2 + end BattleScript_RivalBattleLost:: jumpifhasnohp BS_ATTACKER, BattleScript_RivalBattleLostSkipMonRecall @@ -2899,7 +2899,7 @@ BattleScript_RivalBattleLostSkipMonRecall:: waitstate printstring STRINGID_TRAINER1WINTEXT jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 2, BattleScript_LocalBattleLostPrintWhiteOut - end2 + end BattleScript_LocalBattleLost:: jumpifbattletype BATTLE_TYPE_DOME, BattleScript_CheckDomeDrew @@ -2920,18 +2920,18 @@ BattleScript_LocalBattleLostPrintWhiteOut:: waitmessage B_WAIT_TIME_LONG printstring STRINGID_PLAYERWHITEOUT3 waitmessage B_WAIT_TIME_LONG - end2 + end BattleScript_LocalBattleLostEnd:: printstring STRINGID_PLAYERWHITEOUT2_TRAINER waitmessage B_WAIT_TIME_LONG printstring STRINGID_PLAYERWHITEOUT3 waitmessage B_WAIT_TIME_LONG - end2 + end .else printstring STRINGID_PLAYERWHITEOUT3 waitmessage B_WAIT_TIME_LONG BattleScript_LocalBattleLostEnd:: - end2 + end .endif BattleScript_CheckDomeDrew:: @@ -2954,7 +2954,7 @@ BattleScript_LocalBattleLostDoTrainer2WinText:: waitstate printstring STRINGID_TRAINER2WINTEXT BattleScript_LocalBattleLostEnd_:: - end2 + end BattleScript_FrontierLinkBattleLost:: returnopponentmon1toball @@ -2973,7 +2973,7 @@ BattleScript_FrontierLinkBattleLost:: endlinkbattle BattleScript_FrontierLinkBattleLostEnd:: waitmessage B_WAIT_TIME_LONG - end2 + end BattleScript_LinkBattleWonOrLost:: jumpifbattletype BATTLE_TYPE_BATTLE_TOWER, BattleScript_TowerLinkBattleWon @@ -2983,7 +2983,7 @@ BattleScript_LinkBattleWonOrLost:: endlinkbattle BattleScript_LinkBattleWonOrLostWaitEnd:: waitmessage B_WAIT_TIME_LONG - end2 + end BattleScript_TowerLinkBattleWon:: playtrainerdefeatedmusic @@ -3001,7 +3001,7 @@ BattleScript_TowerLinkBattleWon:: endlinkbattle BattleScript_TowerLinkBattleWonEnd:: waitmessage B_WAIT_TIME_LONG - end2 + end BattleScript_FrontierTrainerBattleWon:: jumpifnotbattletype BATTLE_TYPE_TRAINER, BattleScript_PayDayMoneyAndPickUpItems @@ -3024,38 +3024,38 @@ BattleScript_TryPickUpItems: jumpifnotbattletype BATTLE_TYPE_PYRAMID, BattleScript_FrontierTrainerBattleWon_End pickup BattleScript_FrontierTrainerBattleWon_End: - end2 + end BattleScript_SmokeBallEscape:: playanimation BS_ATTACKER, B_ANIM_SMOKEBALL_ESCAPE printstring STRINGID_PKMNFLEDUSINGITS waitmessage B_WAIT_TIME_LONG - end2 + end BattleScript_RanAwayUsingMonAbility:: call BattleScript_AbilityPopUp printstring STRINGID_GOTAWAYSAFELY waitmessage B_WAIT_TIME_LONG - end2 + end BattleScript_GotAwaySafely:: printstring STRINGID_GOTAWAYSAFELY waitmessage B_WAIT_TIME_LONG - end2 + end BattleScript_WildMonFled:: printstring STRINGID_WILDPKMNFLED waitmessage B_WAIT_TIME_LONG - end2 + end BattleScript_PrintCantRunFromTrainer:: printstring STRINGID_NORUNNINGFROMTRAINERS - end2 + end BattleScript_PrintFailedToRunString:: printfromtable gNoEscapeStringIds waitmessage B_WAIT_TIME_LONG - end2 + end BattleScript_PrintCantEscapeFromBattle:: printselectionstringfromtable gNoEscapeStringIds @@ -3069,7 +3069,7 @@ BattleScript_ActionSwitch:: hpthresholds2 BS_ATTACKER printstring STRINGID_RETURNMON jumpifnopursuitswitchdmg BattleScript_DoSwitchOut - end2 + end BattleScript_DoSwitchOut:: undodynamax BS_ATTACKER @@ -3092,7 +3092,7 @@ BattleScript_DoSwitchOut:: switchinevents moveendcase MOVEEND_STATUS_IMMUNITY_ABILITIES moveendcase MOVEEND_MIRROR_MOVE - end2 + end BattleScript_Pausex20:: pause B_WAIT_TIME_SHORT @@ -3425,8 +3425,7 @@ BattleScript_EncoredMove:: BattleScript_EncoredMoveInPalace:: printselectionstring STRINGID_PKMNGOTENCOREDMOVE BattleScript_SelectingUnusableMoveInPalace:: - moveendto MOVEEND_NEXT_TARGET - end + goto BattleScript_MoveEnd BattleScript_EncoredNoMore:: printstring STRINGID_PKMNENCOREENDED @@ -5178,8 +5177,7 @@ BattleScript_BattlerGotOverItsInfatuation:: BattleScript_IgnoresWhileAsleep:: printstring STRINGID_PKMNIGNORESASLEEP waitmessage B_WAIT_TIME_LONG - moveendto MOVEEND_NEXT_TARGET - end + goto BattleScript_MoveEnd BattleScript_IgnoresAndUsesRandomMove:: printstring STRINGID_PKMNIGNOREDORDERS @@ -5196,8 +5194,7 @@ BattleScript_MoveUsedLoafingAround:: BattleScript_MoveUsedLoafingAroundMsg:: printfromtable gInobedientStringIds waitmessage B_WAIT_TIME_LONG - moveendto MOVEEND_NEXT_TARGET - end + goto BattleScript_MoveEnd BattleScript_TruantLoafingAround:: flushtextbox call BattleScript_AbilityPopUp @@ -5207,8 +5204,7 @@ BattleScript_IgnoresAndFallsAsleep:: printstring STRINGID_PKMNBEGANTONAP waitmessage B_WAIT_TIME_LONG seteffectprimary BS_ATTACKER, BS_ATTACKER, MOVE_EFFECT_SLEEP - moveendto MOVEEND_NEXT_TARGET - end + goto BattleScript_MoveEnd BattleScript_IgnoresAndHitsItself:: printstring STRINGID_PKMNWONTOBEY @@ -5510,7 +5506,7 @@ BattleScript_PalaceEndFlavorText:: BattleScript_PalacePrintFlavorText:: call BattleScript_PalacePrintFlavorTextRet - end2 + end BattleScript_ArenaTurnBeginningRet:: waitcry @@ -5528,7 +5524,7 @@ BattleScript_ArenaTurnBeginningRet:: BattleScript_ArenaTurnBeginning:: call BattleScript_ArenaTurnBeginningRet - end2 + end BattleScript_ArenaDoJudgment:: makevisible BS_PLAYER1 @@ -5573,7 +5569,7 @@ BattleScript_ArenaDoJudgment:: cleareffectsonfaint BS_OPPONENT1 waitanimation arenaopponentmonlost - end2 + end BattleScript_ArenaJudgmentPlayerLoses: arenajudgmentstring B_MSG_REF_OPPONENT_WON @@ -5589,7 +5585,7 @@ BattleScript_ArenaJudgmentPlayerLoses: cleareffectsonfaint BS_PLAYER1 waitanimation arenaplayermonlost - end2 + end BattleScript_ArenaJudgmentDraw: arenajudgmentstring B_MSG_REF_DRAW @@ -5611,7 +5607,7 @@ BattleScript_ArenaJudgmentDraw: dofaintanimation BS_OPPONENT1 cleareffectsonfaint BS_OPPONENT1 waitanimation - end2 + end BattleScript_AskIfWantsToForfeitMatch:: printselectionstring STRINGID_QUESTIONFORFEITMATCH @@ -5621,14 +5617,14 @@ BattleScript_AskIfWantsToForfeitMatch:: BattleScript_PrintPlayerForfeited:: printstring STRINGID_FORFEITEDMATCH waitmessage B_WAIT_TIME_LONG - end2 + end BattleScript_PrintPlayerForfeitedLinkBattle:: printstring STRINGID_FORFEITEDMATCH waitmessage B_WAIT_TIME_LONG endlinkbattle waitmessage B_WAIT_TIME_LONG - end2 + end BattleScript_MirrorHerbCopyStatChange:: call BattleScript_ItemPopUp_Scripting @@ -5699,14 +5695,14 @@ BattleScript_QuickClawActivation:: waitanimation printstring STRINGID_CANACTFASTERTHANKSTO waitmessage B_WAIT_TIME_LONG - end2 + end BattleScript_QuickDrawActivation:: flushtextbox call BattleScript_AbilityPopUp printstring STRINGID_CANACTFASTERTHANKSTO waitmessage B_WAIT_TIME_LONG - end2 + end BattleScript_CustapBerryActivation:: flushtextbox @@ -5717,7 +5713,7 @@ BattleScript_CustapBerryActivation:: waitmessage B_WAIT_TIME_LONG removeitem BS_ATTACKER waitabilitypopup - end2 + end BattleScript_MicleBerryActivate:: call BattleScript_ItemPopUp_Scripting @@ -6322,7 +6318,7 @@ BattleScript_ForfeitBattleGaveMoney:: printstring STRINGID_PLAYERWHITEOUT3 .endif waitmessage B_WAIT_TIME_LONG - end2 + end BattleScript_Attackstring:: printattackstring @@ -6402,7 +6398,7 @@ BattleScript_SilphScopeUnveiled:: pause B_WAIT_TIME_SHORT printstring STRINGID_GHOSTWASMAROWAK waitmessage B_WAIT_TIME_LONG - end2 + end BattleScript_WildBattleVictory:: playfaintcry BS_TARGET diff --git a/data/battle_scripts_2.s b/data/battle_scripts_2.s index 585b79f016..b623a36e1d 100755 --- a/data/battle_scripts_2.s +++ b/data/battle_scripts_2.s @@ -251,12 +251,12 @@ BattleScript_ActionWatchesCarefully: #if IS_FRLG playanimation BS_OPPONENT1, B_ANIM_SAFARI_REACTION #endif - end2 + end BattleScript_ActionGetNear: printfromtable gSafariGetNearStringIds waitmessage B_WAIT_TIME_LONG - end2 + end BattleScript_ActionThrowPokeblock: printstring STRINGID_THREWPOKEBLOCKATPKMN @@ -264,7 +264,7 @@ BattleScript_ActionThrowPokeblock: playanimation BS_ATTACKER, B_ANIM_POKEBLOCK_THROW, NULL printfromtable gSafariPokeblockResultStringIds waitmessage B_WAIT_TIME_LONG - end2 + end BattleScript_ActionWallyThrow: printstring STRINGID_RETURNMON @@ -275,7 +275,7 @@ BattleScript_ActionWallyThrow: waitstate printstring STRINGID_YOUTHROWABALLNOWRIGHT waitmessage B_WAIT_TIME_LONG - end2 + end BattleScript_TrainerASlideMsgRet:: trainerslidein BS_OPPONENT1 @@ -286,9 +286,9 @@ BattleScript_TrainerASlideMsgRet:: handletrainerslidemsg BS_SCRIPTING, RESTORE_BATTLER_SLIDE_CONTROL return -BattleScript_TrainerASlideMsgEnd2:: +BattleScript_TrainerASlideMsgEnd:: call BattleScript_TrainerASlideMsgRet - end2 + end BattleScript_TrainerBSlideMsgRet:: trainerslidein BS_OPPONENT2 @@ -299,9 +299,9 @@ BattleScript_TrainerBSlideMsgRet:: handletrainerslidemsg BS_SCRIPTING, RESTORE_BATTLER_SLIDE_CONTROL return -BattleScript_TrainerBSlideMsgEnd2:: +BattleScript_TrainerBSlideMsgEnd:: call BattleScript_TrainerBSlideMsgRet - end2 + end BattleScript_TrainerPartnerSlideMsgRet:: trainerslidein BS_PLAYER2 @@ -312,9 +312,9 @@ BattleScript_TrainerPartnerSlideMsgRet:: handletrainerslidemsg BS_SCRIPTING, RESTORE_BATTLER_SLIDE_CONTROL return -BattleScript_TrainerPartnerSlideMsgEnd2:: +BattleScript_TrainerPartnerSlideMsgEnd:: call BattleScript_TrainerPartnerSlideMsgRet - end2 + end BattleScript_GhostBallDodge:: waitmessage B_WAIT_TIME_LONG @@ -326,10 +326,10 @@ BattleScript_ActionThrowRock:: printstring STRINGID_THREWROCK waitmessage B_WAIT_TIME_LONG playanimation BS_ATTACKER, B_ANIM_ROCK_THROW - end2 + end BattleScript_ActionThrowBait:: printstring STRINGID_THREWBAIT waitmessage B_WAIT_TIME_LONG playanimation BS_ATTACKER, B_ANIM_POKEBLOCK_THROW - end2 + end diff --git a/docs/tutorials/how_to_new_trainer_slide.md b/docs/tutorials/how_to_new_trainer_slide.md index cc606235d4..e61e3b9aa8 100644 --- a/docs/tutorials/how_to_new_trainer_slide.md +++ b/docs/tutorials/how_to_new_trainer_slide.md @@ -149,13 +149,13 @@ The function to check if this slide SHOULD be initalized is added to the bottom ### `src/battle_main.c` ```diff - BattleScriptExecute(i == 1 ? BattleScript_TrainerASlideMsgEnd2 : BattleScript_TrainerBSlideMsgEnd2); + BattleScriptExecute(i == 1 ? BattleScript_TrainerASlideMsgEnd : BattleScript_TrainerBSlideMsgEnd); else if ((i = ShouldDoTrainerSlide(GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), TRAINER_SLIDE_PLAYER_LANDS_FIRST_CRITICAL_HIT))) - BattleScriptExecute(i == 1 ? BattleScript_TrainerASlideMsgEnd2 : BattleScript_TrainerBSlideMsgEnd2); + BattleScriptExecute(i == 1 ? BattleScript_TrainerASlideMsgEnd : BattleScript_TrainerBSlideMsgEnd); + else if ((i = ShouldDoTrainerSlide(GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), TRAINER_SLIDE_ENEMY_LANDS_FIRST_CRITICAL_HIT))) -+ BattleScriptExecute(i == 1 ? BattleScript_TrainerASlideMsgEnd2 : BattleScript_TrainerBSlideMsgEnd2); ++ BattleScriptExecute(i == 1 ? BattleScript_TrainerASlideMsgEnd : BattleScript_TrainerBSlideMsgEnd); else if ((i = ShouldDoTrainerSlide(GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), TRAINER_SLIDE_PLAYER_LANDS_FIRST_SUPER_EFFECTIVE_HIT))) - BattleScriptExecute(i == 1 ? BattleScript_TrainerASlideMsgEnd2 : BattleScript_TrainerBSlideMsgEnd2); + BattleScriptExecute(i == 1 ? BattleScript_TrainerASlideMsgEnd : BattleScript_TrainerBSlideMsgEnd); else if ((i = ShouldDoTrainerSlide(GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), TRAINER_SLIDE_PLAYER_LANDS_FIRST_STAB_MOVE))) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c ``` diff --git a/include/battle_arena.h b/include/battle_arena.h index c27e46be0d..1a36d4ae06 100644 --- a/include/battle_arena.h +++ b/include/battle_arena.h @@ -7,7 +7,7 @@ void CallBattleArenaFunction(void); u8 BattleArena_ShowJudgmentWindow(u8 *state); void BattleArena_InitPoints(void); void BattleArena_AddMindPoints(enum BattlerId battler); -void BattleArena_AddSkillPoints(enum BattlerId battler); +void BattleArena_AddSkillPoints(enum BattlerId battlerAtk); void BattleArena_DeductSkillPoints(enum BattlerId battler, enum StringID stringId); void DrawArenaRefereeTextBox(void); void EraseArenaRefereeTextBox(void); diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 50c527f40f..ca6e235078 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -285,11 +285,11 @@ extern const u8 BattleScript_MoveEffectClearSmog[]; extern const u8 BattleScript_MoveEffectSmackDown[]; extern const u8 BattleScript_MoveEffectFlameBurst[]; extern const u8 BattleScript_TrainerASlideMsgRet[]; -extern const u8 BattleScript_TrainerASlideMsgEnd2[]; +extern const u8 BattleScript_TrainerASlideMsgEnd[]; extern const u8 BattleScript_TrainerBSlideMsgRet[]; -extern const u8 BattleScript_TrainerBSlideMsgEnd2[]; +extern const u8 BattleScript_TrainerBSlideMsgEnd[]; extern const u8 BattleScript_TrainerPartnerSlideMsgRet[]; -extern const u8 BattleScript_TrainerPartnerSlideMsgEnd2[]; +extern const u8 BattleScript_TrainerPartnerSlideMsgEnd[]; extern const u8 BattleScript_MoveEffectFeint[]; extern const u8 BattleScript_ProteanActivates[]; extern const u8 BattleScript_PokemonCannotUseMove[]; diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index 2ae7e37b77..b6f9228587 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -58,7 +58,6 @@ enum BattleScriptOpcode B_SCR_OP_TRYSELFCONFUSIONDMGFORMCHANGE, B_SCR_OP_RETURN, B_SCR_OP_END, - B_SCR_OP_END2, B_SCR_OP_END3, B_SCR_OP_SETCHARGINGTURN, B_SCR_OP_CALL, @@ -258,6 +257,7 @@ enum BattleScriptOpcode B_SCR_OP_UNUSED_36, B_SCR_OP_UNUSED_37, B_SCR_OP_UNUSED_38, + B_SCR_OP_UNUSED_39, B_SCR_OP_CALLNATIVE, }; diff --git a/src/battle_arena.c b/src/battle_arena.c index f745450040..41d6c4035b 100644 --- a/src/battle_arena.c +++ b/src/battle_arena.c @@ -376,37 +376,42 @@ void BattleArena_AddMindPoints(enum BattlerId battler) } } -void BattleArena_AddSkillPoints(enum BattlerId battler) +void BattleArena_AddSkillPoints(enum BattlerId battlerAtk) { s8 *skillPoints = gBattleStruct->arenaSkillPoints; - if (!gBattleStruct->unableToUseMove) + if (gBattleStruct->unableToUseMove) + return; + + if (gBattleStruct->battlerState[battlerAtk].alreadyStatusedMoveAttempt) { - if (gBattleStruct->battlerState[battler].alreadyStatusedMoveAttempt) + gBattleStruct->battlerState[battlerAtk].alreadyStatusedMoveAttempt = FALSE; + skillPoints[battlerAtk] -= 2; + return; + } + + for (enum BattlerId battlerDef = 0; battlerDef < gBattlersCount; battlerDef++) + { + if (IsBattlerUnaffectedByMove(battlerDef)) { - gBattleStruct->battlerState[battler].alreadyStatusedMoveAttempt = FALSE; - skillPoints[battler] -= 2; + if (!(gBattleStruct->moveResultFlags[battlerDef] & MOVE_RESULT_MISSED)) + skillPoints[battlerAtk] -= 2; } - else if (IsBattlerUnaffectedByMove(gBattlerTarget)) + else if ((gBattleStruct->moveResultFlags[battlerDef] & MOVE_RESULT_HIGH_EFFECTIVENESS) && (gBattleStruct->moveResultFlags[battlerDef] & MOVE_RESULT_LOW_EFFECTIVENESS)) { - if (!(gBattleStruct->moveResultFlags[gBattlerTarget] & MOVE_RESULT_MISSED)) - skillPoints[battler] -= 2; + skillPoints[battlerAtk] += 1; } - else if ((gBattleStruct->moveResultFlags[gBattlerTarget] & MOVE_RESULT_HIGH_EFFECTIVENESS) && (gBattleStruct->moveResultFlags[gBattlerTarget] & MOVE_RESULT_LOW_EFFECTIVENESS)) + else if (gBattleStruct->moveResultFlags[battlerDef] & MOVE_RESULT_HIGH_EFFECTIVENESS) { - skillPoints[battler] += 1; + skillPoints[battlerAtk] += 2; } - else if (gBattleStruct->moveResultFlags[gBattlerTarget] & MOVE_RESULT_HIGH_EFFECTIVENESS) + else if (gBattleStruct->moveResultFlags[battlerDef] & MOVE_RESULT_LOW_EFFECTIVENESS) { - skillPoints[battler] += 2; + skillPoints[battlerAtk] -= 1; } - else if (gBattleStruct->moveResultFlags[gBattlerTarget] & MOVE_RESULT_LOW_EFFECTIVENESS) + else if (!gProtectStructs[battlerDef].protected) { - skillPoints[battler] -= 1; - } - else if (!gProtectStructs[battler].protected) - { - skillPoints[battler] += 1; + skillPoints[battlerAtk] += 1; } } } diff --git a/src/battle_main.c b/src/battle_main.c index 8100687c2d..f59ed3dd10 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -3558,7 +3558,7 @@ static void TryDoEventsBeforeFirstTurn(void) break; case FIRST_TURN_EVENTS_TRAINER_SLIDE_A: if (ShouldDoTrainerSlide(B_BATTLER_1, TRAINER_SLIDE_BEFORE_FIRST_TURN)) - BattleScriptExecute(BattleScript_TrainerASlideMsgEnd2); + BattleScriptExecute(BattleScript_TrainerASlideMsgEnd); gBattleStruct->eventState.beforeFirstTurn++; break; case FIRST_TURN_EVENTS_TRAINER_SLIDE_B: @@ -3569,14 +3569,14 @@ static void TryDoEventsBeforeFirstTurn(void) || (TRAINER_BATTLE_PARAM.opponentB == TRAINER_NONE) || (TRAINER_BATTLE_PARAM.opponentB == 0xFFFF))) { - BattleScriptExecute(BattleScript_TrainerBSlideMsgEnd2); + BattleScriptExecute(BattleScript_TrainerBSlideMsgEnd); } } gBattleStruct->eventState.beforeFirstTurn++; break; case FIRST_TURN_EVENTS_TRAINER_SLIDE_PARTNER: if (ShouldDoTrainerSlide(B_BATTLER_2, TRAINER_SLIDE_BEFORE_FIRST_TURN)) - BattleScriptExecute(BattleScript_TrainerPartnerSlideMsgEnd2); + BattleScriptExecute(BattleScript_TrainerPartnerSlideMsgEnd); gBattleStruct->eventState.beforeFirstTurn++; break; case FIRST_TURN_EVENTS_END: diff --git a/src/battle_move_resolution.c b/src/battle_move_resolution.c index f808d5f112..679ae85b8e 100644 --- a/src/battle_move_resolution.c +++ b/src/battle_move_resolution.c @@ -1,5 +1,6 @@ #include "global.h" #include "battle.h" +#include "battle_arena.h" #include "battle_environment.h" #include "battle_hold_effects.h" #include "battle_ai_record.h" @@ -2118,6 +2119,7 @@ static enum CancelerResult CancelerTargetFailure(struct BattleCalcValues *cv) cv->battlerDef = gBattlerTarget; gBattleStruct->eventState.atkCancelerBattler = 0; + if (moveBouncedBack) { gBattlescriptCurrInstr = BattleScript_MoveEnd; @@ -4243,7 +4245,7 @@ static enum MoveEndResult MoveEndThirdMoveBlock(struct BattleCalcValues *cv) { if ((!IsBattlerAlive(cv->battlerAtk) || gLastPrintedMoves[cv->battlerAtk] != cv->move) && GetConfig(B_FAINT_MOVE_EFFECT_TIMING) < GEN_CHAMPIONS) break; - + BattleScriptCall(BattleScript_RemoveTerrain); result = MOVEEND_RESULT_RUN_SCRIPT; } @@ -4453,6 +4455,9 @@ static enum MoveEndResult MoveEndClearBits(struct BattleCalcValues *cv) enum Move originallyUsedMove = GetOriginallyUsedMove(gChosenMove); enum Type moveType = GetBattleMoveType(cv->move); + if (gBattleTypeFlags & BATTLE_TYPE_ARENA) + BattleArena_AddSkillPoints(cv->battlerAtk); + if (ShouldSetStompingTantrumTimer()) gBattleStruct->battlerState[cv->battlerAtk].stompingTantrumTimer = 2; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 0ed08fbad8..0d74eb2c5e 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -404,7 +404,6 @@ static void Cmd_waitstate(void); static void Cmd_tryselfconfusiondmgformchange(void); static void Cmd_return(void); static void Cmd_end(void); -static void Cmd_end2(void); static void Cmd_end3(void); static void Cmd_setchargingturn(void); static void Cmd_call(void); @@ -622,7 +621,6 @@ void (*const gBattleScriptingCommandsTable[])(void) = [B_SCR_OP_TRYSELFCONFUSIONDMGFORMCHANGE] = Cmd_tryselfconfusiondmgformchange, [B_SCR_OP_RETURN] = Cmd_return, [B_SCR_OP_END] = Cmd_end, - [B_SCR_OP_END2] = Cmd_end2, [B_SCR_OP_END3] = Cmd_end3, [B_SCR_OP_SETCHARGINGTURN] = Cmd_setchargingturn, [B_SCR_OP_CALL] = Cmd_call, @@ -818,6 +816,7 @@ void (*const gBattleScriptingCommandsTable[])(void) = [B_SCR_OP_UNUSED_36] = Cmd_dummy, [B_SCR_OP_UNUSED_37] = Cmd_dummy, [B_SCR_OP_UNUSED_38] = Cmd_dummy, + [B_SCR_OP_UNUSED_39] = Cmd_dummy, [B_SCR_OP_CALLNATIVE] = Cmd_callnative, }; @@ -4668,7 +4667,7 @@ static void Cmd_tryselfconfusiondmgformchange(void) static void Cmd_return(void) { - assertf(gBattleResources->battleScriptsStack->size != 0, "return used with nothing to return to, did you mean end/end2/end3?"); + assertf(gBattleResources->battleScriptsStack->size != 0, "return used with nothing to return to, did you mean end/end3?"); BattleScriptPop(); } @@ -4680,19 +4679,6 @@ static void Cmd_end(void) assertf(gSelectionBattleScripts[gBattlerAttacker] == NULL, "incorrect use of end in selection script, did you mean endselectionscript?"); assertf(gBattleMainFunc != RunBattleScriptCommands, "incorrect use of end in battle script, did you mean end3?"); - if (gBattleTypeFlags & BATTLE_TYPE_ARENA) - BattleArena_AddSkillPoints(gBattlerAttacker); - - gCurrentActionFuncId = B_ACTION_TRY_FINISH; -} - -static void Cmd_end2(void) -{ - CMD_ARGS(); - - assertf(gSelectionBattleScripts[gBattlerAttacker] == NULL, "incorrect use of end2 in selection script, did you mean endselectionscript?"); - assertf(gBattleMainFunc != RunBattleScriptCommands, "incorrect use of end2 in battle script, did you mean end3?"); - gCurrentActionFuncId = B_ACTION_TRY_FINISH; } @@ -4707,7 +4693,7 @@ static void Cmd_end3(void) if (gBattleResources->battleCallbackStack->size != 0) gBattleResources->battleCallbackStack->size--; else // nothing to callback to - assertf(gBattleMainFunc != RunBattleScriptCommands_PopCallbacksStack, "incorrect use of end3 in battle script, did you mean end/end2?"); + assertf(gBattleMainFunc != RunBattleScriptCommands_PopCallbacksStack, "incorrect use of end3 in battle script, did you mean end?"); gBattleMainFunc = gBattleResources->battleCallbackStack->function[gBattleResources->battleCallbackStack->size]; } @@ -14576,12 +14562,12 @@ void BS_DestroyItemPopup(void) if (IsAnyAbilityPopUpActive()) return; - + for (enum BattlerId battler = 0; battler < gBattlersCount; battler++) DestroyAbilityPopUp(battler); FreeAbilityPopUpGfx(); - + gBattlescriptCurrInstr = cmd->nextInstr; } @@ -14597,6 +14583,6 @@ void BS_MultiHitPlurality(void) { PREPARE_STRING_BUFFER(gBattleTextBuff2, STRINGID_S); } - + gBattlescriptCurrInstr = cmd->nextInstr; }