shithub: pokecrystal

Download patch

ref: d504fb88529526f988985f7faaf70609263cb4a0
parent: 7d3ad2136aac8483fa89a4ad0ac7608cd45658a9
author: Rangi <[email protected]>
date: Thu Jan 25 15:34:33 EST 2018

Move AI data tables into data/battle/ai (mirroring engine/battle/ai) so they're more discoverable.

--- a/constants/trainer_data_constants.asm
+++ b/constants/trainer_data_constants.asm
@@ -10,6 +10,7 @@
 NUM_TRAINER_ATTRIBUTES EQU const_value
 
 ; TRNATTR_AI_MOVE_WEIGHTS bit flags (wEnemyTrainerAIFlags)
+; AIScoringPointers indexes (see engine/battle/ai/move.asm)
 	const_def
 	const       NO_AI
 const_value = 0
--- /dev/null
+++ b/data/battle/ai/constant_damage_effects.asm
@@ -1,0 +1,11 @@
+; AIDamageCalc uses BattleCommand_ConstantDamage
+; to calculate damage for these instead of
+; BattleCommand_DamageCalc and BattleCommand_Stab.
+
+ConstantDamageEffects: ; 39413
+	db EFFECT_SUPER_FANG
+	db EFFECT_STATIC_DAMAGE
+	db EFFECT_LEVEL_DAMAGE
+	db EFFECT_PSYWAVE
+	db -1 ; end
+; 39418
--- /dev/null
+++ b/data/battle/ai/encore_moves.asm
@@ -1,0 +1,35 @@
+; AI_SMART encourages these moves with Encore.
+
+EncoreMoves: ; 38c85
+	db SWORDS_DANCE
+	db WHIRLWIND
+	db LEER
+	db ROAR
+	db DISABLE
+	db MIST
+	db LEECH_SEED
+	db GROWTH
+	db POISONPOWDER
+	db STRING_SHOT
+	db MEDITATE
+	db AGILITY
+	db TELEPORT
+	db SCREECH
+	db HAZE
+	db FOCUS_ENERGY
+	db DREAM_EATER
+	db POISON_GAS
+	db SPLASH
+	db SHARPEN
+	db CONVERSION
+	db SUPER_FANG
+	db SUBSTITUTE
+	db TRIPLE_KICK
+	db SPIDER_WEB
+	db MIND_READER
+	db FLAME_WHEEL
+	db AEROBLAST
+	db COTTON_SPORE
+	db POWDER_SNOW
+	db -1 ; end
+; 38ca4
--- /dev/null
+++ b/data/battle/ai/rain_dance_moves.asm
@@ -1,0 +1,16 @@
+; AI_SMART prefers these moves during rain.
+
+RainDanceMoves: ; 390e7
+	db WATER_GUN
+	db HYDRO_PUMP
+	db SURF
+	db BUBBLEBEAM
+	db THUNDER
+	db WATERFALL
+	db CLAMP
+	db BUBBLE
+	db CRABHAMMER
+	db OCTAZOOKA
+	db WHIRLPOOL
+	db -1 ; end
+; 390f3
--- /dev/null
+++ b/data/battle/ai/reckless_moves.asm
@@ -1,0 +1,10 @@
+; AI_AGGRESSIVE does not discourage these moves
+; even if a stronger one is available.
+
+RecklessMoves: ; 393e2
+	db EFFECT_SELFDESTRUCT
+	db EFFECT_RAMPAGE
+	db EFFECT_MULTI_HIT
+	db EFFECT_DOUBLE_HIT
+	db -1 ; end
+; 393e7
--- /dev/null
+++ b/data/battle/ai/residual_moves.asm
@@ -1,0 +1,17 @@
+; AI_CAUTIOUS discourages these moves after the first turn.
+
+ResidualMoves:
+	db MIST
+	db LEECH_SEED
+	db POISONPOWDER
+	db STUN_SPORE
+	db THUNDER_WAVE
+	db FOCUS_ENERGY
+	db BIDE
+	db POISON_GAS
+	db TRANSFORM
+	db CONVERSION
+	db SUBSTITUTE
+	db SPIKES
+	db -1 ; end
+; 39453
--- /dev/null
+++ b/data/battle/ai/risky_effects.asm
@@ -1,0 +1,8 @@
+; AI_RISKY will not use these effects at max HP
+; even if they would KO the player.
+
+RiskyEffects: ; 394ff
+	db EFFECT_SELFDESTRUCT
+	db EFFECT_OHKO
+	db -1 ; end
+; 39502
--- /dev/null
+++ b/data/battle/ai/stall_moves.asm
@@ -1,0 +1,38 @@
+; AI_OPPORTUNIST discourages these moves
+; when the player's HP is low.
+
+StallMoves: ; 39348
+	db SWORDS_DANCE
+	db TAIL_WHIP
+	db LEER
+	db GROWL
+	db DISABLE
+	db MIST
+	db COUNTER
+	db LEECH_SEED
+	db GROWTH
+	db STRING_SHOT
+	db MEDITATE
+	db AGILITY
+	db RAGE
+	db MIMIC
+	db SCREECH
+	db HARDEN
+	db WITHDRAW
+	db DEFENSE_CURL
+	db BARRIER
+	db LIGHT_SCREEN
+	db HAZE
+	db REFLECT
+	db FOCUS_ENERGY
+	db BIDE
+	db AMNESIA
+	db TRANSFORM
+	db SPLASH
+	db ACID_ARMOR
+	db SHARPEN
+	db CONVERSION
+	db SUBSTITUTE
+	db FLAME_WHEEL
+	db -1 ; end
+; 39369
--- /dev/null
+++ b/data/battle/ai/status_only_effects.asm
@@ -1,0 +1,10 @@
+; AI_BASIC discourages these effects if the player
+; already has a status condition.
+
+StatusOnlyEffects: ; 385db
+	db EFFECT_SLEEP
+	db EFFECT_TOXIC
+	db EFFECT_POISON
+	db EFFECT_PARALYZE
+	db -1 ; end
+; 385e0
--- /dev/null
+++ b/data/battle/ai/sunny_day_moves.asm
@@ -1,0 +1,13 @@
+; AI_SMART prefers these moves during harsh sunlight.
+
+SunnyDayMoves: ; 39134
+	db FIRE_PUNCH
+	db EMBER
+	db FLAMETHROWER
+	db FIRE_SPIN
+	db FIRE_BLAST
+	db SACRED_FIRE
+	db MORNING_SUN
+	db SYNTHESIS
+	db -1 ; end
+; 3913d
--- /dev/null
+++ b/data/battle/ai/useful_moves.asm
@@ -1,0 +1,24 @@
+; AI_SMART knows these moves are usable all-around.
+
+UsefulMoves: ; 39301
+	db DOUBLE_EDGE
+	db SING
+	db FLAMETHROWER
+	db HYDRO_PUMP
+	db SURF
+	db ICE_BEAM
+	db BLIZZARD
+	db HYPER_BEAM
+	db SLEEP_POWDER
+	db THUNDERBOLT
+	db THUNDER
+	db EARTHQUAKE
+	db TOXIC
+	db PSYCHIC_M
+	db HYPNOSIS
+	db RECOVER
+	db FIRE_BLAST
+	db SOFTBOILED
+	db SUPER_FANG
+	db -1 ; end
+; 39315
--- a/engine/battle/ai/move.asm
+++ b/engine/battle/ai/move.asm
@@ -202,6 +202,7 @@
 
 
 AIScoringPointers: ; 441af
