shithub: pokecrystal

Download patch

ref: c8575823a0e3694cba7c63e7ef468c55bb301804
parent: 28d5169a119ece438cc39b442adaa018b9a376e3
author: Remy Oukaour <remy.oukaour@gmail.com>
date: Wed Jan 10 12:30:27 EST 2018

Battle data goes in data/battle/
TreeMons, like fish groups, have constants

--- a/constants/battle_constants.asm
+++ b/constants/battle_constants.asm
@@ -20,8 +20,14 @@
 ; default move priority
 BASE_PRIORITY EQU 1
 
-; PlayerStatLevels and EnemyStatLevels indexes
-; used for GetStatName
+; type effectiveness factors, scaled by 10
+SUPER_EFFECTIVE    EQU 20
+EFFECTIVE          EQU 10
+NOT_VERY_EFFECTIVE EQU 05
+NO_EFFECT          EQU 00
+
+; PlayerStatLevels and EnemyStatLevels indexes (see wram.asm)
+; GetStatName arguments (see data/battle/stat_names.asm)
 	const_def
 	const ATTACK
 	const DEFENSE
--- a/constants/item_constants.asm
+++ b/constants/item_constants.asm
@@ -290,9 +290,9 @@
 	add_mt ICE_BEAM
 NUM_TM_HM_TUTOR = __enum__ +- 1
 
-ITEM_FROM_MEM EQU $FF
+ITEM_FROM_MEM EQU $ff
 
 ; leftovers from red
 SAFARI_BALL    EQU $08 ; MOON_STONE
-MOON_STONE_RED EQU $0A ; BURN_HEAL
+MOON_STONE_RED EQU $0a ; BURN_HEAL
 FULL_HEAL_RED  EQU $34 ; X_SPEED
--- a/constants/map_data_constants.asm
+++ b/constants/map_data_constants.asm
@@ -253,6 +253,26 @@
 NUM_FRUIT_TREES EQU const_value +- 1
 
 
+; treemon sets
+; TreeMons indexes (see data/wild/treemons.asm)
+	const_def
+	const TREEMON_SET_CITY
+	const TREEMON_SET_CANYON
+	const TREEMON_SET_AZALEA
+	const TREEMON_SET_ROUTE
+	const TREEMON_SET_KANTO
+	const TREEMON_SET_LAKE
+	const TREEMON_SET_FOREST
+	const TREEMON_SET_ROCK
+NUM_TREEMON_SETS EQU const_value
+
+; treemon scores
+	const_def
+	const TREEMON_SCORE_BAD  ; 0
+	const TREEMON_SCORE_GOOD ; 1
+	const TREEMON_SCORE_RARE ; 2
+
+
 ; elevator floors
 ; used by `elevfloor`
 	const_def
