aboutsummaryrefslogtreecommitdiffstats
path: root/engine/pokemon/add_mon.asm
diff options
context:
space:
mode:
authorNarishma-gb <194818981+Narishma-gb@users.noreply.github.com>2025-11-27 19:39:25 +0100
committerGitHub <noreply@github.com>2025-11-27 13:39:25 -0500
commit3a4382c6055e21da72357dd18638947a2acbbda9 (patch)
treecb383fbd6a0dc57e3b0f9e9483c2a3f898f42f96 /engine/pokemon/add_mon.asm
parentAvoid magic numbers for most `CopyData` calls (#542) (diff)
downloadpokeyellow-3a4382c6055e21da72357dd18638947a2acbbda9.tar.gz
pokeyellow-3a4382c6055e21da72357dd18638947a2acbbda9.tar.xz
pokeyellow-3a4382c6055e21da72357dd18638947a2acbbda9.zip
Use more Pokemon data constants, create MOVE_NAME_LENGTH (#543)
Diffstat (limited to 'engine/pokemon/add_mon.asm')
-rw-r--r--engine/pokemon/add_mon.asm33
1 files changed, 17 insertions, 16 deletions
diff --git a/engine/pokemon/add_mon.asm b/engine/pokemon/add_mon.asm
index a7c201ea..455221ce 100644
--- a/engine/pokemon/add_mon.asm
+++ b/engine/pokemon/add_mon.asm
@@ -59,7 +59,7 @@ _AddPartyMon::
.next3
ldh a, [hNewPartyLength]
dec a
- ld bc, wPartyMon2 - wPartyMon1
+ ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
ld e, l
ld d, h
@@ -117,12 +117,12 @@ _AddPartyMon::
.next4
push bc
- ld bc, wPartyMon1DVs - wPartyMon1
+ ld bc, MON_DVS
add hl, bc
pop bc
ld [hli], a
ld [hl], b ; write IVs
- ld bc, (wPartyMon1HPExp - 1) - (wPartyMon1DVs + 1)
+ ld bc, (MON_HP_EXP - 1) - (MON_DVS + 1)
add hl, bc
ld a, 1
ld c, a
@@ -142,7 +142,7 @@ _AddPartyMon::
inc de
jr .copyMonTypesAndMoves
.copyEnemyMonData
- ld bc, wEnemyMon1DVs - wEnemyMon1
+ ld bc, MON_DVS
add hl, bc
ld a, [wEnemyMonDVs] ; copy IVs from cur enemy mon
ld [hli], a
@@ -237,7 +237,7 @@ _AddPartyMon::
jr .done
.calcFreshStats
pop hl
- ld bc, wPartyMon1HPExp - 1 - wPartyMon1
+ ld bc, MON_HP_EXP - 1
add hl, bc
ld b, $0
call CalcStats ; calculate fresh set of stats
@@ -294,7 +294,7 @@ _AddEnemyMonToPlayerParty::
ld hl, wPartyMons
ld a, [wPartyCount]
dec a
- ld bc, wPartyMon2 - wPartyMon1
+ ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
ld e, l
ld d, h
@@ -379,12 +379,12 @@ _MoveMon::
ld a, [wMoveMonType]
dec a
ld hl, wPartyMons
- ld bc, wPartyMon2 - wPartyMon1 ; $2c
+ ld bc, PARTYMON_STRUCT_LENGTH
ld a, [wPartyCount]
jr nz, .addMonOffset
; if it's PARTY_TO_BOX
ld hl, wBoxMons
- ld bc, wBoxMon2 - wBoxMon1 ; $21
+ ld bc, BOXMON_STRUCT_LENGTH
ld a, [wBoxCount]
.addMonOffset
dec a
@@ -396,20 +396,20 @@ _MoveMon::
ld a, [wMoveMonType]
and a
ld hl, wBoxMons
- ld bc, wBoxMon2 - wBoxMon1 ; $21
+ ld bc, BOXMON_STRUCT_LENGTH
jr z, .addMonOffset2
cp DAYCARE_TO_PARTY
ld hl, wDayCareMon
jr z, .copyMonData
ld hl, wPartyMons
- ld bc, wPartyMon2 - wPartyMon1 ; $2c
+ ld bc, PARTYMON_STRUCT_LENGTH
.addMonOffset2
ld a, [wWhichPokemon]
call AddNTimes
.copyMonData
push hl
push de
- ld bc, wBoxMon2 - wBoxMon1
+ ld bc, BOXMON_STRUCT_LENGTH
call CopyData
pop de
pop hl
@@ -418,7 +418,7 @@ _MoveMon::
jr z, .findOTdest
cp DAYCARE_TO_PARTY
jr z, .findOTdest
- ld bc, wBoxMon2 - wBoxMon1
+ ld bc, BOXMON_STRUCT_LENGTH
add hl, bc
ld a, [hl] ; hl = Level
inc de
@@ -493,6 +493,7 @@ _MoveMon::
jr z, .done
cp PARTY_TO_DAYCARE
jr z, .done
+ ; returning mon to party, compute level and stats
push hl
srl a
add $2
@@ -502,13 +503,13 @@ _MoveMon::
ld a, d
ld [wCurEnemyLevel], a
pop hl
- ld bc, wBoxMon2 - wBoxMon1
- add hl, bc
+ ld bc, BOXMON_STRUCT_LENGTH
+ add hl, bc ; hl = wPartyMon*Level
ld [hli], a
ld d, h
ld e, l
- ld bc, -18
- add hl, bc
+ ld bc, (MON_HP_EXP - 1) - MON_STATS
+ add hl, bc ; hl = wPartyMon*HPExp - 1
ld b, $1
call CalcStats
.done