diff options
author | petuuuhhh <32315520+petuuuhhh@users.noreply.github.com> | 2019-07-07 14:04:10 -0400 |
---|---|---|
committer | petuuuhhh <32315520+petuuuhhh@users.noreply.github.com> | 2019-07-07 14:04:10 -0400 |
commit | 659d7e9c7b847c8811fa1fd8ab0fba3929ec8ede (patch) | |
tree | 07b4ed3534b1159e26a6024b62b0724676e9d0b1 | |
parent | 4f1251b7de6332bb3277ef700bb2001896ef2644 (diff) |
Added tutorial for adding level caps
-rw-r--r-- | Adding-Level-Caps.md | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/Adding-Level-Caps.md b/Adding-Level-Caps.md new file mode 100644 index 0000000..dccffb9 --- /dev/null +++ b/Adding-Level-Caps.md @@ -0,0 +1,125 @@ +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 |