--- /dev/null
+++ b/data/battle/accuracy_multipliers.asm
@@ -1,0 +1,17 @@
+; Multiplier ratios for accuracy from modifier -6 to +6
+; (for other stats, see data/battle/stat_multipliers.asm)
+
+AccuracyLevelMultipliers:
+	db  33, 100 ; -6 =  33%
+	db  36, 100 ; -5 =  36%
+	db  43, 100 ; -4 =  43%
+	db  50, 100 ; -3 =  50%
+	db  60, 100 ; -2 =  60%
+	db  75, 100 ; -1 =  75%
+	db   1,   1 ;  0 = 100%
+	db 133, 100 ; +1 = 133%
+	db 166, 100 ; +2 = 166%
+	db   2,   1 ; +3 = 200%
+	db 233, 100 ; +4 = 233%
+	db 133,  50 ; +5 = 266%
+	db   3,   1 ; +6 = 300%
--- /dev/null
+++ b/data/battle/critical_hits.asm
@@ -1,0 +1,18 @@
+CriticalHitMoves:
+	db KARATE_CHOP
+	db RAZOR_WIND
+	db RAZOR_LEAF
+	db CRABHAMMER
+	db SLASH
+	db AEROBLAST
+	db CROSS_CHOP
+	db -1
+
+CriticalHitChances:
+	db  7 percent     ; 0
+	db 12 percent + 2 ; 1
+	db 25 percent + 1 ; 2
+	db 33 percent + 1 ; 3
+	db 50 percent + 1 ; 4
+	db 50 percent + 1 ; 5
+	db 50 percent + 1 ; 6
--- /dev/null
+++ b/data/battle/stat_multipliers.asm
@@ -1,0 +1,17 @@
+; Multiplier ratios for all stats from modifier -6 to +6
+; (except accuracy, see data/battle/accuracy_multipliers.asm)
+
+StatLevelMultipliers:
+	db  25, 100 ; -6 =  25%
+	db  28, 100 ; -5 =  28%
+	db  33, 100 ; -4 =  33%
+	db  40, 100 ; -3 =  40%
+	db  50, 100 ; -2 =  50%
+	db  66, 100 ; -1 =  66%
+	db   1,   1 ;  0 = 100%
+	db  15,  10 ; +1 = 150%
+	db   2,   1 ; +2 = 200%
+	db  25,  10 ; +3 = 250%
+	db   3,   1 ; +4 = 300%
+	db  35,  10 ; +5 = 350%
+	db   4,   1 ; +6 = 400%
--- /dev/null
+++ b/data/battle/stat_names.asm
@@ -1,0 +1,10 @@
+StatNames:
+; entries correspond to stat ids
+	db "ATTACK@"
+	db "DEFENSE@"
+	db "SPEED@"
+	db "SPCL.ATK@"
+	db "SPCL.DEF@"
+	db "ACCURACY@"
+	db "EVASION@"
+	db "ABILITY@"
--- /dev/null
+++ b/data/battle/type_boost_items.asm
@@ -1,0 +1,20 @@
+TypeBoostItems: ; 35703
+	db HELD_NORMAL_BOOST,   NORMAL   ; PINK_BOW/POLKADOT_BOW
+	db HELD_FIGHTING_BOOST, FIGHTING ; BLACKBELT
+	db HELD_FLYING_BOOST,   FLYING   ; SHARP_BEAK
+	db HELD_POISON_BOOST,   POISON   ; POISON BARB
+	db HELD_GROUND_BOOST,   GROUND   ; SOFT_SAND
+	db HELD_ROCK_BOOST,     ROCK     ; HARD_STONE
+	db HELD_BUG_BOOST,      BUG      ; SILVERPOWDER
+	db HELD_GHOST_BOOST,    GHOST    ; SPELL_TAG
+	db HELD_FIRE_BOOST,     FIRE     ; CHARCOAL
+	db HELD_WATER_BOOST,    WATER    ; MYSTIC WATER
+	db HELD_GRASS_BOOST,    GRASS    ; MIRACLE_SEED
+	db HELD_ELECTRIC_BOOST, ELECTRIC ; MAGNET
+	db HELD_PSYCHIC_BOOST,  PSYCHIC  ; TWISTEDSPOON
+	db HELD_ICE_BOOST,      ICE      ; NEVERMELTICE
+	db HELD_DRAGON_BOOST,   DRAGON   ; DRAGON_SCALE
+	db HELD_DARK_BOOST,     DARK     ; BLACKGLASSES
+	db HELD_STEEL_BOOST,    STEEL    ; METAL_COAT
+	db -1
+; 35726
--- /dev/null
+++ b/data/battle/type_matchups.asm
@@ -1,0 +1,119 @@
+TypeMatchups: ; 34bb1
+	;  attacker,  defender,  *=
+	db NORMAL,    ROCK,      NOT_VERY_EFFECTIVE
+	db NORMAL,    STEEL,     NOT_VERY_EFFECTIVE
+	db FIRE,      FIRE,      NOT_VERY_EFFECTIVE
+	db FIRE,      WATER,     NOT_VERY_EFFECTIVE
+	db FIRE,      GRASS,     SUPER_EFFECTIVE
+	db FIRE,      ICE,       SUPER_EFFECTIVE
+	db FIRE,      BUG,       SUPER_EFFECTIVE
+	db FIRE,      ROCK,      NOT_VERY_EFFECTIVE
+	db FIRE,      DRAGON,    NOT_VERY_EFFECTIVE
+	db FIRE,      STEEL,     SUPER_EFFECTIVE
+	db WATER,     FIRE,      SUPER_EFFECTIVE
+	db WATER,     WATER,     NOT_VERY_EFFECTIVE
+	db WATER,     GRASS,     NOT_VERY_EFFECTIVE
+	db WATER,     GROUND,    SUPER_EFFECTIVE
+	db WATER,     ROCK,      SUPER_EFFECTIVE
+	db WATER,     DRAGON,    NOT_VERY_EFFECTIVE
+	db ELECTRIC,  WATER,     SUPER_EFFECTIVE
+	db ELECTRIC,  ELECTRIC,  NOT_VERY_EFFECTIVE
+	db ELECTRIC,  GRASS,     NOT_VERY_EFFECTIVE
+	db ELECTRIC,  GROUND,    NO_EFFECT
+	db ELECTRIC,  FLYING,    SUPER_EFFECTIVE
+	db ELECTRIC,  DRAGON,    NOT_VERY_EFFECTIVE
+	db GRASS,     FIRE,      NOT_VERY_EFFECTIVE
+	db GRASS,     WATER,     SUPER_EFFECTIVE
+	db GRASS,     GRASS,     NOT_VERY_EFFECTIVE
+	db GRASS,     POISON,    NOT_VERY_EFFECTIVE
+	db GRASS,     GROUND,    SUPER_EFFECTIVE
+	db GRASS,     FLYING,    NOT_VERY_EFFECTIVE
+	db GRASS,     BUG,       NOT_VERY_EFFECTIVE
+	db GRASS,     ROCK,      SUPER_EFFECTIVE
+	db GRASS,     DRAGON,    NOT_VERY_EFFECTIVE
+	db GRASS,     STEEL,     NOT_VERY_EFFECTIVE
+	db ICE,       WATER,     NOT_VERY_EFFECTIVE
+	db ICE,       GRASS,     SUPER_EFFECTIVE
+	db ICE,       ICE,       NOT_VERY_EFFECTIVE
+	db ICE,       GROUND,    SUPER_EFFECTIVE
+	db ICE,       FLYING,    SUPER_EFFECTIVE
+	db ICE,       DRAGON,    SUPER_EFFECTIVE
+	db ICE,       STEEL,     NOT_VERY_EFFECTIVE
+	db ICE,       FIRE,      NOT_VERY_EFFECTIVE
+	db FIGHTING,  NORMAL,    SUPER_EFFECTIVE
+	db FIGHTING,  ICE,       SUPER_EFFECTIVE
+	db FIGHTING,  POISON,    NOT_VERY_EFFECTIVE
+	db FIGHTING,  FLYING,    NOT_VERY_EFFECTIVE
+	db FIGHTING,  PSYCHIC,   NOT_VERY_EFFECTIVE
+	db FIGHTING,  BUG,       NOT_VERY_EFFECTIVE
+	db FIGHTING,  ROCK,      SUPER_EFFECTIVE
+	db FIGHTING,  DARK,      SUPER_EFFECTIVE
+	db FIGHTING,  STEEL,     SUPER_EFFECTIVE
+	db POISON,    GRASS,     SUPER_EFFECTIVE
+	db POISON,    POISON,    NOT_VERY_EFFECTIVE
+	db POISON,    GROUND,    NOT_VERY_EFFECTIVE
+	db POISON,    ROCK,      NOT_VERY_EFFECTIVE
+	db POISON,    GHOST,     NOT_VERY_EFFECTIVE
+	db POISON,    STEEL,     NO_EFFECT
+	db GROUND,    FIRE,      SUPER_EFFECTIVE
+	db GROUND,    ELECTRIC,  SUPER_EFFECTIVE
+	db GROUND,    GRASS,     NOT_VERY_EFFECTIVE
+	db GROUND,    POISON,    SUPER_EFFECTIVE
+	db GROUND,    FLYING,    NO_EFFECT
+	db GROUND,    BUG,       NOT_VERY_EFFECTIVE
+	db GROUND,    ROCK,      SUPER_EFFECTIVE
+	db GROUND,    STEEL,     SUPER_EFFECTIVE
+	db FLYING,    ELECTRIC,  NOT_VERY_EFFECTIVE
+	db FLYING,    GRASS,     SUPER_EFFECTIVE
+	db FLYING,    FIGHTING,  SUPER_EFFECTIVE
+	db FLYING,    BUG,       SUPER_EFFECTIVE
+	db FLYING,    ROCK,      NOT_VERY_EFFECTIVE
+	db FLYING,    STEEL,     NOT_VERY_EFFECTIVE
+	db PSYCHIC,   FIGHTING,  SUPER_EFFECTIVE
+	db PSYCHIC,   POISON,    SUPER_EFFECTIVE
+	db PSYCHIC,   PSYCHIC,   NOT_VERY_EFFECTIVE
+	db PSYCHIC,   DARK,      NO_EFFECT
+	db PSYCHIC,   STEEL,     NOT_VERY_EFFECTIVE
+	db BUG,       FIRE,      NOT_VERY_EFFECTIVE
+	db BUG,       GRASS,     SUPER_EFFECTIVE
+	db BUG,       FIGHTING,  NOT_VERY_EFFECTIVE
+	db BUG,       POISON,    NOT_VERY_EFFECTIVE
+	db BUG,       FLYING,    NOT_VERY_EFFECTIVE
+	db BUG,       PSYCHIC,   SUPER_EFFECTIVE
+	db BUG,       GHOST,     NOT_VERY_EFFECTIVE
+	db BUG,       DARK,      SUPER_EFFECTIVE
+	db BUG,       STEEL,     NOT_VERY_EFFECTIVE
+	db ROCK,      FIRE,      SUPER_EFFECTIVE
+	db ROCK,      ICE,       SUPER_EFFECTIVE
+	db ROCK,      FIGHTING,  NOT_VERY_EFFECTIVE
+	db ROCK,      GROUND,    NOT_VERY_EFFECTIVE
+	db ROCK,      FLYING,    SUPER_EFFECTIVE
+	db ROCK,      BUG,       SUPER_EFFECTIVE
+	db ROCK,      STEEL,     NOT_VERY_EFFECTIVE
+	db GHOST,     NORMAL,    NO_EFFECT
+	db GHOST,     PSYCHIC,   SUPER_EFFECTIVE
+	db GHOST,     DARK,      NOT_VERY_EFFECTIVE
+	db GHOST,     STEEL,     NOT_VERY_EFFECTIVE
+	db GHOST,     GHOST,     SUPER_EFFECTIVE
+	db DRAGON,    DRAGON,    SUPER_EFFECTIVE
+	db DRAGON,    STEEL,     NOT_VERY_EFFECTIVE
+	db DARK,      FIGHTING,  NOT_VERY_EFFECTIVE
+	db DARK,      PSYCHIC,   SUPER_EFFECTIVE
+	db DARK,      GHOST,     SUPER_EFFECTIVE
+	db DARK,      DARK,      NOT_VERY_EFFECTIVE
+	db DARK,      STEEL,     NOT_VERY_EFFECTIVE
+	db STEEL,     FIRE,      NOT_VERY_EFFECTIVE
+	db STEEL,     WATER,     NOT_VERY_EFFECTIVE
+	db STEEL,     ELECTRIC,  NOT_VERY_EFFECTIVE
+	db STEEL,     ICE,       SUPER_EFFECTIVE
+	db STEEL,     ROCK,      SUPER_EFFECTIVE
+	db STEEL,     STEEL,     NOT_VERY_EFFECTIVE
+
+	db -2 ; end
+
+; Foresight removes Ghost's immunities.
+	db NORMAL,    GHOST,     NO_EFFECT
+	db FIGHTING,  GHOST,     NO_EFFECT
+
+	db -1 ; end (with Foresight)
+; 34cfd
--- a/data/type_matchups.asm
+++ /dev/null
@@ -1,125 +1,0 @@
-; The multiplier is divided by 10, so we can use values like 0.5.
-; All other cases are neutral (1x).
-SUPER_EFFECTIVE    EQU 20
-NOT_VERY_EFFECTIVE EQU 05
-NO_EFFECT          EQU 00
-
-TypeMatchups: ; 34bb1
-	;  attacker,  defender,  *=
-	db NORMAL,    ROCK,      NOT_VERY_EFFECTIVE
-	db NORMAL,    STEEL,     NOT_VERY_EFFECTIVE
-	db FIRE,      FIRE,      NOT_VERY_EFFECTIVE
-	db FIRE,      WATER,     NOT_VERY_EFFECTIVE
-	db FIRE,      GRASS,     SUPER_EFFECTIVE
-	db FIRE,      ICE,       SUPER_EFFECTIVE
-	db FIRE,      BUG,       SUPER_EFFECTIVE
-	db FIRE,      ROCK,      NOT_VERY_EFFECTIVE
-	db FIRE,      DRAGON,    NOT_VERY_EFFECTIVE
-	db FIRE,      STEEL,     SUPER_EFFECTIVE
-	db WATER,     FIRE,      SUPER_EFFECTIVE
-	db WATER,     WATER,     NOT_VERY_EFFECTIVE
-	db WATER,     GRASS,     NOT_VERY_EFFECTIVE
-	db WATER,     GROUND,    SUPER_EFFECTIVE
-	db WATER,     ROCK,      SUPER_EFFECTIVE
-	db WATER,     DRAGON,    NOT_VERY_EFFECTIVE
-	db ELECTRIC,  WATER,     SUPER_EFFECTIVE
-	db ELECTRIC,  ELECTRIC,  NOT_VERY_EFFECTIVE
-	db ELECTRIC,  GRASS,     NOT_VERY_EFFECTIVE
-	db ELECTRIC,  GROUND,    NO_EFFECT
-	db ELECTRIC,  FLYING,    SUPER_EFFECTIVE
-	db ELECTRIC,  DRAGON,    NOT_VERY_EFFECTIVE
-	db GRASS,     FIRE,      NOT_VERY_EFFECTIVE
-	db GRASS,     WATER,     SUPER_EFFECTIVE
-	db GRASS,     GRASS,     NOT_VERY_EFFECTIVE
-	db GRASS,     POISON,    NOT_VERY_EFFECTIVE
-	db GRASS,     GROUND,    SUPER_EFFECTIVE
-	db GRASS,     FLYING,    NOT_VERY_EFFECTIVE
-	db GRASS,     BUG,       NOT_VERY_EFFECTIVE
-	db GRASS,     ROCK,      SUPER_EFFECTIVE
-	db GRASS,     DRAGON,    NOT_VERY_EFFECTIVE
-	db GRASS,     STEEL,     NOT_VERY_EFFECTIVE
-	db ICE,       WATER,     NOT_VERY_EFFECTIVE
-	db ICE,       GRASS,     SUPER_EFFECTIVE
-	db ICE,       ICE,       NOT_VERY_EFFECTIVE
-	db ICE,       GROUND,    SUPER_EFFECTIVE
-	db ICE,       FLYING,    SUPER_EFFECTIVE
-	db ICE,       DRAGON,    SUPER_EFFECTIVE
-	db ICE,       STEEL,     NOT_VERY_EFFECTIVE
-	db ICE,       FIRE,      NOT_VERY_EFFECTIVE
-	db FIGHTING,  NORMAL,    SUPER_EFFECTIVE
-	db FIGHTING,  ICE,       SUPER_EFFECTIVE
-	db FIGHTING,  POISON,    NOT_VERY_EFFECTIVE
-	db FIGHTING,  FLYING,    NOT_VERY_EFFECTIVE
-	db FIGHTING,  PSYCHIC,   NOT_VERY_EFFECTIVE
-	db FIGHTING,  BUG,       NOT_VERY_EFFECTIVE
-	db FIGHTING,  ROCK,      SUPER_EFFECTIVE
-	db FIGHTING,  DARK,      SUPER_EFFECTIVE
-	db FIGHTING,  STEEL,     SUPER_EFFECTIVE
-	db POISON,    GRASS,     SUPER_EFFECTIVE
-	db POISON,    POISON,    NOT_VERY_EFFECTIVE
-	db POISON,    GROUND,    NOT_VERY_EFFECTIVE
-	db POISON,    ROCK,      NOT_VERY_EFFECTIVE
-	db POISON,    GHOST,     NOT_VERY_EFFECTIVE
-	db POISON,    STEEL,     NO_EFFECT
-	db GROUND,    FIRE,      SUPER_EFFECTIVE
-	db GROUND,    ELECTRIC,  SUPER_EFFECTIVE
-	db GROUND,    GRASS,     NOT_VERY_EFFECTIVE
-	db GROUND,    POISON,    SUPER_EFFECTIVE
-	db GROUND,    FLYING,    NO_EFFECT
-	db GROUND,    BUG,       NOT_VERY_EFFECTIVE
-	db GROUND,    ROCK,      SUPER_EFFECTIVE
-	db GROUND,    STEEL,     SUPER_EFFECTIVE
-	db FLYING,    ELECTRIC,  NOT_VERY_EFFECTIVE
-	db FLYING,    GRASS,     SUPER_EFFECTIVE
-	db FLYING,    FIGHTING,  SUPER_EFFECTIVE
-	db FLYING,    BUG,       SUPER_EFFECTIVE
-	db FLYING,    ROCK,      NOT_VERY_EFFECTIVE
-	db FLYING,    STEEL,     NOT_VERY_EFFECTIVE
-	db PSYCHIC,   FIGHTING,  SUPER_EFFECTIVE
-	db PSYCHIC,   POISON,    SUPER_EFFECTIVE
-	db PSYCHIC,   PSYCHIC,   NOT_VERY_EFFECTIVE
-	db PSYCHIC,   DARK,      NO_EFFECT
-	db PSYCHIC,   STEEL,     NOT_VERY_EFFECTIVE
-	db BUG,       FIRE,      NOT_VERY_EFFECTIVE
-	db BUG,       GRASS,     SUPER_EFFECTIVE
-	db BUG,       FIGHTING,  NOT_VERY_EFFECTIVE
-	db BUG,       POISON,    NOT_VERY_EFFECTIVE
-	db BUG,       FLYING,    NOT_VERY_EFFECTIVE
-	db BUG,       PSYCHIC,   SUPER_EFFECTIVE
-	db BUG,       GHOST,     NOT_VERY_EFFECTIVE
-	db BUG,       DARK,      SUPER_EFFECTIVE
-	db BUG,       STEEL,     NOT_VERY_EFFECTIVE
-	db ROCK,      FIRE,      SUPER_EFFECTIVE
-	db ROCK,      ICE,       SUPER_EFFECTIVE
-	db ROCK,      FIGHTING,  NOT_VERY_EFFECTIVE
-	db ROCK,      GROUND,    NOT_VERY_EFFECTIVE
-	db ROCK,      FLYING,    SUPER_EFFECTIVE
-	db ROCK,      BUG,       SUPER_EFFECTIVE
-	db ROCK,      STEEL,     NOT_VERY_EFFECTIVE
-	db GHOST,     NORMAL,    NO_EFFECT
-	db GHOST,     PSYCHIC,   SUPER_EFFECTIVE
-	db GHOST,     DARK,      NOT_VERY_EFFECTIVE
-	db GHOST,     STEEL,     NOT_VERY_EFFECTIVE
-	db GHOST,     GHOST,     SUPER_EFFECTIVE
-	db DRAGON,    DRAGON,    SUPER_EFFECTIVE
-	db DRAGON,    STEEL,     NOT_VERY_EFFECTIVE
-	db DARK,      FIGHTING,  NOT_VERY_EFFECTIVE
-	db DARK,      PSYCHIC,   SUPER_EFFECTIVE
-	db DARK,      GHOST,     SUPER_EFFECTIVE
-	db DARK,      DARK,      NOT_VERY_EFFECTIVE
-	db DARK,      STEEL,     NOT_VERY_EFFECTIVE
-	db STEEL,     FIRE,      NOT_VERY_EFFECTIVE
-	db STEEL,     WATER,     NOT_VERY_EFFECTIVE
-	db STEEL,     ELECTRIC,  NOT_VERY_EFFECTIVE
-	db STEEL,     ICE,       SUPER_EFFECTIVE
-	db STEEL,     ROCK,      SUPER_EFFECTIVE
-	db STEEL,     STEEL,     NOT_VERY_EFFECTIVE
-
-	db $fe ; end
-
-; Foresight removes Ghost's immunities.
-	db NORMAL,    GHOST,     NO_EFFECT
-	db FIGHTING,  GHOST,     NO_EFFECT
-
-	db $ff ; end (with Foresight)
-; 34cfd
--- a/data/wild/treemon_maps.asm
+++ b/data/wild/treemon_maps.asm
@@ -4,47 +4,47 @@
 ENDM
 
 TreeMonMaps: ; b825e