+; entries correspond to AI_* constants
 	dw AI_Basic
 	dw AI_Setup
 	dw AI_Types
--- a/engine/battle/ai/scoring.asm
+++ b/engine/battle/ai/scoring.asm
@@ -40,7 +40,7 @@
 	push hl
 	push de
 	push bc
-	ld hl, .statusonlyeffects
+	ld hl, StatusOnlyEffects
 	ld de, 1
 	call IsInArray
 
@@ -63,13 +63,7 @@
 	jr .checkmove
 ; 385db
 
-.statusonlyeffects
-	db EFFECT_SLEEP
-	db EFFECT_TOXIC
-	db EFFECT_POISON
-	db EFFECT_PARALYZE
-	db -1 ; end
-; 385e0
+INCLUDE "data/battle/ai/status_only_effects.asm"
 
 
 
@@ -1502,7 +1496,7 @@
 .asm_38c68
 	push hl
 	ld a, [LastPlayerCounterMove]
-	ld hl, .EncoreMoves
+	ld hl, EncoreMoves
 	ld de, 1
 	call IsInArray
 	pop hl
@@ -1522,39 +1516,7 @@
 	inc [hl]
 	ret
 
-.EncoreMoves:
-	db SWORDS_DANCE
-	db WHIRLWIND
-	db LEER
-	db ROAR
-	db DISABLE
-	db MIST
-	db LEECH_SEED
-	db GROWTH
-	db POISONPOWDER
-	db STRING_SHOT
-	db MEDITATE
-	db AGILITY
-	db TELEPORT
-	db SCREECH
-	db HAZE
-	db FOCUS_ENERGY
-	db DREAM_EATER
-	db POISON_GAS
-	db SPLASH
-	db SHARPEN
-	db CONVERSION
-	db SUPER_FANG
-	db SUBSTITUTE
-	db TRIPLE_KICK
-	db SPIDER_WEB
-	db MIND_READER
-	db FLAME_WHEEL
-	db AEROBLAST
-	db COTTON_SPORE
-	db POWDER_SNOW
-	db -1 ; end
-; 38ca4
+INCLUDE "data/battle/ai/encore_moves.asm"
 
 
 AI_Smart_PainSplit: ; 38ca4
