Add a new wild Pokémon slot - pret/pokecrystal GitHub Wiki

This tutorial is for how to add more variety for wild Pokémon. As an example, we'll add an eighth slot for wild Pokémon in tall grass, and a fourth for wild Pokémon in water.

Contents

  1. Increase the relevant constants
  2. Add more probability slots
  3. Add more wild data

1. Increase the relevant constants

Edit constants/pokemon_data_constants.asm:

-DEF NUM_GRASSMON EQU 7 ; data/wild/*_grass.asm table size
-DEF NUM_WATERMON EQU 3 ; data/wild/*_water.asm table size
+DEF NUM_GRASSMON EQU 8 ; data/wild/*_grass.asm table size
+DEF NUM_WATERMON EQU 4 ; data/wild/*_water.asm table size

If you've seen the data/wild/*.asm files before, it should be obvious that NUM_GRASSMON is the number of slots for Pokémon in tall grass at a particular time of day, and NUM_WATERMON is for Pokémon in water at any time.

2. Add more probability slots

Edit data/wild/probabilities.asm:

 GrassMonProbTable:
 	table_width 2, GrassMonProbTable
 	mon_prob 30,  0 ; 30% chance
 	mon_prob 60,  1 ; 30% chance
 	mon_prob 80,  2 ; 20% chance
 	mon_prob 90,  3 ; 10% chance
-	mon_prob 95,  4 ;  5% chance
-	mon_prob 99,  5 ;  4% chance
-	mon_prob 100, 6 ;  1% chance
+	mon_prob 94,  4 ;  4% chance
+	mon_prob 97,  5 ;  3% chance
+	mon_prob 99,  6 ;  2% chance
+	mon_prob 100, 7 ;  1% chance
 	assert_table_length NUM_GRASSMON
 
 WaterMonProbTable:
 	table_width 2, WaterMonProbTable
 	mon_prob 60,  0 ; 60% chance
-	mon_prob 90,  1 ; 30% chance
-	mon_prob 100, 2 ; 10% chance
+	mon_prob 80,  1 ; 20% chance
+	mon_prob 95,  2 ; 15% chance
+	mon_prob 100, 3 ;  5% chance
 	assert_table_length NUM_WATERMON

These are just the cumulative probabilities for each possible slot.

3. Add more wild data

This will be tedious. If you edit NUM_GRASSMON, you need to update the wild data for every map in data/wild/johto_grass.asm and data/wild/kanto_grass.asm; the same goes for NUM_WATERMON with data/wild/johto_water.asm and data/wild/kanto_water.asm. Make sure that all the quantities are correct.

For example, we increased NUM_GRASSMON from 7 to 8, so here's how Route 29's wild data could change in data/wild/johto_grass.asm:

 	def_grass_wildmons ROUTE_29
 	db 10 percent, 10 percent, 10 percent ; encounter rates: morn/day/nite
 	; morn
 	db 2, PIDGEY
 	db 2, SENTRET
 	db 3, PIDGEY
 	db 3, SENTRET
 	db 2, RATTATA
 	db 3, HOPPIP
 	db 3, HOPPIP
+	db 3, MARILL
 	; day
 	db 2, PIDGEY
 	db 2, SENTRET
 	db 3, PIDGEY
 	db 3, SENTRET
 	db 2, RATTATA
 	db 3, HOPPIP
 	db 3, HOPPIP
+	db 3, MARILL
 	; nite
 	db 2, HOOTHOOT
 	db 2, RATTATA
 	db 3, HOOTHOOT
 	db 3, RATTATA
 	db 2, RATTATA
 	db 3, HOOTHOOT
 	db 3, HOOTHOOT
+	db 3, POLIWAG
 	end_grass_wildmons

And we increased NUM_WATERMON from 3 to 4, so here's how Cherrygrove City's wild data could change in data/wild/johto_water.asm:

 	def_water_wildmons CHERRYGROVE_CITY
 	db 6 percent ; encounter rate
 	db 20, TENTACOOL
 	db 15, TENTACOOL
+	db 20, CORSOLA
 	db 20, TENTACRUEL
 	end_water_wildmons

Don't miss any tables, or you could encounter glitch Pokémon, prevent encounters completely, or cause other weird bugs.

Anyway, that's it! As long as NUM_GRASSMON and NUM_WATERMON match the lengths of GrassMonProbTable, WaterMonProbTable, and the many individual maps' wild data tables, then you can have as many slots as you want.

Screenshot

(If your copy of pokecrystal is from before June 24, 2018, you'll also need to make these changes to engine/overworld/wildmons.asm, replacing some hard-coded numbers with constant expressions.)

If you want to make more specific changes to the logic of how wild Pokémon are encountered, then study the code in engine/overworld/wildmons.asm and look for where its algorithms would need editing.