-	treemon_map ROUTE_26, 4
-	treemon_map ROUTE_27, 4
-	treemon_map ROUTE_28, 0
-	treemon_map ROUTE_29, 3
-	treemon_map ROUTE_30, 3
-	treemon_map ROUTE_31, 3
-	treemon_map ROUTE_32, 4
-	treemon_map ROUTE_33, 2
-	treemon_map ROUTE_34, 3
-	treemon_map ROUTE_35, 3
-	treemon_map ROUTE_36, 3
-	treemon_map ROUTE_37, 3
-	treemon_map ROUTE_38, 3
-	treemon_map ROUTE_39, 3
-	treemon_map ROUTE_40, 0
-	treemon_map ROUTE_41, 0
-	treemon_map ROUTE_42, 2
-	treemon_map ROUTE_43, 5
-	treemon_map ROUTE_44, 1
-	treemon_map ROUTE_45, 1
-	treemon_map ROUTE_46, 1
-	treemon_map NEW_BARK_TOWN, 0
-	treemon_map CHERRYGROVE_CITY, 0
-	treemon_map VIOLET_CITY, 0
-	treemon_map AZALEA_TOWN, 2
-	treemon_map CIANWOOD_CITY, 0
-	treemon_map GOLDENROD_CITY, 0
-	treemon_map OLIVINE_CITY, 0
-	treemon_map ECRUTEAK_CITY, 0
-	treemon_map MAHOGANY_TOWN, 0
-	treemon_map LAKE_OF_RAGE, 5
-	treemon_map BLACKTHORN_CITY, 0
-	treemon_map SILVER_CAVE_OUTSIDE, 0
-	treemon_map ILEX_FOREST, 6
+	treemon_map ROUTE_26,                  TREEMON_SET_KANTO
+	treemon_map ROUTE_27,                  TREEMON_SET_KANTO
+	treemon_map ROUTE_28,                  TREEMON_SET_CITY
+	treemon_map ROUTE_29,                  TREEMON_SET_ROUTE
+	treemon_map ROUTE_30,                  TREEMON_SET_ROUTE
+	treemon_map ROUTE_31,                  TREEMON_SET_ROUTE
+	treemon_map ROUTE_32,                  TREEMON_SET_KANTO
+	treemon_map ROUTE_33,                  TREEMON_SET_AZALEA
+	treemon_map ROUTE_34,                  TREEMON_SET_ROUTE
+	treemon_map ROUTE_35,                  TREEMON_SET_ROUTE
+	treemon_map ROUTE_36,                  TREEMON_SET_ROUTE
+	treemon_map ROUTE_37,                  TREEMON_SET_ROUTE
+	treemon_map ROUTE_38,                  TREEMON_SET_ROUTE
+	treemon_map ROUTE_39,                  TREEMON_SET_ROUTE
+	treemon_map ROUTE_40,                  TREEMON_SET_CITY
+	treemon_map ROUTE_41,                  TREEMON_SET_CITY
+	treemon_map ROUTE_42,                  TREEMON_SET_AZALEA
+	treemon_map ROUTE_43,                  TREEMON_SET_LAKE
+	treemon_map ROUTE_44,                  TREEMON_SET_CANYON
+	treemon_map ROUTE_45,                  TREEMON_SET_CANYON
+	treemon_map ROUTE_46,                  TREEMON_SET_CANYON
+	treemon_map NEW_BARK_TOWN,             TREEMON_SET_CITY
+	treemon_map CHERRYGROVE_CITY,          TREEMON_SET_CITY
+	treemon_map VIOLET_CITY,               TREEMON_SET_CITY
+	treemon_map AZALEA_TOWN,               TREEMON_SET_AZALEA
+	treemon_map CIANWOOD_CITY,             TREEMON_SET_CITY
+	treemon_map GOLDENROD_CITY,            TREEMON_SET_CITY
+	treemon_map OLIVINE_CITY,              TREEMON_SET_CITY
+	treemon_map ECRUTEAK_CITY,             TREEMON_SET_CITY
+	treemon_map MAHOGANY_TOWN,             TREEMON_SET_CITY
+	treemon_map LAKE_OF_RAGE,              TREEMON_SET_LAKE
+	treemon_map BLACKTHORN_CITY,           TREEMON_SET_CITY
+	treemon_map SILVER_CAVE_OUTSIDE,       TREEMON_SET_CITY
+	treemon_map ILEX_FOREST,               TREEMON_SET_FOREST
 	db -1
 ; b82c5
 
 RockMonMaps: ; b82c5
