Comment GeneratePartyMonStats

This commit is contained in:
mid-kid 2018-02-08 19:41:12 +01:00
parent 8ddffef8b8
commit 89c5f0adf0
2 changed files with 60 additions and 17 deletions

View File

@ -10,4 +10,4 @@ PnP_HiddenPlaces:
map ROUTE_16 map ROUTE_16
map ROUTE_14 map ROUTE_14
map CINNABAR_POKECENTER_2F_BETA map CINNABAR_POKECENTER_2F_BETA
PnP_HiddenPlacesEnd PnP_HiddenPlacesEnd:

View File

@ -47,6 +47,7 @@ TryAddMonToParty: ; d88c
ld hl, wPlayerName ld hl, wPlayerName
ld bc, NAME_LENGTH ld bc, NAME_LENGTH
call CopyBytes call CopyBytes
; Only initialize the nickname for party mon
ld a, [wMonType] ld a, [wMonType]
and a and a
jr nz, .skipnickname jr nz, .skipnickname
@ -76,24 +77,34 @@ TryAddMonToParty: ; d88c
ld bc, PARTYMON_STRUCT_LENGTH ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes call AddNTimes
GeneratePartyMonStats: ; d906 GeneratePartyMonStats: ; d906
; 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.
ld e, l ld e, l
ld d, h ld d, h
push hl push hl
; Initialize the species
ld a, [wCurPartySpecies] ld a, [wCurPartySpecies]
ld [wCurSpecies], a ld [wCurSpecies], a
call GetBaseData call GetBaseData
ld a, [wBaseDexNo] ld a, [wBaseDexNo]
ld [de], a ld [de], a
inc de inc de
; Copy the item if it's a wild mon
ld a, [wBattleMode] ld a, [wBattleMode]
and a and a
ld a, $0 ld a, $0
jr z, .skipitem jr z, .skipitem
ld a, [wEnemyMonItem] ld a, [wEnemyMonItem]
.skipitem .skipitem
ld [de], a ld [de], a
inc de inc de
; Copy the moves if it's a wild mon
push de push de
ld h, d ld h, d
ld l, e ld l, e
@ -124,15 +135,19 @@ GeneratePartyMonStats: ; d906
.next .next
pop de pop de
rept 4 rept NUM_MOVES
inc de inc de
endr endr
; Initialize ID.
ld a, [wPlayerID] ld a, [wPlayerID]
ld [de], a ld [de], a
inc de inc de
ld a, [wPlayerID + 1] ld a, [wPlayerID + 1]
ld [de], a ld [de], a
inc de inc de
; Initialize Exp.
push de push de
ld a, [wCurPartyLevel] ld a, [wCurPartyLevel]
ld d, a ld d, a
@ -147,24 +162,28 @@ endr
ld a, [hProduct + 3] ld a, [hProduct + 3]
ld [de], a ld [de], a
inc de inc de
; Initialize stat experience.
xor a xor a
ld b, $a ld b, MON_DVS - MON_STAT_EXP
.loop .loop
ld [de], a ld [de], a
inc de inc de
dec b dec b
jr nz, .loop jr nz, .loop
pop hl pop hl
push hl push hl
ld a, [wMonType] ld a, [wMonType]
and $f and $f
jr z, .generateDVs jr z, .registerpokedex
push hl push hl
farcall GetTrainerDVs farcall GetTrainerDVs
pop hl pop hl
jr .initializetrainermonstats jr .initializeDVs
.generateDVs .registerpokedex
ld a, [wCurPartySpecies] ld a, [wCurPartySpecies]
ld [wd265], a ld [wd265], a
dec a dec a
@ -174,23 +193,26 @@ endr
dec a dec a
call SetSeenAndCaughtMon call SetSeenAndCaughtMon
pop de pop de
pop hl pop hl
push hl push hl
ld a, [wBattleMode] ld a, [wBattleMode]
and a and a
jr nz, .copywildmonstats jr nz, .copywildmonDVs
call Random call Random
ld b, a ld b, a
call Random call Random
ld c, a ld c, a
.initializeDVs
.initializetrainermonstats
ld a, b ld a, b
ld [de], a ld [de], a
inc de inc de
ld a, c ld a, c
ld [de], a ld [de], a
inc de inc de
; Initialize PP.
push hl push hl
push de push de
inc hl inc hl
@ -201,24 +223,37 @@ endr
rept 4 rept 4
inc de inc de
endr endr
ld a, 70
; Initialize happiness.
ld a, BASE_HAPPINESS
ld [de], a ld [de], a
inc de inc de
xor a xor a
; PokerusStatus
ld [de], a ld [de], a
inc de inc de
; CaughtData/CaughtTime/CaughtLevel
ld [de], a ld [de], a
inc de inc de
; CaughtGender/CaughtLocation
ld [de], a ld [de], a
inc de inc de
; Initialize level.
ld a, [wCurPartyLevel] ld a, [wCurPartyLevel]
ld [de], a ld [de], a
inc de inc de
xor a xor a
; Status
ld [de], a ld [de], a
inc de inc de
; Unused
ld [de], a ld [de], a
inc de inc de
; Initialize HP.
ld bc, 10 ld bc, 10
add hl, bc add hl, bc
ld a, $1 ld a, $1
@ -231,9 +266,9 @@ endr
ld a, [hProduct + 3] ld a, [hProduct + 3]
ld [de], a ld [de], a
inc de inc de
jr .next2 jr .initstats
.copywildmonstats .copywildmonDVs
ld a, [wEnemyMonDVs] ld a, [wEnemyMonDVs]
ld [de], a ld [de], a
inc de inc de
@ -252,19 +287,27 @@ endr
jr nz, .wildmonpploop jr nz, .wildmonpploop
pop hl pop hl
; Initialize happiness.
ld a, BASE_HAPPINESS ld a, BASE_HAPPINESS
ld [de], a ld [de], a
inc de inc de
xor a xor a
; PokerusStatus
ld [de], a ld [de], a
inc de inc de
; CaughtData/CaughtTime/CaughtLevel
ld [de], a ld [de], a
inc de inc de
; CaughtGender/CaughtLocation
ld [de], a ld [de], a
inc de inc de
; Initialize level.
ld a, [wCurPartyLevel] ld a, [wCurPartyLevel]
ld [de], a ld [de], a
inc de inc de
ld hl, wEnemyMonStatus ld hl, wEnemyMonStatus
; Copy wEnemyMonStatus ; Copy wEnemyMonStatus
ld a, [hli] ld a, [hli]
@ -282,15 +325,15 @@ endr
ld [de], a ld [de], a
inc de inc de
.next2 .initstats
ld a, [wBattleMode] ld a, [wBattleMode]
dec a dec a
jr nz, .generatestats jr nz, .generatestats
ld hl, wEnemyMonMaxHP ld hl, wEnemyMonMaxHP
ld bc, 2 * 6 ; MaxHP + 5 Stats ld bc, PARTYMON_STRUCT_LENGTH - MON_MAXHP
call CopyBytes call CopyBytes
pop hl pop hl
jr .next3 jr .registerunowndex
.generatestats .generatestats
pop hl pop hl
@ -299,7 +342,7 @@ endr
ld b, $0 ; if b = 1, then stat calculation takes stat exp into account. ld b, $0 ; if b = 1, then stat calculation takes stat exp into account.
call CalcPkmnStats call CalcPkmnStats
.next3 .registerunowndex
ld a, [wMonType] ld a, [wMonType]
and $f and $f
jr nz, .done jr nz, .done