diff --git a/asm/battle_frontier_2.s b/asm/battle_frontier_2.s index f92f964bb..43ad02708 100755 --- a/asm/battle_frontier_2.s +++ b/asm/battle_frontier_2.s @@ -25426,8 +25426,8 @@ sub_81A7B84: @ 81A7B84 .pool thumb_func_end sub_81A7B84 - thumb_func_start sub_81A7B90 -sub_81A7B90: @ 81A7B90 + thumb_func_start TryGenerateBattlePikeWildMon +TryGenerateBattlePikeWildMon: @ 81A7B90 push {r4-r7,lr} mov r7, r10 mov r6, r9 @@ -25437,7 +25437,7 @@ sub_81A7B90: @ 81A7B90 lsls r0, 24 lsrs r0, 24 mov r8, r0 - bl sub_81A7D00 + bl GetBattlePikeWildMonHeaderId lsls r0, 24 lsrs r6, r0, 24 ldr r7, =gSaveBlock2Ptr @@ -25596,10 +25596,10 @@ _081A7CE2: pop {r1} bx r1 .pool - thumb_func_end sub_81A7B90 + thumb_func_end TryGenerateBattlePikeWildMon - thumb_func_start sub_81A7D00 -sub_81A7D00: @ 81A7D00 + thumb_func_start GetBattlePikeWildMonHeaderId +GetBattlePikeWildMonHeaderId: @ 81A7D00 push {lr} ldr r0, =gSaveBlock2Ptr ldr r1, [r0] @@ -25638,7 +25638,7 @@ _081A7D4C: adds r0, r1, 0 pop {r1} bx r1 - thumb_func_end sub_81A7D00 + thumb_func_end GetBattlePikeWildMonHeaderId thumb_func_start sub_81A7D54 sub_81A7D54: @ 81A7D54 @@ -29386,8 +29386,8 @@ _081A9B86: .pool thumb_func_end sub_81A9B44 - thumb_func_start sub_81A9C04 -sub_81A9C04: @ 81A9C04 + thumb_func_start GenerateBattlePyramidWildMon +GenerateBattlePyramidWildMon: @ 81A9C04 push {r4-r6,lr} sub sp, 0x14 ldr r0, =gSaveBlock2Ptr @@ -29627,7 +29627,7 @@ _081A9E0C: pop {r0} bx r0 .pool - thumb_func_end sub_81A9C04 + thumb_func_end GenerateBattlePyramidWildMon thumb_func_start sub_81A9E28 sub_81A9E28: @ 81A9E28 diff --git a/asm/battle_setup.s b/asm/battle_setup.s index 621749734..f77e7a5d0 100644 --- a/asm/battle_setup.s +++ b/asm/battle_setup.s @@ -82,8 +82,8 @@ task_add_01_battle_start: @ 80B065C .pool thumb_func_end task_add_01_battle_start - thumb_func_start sub_80B0698 -sub_80B0698: @ 80B0698 + thumb_func_start BattleSetup_StartWildBattle +BattleSetup_StartWildBattle: @ 80B0698 push {lr} bl GetSafariZoneFlag cmp r0, 0 @@ -95,15 +95,15 @@ _080B06A8: _080B06AC: pop {r0} bx r0 - thumb_func_end sub_80B0698 + thumb_func_end BattleSetup_StartWildBattle - thumb_func_start sub_80B06B0 -sub_80B06B0: @ 80B06B0 + thumb_func_start BattleSetup_StartBattlePikeWildBattle +BattleSetup_StartBattlePikeWildBattle: @ 80B06B0 push {lr} bl sub_80B07B4 pop {r0} bx r0 - thumb_func_end sub_80B06B0 + thumb_func_end BattleSetup_StartBattlePikeWildBattle thumb_func_start sub_80B06BC sub_80B06BC: @ 80B06BC @@ -147,8 +147,8 @@ _080B06F2: .pool thumb_func_end sub_80B06BC - thumb_func_start sub_80B072C -sub_80B072C: @ 80B072C + thumb_func_start BattleSetup_StartRoamerBattle +BattleSetup_StartRoamerBattle: @ 80B072C push {lr} bl ScriptContext2_Enable bl player_bitmagic @@ -174,7 +174,7 @@ sub_80B072C: @ 80B072C pop {r0} bx r0 .pool - thumb_func_end sub_80B072C + thumb_func_end BattleSetup_StartRoamerBattle thumb_func_start sub_80B077C sub_80B077C: @ 80B077C diff --git a/asm/field_control_avatar.s b/asm/field_control_avatar.s index b85c6de07..29164ed7b 100644 --- a/asm/field_control_avatar.s +++ b/asm/field_control_avatar.s @@ -1246,7 +1246,7 @@ sub_809C8DC: @ 809C8DC lsrs r0, 24 cmp r0, 0x1 beq _0809C92E - bl sub_80B5870 + bl UpdateRepelCounter lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -1607,7 +1607,7 @@ _0809CC0C: ldr r5, =gUnknown_020375D6 ldrh r1, [r5] adds r0, r4, 0 - bl is_it_battle_time_2 + bl StandardWildEncounter lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 diff --git a/asm/field_player_avatar.s b/asm/field_player_avatar.s index 34ff54f61..ae405f127 100644 --- a/asm/field_player_avatar.s +++ b/asm/field_player_avatar.s @@ -4316,7 +4316,7 @@ fish5: @ 808CABC adds r0, 0x1 strh r0, [r5, 0x8] movs r6, 0 - bl GetFishingWildMonListHeader + bl DoesCurrentMapHaveFishingMons lsls r0, 24 cmp r0, 0 bne _0808CADC @@ -4640,7 +4640,7 @@ _0808CD58: ldrh r0, [r5, 0x26] lsls r0, 24 lsrs r0, 24 - bl sub_80B5734 + bl FishingWildEncounter movs r0, 0x1 bl sub_80ED950 ldr r0, =Task_Fish diff --git a/asm/pokeblock_feed.s b/asm/pokeblock_feed.s index 9830db888..9cbee2fb9 100644 --- a/asm/pokeblock_feed.s +++ b/asm/pokeblock_feed.s @@ -704,7 +704,7 @@ sub_817A1C4: @ 817A1C4 lsls r0, 24 lsrs r0, 24 adds r1, r4, 0 - bl sub_8136FE4 + bl PokeblockGetGain ldr r6, =gUnknown_0203BC9E strh r0, [r6] ldr r1, =gStringVar1 diff --git a/asm/rom4.s b/asm/rom4.s index 3f59c2807..8b7dec1ae 100644 --- a/asm/rom4.s +++ b/asm/rom4.s @@ -2675,12 +2675,12 @@ sub_8085B2C: @ 8085B2C ldr r1, =gUnknown_02032306 movs r0, 0x1 strb r0, [r1] - bl sub_80B582C + bl GetLocalWaterMon b _08085B62 .pool _08085B5C: ldr r0, =gUnknown_02032306 - bl wild_pokemon_rand_for_map + bl GetLocalWildMon _08085B62: ldr r1, =gUnknown_02032304 strh r0, [r1] diff --git a/asm/rom6.s b/asm/rom6.s index f07689a86..ebff777ea 100644 --- a/asm/rom6.s +++ b/asm/rom6.s @@ -2779,7 +2779,7 @@ sub_8136C8C: @ 8136C8C adds r2, r6 ldr r1, [r5] adds r1, r2 - bl sub_8136FE4 + bl PokeblockGetGain adds r4, r0, 0 lsls r4, 16 lsrs r4, 16 @@ -3177,8 +3177,8 @@ _08136FDE: bx r1 thumb_func_end sub_8136F9C - thumb_func_start sub_8136FE4 -sub_8136FE4: @ 8136FE4 + thumb_func_start PokeblockGetGain +PokeblockGetGain: @ 8136FE4 push {r4-r7,lr} mov r7, r9 mov r6, r8 @@ -3227,7 +3227,7 @@ _0813702A: pop {r1} bx r1 .pool - thumb_func_end sub_8136FE4 + thumb_func_end PokeblockGetGain thumb_func_start sub_8137044 sub_8137044: @ 8137044 @@ -3261,7 +3261,7 @@ _08137074: ldr r0, =gUnknown_085B2720 adds r1, r0 adds r0, r5, 0 - bl sub_8136FE4 + bl PokeblockGetGain lsls r0, 16 cmp r0, 0 ble _081370A0 diff --git a/asm/wild_encounter.s b/asm/wild_encounter.s deleted file mode 100644 index 70346e4d7..000000000 --- a/asm/wild_encounter.s +++ /dev/null @@ -1,2353 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start sub_80B48B8 -sub_80B48B8: @ 80B48B8 - ldr r1, =gUnknown_02038C00 - strb r0, [r1] - bx lr - .pool - thumb_func_end sub_80B48B8 - - thumb_func_start sub_80B48C4 -sub_80B48C4: @ 80B48C4 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x8 - lsls r0, 16 - lsrs r0, 16 - str r0, [sp] - lsls r1, 16 - lsrs r1, 16 - str r1, [sp, 0x4] - lsls r2, 24 - lsrs r2, 24 - ldr r3, =gUnknown_08553A7C - lsls r1, r2, 1 - adds r1, r2 - lsls r2, r1, 1 - adds r2, r3 - adds r0, r1, 0x1 - lsls r0, 1 - adds r0, r3 - ldrh r0, [r0] - mov r9, r0 - adds r1, 0x2 - lsls r1, 1 - adds r1, r3 - ldrh r6, [r1] - ldrh r5, [r2] - cmp r5, r9 - bhi _080B496E - ldr r0, =gMapHeader - mov r10, r0 -_080B4906: - movs r4, 0 - mov r1, r10 - ldr r0, [r1] - ldr r0, [r0] - cmp r4, r0 - bge _080B4964 - ldr r1, [sp] - lsls r0, r1, 16 - asrs r0, 16 - mov r8, r0 - ldr r1, [sp, 0x4] - lsls r0, r1, 16 - asrs r7, r0, 16 -_080B4920: - adds r0, r4, 0x7 - adds r1, r5, 0x7 - bl MapGridGetMetatileBehaviorAt - lsls r0, 24 - lsrs r0, 24 - bl MetatileBehavior_IsSurfableAndNotWaterfall - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _080B4954 - adds r0, r6, 0x1 - lsls r0, 16 - lsrs r6, r0, 16 - cmp r8, r4 - bne _080B4954 - cmp r7, r5 - bne _080B4954 - adds r0, r6, 0 - b _080B4974 - .pool -_080B4954: - adds r0, r4, 0x1 - lsls r0, 16 - lsrs r4, r0, 16 - mov r1, r10 - ldr r0, [r1] - ldr r0, [r0] - cmp r4, r0 - blt _080B4920 -_080B4964: - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - cmp r5, r9 - bls _080B4906 -_080B496E: - adds r0, r6, 0x1 - lsls r0, 16 - lsrs r0, 16 -_080B4974: - add sp, 0x8 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_80B48C4 - - thumb_func_start sub_80B4984 -sub_80B4984: @ 80B4984 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x10 - movs r7, 0 - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldrh r1, [r0, 0x4] - movs r0, 0x88 - lsls r0, 6 - cmp r1, r0 - bne _080B4A7A - add r5, sp, 0xC - mov r4, sp - adds r4, 0xE - adds r0, r5, 0 - adds r1, r4, 0 - bl GetXYCoordsOneStepInFrontOfPlayer - ldrh r0, [r5] - subs r0, 0x7 - strh r0, [r5] - ldrh r0, [r4] - subs r0, 0x7 - strh r0, [r4] - movs r0, 0 - ldrsh r1, [r4, r0] - ldr r0, =gUnknown_08553A7C - mov r9, r5 - mov r8, r4 - ldrh r2, [r0, 0x6] - cmp r1, r2 - blt _080B49D0 - ldrh r3, [r0, 0x8] - cmp r1, r3 - bgt _080B49D0 - movs r7, 0x1 -_080B49D0: - mov r2, r8 - movs r3, 0 - ldrsh r1, [r2, r3] - ldrh r2, [r0, 0xC] - cmp r1, r2 - blt _080B49E4 - ldrh r0, [r0, 0xE] - cmp r1, r0 - bgt _080B49E4 - movs r7, 0x2 -_080B49E4: - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x64 - bl __umodsi3 - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x31 - bls _080B4A08 - b _080B4A7A - .pool -_080B4A04: - movs r0, 0x1 - b _080B4A7C -_080B4A08: - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r3, =0x00002e6a - adds r0, r3 - ldrh r0, [r0] - bl sub_80B4AB8 - movs r5, 0 - ldr r6, =0x000001bf -_080B4A1A: - bl sub_80B4A98 - lsls r1, r5, 1 - mov r2, sp - adds r4, r2, r1 - lsls r0, 16 - lsrs r0, 16 - adds r1, r6, 0 - bl __umodsi3 - strh r0, [r4] - lsls r0, 16 - cmp r0, 0 - bne _080B4A38 - strh r6, [r4] -_080B4A38: - ldrh r0, [r4] - subs r0, 0x1 - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x2 - bls _080B4A4A - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 -_080B4A4A: - cmp r5, 0x6 - bne _080B4A1A - mov r3, r9 - movs r1, 0 - ldrsh r0, [r3, r1] - mov r2, r8 - movs r3, 0 - ldrsh r1, [r2, r3] - adds r2, r7, 0 - bl sub_80B48C4 - lsls r0, 16 - lsrs r1, r0, 16 - movs r5, 0 -_080B4A66: - lsls r0, r5, 1 - add r0, sp - ldrh r0, [r0] - cmp r1, r0 - beq _080B4A04 - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x5 - bls _080B4A66 -_080B4A7A: - movs r0, 0 -_080B4A7C: - add sp, 0x10 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80B4984 - - thumb_func_start sub_80B4A98 -sub_80B4A98: @ 80B4A98 - ldr r2, =gUnknown_02038C04 - ldr r1, [r2] - ldr r0, =0x41c64e6d - muls r0, r1 - ldr r1, =0x00003039 - adds r0, r1 - str r0, [r2] - lsrs r0, 16 - bx lr - .pool - thumb_func_end sub_80B4A98 - - thumb_func_start sub_80B4AB8 -sub_80B4AB8: @ 80B4AB8 - lsls r0, 16 - lsrs r0, 16 - ldr r1, =gUnknown_02038C04 - str r0, [r1] - bx lr - .pool - thumb_func_end sub_80B4AB8 - - thumb_func_start wild_pokemon_rand_grass -wild_pokemon_rand_grass: @ 80B4AC8 - push {lr} - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x64 - bl __umodsi3 - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x13 - bhi _080B4AE4 - movs r0, 0 - b _080B4B7E -_080B4AE4: - adds r0, r1, 0 - subs r0, 0x14 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x13 - bhi _080B4AF4 - movs r0, 0x1 - b _080B4B7E -_080B4AF4: - adds r0, r1, 0 - subs r0, 0x28 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x9 - bhi _080B4B04 - movs r0, 0x2 - b _080B4B7E -_080B4B04: - adds r0, r1, 0 - subs r0, 0x32 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x9 - bhi _080B4B14 - movs r0, 0x3 - b _080B4B7E -_080B4B14: - adds r0, r1, 0 - subs r0, 0x3C - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x9 - bhi _080B4B24 - movs r0, 0x4 - b _080B4B7E -_080B4B24: - adds r0, r1, 0 - subs r0, 0x46 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x9 - bhi _080B4B34 - movs r0, 0x5 - b _080B4B7E -_080B4B34: - adds r0, r1, 0 - subs r0, 0x50 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x4 - bhi _080B4B44 - movs r0, 0x6 - b _080B4B7E -_080B4B44: - adds r0, r1, 0 - subs r0, 0x55 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x4 - bhi _080B4B54 - movs r0, 0x7 - b _080B4B7E -_080B4B54: - adds r0, r1, 0 - subs r0, 0x5A - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x3 - bhi _080B4B64 - movs r0, 0x8 - b _080B4B7E -_080B4B64: - adds r0, r1, 0 - subs r0, 0x5E - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x3 - bhi _080B4B74 - movs r0, 0x9 - b _080B4B7E -_080B4B74: - cmp r1, 0x62 - beq _080B4B7C - movs r0, 0xB - b _080B4B7E -_080B4B7C: - movs r0, 0xA -_080B4B7E: - pop {r1} - bx r1 - thumb_func_end wild_pokemon_rand_grass - - thumb_func_start wild_pokemon_rand_water -wild_pokemon_rand_water: @ 80B4B84 - push {lr} - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x64 - bl __umodsi3 - lsls r0, 24 - lsrs r1, r0, 24 - adds r2, r1, 0 - cmp r1, 0x3B - bhi _080B4BA2 - movs r0, 0 - b _080B4BD4 -_080B4BA2: - adds r0, r1, 0 - subs r0, 0x3C - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1D - bhi _080B4BB2 - movs r0, 0x1 - b _080B4BD4 -_080B4BB2: - adds r0, r1, 0 - subs r0, 0x5A - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x4 - bhi _080B4BC2 - movs r0, 0x2 - b _080B4BD4 -_080B4BC2: - adds r0, r2, 0 - subs r0, 0x5F - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x3 - bls _080B4BD2 - movs r0, 0x4 - b _080B4BD4 -_080B4BD2: - movs r0, 0x3 -_080B4BD4: - pop {r1} - bx r1 - thumb_func_end wild_pokemon_rand_water - - thumb_func_start sub_80B4BD8 -sub_80B4BD8: @ 80B4BD8 - push {r4-r6,lr} - lsls r0, 24 - lsrs r4, r0, 24 - adds r6, r4, 0 - movs r5, 0 - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x64 - bl __umodsi3 - lsls r0, 24 - lsrs r1, r0, 24 - cmp r4, 0x1 - beq _080B4C12 - cmp r4, 0x1 - bgt _080B4C02 - cmp r4, 0 - beq _080B4C08 - b _080B4C6C -_080B4C02: - cmp r6, 0x2 - beq _080B4C36 - b _080B4C6C -_080B4C08: - movs r5, 0x1 - cmp r1, 0x45 - bhi _080B4C6C - movs r5, 0 - b _080B4C6C -_080B4C12: - cmp r1, 0x3B - bhi _080B4C18 - movs r5, 0x2 -_080B4C18: - adds r0, r1, 0 - subs r0, 0x3C - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x13 - bhi _080B4C26 - movs r5, 0x3 -_080B4C26: - adds r0, r1, 0 - subs r0, 0x50 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x13 - bhi _080B4C6C - movs r5, 0x4 - b _080B4C6C -_080B4C36: - cmp r1, 0x27 - bhi _080B4C3C - movs r5, 0x5 -_080B4C3C: - adds r0, r1, 0 - subs r0, 0x28 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x27 - bhi _080B4C4A - movs r5, 0x6 -_080B4C4A: - adds r0, r1, 0 - subs r0, 0x50 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0xE - bhi _080B4C58 - movs r5, 0x7 -_080B4C58: - adds r0, r1, 0 - subs r0, 0x5F - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x3 - bhi _080B4C66 - movs r5, 0x8 -_080B4C66: - cmp r1, 0x63 - bne _080B4C6C - movs r5, 0x9 -_080B4C6C: - adds r0, r5, 0 - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_80B4BD8 - - thumb_func_start sub_80B4C74 -sub_80B4C74: @ 80B4C74 - push {r4-r7,lr} - adds r4, r0, 0 - ldrb r0, [r4, 0x1] - ldrb r1, [r4] - cmp r0, r1 - bcc _080B4C86 - ldrb r7, [r4] - adds r6, r0, 0 - b _080B4C8A -_080B4C86: - ldrb r7, [r4, 0x1] - ldrb r6, [r4] -_080B4C8A: - subs r4, r6, r7 - adds r4, 0x1 - lsls r4, 24 - lsrs r4, 24 - bl Random - lsls r0, 16 - lsrs r0, 16 - adds r1, r4, 0 - bl __modsi3 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r5, =gPlayerParty - adds r0, r5, 0 - movs r1, 0x6 - bl GetMonData - cmp r0, 0 - bne _080B4CEA - adds r0, r5, 0 - bl GetMonAbility - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x37 - beq _080B4CC8 - cmp r0, 0x48 - beq _080B4CC8 - cmp r0, 0x2E - bne _080B4CEA -_080B4CC8: - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x1 - ands r0, r1 - cmp r0, 0 - bne _080B4CE0 - adds r0, r6, 0 - b _080B4CF0 - .pool -_080B4CE0: - cmp r4, 0 - beq _080B4CEA - subs r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 -_080B4CEA: - adds r0, r7, r4 - lsls r0, 24 - lsrs r0, 24 -_080B4CF0: - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_80B4C74 - - thumb_func_start get_wild_data_index_for_map -get_wild_data_index_for_map: @ 80B4CF8 - push {r4-r6,lr} - movs r4, 0 - ldr r0, =gWildMonHeaders - ldrb r1, [r0] - adds r5, r0, 0 - cmp r1, 0xFF - beq _080B4D6C - ldr r6, =0x00006a18 -_080B4D08: - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 2 - adds r3, r0, r5 - ldrb r1, [r3] - ldr r0, =gSaveBlock1Ptr - ldr r2, [r0] - movs r0, 0x4 - ldrsb r0, [r2, r0] - cmp r1, r0 - bne _080B4D58 - ldrb r1, [r3, 0x1] - movs r0, 0x5 - ldrsb r0, [r2, r0] - cmp r1, r0 - bne _080B4D58 - ldrh r0, [r2, 0x4] - cmp r0, r6 - bne _080B4D44 - ldr r0, =0x0000403e - bl VarGet - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x8 - bls _080B4D3E - movs r0, 0 -_080B4D3E: - adds r0, r4, r0 - lsls r0, 16 - lsrs r4, r0, 16 -_080B4D44: - adds r0, r4, 0 - b _080B4D6E - .pool -_080B4D58: - adds r0, r4, 0x1 - lsls r0, 16 - lsrs r4, r0, 16 - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 2 - adds r0, r5 - ldrb r0, [r0] - cmp r0, 0xFF - bne _080B4D08 -_080B4D6C: - ldr r0, =0x0000ffff -_080B4D6E: - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end get_wild_data_index_for_map - - thumb_func_start sub_80B4D78 -sub_80B4D78: @ 80B4D78 - push {r4-r7,lr} - sub sp, 0x1C - bl GetSafariZoneFlag - cmp r0, 0x1 - bne _080B4E0E - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x64 - bl __umodsi3 - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x4F - bhi _080B4E0E - bl SafariZoneGetActivePokeblock - adds r7, r0, 0 - cmp r7, 0 - beq _080B4E0E - movs r5, 0 -_080B4DA6: - mov r1, sp - adds r0, r1, r5 - strb r5, [r0] - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x18 - bls _080B4DA6 - movs r5, 0 -_080B4DB8: - adds r1, r5, 0x1 - lsls r0, r1, 24 - lsrs r4, r0, 24 - adds r6, r1, 0 - cmp r4, 0x18 - bhi _080B4DE8 - add r5, sp -_080B4DC6: - bl Random - movs r1, 0x1 - ands r1, r0 - cmp r1, 0 - beq _080B4DDE - ldrb r2, [r5] - mov r0, sp - adds r1, r0, r4 - ldrb r0, [r1] - strb r0, [r5] - strb r2, [r1] -_080B4DDE: - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x18 - bls _080B4DC6 -_080B4DE8: - lsls r0, r6, 24 - lsrs r5, r0, 24 - cmp r5, 0x17 - bls _080B4DB8 - movs r5, 0 -_080B4DF2: - mov r1, sp - adds r4, r1, r5 - ldrb r0, [r4] - adds r1, r7, 0 - bl sub_8136FE4 - lsls r0, 16 - cmp r0, 0 - bgt _080B4E48 - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x18 - bls _080B4DF2 -_080B4E0E: - ldr r4, =gPlayerParty - adds r0, r4, 0 - movs r1, 0x6 - bl GetMonData - cmp r0, 0 - bne _080B4E4C - adds r0, r4, 0 - bl GetMonAbility - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1C - bne _080B4E4C - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x1 - ands r0, r1 - cmp r0, 0 - bne _080B4E4C - adds r0, r4, 0 - movs r1, 0 - bl GetMonData - b _080B4E54 - .pool -_080B4E48: - ldrb r0, [r4] - b _080B4E5E -_080B4E4C: - bl Random - lsls r0, 16 - lsrs r0, 16 -_080B4E54: - movs r1, 0x19 - bl __umodsi3 - lsls r0, 24 - lsrs r0, 24 -_080B4E5E: - add sp, 0x1C - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_80B4D78 - - thumb_func_start sub_80B4E68 -sub_80B4E68: @ 80B4E68 - push {r4-r7,lr} - sub sp, 0xC - lsls r0, 16 - lsrs r6, r0, 16 - lsls r1, 24 - lsrs r7, r1, 24 - bl ZeroEnemyPartyMons - movs r2, 0x1 - ldr r1, =gBaseStats - lsls r0, r6, 3 - subs r0, r6 - lsls r0, 2 - adds r0, r1 - ldrb r0, [r0, 0x10] - cmp r0, 0 - beq _080B4E96 - cmp r0, 0 - blt _080B4E98 - cmp r0, 0xFF - bgt _080B4E98 - cmp r0, 0xFE - blt _080B4E98 -_080B4E96: - movs r2, 0 -_080B4E98: - cmp r2, 0 - beq _080B4F28 - ldr r5, =gPlayerParty - adds r0, r5, 0 - movs r1, 0x6 - bl GetMonData - cmp r0, 0 - bne _080B4F28 - adds r0, r5, 0 - bl GetMonAbility - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x38 - bne _080B4F28 - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x3 - bl __umodsi3 - lsls r0, 16 - cmp r0, 0 - beq _080B4F28 - adds r0, r5, 0 - movs r1, 0xB - bl GetMonData - adds r4, r0, 0 - lsls r4, 16 - lsrs r4, 16 - adds r0, r5, 0 - movs r1, 0 - bl GetMonData - adds r1, r0, 0 - adds r0, r4, 0 - bl GetGenderFromSpeciesAndPersonality - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0xFE - bne _080B4F00 - movs r4, 0 - b _080B4F02 - .pool -_080B4F00: - movs r4, 0xFE -_080B4F02: - bl sub_80B4D78 - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gEnemyParty - str r4, [sp] - str r0, [sp, 0x4] - movs r0, 0 - str r0, [sp, 0x8] - adds r0, r1, 0 - adds r1, r6, 0 - adds r2, r7, 0 - movs r3, 0x20 - bl CreateMonWithGenderNatureLetter - b _080B4F40 - .pool -_080B4F28: - bl sub_80B4D78 - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gEnemyParty - str r0, [sp] - adds r0, r1, 0 - adds r1, r6, 0 - adds r2, r7, 0 - movs r3, 0x20 - bl CreateMonWithNature -_080B4F40: - add sp, 0xC - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B4E68 - - thumb_func_start sub_80B4F4C -sub_80B4F4C: @ 80B4F4C - push {r4-r6,lr} - sub sp, 0x4 - adds r5, r0, 0 - lsls r1, 24 - lsrs r3, r1, 24 - adds r4, r3, 0 - lsls r2, 24 - lsrs r6, r2, 24 - movs r1, 0 - mov r0, sp - strb r1, [r0] - cmp r3, 0x1 - beq _080B4FA0 - cmp r3, 0x1 - bgt _080B4F70 - cmp r3, 0 - beq _080B4F76 - b _080B4FBA -_080B4F70: - cmp r4, 0x2 - beq _080B4FB2 - b _080B4FBA -_080B4F76: - ldr r0, [r5, 0x4] - movs r1, 0x8 - movs r2, 0x2A - mov r3, sp - bl TryGetAbilityInfluencedWildMonIndex - lsls r0, 24 - cmp r0, 0 - bne _080B4FBA - ldr r0, [r5, 0x4] - movs r1, 0xD - movs r2, 0x9 - mov r3, sp - bl TryGetAbilityInfluencedWildMonIndex - lsls r0, 24 - cmp r0, 0 - bne _080B4FBA - bl wild_pokemon_rand_grass - b _080B4FB6 -_080B4FA0: - ldr r0, [r5, 0x4] - movs r1, 0xD - movs r2, 0x9 - mov r3, sp - bl TryGetAbilityInfluencedWildMonIndex - lsls r0, 24 - cmp r0, 0 - bne _080B4FBA -_080B4FB2: - bl wild_pokemon_rand_water -_080B4FB6: - mov r1, sp - strb r0, [r1] -_080B4FBA: - mov r0, sp - ldrb r1, [r0] - lsls r1, 2 - ldr r0, [r5, 0x4] - adds r0, r1 - bl sub_80B4C74 - lsls r0, 24 - lsrs r4, r0, 24 - movs r0, 0x1 - ands r0, r6 - cmp r0, 0 - beq _080B4FE0 - adds r0, r4, 0 - bl sub_80B58CC - lsls r0, 24 - cmp r0, 0 - beq _080B5000 -_080B4FE0: - ldr r0, =gMapHeader - ldrh r1, [r0, 0x12] - movs r0, 0xB3 - lsls r0, 1 - cmp r1, r0 - beq _080B5008 - movs r0, 0x2 - ands r0, r6 - cmp r0, 0 - beq _080B5008 - adds r0, r4, 0 - bl DoKeenEyeIntimidateWildEncounterTest - lsls r0, 24 - cmp r0, 0 - bne _080B5008 -_080B5000: - movs r0, 0 - b _080B501C - .pool -_080B5008: - mov r0, sp - ldrb r0, [r0] - ldr r1, [r5, 0x4] - lsls r0, 2 - adds r0, r1 - ldrh r0, [r0, 0x2] - adds r1, r4, 0 - bl sub_80B4E68 - movs r0, 0x1 -_080B501C: - add sp, 0x4 - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_80B4F4C - - thumb_func_start sub_80B5024 -sub_80B5024: @ 80B5024 - push {r4,r5,lr} - adds r5, r0, 0 - lsls r0, r1, 24 - lsrs r0, 24 - bl sub_80B4BD8 - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 22 - ldr r0, [r5, 0x4] - adds r0, r4 - bl sub_80B4C74 - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - ldr r0, [r5, 0x4] - adds r0, r4, r0 - ldrh r0, [r0, 0x2] - bl sub_80B4E68 - ldr r0, [r5, 0x4] - adds r4, r0 - ldrh r0, [r4, 0x2] - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80B5024 - - thumb_func_start SetUpMassOutbreakEncounter -SetUpMassOutbreakEncounter: @ 80B505C - push {r4,lr} - lsls r0, 24 - lsrs r0, 24 - movs r1, 0x1 - ands r0, r1 - cmp r0, 0 - beq _080B508C - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r1, =0x00002b94 - adds r0, r1 - ldrb r0, [r0] - bl sub_80B58CC - lsls r0, 24 - cmp r0, 0 - bne _080B508C - movs r0, 0 - b _080B50C6 - .pool -_080B508C: - ldr r0, =gSaveBlock1Ptr - ldr r1, [r0] - ldr r2, =0x00002b90 - adds r0, r1, r2 - ldrh r0, [r0] - adds r2, 0x4 - adds r1, r2 - ldrb r1, [r1] - bl sub_80B4E68 - movs r4, 0 -_080B50A2: - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - lsls r1, r4, 1 - ldr r2, =0x00002b98 - adds r0, r2 - adds r0, r1 - ldrh r1, [r0] - lsls r2, r4, 24 - lsrs r2, 24 - ldr r0, =gEnemyParty - bl SetMonMoveSlot - adds r0, r4, 0x1 - lsls r0, 16 - lsrs r4, r0, 16 - cmp r4, 0x3 - bls _080B50A2 - movs r0, 0x1 -_080B50C6: - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end SetUpMassOutbreakEncounter - - thumb_func_start DoMassOutbreakEncounterTest -DoMassOutbreakEncounterTest: @ 80B50DC - push {r4,lr} - ldr r4, =gSaveBlock1Ptr - ldr r2, [r4] - ldr r1, =0x00002b90 - adds r0, r2, r1 - ldrh r0, [r0] - cmp r0, 0 - beq _080B513C - movs r1, 0x5 - ldrsb r1, [r2, r1] - ldr r3, =0x00002b92 - adds r0, r2, r3 - ldrb r0, [r0] - cmp r1, r0 - bne _080B513C - movs r1, 0x4 - ldrsb r1, [r2, r1] - adds r3, 0x1 - adds r0, r2, r3 - ldrb r0, [r0] - cmp r1, r0 - bne _080B513C - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x64 - bl __umodsi3 - ldr r1, [r4] - ldr r2, =0x00002ba1 - adds r1, r2 - lsls r0, 16 - lsrs r0, 16 - ldrb r1, [r1] - cmp r0, r1 - bcs _080B513C - movs r0, 0x1 - b _080B513E - .pool -_080B513C: - movs r0, 0 -_080B513E: - pop {r4} - pop {r1} - bx r1 - thumb_func_end DoMassOutbreakEncounterTest - - thumb_func_start DoWildEncounterRateDiceRoll -DoWildEncounterRateDiceRoll: @ 80B5144 - push {r4,lr} - adds r4, r0, 0 - lsls r4, 16 - lsrs r4, 16 - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0xB4 - lsls r1, 4 - bl __umodsi3 - lsls r0, 16 - lsrs r0, 16 - cmp r0, r4 - bcc _080B5168 - movs r0, 0 - b _080B516A -_080B5168: - movs r0, 0x1 -_080B516A: - pop {r4} - pop {r1} - bx r1 - thumb_func_end DoWildEncounterRateDiceRoll - - thumb_func_start DoWildEncounterRateTest -DoWildEncounterRateTest: @ 80B5170 - push {r4,lr} - sub sp, 0x4 - str r0, [sp] - lsls r1, 24 - lsrs r4, r1, 24 - lsls r0, 4 - str r0, [sp] - movs r0, 0x6 - bl TestPlayerAvatarFlags - lsls r0, 24 - cmp r0, 0 - beq _080B519A - ldr r1, [sp] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 4 - movs r1, 0x64 - bl __udivsi3 - str r0, [sp] -_080B519A: - mov r0, sp - bl affects_encounter_rate_based_on_flags - mov r0, sp - bl ApplyCleanseTagWildEncounterRateReduction - cmp r4, 0 - bne _080B5216 - ldr r4, =gPlayerParty - adds r0, r4, 0 - movs r1, 0x6 - bl GetMonData - cmp r0, 0 - bne _080B5216 - adds r0, r4, 0 - bl GetMonAbility - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _080B51E8 - ldr r0, =gMapHeader - ldrh r1, [r0, 0x12] - ldr r0, =0x00000169 - cmp r1, r0 - bne _080B5210 - ldr r1, [sp] - lsls r0, r1, 1 - adds r0, r1 - lsrs r0, 2 - b _080B5214 - .pool -_080B51E8: - cmp r0, 0x23 - bne _080B51F2 - ldr r0, [sp] - lsls r0, 1 - b _080B5214 -_080B51F2: - cmp r0, 0x49 - beq _080B5210 - cmp r0, 0x47 - bne _080B5200 - ldr r0, [sp] - lsls r0, 1 - b _080B5214 -_080B5200: - cmp r0, 0x8 - bne _080B5216 - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - adds r0, 0x2E - ldrb r0, [r0] - cmp r0, 0x8 - bne _080B5216 -_080B5210: - ldr r0, [sp] - lsrs r0, 1 -_080B5214: - str r0, [sp] -_080B5216: - ldr r0, [sp] - movs r1, 0xB4 - lsls r1, 4 - cmp r0, r1 - bls _080B5222 - str r1, [sp] -_080B5222: - ldr r0, [sp] - lsls r0, 16 - lsrs r0, 16 - bl DoWildEncounterRateDiceRoll - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end DoWildEncounterRateTest - - thumb_func_start DoGlobalWildEncounterDiceRoll -DoGlobalWildEncounterDiceRoll: @ 80B523C - push {lr} - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x64 - bl __umodsi3 - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x3B - bhi _080B5258 - movs r0, 0x1 - b _080B525A -_080B5258: - movs r0, 0 -_080B525A: - pop {r1} - bx r1 - thumb_func_end DoGlobalWildEncounterDiceRoll - - thumb_func_start sub_80B5260 -sub_80B5260: @ 80B5260 - push {lr} - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldrh r1, [r0, 0x4] - movs r0, 0xE0 - lsls r0, 3 - cmp r1, r0 - bne _080B5280 - movs r0, 0x53 - bl FlagGet - lsls r0, 24 - lsrs r0, 24 - b _080B5282 - .pool -_080B5280: - movs r0, 0 -_080B5282: - pop {r1} - bx r1 - thumb_func_end sub_80B5260 - - thumb_func_start is_it_battle_time_2 -is_it_battle_time_2: @ 80B5288 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - lsls r0, 16 - lsrs r6, r0, 16 - mov r9, r6 - lsls r1, 16 - lsrs r7, r1, 16 - mov r8, r7 - ldr r0, =gUnknown_02038C00 - ldrb r0, [r0] - cmp r0, 0x1 - bne _080B52A6 - b _080B54FE -_080B52A6: - bl get_wild_data_index_for_map - lsls r0, 16 - lsrs r5, r0, 16 - ldr r0, =0x0000ffff - cmp r5, r0 - bne _080B539C - ldr r0, =gMapHeader - ldrh r1, [r0, 0x12] - movs r0, 0xB3 - lsls r0, 1 - cmp r1, r0 - bne _080B5330 - bl sub_81A7D00 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r7, r6 - beq _080B52D8 - bl DoGlobalWildEncounterDiceRoll - lsls r0, 24 - cmp r0, 0 - bne _080B52D8 - b _080B54FE -_080B52D8: - ldr r1, =gUnknown_08553A14 - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 2 - adds r1, 0x4 - adds r4, r0, r1 - ldr r0, [r4] - ldrb r0, [r0] - movs r1, 0 - bl DoWildEncounterRateTest - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _080B52F8 - b _080B54FE -_080B52F8: - ldr r0, [r4] - movs r1, 0 - movs r2, 0x2 - bl sub_80B4F4C - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _080B530C - b _080B54FE -_080B530C: - movs r0, 0x1 - bl sub_81A7B90 - cmp r0, 0 - bne _080B5318 - b _080B54FE -_080B5318: - bl sub_80B06B0 - movs r0, 0x1 - b _080B5500 - .pool -_080B5330: - ldr r0, =0x00000169 - cmp r1, r0 - beq _080B5338 - b _080B54FE -_080B5338: - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - ldr r1, =0x00000cb2 - adds r0, r1 - ldrh r5, [r0] - cmp r7, r6 - beq _080B5352 - bl DoGlobalWildEncounterDiceRoll - lsls r0, 24 - cmp r0, 0 - bne _080B5352 - b _080B54FE -_080B5352: - ldr r1, =gUnknown_08553894 - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 2 - adds r1, 0x4 - adds r4, r0, r1 - ldr r0, [r4] - ldrb r0, [r0] - movs r1, 0 - bl DoWildEncounterRateTest - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _080B5372 - b _080B54FE -_080B5372: - ldr r0, [r4] - movs r1, 0 - movs r2, 0x2 - bl sub_80B4F4C - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _080B5386 - b _080B54FE -_080B5386: - bl sub_81A9C04 - b _080B54F6 - .pool -_080B539C: - lsls r0, r6, 24 - lsrs r4, r0, 24 - adds r0, r4, 0 - bl MetatileBehavior_IsLandWildEncounter - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _080B543C - ldr r1, =gWildMonHeaders - lsls r2, r5, 2 - adds r0, r2, r5 - lsls r0, 2 - adds r1, 0x4 - adds r0, r1 - ldr r0, [r0] - adds r4, r2, 0 - cmp r0, 0 - bne _080B53C4 - b _080B54FE -_080B53C4: - cmp r7, r6 - beq _080B53D4 - bl DoGlobalWildEncounterDiceRoll - lsls r0, 24 - cmp r0, 0 - bne _080B53D4 - b _080B54FE -_080B53D4: - ldr r1, =gWildMonHeaders - adds r0, r4, r5 - lsls r0, 2 - adds r1, 0x4 - adds r0, r1 - ldr r0, [r0] - ldrb r0, [r0] - movs r1, 0 - bl DoWildEncounterRateTest - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _080B53F2 - b _080B54FE -_080B53F2: - bl TryStartRoamerEncounter - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _080B54BA - bl DoMassOutbreakEncounterTest - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _080B5418 - movs r0, 0x3 - bl SetUpMassOutbreakEncounter - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _080B54F6 -_080B5418: - ldr r1, =gWildMonHeaders - adds r0, r4, r5 - lsls r0, 2 - adds r1, 0x4 - adds r0, r1 - ldr r0, [r0] - movs r1, 0 - movs r2, 0x3 - bl sub_80B4F4C - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _080B54F6 - b _080B54FE - .pool -_080B543C: - adds r0, r4, 0 - bl MetatileBehavior_IsWaterWildEncounter - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _080B5464 - movs r0, 0x8 - bl TestPlayerAvatarFlags - lsls r0, 24 - cmp r0, 0 - beq _080B54FE - adds r0, r4, 0 - bl MetatileBehavior_IsBridge - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _080B54FE -_080B5464: - bl sub_80B5260 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _080B54FE - ldr r1, =gWildMonHeaders - lsls r2, r5, 2 - adds r0, r2, r5 - lsls r0, 2 - adds r1, 0x8 - adds r0, r1 - ldr r0, [r0] - adds r4, r2, 0 - cmp r0, 0 - beq _080B54FE - cmp r8, r9 - beq _080B5492 - bl DoGlobalWildEncounterDiceRoll - lsls r0, 24 - cmp r0, 0 - beq _080B54FE -_080B5492: - ldr r1, =gWildMonHeaders - adds r0, r4, r5 - lsls r0, 2 - adds r1, 0x8 - adds r4, r0, r1 - ldr r0, [r4] - ldrb r0, [r0] - movs r1, 0 - bl DoWildEncounterRateTest - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _080B54FE - bl TryStartRoamerEncounter - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _080B54E4 -_080B54BA: - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r1, =0x000031dc - adds r0, r1 - ldrb r0, [r0, 0xC] - bl sub_80B58CC - lsls r0, 24 - cmp r0, 0 - beq _080B54FE - bl sub_80B072C - movs r0, 0x1 - b _080B5500 - .pool -_080B54E4: - ldr r0, [r4] - movs r1, 0x1 - movs r2, 0x3 - bl sub_80B4F4C - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _080B54FE -_080B54F6: - bl sub_80B0698 - movs r0, 0x1 - b _080B5500 -_080B54FE: - movs r0, 0 -_080B5500: - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end is_it_battle_time_2 - - thumb_func_start rock_smash_wild_pokemon_encounter -rock_smash_wild_pokemon_encounter: @ 80B550C - push {r4,lr} - bl get_wild_data_index_for_map - lsls r0, 16 - lsrs r2, r0, 16 - ldr r0, =0x0000ffff - cmp r2, r0 - beq _080B5568 - ldr r1, =gWildMonHeaders - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 2 - adds r1, 0xC - adds r0, r1 - ldr r4, [r0] - cmp r4, 0 - beq _080B5554 - ldrb r0, [r4] - movs r1, 0x1 - bl DoWildEncounterRateTest - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _080B5568 - adds r0, r4, 0 - movs r1, 0x2 - movs r2, 0x3 - bl sub_80B4F4C - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x1 - bne _080B5568 - bl sub_80B0698 -_080B5554: - ldr r0, =gSpecialVar_Result - strh r4, [r0] - b _080B556E - .pool -_080B5568: - ldr r1, =gSpecialVar_Result - movs r0, 0 - strh r0, [r1] -_080B556E: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end rock_smash_wild_pokemon_encounter - - thumb_func_start SweetScentWildEncounter -SweetScentWildEncounter: @ 80B5578 - push {r4,r5,lr} - sub sp, 0x4 - mov r5, sp - adds r5, 0x2 - mov r0, sp - adds r1, r5, 0 - bl PlayerGetDestCoords - bl get_wild_data_index_for_map - lsls r0, 16 - lsrs r4, r0, 16 - ldr r0, =0x0000ffff - cmp r4, r0 - bne _080B562C - ldr r0, =gMapHeader - ldrh r1, [r0, 0x12] - movs r0, 0xB3 - lsls r0, 1 - cmp r1, r0 - bne _080B55E4 - bl sub_81A7D00 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, =gUnknown_08553A14 - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 2 - adds r1, 0x4 - adds r0, r1 - ldr r0, [r0] - movs r1, 0 - movs r2, 0 - bl sub_80B4F4C - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _080B55CA - b _080B56F2 -_080B55CA: - movs r0, 0 - bl sub_81A7B90 - bl sub_80B06B0 - movs r0, 0x1 - b _080B56F4 - .pool -_080B55E4: - ldr r0, =0x00000169 - cmp r1, r0 - beq _080B55EC - b _080B56F2 -_080B55EC: - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - ldr r1, =0x00000cb2 - adds r0, r1 - ldrh r4, [r0] - ldr r1, =gUnknown_08553894 - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 2 - adds r1, 0x4 - adds r0, r1 - ldr r0, [r0] - movs r1, 0 - movs r2, 0 - bl sub_80B4F4C - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _080B56F2 - bl sub_81A9C04 - b _080B56EA - .pool -_080B562C: - mov r0, sp - movs r2, 0 - ldrsh r0, [r0, r2] - movs r2, 0 - ldrsh r1, [r5, r2] - bl MapGridGetMetatileBehaviorAt - lsls r0, 24 - lsrs r0, 24 - bl MetatileBehavior_IsLandWildEncounter - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _080B568C - ldr r1, =gWildMonHeaders - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 2 - adds r1, 0x4 - adds r0, r1 - ldr r4, [r0] - cmp r4, 0 - beq _080B56F2 - bl TryStartRoamerEncounter - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _080B56D4 - bl DoMassOutbreakEncounterTest - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _080B5680 - movs r0, 0 - bl SetUpMassOutbreakEncounter - b _080B56EA - .pool -_080B5680: - adds r0, r4, 0 - movs r1, 0 - movs r2, 0 - bl sub_80B4F4C - b _080B56EA -_080B568C: - mov r0, sp - movs r1, 0 - ldrsh r0, [r0, r1] - movs r2, 0 - ldrsh r1, [r5, r2] - bl MapGridGetMetatileBehaviorAt - lsls r0, 24 - lsrs r0, 24 - bl MetatileBehavior_IsWaterWildEncounter - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _080B56F2 - bl sub_80B5260 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _080B56F2 - ldr r1, =gWildMonHeaders - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 2 - adds r1, 0x8 - adds r0, r1 - ldr r4, [r0] - cmp r4, 0 - beq _080B56F2 - bl TryStartRoamerEncounter - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _080B56E0 -_080B56D4: - bl sub_80B072C - movs r0, 0x1 - b _080B56F4 - .pool -_080B56E0: - adds r0, r4, 0 - movs r1, 0x1 - movs r2, 0 - bl sub_80B4F4C -_080B56EA: - bl sub_80B0698 - movs r0, 0x1 - b _080B56F4 -_080B56F2: - movs r0, 0 -_080B56F4: - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end SweetScentWildEncounter - - thumb_func_start GetFishingWildMonListHeader -GetFishingWildMonListHeader: @ 80B56FC - push {lr} - bl get_wild_data_index_for_map - lsls r0, 16 - lsrs r2, r0, 16 - ldr r0, =0x0000ffff - cmp r2, r0 - beq _080B572C - ldr r0, =gWildMonHeaders - lsls r1, r2, 2 - adds r1, r2 - lsls r1, 2 - adds r0, 0x10 - adds r1, r0 - ldr r0, [r1] - cmp r0, 0 - beq _080B572C - movs r0, 0x1 - b _080B572E - .pool -_080B572C: - movs r0, 0 -_080B572E: - pop {r1} - bx r1 - thumb_func_end GetFishingWildMonListHeader - - thumb_func_start sub_80B5734 -sub_80B5734: @ 80B5734 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - bl sub_80B4984 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _080B5764 - ldr r4, =gUnknown_08553A78 - adds r0, r4, 0 - bl sub_80B4C74 - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - ldrh r4, [r4, 0x2] - adds r0, r4, 0 - bl sub_80B4E68 - b _080B5784 - .pool -_080B5764: - ldr r4, =gWildMonHeaders - bl get_wild_data_index_for_map - lsls r0, 16 - lsrs r0, 16 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 2 - adds r4, 0x10 - adds r1, r4 - ldr r0, [r1] - adds r1, r5, 0 - bl sub_80B5024 - lsls r0, 16 - lsrs r4, r0, 16 -_080B5784: - movs r0, 0xC - bl IncrementGameStat - adds r0, r4, 0 - bl sub_80EDA3C - bl sub_80B0698 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B5734 - - thumb_func_start wild_pokemon_rand_for_map -wild_pokemon_rand_for_map: @ 80B57A0 - push {r4-r6,lr} - adds r6, r0, 0 - movs r0, 0 - strb r0, [r6] - bl get_wild_data_index_for_map - lsls r0, 16 - lsrs r3, r0, 16 - ldr r0, =0x0000ffff - cmp r3, r0 - beq _080B57D2 - ldr r2, =gWildMonHeaders - lsls r1, r3, 2 - adds r1, r3 - lsls r1, 2 - adds r0, r2, 0x4 - adds r0, r1, r0 - ldr r5, [r0] - adds r2, 0x8 - adds r1, r2 - ldr r4, [r1] - cmp r5, 0 - bne _080B57E0 - cmp r4, 0 - bne _080B57E6 -_080B57D2: - movs r0, 0 - b _080B5826 - .pool -_080B57E0: - cmp r4, 0 - bne _080B57F4 - b _080B5818 -_080B57E6: - movs r0, 0x1 - strb r0, [r6] - bl wild_pokemon_rand_water - lsls r0, 24 - ldr r1, [r4, 0x4] - b _080B5820 -_080B57F4: - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x64 - bl __umodsi3 - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x4F - bls _080B5818 - movs r0, 0x1 - strb r0, [r6] - bl wild_pokemon_rand_water - lsls r0, 24 - ldr r1, [r4, 0x4] - b _080B5820 -_080B5818: - bl wild_pokemon_rand_grass - lsls r0, 24 - ldr r1, [r5, 0x4] -_080B5820: - lsrs r0, 22 - adds r0, r1 - ldrh r0, [r0, 0x2] -_080B5826: - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end wild_pokemon_rand_for_map - - thumb_func_start sub_80B582C -sub_80B582C: @ 80B582C - push {r4,lr} - bl get_wild_data_index_for_map - lsls r0, 16 - lsrs r2, r0, 16 - ldr r0, =0x0000ffff - cmp r2, r0 - beq _080B5868 - ldr r1, =gWildMonHeaders - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 2 - adds r1, 0x8 - adds r0, r1 - ldr r4, [r0] - cmp r4, 0 - beq _080B5868 - bl wild_pokemon_rand_water - lsls r0, 24 - ldr r1, [r4, 0x4] - lsrs r0, 22 - adds r0, r1 - ldrh r0, [r0, 0x2] - b _080B586A - .pool -_080B5868: - movs r0, 0 -_080B586A: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_80B582C - - thumb_func_start sub_80B5870 -sub_80B5870: @ 80B5870 - push {r4,r5,lr} - bl InBattlePike - lsls r0, 24 - cmp r0, 0 - bne _080B58C4 - bl InBattlePyramid - lsls r0, 24 - cmp r0, 0 - bne _080B58C4 - bl InUnionRoom - cmp r0, 0x1 - beq _080B58C4 - ldr r5, =0x00004021 - adds r0, r5, 0 - bl VarGet - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0 - beq _080B58C4 - subs r4, r0, 0x1 - lsls r4, 16 - lsrs r4, 16 - adds r0, r5, 0 - adds r1, r4, 0 - bl VarSet - cmp r4, 0 - bne _080B58C4 - ldr r0, =EventScript_RepelWoreOff - bl ScriptContext1_SetupScript - movs r0, 0x1 - b _080B58C6 - .pool -_080B58C4: - movs r0, 0 -_080B58C6: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80B5870 - - thumb_func_start sub_80B58CC -sub_80B58CC: @ 80B58CC - push {r4-r6,lr} - lsls r0, 24 - lsrs r6, r0, 24 - ldr r0, =0x00004021 - bl VarGet - lsls r0, 16 - cmp r0, 0 - beq _080B5912 - movs r5, 0 -_080B58E0: - movs r0, 0x64 - adds r1, r5, 0 - muls r1, r0 - ldr r0, =gPlayerParty - adds r4, r1, r0 - adds r0, r4, 0 - movs r1, 0x39 - bl GetMonData - cmp r0, 0 - beq _080B5920 - adds r0, r4, 0 - movs r1, 0x2D - bl GetMonData - cmp r0, 0 - bne _080B5920 - adds r0, r4, 0 - movs r1, 0x38 - bl GetMonData - lsls r0, 24 - lsrs r0, 24 - cmp r6, r0 - bcc _080B592A -_080B5912: - movs r0, 0x1 - b _080B592C - .pool -_080B5920: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x5 - bls _080B58E0 -_080B592A: - movs r0, 0 -_080B592C: - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_80B58CC - - thumb_func_start DoKeenEyeIntimidateWildEncounterTest -@ _BOOL1 DoKeenEyeIntimidateWildEncounterTest(u8 wildMonLevel) -DoKeenEyeIntimidateWildEncounterTest: @ 80B5934 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - ldr r4, =gPlayerParty - adds r0, r4, 0 - movs r1, 0x6 - bl GetMonData - cmp r0, 0 - bne _080B5988 - adds r0, r4, 0 - bl GetMonAbility - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x33 - beq _080B595A - cmp r0, 0x16 - bne _080B5988 -_080B595A: - adds r0, r4, 0 - movs r1, 0x38 - bl GetMonData - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x5 - bls _080B5988 - subs r0, 0x5 - cmp r5, r0 - bgt _080B5988 - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x1 - ands r0, r1 - cmp r0, 0 - bne _080B5988 - movs r0, 0 - b _080B598A - .pool -_080B5988: - movs r0, 0x1 -_080B598A: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end DoKeenEyeIntimidateWildEncounterTest - - thumb_func_start TryGetRandomWildMonIndexByType -@ _BOOL1 TryGetRandomWildMonIndexByType(WildMonEntry *mons, u8 type, u8 numMons, u8 *monIndex) -TryGetRandomWildMonIndexByType: @ 80B5990 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - mov r7, sp - mov r12, r0 - mov r8, r3 - lsls r1, 24 - lsrs r1, 24 - str r1, [r7] - lsls r2, 24 - lsrs r2, 24 - mov r9, sp - adds r0, r2, 0x3 - lsrs r0, 2 - lsls r0, 2 - mov r1, sp - subs r1, r0 - mov sp, r1 - mov r5, sp - movs r3, 0 - cmp r3, r2 - bcs _080B59D2 - movs r1, 0 -_080B59C4: - adds r0, r5, r3 - strb r1, [r0] - adds r0, r3, 0x1 - lsls r0, 24 - lsrs r3, r0, 24 - cmp r3, r2 - bcc _080B59C4 -_080B59D2: - movs r4, 0 - movs r3, 0 - cmp r4, r2 - bcs _080B5A12 - ldr r6, =gBaseStats - mov r10, r6 -_080B59DE: - lsls r0, r3, 2 - add r0, r12 - ldrh r1, [r0, 0x2] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - mov r6, r10 - adds r1, r0, r6 - ldrb r0, [r1, 0x6] - ldr r6, [r7] - cmp r0, r6 - beq _080B59FC - ldrb r0, [r1, 0x7] - cmp r0, r6 - bne _080B5A08 -_080B59FC: - adds r1, r4, 0 - adds r0, r1, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - adds r1, r5, r1 - strb r3, [r1] -_080B5A08: - adds r0, r3, 0x1 - lsls r0, 24 - lsrs r3, r0, 24 - cmp r3, r2 - bcc _080B59DE -_080B5A12: - cmp r4, 0 - beq _080B5A1A - cmp r4, r2 - bne _080B5A24 -_080B5A1A: - movs r0, 0 - b _080B5A3C - .pool -_080B5A24: - bl Random - lsls r0, 16 - lsrs r0, 16 - adds r1, r4, 0 - bl __modsi3 - adds r0, r5, r0 - ldrb r0, [r0] - mov r1, r8 - strb r0, [r1] - movs r0, 0x1 -_080B5A3C: - mov sp, r9 - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end TryGetRandomWildMonIndexByType - - thumb_func_start TryGetAbilityInfluencedWildMonIndex -@ _BOOL1 TryGetAbilityInfluencedWildMonIndex(WildMonEntry *mons, u8 type, u8 abilityId, u8 *monIndex) -TryGetAbilityInfluencedWildMonIndex: @ 80B5A50 - push {r4-r7,lr} - mov r7, r8 - push {r7} - adds r7, r0, 0 - mov r8, r3 - lsls r1, 24 - lsrs r6, r1, 24 - lsls r2, 24 - lsrs r5, r2, 24 - ldr r4, =gPlayerParty - adds r0, r4, 0 - movs r1, 0x6 - bl GetMonData - cmp r0, 0 - bne _080B5AA4 - adds r0, r4, 0 - bl GetMonAbility - lsls r0, 24 - lsrs r0, 24 - cmp r0, r5 - bne _080B5AA4 - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x1 - ands r0, r1 - cmp r0, 0 - bne _080B5AA4 - adds r0, r7, 0 - adds r1, r6, 0 - movs r2, 0xC - mov r3, r8 - bl TryGetRandomWildMonIndexByType - lsls r0, 24 - lsrs r0, 24 - b _080B5AA6 - .pool -_080B5AA4: - movs r0, 0 -_080B5AA6: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end TryGetAbilityInfluencedWildMonIndex - - thumb_func_start affects_encounter_rate_based_on_flags -@ void affects_encounter_rate_based_on_flags(u32 *val) -affects_encounter_rate_based_on_flags: @ 80B5AB0 - push {r4,lr} - adds r4, r0, 0 - ldr r0, =0x000008ad - bl FlagGet - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _080B5AD0 - ldr r0, [r4] - lsrs r1, r0, 1 - adds r0, r1 - b _080B5AE2 - .pool -_080B5AD0: - ldr r0, =0x000008ae - bl FlagGet - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _080B5AE4 - ldr r0, [r4] - lsrs r0, 1 -_080B5AE2: - str r0, [r4] -_080B5AE4: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end affects_encounter_rate_based_on_flags - - thumb_func_start ApplyCleanseTagWildEncounterRateReduction -ApplyCleanseTagWildEncounterRateReduction: @ 80B5AF0 - push {r4,lr} - adds r4, r0, 0 - ldr r0, =gPlayerParty - movs r1, 0xC - bl GetMonData - cmp r0, 0xBE - bne _080B5B0C - ldr r0, [r4] - lsls r0, 1 - movs r1, 0x3 - bl __udivsi3 - str r0, [r4] -_080B5B0C: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end ApplyCleanseTagWildEncounterRateReduction - - .align 2, 0 @ Don't pad with nop. diff --git a/constants/flags.inc b/constants/flags.inc index 2e4b60d73..66663cb65 100644 --- a/constants/flags.inc +++ b/constants/flags.inc @@ -80,7 +80,7 @@ .equiv FLAG_0x050, 0x50 .equiv FLAG_0x051, 0x51 .equiv FLAG_0x052, 0x52 - .equiv FLAG_0x053, 0x53 + .equiv FLAG_LEGENDARIES_IN_SOOTOPOLIS, 0x53 .equiv FLAG_0x054, 0x54 .equiv FLAG_0x055, 0x55 .equiv FLAG_0x056, 0x56 diff --git a/constants/variables.inc b/constants/variables.inc index e2719e10c..47748891b 100644 --- a/constants/variables.inc +++ b/constants/variables.inc @@ -60,7 +60,7 @@ .equiv VAR_0x403B, 0x403B .equiv VAR_0x403C, 0x403C .equiv VAR_0x403D, 0x403D - .equiv VAR_0x403E, 0x403E + .equiv VAR_ALTERING_CAVE_WILD_SET, 0x403E .equiv VAR_0x403F, 0x403F .equiv VAR_DAYS, 0x4040 .equiv VAR_0x4041, 0x4041 diff --git a/data/scripts/field_move_scripts.inc b/data/scripts/field_move_scripts.inc index fd2ff3b01..76f2aac6b 100644 --- a/data/scripts/field_move_scripts.inc +++ b/data/scripts/field_move_scripts.inc @@ -116,7 +116,7 @@ Route111_EventScript_2907FB:: @ 82907FB specialvar VAR_RESULT, sub_81393FC compare_var_to_value VAR_RESULT, 1 goto_eq Route111_EventScript_290829 - special rock_smash_wild_pokemon_encounter + special RockSmashWildEncounter compare_var_to_value VAR_RESULT, 0 goto_eq Route111_EventScript_290829 waitstate diff --git a/data/scripts/maps/SeafloorCavern_Room9.inc b/data/scripts/maps/SeafloorCavern_Room9.inc index 6f968b4d0..984d53295 100644 --- a/data/scripts/maps/SeafloorCavern_Room9.inc +++ b/data/scripts/maps/SeafloorCavern_Room9.inc @@ -127,7 +127,7 @@ SeafloorCavern_Room9_EventScript_234DC9:: @ 8234DC9 clearflag FLAG_0x3E6 clearflag FLAG_0x3E5 setflag FLAG_0x347 - setflag FLAG_0x053 + setflag FLAG_LEGENDARIES_IN_SOOTOPOLIS clearflag FLAG_0x3B0 clearflag FLAG_0x3B1 setflag FLAG_SYS_WEATHER_CTRL diff --git a/data/scripts/maps/SootopolisCity.inc b/data/scripts/maps/SootopolisCity.inc index 33b65714b..d9eaee6eb 100644 --- a/data/scripts/maps/SootopolisCity.inc +++ b/data/scripts/maps/SootopolisCity.inc @@ -545,7 +545,7 @@ SootopolisCity_EventScript_1E5C1E:: @ 81E5C1E waitstate clearflag FLAG_SYS_WEATHER_CTRL setvar VAR_0x40CA, 3 - clearflag FLAG_0x053 + clearflag FLAG_LEGENDARIES_IN_SOOTOPOLIS fadenewbgm BGM_RUNECITY delay 120 clearflag FLAG_SPECIAL_FLAG_0x4000 @@ -598,7 +598,7 @@ SootopolisCity_EventScript_1E5CCE:: @ 81E5CCE waitstate clearflag FLAG_SYS_WEATHER_CTRL setvar VAR_0x40CA, 2 - clearflag FLAG_0x053 + clearflag FLAG_LEGENDARIES_IN_SOOTOPOLIS fadenewbgm BGM_NAMINORI delay 120 clearflag FLAG_SPECIAL_FLAG_0x4000 diff --git a/data/specials.inc b/data/specials.inc index 51bb34dff..da076f6ff 100644 --- a/data/specials.inc +++ b/data/specials.inc @@ -181,7 +181,7 @@ gSpecials:: @ 81DBA64 def_special sub_813BF60 def_special sub_813BA60 def_special sub_813BF7C - def_special rock_smash_wild_pokemon_encounter + def_special RockSmashWildEncounter def_special GabbyAndTyGetBattleNum def_special GabbyAndTyAfterInterview def_special GabbyAndTyBeforeInterview diff --git a/data/wild_encounter.s b/data/wild_encounter.s index ddb842a76..e221c2f99 100644 --- a/data/wild_encounter.s +++ b/data/wild_encounter.s @@ -9,14 +9,14 @@ .incbin "baserom.gba", 0x55370c, 0x188 -gUnknown_08553894:: @ 8553894 +gBattlePyramidWildMonHeaders:: @ 8553894 .incbin "baserom.gba", 0x553894, 0x180 -gUnknown_08553A14:: @ 8553A14 +gBattlePikeWildMonHeaders:: @ 8553A14 .incbin "baserom.gba", 0x553a14, 0x64 -gUnknown_08553A78:: @ 8553A78 +gWildFeebasRoute119Data:: @ 8553A78 .incbin "baserom.gba", 0x553a78, 0x4 -gUnknown_08553A7C:: @ 8553A7C +gRoute119WaterTileData:: @ 8553A7C .incbin "baserom.gba", 0x553a7c, 0x14 diff --git a/include/battle_setup.h b/include/battle_setup.h index e4acd8601..0168022cc 100644 --- a/include/battle_setup.h +++ b/include/battle_setup.h @@ -4,6 +4,9 @@ void BattleSetup_StartScriptedWildBattle(void); u8 BattleSetup_GetTerrainId(void); u8 *BattleSetup_ConfigureTrainerBattle(const u8 *data); +void BattleSetup_StartBattlePikeWildBattle(void); +void BattleSetup_StartWildBattle(void); +void BattleSetup_StartRoamerBattle(void); u8 HasTrainerAlreadyBeenFought(u16); void trainer_flag_set(u16); diff --git a/include/flags.h b/include/flags.h index a891cc13f..30c28c0c2 100644 --- a/include/flags.h +++ b/include/flags.h @@ -1,7 +1,8 @@ #ifndef GUARD_FLAGS_H #define GUARD_FLAGS_H -#define FLAG_PENDING_DAYCARE_EGG 0x86 +#define FLAG_LEGENDARIES_IN_SOOTOPOLIS 0x53 +#define FLAG_PENDING_DAYCARE_EGG 0x86 #define FLAG_TRAINER_FLAG_START 0x500 diff --git a/include/global.h b/include/global.h index 62f946c6d..f3ec9ce33 100644 --- a/include/global.h +++ b/include/global.h @@ -238,7 +238,9 @@ struct SaveBlock2 /*0xCA9*/ u8 field_CA9_d : 1; // 0x20 /*0xCA9*/ u8 field_CA9_e : 1; // 0x40 /*0xCA9*/ u8 field_CA9_f : 1; // 0x80 - /*0xCAA*/ u16 field_CAA[0x2e]; + /*0xCAA*/ u16 field_CAA[4]; + /*0xCB2*/ u16 battlePyramidWildHeaderId; + /*0xCB4*/ u8 field_CB4[82]; /*0xD06*/ u8 field_D06; /*0xD07*/ u8 field_D07; /*0xD08*/ u8 filler_D08[0x112]; diff --git a/include/link.h b/include/link.h index ef8370d0e..ccde9818c 100644 --- a/include/link.h +++ b/include/link.h @@ -179,6 +179,7 @@ void LinkVSync(void); void Timer3Intr(void); void SerialCB(void); u8 GetLinkPlayerCount(void); +bool32 InUnionRoom(void); void sub_800E0E8(void); bool8 sub_800A520(void); diff --git a/include/pokeblock.h b/include/pokeblock.h index 5d52f8e55..b0e93f0e5 100644 --- a/include/pokeblock.h +++ b/include/pokeblock.h @@ -23,6 +23,7 @@ enum }; void ClearPokeblocks(void); +s16 PokeblockGetGain(u8, const struct Pokeblock *); /* void sub_810B96C(void); @@ -32,7 +33,6 @@ s16 GetPokeblockData(const struct Pokeblock *, u8); u8 sub_810C9E8(struct Pokeblock *); void sub_810BA7C(u8); bool8 PokeblockClearIfExists(u8); -s16 PokeblockGetGain(u8, const struct Pokeblock *); u8 sub_810CB68(u8, u8*); void PokeblockCopyName(struct Pokeblock *pokeblock, u8 *dest); void CB2_PreparePokeblockFeedScene(void); diff --git a/include/tv.h b/include/tv.h index 43f36d69f..3f48af569 100644 --- a/include/tv.h +++ b/include/tv.h @@ -13,5 +13,6 @@ void sub_80EE184(void); void sub_80EEA70(void); void sub_80F14F8(TVShow *shows); size_t sub_80EF370(int value); +void SetPokemonAnglerSpecies(u16 species); #endif //GUARD_TV_H diff --git a/include/vars.h b/include/vars.h index f8057d4b5..763b7379d 100644 --- a/include/vars.h +++ b/include/vars.h @@ -30,6 +30,7 @@ #define VAR_RESET_RTC_ENABLE 0x402C #define VAR_0x4037 0x4037 +#define VAR_ALTERING_CAVE_WILD_SET 0x403E #define VAR_DAYS 0x4040 #define VAR_DEPT_STORE_FLOOR 0x4043 diff --git a/include/wild_encounter.h b/include/wild_encounter.h new file mode 100644 index 000000000..55bbaa7dd --- /dev/null +++ b/include/wild_encounter.h @@ -0,0 +1,44 @@ +#ifndef GUARD_WILD_ENCOUNTER_H +#define GUARD_WILD_ENCOUNTER_H + +#define LAND_WILD_COUNT 12 +#define WATER_WILD_COUNT 5 +#define ROCK_WILD_COUNT 5 +#define FISH_WILD_COUNT 10 + +struct WildPokemon +{ + u8 minLevel; + u8 maxLevel; + u16 species; +}; + +struct WildPokemonInfo +{ + u8 encounterRate; + const struct WildPokemon *wildPokemon; +}; + +struct WildPokemonHeader +{ + u8 mapGroup; + u8 mapNum; + const struct WildPokemonInfo *landMonsInfo; + const struct WildPokemonInfo *waterMonsInfo; + const struct WildPokemonInfo *rockSmashMonsInfo; + const struct WildPokemonInfo *fishingMonsInfo; +}; + +extern const struct WildPokemonHeader gWildMonHeaders[]; + +void DisableWildEncounters(bool8 disabled); +bool8 StandardWildEncounter(u16 currMetaTileBehavior, u16 previousMetaTileBehavior); +void ScrSpecial_RockSmashWildEncounter(void); +bool8 SweetScentWildEncounter(void); +bool8 DoesCurrentMapHaveFishingMons(void); +void FishingWildEncounter(u8 rod); +u16 GetLocalWildMon(bool8 *isWaterMon); +u16 GetLocalWaterMon(void); +bool8 UpdateRepelCounter(void); + +#endif // GUARD_WILD_ENCOUNTER_H diff --git a/ld_script.txt b/ld_script.txt index 40e11e4e1..e9c810adc 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -124,7 +124,7 @@ SECTIONS { asm/battle_setup.o(.text); asm/cable_club.o(.text); asm/trainer_see.o(.text); - asm/wild_encounter.o(.text); + src/wild_encounter.o(.text); asm/field_effect.o(.text); asm/unknown_task.o(.text); asm/option_menu.o(.text); diff --git a/src/tv.c b/src/tv.c index c1d648652..1d978b093 100644 --- a/src/tv.c +++ b/src/tv.c @@ -1883,7 +1883,7 @@ void PutFishingAdviceShowOnTheAir(void) } } -void sub_80EDA3C(u16 species) +void SetPokemonAnglerSpecies(u16 species) { sPokemonAnglerSpecies = species; } diff --git a/src/wild_encounter.c b/src/wild_encounter.c new file mode 100644 index 000000000..ce1e02e5e --- /dev/null +++ b/src/wild_encounter.c @@ -0,0 +1,933 @@ +#include "global.h" +#include "wild_encounter.h" +#include "pokemon.h" +#include "species.h" +#include "metatile_behavior.h" +#include "fieldmap.h" +#include "rng.h" +#include "map_constants.h" +#include "field_player_avatar.h" +#include "abilities.h" +#include "event_data.h" +#include "safari_zone.h" +#include "pokeblock.h" +#include "battle_setup.h" +#include "roamer.h" +#include "game_stat.h" +#include "tv.h" +#include "link.h" +#include "script.h" +#include "items.h" + +extern const u8 EventScript_RepelWoreOff[]; + +#define NUM_FEEBAS_SPOTS 6 + +extern const u16 gRoute119WaterTileData[]; +extern const struct WildPokemonHeader gBattlePikeWildMonHeaders[]; +extern const struct WildPokemonHeader gBattlePyramidWildMonHeaders[]; +extern const struct WildPokemon gWildFeebasRoute119Data; + +extern u8 GetBattlePikeWildMonHeaderId(void); +extern bool32 TryGenerateBattlePikeWildMon(bool8 checkKeenEyeIntimidate); +extern void GenerateBattlePyramidWildMon(void); +extern bool8 InBattlePike(void); +extern bool8 InBattlePyramid(void); + +// this file's functions +static u16 FeebasRandom(void); +static void FeebasSeedRng(u16 seed); +static bool8 IsWildLevelAllowedByRepel(u8 level); +static void ApplyFluteEncounterRateMod(u32 *encRate); +static void ApplyCleanseTagEncounterRateMod(u32 *encRate); +static bool8 TryGetAbilityInfluencedWildMonIndex(const struct WildPokemon *wildMon, u8 type, u8 ability, u8 *monIndex); +static bool8 IsAbilityAllowingEncounter(u8 level); + +EWRAM_DATA u8 sWildEncountersDisabled = 0; +EWRAM_DATA u32 sFeebasRngValue = 0; + +void DisableWildEncounters(bool8 disabled) +{ + sWildEncountersDisabled = disabled; +} + +static u16 GetRoute119WaterTileNum(s16 x, s16 y, u8 section) +{ + u16 xCur; + u16 yCur; + u16 yMin = gRoute119WaterTileData[section * 3 + 0]; + u16 yMax = gRoute119WaterTileData[section * 3 + 1]; + u16 tileNum = gRoute119WaterTileData[section * 3 + 2]; + + for (yCur = yMin; yCur <= yMax; yCur++) + { + for (xCur = 0; xCur < gMapHeader.mapData->width; xCur++) + { + u8 tileBehaviorId = MapGridGetMetatileBehaviorAt(xCur + 7, yCur + 7); + if (MetatileBehavior_IsSurfableAndNotWaterfall(tileBehaviorId) == TRUE) + { + tileNum++; + if (x == xCur && y == yCur) + return tileNum; + } + } + } + return tileNum + 1; +} + +static bool8 CheckFeebas(void) +{ + u8 i; + u16 feebasSpots[NUM_FEEBAS_SPOTS]; + s16 x; + s16 y; + u8 route119Section = 0; + u16 waterTileNum; + + if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP_ROUTE119 + && gSaveBlock1Ptr->location.mapNum == MAP_ID_ROUTE119) + { + GetXYCoordsOneStepInFrontOfPlayer(&x, &y); + x -= 7; + y -= 7; + +#ifdef NONMATCHING + if (y >= gRoute119WaterTileData[3 * 1 + 0] && y <= gRoute119WaterTileData[3 * 1 + 1]) + route119Section = 1; + if (y >= gRoute119WaterTileData[3 * 2 + 0] && y <= gRoute119WaterTileData[3 * 2 + 1]) + route119Section = 2; +#else + { + register const u16 *arr asm("r0"); + if (y >= (arr = gRoute119WaterTileData)[3 * 1 + 0] && y <= arr[3 * 1 + 1]) + route119Section = 1; + if (y >= arr[3 * 2 + 0] && y <= arr[3 * 2 + 1]) + route119Section = 2; + } +#endif + + if (Random() % 100 > 49) // 50% chance of encountering Feebas + return FALSE; + + FeebasSeedRng(gSaveBlock1Ptr->easyChatPairs[0].unk2); + for (i = 0; i != NUM_FEEBAS_SPOTS;) + { + feebasSpots[i] = FeebasRandom() % 447; + if (feebasSpots[i] == 0) + feebasSpots[i] = 447; + if (feebasSpots[i] < 1 || feebasSpots[i] >= 4) + i++; + } + waterTileNum = GetRoute119WaterTileNum(x, y, route119Section); + for (i = 0; i < NUM_FEEBAS_SPOTS; i++) + { + if (waterTileNum == feebasSpots[i]) + return TRUE; + } + } + return FALSE; +} + +// The number 1103515245 comes from the example implementation of rand and srand +// in the ISO C standard. + +static u16 FeebasRandom(void) +{ + sFeebasRngValue = (1103515245 * sFeebasRngValue) + 12345; + return sFeebasRngValue >> 16; +} + +static void FeebasSeedRng(u16 seed) +{ + sFeebasRngValue = seed; +} + +static u8 ChooseWildMonIndex_Land(void) +{ + u8 rand = Random() % 100; + + if (rand < 20) // 20% chance + return 0; + else if (rand >= 20 && rand < 40) // 20% chance + return 1; + else if (rand >= 40 && rand < 50) // 10% chance + return 2; + else if (rand >= 50 && rand < 60) // 10% chance + return 3; + else if (rand >= 60 && rand < 70) // 10% chance + return 4; + else if (rand >= 70 && rand < 80) // 10% chance + return 5; + else if (rand >= 80 && rand < 85) // 5% chance + return 6; + else if (rand >= 85 && rand < 90) // 5% chance + return 7; + else if (rand >= 90 && rand < 94) // 4% chance + return 8; + else if (rand >= 94 && rand < 98) // 4% chance + return 9; + else if (rand == 98) // 1% chance + return 10; + else // 1% chance + return 11; +} + +static u8 ChooseWildMonIndex_WaterRock(void) +{ + u8 rand = Random() % 100; + + if (rand < 60) // 60% chance + return 0; + else if (rand >= 60 && rand < 90) // 30% chance + return 1; + else if (rand >= 90 && rand < 95) // 5% chance + return 2; + else if (rand >= 95 && rand < 99) // 4% chance + return 3; + else // 1% chance + return 4; +} + +enum +{ + OLD_ROD, + GOOD_ROD, + SUPER_ROD +}; + +static u8 ChooseWildMonIndex_Fishing(u8 rod) +{ + u8 wildMonIndex = 0; + u8 rand = Random() % 100; + + switch (rod) + { + case OLD_ROD: + if (rand < 70) // 70% chance + wildMonIndex = 0; + else // 30% chance + wildMonIndex = 1; + break; + case GOOD_ROD: + if (rand < 60) // 60% chance + wildMonIndex = 2; + if (rand >= 60 && rand < 80) // 20% chance + wildMonIndex = 3; + if (rand >= 80 && rand < 100) // 20% chance + wildMonIndex = 4; + break; + case SUPER_ROD: + if (rand < 40) // 40% chance + wildMonIndex = 5; + if (rand >= 40 && rand < 80) // 40% chance + wildMonIndex = 6; + if (rand >= 80 && rand < 95) // 15% chance + wildMonIndex = 7; + if (rand >= 95 && rand < 99) // 4% chance + wildMonIndex = 8; + if (rand == 99) // 1% chance + wildMonIndex = 9; + break; + } + return wildMonIndex; +} + +static u8 ChooseWildMonLevel(const struct WildPokemon *wildPokemon) +{ + u8 min; + u8 max; + u8 range; + u8 rand; + + // Make sure minimum level is less than maximum level + if (wildPokemon->maxLevel >= wildPokemon->minLevel) + { + min = wildPokemon->minLevel; + max = wildPokemon->maxLevel; + } + else + { + min = wildPokemon->maxLevel; + max = wildPokemon->minLevel; + } + range = max - min + 1; + rand = Random() % range; + + // check ability for max level mon + if (!GetMonData(&gPlayerParty[0], MON_DATA_SANITY_BIT3)) + { + u8 ability = GetMonAbility(&gPlayerParty[0]); + if (ability == ABILITY_HUSTLE || ability == ABILITY_VITAL_SPIRIT || ability == ABILITY_PRESSURE) + { + if (Random() % 2 == 0) + return max; + + if (rand != 0) + rand--; + } + } + + return min + rand; +} + +static u16 GetCurrentMapWildMonHeaderId(void) +{ + u16 i; + + for (i = 0; ; i++) + { + const struct WildPokemonHeader *wildHeader = &gWildMonHeaders[i]; + if (wildHeader->mapGroup == 0xFF) + break; + + if (gWildMonHeaders[i].mapGroup == gSaveBlock1Ptr->location.mapGroup && + gWildMonHeaders[i].mapNum == gSaveBlock1Ptr->location.mapNum) + { + if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP_ALTERING_CAVE && + gSaveBlock1Ptr->location.mapNum == MAP_ID_ALTERING_CAVE) + { + u16 alteringCaveId = VarGet(VAR_ALTERING_CAVE_WILD_SET); + if (alteringCaveId > 8) + alteringCaveId = 0; + + i += alteringCaveId; + } + + return i; + } + } + + return -1; +} + +static u8 PickWildMonNature(void) +{ + u8 i; + u8 j; + struct Pokeblock *safariPokeblock; + u8 natures[25]; + + if (GetSafariZoneFlag() == TRUE && Random() % 100 < 80) + { + safariPokeblock = SafariZoneGetActivePokeblock(); + if (safariPokeblock != NULL) + { + for (i = 0; i < 25; i++) + natures[i] = i; + for (i = 0; i < 24; i++) + { + for (j = i + 1; j < 25; j++) + { + if (Random() & 1) + { + u8 temp = natures[i]; + + natures[i] = natures[j]; + natures[j] = temp; + } + } + } + for (i = 0; i < 25; i++) + { + if (PokeblockGetGain(natures[i], safariPokeblock) > 0) + return natures[i]; + } + } + } + // check synchronize for a pokemon with the same ability + if (!GetMonData(&gPlayerParty[0], MON_DATA_SANITY_BIT3) + && GetMonAbility(&gPlayerParty[0]) == ABILITY_SYNCHRONIZE + && Random() % 2 == 0) + { + return GetMonData(&gPlayerParty[0], MON_DATA_PERSONALITY) % 25; + } + + // random nature + return Random() % 25; +} + +static void CreateWildMon(u16 species, u8 level) +{ + bool32 checkCuteCharm; + + ZeroEnemyPartyMons(); + checkCuteCharm = TRUE; + + switch (gBaseStats[species].genderRatio) + { + case MON_MALE: + case MON_FEMALE: + case MON_GENDERLESS: + checkCuteCharm = FALSE; + break; + } + + if (checkCuteCharm + && !GetMonData(&gPlayerParty[0], MON_DATA_SANITY_BIT3) + && GetMonAbility(&gPlayerParty[0]) == ABILITY_CUTE_CHARM + && Random() % 3 != 0) + { + u16 leadingMonSpecies = GetMonData(&gPlayerParty[0], MON_DATA_SPECIES); + u32 leadingMonPersonality = GetMonData(&gPlayerParty[0], MON_DATA_PERSONALITY); + u8 gender = GetGenderFromSpeciesAndPersonality(leadingMonSpecies, leadingMonPersonality); + + // misses mon is genderless check, although no genderless mon can have cute charm as ability + if (gender == MON_FEMALE) + gender = MON_MALE; + else + gender = MON_FEMALE; + + CreateMonWithGenderNatureLetter(&gEnemyParty[0], species, level, 32, gender, PickWildMonNature(), 0); + return; + } + + CreateMonWithNature(&gEnemyParty[0], species, level, 32, PickWildMonNature()); +} + +enum +{ + WILD_AREA_LAND, + WILD_AREA_WATER, + WILD_AREA_ROCKS, + WILD_AREA_FISHING, +}; + +#define WILD_CHECK_REPEL 0x1 +#define WILD_CHECK_KEEN_EYE 0x2 + +static bool8 TryGenerateWildMon(const struct WildPokemonInfo *wildMonInfo, u8 area, u8 flags) +{ + u8 wildMonIndex = 0; + u8 level; + + switch (area) + { + case WILD_AREA_LAND: + if (TryGetAbilityInfluencedWildMonIndex(wildMonInfo->wildPokemon, TYPE_STEEL, ABILITY_MAGNET_PULL, &wildMonIndex)) + break; + if (TryGetAbilityInfluencedWildMonIndex(wildMonInfo->wildPokemon, TYPE_ELECTRIC, ABILITY_STATIC, &wildMonIndex)) + break; + + wildMonIndex = ChooseWildMonIndex_Land(); + break; + case WILD_AREA_WATER: + if (TryGetAbilityInfluencedWildMonIndex(wildMonInfo->wildPokemon, TYPE_ELECTRIC, ABILITY_STATIC, &wildMonIndex)) + break; + + wildMonIndex = ChooseWildMonIndex_WaterRock(); + break; + case WILD_AREA_ROCKS: + wildMonIndex = ChooseWildMonIndex_WaterRock(); + break; + } + + level = ChooseWildMonLevel(&wildMonInfo->wildPokemon[wildMonIndex]); + if (flags & WILD_CHECK_REPEL && !IsWildLevelAllowedByRepel(level)) + return FALSE; + if (gMapHeader.mapDataId != 0x166 && flags & WILD_CHECK_KEEN_EYE && !IsAbilityAllowingEncounter(level)) + return FALSE; + + CreateWildMon(wildMonInfo->wildPokemon[wildMonIndex].species, level); + return TRUE; +} + +static u16 GenerateFishingWildMon(const struct WildPokemonInfo *wildMonInfo, u8 rod) +{ + u8 wildMonIndex = ChooseWildMonIndex_Fishing(rod); + u8 level = ChooseWildMonLevel(&wildMonInfo->wildPokemon[wildMonIndex]); + + CreateWildMon(wildMonInfo->wildPokemon[wildMonIndex].species, level); + return wildMonInfo->wildPokemon[wildMonIndex].species; +} + +static bool8 SetUpMassOutbreakEncounter(u8 flags) +{ + u16 i; + + if (flags & WILD_CHECK_REPEL && !IsWildLevelAllowedByRepel(gSaveBlock1Ptr->outbreakPokemonLevel)) + return FALSE; + + CreateWildMon(gSaveBlock1Ptr->outbreakPokemonSpecies, gSaveBlock1Ptr->outbreakPokemonLevel); + for (i = 0; i < 4; i++) + SetMonMoveSlot(&gEnemyParty[0], gSaveBlock1Ptr->outbreakPokemonMoves[i], i); + + return TRUE; +} + +static bool8 DoMassOutbreakEncounterTest(void) +{ + if (gSaveBlock1Ptr->outbreakPokemonSpecies != 0 + && gSaveBlock1Ptr->location.mapNum == gSaveBlock1Ptr->outbreakLocationMapNum + && gSaveBlock1Ptr->location.mapGroup == gSaveBlock1Ptr->outbreakLocationMapGroup) + { + if (Random() % 100 < gSaveBlock1Ptr->outbreakPokemonProbability) + return TRUE; + } + return FALSE; +} + +static bool8 DoWildEncounterRateDiceRoll(u16 encounterRate) +{ + if (Random() % 2880 < encounterRate) + return TRUE; + else + return FALSE; +} + +static bool8 DoWildEncounterRateTest(u32 encounterRate, bool8 ignoreAbility) +{ + encounterRate *= 16; + if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_MACH_BIKE | PLAYER_AVATAR_FLAG_ACRO_BIKE)) + encounterRate = encounterRate * 80 / 100; + ApplyFluteEncounterRateMod(&encounterRate); + ApplyCleanseTagEncounterRateMod(&encounterRate); + if (!ignoreAbility && !GetMonData(&gPlayerParty[0], MON_DATA_SANITY_BIT3)) + { + u32 ability = GetMonAbility(&gPlayerParty[0]); + + if (ability == ABILITY_STENCH && gMapHeader.mapDataId == 0x169) + encounterRate = encounterRate * 3 / 4; + else if (ability == ABILITY_STENCH) + encounterRate /= 2; + else if (ability == ABILITY_ILLUMINATE) + encounterRate *= 2; + else if (ability == ABILITY_WHITE_SMOKE) + encounterRate /= 2; + else if (ability == ABILITY_ARENA_TRAP) + encounterRate *= 2; + else if (ability == ABILITY_SAND_VEIL && gSaveBlock1Ptr->weather == 8) + encounterRate /= 2; + } + if (encounterRate > 2880) + encounterRate = 2880; + return DoWildEncounterRateDiceRoll(encounterRate); +} + +static bool8 DoGlobalWildEncounterDiceRoll(void) +{ + if (Random() % 100 >= 60) + return FALSE; + else + return TRUE; +} + +static bool8 AreLegendariesInSootopolisPreventingEncounters(void) +{ + if (gSaveBlock1Ptr->location.mapGroup != MAP_GROUP_SOOTOPOLIS_CITY + || gSaveBlock1Ptr->location.mapNum != MAP_ID_SOOTOPOLIS_CITY) + { + return FALSE; + } + + return FlagGet(FLAG_LEGENDARIES_IN_SOOTOPOLIS); +} + +bool8 StandardWildEncounter(u16 currMetaTileBehavior, u16 previousMetaTileBehavior) +{ + u16 headerId; + struct Roamer *roamer; + + if (sWildEncountersDisabled == TRUE) + return FALSE; + + headerId = GetCurrentMapWildMonHeaderId(); + if (headerId == 0xFFFF) // invalid + { + if (gMapHeader.mapDataId == 0x166) + { + headerId = GetBattlePikeWildMonHeaderId(); + if (previousMetaTileBehavior != currMetaTileBehavior && !DoGlobalWildEncounterDiceRoll()) + return FALSE; + else if (DoWildEncounterRateTest(gBattlePikeWildMonHeaders[headerId].landMonsInfo->encounterRate, FALSE) != TRUE) + return FALSE; + else if (TryGenerateWildMon(gBattlePikeWildMonHeaders[headerId].landMonsInfo, WILD_AREA_LAND, WILD_CHECK_KEEN_EYE) != TRUE) + return FALSE; + else if (!TryGenerateBattlePikeWildMon(TRUE)) + return FALSE; + + BattleSetup_StartBattlePikeWildBattle(); + return TRUE; + } + if (gMapHeader.mapDataId == 0x169) + { + headerId = gSaveBlock2Ptr->battlePyramidWildHeaderId; + if (previousMetaTileBehavior != currMetaTileBehavior && !DoGlobalWildEncounterDiceRoll()) + return FALSE; + else if (DoWildEncounterRateTest(gBattlePyramidWildMonHeaders[headerId].landMonsInfo->encounterRate, FALSE) != TRUE) + return FALSE; + else if (TryGenerateWildMon(gBattlePyramidWildMonHeaders[headerId].landMonsInfo, WILD_AREA_LAND, WILD_CHECK_KEEN_EYE) != TRUE) + return FALSE; + + GenerateBattlePyramidWildMon(); + BattleSetup_StartWildBattle(); + return TRUE; + } + } + else + { + if (MetatileBehavior_IsLandWildEncounter(currMetaTileBehavior) == TRUE) + { + if (gWildMonHeaders[headerId].landMonsInfo == NULL) + return FALSE; + else if (previousMetaTileBehavior != currMetaTileBehavior && !DoGlobalWildEncounterDiceRoll()) + return FALSE; + else if (DoWildEncounterRateTest(gWildMonHeaders[headerId].landMonsInfo->encounterRate, FALSE) != TRUE) + return FALSE; + + if (TryStartRoamerEncounter() == TRUE) + { + roamer = &gSaveBlock1Ptr->roamer; + if (!IsWildLevelAllowedByRepel(roamer->level)) + return FALSE; + + BattleSetup_StartRoamerBattle(); + return TRUE; + } + else + { + if (DoMassOutbreakEncounterTest() == TRUE && SetUpMassOutbreakEncounter(WILD_CHECK_REPEL | WILD_CHECK_KEEN_EYE) == TRUE) + { + BattleSetup_StartWildBattle(); + return TRUE; + } + + // try a regular wild land encounter + if (TryGenerateWildMon(gWildMonHeaders[headerId].landMonsInfo, WILD_AREA_LAND, WILD_CHECK_REPEL | WILD_CHECK_KEEN_EYE) == TRUE) + { + BattleSetup_StartWildBattle(); + return TRUE; + } + + return FALSE; + } + } + else if (MetatileBehavior_IsWaterWildEncounter(currMetaTileBehavior) == TRUE + || (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_SURFING) && MetatileBehavior_IsBridge(currMetaTileBehavior) == TRUE)) + { + if (AreLegendariesInSootopolisPreventingEncounters() == TRUE) + return FALSE; + else if (gWildMonHeaders[headerId].waterMonsInfo == NULL) + return FALSE; + else if (previousMetaTileBehavior != currMetaTileBehavior && !DoGlobalWildEncounterDiceRoll()) + return FALSE; + else if (DoWildEncounterRateTest(gWildMonHeaders[headerId].waterMonsInfo->encounterRate, FALSE) != TRUE) + return FALSE; + + if (TryStartRoamerEncounter() == TRUE) + { + roamer = &gSaveBlock1Ptr->roamer; + if (!IsWildLevelAllowedByRepel(roamer->level)) + return FALSE; + + BattleSetup_StartRoamerBattle(); + return TRUE; + } + else // try a regular surfing encounter + { + if (TryGenerateWildMon(gWildMonHeaders[headerId].waterMonsInfo, WILD_AREA_WATER, WILD_CHECK_REPEL | WILD_CHECK_KEEN_EYE) == TRUE) + { + BattleSetup_StartWildBattle(); + return TRUE; + } + + return FALSE; + } + } + } + + return FALSE; +} + +void RockSmashWildEncounter(void) +{ + u16 headerId = GetCurrentMapWildMonHeaderId(); + + if (headerId != 0xFFFF) + { + const struct WildPokemonInfo *wildPokemonInfo = gWildMonHeaders[headerId].rockSmashMonsInfo; + + if (wildPokemonInfo == NULL) + { + gSpecialVar_Result = FALSE; + } + else if (DoWildEncounterRateTest(wildPokemonInfo->encounterRate, 1) == TRUE + && TryGenerateWildMon(wildPokemonInfo, 2, WILD_CHECK_REPEL | WILD_CHECK_KEEN_EYE) == TRUE) + { + BattleSetup_StartWildBattle(); + gSpecialVar_Result = TRUE; + } + else + { + gSpecialVar_Result = FALSE; + } + } + else + { + gSpecialVar_Result = FALSE; + } +} + +bool8 SweetScentWildEncounter(void) +{ + s16 x, y; + u16 headerId; + + PlayerGetDestCoords(&x, &y); + headerId = GetCurrentMapWildMonHeaderId(); + if (headerId == 0xFFFF) // invalid + { + if (gMapHeader.mapDataId == 0x166) + { + headerId = GetBattlePikeWildMonHeaderId(); + if (TryGenerateWildMon(gBattlePikeWildMonHeaders[headerId].landMonsInfo, WILD_AREA_LAND, 0) != TRUE) + return FALSE; + + TryGenerateBattlePikeWildMon(FALSE); + BattleSetup_StartBattlePikeWildBattle(); + return TRUE; + } + if (gMapHeader.mapDataId == 0x169) + { + headerId = gSaveBlock2Ptr->battlePyramidWildHeaderId; + if (TryGenerateWildMon(gBattlePyramidWildMonHeaders[headerId].landMonsInfo, WILD_AREA_LAND, 0) != TRUE) + return FALSE; + + GenerateBattlePyramidWildMon(); + BattleSetup_StartWildBattle(); + return TRUE; + } + } + else + { + if (MetatileBehavior_IsLandWildEncounter(MapGridGetMetatileBehaviorAt(x, y)) == TRUE) + { + if (gWildMonHeaders[headerId].landMonsInfo == NULL) + return FALSE; + + if (TryStartRoamerEncounter() == TRUE) + { + BattleSetup_StartRoamerBattle(); + return TRUE; + } + + if (DoMassOutbreakEncounterTest() == TRUE) + SetUpMassOutbreakEncounter(0); + else + TryGenerateWildMon(gWildMonHeaders[headerId].landMonsInfo, WILD_AREA_LAND, 0); + + BattleSetup_StartWildBattle(); + return TRUE; + } + else if (MetatileBehavior_IsWaterWildEncounter(MapGridGetMetatileBehaviorAt(x, y)) == TRUE) + { + if (AreLegendariesInSootopolisPreventingEncounters() == TRUE) + return FALSE; + if (gWildMonHeaders[headerId].waterMonsInfo == NULL) + return FALSE; + + if (TryStartRoamerEncounter() == TRUE) + { + BattleSetup_StartRoamerBattle(); + return TRUE; + } + + TryGenerateWildMon(gWildMonHeaders[headerId].waterMonsInfo, WILD_AREA_WATER, 0); + BattleSetup_StartWildBattle(); + return TRUE; + } + } + + return FALSE; +} + +bool8 DoesCurrentMapHaveFishingMons(void) +{ + u16 headerId = GetCurrentMapWildMonHeaderId(); + + if (headerId != 0xFFFF && gWildMonHeaders[headerId].fishingMonsInfo != NULL) + return TRUE; + else + return FALSE; +} + +void FishingWildEncounter(u8 rod) +{ + u16 species; + + if (CheckFeebas() == TRUE) + { + u8 level = ChooseWildMonLevel(&gWildFeebasRoute119Data); + + species = gWildFeebasRoute119Data.species; + CreateWildMon(species, level); + } + else + { + species = GenerateFishingWildMon(gWildMonHeaders[GetCurrentMapWildMonHeaderId()].fishingMonsInfo, rod); + } + IncrementGameStat(GAME_STAT_FISHING_CAPTURES); + SetPokemonAnglerSpecies(species); + BattleSetup_StartWildBattle(); +} + +u16 GetLocalWildMon(bool8 *isWaterMon) +{ + u16 headerId; + const struct WildPokemonInfo *landMonsInfo; + const struct WildPokemonInfo *waterMonsInfo; + + *isWaterMon = FALSE; + headerId = GetCurrentMapWildMonHeaderId(); + if (headerId == 0xFFFF) + return SPECIES_NONE; + landMonsInfo = gWildMonHeaders[headerId].landMonsInfo; + waterMonsInfo = gWildMonHeaders[headerId].waterMonsInfo; + // Neither + if (landMonsInfo == NULL && waterMonsInfo == NULL) + return SPECIES_NONE; + // Land Pokemon + else if (landMonsInfo != NULL && waterMonsInfo == NULL) + return landMonsInfo->wildPokemon[ChooseWildMonIndex_Land()].species; + // Water Pokemon + else if (landMonsInfo == NULL && waterMonsInfo != NULL) + { + *isWaterMon = TRUE; + return waterMonsInfo->wildPokemon[ChooseWildMonIndex_WaterRock()].species; + } + // Either land or water Pokemon + if ((Random() % 100) < 80) + { + return landMonsInfo->wildPokemon[ChooseWildMonIndex_Land()].species; + } + else + { + *isWaterMon = TRUE; + return waterMonsInfo->wildPokemon[ChooseWildMonIndex_WaterRock()].species; + } +} + +u16 GetLocalWaterMon(void) +{ + u16 headerId = GetCurrentMapWildMonHeaderId(); + + if (headerId != 0xFFFF) + { + const struct WildPokemonInfo *waterMonsInfo = gWildMonHeaders[headerId].waterMonsInfo; + + if (waterMonsInfo) + return waterMonsInfo->wildPokemon[ChooseWildMonIndex_WaterRock()].species; + } + return SPECIES_NONE; +} + +bool8 UpdateRepelCounter(void) +{ + u16 steps; + + if (InBattlePike() || InBattlePyramid()) + return FALSE; + if (InUnionRoom() == TRUE) + return FALSE; + + steps = VarGet(VAR_REPEL_STEP_COUNT); + + if (steps != 0) + { + steps--; + VarSet(VAR_REPEL_STEP_COUNT, steps); + if (steps == 0) + { + ScriptContext1_SetupScript(EventScript_RepelWoreOff); + return TRUE; + } + } + return FALSE; +} + +static bool8 IsWildLevelAllowedByRepel(u8 wildLevel) +{ + u8 i; + + if (!VarGet(VAR_REPEL_STEP_COUNT)) + return TRUE; + + for (i = 0; i < PARTY_SIZE; i++) + { + if (GetMonData(&gPlayerParty[i], MON_DATA_HP) && !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG)) + { + u8 ourLevel = GetMonData(&gPlayerParty[i], MON_DATA_LEVEL); + + if (wildLevel < ourLevel) + return FALSE; + else + return TRUE; + } + } + + return FALSE; +} + +static bool8 IsAbilityAllowingEncounter(u8 level) +{ + u8 ability; + + if (GetMonData(&gPlayerParty[0], MON_DATA_SANITY_BIT3)) + return TRUE; + + ability = GetMonAbility(&gPlayerParty[0]); + if (ability == ABILITY_KEEN_EYE || ability == ABILITY_INTIMIDATE) + { + u8 playerMonLevel = GetMonData(&gPlayerParty[0], MON_DATA_LEVEL); + if (playerMonLevel > 5 && level <= playerMonLevel - 5 && !(Random() % 2)) + return FALSE; + } + + return TRUE; +} + +static bool8 TryGetRandomWildMonIndexByType(const struct WildPokemon *wildMon, u8 type, u8 numMon, u8 *monIndex) +{ + u8 validIndexes[numMon]; // variable length array, an interesting feature + u8 i, validMonCount; + + for (i = 0; i < numMon; i++) + validIndexes[i] = 0; + + for (validMonCount = 0, i = 0; i < numMon; i++) + { + if (gBaseStats[wildMon[i].species].type1 == type || gBaseStats[wildMon[i].species].type2 == type) + validIndexes[validMonCount++] = i; + } + + if (validMonCount == 0 || validMonCount == numMon) + return FALSE; + + *monIndex = validIndexes[Random() % validMonCount]; + return TRUE; +} + +static bool8 TryGetAbilityInfluencedWildMonIndex(const struct WildPokemon *wildMon, u8 type, u8 ability, u8 *monIndex) +{ + if (GetMonData(&gPlayerParty[0], MON_DATA_SANITY_BIT3)) + return FALSE; + else if (GetMonAbility(&gPlayerParty[0]) != ability) + return FALSE; + else if (Random() % 2 != 0) + return FALSE; + + return TryGetRandomWildMonIndexByType(wildMon, type, LAND_WILD_COUNT, monIndex); +} + +static void ApplyFluteEncounterRateMod(u32 *encRate) +{ + if (FlagGet(FLAG_SYS_ENC_UP_ITEM) == TRUE) + *encRate += *encRate / 2; + else if (FlagGet(FLAG_SYS_ENC_DOWN_ITEM) == TRUE) + *encRate = *encRate / 2; +} + +static void ApplyCleanseTagEncounterRateMod(u32 *encRate) +{ + if (GetMonData(&gPlayerParty[0], MON_DATA_HELD_ITEM) == ITEM_CLEANSE_TAG) + *encRate = *encRate * 2 / 3; +} diff --git a/sym_ewram.txt b/sym_ewram.txt index 778f0b82c..cfe686a7c 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -773,11 +773,7 @@ gUnknown_02038BF9: @ 2038BF9 gUnknown_02038BFC: @ 2038BFC .space 0x4 -gUnknown_02038C00: @ 2038C00 - .space 0x4 - -gUnknown_02038C04: @ 2038C04 - .space 0x4 + .include "src/wild_encounter.o" gFieldEffectArguments: @ 2038C08 .space 0x20