2018-12-23 11:02:07 -08:00
|
|
|
RANDY_OT_ID EQU 01001
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
TryAddMonToParty:
|
2018-02-22 08:13:29 -08:00
|
|
|
; Check if to copy wild mon or generate a new one
|
2015-12-24 19:58:42 -08:00
|
|
|
; Whose is it?
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wPartyCount
|
|
|
|
ld a, [wMonType]
|
2015-12-24 19:58:42 -08:00
|
|
|
and $f
|
|
|
|
jr z, .getpartylocation ; PARTYMON
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wOTPartyCount
|
2015-12-24 19:58:42 -08:00
|
|
|
|
|
|
|
.getpartylocation
|
|
|
|
; Do we have room for it?
|
|
|
|
ld a, [de]
|
|
|
|
inc a
|
|
|
|
cp PARTY_LENGTH + 1
|
|
|
|
ret nc
|
|
|
|
; Increase the party count
|
|
|
|
ld [de], a
|
|
|
|
ld a, [de] ; Why are we doing this?
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hMoveMon], a ; HRAM backup
|
2015-12-24 19:58:42 -08:00
|
|
|
add e
|
|
|
|
ld e, a
|
|
|
|
jr nc, .loadspecies
|
|
|
|
inc d
|
|
|
|
|
|
|
|
.loadspecies
|
|
|
|
; Load the species of the Pokemon into the party list.
|
|
|
|
; The terminator is usually here, but it'll be back.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartySpecies]
|
2015-12-24 19:58:42 -08:00
|
|
|
ld [de], a
|
|
|
|
; Load the terminator into the next slot.
|
|
|
|
inc de
|
|
|
|
ld a, -1
|
|
|
|
ld [de], a
|
|
|
|
; Now let's load the OT name.
|
2021-03-17 13:16:02 -07:00
|
|
|
ld hl, wPartyMonOTs
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMonType]
|
2015-12-24 19:58:42 -08:00
|
|
|
and $f
|
|
|
|
jr z, .loadOTname
|
2021-03-17 13:16:02 -07:00
|
|
|
ld hl, wOTPartyMonOTs
|
2015-12-24 19:58:42 -08:00
|
|
|
|
|
|
|
.loadOTname
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hMoveMon] ; Restore index from backup
|
2015-12-24 19:58:42 -08:00
|
|
|
dec a
|
|
|
|
call SkipNames
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPlayerName
|
2015-12-24 19:58:42 -08:00
|
|
|
ld bc, NAME_LENGTH
|
|
|
|
call CopyBytes
|
2018-02-08 10:41:12 -08:00
|
|
|
; Only initialize the nickname for party mon
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMonType]
|
2015-12-24 19:58:42 -08:00
|
|
|
and a
|
|
|
|
jr nz, .skipnickname
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartySpecies]
|
2020-12-23 13:29:30 -08:00
|
|
|
ld [wNamedObjectIndex], a
|
2015-12-24 19:58:42 -08:00
|
|
|
call GetPokemonName
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPartyMonNicknames
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hMoveMon]
|
2015-12-24 19:58:42 -08:00
|
|
|
dec a
|
|
|
|
call SkipNames
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wStringBuffer1
|
2018-01-20 09:25:55 -08:00
|
|
|
ld bc, MON_NAME_LENGTH
|
2015-12-24 19:58:42 -08:00
|
|
|
call CopyBytes
|
|
|
|
|
|
|
|
.skipnickname
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPartyMon1Species
|
|
|
|
ld a, [wMonType]
|
2015-12-24 19:58:42 -08:00
|
|
|
and $f
|
|
|
|
jr z, .initializeStats
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wOTPartyMon1Species
|
2015-12-24 19:58:42 -08:00
|
|
|
|
|
|
|
.initializeStats
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hMoveMon]
|
2015-12-24 19:58:42 -08:00
|
|
|
dec a
|
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
|
|
|
call AddNTimes
|
2018-06-24 07:09:41 -07:00
|
|
|
GeneratePartyMonStats:
|
2018-02-08 10:41:12 -08:00
|
|
|
; wBattleMode specifies whether it's a wild mon or not.
|
|
|
|
; wMonType specifies whether it's an opposing mon or not.
|
|
|
|
; wCurPartySpecies/wCurPartyLevel specify the species and level.
|
|
|
|
; hl points to the wPartyMon struct to fill.
|
|
|
|
|
2015-12-24 19:58:42 -08:00
|
|
|
ld e, l
|
|
|
|
ld d, h
|
|
|
|
push hl
|
2018-02-08 10:41:12 -08:00
|
|
|
|
|
|
|
; Initialize the species
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartySpecies]
|
|
|
|
ld [wCurSpecies], a
|
2015-12-24 19:58:42 -08:00
|
|
|
call GetBaseData
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wBaseDexNo]
|
2015-12-24 19:58:42 -08:00
|
|
|
ld [de], a
|
|
|
|
inc de
|
2018-02-08 10:41:12 -08:00
|
|
|
|
|
|
|
; Copy the item if it's a wild mon
|
2015-12-24 19:58:42 -08:00
|
|
|
ld a, [wBattleMode]
|
|
|
|
and a
|
|
|
|
ld a, $0
|
|
|
|
jr z, .skipitem
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyMonItem]
|
2015-12-24 19:58:42 -08:00
|
|
|
.skipitem
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
2018-02-08 10:41:12 -08:00
|
|
|
|
|
|
|
; Copy the moves if it's a wild mon
|
2015-12-24 19:58:42 -08:00
|
|
|
push de
|
|
|
|
ld h, d
|
|
|
|
ld l, e
|
|
|
|
ld a, [wBattleMode]
|
|
|
|
and a
|
|
|
|
jr z, .randomlygeneratemoves
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMonType]
|
2015-12-24 19:58:42 -08:00
|
|
|
and a
|
|
|
|
jr nz, .randomlygeneratemoves
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wEnemyMonMoves
|
2020-03-21 11:01:05 -07:00
|
|
|
rept NUM_MOVES - 1
|
2015-12-24 19:58:42 -08:00
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
ld [hli], a
|
2018-05-06 09:16:57 -07:00
|
|
|
endr
|
2015-12-24 19:58:42 -08:00
|
|
|
ld a, [de]
|
|
|
|
ld [hl], a
|
|
|
|
jr .next
|
|
|
|
|
|
|
|
.randomlygeneratemoves
|
|
|
|
xor a
|
2020-03-21 11:01:05 -07:00
|
|
|
rept NUM_MOVES - 1
|
2015-12-24 19:58:42 -08:00
|
|
|
ld [hli], a
|
2018-05-06 09:16:57 -07:00
|
|
|
endr
|
2015-12-24 19:58:42 -08:00
|
|
|
ld [hl], a
|
2020-11-03 16:53:07 -08:00
|
|
|
ld [wSkipMovesBeforeLevelUp], a
|
2018-01-16 11:30:10 -08:00
|
|
|
predef FillMoves
|
2015-12-24 19:58:42 -08:00
|
|
|
|
|
|
|
.next
|
|
|
|
pop de
|
2018-02-08 10:41:12 -08:00
|
|
|
rept NUM_MOVES
|
2015-12-24 19:58:42 -08:00
|
|
|
inc de
|
|
|
|
endr
|
2018-02-08 10:41:12 -08:00
|
|
|
|
|
|
|
; Initialize ID.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerID]
|
2015-12-24 19:58:42 -08:00
|
|
|
ld [de], a
|
|
|
|
inc de
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerID + 1]
|
2015-12-24 19:58:42 -08:00
|
|
|
ld [de], a
|
|
|
|
inc de
|
2018-02-08 10:41:12 -08:00
|
|
|
|
|
|
|
; Initialize Exp.
|
2015-12-24 19:58:42 -08:00
|
|
|
push de
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartyLevel]
|
2015-12-24 19:58:42 -08:00
|
|
|
ld d, a
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar CalcExpAtLevel
|
2015-12-24 19:58:42 -08:00
|
|
|
pop de
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hProduct + 1]
|
2015-12-24 19:58:42 -08:00
|
|
|
ld [de], a
|
|
|
|
inc de
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hProduct + 2]
|
2015-12-24 19:58:42 -08:00
|
|
|
ld [de], a
|
|
|
|
inc de
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hProduct + 3]
|
2015-12-24 19:58:42 -08:00
|
|
|
ld [de], a
|
|
|
|
inc de
|
2018-02-08 10:41:12 -08:00
|
|
|
|
|
|
|
; Initialize stat experience.
|
2015-12-24 19:58:42 -08:00
|
|
|
xor a
|
2018-02-08 10:41:12 -08:00
|
|
|
ld b, MON_DVS - MON_STAT_EXP
|
2015-12-24 19:58:42 -08:00
|
|
|
.loop
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
dec b
|
|
|
|
jr nz, .loop
|
2018-02-08 10:41:12 -08:00
|
|
|
|
2015-12-24 19:58:42 -08:00
|
|
|
pop hl
|
|
|
|
push hl
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMonType]
|
2015-12-24 19:58:42 -08:00
|
|
|
and $f
|
2018-02-08 10:41:12 -08:00
|
|
|
jr z, .registerpokedex
|
|
|
|
|
2015-12-24 19:58:42 -08:00
|
|
|
push hl
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall GetTrainerDVs
|
2015-12-24 19:58:42 -08:00
|
|
|
pop hl
|
2018-02-08 10:41:12 -08:00
|
|
|
jr .initializeDVs
|
2015-12-24 19:58:42 -08:00
|
|
|
|
2018-02-08 10:41:12 -08:00
|
|
|
.registerpokedex
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartySpecies]
|
2018-07-28 16:27:34 -07:00
|
|
|
ld [wTempSpecies], a
|
2015-12-24 19:58:42 -08:00
|
|
|
dec a
|
|
|
|
push de
|
|
|
|
call CheckCaughtMon
|
2018-07-28 16:27:34 -07:00
|
|
|
ld a, [wTempSpecies]
|
2015-12-24 19:58:42 -08:00
|
|
|
dec a
|
|
|
|
call SetSeenAndCaughtMon
|
|
|
|
pop de
|
2018-02-08 10:41:12 -08:00
|
|
|
|
2015-12-24 19:58:42 -08:00
|
|
|
pop hl
|
|
|
|
push hl
|
|
|
|
ld a, [wBattleMode]
|
|
|
|
and a
|
2018-02-08 10:41:12 -08:00
|
|
|
jr nz, .copywildmonDVs
|
|
|
|
|
2015-12-24 19:58:42 -08:00
|
|
|
call Random
|
|
|
|
ld b, a
|
|
|
|
call Random
|
|
|
|
ld c, a
|
2018-02-08 10:41:12 -08:00
|
|
|
.initializeDVs
|
2015-12-24 19:58:42 -08:00
|
|
|
ld a, b
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
ld a, c
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
2018-02-08 10:41:12 -08:00
|
|
|
|
|
|
|
; Initialize PP.
|
2015-12-24 19:58:42 -08:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
inc hl
|
2015-12-26 18:59:03 -08:00
|
|
|
inc hl
|
2018-01-16 11:30:10 -08:00
|
|
|
call FillPP
|
2015-12-24 19:58:42 -08:00
|
|
|
pop de
|
|
|
|
pop hl
|
2018-05-06 09:16:57 -07:00
|
|
|
rept NUM_MOVES
|
2015-12-24 19:58:42 -08:00
|
|
|
inc de
|
|
|
|
endr
|
2018-02-08 10:41:12 -08:00
|
|
|
|
|
|
|
; Initialize happiness.
|
|
|
|
ld a, BASE_HAPPINESS
|
2015-12-24 19:58:42 -08:00
|
|
|
ld [de], a
|
|
|
|
inc de
|
2018-02-08 10:41:12 -08:00
|
|
|
|
2015-12-24 19:58:42 -08:00
|
|
|
xor a
|
2018-02-08 10:41:12 -08:00
|
|
|
; PokerusStatus
|
2015-12-24 19:58:42 -08:00
|
|
|
ld [de], a
|
|
|
|
inc de
|
2018-02-08 10:41:12 -08:00
|
|
|
; CaughtData/CaughtTime/CaughtLevel
|
2015-12-24 19:58:42 -08:00
|
|
|
ld [de], a
|
|
|
|
inc de
|
2018-02-08 10:41:12 -08:00
|
|
|
; CaughtGender/CaughtLocation
|
2015-12-24 19:58:42 -08:00
|
|
|
ld [de], a
|
|
|
|
inc de
|
2018-02-08 10:41:12 -08:00
|
|
|
|
|
|
|
; Initialize level.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartyLevel]
|
2015-12-24 19:58:42 -08:00
|
|
|
ld [de], a
|
|
|
|
inc de
|
2018-02-08 10:41:12 -08:00
|
|
|
|
2015-12-24 19:58:42 -08:00
|
|
|
xor a
|
2018-02-08 10:41:12 -08:00
|
|
|
; Status
|
2015-12-24 19:58:42 -08:00
|
|
|
ld [de], a
|
|
|
|
inc de
|
2018-02-08 10:41:12 -08:00
|
|
|
; Unused
|
2015-12-24 19:58:42 -08:00
|
|
|
ld [de], a
|
|
|
|
inc de
|
2018-02-08 10:41:12 -08:00
|
|
|
|
|
|
|
; Initialize HP.
|
2018-02-12 23:36:25 -08:00
|
|
|
ld bc, MON_STAT_EXP - 1
|
2015-12-24 19:58:42 -08:00
|
|
|
add hl, bc
|
2018-02-12 23:36:25 -08:00
|
|
|
ld a, 1
|
2015-12-24 19:58:42 -08:00
|
|
|
ld c, a
|
|
|
|
ld b, FALSE
|
2018-02-22 08:13:29 -08:00
|
|
|
call CalcMonStatC
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hProduct + 2]
|
2015-12-24 19:58:42 -08:00
|
|
|
ld [de], a
|
|
|
|
inc de
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hProduct + 3]
|
2015-12-24 19:58:42 -08:00
|
|
|
ld [de], a
|
|
|
|
inc de
|
2018-02-08 10:41:12 -08:00
|
|
|
jr .initstats
|
2015-12-24 19:58:42 -08:00
|
|
|
|
2018-02-08 10:41:12 -08:00
|
|
|
.copywildmonDVs
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyMonDVs]
|
2015-12-24 19:58:42 -08:00
|
|
|
ld [de], a
|
|
|
|
inc de
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyMonDVs + 1]
|
2015-12-24 19:58:42 -08:00
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
|
|
|
|
push hl
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonPP
|
2015-12-24 19:58:42 -08:00
|
|
|
ld b, NUM_MOVES
|
|
|
|
.wildmonpploop
|
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
dec b
|
|
|
|
jr nz, .wildmonpploop
|
|
|
|
pop hl
|
|
|
|
|
2018-02-08 10:41:12 -08:00
|
|
|
; Initialize happiness.
|
2015-12-24 19:58:42 -08:00
|
|
|
ld a, BASE_HAPPINESS
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
2018-02-08 10:41:12 -08:00
|
|
|
|
2015-12-24 19:58:42 -08:00
|
|
|
xor a
|
2018-02-08 10:41:12 -08:00
|
|
|
; PokerusStatus
|
2015-12-24 19:58:42 -08:00
|
|
|
ld [de], a
|
|
|
|
inc de
|
2018-02-08 10:41:12 -08:00
|
|
|
; CaughtData/CaughtTime/CaughtLevel
|
2015-12-24 19:58:42 -08:00
|
|
|
ld [de], a
|
|
|
|
inc de
|
2018-02-08 10:41:12 -08:00
|
|
|
; CaughtGender/CaughtLocation
|
2015-12-24 19:58:42 -08:00
|
|
|
ld [de], a
|
|
|
|
inc de
|
2018-02-08 10:41:12 -08:00
|
|
|
|
|
|
|
; Initialize level.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartyLevel]
|
2015-12-24 19:58:42 -08:00
|
|
|
ld [de], a
|
|
|
|
inc de
|
2018-02-08 10:41:12 -08:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonStatus
|
|
|
|
; Copy wEnemyMonStatus
|
2015-12-24 19:58:42 -08:00
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
2016-06-07 05:13:08 -07:00
|
|
|
; Copy EnemyMonUnused
|
2015-12-24 19:58:42 -08:00
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
2018-01-23 14:39:09 -08:00
|
|
|
; Copy wEnemyMonHP
|
2015-12-24 19:58:42 -08:00
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
ld a, [hl]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
|
2018-02-08 10:41:12 -08:00
|
|
|
.initstats
|
2015-12-24 19:58:42 -08:00
|
|
|
ld a, [wBattleMode]
|
|
|
|
dec a
|
|
|
|
jr nz, .generatestats
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonMaxHP
|
2018-02-08 10:41:12 -08:00
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH - MON_MAXHP
|
2015-12-24 19:58:42 -08:00
|
|
|
call CopyBytes
|
|
|
|
pop hl
|
2018-02-08 10:41:12 -08:00
|
|
|
jr .registerunowndex
|
2015-12-24 19:58:42 -08:00
|
|
|
|
|
|
|
.generatestats
|
|
|
|
pop hl
|
2016-01-19 20:28:37 -08:00
|
|
|
ld bc, MON_STAT_EXP - 1
|
2015-12-24 19:58:42 -08:00
|
|
|
add hl, bc
|
2018-02-12 23:36:25 -08:00
|
|
|
ld b, FALSE
|
2018-02-22 08:13:29 -08:00
|
|
|
call CalcMonStats
|
2015-12-24 19:58:42 -08:00
|
|
|
|
2018-02-08 10:41:12 -08:00
|
|
|
.registerunowndex
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMonType]
|
2015-12-24 19:58:42 -08:00
|
|
|
and $f
|
|
|
|
jr nz, .done
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartySpecies]
|
2015-12-24 19:58:42 -08:00
|
|
|
cp UNOWN
|
|
|
|
jr nz, .done
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPartyMon1DVs
|
|
|
|
ld a, [wPartyCount]
|
2015-12-24 19:58:42 -08:00
|
|
|
dec a
|
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
|
|
|
call AddNTimes
|
2018-01-16 11:30:10 -08:00
|
|
|
predef GetUnownLetter
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar UpdateUnownDex
|
2015-12-24 19:58:42 -08:00
|
|
|
|
|
|
|
.done
|
|
|
|
scf ; When this function returns, the carry flag indicates success vs failure.
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
FillPP:
|
2015-12-24 19:58:42 -08:00
|
|
|
push bc
|
|
|
|
ld b, NUM_MOVES
|
|
|
|
.loop
|
|
|
|
ld a, [hli]
|
|
|
|
and a
|
|
|
|
jr z, .next
|
|
|
|
dec a
|
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
|
|
|
ld hl, Moves
|
|
|
|
ld bc, MOVE_LENGTH
|
|
|
|
call AddNTimes
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wStringBuffer1
|
2015-12-24 19:58:42 -08:00
|
|
|
ld a, BANK(Moves)
|
|
|
|
call FarCopyBytes
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wStringBuffer1 + MOVE_PP]
|
2015-12-24 19:58:42 -08:00
|
|
|
|
|
|
|
.next
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
dec b
|
|
|
|
jr nz, .loop
|
|
|
|
pop bc
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AddTempmonToParty:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPartyCount
|
2015-12-24 19:58:42 -08:00
|
|
|
ld a, [hl]
|
|
|
|
cp PARTY_LENGTH
|
|
|
|
scf
|
|
|
|
ret z
|
|
|
|
|
|
|
|
inc a
|
|
|
|
ld [hl], a
|
|
|
|
ld c, a
|
|
|
|
ld b, 0
|
|
|
|
add hl, bc
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartySpecies]
|
2015-12-24 19:58:42 -08:00
|
|
|
ld [hli], a
|
|
|
|
ld [hl], $ff
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPartyMon1Species
|
|
|
|
ld a, [wPartyCount]
|
2015-12-24 19:58:42 -08:00
|
|
|
dec a
|
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
|
|
|
call AddNTimes
|
|
|
|
ld e, l
|
|
|
|
ld d, h
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wTempMonSpecies
|
2015-12-24 19:58:42 -08:00
|
|
|
call CopyBytes
|
|
|
|
|
2021-03-17 13:16:02 -07:00
|
|
|
ld hl, wPartyMonOTs
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPartyCount]
|
2015-12-24 19:58:42 -08:00
|
|
|
dec a
|
|
|
|
call SkipNames
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
2021-03-17 13:16:02 -07:00
|
|
|
ld hl, wOTPartyMonOTs
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartyMon]
|
2015-12-24 19:58:42 -08:00
|
|
|
call SkipNames
|
|
|
|
ld bc, NAME_LENGTH
|
|
|
|
call CopyBytes
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPartyMonNicknames
|
|
|
|
ld a, [wPartyCount]
|
2015-12-24 19:58:42 -08:00
|
|
|
dec a
|
|
|
|
call SkipNames
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wOTPartyMonNicknames
|
|
|
|
ld a, [wCurPartyMon]
|
2015-12-24 19:58:42 -08:00
|
|
|
call SkipNames
|
2018-01-20 09:25:55 -08:00
|
|
|
ld bc, MON_NAME_LENGTH
|
2015-12-24 19:58:42 -08:00
|
|
|
call CopyBytes
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartySpecies]
|
2020-12-23 13:29:30 -08:00
|
|
|
ld [wNamedObjectIndex], a
|
2015-12-24 19:58:42 -08:00
|
|
|
cp EGG
|
|
|
|
jr z, .egg
|
|
|
|
dec a
|
|
|
|
call SetSeenAndCaughtMon
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPartyMon1Happiness
|
|
|
|
ld a, [wPartyCount]
|
2015-12-24 19:58:42 -08:00
|
|
|
dec a
|
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
|
|
|
call AddNTimes
|
|
|
|
ld [hl], BASE_HAPPINESS
|
|
|
|
.egg
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartySpecies]
|
2015-12-24 19:58:42 -08:00
|
|
|
cp UNOWN
|
|
|
|
jr nz, .done
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPartyMon1DVs
|
|
|
|
ld a, [wPartyCount]
|
2015-12-24 19:58:42 -08:00
|
|
|
dec a
|
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
|
|
|
call AddNTimes
|
2018-01-16 11:30:10 -08:00
|
|
|
predef GetUnownLetter
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar UpdateUnownDex
|
2015-12-24 19:58:42 -08:00
|
|
|
ld a, [wFirstUnownSeen]
|
|
|
|
and a
|
|
|
|
jr nz, .done
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wUnownLetter]
|
2015-12-24 19:58:42 -08:00
|
|
|
ld [wFirstUnownSeen], a
|
|
|
|
.done
|
|
|
|
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SendGetMonIntoFromBox:
|
2018-02-22 08:13:29 -08:00
|
|
|
; Sents/Gets mon into/from Box depending on Parameter
|
|
|
|
; wPokemonWithdrawDepositParameter == 0: get mon into Party
|
|
|
|
; wPokemonWithdrawDepositParameter == 1: sent mon into Box
|
|
|
|
; wPokemonWithdrawDepositParameter == 2: get mon from DayCare
|
|
|
|
; wPokemonWithdrawDepositParameter == 3: put mon into DayCare
|
2015-12-24 19:58:42 -08:00
|
|
|
|
|
|
|
ld a, BANK(sBoxCount)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2015-12-24 19:58:42 -08:00
|
|
|
ld a, [wPokemonWithdrawDepositParameter]
|
|
|
|
and a
|
|
|
|
jr z, .check_IfPartyIsFull
|
2017-12-10 10:37:15 -08:00
|
|
|
cp DAY_CARE_WITHDRAW
|
2015-12-24 19:58:42 -08:00
|
|
|
jr z, .check_IfPartyIsFull
|
2017-12-10 10:37:15 -08:00
|
|
|
cp DAY_CARE_DEPOSIT
|
2015-12-24 19:58:42 -08:00
|
|
|
ld hl, wBreedMon1Species
|
|
|
|
jr z, .breedmon
|
|
|
|
|
2018-02-22 08:13:29 -08:00
|
|
|
; we want to sent a mon into the Box
|
2016-06-07 05:13:08 -07:00
|
|
|
; so check if there's enough space
|
2015-12-24 19:58:42 -08:00
|
|
|
ld hl, sBoxCount
|
|
|
|
ld a, [hl]
|
|
|
|
cp MONS_PER_BOX
|
|
|
|
jr nz, .there_is_room
|
|
|
|
jp CloseSRAM_And_SetCarryFlag
|
|
|
|
|
|
|
|
.check_IfPartyIsFull
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPartyCount
|
2015-12-24 19:58:42 -08:00
|
|
|
ld a, [hl]
|
|
|
|
cp PARTY_LENGTH
|
|
|
|
jp z, CloseSRAM_And_SetCarryFlag
|
|
|
|
|
|
|
|
.there_is_room
|
|
|
|
inc a
|
|
|
|
ld [hl], a
|
|
|
|
ld c, a
|
|
|
|
ld b, 0
|
|
|
|
add hl, bc
|
|
|
|
ld a, [wPokemonWithdrawDepositParameter]
|
2017-12-10 10:37:15 -08:00
|
|
|
cp DAY_CARE_WITHDRAW
|
2015-12-24 19:58:42 -08:00
|
|
|
ld a, [wBreedMon1Species]
|
|
|
|
jr z, .okay1
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartySpecies]
|
2015-12-24 19:58:42 -08:00
|
|
|
|
|
|
|
.okay1
|
|
|
|
ld [hli], a
|
|
|
|
ld [hl], $ff
|
|
|
|
ld a, [wPokemonWithdrawDepositParameter]
|
|
|
|
dec a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPartyMon1Species
|
2015-12-24 19:58:42 -08:00
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPartyCount]
|
2015-12-24 19:58:42 -08:00
|
|
|
jr nz, .okay2
|
|
|
|
ld hl, sBoxMon1Species
|
|
|
|
ld bc, BOXMON_STRUCT_LENGTH
|
|
|
|
ld a, [sBoxCount]
|
|
|
|
|
|
|
|
.okay2
|
2018-01-23 14:39:09 -08:00
|
|
|
dec a ; wPartyCount - 1
|
2015-12-24 19:58:42 -08:00
|
|
|
call AddNTimes
|
|
|
|
|
|
|
|
.breedmon
|
|
|
|
push hl
|
|
|
|
ld e, l
|
|
|
|
ld d, h
|
|
|
|
ld a, [wPokemonWithdrawDepositParameter]
|
|
|
|
and a
|
|
|
|
ld hl, sBoxMon1Species
|
|
|
|
ld bc, BOXMON_STRUCT_LENGTH
|
|
|
|
jr z, .okay3
|
2017-12-10 10:37:15 -08:00
|
|
|
cp DAY_CARE_WITHDRAW
|
2015-12-24 19:58:42 -08:00
|
|
|
ld hl, wBreedMon1Species
|
|
|
|
jr z, .okay4
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPartyMon1Species
|
2015-12-24 19:58:42 -08:00
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
|
|
|
|
|
|
|
.okay3
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartyMon]
|
2015-12-24 19:58:42 -08:00
|
|
|
call AddNTimes
|
|
|
|
|
|
|
|
.okay4
|
|
|
|
ld bc, BOXMON_STRUCT_LENGTH
|
|
|
|
call CopyBytes
|
|
|
|
ld a, [wPokemonWithdrawDepositParameter]
|
2017-12-10 10:37:15 -08:00
|
|
|
cp DAY_CARE_DEPOSIT
|
2015-12-24 19:58:42 -08:00
|
|
|
ld de, wBreedMon1OT
|
|
|
|
jr z, .okay5
|
|
|
|
dec a
|
2021-03-17 13:16:02 -07:00
|
|
|
ld hl, wPartyMonOTs
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPartyCount]
|
2015-12-24 19:58:42 -08:00
|
|
|
jr nz, .okay6
|
2021-03-17 13:16:02 -07:00
|
|
|
ld hl, sBoxMonOTs
|
2015-12-24 19:58:42 -08:00
|
|
|
ld a, [sBoxCount]
|
|
|
|
|
|
|
|
.okay6
|
|
|
|
dec a
|
|
|
|
call SkipNames
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
|
|
|
|
|
|
|
.okay5
|
2021-03-17 13:16:02 -07:00
|
|
|
ld hl, sBoxMonOTs
|
2015-12-24 19:58:42 -08:00
|
|
|
ld a, [wPokemonWithdrawDepositParameter]
|
|
|
|
and a
|
|
|
|
jr z, .okay7
|
|
|
|
ld hl, wBreedMon1OT
|
2017-12-10 10:37:15 -08:00
|
|
|
cp DAY_CARE_WITHDRAW
|
2015-12-24 19:58:42 -08:00
|
|
|
jr z, .okay8
|
2021-03-17 13:16:02 -07:00
|
|
|
ld hl, wPartyMonOTs
|
2015-12-24 19:58:42 -08:00
|
|
|
|
|
|
|
.okay7
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartyMon]
|
2015-12-24 19:58:42 -08:00
|
|
|
call SkipNames
|
|
|
|
|
|
|
|
.okay8
|
|
|
|
ld bc, NAME_LENGTH
|
|
|
|
call CopyBytes
|
|
|
|
ld a, [wPokemonWithdrawDepositParameter]
|
2017-12-10 10:37:15 -08:00
|
|
|
cp DAY_CARE_DEPOSIT
|
2021-03-17 13:16:02 -07:00
|
|
|
ld de, wBreedMon1Nickname
|
2015-12-24 19:58:42 -08:00
|
|
|
jr z, .okay9
|
|
|
|
dec a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPartyMonNicknames
|
|
|
|
ld a, [wPartyCount]
|
2015-12-24 19:58:42 -08:00
|
|
|
jr nz, .okay10
|
|
|
|
ld hl, sBoxMonNicknames
|
|
|
|
ld a, [sBoxCount]
|
|
|
|
|
|
|
|
.okay10
|
|
|
|
dec a
|
|
|
|
call SkipNames
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
|
|
|
|
|
|
|
.okay9
|
|
|
|
ld hl, sBoxMonNicknames
|
|
|
|
ld a, [wPokemonWithdrawDepositParameter]
|
|
|
|
and a
|
|
|
|
jr z, .okay11
|
2021-03-17 13:16:02 -07:00
|
|
|
ld hl, wBreedMon1Nickname
|
2017-12-10 10:37:15 -08:00
|
|
|
cp DAY_CARE_WITHDRAW
|
2015-12-24 19:58:42 -08:00
|
|
|
jr z, .okay12
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPartyMonNicknames
|
2015-12-24 19:58:42 -08:00
|
|
|
|
|
|
|
.okay11
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartyMon]
|
2015-12-24 19:58:42 -08:00
|
|
|
call SkipNames
|
|
|
|
|
|
|
|
.okay12
|
2018-01-20 09:25:55 -08:00
|
|
|
ld bc, MON_NAME_LENGTH
|
2015-12-24 19:58:42 -08:00
|
|
|
call CopyBytes
|
|
|
|
pop hl
|
|
|
|
|
|
|
|
ld a, [wPokemonWithdrawDepositParameter]
|
|
|
|
cp PC_DEPOSIT
|
|
|
|
jr z, .took_out_of_box
|
2017-12-10 10:37:15 -08:00
|
|
|
cp DAY_CARE_DEPOSIT
|
2015-12-24 19:58:42 -08:00
|
|
|
jp z, .CloseSRAM_And_ClearCarryFlag
|
|
|
|
|
|
|
|
push hl
|
|
|
|
srl a
|
|
|
|
add $2
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wMonType], a
|
2018-02-22 08:13:29 -08:00
|
|
|
predef CopyMonToTempMon
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar CalcLevel
|
2015-12-24 19:58:42 -08:00
|
|
|
ld a, d
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCurPartyLevel], a
|
2015-12-24 19:58:42 -08:00
|
|
|
pop hl
|
|
|
|
|
|
|
|
ld b, h
|
|
|
|
ld c, l
|
|
|
|
ld hl, MON_LEVEL
|
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
|
|
|
ld hl, MON_MAXHP
|
|
|
|
add hl, bc
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
|
|
|
ld hl, MON_STAT_EXP - 1
|
|
|
|
add hl, bc
|
|
|
|
|
|
|
|
push bc
|
2018-02-22 08:13:29 -08:00
|
|
|
ld b, TRUE
|
|
|
|
call CalcMonStats
|
2015-12-24 19:58:42 -08:00
|
|
|
pop bc
|
|
|
|
|
|
|
|
ld a, [wPokemonWithdrawDepositParameter]
|
|
|
|
and a
|
|
|
|
jr nz, .CloseSRAM_And_ClearCarryFlag
|
|
|
|
ld hl, MON_STATUS
|
|
|
|
add hl, bc
|
|
|
|
xor a
|
|
|
|
ld [hl], a
|
|
|
|
ld hl, MON_HP
|
|
|
|
add hl, bc
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartySpecies]
|
2015-12-24 19:58:42 -08:00
|
|
|
cp EGG
|
|
|
|
jr z, .egg
|
|
|
|
inc hl
|
2015-12-26 18:59:03 -08:00
|
|
|
inc hl
|
2015-12-24 19:58:42 -08:00
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
ld a, [hl]
|
|
|
|
inc de
|
|
|
|
ld [de], a
|
|
|
|
jr .CloseSRAM_And_ClearCarryFlag
|
|
|
|
|
|
|
|
.egg
|
|
|
|
xor a
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
ld [de], a
|
|
|
|
jr .CloseSRAM_And_ClearCarryFlag
|
|
|
|
|
|
|
|
.took_out_of_box
|
|
|
|
ld a, [sBoxCount]
|
|
|
|
dec a
|
|
|
|
ld b, a
|
2018-08-06 08:20:59 -07:00
|
|
|
call RestorePPOfDepositedPokemon
|
2016-04-10 11:42:14 -07:00
|
|
|
.CloseSRAM_And_ClearCarryFlag:
|
2015-12-24 19:58:42 -08:00
|
|
|
call CloseSRAM
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CloseSRAM_And_SetCarryFlag:
|
2015-12-24 19:58:42 -08:00
|
|
|
call CloseSRAM
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-08-06 08:20:59 -07:00
|
|
|
RestorePPOfDepositedPokemon:
|
2015-12-24 19:58:42 -08:00
|
|
|
ld a, b
|
|
|
|
ld hl, sBoxMons
|
|
|
|
ld bc, BOXMON_STRUCT_LENGTH
|
|
|
|
call AddNTimes
|
|
|
|
ld b, h
|
|
|
|
ld c, l
|
|
|
|
ld hl, MON_PP
|
|
|
|
add hl, bc
|
|
|
|
push hl
|
|
|
|
push bc
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wTempMonPP
|
2015-12-24 19:58:42 -08:00
|
|
|
ld bc, NUM_MOVES
|
|
|
|
call CopyBytes
|
|
|
|
pop bc
|
|
|
|
ld hl, MON_MOVES
|
|
|
|
add hl, bc
|
|
|
|
push hl
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wTempMonMoves
|
2015-12-24 19:58:42 -08:00
|
|
|
ld bc, NUM_MOVES
|
|
|
|
call CopyBytes
|
|
|
|
pop hl
|
|
|
|
pop de
|
|
|
|
|
|
|
|
ld a, [wMenuCursorY]
|
|
|
|
push af
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMonType]
|
2015-12-24 19:58:42 -08:00
|
|
|
push af
|
|
|
|
ld b, 0
|
2016-05-04 08:46:23 -07:00
|
|
|
.loop
|
2015-12-24 19:58:42 -08:00
|
|
|
ld a, [hli]
|
|
|
|
and a
|
2016-05-04 08:46:23 -07:00
|
|
|
jr z, .done
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wTempMonMoves], a
|
2015-12-24 19:58:42 -08:00
|
|
|
ld a, BOXMON
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wMonType], a
|
2015-12-24 19:58:42 -08:00
|
|
|
ld a, b
|
|
|
|
ld [wMenuCursorY], a
|
|
|
|
push bc
|
|
|
|
push hl
|
|
|
|
push de
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall GetMaxPPOfMove
|
2015-12-24 19:58:42 -08:00
|
|
|
pop de
|
|
|
|
pop hl
|
2018-07-28 16:27:34 -07:00
|
|
|
ld a, [wTempPP]
|
2015-12-24 19:58:42 -08:00
|
|
|
ld b, a
|
|
|
|
ld a, [de]
|
|
|
|
and %11000000
|
|
|
|
add b
|
|
|
|
ld [de], a
|
|
|
|
pop bc
|
|
|
|
inc de
|
|
|
|
inc b
|
|
|
|
ld a, b
|
|
|
|
cp NUM_MOVES
|
2016-05-04 08:46:23 -07:00
|
|
|
jr c, .loop
|
2015-12-24 19:58:42 -08:00
|
|
|
|
2016-05-04 08:46:23 -07:00
|
|
|
.done
|
2015-12-24 19:58:42 -08:00
|
|
|
pop af
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wMonType], a
|
2015-12-24 19:58:42 -08:00
|
|
|
pop af
|
|
|
|
ld [wMenuCursorY], a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
RetrieveMonFromDayCareMan:
|
2015-12-24 19:58:42 -08:00
|
|
|
ld a, [wBreedMon1Species]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCurPartySpecies], a
|
2015-12-24 19:58:42 -08:00
|
|
|
ld de, SFX_TRANSACTION
|
|
|
|
call PlaySFX
|
|
|
|
call WaitSFX
|
|
|
|
call GetBreedMon1LevelGrowth
|
|
|
|
ld a, b
|
2020-10-29 11:45:40 -07:00
|
|
|
ld [wPrevPartyLevel], a
|
2015-12-24 19:58:42 -08:00
|
|
|
ld a, e
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCurPartyLevel], a
|
2015-12-24 19:58:42 -08:00
|
|
|
xor a
|
|
|
|
ld [wPokemonWithdrawDepositParameter], a
|
2018-02-14 02:51:47 -08:00
|
|
|
jp RetrieveBreedmon
|
2015-12-24 19:58:42 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
RetrieveMonFromDayCareLady:
|
2015-12-24 19:58:42 -08:00
|
|
|
ld a, [wBreedMon2Species]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCurPartySpecies], a
|
2015-12-24 19:58:42 -08:00
|
|
|
ld de, SFX_TRANSACTION
|
|
|
|
call PlaySFX
|
|
|
|
call WaitSFX
|
|
|
|
call GetBreedMon2LevelGrowth
|
|
|
|
ld a, b
|
2020-10-29 11:45:40 -07:00
|
|
|
ld [wPrevPartyLevel], a
|
2015-12-24 19:58:42 -08:00
|
|
|
ld a, e
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCurPartyLevel], a
|
2015-12-24 19:58:42 -08:00
|
|
|
ld a, PC_DEPOSIT
|
|
|
|
ld [wPokemonWithdrawDepositParameter], a
|
2020-10-29 11:45:40 -07:00
|
|
|
jp RetrieveBreedmon ; pointless
|
2015-12-24 19:58:42 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
RetrieveBreedmon:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPartyCount
|
2015-12-24 19:58:42 -08:00
|
|
|
ld a, [hl]
|
|
|
|
cp PARTY_LENGTH
|
|
|
|
jr nz, .room_in_party
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
|
|
|
.room_in_party
|
|
|
|
inc a
|
|
|
|
ld [hl], a
|
|
|
|
ld c, a
|
|
|
|
ld b, 0
|
|
|
|
add hl, bc
|
|
|
|
ld a, [wPokemonWithdrawDepositParameter]
|
|
|
|
and a
|
|
|
|
ld a, [wBreedMon1Species]
|
2021-03-17 13:16:02 -07:00
|
|
|
ld de, wBreedMon1Nickname
|
2015-12-24 19:58:42 -08:00
|
|
|
jr z, .okay
|
|
|
|
ld a, [wBreedMon2Species]
|
2021-03-17 13:16:02 -07:00
|
|
|
ld de, wBreedMon2Nickname
|
2015-12-24 19:58:42 -08:00
|
|
|
|
|
|
|
.okay
|
|
|
|
ld [hli], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCurSpecies], a
|
2015-12-24 19:58:42 -08:00
|
|
|
ld a, $ff
|
|
|
|
ld [hl], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPartyMonNicknames
|
|
|
|
ld a, [wPartyCount]
|
2015-12-24 19:58:42 -08:00
|
|
|
dec a
|
|
|
|
call SkipNames
|
|
|
|
push hl
|
|
|
|
ld h, d
|
|
|
|
ld l, e
|
|
|
|
pop de
|
|
|
|
call CopyBytes
|
|
|
|
push hl
|
2021-03-17 13:16:02 -07:00
|
|
|
ld hl, wPartyMonOTs
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPartyCount]
|
2015-12-24 19:58:42 -08:00
|
|
|
dec a
|
|
|
|
call SkipNames
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
|
|
|
pop hl
|
|
|
|
call CopyBytes
|
|
|
|
push hl
|
2018-02-14 02:51:47 -08:00
|
|
|
call GetLastPartyMon
|
2015-12-24 19:58:42 -08:00
|
|
|
pop hl
|
|
|
|
ld bc, BOXMON_STRUCT_LENGTH
|
|
|
|
call CopyBytes
|
|
|
|
call GetBaseData
|
2018-02-14 02:51:47 -08:00
|
|
|
call GetLastPartyMon
|
2015-12-24 19:58:42 -08:00
|
|
|
ld b, d
|
|
|
|
ld c, e
|
|
|
|
ld hl, MON_LEVEL
|
|
|
|
add hl, bc
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartyLevel]
|
2015-12-24 19:58:42 -08:00
|
|
|
ld [hl], a
|
|
|
|
ld hl, MON_MAXHP
|
|
|
|
add hl, bc
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
2022-03-20 16:58:18 -07:00
|
|
|
ld hl, MON_EXP + 2
|
2015-12-24 19:58:42 -08:00
|
|
|
add hl, bc
|
|
|
|
push bc
|
2018-02-22 08:13:29 -08:00
|
|
|
ld b, TRUE
|
|
|
|
call CalcMonStats
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPartyMon1Moves
|
|
|
|
ld a, [wPartyCount]
|
2015-12-24 19:58:42 -08:00
|
|
|
dec a
|
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
|
|
|
call AddNTimes
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
2020-11-03 16:53:07 -08:00
|
|
|
ld a, TRUE
|
|
|
|
ld [wSkipMovesBeforeLevelUp], a
|
2018-01-16 11:30:10 -08:00
|
|
|
predef FillMoves
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPartyCount]
|
2015-12-24 19:58:42 -08:00
|
|
|
dec a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCurPartyMon], a
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall HealPartyMon
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartyLevel]
|
2015-12-24 19:58:42 -08:00
|
|
|
ld d, a
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar CalcExpAtLevel
|
2015-12-24 19:58:42 -08:00
|
|
|
pop bc
|
2022-03-20 16:58:18 -07:00
|
|
|
ld hl, MON_EXP
|
2015-12-24 19:58:42 -08:00
|
|
|
add hl, bc
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hMultiplicand]
|
2015-12-24 19:58:42 -08:00
|
|
|
ld [hli], a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hMultiplicand + 1]
|
2015-12-24 19:58:42 -08:00
|
|
|
ld [hli], a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hMultiplicand + 2]
|
2015-12-24 19:58:42 -08:00
|
|
|
ld [hl], a
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetLastPartyMon:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPartyCount]
|
2015-12-24 19:58:42 -08:00
|
|
|
dec a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPartyMon1Species
|
2015-12-24 19:58:42 -08:00
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
|
|
|
call AddNTimes
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
DepositMonWithDayCareMan:
|
2021-03-17 13:16:02 -07:00
|
|
|
ld de, wBreedMon1Nickname
|
2015-12-24 19:58:42 -08:00
|
|
|
call DepositBreedmon
|
2018-02-22 12:35:11 -08:00
|
|
|
xor a ; REMOVE_PARTY
|
2015-12-24 19:58:42 -08:00
|
|
|
ld [wPokemonWithdrawDepositParameter], a
|
|
|
|
jp RemoveMonFromPartyOrBox
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
DepositMonWithDayCareLady:
|
2021-03-17 13:16:02 -07:00
|
|
|
ld de, wBreedMon2Nickname
|
2015-12-24 19:58:42 -08:00
|
|
|
call DepositBreedmon
|
2018-02-22 12:35:11 -08:00
|
|
|
xor a ; REMOVE_PARTY
|
2015-12-24 19:58:42 -08:00
|
|
|
ld [wPokemonWithdrawDepositParameter], a
|
|
|
|
jp RemoveMonFromPartyOrBox
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
DepositBreedmon:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartyMon]
|
|
|
|
ld hl, wPartyMonNicknames
|
2015-12-24 19:58:42 -08:00
|
|
|
call SkipNames
|
|
|
|
call CopyBytes
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartyMon]
|
2021-03-17 13:16:02 -07:00
|
|
|
ld hl, wPartyMonOTs
|
2015-12-24 19:58:42 -08:00
|
|
|
call SkipNames
|
|
|
|
call CopyBytes
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartyMon]
|
|
|
|
ld hl, wPartyMon1Species
|
2015-12-24 19:58:42 -08:00
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
|
|
|
call AddNTimes
|
|
|
|
ld bc, BOXMON_STRUCT_LENGTH
|
|
|
|
jp CopyBytes
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SendMonIntoBox:
|
2018-02-22 08:13:29 -08:00
|
|
|
; Sends the mon into one of Bills Boxes
|
2018-01-23 14:39:09 -08:00
|
|
|
; the data comes mainly from 'wEnemyMon:'
|
2015-12-24 19:58:42 -08:00
|
|
|
ld a, BANK(sBoxCount)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2015-12-24 19:58:42 -08:00
|
|
|
ld de, sBoxCount
|
|
|
|
ld a, [de]
|
|
|
|
cp MONS_PER_BOX
|
|
|
|
jp nc, .full
|
|
|
|
inc a
|
|
|
|
ld [de], a
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartySpecies]
|
|
|
|
ld [wCurSpecies], a
|
2015-12-24 19:58:42 -08:00
|
|
|
ld c, a
|
|
|
|
.loop
|
|
|
|
inc de
|
|
|
|
ld a, [de]
|
|
|
|
ld b, a
|
|
|
|
ld a, c
|
|
|
|
ld c, b
|
|
|
|
ld [de], a
|
|
|
|
inc a
|
|
|
|
jr nz, .loop
|
|
|
|
|
|
|
|
call GetBaseData
|
|
|
|
call ShiftBoxMon
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPlayerName
|
2021-03-17 13:16:02 -07:00
|
|
|
ld de, sBoxMonOTs
|
2015-12-24 19:58:42 -08:00
|
|
|
ld bc, NAME_LENGTH
|
|
|
|
call CopyBytes
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartySpecies]
|
2020-12-23 13:29:30 -08:00
|
|
|
ld [wNamedObjectIndex], a
|
2015-12-24 19:58:42 -08:00
|
|
|
call GetPokemonName
|
|
|
|
|
|
|
|
ld de, sBoxMonNicknames
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wStringBuffer1
|
2018-01-20 09:25:55 -08:00
|
|
|
ld bc, MON_NAME_LENGTH
|
2015-12-24 19:58:42 -08:00
|
|
|
call CopyBytes
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMon
|
2015-12-24 19:58:42 -08:00
|
|
|
ld de, sBoxMon1
|
|
|
|
ld bc, 1 + 1 + NUM_MOVES ; species + item + moves
|
|
|
|
call CopyBytes
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPlayerID
|
2015-12-24 19:58:42 -08:00
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
ld a, [hl]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
push de
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartyLevel]
|
2015-12-24 19:58:42 -08:00
|
|
|
ld d, a
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar CalcExpAtLevel
|
2015-12-24 19:58:42 -08:00
|
|
|
pop de
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hProduct + 1]
|
2015-12-24 19:58:42 -08:00
|
|
|
ld [de], a
|
|
|
|
inc de
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hProduct + 2]
|
2015-12-24 19:58:42 -08:00
|
|
|
ld [de], a
|
|
|
|
inc de
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hProduct + 3]
|
2015-12-24 19:58:42 -08:00
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
|
2016-06-07 05:13:08 -07:00
|
|
|
; Set all 5 Experience Values to 0
|
2015-12-24 19:58:42 -08:00
|
|
|
xor a
|
2022-03-20 16:58:18 -07:00
|
|
|
ld b, 2 * NUM_EXP_STATS
|
2015-12-24 19:58:42 -08:00
|
|
|
.loop2
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
dec b
|
|
|
|
jr nz, .loop2
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonDVs
|
|
|
|
ld b, 2 + NUM_MOVES ; DVs and PP ; wEnemyMonHappiness - wEnemyMonDVs
|
2015-12-24 19:58:42 -08:00
|
|
|
.loop3
|
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
dec b
|
|
|
|
jr nz, .loop3
|
|
|
|
|
|
|
|
ld a, BASE_HAPPINESS
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
xor a
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartyLevel]
|
2015-12-24 19:58:42 -08:00
|
|
|
ld [de], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartySpecies]
|
2015-12-24 19:58:42 -08:00
|
|
|
dec a
|
|
|
|
call SetSeenAndCaughtMon
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartySpecies]
|
2015-12-24 19:58:42 -08:00
|
|
|
cp UNOWN
|
|
|
|
jr nz, .not_unown
|
|
|
|
ld hl, sBoxMon1DVs
|
2018-01-16 11:30:10 -08:00
|
|
|
predef GetUnownLetter
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar UpdateUnownDex
|
2015-12-24 19:58:42 -08:00
|
|
|
|
|
|
|
.not_unown
|
|
|
|
ld hl, sBoxMon1Moves
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wTempMonMoves
|
2015-12-24 19:58:42 -08:00
|
|
|
ld bc, NUM_MOVES
|
|
|
|
call CopyBytes
|
|
|
|
|
|
|
|
ld hl, sBoxMon1PP
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wTempMonPP
|
2015-12-24 19:58:42 -08:00
|
|
|
ld bc, NUM_MOVES
|
|
|
|
call CopyBytes
|
|
|
|
|
|
|
|
ld b, 0
|
2018-08-06 08:20:59 -07:00
|
|
|
call RestorePPOfDepositedPokemon
|
2015-12-24 19:58:42 -08:00
|
|
|
|
|
|
|
call CloseSRAM
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.full
|
2015-12-24 19:58:42 -08:00
|
|
|
call CloseSRAM
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ShiftBoxMon:
|
2021-03-17 13:16:02 -07:00
|
|
|
ld hl, sBoxMonOTs
|
2015-12-24 19:58:42 -08:00
|
|
|
ld bc, NAME_LENGTH
|
|
|
|
call .shift
|
|
|
|
|
|
|
|
ld hl, sBoxMonNicknames
|
2018-01-20 09:25:55 -08:00
|
|
|
ld bc, MON_NAME_LENGTH
|
2015-12-24 19:58:42 -08:00
|
|
|
call .shift
|
|
|
|
|
|
|
|
ld hl, sBoxMons
|
|
|
|
ld bc, BOXMON_STRUCT_LENGTH
|
|
|
|
|
|
|
|
.shift
|
|
|
|
ld a, [sBoxCount]
|
|
|
|
cp 2
|
|
|
|
ret c
|
|
|
|
|
|
|
|
push hl
|
|
|
|
call AddNTimes
|
|
|
|
dec hl
|
|
|
|
ld e, l
|
|
|
|
ld d, h
|
|
|
|
pop hl
|
|
|
|
|
|
|
|
ld a, [sBoxCount]
|
|
|
|
dec a
|
|
|
|
call AddNTimes
|
|
|
|
dec hl
|
|
|
|
|
|
|
|
push hl
|
|
|
|
ld a, [sBoxCount]
|
|
|
|
dec a
|
|
|
|
ld hl, 0
|
|
|
|
call AddNTimes
|
|
|
|
ld c, l
|
|
|
|
ld b, h
|
|
|
|
pop hl
|
|
|
|
.loop
|
|
|
|
ld a, [hld]
|
|
|
|
ld [de], a
|
|
|
|
dec de
|
|
|
|
dec bc
|
|
|
|
ld a, c
|
|
|
|
or b
|
|
|
|
jr nz, .loop
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GiveEgg::
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartySpecies]
|
2015-12-24 19:58:42 -08:00
|
|
|
push af
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar GetPreEvolution
|
|
|
|
callfar GetPreEvolution
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartySpecies]
|
2015-12-24 19:58:42 -08:00
|
|
|
dec a
|
|
|
|
|
2018-01-16 11:30:10 -08:00
|
|
|
; TryAddMonToParty sets Seen and Caught flags
|
2015-12-24 19:58:42 -08:00
|
|
|
; when it is successful. This routine will make
|
|
|
|
; sure that we aren't newly setting flags.
|
|
|
|
push af
|
|
|
|
call CheckCaughtMon
|
|
|
|
pop af
|
|
|
|
push bc
|
|
|
|
call CheckSeenMon
|
|
|
|
push bc
|
|
|
|
|
2018-01-16 11:30:10 -08:00
|
|
|
call TryAddMonToParty
|
2015-12-24 19:58:42 -08:00
|
|
|
|
|
|
|
; If we haven't caught this Pokemon before receiving
|
|
|
|
; the Egg, reset the flag that was just set by
|
2018-01-16 11:30:10 -08:00
|
|
|
; TryAddMonToParty.
|
2015-12-24 19:58:42 -08:00
|
|
|
pop bc
|
|
|
|
ld a, c
|
|
|
|
and a
|
|
|
|
jr nz, .skip_caught_flag
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartySpecies]
|
2015-12-24 19:58:42 -08:00
|
|
|
dec a
|
|
|
|
ld c, a
|
|
|
|
ld d, $0
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPokedexCaught
|
2015-12-24 19:58:42 -08:00
|
|
|
ld b, RESET_FLAG
|
2018-01-16 11:30:10 -08:00
|
|
|
predef SmallFarFlagAction
|
2015-12-24 19:58:42 -08:00
|
|
|
|
|
|
|
.skip_caught_flag
|
|
|
|
; If we haven't seen this Pokemon before receiving
|
|
|
|
; the Egg, reset the flag that was just set by
|
2018-01-16 11:30:10 -08:00
|
|
|
; TryAddMonToParty.
|
2015-12-24 19:58:42 -08:00
|
|
|
pop bc
|
|
|
|
ld a, c
|
|
|
|
and a
|
|
|
|
jr nz, .skip_seen_flag
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartySpecies]
|
2015-12-24 19:58:42 -08:00
|
|
|
dec a
|
|
|
|
ld c, a
|
|
|
|
ld d, $0
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPokedexSeen
|
2015-12-24 19:58:42 -08:00
|
|
|
ld b, RESET_FLAG
|
2018-01-16 11:30:10 -08:00
|
|
|
predef SmallFarFlagAction
|
2015-12-24 19:58:42 -08:00
|
|
|
|
|
|
|
.skip_seen_flag
|
|
|
|
pop af
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCurPartySpecies], a
|
|
|
|
ld a, [wPartyCount]
|
2015-12-24 19:58:42 -08:00
|
|
|
dec a
|
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPartyMon1Species
|
2015-12-24 19:58:42 -08:00
|
|
|
call AddNTimes
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartySpecies]
|
2015-12-24 19:58:42 -08:00
|
|
|
ld [hl], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPartyCount
|
2015-12-24 19:58:42 -08:00
|
|
|
ld a, [hl]
|
|
|
|
ld b, 0
|
|
|
|
ld c, a
|
|
|
|
add hl, bc
|
|
|
|
ld a, EGG
|
|
|
|
ld [hl], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPartyCount]
|
2015-12-24 19:58:42 -08:00
|
|
|
dec a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPartyMonNicknames
|
2015-12-24 19:58:42 -08:00
|
|
|
call SkipNames
|
|
|
|
ld de, String_Egg
|
|
|
|
call CopyName2
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPartyCount]
|
2015-12-24 19:58:42 -08:00
|
|
|
dec a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPartyMon1Happiness
|
2015-12-24 19:58:42 -08:00
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
|
|
|
call AddNTimes
|
2018-09-15 17:15:55 -07:00
|
|
|
ld a, [wDebugFlags]
|
|
|
|
bit DEBUG_FIELD_F, a
|
2015-12-24 19:58:42 -08:00
|
|
|
ld a, 1
|
|
|
|
jr nz, .got_init_happiness
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wBaseEggSteps]
|
2015-12-24 19:58:42 -08:00
|
|
|
|
|
|
|
.got_init_happiness
|
|
|
|
ld [hl], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPartyCount]
|
2015-12-24 19:58:42 -08:00
|
|
|
dec a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPartyMon1HP
|
2015-12-24 19:58:42 -08:00
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
|
|
|
call AddNTimes
|
|
|
|
xor a
|
|
|
|
ld [hli], a
|
|
|
|
ld [hl], a
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
String_Egg:
|
2015-12-24 19:58:42 -08:00
|
|
|
db "EGG@"
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
RemoveMonFromPartyOrBox:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPartyCount
|
2015-12-24 19:58:42 -08:00
|
|
|
|
|
|
|
ld a, [wPokemonWithdrawDepositParameter]
|
|
|
|
and a
|
|
|
|
jr z, .okay
|
|
|
|
|
|
|
|
ld a, BANK(sBoxCount)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2015-12-24 19:58:42 -08:00
|
|
|
ld hl, sBoxCount
|
|
|
|
|
|
|
|
.okay
|
|
|
|
ld a, [hl]
|
|
|
|
dec a
|
|
|
|
ld [hli], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartyMon]
|
2015-12-24 19:58:42 -08:00
|
|
|
ld c, a
|
|
|
|
ld b, 0
|
|
|
|
add hl, bc
|
|
|
|
ld e, l
|
|
|
|
ld d, h
|
|
|
|
inc de
|
|
|
|
.loop
|
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
ld [hli], a
|
|
|
|
inc a
|
|
|
|
jr nz, .loop
|
2021-03-17 13:16:02 -07:00
|
|
|
ld hl, wPartyMonOTs
|
2015-12-24 19:58:42 -08:00
|
|
|
ld d, PARTY_LENGTH - 1
|
|
|
|
ld a, [wPokemonWithdrawDepositParameter]
|
|
|
|
and a
|
|
|
|
jr z, .party
|
2021-03-17 13:16:02 -07:00
|
|
|
ld hl, sBoxMonOTs
|
2015-12-24 19:58:42 -08:00
|
|
|
ld d, MONS_PER_BOX - 1
|
|
|
|
|
|
|
|
.party
|
|
|
|
; If this is the last mon in our party (box),
|
|
|
|
; shift all the other mons up to close the gap.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartyMon]
|
2015-12-24 19:58:42 -08:00
|
|
|
call SkipNames
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartyMon]
|
2015-12-24 19:58:42 -08:00
|
|
|
cp d
|
|
|
|
jr nz, .delete_inside
|
|
|
|
ld [hl], -1
|
|
|
|
jp .finish
|
|
|
|
|
|
|
|
.delete_inside
|
|
|
|
; Shift the OT names
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
2018-01-20 09:25:55 -08:00
|
|
|
ld bc, MON_NAME_LENGTH
|
2015-12-24 19:58:42 -08:00
|
|
|
add hl, bc
|
2018-01-23 14:39:09 -08:00
|
|
|
ld bc, wPartyMonNicknames
|
2015-12-24 19:58:42 -08:00
|
|
|
ld a, [wPokemonWithdrawDepositParameter]
|
|
|
|
and a
|
|
|
|
jr z, .party2
|
|
|
|
ld bc, sBoxMonNicknames
|
|
|
|
.party2
|
|
|
|
call CopyDataUntil
|
|
|
|
; Shift the struct
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPartyMons
|
2015-12-24 19:58:42 -08:00
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
|
|
|
ld a, [wPokemonWithdrawDepositParameter]
|
|
|
|
and a
|
|
|
|
jr z, .party4
|
|
|
|
ld hl, sBoxMons
|
|
|
|
ld bc, BOXMON_STRUCT_LENGTH
|
|
|
|
.party4
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartyMon]
|
2015-12-24 19:58:42 -08:00
|
|
|
call AddNTimes
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
|
|
|
ld a, [wPokemonWithdrawDepositParameter]
|
|
|
|
and a
|
|
|
|
jr z, .party5
|
|
|
|
ld bc, BOXMON_STRUCT_LENGTH
|
|
|
|
add hl, bc
|
2021-03-17 13:16:02 -07:00
|
|
|
ld bc, sBoxMonOTs
|
2015-12-24 19:58:42 -08:00
|
|
|
jr .copy
|
|
|
|
|
|
|
|
.party5
|
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
|
|
|
add hl, bc
|
2021-03-17 13:16:02 -07:00
|
|
|
ld bc, wPartyMonOTs
|
2015-12-24 19:58:42 -08:00
|
|
|
.copy
|
|
|
|
call CopyDataUntil
|
|
|
|
; Shift the nicknames
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPartyMonNicknames
|
2015-12-24 19:58:42 -08:00
|
|
|
ld a, [wPokemonWithdrawDepositParameter]
|
|
|
|
and a
|
|
|
|
jr z, .party6
|
|
|
|
ld hl, sBoxMonNicknames
|
|
|
|
.party6
|
2018-01-20 09:25:55 -08:00
|
|
|
ld bc, MON_NAME_LENGTH
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartyMon]
|
2015-12-24 19:58:42 -08:00
|
|
|
call AddNTimes
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
2018-01-20 09:25:55 -08:00
|
|
|
ld bc, MON_NAME_LENGTH
|
2015-12-24 19:58:42 -08:00
|
|
|
add hl, bc
|
2018-01-23 14:39:09 -08:00
|
|
|
ld bc, wPartyMonNicknamesEnd
|
2015-12-24 19:58:42 -08:00
|
|
|
ld a, [wPokemonWithdrawDepositParameter]
|
|
|
|
and a
|
|
|
|
jr z, .party7
|
|
|
|
ld bc, sBoxMonNicknamesEnd
|
|
|
|
.party7
|
|
|
|
call CopyDataUntil
|
|
|
|
; Mail time!
|
|
|
|
.finish
|
|
|
|
ld a, [wPokemonWithdrawDepositParameter]
|
|
|
|
and a
|
|
|
|
jp nz, CloseSRAM
|
|
|
|
ld a, [wLinkMode]
|
|
|
|
and a
|
|
|
|
ret nz
|
|
|
|
; Shift mail
|
|
|
|
ld a, BANK(sPartyMail)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2015-12-24 19:58:42 -08:00
|
|
|
; If this is the last mon in our party, no need to shift mail.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPartyCount
|
|
|
|
ld a, [wCurPartyMon]
|
2015-12-24 19:58:42 -08:00
|
|
|
cp [hl]
|
|
|
|
jr z, .close_sram
|
|
|
|
; Shift our mail messages up.
|
|
|
|
ld hl, sPartyMail
|
|
|
|
ld bc, MAIL_STRUCT_LENGTH
|
|
|
|
call AddNTimes
|
|
|
|
push hl
|
|
|
|
add hl, bc
|
|
|
|
pop de
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartyMon]
|
2015-12-24 19:58:42 -08:00
|
|
|
ld b, a
|
|
|
|
.loop2
|
|
|
|
push bc
|
|
|
|
push hl
|
|
|
|
ld bc, MAIL_STRUCT_LENGTH
|
|
|
|
call CopyBytes
|
|
|
|
pop hl
|
|
|
|
push hl
|
|
|
|
ld bc, MAIL_STRUCT_LENGTH
|
|
|
|
add hl, bc
|
|
|
|
pop de
|
|
|
|
pop bc
|
|
|
|
inc b
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPartyCount]
|
2015-12-24 19:58:42 -08:00
|
|
|
cp b
|
|
|
|
jr nz, .loop2
|
|
|
|
.close_sram
|
|
|
|
jp CloseSRAM
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ComputeNPCTrademonStats:
|
2015-12-24 19:58:42 -08:00
|
|
|
ld a, MON_LEVEL
|
|
|
|
call GetPartyParamLocation
|
|
|
|
ld a, [hl]
|
2021-06-07 16:36:03 -07:00
|
|
|
ld [MON_LEVEL], a ; should be "ld [wCurPartyLevel], a"
|
2015-12-24 19:58:42 -08:00
|
|
|
ld a, MON_SPECIES
|
|
|
|
call GetPartyParamLocation
|
|
|
|
ld a, [hl]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCurSpecies], a
|
2015-12-24 19:58:42 -08:00
|
|
|
call GetBaseData
|
|
|
|
ld a, MON_MAXHP
|
|
|
|
call GetPartyParamLocation
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
|
|
|
push de
|
|
|
|
ld a, MON_STAT_EXP - 1
|
|
|
|
call GetPartyParamLocation
|
2018-02-22 08:13:29 -08:00
|
|
|
ld b, TRUE
|
|
|
|
call CalcMonStats
|
2015-12-24 19:58:42 -08:00
|
|
|
pop de
|
|
|
|
ld a, MON_HP
|
|
|
|
call GetPartyParamLocation
|
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
ld [hli], a
|
|
|
|
ld a, [de]
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CalcMonStats:
|
2018-02-22 08:13:29 -08:00
|
|
|
; Calculates all 6 Stats of a mon
|
2015-12-24 19:58:42 -08:00
|
|
|
; b: Take into account stat EXP if TRUE
|
2018-01-23 14:39:09 -08:00
|
|
|
; 'c' counts from 1-6 and points with 'wBaseStats' to the base value
|
2015-12-24 19:58:42 -08:00
|
|
|
; hl is the path to the Stat EXP
|
2018-02-22 08:13:29 -08:00
|
|
|
; de points to where the final stats will be saved
|
2015-12-24 19:58:42 -08:00
|
|
|
|
2018-07-11 12:40:09 -07:00
|
|
|
ld c, STAT_HP - 1 ; first stat
|
2015-12-24 19:58:42 -08:00
|
|
|
.loop
|
|
|
|
inc c
|
2018-02-22 08:13:29 -08:00
|
|
|
call CalcMonStatC
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hMultiplicand + 1]
|
2015-12-24 19:58:42 -08:00
|
|
|
ld [de], a
|
|
|
|
inc de
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hMultiplicand + 2]
|
2015-12-24 19:58:42 -08:00
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
ld a, c
|
2018-07-11 12:40:09 -07:00
|
|
|
cp STAT_SDEF ; last stat
|
2015-12-24 19:58:42 -08:00
|
|
|
jr nz, .loop
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CalcMonStatC:
|
2015-12-24 19:58:42 -08:00
|
|
|
; 'c' is 1-6 and points to the BaseStat
|
|
|
|
; 1: HP
|
|
|
|
; 2: Attack
|
|
|
|
; 3: Defense
|
|
|
|
; 4: Speed
|
|
|
|
; 5: SpAtk
|
|
|
|
; 6: SpDef
|
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
|
|
|
ld a, b
|
|
|
|
ld d, a
|
|
|
|
push hl
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBaseStats
|
2015-12-24 19:58:42 -08:00
|
|
|
dec hl ; has to be decreased, because 'c' begins with 1
|
2018-07-11 12:40:09 -07:00
|
|
|
ld b, 0
|
2015-12-24 19:58:42 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
ld e, a
|
|
|
|
pop hl
|
|
|
|
push hl
|
|
|
|
ld a, c
|
2018-07-11 12:40:09 -07:00
|
|
|
cp STAT_SDEF ; last stat
|
2015-12-24 19:58:42 -08:00
|
|
|
jr nz, .not_spdef
|
|
|
|
dec hl
|
2015-12-26 18:59:03 -08:00
|
|
|
dec hl
|
2015-12-24 19:58:42 -08:00
|
|
|
|
|
|
|
.not_spdef
|
|
|
|
sla c
|
|
|
|
ld a, d
|
|
|
|
and a
|
2016-01-04 05:43:55 -08:00
|
|
|
jr z, .no_stat_exp
|
2015-12-24 19:58:42 -08:00
|
|
|
add hl, bc
|
|
|
|
push de
|
|
|
|
ld a, [hld]
|
|
|
|
ld e, a
|
|
|
|
ld d, [hl]
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall GetSquareRoot
|
2015-12-24 19:58:42 -08:00
|
|
|
pop de
|
|
|
|
|
2016-01-04 05:43:55 -08:00
|
|
|
.no_stat_exp
|
2015-12-24 19:58:42 -08:00
|
|
|
srl c
|
|
|
|
pop hl
|
|
|
|
push bc
|
|
|
|
ld bc, MON_DVS - MON_HP_EXP + 1
|
|
|
|
add hl, bc
|
|
|
|
pop bc
|
|
|
|
ld a, c
|
|
|
|
cp STAT_ATK
|
|
|
|
jr z, .Attack
|
|
|
|
cp STAT_DEF
|
|
|
|
jr z, .Defense
|
|
|
|
cp STAT_SPD
|
|
|
|
jr z, .Speed
|
|
|
|
cp STAT_SATK
|
|
|
|
jr z, .Special
|
|
|
|
cp STAT_SDEF
|
|
|
|
jr z, .Special
|
2018-05-23 09:48:14 -07:00
|
|
|
; DV_HP = (DV_ATK & 1) << 3 | (DV_DEF & 1) << 2 | (DV_SPD & 1) << 1 | (DV_SPC & 1)
|
2015-12-24 19:58:42 -08:00
|
|
|
push bc
|
|
|
|
ld a, [hl]
|
|
|
|
swap a
|
2018-05-23 09:48:14 -07:00
|
|
|
and 1
|
2015-12-24 19:58:42 -08:00
|
|
|
add a
|
2016-05-10 09:31:49 -07:00
|
|
|
add a
|
|
|
|
add a
|
2015-12-24 19:58:42 -08:00
|
|
|
ld b, a
|
|
|
|
ld a, [hli]
|
2018-05-23 09:48:14 -07:00
|
|
|
and 1
|
2015-12-24 19:58:42 -08:00
|
|
|
add a
|
2015-12-26 18:59:03 -08:00
|
|
|
add a
|
2015-12-24 19:58:42 -08:00
|
|
|
add b
|
|
|
|
ld b, a
|
|
|
|
ld a, [hl]
|
|
|
|
swap a
|
2018-05-23 09:48:14 -07:00
|
|
|
and 1
|
2015-12-24 19:58:42 -08:00
|
|
|
add a
|
|
|
|
add b
|
|
|
|
ld b, a
|
|
|
|
ld a, [hl]
|
2018-05-23 09:48:14 -07:00
|
|
|
and 1
|
2015-12-24 19:58:42 -08:00
|
|
|
add b
|
|
|
|
pop bc
|
|
|
|
jr .GotDV
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Attack:
|
2015-12-24 19:58:42 -08:00
|
|
|
ld a, [hl]
|
|
|
|
swap a
|
|
|
|
and $f
|
|
|
|
jr .GotDV
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Defense:
|
2015-12-24 19:58:42 -08:00
|
|
|
ld a, [hl]
|
|
|
|
and $f
|
|
|
|
jr .GotDV
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Speed:
|
2015-12-24 19:58:42 -08:00
|
|
|
inc hl
|
|
|
|
ld a, [hl]
|
|
|
|
swap a
|
|
|
|
and $f
|
|
|
|
jr .GotDV
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Special:
|
2015-12-24 19:58:42 -08:00
|
|
|
inc hl
|
|
|
|
ld a, [hl]
|
|
|
|
and $f
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.GotDV:
|
2015-12-24 19:58:42 -08:00
|
|
|
ld d, 0
|
|
|
|
add e
|
|
|
|
ld e, a
|
|
|
|
jr nc, .no_overflow_1
|
|
|
|
inc d
|
|
|
|
|
|
|
|
.no_overflow_1
|
|
|
|
sla e
|
|
|
|
rl d
|
|
|
|
srl b
|
|
|
|
srl b
|
|
|
|
ld a, b
|
|
|
|
add e
|
|
|
|
jr nc, .no_overflow_2
|
|
|
|
inc d
|
|
|
|
|
|
|
|
.no_overflow_2
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hMultiplicand + 2], a
|
2015-12-24 19:58:42 -08:00
|
|
|
ld a, d
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hMultiplicand + 1], a
|
2015-12-24 19:58:42 -08:00
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hMultiplicand + 0], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartyLevel]
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hMultiplier], a
|
2015-12-24 19:58:42 -08:00
|
|
|
call Multiply
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hProduct + 1]
|
|
|
|
ldh [hDividend + 0], a
|
|
|
|
ldh a, [hProduct + 2]
|
|
|
|
ldh [hDividend + 1], a
|
|
|
|
ldh a, [hProduct + 3]
|
|
|
|
ldh [hDividend + 2], a
|
2015-12-24 19:58:42 -08:00
|
|
|
ld a, 100
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hDivisor], a
|
2015-12-24 19:58:42 -08:00
|
|
|
ld a, 3
|
|
|
|
ld b, a
|
|
|
|
call Divide
|
|
|
|
ld a, c
|
|
|
|
cp STAT_HP
|
2017-12-08 21:50:59 -08:00
|
|
|
ld a, STAT_MIN_NORMAL
|
2015-12-24 19:58:42 -08:00
|
|
|
jr nz, .not_hp
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartyLevel]
|
2015-12-24 19:58:42 -08:00
|
|
|
ld b, a
|
2018-08-26 10:49:38 -07:00
|
|
|
ldh a, [hQuotient + 3]
|
2015-12-24 19:58:42 -08:00
|
|
|
add b
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hMultiplicand + 2], a
|
2015-12-24 19:58:42 -08:00
|
|
|
jr nc, .no_overflow_3
|
2018-08-26 10:49:38 -07:00
|
|
|
ldh a, [hQuotient + 2]
|
2015-12-24 19:58:42 -08:00
|
|
|
inc a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hMultiplicand + 1], a
|
2015-12-24 19:58:42 -08:00
|
|
|
|
|
|
|
.no_overflow_3
|
2017-12-08 21:50:59 -08:00
|
|
|
ld a, STAT_MIN_HP
|
2015-12-24 19:58:42 -08:00
|
|
|
|
|
|
|
.not_hp
|
|
|
|
ld b, a
|
2018-08-26 10:49:38 -07:00
|
|
|
ldh a, [hQuotient + 3]
|
2015-12-24 19:58:42 -08:00
|
|
|
add b
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hMultiplicand + 2], a
|
2015-12-24 19:58:42 -08:00
|
|
|
jr nc, .no_overflow_4
|
2018-08-26 10:49:38 -07:00
|
|
|
ldh a, [hQuotient + 2]
|
2015-12-24 19:58:42 -08:00
|
|
|
inc a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hMultiplicand + 1], a
|
2015-12-24 19:58:42 -08:00
|
|
|
|
|
|
|
.no_overflow_4
|
2018-08-26 10:49:38 -07:00
|
|
|
ldh a, [hQuotient + 2]
|
2017-12-25 10:40:10 -08:00
|
|
|
cp HIGH(MAX_STAT_VALUE + 1) + 1
|
2015-12-24 19:58:42 -08:00
|
|
|
jr nc, .max_stat
|
2017-12-25 10:40:10 -08:00
|
|
|
cp HIGH(MAX_STAT_VALUE + 1)
|
2015-12-24 19:58:42 -08:00
|
|
|
jr c, .stat_value_okay
|
2018-08-26 10:49:38 -07:00
|
|
|
ldh a, [hQuotient + 3]
|
2017-12-25 10:40:10 -08:00
|
|
|
cp LOW(MAX_STAT_VALUE + 1)
|
2015-12-24 19:58:42 -08:00
|
|
|
jr c, .stat_value_okay
|
|
|
|
|
|
|
|
.max_stat
|
2017-12-25 10:40:10 -08:00
|
|
|
ld a, HIGH(MAX_STAT_VALUE)
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hMultiplicand + 1], a
|
2017-12-25 10:40:10 -08:00
|
|
|
ld a, LOW(MAX_STAT_VALUE)
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hMultiplicand + 2], a
|
2015-12-24 19:58:42 -08:00
|
|
|
|
|
|
|
.stat_value_okay
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GivePoke::
|
2015-12-24 19:58:42 -08:00
|
|
|
push de
|
|
|
|
push bc
|
|
|
|
xor a ; PARTYMON
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wMonType], a
|
2018-01-16 11:30:10 -08:00
|
|
|
call TryAddMonToParty
|
2015-12-24 19:58:42 -08:00
|
|
|
jr nc, .failed
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPartyMonNicknames
|
|
|
|
ld a, [wPartyCount]
|
2015-12-24 19:58:42 -08:00
|
|
|
dec a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCurPartyMon], a
|
2015-12-24 19:58:42 -08:00
|
|
|
call SkipNames
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
|
|
|
pop bc
|
|
|
|
ld a, b
|
|
|
|
ld b, 0
|
|
|
|
push bc
|
|
|
|
push de
|
|
|
|
push af
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurItem]
|
2015-12-24 19:58:42 -08:00
|
|
|
and a
|
|
|
|
jr z, .done
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartyMon]
|
|
|
|
ld hl, wPartyMon1Item
|
2015-12-24 19:58:42 -08:00
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
|
|
|
call AddNTimes
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurItem]
|
2015-12-24 19:58:42 -08:00
|
|
|
ld [hl], a
|
|
|
|
jr .done
|
|
|
|
|
|
|
|
.failed
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartySpecies]
|
|
|
|
ld [wTempEnemyMonSpecies], a
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar LoadEnemyMon
|
2018-02-22 08:13:29 -08:00
|
|
|
call SendMonIntoBox
|
2015-12-24 19:58:42 -08:00
|
|
|
jp nc, .FailedToGiveMon
|
|
|
|
ld a, BOXMON
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wMonType], a
|
2015-12-24 19:58:42 -08:00
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCurPartyMon], a
|
2015-12-24 19:58:42 -08:00
|
|
|
ld de, wMonOrItemNameBuffer
|
|
|
|
pop bc
|
|
|
|
ld a, b
|
|
|
|
ld b, 1
|
|
|
|
push bc
|
|
|
|
push de
|
|
|
|
push af
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurItem]
|
2015-12-24 19:58:42 -08:00
|
|
|
and a
|
|
|
|
jr z, .done
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurItem]
|
2015-12-24 19:58:42 -08:00
|
|
|
ld [sBoxMon1Item], a
|
|
|
|
|
|
|
|
.done
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartySpecies]
|
2020-12-23 13:29:30 -08:00
|
|
|
ld [wNamedObjectIndex], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wTempEnemyMonSpecies], a
|
2015-12-24 19:58:42 -08:00
|
|
|
call GetPokemonName
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wStringBuffer1
|
2015-12-24 19:58:42 -08:00
|
|
|
ld de, wMonOrItemNameBuffer
|
2018-01-20 09:25:55 -08:00
|
|
|
ld bc, MON_NAME_LENGTH
|
2015-12-24 19:58:42 -08:00
|
|
|
call CopyBytes
|
|
|
|
pop af
|
|
|
|
and a
|
|
|
|
jp z, .wildmon
|
|
|
|
pop de
|
|
|
|
pop bc
|
|
|
|
pop hl
|
|
|
|
push bc
|
|
|
|
push hl
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wScriptBank]
|
2021-01-09 12:16:05 -08:00
|
|
|
call GetFarWord
|
2018-01-20 09:25:55 -08:00
|
|
|
ld bc, MON_NAME_LENGTH
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wScriptBank]
|
2015-12-24 19:58:42 -08:00
|
|
|
call FarCopyBytes
|
|
|
|
pop hl
|
|
|
|
inc hl
|
2015-12-26 18:59:03 -08:00
|
|
|
inc hl
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wScriptBank]
|
2021-01-09 12:16:05 -08:00
|
|
|
call GetFarWord
|
2015-12-24 19:58:42 -08:00
|
|
|
pop bc
|
|
|
|
ld a, b
|
|
|
|
and a
|
|
|
|
push de
|
|
|
|
push bc
|
|
|
|
jr nz, .send_to_box
|
|
|
|
|
|
|
|
push hl
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartyMon]
|
2021-03-17 13:16:02 -07:00
|
|
|
ld hl, wPartyMonOTs
|
2015-12-24 19:58:42 -08:00
|
|
|
call SkipNames
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
|
|
|
pop hl
|
|
|
|
.otnameloop
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wScriptBank]
|
2015-12-24 19:58:42 -08:00
|
|
|
call GetFarByte
|
|
|
|
ld [de], a
|
|
|
|
inc hl
|
|
|
|
inc de
|
|
|
|
cp "@"
|
|
|
|
jr nz, .otnameloop
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wScriptBank]
|
2015-12-24 19:58:42 -08:00
|
|
|
call GetFarByte
|
|
|
|
ld b, a
|
|
|
|
push bc
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartyMon]
|
|
|
|
ld hl, wPartyMon1ID
|
2015-12-24 19:58:42 -08:00
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
|
|
|
call AddNTimes
|
2018-12-23 11:02:07 -08:00
|
|
|
ld a, HIGH(RANDY_OT_ID)
|
2015-12-24 19:58:42 -08:00
|
|
|
ld [hli], a
|
2018-12-23 11:02:07 -08:00
|
|
|
ld [hl], LOW(RANDY_OT_ID)
|
2015-12-24 19:58:42 -08:00
|
|
|
pop bc
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall SetGiftPartyMonCaughtData
|
2015-12-24 19:58:42 -08:00
|
|
|
jr .skip_nickname
|
|
|
|
|
|
|
|
.send_to_box
|
2021-03-17 13:16:02 -07:00
|
|
|
ld a, BANK(sBoxMonOTs)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2021-03-17 13:16:02 -07:00
|
|
|
ld de, sBoxMonOTs
|
2015-12-24 19:58:42 -08:00
|
|
|
.loop
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wScriptBank]
|
2015-12-24 19:58:42 -08:00
|
|
|
call GetFarByte
|
|
|
|
ld [de], a
|
|
|
|
inc hl
|
|
|
|
inc de
|
|
|
|
cp "@"
|
|
|
|
jr nz, .loop
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wScriptBank]
|
2015-12-24 19:58:42 -08:00
|
|
|
call GetFarByte
|
|
|
|
ld b, a
|
|
|
|
ld hl, sBoxMon1ID
|
|
|
|
call Random
|
|
|
|
ld [hli], a
|
|
|
|
call Random
|
|
|
|
ld [hl], a
|
|
|
|
call CloseSRAM
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall SetGiftBoxMonCaughtData
|
2015-12-24 19:58:42 -08:00
|
|
|
jr .skip_nickname
|
|
|
|
|
|
|
|
.wildmon
|
|
|
|
pop de
|
|
|
|
pop bc
|
|
|
|
push bc
|
|
|
|
push de
|
|
|
|
ld a, b
|
|
|
|
and a
|
|
|
|
jr z, .party
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall SetBoxMonCaughtData
|
2015-12-24 19:58:42 -08:00
|
|
|
jr .set_caught_data
|
|
|
|
|
|
|
|
.party
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall SetCaughtData
|
2015-12-24 19:58:42 -08:00
|
|
|
.set_caught_data
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall GiveANickname_YesNo
|
2015-12-24 19:58:42 -08:00
|
|
|
pop de
|
|
|
|
jr c, .skip_nickname
|
|
|
|
call InitNickname
|
|
|
|
|
|
|
|
.skip_nickname
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
ld a, b
|
|
|
|
and a
|
|
|
|
ret z
|
2019-10-20 15:24:17 -07:00
|
|
|
ld hl, WasSentToBillsPCText
|
2015-12-24 19:58:42 -08:00
|
|
|
call PrintText
|
|
|
|
ld a, BANK(sBoxMonNicknames)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2015-12-24 19:58:42 -08:00
|
|
|
ld hl, wMonOrItemNameBuffer
|
|
|
|
ld de, sBoxMonNicknames
|
2018-01-20 09:25:55 -08:00
|
|
|
ld bc, MON_NAME_LENGTH
|
2015-12-24 19:58:42 -08:00
|
|
|
call CopyBytes
|
|
|
|
call CloseSRAM
|
|
|
|
ld b, $1
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.FailedToGiveMon:
|
2015-12-24 19:58:42 -08:00
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
ld b, $2
|
|
|
|
ret
|
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
WasSentToBillsPCText:
|
|
|
|
text_far _WasSentToBillsPCText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|
2015-12-24 19:58:42 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
InitNickname:
|
2015-12-24 19:58:42 -08:00
|
|
|
push de
|
2018-01-23 13:08:43 -08:00
|
|
|
call LoadStandardMenuHeader
|
2015-12-24 19:58:42 -08:00
|
|
|
call DisableSpriteUpdates
|
|
|
|
pop de
|
|
|
|
push de
|
2018-09-16 13:02:58 -07:00
|
|
|
ld b, NAME_MON
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall NamingScreen
|
2015-12-24 19:58:42 -08:00
|
|
|
pop hl
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wStringBuffer1
|
2015-12-24 19:58:42 -08:00
|
|
|
call InitName
|
2020-11-09 13:38:11 -08:00
|
|
|
ld a, $4 ; ExitAllMenus is in bank 0; maybe it used to be in bank 4
|
2015-12-24 19:58:42 -08:00
|
|
|
ld hl, ExitAllMenus
|
|
|
|
rst FarCall
|
|
|
|
ret
|