Better document the “can encounter Pokémon outside grass” code.

Pointed out by Lin.
This commit is contained in:
IIMarckus 2014-10-10 03:44:52 -06:00
parent 00049b6f39
commit bf6a1bab61

View file

@ -110,31 +110,36 @@ Func_13870: ; 13870 (4:7870)
jr z, .asm_13905 jr z, .asm_13905
ld [wd0db], a ld [wd0db], a
.asm_1389e .asm_1389e
; determine if wild pokémon can appear where were standing.
; are we standing in grass/water?
hlCoord 9, 9 hlCoord 9, 9
ld c, [hl] ld c, [hl]
ld a, [W_GRASSTILE] ld a, [W_GRASSTILE]
cp c cp c
ld a, [W_GRASSRATE] ; W_GRASSRATE ld a, [W_GRASSRATE]
jr z, .asm_138c4 jr z, .CanEncounter
ld a, $14 ld a, $14 ; in all tilesets with a water tile, this is its id
cp c cp c
ld a, [W_WATERRATE] ; wEnemyMon1Species ld a, [W_WATERRATE]
jr z, .asm_138c4 jr z, .CanEncounter
ld a, [W_CURMAP] ; W_CURMAP ; even if not in grass/water, standing anywhere we can encounter pokémon
cp REDS_HOUSE_1F ; so long as the map is “indoor” and has wild pokémon defined.
jr c, .asm_13912 ; …as long as its not Viridian Forest or Safari Zone.
ld a, [W_CURMAPTILESET] ; W_CURMAPTILESET ld a, [W_CURMAP]
cp REDS_HOUSE_1F ; is this an indoor map?
jr c, .CantEncounter
ld a, [W_CURMAPTILESET]
cp FOREST ; Viridian Forest/Safari Zone cp FOREST ; Viridian Forest/Safari Zone
jr z, .asm_13912 jr z, .CantEncounter
ld a, [W_GRASSRATE] ; W_GRASSRATE ld a, [W_GRASSRATE]
.asm_138c4 .CanEncounter
ld b, a ld b, a
ld a, [hRandomAdd] ld a, [hRandomAdd]
cp b cp b
jr nc, .asm_13912 jr nc, .CantEncounter
ld a, [hRandomSub] ld a, [hRandomSub]
ld b, a ld b, a
ld hl, WildMonEncounterSlotChances ; $7918 ld hl, WildMonEncounterSlotChances
.asm_138d0 .asm_138d0
ld a, [hli] ld a, [hli]
cp b cp b
@ -143,27 +148,27 @@ Func_13870: ; 13870 (4:7870)
jr .asm_138d0 jr .asm_138d0
.asm_138d7 .asm_138d7
ld c, [hl] ld c, [hl]
ld hl, W_GRASSMONS ; wd888 ld hl, W_GRASSMONS
aCoord 8, 9 aCoord 8, 9
cp $14 cp $14
jr nz, .asm_138e5 jr nz, .asm_138e5
ld hl, W_WATERMONS ; wd8a5 (aliases: wEnemyMon1HP) ld hl, W_WATERMONS
.asm_138e5 .asm_138e5
ld b, $0 ld b, $0
add hl, bc add hl, bc
ld a, [hli] ld a, [hli]
ld [W_CURENEMYLVL], a ; W_CURENEMYLVL ld [W_CURENEMYLVL], a
ld a, [hl] ld a, [hl]
ld [wcf91], a ld [wcf91], a
ld [wEnemyMonSpecies2], a ld [wEnemyMonSpecies2], a
ld a, [wd0db] ld a, [wd0db]
and a and a
jr z, .asm_13916 jr z, .asm_13916
ld a, [wPartyMon1Level] ; wPartyMon1Level ld a, [wPartyMon1Level]
ld b, a ld b, a
ld a, [W_CURENEMYLVL] ; W_CURENEMYLVL ld a, [W_CURENEMYLVL]
cp b cp b
jr c, .asm_13912 jr c, .CantEncounter
jr .asm_13916 jr .asm_13916
.asm_13905 .asm_13905
ld [wd0db], a ld [wd0db], a
@ -171,7 +176,7 @@ Func_13870: ; 13870 (4:7870)
ld [H_DOWNARROWBLINKCNT2], a ; $ff8c ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
call EnableAutoTextBoxDrawing call EnableAutoTextBoxDrawing
call DisplayTextID call DisplayTextID
.asm_13912 .CantEncounter
ld a, $1 ld a, $1
and a and a
ret ret