diff options
author | Brendan Byers <b11484@gmail.com> | 2019-11-18 13:12:29 -0800 |
---|---|---|
committer | Brendan Byers <b11484@gmail.com> | 2019-11-18 13:12:29 -0800 |
commit | ba8ea61956947c595720b12ca01fdfa5387cd3c2 (patch) | |
tree | 8cb087de9c355c4cead8a2c1d016d8a4bbd7fad9 | |
parent | 8ca0aa915754d366536e4344098312acd7de8595 (diff) |
Updated Add a new level cap (markdown)
-rw-r--r-- | Add-a-new-level-cap.md | 104 |
1 files changed, 79 insertions, 25 deletions
diff --git a/Add-a-new-level-cap.md b/Add-a-new-level-cap.md index a7ed7a2..bfb1838 100644 --- a/Add-a-new-level-cap.md +++ b/Add-a-new-level-cap.md @@ -1,77 +1,124 @@ **TODO**: Add context lines to the diffs, use diff syntax highlighting, and explain what this tutorial will accomplish. -1. In engine/battle/experience.asm, go to line 9, `cp LOW(MAX_LEVEL + 1)`. This is what we first need to change. Before the `ld a, d` on the line before it, add -``` +1. In `engine/pokemon/experience.asm`, go to line 9: `cp LOW(MAX_LEVEL + 1)`. This is what we first need to change. Before the `ld a, d` on the line before it, add code to load the new level cap into register `b`. + +```diff +.next_level + inc d + ld a, [wLevelCap] + inc a + push bc + ld b, a -``` -After that, below `ld a, d` add -``` + ld a, d + cp b + pop bc + cp LOW(MAX_LEVEL + 1) + jr z, .got_level + call CalcExpAtLevel ``` -2. There are now five more instances of `MAX_LEVEL` that you'll need to change. First, go to line 7149 of engine/battle/core.asm, `ld d, MAX_LEVEL`. Replace this with -``` +2. There are now five more instances of `MAX_LEVEL` that you'll need to change. First, go to the `.no_exp_overflow` label located in `engine/battle/core.asm`. Instead of storing the `MAX_LEVEL` value, we load our custom max level. + +```diff +.no_exp_overflow + ld a, [wCurPartyMon] + ld e, a + ld d, 0 + ld hl, wPartySpecies + add hl, de + ld a, [hl] + ld [wCurSpecies], a + call GetBaseData + push bc +- ld d, MAX_LEVEL + push af + ld a, [wLevelCap] + ld d, a + pop af + callfar CalcExpAtLevel ``` -Second, ctrl + f for the next instance of MAX_LEVEL. You'll notice that the line before this reads `ld a, [hl]` Before this line, add -``` + +Next, `ctrl + f` for the next instance of `MAX_LEVEL`, located in the `.not_max_exp` label. You'll notice that the line before this reads `ld a, [hl]` Before this line, load the level cap into register b. Then, after `ld a, [hl]`, add a comparison and restore the `bc` register. Here we use the comparison to control the jump. + +```diff +.not_max_exp +; Check if the mon leveled up + xor a ; PARTYMON + ld [wMonType], a + predef CopyMonToTempMon + callfar CalcLevel + pop bc + ld hl, MON_LEVEL + add hl, bc + ld a, [wLevelCap] + push bc + ld b, a -``` -Then, after `ld a, [hl]`, add -``` + ld a, [hl] + cp b + pop bc + cp MAX_LEVEL + jp nc, .next_mon ``` + Third, ctrl + f for the next instance of MAX_LEVEL. You'll notice there's a `ld a, [wBattleMonLevel]` before it. Before this, add -``` -+ ld a, [wLevelCap] -+ push bc -+ ld b, a + +```diff +AnimateExpBar: + push bc + + ld hl, wCurPartyMon + ld a, [wCurBattleMon] + cp [hl] + jp nz, .finish + + ld a, [wBattleMonLevel] + cp MAX_LEVEL + jp nc, .finish ``` After `ld a, [wBattleMonLevel]`, add -``` + +```diff + cp b + pop bc ``` Fourth, ctrl + f for the next instance of MAX_LEVEL. Replace `ld d, MAX_LEVEL` with -``` + +```diff + push af + ld a, [wLevelCap] + ld d, a + pop af ``` + Fifth, ctrl + f for the final instance of MAX_LEVEL. You'll notice before it reads `ld a, e`. Before this, add -``` + +```diff + ld a, [wLevelCap] + push bc + ld b, a ``` Then, after `ld a, e`, add -``` + +```diff + cp b + pop bc ``` + Now you're done with replacing the max level checks with the level cap checks. 3. Now, you need to add wLevelCap to wram.asm in the root folder. In wram.asm, go to line 2668, `wBeverlyFightCount:: db ; unused`. Since this byte is unused, you can replace it. Replace this line with `wLevelCap:: db`. 4. Optional: You'll notice that the exp. gain text still displays when you reach the level cap. To remove this, go to line 7059 in engine/battle/core.asm, which should be about the lines of -``` + +```diff inc de dec c jr nz, .stat_exp_loop ``` + Add this routine after it: -``` + +```diff + pop bc + ld hl, MON_LEVEL + add hl, bc @@ -84,14 +131,18 @@ Add this routine after it: + jp nc, .next_mon + push bc ``` + Next, go to -``` + +```diff ld c, PARTY_LENGTH ld d, 0 .count_loop ``` + Underneath this, add -``` + +```diff + push bc + push de + ld a, [wLevelCap] @@ -114,13 +165,16 @@ Underneath this, add + jr .no_exp +.gains_exp ``` + Last, under that is -``` + +```diff xor a srl b adc d ld d, a ``` + After this, add `.no_exp` To set a level cap, write this in a script: |