From 10470ef536132c317f0c478e42ad37657a0f00aa Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Tue, 28 Nov 2017 23:02:09 +0100 Subject: [PATCH] start working on battle setup --- asm/battle_frontier_1.s | 2 +- asm/battle_frontier_2.s | 2 +- asm/battle_setup.s | 1204 +---------------- asm/battle_tower.s | 4 +- asm/battle_transition.s | 6 +- asm/field_control_avatar.s | 6 +- asm/field_effect.s | 24 +- asm/field_screen.s | 32 +- asm/fldeff_80F9BCC.s | 6 +- asm/item_menu.s | 2 +- asm/map_obj_8097404.s | 8 +- asm/map_obj_lock.s | 2 +- asm/rom4.s | 16 +- asm/rom6.s | 2 +- asm/start_menu.s | 2 +- constants/battle_constants.inc | 2 +- data/battle_scripts_1.s | 4 +- data/battle_setup.s | 6 - data/scripts/maps/AncientTomb.inc | 2 +- data/scripts/maps/BirthIsland_Exterior.inc | 2 +- data/scripts/maps/DesertRuins.inc | 2 +- data/scripts/maps/FarawayIsland_Interior.inc | 2 +- data/scripts/maps/IslandCave.inc | 2 +- data/scripts/maps/MarineCave_End.inc | 2 +- data/scripts/maps/NavelRock_Bottom.inc | 2 +- data/scripts/maps/NavelRock_Top.inc | 2 +- data/scripts/maps/PetalburgCity.inc | 2 +- data/scripts/maps/SkyPillar_Top.inc | 2 +- data/scripts/maps/SouthernIsland_Interior.inc | 2 +- data/scripts/maps/TerraCave_End.inc | 2 +- data/specials.inc | 10 +- include/battle.h | 18 +- include/battle_transition.h | 46 + include/pokemon_3.h | 1 + include/safari_zone.h | 2 + include/songs.h | 42 +- include/trainer_ids.h | 5 + include/vars.h | 1 + ld_script.txt | 2 + src/battle_setup.c | 586 ++++++++ src/pokemon_3.c | 2 +- src/safari_zone.c | 2 +- 42 files changed, 763 insertions(+), 1308 deletions(-) create mode 100644 src/battle_setup.c diff --git a/asm/battle_frontier_1.s b/asm/battle_frontier_1.s index 973e87fbb..5bd832acd 100755 --- a/asm/battle_frontier_1.s +++ b/asm/battle_frontier_1.s @@ -13887,7 +13887,7 @@ task_prev_quest: @ 81960A8 cmp r0, 0 bne _081960C2 bl ScriptContext2_Enable - bl player_bitmagic + bl FreezeMapObjects bl sub_808B864 bl sub_808BCF4 _081960C2: diff --git a/asm/battle_frontier_2.s b/asm/battle_frontier_2.s index d90fa94f0..ead4750e1 100755 --- a/asm/battle_frontier_2.s +++ b/asm/battle_frontier_2.s @@ -12380,7 +12380,7 @@ _081A0C8E: sub_81A0C9C: @ 81A0C9C push {lr} bl ScriptContext2_Enable - bl player_bitmagic + bl FreezeMapObjects bl sub_808B864 bl sub_808BCF4 movs r0, 0 diff --git a/asm/battle_setup.s b/asm/battle_setup.s index f77e7a5d0..207856474 100644 --- a/asm/battle_setup.s +++ b/asm/battle_setup.s @@ -5,1191 +5,9 @@ .text - thumb_func_start task01_battle_start -task01_battle_start: @ 80B05F0 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r4, r0, r1 - movs r1, 0 - ldrsh r0, [r4, r1] - cmp r0, 0 - beq _080B0614 - cmp r0, 0x1 - beq _080B062E - b _080B0652 - .pool -_080B0614: - bl c3_80A0DD8_is_running - cmp r0, 0 - bne _080B0652 - ldrb r0, [r4, 0x2] - bl sub_8145EF4 - bl sub_81BE72C - ldrh r0, [r4] - adds r0, 0x1 - strh r0, [r4] - b _080B0652 -_080B062E: - bl IsBattleTransitionDone - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _080B0652 - bl overworld_free_bg_tilemaps - ldr r0, =CB2_InitBattle - bl SetMainCallback2 - bl prev_quest_postbuffer_cursor_backup_reset - bl overworld_poison_timer_set - adds r0, r5, 0 - bl DestroyTask -_080B0652: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end task01_battle_start - thumb_func_start task_add_01_battle_start -task_add_01_battle_start: @ 80B065C - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - lsls r4, 24 - lsrs r4, 24 - lsls r5, 16 - lsrs r5, 16 - ldr r0, =task01_battle_start - movs r1, 0x1 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - strh r4, [r1, 0xA] - adds r0, r5, 0 - bl PlayMapChosenOrBattleBGM - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end task_add_01_battle_start - thumb_func_start BattleSetup_StartWildBattle -BattleSetup_StartWildBattle: @ 80B0698 - push {lr} - bl GetSafariZoneFlag - cmp r0, 0 - beq _080B06A8 - bl sub_80B077C - b _080B06AC -_080B06A8: - bl sub_80B06BC -_080B06AC: - pop {r0} - bx r0 - thumb_func_end BattleSetup_StartWildBattle - thumb_func_start BattleSetup_StartBattlePikeWildBattle -BattleSetup_StartBattlePikeWildBattle: @ 80B06B0 - push {lr} - bl sub_80B07B4 - pop {r0} - bx r0 - thumb_func_end BattleSetup_StartBattlePikeWildBattle - - thumb_func_start sub_80B06BC -sub_80B06BC: @ 80B06BC - push {r4,lr} - bl ScriptContext2_Enable - bl player_bitmagic - bl sub_808BCF4 - ldr r1, =gMain - ldr r0, =sub_80B0AF8 - str r0, [r1, 0x8] - ldr r4, =gBattleTypeFlags - movs r0, 0 - str r0, [r4] - bl InBattlePyramid - lsls r0, 24 - cmp r0, 0 - beq _080B06F2 - ldr r0, =0x0000400e - movs r1, 0 - bl VarSet - ldr r0, [r4] - movs r1, 0x80 - lsls r1, 14 - orrs r0, r1 - str r0, [r4] -_080B06F2: - bl sub_80B0EC8 - lsls r0, 24 - lsrs r0, 24 - movs r1, 0 - bl task_add_01_battle_start - movs r0, 0x7 - bl IncrementGameStat - movs r0, 0x8 - bl IncrementGameStat - bl sub_80EECC8 - bl sub_80B1218 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B06BC - - thumb_func_start BattleSetup_StartRoamerBattle -BattleSetup_StartRoamerBattle: @ 80B072C - push {lr} - bl ScriptContext2_Enable - bl player_bitmagic - bl sub_808BCF4 - ldr r1, =gMain - ldr r0, =sub_80B0AF8 - str r0, [r1, 0x8] - ldr r1, =gBattleTypeFlags - movs r0, 0x80 - lsls r0, 3 - str r0, [r1] - bl sub_80B0EC8 - lsls r0, 24 - lsrs r0, 24 - movs r1, 0 - bl task_add_01_battle_start - movs r0, 0x7 - bl IncrementGameStat - movs r0, 0x8 - bl IncrementGameStat - bl sub_80EECC8 - bl sub_80B1218 - pop {r0} - bx r0 - .pool - thumb_func_end BattleSetup_StartRoamerBattle - - thumb_func_start sub_80B077C -sub_80B077C: @ 80B077C - push {lr} - bl ScriptContext2_Enable - bl player_bitmagic - bl sub_808BCF4 - ldr r1, =gMain - ldr r0, =sub_80FC190 - str r0, [r1, 0x8] - ldr r1, =gBattleTypeFlags - movs r0, 0x80 - str r0, [r1] - bl sub_80B0EC8 - lsls r0, 24 - lsrs r0, 24 - movs r1, 0 - bl task_add_01_battle_start - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B077C - - thumb_func_start sub_80B07B4 -sub_80B07B4: @ 80B07B4 - push {lr} - bl ScriptContext2_Enable - bl player_bitmagic - bl sub_808BCF4 - ldr r1, =gMain - ldr r0, =sub_80B0AF8 - str r0, [r1, 0x8] - ldr r1, =gBattleTypeFlags - movs r0, 0x80 - lsls r0, 13 - str r0, [r1] - bl sub_80B0EC8 - lsls r0, 24 - lsrs r0, 24 - movs r1, 0 - bl task_add_01_battle_start - movs r0, 0x7 - bl IncrementGameStat - movs r0, 0x8 - bl IncrementGameStat - bl sub_80EECC8 - bl sub_80B1218 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B07B4 - - thumb_func_start task_add_01_battle_start_with_music_and_stats -task_add_01_battle_start_with_music_and_stats: @ 80B0804 - push {lr} - bl reads_trainer_data_byte1_byte0x18 - lsls r0, 24 - lsrs r0, 24 - movs r1, 0 - bl task_add_01_battle_start - movs r0, 0x7 - bl IncrementGameStat - movs r0, 0x9 - bl IncrementGameStat - bl sub_80B1234 - pop {r0} - bx r0 - thumb_func_end task_add_01_battle_start_with_music_and_stats - - thumb_func_start sub_80B0828 -sub_80B0828: @ 80B0828 - push {lr} - bl InBattlePyramid - lsls r0, 24 - cmp r0, 0 - beq _080B0846 - movs r0, 0xA - bl sub_80B100C - lsls r0, 24 - lsrs r0, 24 - movs r1, 0 - bl task_add_01_battle_start - b _080B0856 -_080B0846: - movs r0, 0xB - bl sub_80B100C - lsls r0, 24 - lsrs r0, 24 - movs r1, 0 - bl task_add_01_battle_start -_080B0856: - movs r0, 0x7 - bl IncrementGameStat - movs r0, 0x9 - bl IncrementGameStat - bl sub_80B1234 - pop {r0} - bx r0 - thumb_func_end sub_80B0828 - - thumb_func_start sub_80B086C -sub_80B086C: @ 80B086C - push {lr} - ldr r0, =gEnemyParty - movs r1, 0xC4 - lsls r1, 1 - movs r2, 0x5 - bl CreateMaleMon - bl ScriptContext2_Enable - ldr r1, =gMain - ldr r0, =c2_exit_to_overworld_1_continue_scripts_restart_music - str r0, [r1, 0x8] - ldr r1, =gBattleTypeFlags - movs r0, 0x80 - lsls r0, 2 - str r0, [r1] - movs r0, 0x8 - movs r1, 0 - bl task_add_01_battle_start - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B086C - - thumb_func_start BattleSetup_StartScriptedWildBattle -BattleSetup_StartScriptedWildBattle: @ 80B08A8 - push {lr} - bl ScriptContext2_Enable - ldr r1, =gMain - ldr r0, =sub_80B0B6C - str r0, [r1, 0x8] - ldr r1, =gBattleTypeFlags - movs r0, 0 - str r0, [r1] - bl sub_80B0EC8 - lsls r0, 24 - lsrs r0, 24 - movs r1, 0 - bl task_add_01_battle_start - movs r0, 0x7 - bl IncrementGameStat - movs r0, 0x8 - bl IncrementGameStat - bl sub_80EECC8 - bl sub_80B1218 - pop {r0} - bx r0 - .pool - thumb_func_end BattleSetup_StartScriptedWildBattle - - thumb_func_start sub_80B08EC -sub_80B08EC: @ 80B08EC - push {lr} - bl ScriptContext2_Enable - ldr r1, =gMain - ldr r0, =sub_80B0B6C - str r0, [r1, 0x8] - ldr r1, =gBattleTypeFlags - movs r0, 0x80 - lsls r0, 6 - str r0, [r1] - bl sub_80B0EC8 - lsls r0, 24 - lsrs r0, 24 - movs r1, 0 - bl task_add_01_battle_start - movs r0, 0x7 - bl IncrementGameStat - movs r0, 0x8 - bl IncrementGameStat - bl sub_80EECC8 - bl sub_80B1218 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B08EC - - thumb_func_start sub_80B0934 -sub_80B0934: @ 80B0934 - push {r4,lr} - bl ScriptContext2_Enable - ldr r1, =gMain - ldr r0, =sub_80B0B6C - str r0, [r1, 0x8] - ldr r4, =gBattleTypeFlags - movs r0, 0x80 - lsls r0, 6 - str r0, [r4] - ldr r0, =gEnemyParty - movs r1, 0xB - movs r2, 0 - bl GetMonData - adds r1, r0, 0 - movs r0, 0xCA - lsls r0, 1 - cmp r1, r0 - beq _080B09B8 - cmp r1, r0 - bhi _080B0988 - cmp r1, 0x97 - beq _080B09F4 - cmp r1, 0x97 - bcc _080B099A - cmp r1, 0xFA - bhi _080B099A - cmp r1, 0xF9 - bcc _080B099A - ldr r1, =0x00000229 - b _080B09E6 - .pool -_080B0988: - movs r0, 0xCB - lsls r0, 1 - cmp r1, r0 - beq _080B09CE - cmp r1, r0 - bcc _080B099A - adds r0, 0x4 - cmp r1, r0 - beq _080B09E4 -_080B099A: - ldr r2, =gBattleTypeFlags - ldr r0, [r2] - movs r1, 0x80 - lsls r1, 21 - orrs r0, r1 - str r0, [r2] - movs r1, 0xF0 - lsls r1, 1 - movs r0, 0x17 - bl task_add_01_battle_start - b _080B09FE - .pool -_080B09B8: - ldr r0, [r4] - movs r1, 0x80 - lsls r1, 22 - orrs r0, r1 - str r0, [r4] - movs r1, 0xF0 - lsls r1, 1 - movs r0, 0x16 - bl task_add_01_battle_start - b _080B09FE -_080B09CE: - ldr r0, [r4] - movs r1, 0x80 - lsls r1, 23 - orrs r0, r1 - str r0, [r4] - movs r1, 0xEB - lsls r1, 1 - movs r0, 0x18 - bl task_add_01_battle_start - b _080B09FE -_080B09E4: - ldr r1, =0x00000227 -_080B09E6: - movs r0, 0 - bl task_add_01_battle_start - b _080B09FE - .pool -_080B09F4: - movs r1, 0xEC - lsls r1, 1 - movs r0, 0xA - bl task_add_01_battle_start -_080B09FE: - movs r0, 0x7 - bl IncrementGameStat - movs r0, 0x8 - bl IncrementGameStat - bl sub_80EECC8 - bl sub_80B1218 - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_80B0934 - - thumb_func_start sub_80B0A18 -sub_80B0A18: @ 80B0A18 - push {lr} - bl ScriptContext2_Enable - ldr r1, =gMain - ldr r0, =sub_80B0B6C - str r0, [r1, 0x8] - ldr r1, =gBattleTypeFlags - movs r0, 0xC0 - lsls r0, 6 - str r0, [r1] - ldr r0, =gGameVersion - ldrb r0, [r0] - cmp r0, 0x2 - bne _080B0A50 - movs r1, 0xF0 - lsls r1, 1 - movs r0, 0xB - bl task_add_01_battle_start - b _080B0A5A - .pool -_080B0A50: - movs r1, 0xF0 - lsls r1, 1 - movs r0, 0x6 - bl task_add_01_battle_start -_080B0A5A: - movs r0, 0x7 - bl IncrementGameStat - movs r0, 0x8 - bl IncrementGameStat - bl sub_80EECC8 - bl sub_80B1218 - pop {r0} - bx r0 - thumb_func_end sub_80B0A18 - - thumb_func_start sub_80B0A74 -sub_80B0A74: @ 80B0A74 - push {lr} - bl ScriptContext2_Enable - ldr r1, =gMain - ldr r0, =sub_80B0B6C - str r0, [r1, 0x8] - ldr r1, =gBattleTypeFlags - movs r0, 0xC0 - lsls r0, 7 - str r0, [r1] - ldr r0, =gEnemyParty - movs r1, 0xB - bl GetMonData - lsls r0, 16 - lsrs r1, r0, 16 - adds r2, r1, 0 - movs r0, 0xC9 - lsls r0, 1 - cmp r1, r0 - beq _080B0ACC - cmp r1, r0 - bgt _080B0ABC - subs r0, 0x1 - cmp r1, r0 - beq _080B0AC8 - b _080B0AD4 - .pool -_080B0ABC: - ldr r0, =0x00000193 - cmp r2, r0 - beq _080B0AD0 - b _080B0AD4 - .pool -_080B0AC8: - movs r0, 0x15 - b _080B0AD6 -_080B0ACC: - movs r0, 0x13 - b _080B0AD6 -_080B0AD0: - movs r0, 0x14 - b _080B0AD6 -_080B0AD4: - movs r0, 0xA -_080B0AD6: - ldr r1, =0x000001df - bl task_add_01_battle_start - movs r0, 0x7 - bl IncrementGameStat - movs r0, 0x8 - bl IncrementGameStat - bl sub_80EECC8 - bl sub_80B1218 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B0A74 - - thumb_func_start sub_80B0AF8 -sub_80B0AF8: @ 80B0AF8 - push {lr} - sub sp, 0x4 - mov r1, sp - movs r0, 0 - strh r0, [r1] - movs r1, 0xA0 - lsls r1, 19 - ldr r2, =0x01000100 - mov r0, sp - bl CpuSet - movs r0, 0 - movs r1, 0x80 - bl ResetOamRange - ldr r0, =gBattleOutcome - ldrb r0, [r0] - bl battle_exit_is_player_defeat - cmp r0, 0x1 - bne _080B0B4C - bl InBattlePyramid - lsls r0, 24 - cmp r0, 0 - bne _080B0B4C - bl InBattlePike - lsls r0, 24 - cmp r0, 0 - bne _080B0B4C - ldr r0, =c2_whiteout - bl SetMainCallback2 - b _080B0B58 - .pool -_080B0B4C: - ldr r0, =c2_exit_to_overworld_2_switch - bl SetMainCallback2 - ldr r1, =gFieldCallback - ldr r0, =sub_80AF6F0 - str r0, [r1] -_080B0B58: - add sp, 0x4 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B0AF8 - - thumb_func_start sub_80B0B6C -sub_80B0B6C: @ 80B0B6C - push {lr} - sub sp, 0x4 - mov r1, sp - movs r0, 0 - strh r0, [r1] - movs r1, 0xA0 - lsls r1, 19 - ldr r2, =0x01000100 - mov r0, sp - bl CpuSet - movs r0, 0 - movs r1, 0x80 - bl ResetOamRange - ldr r0, =gBattleOutcome - ldrb r0, [r0] - bl battle_exit_is_player_defeat - cmp r0, 0x1 - bne _080B0BC0 - bl InBattlePyramid - lsls r0, 24 - cmp r0, 0 - beq _080B0BB4 - ldr r0, =c2_exit_to_overworld_1_continue_scripts_restart_music - bl SetMainCallback2 - b _080B0BC6 - .pool -_080B0BB4: - ldr r0, =c2_whiteout - bl SetMainCallback2 - b _080B0BC6 - .pool -_080B0BC0: - ldr r0, =c2_exit_to_overworld_1_continue_scripts_restart_music - bl SetMainCallback2 -_080B0BC6: - add sp, 0x4 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B0B6C - - thumb_func_start BattleSetup_GetTerrainId -BattleSetup_GetTerrainId: @ 80B0BD0 - push {r4,r5,lr} - sub sp, 0x4 - mov r4, sp - adds r4, 0x2 - mov r0, sp - adds r1, r4, 0 - bl PlayerGetDestCoords - mov r0, sp - movs r1, 0 - ldrsh r0, [r0, r1] - movs r2, 0 - ldrsh r1, [r4, r2] - bl MapGridGetMetatileBehaviorAt - lsls r0, 16 - lsrs r5, r0, 16 - lsls r0, r5, 24 - lsrs r4, r0, 24 - adds r0, r4, 0 - bl MetatileBehavior_IsTallGrass - lsls r0, 24 - cmp r0, 0 - beq _080B0C06 - movs r0, 0 - b _080B0D1A -_080B0C06: - adds r0, r4, 0 - bl MetatileBehavior_IsLongGrass - lsls r0, 24 - cmp r0, 0 - beq _080B0C16 - movs r0, 0x1 - b _080B0D1A -_080B0C16: - adds r0, r4, 0 - bl MetatileBehavior_IsSandOrDeepSand - lsls r0, 24 - cmp r0, 0 - bne _080B0D18 - ldr r0, =gMapHeader - ldrb r0, [r0, 0x17] - subs r0, 0x1 - cmp r0, 0x8 - bhi _080B0C9C - lsls r0, 2 - ldr r1, =_080B0C40 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_080B0C40: - .4byte _080B0C9C - .4byte _080B0C9C - .4byte _080B0C9C - .4byte _080B0C64 - .4byte _080B0C88 - .4byte _080B0C8C - .4byte _080B0C9C - .4byte _080B0C74 - .4byte _080B0C74 -_080B0C64: - lsls r0, r5, 24 - lsrs r4, r0, 24 - adds r0, r4, 0 - bl MetatileBehavior_IsMB_0B - lsls r0, 24 - cmp r0, 0 - beq _080B0C78 -_080B0C74: - movs r0, 0x8 - b _080B0D1A -_080B0C78: - adds r0, r4, 0 - bl MetatileBehavior_IsSurfableWaterOrUnderwater - lsls r0, 24 - cmp r0, 0 - bne _080B0CE0 - movs r0, 0x7 - b _080B0D1A -_080B0C88: - movs r0, 0x3 - b _080B0D1A -_080B0C8C: - lsls r0, r5, 24 - lsrs r0, 24 - bl MetatileBehavior_IsSurfableWaterOrUnderwater - lsls r0, 24 - cmp r0, 0 - bne _080B0CF2 - b _080B0D10 -_080B0C9C: - lsls r0, r5, 24 - lsrs r4, r0, 24 - adds r0, r4, 0 - bl MetatileBehavior_IsDeepOrOceanWater - lsls r0, 24 - cmp r0, 0 - bne _080B0CF2 - adds r0, r4, 0 - bl MetatileBehavior_IsSurfableWaterOrUnderwater - lsls r0, 24 - cmp r0, 0 - bne _080B0CE0 - adds r0, r4, 0 - bl MetatileBehavior_IsMountain - lsls r0, 24 - cmp r0, 0 - beq _080B0CC8 - movs r0, 0x6 - b _080B0D1A -_080B0CC8: - movs r0, 0x8 - bl TestPlayerAvatarFlags - lsls r0, 24 - cmp r0, 0 - beq _080B0CF6 - adds r0, r4, 0 - bl MetatileBehavior_GetBridgeSth - lsls r0, 24 - cmp r0, 0 - beq _080B0CE4 -_080B0CE0: - movs r0, 0x5 - b _080B0D1A -_080B0CE4: - adds r0, r4, 0 - bl MetatileBehavior_IsBridge - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _080B0CF6 -_080B0CF2: - movs r0, 0x4 - b _080B0D1A -_080B0CF6: - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldrh r1, [r0, 0x4] - movs r0, 0xE0 - lsls r0, 5 - cmp r1, r0 - beq _080B0D18 - bl sav1_get_weather_probably - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x8 - beq _080B0D18 -_080B0D10: - movs r0, 0x9 - b _080B0D1A - .pool -_080B0D18: - movs r0, 0x2 -_080B0D1A: - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end BattleSetup_GetTerrainId - - thumb_func_start sub_80B0D24 -sub_80B0D24: @ 80B0D24 - push {r4,lr} - sub sp, 0x4 - mov r4, sp - adds r4, 0x2 - mov r0, sp - adds r1, r4, 0 - bl PlayerGetDestCoords - mov r0, sp - movs r1, 0 - ldrsh r0, [r0, r1] - movs r2, 0 - ldrsh r1, [r4, r2] - bl MapGridGetMetatileBehaviorAt - lsls r0, 16 - lsrs r4, r0, 16 - bl sav1_get_flash_used_on_map - lsls r0, 24 - cmp r0, 0 - beq _080B0D54 - movs r0, 0x2 - b _080B0D7E -_080B0D54: - lsls r0, r4, 24 - lsrs r0, 24 - bl MetatileBehavior_IsSurfableWaterOrUnderwater - lsls r0, 24 - cmp r0, 0 - bne _080B0D7C - ldr r0, =gMapHeader - ldrb r0, [r0, 0x17] - cmp r0, 0x4 - beq _080B0D78 - cmp r0, 0x5 - beq _080B0D7C - movs r0, 0 - b _080B0D7E - .pool -_080B0D78: - movs r0, 0x1 - b _080B0D7E -_080B0D7C: - movs r0, 0x3 -_080B0D7E: - add sp, 0x4 - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_80B0D24 - - thumb_func_start sub_80B0D88 -sub_80B0D88: @ 80B0D88 - push {r4-r7,lr} - lsls r0, 24 - lsrs r5, r0, 24 - movs r7, 0 - movs r6, 0 -_080B0D92: - movs r0, 0x64 - adds r1, r6, 0 - muls r1, r0 - ldr r0, =gPlayerParty - adds r4, r1, r0 - adds r0, r4, 0 - movs r1, 0x41 - bl GetMonData - adds r1, r0, 0 - movs r0, 0xCE - lsls r0, 1 - cmp r1, r0 - beq _080B0DD6 - cmp r1, 0 - beq _080B0DD6 - adds r0, r4, 0 - movs r1, 0x39 - bl GetMonData - cmp r0, 0 - beq _080B0DD6 - adds r0, r4, 0 - movs r1, 0x38 - bl GetMonData - adds r0, r7, r0 - lsls r0, 24 - lsrs r7, r0, 24 - subs r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0 - beq _080B0DDC -_080B0DD6: - adds r6, 0x1 - cmp r6, 0x5 - ble _080B0D92 -_080B0DDC: - adds r0, r7, 0 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80B0D88 - - thumb_func_start reads_trainer_data_byte0 -reads_trainer_data_byte0: @ 80B0DE8 - push {r4,r5,lr} - lsls r0, 16 - lsrs r0, 16 - lsls r1, 24 - lsrs r4, r1, 24 - ldr r5, =gTrainers - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r2, r1, r5 - adds r0, r2, 0 - adds r0, 0x20 - ldrb r0, [r0] - cmp r0, r4 - bcs _080B0E08 - adds r4, r0, 0 -_080B0E08: - movs r3, 0 - ldrb r0, [r2] - cmp r0, 0x1 - beq _080B0E50 - cmp r0, 0x1 - bgt _080B0E20 - cmp r0, 0 - beq _080B0E2A - b _080B0EC0 - .pool -_080B0E20: - cmp r0, 0x2 - beq _080B0E76 - cmp r0, 0x3 - beq _080B0E9C - b _080B0EC0 -_080B0E2A: - adds r0, r5, 0 - adds r0, 0x24 - adds r0, r1, r0 - ldr r1, [r0] - movs r2, 0 - cmp r3, r4 - bcs _080B0EC0 -_080B0E38: - lsls r0, r2, 3 - adds r0, r1 - ldrb r0, [r0, 0x2] - adds r0, r3, r0 - lsls r0, 24 - lsrs r3, r0, 24 - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, r4 - bcc _080B0E38 - b _080B0EC0 -_080B0E50: - adds r0, r5, 0 - adds r0, 0x24 - adds r0, r1, r0 - ldr r1, [r0] - movs r2, 0 - cmp r3, r4 - bcs _080B0EC0 -_080B0E5E: - lsls r0, r2, 4 - adds r0, r1 - ldrb r0, [r0, 0x2] - adds r0, r3, r0 - lsls r0, 24 - lsrs r3, r0, 24 - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, r4 - bcc _080B0E5E - b _080B0EC0 -_080B0E76: - adds r0, r5, 0 - adds r0, 0x24 - adds r0, r1, r0 - ldr r1, [r0] - movs r2, 0 - cmp r3, r4 - bcs _080B0EC0 -_080B0E84: - lsls r0, r2, 3 - adds r0, r1 - ldrb r0, [r0, 0x2] - adds r0, r3, r0 - lsls r0, 24 - lsrs r3, r0, 24 - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, r4 - bcc _080B0E84 - b _080B0EC0 -_080B0E9C: - adds r0, r5, 0 - adds r0, 0x24 - adds r0, r1, r0 - ldr r1, [r0] - movs r2, 0 - cmp r3, r4 - bcs _080B0EC0 -_080B0EAA: - lsls r0, r2, 4 - adds r0, r1 - ldrb r0, [r0, 0x2] - adds r0, r3, r0 - lsls r0, 24 - lsrs r3, r0, 24 - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, r4 - bcc _080B0EAA -_080B0EC0: - adds r0, r3, 0 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end reads_trainer_data_byte0 - - thumb_func_start sub_80B0EC8 -sub_80B0EC8: @ 80B0EC8 - push {r4-r6,lr} - bl sub_80B0D24 - lsls r0, 24 - lsrs r5, r0, 24 - adds r6, r5, 0 - ldr r0, =gEnemyParty - movs r1, 0x38 - bl GetMonData - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - movs r0, 0x1 - bl sub_80B0D88 - lsls r0, 24 - lsrs r0, 24 - cmp r4, r0 - bcs _080B0F10 - bl InBattlePyramid - lsls r0, 24 - cmp r0, 0 - beq _080B0F04 - movs r0, 0 - b _080B0F2E - .pool -_080B0F04: - ldr r0, =gUnknown_0854FE88 - lsls r1, r5, 1 - b _080B0F20 - .pool -_080B0F10: - bl InBattlePyramid - lsls r0, 24 - cmp r0, 0 - bne _080B0F2C - ldr r0, =gUnknown_0854FE88 - lsls r1, r6, 1 - adds r0, 0x1 -_080B0F20: - adds r1, r0 - ldrb r0, [r1] - b _080B0F2E - .pool -_080B0F2C: - movs r0, 0xA -_080B0F2E: - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_80B0EC8 - - thumb_func_start reads_trainer_data_byte1_byte0x18 -reads_trainer_data_byte1_byte0x18: @ 80B0F34 - push {r4-r6,lr} - ldr r4, =gTrainerBattleOpponent_A - ldrh r1, [r4] - movs r0, 0x80 - lsls r0, 3 - cmp r1, r0 - beq _080B0F98 - ldr r1, =gTrainers - ldrh r2, [r4] - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - adds r0, r1 - ldrb r1, [r0, 0x1] - cmp r1, 0x1F - bne _080B0F94 - adds r1, r2, 0 - ldr r0, =0x00000105 - cmp r1, r0 - bne _080B0F6C - movs r0, 0xC - b _080B1000 - .pool -_080B0F6C: - movs r0, 0x83 - lsls r0, 1 - cmp r1, r0 - bne _080B0F78 - movs r0, 0xD - b _080B1000 -_080B0F78: - ldr r0, =0x00000107 - cmp r1, r0 - bne _080B0F88 - movs r0, 0xE - b _080B1000 - .pool -_080B0F88: - movs r0, 0x84 - lsls r0, 1 - cmp r1, r0 - bne _080B0F98 - movs r0, 0xF - b _080B1000 -_080B0F94: - cmp r1, 0x26 - bne _080B0F9C -_080B0F98: - movs r0, 0x10 - b _080B1000 -_080B0F9C: - cmp r1, 0x9 - beq _080B0FA8 - cmp r1, 0x35 - beq _080B0FA8 - cmp r1, 0x31 - bne _080B0FAC -_080B0FA8: - movs r0, 0x12 - b _080B1000 -_080B0FAC: - cmp r1, 0x3 - beq _080B0FB8 - cmp r1, 0xD - beq _080B0FB8 - cmp r1, 0xB - bne _080B0FBC -_080B0FB8: - movs r0, 0x11 - b _080B1000 -_080B0FBC: - ldrb r0, [r0, 0x18] - movs r5, 0x1 - cmp r0, 0x1 - bne _080B0FC6 - movs r5, 0x2 -_080B0FC6: - bl sub_80B0D24 - lsls r0, 24 - lsrs r6, r0, 24 - ldrh r0, [r4] - adds r1, r5, 0 - bl reads_trainer_data_byte0 - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - adds r0, r5, 0 - bl sub_80B0D88 - lsls r0, 24 - lsrs r0, 24 - cmp r4, r0 - bcc _080B0FF8 - ldr r0, =gUnknown_0854FE90 - lsls r1, r6, 1 - adds r0, 0x1 - b _080B0FFC - .pool -_080B0FF8: - ldr r0, =gUnknown_0854FE90 - lsls r1, r6, 1 -_080B0FFC: - adds r1, r0 - ldrb r0, [r1] -_080B1000: - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end reads_trainer_data_byte1_byte0x18 thumb_func_start sub_80B100C sub_80B100C: @ 80B100C @@ -1202,7 +20,7 @@ sub_80B100C: @ 80B100C lsls r4, 24 lsrs r4, 24 movs r0, 0x1 - bl sub_80B0D88 + bl GetSumOfPlayerPartyLevel lsls r0, 24 lsrs r0, 24 cmp r4, r0 @@ -1390,7 +208,7 @@ sub_80B11A8: @ 80B11A8 ldr r0, =CB2_InitBattle bl SetMainCallback2 bl prev_quest_postbuffer_cursor_backup_reset - bl overworld_poison_timer_set + bl ResetPoisonStepCounter movs r0, 0x7 bl IncrementGameStat movs r0, 0x8 @@ -1507,8 +325,8 @@ sub_80B1290: @ 80B1290 .pool thumb_func_end sub_80B1290 - thumb_func_start battle_exit_is_player_defeat -battle_exit_is_player_defeat: @ 80B12A8 + thumb_func_start IsPlayerDefeated +IsPlayerDefeated: @ 80B12A8 push {lr} subs r0, 0x1 cmp r0, 0x6 @@ -1536,7 +354,7 @@ _080B12E0: _080B12E2: pop {r1} bx r1 - thumb_func_end battle_exit_is_player_defeat + thumb_func_end IsPlayerDefeated thumb_func_start ResetTrainerOpponentIds ResetTrainerOpponentIds: @ 80B12E8 @@ -2211,7 +1029,7 @@ _080B18E8: b _080B190C .pool _080B1908: - bl task_add_01_battle_start_with_music_and_stats + bl DoTrainerBattle _080B190C: bl ScriptContext1_Stop pop {r4} @@ -2230,7 +1048,7 @@ sub_80B1918: @ 80B1918 beq _080B1946 ldr r0, =gBattleOutcome ldrb r0, [r0] - bl battle_exit_is_player_defeat + bl IsPlayerDefeated cmp r0, 0x1 bne _080B1968 bl InBattlePyramid @@ -2247,7 +1065,7 @@ _080B1946: b _080B198A .pool _080B195C: - ldr r0, =c2_whiteout + ldr r0, =CB2_WhiteOut bl SetMainCallback2 b _080B198A .pool @@ -2286,10 +1104,10 @@ sub_80B1994: @ 80B1994 _080B19B4: ldr r0, =gBattleOutcome ldrb r0, [r0] - bl battle_exit_is_player_defeat + bl IsPlayerDefeated cmp r0, 0x1 bne _080B19D0 - ldr r0, =c2_whiteout + ldr r0, =CB2_WhiteOut bl SetMainCallback2 b _080B19E2 .pool @@ -2314,7 +1132,7 @@ sub_80B19EC: @ 80B19EC ldr r1, =gMain ldr r0, =sub_80B1994 str r0, [r1, 0x8] - bl task_add_01_battle_start_with_music_and_stats + bl DoTrainerBattle bl ScriptContext1_Stop pop {r0} bx r0 diff --git a/asm/battle_tower.s b/asm/battle_tower.s index 42dcb431a..1a8ca411b 100755 --- a/asm/battle_tower.s +++ b/asm/battle_tower.s @@ -3534,7 +3534,7 @@ _08163E10: bl sub_80B100C lsls r0, 24 lsrs r0, 24 - bl sub_8145EF4 + bl BattleTransition_StartOnField b _08163E68 .pool _08163E2C: @@ -3561,7 +3561,7 @@ _08163E2C: movs r0, 0 bl PlayMapChosenOrBattleBGM movs r0, 0x12 - bl sub_8145EF4 + bl BattleTransition_StartOnField _08163E68: add sp, 0x4 pop {r4-r6} diff --git a/asm/battle_transition.s b/asm/battle_transition.s index 6ffa17320..13869eea9 100644 --- a/asm/battle_transition.s +++ b/asm/battle_transition.s @@ -57,8 +57,8 @@ TestBattleTransition: @ 8145EDC .pool thumb_func_end TestBattleTransition - thumb_func_start sub_8145EF4 -sub_8145EF4: @ 8145EF4 + thumb_func_start BattleTransition_StartOnField +BattleTransition_StartOnField: @ 8145EF4 push {lr} lsls r0, 24 lsrs r0, 24 @@ -69,7 +69,7 @@ sub_8145EF4: @ 8145EF4 pop {r0} bx r0 .pool - thumb_func_end sub_8145EF4 + thumb_func_end BattleTransition_StartOnField thumb_func_start sub_8145F10 sub_8145F10: @ 8145F10 diff --git a/asm/field_control_avatar.s b/asm/field_control_avatar.s index 29164ed7b..27bf46c93 100644 --- a/asm/field_control_avatar.s +++ b/asm/field_control_avatar.s @@ -1531,8 +1531,8 @@ _0809CB72: .pool thumb_func_end AdjustFriendship_step - thumb_func_start overworld_poison_timer_set -overworld_poison_timer_set: @ 809CB80 + thumb_func_start ResetPoisonStepCounter +ResetPoisonStepCounter: @ 809CB80 push {lr} ldr r0, =0x0000402b movs r1, 0 @@ -1540,7 +1540,7 @@ overworld_poison_timer_set: @ 809CB80 pop {r0} bx r0 .pool - thumb_func_end overworld_poison_timer_set + thumb_func_end ResetPoisonStepCounter thumb_func_start overworld_poison_step overworld_poison_step: @ 809CB94 diff --git a/asm/field_effect.s b/asm/field_effect.s index bfa563af1..62362529b 100644 --- a/asm/field_effect.s +++ b/asm/field_effect.s @@ -1961,7 +1961,7 @@ mapldr_080842E8: @ 80B69FC movs r1, 0 bl CreateTask bl ScriptContext2_Enable - bl player_bitmagic + bl FreezeMapObjects ldr r1, =gFieldCallback movs r0, 0 str r0, [r1] @@ -2057,7 +2057,7 @@ mapldr_08084390: @ 80B6AA4 bl FieldObjectTurn _080B6AE6: bl ScriptContext2_Enable - bl player_bitmagic + bl FreezeMapObjects ldr r1, =gFieldCallback movs r0, 0 str r0, [r1] @@ -2116,7 +2116,7 @@ sub_80B6B68: @ 80B6B68 bl sub_8085784 bl pal_fill_for_maplights bl ScriptContext2_Enable - bl player_bitmagic + bl FreezeMapObjects ldr r0, =sub_80B6B94 movs r1, 0 bl CreateTask @@ -2534,7 +2534,7 @@ _080B6E9A: sub_80B6EC0: @ 80B6EC0 push {r4,lr} adds r4, r0, 0 - bl player_bitmagic + bl FreezeMapObjects bl CameraObjectReset2 ldrb r0, [r4, 0xA] bl sub_80E1558 @@ -3476,7 +3476,7 @@ sub_80B764C: @ 80B764C push {r4,r5,lr} adds r4, r0, 0 adds r5, r1, 0 - bl player_bitmagic + bl FreezeMapObjects bl CameraObjectReset2 movs r0, 0 bl SetCameraPanningCallback @@ -3807,7 +3807,7 @@ sub_80B78EC: @ 80B78EC adds r5, r0, 0 adds r4, r1, 0 bl CameraObjectReset2 - bl player_bitmagic + bl FreezeMapObjects ldr r1, =gPlayerAvatar movs r0, 0x1 strb r0, [r1, 0x6] @@ -4055,7 +4055,7 @@ sub_80B7AE8: @ 80B7AE8 push {r4,r5,lr} adds r5, r0, 0 adds r4, r1, 0 - bl player_bitmagic + bl FreezeMapObjects bl CameraObjectReset2 ldr r1, =gPlayerAvatar movs r0, 0x1 @@ -4287,7 +4287,7 @@ _080B7CC4: sub_80B7CC8: @ 80B7CC8 push {lr} bl ScriptContext2_Enable - bl player_bitmagic + bl FreezeMapObjects ldr r0, =sub_80B7CE4 movs r1, 0x50 bl CreateTask @@ -4461,7 +4461,7 @@ mapldr_080859D4: @ 80B7E48 bl sub_8085784 bl pal_fill_for_maplights bl ScriptContext2_Enable - bl player_bitmagic + bl FreezeMapObjects ldr r1, =gFieldCallback movs r0, 0 str r0, [r1] @@ -4672,7 +4672,7 @@ sub_80B800C: @ 80B800C push {r4,lr} adds r4, r0, 0 bl ScriptContext2_Enable - bl player_bitmagic + bl FreezeMapObjects bl CameraObjectReset2 bl player_get_direction_lower_nybble lsls r0, 24 @@ -4906,7 +4906,7 @@ mapldr_08085D88: @ 80B8200 bl sub_8085784 bl pal_fill_for_maplights bl ScriptContext2_Enable - bl player_bitmagic + bl FreezeMapObjects ldr r1, =gFieldCallback movs r0, 0 str r0, [r1] @@ -6334,7 +6334,7 @@ sub_80B8DB4: @ 80B8DB4 push {r6} adds r4, r0, 0 bl ScriptContext2_Enable - bl player_bitmagic + bl FreezeMapObjects ldr r5, =gPlayerAvatar movs r0, 0x1 strb r0, [r5, 0x6] diff --git a/asm/field_screen.s b/asm/field_screen.s index 497346f8a..fa6c43099 100644 --- a/asm/field_screen.s +++ b/asm/field_screen.s @@ -7527,15 +7527,15 @@ SetSav1Weather: @ 80AED7C .pool thumb_func_end SetSav1Weather - thumb_func_start sav1_get_weather_probably -sav1_get_weather_probably: @ 80AEDAC + thumb_func_start GetSav1Weather +GetSav1Weather: @ 80AEDAC ldr r0, =gSaveBlock1Ptr ldr r0, [r0] adds r0, 0x2E ldrb r0, [r0] bx lr .pool - thumb_func_end sav1_get_weather_probably + thumb_func_end GetSav1Weather thumb_func_start sub_80AEDBC sub_80AEDBC: @ 80AEDBC @@ -7565,7 +7565,7 @@ sub_80AEDBC: @ 80AEDBC sub_80AEDF0: @ 80AEDF0 push {lr} bl SetSav1Weather - bl sav1_get_weather_probably + bl GetSav1Weather lsls r0, 24 lsrs r0, 24 bl weather_set @@ -7577,7 +7577,7 @@ sub_80AEDF0: @ 80AEDF0 sub_80AEE08: @ 80AEE08 push {lr} bl SetSav1Weather - bl sav1_get_weather_probably + bl GetSav1Weather lsls r0, 24 lsrs r0, 24 bl sub_80AB104 @@ -7588,7 +7588,7 @@ sub_80AEE08: @ 80AEE08 thumb_func_start DoCurrentWeather DoCurrentWeather: @ 80AEE20 push {r4,r5,lr} - bl sav1_get_weather_probably + bl GetSav1Weather lsls r0, 24 lsrs r4, r0, 24 cmp r4, 0xF @@ -7632,7 +7632,7 @@ _080AEE6E: thumb_func_start sub_80AEE84 sub_80AEE84: @ 80AEE84 push {r4,r5,lr} - bl sav1_get_weather_probably + bl GetSav1Weather lsls r0, 24 lsrs r4, r0, 24 cmp r4, 0xF @@ -8382,7 +8382,7 @@ _080AF46C: _080AF480: movs r0, 0 bl sub_80AF0F4 - bl player_bitmagic + bl FreezeMapObjects adds r0, r6, 0 adds r1, r7, 0 bl PlayerGetDestCoords @@ -8508,7 +8508,7 @@ _080AF580: _080AF58A: movs r0, 0 bl sub_80AF0F4 - bl player_bitmagic + bl FreezeMapObjects adds r0, r6, 0 adds r1, r7, 0 bl PlayerGetDestCoords @@ -8583,7 +8583,7 @@ task_map_chg_seq_0807E2CC: @ 80AF610 b _080AF65A .pool _080AF634: - bl player_bitmagic + bl FreezeMapObjects bl ScriptContext2_Enable ldrh r0, [r4, 0x8] adds r0, 0x1 @@ -9062,7 +9062,7 @@ _080AFA34: beq _080AFA6C b _080AFA7C _080AFA3A: - bl player_bitmagic + bl FreezeMapObjects bl ScriptContext2_Enable b _080AFA64 _080AFA44: @@ -9133,7 +9133,7 @@ _080AFAC0: .4byte _080AFBB8 .4byte _080AFBD4 _080AFAD4: - bl player_bitmagic + bl FreezeMapObjects adds r0, r4, 0 adds r1, r6, 0 bl PlayerGetDestCoords @@ -9290,7 +9290,7 @@ _080AFC1C: beq _080AFC46 b _080AFC56 _080AFC22: - bl player_bitmagic + bl FreezeMapObjects bl ScriptContext2_Enable b _080AFC3E _080AFC2C: @@ -9877,7 +9877,7 @@ sub_80B009C: @ 80B009C lsls r0, 24 lsrs r0, 24 adds r4, r0, 0 - bl sav1_get_flash_used_on_map + bl Overworld_GetFlashLevel lsls r0, 24 lsrs r0, 24 movs r5, 0 @@ -9982,7 +9982,7 @@ task0A_mpl_807E31C: @ 80B0160 b _080B01B6 .pool _080B0184: - bl player_bitmagic + bl FreezeMapObjects bl ScriptContext2_Enable bl sub_808D194 ldrh r0, [r4, 0x8] @@ -10033,7 +10033,7 @@ _080B01E4: beq _080B022A b _080B023A _080B01EE: - bl player_bitmagic + bl FreezeMapObjects bl ScriptContext2_Enable movs r0, 0x2D bl PlaySE diff --git a/asm/fldeff_80F9BCC.s b/asm/fldeff_80F9BCC.s index efdc114a2..bb5feb115 100644 --- a/asm/fldeff_80F9BCC.s +++ b/asm/fldeff_80F9BCC.s @@ -2275,8 +2275,8 @@ overworld_posion_effect: @ 80FAEA8 .pool thumb_func_end overworld_posion_effect - thumb_func_start c3_80A0DD8_is_running -c3_80A0DD8_is_running: @ 80FAEC0 + thumb_func_start FieldPoisonEffectIsRunning +FieldPoisonEffectIsRunning: @ 80FAEC0 push {lr} ldr r0, =task50_overworld_posion_effect bl FuncIsActiveTask @@ -2285,7 +2285,7 @@ c3_80A0DD8_is_running: @ 80FAEC0 pop {r1} bx r1 .pool - thumb_func_end c3_80A0DD8_is_running + thumb_func_end FieldPoisonEffectIsRunning thumb_func_start sub_80FAED4 sub_80FAED4: @ 80FAED4 diff --git a/asm/item_menu.s b/asm/item_menu.s index 61bd5c6e9..9c9916e37 100755 --- a/asm/item_menu.s +++ b/asm/item_menu.s @@ -4748,7 +4748,7 @@ _081AD550: cmp r6, 0x1 bne _081AD5C4 bl ScriptContext2_Enable - bl player_bitmagic + bl FreezeMapObjects bl sub_808B864 bl sub_808BCF4 ldr r2, =gSpecialVar_ItemId diff --git a/asm/map_obj_8097404.s b/asm/map_obj_8097404.s index 96ffc2254..4a6ae9945 100644 --- a/asm/map_obj_8097404.s +++ b/asm/map_obj_8097404.s @@ -82,9 +82,9 @@ _0809748E: bx r1 thumb_func_end sub_8097404 - thumb_func_start player_bitmagic -@ void player_bitmagic() -player_bitmagic: @ 8097494 + thumb_func_start FreezeMapObjects +@ void FreezeMapObjects() +FreezeMapObjects: @ 8097494 push {r4,r5,lr} movs r4, 0 ldr r5, =gMapObjects @@ -113,7 +113,7 @@ _080974B8: pop {r0} bx r0 .pool - thumb_func_end player_bitmagic + thumb_func_end FreezeMapObjects thumb_func_start sub_80974D0 sub_80974D0: @ 80974D0 diff --git a/asm/map_obj_lock.s b/asm/map_obj_lock.s index 2270051c2..caa07638f 100644 --- a/asm/map_obj_lock.s +++ b/asm/map_obj_lock.s @@ -62,7 +62,7 @@ _080983E2: thumb_func_start ScriptFreezeMapObjects ScriptFreezeMapObjects: @ 80983E8 push {lr} - bl player_bitmagic + bl FreezeMapObjects ldr r0, =sub_80983A4 movs r1, 0x50 bl CreateTask diff --git a/asm/rom4.s b/asm/rom4.s index ea03b8a8d..00d1d1376 100644 --- a/asm/rom4.s +++ b/asm/rom4.s @@ -1880,15 +1880,15 @@ _080854FE: .pool thumb_func_end Overworld_SetFlashLevel - thumb_func_start sav1_get_flash_used_on_map -sav1_get_flash_used_on_map: @ 8085514 + thumb_func_start Overworld_GetFlashLevel +Overworld_GetFlashLevel: @ 8085514 ldr r0, =gSaveBlock1Ptr ldr r0, [r0] adds r0, 0x30 ldrb r0, [r0] bx lr .pool - thumb_func_end sav1_get_flash_used_on_map + thumb_func_end Overworld_GetFlashLevel thumb_func_start sub_8085524 sub_8085524: @ 8085524 @@ -2133,7 +2133,7 @@ sav1_map_get_music: @ 80856D4 lsls r0, 5 cmp r1, r0 bne _080856FC - bl sav1_get_weather_probably + bl GetSav1Weather lsls r0, 24 lsrs r0, 24 cmp r0, 0x8 @@ -3192,8 +3192,8 @@ CB2_NewGame: @ 8085EF8 .pool thumb_func_end CB2_NewGame - thumb_func_start c2_whiteout -c2_whiteout: @ 8085F58 + thumb_func_start CB2_WhiteOut +CB2_WhiteOut: @ 8085F58 push {lr} sub sp, 0x4 ldr r1, =gMain @@ -3232,7 +3232,7 @@ _08085FB0: pop {r0} bx r0 .pool - thumb_func_end c2_whiteout + thumb_func_end CB2_WhiteOut thumb_func_start c2_load_new_map c2_load_new_map: @ 8085FCC @@ -3661,7 +3661,7 @@ sub_80863B0: @ 80863B0 b _080863F0 .pool _080863D4: - bl sav1_get_flash_used_on_map + bl Overworld_GetFlashLevel lsls r0, 24 lsrs r0, 24 cmp r0, 0 diff --git a/asm/rom6.s b/asm/rom6.s index 430ed7ee9..f87733290 100644 --- a/asm/rom6.s +++ b/asm/rom6.s @@ -4180,7 +4180,7 @@ _0813785A: thumb_func_start sp0C8_whiteout_maybe sp0C8_whiteout_maybe: @ 813787C push {lr} - ldr r0, =c2_whiteout + ldr r0, =CB2_WhiteOut bl SetMainCallback2 movs r0, 0 pop {r1} diff --git a/asm/start_menu.s b/asm/start_menu.s index 634425f80..1732aca00 100644 --- a/asm/start_menu.s +++ b/asm/start_menu.s @@ -356,7 +356,7 @@ sub_809FA9C: @ 809FA9C bl is_c1_link_related_active cmp r0, 0 bne _0809FAB2 - bl player_bitmagic + bl FreezeMapObjects bl sub_808B864 bl sub_808BCF4 _0809FAB2: diff --git a/constants/battle_constants.inc b/constants/battle_constants.inc index 34f16a8c9..bf1f2db6a 100644 --- a/constants/battle_constants.inc +++ b/constants/battle_constants.inc @@ -19,7 +19,7 @@ .set BATTLE_TYPE_PALACE, 0x20000 .set BATTLE_TYPE_ARENA, 0x40000 .set BATTLE_TYPE_FACTORY, 0x80000 - .set BATTLE_TYPE_x100000, 0x100000 + .set BATTLE_TYPE_PIKE, 0x100000 .set BATTLE_TYPE_PYRAMID, 0x200000 .set BATTLE_TYPE_INGAME_PARTNER, 0x400000 .set BATTLE_TYPE_x800000, 0x800000 diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 0be60d109..4e64a27e8 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -2868,7 +2868,7 @@ BattleScript_82DA816:: jumpifword NO_COMMON_BITS, gBattleTypeFlags, BATTLE_TYPE_TRAINER, BattleScript_82DA8D0 jumpifword COMMON_BITS, gBattleTypeFlags, BATTLE_TYPE_LINK, BattleScript_82DA8D0 jumpifword COMMON_BITS, gBattleTypeFlags, BATTLE_TYPE_x2000000, BattleScript_82DA8D0 - jumpifword COMMON_BITS, gBattleTypeFlags, BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_DOME | BATTLE_TYPE_PALACE | BATTLE_TYPE_ARENA | BATTLE_TYPE_FACTORY | BATTLE_TYPE_x100000 | BATTLE_TYPE_PYRAMID, BattleScript_82DA8D0 + jumpifword COMMON_BITS, gBattleTypeFlags, BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_DOME | BATTLE_TYPE_PALACE | BATTLE_TYPE_ARENA | BATTLE_TYPE_FACTORY | BATTLE_TYPE_PIKE | BATTLE_TYPE_PYRAMID, BattleScript_82DA8D0 jumpifword COMMON_BITS, gBattleTypeFlags, BATTLE_TYPE_DOUBLE, BattleScript_82DA8D0 jumpifword COMMON_BITS, gHitMarker, HITMARKER_x400000, BattleScript_82DA8D0 jumpifbyte EQUAL, sBATTLE_STYLE, 0x1, BattleScript_82DA8D0 @@ -2963,7 +2963,7 @@ BattleScript_PayDayMoneyAndPickUpItems:: BattleScript_LocalBattleLost:: jumpifword COMMON_BITS, gBattleTypeFlags, BATTLE_TYPE_DOME, BattleScript_CheckDomeDrew - jumpifword COMMON_BITS, gBattleTypeFlags, BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_DOME | BATTLE_TYPE_PALACE | BATTLE_TYPE_ARENA | BATTLE_TYPE_FACTORY | BATTLE_TYPE_x100000 | BATTLE_TYPE_PYRAMID, BattleScript_LocalBattleLostPrintTrainersWinText + jumpifword COMMON_BITS, gBattleTypeFlags, BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_DOME | BATTLE_TYPE_PALACE | BATTLE_TYPE_ARENA | BATTLE_TYPE_FACTORY | BATTLE_TYPE_PIKE | BATTLE_TYPE_PYRAMID, BattleScript_LocalBattleLostPrintTrainersWinText jumpifword COMMON_BITS, gBattleTypeFlags, BATTLE_TYPE_x4000000, BattleScript_LocalBattleLostPrintTrainersWinText jumpifword COMMON_BITS, gBattleTypeFlags, BATTLE_TYPE_EREADER_TRAINER, BattleScript_LocalBattleLostEnd jumpifhalfword EQUAL, gTrainerBattleOpponent_A, 0x400, BattleScript_LocalBattleLostEnd diff --git a/data/battle_setup.s b/data/battle_setup.s index d5043aae9..cd7c5d57b 100644 --- a/data/battle_setup.s +++ b/data/battle_setup.s @@ -4,12 +4,6 @@ .section .rodata .align 2, 0 -gUnknown_0854FE88:: @ 854FE88 - .byte 0x08, 0x09, 0x05, 0x0a, 0x00, 0x0a, 0x07, 0x06 - -gUnknown_0854FE90:: @ 854FE90 - .byte 0x04, 0x0b, 0x02, 0x03, 0x00, 0x0a, 0x01, 0x06 - gUnknown_0854FE98:: @ 854FE98 .byte 0x1d, 0x1e, 0x1f, 0x20, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29 diff --git a/data/scripts/maps/AncientTomb.inc b/data/scripts/maps/AncientTomb.inc index 85a1d708d..240a40fd8 100644 --- a/data/scripts/maps/AncientTomb.inc +++ b/data/scripts/maps/AncientTomb.inc @@ -72,7 +72,7 @@ AncientTomb_EventScript_23905A:: @ 823905A waitmoncry setwildbattle SPECIES_REGISTEEL, 40, ITEM_NONE setflag FLAG_SYS_CTRL_OBJ_DELETE - special sub_80B0A74 + special StartRegiBattle waitstate clearflag FLAG_SYS_CTRL_OBJ_DELETE specialvar VAR_RESULT, sub_8138B80 diff --git a/data/scripts/maps/BirthIsland_Exterior.inc b/data/scripts/maps/BirthIsland_Exterior.inc index 8ea18a673..8c298c85a 100644 --- a/data/scripts/maps/BirthIsland_Exterior.inc +++ b/data/scripts/maps/BirthIsland_Exterior.inc @@ -88,7 +88,7 @@ BirthIsland_Exterior_EventScript_267FC1:: @ 8267FC1 setvar VAR_0x8006, 0 special DoScriptedWildBattle setflag FLAG_SYS_CTRL_OBJ_DELETE - special sub_80B0934 + special BattleSetup_StartLegendaryBattle waitstate clearflag FLAG_SYS_CTRL_OBJ_DELETE specialvar VAR_RESULT, sub_8138B80 diff --git a/data/scripts/maps/DesertRuins.inc b/data/scripts/maps/DesertRuins.inc index bb2f6d23d..afbd24903 100644 --- a/data/scripts/maps/DesertRuins.inc +++ b/data/scripts/maps/DesertRuins.inc @@ -72,7 +72,7 @@ DesertRuins_EventScript_22DA02:: @ 822DA02 waitmoncry setwildbattle SPECIES_REGIROCK, 40, ITEM_NONE setflag FLAG_SYS_CTRL_OBJ_DELETE - special sub_80B0A74 + special StartRegiBattle waitstate clearflag FLAG_SYS_CTRL_OBJ_DELETE specialvar VAR_RESULT, sub_8138B80 diff --git a/data/scripts/maps/FarawayIsland_Interior.inc b/data/scripts/maps/FarawayIsland_Interior.inc index f49d938a7..e86a2da52 100644 --- a/data/scripts/maps/FarawayIsland_Interior.inc +++ b/data/scripts/maps/FarawayIsland_Interior.inc @@ -145,7 +145,7 @@ FarawayIsland_Interior_EventScript_267DF2:: @ 8267DF2 setvar VAR_0x8006, 0 special DoScriptedWildBattle setflag FLAG_SYS_CTRL_OBJ_DELETE - special sub_80B0934 + special BattleSetup_StartLegendaryBattle waitstate clearflag FLAG_SYS_CTRL_OBJ_DELETE specialvar VAR_RESULT, sub_8138B80 diff --git a/data/scripts/maps/IslandCave.inc b/data/scripts/maps/IslandCave.inc index 69a3ef76a..4d6a4fda9 100644 --- a/data/scripts/maps/IslandCave.inc +++ b/data/scripts/maps/IslandCave.inc @@ -104,7 +104,7 @@ IslandCave_EventScript_238F58:: @ 8238F58 waitmoncry setwildbattle SPECIES_REGICE, 40, ITEM_NONE setflag FLAG_SYS_CTRL_OBJ_DELETE - special sub_80B0A74 + special StartRegiBattle waitstate clearflag FLAG_SYS_CTRL_OBJ_DELETE specialvar VAR_RESULT, sub_8138B80 diff --git a/data/scripts/maps/MarineCave_End.inc b/data/scripts/maps/MarineCave_End.inc index dc2e2b3a0..fafc10b63 100644 --- a/data/scripts/maps/MarineCave_End.inc +++ b/data/scripts/maps/MarineCave_End.inc @@ -38,7 +38,7 @@ MarineCave_End_EventScript_23B01B:: @ 823B01B setvar VAR_LAST_TALKED, 1 setwildbattle SPECIES_KYOGRE, 70, ITEM_NONE setflag FLAG_SYS_CTRL_OBJ_DELETE - special sub_80B0934 + special BattleSetup_StartLegendaryBattle waitstate clearflag FLAG_SYS_CTRL_OBJ_DELETE setvar VAR_0x4001, 0 diff --git a/data/scripts/maps/NavelRock_Bottom.inc b/data/scripts/maps/NavelRock_Bottom.inc index 055697d23..5167af41a 100644 --- a/data/scripts/maps/NavelRock_Bottom.inc +++ b/data/scripts/maps/NavelRock_Bottom.inc @@ -61,7 +61,7 @@ NavelRock_Bottom_EventScript_2692A2:: @ 82692A2 setvar VAR_0x8006, 0 special DoScriptedWildBattle setflag FLAG_SYS_CTRL_OBJ_DELETE - special sub_80B0934 + special BattleSetup_StartLegendaryBattle waitstate clearflag FLAG_SYS_CTRL_OBJ_DELETE specialvar VAR_RESULT, sub_8138B80 diff --git a/data/scripts/maps/NavelRock_Top.inc b/data/scripts/maps/NavelRock_Top.inc index 01c9a1523..edebb3976 100644 --- a/data/scripts/maps/NavelRock_Top.inc +++ b/data/scripts/maps/NavelRock_Top.inc @@ -65,7 +65,7 @@ NavelRock_Top_EventScript_26916F:: @ 826916F setvar VAR_0x8006, 0 special DoScriptedWildBattle setflag FLAG_SYS_CTRL_OBJ_DELETE - special sub_80B0934 + special BattleSetup_StartLegendaryBattle waitstate clearflag FLAG_SYS_CTRL_OBJ_DELETE setvar VAR_LAST_TALKED, 1 diff --git a/data/scripts/maps/PetalburgCity.inc b/data/scripts/maps/PetalburgCity.inc index e223bf414..ad7e2f1cb 100644 --- a/data/scripts/maps/PetalburgCity.inc +++ b/data/scripts/maps/PetalburgCity.inc @@ -36,7 +36,7 @@ PetalburgCity_EventScript_1DC32E:: @ 81DC32E applymovement 255, PetalburgCity_Movement_1DC430 waitmovement 0 msgbox PetalburgCity_Text_1EC1F8, 4 - special sub_80B086C + special StartWallyTutorialBattle waitstate msgbox PetalburgCity_Text_1EC271, 4 applymovementat 2, PetalburgCity_Movement_2725A4, PETALBURG_CITY diff --git a/data/scripts/maps/SkyPillar_Top.inc b/data/scripts/maps/SkyPillar_Top.inc index d5a4e477c..7d7e575fc 100644 --- a/data/scripts/maps/SkyPillar_Top.inc +++ b/data/scripts/maps/SkyPillar_Top.inc @@ -53,7 +53,7 @@ SkyPillar_Top_EventScript_239722:: @ 8239722 waitmoncry setwildbattle SPECIES_RAYQUAZA, 70, ITEM_NONE setflag FLAG_SYS_CTRL_OBJ_DELETE - special sub_80B0934 + special BattleSetup_StartLegendaryBattle waitstate clearflag FLAG_SYS_CTRL_OBJ_DELETE specialvar VAR_RESULT, sub_8138B80 diff --git a/data/scripts/maps/SouthernIsland_Interior.inc b/data/scripts/maps/SouthernIsland_Interior.inc index 1853c08b8..aa19dc5fb 100644 --- a/data/scripts/maps/SouthernIsland_Interior.inc +++ b/data/scripts/maps/SouthernIsland_Interior.inc @@ -87,7 +87,7 @@ SouthernIsland_Interior_EventScript_242AD0:: @ 8242AD0 compare_var_to_value VAR_0x40D5, 0 call_if 5, SouthernIsland_Interior_EventScript_242BB7 setflag FLAG_SYS_CTRL_OBJ_DELETE - special sub_80B08EC + special BattleSetup_StartLatiBattle waitstate clearflag FLAG_SYS_CTRL_OBJ_DELETE specialvar VAR_RESULT, sub_8138B80 diff --git a/data/scripts/maps/TerraCave_End.inc b/data/scripts/maps/TerraCave_End.inc index a39856dda..f3168036f 100644 --- a/data/scripts/maps/TerraCave_End.inc +++ b/data/scripts/maps/TerraCave_End.inc @@ -38,7 +38,7 @@ TerraCave_End_EventScript_23B0EC:: @ 823B0EC setvar VAR_LAST_TALKED, 1 setwildbattle SPECIES_GROUDON, 70, ITEM_NONE setflag FLAG_SYS_CTRL_OBJ_DELETE - special sub_80B0934 + special BattleSetup_StartLegendaryBattle waitstate clearflag FLAG_SYS_CTRL_OBJ_DELETE setvar VAR_0x4001, 0 diff --git a/data/specials.inc b/data/specials.inc index 19adbae4d..e1a355870 100644 --- a/data/specials.inc +++ b/data/specials.inc @@ -167,7 +167,7 @@ gSpecials:: @ 81DBA64 def_special Special_StartWallClock def_special Special_ViewWallClock def_special sub_80B1138 - def_special sub_80B086C + def_special StartWallyTutorialBattle def_special ChangePokemonNickname def_special sub_81B94B0 def_special GetFirstFreePokeblockSlot @@ -320,9 +320,9 @@ gSpecials:: @ 81DBA64 def_special sub_8139540 def_special sub_809E1C8 def_special sub_8139560 - def_special sub_80B0A18 - def_special sub_80B0934 - def_special sub_80B0A74 + def_special StartGroudonKyogreBattle + def_special BattleSetup_StartLegendaryBattle + def_special StartRegiBattle def_special sub_80B16D8 def_special DoSealedChamberShakingEffect2 def_special sub_8139634 @@ -332,7 +332,7 @@ gSpecials:: @ 81DBA64 def_special sub_80F8D28 def_special sub_80F8EB8 def_special sub_8162794 - def_special sub_80B08EC + def_special BattleSetup_StartLatiBattle def_special sub_8139648 def_special sub_8139668 def_special sub_80F8FA0 diff --git a/include/battle.h b/include/battle.h index c172cb0f6..4551c3dd6 100644 --- a/include/battle.h +++ b/include/battle.h @@ -53,7 +53,7 @@ #define BATTLE_TYPE_PALACE 0x20000 #define BATTLE_TYPE_ARENA 0x40000 #define BATTLE_TYPE_FACTORY 0x80000 -#define BATTLE_TYPE_x100000 0x100000 +#define BATTLE_TYPE_PIKE 0x100000 #define BATTLE_TYPE_PYRAMID 0x200000 #define BATTLE_TYPE_INGAME_PARTNER 0x400000 #define BATTLE_TYPE_x800000 0x800000 @@ -72,8 +72,8 @@ #define STEVEN_PARTNER_ID 0xC03 #define SECRET_BASE_OPPONENT 0x400 -#define BATTLE_TYPE_FRONTIER (BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_DOME | BATTLE_TYPE_PALACE | BATTLE_TYPE_ARENA | BATTLE_TYPE_FACTORY | BATTLE_TYPE_x100000 | BATTLE_TYPE_PYRAMID) -#define BATTLE_TYPE_FRONTIER_NO_PYRAMID (BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_DOME | BATTLE_TYPE_PALACE | BATTLE_TYPE_ARENA | BATTLE_TYPE_FACTORY | BATTLE_TYPE_x100000) +#define BATTLE_TYPE_FRONTIER (BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_DOME | BATTLE_TYPE_PALACE | BATTLE_TYPE_ARENA | BATTLE_TYPE_FACTORY | BATTLE_TYPE_PIKE | BATTLE_TYPE_PYRAMID) +#define BATTLE_TYPE_FRONTIER_NO_PYRAMID (BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_DOME | BATTLE_TYPE_PALACE | BATTLE_TYPE_ARENA | BATTLE_TYPE_FACTORY | BATTLE_TYPE_PIKE) #define BATTLE_WON 0x1 #define BATTLE_LOST 0x2 @@ -228,9 +228,9 @@ #define BATTLE_TERRAIN_UNDERWATER 3 #define BATTLE_TERRAIN_WATER 4 #define BATTLE_TERRAIN_POND 5 -#define BATTLE_TERRAIN_ROCK 6 +#define BATTLE_TERRAIN_MOUNTAIN 6 #define BATTLE_TERRAIN_CAVE 7 -#define BATTLE_TERRAIN_INSIDE 8 +#define BATTLE_TERRAIN_BUILDING 8 #define BATTLE_TERRAIN_PLAIN 9 // array entries for battle communication @@ -327,10 +327,10 @@ struct TrainerMonItemCustomMoves union TrainerMonPtr { - struct TrainerMonNoItemDefaultMoves* NoItemDefaultMoves; - struct TrainerMonNoItemCustomMoves* NoItemCustomMoves; - struct TrainerMonItemDefaultMoves* ItemDefaultMoves; - struct TrainerMonItemCustomMoves* ItemCustomMoves; + struct TrainerMonNoItemDefaultMoves *NoItemDefaultMoves; + struct TrainerMonNoItemCustomMoves *NoItemCustomMoves; + struct TrainerMonItemDefaultMoves *ItemDefaultMoves; + struct TrainerMonItemCustomMoves *ItemCustomMoves; }; struct Trainer diff --git a/include/battle_transition.h b/include/battle_transition.h index 1603f5c93..26b836c66 100644 --- a/include/battle_transition.h +++ b/include/battle_transition.h @@ -2,5 +2,51 @@ #define GUARD_BATTLE_TRANSITION_H void sub_8149DFC(u8 a1); +void BattleTransition_StartOnField(u8 transitionID); +void BattleTransition_Start(u8 transitionID); +bool8 IsBattleTransitionDone(void); + +#define TRANSITIONS_NO 25 + +enum // TRANSITION_MUGSHOT +{ + MUGSHOT_SYDNEY, + MUGSHOT_PHOEBE, + MUGSHOT_GLACIA, + MUGSHOT_DRAKE, + MUGSHOT_STEVEN, +}; + +#define MUGSHOTS_NO 5 + +// credits for the names go to Dyskinesia and Tetrable +// names are naturally subject to change + +#define B_TRANSITION_BLUR 0 +#define B_TRANSITION_SWIRL 1 +#define B_TRANSITION_SHUFFLE 2 +#define B_TRANSITION_BIG_POKEBALL 3 +#define B_TRANSITION_POKEBALLS_TRAIL 4 +#define B_TRANSITION_CLOCKWISE_BLACKFADE 5 +#define B_TRANSITION_RIPPLE 6 +#define B_TRANSITION_WAVE 7 +#define B_TRANSITION_SLICE 8 +#define B_TRANSITION_WHITEFADE 9 +#define B_TRANSITION_GRID_SQUARES 10 +#define B_TRANSITION_SHARDS 11 +#define B_TRANSITION_SYDNEY 12 +#define B_TRANSITION_PHOEBE 13 +#define B_TRANSITION_GLACIA 14 +#define B_TRANSITION_DRAKE 15 +#define B_TRANSITION_STEVEN 16 +// added in Emerald +#define B_TRANSITION_AQUA 17 +#define B_TRANSITION_MAGMA 18 +#define B_TRANSITION_REGICE 19 +#define B_TRANSITION_REGISTEEL 20 +#define B_TRANSITION_REGIROCK 21 +#define B_TRANSITION_KYORGE 22 +#define B_TRANSITION_GROUDON 23 +#define B_TRANSITION_RAYQUAZA 24 #endif // GUARD_BATTLE_TRANSITION_H diff --git a/include/pokemon_3.h b/include/pokemon_3.h index 5c9862d57..66ed0d9b2 100644 --- a/include/pokemon_3.h +++ b/include/pokemon_3.h @@ -3,5 +3,6 @@ const u8* GetTrainerClassNameFromId(u16 trainerId); const u8* GetTrainerNameFromId(u16 trainerId); +void PlayMapChosenOrBattleBGM(u16 song); #endif // GUARD_POKEMON_3_H diff --git a/include/safari_zone.h b/include/safari_zone.h index 9a81894b8..39ee3ccb3 100644 --- a/include/safari_zone.h +++ b/include/safari_zone.h @@ -13,6 +13,8 @@ void ExitSafariMode(void); bool8 SafariZoneTakeStep(void); void SafariZoneRetirePrompt(void); +void CB2_EndSafariBattle(void); + struct Pokeblock *SafariZoneGetActivePokeblock(void); void SafariZoneActivatePokeblockFeeder(u8 pokeblock_index); diff --git a/include/songs.h b/include/songs.h index 5a1fff00c..37c4f16b4 100644 --- a/include/songs.h +++ b/include/songs.h @@ -372,20 +372,20 @@ enum BGM_BATTLE_DOME_TOURNAMENT, BGM_BATTLE_PIKE, BGM_BATTLE_FACTORY, - BGM_BATTLE_LEGENDARY, - BGM_BATTLE_FRONTIER_BRAIN, - BGM_BATTLE_MEW, - BGM_BATTLE_DOME, // end of the human-readable names + /*0x1D6*/ BGM_BATTLE_LEGENDARY, + /*0x1D7*/ BGM_BATTLE_FRONTIER_BRAIN, + /*0x1D8*/ BGM_BATTLE_MEW, + /*0x1D9*/ BGM_BATTLE_DOME, // end of the human-readable names /*0x1DA*/ BGM_BATTLE27, // wild - BGM_BATTLE31, // aqua/magma grunt - BGM_BATTLE20, // trainer - BGM_BATTLE32, // gym leader - BGM_BATTLE33, // champion - BGM_BATTLE36, // regi - BGM_BATTLE34, // weather trio - BGM_BATTLE35, // rival - BGM_BATTLE38, // elite four - BGM_BATTLE30, // aqua/magma leader + /*0x1DB*/ BGM_BATTLE31, // aqua/magma grunt + /*0x1DC*/ BGM_BATTLE20, // trainer + /*0x1DD*/ BGM_BATTLE32, // gym leader + /*0x1DE*/ BGM_BATTLE33, // champion + /*0x1DF*/ BGM_BATTLE36, // regi + /*0x1E0*/ BGM_BATTLE34, // weather trio + /*0x1E1*/ BGM_BATTLE35, // rival + /*0x1E2*/ BGM_BATTLE38, // elite four + /*0x1E3*/ BGM_BATTLE30, // aqua/magma leader /*0x1E4*/ BGM_FRLG_FOLLOW_ME, // FR/LG names not known, human-readable again! BGM_FRLG_GAMECORNER, BGM_FRLG_ROCKET_HIDEOUT, @@ -453,14 +453,14 @@ enum BGM_FRLG_ISLAND_FOUR, BGM_FRLG_ISLAND_SIX, BGM_FRLG_FLUTE, - BGM_FRLG_BATTLE_DEOXYS, - BGM_FRLG_BATTLE_MEWTWO, - BGM_FRLG_BATTLE_LEGENDARY, - BGM_FRLG_LEADER_EYE, - BGM_FRLG_DEOXYS_EYE, - BGM_FRLG_TRAINER_TOWER, - BGM_FRLG_HALL_OF_FAME_PALLET_TOWN, - /*0x22E*/BGM_FRLG_TEACHY_TV, + /*0x227*/ BGM_FRLG_BATTLE_DEOXYS, + /*0x228*/ BGM_FRLG_BATTLE_MEWTWO, + /*0x229*/ BGM_FRLG_BATTLE_LEGENDARY, + /*0x22A*/ BGM_FRLG_LEADER_EYE, + /*0x22B*/ BGM_FRLG_DEOXYS_EYE, + /*0x22C*/ BGM_FRLG_TRAINER_TOWER, + /*0x22D*/ BGM_FRLG_HALL_OF_FAME_PALLET_TOWN, + /*0x22E*/ BGM_FRLG_TEACHY_TV, }; #endif // GUARD_SONGS_H diff --git a/include/trainer_ids.h b/include/trainer_ids.h index 65c80187f..5d807789b 100644 --- a/include/trainer_ids.h +++ b/include/trainer_ids.h @@ -2,6 +2,11 @@ #define GUARD_TRAINER_IDS_H #define NO_OF_TRAINERS 854 + +#define TRAINER_ID_SIDNEY 261 +#define TRAINER_ID_PHOEBE 262 +#define TRAINER_ID_GLACIA 263 +#define TRAINER_ID_DRAKE 264 #define TRAINER_ID_STEVEN 804 #endif // GUARD_TRAINER_IDS_H diff --git a/include/vars.h b/include/vars.h index 763b7379d..0851ad700 100644 --- a/include/vars.h +++ b/include/vars.h @@ -14,6 +14,7 @@ #define VAR_0x4008 0x4008 #define VAR_0x4009 0x4009 #define VAR_0x400A 0x400A +#define VAR_0x400E 0x400E #define VAR_0x4010 0x4010 #define VAR_0x4011 0x4011 #define VAR_0x401F 0x401F diff --git a/ld_script.txt b/ld_script.txt index 8a3d6ecb0..2337dff3b 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -119,6 +119,7 @@ SECTIONS { asm/battle_anim_80A9C70.o(.text); 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); asm/trainer_see.o(.text); @@ -377,6 +378,7 @@ SECTIONS { data/battle_anim_80A9C70.o(.rodata); 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); diff --git a/src/battle_setup.c b/src/battle_setup.c new file mode 100644 index 000000000..310616b60 --- /dev/null +++ b/src/battle_setup.c @@ -0,0 +1,586 @@ +#include "global.h" +#include "battle.h" +#include "battle_setup.h" +#include "battle_transition.h" +#include "main.h" +#include "task.h" +#include "pokemon_3.h" +#include "safari_zone.h" +#include "script.h" +#include "game_stat.h" +#include "event_data.h" +#include "species.h" +#include "songs.h" +#include "metatile_behavior.h" +#include "map_constants.h" +#include "field_player_avatar.h" +#include "fieldmap.h" +#include "trainer_classes.h" +#include "trainer_ids.h" + +extern bool8 InBattlePyramid(void); +extern bool8 InBattlePike(void); +extern bool32 FieldPoisonEffectIsRunning(void); +extern void overworld_free_bg_tilemaps(void); +extern void prev_quest_postbuffer_cursor_backup_reset(void); +extern void ResetPoisonStepCounter(void); +extern void sub_81BE72C(void); +extern void FreezeMapObjects(void); +extern void sub_808BCF4(void); +extern void sub_80EECC8(void); +extern void c2_exit_to_overworld_1_continue_scripts_restart_music(void); +extern void c2_exit_to_overworld_2_switch(void); +extern void CB2_WhiteOut(void); +extern void sub_80AF6F0(void); +extern u8 GetSav1Weather(void); +extern u8 Overworld_GetFlashLevel(void); + +extern u32 gBattleTypeFlags; +extern u8 gBattleOutcome; +extern void (*gFieldCallback)(void); +extern u16 gTrainerBattleOpponent_A; +extern u16 gTrainerBattleOpponent_B; + +// 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(u8 arg0); +void sub_80B1218(void); +void sub_80B1234(void); +bool32 IsPlayerDefeated(u8 battleOutcome); + +// const rom data + +// The first transition is used if the enemy pokemon are lower level than our pokemon. +// Otherwise, the second transition is used. +static const u8 sBattleTransitionTable_Wild[][2] = +{ + {B_TRANSITION_SLICE, B_TRANSITION_WHITEFADE}, // Normal + {B_TRANSITION_CLOCKWISE_BLACKFADE, B_TRANSITION_GRID_SQUARES}, // Cave + {B_TRANSITION_BLUR, B_TRANSITION_GRID_SQUARES}, // Cave with flash used + {B_TRANSITION_WAVE, B_TRANSITION_RIPPLE}, // Water +}; + +static const u8 sBattleTransitionTable_Trainer[][2] = +{ + {B_TRANSITION_POKEBALLS_TRAIL, B_TRANSITION_SHARDS}, // Normal + {B_TRANSITION_SHUFFLE, B_TRANSITION_BIG_POKEBALL}, // Cave + {B_TRANSITION_BLUR, B_TRANSITION_GRID_SQUARES}, // Cave with flash used + {B_TRANSITION_SWIRL, B_TRANSITION_RIPPLE}, // Water +}; + +#define tState data[0] +#define tTransition data[1] + +void Task_BattleStart(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + + switch (tState) + { + case 0: + if (!FieldPoisonEffectIsRunning()) // is poison not active? + { + BattleTransition_StartOnField(tTransition); + sub_81BE72C(); + tState++; // go to case 1. + } + break; + case 1: + if (IsBattleTransitionDone() == TRUE) + { + overworld_free_bg_tilemaps(); + SetMainCallback2(CB2_InitBattle); + prev_quest_postbuffer_cursor_backup_reset(); + ResetPoisonStepCounter(); + DestroyTask(taskId); + } + break; + } +} + +void CreateBattleStartTask(u8 transition, u16 song) +{ + u8 taskId = CreateTask(Task_BattleStart, 1); + + gTasks[taskId].tTransition = transition; + PlayMapChosenOrBattleBGM(song); +} + +#undef tState +#undef tTransition + +void BattleSetup_StartWildBattle(void) +{ + if (GetSafariZoneFlag()) + DoSafariBattle(); + else + DoStandardWildBattle(); +} + +void BattleSetup_StartBattlePikeWildBattle(void) +{ + DoBattlePikeWildBattle(); +} + +void DoStandardWildBattle(void) +{ + ScriptContext2_Enable(); + FreezeMapObjects(); + sub_808BCF4(); + gMain.savedCallback = CB2_EndWildBattle; + gBattleTypeFlags = 0; + if (InBattlePyramid()) + { + VarSet(VAR_0x400E, 0); + gBattleTypeFlags |= BATTLE_TYPE_PYRAMID; + } + CreateBattleStartTask(GetWildBattleTransition(), 0); + IncrementGameStat(GAME_STAT_TOTAL_BATTLES); + IncrementGameStat(GAME_STAT_WILD_BATTLES); + sub_80EECC8(); + sub_80B1218(); +} + +void BattleSetup_StartRoamerBattle(void) +{ + ScriptContext2_Enable(); + FreezeMapObjects(); + sub_808BCF4(); + gMain.savedCallback = CB2_EndWildBattle; + gBattleTypeFlags = BATTLE_TYPE_ROAMER; + CreateBattleStartTask(GetWildBattleTransition(), 0); + IncrementGameStat(GAME_STAT_TOTAL_BATTLES); + IncrementGameStat(GAME_STAT_WILD_BATTLES); + sub_80EECC8(); + sub_80B1218(); +} + +void DoSafariBattle(void) +{ + ScriptContext2_Enable(); + FreezeMapObjects(); + sub_808BCF4(); + gMain.savedCallback = CB2_EndSafariBattle; + gBattleTypeFlags = BATTLE_TYPE_SAFARI; + CreateBattleStartTask(GetWildBattleTransition(), 0); +} + +void DoBattlePikeWildBattle(void) +{ + ScriptContext2_Enable(); + FreezeMapObjects(); + sub_808BCF4(); + gMain.savedCallback = CB2_EndWildBattle; + gBattleTypeFlags = BATTLE_TYPE_PIKE; + CreateBattleStartTask(GetWildBattleTransition(), 0); + IncrementGameStat(GAME_STAT_TOTAL_BATTLES); + IncrementGameStat(GAME_STAT_WILD_BATTLES); + sub_80EECC8(); + sub_80B1218(); +} + +void DoTrainerBattle(void) +{ + CreateBattleStartTask(GetTrainerBattleTransition(), 0); + IncrementGameStat(GAME_STAT_TOTAL_BATTLES); + IncrementGameStat(GAME_STAT_TRAINER_BATTLES); + sub_80B1234(); +} + +void sub_80B0828(void) +{ + if (InBattlePyramid()) + CreateBattleStartTask(sub_80B100C(10), 0); + else + CreateBattleStartTask(sub_80B100C(11), 0); + + IncrementGameStat(GAME_STAT_TOTAL_BATTLES); + IncrementGameStat(GAME_STAT_TRAINER_BATTLES); + sub_80B1234(); +} + +// Initiates battle where Wally catches Ralts +void StartWallyTutorialBattle(void) +{ + CreateMaleMon(&gEnemyParty[0], SPECIES_RALTS, 5); + ScriptContext2_Enable(); + gMain.savedCallback = c2_exit_to_overworld_1_continue_scripts_restart_music; + gBattleTypeFlags = BATTLE_TYPE_WALLY_TUTORIAL; + CreateBattleStartTask(B_TRANSITION_SLICE, 0); +} + +void BattleSetup_StartScriptedWildBattle(void) +{ + ScriptContext2_Enable(); + gMain.savedCallback = CB2_EndScriptedWildBattle; + gBattleTypeFlags = 0; + CreateBattleStartTask(GetWildBattleTransition(), 0); + IncrementGameStat(GAME_STAT_TOTAL_BATTLES); + IncrementGameStat(GAME_STAT_WILD_BATTLES); + sub_80EECC8(); + sub_80B1218(); +} + +void BattleSetup_StartLatiBattle(void) +{ + ScriptContext2_Enable(); + gMain.savedCallback = CB2_EndScriptedWildBattle; + gBattleTypeFlags = BATTLE_TYPE_LEGENDARY; + CreateBattleStartTask(GetWildBattleTransition(), 0); + IncrementGameStat(GAME_STAT_TOTAL_BATTLES); + IncrementGameStat(GAME_STAT_WILD_BATTLES); + sub_80EECC8(); + sub_80B1218(); +} + +void BattleSetup_StartLegendaryBattle(void) +{ + ScriptContext2_Enable(); + gMain.savedCallback = CB2_EndScriptedWildBattle; + gBattleTypeFlags = BATTLE_TYPE_LEGENDARY; + + switch (GetMonData(&gEnemyParty[0], MON_DATA_SPECIES, NULL)) + { + default: + case SPECIES_GROUDON: + gBattleTypeFlags |= BATTLE_TYPE_GROUDON; + CreateBattleStartTask(B_TRANSITION_GROUDON, BGM_BATTLE34); + break; + case SPECIES_KYOGRE: + gBattleTypeFlags |= BATTLE_TYPE_KYORGE; + CreateBattleStartTask(B_TRANSITION_KYORGE, BGM_BATTLE34); + break; + case SPECIES_RAYQUAZA: + gBattleTypeFlags |= BATTLE_TYPE_RAYQUAZA; + CreateBattleStartTask(B_TRANSITION_RAYQUAZA, BGM_BATTLE_LEGENDARY); + break; + case SPECIES_DEOXYS: + CreateBattleStartTask(B_TRANSITION_BLUR, BGM_FRLG_BATTLE_DEOXYS); + break; + case SPECIES_LUGIA: + case SPECIES_HO_OH: + CreateBattleStartTask(B_TRANSITION_BLUR, BGM_FRLG_BATTLE_LEGENDARY); + break; + case SPECIES_MEW: + CreateBattleStartTask(B_TRANSITION_GRID_SQUARES, BGM_BATTLE_MEW); + break; + } + + IncrementGameStat(GAME_STAT_TOTAL_BATTLES); + IncrementGameStat(GAME_STAT_WILD_BATTLES); + sub_80EECC8(); + sub_80B1218(); +} + +void StartGroudonKyogreBattle(void) +{ + ScriptContext2_Enable(); + gMain.savedCallback = CB2_EndScriptedWildBattle; + gBattleTypeFlags = BATTLE_TYPE_LEGENDARY | BATTLE_TYPE_KYOGRE_GROUDON; + + if (gGameVersion == VERSION_RUBY) + CreateBattleStartTask(B_TRANSITION_SHARDS, BGM_BATTLE34); // GROUDON + else + CreateBattleStartTask(B_TRANSITION_RIPPLE, BGM_BATTLE34); // KYOGRE + + IncrementGameStat(GAME_STAT_TOTAL_BATTLES); + IncrementGameStat(GAME_STAT_WILD_BATTLES); + sub_80EECC8(); + sub_80B1218(); +} + +void StartRegiBattle(void) +{ + u8 transitionId; + u16 species; + + ScriptContext2_Enable(); + gMain.savedCallback = CB2_EndScriptedWildBattle; + gBattleTypeFlags = BATTLE_TYPE_LEGENDARY | BATTLE_TYPE_REGI; + + species = GetMonData(&gEnemyParty[0], MON_DATA_SPECIES); + switch (species) + { + case SPECIES_REGIROCK: + transitionId = B_TRANSITION_REGIROCK; + break; + case SPECIES_REGICE: + transitionId = B_TRANSITION_REGICE; + break; + case SPECIES_REGISTEEL: + transitionId = B_TRANSITION_REGISTEEL; + break; + default: + transitionId = B_TRANSITION_GRID_SQUARES; + break; + } + CreateBattleStartTask(transitionId, BGM_BATTLE36); + + IncrementGameStat(GAME_STAT_TOTAL_BATTLES); + IncrementGameStat(GAME_STAT_WILD_BATTLES); + sub_80EECC8(); + sub_80B1218(); +} + +void CB2_EndWildBattle(void) +{ + CpuFill16(0, (void*)(BG_PLTT), BG_PLTT_SIZE); + ResetOamRange(0, 128); + + if (IsPlayerDefeated(gBattleOutcome) == TRUE && !InBattlePyramid() && !InBattlePike()) + { + SetMainCallback2(CB2_WhiteOut); + } + else + { + SetMainCallback2(c2_exit_to_overworld_2_switch); + gFieldCallback = sub_80AF6F0; + } +} + +void CB2_EndScriptedWildBattle(void) +{ + CpuFill16(0, (void*)(BG_PLTT), BG_PLTT_SIZE); + ResetOamRange(0, 128); + + if (IsPlayerDefeated(gBattleOutcome) == TRUE) + { + if (InBattlePyramid()) + 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); + } +} + +u8 BattleSetup_GetTerrainId(void) +{ + u16 tileBehavior; + s16 x, y; + + PlayerGetDestCoords(&x, &y); + tileBehavior = MapGridGetMetatileBehaviorAt(x, y); + + if (MetatileBehavior_IsTallGrass(tileBehavior)) + return BATTLE_TERRAIN_GRASS; + if (MetatileBehavior_IsLongGrass(tileBehavior)) + return BATTLE_TERRAIN_LONG_GRASS; + if (MetatileBehavior_IsSandOrDeepSand(tileBehavior)) + return BATTLE_TERRAIN_SAND; + + switch (gMapHeader.mapType) + { + case MAP_TYPE_TOWN: + case MAP_TYPE_CITY: + case MAP_TYPE_ROUTE: + break; + case MAP_TYPE_UNDERGROUND: + if (MetatileBehavior_IsMB_0B(tileBehavior)) + return BATTLE_TERRAIN_BUILDING; + if (MetatileBehavior_IsSurfableWaterOrUnderwater(tileBehavior)) + return BATTLE_TERRAIN_POND; + return BATTLE_TERRAIN_CAVE; + case MAP_TYPE_INDOOR: + case MAP_TYPE_SECRET_BASE: + return BATTLE_TERRAIN_BUILDING; + case MAP_TYPE_UNDERWATER: + return BATTLE_TERRAIN_UNDERWATER; + case MAP_TYPE_6: + if (MetatileBehavior_IsSurfableWaterOrUnderwater(tileBehavior)) + return BATTLE_TERRAIN_WATER; + return BATTLE_TERRAIN_PLAIN; + } + if (MetatileBehavior_IsDeepOrOceanWater(tileBehavior)) + return BATTLE_TERRAIN_WATER; + if (MetatileBehavior_IsSurfableWaterOrUnderwater(tileBehavior)) + return BATTLE_TERRAIN_POND; + if (MetatileBehavior_IsMountain(tileBehavior)) + return BATTLE_TERRAIN_MOUNTAIN; + if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_SURFING)) + { + if (MetatileBehavior_GetBridgeSth(tileBehavior)) + return BATTLE_TERRAIN_POND; + if (MetatileBehavior_IsBridge(tileBehavior) == TRUE) + return BATTLE_TERRAIN_WATER; + } + if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP_ROUTE113 && gSaveBlock1Ptr->location.mapNum == MAP_ID_ROUTE113) + return BATTLE_TERRAIN_SAND; + if (GetSav1Weather() == 8) + return BATTLE_TERRAIN_SAND; + + return BATTLE_TERRAIN_PLAIN; +} + +u8 GetBattleTransitionTypeByMap(void) +{ + u16 tileBehavior; + s16 x, y; + + PlayerGetDestCoords(&x, &y); + tileBehavior = MapGridGetMetatileBehaviorAt(x, y); + if (Overworld_GetFlashLevel()) + return B_TRANSITION_SHUFFLE; + if (!MetatileBehavior_IsSurfableWaterOrUnderwater(tileBehavior)) + { + switch (gMapHeader.mapType) + { + case MAP_TYPE_UNDERGROUND: + return B_TRANSITION_SWIRL; + case MAP_TYPE_UNDERWATER: + return B_TRANSITION_BIG_POKEBALL; + default: + return B_TRANSITION_BLUR; + } + } + return B_TRANSITION_BIG_POKEBALL; +} + +u16 GetSumOfPlayerPartyLevel(u8 numMons) +{ + u8 sum = 0; + int i; + + for (i = 0; i < PARTY_SIZE; i++) + { + u32 species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); + + if (species != SPECIES_EGG && species != SPECIES_NONE && GetMonData(&gPlayerParty[i], MON_DATA_HP) != 0) + { + sum += GetMonData(&gPlayerParty[i], MON_DATA_LEVEL); + if (--numMons == 0) + break; + } + } + return sum; +} + +u8 GetSumOfEnemyPartyLevel(u16 opponentId, u8 numMons) +{ + u8 i; + u8 sum; + u32 count = numMons; + + if (gTrainers[opponentId].partySize < count) + count = gTrainers[opponentId].partySize; + + sum = 0; + + switch (gTrainers[opponentId].partyFlags) + { + case 0: + { + const struct TrainerMonNoItemDefaultMoves *party; + party = gTrainers[opponentId].party.NoItemDefaultMoves; + for (i = 0; i < count; i++) + sum += party[i].lvl; + } + break; + case PARTY_FLAG_CUSTOM_MOVES: + { + const struct TrainerMonNoItemCustomMoves *party; + party = gTrainers[opponentId].party.NoItemCustomMoves; + for (i = 0; i < count; i++) + sum += party[i].lvl; + } + break; + case PARTY_FLAG_HAS_ITEM: + { + const struct TrainerMonItemDefaultMoves *party; + party = gTrainers[opponentId].party.ItemDefaultMoves; + for (i = 0; i < count; i++) + sum += party[i].lvl; + } + break; + case PARTY_FLAG_CUSTOM_MOVES | PARTY_FLAG_HAS_ITEM: + { + const struct TrainerMonItemCustomMoves *party; + party = gTrainers[opponentId].party.ItemCustomMoves; + for (i = 0; i < count; i++) + sum += party[i].lvl; + } + break; + } + + return sum; +} + +u8 GetWildBattleTransition(void) +{ + u8 transitionType = GetBattleTransitionTypeByMap(); + u8 enemyLevel = GetMonData(&gEnemyParty[0], MON_DATA_LEVEL); + u8 playerLevel = GetSumOfPlayerPartyLevel(1); + + if (enemyLevel < playerLevel) + { + if (InBattlePyramid()) + return B_TRANSITION_BLUR; + else + return sBattleTransitionTable_Wild[transitionType][0]; + } + else + { + if (InBattlePyramid()) + return B_TRANSITION_GRID_SQUARES; + else + return sBattleTransitionTable_Wild[transitionType][1]; + } +} + +u8 GetTrainerBattleTransition(void) +{ + u8 minPartyCount; + u8 transitionType; + u8 enemyLevel; + u8 playerLevel; + + if (gTrainerBattleOpponent_A == SECRET_BASE_OPPONENT) + return B_TRANSITION_STEVEN; + + if (gTrainers[gTrainerBattleOpponent_A].trainerClass == CLASS_ELITE_FOUR) + { + if (gTrainerBattleOpponent_A == TRAINER_ID_SIDNEY) + return B_TRANSITION_SYDNEY; + if (gTrainerBattleOpponent_A == TRAINER_ID_PHOEBE) + return B_TRANSITION_PHOEBE; + if (gTrainerBattleOpponent_A == TRAINER_ID_GLACIA) + return B_TRANSITION_GLACIA; + if (gTrainerBattleOpponent_A == TRAINER_ID_DRAKE) + return B_TRANSITION_DRAKE; + return B_TRANSITION_STEVEN; + } + + if (gTrainers[gTrainerBattleOpponent_A].trainerClass == CLASS_CHAMPION) + return B_TRANSITION_STEVEN; + + if (gTrainers[gTrainerBattleOpponent_A].trainerClass == CLASS_TEAM_MAGMA + || gTrainers[gTrainerBattleOpponent_A].trainerClass == CLASS_MAGMA_LEADER + || gTrainers[gTrainerBattleOpponent_A].trainerClass == CLASS_MAGMA_ADMIN) + return B_TRANSITION_MAGMA; + + if (gTrainers[gTrainerBattleOpponent_A].trainerClass == CLASS_TEAM_AQUA + || gTrainers[gTrainerBattleOpponent_A].trainerClass == CLASS_AQUA_LEADER + || gTrainers[gTrainerBattleOpponent_A].trainerClass == CLASS_AQUA_ADMIN) + return B_TRANSITION_AQUA; + + if (gTrainers[gTrainerBattleOpponent_A].doubleBattle == TRUE) + minPartyCount = 2; // double battles always at least have 2 pokemon. + else + minPartyCount = 1; + + transitionType = GetBattleTransitionTypeByMap(); + enemyLevel = GetSumOfEnemyPartyLevel(gTrainerBattleOpponent_A, minPartyCount); + playerLevel = GetSumOfPlayerPartyLevel(minPartyCount); + if (enemyLevel < playerLevel) // is wild mon level than the player's mon level? + return sBattleTransitionTable_Trainer[transitionType][0]; + else + return sBattleTransitionTable_Trainer[transitionType][1]; +} diff --git a/src/pokemon_3.c b/src/pokemon_3.c index 1fafee810..b7a95fc64 100644 --- a/src/pokemon_3.c +++ b/src/pokemon_3.c @@ -1396,7 +1396,7 @@ static s32 GetWildMonTableIdInAlteringCave(u16 species) void SetWildMonHeldItem(void) { - if (!(gBattleTypeFlags & (BATTLE_TYPE_LEGENDARY | BATTLE_TYPE_TRAINER | BATTLE_TYPE_PYRAMID | BATTLE_TYPE_x100000))) + if (!(gBattleTypeFlags & (BATTLE_TYPE_LEGENDARY | BATTLE_TYPE_TRAINER | BATTLE_TYPE_PYRAMID | BATTLE_TYPE_PIKE))) { u16 rnd = Random() % 100; u16 species = GetMonData(&gEnemyParty[0], MON_DATA_SPECIES, 0); diff --git a/src/safari_zone.c b/src/safari_zone.c index d3d40af28..38abcdd4c 100644 --- a/src/safari_zone.c +++ b/src/safari_zone.c @@ -105,7 +105,7 @@ void SafariZoneRetirePrompt(void) ScriptContext1_SetupScript(EventScript_2A4B6F); } -void sub_80FC190(void) +void CB2_EndSafariBattle(void) { sSafariZoneFleedMons += gBattleResults.field_1F; if (gBattleOutcome == BATTLE_CAUGHT)