Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Modified Encounter Code
- ChooseWildEncounter:
- call LoadWildMonDataPointer
- jp nc, .nowildbattle
- call CheckEncounterRoamMon
- jp c, .startwildbattle
- ; Pick a random mon out of ContestMons.
- .loop
- call Random
- cp 100 << 1
- jr nc, .loop
- srl a
- ld hl, ContestMons
- ld de, 4
- .CheckMon:
- sub [hl]
- jr c, .GotMon
- add hl, de
- jr .CheckMon
- .GotMon:
- inc hl
- ; Species
- ld a, [hli]
- ld [wTempWildMonSpecies], a
- ; Min level
- ld a, [hli]
- ld d, a
- ; Max level
- ld a, [hl]
- sub d
- jr nz, .RandomLevel
- ; If min and max are the same.
- ld a, d
- jr .GotLevel
- .RandomLevel:
- ; Get a random level between the min and max.
- ld c, a
- inc c
- call Random
- ldh a, [hRandomAdd]
- call SimpleDivide
- add d
- .GotLevel:
- ld [wCurPartyLevel], a
- xor a
- ret
- .nowildbattle
- ld a, 1
- and a
- ret
- .startwildbattle
- xor a
- ret
- INCLUDE "data/wild/bug_contest_mons.asm"
- ; Original Encounter code
- ChooseWildEncounter:
- call LoadWildMonDataPointer
- jp nc, .nowildbattle
- call CheckEncounterRoamMon
- jp c, .startwildbattle
- inc hl
- inc hl
- inc hl
- call CheckOnWater
- ld de, WaterMonProbTable
- jr z, .watermon
- inc hl
- inc hl
- ld a, [wTimeOfDay]
- ld bc, NUM_GRASSMON * 2
- call AddNTimes
- ld de, GrassMonProbTable
- .watermon
- ; hl contains the pointer to the wild mon data, let's save that to the stack
- push hl
- .randomloop
- call Random
- cp 100
- jr nc, .randomloop
- inc a ; 1 <= a <= 100
- ld b, a
- ld h, d
- ld l, e
- ; This next loop chooses which mon to load up.
- .prob_bracket_loop
- ld a, [hli]
- cp b
- jr nc, .got_it
- inc hl
- jr .prob_bracket_loop
- .got_it
- ld c, [hl]
- ld b, 0
- pop hl
- add hl, bc ; this selects our mon
- ld a, [hli]
- ld b, a
- ; If the Pokemon is encountered by surfing, we need to give the levels some variety.
- call CheckOnWater
- jr nz, .ok
- ; Check if we buff the wild mon, and by how much.
- call Random
- cp 35 percent
- jr c, .ok
- inc b
- cp 65 percent
- jr c, .ok
- inc b
- cp 85 percent
- jr c, .ok
- inc b
- cp 95 percent
- jr c, .ok
- inc b
- ; Store the level
- .ok
- ld a, b
- ld [wCurPartyLevel], a
- ld b, [hl]
- ; ld a, b
- call ValidateTempWildMonSpecies
- jr c, .nowildbattle
- ld a, b ; This is in the wrong place.
- cp UNOWN
- jr nz, .done
- ld a, [wUnlockedUnowns]
- and a
- jr z, .nowildbattle
- .done
- jr .loadwildmon
- .nowildbattle
- ld a, 1
- and a
- ret
- .loadwildmon
- ld a, b
- ld [wTempWildMonSpecies], a
- .startwildbattle
- xor a
- ret
- INCLUDE "data/wild/probabilities.asm"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement