diff options
author | Idain <luiscarlosholguinperez@outlook.com> | 2022-01-28 15:32:07 -0400 |
---|---|---|
committer | Idain <luiscarlosholguinperez@outlook.com> | 2022-01-28 15:32:07 -0400 |
commit | 227d0a4d705e9d9c8af8ed08d9de6a786b677cfe (patch) | |
tree | ebc08acb299cf691ad396be335b87be7ed267765 | |
parent | 5820a32434d99f9f0ec84850f0a4c24e98cd5639 (diff) |
Fix broken Content's hyperlinks and change format for Content table and code
-rw-r--r-- | Make-wild-Pokémon-encounter-levels-vary.md | 111 |
1 files changed, 53 insertions, 58 deletions
diff --git a/Make-wild-Pokémon-encounter-levels-vary.md b/Make-wild-Pokémon-encounter-levels-vary.md index ad4ab74..e370322 100644 --- a/Make-wild-Pokémon-encounter-levels-vary.md +++ b/Make-wild-Pokémon-encounter-levels-vary.md @@ -17,26 +17,26 @@ You decide what works best for you and your vision for your fangame! ## Contents -1. [Method #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) -4. [Other notes for Method 1](#4-Other-notes-for-Method-1) -5. [Method #2: Custom probabilities and level ranges for each encounter table](#5-method-2-custom-probabilities-and-level-ranges-for-each-encounter-table) -6. [Adjust data related to wildata constants](#6-adjust-data-related-to-wildata-constants) -7. [Edit the encounter tables](t#7-edit-the-encounter-tables) -8. [Fix space issues](#8-fix-space-issues) -9. [Method #3: Hijack the surf variance code](#5-Method-2-hijack-the-surf-variance-code) +1. [Method #1: Understanding Bug Catching Contest Encounter Code](#1-method-1-understanding-bug-catching-contest-encounter-code) + - [Add max levels in probabilities](#add-max-levels-in-probabilities) + - [Change wild encounter algorithm](#change-wild-encounter-algorithm) + - [Other notes for Method 1](#other-notes-for-method-1) +2. [Method #2: Custom probabilities and level ranges for each encounter table](#2-method-2-custom-probabilities-and-level-ranges-for-each-encounter-table) + - [Adjust data related to wildata constants](#adjust-data-related-to-wildata-constants) + - [Edit the encounter tables](#edit-the-encounter-tables) + - [Fix space issues](#fix-space-issues) +3. [Method #3: Hijack the surf variance code](#3-method-3-hijack-the-surf-variance-code) -## 1. Understanding Bug Catching Contest Encounter Code +## 1. Method #1: Understanding Bug Catching Contest Encounter Code First, we look at a snippet used in [engine/overworld/events.asm](../blob/master/engine/overworld/events.asm) because we'll use a portion of the code to replace a portion of wild encounter code. ```asm -ChooseWildEncounter_BugContest:: -; Pick a random mon out of ContestMons. + ChooseWildEncounter_BugContest:: + ; Pick a random mon out of ContestMons. -.loop + .loop call Random cp 100 << 1 jr nc, .loop @@ -44,35 +44,35 @@ ChooseWildEncounter_BugContest:: ld hl, ContestMons ld de, 4 -.CheckMon: + .CheckMon: sub [hl] jr c, .GotMon add hl, de jr .CheckMon -.GotMon: + .GotMon: inc hl -; Species + ; Species ld a, [hli] ld [wTempWildMonSpecies], a -; Min level + ; Min level ld a, [hli] ld d, a -; Max level + ; Max level ld a, [hl] sub d jr nz, .RandomLevel -; If min and max are the same. + ; If min and max are the same. ld a, d jr .GotLevel -.RandomLevel: -; Get a random level between the min and max. + .RandomLevel: + ; Get a random level between the min and max. ld c, a inc c call Random @@ -80,7 +80,7 @@ ChooseWildEncounter_BugContest:: call SimpleDivide add d -.GotLevel: + .GotLevel: ld [wCurPartyLevel], a xor a @@ -90,7 +90,7 @@ ChooseWildEncounter_BugContest:: This code is used to randomize wild encounters in the Bug Catching Contest. We then look at [data/wild/bug_contest_mons.asm](../blob/master/data/wild/bug_contest_mons.asm). ```asm -ContestMons: + ContestMons: ; %, species, min, max db 20, CATERPIE, 7, 18 db 20, WEEDLE, 7, 18 @@ -108,7 +108,7 @@ ContestMons: 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 [engine/overworld/events.asm](../blob/master/engine/overworld/events.asm) to randomize regular wild encounters. -## 2. Add max levels in probabilities +### Add max levels in probabilities Edit [data/wild/probabilities.asm](https://github.com/pret/pokecrystal/blob/master/data/wild/probabilities.asm). @@ -135,7 +135,7 @@ Edit [data/wild/probabilities.asm](https://github.com/pret/pokecrystal/blob/mast Both `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 Pokémon will be Lv. 4. -## 3. Change wild encounter algorithm +### Change wild encounter algorithm Finally, we change the wild encounter algorithm in [engine/overworld/wildmons.asm](../blob/master/engine/overworld/wildmons.asm): @@ -147,8 +147,8 @@ Finally, we change the wild encounter algorithm in [engine/overworld/wildmons.as + ld de, MaxLevelWater + jr z, .prob_bracket_loop + ld de, MaxLevelGrass -; This next loop chooses which mon to load up. -.prob_bracket_loop + ; This next loop chooses which mon to load up. + .prob_bracket_loop ld a, [hli] cp b jr nc, .got_it @@ -156,7 +156,7 @@ Finally, we change the wild encounter algorithm in [engine/overworld/wildmons.as + inc de jr .prob_bracket_loop -.got_it + .got_it ld c, [hl] ld b, 0 pop hl @@ -203,14 +203,14 @@ Finally, we change the wild encounter algorithm in [engine/overworld/wildmons.as + ld b, a + ; Store the level -.ok + .ok ld a, b ``` And there you have it! Wild encounters have been randomized. -## 4. Other notes for Method 1 +### Other notes for method #1 Take note that the slots in `MaxLevelGrass` and `MaxLevelWater` in [data/wild/probabilities.asm](../blob/master/data/wild/probabilities.asm) correspond to the probability slots in the same file. Also, each slot is tied to the wild Pokémon slots in each map where there are wild encounters. Thus if you use the tutorial to [add a wild Pokémon slot](Add-a-new-wild-Pokémon-slot), you also need to add new slots in `MaxLevelGrass` and/or `MaxLevelWater`. @@ -221,7 +221,7 @@ Sometimes, you might want to create custom encounter tables. For example: If you add [wild Pokémon slots](Add-a-new-wild-Pokémon-slot) to accommodate all encounters in the morning, you'd have to use 19 slots because each level is placed in one slot. So for example, you need to use 3 slots for Abra, one for each level: Lv. 13, Lv. 14, and Lv. 15. After following this tutorial, you no longer need so many of the same Pokémon occupying multiple slots in the table, so extra slots can now mean more unique species in an area! -## 5. Method #2: custom probabilities and level ranges for each encounter table +## 2. Method #2: custom probabilities and level ranges for each encounter table Method #1 has some inconveniences, though: each slot still has a fixed probability and the same level variation. For example, the first slot of each encounter table will always have a 30% probability and will vary at most by 2 levels from the minumum. What if we wanted to have custom probabilities and individual level ranges for each slot for each encounter table? It's totally possible! @@ -369,7 +369,7 @@ Let's give a quick explanation. The code works similarly to `ChooseWildEncounter You might have noticed that we did `ld bc, NUM_GRASSMON * 4` at some point and it's because each slot will now contain four bytes (% chance, species, min. level and max. level) instead of two (level, species). We need to make similar changes in other places, too. -## 6. Adjust data related to Wildata constants +### Adjust data related to Wildata constants Let's edit data related to `NUM_GRASSMON` and `NUM_WATERMON`. In the same file: @@ -457,12 +457,12 @@ Finally, edit [constants/pokemon_data_constants.asm](../blob/master/constants/po About this last edit, since the encounter tables now have more bytes the data length of each one is bigger, so we needed to adjust the related constants. -## 7. Edit the encounter tables +### Edit the encounter tables This is the most tedious part. You'll now have to edit _each encounter table_ to match the new format. For example, this is how it'd look like for Sprout Tower 2F: ```diff -JohtoGrassWildMons: + JohtoGrassWildMons: def_grass_wildmons SPROUT_TOWER_2F db 2 percent, 2 percent, 2 percent ; encounter rates: morn/day/nite @@ -522,9 +522,11 @@ JohtoGrassWildMons: + db 1, RATTATA, 3, 5 ``` +**Note:** You can change the percentages freely, as long as they add 100. + You have five places to edit: [data/wild/johto_grass.asm](../blob/master/data/wild/johto_grass.asm), [data/wild/kanto_grass.asm](./blob/master/data/wild/kanto_grass.asm), [data/wild/johto_water.asm](../blob/master/data/wild/johto_water.asm), [data/wild/kanto_water.asm](../blob/master/data/wild/kanto_water.asm) and [data/wild/swarm_grass.asm](../blob/master/data/wild/swarm_grass.asm). _Have fun._ -## 8. Fix space issues +### Fix space issues Congrats! You edited each encounter table and it probably took you some hours, but you have a new problem: one of your banks is now full and you can't assemble your ROM. An easy way to fix this is to put [engine/overworld/wildmons.asm](../blob/master/engine/overworld/wildmons.asm) in a new section. Go to [main.asm](../blob/master/main.asm): @@ -546,17 +548,17 @@ Congrats! You edited each encounter table and it probably took you some hours, b Now RGBDS (our development tool) will take care of it and put the new section where there's free space. -## 9. Method #3: Hijack the surf variance code +## 3. Method #3: Hijack the surf variance code Method #1 made use of the surf variance code in a more complex way, allowing for more finer control over the tables, and method #2 went even further, making the code similar to how the Bug Contest handles wild encounters. The following method is a lot simpler to implement, and has a similar effect to method #1, but lacks that deeper control of the encounter levels. Head on over to `ChooseWildEncounter` in [engine/overworld/wildmons.asm](https://github.com/pret/pokecrystal/blob/master/engine/overworld.wildmons.asm): ``` -; If the Pokemon is encountered by surfing, we need to give the levels some variety. + ; 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. + ; Check if we buff the wild mon, and by how much. call Random cp 35 percent jr c, .ok @@ -570,24 +572,20 @@ Head on over to `ChooseWildEncounter` in [engine/overworld/wildmons.asm](https:/ cp 95 percent jr c, .ok inc b -; Store the level -.ok ``` Let's break it down. -As you can see, there IS level variance code right in the original game! It calls `CheckOnWater` to see if player is currently surfing and if so, falls through to call `Random`. -`Random` will randomly choose one of these percentages, and then add that percentage to `b`, adding the rolled variance level to the level of the currently encountered surfing Pokémon inside `b`. +As you can see, there _is_ level variance code right in the original game! It calls `CheckOnWater` to see if player is currently surfing and if so, falls through to call `Random`, which will randomly choose one of these percentages, and then add that percentage to `b`, adding the rolled variance level to the level of the currently encountered surfing Pokémon inside `b`. -The slots for surfing Pokémon are the minimum level for that slot, as is the logic for any encounter table slot. Through the use of `Random`, however, surfing Pokémon have a chance to be -encountered at levels higher than their set level in the encounter slot. +The slots for surfing Pokémon are the minimum level for that slot, as is the logic for any encounter table slot. Through the use of `Random`, however, surfing Pokémon have a chance to be encountered at levels higher than their set level in the encounter slot. See below: -* +0: 35% chance -* +1: 30% -* +2: 20% -* +3: 10% -* +4: 5% + * +0: 35% chance + * +1: 30% + * +2: 20% + * +3: 10% + * +4: 5% These probabilities are approximate, as an 8-bit register is limited in the range of values it can take! @@ -613,8 +611,6 @@ What happens if we just... remove that `CheckOnWater`? cp 95 percent jr c, .ok inc b -; Store the level -.ok ``` Wow! Now any encountered wild Pokémon can vary up to 0-4 levels, in grass, in caves, in water... anywhere! @@ -630,7 +626,7 @@ Just load `wBattleType` into `a`, and check for the specific special encounter t + ld a, [wBattleType] + cp BATTLETYPE_SUICUNE + jr z, .ok -; Check if we buff the wild mon, and by how much. + ; Check if we buff the wild mon, and by how much. call Random cp 35 percent jr c, .ok @@ -644,18 +640,17 @@ Just load `wBattleType` into `a`, and check for the specific special encounter t cp 95 percent jr c, .ok inc b -; Store the level -.ok ``` Now when the player encounters a wildmon, it will now check the `wBattleType` and see if it is `BATTLETYPE_SUICUNE`. If it is `BATTLETYPE_SUICUNE`, then it will skip the random level variance and jump down to `.ok`. You can add multiple checks for different encounter types, or even specify special encounter types that DO make use of the level variance. Armed with this new level variance technology, entering an unedited Route 29 during the day and rummaging through the grass, you could now encounter: -* Rattata: Levels 2-6 -* Sentret: Levels 2-7 -* Pidgey: Levels 2-7 -* Hoppip: Levels 3-7 + + * Rattata: Levels 2-6 + * Sentret: Levels 2-7 + * Pidgey: Levels 2-7 + * Hoppip: Levels 3-7 Whichever way you decide to implement level variance, it makes for a much more diverse experience exploring the overworld.
\ No newline at end of file |