2018-06-24 07:09:41 -07:00
|
|
|
_FindPartyMonAboveLevel:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPartyMon1Level
|
2018-02-25 16:23:01 -08:00
|
|
|
call FindAboveLevel
|
2016-05-04 08:46:23 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
_FindPartyMonAtLeastThatHappy:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPartyMon1Happiness
|
2016-05-04 08:46:23 -07:00
|
|
|
call FindAtLeastThatHappy
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
_FindPartyMonThatSpecies:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPartyMon1Species
|
2016-05-04 08:46:23 -07:00
|
|
|
jp FindThatSpecies
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
_FindPartyMonThatSpeciesYourTrainerID:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPartyMon1Species
|
2016-05-04 08:46:23 -07:00
|
|
|
call FindThatSpecies
|
|
|
|
ret z
|
|
|
|
ld a, c
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPartyMon1ID
|
2016-05-04 08:46:23 -07:00
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
|
|
|
call AddNTimes
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerID]
|
2016-05-04 08:46:23 -07:00
|
|
|
cp [hl]
|
|
|
|
jr nz, .nope
|
|
|
|
inc hl
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerID + 1]
|
2016-05-04 08:46:23 -07:00
|
|
|
cp [hl]
|
|
|
|
jr nz, .nope
|
|
|
|
ld a, $1
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.nope
|
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
FindAtLeastThatHappy:
|
2016-05-04 08:46:23 -07:00
|
|
|
; Sets the bits for the Pokemon that have a happiness greater than or equal to b.
|
|
|
|
; The lowest bits are used. Sets z if no Pokemon in your party is at least that happy.
|
|
|
|
ld c, $0
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPartyCount]
|
2016-05-04 08:46:23 -07:00
|
|
|
ld d, a
|
|
|
|
.loop
|
|
|
|
ld a, d
|
|
|
|
dec a
|
|
|
|
push hl
|
|
|
|
push bc
|
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
|
|
|
call AddNTimes
|
|
|
|
pop bc
|
|
|
|
ld a, b
|
|
|
|
cp [hl]
|
|
|
|
pop hl
|
|
|
|
jr z, .greater_equal
|
|
|
|
jr nc, .lower
|
|
|
|
|
|
|
|
.greater_equal
|
|
|
|
ld a, c
|
|
|
|
or $1
|
|
|
|
ld c, a
|
|
|
|
|
|
|
|
.lower
|
|
|
|
sla c
|
|
|
|
dec d
|
|
|
|
jr nz, .loop
|
|
|
|
call RetroactivelyIgnoreEggs
|
|
|
|
ld a, c
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
FindAboveLevel:
|
2016-05-04 08:46:23 -07:00
|
|
|
ld c, $0
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPartyCount]
|
2016-05-04 08:46:23 -07:00
|
|
|
ld d, a
|
|
|
|
.loop
|
|
|
|
ld a, d
|
|
|
|
dec a
|
|
|
|
push hl
|
|
|
|
push bc
|
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
|
|
|
call AddNTimes
|
|
|
|
pop bc
|
|
|
|
ld a, b
|
|
|
|
cp [hl]
|
|
|
|
pop hl
|
|
|
|
jr c, .greater
|
|
|
|
ld a, c
|
|
|
|
or $1
|
|
|
|
ld c, a
|
|
|
|
|
|
|
|
.greater
|
|
|
|
sla c
|
|
|
|
dec d
|
|
|
|
jr nz, .loop
|
|
|
|
call RetroactivelyIgnoreEggs
|
|
|
|
ld a, c
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
FindThatSpecies:
|
2016-05-04 08:46:23 -07:00
|
|
|
; Find species b in your party.
|
|
|
|
; If you have no Pokemon, returns c = -1 and z.
|
|
|
|
; If that species is in your party, returns its location in c, and nz.
|
|
|
|
; Otherwise, returns z.
|
|
|
|
ld c, -1
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPartySpecies
|
2016-05-04 08:46:23 -07:00
|
|
|
.loop
|
|
|
|
ld a, [hli]
|
|
|
|
cp -1
|
|
|
|
ret z
|
|
|
|
inc c
|
|
|
|
cp b
|
|
|
|
jr nz, .loop
|
|
|
|
ld a, $1
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
RetroactivelyIgnoreEggs:
|
2016-05-04 08:46:23 -07:00
|
|
|
ld e, -2
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPartySpecies
|
2016-05-04 08:46:23 -07:00
|
|
|
.loop
|
|
|
|
ld a, [hli]
|
|
|
|
cp -1
|
|
|
|
ret z
|
|
|
|
cp EGG
|
|
|
|
jr nz, .skip_notegg
|
|
|
|
ld a, c
|
|
|
|
and e
|
|
|
|
ld c, a
|
|
|
|
|
|
|
|
.skip_notegg
|
|
|
|
rlc e
|
|
|
|
jr .loop
|