mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-11-16 11:37:40 +01:00
more work on wild encounter
This commit is contained in:
parent
b37d8c0821
commit
a2a17bba92
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -6,598 +6,7 @@
|
||||
.text
|
||||
|
||||
|
||||
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, =sWildEncountersDisabled
|
||||
ldrb r0, [r0]
|
||||
cmp r0, 0x1
|
||||
bne _080B52A6
|
||||
b _080B54FE
|
||||
_080B52A6:
|
||||
bl GetCurrentMapWildMonHeaderId
|
||||
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 TryGenerateWildMon
|
||||
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 TryGenerateWildMon
|
||||
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 TryGenerateWildMon
|
||||
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 IsWildLevelAllowedByRepel
|
||||
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 TryGenerateWildMon
|
||||
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 GetCurrentMapWildMonHeaderId
|
||||
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 TryGenerateWildMon
|
||||
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 GetCurrentMapWildMonHeaderId
|
||||
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 TryGenerateWildMon
|
||||
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 TryGenerateWildMon
|
||||
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 TryGenerateWildMon
|
||||
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 TryGenerateWildMon
|
||||
_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 GetCurrentMapWildMonHeaderId
|
||||
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
|
||||
@ -640,7 +49,7 @@ _080B5784:
|
||||
bl IncrementGameStat
|
||||
adds r0, r4, 0
|
||||
bl sub_80EDA3C
|
||||
bl sub_80B0698
|
||||
bl BattleSetup_StartWildBattle
|
||||
pop {r4,r5}
|
||||
pop {r0}
|
||||
bx r0
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -9,10 +9,10 @@
|
||||
|
||||
.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
|
||||
|
@ -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);
|
||||
|
@ -1,6 +1,8 @@
|
||||
#ifndef GUARD_FLAGS_H
|
||||
#define GUARD_FLAGS_H
|
||||
|
||||
#define FLAG_LEGENDARIES_IN_SOOTOPOLIS 0x53
|
||||
|
||||
#define FLAG_TRAINER_FLAG_START 0x500
|
||||
#define TRAINERS_FLAG_NO 0x356
|
||||
#define CODE_FLAGS (FLAG_TRAINER_FLAG_START + TRAINERS_FLAG_NO + 0xA) // 0x860
|
||||
|
@ -215,7 +215,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[88];
|
||||
/*0xD06*/ u8 field_D06;
|
||||
/*0xD07*/ u8 field_D07;
|
||||
/*0xd08*/ u8 filler_D08[0x112];
|
||||
@ -590,7 +592,7 @@ struct SaveBlock1
|
||||
/*0x3030*/ struct DaycareData daycare;
|
||||
/*0x3150*/ struct LinkBattleRecord linkBattleRecords[5];
|
||||
/*0x31A0*/ u8 unk_31A0;
|
||||
/*0x31A1*/ u8 filler_31A1[7];
|
||||
/*0x31A1*/ u8 filler_31A1[3];
|
||||
/*0x31A8*/ u8 giftRibbons[52];
|
||||
/*0x31DC*/ struct Roamer roamer;
|
||||
/*0x31F8*/ struct EnigmaBerry enigmaBerry;
|
||||
|
@ -11,6 +11,8 @@
|
||||
#include "event_data.h"
|
||||
#include "safari_zone.h"
|
||||
#include "pokeblock.h"
|
||||
#include "battle_setup.h"
|
||||
#include "roamer.h"
|
||||
|
||||
EWRAM_DATA u8 sWildEncountersDisabled = 0;
|
||||
EWRAM_DATA u32 sFeebasRngValue = 0;
|
||||
@ -18,6 +20,12 @@ EWRAM_DATA u32 sFeebasRngValue = 0;
|
||||
#define NUM_FEEBAS_SPOTS 6
|
||||
|
||||
extern const u16 gRoute119WaterTileData[];
|
||||
extern const struct WildPokemonHeader gBattlePikeWildMonHeaders[];
|
||||
extern const struct WildPokemonHeader gBattlePyramidWildMonHeaders[];
|
||||
|
||||
extern u8 GetBattlePikeWildMonHeaderId(void);
|
||||
extern bool32 TryGenerateBattlePikeWildMon(bool8 checkKeenEyeIntimidate);
|
||||
extern void GenerateBattlePyramidWildMon(void);
|
||||
|
||||
// this file's functions
|
||||
u16 FeebasRandom(void);
|
||||
@ -374,7 +382,7 @@ enum
|
||||
#define WILD_CHECK_REPEL 0x1
|
||||
#define WILD_CHECK_KEEN_EYE 0x2
|
||||
|
||||
bool8 TryGenerateWildMon(struct WildPokemonInfo *wildMonInfo, u8 area, u8 flags)
|
||||
bool8 TryGenerateWildMon(const struct WildPokemonInfo *wildMonInfo, u8 area, u8 flags)
|
||||
{
|
||||
u8 wildMonIndex = 0;
|
||||
u8 level;
|
||||
@ -481,3 +489,250 @@ bool8 DoWildEncounterRateTest(u32 encounterRate, bool8 ignoreAbility)
|
||||
encounterRate = 2880;
|
||||
return DoWildEncounterRateDiceRoll(encounterRate);
|
||||
}
|
||||
|
||||
bool8 DoGlobalWildEncounterDiceRoll(void)
|
||||
{
|
||||
if (Random() % 100 >= 60)
|
||||
return FALSE;
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
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;
|
||||
if (DoWildEncounterRateTest(gBattlePikeWildMonHeaders[headerId].landMonsInfo->encounterRate, FALSE) != TRUE)
|
||||
return FALSE;
|
||||
if (TryGenerateWildMon(gBattlePikeWildMonHeaders[headerId].landMonsInfo, WILD_AREA_LAND, WILD_CHECK_KEEN_EYE) != TRUE)
|
||||
return FALSE;
|
||||
if (!TryGenerateBattlePikeWildMon(TRUE))
|
||||
return FALSE;
|
||||
|
||||
BattleSetup_StartBattlePikeWildBattle();
|
||||
return TRUE;
|
||||
}
|
||||
if (gMapHeader.mapDataId == 0x169)
|
||||
{
|
||||
headerId = gSaveBlock2Ptr->battlePyramidWildHeaderId;
|
||||
if (previousMetaTileBehavior != currMetaTileBehavior && !DoGlobalWildEncounterDiceRoll())
|
||||
return FALSE;
|
||||
if (DoWildEncounterRateTest(gBattlePyramidWildMonHeaders[headerId].landMonsInfo->encounterRate, FALSE) != TRUE)
|
||||
return FALSE;
|
||||
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;
|
||||
if (previousMetaTileBehavior != currMetaTileBehavior && !DoGlobalWildEncounterDiceRoll())
|
||||
return FALSE;
|
||||
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;
|
||||
if (gWildMonHeaders[headerId].waterMonsInfo == NULL)
|
||||
return FALSE;
|
||||
if (previousMetaTileBehavior != currMetaTileBehavior && !DoGlobalWildEncounterDiceRoll())
|
||||
return FALSE;
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user