summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKDLPro <38602758+KDLPro@users.noreply.github.com>2021-04-02 18:39:00 +0800
committerKDLPro <38602758+KDLPro@users.noreply.github.com>2021-04-02 18:39:00 +0800
commit04eb7cd235dcd25e7cbec89e63f4b22dc613edab (patch)
tree8109d83079baed1221cf2c8003321b0e02bf8ac1
parent092642342e9e5105b40864b6bc0ead1ccb29fe64 (diff)
Added limit total EVs to 512
-rw-r--r--Replace-stat-experience-with-EVs.md149
1 files changed, 145 insertions, 4 deletions
diff --git a/Replace-stat-experience-with-EVs.md b/Replace-stat-experience-with-EVs.md
index fe3586a..6e48028 100644
--- a/Replace-stat-experience-with-EVs.md
+++ b/Replace-stat-experience-with-EVs.md
@@ -15,7 +15,8 @@ Gen 3 replaced stat experience with EVs, which are different in a number of ways
8. [Replace some more labels](#8-replace-some-more-labels)
9. [Remove unused square root code](#9-remove-unused-square-root-code)
10. [Add Zinc to boost Special Defense EVs](#10-add-zinc-to-boost-special-defense-evs)
-11. [Replace stat experience with EVs in the Debug Room](#11-replace-stat-experience-with-evs-in-the-debug-room)
+11. [Limit total EVs to 510](#11-limit-total-evs-to-510)
+12. [Replace stat experience with EVs in the Debug Room](#12-replace-stat-experience-with-evs-in-the-debug-room)
## 1. Replace stat experience with EVs in the Pokémon data structure
@@ -707,7 +708,149 @@ That's all!
![Screenshot](screenshots/zinc.png)
-## 11. Replace stat experience with EVs in the Debug Room
+## 11. Limit total EVs to 512
+
+This section allows you to limit total EVs of each Pokémon to 512.
+
+First, edit [constants/pokemon_data_constants.asm](../blob/master/constants/pokemon_data_constants.asm) again:
+
+```diff
+; significant EV values
+MAX_EV EQU 252
++ MAX_TOTAL_EV EQU 510```
+
+Next edit `GiveExperiencePoints` in [engine/battle/core.asm](../blob/master/engine/battle/core.asm) again:
+
+```
+ jr z, .no_pokerus_boost
+ add a
+.no_pokerus_boost
++; Make sure total EVs never surpass 510
++ push de
++ ld d, a
++ push af
++ push bc
++ push hl
++ ld a, c
++.find_correct_ev_add ; if address of first ev is changed, find the correct ev address
++ cp 6
++ jr nc, .found_add
++ dec hl
++ inc a
++ jr .find_correct_ev_add
++.found_add
++ ld e, 6
++ ld bc, 0
++.count_evs
++ ld a, [hli]
++ add c
++ ld c, a
++ jr nc, .cont
++ inc b
++.cont
++ dec e
++ jr nz, .count_evs
++ ld a, d
++ add c
++ ld c, a
++ adc b
++ sub c
++ ld b, a
++ ld e, d
++.decrease_evs_gained
++ call IsEvsGreaterThan510
++ jr z, .check_ev_overflow
++ jr c, .check_ev_overflow
++ dec e
++ dec bc
++ jr .decrease_evs_gained
++.check_ev_overflow
++ pop hl
++ pop bc
++ pop af
++ ld a, e
++ pop de
+ add [hl]
+ cp MAX_EV
+
+...
+
+ ldh a, [hQuotient + 3]
+ ld [hli], a
+ dec c
+ jr nz, .base_stat_division_loop
+ ret
+
++IsEvsGreaterThan510:
++ ; EV total in bc
++ ; Returns c if lower
++ ld a, b
++ cp HIGH(MAX_TOTAL_EV)
++ ret nz
++ ld a, c
++ cp LOW(MAX_TOTAL_EV)
++ ret```
+
+What this does is first, count the EVs your Pokémon currently have, then add the EVs you would normally gain. If the total EVs after the battle is greater than 510, decrease the EVs you gained in this battle until the total EVs after the battle is 510.
+
+But this change doesn't affect vitamins, thus, we need to do another edit.
+
+Edit `VitaminEffect` in [engine/items/item_effects.asm](../blob/master/engine/items/item_effects.asm) again:
+
+```diff
+ ld a, MON_EVS
+ call GetPartyParamLocation
+
++ push de
++ ld d, 10
++ push af
++ push bc
++ push hl
++ ld e, 6
++ ld bc, 0
++.count_evs
++ ld a, [hli]
++ add c
++ ld c, a
++ jr nc, .cont
++ inc b
++.cont
++ dec e
++ jr nz, .count_evs
++ ld a, d
++ add c
++ ld c, a
++ adc b
++ sub c
++ ld b, a
++ ld e, d
++.decrease_evs_gained
++ callfar IsEvsGreaterThan510
++ jr z, .check_ev_overflow
++ jr c, .check_ev_overflow
++ dec e
++ dec bc
++ jr .decrease_evs_gained
++.check_ev_overflow
++ pop hl
++ pop bc
++ pop af
++
+
+ add hl, bc
+ ld a, [hl]
+ cp 100
+ jr nc, NoEffectMessage
+
++ ld a, e
++ cp 0
++ jr z, NoEffectMessage
+```
+
+This way, not only the limit of 510 EVs be implemented, but will display a message if EVs can't be changed if the total EVs reached the max limit.
+
+
+## 12. Replace stat experience with EVs in the Debug Room
This is only relevant if you're building a debug ROM. If you're not, you can skip this step.
@@ -770,6 +913,4 @@ Edit [engine/debug/debug_room.asm](../blob/master/engine/debug/debug_room.asm):
...
```
-TODO: limit total EVs to 510.
-
TODO: add Macho Brace.