summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWasabiRaptor <ketchupraptor@gmail.com>2019-02-23 01:19:51 -0500
committerWasabiRaptor <ketchupraptor@gmail.com>2019-02-23 01:19:51 -0500
commitcf03eff0db322c0f67776d9062a53374fdcaf57f (patch)
tree00e528be57ae5c04f10846c8e5e13b70c9769d7f
parentc1fed533555d00ebffd8e5ac499d9b489ae17fb3 (diff)
add code for 510 total EV limit
-rw-r--r--Replace-stat-experience-with-EVs.md24
1 files changed, 21 insertions, 3 deletions
diff --git a/Replace-stat-experience-with-EVs.md b/Replace-stat-experience-with-EVs.md
index ef24100..84110ce 100644
--- a/Replace-stat-experience-with-EVs.md
+++ b/Replace-stat-experience-with-EVs.md
@@ -91,6 +91,7 @@ And edit [constants/pokemon_data_constants.asm](../blob/master/constants/pokemon
+; significant EV values
+MAX_EV EQU 252
++MAX_EVS_TOTAL EQU 510
```
By replacing the 10 stat experience bytes with 6 EV bytes, we've freed up 4 bytes in `box_struct`. That's valuable space, since it gets saved when Pokémon are deposited in the PC. Making use of it is beyond the scope of this tutorial, so we'll leave it as padding for now.
@@ -286,6 +287,23 @@ GiveExperiencePoints:
+ ld hl, MON_EVS
+ add hl, bc
+ push bc
++
++;get total EVS
++ ld d, 6 ;six EVs
++.ev_total_loop
++ ld a, [hli]
++ ;add a to bc
++ add c
++ ld c, a
++ adc b
++ sub c
++ ld b, a
++ cp MAX_EVS_TOTAL - $ff
++ jr nc, .evs_done ;don't add anymore evs if greater than the const for max which is set to 510
++ dec d
++ jr nz, .ev_total_loop
++ ;after totaling all 6 evs if it not too much then go on to add more
++
+ ld a, [wEnemyMonSpecies]
+ ld [wCurSpecies], a
+ call GetBaseData
@@ -324,7 +342,9 @@ GiveExperiencePoints:
+.evs_done
```
-Now instead of gaining the enemy's base stats toward your stat experience, you'll gain their base EV yields toward your EV totals. Having Pokérus will double EV gain.
+Now instead of gaining the enemy's base stats toward your stat experience, you'll gain their base EV yields toward your EV totals. Having Pokérus will double EV gain.
+
+If the total amount of EVs a pokemon has is greater than or equal to MAX_EVS_TOTAL, which is set to 510, then no more EVs will be added to the pokemon.
## 4. Calculate stats based on EVs
@@ -701,6 +721,4 @@ That's all!
![Screenshot](screenshots/zinc.png)
-TODO: limit total EVs to 510.
-
TODO: add Macho Brace.