From 926ac952dbe30e2dac188e013febf215416a71ac Mon Sep 17 00:00:00 2001 From: mid-kid Date: Mon, 15 Jul 2019 18:31:13 +0200 Subject: Updated Adding Level Caps (markdown) --- Add-a-new-level-cap.md | 127 +++++++++++++++++++++++++++++++++++++++++++++++++ Adding-Level-Caps.md | 127 ------------------------------------------------- 2 files changed, 127 insertions(+), 127 deletions(-) create mode 100644 Add-a-new-level-cap.md delete mode 100644 Adding-Level-Caps.md diff --git a/Add-a-new-level-cap.md b/Add-a-new-level-cap.md new file mode 100644 index 0000000..a7ed7a2 --- /dev/null +++ b/Add-a-new-level-cap.md @@ -0,0 +1,127 @@ +**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 +``` ++ ld a, [wLevelCap] ++ inc a ++ push bc ++ ld b, a +``` +After that, below `ld a, d` add +``` ++ cp b ++ pop bc +``` + +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 +``` ++ push af ++ ld a, [wLevelCap] ++ ld d, a ++ pop af +``` +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 +``` ++ ld a, [wLevelCap] ++ push bc ++ ld b, a +``` +Then, after `ld a, [hl]`, add +``` ++ cp b ++ pop bc +``` +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 +``` +After `ld a, [wBattleMonLevel]`, add +``` ++ cp b ++ pop bc +``` +Fourth, ctrl + f for the next instance of MAX_LEVEL. Replace `ld d, MAX_LEVEL` with +``` ++ 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 +``` ++ ld a, [wLevelCap] ++ push bc ++ ld b, a +``` +Then, after `ld a, e`, add +``` ++ 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 +``` + inc de + dec c + jr nz, .stat_exp_loop +``` +Add this routine after it: +``` ++ pop bc ++ ld hl, MON_LEVEL ++ add hl, bc ++ ld a, [wLevelCap] ++ push bc ++ ld b, a ++ ld a, [hl] ++ cp b ++ pop bc ++ jp nc, .next_mon ++ push bc +``` +Next, go to +``` + ld c, PARTY_LENGTH + ld d, 0 +.count_loop +``` +Underneath this, add +``` ++ push bc ++ push de ++ ld a, [wLevelCap] ++ ld b, a ++ ld a, [wPartyCount] ++ cp c ++ jr c, .no_mon ++ ld a, c ++ dec a ++ ld hl, wPartyMon1Level ++ call GetPartyLocation ++ ld a, [hl] ++.no_mon ++ cp b ++ pop de ++ pop bc ++ jr nz, .gains_exp ++ srl b ++ ld a, d ++ jr .no_exp ++.gains_exp +``` +Last, under that is +``` + xor a + srl b + adc d + ld d, a +``` +After this, add `.no_exp` + +To set a level cap, write this in a script: +`loadmem wLevelCap, number from 0 to 255 representing what your level cap should be` \ No newline at end of file diff --git a/Adding-Level-Caps.md b/Adding-Level-Caps.md deleted file mode 100644 index a7ed7a2..0000000 --- a/Adding-Level-Caps.md +++ /dev/null @@ -1,127 +0,0 @@ -**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 -``` -+ ld a, [wLevelCap] -+ inc a -+ push bc -+ ld b, a -``` -After that, below `ld a, d` add -``` -+ cp b -+ pop bc -``` - -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 -``` -+ push af -+ ld a, [wLevelCap] -+ ld d, a -+ pop af -``` -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 -``` -+ ld a, [wLevelCap] -+ push bc -+ ld b, a -``` -Then, after `ld a, [hl]`, add -``` -+ cp b -+ pop bc -``` -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 -``` -After `ld a, [wBattleMonLevel]`, add -``` -+ cp b -+ pop bc -``` -Fourth, ctrl + f for the next instance of MAX_LEVEL. Replace `ld d, MAX_LEVEL` with -``` -+ 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 -``` -+ ld a, [wLevelCap] -+ push bc -+ ld b, a -``` -Then, after `ld a, e`, add -``` -+ 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 -``` - inc de - dec c - jr nz, .stat_exp_loop -``` -Add this routine after it: -``` -+ pop bc -+ ld hl, MON_LEVEL -+ add hl, bc -+ ld a, [wLevelCap] -+ push bc -+ ld b, a -+ ld a, [hl] -+ cp b -+ pop bc -+ jp nc, .next_mon -+ push bc -``` -Next, go to -``` - ld c, PARTY_LENGTH - ld d, 0 -.count_loop -``` -Underneath this, add -``` -+ push bc -+ push de -+ ld a, [wLevelCap] -+ ld b, a -+ ld a, [wPartyCount] -+ cp c -+ jr c, .no_mon -+ ld a, c -+ dec a -+ ld hl, wPartyMon1Level -+ call GetPartyLocation -+ ld a, [hl] -+.no_mon -+ cp b -+ pop de -+ pop bc -+ jr nz, .gains_exp -+ srl b -+ ld a, d -+ jr .no_exp -+.gains_exp -``` -Last, under that is -``` - xor a - srl b - adc d - ld d, a -``` -After this, add `.no_exp` - -To set a level cap, write this in a script: -`loadmem wLevelCap, number from 0 to 255 representing what your level cap should be` \ No newline at end of file -- cgit v1.2.3