@@ -2521,20 +2483,7 @@
 	jr AI_Smart_WeatherMove
 ; 390e7
 
-RainDanceMoves: ; 390e7
-	db WATER_GUN
-	db HYDRO_PUMP
-	db SURF
-	db BUBBLEBEAM
-	db THUNDER
-	db WATERFALL
-	db CLAMP
-	db BUBBLE
-	db CRABHAMMER
-	db OCTAZOOKA
-	db WHIRLPOOL
-	db -1 ; end
-; 390f3
+INCLUDE "data/battle/ai/rain_dance_moves.asm"
 
 
 AI_Smart_SunnyDay: ; 390f3
@@ -2613,17 +2562,7 @@
 ; 39134
 
 
-SunnyDayMoves: ; 39134
-	db FIRE_PUNCH
-	db EMBER
-	db FLAMETHROWER
-	db FIRE_SPIN
-	db FIRE_BLAST
-	db SACRED_FIRE
-	db MORNING_SUN
-	db SYNTHESIS
-	db -1 ; end
-; 3913d
+INCLUDE "data/battle/ai/sunny_day_moves.asm"
 
 
 AI_Smart_BellyDrum: ; 3913d
@@ -3104,29 +3043,7 @@
 ; 39301
 
 
-UsefulMoves: ; 39301
-; Moves that are usable all-around.
-	db DOUBLE_EDGE
-	db SING
-	db FLAMETHROWER
-	db HYDRO_PUMP
-	db SURF
-	db ICE_BEAM
-	db BLIZZARD
-	db HYPER_BEAM
-	db SLEEP_POWDER
-	db THUNDERBOLT
-	db THUNDER
-	db EARTHQUAKE
-	db TOXIC
-	db PSYCHIC_M
-	db HYPNOSIS
-	db RECOVER
-	db FIRE_BLAST
-	db SOFTBOILED
-	db SUPER_FANG
-	db -1 ; end
-; 39315
+INCLUDE "data/battle/ai/useful_moves.asm"
 
 
 AI_Opportunist: ; 39315
@@ -3161,7 +3078,7 @@
 	push hl
 	push de
 	push bc
-	ld hl, .stallmoves
+	ld hl, StallMoves
 	ld de, 1
 	call IsInArray
 
@@ -3176,41 +3093,7 @@
 .asm_39347
 	ret
 