-	treemon_map CIANWOOD_CITY, 7
-	treemon_map ROUTE_40, 7
-	treemon_map DARK_CAVE_VIOLET_ENTRANCE, 7
-	treemon_map SLOWPOKE_WELL_B1F, 7
+	treemon_map CIANWOOD_CITY,             TREEMON_SET_ROCK
+	treemon_map ROUTE_40,                  TREEMON_SET_ROCK
+	treemon_map DARK_CAVE_VIOLET_ENTRANCE, TREEMON_SET_ROCK
+	treemon_map SLOWPOKE_WELL_B1F,         TREEMON_SET_ROCK
 	db -1
 ; b82d2
--- a/data/wild/treemons.asm
+++ b/data/wild/treemons.asm
@@ -1,19 +1,21 @@
 TreeMons: ; b82e8
-	dw TreeMons1
-	dw TreeMons1
-	dw TreeMons2
-	dw TreeMons3
-	dw TreeMons4
-	dw TreeMons5
-	dw TreeMons6
-	dw RockMons
-	dw TreeMons1
+; entries correspond to TREEMON_SET_* constants
+	dw TreeMonSet_City
+	dw TreeMonSet_Canyon
+	dw TreeMonSet_Azalea
+	dw TreeMonSet_Route
+	dw TreeMonSet_Kanto
+	dw TreeMonSet_Lake
+	dw TreeMonSet_Forest
+	dw TreeMonSet_Rock
+	dw TreeMonSet_City
 
 ; Two tables each (common, rare).
 ; Structure:
 ;	db  %, species, level
 
