shithub: pokecrystal

Download patch

ref: 50ce0a219ef291099aa3aa43a177bcea2807d97b
parent: 7b3de85a06e81d14ac0c73e8f9e1ab8e4a474beb
author: Remy Oukaour <remy.oukaour@gmail.com>
date: Tue Jan 16 12:36:12 EST 2018

Fewer hard-coded values

--- a/engine/wildmons.asm
+++ b/engine/wildmons.asm
@@ -212,7 +212,7 @@
 GetMapEncounterRate: ; 2a111
 	ld hl, wMornEncounterRate
 	call CheckOnWater
-	ld a, 3
+	ld a, wWaterEncounterRate - wMornEncounterRate
 	jr z, .ok
 	ld a, [TimeOfDay]
 .ok
@@ -571,7 +571,7 @@
 	ld hl, wRoamMon1MapGroup
 	ld c, a
 	ld b, 0
-	ld a, 7 ; length of the RoamMon struct
+	ld a, 7 ; length of the roam_struct
 	call AddNTimes
 	ld a, d
 	cp [hl]
@@ -821,7 +821,7 @@
 	ld bc, 5 + 4 * 2 ; Location of the level of the 5th wild Pokemon in that map
 	add hl, bc
 	ld a, [TimeOfDay]
-	ld bc, 7 * 2
+	ld bc, NUM_GRASSMON * 2
 	call AddNTimes
 .randloop1
 	call Random
@@ -893,7 +893,7 @@
 	add hl, bc
 	ld a, [TimeOfDay]
 	inc a
-	ld bc, 7 * 2
+	ld bc, NUM_GRASSMON * 2
 .loop
 	dec a
 	jr z, .done
@@ -952,16 +952,17 @@
 	ld a, BANK(Trainers)
 	call GetFarByte
 	inc hl
-	ld bc, 2
-	cp 0
+	ld bc, 2 ; level, species
+	cp TRAINERTYPE_NORMAL
 	jr z, .got_mon_length
-	ld bc, 2 + NUM_MOVES
-	cp 1
+	ld bc, 2 + NUM_MOVES ; level, species, moves
+	cp TRAINERTYPE_MOVES
 	jr z, .got_mon_length
-	ld bc, 2 + 1
-	cp 2
+	ld bc, 2 + 1 ; level, species, item
+	cp TRAINERTYPE_ITEM
 	jr z, .got_mon_length
-	ld bc, 2 + 1 + NUM_MOVES
+	; TRAINERTYPE_ITEM_MOVES
+	ld bc, 2 + 1 + NUM_MOVES ; level, species, item, moves
 .got_mon_length
 
 	ld e, 0
@@ -977,7 +978,7 @@
 
 .rand
 	call Random
-	and 7
+	maskbits PARTY_LENGTH
 	cp e
 	jr nc, .rand