diff options
author | Idain <luiscarlosholguinperez@outlook.com> | 2021-03-15 05:39:36 -0400 |
---|---|---|
committer | Idain <luiscarlosholguinperez@outlook.com> | 2021-03-15 05:39:36 -0400 |
commit | 1a89f67236a5b136286f5378a577ab3eaffa331c (patch) | |
tree | c16bc8bbffd40702966c56ec97d8b4343fee2270 | |
parent | 1f19aa7c8aaeedab828dc51d096ad21f4d24698d (diff) |
Added an optional step for those who try to build a debug ROM, since otherwise it won't assemble
-rw-r--r-- | Replace-stat-experience-with-EVs.md | 114 |
1 files changed, 96 insertions, 18 deletions
diff --git a/Replace-stat-experience-with-EVs.md b/Replace-stat-experience-with-EVs.md index ec9a629..fdb4e0a 100644 --- a/Replace-stat-experience-with-EVs.md +++ b/Replace-stat-experience-with-EVs.md @@ -6,15 +6,16 @@ Gen 3 replaced stat experience with EVs, which are different in a number of ways ## Contents 1. [Replace stat experience with EVs in the Pokémon data structure](#1-replace-stat-experience-with-evs-in-the-pokémon-data-structure) -2. [Replace stat experience with EVs in base data](#2-replace-stat-experience-with-evs-in-base-data) -3. [Gain EVs from winning battles](#3-gain-evs-from-winning-battles) -4. [Calculate stats based on EVs](#4-calculate-stats-based-on-evs) -5. [Vitamins give EVs, not stat experience](#5-vitamins-give-evs-not-stat-experience) -6. [Replace Odd Egg and Battle Tower stat experience with EVs](#6-replace-odd-egg-and-battle-tower-stat-experience-with-evs) -7. [Replace `MON_STAT_EXP` with `MON_EVS` everywhere](#7-replace-mon_stat_exp-with-mon_evs-everywhere) -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) +2. [(OPTIONAL) Replace stat experience with EVs in Debug Room](#2-optional-replace-stat-experience-with-evs-in-debug-room) +3. [Replace stat experience with EVs in base data](#3-replace-stat-experience-with-evs-in-base-data) +4. [Gain EVs from winning battles](#4-gain-evs-from-winning-battles) +5. [Calculate stats based on EVs](#5-calculate-stats-based-on-evs) +6. [Vitamins give EVs, not stat experience](#6-vitamins-give-evs-not-stat-experience) +7. [Replace Odd Egg and Battle Tower stat experience with EVs](#7-replace-odd-egg-and-battle-tower-stat-experience-with-evs) +8. [Replace `MON_STAT_EXP` with `MON_EVS` everywhere](#8-replace-mon_stat_exp-with-mon_evs-everywhere) +9. [Replace some more labels](#9-replace-some-more-labels) +10. [Remove unused square root code](#10-remove-unused-square-root-code) +11. [Add Zinc to boost Special Defense EVs](#11-add-zinc-to-boost-special-defense-evs) ## 1. Replace stat experience with EVs in the Pokémon data structure @@ -99,8 +100,85 @@ And edit [constants/pokemon_data_constants.asm](../blob/master/constants/pokemon 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. (OPTIONAL) Replace stat experience with EVs in Debug Room -## 2. Replace stat experience with EVs in base data +If you're going to build a debug ROM to test your project, this step is necessary. One of the options in the debug room, "POKÉMON GET!", lets you edit the structure of a Pokémon before creating it, but some pages use Stat Experience instead of EVs, so we'll need to change this; otherwise, our debug ROM won't assemble. Go to [engine/debug/debug_room.asm](.../blob/engine/debug/debug_room.asm) and edit it: + +```diff + DebugRoomMenu_PokemonGet_Page2Values: + db 8 +- paged_value wDebugRoomMonHPExp+0, $00, $ff, $00, DebugRoom_BoxStructStrings.HPExp0, NULL, FALSE +- paged_value wDebugRoomMonHPExp+1, $00, $ff, $00, DebugRoom_BoxStructStrings.HPExp1, NULL, FALSE +- paged_value wDebugRoomMonAtkExp+0, $00, $ff, $00, DebugRoom_BoxStructStrings.AttkExp0, NULL, FALSE +- paged_value wDebugRoomMonAtkExp+1, $00, $ff, $00, DebugRoom_BoxStructStrings.AttkExp1, NULL, FALSE +- paged_value wDebugRoomMonDefExp+0, $00, $ff, $00, DebugRoom_BoxStructStrings.DfnsExp0, NULL, FALSE +- paged_value wDebugRoomMonDefExp+1, $00, $ff, $00, DebugRoom_BoxStructStrings.DfnsExp1, NULL, FALSE +- paged_value wDebugRoomMonSpdExp+0, $00, $ff, $00, DebugRoom_BoxStructStrings.SpeedExp0, NULL, FALSE +- paged_value wDebugRoomMonSpdExp+1, $00, $ff, $00, DebugRoom_BoxStructStrings.SpeedExp1, NULL, FALSE ++ paged_value wDebugRoomMonHPEV, $00, $ff, $00, DebugRoom_BoxStructStrings.HPEV, NULL, FALSE ++ paged_value wDebugRoomMonAtkEV, $00, $ff, $00, DebugRoom_BoxStructStrings.AttkEV, NULL, FALSE ++ paged_value wDebugRoomMonDefEV, $00, $ff, $00, DebugRoom_BoxStructStrings.DfnsEV, NULL, FALSE ++ paged_value wDebugRoomMonSpdEV, $00, $ff, $00, DebugRoom_BoxStructStrings.SpeedEV, NULL, FALSE ++ paged_value wDebugRoomMonSpclAtkEV, $00, $ff, $00, DebugRoom_BoxStructStrings.SpclAtkEV, NULL, FALSE ++ paged_value wDebugRoomMonSpclDefEV, $00, $ff, $00, DebugRoom_BoxStructStrings.SpclDefEV, NULL, FALSE ++ paged_value wDebugRoomMonDVs+0, $00, $ff, $00, DebugRoom_BoxStructStrings.PowerRnd0, NULL, TRUE ++ paged_value wDebugRoomMonDVs+1, $00, $ff, $00, DebugRoom_BoxStructStrings.PowerRnd1, NULL, TRUE + + + DebugRoomMenu_PokemonGet_Page3Values: + db 8 +- paged_value wDebugRoomMonSpcExp+0, $00, $ff, $00, DebugRoom_BoxStructStrings.SpclExp0, NULL, FALSE +- paged_value wDebugRoomMonSpcExp+1, $00, $ff, $00, DebugRoom_BoxStructStrings.SpclExp1, NULL, FALSE +- paged_value wDebugRoomMonDVs+0, $00, $ff, $00, DebugRoom_BoxStructStrings.PowerRnd0, NULL, TRUE +- paged_value wDebugRoomMonDVs+1, $00, $ff, $00, DebugRoom_BoxStructStrings.PowerRnd1, NULL, TRUE +- paged_value wDebugRoomMonPP+0, $00, $ff, $00, DebugRoom_BoxStructStrings.PP1, NULL, FALSE +- paged_value wDebugRoomMonPP+1, $00, $ff, $00, DebugRoom_BoxStructStrings.PP2, NULL, FALSE +- paged_value wDebugRoomMonPP+2, $00, $ff, $00, DebugRoom_BoxStructStrings.PP3, NULL, FALSE +- paged_value wDebugRoomMonPP+3, $00, $ff, $00, DebugRoom_BoxStructStrings.PP4, NULL, FALSE ++ paged_value wDebugRoomMonPP+0, $00, $ff, $00, DebugRoom_BoxStructStrings.PP1, NULL, FALSE ++ paged_value wDebugRoomMonPP+1, $00, $ff, $00, DebugRoom_BoxStructStrings.PP2, NULL, FALSE ++ paged_value wDebugRoomMonPP+2, $00, $ff, $00, DebugRoom_BoxStructStrings.PP3, NULL, FALSE ++ paged_value wDebugRoomMonPP+3, $00, $ff, $00, DebugRoom_BoxStructStrings.PP4, NULL, FALSE ++ paged_value wDebugRoomMonHappiness, $00, $ff, BASE_HAPPINESS, DebugRoom_BoxStructStrings.Friend, NULL, FALSE ++ paged_value wDebugRoomMonPokerusStatus, $00, $ff, $00, DebugRoom_BoxStructStrings.Pokerus, NULL, TRUE ++ paged_value wDebugRoomMonCaughtData+0, $00, $ff, $00, DebugRoom_BoxStructStrings.NoUse0, NULL, FALSE ++ paged_value wDebugRoomMonCaughtData+1, $00, $ff, $00, DebugRoom_BoxStructStrings.NoUse1, NULL, FALSE + + + DebugRoomMenu_PokemonGet_Page4Values: +- db 6 ++ db 2 +- paged_value wDebugRoomMonHappiness, $00, $ff, BASE_HAPPINESS, DebugRoom_BoxStructStrings.Friend, NULL, FALSE +- paged_value wDebugRoomMonPokerusStatus, $00, $ff, $00, DebugRoom_BoxStructStrings.Pokerus, NULL, TRUE +- paged_value wDebugRoomMonCaughtData+0, $00, $ff, $00, DebugRoom_BoxStructStrings.NoUse0, NULL, FALSE +- paged_value wDebugRoomMonCaughtData+1, $00, $ff, $00, DebugRoom_BoxStructStrings.NoUse1, NULL, FALSE + paged_value wDebugRoomMonLevel, 1, MAX_LEVEL, $05, DebugRoom_BoxStructStrings.Level, NULL, FALSE + paged_value wDebugRoomMonBox, 1, NUM_BOXES, $0e, DebugRoom_BoxStructStrings.SendBox, NULL, FALSE +``` + +```diff + DebugRoom_BoxStructStrings: + ... +-.HPExp0: db "HP EXP[0]@" +-.HPExp1: db "HP EXP[1]@" +-.AttkExp0: db "ATTK EXP[0]@" +-.AttkExp1: db "ATTK EXP[1]@" +-.DfnsExp0: db "DFNS EXP[0]@" +-.DfnsExp1: db "DFNS EXP[1]@" +-.SpeedExp0: db "SPEED EXP[0]@" +-.SpeedExp1: db "SPEED EXP[1]@" +-.SpclExp0: db "SPCL EXP[0]@" +-.SpclExp1: db "SPCL EXP[1]@" ++.HPEV: db "HP EV@" ++.AttkEV: db "ATK EV@" ++.DfnsEV: db "DEF EV@" ++.SpeedEV: db "SPEED EV@" ++.SpclAtkEV: db "SP.ATK EV@" ++.SpclDefEV: db "SP.DEF EV@" +``` +What we did was to change all references to Stat Experience for EVs and delete all _Stat_Exp1 since they're no longer needed (remember, Stat Exp takes _two bytes_, whereas EV only takes _one_ byte, so having a second byte for stats it's useless). Also, we moved some elements from one page to another, since we've freed up some space and that way it looks more organized. + +## 3. Replace stat experience with EVs in base data When you knock out a Pokémon, the stat experience you gain is equal to its base stats. That doesn't work for EVs; each species has its own set of EV yields, with a gain of 0 to 3 for each stat. That means we can store each stat's gain in two bits, so six stats will fit in two bytes. Conveniently, there are two unused bytes in base data that we can replace. @@ -215,7 +293,7 @@ Update data/pokemon/base_stats/zubat.asm That will format all the base data files correctly, but with zero EV yields. You'll have to fill in the correct values yourself. -## 3. Gain EVs from winning battles +## 4. Gain EVs from winning battles Edit [engine/battle/core.asm](../blob/master/engine/battle/core.asm): @@ -331,7 +409,7 @@ GiveExperiencePoints: 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. -## 4. Calculate stats based on EVs +## 5. Calculate stats based on EVs Edit [engine/pokemon/move_mon.asm](../blob/master/engine/pokemon/move_mon.asm): @@ -430,7 +508,7 @@ For example, 50 EVs are equivalent to 50² = 2,500 stat exp, and 100 EVs are e Eventually this won't matter, since the maximum 252 EVs or 65,535 stat exp both result in the same stats (252 / 4 = √65,535 / 4 = 63). But you may notice your Pokémon stats growing more slowly at first, and more quickly later on than you're used to. -## 5. Vitamins give EVs, not stat experience +## 6. Vitamins give EVs, not stat experience Edit [engine/items/item_effects.asm](../blob/master/engine/items/item_effects.asm): @@ -524,7 +602,7 @@ Edit [data/items/descriptions.asm](../blob/master/data/items/descriptions.asm): ``` -## 6. Replace Odd Egg and Battle Tower stat experience with EVs +## 7. Replace Odd Egg and Battle Tower stat experience with EVs First, edit [data/events/odd_eggs.asm](../blob/master/data/events/odd_eggs.asm). Make this same replacement 14 times, once for each hard-coded Odd Egg Pokémon structure: @@ -615,7 +693,7 @@ Done! ``` -## 7. Replace `MON_STAT_EXP` with `MON_EVS` everywhere +## 8. Replace `MON_STAT_EXP` with `MON_EVS` everywhere Replace every occurrence of `MON_STAT_EXP` with `MON_EVS` in these files: @@ -632,7 +710,7 @@ Replace every occurrence of `MON_STAT_EXP` with `MON_EVS` in these files: Most of the `MON_STAT_EXP` occurrences are part of an argument passed to `CalcMonStats`. -## 8. Replace some more labels +## 9. Replace some more labels Edit [engine/events/daycare.asm](../blob/master/engine/events/daycare.asm): @@ -653,7 +731,7 @@ Edit [engine/events/daycare.asm](../blob/master/engine/events/daycare.asm): We're technically done now; EVs will work behind the scenes just like stat experience did. But there's room for more improvement. -## 9. Remove unused square root code +## 10. Remove unused square root code The only place `GetSquareRoot` was used was in `CalcMonStatC`. Without that, we can safely remove it. @@ -666,7 +744,7 @@ Then edit [main.asm](../blob/master/main.asm): ``` -## 10. Add Zinc to boost Special Defense EVs +## 11. Add Zinc to boost Special Defense EVs Now that Calcium only boosts Special Attack EVs, we need Zinc for Special Defense. Follow [this tutorial](Add-a-new-item) to add a new item. |