-TreeMons1: ; b82fa
+TreeMonSet_City:
+TreeMonSet_Canyon: ; b82fa
 ; common
 	db 50, SPEAROW,    10
 	db 15, SPEAROW,    10
@@ -31,7 +33,7 @@
 	db  5, AIPOM,      10
 	db -1
 
-TreeMons2: ; b8320
+TreeMonSet_Azalea: ; b8320
 ; common
 	db 50, SPEAROW,    10
 	db 15, EKANS,      10
@@ -49,7 +51,7 @@
 	db  5, AIPOM,      10
 	db -1
 
-TreeMons3: ; b8346
+TreeMonSet_Route: ; b8346
 ; common
 	db 50, HOOTHOOT,   10
 	db 15, SPINARAK,   10
@@ -67,7 +69,7 @@
 	db  5, EXEGGCUTE,  10
 	db -1
 
-TreeMons4: ; b836c
+TreeMonSet_Kanto: ; b836c
 ; common
 	db 50, HOOTHOOT,   10
 	db 15, EKANS,      10
@@ -85,7 +87,7 @@
 	db  5, EXEGGCUTE,  10
 	db -1
 
-TreeMons5: ; b8392
+TreeMonSet_Lake: ; b8392
 ; common
 	db 50, HOOTHOOT,   10
 	db 15, VENONAT,    10
