summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIdain <luiscarlosholguinperez@outlook.com>2021-05-19 05:00:47 -0400
committerIdain <luiscarlosholguinperez@outlook.com>2021-05-19 05:00:47 -0400
commit49dd7179bf087e7a3f3b3bcc3253ee3ec9105114 (patch)
tree95a51369df74ded76f1c1b150d95e6b4736355bd
parent5fa6ac8087a75274fdf58b00fd6ab5eafa052d17 (diff)
Updating tutorial
-rw-r--r--Replace-stat-experience-with-EVs.md160
1 files changed, 90 insertions, 70 deletions
diff --git a/Replace-stat-experience-with-EVs.md b/Replace-stat-experience-with-EVs.md
index 26b4386..735c228 100644
--- a/Replace-stat-experience-with-EVs.md
+++ b/Replace-stat-experience-with-EVs.md
@@ -110,35 +110,35 @@ Edit [wram.asm](../blob/master/wram.asm):
```diff
; corresponds to the data/pokemon/base_stats/*.asm contents
- wCurBaseData:: ; d236
- wBaseDexNo:: db ; d236
- wBaseStats:: ; d237
- wBaseHP:: db ; d237
- wBaseAttack:: db ; d238
- wBaseDefense:: db ; d239
- wBaseSpeed:: db ; d23a
- wBaseSpecialAttack:: db ; d23b
- wBaseSpecialDefense:: db ; d23c
+ wCurBaseData::
+ wBaseDexNo:: db
+ wBaseStats::
+ wBaseHP:: db
+ wBaseAttack:: db
+ wBaseDefense:: db
+ wBaseSpeed:: db
+ wBaseSpecialAttack:: db
+ wBaseSpecialDefense:: db
+wBaseEVs::
+wBaseHPAtkDefSpdEVs:: db
+wBaseSpAtkSpDefEVs:: db
- wBaseType:: ; d23d
- wBaseType1:: db ; d23d
- wBaseType2:: db ; d23e
- wBaseCatchRate:: db ; d23f
- wBaseExp:: db ; d240
- wBaseItems:: ; d241
- wBaseItem1:: db ; d241
- wBaseItem2:: db ; d242
- wBaseGender:: db ; d243
--wBaseUnknown1:: db ; d244
- wBaseEggSteps:: db ; d245
--wBaseUnknown2:: db ; d246
- wBasePicSize:: db ; d247
- wBasePadding:: ds 4 ; d248
- wBaseGrowthRate:: db ; d24c
- wBaseEggGroups:: db ; d24d
- wBaseTMHM:: flag_array NUM_TM_HM_TUTOR ; d24e
+ wBaseType::
+ wBaseType1:: db
+ wBaseType2:: db
+ wBaseCatchRate:: db
+ wBaseExp:: db
+ wBaseItems::
+ wBaseItem1:: db
+ wBaseItem2:: db
+ wBaseGender:: db
+-wBaseUnknown1:: db
+ wBaseEggSteps:: db
+-wBaseUnknown2:: db
+ wBasePicSize:: db
+ wBasePadding:: ds 4
+ wBaseGrowthRate:: db
+ wBaseEggGroups:: db
+ wBaseTMHM:: flag_array NUM_TM_HM_TUTOR
wCurBaseDataEnd::
```
@@ -233,20 +233,20 @@ GiveExperiencePoints:
- ld hl, wEnemyMonBaseStats - 1
- push bc
- ld c, NUM_EXP_STATS
--.loop1
+-.stat_exp_loop
- inc hl
- ld a, [de]
- add [hl]
- ld [de], a
-- jr nc, .okay1
+- jr nc, .no_carry_stat_exp
- dec de
- ld a, [de]
- inc a
-- jr z, .next
+- jr z, .stat_exp_maxed_out
- ld [de], a
- inc de
-
--.okay1
+-.no_carry_stat_exp
- push hl
- push bc
- ld a, MON_PKRUS
@@ -255,30 +255,30 @@ GiveExperiencePoints:
- and a
- pop bc
- pop hl
-- jr z, .skip
+- jr z, .stat_exp_awarded
- ld a, [de]
- add [hl]
- ld [de], a
-- jr nc, .skip
+- jr nc, .stat_exp_awarded
- dec de
- ld a, [de]
- inc a
-- jr z, .next
+- jr z, .stat_exp_maxed_out
- ld [de], a
- inc de
-- jr .skip
+- jr .stat_exp_maxed_out
-
--.next
+-.stat_exp_maxed_out
- ld a, $ff
- ld [de], a
- inc de
- ld [de], a
-
--.skip
+-.stat_exp_awarded
- inc de
- inc de
- dec c
-- jr nz, .loop1
+- jr nz, .stat_exp_loop
+; Give EVs
+; e = 0 for no Pokerus, 1 for Pokerus
+ ld e, 0
@@ -328,10 +328,35 @@ GiveExperiencePoints:
+ ld b, a
+ jr .ev_loop
+.evs_done
+ ...
+
+ .EvenlyDivideExpAmongParticipants:
+ ...
+ 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
+- dec c
+- jr nz, .base_stat_division_loop
++ ld [hl], a
+ ret
```
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.
+Also, since we're not using stat experience, we no longer need to divide the enemy's base stats among the battle participants.
+
## 4. Calculate stats based on EVs
@@ -494,10 +519,10 @@ Edit [engine/items/item_effects.asm](../blob/master/engine/items/item_effects.as
-GetStatExpRelativePointer:
+GetEVRelativePointer:
ld a, [wCurItem]
- ld hl, Table_eeeb
+ ld hl, StatExpItemPointerOffsets
...
- Table_eeeb:
+ StatExpItemPointerOffsets:
- db HP_UP, MON_HP_EXP - MON_STAT_EXP
- db PROTEIN, MON_ATK_EXP - MON_STAT_EXP
- db IRON, MON_DEF_EXP - MON_STAT_EXP
@@ -694,7 +719,7 @@ Then edit [engine/items/item_effects.asm](../blob/master/engine/items/item_effec
...
- Table_eeeb:
+ StatExpItemPointerOffsets:
db HP_UP, MON_HP_EV - MON_EVS
db PROTEIN, MON_ATK_EV - MON_EVS
db IRON, MON_DEF_EV - MON_EVS
@@ -715,9 +740,9 @@ This section allows you to limit total EVs of each Pokémon to 510.
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
+ ; 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:
@@ -725,21 +750,20 @@ Next edit `GiveExperiencePoints` in [engine/battle/core.asm](../blob/master/engi
```diff
jr z, .no_pokerus_boost
add a
-.no_pokerus_boost
+ .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
++.find_correct_ev_address ; If address of first EV is changed, find the correct one
+ cp 6
-+ jr nc, .found_add
++ jr z, .found_address
+ dec hl
+ inc a
-+ jr .find_correct_ev_add
-+.found_add
++ jr .find_correct_ev_address
++.found_address
+ ld e, 6
+ ld bc, 0
+.count_evs
@@ -755,13 +779,12 @@ Next edit `GiveExperiencePoints` in [engine/battle/core.asm](../blob/master/engi
+ add c
+ ld c, a
+ adc b
-+ sub c
++ sub c
+ ld b, a
+ ld e, d
+.decrease_evs_gained
+ call IsEvsGreaterThan510
-+ jr z, .check_ev_overflow
-+ jr c, .check_ev_overflow
++ jr nc, .check_ev_overflow
+ dec e
+ dec bc
+ jr .decrease_evs_gained
@@ -770,7 +793,6 @@ Next edit `GiveExperiencePoints` in [engine/battle/core.asm](../blob/master/engi
+ pop bc
+ pop af
+ ld a, e
-+ pop de
add [hl]
cp MAX_EV
@@ -783,27 +805,27 @@ Next edit `GiveExperiencePoints` in [engine/battle/core.asm](../blob/master/engi
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
++; Total EVs in bc. Set Carry flag if bc > 510.
++ ld a, HIGH(MAX_TOTAL_EV)
++ cp b
++ ret nz
++ ld a, LOW(MAX_TOTAL_EV)
++ cp c
++ 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.
+What this does is first count your Pokémon's total EVs, then add the EVs you would normally gain. If the total EVs after the battle is greater than 510, decrease the EVs you gained 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
+VitaminEffect:
+ ...
ld a, MON_EVS
call GetPartyParamLocation
-+ push de
+ ld d, 10
+ push af
+ push bc
@@ -827,9 +849,8 @@ Edit `VitaminEffect` in [engine/items/item_effects.asm](../blob/master/engine/it
+ ld b, a
+ ld e, d
+.decrease_evs_gained
-+ callfar IsEvsGreaterThan510
-+ jr z, .check_ev_overflow
-+ jr c, .check_ev_overflow
++ farcall IsEvsGreaterThan510
++ jr nc, .check_ev_overflow
+ dec e
+ dec bc
+ jr .decrease_evs_gained
@@ -837,7 +858,6 @@ Edit `VitaminEffect` in [engine/items/item_effects.asm](../blob/master/engine/it
+ pop hl
+ pop bc
+ pop af
-+
add hl, bc
ld a, [hl]
@@ -845,18 +865,18 @@ Edit `VitaminEffect` in [engine/items/item_effects.asm](../blob/master/engine/it
jr nc, NoEffectMessage
+ ld a, e
-+ cp 0
++ and a
+ 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.
+This way, not only the limit of 510 EVs is implemented, but it will also display a message if the total EVs has 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.
-The "POKéMON GET!" option in the Debug Room creates a Pokémon by manually entering each field of its `party_struct`. We need to change the stat experience fields to EVs, otherwise the debug ROM can't be assembled.
+The "POKéMON GET!" option in the Debug Room creates a Pokémon by manually editing each field of its `party_struct`. We need to change the stat experience fields to EVs, otherwise the debug ROM can't be assembled.
Edit [engine/debug/debug_room.asm](../blob/master/engine/debug/debug_room.asm):