From 061ea37b8d2161bc2f503588c19f5f77e69f7b7b Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Mon, 11 Nov 2024 22:29:51 +0000 Subject: [PATCH] Identify AI info in card data, rename AI score routines --- bugs_and_glitches.md | 4 +- src/constants/card_data_constants.asm | 14 +- src/data/cards.asm | 374 +++++++++++----------- src/data/duel/ai_trainer_card_logic.asm | 4 +- src/engine/duel/ai/attacks.asm | 60 ++-- src/engine/duel/ai/core.asm | 184 ++++++----- src/engine/duel/ai/damage_calculation.asm | 12 +- src/engine/duel/ai/energy.asm | 76 ++--- src/engine/duel/ai/hand_pokemon.asm | 65 ++-- src/engine/duel/ai/pkmn_powers.asm | 24 +- src/engine/duel/ai/retreat.asm | 158 ++++----- src/engine/duel/ai/special_attacks.asm | 26 +- src/engine/duel/ai/trainer_cards.asm | 4 +- src/engine/duel/core.asm | 14 +- src/home/duel.asm | 10 +- src/home/substatus.asm | 28 +- src/macros/wram.asm | 4 +- src/wram.asm | 25 +- 18 files changed, 562 insertions(+), 524 deletions(-) diff --git a/bugs_and_glitches.md b/bugs_and_glitches.md index 82e501bf..1da1b7bb 100644 --- a/bugs_and_glitches.md +++ b/bugs_and_glitches.md @@ -63,7 +63,7 @@ DetermineAIScoreOfAttackEnergyRequirement: jr nc, .check_evolution .atk_kos_defending ld a, 20 - call AddToAIScore + call AIEncourage -; this is possibly a bug. -; this is an identical check as above to test whether this card is active. @@ -72,7 +72,7 @@ DetermineAIScoreOfAttackEnergyRequirement: or a jr nz, .check_evolution ld a, 10 - call AddToAIScore + call AIEncourage ... ``` diff --git a/src/constants/card_data_constants.asm b/src/constants/card_data_constants.asm index 505c2239..7d94efdd 100644 --- a/src/constants/card_data_constants.asm +++ b/src/constants/card_data_constants.asm @@ -69,12 +69,12 @@ DEF CARD_DATA_WEAKNESS EQU $33 DEF CARD_DATA_RESISTANCE EQU $34 DEF CARD_DATA_CATEGORY EQU $35 DEF CARD_DATA_POKEDEX_NUMBER EQU $37 -DEF CARD_DATA_UNKNOWN1 EQU $38 +DEF CARD_DATA_UNUSED EQU $38 DEF CARD_DATA_LEVEL EQU $39 DEF CARD_DATA_LENGTH EQU $3a DEF CARD_DATA_WEIGHT EQU $3c DEF CARD_DATA_PKMN_DESCRIPTION EQU $3e -DEF CARD_DATA_UNKNOWN2 EQU $40 +DEF CARD_DATA_AI_INFO EQU $40 DEF PKMN_CARD_DATA_LENGTH EQU $41 @@ -251,3 +251,13 @@ DEF SECOND_ATTACK EQU $1 ; has limit on attached energy cards boost. DEF MAX_ENERGY_BOOST_IS_LIMITED EQU $2 DEF MAX_ENERGY_BOOST_IS_NOT_LIMITED EQU $3 + +; CARD_DATA_AI_INFO constants +DEF AI_INFO_BENCH_UTILITY EQU $1 +DEF AI_INFO_ENCOURAGE_EVO EQU $2 +DEF AI_INFO_UNK_03 EQU $3 +DEF AI_INFO_UNK_05 EQU $5 +DEF AI_INFO_UNK_08 EQU $8 + +DEF HAS_EVOLUTION_F EQU 4 +DEF HAS_EVOLUTION EQU 1 << HAS_EVOLUTION_F diff --git a/src/data/cards.asm b/src/data/cards.asm index ab8482b5..b9e65bb9 100644 --- a/src/data/cards.asm +++ b/src/data/cards.asm @@ -284,7 +284,7 @@ BulbasaurCard: db 2, 4 ; length dw 15 * 10 ; weight tx BulbasaurDescription ; description - db 16 + db HAS_EVOLUTION ; AI info IvysaurCard: db TYPE_PKMN_GRASS ; type @@ -335,7 +335,7 @@ IvysaurCard: db 3, 3 ; length dw 29 * 10 ; weight tx IvysaurDescription ; description - db 16 + db HAS_EVOLUTION ; AI info VenusaurLv64Card: db TYPE_PKMN_GRASS ; type @@ -386,7 +386,7 @@ VenusaurLv64Card: db 6, 7 ; length dw 221 * 10 ; weight tx VenusaurLv64Description ; description - db 0 + db 0 ; AI info VenusaurLv67Card: db TYPE_PKMN_GRASS ; type @@ -437,7 +437,7 @@ VenusaurLv67Card: db 6, 7 ; length dw 221 * 10 ; weight tx VenusaurLv67Description ; description - db 0 + db 0 ; AI info CaterpieCard: db TYPE_PKMN_GRASS ; type @@ -488,7 +488,7 @@ CaterpieCard: db 1, 0 ; length dw 6 * 10 ; weight tx CaterpieDescription ; description - db 19 + db AI_INFO_UNK_03 | HAS_EVOLUTION ; AI info MetapodCard: db TYPE_PKMN_GRASS ; type @@ -539,7 +539,7 @@ MetapodCard: db 2, 4 ; length dw 22 * 10 ; weight tx MetapodDescription ; description - db 16 + db HAS_EVOLUTION ; AI info ButterfreeCard: db TYPE_PKMN_GRASS ; type @@ -590,7 +590,7 @@ ButterfreeCard: db 3, 7 ; length dw 71 * 10 ; weight tx ButterfreeDescription ; description - db 0 + db 0 ; AI info WeedleCard: db TYPE_PKMN_GRASS ; type @@ -641,7 +641,7 @@ WeedleCard: db 1, 0 ; length dw 7 * 10 ; weight tx WeedleDescription ; description - db 19 + db AI_INFO_UNK_03 | HAS_EVOLUTION ; AI info KakunaCard: db TYPE_PKMN_GRASS ; type @@ -692,7 +692,7 @@ KakunaCard: db 2, 0 ; length dw 22 * 10 ; weight tx KakunaDescription ; description - db 16 + db HAS_EVOLUTION ; AI info BeedrillCard: db TYPE_PKMN_GRASS ; type @@ -743,7 +743,7 @@ BeedrillCard: db 3, 3 ; length dw 65 * 10 ; weight tx BeedrillDescription ; description - db 0 + db 0 ; AI info EkansCard: db TYPE_PKMN_GRASS ; type @@ -794,7 +794,7 @@ EkansCard: db 6, 7 ; length dw 15 * 10 ; weight tx EkansDescription ; description - db 19 + db AI_INFO_UNK_03 | HAS_EVOLUTION ; AI info ArbokCard: db TYPE_PKMN_GRASS ; type @@ -845,7 +845,7 @@ ArbokCard: db 11, 6 ; length dw 143 * 10 ; weight tx ArbokDescription ; description - db 0 + db 0 ; AI info NidoranFCard: db TYPE_PKMN_GRASS ; type @@ -896,7 +896,7 @@ NidoranFCard: db 1, 4 ; length dw 15 * 10 ; weight tx NidoranFDescription ; description - db 19 + db AI_INFO_UNK_03 | HAS_EVOLUTION ; AI info NidorinaCard: db TYPE_PKMN_GRASS ; type @@ -947,7 +947,7 @@ NidorinaCard: db 2, 7 ; length dw 44 * 10 ; weight tx NidorinaDescription ; description - db 16 + db HAS_EVOLUTION ; AI info NidoqueenCard: db TYPE_PKMN_GRASS ; type @@ -998,7 +998,7 @@ NidoqueenCard: db 4, 3 ; length dw 132 * 10 ; weight tx NidoqueenDescription ; description - db 0 + db 0 ; AI info NidoranMCard: db TYPE_PKMN_GRASS ; type @@ -1049,7 +1049,7 @@ NidoranMCard: db 1, 4 ; length dw 15 * 10 ; weight tx NidoranMDescription ; description - db 19 + db AI_INFO_UNK_03 | HAS_EVOLUTION ; AI info NidorinoCard: db TYPE_PKMN_GRASS ; type @@ -1100,7 +1100,7 @@ NidorinoCard: db 2, 11 ; length dw 43 * 10 ; weight tx NidorinoDescription ; description - db 16 + db HAS_EVOLUTION ; AI info NidokingCard: db TYPE_PKMN_GRASS ; type @@ -1151,7 +1151,7 @@ NidokingCard: db 4, 7 ; length dw 137 * 10 ; weight tx NidokingDescription ; description - db 0 + db 0 ; AI info ZubatCard: db TYPE_PKMN_GRASS ; type @@ -1202,7 +1202,7 @@ ZubatCard: db 2, 7 ; length dw 17 * 10 ; weight tx ZubatDescription ; description - db 16 + db HAS_EVOLUTION ; AI info GolbatCard: db TYPE_PKMN_GRASS ; type @@ -1253,7 +1253,7 @@ GolbatCard: db 5, 3 ; length dw 121 * 10 ; weight tx GolbatDescription ; description - db 0 + db 0 ; AI info OddishCard: db TYPE_PKMN_GRASS ; type @@ -1304,7 +1304,7 @@ OddishCard: db 1, 8 ; length dw 12 * 10 ; weight tx OddishDescription ; description - db 16 + db HAS_EVOLUTION ; AI info GloomCard: db TYPE_PKMN_GRASS ; type @@ -1355,7 +1355,7 @@ GloomCard: db 2, 7 ; length dw 19 * 10 ; weight tx GloomDescription ; description - db 16 + db HAS_EVOLUTION ; AI info VileplumeCard: db TYPE_PKMN_GRASS ; type @@ -1406,7 +1406,7 @@ VileplumeCard: db 3, 11 ; length dw 41 * 10 ; weight tx VileplumeDescription ; description - db 0 + db 0 ; AI info ParasCard: db TYPE_PKMN_GRASS ; type @@ -1457,7 +1457,7 @@ ParasCard: db 1, 0 ; length dw 12 * 10 ; weight tx ParasDescription ; description - db 16 + db HAS_EVOLUTION ; AI info ParasectCard: db TYPE_PKMN_GRASS ; type @@ -1508,7 +1508,7 @@ ParasectCard: db 3, 3 ; length dw 65 * 10 ; weight tx ParasectDescription ; description - db 0 + db 0 ; AI info VenonatCard: db TYPE_PKMN_GRASS ; type @@ -1559,7 +1559,7 @@ VenonatCard: db 3, 3 ; length dw 66 * 10 ; weight tx VenonatDescription ; description - db 19 + db AI_INFO_UNK_03 | HAS_EVOLUTION ; AI info VenomothCard: db TYPE_PKMN_GRASS ; type @@ -1610,7 +1610,7 @@ VenomothCard: db 4, 11 ; length dw 28 * 10 ; weight tx VenomothDescription ; description - db 0 + db 0 ; AI info BellsproutCard: db TYPE_PKMN_GRASS ; type @@ -1661,7 +1661,7 @@ BellsproutCard: db 2, 4 ; length dw 9 * 10 ; weight tx BellsproutDescription ; description - db 19 + db AI_INFO_UNK_03 | HAS_EVOLUTION ; AI info WeepinbellCard: db TYPE_PKMN_GRASS ; type @@ -1712,7 +1712,7 @@ WeepinbellCard: db 3, 3 ; length dw 14 * 10 ; weight tx WeepinbellDescription ; description - db 16 + db HAS_EVOLUTION ; AI info VictreebelCard: db TYPE_PKMN_GRASS ; type @@ -1763,7 +1763,7 @@ VictreebelCard: db 5, 7 ; length dw 34 * 10 ; weight tx VictreebelDescription ; description - db 0 + db 0 ; AI info GrimerCard: db TYPE_PKMN_GRASS ; type @@ -1814,7 +1814,7 @@ GrimerCard: db 2, 11 ; length dw 66 * 10 ; weight tx GrimerDescription ; description - db 19 + db AI_INFO_UNK_03 | HAS_EVOLUTION ; AI info MukCard: db TYPE_PKMN_GRASS ; type @@ -1865,7 +1865,7 @@ MukCard: db 3, 11 ; length dw 66 * 10 ; weight tx MukDescription ; description - db 0 + db 0 ; AI info ExeggcuteCard: db TYPE_PKMN_GRASS ; type @@ -1916,7 +1916,7 @@ ExeggcuteCard: db 1, 4 ; length dw 6 * 10 ; weight tx ExeggcuteDescription ; description - db 18 + db AI_INFO_ENCOURAGE_EVO | HAS_EVOLUTION ; AI info ExeggutorCard: db TYPE_PKMN_GRASS ; type @@ -1967,7 +1967,7 @@ ExeggutorCard: db 6, 7 ; length dw 265 * 10 ; weight tx ExeggutorDescription ; description - db 0 + db 0 ; AI info KoffingCard: db TYPE_PKMN_GRASS ; type @@ -2018,7 +2018,7 @@ KoffingCard: db 2, 0 ; length dw 2 * 10 ; weight tx KoffingDescription ; description - db 16 + db HAS_EVOLUTION ; AI info WeezingCard: db TYPE_PKMN_GRASS ; type @@ -2069,7 +2069,7 @@ WeezingCard: db 3, 11 ; length dw 21 * 10 ; weight tx WeezingDescription ; description - db 0 + db 0 ; AI info TangelaLv8Card: db TYPE_PKMN_GRASS ; type @@ -2120,7 +2120,7 @@ TangelaLv8Card: db 3, 3 ; length dw 77 * 10 ; weight tx TangelaLv8Description ; description - db 0 + db 0 ; AI info TangelaLv12Card: db TYPE_PKMN_GRASS ; type @@ -2171,7 +2171,7 @@ TangelaLv12Card: db 3, 3 ; length dw 77 * 10 ; weight tx TangelaLv12Description ; description - db 0 + db 0 ; AI info ScytherCard: db TYPE_PKMN_GRASS ; type @@ -2222,7 +2222,7 @@ ScytherCard: db 4, 11 ; length dw 123 * 10 ; weight tx ScytherDescription ; description - db 0 + db 0 ; AI info PinsirCard: db TYPE_PKMN_GRASS ; type @@ -2273,7 +2273,7 @@ PinsirCard: db 4, 11 ; length dw 121 * 10 ; weight tx PinsirDescription ; description - db 0 + db 0 ; AI info CharmanderCard: db TYPE_PKMN_FIRE ; type @@ -2324,7 +2324,7 @@ CharmanderCard: db 2, 0 ; length dw 19 * 10 ; weight tx CharmanderDescription ; description - db 21 + db AI_INFO_UNK_05 | HAS_EVOLUTION ; AI info CharmeleonCard: db TYPE_PKMN_FIRE ; type @@ -2375,7 +2375,7 @@ CharmeleonCard: db 3, 7 ; length dw 42 * 10 ; weight tx CharmeleonDescription ; description - db 18 + db AI_INFO_ENCOURAGE_EVO | HAS_EVOLUTION ; AI info CharizardCard: db TYPE_PKMN_FIRE ; type @@ -2426,7 +2426,7 @@ CharizardCard: db 5, 7 ; length dw 200 * 10 ; weight tx CharizardDescription ; description - db 0 + db 0 ; AI info VulpixCard: db TYPE_PKMN_FIRE ; type @@ -2477,7 +2477,7 @@ VulpixCard: db 2, 0 ; length dw 22 * 10 ; weight tx VulpixDescription ; description - db 18 + db AI_INFO_ENCOURAGE_EVO | HAS_EVOLUTION ; AI info NinetalesLv32Card: db TYPE_PKMN_FIRE ; type @@ -2528,7 +2528,7 @@ NinetalesLv32Card: db 3, 7 ; length dw 44 * 10 ; weight tx NinetalesLv32Description ; description - db 0 + db 0 ; AI info NinetalesLv35Card: db TYPE_PKMN_FIRE ; type @@ -2579,7 +2579,7 @@ NinetalesLv35Card: db 3, 7 ; length dw 44 * 10 ; weight tx NinetalesLv35Description ; description - db 0 + db 0 ; AI info GrowlitheCard: db TYPE_PKMN_FIRE ; type @@ -2630,7 +2630,7 @@ GrowlitheCard: db 2, 4 ; length dw 42 * 10 ; weight tx GrowlitheDescription ; description - db 16 + db HAS_EVOLUTION ; AI info ArcanineLv34Card: db TYPE_PKMN_FIRE ; type @@ -2681,7 +2681,7 @@ ArcanineLv34Card: db 6, 3 ; length dw 342 * 10 ; weight tx ArcanineLv34Description ; description - db 0 + db 0 ; AI info ArcanineLv45Card: db TYPE_PKMN_FIRE ; type @@ -2732,7 +2732,7 @@ ArcanineLv45Card: db 6, 3 ; length dw 342 * 10 ; weight tx ArcanineLv45Description ; description - db 0 + db 0 ; AI info PonytaCard: db TYPE_PKMN_FIRE ; type @@ -2783,7 +2783,7 @@ PonytaCard: db 3, 3 ; length dw 66 * 10 ; weight tx PonytaDescription ; description - db 16 + db HAS_EVOLUTION ; AI info RapidashCard: db TYPE_PKMN_FIRE ; type @@ -2834,7 +2834,7 @@ RapidashCard: db 5, 7 ; length dw 209 * 10 ; weight tx RapidashDescription ; description - db 0 + db 0 ; AI info MagmarLv24Card: db TYPE_PKMN_FIRE ; type @@ -2885,7 +2885,7 @@ MagmarLv24Card: db 4, 3 ; length dw 98 * 10 ; weight tx MagmarLv24Description ; description - db 0 + db 0 ; AI info MagmarLv31Card: db TYPE_PKMN_FIRE ; type @@ -2936,7 +2936,7 @@ MagmarLv31Card: db 4, 3 ; length dw 98 * 10 ; weight tx MagmarLv31Description ; description - db 3 + db AI_INFO_UNK_03 ; AI info FlareonLv22Card: db TYPE_PKMN_FIRE ; type @@ -2987,7 +2987,7 @@ FlareonLv22Card: db 2, 11 ; length dw 55 * 10 ; weight tx FlareonLv22Description ; description - db 0 + db 0 ; AI info FlareonLv28Card: db TYPE_PKMN_FIRE ; type @@ -3038,7 +3038,7 @@ FlareonLv28Card: db 2, 11 ; length dw 55 * 10 ; weight tx FlareonLv28Description ; description - db 0 + db 0 ; AI info MoltresLv35Card: db TYPE_PKMN_FIRE ; type @@ -3089,7 +3089,7 @@ MoltresLv35Card: db 6, 7 ; length dw 132 * 10 ; weight tx MoltresLv35Description ; description - db 0 + db 0 ; AI info MoltresLv37Card: db TYPE_PKMN_FIRE ; type @@ -3140,7 +3140,7 @@ MoltresLv37Card: db 6, 7 ; length dw 132 * 10 ; weight tx MoltresLv37Description ; description - db 0 + db 0 ; AI info SquirtleCard: db TYPE_PKMN_WATER ; type @@ -3191,7 +3191,7 @@ SquirtleCard: db 1, 8 ; length dw 20 * 10 ; weight tx SquirtleDescription ; description - db 21 + db AI_INFO_UNK_05 | HAS_EVOLUTION ; AI info WartortleCard: db TYPE_PKMN_WATER ; type @@ -3242,7 +3242,7 @@ WartortleCard: db 3, 3 ; length dw 50 * 10 ; weight tx WartortleDescription ; description - db 18 + db AI_INFO_ENCOURAGE_EVO | HAS_EVOLUTION ; AI info BlastoiseCard: db TYPE_PKMN_WATER ; type @@ -3293,7 +3293,7 @@ BlastoiseCard: db 5, 3 ; length dw 189 * 10 ; weight tx BlastoiseDescription ; description - db 0 + db 0 ; AI info PsyduckCard: db TYPE_PKMN_WATER ; type @@ -3344,7 +3344,7 @@ PsyduckCard: db 2, 7 ; length dw 43 * 10 ; weight tx PsyduckDescription ; description - db 19 + db AI_INFO_UNK_03 | HAS_EVOLUTION ; AI info GolduckCard: db TYPE_PKMN_WATER ; type @@ -3395,7 +3395,7 @@ GolduckCard: db 5, 7 ; length dw 169 * 10 ; weight tx GolduckDescription ; description - db 3 + db AI_INFO_UNK_03 ; AI info PoliwagCard: db TYPE_PKMN_WATER ; type @@ -3446,7 +3446,7 @@ PoliwagCard: db 2, 0 ; length dw 27 * 10 ; weight tx PoliwagDescription ; description - db 19 + db AI_INFO_UNK_03 | HAS_EVOLUTION ; AI info PoliwhirlCard: db TYPE_PKMN_WATER ; type @@ -3497,7 +3497,7 @@ PoliwhirlCard: db 3, 4 ; length dw 44 * 10 ; weight tx PoliwhirlsDescription ; description - db 16 + db HAS_EVOLUTION ; AI info PoliwrathCard: db TYPE_PKMN_WATER ; type @@ -3548,7 +3548,7 @@ PoliwrathCard: db 4, 3 ; length dw 119 * 10 ; weight tx PoliwrathDescription ; description - db 0 + db 0 ; AI info TentacoolCard: db TYPE_PKMN_WATER ; type @@ -3599,7 +3599,7 @@ TentacoolCard: db 2, 11 ; length dw 100 * 10 ; weight tx TentacoolDescription ; description - db 19 + db AI_INFO_UNK_03 | HAS_EVOLUTION ; AI info TentacruelCard: db TYPE_PKMN_WATER ; type @@ -3650,7 +3650,7 @@ TentacruelCard: db 5, 3 ; length dw 121 * 10 ; weight tx TentacruelDescription ; description - db 0 + db 0 ; AI info SeelCard: db TYPE_PKMN_WATER ; type @@ -3701,7 +3701,7 @@ SeelCard: db 3, 7 ; length dw 198 * 10 ; weight tx SeelDescription ; description - db 19 + db AI_INFO_UNK_03 | HAS_EVOLUTION ; AI info DewgongCard: db TYPE_PKMN_WATER ; type @@ -3752,7 +3752,7 @@ DewgongCard: db 5, 7 ; length dw 265 * 10 ; weight tx DewgongDescription ; description - db 0 + db 0 ; AI info ShellderCard: db TYPE_PKMN_WATER ; type @@ -3803,7 +3803,7 @@ ShellderCard: db 1, 0 ; length dw 9 * 10 ; weight tx ShellderDescription ; description - db 19 + db AI_INFO_UNK_03 | HAS_EVOLUTION ; AI info CloysterCard: db TYPE_PKMN_WATER ; type @@ -3854,7 +3854,7 @@ CloysterCard: db 4, 11 ; length dw 292 * 10 ; weight tx CloysterDescription ; description - db 0 + db 0 ; AI info KrabbyCard: db TYPE_PKMN_WATER ; type @@ -3905,7 +3905,7 @@ KrabbyCard: db 1, 4 ; length dw 14 * 10 ; weight tx KrabbyDescription ; description - db 16 + db HAS_EVOLUTION ; AI info KinglerCard: db TYPE_PKMN_WATER ; type @@ -3956,7 +3956,7 @@ KinglerCard: db 4, 3 ; length dw 132 * 10 ; weight tx KinglerDescription ; description - db 0 + db 0 ; AI info HorseaCard: db TYPE_PKMN_WATER ; type @@ -4007,7 +4007,7 @@ HorseaCard: db 1, 4 ; length dw 18 * 10 ; weight tx HorseaDescription ; description - db 19 + db AI_INFO_UNK_03 | HAS_EVOLUTION ; AI info SeadraCard: db TYPE_PKMN_WATER ; type @@ -4058,7 +4058,7 @@ SeadraCard: db 3, 1 ; length dw 55 * 10 ; weight tx SeadraDescription ; description - db 0 + db 0 ; AI info GoldeenCard: db TYPE_PKMN_WATER ; type @@ -4109,7 +4109,7 @@ GoldeenCard: db 2, 0 ; length dw 33 * 10 ; weight tx GoldeenDescription ; description - db 21 + db AI_INFO_UNK_05 | HAS_EVOLUTION ; AI info SeakingCard: db TYPE_PKMN_WATER ; type @@ -4160,7 +4160,7 @@ SeakingCard: db 4, 3 ; length dw 86 * 10 ; weight tx SeakingDescription ; description - db 0 + db 0 ; AI info StaryuCard: db TYPE_PKMN_WATER ; type @@ -4211,7 +4211,7 @@ StaryuCard: db 2, 7 ; length dw 76 * 10 ; weight tx StaryuDescription ; description - db 19 + db AI_INFO_UNK_03 | HAS_EVOLUTION ; AI info StarmieCard: db TYPE_PKMN_WATER ; type @@ -4262,7 +4262,7 @@ StarmieCard: db 3, 7 ; length dw 176 * 10 ; weight tx StarmieDescription ; description - db 0 + db 0 ; AI info MagikarpCard: db TYPE_PKMN_WATER ; type @@ -4313,7 +4313,7 @@ MagikarpCard: db 2, 11 ; length dw 22 * 10 ; weight tx MagikarpDescription ; description - db 18 + db AI_INFO_ENCOURAGE_EVO | HAS_EVOLUTION ; AI info GyaradosCard: db TYPE_PKMN_WATER ; type @@ -4364,7 +4364,7 @@ GyaradosCard: db 21, 4 ; length dw 518 * 10 ; weight tx GyaradosDescription ; description - db 0 + db 0 ; AI info LaprasCard: db TYPE_PKMN_WATER ; type @@ -4415,7 +4415,7 @@ LaprasCard: db 8, 2 ; length dw 485 * 10 ; weight tx LaprasDescription ; description - db 0 + db 0 ; AI info VaporeonLv29Card: db TYPE_PKMN_WATER ; type @@ -4466,7 +4466,7 @@ VaporeonLv29Card: db 3, 3 ; length dw 64 * 10 ; weight tx VaporeonLv29Description ; description - db 0 + db 0 ; AI info VaporeonLv42Card: db TYPE_PKMN_WATER ; type @@ -4517,7 +4517,7 @@ VaporeonLv42Card: db 3, 3 ; length dw 64 * 10 ; weight tx VaporeonLv42Description ; description - db 0 + db 0 ; AI info OmanyteCard: db TYPE_PKMN_WATER ; type @@ -4568,7 +4568,7 @@ OmanyteCard: db 1, 4 ; length dw 17 * 10 ; weight tx OmanyteDescription ; description - db 17 + db AI_INFO_BENCH_UTILITY | HAS_EVOLUTION ; AI info OmastarCard: db TYPE_PKMN_WATER ; type @@ -4619,7 +4619,7 @@ OmastarCard: db 3, 3 ; length dw 77 * 10 ; weight tx OmastarDescription ; description - db 0 + db 0 ; AI info ArticunoLv35Card: db TYPE_PKMN_WATER ; type @@ -4670,7 +4670,7 @@ ArticunoLv35Card: db 5, 7 ; length dw 122 * 10 ; weight tx ArticunoLv35Description ; description - db 0 + db 0 ; AI info ArticunoLv37Card: db TYPE_PKMN_WATER ; type @@ -4721,7 +4721,7 @@ ArticunoLv37Card: db 5, 7 ; length dw 122 * 10 ; weight tx ArticunoLv37Description ; description - db 0 + db 0 ; AI info PikachuLv12Card: db TYPE_PKMN_LIGHTNING ; type @@ -4772,7 +4772,7 @@ PikachuLv12Card: db 1, 4 ; length dw 13 * 10 ; weight tx PikachuLv12Description ; description - db 19 + db AI_INFO_UNK_03 | HAS_EVOLUTION ; AI info PikachuLv14Card: db TYPE_PKMN_LIGHTNING ; type @@ -4823,7 +4823,7 @@ PikachuLv14Card: db 1, 4 ; length dw 13 * 10 ; weight tx PikachuLv14Description ; description - db 16 + db HAS_EVOLUTION ; AI info PikachuLv16Card: db TYPE_PKMN_LIGHTNING ; type @@ -4874,7 +4874,7 @@ PikachuLv16Card: db 1, 4 ; length dw 13 * 10 ; weight tx PikachuLv16Description ; description - db 16 + db HAS_EVOLUTION ; AI info PikachuAltLv16Card: db TYPE_PKMN_LIGHTNING ; type @@ -4925,7 +4925,7 @@ PikachuAltLv16Card: db 1, 4 ; length dw 13 * 10 ; weight tx PikachuLv16Description ; description - db 16 + db HAS_EVOLUTION ; AI info FlyingPikachuCard: db TYPE_PKMN_LIGHTNING ; type @@ -4976,7 +4976,7 @@ FlyingPikachuCard: db 1, 4 ; length dw 13 * 10 ; weight tx FlyingPikachuDescription ; description - db 3 + db AI_INFO_UNK_03 ; AI info SurfingPikachuLv13Card: db TYPE_PKMN_LIGHTNING ; type @@ -5027,7 +5027,7 @@ SurfingPikachuLv13Card: db 1, 4 ; length dw 13 * 10 ; weight tx SurfingPikachuDescription ; description - db 0 + db 0 ; AI info SurfingPikachuAltLv13Card: db TYPE_PKMN_LIGHTNING ; type @@ -5078,7 +5078,7 @@ SurfingPikachuAltLv13Card: db 1, 4 ; length dw 13 * 10 ; weight tx SurfingPikachuDescription ; description - db 0 + db 0 ; AI info RaichuLv40Card: db TYPE_PKMN_LIGHTNING ; type @@ -5129,7 +5129,7 @@ RaichuLv40Card: db 2, 7 ; length dw 66 * 10 ; weight tx RaichuLv40Description ; description - db 0 + db 0 ; AI info RaichuLv45Card: db TYPE_PKMN_LIGHTNING ; type @@ -5180,7 +5180,7 @@ RaichuLv45Card: db 2, 7 ; length dw 66 * 10 ; weight tx RaichuLv45Description ; description - db 0 + db 0 ; AI info MagnemiteLv13Card: db TYPE_PKMN_LIGHTNING ; type @@ -5231,7 +5231,7 @@ MagnemiteLv13Card: db 1, 0 ; length dw 13 * 10 ; weight tx MagnemiteLv13Description ; description - db 19 + db AI_INFO_UNK_03 | HAS_EVOLUTION ; AI info MagnemiteLv15Card: db TYPE_PKMN_LIGHTNING ; type @@ -5282,7 +5282,7 @@ MagnemiteLv15Card: db 1, 0 ; length dw 13 * 10 ; weight tx MagnemiteLv15Description ; description - db 19 + db AI_INFO_UNK_03 | HAS_EVOLUTION ; AI info MagnetonLv28Card: db TYPE_PKMN_LIGHTNING ; type @@ -5333,7 +5333,7 @@ MagnetonLv28Card: db 3, 3 ; length dw 132 * 10 ; weight tx MagnetonLv28Description ; description - db 0 + db 0 ; AI info MagnetonLv35Card: db TYPE_PKMN_LIGHTNING ; type @@ -5384,7 +5384,7 @@ MagnetonLv35Card: db 3, 3 ; length dw 132 * 10 ; weight tx MagnetonLv35Description ; description - db 0 + db 0 ; AI info VoltorbCard: db TYPE_PKMN_LIGHTNING ; type @@ -5435,7 +5435,7 @@ VoltorbCard: db 1, 8 ; length dw 23 * 10 ; weight tx VoltorbDescription ; description - db 21 + db AI_INFO_UNK_05 | HAS_EVOLUTION ; AI info ElectrodeLv35Card: db TYPE_PKMN_LIGHTNING ; type @@ -5486,7 +5486,7 @@ ElectrodeLv35Card: db 3, 11 ; length dw 147 * 10 ; weight tx ElectrodeLv35Description ; description - db 0 + db 0 ; AI info ElectrodeLv42Card: db TYPE_PKMN_LIGHTNING ; type @@ -5537,7 +5537,7 @@ ElectrodeLv42Card: db 3, 11 ; length dw 147 * 10 ; weight tx ElectrodeLv42Description ; description - db 0 + db 0 ; AI info ElectabuzzLv20Card: db TYPE_PKMN_LIGHTNING ; type @@ -5588,7 +5588,7 @@ ElectabuzzLv20Card: db 3, 7 ; length dw 66 * 10 ; weight tx ElectabuzzLv20Description ; description - db 0 + db 0 ; AI info ElectabuzzLv35Card: db TYPE_PKMN_LIGHTNING ; type @@ -5639,7 +5639,7 @@ ElectabuzzLv35Card: db 3, 7 ; length dw 66 * 10 ; weight tx ElectabuzzLv35Description ; description - db 0 + db 0 ; AI info JolteonLv24Card: db TYPE_PKMN_LIGHTNING ; type @@ -5690,7 +5690,7 @@ JolteonLv24Card: db 2, 7 ; length dw 54 * 10 ; weight tx JolteonLv24Description ; description - db 0 + db 0 ; AI info JolteonLv29Card: db TYPE_PKMN_LIGHTNING ; type @@ -5741,7 +5741,7 @@ JolteonLv29Card: db 2, 7 ; length dw 54 * 10 ; weight tx JolteonLv29Description ; description - db 0 + db 0 ; AI info ZapdosLv40Card: db TYPE_PKMN_LIGHTNING ; type @@ -5792,7 +5792,7 @@ ZapdosLv40Card: db 5, 3 ; length dw 116 * 10 ; weight tx ZapdosLv40Description ; description - db 0 + db 0 ; AI info ZapdosLv64Card: db TYPE_PKMN_LIGHTNING ; type @@ -5843,7 +5843,7 @@ ZapdosLv64Card: db 5, 3 ; length dw 116 * 10 ; weight tx ZapdosLv64Description ; description - db 0 + db 0 ; AI info ZapdosLv68Card: db TYPE_PKMN_LIGHTNING ; type @@ -5894,7 +5894,7 @@ ZapdosLv68Card: db 5, 3 ; length dw 116 * 10 ; weight tx ZapdosLv68Description ; description - db 0 + db 0 ; AI info SandshrewCard: db TYPE_PKMN_FIGHTING ; type @@ -5945,7 +5945,7 @@ SandshrewCard: db 2, 0 ; length dw 26 * 10 ; weight tx SandshrewDescription ; description - db 19 + db AI_INFO_UNK_03 | HAS_EVOLUTION ; AI info SandslashCard: db TYPE_PKMN_FIGHTING ; type @@ -5996,7 +5996,7 @@ SandslashCard: db 3, 3 ; length dw 65 * 10 ; weight tx SandslashDescription ; description - db 0 + db 0 ; AI info DiglettCard: db TYPE_PKMN_FIGHTING ; type @@ -6047,7 +6047,7 @@ DiglettCard: db 0, 8 ; length dw 2 * 10 ; weight tx DiglettDescription ; description - db 19 + db AI_INFO_UNK_03 | HAS_EVOLUTION ; AI info DugtrioCard: db TYPE_PKMN_FIGHTING ; type @@ -6098,7 +6098,7 @@ DugtrioCard: db 2, 4 ; length dw 73 * 10 ; weight tx DugtrioDescription ; description - db 0 + db 0 ; AI info MankeyCard: db TYPE_PKMN_FIGHTING ; type @@ -6149,7 +6149,7 @@ MankeyCard: db 1, 8 ; length dw 62 * 10 ; weight tx MankeyDescription ; description - db 17 + db AI_INFO_BENCH_UTILITY | HAS_EVOLUTION ; AI info PrimeapeCard: db TYPE_PKMN_FIGHTING ; type @@ -6200,7 +6200,7 @@ PrimeapeCard: db 3, 3 ; length dw 71 * 10 ; weight tx PrimeapeDescription ; description - db 0 + db 0 ; AI info MachopCard: db TYPE_PKMN_FIGHTING ; type @@ -6251,7 +6251,7 @@ MachopCard: db 2, 7 ; length dw 43 * 10 ; weight tx MachopDescription ; description - db 21 + db AI_INFO_UNK_05 | HAS_EVOLUTION ; AI info MachokeCard: db TYPE_PKMN_FIGHTING ; type @@ -6302,7 +6302,7 @@ MachokeCard: db 4, 11 ; length dw 155 * 10 ; weight tx MachokeDescription ; description - db 16 + db HAS_EVOLUTION ; AI info MachampCard: db TYPE_PKMN_FIGHTING ; type @@ -6353,7 +6353,7 @@ MachampCard: db 5, 3 ; length dw 287 * 10 ; weight tx MachampDescription ; description - db 0 + db 0 ; AI info GeodudeCard: db TYPE_PKMN_FIGHTING ; type @@ -6404,7 +6404,7 @@ GeodudeCard: db 1, 4 ; length dw 44 * 10 ; weight tx GeodudeDescription ; description - db 19 + db AI_INFO_UNK_03 | HAS_EVOLUTION ; AI info GravelerCard: db TYPE_PKMN_FIGHTING ; type @@ -6455,7 +6455,7 @@ GravelerCard: db 3, 3 ; length dw 232 * 10 ; weight tx GravelerDescription ; description - db 16 + db HAS_EVOLUTION ; AI info GolemCard: db TYPE_PKMN_FIGHTING ; type @@ -6506,7 +6506,7 @@ GolemCard: db 4, 7 ; length dw 662 * 10 ; weight tx GolemDescription ; description - db 0 + db 0 ; AI info OnixCard: db TYPE_PKMN_FIGHTING ; type @@ -6557,7 +6557,7 @@ OnixCard: db 28, 10 ; length dw 463 * 10 ; weight tx OnixDescription ; description - db 0 + db 0 ; AI info CuboneCard: db TYPE_PKMN_FIGHTING ; type @@ -6608,7 +6608,7 @@ CuboneCard: db 1, 4 ; length dw 14 * 10 ; weight tx CuboneDescription ; description - db 19 + db AI_INFO_UNK_03 | HAS_EVOLUTION ; AI info MarowakLv26Card: db TYPE_PKMN_FIGHTING ; type @@ -6659,7 +6659,7 @@ MarowakLv26Card: db 3, 3 ; length dw 99 * 10 ; weight tx MarowakLv26Description ; description - db 0 + db 0 ; AI info MarowakLv32Card: db TYPE_PKMN_FIGHTING ; type @@ -6710,7 +6710,7 @@ MarowakLv32Card: db 3, 3 ; length dw 99 * 10 ; weight tx MarowakLv32Description ; description - db 0 + db 0 ; AI info HitmonleeCard: db TYPE_PKMN_FIGHTING ; type @@ -6761,7 +6761,7 @@ HitmonleeCard: db 4, 11 ; length dw 110 * 10 ; weight tx HitmonleeDescription ; description - db 0 + db 0 ; AI info HitmonchanCard: db TYPE_PKMN_FIGHTING ; type @@ -6812,7 +6812,7 @@ HitmonchanCard: db 4, 7 ; length dw 111 * 10 ; weight tx HitmonchanDescription ; description - db 0 + db 0 ; AI info RhyhornCard: db TYPE_PKMN_FIGHTING ; type @@ -6863,7 +6863,7 @@ RhyhornCard: db 3, 3 ; length dw 254 * 10 ; weight tx RhyhornDescription ; description - db 16 + db HAS_EVOLUTION ; AI info RhydonCard: db TYPE_PKMN_FIGHTING ; type @@ -6914,7 +6914,7 @@ RhydonCard: db 6, 3 ; length dw 265 * 10 ; weight tx RhydonDescription ; description - db 0 + db 0 ; AI info KabutoCard: db TYPE_PKMN_FIGHTING ; type @@ -6965,7 +6965,7 @@ KabutoCard: db 1, 8 ; length dw 25 * 10 ; weight tx KabutoDescription ; description - db 19 + db AI_INFO_UNK_03 | HAS_EVOLUTION ; AI info KabutopsCard: db TYPE_PKMN_FIGHTING ; type @@ -7016,7 +7016,7 @@ KabutopsCard: db 4, 3 ; length dw 89 * 10 ; weight tx KabutopsDescription ; description - db 0 + db 0 ; AI info AerodactylCard: db TYPE_PKMN_FIGHTING ; type @@ -7067,7 +7067,7 @@ AerodactylCard: db 5, 11 ; length dw 130 * 10 ; weight tx AerodactylDescription ; description - db 1 + db AI_INFO_BENCH_UTILITY ; AI info AbraCard: db TYPE_PKMN_PSYCHIC ; type @@ -7118,7 +7118,7 @@ AbraCard: db 2, 11 ; length dw 43 * 10 ; weight tx AbraDescription ; description - db 16 + db HAS_EVOLUTION ; AI info KadabraCard: db TYPE_PKMN_PSYCHIC ; type @@ -7169,7 +7169,7 @@ KadabraCard: db 4, 3 ; length dw 125 * 10 ; weight tx KadabraDescription ; description - db 16 + db HAS_EVOLUTION ; AI info AlakazamCard: db TYPE_PKMN_PSYCHIC ; type @@ -7220,7 +7220,7 @@ AlakazamCard: db 4, 11 ; length dw 106 * 10 ; weight tx AlakazamDescription ; description - db 0 + db 0 ; AI info SlowpokeLv9Card: db TYPE_PKMN_PSYCHIC ; type @@ -7271,7 +7271,7 @@ SlowpokeLv9Card: db 3, 11 ; length dw 79 * 10 ; weight tx SlowpokeLv9Description ; description - db 19 + db AI_INFO_UNK_03 | HAS_EVOLUTION ; AI info SlowpokeLv18Card: db TYPE_PKMN_PSYCHIC ; type @@ -7322,7 +7322,7 @@ SlowpokeLv18Card: db 3, 11 ; length dw 79 * 10 ; weight tx SlowpokeLv9Description ; description - db 16 + db HAS_EVOLUTION ; AI info SlowbroCard: db TYPE_PKMN_PSYCHIC ; type @@ -7373,7 +7373,7 @@ SlowbroCard: db 5, 3 ; length dw 173 * 10 ; weight tx SlowbroDescription ; description - db 1 + db AI_INFO_BENCH_UTILITY ; AI info GastlyLv8Card: db TYPE_PKMN_PSYCHIC ; type @@ -7424,7 +7424,7 @@ GastlyLv8Card: db 4, 3 ; length dw 2 ; weight tx GastlyLv8Description ; description - db 16 + db HAS_EVOLUTION ; AI info GastlyLv17Card: db TYPE_PKMN_PSYCHIC ; type @@ -7475,7 +7475,7 @@ GastlyLv17Card: db 4, 3 ; length dw 2 ; weight tx GastlyLv17Description ; description - db 19 + db AI_INFO_UNK_03 | HAS_EVOLUTION ; AI info HaunterLv17Card: db TYPE_PKMN_PSYCHIC ; type @@ -7526,7 +7526,7 @@ HaunterLv17Card: db 5, 3 ; length dw 2 ; weight tx HaunterDescription ; description - db 16 + db HAS_EVOLUTION ; AI info HaunterLv22Card: db TYPE_PKMN_PSYCHIC ; type @@ -7577,7 +7577,7 @@ HaunterLv22Card: db 5, 3 ; length dw 2 ; weight tx HaunterDescription ; description - db 16 + db HAS_EVOLUTION ; AI info GengarCard: db TYPE_PKMN_PSYCHIC ; type @@ -7628,7 +7628,7 @@ GengarCard: db 4, 11 ; length dw 89 * 10 ; weight tx GengarDescription ; description - db 1 + db AI_INFO_BENCH_UTILITY ; AI info DrowzeeCard: db TYPE_PKMN_PSYCHIC ; type @@ -7679,7 +7679,7 @@ DrowzeeCard: db 3, 3 ; length dw 71 * 10 ; weight tx DrowzeeDescription ; description - db 19 + db AI_INFO_UNK_03 | HAS_EVOLUTION ; AI info HypnoCard: db TYPE_PKMN_PSYCHIC ; type @@ -7730,7 +7730,7 @@ HypnoCard: db 5, 3 ; length dw 167 * 10 ; weight tx HypnoDescription ; description - db 0 + db 0 ; AI info MrMimeCard: db TYPE_PKMN_PSYCHIC ; type @@ -7781,7 +7781,7 @@ MrMimeCard: db 4, 3 ; length dw 120 * 10 ; weight tx MrMimeDescription ; description - db 3 + db AI_INFO_UNK_03 ; AI info JynxCard: db TYPE_PKMN_PSYCHIC ; type @@ -7832,7 +7832,7 @@ JynxCard: db 4, 7 ; length dw 90 * 10 ; weight tx JynxDescription ; description - db 0 + db 0 ; AI info MewtwoLv53Card: db TYPE_PKMN_PSYCHIC ; type @@ -7883,7 +7883,7 @@ MewtwoLv53Card: db 6, 7 ; length dw 269 * 10 ; weight tx MewtwoLv53Description ; description - db 0 + db 0 ; AI info MewtwoLv60Card: db TYPE_PKMN_PSYCHIC ; type @@ -7934,7 +7934,7 @@ MewtwoLv60Card: db 6, 7 ; length dw 269 * 10 ; weight tx MewtwoLv60Description ; description - db 0 + db 0 ; AI info MewtwoAltLV60Card: db TYPE_PKMN_PSYCHIC ; type @@ -7985,7 +7985,7 @@ MewtwoAltLV60Card: db 6, 7 ; length dw 269 * 10 ; weight tx MewtwoLv60Description ; description - db 0 + db 0 ; AI info MewLv8Card: db TYPE_PKMN_PSYCHIC ; type @@ -8036,7 +8036,7 @@ MewLv8Card: db 1, 4 ; length dw 9 * 10 ; weight tx MewLv8Description ; description - db 3 + db AI_INFO_UNK_03 ; AI info MewLv15Card: db TYPE_PKMN_PSYCHIC ; type @@ -8087,7 +8087,7 @@ MewLv15Card: db 1, 4 ; length dw 9 * 10 ; weight tx MewLv15Description ; description - db 0 + db 0 ; AI info MewLv23Card: db TYPE_PKMN_PSYCHIC ; type @@ -8138,7 +8138,7 @@ MewLv23Card: db 1, 4 ; length dw 9 * 10 ; weight tx MewLv8Description ; description - db 8 + db AI_INFO_UNK_08 ; AI info PidgeyCard: db TYPE_PKMN_COLORLESS ; type @@ -8189,7 +8189,7 @@ PidgeyCard: db 1, 0 ; length dw 4 * 10 ; weight tx PidgeyDescription ; description - db 18 + db AI_INFO_ENCOURAGE_EVO | HAS_EVOLUTION ; AI info PidgeottoCard: db TYPE_PKMN_COLORLESS ; type @@ -8240,7 +8240,7 @@ PidgeottoCard: db 3, 7 ; length dw 66 * 10 ; weight tx PidgeottoDescription ; description - db 16 + db HAS_EVOLUTION ; AI info PidgeotLv38Card: db TYPE_PKMN_COLORLESS ; type @@ -8291,7 +8291,7 @@ PidgeotLv38Card: db 4, 11 ; length dw 87 * 10 ; weight tx PidgeotLv38Description ; description - db 0 + db 0 ; AI info PidgeotLv40Card: db TYPE_PKMN_COLORLESS ; type @@ -8342,7 +8342,7 @@ PidgeotLv40Card: db 4, 11 ; length dw 87 * 10 ; weight tx PidgeotLv40Description ; description - db 0 + db 0 ; AI info RattataCard: db TYPE_PKMN_COLORLESS ; type @@ -8393,7 +8393,7 @@ RattataCard: db 1, 0 ; length dw 8 * 10 ; weight tx RattataDescription ; description - db 19 + db AI_INFO_UNK_03 | HAS_EVOLUTION ; AI info RaticateCard: db TYPE_PKMN_COLORLESS ; type @@ -8444,7 +8444,7 @@ RaticateCard: db 2, 4 ; length dw 41 * 10 ; weight tx RaticateDescription ; description - db 3 + db AI_INFO_UNK_03 ; AI info SpearowCard: db TYPE_PKMN_COLORLESS ; type @@ -8495,7 +8495,7 @@ SpearowCard: db 1, 0 ; length dw 4 * 10 ; weight tx SpearowDescription ; description - db 19 + db AI_INFO_UNK_03 | HAS_EVOLUTION ; AI info FearowCard: db TYPE_PKMN_COLORLESS ; type @@ -8546,7 +8546,7 @@ FearowCard: db 3, 11 ; length dw 84 * 10 ; weight tx FearowDescription ; description - db 0 + db 0 ; AI info ClefairyCard: db TYPE_PKMN_COLORLESS ; type @@ -8597,7 +8597,7 @@ ClefairyCard: db 2, 0 ; length dw 17 * 10 ; weight tx ClefairyDescription ; description - db 18 + db AI_INFO_ENCOURAGE_EVO | HAS_EVOLUTION ; AI info ClefableCard: db TYPE_PKMN_COLORLESS ; type @@ -8648,7 +8648,7 @@ ClefableCard: db 4, 3 ; length dw 88 * 10 ; weight tx ClefableDescription ; description - db 0 + db 0 ; AI info JigglypuffLv12Card: db TYPE_PKMN_COLORLESS ; type @@ -8699,7 +8699,7 @@ JigglypuffLv12Card: db 1, 8 ; length dw 12 * 10 ; weight tx JigglypuffLv12Description ; description - db 16 + db HAS_EVOLUTION ; AI info JigglypuffLv13Card: db TYPE_PKMN_COLORLESS ; type @@ -8750,7 +8750,7 @@ JigglypuffLv13Card: db 1, 8 ; length dw 12 * 10 ; weight tx JigglypuffLv13Description ; description - db 16 + db HAS_EVOLUTION ; AI info JigglypuffLv14Card: db TYPE_PKMN_COLORLESS ; type @@ -8801,7 +8801,7 @@ JigglypuffLv14Card: db 1, 8 ; length dw 12 * 10 ; weight tx JigglypuffLv14Description ; description - db 16 + db HAS_EVOLUTION ; AI info WigglytuffCard: db TYPE_PKMN_COLORLESS ; type @@ -8852,7 +8852,7 @@ WigglytuffCard: db 3, 3 ; length dw 26 * 10 ; weight tx WigglytuffDescription ; description - db 0 + db 0 ; AI info MeowthLv14Card: db TYPE_PKMN_COLORLESS ; type @@ -8903,7 +8903,7 @@ MeowthLv14Card: db 1, 4 ; length dw 9 * 10 ; weight tx MeowthLv14Description ; description - db 16 + db HAS_EVOLUTION ; AI info MeowthLv15Card: db TYPE_PKMN_COLORLESS ; type @@ -8954,7 +8954,7 @@ MeowthLv15Card: db 1, 4 ; length dw 9 * 10 ; weight tx MeowthLv15Description ; description - db 16 + db HAS_EVOLUTION ; AI info PersianCard: db TYPE_PKMN_COLORLESS ; type @@ -9005,7 +9005,7 @@ PersianCard: db 3, 3 ; length dw 71 * 10 ; weight tx PersianDescription ; description - db 0 + db 0 ; AI info FarfetchdCard: db TYPE_PKMN_COLORLESS ; type @@ -9056,7 +9056,7 @@ FarfetchdCard: db 2, 7 ; length dw 33 * 10 ; weight tx FarfetchdDescription ; description - db 3 + db AI_INFO_UNK_03 ; AI info DoduoCard: db TYPE_PKMN_COLORLESS ; type @@ -9107,7 +9107,7 @@ DoduoCard: db 4, 7 ; length dw 86 * 10 ; weight tx DoduoDescription ; description - db 19 + db AI_INFO_UNK_03 | HAS_EVOLUTION ; AI info DodrioCard: db TYPE_PKMN_COLORLESS ; type @@ -9158,7 +9158,7 @@ DodrioCard: db 5, 11 ; length dw 188 * 10 ; weight tx DodrioDescription ; description - db 1 + db AI_INFO_BENCH_UTILITY ; AI info LickitungCard: db TYPE_PKMN_COLORLESS ; type @@ -9209,7 +9209,7 @@ LickitungCard: db 3, 11 ; length dw 144 * 10 ; weight tx LickitungDescription ; description - db 0 + db 0 ; AI info ChanseyCard: db TYPE_PKMN_COLORLESS ; type @@ -9260,7 +9260,7 @@ ChanseyCard: db 3, 7 ; length dw 76 * 10 ; weight tx ChanseyDescription ; description - db 8 + db AI_INFO_UNK_08 ; AI info KangaskhanCard: db TYPE_PKMN_COLORLESS ; type @@ -9311,7 +9311,7 @@ KangaskhanCard: db 7, 3 ; length dw 176 * 10 ; weight tx KangaskhanDescription ; description - db 0 + db 0 ; AI info TaurosCard: db TYPE_PKMN_COLORLESS ; type @@ -9362,7 +9362,7 @@ TaurosCard: db 4, 7 ; length dw 195 * 10 ; weight tx TaurosDescription ; description - db 0 + db 0 ; AI info DittoCard: db TYPE_PKMN_COLORLESS ; type @@ -9413,7 +9413,7 @@ DittoCard: db 1, 0 ; length dw 9 * 10 ; weight tx DittoDescription ; description - db 0 + db 0 ; AI info EeveeCard: db TYPE_PKMN_COLORLESS ; type @@ -9464,7 +9464,7 @@ EeveeCard: db 1, 0 ; length dw 14 * 10 ; weight tx EeveeDescription ; description - db 17 + db AI_INFO_BENCH_UTILITY | HAS_EVOLUTION ; AI info PorygonCard: db TYPE_PKMN_COLORLESS ; type @@ -9515,7 +9515,7 @@ PorygonCard: db 2, 7 ; length dw 80 * 10 ; weight tx PorygonDescription ; description - db 0 + db 0 ; AI info SnorlaxCard: db TYPE_PKMN_COLORLESS ; type @@ -9566,7 +9566,7 @@ SnorlaxCard: db 6, 11 ; length dw 1014 * 10 ; weight tx SnorlaxDescription ; description - db 0 + db 0 ; AI info DratiniCard: db TYPE_PKMN_COLORLESS ; type @@ -9617,7 +9617,7 @@ DratiniCard: db 5, 11 ; length dw 7 * 10 ; weight tx DratiniDescription ; description - db 18 + db AI_INFO_ENCOURAGE_EVO | HAS_EVOLUTION ; AI info DragonairCard: db TYPE_PKMN_COLORLESS ; type @@ -9668,7 +9668,7 @@ DragonairCard: db 13, 1 ; length dw 36 * 10 ; weight tx DragonairDescription ; description - db 16 + db HAS_EVOLUTION ; AI info DragoniteLv41Card: db TYPE_PKMN_COLORLESS ; type @@ -9719,7 +9719,7 @@ DragoniteLv41Card: db 7, 3 ; length dw 463 * 10 ; weight tx DragoniteLv41Description ; description - db 0 + db 0 ; AI info DragoniteLv45Card: db TYPE_PKMN_COLORLESS ; type @@ -9770,7 +9770,7 @@ DragoniteLv45Card: db 7, 3 ; length dw 463 * 10 ; weight tx DragoniteDescription ; description - db 0 + db 0 ; AI info GrassEnergyCard: db TYPE_ENERGY_GRASS ; type diff --git a/src/data/duel/ai_trainer_card_logic.asm b/src/data/duel/ai_trainer_card_logic.asm index 0d3b8712..c950bca4 100644 --- a/src/data/duel/ai_trainer_card_logic.asm +++ b/src/data/duel/ai_trainer_card_logic.asm @@ -6,8 +6,8 @@ MACRO ai_trainer_card_logic ENDM AITrainerCardLogic: - ai_trainer_card_logic AI_TRAINER_CARD_PHASE_07, POTION, AIDecide_Potion1, AIPlay_Potion - ai_trainer_card_logic AI_TRAINER_CARD_PHASE_10, POTION, AIDecide_Potion2, AIPlay_Potion + ai_trainer_card_logic AI_TRAINER_CARD_PHASE_07, POTION, AIDecide_Potion_Phase07, AIPlay_Potion + ai_trainer_card_logic AI_TRAINER_CARD_PHASE_10, POTION, AIDecide_Potion_Phase10, AIPlay_Potion ai_trainer_card_logic AI_TRAINER_CARD_PHASE_08, SUPER_POTION, AIDecide_SuperPotion1, AIPlay_SuperPotion ai_trainer_card_logic AI_TRAINER_CARD_PHASE_11, SUPER_POTION, AIDecide_SuperPotion2, AIPlay_SuperPotion ai_trainer_card_logic AI_TRAINER_CARD_PHASE_13, DEFENDER, AIDecide_Defender1, AIPlay_Defender diff --git a/src/engine/duel/ai/attacks.asm b/src/engine/duel/ai/attacks.asm index 5b74c2fa..94d75b01 100644 --- a/src/engine/duel/ai/attacks.asm +++ b/src/engine/duel/ai/attacks.asm @@ -240,7 +240,7 @@ GetAIScoreOfAttack: jr .check_damage .can_ko ld a, 20 - call AddToAIScore + call AIEncourage ; raise AI score by the number of damage counters that this attack deals. ; if no damage is dealt, subtract AI score. in case wDamage is zero @@ -255,17 +255,17 @@ GetAIScoreOfAttack: or a jr z, .no_damage call ConvertHPToDamageCounters_Bank5 - call AddToAIScore + call AIEncourage jr .check_recoil .no_damage ld a, $01 ld [wAIAttackIsNonDamaging], a - call SubFromAIScore + call AIDiscourage ld a, [wAIMaxDamage] or a jr z, .no_max_damage ld a, 2 - call AddToAIScore + call AIEncourage xor a ld [wAIAttackIsNonDamaging], a .no_max_damage @@ -273,7 +273,7 @@ GetAIScoreOfAttack: call CheckLoadedAttackFlag jr nc, .check_recoil ld a, 2 - call AddToAIScore + call AIEncourage ; handle recoil attacks (low and high recoil). .check_recoil @@ -293,7 +293,7 @@ GetAIScoreOfAttack: call ApplyDamageModifiers_DamageToSelf ld a, e call ConvertHPToDamageCounters_Bank5 - call SubFromAIScore + call AIDiscourage push de ld a, ATTACK_FLAG1_ADDRESS | HIGH_RECOIL_F @@ -309,7 +309,7 @@ GetAIScoreOfAttack: jp nz, .check_defending_can_ko .kos_self ld a, 10 - call SubFromAIScore + call AIDiscourage .high_recoil ; dismiss this attack if no benched Pokémon @@ -340,7 +340,7 @@ GetAIScoreOfAttack: .encourage_high_recoil_atk ld a, 20 - call AddToAIScore + call AIEncourage jp .done ; Zapping Selfdestruct deck only uses this attack @@ -436,7 +436,7 @@ GetAIScoreOfAttack: ; attack causes CPU to draw all prize cards .wins_the_duel ld a, 20 - call AddToAIScore + call AIEncourage jp .done ; subtract from AI score number of own benched Pokémon KO'd @@ -446,13 +446,13 @@ GetAIScoreOfAttack: or a jr z, .count_player_ko_bench dec a - call SubFromAIScore + call AIDiscourage ; add to AI score number of player benched Pokémon KO'd .count_player_ko_bench pop bc ld a, b - call AddToAIScore + call AIEncourage jr .check_defending_can_ko ; local function that gets called to determine damage to @@ -515,12 +515,12 @@ GetAIScoreOfAttack: ld [wSelectedAttack], a jr nc, .check_discard ld a, 5 - call AddToAIScore + call AIEncourage ld a, [wAIAttackIsNonDamaging] or a jr z, .check_discard ld a, 5 - call SubFromAIScore + call AIDiscourage ; subtract from AI score if this attack requires ; discarding any energy cards. @@ -535,16 +535,16 @@ GetAIScoreOfAttack: call CheckLoadedAttackFlag jr nc, .asm_16ca6 ld a, 1 - call SubFromAIScore + call AIDiscourage ld a, [wLoadedAttackEffectParam] - call SubFromAIScore + call AIDiscourage .asm_16ca6 ld a, ATTACK_FLAG2_ADDRESS | FLAG_2_BIT_6_F call CheckLoadedAttackFlag jr nc, .check_nullify_flag ld a, [wLoadedAttackEffectParam] - call AddToAIScore + call AIEncourage ; encourage attack if it has a nullify or weaken attack effect. .check_nullify_flag @@ -552,7 +552,7 @@ GetAIScoreOfAttack: call CheckLoadedAttackFlag jr nc, .check_draw_flag ld a, 1 - call AddToAIScore + call AIEncourage ; encourage attack if it has an effect to draw a card. .check_draw_flag @@ -560,7 +560,7 @@ GetAIScoreOfAttack: call CheckLoadedAttackFlag jr nc, .check_heal_flag ld a, 1 - call AddToAIScore + call AIEncourage .check_heal_flag ld a, ATTACK_FLAG2_ADDRESS | HEAL_USER_F @@ -591,11 +591,11 @@ GetAIScoreOfAttack: call GetCardDamageAndMaxHP call ConvertHPToDamageCounters_Bank5 pop bc - cp b ; wLoadedAttackEffectParam + cp b jr c, .add_heal_score ld a, b .add_heal_score - call AddToAIScore + call AIEncourage .check_status_effect ld a, DUELVARS_ARENA_CARD @@ -630,11 +630,11 @@ GetAIScoreOfAttack: call CheckLoadedAttackFlag jr nc, .check_sleep ld a, 2 - call SubFromAIScore + call AIDiscourage jr .check_sleep .add_poison_score ld a, 2 - call AddToAIScore + call AIEncourage ; encourage sleep-inducing attack if other Pokémon isn't asleep. .check_sleep @@ -646,7 +646,7 @@ GetAIScoreOfAttack: cp ASLEEP jr z, .check_paralysis ld a, 1 - call AddToAIScore + call AIEncourage ; encourage paralysis-inducing attack if other Pokémon isn't asleep. ; otherwise, if other Pokémon is asleep, discourage attack. @@ -659,11 +659,11 @@ GetAIScoreOfAttack: cp ASLEEP jr z, .sub_prz_score ld a, 1 - call AddToAIScore + call AIEncourage jr .check_confusion .sub_prz_score ld a, 1 - call SubFromAIScore + call AIDiscourage ; encourage confuse-inducing attack if other Pokémon isn't asleep ; or confused already. @@ -682,11 +682,11 @@ GetAIScoreOfAttack: cp CONFUSED jr z, .check_if_confused ld a, 1 - call AddToAIScore + call AIEncourage jr .check_if_confused .sub_cnf_score ld a, 1 - call SubFromAIScore + call AIDiscourage ; if this Pokémon is confused, subtract from score. .check_if_confused @@ -696,7 +696,7 @@ GetAIScoreOfAttack: cp CONFUSED jr nz, .handle_special_atks ld a, 1 - call SubFromAIScore + call AIDiscourage ; SPECIAL_AI_HANDLING marks attacks that the AI handles individually. ; each attack has its own checks and modifies AI score accordingly. @@ -708,13 +708,13 @@ GetAIScoreOfAttack: cp $80 jr c, .negative_score sub $80 - call AddToAIScore + call AIEncourage jr .done .negative_score ld b, a ld a, $80 sub b - call SubFromAIScore + call AIDiscourage .done ret diff --git a/src/engine/duel/ai/core.asm b/src/engine/duel/ai/core.asm index ff59036a..bdbe92ea 100644 --- a/src/engine/duel/ai/core.asm +++ b/src/engine/duel/ai/core.asm @@ -9,12 +9,10 @@ INCLUDE "engine/duel/ai/decks/unreferenced.asm" ; [wSelectedAttack] = attack index that KOs CheckIfAnyAttackKnocksOutDefendingCard: xor a ; FIRST_ATTACK_OR_PKMN_POWER - call CheckIfAttackKnocksOutDefendingCard + call .CheckAttack ret c ld a, SECOND_ATTACK -; fallthrough - -CheckIfAttackKnocksOutDefendingCard: +.CheckAttack: call EstimateDamage_VersusDefendingCard ld a, DUELVARS_ARENA_CARD_HP call GetNonTurnDuelistVariable @@ -59,7 +57,7 @@ FindHighestBenchScore: ld e, c ld d, c ld hl, wPlayAreaAIScore + 1 - jp .next + jp .next ; can be jr .loop ld a, [hli] @@ -78,23 +76,23 @@ FindHighestBenchScore: ret ; adds a to wAIScore -; if there's overflow, it's capped at $ff +; if there's overflow, it's capped at 255 ; output: -; a = a + wAIScore (capped at $ff) -AddToAIScore: +; a = a + wAIScore (capped at 255) +AIEncourage: push hl ld hl, wAIScore add [hl] jr nc, .no_cap - ld a, $ff + ld a, 255 .no_cap ld [hl], a pop hl ret ; subs a from wAIScore -; if there's underflow, it's capped at $00 -SubFromAIScore: +; if there's underflow, it's capped at 0 +AIDiscourage: push hl push de ld e, a @@ -105,7 +103,7 @@ SubFromAIScore: sub e ld [hl], a jr nc, .done - ld [hl], $00 + ld [hl], 0 .done pop de pop hl @@ -631,7 +629,7 @@ CreateEnergyCardListFromHand: call GetTurnDuelistVariable ld c, a inc c - ld l, LOW(wOpponentHand) + ld l, DUELVARS_HAND jr .decrease .loop @@ -1585,7 +1583,7 @@ SortTempHandByIDList: CheckEnergyFlagsNeededInList: ld e, a ld hl, wDuelTempList -.next_card +.loop_cards ld a, [hli] cp $ff jr z, .no_carry @@ -1626,7 +1624,7 @@ CheckEnergyFlagsNeededInList: jr .check_energy .colorless cp DOUBLE_COLORLESS_ENERGY - jr nz, .next_card + jr nz, .loop_cards ld a, COLORLESS_F ; if energy card matches required energy, return carry @@ -1634,7 +1632,7 @@ CheckEnergyFlagsNeededInList: ld d, e and e ld e, d - jr z, .next_card + jr z, .loop_cards scf ret .no_carry @@ -1652,12 +1650,12 @@ CheckEnergyFlagsNeededInList: GetAttacksEnergyCostBits: call LoadCardDataToBuffer2_FromDeckIndex ld hl, wLoadedCard2Atk1EnergyCost - call GetEnergyCostBits + call .GetEnergyCostBits ld b, a push bc ld hl, wLoadedCard2Atk2EnergyCost - call GetEnergyCostBits + call .GetEnergyCostBits pop bc or b ret @@ -1670,7 +1668,7 @@ GetAttacksEnergyCostBits: ; [hl] = Loaded card attack energy cost ; output: ; a = bits of each energy requirement -GetEnergyCostBits: +.GetEnergyCostBits: ld c, $00 ld a, [hli] ld b, a @@ -1892,10 +1890,9 @@ LookForCardThatIsKnockedOutOnDevolution: ; returns carry if the following conditions are met: ; - arena card HP >= half max HP -; - arena card Unknown2's 4 bit is not set or -; is set but there's no evolution of card in hand/deck +; - arena card cannot potentially evolve ; - arena card can use second attack -CheckIfArenaCardIsAtHalfHPCanEvolveAndUseSecondAttack: +CheckIfArenaCardIsFullyPowered: ld a, DUELVARS_ARENA_CARD call GetTurnDuelistVariable ld d, a @@ -1910,8 +1907,8 @@ CheckIfArenaCardIsAtHalfHPCanEvolveAndUseSecondAttack: pop de jr nc, .no_carry - ld a, [wLoadedCard1Unknown2] - and %00010000 + ld a, [wLoadedCard1AIInfo] + and HAS_EVOLUTION jr z, .check_second_attack ld a, d call CheckCardEvolutionInHandOrDeck @@ -1981,10 +1978,9 @@ CountNumberOfSetUpBenchPokemon: pop de jr nc, .next - ld a, [wLoadedCard1Unknown2] - and $10 + ld a, [wLoadedCard1AIInfo] + and HAS_EVOLUTION jr z, .check_second_attack - ld a, d push bc call CheckCardEvolutionInHandOrDeck @@ -1994,6 +1990,9 @@ CountNumberOfSetUpBenchPokemon: .check_second_attack ld a, c ldh [hTempPlayAreaLocation_ff9d], a + ; bug, there is an assumption that the card + ; has a second attack, but it may be the case + ; that it doesn't, which will return carry ld a, SECOND_ATTACK ld [wSelectedAttack], a push bc @@ -2107,7 +2106,6 @@ AISelectSpecialAttackParameters: ; store the deck index of energy card found ld a, b ldh [hTempPlayAreaLocation_ffa1], a - ; fallthrough .set_carry_2 scf @@ -2132,6 +2130,7 @@ AISelectSpecialAttackParameters: or a jp z, .no_carry ; can be jr +; if none were found in Deck, return carry... ld a, CARD_LOCATION_DECK ld e, LIGHTNING_ENERGY @@ -2356,13 +2355,13 @@ CheckIfDefendingPokemonCanKnockOut: ld [wAISecondAttackDamage], a ; first attack - call CheckIfDefendingPokemonCanKnockOutWithAttack + call .CheckAttack jr nc, .second_attack ld a, [wDamage] ld [wAIFirstAttackDamage], a .second_attack ld a, SECOND_ATTACK - call CheckIfDefendingPokemonCanKnockOutWithAttack + call .CheckAttack jr nc, .return_if_neither_kos ld a, [wDamage] ld [wAISecondAttackDamage], a @@ -2389,7 +2388,7 @@ CheckIfDefendingPokemonCanKnockOut: ; input: ; a = attack index ; [hTempPlayAreaLocation_ff9d] = location of card to check -CheckIfDefendingPokemonCanKnockOutWithAttack: +.CheckAttack: ld [wSelectedAttack], a ldh a, [hTempPlayAreaLocation_ff9d] push af @@ -2411,10 +2410,10 @@ CheckIfDefendingPokemonCanKnockOutWithAttack: call GetTurnDuelistVariable ld hl, wDamage sub [hl] - jr z, .set_carry + jr z, .can_ko ret -.set_carry +.can_ko scf ret @@ -2515,7 +2514,7 @@ AIChooseRandomlyNotToDoAction: ; output: ; carry set if the above requirements are met CheckForBenchIDAtHalfHPAndCanUseSecondAttack: - ld [wcdf9], a + ld [wSamePokemonCardID], a ldh a, [hTempPlayAreaLocation_ff9d] ld d, a ld a, [wSelectedAttack] @@ -2549,7 +2548,7 @@ CheckForBenchIDAtHalfHPAndCanUseSecondAttack: jr nc, .loop ; half max HP < current HP ld a, [wLoadedCard1ID] - ld hl, wcdf9 + ld hl, wSamePokemonCardID cp [hl] jr nz, .loop @@ -2606,107 +2605,106 @@ RaiseAIScoreToAllMatchingIDsInBench: pop hl jr .loop -; goes through each play area Pokémon, and -; for all cards of the same ID, determine which -; card has highest value calculated from Func_17583 -; the card with highest value gets increased wPlayAreaEnergyAIScore -; while all others get decreased wPlayAreaEnergyAIScore -Func_174f2: +; used by AI to determine which Pokémon it should favor in the bench +; in order to attach an energy card from the hand, in case there are repeats +; if there is repeated Pokémon in bench, then increase wPlayAreaEnergyAIScore +; from the Pokémon with less damage and more energy cards, +; and decrease from all others +HandleAIEnergyScoringForRepeatedBenchPokemon: + ; clears wSamePokemonEnergyScoreHandled ld a, MAX_PLAY_AREA_POKEMON - ld hl, wcdfa + ld hl, wSamePokemonEnergyScoreHandled call ClearMemory_Bank5 + ld a, DUELVARS_BENCH call GetTurnDuelistVariable ld e, 0 - -.loop_play_area +.loop_bench + ; clears wSamePokemonEnergyScore push hl ld a, MAX_PLAY_AREA_POKEMON - ld hl, wcdea + ld hl, wSamePokemonEnergyScore call ClearMemory_Bank5 pop hl + inc e ld a, [hli] cp $ff - ret z + ret z ; done looping bench - ld [wcdf9], a - push de - push hl + ld [wSamePokemonCardID], a ; deck index -; checks wcdfa + play area location in e +; checks wSamePokemonEnergyScoreHandled of location in e ; if != 0, go to next in play area + push de + push hl ld d, $00 - ld hl, wcdfa + ld hl, wSamePokemonEnergyScoreHandled add hl, de ld a, [hl] or a pop hl pop de - jr nz, .loop_play_area + jr nz, .loop_bench ; already handled -; loads wcdf9 with card ID -; and call Func_17583 + ; store this card's ID push de - ld a, [wcdf9] + ld a, [wSamePokemonCardID] call GetCardIDFromDeckIndex ld a, e - ld [wcdf9], a + ld [wSamePokemonCardID], a pop de + + ; calculate score of this Pokémon + ; and all cards with same ID push hl push de - call Func_17583 - -; check play area Pokémon ahead -; if there is a card with the same ID, -; call Func_17583 for it as well -.loop_1 + call .CalculateScore +.loop_search_same_card_id inc e ld a, [hli] cp $ff - jr z, .check_if_repeated_id + jr z, .tally_repeated_pokemon push de call GetCardIDFromDeckIndex - ld a, [wcdf9] + ld a, [wSamePokemonCardID] cp e pop de - jr nz, .loop_1 - call Func_17583 - jr .loop_1 - -; if there are more than 1 of the same ID -; in play area, iterate bench backwards -; and determines which card has highest -; score in wcdea -.check_if_repeated_id - call Func_175a8 + jr nz, .loop_search_same_card_id + call .CalculateScore + jr .loop_search_same_card_id + +.tally_repeated_pokemon + call .CountNumberOfCardsWithSameID jr c, .next + + ; has repeated card IDs in bench + ; find which one has highest score lb bc, 0, 0 - ld hl, wcdea + MAX_BENCH_POKEMON - ld d, MAX_PLAY_AREA_POKEMON + ld hl, wSamePokemonEnergyScore + PLAY_AREA_BENCH_5 + ld d, PLAY_AREA_BENCH_5 + 1 .loop_2 dec d - jr z, .asm_17560 + jr z, .got_highest_score ld a, [hld] cp b jr c, .loop_2 - ld b, a - ld c, d + ld b, a ; highest score + ld c, d ; play area location jr .loop_2 ; c = play area location of highest score -; decrease wPlayAreaEnergyAIScore score for all cards with same ID -; except for the one with highest score ; increase wPlayAreaEnergyAIScore score for card with highest ID -.asm_17560 +; decrease wPlayAreaEnergyAIScore score for all cards with same ID +.got_highest_score ld hl, wPlayAreaEnergyAIScore - ld de, wcdea + ld de, wSamePokemonEnergyScore ld b, PLAY_AREA_ARENA .loop_3 ld a, c cp b jr z, .card_with_highest - ld a, [de] + ld a, [de] ; score or a jr z, .check_next ; decrease score @@ -2727,13 +2725,13 @@ Func_174f2: .next pop de pop hl - jp .loop_play_area + jp .loop_bench -; loads wcdea + play area location in e +; loads wSamePokemonEnergyScore + play area location in e ; with energy * 2 + $80 - floor(dam / 10) -; loads wcdfa + play area location in e +; loads wSamePokemonEnergyScoreHandled + play area location in e ; with $01 -Func_17583: +.CalculateScore: push hl push de call GetCardDamageAndMaxHP @@ -2748,21 +2746,21 @@ Func_17583: pop de push de ld d, $00 - ld hl, wcdea + ld hl, wSamePokemonEnergyScore add hl, de ld [hl], a - ld hl, wcdfa + ld hl, wSamePokemonEnergyScoreHandled add hl, de ld [hl], $01 pop de pop hl ret -; counts how many play area locations in wcdea +; counts how many play area locations in wSamePokemonEnergyScore ; are != 0, and outputs result in a ; also returns carry if result is < 2 -Func_175a8: - ld hl, wcdea +.CountNumberOfCardsWithSameID: + ld hl, wSamePokemonEnergyScore ld d, $00 ld e, MAX_PLAY_AREA_POKEMON + 1 .loop diff --git a/src/engine/duel/ai/damage_calculation.asm b/src/engine/duel/ai/damage_calculation.asm index 9b9af40f..9a7ee122 100644 --- a/src/engine/duel/ai/damage_calculation.asm +++ b/src/engine/duel/ai/damage_calculation.asm @@ -94,13 +94,11 @@ EstimateDamage_VersusDefendingCard: ; [hTempPlayAreaLocation_ff9d] = turn holder's card location as the attacker CalculateDamage_VersusDefendingPokemon: ld hl, wAIMinDamage - call _CalculateDamage_VersusDefendingPokemon + call .Calculate ld hl, wAIMaxDamage - call _CalculateDamage_VersusDefendingPokemon + call .Calculate ld hl, wDamage -; fallthrough - -_CalculateDamage_VersusDefendingPokemon: +.Calculate: ld e, [hl] ld d, $00 push hl @@ -127,7 +125,7 @@ _CalculateDamage_VersusDefendingPokemon: pop de jr nc, .vulnerable ; invulnerable to damage - ld de, $0 + ld de, 0 jr .done .vulnerable ldh a, [hTempPlayAreaLocation_ff9d] @@ -177,7 +175,7 @@ _CalculateDamage_VersusDefendingPokemon: ; test if de underflowed bit 7, d jr z, .no_underflow - ld de, $0 + ld de, 0 .no_underflow ld a, DUELVARS_ARENA_CARD_STATUS diff --git a/src/engine/duel/ai/energy.asm b/src/engine/duel/ai/energy.asm index 3bdf7318..27ec0406 100644 --- a/src/engine/duel/ai/energy.asm +++ b/src/engine/duel/ai/energy.asm @@ -153,7 +153,7 @@ AIProcessEnergyCards: jr nc, .no_evolution_in_hand ld [wTempAI], a ; store evolution card found ld a, 2 - call AddToAIScore + call AIEncourage jr .check_venusaur .no_evolution_in_hand @@ -161,7 +161,7 @@ AIProcessEnergyCards: call CheckForEvolutionInDeck jr nc, .check_venusaur ld a, 1 - call AddToAIScore + call AIEncourage ; if there's no Muk in any Play Area ; and there's VenusaurLv67 in own Play Area, @@ -174,7 +174,7 @@ AIProcessEnergyCards: call CountTurnDuelistPokemonWithActivePkmnPower jr nc, .check_if_active ld a, 1 - call AddToAIScore + call AIEncourage .check_if_active ldh a, [hTempPlayAreaLocation_ff9d] @@ -189,12 +189,12 @@ AIProcessEnergyCards: ; subtract from score instead ; if Player is running MewtwoLv53 mill deck. ld a, 5 - call SubFromAIScore + call AIDiscourage jr .check_defending_can_ko .add_to_score ld a, 4 - call AddToAIScore + call AIEncourage ; lower AI score if poison/double poison ; will KO Pokémon between turns @@ -220,13 +220,13 @@ AIProcessEnergyCards: jr z, .check_defending_can_ko .poison_will_ko ld a, 10 - call SubFromAIScore + call AIDiscourage jr .check_bench .check_defending_can_ko call CheckIfDefendingPokemonCanKnockOut jr nc, .ai_score_bonus ld a, 10 - call SubFromAIScore + call AIDiscourage ; if either poison will KO or defending Pokémon can KO, ; check if there are bench Pokémon, @@ -237,7 +237,7 @@ AIProcessEnergyCards: dec a jr nz, .ai_score_bonus ld a, 6 - call AddToAIScore + call AIEncourage jr .ai_score_bonus ; lower AI score by 3 - (bench HP)/10 @@ -252,7 +252,7 @@ AIProcessEnergyCards: ld b, a ld a, 3 sub b - call SubFromAIScore + call AIDiscourage ; check list in wAICardListEnergyBonus .ai_score_bonus @@ -290,22 +290,22 @@ AIProcessEnergyCards: jr c, .check_id_score ; already reached target number of energy cards ld a, 10 - call SubFromAIScore - jr .store_score + call AIDiscourage + jr .store_score ; bug, should be jr .check_boss_deck .check_id_score ld a, [hli] cp $80 jr c, .decrease_score_1 sub $80 - call AddToAIScore + call AIEncourage jr .check_boss_deck .decrease_score_1 ld d, a ld a, $80 sub d - call SubFromAIScore + call AIDiscourage jr .check_boss_deck .next_id @@ -313,14 +313,16 @@ AIProcessEnergyCards: inc hl jr .loop_id_list -; if it's a boss deck, call Func_174f2 +; if it's a boss deck, call HandleAIEnergyScoringForRepeatedBenchPokemon ; and apply to the AI score the values ; determined for this card .check_boss_deck call CheckIfNotABossDeckID jr c, .skip_boss_deck - call Func_174f2 + call HandleAIEnergyScoringForRepeatedBenchPokemon + + ; applies wPlayAreaEnergyAIScore ldh a, [hTempPlayAreaLocation_ff9d] ld c, a ld b, $00 @@ -330,18 +332,18 @@ AIProcessEnergyCards: cp $80 jr c, .decrease_score_2 sub $80 - call AddToAIScore + call AIEncourage jr .skip_boss_deck .decrease_score_2 ld b, a ld a, $80 sub b - call SubFromAIScore + call AIDiscourage .skip_boss_deck ld a, 1 - call AddToAIScore + call AIEncourage ; add AI score for both attacks, ; according to their energy requirements. @@ -413,7 +415,7 @@ DetermineAIScoreOfAttackEnergyRequirement: ; is MAX_ENERGY_BOOST_IS_NOT_LIMITED, ; which is equal to 3, add to score. - call AddToAIScore + call AIEncourage jp .check_evolution .check_surplus_energy @@ -424,12 +426,12 @@ DetermineAIScoreOfAttackEnergyRequirement: .asm_166c5 ld a, 5 - call SubFromAIScore + call AIDiscourage jp .check_evolution .asm_166cd ld a, 2 - call AddToAIScore + call AIEncourage ; check whether attack has ATTACHED_ENERGY_BOOST flag ; and add to AI score if attaching another energy @@ -457,12 +459,12 @@ DetermineAIScoreOfAttackEnergyRequirement: .attaching_kos_player ld a, 20 - call AddToAIScore + call AIEncourage ldh a, [hTempPlayAreaLocation_ff9d] or a jr nz, .check_evolution ld a, 10 - call AddToAIScore + call AIEncourage jr .check_evolution ; checks if there is surplus energy for attack @@ -482,7 +484,7 @@ DetermineAIScoreOfAttackEnergyRequirement: call CheckLoadedAttackFlag jr nc, .check_color_needed ld a, 5 - call SubFromAIScore + call AIDiscourage ; if the energy card color needed is in hand, increase AI score. ; if a colorless card is needed, increase AI score. @@ -494,14 +496,14 @@ DetermineAIScoreOfAttackEnergyRequirement: call LookForCardIDInHand jr c, .check_colorless_needed ld a, 4 - call AddToAIScore + call AIEncourage jr .check_total_needed .check_colorless_needed ld a, c or a jr z, .check_evolution ld a, 3 - call AddToAIScore + call AIEncourage ; if only one energy card is needed for attack, ; encourage playing energy card. @@ -511,7 +513,7 @@ DetermineAIScoreOfAttackEnergyRequirement: dec a jr nz, .check_evolution ld a, 3 - call AddToAIScore + call AIEncourage ; if the attack KOs player and this is the active card, add to AI score. ldh a, [hTempPlayAreaLocation_ff9d] @@ -527,7 +529,7 @@ DetermineAIScoreOfAttackEnergyRequirement: jr nc, .check_evolution .atk_kos_defending ld a, 20 - call AddToAIScore + call AIEncourage ; this is possibly a bug. ; this is an identical check as above to test whether this card is active. @@ -536,7 +538,7 @@ DetermineAIScoreOfAttackEnergyRequirement: or a jr nz, .check_evolution ld a, 10 - call AddToAIScore + call AIEncourage .check_evolution ld a, [wTempAI] ; evolution in hand @@ -567,14 +569,14 @@ DetermineAIScoreOfAttackEnergyRequirement: call LookForCardIDInHand jr c, .check_colorless_needed_evo ld a, 2 - call AddToAIScore + call AIEncourage jr .done .check_colorless_needed_evo ld a, c or a jr z, .done ld a, 1 - call AddToAIScore + call AIEncourage ; recover the original card in the Play Area location. .done @@ -707,8 +709,8 @@ CheckIfEvolutionNeedsEnergyForAttack: ; if it's Charizard's Fire Spin or Exeggutor's Big Eggsplosion ; attack, don't return energy card ID, but set carry. ; output: -; b = 1 if needs color energy, 0 otherwise; -; c = 1 if only needs colorless energy, 0 otherwise; +; b = TRUE if needs color energy; +; c = TRUE if only needs colorless energy; ; carry set if not ZapdosLv64's Thunderbolt attack. GetEnergyCardForDiscardOrEnergyBoostAttack: ; load card ID and check selected attack index. @@ -727,7 +729,7 @@ GetEnergyCardForDiscardOrEnergyBoostAttack: ; for both attacks, load its energy cost. ld a, b cp ZAPDOS_LV64 - jr z, .zapdos2 + jr z, .zapdos cp CHARIZARD jr z, .charizard_or_exeggutor cp EXEGGUTOR @@ -777,19 +779,19 @@ GetEnergyCardForDiscardOrEnergyBoostAttack: ld e, PSYCHIC_ENERGY .set_carry - lb bc, $01, $00 + lb bc, TRUE, FALSE scf ret ; for ZapdosLv64's Thunderbolt attack, return with no carry. -.zapdos2 +.zapdos or a ret ; Charizard's Fire Spin and Exeggutor's Big Eggsplosion, ; return carry. .charizard_or_exeggutor - lb bc, $00, $01 + lb bc, FALSE, TRUE scf ret diff --git a/src/engine/duel/ai/hand_pokemon.asm b/src/engine/duel/ai/hand_pokemon.asm index 4c619b59..96a61f13 100644 --- a/src/engine/duel/ai/hand_pokemon.asm +++ b/src/engine/duel/ai/hand_pokemon.asm @@ -37,11 +37,11 @@ AIDecidePlayPokemonCard: cp 4 jr c, .has_4_or_fewer ld a, 20 - call SubFromAIScore + call AIDiscourage jr .check_defending_can_ko .has_4_or_fewer ld a, 50 - call AddToAIScore + call AIEncourage ; if defending Pokémon can KO active card, increase AI score .check_defending_can_ko @@ -50,7 +50,7 @@ AIDecidePlayPokemonCard: call CheckIfDefendingPokemonCanKnockOut jr nc, .check_energy_cards ld a, 20 - call AddToAIScore + call AIEncourage ; if energy cards are found in hand ; for this card's attacks, raise AI score @@ -60,7 +60,7 @@ AIDecidePlayPokemonCard: call CheckEnergyFlagsNeededInList jr nc, .check_evolution_hand ld a, 20 - call AddToAIScore + call AIEncourage ; if evolution card is found in hand ; for this card, raise AI score @@ -69,7 +69,7 @@ AIDecidePlayPokemonCard: call CheckForEvolutionInList jr nc, .check_evolution_deck ld a, 20 - call AddToAIScore + call AIEncourage ; if evolution card is found in deck ; for this card, raise AI score @@ -78,7 +78,7 @@ AIDecidePlayPokemonCard: call CheckForEvolutionInDeck jr nc, .check_score ld a, 10 - call AddToAIScore + call AIEncourage ; if AI score is >= 180, play card from hand .check_score @@ -203,21 +203,21 @@ AIDecideEvolution: jr c, .evolution_cant_attack .evolution_can_attack ld a, 5 - call AddToAIScore + call AIEncourage jr .check_evolution_ko .evolution_cant_attack ld a, [wCurCardCanAttack] or a jr z, .check_evolution_ko ld a, 2 - call SubFromAIScore + call AIDiscourage ld a, [wAlreadyPlayedEnergy] or a jr nz, .check_evolution_ko call LookForEnergyNeededInHand jr nc, .check_evolution_ko ld a, 7 - call AddToAIScore + call AIEncourage ; if it's an active card: ; if evolution can't KO but the current card can, lower AI score; @@ -234,14 +234,14 @@ AIDecideEvolution: call CheckIfSelectedAttackIsUnusable jr c, .evolution_cant_ko ld a, 5 - call AddToAIScore + call AIEncourage jr .check_defending_can_ko_evolution .evolution_cant_ko ld a, [wCurCardCanKO] or a jr z, .check_defending_can_ko_evolution ld a, 20 - call SubFromAIScore + call AIDiscourage ; if defending Pokémon can KO evolution, lower AI score .check_defending_can_ko_evolution @@ -253,7 +253,7 @@ AIDecideEvolution: call CheckIfDefendingPokemonCanKnockOut jr nc, .check_mr_mime ld a, 5 - call SubFromAIScore + call AIDiscourage ; if evolution can't damage player's Mr Mime, lower AI score .check_mr_mime @@ -261,7 +261,7 @@ AIDecideEvolution: call CheckDamageToMrMime jr c, .check_defending_can_ko ld a, 20 - call SubFromAIScore + call AIDiscourage ; if defending Pokémon can KO current card, raise AI score .check_defending_can_ko @@ -278,7 +278,7 @@ AIDecideEvolution: call CheckIfDefendingPokemonCanKnockOut jr nc, .check_status ld a, 5 - call AddToAIScore + call AIEncourage ; if current card has a status condition, raise AI score .check_status @@ -287,7 +287,7 @@ AIDecideEvolution: or a jr z, .check_2nd_stage_hand ld a, 4 - call AddToAIScore + call AIEncourage ; if hand has 2nd stage card to evolve evolution card, raise AI score .check_2nd_stage_hand @@ -295,7 +295,7 @@ AIDecideEvolution: call CheckForEvolutionInList jr nc, .check_2nd_stage_deck ld a, 2 - call AddToAIScore + call AIEncourage jr .check_damage ; if deck has 2nd stage card to evolve evolution card, raise AI score @@ -304,7 +304,7 @@ AIDecideEvolution: call CheckForEvolutionInDeck jr nc, .check_damage ld a, 1 - call AddToAIScore + call AIEncourage ; decrease AI score proportional to damage ; AI score -= floor(Damage / 40) @@ -317,10 +317,10 @@ AIDecideEvolution: srl a srl a call ConvertHPToDamageCounters_Bank5 - call SubFromAIScore + call AIDiscourage ; if is Mysterious Fossil or -; wLoadedCard1Unknown2 is set to $02, +; wLoadedCard1AIInfo is AI_INFO_ENCOURAGE_EVO, ; raise AI score .check_mysterious_fossil ld a, [wTempAI] @@ -330,16 +330,17 @@ AIDecideEvolution: ld a, [wLoadedCard1ID] cp MYSTERIOUS_FOSSIL jr z, .mysterious_fossil - ld a, [wLoadedCard1Unknown2] - cp $02 + ld a, [wLoadedCard1AIInfo] + ; bug, should mask out HAS_EVOLUTION flag first + cp AI_INFO_ENCOURAGE_EVO jr nz, .pikachu_deck ld a, 2 - call AddToAIScore + call AIEncourage jr .pikachu_deck .mysterious_fossil ld a, 5 - call AddToAIScore + call AIEncourage ; in Pikachu Deck, decrease AI score for evolving Pikachu .pikachu_deck @@ -357,7 +358,7 @@ AIDecideEvolution: jr nz, .check_score .pikachu ld a, 3 - call SubFromAIScore + call AIDiscourage ; if AI score >= 133, go through with the evolution .check_score @@ -424,11 +425,11 @@ AIDecideSpecialEvolutions: cp 6 jr c, .not_enough_energy ld a, 3 - call AddToAIScore + call AIEncourage ret .not_enough_energy ld a, 10 - call SubFromAIScore + call AIDiscourage ret ; check if Magikarp is not the active card @@ -442,7 +443,7 @@ AIDecideSpecialEvolutions: cp 2 ret c ld a, 3 - call AddToAIScore + call AIEncourage ret .invincible_ronald @@ -457,7 +458,7 @@ AIDecideSpecialEvolutions: or a ; active card ret z ld a, 10 - call AddToAIScore + call AIEncourage ret .legendary_ronald @@ -495,7 +496,7 @@ AIDecideSpecialEvolutions: jr c, .check_muk .lower_score ld a, 10 - call SubFromAIScore + call AIDiscourage ret ; if there's no Muk, raise score @@ -504,7 +505,7 @@ AIDecideSpecialEvolutions: call CountPokemonWithActivePkmnPowerInBothPlayAreas jr c, .lower_score ld a, 10 - call AddToAIScore + call AIEncourage ret ; if Dragonair is active, check its damage in HP @@ -604,11 +605,11 @@ AIDecidePlayLegendaryBirds: ; add ld a, 70 - call AddToAIScore + call AIEncourage ret .subtract ld a, 100 - call SubFromAIScore + call AIDiscourage ret .moltres diff --git a/src/engine/duel/ai/pkmn_powers.asm b/src/engine/duel/ai/pkmn_powers.asm index ef7853ca..79915d26 100644 --- a/src/engine/duel/ai/pkmn_powers.asm +++ b/src/engine/duel/ai/pkmn_powers.asm @@ -460,27 +460,31 @@ HandleAIPkmnPowers: ld a, e push bc -; check heal +; heal cp VILEPLUME - jr nz, .check_shift + jr nz, .shift call HandleAIHeal jr .next_1 -.check_shift + +.shift cp VENOMOTH - jr nz, .check_peek + jr nz, .peek call HandleAIShift jr .next_1 -.check_peek + +.peek cp MANKEY - jr nz, .check_strange_behavior + jr nz, .strange_behavior call HandleAIPeek jr .next_1 -.check_strange_behavior + +.strange_behavior cp SLOWBRO - jr nz, .check_curse + jr nz, .curse call HandleAIStrangeBehavior jr .next_1 -.check_curse + +.curse cp GENGAR jr nz, .next_1 call z, HandleAICurse @@ -992,7 +996,7 @@ HandleAICowardice: ; return carry if Pkmn Power was used. ; input: ; c = Play Area location (PLAY_AREA_*) of Tentacool. -.CheckWhetherToUseCowardice +.CheckWhetherToUseCowardice: ld a, c ldh [hTemp_ffa0], a ld e, a diff --git a/src/engine/duel/ai/retreat.asm b/src/engine/duel/ai/retreat.asm index 238908dc..69ae64a6 100644 --- a/src/engine/duel/ai/retreat.asm +++ b/src/engine/duel/ai/retreat.asm @@ -1,7 +1,7 @@ ; determine AI score for retreating ; return carry if AI decides to retreat AIDecideWhetherToRetreat: - ld a, [wGotHeadsFromConfusionCheckDuringRetreat] + ld a, [wConfusionRetreatCheckWasUnsuccessful] or a jp nz, .no_carry xor a @@ -16,26 +16,26 @@ AIDecideWhetherToRetreat: srl a srl a sla a ; *8 - call AddToAIScore + call AIEncourage .check_status ld a, DUELVARS_ARENA_CARD_STATUS call GetTurnDuelistVariable or a - jr z, .check_ko_1 ; no status + jr z, .skip_status_check ; no status and DOUBLE_POISONED jr z, .check_cnf ; no poison ld a, 2 - call AddToAIScore + call AIEncourage .check_cnf ld a, [hl] and CNF_SLP_PRZ cp CONFUSED - jr nz, .check_ko_1 + jr nz, .skip_status_check ld a, 1 - call AddToAIScore + call AIEncourage -.check_ko_1 +.skip_status_check xor a ; PLAY_AREA_ARENA ldh [hTempPlayAreaLocation_ff9d], a call CheckIfAnyAttackKnocksOutDefendingCard @@ -47,25 +47,25 @@ AIDecideWhetherToRetreat: .active_cant_use_atk ld a, 5 - call SubFromAIScore + call AIDiscourage ld a, [wAIOpponentPrizeCount] cp 2 jr nc, .active_cant_ko_1 ld a, 35 - call SubFromAIScore + call AIDiscourage .active_cant_ko_1 call CheckIfDefendingPokemonCanKnockOut jr nc, .defending_cant_ko ld a, 2 - call AddToAIScore + call AIEncourage call CheckIfNotABossDeckID jr c, .check_resistance_1 ld a, [wAIPlayerPrizeCount] cp 2 jr nc, .check_prize_count - ld a, $01 + ld a, TRUE ld [wAIPlayEnergyCardForRetreat], a .defending_cant_ko @@ -75,14 +75,14 @@ AIDecideWhetherToRetreat: cp 2 jr nc, .check_prize_count ld a, 2 - call AddToAIScore + call AIEncourage .check_prize_count ld a, [wAIOpponentPrizeCount] cp 2 jr nc, .check_resistance_1 ld a, 2 - call SubFromAIScore + call AIDiscourage .check_resistance_1 call GetArenaCardColor @@ -92,11 +92,11 @@ AIDecideWhetherToRetreat: and b jr z, .check_weakness_1 ld a, 1 - call AddToAIScore + call AIEncourage ; check bench for Pokémon that ; the defending card is not resistant to -; if one is found, skip SubFromAIScore +; if one is found, skip AIDiscourage ld a, [wAIPlayerResistance] ld b, a ld a, DUELVARS_BENCH @@ -113,7 +113,7 @@ AIDecideWhetherToRetreat: jr .check_weakness_1 .exit_loop_resistance_1 ld a, 2 - call SubFromAIScore + call AIDiscourage .check_weakness_1 ld a, [wAIPlayerColor] @@ -122,11 +122,11 @@ AIDecideWhetherToRetreat: and b jr z, .check_resistance_2 ld a, 2 - call AddToAIScore + call AIEncourage ; check bench for Pokémon that ; is not weak to defending Pokémon -; if one is found, skip SubFromAIScore +; if one is found, skip AIDiscourage ld a, [wAIPlayerColor] ld b, a ld a, DUELVARS_BENCH @@ -142,7 +142,7 @@ AIDecideWhetherToRetreat: jr .check_resistance_2 .exit_loop_weakness_1 ld a, 3 - call SubFromAIScore + call AIDiscourage .check_resistance_2 ld a, [wAIPlayerColor] @@ -151,17 +151,17 @@ AIDecideWhetherToRetreat: and b jr z, .check_weakness_2 ld a, 3 - call SubFromAIScore + call AIDiscourage ; check bench for Pokémon that ; is the defending Pokémon's weakness -; if none is found, skip AddToAIScore +; if none is found, skip AIEncourage .check_weakness_2 ld a, [wAIPlayerWeakness] ld b, a ld a, DUELVARS_BENCH call GetTurnDuelistVariable - ld e, $00 + ld e, PLAY_AREA_BENCH_1 - 1 .loop_weakness_2 inc e ld a, [hli] @@ -175,7 +175,7 @@ AIDecideWhetherToRetreat: and b jr z, .loop_weakness_2 ld a, 2 - call AddToAIScore + call AIEncourage push de ld a, DUELVARS_ARENA_CARD @@ -191,7 +191,7 @@ AIDecideWhetherToRetreat: call CheckIfCanDamageDefendingPokemon jr nc, .check_weakness_3 ld a, 10 - call AddToAIScore + call AIEncourage jr .check_resistance_3 .check_weakness_3 @@ -202,11 +202,11 @@ AIDecideWhetherToRetreat: and b jr z, .check_resistance_3 ld a, 3 - call SubFromAIScore + call AIDiscourage ; check bench for Pokémon that ; is resistant to defending Pokémon -; if none is found, skip AddToAIScore +; if none is found, skip AIEncourage .check_resistance_3 ld a, [wAIPlayerColor] ld b, a @@ -221,11 +221,11 @@ AIDecideWhetherToRetreat: and b jr z, .loop_resistance_2 ld a, 1 - call AddToAIScore + call AIEncourage ; check bench for Pokémon that ; can KO defending Pokémon -; if none is found, skip AddToAIScore +; if none is found, skip AIEncourage .check_ko_2 ld a, DUELVARS_BENCH call GetTurnDuelistVariable @@ -253,7 +253,7 @@ AIDecideWhetherToRetreat: pop bc pop hl ld a, 2 - call AddToAIScore + call AIEncourage ; a bench Pokémon was found that can KO ; if this is a boss deck and it's at last prize card @@ -274,8 +274,8 @@ AIDecideWhetherToRetreat: jp nc, .check_defending_id .active_cant_ko_2 ld a, 40 - call AddToAIScore - ld a, $01 + call AIEncourage + ld a, TRUE ld [wAIPlayEnergyCardForRetreat], a .check_defending_id @@ -287,13 +287,13 @@ AIDecideWhetherToRetreat: ld a, e cp MR_MIME jr z, .mr_mime_or_hitmonlee - cp HITMONLEE ; ?? + cp HITMONLEE jr nz, .check_retreat_cost ; check bench if there's any Pokémon ; that can damage defending Pokémon ; this is done because of Mr. Mime's PKMN PWR -; but why Hitmonlee ($87) as well? +; and Hitmonlee's ability to attack Bench .mr_mime_or_hitmonlee xor a ; PLAY_AREA_ARENA call CheckIfCanDamageDefendingPokemon @@ -318,8 +318,8 @@ AIDecideWhetherToRetreat: pop bc pop hl ld a, 5 - call AddToAIScore - ld a, $01 + call AIEncourage + ld a, TRUE ld [wAIPlayEnergyCardForRetreat], a ; subtract from wAIScore if retreat cost is larger than 1 @@ -337,24 +337,24 @@ AIDecideWhetherToRetreat: jr nc, .three_or_more ; exactly two ld a, 1 - call SubFromAIScore + call AIDiscourage jr .one_or_none .three_or_more ld a, 2 - call SubFromAIScore + call AIDiscourage .one_or_none - call CheckIfArenaCardIsAtHalfHPCanEvolveAndUseSecondAttack + call CheckIfArenaCardIsFullyPowered jr c, .check_defending_can_ko call CountNumberOfSetUpBenchPokemon cp 2 jr c, .check_defending_can_ko - call AddToAIScore + call AIEncourage ; check bench for Pokémon that ; the defending Pokémon can't knock out -; if none is found, skip SubFromAIScore +; if none is found, skip AIDiscourage .check_defending_can_ko ld a, DUELVARS_BENCH call GetTurnDuelistVariable @@ -385,7 +385,7 @@ AIDecideWhetherToRetreat: jr .check_active_id .exit_loop_ko ld a, 20 - call SubFromAIScore + call AIDiscourage .check_active_id ld a, DUELVARS_ARENA_CARD @@ -436,10 +436,10 @@ AIDecideWhetherToRetreat: ; if player's turn and loaded attack is not a Pokémon Power OR ; if opponent's turn and wAITriedAttack == 0 -; set wcdda's bit 7 flag -Func_15b54: +; set wAIRetreatFlags's bit 7 flag +SetAIRetreatFlags: xor a - ld [wcdda], a + ld [wAIRetreatFlags], a ld a, [wWhoseTurn] cp OPPONENT_TURN jr z, .opponent @@ -457,7 +457,7 @@ Func_15b54: .set_flag ld a, %10000000 - ld [wcdda], a + ld [wAIRetreatFlags], a ret ; calculates AI score for bench Pokémon @@ -473,7 +473,7 @@ AIDecideBenchPokemonToSwitchTo: ret c ; has at least 2 Pokémon in Play Area - call Func_15b54 + call SetAIRetreatFlags call LoadDefendingPokemonColorWRAndPrizeCards ld a, 50 ld [wAIScore], a @@ -484,7 +484,7 @@ AIDecideBenchPokemonToSwitchTo: push bc jp .store_score -.next_bench +.loop_play_area push bc ld a, c ldh [hTempPlayAreaLocation_ff9d], a @@ -499,15 +499,15 @@ AIDecideBenchPokemonToSwitchTo: call CheckIfSelectedAttackIsUnusable jr c, .check_can_use_atks ld a, 10 - call AddToAIScore - ld a, [wcdda] + call AIEncourage + ld a, [wAIRetreatFlags] or %00000001 - ld [wcdda], a + ld [wAIRetreatFlags], a call CountPrizes cp 2 jp nc, .check_defending_weak ld a, 10 - call AddToAIScore + call AIEncourage ; calculates damage of both attacks ; to raise AI score accordingly @@ -531,7 +531,7 @@ AIDecideBenchPokemonToSwitchTo: ld a, [wDamage] call ConvertHPToDamageCounters_Bank5 inc a - call AddToAIScore + call AIEncourage ret ; if an energy card that is needed is found in hand @@ -545,7 +545,7 @@ AIDecideBenchPokemonToSwitchTo: ld a, [wDamage] call ConvertHPToDamageCounters_Bank5 srl a - call AddToAIScore + call AIEncourage ; if no energies attached to card, lower AI score .check_attached_energy @@ -556,7 +556,7 @@ AIDecideBenchPokemonToSwitchTo: or a jr nz, .check_mr_mime ld a, 1 - call SubFromAIScore + call AIDiscourage ; if can damage Mr Mime, raise AI score .check_mr_mime @@ -579,7 +579,7 @@ AIDecideBenchPokemonToSwitchTo: jr z, .check_defending_weak .can_damage ld a, 5 - call AddToAIScore + call AIEncourage ; if defending card is weak to this card, raise AI score .check_defending_weak @@ -594,7 +594,7 @@ AIDecideBenchPokemonToSwitchTo: and [hl] jr z, .check_defending_resist ld a, 3 - call AddToAIScore + call AIEncourage ; if defending card is resistant to this card, lower AI score .check_defending_resist @@ -603,7 +603,7 @@ AIDecideBenchPokemonToSwitchTo: and [hl] jr z, .check_resistance ld a, 2 - call SubFromAIScore + call AIDiscourage ; if this card is resistant to defending Pokémon, raise AI score .check_resistance @@ -612,7 +612,7 @@ AIDecideBenchPokemonToSwitchTo: and [hl] jr z, .check_weakness ld a, 2 - call AddToAIScore + call AIEncourage ; if this card is weak to defending Pokémon, lower AI score .check_weakness @@ -621,7 +621,7 @@ AIDecideBenchPokemonToSwitchTo: and [hl] jr z, .check_retreat_cost ld a, 3 - call SubFromAIScore + call AIDiscourage ; if this card's retreat cost < 2, raise AI score ; if this card's retreat cost > 2, lower AI score @@ -631,18 +631,18 @@ AIDecideBenchPokemonToSwitchTo: jr c, .one_or_none jr z, .check_player_prize_count ld a, 1 - call SubFromAIScore + call AIDiscourage jr .check_player_prize_count .one_or_none ld a, 1 - call AddToAIScore + call AIEncourage -; if wcdda != $81 +; if wAIRetreatFlags != $81 ; if defending Pokémon can KO this card ; if player is not at last prize card, lower 3 from AI score ; if player is at last prize card, lower 10 from AI score .check_player_prize_count - ld a, [wcdda] + ld a, [wAIRetreatFlags] cp %10000000 | %00000001 jr z, .check_hp call CheckIfDefendingPokemonCanKnockOut @@ -654,7 +654,7 @@ AIDecideBenchPokemonToSwitchTo: ld e, 10 .lower_score_1 ld a, e - call SubFromAIScore + call AIDiscourage ; if this card's HP is 0, make AI score 0 .check_hp @@ -672,7 +672,7 @@ AIDecideBenchPokemonToSwitchTo: ld a, 4 call CalculateBDividedByA_Bank5 call ConvertHPToDamageCounters_Bank5 - call AddToAIScore + call AIEncourage ; raise AI score if ; - is a Mr Mime OR @@ -684,24 +684,26 @@ AIDecideBenchPokemonToSwitchTo: cp MR_MIME jr z, .raise_score cp MEW_LV8 - jr nz, .asm_15cf0 + jr nz, .check_if_has_bench_utility ld a, DUELVARS_ARENA_CARD call GetNonTurnDuelistVariable call LoadCardDataToBuffer2_FromDeckIndex ld a, [wLoadedCard2Stage] or a - jr z, .asm_15cf0 + jr z, .check_if_has_bench_utility .raise_score ld a, 5 - call AddToAIScore + call AIEncourage -; if wLoadedCard1Unknown2 == $01, lower AI score -.asm_15cf0 - ld a, [wLoadedCard1Unknown2] - cp $01 +; if wLoadedCard1AIInfo == AI_INFO_BENCH_UTILITY, +; lower AI score +.check_if_has_bench_utility + ld a, [wLoadedCard1AIInfo] + ; bug, should mask out HAS_EVOLUTION flag first + cp AI_INFO_BENCH_UTILITY jr nz, .mysterious_fossil_or_clefairy_doll ld a, 2 - call SubFromAIScore + call AIDiscourage ; if card is Mysterious Fossil or Clefairy Doll, ; lower AI score @@ -713,7 +715,7 @@ AIDecideBenchPokemonToSwitchTo: jr nz, .ai_score_bonus .lower_score_2 ld a, 10 - call SubFromAIScore + call AIDiscourage .ai_score_bonus ld b, a @@ -721,7 +723,7 @@ AIDecideBenchPokemonToSwitchTo: or a jr z, .store_score ld h, a - ld a, [wAICardListRetreatBonus] + ld a, [wAICardListRetreatBonus + 0] ld l, a .loop_ids @@ -734,13 +736,13 @@ AIDecideBenchPokemonToSwitchTo: cp $80 jr c, .subtract_score sub $80 - call AddToAIScore + call AIEncourage jr .next_id .subtract_score ld c, a ld a, $80 sub c - call SubFromAIScore + call AIDiscourage .next_id inc hl jr .loop_ids @@ -756,7 +758,7 @@ AIDecideBenchPokemonToSwitchTo: pop bc inc c dec b - jp nz, .next_bench + jp nz, .loop_play_area ; done xor a diff --git a/src/engine/duel/ai/special_attacks.asm b/src/engine/duel/ai/special_attacks.asm index 797c5ca5..7263785b 100644 --- a/src/engine/duel/ai/special_attacks.asm +++ b/src/engine/duel/ai/special_attacks.asm @@ -347,7 +347,7 @@ HandleSpecialAIAttacks: ld a, DUELVARS_BENCH call GetTurnDuelistVariable - lb de, 0, 0 + lb de, 0, PLAY_AREA_BENCH_1 - 1 .loop_earthquake inc e ld a, [hli] @@ -355,15 +355,23 @@ HandleSpecialAIAttacks: jr z, .count_prizes ld a, e add DUELVARS_ARENA_CARD_HP + ; bug, GetTurnDuelistVariable clobbers hl + ; uncomment the following lines to preserve hl + ; push hl call GetTurnDuelistVariable + ; pop hl cp 20 jr nc, .loop_earthquake inc d jr .loop_earthquake .count_prizes + ; bug, this is supposed to count the player's prize cards + ; not the opponent's, missing calls to SwapTurn push de + ; call SwapTurn call CountPrizes + ; call SwapTurn pop de cp d jp c, .zero_score @@ -409,25 +417,23 @@ CheckWhetherToSwitchToFirstAttack: cp $50 jr c, .keep_second_attack -; first attack has more than minimum score to be used. -; check if second attack can KO. -; in case it can't, the AI keeps it as the attack to be used. -; (possibly due to the assumption that if the -; second attack cannot KO, the first attack can't KO as well.) +; first attack has more than minimum score to be used, +; check if it can KO, in case it can't +; then the AI keeps second attack as selection. xor a ; PLAY_AREA_ARENA ldh [hTempPlayAreaLocation_ff9d], a + ; a = FIRST_ATTACK_OR_PKMN_POWER call EstimateDamage_VersusDefendingCard ld a, DUELVARS_ARENA_CARD_HP call GetNonTurnDuelistVariable ld hl, wDamage - sub [hl] + sub [hl] ; HP - damage jr z, .check_flag - jr nc, .keep_second_attack + jr nc, .keep_second_attack ; cannot KO -; second attack can ko, check its flag. +; first attack can ko, check flags from second attack ; in case its effect is to heal user or nullify/weaken damage ; next turn, keep second attack as the option. -; otherwise switch to the first attack. .check_flag ld a, DUELVARS_ARENA_CARD call GetTurnDuelistVariable diff --git a/src/engine/duel/ai/trainer_cards.asm b/src/engine/duel/ai/trainer_cards.asm index 8be0821b..c7bd8aed 100644 --- a/src/engine/duel/ai/trainer_cards.asm +++ b/src/engine/duel/ai/trainer_cards.asm @@ -171,7 +171,7 @@ AIPlay_Potion: ; next turn after using Potion. ; if it cannot, return carry. ; also take into account whether attack is high recoil. -AIDecide_Potion1: +AIDecide_Potion_Phase07: farcall AIDecideWhetherToRetreat jr c, .no_carry call AICheckIfAttackIsHighRecoil @@ -213,7 +213,7 @@ AIDecide_Potion1: ; output: ; a = card to use Potion on; ; carry set if Potion should be used. -AIDecide_Potion2: +AIDecide_Potion_Phase10: xor a ; PLAY_AREA_ARENA ldh [hTempPlayAreaLocation_ff9d], a farcall CheckIfDefendingPokemonCanKnockOut diff --git a/src/engine/duel/core.asm b/src/engine/duel/core.asm index 9b425da4..ccc3e45c 100644 --- a/src/engine/duel/core.asm +++ b/src/engine/duel/core.asm @@ -479,7 +479,7 @@ DuelMenu_Retreat: cp CONFUSED ldh [hTemp_ffa0], a jr nz, .not_confused - ld a, [wGotHeadsFromConfusionCheckDuringRetreat] + ld a, [wConfusionRetreatCheckWasUnsuccessful] or a jr nz, .unable_due_to_confusion call CheckAbleToRetreat @@ -5810,16 +5810,16 @@ AttemptRetreat: ldtx de, ConfusionCheckRetreatText call TossCoin jr c, .success - ld a, 1 - ld [wGotHeadsFromConfusionCheckDuringRetreat], a + ld a, TRUE + ld [wConfusionRetreatCheckWasUnsuccessful], a scf ret .success ldh a, [hTempPlayAreaLocation_ffa1] ld e, a call SwapArenaWithBenchPokemon - xor a - ld [wGotHeadsFromConfusionCheckDuringRetreat], a + xor a ; FALSE + ld [wConfusionRetreatCheckWasUnsuccessful], a ret ; given a number between 0-255 in a, converts it to TX_SYMBOL format, @@ -7149,7 +7149,7 @@ ConvertSpecialTrainerCardToPokemon:: ld bc, CARD_DATA_HP add hl, bc ld de, .trainer_to_pkmn_data - ld c, CARD_DATA_UNKNOWN2 - CARD_DATA_HP + ld c, CARD_DATA_AI_INFO - CARD_DATA_HP .loop ld a, [de] inc de @@ -7677,7 +7677,7 @@ InitVariablesToBeginDuel: InitVariablesToBeginTurn: xor a ld [wAlreadyPlayedEnergy], a - ld [wGotHeadsFromConfusionCheckDuringRetreat], a + ld [wConfusionRetreatCheckWasUnsuccessful], a ld [wGotHeadsFromSandAttackOrSmokescreenCheck], a ldh a, [hWhoseTurn] ld [wWhoseTurn], a diff --git a/src/home/duel.asm b/src/home/duel.asm index 3e87b64e..77d9ba9b 100644 --- a/src/home/duel.asm +++ b/src/home/duel.asm @@ -1725,10 +1725,10 @@ ApplyTransparencyIfApplicable:: ld de, 0 ret -; return carry and 1 into wGotHeadsFromConfusionCheck if damage will be dealt to oneself due to confusion +; return carry and TRUE in wConfusionAttackCheckWasUnsuccessful if damage will be dealt to oneself due to confusion CheckSelfConfusionDamage:: - xor a - ld [wGotHeadsFromConfusionCheck], a + xor a ; FALSE + ld [wConfusionAttackCheckWasUnsuccessful], a ld a, DUELVARS_ARENA_CARD_STATUS call GetTurnDuelistVariable and CNF_SLP_PRZ @@ -1740,8 +1740,8 @@ CheckSelfConfusionDamage:: ldtx de, ConfusionCheckDamageText call TossCoin jr c, .no_confusion_damage - ld a, 1 - ld [wGotHeadsFromConfusionCheck], a + ld a, TRUE + ld [wConfusionAttackCheckWasUnsuccessful], a scf ret .no_confusion_damage diff --git a/src/home/substatus.asm b/src/home/substatus.asm index f1df0111..963baab0 100644 --- a/src/home/substatus.asm +++ b/src/home/substatus.asm @@ -68,6 +68,7 @@ HandleDamageReductionExceptSubstatus2:: call GetTurnDuelistVariable or a jr z, .not_affected_by_substatus1 + cp SUBSTATUS1_NO_DAMAGE_STIFFEN jr z, .no_damage cp SUBSTATUS1_NO_DAMAGE_10 @@ -84,6 +85,7 @@ HandleDamageReductionExceptSubstatus2:: jr z, .prevent_less_than_40_damage cp SUBSTATUS1_HALVE_DAMAGE jr z, .halve_damage + .not_affected_by_substatus1 call CheckIsIncapableOfUsingPkmnPower_ArenaCard ret c @@ -93,33 +95,38 @@ HandleDamageReductionExceptSubstatus2:: ret z ld a, [wTempNonTurnDuelistCardID] cp MR_MIME - jr z, .prevent_less_than_30_damage ; invisible wall + jr z, .invisible_wall cp KABUTO - jr z, .halve_damage2 ; kabuto armor + jr z, .kabuto_armor ret + .no_damage ld de, 0 ret + .reduce_damage_by_10 ld hl, -10 add hl, de ld e, l ld d, h ret + .reduce_damage_by_20 ld hl, -20 add hl, de ld e, l ld d, h ret + .prevent_less_than_40_damage ld bc, 40 call CompareDEtoBC ret nc ld de, 0 ret + .halve_damage - sla d + sla d ; bug, should be sra d rr e bit 0, e ret z @@ -128,7 +135,8 @@ HandleDamageReductionExceptSubstatus2:: ld e, l ld d, h ret -.prevent_less_than_30_damage + +.invisible_wall ld a, [wLoadedAttackCategory] cp POKEMON_POWER ret z @@ -137,8 +145,9 @@ HandleDamageReductionExceptSubstatus2:: ret c ld de, 0 ret -.halve_damage2 - sla d + +.kabuto_armor + sla d ; bug, should be sra d rr e bit 0, e ret z @@ -331,7 +340,9 @@ HandleSandAttackOrSmokescreenSubstatus:: scf ret -; return carry if the turn holder's arena card is under the effects of sand attack or smokescreen +; return carry if the turn holder's arena card is under +; the effects of sand attack or smokescreen +; and got tails on the coin toss CheckSandAttackOrSmokescreenSubstatus:: ld a, DUELVARS_ARENA_CARD_SUBSTATUS2 call GetTurnDuelistVariable @@ -348,7 +359,8 @@ CheckSandAttackOrSmokescreenSubstatus:: .card_is_affected ld a, [wGotHeadsFromSandAttackOrSmokescreenCheck] or a - ret nz + ret nz ; got heads + ; got tails scf ret diff --git a/src/macros/wram.asm b/src/macros/wram.asm index 020dc6b7..1d4eec70 100644 --- a/src/macros/wram.asm +++ b/src/macros/wram.asm @@ -17,12 +17,12 @@ MACRO card_data_struct \1Resistance:: ds 1 \1Category:: ds 2 \1PokedexNumber:: ds 1 -\1Unknown1:: ds 1 +ds 1 \1Level:: ds 1 \1Length:: ds 2 \1Weight:: ds 2 \1Description:: ds 2 -\1Unknown2:: ds 1 +\1AIInfo:: ds 1 ENDM MACRO atk_data_struct diff --git a/src/wram.asm b/src/wram.asm index 9d3dd165..c1c182ae 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -652,8 +652,8 @@ wGotHeadsFromSandAttackOrSmokescreenCheck:: ; cc0a wAlreadyPlayedEnergy:: ; cc0b ds $1 -; set to 1 if the confusion check coin toss in AttemptRetreat is heads -wGotHeadsFromConfusionCheckDuringRetreat:: ; cc0c +; set to TRUE if the confusion check coin toss in AttemptRetreat is tails +wConfusionRetreatCheckWasUnsuccessful:: ; cc0c ds $1 ; DUELIST_TYPE_* of the turn holder @@ -780,8 +780,8 @@ wNoDamageOrEffect:: ; ccc7 wNumberPrizeCardsToTake:: ; ccc8 ds $1 -; set to 1 if the coin toss in the confusion check is heads (CheckSelfConfusionDamage) -wGotHeadsFromConfusionCheck:: ; ccc9 +; set to TRUE if the coin toss in the confusion check is tails (CheckSelfConfusionDamage) +wConfusionAttackCheckWasUnsuccessful:: ; ccc9 ds $1 ; used to store card indices of all stages, in order, of a Play Area Pokémon @@ -1155,8 +1155,8 @@ wAIPluspowerAttack:: ; cdd6 ; whether AI is allowed to play an energy card ; from the hand in order to retreat arena card -; $00 = not allowed -; $01 = allowed +; FALSE = not allowed +; TRUE = allowed wAIPlayEnergyCardForRetreat:: ; cdd7 ds $1 @@ -1172,7 +1172,12 @@ wAIEnergyAttachLogicFlags:: ; cdd8 wAIExecuteProcessedAttack:: ; cdd9 ds $1 -wcdda:: ; cdda +; flags used by AI for retreat logic +; if bit 0 set, then it means the current Pokémon +; can KO the defending card with one of its attacks +; if bit 7 is set, then it means the switch is due +; to the effect of an attack (not Pkmn Power) +wAIRetreatFlags:: ; cdda ds $1 wAITriedAttack:: ; cddb @@ -1194,7 +1199,7 @@ wTempAIScore:: ; cde3 wPlayAreaEnergyAIScore:: ; cde4 ds MAX_PLAY_AREA_POKEMON -wcdea:: ; cdea +wSamePokemonEnergyScore:: ; cdea ds MAX_PLAY_AREA_POKEMON ; whether AI cannot inflict damage on player's active Pokémon @@ -1228,10 +1233,10 @@ wCurCardCanKO:: ; cdf4 ds $4 -wcdf9:: ; cdf9 +wSamePokemonCardID:: ; cdf9 ds $1 -wcdfa:: ; cdfa +wSamePokemonEnergyScoreHandled:: ; cdfa ds MAX_PLAY_AREA_POKEMON wAIFirstAttackDamage:: ; ce00