@@ -103,7 +105,7 @@
 	db  5, EXEGGCUTE,  10
 	db -1
 
-TreeMons6: ; b83b8
+TreeMonSet_Forest: ; b83b8
 ; common
 	db 50, HOOTHOOT,   10
 	db 15, PINECO,     10
@@ -121,7 +123,7 @@
 	db  5, KAKUNA,     10
 	db -1
 
-RockMons: ; b83de
+TreeMonSet_Rock: ; b83de
 	db 90, KRABBY,     15
 	db 10, SHUCKLE,    15
 	db -1
--- a/engine/battle/effect_commands.asm
+++ b/engine/battle/effect_commands.asm
@@ -64,7 +64,7 @@
 	inc hl
 	ld [de], a
 	inc de
-	cp $ff
+	cp -1
 	jr nz, .GetMoveEffect
 
 ; Start at the first command.
@@ -138,7 +138,7 @@
 	ld [AlreadyFailed], a
 	ld [wSomeoneIsRampaging], a
 
-	ld a, 10 ; 1.0
+	ld a, EFFECTIVE
 	ld [TypeModifier], a
 
 	ld a, [hBattleTurn]
@@ -282,7 +282,7 @@
 
 	; 50% chance of hitting itself
 	call BattleRandom
-	cp $80
+	cp 50 percent + 1
 	jr nc, .not_confused
 
 	; clear confusion-dependent substatus
@@ -311,7 +311,7 @@
 
 	; 50% chance of infatuation
 	call BattleRandom
-	cp $80
+	cp 50 percent + 1
 	jr c, .not_infatuated
 
 	ld hl, InfatuationText
@@ -345,7 +345,7 @@
 
 	; 25% chance to be fully paralyzed
 	call BattleRandom
-	cp $3f
+	cp 25 percent
 	ret nc
 
 	ld hl, FullyParalyzedText
@@ -457,6 +457,8 @@
 	ld hl, EnemyMonStatus
 	bit FRZ, [hl]
 	jr z, .not_frozen
+
+	; Flame Wheel and Sacred Fire thaw the user.
 	ld a, [CurEnemyMove]
 	cp FLAME_WHEEL
 	jr z, .not_frozen
@@ -611,7 +613,7 @@
 
 	; 25% chance to be fully paralyzed
 	call BattleRandom
-	cp $3f
+	cp 25 percent
 	ret nc
 
 	ld hl, FullyParalyzedText
@@ -989,6 +991,7 @@
 	ld a, BATTLE_VARS_MOVE_ANIM
 	call GetBattleVar
 
+	; Snore and Sleep Talk bypass sleep.
 	cp SNORE
 	jr z, .CheckSleep
 	cp SLEEP_TALK
@@ -1172,7 +1175,7 @@
 	db EFFECT_ROLLOUT
 	db EFFECT_BIDE
 	db EFFECT_RAMPAGE
-	db $ff
+	db -1
 ; 3460b
 
 CheckMimicUsed: ; 3460b
@@ -1266,7 +1269,7 @@
 	ld a, BATTLE_VARS_MOVE_ANIM
 	call GetBattleVar
 	ld de, 1
-	ld hl, .Criticals
+	ld hl, CriticalHitMoves
 	push bc
 	call IsInArray
 	pop bc
@@ -1288,7 +1291,7 @@
 	inc c
 
 .Tally:
-	ld hl, .Chances
+	ld hl, CriticalHitChances
 	ld b, 0
 	add hl, bc
 	call BattleRandom
@@ -1298,12 +1301,7 @@
 	ld [CriticalHit], a
 	ret
 
-.Criticals:
-	db KARATE_CHOP, RAZOR_WIND, RAZOR_LEAF, CRABHAMMER, SLASH, AEROBLAST, CROSS_CHOP, $ff
-.Chances:
-	; 6.25% 12.1% 24.6% 33.2% 49.6% 49.6% 49.6%
-	db $11,  $20,  $40,  $55,  $80,  $80,  $80
-	;   0     1     2     3     4     5     6
+INCLUDE "data/battle/critical_hits.asm"
 ; 346b2
 
 
@@ -1433,11 +1431,11 @@
 .TypesLoop:
 	ld a, [hli]
 
-	cp $ff
+	cp -1
 	jr z, .end
 
 	; foresight
-	cp $fe
+	cp -2
 	jr nz, .SkipForesightCheck
 	ld a, BATTLE_VARS_SUBSTATUS1_OPP
 	call GetBattleVar
@@ -1562,9 +1560,9 @@
 	ld hl, TypeMatchups
 .TypesLoop:
 	ld a, [hli]
-	cp $ff
+	cp -1
 	jr z, .End
-	cp $fe
+	cp -2
 	jr nz, .Next
 	ld a, BATTLE_VARS_SUBSTATUS1_OPP
 	call GetBattleVar
