summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKDLPro <38602758+KDLPro@users.noreply.github.com>2021-03-08 12:19:46 +0800
committerKDLPro <38602758+KDLPro@users.noreply.github.com>2021-03-08 12:19:46 +0800
commitf6f1102367a5b221b07d1a35311f89dca1e014c8 (patch)
tree2438e398cfc13d6e45f0ecd322169bc0c567da4c
parent748d9eac8fb49f65598c4e5ace5648e485c68bbe (diff)
Created Make wild Pokémon encounter levels vary (markdown)
-rw-r--r--Make-wild-Pokémon-encounter-levels-vary.md187
1 files changed, 187 insertions, 0 deletions
diff --git a/Make-wild-Pokémon-encounter-levels-vary.md b/Make-wild-Pokémon-encounter-levels-vary.md
new file mode 100644
index 0000000..ebf57be
--- /dev/null
+++ b/Make-wild-Pokémon-encounter-levels-vary.md
@@ -0,0 +1,187 @@
+Sometimes, you might want to create custom encounter tables. For example:
+
+![Custom Encounter Rates](https://user-images.githubusercontent.com/38602758/110269446-b6c95280-7ffe-11eb-9ac0-1de06894094e.png)
+
+If you add [wild Pokémon slots](Add-a-new-wild-Pokémon-slot) to accommodate all encounters in the morning, you need to use 19 slots because each level is placed in one slot. So for example, you need to use 3 slots for Abra: Lv. 13 Abra, Lv. 14 Abra, and Lv. 15 Abra. In this tutorial, we can use fewer slots while keeping the variety of wild Pokémon in an area.
+
+## Contents
+
+1. [Understanding Bug Catching Contest Encounter Code](#1-understanding-bug-catching-contest-encounter-code)
+2. [Add max levels in probabilities](#2-add-max-levels-in-probabilities)
+3. [Change wild encounter algorithm](#3-change-wild-encounter-algorithm)
+
+## 1. Understanding Bug Catching Contest Encounter Code
+
+First, we look at a snippet used in (events.asm)[https://github.com/pret/pokecrystal/blob/master/engine/overworld/events.asm] because we will use a portion of the code to replace a portion of wild encounter code.
+
+```
+ChooseWildEncounter_BugContest::
+; Pick a random mon out of ContestMons.
+
+.loop
+ call Random
+ cp 100 << 1
+ jr nc, .loop
+ srl a
+
+ ld hl, ContestMons
+ ld de, 4
+.CheckMon:
+ sub [hl]
+ jr c, .GotMon
+ add hl, de
+ jr .CheckMon
+
+.GotMon:
+ inc hl
+
+; Species
+ ld a, [hli]
+ ld [wTempWildMonSpecies], a
+
+; Min level
+ ld a, [hli]
+ ld d, a
+
+; Max level
+ ld a, [hl]
+
+ sub d
+ jr nz, .RandomLevel
+
+; If min and max are the same.
+ ld a, d
+ jr .GotLevel
+
+.RandomLevel:
+; Get a random level between the min and max.
+ ld c, a
+ inc c
+ call Random
+ ldh a, [hRandomAdd]
+ call SimpleDivide
+ add d
+
+.GotLevel:
+ ld [wCurPartyLevel], a
+
+ xor a
+ ret
+```
+
+This code is used to randomize wild encounters in the Bug Catching Contest. We then look at (bug_contest_mons.asm)[https://github.com/pret/pokecrystal/blob/master/data/wild/bug_contest_mons.asm].
+
+```
+ContestMons:
+ ; %, species, min, max
+ db 20, CATERPIE, 7, 18
+ db 20, WEEDLE, 7, 18
+ db 10, METAPOD, 9, 18
+ db 10, KAKUNA, 9, 18
+ db 5, BUTTERFREE, 12, 15
+ db 5, BEEDRILL, 12, 15
+ db 10, VENONAT, 10, 16
+ db 10, PARAS, 10, 17
+ db 5, SCYTHER, 13, 14
+ db 5, PINSIR, 13, 14
+ db -1, VENOMOTH, 30, 40
+```
+
+We can see that there's a minimum and maximum level for every wild Pokémon. The last slot, occupied by Venomoth, signals the end of the list. We can use a part of the algorithm of Bug Catching Contest encounters in (events.asm)[https://github.com/pret/pokecrystal/blob/master/engine/overworld/events.asm] to randomize regular wild encounters.
+
+## 2. Add max levels in probabilities
+
+Edit (data/wild/probabilities.asm)[https://github.com/pret/pokecrystal/blob/master/data/wild/probabilities.asm].
+
+```diff
+ mon_prob 100, 2 ; 10% chance
+
++MaxLevelGrass:
++ db 2
++ db 3
++ db 0
++ db 2
++ db 1
++ db 2
++ db 3
++
++MaxLevelWater:
++ db 2
++ db 3
++ db 4
+```
+
+The `MaxLevelGrass` and `MaxLevelWater` contain the level buffs to obtain the highest leveled encounter on that area. For example, if the first slot in the encounter table is Lv. 2, then the max level for the wild mon is Lv. 4.
+
+## 3. Change wild encounter algorithm
+
+Finally, we change the wild encounter algorithm in (engine/overworld/wildmons.asm)[https://github.com/pret/pokecrystal/blob/master/engine/overworld.wildmons.asm]:
+
+```diff
+
+ ld h, d
+ ld l, e
++ call CheckOnWater
++ ld de, MaxLevelWater
++ jr z, .prob_bracket_loop
++ ld de, MaxLevelGrass
+; This next loop chooses which mon to load up.
+.prob_bracket_loop
+ ld a, [hli]
+ cp b
+ jr nc, .got_it
+ inc hl
++ inc de
+ jr .prob_bracket_loop
+
+.got_it
+ ld c, [hl]
+ ld b, 0
+ pop hl
+ add hl, bc ; this selects our mon
++; Min Level
+ ld a, [hli]
+ ld b, a
+-; If the Pokemon is encountered by surfing, we need to give the levels some variety.
+- call CheckOnWater
+- jr nz, .ok
+-; Check if we buff the wild mon, and by how much.
+- call Random
+- cp 35 percent
+- jr c, .ok
+- inc b
+- cp 65 percent
+- jr c, .ok
+- inc b
+- cp 85 percent
+- jr c, .ok
+- inc b
+- cp 95 percent
+- jr c, .ok
+- inc b
++; Max Level
++ ld a, [de]
++; Min Level
++ ld d, b
++ ld b, a
++ ld a, b
++ cp 0
++ jr nz, .RandomLevel
++; If min and max are the same.
++ ld a, d
++ jr .ok
++
++.RandomLevel:
++; Get a random level between the min and max.
++ ld c, a
++ inc c
++ call Random
++ ldh a, [hRandomAdd]
++ call SimpleDivide
++ add d
++
+; Store the level
+.ok
+ ld a, b
+
+And there you have it! Wild encounters have been randomized. \ No newline at end of file