diff options
78 files changed, 1558 insertions, 2554 deletions
diff --git a/asm/battle_frontier_1.s b/asm/battle_frontier_1.s index 5bd832acd..fd372f81b 100755 --- a/asm/battle_frontier_1.s +++ b/asm/battle_frontier_1.s @@ -13791,7 +13791,7 @@ sub_8195FF8: @ 8195FF8 push {r4-r6,lr} adds r5, r0, 0 movs r4, 0 - ldr r6, =gUnknown_085500A4 + ldr r6, =gRematchTable _08196000: movs r1, 0xAE lsls r1, 1 @@ -14659,7 +14659,7 @@ sub_8196710: @ 8196710 thumb_func_start sub_819672C sub_819672C: @ 819672C push {lr} - ldr r1, =gUnknown_085500A4 + ldr r1, =gRematchTable lsls r0, 4 adds r0, r1 ldrh r2, [r0, 0xA] @@ -14677,10 +14677,10 @@ sub_8196748: @ 8196748 push {r4-r6,lr} movs r5, 0 movs r6, 0 - ldr r4, =gUnknown_085500A4 + ldr r4, =gRematchTable _08196750: ldrh r0, [r4] - bl HasTrainerAlreadyBeenFought + bl HasTrainerBeenFought lsls r0, 24 cmp r0, 0 beq _0819675E @@ -14703,10 +14703,10 @@ sub_8196774: @ 8196774 adds r7, r0, 0 movs r4, 0 movs r6, 0 - ldr r5, =gUnknown_085500A4 + ldr r5, =gRematchTable _0819677E: ldrh r0, [r5] - bl HasTrainerAlreadyBeenFought + bl HasTrainerBeenFought lsls r0, 24 cmp r0, 0 beq _0819679A @@ -14766,7 +14766,7 @@ _081967EC: adds r4, r0, 0 movs r7, 0x1 adds r0, r5, 0 - bl sub_80B1E94 + bl UpdateRematchIfDefeated b _08196832 _0819680A: bl Random @@ -15270,7 +15270,7 @@ sub_8196B98: @ 8196B98 adds r7, r0, 0 cmp r1, 0xFF beq _08196C5C - ldr r1, =gUnknown_085500A4 + ldr r1, =gRematchTable lsls r0, r2, 4 adds r2, r0, r1 ldrh r4, [r2, 0xA] @@ -15373,7 +15373,7 @@ sub_8196C70: @ 8196C70 lsls r1, 2 adds r1, r2 ldrh r0, [r1] - bl sub_80B2250 + bl GetLastBeatenRematchTrainerId lsls r0, 16 lsrs r0, 16 ldr r5, =gTrainers diff --git a/asm/battle_setup.s b/asm/battle_setup.s deleted file mode 100644 index 14117ae31..000000000 --- a/asm/battle_setup.s +++ /dev/null @@ -1,1970 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - - - - - - - thumb_func_start TrainerBattleLoadArgs -@ void TrainerBattleLoadArgs(struct TrainerBattleArgSpec *argSpecs, u8 *args) -TrainerBattleLoadArgs: @ 80B1370 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 -_080B1376: - ldrb r0, [r4, 0x4] - cmp r0, 0x6 - bhi _080B13E8 - lsls r0, 2 - ldr r1, =_080B138C - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_080B138C: - .4byte _080B13A8 - .4byte _080B13B6 - .4byte _080B13C4 - .4byte _080B13D2 - .4byte _080B13DA - .4byte _080B13E2 - .4byte _080B13EC -_080B13A8: - adds r0, r5, 0 - bl TrainerBattleLoadArg8 - ldr r1, [r4] - strb r0, [r1] - adds r5, 0x1 - b _080B13E8 -_080B13B6: - adds r0, r5, 0 - bl TrainerBattleLoadArg16 - ldr r1, [r4] - strh r0, [r1] - adds r5, 0x2 - b _080B13E8 -_080B13C4: - adds r0, r5, 0 - bl TrainerBattleLoadArg32 - ldr r1, [r4] - str r0, [r1] - adds r5, 0x4 - b _080B13E8 -_080B13D2: - ldr r1, [r4] - movs r0, 0 - strb r0, [r1] - b _080B13E8 -_080B13DA: - ldr r1, [r4] - movs r0, 0 - strh r0, [r1] - b _080B13E8 -_080B13E2: - ldr r1, [r4] - movs r0, 0 - str r0, [r1] -_080B13E8: - adds r4, 0x8 - b _080B1376 -_080B13EC: - ldr r0, [r4] - str r5, [r0] - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end TrainerBattleLoadArgs - - thumb_func_start battle_80801F0 -battle_80801F0: @ 80B13F8 - push {lr} - ldr r0, =sTrainerMapObjectLocalId - ldrh r1, [r0] - cmp r1, 0 - beq _080B141A - ldr r0, =gSpecialVar_LastTalked - strh r1, [r0] - lsls r0, r1, 24 - lsrs r0, 24 - ldr r1, =gSaveBlock1Ptr - ldr r2, [r1] - ldrb r1, [r2, 0x5] - ldrb r2, [r2, 0x4] - bl GetFieldObjectIdByLocalIdAndMap - ldr r1, =gSelectedMapObject - strb r0, [r1] -_080B141A: - pop {r0} - bx r0 - .pool - thumb_func_end battle_80801F0 - - thumb_func_start BattleSetup_ConfigureTrainerBattle -@ u8 *BattleSetup_ConfigureTrainerBattle(u8 *args) -BattleSetup_ConfigureTrainerBattle: @ 80B1430 - push {r4,r5,lr} - adds r5, r0, 0 - bl InitTrainerBattleVariables - ldr r4, =sTrainerBattleMode - adds r0, r5, 0 - bl TrainerBattleLoadArg8 - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4] - ldrh r0, [r4] - subs r0, 0x1 - cmp r0, 0xB - bls _080B1450 - b _080B15F4 -_080B1450: - lsls r0, 2 - ldr r1, =_080B1464 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_080B1464: - .4byte _080B14CC - .4byte _080B14B0 - .4byte _080B1494 - .4byte _080B14A8 - .4byte _080B1514 - .4byte _080B14D4 - .4byte _080B14EC - .4byte _080B14D4 - .4byte _080B153C - .4byte _080B1590 - .4byte _080B1598 - .4byte _080B15A8 -_080B1494: - ldr r0, =gUnknown_0854FF84 - adds r1, r5, 0 - bl TrainerBattleLoadArgs - ldr r0, =EventScript_2713C2 - b _080B161E - .pool -_080B14A8: - ldr r0, =gUnknown_0854FF3C - b _080B14D6 - .pool -_080B14B0: - ldr r0, =gApproachingTrainerId - ldrb r0, [r0] - cmp r0, 0 - bne _080B14C4 - ldr r0, =gUnknown_0854FEF4 - b _080B15FE - .pool -_080B14C4: - ldr r0, =gUnknown_0855005C - b _080B1616 - .pool -_080B14CC: - ldr r0, =gUnknown_0854FEF4 - b _080B15FE - .pool -_080B14D4: - ldr r0, =gUnknown_0854FFCC -_080B14D6: - adds r1, r5, 0 - bl TrainerBattleLoadArgs - bl battle_80801F0 - ldr r0, =EventScript_27138A - b _080B161E - .pool -_080B14EC: - ldr r0, =gUnknown_0854FF3C - adds r1, r5, 0 - bl TrainerBattleLoadArgs - bl battle_80801F0 - ldr r4, =gTrainerBattleOpponent_A - ldrh r0, [r4] - bl sub_80B2234 - strh r0, [r4] - ldr r0, =EventScript_2713F8 - b _080B161E - .pool -_080B1514: - ldr r0, =gUnknown_0854FEAC - adds r1, r5, 0 - bl TrainerBattleLoadArgs - bl battle_80801F0 - ldr r4, =gTrainerBattleOpponent_A - ldrh r0, [r4] - bl sub_80B2234 - strh r0, [r4] - ldr r0, =EventScript_2713D1 - b _080B161E - .pool -_080B153C: - ldr r0, =gApproachingTrainerId - ldrb r0, [r0] - cmp r0, 0 - bne _080B156C - ldr r0, =gUnknown_0854FEAC - adds r1, r5, 0 - bl TrainerBattleLoadArgs - bl battle_80801F0 - ldr r0, =gSpecialVar_LastTalked - ldrb r0, [r0] - bl sub_81A9AA8 - ldr r1, =gTrainerBattleOpponent_A - b _080B157E - .pool -_080B156C: - ldr r0, =gUnknown_08550014 - adds r1, r5, 0 - bl TrainerBattleLoadArgs - ldr r0, =gSpecialVar_LastTalked - ldrb r0, [r0] - bl sub_81A9AA8 -_080B157C: - ldr r1, =gTrainerBattleOpponent_B -_080B157E: - strh r0, [r1] - b _080B161C - .pool -_080B1590: - ldr r0, =gUnknown_0854FEAC - b _080B159A - .pool -_080B1598: - ldr r0, =gUnknown_08550014 -_080B159A: - adds r1, r5, 0 - bl TrainerBattleLoadArgs - movs r0, 0 - b _080B161E - .pool -_080B15A8: - ldr r0, =gApproachingTrainerId - ldrb r0, [r0] - cmp r0, 0 - bne _080B15D8 - ldr r0, =gUnknown_0854FEAC - adds r1, r5, 0 - bl TrainerBattleLoadArgs - bl battle_80801F0 - ldr r0, =gSpecialVar_LastTalked - ldrb r0, [r0] - bl battle_init - ldr r1, =gTrainerBattleOpponent_A - b _080B157E - .pool -_080B15D8: - ldr r0, =gUnknown_08550014 - adds r1, r5, 0 - bl TrainerBattleLoadArgs - ldr r0, =gSpecialVar_LastTalked - ldrb r0, [r0] - bl battle_init - b _080B157C - .pool -_080B15F4: - ldr r0, =gApproachingTrainerId - ldrb r0, [r0] - cmp r0, 0 - bne _080B1614 - ldr r0, =gUnknown_0854FEAC -_080B15FE: - adds r1, r5, 0 - bl TrainerBattleLoadArgs - bl battle_80801F0 - b _080B161C - .pool -_080B1614: - ldr r0, =gUnknown_08550014 -_080B1616: - adds r1, r5, 0 - bl TrainerBattleLoadArgs -_080B161C: - ldr r0, =EventScript_271362 -_080B161E: - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end BattleSetup_ConfigureTrainerBattle - - thumb_func_start SingleTrainerWantsBattle -@ void SingleTrainerWantsBattle(u8 trainerFieldObjectId, u8 *trainerScript) -SingleTrainerWantsBattle: @ 80B162C - push {r4,lr} - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gSelectedMapObject - strb r0, [r2] - ldr r4, =gSpecialVar_LastTalked - ldr r3, =gMapObjects - lsls r2, r0, 3 - adds r2, r0 - lsls r2, 2 - adds r2, r3 - ldrb r0, [r2, 0x8] - strh r0, [r4] - adds r1, 0x1 - adds r0, r1, 0 - bl BattleSetup_ConfigureTrainerBattle - ldr r0, =EventScript_271354 - bl ScriptContext1_SetupScript - bl ScriptContext2_Enable - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end SingleTrainerWantsBattle - - thumb_func_start TwoTrainersWantBattle -@ void TwoTrainersWantBattle(u8 trainerFieldObjectId, u8 *trainerScript) -TwoTrainersWantBattle: @ 80B1670 - push {r4,lr} - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gSelectedMapObject - strb r0, [r2] - ldr r4, =gSpecialVar_LastTalked - ldr r3, =gMapObjects - lsls r2, r0, 3 - adds r2, r0 - lsls r2, 2 - adds r2, r3 - ldrb r0, [r2, 0x8] - strh r0, [r4] - adds r1, 0x1 - adds r0, r1, 0 - bl BattleSetup_ConfigureTrainerBattle - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end TwoTrainersWantBattle - - thumb_func_start TwoTrainersWantBattleExecuteScript -@ void TwoTrainersWantBattleExecuteScript() -TwoTrainersWantBattleExecuteScript: @ 80B16A4 - push {lr} - ldr r0, =EventScript_271354 - bl ScriptContext1_SetupScript - bl ScriptContext2_Enable - pop {r0} - bx r0 - .pool - thumb_func_end TwoTrainersWantBattleExecuteScript - - thumb_func_start GetTrainerFlagFromScriptPointer -@ u8 GetTrainerFlagFromScriptPointer(u8 *scriptPointer) -GetTrainerFlagFromScriptPointer: @ 80B16B8 - push {lr} - adds r0, 0x2 - bl TrainerBattleLoadArg16 - lsls r0, 16 - movs r1, 0xA0 - lsls r1, 19 - adds r0, r1 - lsrs r0, 16 - bl FlagGet - lsls r0, 24 - lsrs r0, 24 - pop {r1} - bx r1 - thumb_func_end GetTrainerFlagFromScriptPointer - - thumb_func_start sub_80B16D8 -sub_80B16D8: @ 80B16D8 - push {r4,lr} - ldr r0, =gSelectedMapObject - ldrb r0, [r0] - lsls r4, r0, 3 - adds r4, r0 - lsls r4, 2 - ldr r0, =gMapObjects - adds r4, r0 - ldrb r0, [r4, 0x18] - lsls r0, 28 - lsrs r0, 28 - bl npc_running_behaviour_by_direction - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - adds r0, r4, 0 - bl npc_set_running_behaviour_etc - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B16D8 - - thumb_func_start sub_80B170C -sub_80B170C: @ 80B170C - ldr r0, =sTrainerBattleMode - ldrb r0, [r0] - bx lr - .pool - thumb_func_end sub_80B170C - - thumb_func_start check_trainer_flag -@ pokescrcmd -check_trainer_flag: @ 80B1718 - push {lr} - bl InBattlePyramid - lsls r0, 24 - cmp r0, 0 - beq _080B1734 - ldr r0, =gSelectedMapObject - ldrb r0, [r0] - bl GetBattlePyramidTrainerFlag - b _080B1752 - .pool -_080B1734: - bl InTrainerHill - cmp r0, 0 - bne _080B174A - bl GetTrainerAFlag - lsls r0, 16 - lsrs r0, 16 - bl FlagGet - b _080B1752 -_080B174A: - ldr r0, =gSelectedMapObject - ldrb r0, [r0] - bl GetTrainerHillTrainerFlag -_080B1752: - lsls r0, 24 - lsrs r0, 24 - pop {r1} - bx r1 - .pool - thumb_func_end check_trainer_flag - - thumb_func_start rom_npc_set_flag_for_script_id -rom_npc_set_flag_for_script_id: @ 80B1760 - push {lr} - ldr r0, =gTrainerBattleOpponent_B - ldrh r0, [r0] - cmp r0, 0 - beq _080B1776 - bl GetTrainerBFlag - lsls r0, 16 - lsrs r0, 16 - bl FlagSet -_080B1776: - bl GetTrainerAFlag - lsls r0, 16 - lsrs r0, 16 - bl FlagSet - pop {r0} - bx r0 - .pool - thumb_func_end rom_npc_set_flag_for_script_id - - thumb_func_start sub_80B178C -sub_80B178C: @ 80B178C - push {lr} - bl GetTrainerAFlag - lsls r0, 16 - lsrs r0, 16 - bl FlagSet - pop {r0} - bx r0 - thumb_func_end sub_80B178C - - thumb_func_start HasTrainerAlreadyBeenFought -HasTrainerAlreadyBeenFought: @ 80B17A0 - push {lr} - lsls r0, 16 - movs r1, 0xA0 - lsls r1, 19 - adds r0, r1 - lsrs r0, 16 - bl FlagGet - lsls r0, 24 - lsrs r0, 24 - pop {r1} - bx r1 - thumb_func_end HasTrainerAlreadyBeenFought - - thumb_func_start trainer_flag_set -trainer_flag_set: @ 80B17B8 - push {lr} - lsls r0, 16 - movs r1, 0xA0 - lsls r1, 19 - adds r0, r1 - lsrs r0, 16 - bl FlagSet - pop {r0} - bx r0 - thumb_func_end trainer_flag_set - - thumb_func_start trainer_flag_clear -trainer_flag_clear: @ 80B17CC - push {lr} - lsls r0, 16 - movs r1, 0xA0 - lsls r1, 19 - adds r0, r1 - lsrs r0, 16 - bl FlagClear - pop {r0} - bx r0 - thumb_func_end trainer_flag_clear - - thumb_func_start BattleSetup_StartTrainerBattle -BattleSetup_StartTrainerBattle: @ 80B17E0 - push {r4,lr} - ldr r0, =gUnknown_030060A8 - ldrb r0, [r0] - cmp r0, 0x2 - bne _080B17FC - ldr r1, =gBattleTypeFlags - ldr r0, =0x00008009 - b _080B1800 - .pool -_080B17FC: - ldr r1, =gBattleTypeFlags - movs r0, 0x8 -_080B1800: - str r0, [r1] - bl InBattlePyramid - lsls r0, 24 - cmp r0, 0 - beq _080B1884 - ldr r0, =0x0000400e - movs r1, 0 - bl VarSet - ldr r2, =gBattleTypeFlags - ldr r0, [r2] - movs r1, 0x80 - lsls r1, 14 - orrs r0, r1 - str r0, [r2] - ldr r0, =gUnknown_030060A8 - ldrb r0, [r0] - cmp r0, 0x2 - bne _080B1864 - movs r0, 0x1 - bl sub_816306C - ldr r4, =gEnemyParty + 100 - adds r0, r4, 0 - bl ZeroMonData - adds r0, r4, 0 - adds r0, 0x64 - bl ZeroMonData - movs r1, 0x96 - lsls r1, 1 - adds r0, r4, r1 - bl ZeroMonData - movs r1, 0xC8 - lsls r1, 1 - adds r0, r4, r1 - bl ZeroMonData - b _080B187A - .pool -_080B1864: - movs r0, 0x1 - bl sub_8163048 - ldr r4, =gEnemyParty + 100 - adds r0, r4, 0 - bl ZeroMonData - adds r4, 0x64 - adds r0, r4, 0 - bl ZeroMonData -_080B187A: - bl sub_81A9B04 - b _080B18B8 - .pool -_080B1884: - bl sub_81D5C18 - lsls r0, 24 - cmp r0, 0 - beq _080B18B8 - ldr r2, =gBattleTypeFlags - ldr r0, [r2] - movs r1, 0x80 - lsls r1, 19 - orrs r0, r1 - str r0, [r2] - ldr r0, =gUnknown_030060A8 - ldrb r0, [r0] - cmp r0, 0x2 - bne _080B18B0 - bl sub_81D639C - b _080B18B4 - .pool -_080B18B0: - bl sub_81D6384 -_080B18B4: - bl sub_81D61E8 -_080B18B8: - ldr r1, =gUnknown_02038BF9 - ldr r2, =gUnknown_030060A8 - ldrb r0, [r2] - strb r0, [r1] - movs r1, 0 - strb r1, [r2] - ldr r0, =gUnknown_02038BF8 - strb r1, [r0] - ldr r1, =gUnknown_03006080 - movs r0, 0 - strh r0, [r1] - ldr r1, =gMain - ldr r0, =sub_80B1918 - str r0, [r1, 0x8] - bl InBattlePyramid - lsls r0, 24 - cmp r0, 0 - bne _080B18E8 - bl sub_81D5C18 - lsls r0, 24 - cmp r0, 0 - beq _080B1908 -_080B18E8: - bl sub_80B0828 - b _080B190C - .pool -_080B1908: - bl DoTrainerBattle -_080B190C: - bl ScriptContext1_Stop - pop {r4} - pop {r0} - bx r0 - thumb_func_end BattleSetup_StartTrainerBattle - - thumb_func_start sub_80B1918 -sub_80B1918: @ 80B1918 - push {lr} - ldr r0, =gTrainerBattleOpponent_A - ldrh r1, [r0] - movs r0, 0x80 - lsls r0, 3 - cmp r1, r0 - beq _080B1946 - ldr r0, =gBattleOutcome - ldrb r0, [r0] - bl IsPlayerDefeated - cmp r0, 0x1 - bne _080B1968 - bl InBattlePyramid - lsls r0, 24 - cmp r0, 0 - bne _080B1946 - bl sub_81D5C18 - lsls r0, 24 - cmp r0, 0 - beq _080B195C -_080B1946: - ldr r0, =c2_exit_to_overworld_1_continue_scripts_restart_music - bl SetMainCallback2 - b _080B198A - .pool -_080B195C: - ldr r0, =CB2_WhiteOut - bl SetMainCallback2 - b _080B198A - .pool -_080B1968: - ldr r0, =c2_exit_to_overworld_1_continue_scripts_restart_music - bl SetMainCallback2 - bl InBattlePyramid - lsls r0, 24 - cmp r0, 0 - bne _080B198A - bl sub_81D5C18 - lsls r0, 24 - cmp r0, 0 - bne _080B198A - bl sub_80B20BC - bl rom_npc_set_flag_for_script_id -_080B198A: - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B1918 - - thumb_func_start sub_80B1994 -sub_80B1994: @ 80B1994 - push {lr} - ldr r0, =gTrainerBattleOpponent_A - ldrh r1, [r0] - movs r0, 0x80 - lsls r0, 3 - cmp r1, r0 - bne _080B19B4 - ldr r0, =c2_exit_to_overworld_1_continue_scripts_restart_music - bl SetMainCallback2 - b _080B19E2 - .pool -_080B19B4: - ldr r0, =gBattleOutcome - ldrb r0, [r0] - bl IsPlayerDefeated - cmp r0, 0x1 - bne _080B19D0 - ldr r0, =CB2_WhiteOut - bl SetMainCallback2 - b _080B19E2 - .pool -_080B19D0: - ldr r0, =c2_exit_to_overworld_1_continue_scripts_restart_music - bl SetMainCallback2 - bl sub_80B20BC - bl rom_npc_set_flag_for_script_id - bl sub_80B22BC -_080B19E2: - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B1994 - - thumb_func_start sub_80B19EC -sub_80B19EC: @ 80B19EC - push {lr} - ldr r1, =gBattleTypeFlags - movs r0, 0x8 - str r0, [r1] - ldr r1, =gMain - ldr r0, =sub_80B1994 - str r0, [r1, 0x8] - bl DoTrainerBattle - bl ScriptContext1_Stop - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B19EC - - thumb_func_start sub_80B1A14 -sub_80B1A14: @ 80B1A14 - push {lr} - bl InBattlePyramid - lsls r0, 24 - cmp r0, 0 - beq _080B1A7C - ldr r0, =gUnknown_030060A8 - ldrb r0, [r0] - cmp r0, 0x1 - bhi _080B1A44 - ldr r0, =gSpecialVar_LastTalked - ldrb r0, [r0] - bl sub_81A9AA8 - lsls r0, 16 - lsrs r0, 16 - bl sub_81A9EDC - b _080B1AD8 - .pool -_080B1A44: - ldr r3, =gMapObjects - ldr r2, =gUnknown_03006090 - ldr r0, =gApproachingTrainerId - ldrb r1, [r0] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r1, [r0] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - ldrb r0, [r0, 0x8] - bl sub_81A9AA8 - lsls r0, 16 - lsrs r0, 16 - bl sub_81A9EDC - b _080B1AD8 - .pool -_080B1A7C: - bl sub_81D5C18 - lsls r0, 24 - cmp r0, 0 - beq _080B1AEC - ldr r0, =gUnknown_030060A8 - ldrb r0, [r0] - cmp r0, 0x1 - bhi _080B1AAC - ldr r0, =gSpecialVar_LastTalked - ldrb r0, [r0] - bl battle_init - adds r1, r0, 0 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x2 - bl sub_81D572C - b _080B1AD8 - .pool -_080B1AAC: - ldr r3, =gMapObjects - ldr r2, =gUnknown_03006090 - ldr r0, =gApproachingTrainerId - ldrb r1, [r0] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r1, [r0] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - ldrb r0, [r0, 0x8] - bl battle_init - adds r1, r0, 0 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x2 - bl sub_81D572C -_080B1AD8: - bl sub_80982B8 - b _080B1AF4 - .pool -_080B1AEC: - bl sub_80B1C7C - bl ShowFieldMessage -_080B1AF4: - pop {r0} - bx r0 - thumb_func_end sub_80B1A14 - - thumb_func_start BattleSetup_GetScriptAddrAfterBattle -BattleSetup_GetScriptAddrAfterBattle: @ 80B1AF8 - push {lr} - ldr r0, =gUnknown_02038BEC - ldr r0, [r0] - cmp r0, 0 - bne _080B1B04 - ldr r0, =EventScript_2C8436 -_080B1B04: - pop {r1} - bx r1 - .pool - thumb_func_end BattleSetup_GetScriptAddrAfterBattle - - thumb_func_start BattleSetup_GetTrainerPostBattleScript -BattleSetup_GetTrainerPostBattleScript: @ 80B1B10 - push {lr} - ldr r1, =gUnknown_02038BF8 - ldrb r2, [r1] - cmp r2, 0 - beq _080B1B3C - movs r0, 0 - strb r0, [r1] - ldr r0, =gUnknown_02038BF4 - ldr r2, [r0] - cmp r2, 0 - beq _080B1B54 - ldr r1, =gUnknown_03006080 - movs r0, 0x1 - strh r0, [r1] - adds r0, r2, 0 - b _080B1B56 - .pool -_080B1B3C: - ldr r0, =gUnknown_02038BF0 - ldr r1, [r0] - cmp r1, 0 - beq _080B1B54 - ldr r0, =gUnknown_03006080 - strh r2, [r0] - adds r0, r1, 0 - b _080B1B56 - .pool -_080B1B54: - ldr r0, =LavaridgeTown_Gym_1F_EventScript_2742E6 -_080B1B56: - pop {r1} - bx r1 - .pool - thumb_func_end BattleSetup_GetTrainerPostBattleScript - - thumb_func_start special_trainer_unable_to_battle -special_trainer_unable_to_battle: @ 80B1B60 - push {lr} - bl sub_80B1D18 - bl ShowFieldMessage - pop {r0} - bx r0 - thumb_func_end special_trainer_unable_to_battle - - thumb_func_start SetUpTrainerEncounterMusic -@ void SetUpTrainerEncounterMusic() -SetUpTrainerEncounterMusic: @ 80B1B70 - push {lr} - ldr r0, =gApproachingTrainerId - ldrb r0, [r0] - cmp r0, 0 - bne _080B1B88 - ldr r0, =gTrainerBattleOpponent_A - b _080B1B8A - .pool -_080B1B88: - ldr r0, =gTrainerBattleOpponent_B -_080B1B8A: - ldrh r1, [r0] - ldr r0, =sTrainerBattleMode - ldrh r0, [r0] - cmp r0, 0x1 - beq _080B1C62 - cmp r0, 0x8 - beq _080B1C62 - adds r0, r1, 0 - bl GetTrainerEncounterMusicId - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0xD - bhi _080B1C5C - lsls r0, 2 - ldr r1, =_080B1BBC - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_080B1BBC: - .4byte _080B1BF4 - .4byte _080B1BFA - .4byte _080B1C04 - .4byte _080B1C5C - .4byte _080B1C0C - .4byte _080B1C12 - .4byte _080B1C1C - .4byte _080B1C24 - .4byte _080B1C2C - .4byte _080B1C34 - .4byte _080B1C3C - .4byte _080B1C42 - .4byte _080B1C4C - .4byte _080B1C54 -_080B1BF4: - movs r0, 0xBE - lsls r0, 1 - b _080B1C5E -_080B1BFA: - ldr r0, =0x00000197 - b _080B1C5E - .pool -_080B1C04: - ldr r0, =0x0000017b - b _080B1C5E - .pool -_080B1C0C: - movs r0, 0xD0 - lsls r0, 1 - b _080B1C5E -_080B1C12: - ldr r0, =0x000001a1 - b _080B1C5E - .pool -_080B1C1C: - ldr r0, =0x000001a3 - b _080B1C5E - .pool -_080B1C24: - ldr r0, =0x000001b9 - b _080B1C5E - .pool -_080B1C2C: - ldr r0, =0x00000181 - b _080B1C5E - .pool -_080B1C34: - ldr r0, =0x000001c1 - b _080B1C5E - .pool -_080B1C3C: - movs r0, 0xE1 - lsls r0, 1 - b _080B1C5E -_080B1C42: - ldr r0, =0x000001c3 - b _080B1C5E - .pool -_080B1C4C: - ldr r0, =0x000001c5 - b _080B1C5E - .pool -_080B1C54: - ldr r0, =0x0000018d - b _080B1C5E - .pool -_080B1C5C: - ldr r0, =0x000001a7 -_080B1C5E: - bl PlayNewMapMusic -_080B1C62: - pop {r0} - bx r0 - .pool - thumb_func_end SetUpTrainerEncounterMusic - - thumb_func_start ReturnEmptyStringIfNull -@ u8 *ReturnEmptyStringIfNull(u8 *str) -ReturnEmptyStringIfNull: @ 80B1C6C - push {lr} - cmp r0, 0 - bne _080B1C74 - ldr r0, =gText_EmptyString2 -_080B1C74: - pop {r1} - bx r1 - .pool - thumb_func_end ReturnEmptyStringIfNull - - thumb_func_start sub_80B1C7C -sub_80B1C7C: @ 80B1C7C - push {lr} - ldr r0, =gApproachingTrainerId - ldrb r0, [r0] - cmp r0, 0 - beq _080B1C94 - ldr r0, =sTrainerBIntroSpeech - b _080B1C96 - .pool -_080B1C94: - ldr r0, =sTrainerAIntroSpeech -_080B1C96: - ldr r0, [r0] - bl ReturnEmptyStringIfNull - pop {r1} - bx r1 - .pool - thumb_func_end sub_80B1C7C - - thumb_func_start GetTrainer1LoseText -GetTrainer1LoseText: @ 80B1CA4 - push {r4,lr} - ldr r0, =gTrainerBattleOpponent_A - ldrh r1, [r0] - movs r0, 0x80 - lsls r0, 3 - cmp r1, r0 - bne _080B1CBC - bl sub_80EA250 - b _080B1CC0 - .pool -_080B1CBC: - ldr r0, =sTrainerADefeatSpeech - ldr r0, [r0] -_080B1CC0: - ldr r4, =gStringVar4 - bl ReturnEmptyStringIfNull - adds r1, r0, 0 - adds r0, r4, 0 - bl StringExpandPlaceholders - adds r0, r4, 0 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end GetTrainer1LoseText - - thumb_func_start GetTrainer2LoseText -GetTrainer2LoseText: @ 80B1CE0 - push {r4,lr} - ldr r4, =gStringVar4 - ldr r0, =sTrainerBDefeatSpeech - ldr r0, [r0] - bl ReturnEmptyStringIfNull - adds r1, r0, 0 - adds r0, r4, 0 - bl StringExpandPlaceholders - adds r0, r4, 0 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end GetTrainer2LoseText - - thumb_func_start sub_80B1D04 -sub_80B1D04: @ 80B1D04 - push {lr} - ldr r0, =sTrainerVictorySpeech - ldr r0, [r0] - bl ReturnEmptyStringIfNull - pop {r1} - bx r1 - .pool - thumb_func_end sub_80B1D04 - - thumb_func_start sub_80B1D18 -sub_80B1D18: @ 80B1D18 - push {lr} - ldr r0, =sTrainerCannotBattleSpeech - ldr r0, [r0] - bl ReturnEmptyStringIfNull - pop {r1} - bx r1 - .pool - thumb_func_end sub_80B1D18 - - thumb_func_start sub_80B1D2C -sub_80B1D2C: @ 80B1D2C - push {lr} - lsls r1, 16 - lsrs r1, 16 - movs r3, 0 - adds r2, r0, 0 -_080B1D36: - ldrh r0, [r2] - cmp r0, r1 - bne _080B1D40 - adds r0, r3, 0 - b _080B1D4C -_080B1D40: - adds r2, 0x10 - adds r3, 0x1 - cmp r3, 0x4D - ble _080B1D36 - movs r0, 0x1 - negs r0, r0 -_080B1D4C: - pop {r1} - bx r1 - thumb_func_end sub_80B1D2C - - thumb_func_start sub_80B1D50 -sub_80B1D50: @ 80B1D50 - push {r4,r5,lr} - lsls r1, 16 - lsrs r5, r1, 16 - movs r4, 0 - adds r2, r0, 0 -_080B1D5A: - movs r1, 0 - ldrh r0, [r2] - cmp r0, 0 - beq _080B1D80 - movs r3, 0 -_080B1D64: - adds r0, r2, r3 - ldrh r0, [r0] - cmp r0, r5 - bne _080B1D70 - adds r0, r4, 0 - b _080B1D8C -_080B1D70: - adds r3, 0x2 - adds r1, 0x1 - cmp r1, 0x4 - bgt _080B1D80 - adds r0, r2, r3 - ldrh r0, [r0] - cmp r0, 0 - bne _080B1D64 -_080B1D80: - adds r2, 0x10 - adds r4, 0x1 - cmp r4, 0x4D - ble _080B1D5A - movs r0, 0x1 - negs r0, r0 -_080B1D8C: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80B1D50 - - thumb_func_start sub_80B1D94 -sub_80B1D94: @ 80B1D94 - push {lr} - cmp r0, 0x48 - ble _080B1D9E - movs r0, 0x1 - b _080B1DB8 -_080B1D9E: - cmp r0, 0x40 - bne _080B1DB6 - movs r0, 0x7E - bl FlagGet - movs r1, 0 - lsls r0, 24 - cmp r0, 0 - bne _080B1DB2 - movs r1, 0x1 -_080B1DB2: - adds r0, r1, 0 - b _080B1DB8 -_080B1DB6: - movs r0, 0 -_080B1DB8: - pop {r1} - bx r1 - thumb_func_end sub_80B1D94 - - thumb_func_start sub_80B1DBC -sub_80B1DBC: @ 80B1DBC - push {r4-r6,lr} - adds r6, r1, 0 - movs r5, 0x1 - lsls r1, r6, 4 - adds r1, r0 - adds r4, r1, 0x2 - b _080B1DCE -_080B1DCA: - adds r4, 0x2 - adds r5, 0x1 -_080B1DCE: - cmp r5, 0x4 - bgt _080B1DE2 - ldrh r0, [r4] - cmp r0, 0 - beq _080B1DE2 - bl HasTrainerAlreadyBeenFought - lsls r0, 24 - cmp r0, 0 - bne _080B1DCA -_080B1DE2: - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r1, =0x000009ca - adds r0, r1 - adds r0, r6 - strb r5, [r0] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B1DBC - - thumb_func_start sub_80B1DFC -sub_80B1DFC: @ 80B1DFC - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - adds r6, r0, 0 - lsls r1, 16 - lsrs r1, 16 - mov r9, r1 - lsls r2, 16 - lsrs r2, 16 - mov r8, r2 - movs r7, 0 - movs r5, 0 - adds r4, r6, 0 - adds r4, 0xA -_080B1E1A: - ldrh r0, [r4] - cmp r0, r9 - bne _080B1E74 - ldrh r0, [r4, 0x2] - cmp r0, r8 - bne _080B1E74 - adds r0, r5, 0 - bl sub_80B1D94 - cmp r0, 0 - bne _080B1E74 - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r1, =0x000009ca - adds r0, r1 - adds r0, r5 - ldrb r0, [r0] - cmp r0, 0 - bne _080B1E72 - movs r1, 0xAE - lsls r1, 1 - adds r0, r5, r1 - lsls r0, 16 - lsrs r0, 16 - bl FlagGet - lsls r0, 24 - cmp r0, 0 - beq _080B1E74 - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x64 - bl __umodsi3 - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x1E - bhi _080B1E74 - adds r0, r6, 0 - adds r1, r5, 0 - bl sub_80B1DBC -_080B1E72: - movs r7, 0x1 -_080B1E74: - adds r4, 0x10 - adds r5, 0x1 - cmp r5, 0x40 - ble _080B1E1A - adds r0, r7, 0 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80B1DFC - - thumb_func_start sub_80B1E94 -sub_80B1E94: @ 80B1E94 - push {r4,r5,lr} - adds r4, r0, 0 - ldr r5, =gUnknown_085500A4 - lsls r0, r4, 4 - adds r0, r5 - ldrh r0, [r0] - bl HasTrainerAlreadyBeenFought - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _080B1EB4 - adds r0, r5, 0 - adds r1, r4, 0 - bl sub_80B1DBC -_080B1EB4: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B1E94 - - thumb_func_start sub_80B1EC0 -sub_80B1EC0: @ 80B1EC0 - push {r4-r6,lr} - lsls r1, 16 - lsrs r4, r1, 16 - lsls r2, 16 - lsrs r2, 16 - movs r1, 0 - adds r3, r0, 0 - adds r3, 0xA - ldr r5, =gSaveBlock1Ptr -_080B1ED2: - ldrh r0, [r3] - cmp r0, r4 - bne _080B1EF8 - ldrh r0, [r3, 0x2] - cmp r0, r2 - bne _080B1EF8 - ldr r0, [r5] - ldr r6, =0x000009ca - adds r0, r6 - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0 - beq _080B1EF8 - movs r0, 0x1 - b _080B1F02 - .pool -_080B1EF8: - adds r3, 0x10 - adds r1, 0x1 - cmp r1, 0x4D - ble _080B1ED2 - movs r0, 0 -_080B1F02: - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_80B1EC0 - - thumb_func_start sub_80B1F08 -sub_80B1F08: @ 80B1F08 - push {r4,lr} - lsls r1, 16 - lsrs r4, r1, 16 - lsls r2, 16 - lsrs r2, 16 - movs r1, 0 - adds r3, r0, 0 - adds r3, 0xA -_080B1F18: - ldrh r0, [r3] - cmp r0, r4 - bne _080B1F28 - ldrh r0, [r3, 0x2] - cmp r0, r2 - bne _080B1F28 - movs r0, 0x1 - b _080B1F32 -_080B1F28: - adds r3, 0x10 - adds r1, 0x1 - cmp r1, 0x4D - ble _080B1F18 - movs r0, 0 -_080B1F32: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_80B1F08 - - thumb_func_start sub_80B1F38 -sub_80B1F38: @ 80B1F38 - push {lr} - lsls r1, 16 - lsrs r1, 16 - bl sub_80B1D2C - adds r1, r0, 0 - movs r0, 0x1 - negs r0, r0 - cmp r1, r0 - beq _080B1F6C - cmp r1, 0x63 - bgt _080B1F6C - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r2, =0x000009ca - adds r0, r2 - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0 - beq _080B1F6C - movs r0, 0x1 - b _080B1F6E - .pool -_080B1F6C: - movs r0, 0 -_080B1F6E: - pop {r1} - bx r1 - thumb_func_end sub_80B1F38 - - thumb_func_start sub_80B1F74 -sub_80B1F74: @ 80B1F74 - push {lr} - lsls r1, 16 - lsrs r1, 16 - bl sub_80B1D50 - adds r1, r0, 0 - movs r0, 0x1 - negs r0, r0 - cmp r1, r0 - beq _080B1FA8 - cmp r1, 0x63 - bgt _080B1FA8 - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r2, =0x000009ca - adds r0, r2 - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0 - beq _080B1FA8 - movs r0, 0x1 - b _080B1FAA - .pool -_080B1FA8: - movs r0, 0 -_080B1FAA: - pop {r1} - bx r1 - thumb_func_end sub_80B1F74 - - thumb_func_start sub_80B1FB0 -sub_80B1FB0: @ 80B1FB0 - push {r4-r7,lr} - adds r4, r0, 0 - lsls r1, 16 - lsrs r1, 16 - bl sub_80B1D2C - adds r1, r0, 0 - movs r0, 0x1 - negs r0, r0 - cmp r1, r0 - bne _080B1FD8 - movs r0, 0 - b _080B1FFE -_080B1FCA: - subs r0, r6, 0x1 - lsls r0, 1 - adds r0, r7, r0 - ldrh r0, [r0] - b _080B1FFE -_080B1FD4: - ldrh r0, [r5] - b _080B1FFE -_080B1FD8: - lsls r0, r1, 4 - adds r7, r4, r0 - movs r6, 0x1 - adds r5, r7, 0x2 - adds r4, r5, 0 -_080B1FE2: - ldrh r0, [r4] - cmp r0, 0 - beq _080B1FCA - bl HasTrainerAlreadyBeenFought - lsls r0, 24 - cmp r0, 0 - beq _080B1FD4 - adds r4, 0x2 - adds r5, 0x2 - adds r6, 0x1 - cmp r6, 0x4 - ble _080B1FE2 - ldrh r0, [r7, 0x8] -_080B1FFE: - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_80B1FB0 - - thumb_func_start sub_80B2004 -sub_80B2004: @ 80B2004 - push {r4-r6,lr} - adds r4, r0, 0 - lsls r1, 16 - lsrs r1, 16 - bl sub_80B1D2C - adds r1, r0, 0 - movs r0, 0x1 - negs r0, r0 - cmp r1, r0 - bne _080B2032 - movs r0, 0 - b _080B2054 -_080B201E: - subs r0, r5, 0x1 - lsls r0, 1 - adds r0, r6, r0 - ldrh r0, [r0] - b _080B2054 -_080B2028: - subs r0, r5, 0x1 - lsls r0, 1 - adds r0, r6, r0 - ldrh r0, [r0] - b _080B2054 -_080B2032: - lsls r0, r1, 4 - adds r6, r4, r0 - movs r5, 0x1 - adds r4, r6, 0x2 -_080B203A: - ldrh r0, [r4] - cmp r0, 0 - beq _080B201E - bl HasTrainerAlreadyBeenFought - lsls r0, 24 - cmp r0, 0 - beq _080B2028 - adds r4, 0x2 - adds r5, 0x1 - cmp r5, 0x4 - ble _080B203A - ldrh r0, [r6, 0x8] -_080B2054: - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_80B2004 - - thumb_func_start sub_80B205C -sub_80B205C: @ 80B205C - push {lr} - lsls r1, 16 - lsrs r1, 16 - bl sub_80B1D50 - adds r1, r0, 0 - movs r0, 0x1 - negs r0, r0 - cmp r1, r0 - beq _080B207E - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r2, =0x000009ca - adds r0, r2 - adds r0, r1 - movs r1, 0 - strb r1, [r0] -_080B207E: - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B205C - - thumb_func_start sub_80B208C -sub_80B208C: @ 80B208C - push {r4,lr} - adds r3, r0, 0 - movs r1, 0 - movs r4, 0xAE - lsls r4, 1 - ldr r2, =gUnknown_085500A4 -_080B2098: - ldrh r0, [r2] - cmp r0, r3 - bne _080B20A8 - adds r0, r1, r4 - b _080B20B2 - .pool -_080B20A8: - adds r2, 0x10 - adds r1, 0x1 - cmp r1, 0x4D - ble _080B2098 - ldr r0, =0x0000ffff -_080B20B2: - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80B208C - - thumb_func_start sub_80B20BC -sub_80B20BC: @ 80B20BC - push {lr} - ldr r0, =0x0000012f - bl FlagGet - lsls r0, 24 - cmp r0, 0 - beq _080B20E2 - ldr r0, =gTrainerBattleOpponent_A - ldrh r0, [r0] - bl sub_80B208C - adds r1, r0, 0 - ldr r0, =0x0000ffff - cmp r1, r0 - beq _080B20E2 - lsls r0, r1, 16 - lsrs r0, 16 - bl FlagSet -_080B20E2: - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B20BC - - thumb_func_start sub_80B20F4 -sub_80B20F4: @ 80B20F4 - push {r4,lr} - adds r4, r0, 0 - lsls r1, 16 - lsrs r1, 16 - bl sub_80B1D2C - adds r1, r0, 0 - movs r0, 0x1 - negs r0, r0 - cmp r1, r0 - beq _080B211E - lsls r0, r1, 4 - adds r0, r4 - ldrh r0, [r0, 0x2] - bl HasTrainerAlreadyBeenFought - lsls r0, 24 - cmp r0, 0 - beq _080B211E - movs r0, 0x1 - b _080B2120 -_080B211E: - movs r0, 0 -_080B2120: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_80B20F4 - - thumb_func_start sub_80B2128 -sub_80B2128: @ 80B2128 - push {r4-r6,lr} - movs r6, 0 - movs r5, 0 - ldr r4, =gUnknown_08550584 -_080B2130: - ldrh r0, [r4] - bl FlagGet - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _080B214C - adds r6, 0x1 - cmp r6, 0x4 - ble _080B214C - movs r0, 0x1 - b _080B2156 - .pool -_080B214C: - adds r4, 0x2 - adds r5, 0x1 - cmp r5, 0x7 - bls _080B2130 - movs r0, 0 -_080B2156: - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_80B2128 - - thumb_func_start sub_80B215C -sub_80B215C: @ 80B215C - push {lr} - bl sub_80B2128 - cmp r0, 0 - beq _080B2184 - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r2, =0x000009c8 - adds r1, r0, r2 - ldrh r0, [r1] - cmp r0, 0xFE - bls _080B2180 - movs r0, 0xFF - b _080B2182 - .pool -_080B2180: - adds r0, 0x1 -_080B2182: - strh r0, [r1] -_080B2184: - pop {r0} - bx r0 - thumb_func_end sub_80B215C - - thumb_func_start sub_80B2188 -sub_80B2188: @ 80B2188 - push {lr} - bl sub_80B2128 - cmp r0, 0 - beq _080B21AC - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r1, =0x000009c8 - adds r0, r1 - ldrh r0, [r0] - cmp r0, 0xFE - bls _080B21AC - movs r0, 0x1 - b _080B21AE - .pool -_080B21AC: - movs r0, 0 -_080B21AE: - pop {r1} - bx r1 - thumb_func_end sub_80B2188 - - thumb_func_start sub_80B21B4 -sub_80B21B4: @ 80B21B4 - push {r4,r5,lr} - lsls r0, 16 - lsrs r5, r0, 16 - lsls r1, 16 - lsrs r4, r1, 16 - bl sub_80B2188 - cmp r0, 0 - beq _080B21E0 - ldr r0, =gUnknown_085500A4 - adds r1, r5, 0 - adds r2, r4, 0 - bl sub_80B1DFC - cmp r0, 0x1 - bne _080B21E0 - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r1, =0x000009c8 - adds r0, r1 - movs r1, 0 - strh r1, [r0] -_080B21E0: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B21B4 - - thumb_func_start sub_80B21F4 -sub_80B21F4: @ 80B21F4 - push {lr} - adds r3, r0, 0 - adds r2, r1, 0 - lsls r3, 16 - lsrs r3, 16 - lsls r2, 16 - lsrs r2, 16 - ldr r0, =gUnknown_085500A4 - adds r1, r3, 0 - bl sub_80B1EC0 - pop {r1} - bx r1 - .pool - thumb_func_end sub_80B21F4 - - thumb_func_start sub_80B2214 -sub_80B2214: @ 80B2214 - push {lr} - adds r3, r0, 0 - adds r2, r1, 0 - lsls r3, 16 - lsrs r3, 16 - lsls r2, 16 - lsrs r2, 16 - ldr r0, =gUnknown_085500A4 - adds r1, r3, 0 - bl sub_80B1F08 - pop {r1} - bx r1 - .pool - thumb_func_end sub_80B2214 - - thumb_func_start sub_80B2234 -sub_80B2234: @ 80B2234 - push {lr} - adds r1, r0, 0 - lsls r1, 16 - lsrs r1, 16 - ldr r0, =gUnknown_085500A4 - bl sub_80B1FB0 - lsls r0, 16 - lsrs r0, 16 - pop {r1} - bx r1 - .pool - thumb_func_end sub_80B2234 - - thumb_func_start sub_80B2250 -sub_80B2250: @ 80B2250 - push {lr} - adds r1, r0, 0 - lsls r1, 16 - lsrs r1, 16 - ldr r0, =gUnknown_085500A4 - bl sub_80B2004 - lsls r0, 16 - lsrs r0, 16 - pop {r1} - bx r1 - .pool - thumb_func_end sub_80B2250 - - thumb_func_start sub_80B226C -sub_80B226C: @ 80B226C - push {r4,r5,lr} - ldr r5, =gUnknown_085500A4 - ldr r4, =gTrainerBattleOpponent_A - ldrh r1, [r4] - adds r0, r5, 0 - bl sub_80B1F38 - lsls r0, 24 - cmp r0, 0 - bne _080B2298 - ldrh r1, [r4] - adds r0, r5, 0 - bl sub_80B20F4 - lsls r0, 24 - lsrs r0, 24 - b _080B229A - .pool -_080B2298: - movs r0, 0x1 -_080B229A: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80B226C - - thumb_func_start sub_80B22A0 -sub_80B22A0: @ 80B22A0 - push {lr} - ldr r0, =gUnknown_085500A4 - ldr r1, =gTrainerBattleOpponent_A - ldrh r1, [r1] - bl sub_80B1F74 - lsls r0, 24 - lsrs r0, 24 - pop {r1} - bx r1 - .pool - thumb_func_end sub_80B22A0 - - thumb_func_start sub_80B22BC -sub_80B22BC: @ 80B22BC - push {lr} - ldr r0, =gUnknown_085500A4 - ldr r1, =gTrainerBattleOpponent_A - ldrh r1, [r1] - bl sub_80B205C - bl rom_npc_set_flag_for_script_id - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B22BC - - thumb_func_start CheckIfMultipleTrainersWantBattle -CheckIfMultipleTrainersWantBattle: @ 80B22D8 - push {lr} - ldr r1, =gUnknown_02038BF9 - ldrb r0, [r1] - cmp r0, 0x1 - bls _080B2300 - movs r0, 0 - strb r0, [r1] - ldr r1, =gUnknown_02038BF8 - movs r0, 0x1 - strb r0, [r1] - ldr r1, =gSpecialVar_Result - movs r0, 0x1 - b _080B230A - .pool -_080B2300: - ldr r1, =gUnknown_02038BF8 - movs r0, 0 - strb r0, [r1] - ldr r1, =gSpecialVar_Result - movs r0, 0 -_080B230A: - strh r0, [r1] - pop {r0} - bx r0 - .pool - thumb_func_end CheckIfMultipleTrainersWantBattle - - thumb_func_start sub_80B2318 -sub_80B2318: @ 80B2318 - push {r4-r7,lr} - lsls r0, 16 - ldr r7, =gUnknown_085500A4 - lsrs r4, r0, 12 - adds r6, r4, r7 - ldrh r0, [r6] - bl HasTrainerAlreadyBeenFought - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _080B2338 - movs r0, 0 - b _080B2364 - .pool -_080B2338: - movs r5, 0x1 - adds r0, r4, 0x2 - adds r0, r7 - ldrh r0, [r0] - cmp r0, 0 - beq _080B2360 - adds r4, r6, 0x2 -_080B2346: - ldrh r0, [r4] - bl HasTrainerAlreadyBeenFought - lsls r0, 24 - cmp r0, 0 - beq _080B2360 - adds r4, 0x2 - adds r5, 0x1 - cmp r5, 0x4 - bgt _080B2360 - ldrh r0, [r4] - cmp r0, 0 - bne _080B2346 -_080B2360: - lsls r0, r5, 16 - lsrs r0, 16 -_080B2364: - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_80B2318 - - .align 2, 0 @ Don't pad with nop. diff --git a/asm/field_control_avatar.s b/asm/field_control_avatar.s index 27bf46c93..9252b79d2 100644 --- a/asm/field_control_avatar.s +++ b/asm/field_control_avatar.s @@ -721,7 +721,7 @@ TryGetInvisibleMapObjectScript: @ 809C458 ldr r2, [r0, 0x8] cmp r2, 0 bne _0809C490 - ldr r0, =EventScript_2C8436 + ldr r0, =EventScript_TestSignpostMsg b _0809C532 .pool _0809C490: @@ -1365,7 +1365,7 @@ per_step_scripts: @ 809C9F4 bne _0809CA04 b _0809CB24 _0809CA04: - bl sub_80B215C + bl IncrementRematchStepCounter bl AdjustFriendship_step bl sub_81D4998 ldr r0, =gPlayerAvatar diff --git a/asm/macros/event.inc b/asm/macros/event.inc index 69cdb38e5..7f86f8dc8 100644 --- a/asm/macros/event.inc +++ b/asm/macros/event.inc @@ -663,11 +663,11 @@ .byte 0x5d .endm - .macro ontrainerbattleend + .macro gotobattleendscript .byte 0x5e .endm - .macro ontrainerbattleendgoto + .macro gototrainerscript .byte 0x5f .endm diff --git a/asm/map_obj_lock.s b/asm/map_obj_lock.s index caa07638f..f7a33e508 100644 --- a/asm/map_obj_lock.s +++ b/asm/map_obj_lock.s @@ -348,7 +348,7 @@ sub_8098630: @ 8098630 bl sub_80B47E0 lsls r0, 24 lsrs r4, r0, 24 - ldr r0, =gUnknown_030060A8 + ldr r0, =gNoOfApproachingTrainers ldrb r0, [r0] cmp r0, 0x2 bne _080986E0 diff --git a/asm/pokenav.s b/asm/pokenav.s index 532d7599b..8b38def62 100755 --- a/asm/pokenav.s +++ b/asm/pokenav.s @@ -8089,7 +8089,7 @@ _081CB0C0: thumb_func_start sub_81CB0C8 sub_81CB0C8: @ 81CB0C8 push {lr} - ldr r1, =gUnknown_085500A4 + ldr r1, =gRematchTable lsls r0, 4 adds r0, r1 ldrh r2, [r0, 0xA] @@ -20738,7 +20738,7 @@ _081D15B6: thumb_func_start sub_81D15BC sub_81D15BC: @ 81D15BC - ldr r1, =gUnknown_085500A4 + ldr r1, =gRematchTable lsls r0, 4 adds r0, r1 ldrh r0, [r0] @@ -20751,7 +20751,7 @@ sub_81D15CC: @ 81D15CC push {lr} adds r3, r0, 0 movs r1, 0 - ldr r2, =gUnknown_085500A4 + ldr r2, =gRematchTable _081D15D4: ldrh r0, [r2] cmp r0, r3 @@ -21440,7 +21440,7 @@ _081D1A24: cmp r0, 0 bne _081D1A1C adds r0, r7, 0 - bl sub_80B2318 + bl CountBattledRematchTeams lsls r0, 16 lsrs r0, 16 cmp r0, 0x1 @@ -30343,8 +30343,8 @@ _081D6176: .pool thumb_func_end sub_81D6134 - thumb_func_start battle_init -battle_init: @ 81D6180 + thumb_func_start sub_81D6180 +sub_81D6180: @ 81D6180 lsls r0, 24 ldr r1, =gSaveBlock2Ptr ldr r1, [r1] @@ -30355,7 +30355,7 @@ battle_init: @ 81D6180 ldrh r0, [r1] bx lr .pool - thumb_func_end battle_init + thumb_func_end sub_81D6180 thumb_func_start GetTrainerHillTrainerFlag @ u8 GetTrainerHillTrainerFlag(u8 fieldObjectId) diff --git a/asm/rom4.s b/asm/rom4.s index f4e5a4fa3..7e91b8054 100644 --- a/asm/rom4.s +++ b/asm/rom4.s @@ -1381,7 +1381,7 @@ _080850C8: bl prev_quest_postbuffer_cursor_backup_reset adds r0, r6, 0 adds r1, r5, 0 - bl sub_80B21B4 + bl TryUpdateRandomTrainerRematches bl DoTimeBasedEvents bl sub_80AEDBC bl sub_8085B2C @@ -1478,7 +1478,7 @@ _080851A2: asrs r1, 24 lsls r1, 16 lsrs r1, 16 - bl sub_80B21B4 + bl TryUpdateRandomTrainerRematches cmp r7, 0x1 beq _080851EE bl DoTimeBasedEvents diff --git a/asm/script_pokemon_util_80F87D8.s b/asm/script_pokemon_util_80F87D8.s index 3a3cf4269..e093ea149 100644 --- a/asm/script_pokemon_util_80F87D8.s +++ b/asm/script_pokemon_util_80F87D8.s @@ -1359,8 +1359,8 @@ ScriptGiveEgg: @ 80F92C8 bx r1 thumb_func_end ScriptGiveEgg - thumb_func_start sub_80F92F8 -sub_80F92F8: @ 80F92F8 + thumb_func_start HasEnoughMonsForDoubleBattle +HasEnoughMonsForDoubleBattle: @ 80F92F8 push {lr} bl GetMonsStateToDoubles lsls r0, 24 @@ -1382,7 +1382,7 @@ _080F9318: pop {r0} bx r0 .pool - thumb_func_end sub_80F92F8 + thumb_func_end HasEnoughMonsForDoubleBattle thumb_func_start sub_80F9320 sub_80F9320: @ 80F9320 diff --git a/asm/trainer_rematch.s b/asm/trainer_rematch.s index b814934a3..1c874f28f 100755 --- a/asm/trainer_rematch.s +++ b/asm/trainer_rematch.s @@ -178,14 +178,14 @@ sub_81DA6CC: @ 81DA6CC push {r4-r6,lr} adds r5, r0, 0 movs r4, 0 - ldr r6, =gUnknown_085500A4 + ldr r6, =gRematchTable _081DA6D4: lsls r0, r4, 1 lsls r1, r5, 4 adds r0, r1 adds r0, r6 ldrh r0, [r0] - bl HasTrainerAlreadyBeenFought + bl HasTrainerBeenFought lsls r0, 24 cmp r0, 0 bne _081DA6F0 diff --git a/asm/trainer_see.s b/asm/trainer_see.s index 7a3086bfd..16398f9a4 100644 --- a/asm/trainer_see.s +++ b/asm/trainer_see.s @@ -5,133 +5,6 @@ .text - thumb_func_start CheckForTrainersWantingBattle -@ bool8 CheckForTrainersWantingBattle() -CheckForTrainersWantingBattle: @ 80B3BE8 - push {r4-r7,lr} - ldr r0, =gUnknown_030060A8 - movs r1, 0 - strb r1, [r0] - ldr r0, =gApproachingTrainerId - strb r1, [r0] - movs r4, 0 - ldr r6, =gMapObjects -_080B3BF8: - lsls r0, r4, 3 - adds r0, r4 - lsls r0, 2 - adds r1, r0, r6 - ldrb r0, [r1] - lsls r0, 31 - cmp r0, 0 - beq _080B3C38 - ldrb r0, [r1, 0x7] - cmp r0, 0x1 - beq _080B3C12 - cmp r0, 0x3 - bne _080B3C38 -_080B3C12: - adds r0, r4, 0 - bl CheckIfTrainerWantsBattle - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x2 - beq _080B3C42 - cmp r0, 0 - beq _080B3C38 - ldr r0, =gUnknown_030060A8 - ldrb r1, [r0] - adds r5, r0, 0 - cmp r1, 0x1 - bhi _080B3C88 - bl GetMonsStateToDoubles_2 - lsls r0, 24 - cmp r0, 0 - bne _080B3C42 -_080B3C38: - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0xF - bls _080B3BF8 -_080B3C42: - ldr r0, =gUnknown_030060A8 - ldrb r4, [r0] - adds r5, r0, 0 - cmp r4, 0x1 - bne _080B3C88 - bl ResetTrainerOpponentIds - ldr r2, =gUnknown_03006090 - ldrb r0, [r5] - subs r0, 0x1 - lsls r1, r0, 1 - adds r1, r0 - lsls r1, 2 - adds r0, r1, r2 - ldrb r0, [r0] - adds r2, 0x4 - adds r1, r2 - ldr r1, [r1] - bl SingleTrainerWantsBattle - ldr r0, =gUnknown_030060AC - strb r4, [r0] - movs r0, 0x1 - b _080B3CF4 - .pool -_080B3C88: - ldrb r0, [r5] - cmp r0, 0x2 - bne _080B3CEC - bl ResetTrainerOpponentIds - movs r4, 0 - ldrb r5, [r5] - cmp r4, r5 - bcs _080B3CC6 - ldr r6, =gUnknown_03006090 - adds r7, r6, 0x4 - ldr r5, =gApproachingTrainerId -_080B3CA0: - lsls r1, r4, 1 - adds r1, r4 - lsls r1, 2 - adds r0, r1, r6 - ldrb r0, [r0] - adds r1, r7 - ldr r1, [r1] - bl TwoTrainersWantBattle - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - ldrb r0, [r5] - adds r0, 0x1 - strb r0, [r5] - ldr r0, =gUnknown_030060A8 - ldrb r0, [r0] - cmp r4, r0 - bcc _080B3CA0 -_080B3CC6: - bl TwoTrainersWantBattleExecuteScript - ldr r1, =gApproachingTrainerId - movs r0, 0 - strb r0, [r1] - ldr r1, =gUnknown_030060AC - movs r0, 0x1 - strb r0, [r1] - movs r0, 0x1 - b _080B3CF4 - .pool -_080B3CEC: - ldr r1, =gUnknown_030060AC - movs r0, 0 - strb r0, [r1] - movs r0, 0 -_080B3CF4: - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end CheckForTrainersWantingBattle - thumb_func_start CheckIfTrainerWantsBattle @ u8 CheckIfTrainerWantsBattle(u8 trainerFieldObjectId) CheckIfTrainerWantsBattle: @ 80B3D00 @@ -203,8 +76,8 @@ _080B3D7C: movs r1, 0x2 mov r9, r1 _080B3D8A: - ldr r2, =gUnknown_03006090 - ldr r4, =gUnknown_030060A8 + ldr r2, =gApproachingTrainers + ldr r4, =gNoOfApproachingTrainers ldrb r1, [r4] lsls r0, r1, 1 adds r0, r1 @@ -608,8 +481,8 @@ TrainerApproachPlayer: @ 80B406C ldr r0, =c3_8081EDC movs r1, 0x50 bl CreateTask - ldr r4, =gUnknown_03006090 - ldr r3, =gUnknown_030060A8 + ldr r4, =gApproachingTrainers + ldr r3, =gNoOfApproachingTrainers ldrb r2, [r3] lsls r1, r2, 1 adds r1, r2 @@ -649,12 +522,12 @@ sub_80B40C8: @ 80B40C8 ldrb r0, [r0] cmp r0, 0 bne _080B40E4 - ldr r0, =gUnknown_03006090 + ldr r0, =gApproachingTrainers ldrb r5, [r0, 0x8] b _080B40E8 .pool _080B40E4: - ldr r0, =gUnknown_03006090 + ldr r0, =gApproachingTrainers ldrb r5, [r0, 0x14] _080B40E8: ldr r4, =c3_8081EDC @@ -1290,7 +1163,7 @@ sub_80B45BC: @ 80B45BC thumb_func_start sub_80B45D0 sub_80B45D0: @ 80B45D0 push {lr} - ldr r0, =gUnknown_030060A8 + ldr r0, =gNoOfApproachingTrainers ldrb r0, [r0] cmp r0, 0x2 bne _080B4610 @@ -1304,7 +1177,7 @@ sub_80B45D0: @ 80B45D0 movs r0, 0x1 strh r0, [r1] bl UnfreezeMapObjects - ldr r0, =gUnknown_03006090 + ldr r0, =gApproachingTrainers ldrb r0, [r0, 0xC] bl sub_80974D0 b _080B4616 @@ -1535,12 +1408,12 @@ sub_80B47BC: @ 80B47BC ldrb r0, [r0] cmp r0, 0 beq _080B47D4 - ldr r0, =gUnknown_03006090 + ldr r0, =gApproachingTrainers ldrb r0, [r0, 0xC] b _080B47D8 .pool _080B47D4: - ldr r0, =gUnknown_03006090 + ldr r0, =gApproachingTrainers ldrb r0, [r0] _080B47D8: pop {r1} @@ -1560,12 +1433,12 @@ sub_80B47E0: @ 80B47E0 _080B47EE: cmp r0, 0 beq _080B47FC - ldr r0, =gUnknown_03006090 + ldr r0, =gApproachingTrainers ldrb r0, [r0, 0xC] b _080B4800 .pool _080B47FC: - ldr r0, =gUnknown_03006090 + ldr r0, =gApproachingTrainers ldrb r0, [r0] _080B4800: pop {r1} @@ -1580,7 +1453,7 @@ sub_80B4808: @ 80B4808 ldrb r0, [r0] cmp r0, 0x1 bne _080B4870 - ldr r2, =gUnknown_03006090 + ldr r2, =gApproachingTrainers ldr r0, =gUnknown_03006080 ldrh r1, [r0] lsls r0, r1, 1 diff --git a/data/battle_setup.s b/data/battle_setup.s deleted file mode 100644 index dacc3faa4..000000000 --- a/data/battle_setup.s +++ /dev/null @@ -1,176 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2, 0 - - - .align 2 -gUnknown_0854FEAC:: @ 854FEAC - .4byte sTrainerBattleMode, 0x00000000 - .4byte gTrainerBattleOpponent_A, 0x00000001 - .4byte sTrainerMapObjectLocalId, 0x00000001 - .4byte sTrainerAIntroSpeech, 0x00000002 - .4byte sTrainerADefeatSpeech, 0x00000002 - .4byte sTrainerVictorySpeech, 0x00000005 - .4byte sTrainerCannotBattleSpeech, 0x00000005 - .4byte gUnknown_02038BF0, 0x00000005 - .4byte gUnknown_02038BEC, 0x00000006 - - .align 2 -gUnknown_0854FEF4:: @ 854FEF4 - .4byte sTrainerBattleMode, 0x00000000 - .4byte gTrainerBattleOpponent_A, 0x00000001 - .4byte sTrainerMapObjectLocalId, 0x00000001 - .4byte sTrainerAIntroSpeech, 0x00000002 - .4byte sTrainerADefeatSpeech, 0x00000002 - .4byte sTrainerVictorySpeech, 0x00000005 - .4byte sTrainerCannotBattleSpeech, 0x00000005 - .4byte gUnknown_02038BF0, 0x00000002 - .4byte gUnknown_02038BEC, 0x00000006 - - .align 2 -gUnknown_0854FF3C:: @ 854FF3C - .4byte sTrainerBattleMode, 0x00000000 - .4byte gTrainerBattleOpponent_A, 0x00000001 - .4byte sTrainerMapObjectLocalId, 0x00000001 - .4byte sTrainerAIntroSpeech, 0x00000002 - .4byte sTrainerADefeatSpeech, 0x00000002 - .4byte sTrainerVictorySpeech, 0x00000005 - .4byte sTrainerCannotBattleSpeech, 0x00000002 - .4byte gUnknown_02038BF0, 0x00000005 - .4byte gUnknown_02038BEC, 0x00000006 - - .align 2 -gUnknown_0854FF84:: @ 854FF84 - .4byte sTrainerBattleMode, 0x00000000 - .4byte gTrainerBattleOpponent_A, 0x00000001 - .4byte sTrainerMapObjectLocalId, 0x00000001 - .4byte sTrainerAIntroSpeech, 0x00000005 - .4byte sTrainerADefeatSpeech, 0x00000002 - .4byte sTrainerVictorySpeech, 0x00000005 - .4byte sTrainerCannotBattleSpeech, 0x00000005 - .4byte gUnknown_02038BF0, 0x00000005 - .4byte gUnknown_02038BEC, 0x00000006 - - .align 2 -gUnknown_0854FFCC:: @ 854FFCC - .4byte sTrainerBattleMode, 0x00000000 - .4byte gTrainerBattleOpponent_A, 0x00000001 - .4byte sTrainerMapObjectLocalId, 0x00000001 - .4byte sTrainerAIntroSpeech, 0x00000002 - .4byte sTrainerADefeatSpeech, 0x00000002 - .4byte sTrainerVictorySpeech, 0x00000005 - .4byte sTrainerCannotBattleSpeech, 0x00000002 - .4byte gUnknown_02038BF0, 0x00000002 - .4byte gUnknown_02038BEC, 0x00000006 - - .align 2 -gUnknown_08550014:: @ 8550014 - .4byte sTrainerBattleMode, 0x00000000 - .4byte gTrainerBattleOpponent_B, 0x00000001 - .4byte sTrainerMapObjectLocalId, 0x00000001 - .4byte sTrainerBIntroSpeech, 0x00000002 - .4byte sTrainerBDefeatSpeech, 0x00000002 - .4byte sTrainerVictorySpeech, 0x00000005 - .4byte sTrainerCannotBattleSpeech, 0x00000005 - .4byte gUnknown_02038BF4, 0x00000005 - .4byte gUnknown_02038BEC, 0x00000006 - - .align 2 -gUnknown_0855005C:: @ 855005C - .4byte sTrainerBattleMode, 0x00000000 - .4byte gTrainerBattleOpponent_B, 0x00000001 - .4byte sTrainerMapObjectLocalId, 0x00000001 - .4byte sTrainerBIntroSpeech, 0x00000002 - .4byte sTrainerBDefeatSpeech, 0x00000002 - .4byte sTrainerVictorySpeech, 0x00000005 - .4byte sTrainerCannotBattleSpeech, 0x00000005 - .4byte gUnknown_02038BF4, 0x00000002 - .4byte gUnknown_02038BEC, 0x00000006 - - .align 2 -gUnknown_085500A4:: @ 85500A4 - .2byte 0x0025, 0x0028, 0x0029, 0x002a, 0x002b, 0x0000, 0x0021, 0x0000 - .2byte 0x02e1, 0x032c, 0x032d, 0x032e, 0x032f, 0x0000, 0x0014, 0x0000 - .2byte 0x002c, 0x002f, 0x0030, 0x0031, 0x0032, 0x0000, 0x001a, 0x0000 - .2byte 0x0039, 0x003c, 0x003d, 0x003e, 0x003f, 0x0000, 0x0018, 0x0000 - .2byte 0x0040, 0x0043, 0x0044, 0x0045, 0x0046, 0x0000, 0x0018, 0x0000 - .2byte 0x02af, 0x02b0, 0x02b1, 0x02b2, 0x02b3, 0x0000, 0x0027, 0x0000 - .2byte 0x02ff, 0x033c, 0x033d, 0x033e, 0x033f, 0x0000, 0x0024, 0x0000 - .2byte 0x005e, 0x0065, 0x0066, 0x0067, 0x0068, 0x0000, 0x001a, 0x0000 - .2byte 0x004e, 0x0054, 0x0055, 0x0056, 0x0057, 0x0000, 0x001a, 0x0000 - .2byte 0x006c, 0x006e, 0x006f, 0x0070, 0x0071, 0x0018, 0x0014, 0x0000 - .2byte 0x0072, 0x0078, 0x0079, 0x007a, 0x007b, 0x0000, 0x0013, 0x0000 - .2byte 0x0090, 0x034c, 0x034d, 0x034e, 0x034f, 0x0018, 0x0038, 0x0000 - .2byte 0x007f, 0x0084, 0x0085, 0x0086, 0x0087, 0x0000, 0x0024, 0x0000 - .2byte 0x0088, 0x008b, 0x008c, 0x008d, 0x008e, 0x0000, 0x0013, 0x0000 - .2byte 0x008f, 0x0093, 0x0094, 0x0095, 0x0096, 0x0000, 0x001d, 0x0000 - .2byte 0x009b, 0x00af, 0x00b0, 0x00b1, 0x00b2, 0x0000, 0x0016, 0x0000 - .2byte 0x00b7, 0x00b8, 0x00b9, 0x00ba, 0x00bb, 0x0000, 0x001e, 0x0000 - .2byte 0x02a0, 0x0338, 0x0339, 0x033a, 0x033b, 0x0000, 0x002a, 0x0000 - .2byte 0x00c3, 0x0340, 0x0341, 0x0342, 0x0343, 0x0000, 0x0026, 0x0000 - .2byte 0x00c4, 0x00c5, 0x00c6, 0x00c7, 0x00c8, 0x0000, 0x0021, 0x0000 - .2byte 0x00ce, 0x00cf, 0x00d0, 0x00d1, 0x00d2, 0x0000, 0x001d, 0x0000 - .2byte 0x00d8, 0x00db, 0x00dc, 0x00dd, 0x00de, 0x0018, 0x000d, 0x0000 - .2byte 0x02a9, 0x02aa, 0x02ab, 0x02ac, 0x02ad, 0x0018, 0x0001, 0x0000 - .2byte 0x00e2, 0x00e4, 0x00e5, 0x00e6, 0x00e7, 0x0000, 0x0023, 0x0000 - .2byte 0x00ee, 0x00ef, 0x00f0, 0x00f1, 0x00f2, 0x0000, 0x0026, 0x0000 - .2byte 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x0000, 0x0026, 0x0000 - .2byte 0x00fe, 0x0101, 0x0102, 0x0103, 0x0104, 0x0000, 0x0024, 0x0000 - .2byte 0x0118, 0x011a, 0x011b, 0x011c, 0x011d, 0x0000, 0x001f, 0x0000 - .2byte 0x0111, 0x0114, 0x0115, 0x0116, 0x0117, 0x0000, 0x001f, 0x0000 - .2byte 0x011f, 0x0120, 0x0121, 0x0122, 0x0123, 0x0000, 0x0020, 0x0000 - .2byte 0x012e, 0x012f, 0x0130, 0x0131, 0x0132, 0x0000, 0x0019, 0x0000 - .2byte 0x0125, 0x0127, 0x0128, 0x0129, 0x012a, 0x0000, 0x0012, 0x0000 - .2byte 0x0133, 0x0134, 0x0135, 0x0136, 0x0137, 0x0000, 0x001e, 0x0000 - .2byte 0x0139, 0x013a, 0x013b, 0x013c, 0x013d, 0x0018, 0x000c, 0x0000 - .2byte 0x013e, 0x0148, 0x0149, 0x014a, 0x014b, 0x0000, 0x0011, 0x0000 - .2byte 0x0153, 0x015a, 0x015b, 0x015c, 0x015d, 0x0000, 0x0015, 0x0000 - .2byte 0x0178, 0x017b, 0x017c, 0x017d, 0x017e, 0x0000, 0x002b, 0x0000 - .2byte 0x0171, 0x0172, 0x0173, 0x0174, 0x0175, 0x0000, 0x0020, 0x0000 - .2byte 0x0166, 0x0168, 0x0169, 0x016a, 0x016b, 0x0000, 0x0019, 0x0000 - .2byte 0x016c, 0x016d, 0x016e, 0x016f, 0x0170, 0x0000, 0x0020, 0x0000 - .2byte 0x0182, 0x0184, 0x0185, 0x0186, 0x0187, 0x0000, 0x002b, 0x0000 - .2byte 0x0161, 0x0162, 0x0163, 0x0164, 0x0165, 0x0000, 0x0019, 0x0000 - .2byte 0x0179, 0x0334, 0x0335, 0x0336, 0x0337, 0x0000, 0x0029, 0x0000 - .2byte 0x0188, 0x0189, 0x018a, 0x018b, 0x018c, 0x0018, 0x0001, 0x0000 - .2byte 0x0196, 0x0199, 0x019a, 0x019b, 0x019c, 0x0000, 0x0023, 0x0000 - .2byte 0x01a3, 0x01a5, 0x01a6, 0x01a7, 0x01a8, 0x0000, 0x001c, 0x0000 - .2byte 0x01ab, 0x01ae, 0x01af, 0x01b0, 0x01b1, 0x0000, 0x001e, 0x0000 - .2byte 0x01b2, 0x01b5, 0x01b6, 0x01b7, 0x01b8, 0x0000, 0x001c, 0x0000 - .2byte 0x01c1, 0x01d1, 0x01d2, 0x01d3, 0x01d4, 0x0000, 0x0027, 0x0000 - .2byte 0x01da, 0x01dd, 0x01de, 0x01df, 0x01e0, 0x0018, 0x000d, 0x0000 - .2byte 0x01e1, 0x01e2, 0x01e7, 0x01e8, 0x01e9, 0x0000, 0x0012, 0x0000 - .2byte 0x01ec, 0x01f1, 0x01f2, 0x01f3, 0x01f4, 0x0000, 0x0028, 0x0000 - .2byte 0x02e4, 0x0330, 0x0331, 0x0332, 0x0333, 0x0000, 0x0017, 0x0000 - .2byte 0x0200, 0x0203, 0x0204, 0x0205, 0x0206, 0x0000, 0x0019, 0x0000 - .2byte 0x0221, 0x0224, 0x0225, 0x0226, 0x0227, 0x0000, 0x0020, 0x0000 - .2byte 0x021a, 0x021d, 0x021e, 0x021f, 0x0220, 0x0000, 0x0020, 0x0000 - .2byte 0x0009, 0x0348, 0x0349, 0x034a, 0x034b, 0x0018, 0x0011, 0x0000 - .2byte 0x022f, 0x0232, 0x0233, 0x0234, 0x0235, 0x0000, 0x0022, 0x0000 - .2byte 0x0228, 0x022b, 0x022c, 0x022d, 0x022e, 0x0000, 0x0022, 0x0000 - .2byte 0x025c, 0x025f, 0x0260, 0x0261, 0x0262, 0x0000, 0x0013, 0x0000 - .2byte 0x026d, 0x026e, 0x026f, 0x0270, 0x0271, 0x0018, 0x000b, 0x0000 - .2byte 0x0273, 0x027c, 0x027d, 0x027e, 0x027f, 0x0000, 0x001b, 0x0000 - .2byte 0x0001, 0x0344, 0x0345, 0x0346, 0x0347, 0x0018, 0x000c, 0x0000 - .2byte 0x0282, 0x0283, 0x0284, 0x0285, 0x0286, 0x0018, 0x003e, 0x0000 - .2byte 0x0291, 0x0292, 0x0293, 0x0294, 0x0294, 0x0018, 0x002b, 0x0000 - .2byte 0x0109, 0x0302, 0x0303, 0x0304, 0x0305, 0x0000, 0x0003, 0x0000 - .2byte 0x010a, 0x0306, 0x0307, 0x0308, 0x0309, 0x0000, 0x000b, 0x0000 - .2byte 0x010b, 0x030a, 0x030b, 0x030c, 0x030d, 0x0000, 0x0002, 0x0000 - .2byte 0x010c, 0x030e, 0x030f, 0x0310, 0x0311, 0x0000, 0x000c, 0x0000 - .2byte 0x010d, 0x0312, 0x0313, 0x0314, 0x0315, 0x0000, 0x0000, 0x0000 - .2byte 0x010e, 0x0316, 0x0317, 0x0318, 0x0319, 0x0000, 0x0004, 0x0000 - .2byte 0x010f, 0x031a, 0x031b, 0x031c, 0x031d, 0x0000, 0x0006, 0x0000 - .2byte 0x0110, 0x031e, 0x031f, 0x0320, 0x0321, 0x0000, 0x0007, 0x0000 - .2byte 0x0105, 0x0105, 0x0105, 0x0105, 0x0105, 0x0000, 0x0008, 0x0000 - .2byte 0x0106, 0x0106, 0x0106, 0x0106, 0x0106, 0x0000, 0x0008, 0x0000 - .2byte 0x0107, 0x0107, 0x0107, 0x0107, 0x0107, 0x0000, 0x0008, 0x0000 - .2byte 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0000, 0x0008, 0x0000 - .2byte 0x014f, 0x014f, 0x014f, 0x014f, 0x014f, 0x0000, 0x0008, 0x0000 - - .align 2 -gUnknown_08550584:: @ 8550584 - .2byte 0x0867, 0x0868, 0x0869, 0x086a, 0x086b, 0x086c, 0x086d, 0x086e - diff --git a/data/event_scripts.s b/data/event_scripts.s index 763b39585..2c619e4bd 100644 --- a/data/event_scripts.s +++ b/data/event_scripts.s @@ -842,101 +842,101 @@ EventScript_271356:: @ 8271356 special SetUpTrainerEncounterMusic special sub_80B45AC waitstate - goto EventScript_27143C + goto EventScript_ShowTrainerIntroMsg EventScript_271362:: @ 8271362 lock faceplayer - applymovement 0x800F, Movement_27143A + applymovement VAR_LAST_TALKED, Movement_27143A waitmovement 0 - specialvar VAR_RESULT, check_trainer_flag + specialvar VAR_RESULT, GetTrainerFlag compare_var_to_value VAR_RESULT, 0 goto_if 5, EventScript_271389 special SetUpTrainerEncounterMusic special sub_80B16D8 - goto EventScript_27143C + goto EventScript_ShowTrainerIntroMsg EventScript_271389:: @ 8271389 - ontrainerbattleend + gotobattleendscript -EventScript_27138A:: @ 827138A +EventScript_TryDoDoubleTrainerBattle:: @ 827138A lock faceplayer call EventScript_27142F - specialvar VAR_RESULT, check_trainer_flag + specialvar VAR_RESULT, GetTrainerFlag compare_var_to_value VAR_RESULT, 0 goto_if 5, EventScript_2713C1 - special sub_80F92F8 + special HasEnoughMonsForDoubleBattle compare_var_to_value VAR_RESULT, 0 - goto_if 5, EventScript_2713BA + goto_if 5, EventScript_NotEnoughMonsForDoubleBattle special SetUpTrainerEncounterMusic special sub_80B16D8 - goto EventScript_27143C + goto EventScript_ShowTrainerIntroMsg -EventScript_2713BA:: @ 82713BA - special special_trainer_unable_to_battle +EventScript_NotEnoughMonsForDoubleBattle:: @ 82713BA + special ShowTrainerCantBattleSpeech waitmessage waitbuttonpress release end EventScript_2713C1:: @ 82713C1 - ontrainerbattleend + gotobattleendscript EventScript_2713C2:: @ 82713C2 - applymovement 0x800F, Movement_27143A + applymovement VAR_LAST_TALKED, Movement_27143A waitmovement 0 special SetUpTrainerEncounterMusic trainerbattlebegin - ontrainerbattleend + gotobattleendscript EventScript_2713D1:: @ 82713D1 call EventScript_27142F - specialvar VAR_RESULT, sub_80B22A0 + specialvar VAR_RESULT, IsTrainerReadyForRematch compare_var_to_value VAR_RESULT, 0 goto_eq EventScript_2713F7 special SetUpTrainerEncounterMusic special sub_80B16D8 - special sub_80B1A14 + special ShowTrainerIntroSpeech waitmessage waitbuttonpress - special sub_80B19EC + special BattleSetup_StartRematchBattle waitstate releaseall end EventScript_2713F7:: @ 82713F7 - ontrainerbattleend + gotobattleendscript -EventScript_2713F8:: @ 82713F8 - specialvar VAR_RESULT, sub_80B22A0 +EventScript_TryDoDoubleRematchBattle:: @ 82713F8 + specialvar VAR_RESULT, IsTrainerReadyForRematch compare_var_to_value VAR_RESULT, 0 goto_eq EventScript_271427 - special sub_80F92F8 + special HasEnoughMonsForDoubleBattle compare_var_to_value VAR_RESULT, 0 - goto_if 5, EventScript_271428 + goto_if 5, EventScript_NotEnoughMonsForDoubleRematchBattle special SetUpTrainerEncounterMusic special sub_80B16D8 - special sub_80B1A14 + special ShowTrainerIntroSpeech waitmessage waitbuttonpress - special sub_80B19EC + special BattleSetup_StartRematchBattle waitstate releaseall end EventScript_271427:: @ 8271427 - ontrainerbattleend + gotobattleendscript -EventScript_271428:: @ 8271428 - special special_trainer_unable_to_battle +EventScript_NotEnoughMonsForDoubleRematchBattle:: @ 8271428 + special ShowTrainerCantBattleSpeech waitmessage waitbuttonpress release end EventScript_27142F:: @ 827142F - applymovement 0x800F, Movement_27143A + applymovement VAR_LAST_TALKED, Movement_27143A waitmovement 0 return @@ -944,18 +944,18 @@ Movement_27143A: @ 827143A step_59 step_end -EventScript_27143C:: @ 827143C - special sub_80B1A14 +EventScript_ShowTrainerIntroMsg:: @ 827143C + special ShowTrainerIntroSpeech waitmessage waitbuttonpress special sub_80B45D0 compare_var_to_value VAR_RESULT, 1 goto_eq EventScript_271356 - goto EventScript_271454 + goto EventScript_DoTrainerBattle -EventScript_271454:: @ 8271454 +EventScript_DoTrainerBattle:: @ 8271454 trainerbattlebegin - specialvar VAR_RESULT, sub_80B170C + specialvar VAR_RESULT, GetTrainerBattleMode compare_var_to_value VAR_RESULT, 0 goto_eq EventScript_271491 compare_var_to_value VAR_RESULT, 2 @@ -968,7 +968,7 @@ EventScript_271454:: @ 8271454 goto_eq EventScript_271491 EventScript_271491:: @ 8271491 - ontrainerbattleendgoto + gototrainerscript releaseall end @@ -4082,15 +4082,15 @@ Std_8:: @ 82742C9 delay 30 return -LavaridgeTown_Gym_1F_EventScript_2742E6:: @ 82742E6 - special CheckIfMultipleTrainersWantBattle +EventScript_TryGetTrainerScript:: @ 82742E6 + special ShouldTryGetTrainerScript compare_var_to_value VAR_RESULT, 1 - goto_eq LavaridgeTown_Gym_1F_EventScript_2742F6 + goto_eq EventScript_GotoTrainerScript releaseall end -LavaridgeTown_Gym_1F_EventScript_2742F6:: @ 82742F6 - ontrainerbattleendgoto +EventScript_GotoTrainerScript:: @ 82742F6 + gototrainerscript releaseall end @@ -13969,12 +13969,12 @@ EventScript_2C83F0:: @ 82C83F0 closemessage end -Text_2C840A:: @ 82C840A +Text_ThisIsATestSignpostMsg:: @ 82C840A .string "This is a test message.\n" .string "This is a signpost.$" -EventScript_2C8436:: @ 82C8436 - msgbox Text_2C840A, 3 +EventScript_TestSignpostMsg:: @ 82C8436 + msgbox Text_ThisIsATestSignpostMsg, 3 end .string "It’s very disappointing…$" diff --git a/data/script_cmd_table.inc b/data/script_cmd_table.inc index b33db9218..a50cb6afe 100644 --- a/data/script_cmd_table.inc +++ b/data/script_cmd_table.inc @@ -94,8 +94,8 @@ gScriptCmdTable:: @ 81DB67C .4byte ScrCmd_turnobject .4byte ScrCmd_trainerbattle .4byte ScrCmd_dotrainerbattle - .4byte ScrCmd_ontrainerbattleend - .4byte ScrCmd_ontrainerbattleendgoto + .4byte ScrCmd_gotobattleendscript + .4byte ScrCmd_gototrainerscript .4byte ScrCmd_checktrainerflag .4byte ScrCmd_settrainerflag .4byte ScrCmd_cleartrainerflag diff --git a/data/scripts/cable_club.inc b/data/scripts/cable_club.inc index 71e3303b5..bfea16d8f 100644 --- a/data/scripts/cable_club.inc +++ b/data/scripts/cable_club.inc @@ -409,7 +409,7 @@ OldaleTown_PokemonCenter_2F_EventScript_276F23:: @ 8276F23 end OldaleTown_PokemonCenter_2F_EventScript_276F2E:: @ 8276F2E - special sub_80F92F8 + special HasEnoughMonsForDoubleBattle compare_var_to_value VAR_RESULT, 0 goto_if 5, OldaleTown_PokemonCenter_2F_EventScript_276F47 setvar VAR_0x8004, 2 @@ -1194,7 +1194,7 @@ OldaleTown_PokemonCenter_2F_EventScript_27788E:: @ 827788E end OldaleTown_PokemonCenter_2F_EventScript_277899:: @ 8277899 - special sub_80F92F8 + special HasEnoughMonsForDoubleBattle compare_var_to_value VAR_RESULT, 0 goto_if 5, OldaleTown_PokemonCenter_2F_EventScript_2778B2 setvar VAR_0x8004, 1 diff --git a/data/scripts/maps/AbandonedShip_Rooms2_1F.inc b/data/scripts/maps/AbandonedShip_Rooms2_1F.inc index 7d86c6f3f..0b687aaeb 100644 --- a/data/scripts/maps/AbandonedShip_Rooms2_1F.inc +++ b/data/scripts/maps/AbandonedShip_Rooms2_1F.inc @@ -3,7 +3,7 @@ AbandonedShip_Rooms2_1F_MapScripts:: @ 82380A6 AbandonedShip_Rooms2_1F_EventScript_2380A7:: @ 82380A7 trainerbattle 6, TRAINER_KIRA_AND_DAN_1, 0, AbandonedShip_Rooms2_1F_Text_23819D, AbandonedShip_Rooms2_1F_Text_2381DA, AbandonedShip_Rooms2_1F_Text_238257, AbandonedShip_Rooms2_1F_EventScript_2380D7 - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq AbandonedShip_Rooms2_1F_EventScript_2380F0 msgbox AbandonedShip_Rooms2_1F_Text_23820F, 4 @@ -26,7 +26,7 @@ AbandonedShip_Rooms2_1F_EventScript_2380F0:: @ 82380F0 AbandonedShip_Rooms2_1F_EventScript_23810B:: @ 823810B trainerbattle 6, TRAINER_KIRA_AND_DAN_1, 0, AbandonedShip_Rooms2_1F_Text_2382A4, AbandonedShip_Rooms2_1F_Text_2382F4, AbandonedShip_Rooms2_1F_Text_23836F, AbandonedShip_Rooms2_1F_EventScript_23813B - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq AbandonedShip_Rooms2_1F_EventScript_238154 msgbox AbandonedShip_Rooms2_1F_Text_23830A, 4 diff --git a/data/scripts/maps/AbandonedShip_Rooms_1F.inc b/data/scripts/maps/AbandonedShip_Rooms_1F.inc index 025b497dd..beaea9b34 100644 --- a/data/scripts/maps/AbandonedShip_Rooms_1F.inc +++ b/data/scripts/maps/AbandonedShip_Rooms_1F.inc @@ -12,7 +12,7 @@ AbandonedShip_Rooms_1F_EventScript_237A9C:: @ 8237A9C AbandonedShip_Rooms_1F_EventScript_237AB3:: @ 8237AB3 trainerbattle 2, TRAINER_THALIA_1, 0, AbandonedShip_Rooms_1F_Text_237B76, AbandonedShip_Rooms_1F_Text_237BB8, AbandonedShip_Rooms_1F_EventScript_237ADF - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq AbandonedShip_Rooms_1F_EventScript_237AFE msgbox AbandonedShip_Rooms_1F_Text_237BDB, 4 diff --git a/data/scripts/maps/DewfordTown_Gym.inc b/data/scripts/maps/DewfordTown_Gym.inc index a3f996f25..5e9b5fa7d 100644 --- a/data/scripts/maps/DewfordTown_Gym.inc +++ b/data/scripts/maps/DewfordTown_Gym.inc @@ -157,7 +157,7 @@ DewfordTown_Gym_EventScript_1FC7C1:: @ 81FC7C1 DewfordTown_Gym_EventScript_1FC7C2:: @ 81FC7C2 trainerbattle 1, TRAINER_BRAWLY_1, 0, DewfordTown_Gym_Text_1FCF44, DewfordTown_Gym_Text_1FD008, DewfordTown_Gym_EventScript_1FC7F7 - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq DewfordTown_Gym_EventScript_1FC89C checkflag FLAG_0x0A6 diff --git a/data/scripts/maps/FortreeCity_Gym.inc b/data/scripts/maps/FortreeCity_Gym.inc index e3990cd23..67d5a21eb 100644 --- a/data/scripts/maps/FortreeCity_Gym.inc +++ b/data/scripts/maps/FortreeCity_Gym.inc @@ -17,7 +17,7 @@ FortreeCity_Gym_EventScript_2165C4:: @ 82165C4 FortreeCity_Gym_EventScript_2165C8:: @ 82165C8 trainerbattle 1, TRAINER_WINONA_1, 0, FortreeCity_Gym_Text_216D75, FortreeCity_Gym_Text_216E60, FortreeCity_Gym_EventScript_2165FD - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq FortreeCity_Gym_EventScript_21668D checkflag FLAG_0x0AA diff --git a/data/scripts/maps/JaggedPass.inc b/data/scripts/maps/JaggedPass.inc index 1fb3b316e..4cc415b30 100644 --- a/data/scripts/maps/JaggedPass.inc +++ b/data/scripts/maps/JaggedPass.inc @@ -104,7 +104,7 @@ JaggedPass_EventScript_230785:: @ 8230785 JaggedPass_EventScript_23079C:: @ 823079C trainerbattle 2, TRAINER_DIANA_1, 0, JaggedPass_Text_230974, JaggedPass_Text_2309B5, JaggedPass_EventScript_2307C8 - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq JaggedPass_EventScript_2307E4 msgbox JaggedPass_Text_2309D8, 4 @@ -128,7 +128,7 @@ JaggedPass_EventScript_2307E4:: @ 82307E4 JaggedPass_EventScript_2307FB:: @ 82307FB trainerbattle 2, TRAINER_ETHAN_1, 0, JaggedPass_Text_230B10, JaggedPass_Text_230B50, JaggedPass_EventScript_230827 - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq JaggedPass_EventScript_230843 msgbox JaggedPass_Text_230B93, 4 diff --git a/data/scripts/maps/LavaridgeTown_Gym_1F.inc b/data/scripts/maps/LavaridgeTown_Gym_1F.inc index 55ae851e0..581f4ca1d 100644 --- a/data/scripts/maps/LavaridgeTown_Gym_1F.inc +++ b/data/scripts/maps/LavaridgeTown_Gym_1F.inc @@ -60,7 +60,7 @@ LavaridgeTown_Gym_1F_EventScript_1FE78B:: @ 81FE78B LavaridgeTown_Gym_1F_EventScript_1FE78C:: @ 81FE78C trainerbattle 1, TRAINER_FLANNERY_1, 0, LavaridgeTown_Gym_1F_Text_1FF0DC, LavaridgeTown_Gym_1F_Text_1FF233, LavaridgeTown_Gym_1F_EventScript_1FE7C1 - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq LavaridgeTown_Gym_1F_EventScript_1FE864 checkflag FLAG_0x0A8 @@ -127,9 +127,9 @@ LavaridgeTown_Gym_1F_EventScript_1FE89A:: @ 81FE89A LavaridgeTown_Gym_B1F_EventScript_1FE89A:: @ 81FE89A call LavaridgeTown_Gym_1F_EventScript_1FE705 release - special CheckIfMultipleTrainersWantBattle + special ShouldTryGetTrainerScript compare_var_to_value VAR_RESULT, 1 - goto_eq LavaridgeTown_Gym_1F_EventScript_2742F6 + goto_eq EventScript_GotoTrainerScript end LavaridgeTown_Gym_1F_EventScript_1FE8AF:: @ 81FE8AF diff --git a/data/scripts/maps/MauvilleCity_Gym.inc b/data/scripts/maps/MauvilleCity_Gym.inc index 899550337..dd2d502db 100644 --- a/data/scripts/maps/MauvilleCity_Gym.inc +++ b/data/scripts/maps/MauvilleCity_Gym.inc @@ -77,7 +77,7 @@ MauvilleCity_Gym_EventScript_20DEE7:: @ 820DEE7 MauvilleCity_Gym_EventScript_20DEEB:: @ 820DEEB trainerbattle 1, TRAINER_WATTSON_1, 0, MauvilleCity_Gym_Text_20E602, MauvilleCity_Gym_Text_20E734, MauvilleCity_Gym_EventScript_20DF2B - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq MauvilleCity_Gym_EventScript_20DFDE checkflag FLAG_0x0A7 diff --git a/data/scripts/maps/MeteorFalls_1F_2R.inc b/data/scripts/maps/MeteorFalls_1F_2R.inc index 8cf171209..12e84c761 100644 --- a/data/scripts/maps/MeteorFalls_1F_2R.inc +++ b/data/scripts/maps/MeteorFalls_1F_2R.inc @@ -3,7 +3,7 @@ MeteorFalls_1F_2R_MapScripts:: @ 822C4DD MeteorFalls_1F_2R_EventScript_22C4DE:: @ 822C4DE trainerbattle 2, TRAINER_NICOLAS_1, 0, MeteorFalls_1F_2R_Text_22C608, MeteorFalls_1F_2R_Text_22C678, MeteorFalls_1F_2R_EventScript_22C50A - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq MeteorFalls_1F_2R_EventScript_22C529 msgbox MeteorFalls_1F_2R_Text_22C6A3, 4 @@ -28,7 +28,7 @@ MeteorFalls_1F_2R_EventScript_22C529:: @ 822C529 MeteorFalls_1F_2R_EventScript_22C540:: @ 822C540 trainerbattle 6, TRAINER_JOHN_AND_JAY_1, 0, MeteorFalls_1F_2R_Text_22C843, MeteorFalls_1F_2R_Text_22C89C, MeteorFalls_1F_2R_Text_22C92B, MeteorFalls_1F_2R_EventScript_22C570 - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq MeteorFalls_1F_2R_EventScript_22C589 msgbox MeteorFalls_1F_2R_Text_22C8C1, 4 @@ -51,7 +51,7 @@ MeteorFalls_1F_2R_EventScript_22C589:: @ 822C589 MeteorFalls_1F_2R_EventScript_22C5A4:: @ 822C5A4 trainerbattle 6, TRAINER_JOHN_AND_JAY_1, 0, MeteorFalls_1F_2R_Text_22C9E6, MeteorFalls_1F_2R_Text_22CA44, MeteorFalls_1F_2R_Text_22CACD, MeteorFalls_1F_2R_EventScript_22C5D4 - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq MeteorFalls_1F_2R_EventScript_22C5ED msgbox MeteorFalls_1F_2R_Text_22CA70, 4 diff --git a/data/scripts/maps/MossdeepCity_Gym.inc b/data/scripts/maps/MossdeepCity_Gym.inc index 89c243767..dfcb14721 100644 --- a/data/scripts/maps/MossdeepCity_Gym.inc +++ b/data/scripts/maps/MossdeepCity_Gym.inc @@ -50,7 +50,7 @@ MossdeepCity_Gym_EventScript_220885:: @ 8220885 MossdeepCity_Gym_EventScript_220898:: @ 8220898 trainerbattle 8, TRAINER_TATE_AND_LIZA_1, 0, MossdeepCity_Gym_Text_221783, MossdeepCity_Gym_Text_2218EC, MossdeepCity_Gym_Text_221BCE, MossdeepCity_Gym_EventScript_2208D1 - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq MossdeepCity_Gym_EventScript_22097E checkflag FLAG_0x0AB diff --git a/data/scripts/maps/MtChimney.inc b/data/scripts/maps/MtChimney.inc index d7a2ed83a..b93fbd3ec 100644 --- a/data/scripts/maps/MtChimney.inc +++ b/data/scripts/maps/MtChimney.inc @@ -488,7 +488,7 @@ MtChimney_EventScript_22F141:: @ 822F141 MtChimney_EventScript_22F14A:: @ 822F14A trainerbattle 2, TRAINER_SHELBY_1, 0, MtChimney_Text_23001D, MtChimney_Text_230076, MtChimney_EventScript_22F176 - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq MtChimney_EventScript_22F195 msgbox MtChimney_Text_2300A2, 4 @@ -533,7 +533,7 @@ MtChimney_EventScript_22F1F1:: @ 822F1F1 MtChimney_EventScript_22F208:: @ 822F208 trainerbattle 2, TRAINER_SAWYER_1, 0, MtChimney_Text_2304B3, MtChimney_Text_2304F7, MtChimney_EventScript_22F234 - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq MtChimney_EventScript_22F253 msgbox MtChimney_Text_230519, 4 diff --git a/data/scripts/maps/MtPyre_3F.inc b/data/scripts/maps/MtPyre_3F.inc index ad99e6c9a..7c95a8d84 100644 --- a/data/scripts/maps/MtPyre_3F.inc +++ b/data/scripts/maps/MtPyre_3F.inc @@ -13,7 +13,7 @@ MtPyre_3F_EventScript_23176A:: @ 823176A MtPyre_3F_EventScript_231781:: @ 8231781 trainerbattle 2, TRAINER_GABRIELLE_1, 0, MtPyre_3F_Text_231952, MtPyre_3F_Text_23196A, MtPyre_3F_EventScript_2317AD - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq MtPyre_3F_EventScript_2317CC msgbox MtPyre_3F_Text_23199B, 4 diff --git a/data/scripts/maps/MtPyre_6F.inc b/data/scripts/maps/MtPyre_6F.inc index 36a727daa..6c61221d5 100644 --- a/data/scripts/maps/MtPyre_6F.inc +++ b/data/scripts/maps/MtPyre_6F.inc @@ -3,7 +3,7 @@ MtPyre_6F_MapScripts:: @ 8231D3A MtPyre_6F_EventScript_231D3B:: @ 8231D3B trainerbattle 2, TRAINER_VALERIE_1, 0, MtPyre_6F_Text_231DB4, MtPyre_6F_Text_231DE2, MtPyre_6F_EventScript_231D67 - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq MtPyre_6F_EventScript_231D86 msgbox MtPyre_6F_Text_231DFC, 4 diff --git a/data/scripts/maps/PetalburgCity_Gym.inc b/data/scripts/maps/PetalburgCity_Gym.inc index e6cdd1334..3c119a227 100644 --- a/data/scripts/maps/PetalburgCity_Gym.inc +++ b/data/scripts/maps/PetalburgCity_Gym.inc @@ -62,7 +62,7 @@ PetalburgCity_Gym_EventScript_204955:: @ 8204955 PetalburgCity_Gym_EventScript_20495D:: @ 820495D setorcopyvar 0x8015, 269 - specialvar VAR_RESULT, sub_80B22A0 + specialvar VAR_RESULT, IsTrainerReadyForRematch compare_var_to_value VAR_RESULT, 1 goto_eq PetalburgCity_Gym_EventScript_204985 compare_var_to_value VAR_0x4085, 8 diff --git a/data/scripts/maps/PetalburgWoods.inc b/data/scripts/maps/PetalburgWoods.inc index a6b018134..d79d4a414 100644 --- a/data/scripts/maps/PetalburgWoods.inc +++ b/data/scripts/maps/PetalburgWoods.inc @@ -279,7 +279,7 @@ PetalburgWoods_EventScript_22E26D:: @ 822E26D PetalburgWoods_EventScript_22E284:: @ 822E284 trainerbattle 2, TRAINER_JAMES_1, 0, PetalburgWoods_Text_22E827, PetalburgWoods_Text_22E86B, PetalburgWoods_EventScript_22E2C5 - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq PetalburgWoods_EventScript_22E31B setvar VAR_0x8004, 621 diff --git a/data/scripts/maps/Route102.inc b/data/scripts/maps/Route102.inc index 00c8c309f..1f1e7c2d8 100644 --- a/data/scripts/maps/Route102.inc +++ b/data/scripts/maps/Route102.inc @@ -19,7 +19,7 @@ Route102_EventScript_1EC0FC:: @ 81EC0FC Route102_EventScript_1EC105:: @ 81EC105 trainerbattle 2, TRAINER_CALVIN_1, 0, Route102_Text_294513, Route102_Text_29457C, Route102_EventScript_1EC146 - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route102_EventScript_1EC19C setvar VAR_0x8004, 318 diff --git a/data/scripts/maps/Route103.inc b/data/scripts/maps/Route103.inc index 4dd68204a..dcfa8cde3 100644 --- a/data/scripts/maps/Route103.inc +++ b/data/scripts/maps/Route103.inc @@ -209,7 +209,7 @@ Route103_EventScript_1EC5F4:: @ 81EC5F4 Route103_EventScript_1EC60B:: @ 81EC60B trainerbattle 6, TRAINER_AMY_AND_LIV_1, 0, Route103_Text_2949F9, Route103_Text_294A3D, Route103_Text_294AAE, Route103_EventScript_1EC63A - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route103_EventScript_1EC653 msgbox Route103_Text_294A52, 6 @@ -231,7 +231,7 @@ Route103_EventScript_1EC653:: @ 81EC653 Route103_EventScript_1EC66E:: @ 81EC66E trainerbattle 6, TRAINER_AMY_AND_LIV_1, 0, Route103_Text_294AFD, Route103_Text_294B22, Route103_Text_294BD0, Route103_EventScript_1EC69D - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route103_EventScript_1EC6B6 msgbox Route103_Text_294B40, 6 @@ -258,7 +258,7 @@ Route103_EventScript_1EC6D1:: @ 81EC6D1 Route103_EventScript_1EC6E8:: @ 81EC6E8 trainerbattle 2, TRAINER_MIGUEL_1, 0, Route103_Text_294EDF, Route103_Text_294F21, Route103_EventScript_1EC714 - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route103_EventScript_1EC733 msgbox Route103_Text_294F42, 4 diff --git a/data/scripts/maps/Route104.inc b/data/scripts/maps/Route104.inc index 8c4138f11..9dc400109 100644 --- a/data/scripts/maps/Route104.inc +++ b/data/scripts/maps/Route104.inc @@ -882,7 +882,7 @@ Route104_EventScript_1ED376:: @ 81ED376 Route104_EventScript_1ED38D:: @ 81ED38D trainerbattle 2, TRAINER_HALEY_1, 0, Route104_Text_29563A, Route104_Text_29566F, Route104_EventScript_1ED3CE - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route104_EventScript_1ED424 setvar VAR_0x8004, 604 @@ -933,7 +933,7 @@ Route104_EventScript_1ED424:: @ 81ED424 Route104_EventScript_1ED43B:: @ 81ED43B trainerbattle 2, TRAINER_WINSTON_1, 0, Route104_Text_295870, Route104_Text_2958AD, Route104_EventScript_1ED47C - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route104_EventScript_1ED4D2 setvar VAR_0x8004, 136 @@ -984,7 +984,7 @@ Route104_EventScript_1ED4D2:: @ 81ED4D2 Route104_EventScript_1ED4E9:: @ 81ED4E9 trainerbattle 2, TRAINER_CINDY_1, 0, Route104_Text_295A7E, Route104_Text_295ABB, Route104_EventScript_1ED52A - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route104_EventScript_1ED580 setvar VAR_0x8004, 114 diff --git a/data/scripts/maps/Route105.inc b/data/scripts/maps/Route105.inc index 72b35e7b0..b527fc7a8 100644 --- a/data/scripts/maps/Route105.inc +++ b/data/scripts/maps/Route105.inc @@ -63,7 +63,7 @@ Route105_EventScript_1EE2BD:: @ 81EE2BD Route105_EventScript_1EE2D4:: @ 81EE2D4 trainerbattle 2, TRAINER_ANDRES_1, 0, Route105_Text_2960A9, Route105_Text_2960DB, Route105_EventScript_1EE300 - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route105_EventScript_1EE31F msgbox Route105_Text_2960FA, 4 diff --git a/data/scripts/maps/Route106.inc b/data/scripts/maps/Route106.inc index 3bb5e27e7..8b0df4336 100644 --- a/data/scripts/maps/Route106.inc +++ b/data/scripts/maps/Route106.inc @@ -17,7 +17,7 @@ Route106_EventScript_1EE4AA:: @ 81EE4AA Route106_EventScript_1EE4C1:: @ 81EE4C1 trainerbattle 2, TRAINER_ELLIOT_1, 0, Route106_Text_296327, Route106_Text_29635C, Route106_EventScript_1EE4ED - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route106_EventScript_1EE50C msgbox Route106_Text_29638C, 4 diff --git a/data/scripts/maps/Route107.inc b/data/scripts/maps/Route107.inc index 736eaa8ee..0f144a6bb 100644 --- a/data/scripts/maps/Route107.inc +++ b/data/scripts/maps/Route107.inc @@ -8,7 +8,7 @@ Route107_EventScript_1EE595:: @ 81EE595 Route107_EventScript_1EE5AC:: @ 81EE5AC trainerbattle 2, TRAINER_TONY_1, 0, Route107_Text_2967AD, Route107_Text_2967D8, Route107_EventScript_1EE5D8 - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route107_EventScript_1EE5F7 msgbox Route107_Text_2967FF, 4 diff --git a/data/scripts/maps/Route108.inc b/data/scripts/maps/Route108.inc index d88f63ca1..5c416d7dd 100644 --- a/data/scripts/maps/Route108.inc +++ b/data/scripts/maps/Route108.inc @@ -28,7 +28,7 @@ Route108_EventScript_1EE6E6:: @ 81EE6E6 Route108_EventScript_1EE6FD:: @ 81EE6FD trainerbattle 2, TRAINER_CORY_1, 0, Route108_Text_296F5D, Route108_Text_296F93, Route108_EventScript_1EE729 - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route108_EventScript_1EE748 msgbox Route108_Text_296FB0, 4 diff --git a/data/scripts/maps/Route109.inc b/data/scripts/maps/Route109.inc index 4cdd835ff..da36de73c 100644 --- a/data/scripts/maps/Route109.inc +++ b/data/scripts/maps/Route109.inc @@ -397,7 +397,7 @@ Route109_EventScript_1EEA82:: @ 81EEA82 Route109_EventScript_1EEA99:: @ 81EEA99 trainerbattle 2, TRAINER_RICKY_1, 0, Route109_Text_29733B, Route109_Text_297379, Route109_EventScript_1EEAC5 - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route109_EventScript_1EEAE4 msgbox Route109_Text_297380, 4 @@ -422,7 +422,7 @@ Route109_EventScript_1EEAE4:: @ 81EEAE4 Route109_EventScript_1EEAFB:: @ 81EEAFB trainerbattle 2, TRAINER_LOLA_1, 0, Route109_Text_29749C, Route109_Text_2974CF, Route109_EventScript_1EEB27 - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route109_EventScript_1EEB46 msgbox Route109_Text_2974D6, 4 diff --git a/data/scripts/maps/Route110.inc b/data/scripts/maps/Route110.inc index 0fa78b385..f07ca623e 100644 --- a/data/scripts/maps/Route110.inc +++ b/data/scripts/maps/Route110.inc @@ -176,7 +176,7 @@ Route110_EventScript_1EF409:: @ 81EF409 Route110_EventScript_1EF420:: @ 81EF420 trainerbattle 2, TRAINER_EDWIN_1, 0, Route110_Text_29815E, Route110_Text_29818F, Route110_EventScript_1EF44C - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route110_EventScript_1EF46B msgbox Route110_Text_2981B3, 4 @@ -216,7 +216,7 @@ Route110_EventScript_1EF4B0:: @ 81EF4B0 Route110_EventScript_1EF4C7:: @ 81EF4C7 trainerbattle 2, TRAINER_BENJAMIN_1, 0, Route110_Text_297C63, Route110_Text_297C8A, Route110_EventScript_1EF4F3 - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route110_EventScript_1EF512 msgbox Route110_Text_297CB4, 4 @@ -246,7 +246,7 @@ Route110_EventScript_1EF529:: @ 81EF529 Route110_EventScript_1EF540:: @ 81EF540 trainerbattle 2, TRAINER_ABIGAIL_1, 0, Route110_Text_297DFA, Route110_Text_297E69, Route110_EventScript_1EF56C - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route110_EventScript_1EF58B msgbox Route110_Text_297E88, 4 @@ -271,7 +271,7 @@ Route110_EventScript_1EF58B:: @ 81EF58B Route110_EventScript_1EF5A2:: @ 81EF5A2 trainerbattle 2, TRAINER_ISABEL_1, 0, Route110_Text_298349, Route110_Text_298389, Route110_EventScript_1EF5CE - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route110_EventScript_1EF5ED msgbox Route110_Text_2983A2, 4 diff --git a/data/scripts/maps/Route111.inc b/data/scripts/maps/Route111.inc index c51b07b6c..18dc4c389 100644 --- a/data/scripts/maps/Route111.inc +++ b/data/scripts/maps/Route111.inc @@ -473,7 +473,7 @@ Route111_EventScript_1F1249:: @ 81F1249 Route111_EventScript_1F1260:: @ 81F1260 trainerbattle 2, TRAINER_DUSTY_1, 0, Route111_Text_298B08, Route111_Text_298B53, Route111_EventScript_1F128C - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route111_EventScript_1F12AB msgbox Route111_Text_298B9A, 4 @@ -513,7 +513,7 @@ Route111_EventScript_1F12F0:: @ 81F12F0 Route111_EventScript_1F1307:: @ 81F1307 trainerbattle 2, TRAINER_WILTON_1, 0, Route111_Text_298F79, Route111_Text_298FA9, Route111_EventScript_1F1333 - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route111_EventScript_1F1352 msgbox Route111_Text_298FD4, 4 @@ -538,7 +538,7 @@ Route111_EventScript_1F1352:: @ 81F1352 Route111_EventScript_1F1369:: @ 81F1369 trainerbattle 2, TRAINER_BROOKE_1, 0, Route111_Text_299143, Route111_Text_299193, Route111_EventScript_1F1395 - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route111_EventScript_1F13B4 msgbox Route111_Text_2991C2, 4 diff --git a/data/scripts/maps/Route112.inc b/data/scripts/maps/Route112.inc index 066a7a347..6a9f506f6 100644 --- a/data/scripts/maps/Route112.inc +++ b/data/scripts/maps/Route112.inc @@ -67,7 +67,7 @@ Route112_EventScript_1F1E6A:: @ 81F1E6A Route112_EventScript_1F1E81:: @ 81F1E81 trainerbattle 2, TRAINER_TRENT_1, 0, Route112_Text_299815, Route112_Text_29987C, Route112_EventScript_1F1EAD - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route112_EventScript_1F1ECC msgbox Route112_Text_299896, 4 diff --git a/data/scripts/maps/Route113.inc b/data/scripts/maps/Route113.inc index 7ee63e492..30bf10068 100644 --- a/data/scripts/maps/Route113.inc +++ b/data/scripts/maps/Route113.inc @@ -60,7 +60,7 @@ Route113_EventScript_1F21D7:: @ 81F21D7 Route113_EventScript_1F21EE:: @ 81F21EE trainerbattle 2, TRAINER_MADELINE_1, 0, Route113_Text_299EA6, Route113_Text_299EF9, Route113_EventScript_1F221A - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route113_EventScript_1F2239 msgbox Route113_Text_299F15, 4 @@ -85,7 +85,7 @@ Route113_EventScript_1F2239:: @ 81F2239 Route113_EventScript_1F2250:: @ 81F2250 trainerbattle 2, TRAINER_LAO_1, 0, Route113_Text_29A015, Route113_Text_29A04C, Route113_EventScript_1F227C - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route113_EventScript_1F229B msgbox Route113_Text_29A067, 4 diff --git a/data/scripts/maps/Route114.inc b/data/scripts/maps/Route114.inc index cca7be5af..f1aaf24d2 100644 --- a/data/scripts/maps/Route114.inc +++ b/data/scripts/maps/Route114.inc @@ -110,7 +110,7 @@ Route114_EventScript_1F2685:: @ 81F2685 Route114_EventScript_1F269C:: @ 81F269C trainerbattle 2, TRAINER_STEVE_1, 0, Route114_Text_29A943, Route114_Text_29A973, Route114_EventScript_1F26C8 - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route114_EventScript_1F26E7 msgbox Route114_Text_29A981, 4 @@ -135,7 +135,7 @@ Route114_EventScript_1F26E7:: @ 81F26E7 Route114_EventScript_1F26FE:: @ 81F26FE trainerbattle 2, TRAINER_BERNIE_1, 0, Route114_Text_29AADB, Route114_Text_29AB1A, Route114_EventScript_1F272A - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route114_EventScript_1F2749 msgbox Route114_Text_29AB36, 4 diff --git a/data/scripts/maps/Route115.inc b/data/scripts/maps/Route115.inc index 8ea531f9d..8adf2fa04 100644 --- a/data/scripts/maps/Route115.inc +++ b/data/scripts/maps/Route115.inc @@ -38,7 +38,7 @@ Route115_EventScript_1F2985:: @ 81F2985 Route115_EventScript_1F298E:: @ 81F298E trainerbattle 2, TRAINER_TIMOTHY_1, 0, Route115_Text_29B1FA, Route115_Text_29B230, Route115_EventScript_1F29BA - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route115_EventScript_1F29D9 msgbox Route115_Text_29B258, 4 @@ -68,7 +68,7 @@ Route115_EventScript_1F29F0:: @ 81F29F0 Route115_EventScript_1F2A07:: @ 81F2A07 trainerbattle 2, TRAINER_NOB_1, 0, Route115_Text_29B449, Route115_Text_29B480, Route115_EventScript_1F2A33 - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route115_EventScript_1F2A52 msgbox Route115_Text_29B49D, 4 @@ -93,7 +93,7 @@ Route115_EventScript_1F2A52:: @ 81F2A52 Route115_EventScript_1F2A69:: @ 81F2A69 trainerbattle 2, TRAINER_CYNDY_1, 0, Route115_Text_29B5EF, Route115_Text_29B62D, Route115_EventScript_1F2A95 - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route115_EventScript_1F2AB4 msgbox Route115_Text_29B647, 4 diff --git a/data/scripts/maps/Route116.inc b/data/scripts/maps/Route116.inc index 359f21375..74ab9d428 100644 --- a/data/scripts/maps/Route116.inc +++ b/data/scripts/maps/Route116.inc @@ -259,7 +259,7 @@ Route116_EventScript_1F2EA0:: @ 81F2EA0 Route116_EventScript_1F2EB7:: @ 81F2EB7 trainerbattle 2, TRAINER_JERRY_1, 0, Route116_Text_29BD0C, Route116_Text_29BD66, Route116_EventScript_1F2EF8 - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route116_EventScript_1F2F4E setvar VAR_0x8004, 273 @@ -320,7 +320,7 @@ Route116_EventScript_1F2F7C:: @ 81F2F7C Route116_EventScript_1F2F93:: @ 81F2F93 trainerbattle 2, TRAINER_KAREN_1, 0, Route116_Text_29BFC5, Route116_Text_29BFFA, Route116_EventScript_1F2FD4 - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route116_EventScript_1F302A setvar VAR_0x8004, 280 diff --git a/data/scripts/maps/Route117.inc b/data/scripts/maps/Route117.inc index 01463516b..5140596d8 100644 --- a/data/scripts/maps/Route117.inc +++ b/data/scripts/maps/Route117.inc @@ -40,7 +40,7 @@ Route117_EventScript_1F39C7:: @ 81F39C7 Route117_EventScript_1F39D0:: @ 81F39D0 trainerbattle 2, TRAINER_ISAAC_1, 0, Route117_Text_29C43F, Route117_Text_29C47A, Route117_EventScript_1F39FC - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route117_EventScript_1F3A1B msgbox Route117_Text_29C498, 4 @@ -65,7 +65,7 @@ Route117_EventScript_1F3A1B:: @ 81F3A1B Route117_EventScript_1F3A32:: @ 81F3A32 trainerbattle 2, TRAINER_LYDIA_1, 0, Route117_Text_29C612, Route117_Text_29C659, Route117_EventScript_1F3A5E - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route117_EventScript_1F3A7D msgbox Route117_Text_29C679, 4 @@ -90,7 +90,7 @@ Route117_EventScript_1F3A7D:: @ 81F3A7D Route117_EventScript_1F3A94:: @ 81F3A94 trainerbattle 2, TRAINER_DYLAN_1, 0, Route117_Text_29C7A5, Route117_Text_29C7EB, Route117_EventScript_1F3AC0 - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route117_EventScript_1F3ADF msgbox Route117_Text_29C800, 4 @@ -115,7 +115,7 @@ Route117_EventScript_1F3ADF:: @ 81F3ADF Route117_EventScript_1F3AF6:: @ 81F3AF6 trainerbattle 2, TRAINER_MARIA_1, 0, Route117_Text_29C955, Route117_Text_29C9A6, Route117_EventScript_1F3B22 - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route117_EventScript_1F3B41 msgbox Route117_Text_29C9D0, 4 @@ -145,7 +145,7 @@ Route117_EventScript_1F3B58:: @ 81F3B58 Route117_EventScript_1F3B6F:: @ 81F3B6F trainerbattle 6, TRAINER_ANNA_AND_MEG_1, 0, Route117_Text_29CC4A, Route117_Text_29CC8E, Route117_Text_29CD61, Route117_EventScript_1F3B9F - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route117_EventScript_1F3BB8 msgbox Route117_Text_29CCCB, 4 @@ -168,7 +168,7 @@ Route117_EventScript_1F3BB8:: @ 81F3BB8 Route117_EventScript_1F3BD3:: @ 81F3BD3 trainerbattle 6, TRAINER_ANNA_AND_MEG_1, 0, Route117_Text_29CD9D, Route117_Text_29CDE9, Route117_Text_29CE52, Route117_EventScript_1F3C03 - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route117_EventScript_1F3C1C msgbox Route117_Text_29CE17, 4 diff --git a/data/scripts/maps/Route118.inc b/data/scripts/maps/Route118.inc index 42c3d6d57..5d46224a9 100644 --- a/data/scripts/maps/Route118.inc +++ b/data/scripts/maps/Route118.inc @@ -188,7 +188,7 @@ Route118_Movement_1F3F7E: @ 81F3F7E Route118_EventScript_1F3F87:: @ 81F3F87 trainerbattle 2, TRAINER_ROSE_1, 0, Route118_Text_29D290, Route118_Text_29D2D8, Route118_EventScript_1F3FB3 - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route118_EventScript_1F3FD2 msgbox Route118_Text_29D2FA, 4 @@ -223,7 +223,7 @@ Route118_EventScript_1F4000:: @ 81F4000 Route118_EventScript_1F4017:: @ 81F4017 trainerbattle 2, TRAINER_DALTON_1, 0, Route118_Text_29D6AF, Route118_Text_29D6CD, Route118_EventScript_1F4043 - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route118_EventScript_1F4062 msgbox Route118_Text_29D6D8, 4 diff --git a/data/scripts/maps/Route119.inc b/data/scripts/maps/Route119.inc index 4436005ba..f9bbadb85 100644 --- a/data/scripts/maps/Route119.inc +++ b/data/scripts/maps/Route119.inc @@ -368,7 +368,7 @@ Route119_EventScript_1F47F9:: @ 81F47F9 Route119_EventScript_1F4810:: @ 81F4810 trainerbattle 2, TRAINER_JACKSON_1, 0, Route119_Text_29DC4C, Route119_Text_29DC9F, Route119_EventScript_1F483C - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route119_EventScript_1F485B msgbox Route119_Text_29DCC6, 4 @@ -393,7 +393,7 @@ Route119_EventScript_1F485B:: @ 81F485B Route119_EventScript_1F4872:: @ 81F4872 trainerbattle 2, TRAINER_CATHERINE_1, 0, Route119_Text_29DE0F, Route119_Text_29DE5D, Route119_EventScript_1F489E - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route119_EventScript_1F48BD msgbox Route119_Text_29DE88, 4 diff --git a/data/scripts/maps/Route120.inc b/data/scripts/maps/Route120.inc index aaffe0f12..9651ab8ab 100644 --- a/data/scripts/maps/Route120.inc +++ b/data/scripts/maps/Route120.inc @@ -297,7 +297,7 @@ Route120_EventScript_1F57D7:: @ 81F57D7 Route120_EventScript_1F57EE:: @ 81F57EE trainerbattle 2, TRAINER_ROBERT_1, 0, Route120_Text_29E6E3, Route120_Text_29E70A, Route120_EventScript_1F581A - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route120_EventScript_1F5839 msgbox Route120_Text_29E726, 4 @@ -332,7 +332,7 @@ Route120_EventScript_1F5867:: @ 81F5867 Route120_EventScript_1F587E:: @ 81F587E trainerbattle 2, TRAINER_JEFFREY_1, 0, Route120_Text_29E9D7, Route120_Text_29E9FF, Route120_EventScript_1F58AA - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route120_EventScript_1F58C9 msgbox Route120_Text_29EA08, 4 diff --git a/data/scripts/maps/Route121.inc b/data/scripts/maps/Route121.inc index 0d1f8863e..59623b4e6 100644 --- a/data/scripts/maps/Route121.inc +++ b/data/scripts/maps/Route121.inc @@ -72,7 +72,7 @@ Route121_EventScript_1F5E74:: @ 81F5E74 Route121_EventScript_1F5E8B:: @ 81F5E8B trainerbattle 2, TRAINER_WALTER_1, 0, Route121_Text_29F199, Route121_Text_29F20D, Route121_EventScript_1F5EB7 - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route121_EventScript_1F5ED6 msgbox Route121_Text_29F21E, 4 @@ -112,7 +112,7 @@ Route121_EventScript_1F5F1F:: @ 81F5F1F Route121_EventScript_1F5F3A:: @ 81F5F3A trainerbattle 2, TRAINER_JESSICA_1, 0, Route121_Text_29F612, Route121_Text_29F641, Route121_EventScript_1F5F66 - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route121_EventScript_1F5F85 msgbox Route121_Text_29F66F, 4 @@ -157,7 +157,7 @@ Route121_EventScript_1F5FE1:: @ 81F5FE1 Route121_EventScript_1F5FF8:: @ 81F5FF8 trainerbattle 2, TRAINER_CRISTIN_1, 0, Route121_Text_29F770, Route121_Text_29F7C1, Route121_EventScript_1F6024 - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route121_EventScript_1F6043 msgbox Route121_Text_29F7D4, 4 diff --git a/data/scripts/maps/Route123.inc b/data/scripts/maps/Route123.inc index 8eb397fd4..ee659a496 100644 --- a/data/scripts/maps/Route123.inc +++ b/data/scripts/maps/Route123.inc @@ -62,7 +62,7 @@ Route123_EventScript_1F61F3:: @ 81F61F3 Route123_EventScript_1F620A:: @ 81F620A trainerbattle 2, TRAINER_CAMERON_1, 0, Route123_Text_29FDBA, Route123_Text_29FE1E, Route123_EventScript_1F6236 - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route123_EventScript_1F6255 msgbox Route123_Text_29FE2A, 4 @@ -87,7 +87,7 @@ Route123_EventScript_1F6255:: @ 81F6255 Route123_EventScript_1F626C:: @ 81F626C trainerbattle 2, TRAINER_JACKI_1, 0, Route123_Text_29FF61, Route123_Text_29FFD8, Route123_EventScript_1F6298 - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route123_EventScript_1F62B7 msgbox Route123_Text_29FFE5, 4 @@ -162,7 +162,7 @@ Route123_EventScript_1F63A5:: @ 81F63A5 Route123_EventScript_1F63BC:: @ 81F63BC trainerbattle 2, TRAINER_FERNANDO_1, 0, Route123_Text_2A0323, Route123_Text_2A035C, Route123_EventScript_1F63E8 - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route123_EventScript_1F6407 msgbox Route123_Text_2A0389, 4 diff --git a/data/scripts/maps/Route124.inc b/data/scripts/maps/Route124.inc index 2a0298650..01687eba8 100644 --- a/data/scripts/maps/Route124.inc +++ b/data/scripts/maps/Route124.inc @@ -23,7 +23,7 @@ Route124_EventScript_1F659C:: @ 81F659C Route124_EventScript_1F65B3:: @ 81F65B3 trainerbattle 2, TRAINER_JENNY_1, 0, Route124_Text_2A0B37, Route124_Text_2A0B7C, Route124_EventScript_1F65DF - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route124_EventScript_1F65FE msgbox Route124_Text_2A0B9A, 4 @@ -58,7 +58,7 @@ Route124_EventScript_1F662C:: @ 81F662C Route124_EventScript_1F6643:: @ 81F6643 trainerbattle 6, TRAINER_LILA_AND_ROY_1, 0, Route124_Text_2A0E87, Route124_Text_2A0EFE, Route124_Text_2A0F8C, Route124_EventScript_1F6673 - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route124_EventScript_1F668C msgbox Route124_Text_2A0F3A, 4 @@ -81,7 +81,7 @@ Route124_EventScript_1F668C:: @ 81F668C Route124_EventScript_1F66A7:: @ 81F66A7 trainerbattle 6, TRAINER_LILA_AND_ROY_1, 0, Route124_Text_2A0FD1, Route124_Text_2A1012, Route124_Text_2A10E5, Route124_EventScript_1F66D7 - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route124_EventScript_1F66F0 msgbox Route124_Text_2A103E, 4 diff --git a/data/scripts/maps/Route125.inc b/data/scripts/maps/Route125.inc index 953bf52b2..b93e7f016 100644 --- a/data/scripts/maps/Route125.inc +++ b/data/scripts/maps/Route125.inc @@ -48,7 +48,7 @@ Route125_EventScript_1F67E9:: @ 81F67E9 Route125_EventScript_1F6800:: @ 81F6800 trainerbattle 2, TRAINER_ERNEST_1, 0, Route125_Text_2A16FC, Route125_Text_2A173A, Route125_EventScript_1F682C - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route125_EventScript_1F684B msgbox Route125_Text_2A1755, 4 diff --git a/data/scripts/maps/Route126.inc b/data/scripts/maps/Route126.inc index 4678fe39d..e6f8848b7 100644 --- a/data/scripts/maps/Route126.inc +++ b/data/scripts/maps/Route126.inc @@ -44,7 +44,7 @@ Route126_EventScript_1F6960:: @ 81F6960 Route126_EventScript_1F6977:: @ 81F6977 trainerbattle 2, TRAINER_PABLO_1, 0, Route126_Text_2A1EA5, Route126_Text_2A1EE3, Route126_EventScript_1F69A3 - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route126_EventScript_1F69C2 msgbox Route126_Text_2A1F10, 4 diff --git a/data/scripts/maps/Route127.inc b/data/scripts/maps/Route127.inc index 9851df043..68992425e 100644 --- a/data/scripts/maps/Route127.inc +++ b/data/scripts/maps/Route127.inc @@ -63,7 +63,7 @@ Route127_EventScript_1F6ABF:: @ 81F6ABF Route127_EventScript_1F6AD6:: @ 81F6AD6 trainerbattle 2, TRAINER_KOJI_1, 0, Route127_Text_2A264D, Route127_Text_2A2685, Route127_EventScript_1F6B02 - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route127_EventScript_1F6B21 msgbox Route127_Text_2A26AC, 4 diff --git a/data/scripts/maps/Route128.inc b/data/scripts/maps/Route128.inc index 1ba1b3448..21824eb41 100644 --- a/data/scripts/maps/Route128.inc +++ b/data/scripts/maps/Route128.inc @@ -177,7 +177,7 @@ Route128_Movement_1F6CBB: @ 81F6CBB Route128_EventScript_1F6CBE:: @ 81F6CBE trainerbattle 2, TRAINER_ISAIAH_1, 0, Route128_Text_2A287F, Route128_Text_2A28AB, Route128_EventScript_1F6CEA - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route128_EventScript_1F6D09 msgbox Route128_Text_2A28D7, 4 @@ -202,7 +202,7 @@ Route128_EventScript_1F6D09:: @ 81F6D09 Route128_EventScript_1F6D20:: @ 81F6D20 trainerbattle 2, TRAINER_KATELYN_1, 0, Route128_Text_2A2A1F, Route128_Text_2A2A94, Route128_EventScript_1F6D4C - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq Route128_EventScript_1F6D6B msgbox Route128_Text_2A2AB7, 4 diff --git a/data/scripts/maps/RustboroCity_Gym.inc b/data/scripts/maps/RustboroCity_Gym.inc index dec6a8e73..dde0cc6a6 100644 --- a/data/scripts/maps/RustboroCity_Gym.inc +++ b/data/scripts/maps/RustboroCity_Gym.inc @@ -3,7 +3,7 @@ RustboroCity_Gym_MapScripts:: @ 8212F30 RustboroCity_Gym_EventScript_212F31:: @ 8212F31 trainerbattle 1, TRAINER_ROXANNE_1, 0, RustboroCity_Gym_Text_21362A, RustboroCity_Gym_Text_21370B, RustboroCity_Gym_EventScript_212F66 - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq RustboroCity_Gym_EventScript_212FC8 checkflag FLAG_0x0A5 diff --git a/data/scripts/maps/SootopolisCity_Gym_1F.inc b/data/scripts/maps/SootopolisCity_Gym_1F.inc index e28d8d13f..8b6a5754e 100644 --- a/data/scripts/maps/SootopolisCity_Gym_1F.inc +++ b/data/scripts/maps/SootopolisCity_Gym_1F.inc @@ -87,7 +87,7 @@ SootopolisCity_Gym_1F_Movement_224F42: @ 8224F42 SootopolisCity_Gym_1F_EventScript_224F44:: @ 8224F44 trainerbattle 1, TRAINER_JUAN_1, 0, SootopolisCity_Gym_1F_Text_225268, SootopolisCity_Gym_1F_Text_225432, SootopolisCity_Gym_1F_EventScript_224F82 - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq SootopolisCity_Gym_1F_EventScript_225025 checkflag FLAG_0x0AC diff --git a/data/scripts/maps/VictoryRoad_1F.inc b/data/scripts/maps/VictoryRoad_1F.inc index 8bc22aa3d..94ecc0946 100644 --- a/data/scripts/maps/VictoryRoad_1F.inc +++ b/data/scripts/maps/VictoryRoad_1F.inc @@ -83,7 +83,7 @@ VictoryRoad_1F_EventScript_235E2C:: @ 8235E2C VictoryRoad_1F_EventScript_235E35:: @ 8235E35 trainerbattle 0, TRAINER_WALLY_3, 0, VictoryRoad_1F_Text_236073, VictoryRoad_1F_Text_2360DA - specialvar VAR_RESULT, sub_80B226C + specialvar VAR_RESULT, ShouldTryRematchBattle compare_var_to_value VAR_RESULT, 1 goto_eq VictoryRoad_1F_EventScript_235E5C msgbox VictoryRoad_1F_Text_2360FE, 6 diff --git a/data/specials.inc b/data/specials.inc index 4f8473e17..0f15b6784 100644 --- a/data/specials.inc +++ b/data/specials.inc @@ -61,17 +61,17 @@ gSpecials:: @ 81DBA64 def_special FieldObjectInteractionWaterBerryTree def_special PlayerHasBerries def_special IsEnigmaBerryValid - def_special sub_80B170C - def_special sub_80B1A14 - def_special special_trainer_unable_to_battle - def_special check_trainer_flag + def_special GetTrainerBattleMode + def_special ShowTrainerIntroSpeech + def_special ShowTrainerCantBattleSpeech + def_special GetTrainerFlag def_special sub_80B45AC def_special SetUpTrainerEncounterMusic - def_special sub_80B226C - def_special sub_80B22A0 - def_special sub_80B19EC + def_special ShouldTryRematchBattle + def_special IsTrainerReadyForRematch + def_special BattleSetup_StartRematchBattle def_special sub_80C7578 - def_special sub_80F92F8 + def_special HasEnoughMonsForDoubleBattle def_special TurnOffTVScreen def_special DoTVShow def_special DoPokeNews @@ -415,7 +415,7 @@ gSpecials:: @ 81DBA64 def_special PutLilycoveContestLadyShowOnTheAir def_special sub_813B880 def_special sub_81A085C - def_special CheckIfMultipleTrainersWantBattle + def_special ShouldTryGetTrainerScript def_special AddMapNamePopUpWindowTask def_special AddMapNamePopUpWindowTask def_special sub_81BE994 diff --git a/include/battle_setup.h b/include/battle_setup.h index 0168022cc..e4bae6fdb 100644 --- a/include/battle_setup.h +++ b/include/battle_setup.h @@ -1,18 +1,85 @@ #ifndef GUARD_BATTLE_SETUP_H #define GUARD_BATTLE_SETUP_H -void BattleSetup_StartScriptedWildBattle(void); -u8 BattleSetup_GetTerrainId(void); -u8 *BattleSetup_ConfigureTrainerBattle(const u8 *data); -void BattleSetup_StartBattlePikeWildBattle(void); +enum +{ + TRAINER_BATTLE_NORMAL, + TRAINER_BATTLE_CONTINUE_SCRIPT_NO_MUSIC, + TRAINER_BATTLE_CONTINUE_SCRIPT, + TRAINER_BATTLE_NORMAL_NO_INTRO_TEXT, + TRAINER_BATTLE_DOUBLE, + TRAINER_BATTLE_REMATCH, + TRAINER_BATTLE_CONTINUE_SCRIPT_DOUBLE, + TRAINER_BATTLE_REMATCH_DOUBLE, + TRAINER_BATTLE_CONTINUE_SCRIPT_DOUBLE_NO_MUSIC, + TRAINER_BATTLE_9, + TRAINER_BATTLE_SET_TRAINER_A, + TRAINER_BATTLE_SET_TRAINER_B, + TRAINER_BATTLE_12, +}; + +#define REMATCHES_COUNT 5 +#define REMATCH_TABLE_ENTRIES 78 +#define REMATCH_WALLY_ENTRY 64 +#define REMATCH_ELITE_FOUR_ENTRIES 73 + +struct RematchTrainer +{ + u16 trainerIds[REMATCHES_COUNT]; + u16 mapGroup; + u16 mapNum; +}; + +extern const struct RematchTrainer gRematchTable[REMATCH_TABLE_ENTRIES]; + +extern u16 gTrainerBattleOpponent_A; +extern u16 gTrainerBattleOpponent_B; +extern u16 gPartnerTrainerId; + void BattleSetup_StartWildBattle(void); +void BattleSetup_StartBattlePikeWildBattle(void); void BattleSetup_StartRoamerBattle(void); - -u8 HasTrainerAlreadyBeenFought(u16); -void trainer_flag_set(u16); -void trainer_flag_clear(u16); +void StartWallyTutorialBattle(void); +void BattleSetup_StartScriptedWildBattle(void); +void BattleSetup_StartLatiBattle(void); +void BattleSetup_StartLegendaryBattle(void); +void StartGroudonKyogreBattle(void); +void StartRegiBattle(void); +u8 BattleSetup_GetTerrainId(void); +u8 sub_80B100C(s32 arg0); +void ChooseStarter(void); +void ResetTrainerOpponentIds(void); +void SetMapVarsToTrainer(void); +const u8 *BattleSetup_ConfigureTrainerBattle(const u8 *data); +void ConfigureAndSetUpOneTrainerBattle(u8 trainerMapObjId, const u8 *trainerScript); +void ConfigureTwoTrainersBattle(u8 trainerMapObjId, const u8 *trainerScript); +void SetUpTwoTrainersBattle(void); +bool32 GetTrainerFlagFromScriptPointer(const u8 *data); +void sub_80B16D8(void); +u8 GetTrainerBattleMode(void); +bool8 GetTrainerFlag(void); +bool8 HasTrainerBeenFought(u16 trainerId); +void SetTrainerFlag(u16 trainerId); +void ClearTrainerFlag(u16 trainerId); void BattleSetup_StartTrainerBattle(void); -u8 *BattleSetup_GetScriptAddrAfterBattle(void); -u8 *BattleSetup_GetTrainerPostBattleScript(void); +void BattleSetup_StartRematchBattle(void); +void ShowTrainerIntroSpeech(void); +const u8 *BattleSetup_GetScriptAddrAfterBattle(void); +const u8 *BattleSetup_GetTrainerPostBattleScript(void); +void ShowTrainerCantBattleSpeech(void); +void SetUpTrainerEncounterMusic(void); +const u8 *GetTrainerALoseText(void); +const u8 *GetTrainerBLoseText(void); +const u8 *GetTrainerWonSpeech(void); +void UpdateRematchIfDefeated(s32 rematchTableId); +void IncrementRematchStepCounter(void); +void TryUpdateRandomTrainerRematches(u16 mapGroup, u16 mapNum); +bool32 DoesSomeoneWantRematchIn(u16 mapGroup, u16 mapNum); +bool32 IsRematchTrainerIn(u16 mapGroup, u16 mapNum); +u16 GetLastBeatenRematchTrainerId(u16 trainerId); +bool8 ShouldTryRematchBattle(void); +bool8 IsTrainerReadyForRematch(void); +void ShouldTryGetTrainerScript(void); +u16 CountBattledRematchTeams(u16 trainerId); #endif // GUARD_BATTLE_SETUP_H diff --git a/include/battle_transition.h b/include/battle_transition.h index 26b836c66..b160f3e02 100644 --- a/include/battle_transition.h +++ b/include/battle_transition.h @@ -14,7 +14,7 @@ enum // TRANSITION_MUGSHOT MUGSHOT_PHOEBE, MUGSHOT_GLACIA, MUGSHOT_DRAKE, - MUGSHOT_STEVEN, + MUGSHOT_CHAMPION, }; #define MUGSHOTS_NO 5 @@ -38,7 +38,7 @@ enum // TRANSITION_MUGSHOT #define B_TRANSITION_PHOEBE 13 #define B_TRANSITION_GLACIA 14 #define B_TRANSITION_DRAKE 15 -#define B_TRANSITION_STEVEN 16 +#define B_TRANSITION_CHAMPION 16 // added in Emerald #define B_TRANSITION_AQUA 17 #define B_TRANSITION_MAGMA 18 @@ -48,5 +48,22 @@ enum // TRANSITION_MUGSHOT #define B_TRANSITION_KYORGE 22 #define B_TRANSITION_GROUDON 23 #define B_TRANSITION_RAYQUAZA 24 +#define B_TRANSITION_25 25 +#define B_TRANSITION_26 26 +#define B_TRANSITION_27 27 +#define B_TRANSITION_28 28 +#define B_TRANSITION_29 29 +#define B_TRANSITION_30 30 +#define B_TRANSITION_31 31 +#define B_TRANSITION_32 32 +#define B_TRANSITION_33 33 +#define B_TRANSITION_34 34 +#define B_TRANSITION_35 35 +#define B_TRANSITION_36 36 +#define B_TRANSITION_37 37 +#define B_TRANSITION_38 38 +#define B_TRANSITION_39 39 +#define B_TRANSITION_40 40 +#define B_TRANSITION_41 41 #endif // GUARD_BATTLE_TRANSITION_H diff --git a/include/event_scripts.h b/include/event_scripts.h index 844f1052a..a54e0e463 100755 --- a/include/event_scripts.h +++ b/include/event_scripts.h @@ -7,10 +7,18 @@ extern const u8 gUnknown_0823B4E8[]; extern const u8 gUnknown_0823B5E9[]; +extern const u8 EventScript_TestSignpostMsg[]; +extern const u8 EventScript_TryGetTrainerScript[]; extern const u8 EventScript_275BB7[]; extern const u8 EventScript_275D0C[]; extern const u8 EventScript_275D1F[]; extern const u8 EventScript_275D2E[]; +extern const u8 EventScript_271354[]; +extern const u8 EventScript_2713C2[]; +extern const u8 EventScript_TryDoDoubleTrainerBattle[]; +extern const u8 EventScript_271362[]; +extern const u8 EventScript_TryDoDoubleRematchBattle[]; +extern const u8 EventScript_2713D1[]; extern const u8 EventScript_2766A2[]; extern const u8 EventScript_2766A6[]; diff --git a/include/field_map_obj.h b/include/field_map_obj.h index 0107fa10f..696d1c2e2 100755 --- a/include/field_map_obj.h +++ b/include/field_map_obj.h @@ -76,6 +76,8 @@ void MoveCoords(u8, s16 *, s16 *); bool8 FieldObjectIsSpecialAnimActive(struct MapObject *); u8 FieldObjectClearAnimIfSpecialAnimFinished(struct MapObject *); u8 GetFieldObjectIdByXYZ(u16 x, u16 y, u8 z); +void npc_set_running_behaviour_etc(struct MapObject *mapObject, u8 animPattern); +u8 npc_running_behaviour_by_direction(u8 direction); // Exported data declarations diff --git a/include/flags.h b/include/flags.h index 31d634c59..cf5e67576 100644 --- a/include/flags.h +++ b/include/flags.h @@ -1,9 +1,12 @@ #ifndef GUARD_FLAGS_H #define GUARD_FLAGS_H -#define FLAG_340 0x340 #define FLAG_LEGENDARIES_IN_SOOTOPOLIS 0x53 #define FLAG_PENDING_DAYCARE_EGG 0x86 +#define FLAG_7E 0x7E +#define FLAG_HAS_MATCH_CALL 0x12F +#define FLAG_MATCH_CALL_REGISTERED 0x15C +#define FLAG_340 0x340 #define FLAG_TRAINER_FLAG_START 0x500 diff --git a/include/pokemon.h b/include/pokemon.h index 480c8d9b9..cdab96687 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -653,6 +653,7 @@ u8 GetSecretBaseTrainerPicIndex(void); bool8 TryIncrementMonLevel(struct Pokemon *mon); void BoxMonToMon(struct BoxPokemon *srcMon, struct Pokemon *dstMon); u8 GetLevelUpMovesBySpecies(u16 species, u16 *moves); +u8 GetMonsStateToDoubles_2(void); #include "sprite.h" diff --git a/include/pokemon_3.h b/include/pokemon_3.h index 66ed0d9b2..82dfacf48 100644 --- a/include/pokemon_3.h +++ b/include/pokemon_3.h @@ -4,5 +4,6 @@ const u8* GetTrainerClassNameFromId(u16 trainerId); const u8* GetTrainerNameFromId(u16 trainerId); void PlayMapChosenOrBattleBGM(u16 song); +u8 GetTrainerEncounterMusicId(u16 trainerOpponentId); #endif // GUARD_POKEMON_3_H diff --git a/include/secret_base.h b/include/secret_base.h index 630a36773..b2502889c 100644 --- a/include/secret_base.h +++ b/include/secret_base.h @@ -9,5 +9,6 @@ void sub_80E9578(void); void sub_80E980C(void); u8 *GetSecretBaseMapName(u8 *dest); +const u8 *GetSecretBaseTrainerLoseText(void); #endif //GUARD_SECRET_BASE_H diff --git a/include/strings.h b/include/strings.h index 08e2b4bba..1a46dd5a8 100644 --- a/include/strings.h +++ b/include/strings.h @@ -82,5 +82,6 @@ extern const u8 gText_NoRegistry[]; extern const u8 gText_OkayToDeleteFromRegistry[]; extern const u8 gText_RegisteredDataDeleted[]; extern const u8 gUnknown_085EA79D[]; +extern const u8 gText_EmptyString2[]; #endif //GUARD_STRINGS_H diff --git a/include/trainer.h b/include/trainer.h new file mode 100644 index 000000000..232cde608 --- /dev/null +++ b/include/trainer.h @@ -0,0 +1,19 @@ +#ifndef GUARD_TRAINER_H +#define GUARD_TRAINER_H + +#define TRAINER_ENCOUNTER_MUSIC_MALE 0 // standard male encounter music +#define TRAINER_ENCOUNTER_MUSIC_FEMALE 1 // standard female encounter music +#define TRAINER_ENCOUNTER_MUSIC_GIRL 2 // used for male Tubers and Young Couples too +#define TRAINER_ENCOUNTER_MUSIC_SUSPICIOUS 3 +#define TRAINER_ENCOUNTER_MUSIC_INTENSE 4 +#define TRAINER_ENCOUNTER_MUSIC_COOL 5 +#define TRAINER_ENCOUNTER_MUSIC_AQUA 6 +#define TRAINER_ENCOUNTER_MUSIC_MAGMA 7 +#define TRAINER_ENCOUNTER_MUSIC_SWIMMER 8 +#define TRAINER_ENCOUNTER_MUSIC_TWINS 9 // used for other trainer classes too +#define TRAINER_ENCOUNTER_MUSIC_ELITE_FOUR 10 +#define TRAINER_ENCOUNTER_MUSIC_HIKER 11 // used for other trainer classes too +#define TRAINER_ENCOUNTER_MUSIC_INTERVIEWER 12 +#define TRAINER_ENCOUNTER_MUSIC_RICH 13 // Rich Boys and Gentlemen + +#endif // GUARD_TRAINER_H diff --git a/include/trainer_see.h b/include/trainer_see.h index ab035d9f8..5da50cfa1 100644 --- a/include/trainer_see.h +++ b/include/trainer_see.h @@ -1,6 +1,21 @@ #ifndef GUARD_TRAINER_SEE_H #define GUARD_TRAINER_SEE_H +struct ApproachingTrainer +{ + u8 mapObjectId; + u8 radius; + u8 field_2; + u8 field_3; + const u8 *trainerScriptPtr; + u8 field_8; + u8 field_9; + u8 field_A; + u8 field_B; +}; + +extern struct ApproachingTrainer gApproachingTrainers[]; + void sub_80B4578(struct MapObject *); u8 sub_80B47BC(void); void sub_8155D78(struct MapObject *); diff --git a/ld_script.txt b/ld_script.txt index 2337dff3b..a275127a7 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -120,8 +120,8 @@ SECTIONS { asm/title_screen.o(.text); asm/field_screen.o(.text); src/battle_setup.o(.text); - asm/battle_setup.o(.text); asm/cable_club.o(.text); + src/trainer_see.o(.text); asm/trainer_see.o(.text); src/wild_encounter.o(.text); asm/field_effect.o(.text); @@ -379,7 +379,6 @@ SECTIONS { data/title_screen.o(.rodata); data/field_screen.o(.rodata); src/battle_setup.o(.rodata); - data/battle_setup.o(.rodata); data/cable_club.o(.rodata); data/trainer_see.o(.rodata); data/wild_encounter.o(.rodata); diff --git a/src/battle_message.c b/src/battle_message.c index 77f7cc722..5faf60290 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -12,6 +12,7 @@ #include "window.h" #include "palette.h" #include "battle_controllers.h" +#include "battle_setup.h" extern u16 gLastUsedItem; extern u8 gLastUsedAbility; @@ -54,8 +55,6 @@ extern void sub_81D5554(u8 *txtPtr, u16 trainerId); // pokenav extern void GetEreaderTrainerName(u8 *txtPtr); extern void sub_81A36D0(u8 arg0, u16 trainerId); // battle_frontier_2 extern void sub_81D572C(u8 arg0, u16 trainerId); // pokenav -extern const u8* GetTrainer1LoseText(void); // battle_setup -extern const u8* GetTrainer2LoseText(void); // battle_setup extern void GetFrontierTrainerName(u8 *dst, u16 trainerId); extern s32 GetStringCenterAlignXOffsetWithLetterSpacing(u8 fontId, const u8 *str, s32 totalWidth, s16 letterSpacing); extern u8 GetTextSpeedInRecordedBattle(void); @@ -2068,7 +2067,7 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst) } else { - toCpy = GetTrainer1LoseText(); + toCpy = GetTrainerALoseText(); } break; case B_TXT_TRAINER1_WIN_TEXT: // trainerA win text @@ -2165,7 +2164,7 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst) } else { - toCpy = GetTrainer2LoseText(); + toCpy = GetTrainerBLoseText(); } break; case B_TXT_TRAINER2_WIN_TEXT: diff --git a/src/battle_setup.c b/src/battle_setup.c index 3121e9262..bcb883ca1 100644 --- a/src/battle_setup.c +++ b/src/battle_setup.c @@ -23,9 +23,36 @@ #include "items.h" #include "palette.h" #include "window.h" +#include "field_map_obj.h" +#include "event_scripts.h" +#include "trainer_see.h" +#include "field_message_box.h" +#include "trainer.h" +#include "sound.h" +#include "strings.h" +#include "secret_base.h" +#include "string_util.h" + +enum +{ + TRAINER_PARAM_LOAD_VAL_8BIT, + TRAINER_PARAM_LOAD_VAL_16BIT, + TRAINER_PARAM_LOAD_VAL_32BIT, + TRAINER_PARAM_CLEAR_VAL_8BIT, + TRAINER_PARAM_CLEAR_VAL_16BIT, + TRAINER_PARAM_CLEAR_VAL_32BIT, + TRAINER_PARAM_LOAD_SCRIPT_RET_ADDR, +}; + +struct TrainerBattleParameter +{ + void *varPtr; + u8 ptrType; +}; extern bool8 InBattlePyramid(void); extern bool8 InBattlePike(void); +extern bool32 InTrainerHill(void); extern bool32 FieldPoisonEffectIsRunning(void); extern void overworld_free_bg_tilemaps(void); extern void prev_quest_postbuffer_cursor_backup_reset(void); @@ -43,43 +70,66 @@ extern void PlayBattleBGM(void); extern void sub_81DA57C(void); extern u8 GetSav1Weather(void); extern u8 Overworld_GetFlashLevel(void); +extern u16 sub_81A9AA8(u8 localId); +extern u16 sub_81D6180(u8 localId); +extern bool8 GetBattlePyramidTrainerFlag(u8 mapObjId); +extern bool8 GetTrainerHillTrainerFlag(u8 mapObjId); +extern bool8 sub_81D5C18(void); +extern void sub_816306C(u8 a0); +extern void sub_8163048(u8 a0); +extern void sub_81A9B04(void); +extern void sub_81D639C(void); +extern void sub_81D6384(void); +extern void sub_81D61E8(void); +extern void sub_80982B8(void); +extern void sub_81A9EDC(u16 a0); +extern void sub_81D572C(u8 a0, u16 arg1); extern u32 gBattleTypeFlags; extern u8 gBattleOutcome; extern void (*gFieldCallback)(void); extern u8 gApproachingTrainerId; +extern u8 gNoOfApproachingTrainers; +extern u16 gUnknown_03006080; // this file's functions -void DoBattlePikeWildBattle(void); -void DoSafariBattle(void); -void DoStandardWildBattle(void); -void CB2_EndWildBattle(void); -void CB2_EndScriptedWildBattle(void); -u8 GetWildBattleTransition(void); -u8 GetTrainerBattleTransition(void); -u8 sub_80B100C(s32 arg0); -void sub_80B1218(void); -void sub_80B1234(void); -void CB2_GiveStarter(void); -void CB2_StartFirstBattle(void); -void CB2_EndFirstBattle(void); -bool32 IsPlayerDefeated(u32 battleOutcome); +static void DoBattlePikeWildBattle(void); +static void DoSafariBattle(void); +static void DoStandardWildBattle(void); +static void CB2_EndWildBattle(void); +static void CB2_EndScriptedWildBattle(void); +static u8 GetWildBattleTransition(void); +static u8 GetTrainerBattleTransition(void); +static void sub_80B1218(void); +static void sub_80B1234(void); +static void CB2_GiveStarter(void); +static void CB2_StartFirstBattle(void); +static void CB2_EndFirstBattle(void); +static void CB2_EndTrainerBattle(void); +static bool32 IsPlayerDefeated(u32 battleOutcome); +static u16 GetRematchTrainerId(u16 trainerId); +static void RegisterTrainerInMatchCall(void); +static void HandleRematchVarsOnBattleEnd(void); +static const u8 *GetIntroSpeechOfApproachingTrainer(void); +static const u8 *GetTrainerCantBattleSpeech(void); // ewram data -EWRAM_DATA u16 sTrainerBattleMode = 0; +EWRAM_DATA static u16 sTrainerBattleMode = 0; EWRAM_DATA u16 gTrainerBattleOpponent_A = 0; EWRAM_DATA u16 gTrainerBattleOpponent_B = 0; EWRAM_DATA u16 gPartnerTrainerId = 0; -EWRAM_DATA u16 sTrainerMapObjectLocalId = 0; -EWRAM_DATA u8 *sTrainerAIntroSpeech = NULL; -EWRAM_DATA u8 *sTrainerBIntroSpeech = NULL; -EWRAM_DATA u8 *sTrainerADefeatSpeech = NULL; -EWRAM_DATA u8 *sTrainerBDefeatSpeech = NULL; -EWRAM_DATA u8 *sTrainerVictorySpeech = NULL; -EWRAM_DATA u8 *sTrainerCannotBattleSpeech = NULL; -EWRAM_DATA u8 *gUnknown_02038BEC = NULL; -EWRAM_DATA u8 *gUnknown_02038BF0 = NULL; -EWRAM_DATA u8 *gUnknown_02038BF4 = NULL; +EWRAM_DATA static u16 sTrainerMapObjectLocalId = 0; +EWRAM_DATA static u8 *sTrainerAIntroSpeech = NULL; +EWRAM_DATA static u8 *sTrainerBIntroSpeech = NULL; +EWRAM_DATA static u8 *sTrainerADefeatSpeech = NULL; +EWRAM_DATA static u8 *sTrainerBDefeatSpeech = NULL; +EWRAM_DATA static u8 *sTrainerVictorySpeech = NULL; +EWRAM_DATA static u8 *sTrainerCannotBattleSpeech = NULL; +EWRAM_DATA static u8 *sTrainerBattleEndScript = NULL; +EWRAM_DATA static u8 *sTrainerABattleScriptRetAddr = NULL; +EWRAM_DATA static u8 *sTrainerBBattleScriptRetAddr = NULL; +EWRAM_DATA static bool8 sShouldCheckTrainerBScript = FALSE; +EWRAM_DATA static u8 sNoOfPossibleTrainerRetScripts = 0; // const rom data @@ -103,23 +153,204 @@ static const u8 sBattleTransitionTable_Trainer[][2] = static const u8 sUnknown_0854FE98[] = { - 0x1d, 0x1e, 0x1f, 0x20, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29 + B_TRANSITION_29, B_TRANSITION_30, B_TRANSITION_31, B_TRANSITION_32, + B_TRANSITION_34, B_TRANSITION_35, B_TRANSITION_36, B_TRANSITION_37, + B_TRANSITION_38, B_TRANSITION_39, B_TRANSITION_40, B_TRANSITION_41 }; static const u8 sUnknown_0854FEA4[] = { - 0x1f, 0x20, 0x21 + B_TRANSITION_31, B_TRANSITION_32, B_TRANSITION_33 }; static const u8 sUnknown_0854FEA7[] = { - 0x1d, 0x1f, 0x20, 0x21 + B_TRANSITION_29, B_TRANSITION_31, B_TRANSITION_32, B_TRANSITION_33 +}; + +static const struct TrainerBattleParameter sOrdinaryBattleParams[] = +{ + {&sTrainerBattleMode, TRAINER_PARAM_LOAD_VAL_8BIT}, + {&gTrainerBattleOpponent_A, TRAINER_PARAM_LOAD_VAL_16BIT}, + {&sTrainerMapObjectLocalId, TRAINER_PARAM_LOAD_VAL_16BIT}, + {&sTrainerAIntroSpeech, TRAINER_PARAM_LOAD_VAL_32BIT}, + {&sTrainerADefeatSpeech, TRAINER_PARAM_LOAD_VAL_32BIT}, + {&sTrainerVictorySpeech, TRAINER_PARAM_CLEAR_VAL_32BIT}, + {&sTrainerCannotBattleSpeech, TRAINER_PARAM_CLEAR_VAL_32BIT}, + {&sTrainerABattleScriptRetAddr, TRAINER_PARAM_CLEAR_VAL_32BIT}, + {&sTrainerBattleEndScript, TRAINER_PARAM_LOAD_SCRIPT_RET_ADDR}, +}; + +static const struct TrainerBattleParameter sContinueScriptBattleParams[] = +{ + {&sTrainerBattleMode, TRAINER_PARAM_LOAD_VAL_8BIT}, + {&gTrainerBattleOpponent_A, TRAINER_PARAM_LOAD_VAL_16BIT}, + {&sTrainerMapObjectLocalId, TRAINER_PARAM_LOAD_VAL_16BIT}, + {&sTrainerAIntroSpeech, TRAINER_PARAM_LOAD_VAL_32BIT}, + {&sTrainerADefeatSpeech, TRAINER_PARAM_LOAD_VAL_32BIT}, + {&sTrainerVictorySpeech, TRAINER_PARAM_CLEAR_VAL_32BIT}, + {&sTrainerCannotBattleSpeech, TRAINER_PARAM_CLEAR_VAL_32BIT}, + {&sTrainerABattleScriptRetAddr, TRAINER_PARAM_LOAD_VAL_32BIT}, + {&sTrainerBattleEndScript, TRAINER_PARAM_LOAD_SCRIPT_RET_ADDR}, +}; + +static const struct TrainerBattleParameter sDoubleBattleParams[] = +{ + {&sTrainerBattleMode, TRAINER_PARAM_LOAD_VAL_8BIT}, + {&gTrainerBattleOpponent_A, TRAINER_PARAM_LOAD_VAL_16BIT}, + {&sTrainerMapObjectLocalId, TRAINER_PARAM_LOAD_VAL_16BIT}, + {&sTrainerAIntroSpeech, TRAINER_PARAM_LOAD_VAL_32BIT}, + {&sTrainerADefeatSpeech, TRAINER_PARAM_LOAD_VAL_32BIT}, + {&sTrainerVictorySpeech, TRAINER_PARAM_CLEAR_VAL_32BIT}, + {&sTrainerCannotBattleSpeech, TRAINER_PARAM_LOAD_VAL_32BIT}, + {&sTrainerABattleScriptRetAddr, TRAINER_PARAM_CLEAR_VAL_32BIT}, + {&sTrainerBattleEndScript, TRAINER_PARAM_LOAD_SCRIPT_RET_ADDR}, +}; + +static const struct TrainerBattleParameter sOrdinaryNoIntroBattleParams[] = +{ + {&sTrainerBattleMode, TRAINER_PARAM_LOAD_VAL_8BIT}, + {&gTrainerBattleOpponent_A, TRAINER_PARAM_LOAD_VAL_16BIT}, + {&sTrainerMapObjectLocalId, TRAINER_PARAM_LOAD_VAL_16BIT}, + {&sTrainerAIntroSpeech, TRAINER_PARAM_CLEAR_VAL_32BIT}, + {&sTrainerADefeatSpeech, TRAINER_PARAM_LOAD_VAL_32BIT}, + {&sTrainerVictorySpeech, TRAINER_PARAM_CLEAR_VAL_32BIT}, + {&sTrainerCannotBattleSpeech, TRAINER_PARAM_CLEAR_VAL_32BIT}, + {&sTrainerABattleScriptRetAddr, TRAINER_PARAM_CLEAR_VAL_32BIT}, + {&sTrainerBattleEndScript, TRAINER_PARAM_LOAD_SCRIPT_RET_ADDR}, +}; + +static const struct TrainerBattleParameter sContinueScriptDoubleBattleParams[] = +{ + {&sTrainerBattleMode, TRAINER_PARAM_LOAD_VAL_8BIT}, + {&gTrainerBattleOpponent_A, TRAINER_PARAM_LOAD_VAL_16BIT}, + {&sTrainerMapObjectLocalId, TRAINER_PARAM_LOAD_VAL_16BIT}, + {&sTrainerAIntroSpeech, TRAINER_PARAM_LOAD_VAL_32BIT}, + {&sTrainerADefeatSpeech, TRAINER_PARAM_LOAD_VAL_32BIT}, + {&sTrainerVictorySpeech, TRAINER_PARAM_CLEAR_VAL_32BIT}, + {&sTrainerCannotBattleSpeech, TRAINER_PARAM_LOAD_VAL_32BIT}, + {&sTrainerABattleScriptRetAddr, TRAINER_PARAM_LOAD_VAL_32BIT}, + {&sTrainerBattleEndScript, TRAINER_PARAM_LOAD_SCRIPT_RET_ADDR}, +}; + +static const struct TrainerBattleParameter sTrainerBOrdinaryBattleParams[] = +{ + {&sTrainerBattleMode, TRAINER_PARAM_LOAD_VAL_8BIT}, + {&gTrainerBattleOpponent_B, TRAINER_PARAM_LOAD_VAL_16BIT}, + {&sTrainerMapObjectLocalId, TRAINER_PARAM_LOAD_VAL_16BIT}, + {&sTrainerBIntroSpeech, TRAINER_PARAM_LOAD_VAL_32BIT}, + {&sTrainerBDefeatSpeech, TRAINER_PARAM_LOAD_VAL_32BIT}, + {&sTrainerVictorySpeech, TRAINER_PARAM_CLEAR_VAL_32BIT}, + {&sTrainerCannotBattleSpeech, TRAINER_PARAM_CLEAR_VAL_32BIT}, + {&sTrainerBBattleScriptRetAddr, TRAINER_PARAM_CLEAR_VAL_32BIT}, + {&sTrainerBattleEndScript, TRAINER_PARAM_LOAD_SCRIPT_RET_ADDR}, +}; + +static const struct TrainerBattleParameter sTrainerBContinueScriptBattleParams[] = +{ + {&sTrainerBattleMode, TRAINER_PARAM_LOAD_VAL_8BIT}, + {&gTrainerBattleOpponent_B, TRAINER_PARAM_LOAD_VAL_16BIT}, + {&sTrainerMapObjectLocalId, TRAINER_PARAM_LOAD_VAL_16BIT}, + {&sTrainerBIntroSpeech, TRAINER_PARAM_LOAD_VAL_32BIT}, + {&sTrainerBDefeatSpeech, TRAINER_PARAM_LOAD_VAL_32BIT}, + {&sTrainerVictorySpeech, TRAINER_PARAM_CLEAR_VAL_32BIT}, + {&sTrainerCannotBattleSpeech, TRAINER_PARAM_CLEAR_VAL_32BIT}, + {&sTrainerBBattleScriptRetAddr, TRAINER_PARAM_LOAD_VAL_32BIT}, + {&sTrainerBattleEndScript, TRAINER_PARAM_LOAD_SCRIPT_RET_ADDR}, +}; + +const struct RematchTrainer gRematchTable[REMATCH_TABLE_ENTRIES] = +{ + {{0x0025, 0x0028, 0x0029, 0x002a, 0x002b}, 0x0000, 0x0021}, + {{0x02e1, 0x032c, 0x032d, 0x032e, 0x032f}, 0x0000, 0x0014}, + {{0x002c, 0x002f, 0x0030, 0x0031, 0x0032}, 0x0000, 0x001a}, + {{0x0039, 0x003c, 0x003d, 0x003e, 0x003f}, 0x0000, 0x0018}, + {{0x0040, 0x0043, 0x0044, 0x0045, 0x0046}, 0x0000, 0x0018}, + {{0x02af, 0x02b0, 0x02b1, 0x02b2, 0x02b3}, 0x0000, 0x0027}, + {{0x02ff, 0x033c, 0x033d, 0x033e, 0x033f}, 0x0000, 0x0024}, + {{0x005e, 0x0065, 0x0066, 0x0067, 0x0068}, 0x0000, 0x001a}, + {{0x004e, 0x0054, 0x0055, 0x0056, 0x0057}, 0x0000, 0x001a}, + {{0x006c, 0x006e, 0x006f, 0x0070, 0x0071}, 0x0018, 0x0014}, + {{0x0072, 0x0078, 0x0079, 0x007a, 0x007b}, 0x0000, 0x0013}, + {{0x0090, 0x034c, 0x034d, 0x034e, 0x034f}, 0x0018, 0x0038}, + {{0x007f, 0x0084, 0x0085, 0x0086, 0x0087}, 0x0000, 0x0024}, + {{0x0088, 0x008b, 0x008c, 0x008d, 0x008e}, 0x0000, 0x0013}, + {{0x008f, 0x0093, 0x0094, 0x0095, 0x0096}, 0x0000, 0x001d}, + {{0x009b, 0x00af, 0x00b0, 0x00b1, 0x00b2}, 0x0000, 0x0016}, + {{0x00b7, 0x00b8, 0x00b9, 0x00ba, 0x00bb}, 0x0000, 0x001e}, + {{0x02a0, 0x0338, 0x0339, 0x033a, 0x033b}, 0x0000, 0x002a}, + {{0x00c3, 0x0340, 0x0341, 0x0342, 0x0343}, 0x0000, 0x0026}, + {{0x00c4, 0x00c5, 0x00c6, 0x00c7, 0x00c8}, 0x0000, 0x0021}, + {{0x00ce, 0x00cf, 0x00d0, 0x00d1, 0x00d2}, 0x0000, 0x001d}, + {{0x00d8, 0x00db, 0x00dc, 0x00dd, 0x00de}, 0x0018, 0x000d}, + {{0x02a9, 0x02aa, 0x02ab, 0x02ac, 0x02ad}, 0x0018, 0x0001}, + {{0x00e2, 0x00e4, 0x00e5, 0x00e6, 0x00e7}, 0x0000, 0x0023}, + {{0x00ee, 0x00ef, 0x00f0, 0x00f1, 0x00f2}, 0x0000, 0x0026}, + {{0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd}, 0x0000, 0x0026}, + {{0x00fe, 0x0101, 0x0102, 0x0103, 0x0104}, 0x0000, 0x0024}, + {{0x0118, 0x011a, 0x011b, 0x011c, 0x011d}, 0x0000, 0x001f}, + {{0x0111, 0x0114, 0x0115, 0x0116, 0x0117}, 0x0000, 0x001f}, + {{0x011f, 0x0120, 0x0121, 0x0122, 0x0123}, 0x0000, 0x0020}, + {{0x012e, 0x012f, 0x0130, 0x0131, 0x0132}, 0x0000, 0x0019}, + {{0x0125, 0x0127, 0x0128, 0x0129, 0x012a}, 0x0000, 0x0012}, + {{0x0133, 0x0134, 0x0135, 0x0136, 0x0137}, 0x0000, 0x001e}, + {{0x0139, 0x013a, 0x013b, 0x013c, 0x013d}, 0x0018, 0x000c}, + {{0x013e, 0x0148, 0x0149, 0x014a, 0x014b}, 0x0000, 0x0011}, + {{0x0153, 0x015a, 0x015b, 0x015c, 0x015d}, 0x0000, 0x0015}, + {{0x0178, 0x017b, 0x017c, 0x017d, 0x017e}, 0x0000, 0x002b}, + {{0x0171, 0x0172, 0x0173, 0x0174, 0x0175}, 0x0000, 0x0020}, + {{0x0166, 0x0168, 0x0169, 0x016a, 0x016b}, 0x0000, 0x0019}, + {{0x016c, 0x016d, 0x016e, 0x016f, 0x0170}, 0x0000, 0x0020}, + {{0x0182, 0x0184, 0x0185, 0x0186, 0x0187}, 0x0000, 0x002b}, + {{0x0161, 0x0162, 0x0163, 0x0164, 0x0165}, 0x0000, 0x0019}, + {{0x0179, 0x0334, 0x0335, 0x0336, 0x0337}, 0x0000, 0x0029}, + {{0x0188, 0x0189, 0x018a, 0x018b, 0x018c}, 0x0018, 0x0001}, + {{0x0196, 0x0199, 0x019a, 0x019b, 0x019c}, 0x0000, 0x0023}, + {{0x01a3, 0x01a5, 0x01a6, 0x01a7, 0x01a8}, 0x0000, 0x001c}, + {{0x01ab, 0x01ae, 0x01af, 0x01b0, 0x01b1}, 0x0000, 0x001e}, + {{0x01b2, 0x01b5, 0x01b6, 0x01b7, 0x01b8}, 0x0000, 0x001c}, + {{0x01c1, 0x01d1, 0x01d2, 0x01d3, 0x01d4}, 0x0000, 0x0027}, + {{0x01da, 0x01dd, 0x01de, 0x01df, 0x01e0}, 0x0018, 0x000d}, + {{0x01e1, 0x01e2, 0x01e7, 0x01e8, 0x01e9}, 0x0000, 0x0012}, + {{0x01ec, 0x01f1, 0x01f2, 0x01f3, 0x01f4}, 0x0000, 0x0028}, + {{0x02e4, 0x0330, 0x0331, 0x0332, 0x0333}, 0x0000, 0x0017}, + {{0x0200, 0x0203, 0x0204, 0x0205, 0x0206}, 0x0000, 0x0019}, + {{0x0221, 0x0224, 0x0225, 0x0226, 0x0227}, 0x0000, 0x0020}, + {{0x021a, 0x021d, 0x021e, 0x021f, 0x0220}, 0x0000, 0x0020}, + {{0x0009, 0x0348, 0x0349, 0x034a, 0x034b}, 0x0018, 0x0011}, + {{0x022f, 0x0232, 0x0233, 0x0234, 0x0235}, 0x0000, 0x0022}, + {{0x0228, 0x022b, 0x022c, 0x022d, 0x022e}, 0x0000, 0x0022}, + {{0x025c, 0x025f, 0x0260, 0x0261, 0x0262}, 0x0000, 0x0013}, + {{0x026d, 0x026e, 0x026f, 0x0270, 0x0271}, 0x0018, 0x000b}, + {{0x0273, 0x027c, 0x027d, 0x027e, 0x027f}, 0x0000, 0x001b}, + {{0x0001, 0x0344, 0x0345, 0x0346, 0x0347}, 0x0018, 0x000c}, + {{0x0282, 0x0283, 0x0284, 0x0285, 0x0286}, 0x0018, 0x003e}, + {{0x0291, 0x0292, 0x0293, 0x0294, 0x0294}, 0x0018, 0x002b}, + {{0x0109, 0x0302, 0x0303, 0x0304, 0x0305}, 0x0000, 0x0003}, + {{0x010a, 0x0306, 0x0307, 0x0308, 0x0309}, 0x0000, 0x000b}, + {{0x010b, 0x030a, 0x030b, 0x030c, 0x030d}, 0x0000, 0x0002}, + {{0x010c, 0x030e, 0x030f, 0x0310, 0x0311}, 0x0000, 0x000c}, + {{0x010d, 0x0312, 0x0313, 0x0314, 0x0315}, 0x0000, 0x0000}, + {{0x010e, 0x0316, 0x0317, 0x0318, 0x0319}, 0x0000, 0x0004}, + {{0x010f, 0x031a, 0x031b, 0x031c, 0x031d}, 0x0000, 0x0006}, + {{0x0110, 0x031e, 0x031f, 0x0320, 0x0321}, 0x0000, 0x0007}, + {{0x0105, 0x0105, 0x0105, 0x0105, 0x0105}, 0x0000, 0x0008}, + {{0x0106, 0x0106, 0x0106, 0x0106, 0x0106}, 0x0000, 0x0008}, + {{0x0107, 0x0107, 0x0107, 0x0107, 0x0107}, 0x0000, 0x0008}, + {{0x0108, 0x0108, 0x0108, 0x0108, 0x0108}, 0x0000, 0x0008}, + {{0x014f, 0x014f, 0x014f, 0x014f, 0x014f}, 0x0000, 0x0008}, +}; + +static const u16 sBadgeFlags[8] = +{ + FLAG_BADGE01_GET, FLAG_BADGE02_GET, FLAG_BADGE03_GET, FLAG_BADGE04_GET, + FLAG_BADGE05_GET, FLAG_BADGE06_GET, FLAG_BADGE07_GET, FLAG_BADGE08_GET, }; #define tState data[0] #define tTransition data[1] -void Task_BattleStart(u8 taskId) +static void Task_BattleStart(u8 taskId) { s16 *data = gTasks[taskId].data; @@ -146,7 +377,7 @@ void Task_BattleStart(u8 taskId) } } -void CreateBattleStartTask(u8 transition, u16 song) +static void CreateBattleStartTask(u8 transition, u16 song) { u8 taskId = CreateTask(Task_BattleStart, 1); @@ -170,7 +401,7 @@ void BattleSetup_StartBattlePikeWildBattle(void) DoBattlePikeWildBattle(); } -void DoStandardWildBattle(void) +static void DoStandardWildBattle(void) { ScriptContext2_Enable(); FreezeMapObjects(); @@ -203,7 +434,7 @@ void BattleSetup_StartRoamerBattle(void) sub_80B1218(); } -void DoSafariBattle(void) +static void DoSafariBattle(void) { ScriptContext2_Enable(); FreezeMapObjects(); @@ -213,7 +444,7 @@ void DoSafariBattle(void) CreateBattleStartTask(GetWildBattleTransition(), 0); } -void DoBattlePikeWildBattle(void) +static void DoBattlePikeWildBattle(void) { ScriptContext2_Enable(); FreezeMapObjects(); @@ -227,7 +458,7 @@ void DoBattlePikeWildBattle(void) sub_80B1218(); } -void DoTrainerBattle(void) +static void DoTrainerBattle(void) { CreateBattleStartTask(GetTrainerBattleTransition(), 0); IncrementGameStat(GAME_STAT_TOTAL_BATTLES); @@ -235,7 +466,7 @@ void DoTrainerBattle(void) sub_80B1234(); } -void sub_80B0828(void) +static void sub_80B0828(void) { if (InBattlePyramid()) CreateBattleStartTask(sub_80B100C(10), 0); @@ -370,7 +601,7 @@ void StartRegiBattle(void) sub_80B1218(); } -void CB2_EndWildBattle(void) +static void CB2_EndWildBattle(void) { CpuFill16(0, (void*)(BG_PLTT), BG_PLTT_SIZE); ResetOamRange(0, 128); @@ -386,7 +617,7 @@ void CB2_EndWildBattle(void) } } -void CB2_EndScriptedWildBattle(void) +static void CB2_EndScriptedWildBattle(void) { CpuFill16(0, (void*)(BG_PLTT), BG_PLTT_SIZE); ResetOamRange(0, 128); @@ -462,7 +693,7 @@ u8 BattleSetup_GetTerrainId(void) return BATTLE_TERRAIN_PLAIN; } -u8 GetBattleTransitionTypeByMap(void) +static u8 GetBattleTransitionTypeByMap(void) { u16 tileBehavior; s16 x, y; @@ -486,7 +717,7 @@ u8 GetBattleTransitionTypeByMap(void) return B_TRANSITION_BIG_POKEBALL; } -u16 GetSumOfPlayerPartyLevel(u8 numMons) +static u16 GetSumOfPlayerPartyLevel(u8 numMons) { u8 sum = 0; int i; @@ -505,7 +736,7 @@ u16 GetSumOfPlayerPartyLevel(u8 numMons) return sum; } -u8 GetSumOfEnemyPartyLevel(u16 opponentId, u8 numMons) +static u8 GetSumOfEnemyPartyLevel(u16 opponentId, u8 numMons) { u8 i; u8 sum; @@ -555,7 +786,7 @@ u8 GetSumOfEnemyPartyLevel(u16 opponentId, u8 numMons) return sum; } -u8 GetWildBattleTransition(void) +static u8 GetWildBattleTransition(void) { u8 transitionType = GetBattleTransitionTypeByMap(); u8 enemyLevel = GetMonData(&gEnemyParty[0], MON_DATA_LEVEL); @@ -577,7 +808,7 @@ u8 GetWildBattleTransition(void) } } -u8 GetTrainerBattleTransition(void) +static u8 GetTrainerBattleTransition(void) { u8 minPartyCount; u8 transitionType; @@ -585,7 +816,7 @@ u8 GetTrainerBattleTransition(void) u8 playerLevel; if (gTrainerBattleOpponent_A == SECRET_BASE_OPPONENT) - return B_TRANSITION_STEVEN; + return B_TRANSITION_CHAMPION; if (gTrainers[gTrainerBattleOpponent_A].trainerClass == CLASS_ELITE_FOUR) { @@ -597,11 +828,11 @@ u8 GetTrainerBattleTransition(void) return B_TRANSITION_GLACIA; if (gTrainerBattleOpponent_A == TRAINER_ID_DRAKE) return B_TRANSITION_DRAKE; - return B_TRANSITION_STEVEN; + return B_TRANSITION_CHAMPION; } if (gTrainers[gTrainerBattleOpponent_A].trainerClass == CLASS_CHAMPION) - return B_TRANSITION_STEVEN; + return B_TRANSITION_CHAMPION; if (gTrainers[gTrainerBattleOpponent_A].trainerClass == CLASS_TEAM_MAGMA || gTrainers[gTrainerBattleOpponent_A].trainerClass == CLASS_MAGMA_LEADER @@ -681,7 +912,7 @@ void ChooseStarter(void) gMain.savedCallback = CB2_GiveStarter; } -void CB2_GiveStarter(void) +static void CB2_GiveStarter(void) { u16 starterMon; @@ -694,7 +925,7 @@ void CB2_GiveStarter(void) BattleTransition_Start(B_TRANSITION_BLUR); } -void CB2_StartFirstBattle(void) +static void CB2_StartFirstBattle(void) { UpdatePaletteFade(); RunTasks(); @@ -714,51 +945,51 @@ void CB2_StartFirstBattle(void) } } -void CB2_EndFirstBattle(void) +static void CB2_EndFirstBattle(void) { Overworld_ClearSavedMusic(); SetMainCallback2(c2_exit_to_overworld_1_continue_scripts_restart_music); } -void sub_80B1218(void) +static void sub_80B1218(void) { if (GetGameStat(GAME_STAT_WILD_BATTLES) % 60 == 0) sub_81DA57C(); } -void sub_80B1234(void) +static void sub_80B1234(void) { if (GetGameStat(GAME_STAT_TRAINER_BATTLES) % 20 == 0) sub_81DA57C(); } // why not just use the macros? maybe its because they didnt want to uncast const every time? -u32 TrainerBattleLoadArg32(const u8 *ptr) +static u32 TrainerBattleLoadArg32(const u8 *ptr) { return T1_READ_32(ptr); } -u16 TrainerBattleLoadArg16(const u8 *ptr) +static u16 TrainerBattleLoadArg16(const u8 *ptr) { return T1_READ_16(ptr); } -u8 TrainerBattleLoadArg8(const u8 *ptr) +static u8 TrainerBattleLoadArg8(const u8 *ptr) { return T1_READ_8(ptr); } -u16 GetTrainerAFlag(void) +static u16 GetTrainerAFlag(void) { return FLAG_TRAINER_FLAG_START + gTrainerBattleOpponent_A; } -u16 GetTrainerBFlag(void) +static u16 GetTrainerBFlag(void) { return FLAG_TRAINER_FLAG_START + gTrainerBattleOpponent_B; } -bool32 IsPlayerDefeated(u32 battleOutcome) +static bool32 IsPlayerDefeated(u32 battleOutcome) { switch (battleOutcome) { @@ -782,23 +1013,872 @@ void ResetTrainerOpponentIds(void) gTrainerBattleOpponent_B = 0; } -void InitTrainerBattleVariables(void) +static void InitTrainerBattleVariables(void) { sTrainerBattleMode = 0; if (gApproachingTrainerId == 0) { sTrainerAIntroSpeech = NULL; sTrainerADefeatSpeech = NULL; - gUnknown_02038BF0 = NULL; + sTrainerABattleScriptRetAddr = NULL; } else { sTrainerBIntroSpeech = NULL; sTrainerBDefeatSpeech = NULL; - gUnknown_02038BF4 = NULL; + sTrainerBBattleScriptRetAddr = NULL; } sTrainerMapObjectLocalId = 0; sTrainerVictorySpeech = NULL; sTrainerCannotBattleSpeech = NULL; - gUnknown_02038BEC = NULL; + sTrainerBattleEndScript = NULL; +} + +static inline void SetU8(void *ptr, u8 value) +{ + *(u8*)(ptr) = value; +} + +static inline void SetU16(void *ptr, u16 value) +{ + *(u16*)(ptr) = value; +} + +static inline void SetU32(void *ptr, u32 value) +{ + *(u32*)(ptr) = value; +} + +static inline void SetPtr(const void *ptr, const void* value) +{ + *(const void**)(ptr) = value; +} + +static void TrainerBattleLoadArgs(const struct TrainerBattleParameter *specs, const u8 *data) +{ + while (1) + { + switch (specs->ptrType) + { + case TRAINER_PARAM_LOAD_VAL_8BIT: + SetU8(specs->varPtr, TrainerBattleLoadArg8(data)); + data += 1; + break; + case TRAINER_PARAM_LOAD_VAL_16BIT: + SetU16(specs->varPtr, TrainerBattleLoadArg16(data)); + data += 2; + break; + case TRAINER_PARAM_LOAD_VAL_32BIT: + SetU32(specs->varPtr, TrainerBattleLoadArg32(data)); + data += 4; + break; + case TRAINER_PARAM_CLEAR_VAL_8BIT: + SetU8(specs->varPtr, 0); + break; + case TRAINER_PARAM_CLEAR_VAL_16BIT: + SetU16(specs->varPtr, 0); + break; + case TRAINER_PARAM_CLEAR_VAL_32BIT: + SetU32(specs->varPtr, 0); + break; + case TRAINER_PARAM_LOAD_SCRIPT_RET_ADDR: + SetPtr(specs->varPtr, data); + return; + } + specs++; + } +} + +void SetMapVarsToTrainer(void) +{ + if (sTrainerMapObjectLocalId != 0) + { + gSpecialVar_LastTalked = sTrainerMapObjectLocalId; + gSelectedMapObject = GetFieldObjectIdByLocalIdAndMap(sTrainerMapObjectLocalId, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup); + } +} + +const u8 *BattleSetup_ConfigureTrainerBattle(const u8 *data) +{ + InitTrainerBattleVariables(); + sTrainerBattleMode = TrainerBattleLoadArg8(data); + + switch (sTrainerBattleMode) + { + case 3: + TrainerBattleLoadArgs(sOrdinaryNoIntroBattleParams, data); + return EventScript_2713C2; + case 4: + TrainerBattleLoadArgs(sDoubleBattleParams, data); + SetMapVarsToTrainer(); + return EventScript_TryDoDoubleTrainerBattle; + case 2: + if (gApproachingTrainerId == 0) + { + TrainerBattleLoadArgs(sContinueScriptBattleParams, data); + SetMapVarsToTrainer(); + } + else + { + TrainerBattleLoadArgs(sTrainerBContinueScriptBattleParams, data); + } + return EventScript_271362; + case 1: + TrainerBattleLoadArgs(sContinueScriptBattleParams, data); + SetMapVarsToTrainer(); + return EventScript_271362; + case 6: + case 8: + TrainerBattleLoadArgs(sContinueScriptDoubleBattleParams, data); + SetMapVarsToTrainer(); + return EventScript_TryDoDoubleTrainerBattle; + case 7: + TrainerBattleLoadArgs(sDoubleBattleParams, data); + SetMapVarsToTrainer(); + gTrainerBattleOpponent_A = GetRematchTrainerId(gTrainerBattleOpponent_A); + return EventScript_TryDoDoubleRematchBattle; + case 5: + TrainerBattleLoadArgs(sOrdinaryBattleParams, data); + SetMapVarsToTrainer(); + gTrainerBattleOpponent_A = GetRematchTrainerId(gTrainerBattleOpponent_A); + return EventScript_2713D1; + case 9: + if (gApproachingTrainerId == 0) + { + TrainerBattleLoadArgs(sOrdinaryBattleParams, data); + SetMapVarsToTrainer(); + gTrainerBattleOpponent_A = sub_81A9AA8(gSpecialVar_LastTalked); + } + else + { + TrainerBattleLoadArgs(sTrainerBOrdinaryBattleParams, data); + gTrainerBattleOpponent_B = sub_81A9AA8(gSpecialVar_LastTalked); + } + return EventScript_271362; + case 10: + TrainerBattleLoadArgs(sOrdinaryBattleParams, data); + return NULL; + case 11: + TrainerBattleLoadArgs(sTrainerBOrdinaryBattleParams, data); + return NULL; + case 12: + if (gApproachingTrainerId == 0) + { + TrainerBattleLoadArgs(sOrdinaryBattleParams, data); + SetMapVarsToTrainer(); + gTrainerBattleOpponent_A = sub_81D6180(gSpecialVar_LastTalked); + } + else + { + TrainerBattleLoadArgs(sTrainerBOrdinaryBattleParams, data); + gTrainerBattleOpponent_B = sub_81D6180(gSpecialVar_LastTalked); + } + return EventScript_271362; + default: + if (gApproachingTrainerId == 0) + { + TrainerBattleLoadArgs(sOrdinaryBattleParams, data); + SetMapVarsToTrainer(); + } + else + { + TrainerBattleLoadArgs(sTrainerBOrdinaryBattleParams, data); + } + return EventScript_271362; + } +} + +void ConfigureAndSetUpOneTrainerBattle(u8 trainerMapObjId, const u8 *trainerScript) +{ + gSelectedMapObject = trainerMapObjId; + gSpecialVar_LastTalked = gMapObjects[trainerMapObjId].localId; + BattleSetup_ConfigureTrainerBattle(trainerScript + 1); + ScriptContext1_SetupScript(EventScript_271354); + ScriptContext2_Enable(); +} + +void ConfigureTwoTrainersBattle(u8 trainerMapObjId, const u8 *trainerScript) +{ + gSelectedMapObject = trainerMapObjId; + gSpecialVar_LastTalked = gMapObjects[trainerMapObjId].localId; + BattleSetup_ConfigureTrainerBattle(trainerScript + 1); +} + +void SetUpTwoTrainersBattle(void) +{ + ScriptContext1_SetupScript(EventScript_271354); + ScriptContext2_Enable(); +} + +bool32 GetTrainerFlagFromScriptPointer(const u8 *data) +{ + u32 flag = TrainerBattleLoadArg16(data + 2); + return FlagGet(FLAG_TRAINER_FLAG_START + flag); +} + +void sub_80B16D8(void) +{ + struct MapObject *mapObject = &gMapObjects[gSelectedMapObject]; + + npc_set_running_behaviour_etc(mapObject, npc_running_behaviour_by_direction(mapObject->mapobj_unk_18)); +} + +u8 GetTrainerBattleMode(void) +{ + return sTrainerBattleMode; +} + +bool8 GetTrainerFlag(void) +{ + if (InBattlePyramid()) + return GetBattlePyramidTrainerFlag(gSelectedMapObject); + else if (InTrainerHill()) + return GetTrainerHillTrainerFlag(gSelectedMapObject); + else + return FlagGet(GetTrainerAFlag()); +} + +static void SetBattledTrainersFlags(void) +{ + if (gTrainerBattleOpponent_B != 0) + FlagSet(GetTrainerBFlag()); + FlagSet(GetTrainerAFlag()); +} + +static void SetBattledTrainerFlag(void) +{ + FlagSet(GetTrainerAFlag()); +} + +bool8 HasTrainerBeenFought(u16 trainerId) +{ + return FlagGet(FLAG_TRAINER_FLAG_START + trainerId); +} + +void SetTrainerFlag(u16 trainerId) +{ + FlagSet(FLAG_TRAINER_FLAG_START + trainerId); +} + +void ClearTrainerFlag(u16 trainerId) +{ + FlagClear(FLAG_TRAINER_FLAG_START + trainerId); +} + +void BattleSetup_StartTrainerBattle(void) +{ + if (gNoOfApproachingTrainers == 2) + gBattleTypeFlags = (BATTLE_TYPE_DOUBLE | BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_TRAINER); + else + gBattleTypeFlags = (BATTLE_TYPE_TRAINER); + + if (InBattlePyramid()) + { + VarSet(VAR_0x400E, 0); + gBattleTypeFlags |= BATTLE_TYPE_PYRAMID; + + if (gNoOfApproachingTrainers == 2) + { + sub_816306C(1); + ZeroMonData(&gEnemyParty[1]); + ZeroMonData(&gEnemyParty[2]); + ZeroMonData(&gEnemyParty[4]); + ZeroMonData(&gEnemyParty[5]); + } + else + { + sub_8163048(1); + ZeroMonData(&gEnemyParty[1]); + ZeroMonData(&gEnemyParty[2]); + } + + sub_81A9B04(); + } + else if (sub_81D5C18()) + { + gBattleTypeFlags |= BATTLE_TYPE_x4000000; + + if (gNoOfApproachingTrainers == 2) + sub_81D639C(); + else + sub_81D6384(); + + sub_81D61E8(); + } + + sNoOfPossibleTrainerRetScripts = gNoOfApproachingTrainers; + gNoOfApproachingTrainers = 0; + sShouldCheckTrainerBScript = FALSE; + gUnknown_03006080 = 0; + gMain.savedCallback = CB2_EndTrainerBattle; + + if (InBattlePyramid() || sub_81D5C18()) + sub_80B0828(); + else + DoTrainerBattle(); + + ScriptContext1_Stop(); +} + +static void CB2_EndTrainerBattle(void) +{ + if (gTrainerBattleOpponent_A == SECRET_BASE_OPPONENT) + { + SetMainCallback2(c2_exit_to_overworld_1_continue_scripts_restart_music); + } + else if (IsPlayerDefeated(gBattleOutcome) == TRUE) + { + if (InBattlePyramid() || sub_81D5C18()) + SetMainCallback2(c2_exit_to_overworld_1_continue_scripts_restart_music); + else + SetMainCallback2(CB2_WhiteOut); + } + else + { + SetMainCallback2(c2_exit_to_overworld_1_continue_scripts_restart_music); + if (!InBattlePyramid() && !sub_81D5C18()) + { + RegisterTrainerInMatchCall(); + SetBattledTrainersFlags(); + } + } +} + +static void CB2_EndRematchBattle(void) +{ + if (gTrainerBattleOpponent_A == SECRET_BASE_OPPONENT) + { + SetMainCallback2(c2_exit_to_overworld_1_continue_scripts_restart_music); + } + else if (IsPlayerDefeated(gBattleOutcome) == TRUE) + { + SetMainCallback2(CB2_WhiteOut); + } + else + { + SetMainCallback2(c2_exit_to_overworld_1_continue_scripts_restart_music); + RegisterTrainerInMatchCall(); + SetBattledTrainersFlags(); + HandleRematchVarsOnBattleEnd(); + } +} + +void BattleSetup_StartRematchBattle(void) +{ + gBattleTypeFlags = BATTLE_TYPE_TRAINER; + gMain.savedCallback = CB2_EndRematchBattle; + DoTrainerBattle(); + ScriptContext1_Stop(); +} + +void ShowTrainerIntroSpeech(void) +{ + if (InBattlePyramid()) + { + if (gNoOfApproachingTrainers == 0 || gNoOfApproachingTrainers == 1) + sub_81A9EDC(sub_81A9AA8(gSpecialVar_LastTalked)); + else + sub_81A9EDC(sub_81A9AA8(gMapObjects[gApproachingTrainers[gApproachingTrainerId].mapObjectId].localId)); + + sub_80982B8(); + } + else if (sub_81D5C18()) + { + if (gNoOfApproachingTrainers == 0 || gNoOfApproachingTrainers == 1) + sub_81D572C(2, sub_81D6180(gSpecialVar_LastTalked)); + else + sub_81D572C(2, sub_81D6180(gMapObjects[gApproachingTrainers[gApproachingTrainerId].mapObjectId].localId)); + + sub_80982B8(); + } + else + { + ShowFieldMessage(GetIntroSpeechOfApproachingTrainer()); + } +} + +const u8 *BattleSetup_GetScriptAddrAfterBattle(void) +{ + if (sTrainerBattleEndScript != NULL) + return sTrainerBattleEndScript; + else + return EventScript_TestSignpostMsg; +} + +const u8 *BattleSetup_GetTrainerPostBattleScript(void) +{ + if (sShouldCheckTrainerBScript) + { + sShouldCheckTrainerBScript = FALSE; + if (sTrainerBBattleScriptRetAddr != NULL) + { + gUnknown_03006080 = 1; + return sTrainerBBattleScriptRetAddr; + } + } + else + { + if (sTrainerABattleScriptRetAddr != NULL) + { + gUnknown_03006080 = 0; + return sTrainerABattleScriptRetAddr; + } + } + + return EventScript_TryGetTrainerScript; +} + +void ShowTrainerCantBattleSpeech(void) +{ + ShowFieldMessage(GetTrainerCantBattleSpeech()); +} + +void SetUpTrainerEncounterMusic(void) +{ + u16 trainerId; + u16 music; + + if (gApproachingTrainerId == 0) + trainerId = gTrainerBattleOpponent_A; + else + trainerId = gTrainerBattleOpponent_B; + + if (sTrainerBattleMode != TRAINER_BATTLE_CONTINUE_SCRIPT_NO_MUSIC + && sTrainerBattleMode != TRAINER_BATTLE_CONTINUE_SCRIPT_DOUBLE_NO_MUSIC) + { + switch (GetTrainerEncounterMusicId(trainerId)) + { + case TRAINER_ENCOUNTER_MUSIC_MALE: + music = BGM_BOYEYE; + break; + case TRAINER_ENCOUNTER_MUSIC_FEMALE: + music = BGM_GIRLEYE; + break; + case TRAINER_ENCOUNTER_MUSIC_GIRL: + music = BGM_SYOUJOEYE; + break; + case TRAINER_ENCOUNTER_MUSIC_INTENSE: + music = BGM_HAGESHII; + break; + case TRAINER_ENCOUNTER_MUSIC_COOL: + music = BGM_KAKKOII; + break; + case TRAINER_ENCOUNTER_MUSIC_AQUA: + music = BGM_AQA_0; + break; + case TRAINER_ENCOUNTER_MUSIC_MAGMA: + music = BGM_MGM0; + break; + case TRAINER_ENCOUNTER_MUSIC_SWIMMER: + music = BGM_SWIMEYE; + break; + case TRAINER_ENCOUNTER_MUSIC_TWINS: + music = BGM_HUTAGO; + break; + case TRAINER_ENCOUNTER_MUSIC_ELITE_FOUR: + music = BGM_SITENNOU; + break; + case TRAINER_ENCOUNTER_MUSIC_HIKER: + music = BGM_YAMA_EYE; + break; + case TRAINER_ENCOUNTER_MUSIC_INTERVIEWER: + music = BGM_INTER_V; + break; + case TRAINER_ENCOUNTER_MUSIC_RICH: + music = BGM_TEST; + break; + default: + music = BGM_AYASII; + } + PlayNewMapMusic(music); + } +} + +static const u8 *ReturnEmptyStringIfNull(const u8 *string) +{ + if (string == NULL) + return gText_EmptyString2; + else + return string; +} + +static const u8 *GetIntroSpeechOfApproachingTrainer(void) +{ + if (gApproachingTrainerId == 0) + return ReturnEmptyStringIfNull(sTrainerAIntroSpeech); + else + return ReturnEmptyStringIfNull(sTrainerBIntroSpeech); +} + +const u8 *GetTrainerALoseText(void) +{ + const u8 *string; + + if (gTrainerBattleOpponent_A == SECRET_BASE_OPPONENT) + string = GetSecretBaseTrainerLoseText(); + else + string = sTrainerADefeatSpeech; + + StringExpandPlaceholders(gStringVar4, ReturnEmptyStringIfNull(string)); + return gStringVar4; +} + +const u8 *GetTrainerBLoseText(void) +{ + StringExpandPlaceholders(gStringVar4, ReturnEmptyStringIfNull(sTrainerBDefeatSpeech)); + return gStringVar4; +} + +const u8 *GetTrainerWonSpeech(void) +{ + return ReturnEmptyStringIfNull(sTrainerVictorySpeech); +} + +static const u8 *GetTrainerCantBattleSpeech(void) +{ + return ReturnEmptyStringIfNull(sTrainerCannotBattleSpeech); +} + +static s32 FirstBattleTrainerIdToRematchTableId(const struct RematchTrainer *table, u16 trainerId) +{ + s32 i; + + for (i = 0; i < REMATCH_TABLE_ENTRIES; i++) + { + if (table[i].trainerIds[0] == trainerId) + return i; + } + + return -1; +} + +static s32 TrainerIdToRematchTableId(const struct RematchTrainer *table, u16 trainerId) +{ + s32 i, j; + + for (i = 0; i < REMATCH_TABLE_ENTRIES; i++) + { + for (j = 0; j < REMATCHES_COUNT; j++) + { + if (table[i].trainerIds[j] == 0) + break; + if (table[i].trainerIds[j] == trainerId) + return i; + } + } + + return -1; +} + +static bool32 sub_80B1D94(s32 rematchTableId) +{ + if (rematchTableId >= REMATCH_ELITE_FOUR_ENTRIES) + return TRUE; + else if (rematchTableId == REMATCH_WALLY_ENTRY) + return (FlagGet(FLAG_7E) == FALSE); + else + return FALSE; +} + +static void SetRematchIdForTrainer(const struct RematchTrainer *table, u32 tableId) +{ + s32 i; + + for (i = 1; i < REMATCHES_COUNT; i++) + { + u16 trainerId = table[tableId].trainerIds[i]; + + if (trainerId == 0) + break; + if (!HasTrainerBeenFought(trainerId)) + break; + } + + gSaveBlock1Ptr->trainerRematches[tableId] = i; +} + +static bool32 UpdateRandomTrainerRematches(const struct RematchTrainer *table, u16 mapGroup, u16 mapNum) +{ + s32 i; + bool32 ret = FALSE; + + for (i = 0; i <= REMATCH_WALLY_ENTRY; i++) + { + if (table[i].mapGroup == mapGroup && table[i].mapNum == mapNum && !sub_80B1D94(i)) + { + if (gSaveBlock1Ptr->trainerRematches[i] != 0) + { + // Trainer already wants a rematch. Don't bother updating it + ret = TRUE; + } + else if (FlagGet(FLAG_MATCH_CALL_REGISTERED + i) + && (Random() % 100) <= 30) // 31% chance of getting a rematch + { + SetRematchIdForTrainer(table, i); + ret = TRUE; + } + } + } + + return ret; +} + +void UpdateRematchIfDefeated(s32 rematchTableId) +{ + if (HasTrainerBeenFought(gRematchTable[rematchTableId].trainerIds[0]) == TRUE) + SetRematchIdForTrainer(gRematchTable, rematchTableId); +} + +static bool32 DoesSomeoneWantRematchIn_(const struct RematchTrainer *table, u16 mapGroup, u16 mapNum) +{ + s32 i; + + for (i = 0; i < REMATCH_TABLE_ENTRIES; i++) + { + if (table[i].mapGroup == mapGroup && table[i].mapNum == mapNum && gSaveBlock1Ptr->trainerRematches[i] != 0) + return TRUE; + } + + return FALSE; +} + +static bool32 IsRematchTrainerIn_(const struct RematchTrainer *table, u16 mapGroup, u16 mapNum) +{ + s32 i; + + for (i = 0; i < REMATCH_TABLE_ENTRIES; i++) + { + if (table[i].mapGroup == mapGroup && table[i].mapNum == mapNum) + return TRUE; + } + + return FALSE; +} + +static bool8 IsFirstTrainerIdReadyForRematch(const struct RematchTrainer *table, u16 firstBattleTrainerId) +{ + s32 tableId = FirstBattleTrainerIdToRematchTableId(table, firstBattleTrainerId); + + if (tableId == -1) + return FALSE; + if (tableId >= 100) + return FALSE; + if (gSaveBlock1Ptr->trainerRematches[tableId] == 0) + return FALSE; + + return TRUE; +} + +static bool8 IsTrainerReadyForRematch_(const struct RematchTrainer *table, u16 trainerId) +{ + s32 tableId = TrainerIdToRematchTableId(table, trainerId); + + if (tableId == -1) + return FALSE; + if (tableId >= 100) + return FALSE; + if (gSaveBlock1Ptr->trainerRematches[tableId] == 0) + return FALSE; + + return TRUE; +} + +static u16 GetRematchTrainerIdFromTable(const struct RematchTrainer *table, u16 firstBattleTrainerId) +{ + const struct RematchTrainer *trainerEntry; + s32 i; + s32 tableId = FirstBattleTrainerIdToRematchTableId(table, firstBattleTrainerId); + + if (tableId == -1) + return FALSE; + + trainerEntry = &table[tableId]; + for (i = 1; i < REMATCHES_COUNT; i++) + { + if (trainerEntry->trainerIds[i] == 0) // previous entry was this trainer's last one + return trainerEntry->trainerIds[i - 1]; + if (!HasTrainerBeenFought(trainerEntry->trainerIds[i])) + return trainerEntry->trainerIds[i]; + } + + return trainerEntry->trainerIds[REMATCHES_COUNT - 1]; // already beaten at max stage +} + +static u16 GetLastBeatenRematchTrainerIdFromTable(const struct RematchTrainer *table, u16 firstBattleTrainerId) +{ + const struct RematchTrainer *trainerEntry; + s32 i; + s32 tableId = FirstBattleTrainerIdToRematchTableId(table, firstBattleTrainerId); + + if (tableId == -1) + return FALSE; + + trainerEntry = &table[tableId]; + for (i = 1; i < REMATCHES_COUNT; i++) + { + if (trainerEntry->trainerIds[i] == 0) // previous entry was this trainer's last one + return trainerEntry->trainerIds[i - 1]; + if (!HasTrainerBeenFought(trainerEntry->trainerIds[i])) + return trainerEntry->trainerIds[i - 1]; + } + + return trainerEntry->trainerIds[REMATCHES_COUNT - 1]; // already beaten at max stage +} + +static void ClearTrainerWantRematchState(const struct RematchTrainer *table, u16 firstBattleTrainerId) +{ + s32 tableId = TrainerIdToRematchTableId(table, firstBattleTrainerId); + + if (tableId != -1) + gSaveBlock1Ptr->trainerRematches[tableId] = 0; +} + +static u32 GetTrainerMatchCallFlag(u32 trainerId) +{ + s32 i; + + for (i = 0; i < REMATCH_TABLE_ENTRIES; i++) + { + if (gRematchTable[i].trainerIds[0] == trainerId) + return FLAG_MATCH_CALL_REGISTERED + i; + } + + return 0xFFFF; +} + +static void RegisterTrainerInMatchCall(void) +{ + if (FlagGet(FLAG_HAS_MATCH_CALL)) + { + u32 matchCallFlagId = GetTrainerMatchCallFlag(gTrainerBattleOpponent_A); + if (matchCallFlagId != 0xFFFF) + FlagSet(matchCallFlagId); + } +} + +static bool8 WasSecondRematchWon(const struct RematchTrainer *table, u16 firstBattleTrainerId) +{ + s32 tableId = FirstBattleTrainerIdToRematchTableId(table, firstBattleTrainerId); + + if (tableId == -1) + return FALSE; + if (!HasTrainerBeenFought(table[tableId].trainerIds[1])) + return FALSE; + + return TRUE; +} + +static bool32 HasAtLeastFiveBadges(void) +{ + s32 i, count; + + for (count = 0, i = 0; i < ARRAY_COUNT(sBadgeFlags); i++) + { + if (FlagGet(sBadgeFlags[i]) == TRUE) + { + if (++count >= 5) + return TRUE; + } + } + + return FALSE; +} + +#define STEP_COUNTER_MAX 255 + +void IncrementRematchStepCounter(void) +{ + if (HasAtLeastFiveBadges()) + { + if (gSaveBlock1Ptr->trainerRematchStepCounter >= STEP_COUNTER_MAX) + gSaveBlock1Ptr->trainerRematchStepCounter = STEP_COUNTER_MAX; + else + gSaveBlock1Ptr->trainerRematchStepCounter++; + } +} + +static bool32 IsRematchStepCounterMaxed(void) +{ + if (HasAtLeastFiveBadges() && gSaveBlock1Ptr->trainerRematchStepCounter >= STEP_COUNTER_MAX) + return TRUE; + else + return FALSE; +} + +void TryUpdateRandomTrainerRematches(u16 mapGroup, u16 mapNum) +{ + if (IsRematchStepCounterMaxed() && UpdateRandomTrainerRematches(gRematchTable, mapGroup, mapNum) == TRUE) + gSaveBlock1Ptr->trainerRematchStepCounter = 0; +} + +bool32 DoesSomeoneWantRematchIn(u16 mapGroup, u16 mapNum) +{ + return DoesSomeoneWantRematchIn_(gRematchTable, mapGroup, mapNum); +} + +bool32 IsRematchTrainerIn(u16 mapGroup, u16 mapNum) +{ + return IsRematchTrainerIn_(gRematchTable, mapGroup, mapNum); +} + +static u16 GetRematchTrainerId(u16 trainerId) +{ + return GetRematchTrainerIdFromTable(gRematchTable, trainerId); +} + +u16 GetLastBeatenRematchTrainerId(u16 trainerId) +{ + return GetLastBeatenRematchTrainerIdFromTable(gRematchTable, trainerId); +} + +bool8 ShouldTryRematchBattle(void) +{ + if (IsFirstTrainerIdReadyForRematch(gRematchTable, gTrainerBattleOpponent_A)) + return TRUE; + + return WasSecondRematchWon(gRematchTable, gTrainerBattleOpponent_A); +} + +bool8 IsTrainerReadyForRematch(void) +{ + return IsTrainerReadyForRematch_(gRematchTable, gTrainerBattleOpponent_A); +} + +static void HandleRematchVarsOnBattleEnd(void) +{ + ClearTrainerWantRematchState(gRematchTable, gTrainerBattleOpponent_A); + SetBattledTrainersFlags(); +} + +void ShouldTryGetTrainerScript(void) +{ + if (sNoOfPossibleTrainerRetScripts > 1) + { + sNoOfPossibleTrainerRetScripts = 0; + sShouldCheckTrainerBScript = TRUE; + gSpecialVar_Result = TRUE; + } + else + { + sShouldCheckTrainerBScript = FALSE; + gSpecialVar_Result = FALSE; + } +} + +u16 CountBattledRematchTeams(u16 trainerId) +{ + s32 i; + + if (HasTrainerBeenFought(gRematchTable[trainerId].trainerIds[0]) != TRUE) + return 0; + + for (i = 1; i < REMATCHES_COUNT; i++) + { + if (gRematchTable[trainerId].trainerIds[i] == 0) + break; + if (!HasTrainerBeenFought(gRematchTable[trainerId].trainerIds[i])) + break; + } + + return i; } diff --git a/src/pokemon_2.c b/src/pokemon_2.c index 7014be492..4602b2f7a 100644 --- a/src/pokemon_2.c +++ b/src/pokemon_2.c @@ -1155,7 +1155,7 @@ u8 GetMonsStateToDoubles_2(void) s32 aliveCount = 0; s32 i; - for (i = 0; i < 6; i++) + for (i = 0; i < PARTY_SIZE; i++) { u32 species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2, NULL); if (species != SPECIES_EGG && species != SPECIES_NONE diff --git a/src/scrcmd.c b/src/scrcmd.c index 183b9bab5..f292bd769 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -656,7 +656,7 @@ bool8 ScrCmd_fadescreenspeed(struct ScriptContext *ctx) bool8 ScrCmd_fadescreenswapbuffers(struct ScriptContext *ctx) { u8 mode = ScriptReadByte(ctx); - + switch (mode) { case 1: @@ -1445,7 +1445,7 @@ bool8 ScrCmd_drawboxtext(struct ScriptContext *ctx) u8 top = ScriptReadByte(ctx); u8 multichoiceId = ScriptReadByte(ctx); u8 ignoreBPress = ScriptReadByte(ctx); - + /*if (Multichoice(left, top, multichoiceId, ignoreBPress) == TRUE) { ScriptContext1_Stop(); @@ -1501,31 +1501,31 @@ bool8 ScrCmd_braillemessage(struct ScriptContext *ctx) u8 y; StringExpandPlaceholders(gStringVar4, ptr + 6); - + width = GetStringWidth(6, gStringVar4, -1) / 8; - + if (width > 0x1C) width = 0x1C; - + for (i = 0, height = 4; gStringVar4[i] != 0xFF;) { if (gStringVar4[i++] == 0xFE) height += 3; } - + if (height > 0x12) height = 0x12; - + x = width + 2; temp1 = (0x1E - x) / 2; x = temp1 + 1; temp1 = ((x - temp1 - 1) * 8 + 3); - + y = height + 2; temp2 = (0x14 - y) / 2; y = temp2 + 2; temp2 = ((y - temp2 - 1) * 8); - + sub_8198A50(&template1, 0, x, y, width, height, 0xF, 0x1); template2 = template1; gUnknown_03000F30 = AddWindow(&template2); @@ -1924,7 +1924,7 @@ bool8 ScrCmd_hidemoneybox(struct ScriptContext *ctx) { /*u8 x = ScriptReadByte(ctx); u8 y = ScriptReadByte(ctx);*/ - + HideMoneyBox(); return FALSE; } @@ -1979,13 +1979,13 @@ bool8 ScrCmd_dotrainerbattle(struct ScriptContext *ctx) return TRUE; } -bool8 ScrCmd_ontrainerbattleend(struct ScriptContext *ctx) +bool8 ScrCmd_gotobattleendscript(struct ScriptContext *ctx) { ctx->scriptPtr = BattleSetup_GetScriptAddrAfterBattle(); return FALSE; } -bool8 ScrCmd_ontrainerbattleendgoto(struct ScriptContext *ctx) +bool8 ScrCmd_gototrainerscript(struct ScriptContext *ctx) { ctx->scriptPtr = BattleSetup_GetTrainerPostBattleScript(); return FALSE; @@ -1995,7 +1995,7 @@ bool8 ScrCmd_checktrainerflag(struct ScriptContext *ctx) { u16 index = VarGet(ScriptReadHalfword(ctx)); - ctx->comparisonResult = HasTrainerAlreadyBeenFought(index); + ctx->comparisonResult = HasTrainerBeenFought(index); return FALSE; } @@ -2003,7 +2003,7 @@ bool8 ScrCmd_settrainerflag(struct ScriptContext *ctx) { u16 index = VarGet(ScriptReadHalfword(ctx)); - trainer_flag_set(index); + SetTrainerFlag(index); return FALSE; } @@ -2011,7 +2011,7 @@ bool8 ScrCmd_cleartrainerflag(struct ScriptContext *ctx) { u16 index = VarGet(ScriptReadHalfword(ctx)); - trainer_flag_clear(index); + ClearTrainerFlag(index); return FALSE; } @@ -2374,7 +2374,7 @@ bool8 ScrCmd_checkmonobedience(struct ScriptContext *ctx) bool8 ScrCmd_cmdCF(struct ScriptContext *ctx) { const u8* v1 = sub_8099244(); - + if (v1) { ((u8*)gUnknown_020375C0) = ctx->scriptPtr; diff --git a/src/secret_base.c b/src/secret_base.c index de2b7221a..0550d7786 100644 --- a/src/secret_base.c +++ b/src/secret_base.c @@ -1282,7 +1282,7 @@ u8 sub_80EA20C(u8 secretBaseRecordId) return (gSaveBlock1Ptr->secretBases[secretBaseRecordId].trainerId[0] % 5) + (gSaveBlock1Ptr->secretBases[secretBaseRecordId].gender * 5); } -const u8 *sub_80EA250(void) +const u8 *GetSecretBaseTrainerLoseText(void) { u8 param; diff --git a/src/trainer_see.c b/src/trainer_see.c new file mode 100644 index 000000000..c469e11ed --- /dev/null +++ b/src/trainer_see.c @@ -0,0 +1,68 @@ +#include "global.h" +#include "trainer_see.h" +#include "battle_setup.h" + +extern u8 gApproachingTrainerId; +extern u8 gNoOfApproachingTrainers; +extern u8 gUnknown_030060AC; +extern u16 gUnknown_03006080; + +// this file's functions +u8 CheckIfTrainerWantsBattle(u8 mapObjectId); + +bool8 CheckForTrainersWantingBattle(void) +{ + u8 i; + + gNoOfApproachingTrainers = 0; + gApproachingTrainerId = 0; + + for (i = 0; i < MAP_OBJECTS_COUNT; i++) + { + u8 retVal; + + if (!gMapObjects[i].active) + continue; + if (gMapObjects[i].trainerType != 1 && gMapObjects[i].trainerType != 3) + continue; + + retVal = CheckIfTrainerWantsBattle(i); + if (retVal == 2) + break; // two trainers has been found + + if (retVal == 0) // no trainers + continue; + + if (gNoOfApproachingTrainers > 1) + break; + if (GetMonsStateToDoubles_2() != 0) // one trainer found and cant have a double battle + break; + } + + if (gNoOfApproachingTrainers == 1) + { + ResetTrainerOpponentIds(); + ConfigureAndSetUpOneTrainerBattle(gApproachingTrainers[gNoOfApproachingTrainers - 1].mapObjectId, + gApproachingTrainers[gNoOfApproachingTrainers - 1].trainerScriptPtr); + gUnknown_030060AC = 1; + return TRUE; + } + else if (gNoOfApproachingTrainers == 2) + { + ResetTrainerOpponentIds(); + for (i = 0; i < gNoOfApproachingTrainers; i++, gApproachingTrainerId++) + { + ConfigureTwoTrainersBattle(gApproachingTrainers[i].mapObjectId, + gApproachingTrainers[i].trainerScriptPtr); + } + SetUpTwoTrainersBattle(); + gApproachingTrainerId = 0; + gUnknown_030060AC = 1; + return TRUE; + } + else + { + gUnknown_030060AC = 0; + return FALSE; + } +} diff --git a/sym_common.txt b/sym_common.txt index 93b8431f4..646db3bb7 100644 --- a/sym_common.txt +++ b/sym_common.txt @@ -302,10 +302,10 @@ gUnknown_03006080: @ 3006080 gUnknown_03006084: @ 3006084 .space 0xC -gUnknown_03006090: @ 3006090 +gApproachingTrainers: @ 3006090 .space 0x18 -gUnknown_030060A8: @ 30060A8 +gNoOfApproachingTrainers: @ 30060A8 .space 0x4 gUnknown_030060AC: @ 30060AC diff --git a/sym_ewram.txt b/sym_ewram.txt index 1466aeead..ef9230b39 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -708,11 +708,7 @@ gUnknown_02038BC6: @ 2038BC6 .include "src/battle_setup.o" -gUnknown_02038BF8: @ 2038BF8 - .space 0x1 - -gUnknown_02038BF9: @ 2038BF9 - .space 0x3 +.align 2 gApproachingTrainerId: @ 2038BFC .space 0x4 |