@@ -1640,7 +1638,7 @@
 
 INCLUDE "engine/battle/ai/switch.asm"
 
-INCLUDE "data/type_matchups.asm"
+INCLUDE "data/battle/type_matchups.asm"
 
 BattleCommand_DamageVariation: ; 34cfd
 ; damagevariation
@@ -1675,7 +1673,7 @@
 .loop
 	call BattleRandom
 	rrca
-	cp $d9 ; 85%
+	cp 85 percent + 1
 	jr c, .loop
 
 	ld [hMultiplier], a
@@ -1756,7 +1754,7 @@
 
 .skip_brightpowder
 	ld a, b
-	cp $ff
+	cp -1
 	jr z, .Hit
 
 	call BattleRandom
@@ -1954,7 +1952,7 @@
 
 .skip_foresight_check
 	; subtract evasion from 14
-	ld a, 14
+	ld a, MAX_STAT_LEVEL + 1
 	sub c
 	ld c, a
 	; store the base move accuracy for math ops
@@ -1969,7 +1967,7 @@
 .accuracy_loop
 	; look up the multiplier from the table
 	push bc
-	ld hl, .AccProb
+	ld hl, AccuracyLevelMultipliers
 	dec b
 	sla b
 	ld c, b
@@ -2013,21 +2011,7 @@
 	ld [hl], a
 	ret
 
-.AccProb:
-	db  33, 100 ;  33% -6
-	db  36, 100 ;  36% -5
-	db  43, 100 ;  43% -4
-	db  50, 100 ;  50% -3
-	db  60, 100 ;  60% -2
-	db  75, 100 ;  75% -1
-	db   1,   1 ; 100%  0
-	db 133, 100 ; 133% +1
-	db 166, 100 ; 166% +2
-	db   2,   1 ; 200% +3
-	db 233, 100 ; 233% +4
-	db 133,  50 ; 266% +5
-	db   3,   1 ; 300% +6
-
+INCLUDE "data/battle/accuracy_multipliers.asm"
 ; 34ecc
 
 
@@ -2199,7 +2183,7 @@
 	xor 1
 	ld [wKickCounter], a
 	ld a, [de]
-	cp $1
+	cp 1
 	push af
 	ld a, BATTLE_VARS_MOVE_ANIM
 	call GetBattleVar
@@ -2438,7 +2422,7 @@
 	ld hl, AttackMissedText
 	ld de, AttackMissed2Text
 	ld a, [CriticalHit]
-	cp $ff
+	cp -1
 	jr nz, .got_text
 	ld hl, UnaffectedText
 .got_text
@@ -3519,7 +3503,7 @@
 
 .NextItem:
 	ld a, [hli]
-	cp $ff
+	cp -1
 	jr z, .DoneItem
 
 ; Item effect
@@ -3657,26 +3641,7 @@
 ; 35703
 
 
-TypeBoostItems: ; 35703
-	db HELD_NORMAL_BOOST,   NORMAL   ; Pink/Polkadot Bow
-	db HELD_FIGHTING_BOOST, FIGHTING ; Blackbelt
-	db HELD_FLYING_BOOST,   FLYING   ; Sharp Beak
-	db HELD_POISON_BOOST,   POISON   ; Poison Barb
-	db HELD_GROUND_BOOST,   GROUND   ; Soft Sand
-	db HELD_ROCK_BOOST,     ROCK     ; Hard Stone
-	db HELD_BUG_BOOST,      BUG      ; Silverpowder
-	db HELD_GHOST_BOOST,    GHOST    ; Spell Tag
-	db HELD_FIRE_BOOST,     FIRE     ; Charcoal
-	db HELD_WATER_BOOST,    WATER    ; Mystic Water
-	db HELD_GRASS_BOOST,    GRASS    ; Miracle Seed
-	db HELD_ELECTRIC_BOOST, ELECTRIC ; Magnet
-	db HELD_PSYCHIC_BOOST,  PSYCHIC  ; Twistedspoon
-	db HELD_ICE_BOOST,      ICE      ; Nevermeltice
-	db HELD_DRAGON_BOOST,   DRAGON   ; Dragon Scale
-	db HELD_DARK_BOOST,     DARK     ; Blackglasses
-	db HELD_STEEL_BOOST,    STEEL    ; Metal Coat
-	db $ff
-; 35726
+INCLUDE "data/battle/type_boost_items.asm"
 
 
 BattleCommand_ConstantDamage: ; 35726
@@ -4671,7 +4636,7 @@
 	ld [de], a
 .okay
 	ld a, [CriticalHit]
-	cp $2
+	cp 2
 	jr nz, .carry
 	xor a
 	ld [CriticalHit], a
@@ -5049,7 +5014,7 @@
 	jr nz, .dont_fail
 
 	call BattleRandom
-	cp $40 ; 25%
+	cp 25 percent + 1 ; 25% chance AI fails
 	ret c
 
 .dont_fail
@@ -5149,7 +5114,7 @@
 	jr nz, .mimic_random
 
 	call BattleRandom
-	cp $40 ; 25% chance AI fails
+	cp 25 percent + 1 ; 25% chance AI fails
 	jr c, .failed
 
 .mimic_random
@@ -5827,7 +5792,7 @@
 	inc b
 
 .ComputerMiss:
-; Computer opponents have a 1/4 chance of failing.
+; Computer opponents have a 25% chance of failing.
 	ld a, [hBattleTurn]
 	and a
 	jr z, .DidntMiss
@@ -5852,7 +5817,7 @@
 	jr z, .DidntMiss
 
 	call BattleRandom
-	cp $40
+	cp 25 percent + 1 ; 25% chance AI fails
 	jr c, .Failed
 
 .DidntMiss:
@@ -6104,7 +6069,7 @@
 
 
 GetStatName: ; 3648f
-	ld hl, .names
+	ld hl, StatNames
 	ld c, "@"
 .CheckName:
 	dec b
@@ -6120,33 +6085,10 @@
 	ld bc, StringBuffer3 - StringBuffer2
 	jp CopyBytes
 
