summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKDLPro <38602758+KDLPro@users.noreply.github.com>2021-05-03 18:54:05 +0800
committerKDLPro <38602758+KDLPro@users.noreply.github.com>2021-05-03 18:54:05 +0800
commit654655f40b2ab5b9e91a65fb88a107ccfa2989cd (patch)
tree5d7b81f7a6cd32e2b3d1b8c159a3e689217121ec
parent6db7dea71fba315939dacac4ce22baccb2303334 (diff)
Fixed bug on dividing EVs among battle participants
-rw-r--r--Replace-stat-experience-with-EVs.md36
1 files changed, 32 insertions, 4 deletions
diff --git a/Replace-stat-experience-with-EVs.md b/Replace-stat-experience-with-EVs.md
index 26b4386..2439032 100644
--- a/Replace-stat-experience-with-EVs.md
+++ b/Replace-stat-experience-with-EVs.md
@@ -16,12 +16,13 @@ Gen 3 replaced stat experience with EVs, which are different in a number of ways
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. [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)
+12. [Fix bug that shares EVs among battle participants](#12-fix-bug-that-shares-evs-among-battle-participants)
+13. [Replace stat experience with EVs in the Debug Room](#13-replace-stat-experience-with-evs-in-the-debug-room)
## 1. Replace stat experience with EVs in the Pokémon data structure
-Stat experience for each stat is a two-byte quantity from 0 to 65,535, with a single Special stat experience shared between Special Attack and Special Defense. EVs for each stat are one byte, from 0 to 255 (actually 252), with independent Special Attack and Special Defense quantities.
+Stat experience for each stat is a two-byte quantity from 0 to 65,535, with a single Special stat experience shared between Special Attack and Special Defense. EVs for each stat is one byte, from 0 to 255 (actually 252), with independent Special Attack and Special Defense quantities.
Edit [macros/wram.asm](../blob/master/macros/wram.asm):
@@ -99,7 +100,7 @@ And edit [constants/pokemon_data_constants.asm](../blob/master/constants/pokemon
+MAX_EV EQU 252
```
-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.
+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.
## 2. Replace stat experience with EVs in base data
@@ -852,7 +853,34 @@ Edit `VitaminEffect` in [engine/items/item_effects.asm](../blob/master/engine/it
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
+## 12. Fix bug that shares EVs among battle participants
+
+In Generation 2, there is a bug with the Exp. Share in which the item shares the Stat Exp. gained is shared among battle participants and Exp. Share holders. While this is not technically a bug with the Stat Exp. system, it is considered a bug since any Pokémon that gains experience also gains all EVs awarded from that battle. We can fix this by editing `GiveExperiencePoints` in [engine/battle/core.asm](../blob/master/engine/battle/core.asm) again:
+
+```diff
+
+ ld [wTempByteValue], a
+- ld hl, wEnemyMonBaseStats
+- ld c, wEnemyMonEnd - wEnemyMonBaseStats
++ ld hl, wEnemyMonBaseExp
+-.base_stat_division_loop
+ xor a
+ ldh [hDividend + 0], a
+ ld a, [hl]
+ ldh [hDividend + 1], a
+ ld a, [wTempByteValue]
+ ldh [hDivisor], a
+ ld b, 2
+ call Divide
+ ldh a, [hQuotient + 3]
+- ld [hli], a
++ ld [hl], a
+- dec c
+- jr nz, .base_stat_division_loop
+```
+
+
+## 13. 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.