1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
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`
|