-.stallmoves
-	db SWORDS_DANCE
-	db TAIL_WHIP
-	db LEER
-	db GROWL
-	db DISABLE
-	db MIST
-	db COUNTER
-	db LEECH_SEED
-	db GROWTH
-	db STRING_SHOT
-	db MEDITATE
-	db AGILITY
-	db RAGE
-	db MIMIC
-	db SCREECH
-	db HARDEN
-	db WITHDRAW
-	db DEFENSE_CURL
-	db BARRIER
-	db LIGHT_SCREEN
-	db HAZE
-	db REFLECT
-	db FOCUS_ENERGY
-	db BIDE
-	db AMNESIA
-	db TRANSFORM
-	db SPLASH
-	db ACID_ARMOR
-	db SHARPEN
-	db CONVERSION
-	db SUBSTITUTE
-	db FLAME_WHEEL
-	db -1 ; end
-; 39369
+INCLUDE "data/battle/ai/stall_moves.asm"
 
 
 
@@ -3304,7 +3187,7 @@
 	push de
 	push bc
 	ld a, [wEnemyMoveStruct + MOVE_EFFECT]
-	ld hl, .RecklessMoves
+	ld hl, RecklessMoves
 	ld de, 1
 	call IsInArray
 	pop bc
@@ -3319,13 +3202,7 @@
 .done
 	ret
 
-.RecklessMoves:
-	db EFFECT_SELFDESTRUCT
-	db EFFECT_RAMPAGE
-	db EFFECT_MULTI_HIT
-	db EFFECT_DOUBLE_HIT
-	db -1 ; end
-; 393e7
+INCLUDE "data/battle/ai/reckless_moves.asm"
 
 
 AIDamageCalc: ; 393e7
@@ -3333,7 +3210,7 @@
 	ld [hBattleTurn], a
 	ld a, [wEnemyMoveStruct + MOVE_EFFECT]
 	ld de, 1
-	ld hl, .ConstantDamageEffects
+	ld hl, ConstantDamageEffects
 	call IsInArray
 	jr nc, .asm_39400
 	callfar BattleCommand_ConstantDamage
@@ -3345,13 +3222,7 @@
 	callfar BattleCommand_Stab
 	ret
 
-.ConstantDamageEffects:
-	db EFFECT_SUPER_FANG
-	db EFFECT_STATIC_DAMAGE
-	db EFFECT_LEVEL_DAMAGE
-	db EFFECT_PSYWAVE
-	db -1 ; end
-; 39418
+INCLUDE "data/battle/ai/constant_damage_effects.asm"
 
 
 AI_Cautious: ; 39418
@@ -3377,7 +3248,7 @@
 	push hl
 	push de
 	push bc
-	ld hl, .residualmoves
+	ld hl, ResidualMoves
 	ld de, 1
 	call IsInArray
 
@@ -3393,21 +3264,7 @@
 	inc [hl]
 	jr .asm_39425
 
-.residualmoves
-	db MIST
-	db LEECH_SEED
-	db POISONPOWDER
-	db STUN_SPORE
-	db THUNDER_WAVE
-	db FOCUS_ENERGY
-	db BIDE
-	db POISON_GAS
-	db TRANSFORM
-	db CONVERSION
-	db SUBSTITUTE
-	db SPIKES
-	db -1 ; end
-; 39453
+INCLUDE "data/battle/ai/residual_moves.asm"
 
 
 
@@ -3504,7 +3361,7 @@
 ; Don't use risky moves at max hp.
 	ld a, [wEnemyMoveStruct + MOVE_EFFECT]
 	ld de, 1
-	ld hl, .RiskyMoves
+	ld hl, RiskyEffects
 	call IsInArray
 	jr nc, .checkko
 
@@ -3541,11 +3398,7 @@
 	pop de
 	jr .checkmove
 
-.RiskyMoves:
-	db EFFECT_SELFDESTRUCT
-	db EFFECT_OHKO
-	db -1 ; end
-; 39502
+INCLUDE "data/battle/ai/risky_effects.asm"