diff --git a/constants/battle_script_constants.inc b/constants/battle_script_constants.inc index fb0c39ab97..c4a16238a4 100644 --- a/constants/battle_script_constants.inc +++ b/constants/battle_script_constants.inc @@ -146,8 +146,8 @@ .equiv sANIM_ARG2, gBattleScripting + 0x11 .equiv sTRIPLE_KICK_POWER, gBattleScripting + 0x12 .equiv sMOVEEND_STATE, gBattleScripting + 0x14 - .equiv sFIELD_15, gBattleScripting + 0x15 - .equiv sFIELD_16, gBattleScripting + 0x16 + .equiv sBANK_WITH_ABILITY, gBattleScripting + 0x15 + .equiv sMULTIHIT_EFFECT, gBattleScripting + 0x16 .equiv sBANK, gBattleScripting + 0x17 .equiv sANIM_TURN, gBattleScripting + 0x18 .equiv sANIM_TARGETS_HIT, gBattleScripting + 0x19 diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 10de50082c..2d06af55d9 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -624,19 +624,19 @@ BattleScript_EffectMultiHit:: ppreduce setmultihitcounter 0x0 initmultihitstring - setbyte sFIELD_16, 0x0 -BattleScript_82D8DFD:: - jumpifhasnohp ATTACKER, BattleScript_82D8E93 - jumpifhasnohp TARGET, BattleScript_82D8E74 - jumpifhalfword EQUAL, gChosenMove, MOVE_SLEEP_TALK, BattleScript_82D8E1F - jumpifstatus ATTACKER, STATUS_SLEEP, BattleScript_82D8E74 -BattleScript_82D8E1F:: + setbyte sMULTIHIT_EFFECT, 0x0 +BattleScript_MultiHitLoop:: + jumpifhasnohp ATTACKER, BattleScript_MultiHitEnd + jumpifhasnohp TARGET, BattleScript_MultiHitPrintStrings + jumpifhalfword EQUAL, gChosenMove, MOVE_SLEEP_TALK, BattleScript_DoMultiHit + jumpifstatus ATTACKER, STATUS_SLEEP, BattleScript_MultiHitPrintStrings +BattleScript_DoMultiHit:: movevaluescleanup - copybyte cEFFECT_CHOOSER, sFIELD_16 + copybyte cEFFECT_CHOOSER, sMULTIHIT_EFFECT critcalc damagecalc typecalc - jumpifmovehadnoeffect BattleScript_82D8E71 + jumpifmovehadnoeffect BattleScript_MultiHitNoMoreHits adjustnormaldamage attackanimation waitanimation @@ -652,19 +652,19 @@ BattleScript_82D8E1F:: addbyte sMULTIHIT_STRING + 4, 0x1 setbyte sMOVEEND_STATE, 0x0 moveend 0x2, 0x10 - jumpifbyte COMMON_BITS, gBattleMoveFlags, MOVESTATUS_ENDURED, BattleScript_82D8E74 - decrementmultihit BattleScript_82D8DFD - goto BattleScript_82D8E74 -BattleScript_82D8E71:: + jumpifbyte COMMON_BITS, gBattleMoveFlags, MOVESTATUS_ENDURED, BattleScript_MultiHitPrintStrings + decrementmultihit BattleScript_MultiHitLoop + goto BattleScript_MultiHitPrintStrings +BattleScript_MultiHitNoMoreHits:: pause 0x20 -BattleScript_82D8E74:: +BattleScript_MultiHitPrintStrings:: resultmessage waitmessage 0x40 - jumpifmovehadnoeffect BattleScript_82D8E93 + jumpifmovehadnoeffect BattleScript_MultiHitEnd copyarray gBattleTextBuff1, sMULTIHIT_STRING, 0x6 printstring STRINGID_HITXTIMES waitmessage 0x40 -BattleScript_82D8E93:: +BattleScript_MultiHitEnd:: seteffectwithchance tryfaintmon TARGET, FALSE, NULL setbyte sMOVEEND_STATE, 0x2 @@ -862,8 +862,8 @@ BattleScript_EffectDoubleHit:: ppreduce setmultihitcounter 0x2 initmultihitstring - setbyte sFIELD_16, 0x0 - goto BattleScript_82D8DFD + setbyte sMULTIHIT_EFFECT, 0x0 + goto BattleScript_MultiHitLoop BattleScript_EffectRecoilIfMiss:: attackcanceler @@ -1094,12 +1094,12 @@ BattleScript_EffectConfuseHit:: BattleScript_EffectTwineedle:: attackcanceler accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE - setbyte sFIELD_16, 0x2 + setbyte sMULTIHIT_EFFECT, EFFECT_POISON attackstring ppreduce setmultihitcounter 0x2 initmultihitstring - goto BattleScript_82D8DFD + goto BattleScript_MultiHitLoop BattleScript_EffectSubstitute:: attackcanceler @@ -1952,7 +1952,7 @@ BattleScript_EffectTeleport:: jumpifbattletype BATTLE_TYPE_TRAINER, BattleScript_ButItFailed getifcantrunfrombattle ATTACKER jumpifbyte EQUAL, gBattleCommunication, 0x1, BattleScript_ButItFailed - jumpifbyte EQUAL, gBattleCommunication, 0x2, BattleScript_82DA382 + jumpifbyte EQUAL, gBattleCommunication, 0x2, BattleScript_PrintAbilityMadeIneffective attackanimation waitanimation printstring STRINGID_PKMNFLEDFROMBATTLE @@ -2474,8 +2474,8 @@ BattleScript_EffectYawn:: attackcanceler attackstring ppreduce - jumpifability TARGET, ABILITY_VITAL_SPIRIT, BattleScript_82DA378 - jumpifability TARGET, ABILITY_INSOMNIA, BattleScript_82DA378 + jumpifability TARGET, ABILITY_VITAL_SPIRIT, BattleScript_PrintBankAbilityMadeIneffective + jumpifability TARGET, ABILITY_INSOMNIA, BattleScript_PrintBankAbilityMadeIneffective jumpifstatus2 TARGET, STATUS2_SUBSTITUTE, BattleScript_ButItFailed jumpifsideaffecting TARGET, SIDE_STATUS_SAFEGUARD, BattleScript_SafeguardProtected accuracycheck BattleScript_ButItFailed, NO_ACC_CALC_CHECK_LOCK_ON @@ -2486,9 +2486,9 @@ BattleScript_EffectYawn:: printstring STRINGID_PKMNWASMADEDROWSY waitmessage 0x40 goto BattleScript_MoveEnd -BattleScript_82DA378:: - copybyte sBANK, sFIELD_15 -BattleScript_82DA382:: +BattleScript_PrintBankAbilityMadeIneffective:: + copybyte sBANK, sBANK_WITH_ABILITY +BattleScript_PrintAbilityMadeIneffective:: pause 0x20 printstring STRINGID_PKMNSXMADEITINEFFECTIVE waitmessage 0x40 diff --git a/data/battle_scripts_2.s b/data/battle_scripts_2.s index 88991ccd04..b2718b986b 100644 --- a/data/battle_scripts_2.s +++ b/data/battle_scripts_2.s @@ -24,13 +24,13 @@ gBattlescriptsForBallThrow:: @ 82DBD08 .4byte BattleScript_BallThrow .align 2 -gUnknown_082DBD3C:: @ 82DBD3C - .4byte BattleScript_82DBE12 - .4byte BattleScript_82DBE1C - .4byte BattleScript_82DBE1C - .4byte BattleScript_82DBE4B - .4byte BattleScript_82DBE6F - .4byte BattleScript_82DBE91 +gBattlescriptsForUsingItem:: @ 82DBD3C + .4byte BattleScript_PlayerUsesItem + .4byte BattleScript_OpponentUsesHealItem + .4byte BattleScript_OpponentUsesHealItem + .4byte BattleScript_OpponentUsesStatusCureItem + .4byte BattleScript_OpponentUsesXItem + .4byte BattleScript_OpponentUsesGuardSpecs .align 2 gBattlescriptsForRunningByItem:: @ 82DBD54 @@ -58,27 +58,27 @@ BattleScript_SafariBallThrow:: handleballthrow BattleScript_SuccessBallThrow:: - jumpifhalfword EQUAL, gLastUsedItem, ITEM_SAFARI_BALL, BattleScript_82DBD92 + jumpifhalfword EQUAL, gLastUsedItem, ITEM_SAFARI_BALL, BattleScript_PrintCaughtMonInfo incrementgamestat 0xB -BattleScript_82DBD92:: +BattleScript_PrintCaughtMonInfo:: printstring STRINGID_GOTCHAPKMNCAUGHT - trysetcaughtmondexflags BattleScript_82DBDA5 + trysetcaughtmondexflags BattleScript_TryNicknameCaughtMon printstring STRINGID_PKMNDATAADDEDTODEX waitstate setbyte gBattleCommunication, 0x0 displaydexinfo -BattleScript_82DBDA5:: +BattleScript_TryNicknameCaughtMon:: printstring STRINGID_GIVENICKNAMECAPTURED waitstate setbyte gBattleCommunication, 0x0 - trygivecaughtmonnick BattleScript_82DBDC2 + trygivecaughtmonnick BattleScript_GiveCaughtMonEnd givecaughtmon printfromtable gCaughtMonStringIds waitmessage 0x40 - goto BattleScript_82DBDC3 -BattleScript_82DBDC2:: + goto BattleScript_SuccessBallThrowEnd +BattleScript_GiveCaughtMonEnd:: givecaughtmon -BattleScript_82DBDC3:: +BattleScript_SuccessBallThrowEnd:: setbyte gBattleOutcome, CAUGHT finishturn @@ -106,12 +106,12 @@ BattleScript_TrainerBallBlock:: waitmessage 0x40 finishaction -BattleScript_82DBE12:: +BattleScript_PlayerUsesItem:: setbyte sMOVEEND_STATE, 0xF moveend 0x1, 0x0 end -BattleScript_82DBE1C:: +BattleScript_OpponentUsesHealItem:: printstring STRINGID_EMPTYSTRING3 pause 0x30 playse SE_KAIFUKU @@ -128,7 +128,7 @@ BattleScript_82DBE1C:: moveend 0x1, 0x0 finishaction -BattleScript_82DBE4B:: +BattleScript_OpponentUsesStatusCureItem:: printstring STRINGID_EMPTYSTRING3 pause 0x30 playse SE_KAIFUKU @@ -142,7 +142,7 @@ BattleScript_82DBE4B:: moveend 0x1, 0x0 finishaction -BattleScript_82DBE6F:: +BattleScript_OpponentUsesXItem:: printstring STRINGID_EMPTYSTRING3 pause 0x30 playse SE_KAIFUKU @@ -155,7 +155,7 @@ BattleScript_82DBE6F:: moveend 0x1, 0x0 finishaction -BattleScript_82DBE91:: +BattleScript_OpponentUsesGuardSpecs:: printstring STRINGID_EMPTYSTRING3 pause 0x30 playse SE_KAIFUKU diff --git a/include/battle.h b/include/battle.h index 08c9983522..9330f94e98 100644 --- a/include/battle.h +++ b/include/battle.h @@ -616,7 +616,7 @@ struct BattleStruct u8 focusPunchBank; u8 field_49; u8 moneyMultiplier; - u8 field_4B; + u8 savedTurnActionNumber; u8 switchInAbilitiesCounter; u8 faintedActionsState; u8 faintedActionsBank; @@ -846,8 +846,8 @@ struct BattleScripting u8 animArg2; u16 tripleKickPower; u8 atk49_state; - u8 field_15; - u8 field_16; + u8 bankWithAbility; + u8 multihitMoveEffect; u8 bank; u8 animTurn; u8 animTargetsHit; diff --git a/src/battle_2.c b/src/battle_2.c index 9bb41461d7..328eacd854 100644 --- a/src/battle_2.c +++ b/src/battle_2.c @@ -160,7 +160,7 @@ extern const u8 gStatStageRatios[][2]; extern const u8 * const gBattleScriptsForMoveEffects[]; extern const u8 * const gBattlescriptsForBallThrow[]; extern const u8 * const gBattlescriptsForRunningByItem[]; -extern const u8 * const gUnknown_082DBD3C[]; +extern const u8 * const gBattlescriptsForUsingItem[]; extern const u8 * const gBattlescriptsForSafariActions[]; // strings @@ -4692,7 +4692,7 @@ static void CheckFocusPunch_ClearVarsBeforeTurnStarts(void) gBattleMainFunc = RunTurnActionsFunctions; gBattleCommunication[3] = 0; gBattleCommunication[4] = 0; - gBattleScripting.field_16 = 0; + gBattleScripting.multihitMoveEffect = 0; gBattleResources->battleScriptsStack->size = 0; } @@ -4701,7 +4701,7 @@ static void RunTurnActionsFunctions(void) if (gBattleOutcome != 0) gCurrentActionFuncId = 12; - *(&gBattleStruct->field_4B) = gCurrentTurnActionNumber; + *(&gBattleStruct->savedTurnActionNumber) = gCurrentTurnActionNumber; sTurnActionsFuncsTable[gCurrentActionFuncId](); if (gCurrentTurnActionNumber >= gNoOfAllBanks) // everyone did their actions, turn finished @@ -4711,7 +4711,7 @@ static void RunTurnActionsFunctions(void) } else { - if (gBattleStruct->field_4B != gCurrentTurnActionNumber) // action turn has been done, clear hitmarker bits for another bank + if (gBattleStruct->savedTurnActionNumber != gCurrentTurnActionNumber) // action turn has been done, clear hitmarker bits for another bank { gHitMarker &= ~(HITMARKER_NO_ATTACKSTRING); gHitMarker &= ~(HITMARKER_UNABLE_TO_USE_MOVE); @@ -5276,7 +5276,7 @@ static void HandleAction_UseItem(void) } else if (GetBankSide(gBankAttacker) == SIDE_PLAYER) { - gBattlescriptCurrInstr = gUnknown_082DBD3C[0]; + gBattlescriptCurrInstr = gBattlescriptsForUsingItem[0]; } else { @@ -5332,7 +5332,7 @@ static void HandleAction_UseItem(void) break; } - gBattlescriptCurrInstr = gUnknown_082DBD3C[*(gBattleStruct->AI_itemType + gBankAttacker / 2)]; + gBattlescriptCurrInstr = gBattlescriptsForUsingItem[*(gBattleStruct->AI_itemType + gBankAttacker / 2)]; } gCurrentActionFuncId = ACTION_RUN_BATTLESCRIPT; } @@ -5607,6 +5607,6 @@ static void HandleAction_ActionFinished(void) gBattleScripting.atk49_state = 0; gBattleCommunication[3] = 0; gBattleCommunication[4] = 0; - gBattleScripting.field_16 = 0; + gBattleScripting.multihitMoveEffect = 0; gBattleResources->battleScriptsStack->size = 0; } diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 54811a90de..60b08d2c2e 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3040,7 +3040,7 @@ static void atk15_seteffectwithchance(void) } gBattleCommunication[MOVE_EFFECT_BYTE] = 0; - gBattleScripting.field_16 = 0; + gBattleScripting.multihitMoveEffect = 0; } static void atk16_seteffectprimary(void) @@ -3064,7 +3064,7 @@ static void atk18_clearstatusfromeffect(void) gBattleCommunication[MOVE_EFFECT_BYTE] = 0; gBattlescriptCurrInstr += 2; - gBattleScripting.field_16 = 0; + gBattleScripting.multihitMoveEffect = 0; } static void atk19_tryfaintmon(void) @@ -3221,7 +3221,7 @@ static void atk1E_jumpifability(void) gLastUsedAbility = ability; gBattlescriptCurrInstr = jumpPtr; RecordAbilityBattle(bank - 1, gLastUsedAbility); - gBattleScripting.field_15 = bank - 1; + gBattleScripting.bankWithAbility = bank - 1; } else gBattlescriptCurrInstr += 7; @@ -3234,7 +3234,7 @@ static void atk1E_jumpifability(void) gLastUsedAbility = ability; gBattlescriptCurrInstr = jumpPtr; RecordAbilityBattle(bank - 1, gLastUsedAbility); - gBattleScripting.field_15 = bank - 1; + gBattleScripting.bankWithAbility = bank - 1; } else gBattlescriptCurrInstr += 7; @@ -3247,7 +3247,7 @@ static void atk1E_jumpifability(void) gLastUsedAbility = ability; gBattlescriptCurrInstr = jumpPtr; RecordAbilityBattle(bank, gLastUsedAbility); - gBattleScripting.field_15 = bank; + gBattleScripting.bankWithAbility = bank; } else gBattlescriptCurrInstr += 7;