-.names
-	db "ATTACK@"
-	db "DEFENSE@"
-	db "SPEED@"
-	db "SPCL.ATK@"
-	db "SPCL.DEF@"
-	db "ACCURACY@"
-	db "EVASION@"
-	db "ABILITY@"
-; 364e6
+INCLUDE "data/battle/stat_names.asm"
 
 
-StatLevelMultipliers: ; 364e6
-	db 25, 100 ; 0.25x
-	db 28, 100 ; 0.28x
-	db 33, 100 ; 0.33x
-	db 40, 100 ; 0.40x
-	db 50, 100 ; 0.50x
-	db 66, 100 ; 0.66x
-	db  1,   1 ; 1.00x
-	db 15,  10 ; 1.50x
-	db  2,   1 ; 2.00x
-	db 25,  10 ; 2.50x
-	db  3,   1 ; 3.00x
-	db 35,  10 ; 3.50x
-	db  4,   1 ; 4.00x
-; 36500
+INCLUDE "data/battle/stat_multipliers.asm"
 
 
 BattleCommand_AllStatsUp: ; 36500
--- a/engine/events_3.asm
+++ b/engine/events_3.asm
@@ -1,13 +1,11 @@
 ReturnFromMapSetupScript:: ; b8000
 	xor a
 	ld [hBGMapMode], a
-	; For some reson, GameFreak chose to use a farcall here instead of just falling through.
-	; No other function in the game references the function at 2E:400A, here labeled
-	; ReturnFromMapSetupScript.inefficient_farcall.
 	farcall .inefficient_farcall ; this is a waste of 6 ROM bytes and 6 stack bytes
 	ret
 ; b800a
 
+; should have just been a fallthrough
 .inefficient_farcall ; b800a
 	ld a, [MapGroup]
 	ld b, a
@@ -70,6 +68,7 @@
 ; b8070
 
 .CheckSpecialMap: ; b8070
+; These landmarks do not get pop-up signs.
 	cp -1
 	ret z
 	cp SPECIAL_MAP
@@ -401,6 +400,7 @@
 	call GetTreeMons
 	jr nc, .no_battle
 
+	; 40% chance of an encounter
 	ld a, 10
 	call RandomRange
 	cp 4
@@ -461,7 +461,7 @@
 ; Return the address of TreeMon table a in hl.
 ; Return nc if table a doesn't exist.
 
-	cp 8
+	cp NUM_TREEMON_SETS
 	jr nc, .quit
 
 	and a
@@ -491,15 +491,16 @@
 	push hl
 	call GetTreeScore
 	pop hl
-	and a
+	and a ; TREEMON_SCORE_BAD
 	jr z, .bad
-	cp 1
+	cp TREEMON_SCORE_GOOD
 	jr z, .good
-	cp 2
+	cp TREEMON_SCORE_RARE
 	jr z, .rare
 	ret
 
 .bad
+	; 10% chance of an encounter
 	ld a, 10
 	call RandomRange
 	and a
@@ -507,6 +508,7 @@
 	jr SelectTreeMon
 
 .good
+	; 50% chance of an encounter
 	ld a, 10
 	call RandomRange
 	cp 5
@@ -514,6 +516,7 @@
 	jr SelectTreeMon
 
 .rare
+	; 80% chance of an encounter
 	ld a, 10
 	call RandomRange
 	cp 8
@@ -542,7 +545,7 @@
 
 .ok
 	ld a, [hli]
-	cp $ff
+	cp -1
 	jr z, NoTreeMon
 
 	ld a, [hli]
@@ -575,15 +578,15 @@
 	jr c, .good
 
 .bad
-	xor a
+	xor a ; TREEMON_SCORE_BAD
 	ret
 
 .good
-	ld a, 1
+	ld a, TREEMON_SCORE_GOOD
 	ret
 
 .rare
-	ld a, 2
+	ld a, TREEMON_SCORE_RARE
 	ret
 ; b8466
 
--- a/engine/link.asm
+++ b/engine/link.asm
@@ -2045,12 +2045,12 @@
 
 ; If any party Pokemon was introduced in the generation 2 games, don't let it in.
 	ld hl, PartySpecies
-	ld b, PARTY_LENGTH ; 6
+	ld b, PARTY_LENGTH
 .loop
 	ld a, [hli]
 	cp -1
 	jr z, .checkitem
-	cp CHIKORITA ; MEW + 1 ; 151 + 1
+	cp MEW + 1
 	jr nc, .mon_too_new
 	dec b
 	jr nz, .loop
--- a/engine/warp_connection.asm
+++ b/engine/warp_connection.asm
@@ -174,8 +174,11 @@
 	call GetAnyMapEnvironment
 	call CheckIndoorMap
 	ret nz
+
+; MOUNT_MOON_SQUARE and TIN_TOWER_ROOF are outdoor maps within indoor maps.
+; Dig and Escape Rope should not take you to them.
 	ld a, [wPrevMapGroup]
-	cp GROUP_MOUNT_MOON_SQUARE
+	cp GROUP_MOUNT_MOON_SQUARE ; GROUP_TIN_TOWER_ROOF
 	jr nz, .not_mt_moon_or_tin_tower
 	ld a, [wPrevMapNumber]
 	cp MAP_MOUNT_MOON_SQUARE
@@ -183,6 +186,7 @@
 	cp MAP_TIN_TOWER_ROOF
 	ret z
 .not_mt_moon_or_tin_tower
+
 	ld a, [wPrevWarp]
 	ld [wDigWarpNumber], a
 	ld a, [wPrevMapGroup]
@@ -206,6 +210,8 @@
 	ld b, a
 	ld a, [wNextMapNumber]
 	ld c, a
+
+; Respawn in Pokémon Centers.
 	call GetAnyMapTileset
 	ld a, c
 	cp TILESET_POKECENTER
@@ -214,6 +220,7 @@
 	jr z, .pokecenter_pokecom
 	ret
 .pokecenter_pokecom
+
 	ld a, [wPrevMapGroup]
 	ld [wLastSpawnMapGroup], a
 	ld a, [wPrevMapNumber]
--- a/home/map.asm
+++ b/home/map.asm
@@ -1429,6 +1429,7 @@
 	pop af
 	ld [rSVBK], a
 
+; These tilesets support dynamic per-mapgroup roof tiles.
 	ld a, [wTileset]
 	cp TILESET_JOHTO_1
 	jr z, .load_roof