From b5417fafec7dd37cb4be391f3bd3d4541a2a381e Mon Sep 17 00:00:00 2001 From: Remy Oukaour Date: Tue, 26 Dec 2017 17:47:05 -0500 Subject: Split battle/ into data/ and engine/ components --- Makefile | 34 +- battle/ai/items.asm | 882 --- battle/ai/move.asm | 221 - battle/ai/redundant.asm | 198 - battle/ai/scoring.asm | 3598 --------- battle/ai/switch.asm | 672 -- battle/anim_commands.asm | 1515 ---- battle/anim_gfx.asm | 41 - battle/anim_objects.asm | 9 - battle/anims.asm | 5175 ------------ battle/bg_effects.asm | 2957 ------- battle/core.asm | 9511 ---------------------- battle/effect_command_pointers.asm | 180 - battle/effect_commands.asm | 10069 ------------------------ battle/effects/attract.asm | 79 - battle/effects/curse.asm | 97 - battle/effects/endure.asm | 17 - battle/effects/foresight.asm | 23 - battle/effects/metronome.asm | 61 - battle/effects/mirror_move.asm | 52 - battle/effects/nightmare.asm | 38 - battle/effects/perish_song.asm | 40 - battle/effects/present.asm | 93 - battle/effects/protect.asm | 80 - battle/effects/rollout.asm | 99 - battle/effects/sandstorm.asm | 19 - battle/effects/spikes.asm | 27 - battle/effects/thief.asm | 116 - battle/effects/transform.asm | 141 - battle/hidden_power.asm | 111 - battle/link_result.asm | 162 - battle/menu.asm | 118 - battle/misc.asm | 257 - battle/move_names.asm | 252 - battle/moves/move_descriptions.asm | 1270 --- battle/moves/move_effects.asm | 2075 ----- battle/moves/move_effects_pointers.asm | 159 - battle/moves/moves.asm | 265 - battle/objects/data.asm | 209 - battle/objects/engine.asm | 314 - battle/objects/framesets.asm | 1270 --- battle/objects/functions.asm | 4156 ---------- battle/objects/helpers.asm | 130 - battle/objects/oam.asm | 1085 --- battle/objects/object_gfx.asm | 51 - battle/sliding_intro.asm | 104 - battle/trainer_huds.asm | 269 - battle/type_matchup.asm | 128 - battle/used_move_text.asm | 341 - constants.asm | 1 + constants/animation_constants.asm | 24 +- constants/battle_constants.asm | 4 +- constants/item_constants.asm | 2 +- constants/map_setup_constants.asm | 42 +- constants/move_constants.asm | 8 +- constants/pokemon_data_constants.asm | 12 + constants/sprite_anim_constants.asm | 316 + constants/sprite_data_constants.asm | 317 - constants/type_constants.asm | 4 +- data/anims/ball_colors.asm | 16 + data/anims/framesets.asm | 1271 +++ data/anims/oam.asm | 1086 +++ data/anims/object_gfx.asm | 51 + data/anims/objects.asm | 209 + data/battle/ball_colors.asm | 16 - data/battle/flee_mons.asm | 36 - data/flypoints.asm | 38 - data/maps/flypoints.asm | 38 + data/maps/map_setup_scripts.asm | 177 + data/moves/effect_command_pointers.asm | 180 + data/moves/move_anims.asm | 5176 ++++++++++++ data/moves/move_descriptions.asm | 1270 +++ data/moves/move_effects.asm | 2075 +++++ data/moves/move_effects_pointers.asm | 159 + data/moves/move_names.asm | 252 + data/moves/moves.asm | 265 + data/moves/tmhm_moves.asm | 66 + data/mystery_gift/decos.asm | 40 - data/mystery_gift/items.asm | 40 - data/mystery_gift_decos.asm | 40 + data/mystery_gift_items.asm | 40 + data/sprite_anim_frames.asm | 499 -- data/sprite_anim_oam.asm | 1131 --- data/sprite_anim_seqs.asm | 49 - data/sprites/framesets.asm | 499 ++ data/sprites/oam.asm | 1131 +++ data/sprites/sequences.asm | 49 + data/tmhm_moves.asm | 69 - data/type_matchups.asm | 125 + data/type_names.asm | 50 + data/wild/flee_mons.asm | 36 + docs/bugs_and_glitches.md | 26 +- docs/move_anim_commands.md | 2 +- docs/pic_animations.md | 2 +- engine/anim_hp_bar.asm | 435 - engine/anims/anim_commands.asm | 1514 ++++ engine/anims/bg_effects.asm | 2958 +++++++ engine/anims/engine.asm | 314 + engine/anims/functions.asm | 4157 ++++++++++ engine/anims/helpers.asm | 130 + engine/battle/ai/items.asm | 882 +++ engine/battle/ai/move.asm | 221 + engine/battle/ai/redundant.asm | 198 + engine/battle/ai/scoring.asm | 3598 +++++++++ engine/battle/ai/switch.asm | 672 ++ engine/battle/anim_hp_bar.asm | 435 + engine/battle/battle_transition.asm | 873 ++ engine/battle/core.asm | 9511 ++++++++++++++++++++++ engine/battle/effect_commands.asm | 10066 +++++++++++++++++++++++ engine/battle/effect_commands/attract.asm | 79 + engine/battle/effect_commands/curse.asm | 97 + engine/battle/effect_commands/endure.asm | 17 + engine/battle/effect_commands/foresight.asm | 23 + engine/battle/effect_commands/metronome.asm | 61 + engine/battle/effect_commands/mirror_move.asm | 52 + engine/battle/effect_commands/nightmare.asm | 38 + engine/battle/effect_commands/perish_song.asm | 40 + engine/battle/effect_commands/present.asm | 93 + engine/battle/effect_commands/protect.asm | 80 + engine/battle/effect_commands/rollout.asm | 99 + engine/battle/effect_commands/sandstorm.asm | 19 + engine/battle/effect_commands/spikes.asm | 27 + engine/battle/effect_commands/thief.asm | 116 + engine/battle/effect_commands/transform.asm | 141 + engine/battle/hidden_power.asm | 111 + engine/battle/link_result.asm | 162 + engine/battle/menu.asm | 118 + engine/battle/misc.asm | 257 + engine/battle/read_trainer_attributes.asm | 64 + engine/battle/read_trainer_party.asm | 398 + engine/battle/sliding_intro.asm | 104 + engine/battle/start_battle.asm | 197 + engine/battle/trainer_huds.asm | 269 + engine/battle/trainer_scripts.asm | 31 + engine/battle/used_move_text.asm | 338 + engine/battle_transition.asm | 873 -- engine/map_setup.asm | 180 +- engine/mystery_gift_2.asm | 4 +- engine/pokegear.asm | 2 +- engine/read_trainer_attributes.asm | 64 - engine/read_trainer_party.asm | 398 - engine/sprites.asm | 6 +- engine/start_battle.asm | 197 - engine/tmhm.asm | 2 +- engine/trainer_scripts.asm | 31 - engine/types.asm | 101 + gfx/anims.asm | 41 + gfx/anims/aeroblast.2bpp.lz.2f07c4ea | Bin 0 -> 128 bytes gfx/anims/aeroblast.png | Bin 0 -> 187 bytes gfx/anims/angels.2bpp.lz.b026d81e | Bin 0 -> 368 bytes gfx/anims/angels.png | Bin 0 -> 363 bytes gfx/anims/beam.2bpp.lz.80b6d613 | Bin 0 -> 144 bytes gfx/anims/beam.png | Bin 0 -> 562 bytes gfx/anims/bubble.2bpp.lz.03b8ac99 | Bin 0 -> 160 bytes gfx/anims/bubble.png | Bin 0 -> 237 bytes gfx/anims/charge.2bpp.lz.95d3ea98 | Bin 0 -> 112 bytes gfx/anims/charge.png | Bin 0 -> 188 bytes gfx/anims/cut.2bpp.lz.03d343ed | Bin 0 -> 96 bytes gfx/anims/cut.png | Bin 0 -> 170 bytes gfx/anims/egg.2bpp.lz.41dd1a53 | Bin 0 -> 128 bytes gfx/anims/egg.png | Bin 0 -> 200 bytes gfx/anims/explosion.2bpp.lz.55fc334f | Bin 0 -> 96 bytes gfx/anims/explosion.png | Bin 0 -> 157 bytes gfx/anims/fire.2bpp.lz.d7701cda | Bin 0 -> 96 bytes gfx/anims/fire.png | Bin 0 -> 153 bytes gfx/anims/flower.2bpp.lz.1bc2e9d2 | Bin 0 -> 96 bytes gfx/anims/flower.png | Bin 0 -> 149 bytes gfx/anims/globe.2bpp.lz.710dbb8e | Bin 0 -> 240 bytes gfx/anims/globe.png | Bin 0 -> 292 bytes gfx/anims/haze.2bpp.lz.91424607 | Bin 0 -> 144 bytes gfx/anims/haze.png | Bin 0 -> 173 bytes gfx/anims/hit.2bpp.lz.2b3c83f2 | Bin 0 -> 240 bytes gfx/anims/hit.png | Bin 0 -> 306 bytes gfx/anims/horn.2bpp.lz.48908aae | Bin 0 -> 96 bytes gfx/anims/horn.png | Bin 0 -> 179 bytes gfx/anims/ice.2bpp.lz.664d900f | Bin 0 -> 64 bytes gfx/anims/ice.png | Bin 0 -> 137 bytes gfx/anims/lightning.2bpp.lz.a88fc131 | Bin 0 -> 320 bytes gfx/anims/lightning.png | Bin 0 -> 820 bytes gfx/anims/misc.2bpp.lz.4b20c3d7 | Bin 0 -> 416 bytes gfx/anims/misc.png | Bin 0 -> 1082 bytes gfx/anims/noise.2bpp.lz.acb4a76e | Bin 0 -> 192 bytes gfx/anims/noise.png | Bin 0 -> 526 bytes gfx/anims/objects.2bpp.lz.83f812de | Bin 0 -> 224 bytes gfx/anims/objects.png | Bin 0 -> 705 bytes gfx/anims/plant.2bpp.lz.4a00c417 | Bin 0 -> 224 bytes gfx/anims/plant.png | Bin 0 -> 293 bytes gfx/anims/poison.2bpp.lz.fc7dc9c1 | Bin 0 -> 112 bytes gfx/anims/poison.png | Bin 0 -> 166 bytes gfx/anims/pokeball.2bpp.lz.c58f7e01 | Bin 0 -> 80 bytes gfx/anims/pokeball.png | Bin 0 -> 388 bytes gfx/anims/powder.2bpp.lz.bfd566bb | Bin 0 -> 32 bytes gfx/anims/powder.png | Bin 0 -> 100 bytes gfx/anims/psychic.2bpp.lz.d80f285c | Bin 0 -> 112 bytes gfx/anims/psychic.png | Bin 0 -> 175 bytes gfx/anims/reflect.2bpp.lz.9a9c822d | Bin 0 -> 112 bytes gfx/anims/reflect.png | Bin 0 -> 211 bytes gfx/anims/rocks.2bpp.lz.73d0153e | Bin 0 -> 240 bytes gfx/anims/rocks.png | Bin 0 -> 669 bytes gfx/anims/rope.2bpp.lz.209d63dd | Bin 0 -> 192 bytes gfx/anims/rope.png | Bin 0 -> 256 bytes gfx/anims/sand.2bpp.lz.c87c0eaa | Bin 0 -> 96 bytes gfx/anims/sand.png | Bin 0 -> 384 bytes gfx/anims/shapes.2bpp.lz.262d77f0 | Bin 0 -> 160 bytes gfx/anims/shapes.png | Bin 0 -> 237 bytes gfx/anims/shine.2bpp.lz.5fb79056 | Bin 0 -> 224 bytes gfx/anims/shine.png | Bin 0 -> 273 bytes gfx/anims/skyattack.2bpp.lz.31738ab8 | Bin 0 -> 352 bytes gfx/anims/skyattack.png | Bin 0 -> 393 bytes gfx/anims/smoke.2bpp.lz.aa05905e | Bin 0 -> 144 bytes gfx/anims/smoke.png | Bin 0 -> 191 bytes gfx/anims/speed.2bpp.lz.1732b364 | Bin 0 -> 80 bytes gfx/anims/speed.png | Bin 0 -> 136 bytes gfx/anims/status.2bpp.lz.0c0aa13e | Bin 0 -> 288 bytes gfx/anims/status.png | Bin 0 -> 364 bytes gfx/anims/water.2bpp.lz.7b52ed12 | Bin 0 -> 208 bytes gfx/anims/water.png | Bin 0 -> 277 bytes gfx/anims/wave.2bpp.lz.bee99402 | Bin 0 -> 160 bytes gfx/anims/wave.png | Bin 0 -> 205 bytes gfx/anims/web.2bpp.lz.80e3d480 | Bin 0 -> 128 bytes gfx/anims/web.png | Bin 0 -> 191 bytes gfx/anims/whip.2bpp.lz.d80d8d6e | Bin 0 -> 128 bytes gfx/anims/whip.png | Bin 0 -> 210 bytes gfx/anims/wind.2bpp.lz.5a785180 | Bin 0 -> 192 bytes gfx/anims/wind.png | Bin 0 -> 286 bytes gfx/fx/aeroblast.2bpp.lz.2f07c4ea | Bin 128 -> 0 bytes gfx/fx/aeroblast.png | Bin 187 -> 0 bytes gfx/fx/angels.2bpp.lz.b026d81e | Bin 368 -> 0 bytes gfx/fx/angels.png | Bin 363 -> 0 bytes gfx/fx/beam.2bpp.lz.80b6d613 | Bin 144 -> 0 bytes gfx/fx/beam.png | Bin 562 -> 0 bytes gfx/fx/bubble.2bpp.lz.03b8ac99 | Bin 160 -> 0 bytes gfx/fx/bubble.png | Bin 237 -> 0 bytes gfx/fx/charge.2bpp.lz.95d3ea98 | Bin 112 -> 0 bytes gfx/fx/charge.png | Bin 188 -> 0 bytes gfx/fx/cut.2bpp.lz.03d343ed | Bin 96 -> 0 bytes gfx/fx/cut.png | Bin 170 -> 0 bytes gfx/fx/egg.2bpp.lz.41dd1a53 | Bin 128 -> 0 bytes gfx/fx/egg.png | Bin 200 -> 0 bytes gfx/fx/explosion.2bpp.lz.55fc334f | Bin 96 -> 0 bytes gfx/fx/explosion.png | Bin 157 -> 0 bytes gfx/fx/fire.2bpp.lz.d7701cda | Bin 96 -> 0 bytes gfx/fx/fire.png | Bin 153 -> 0 bytes gfx/fx/flower.2bpp.lz.1bc2e9d2 | Bin 96 -> 0 bytes gfx/fx/flower.png | Bin 149 -> 0 bytes gfx/fx/globe.2bpp.lz.710dbb8e | Bin 240 -> 0 bytes gfx/fx/globe.png | Bin 292 -> 0 bytes gfx/fx/haze.2bpp.lz.91424607 | Bin 144 -> 0 bytes gfx/fx/haze.png | Bin 173 -> 0 bytes gfx/fx/hit.2bpp.lz.2b3c83f2 | Bin 240 -> 0 bytes gfx/fx/hit.png | Bin 306 -> 0 bytes gfx/fx/horn.2bpp.lz.48908aae | Bin 96 -> 0 bytes gfx/fx/horn.png | Bin 179 -> 0 bytes gfx/fx/ice.2bpp.lz.664d900f | Bin 64 -> 0 bytes gfx/fx/ice.png | Bin 137 -> 0 bytes gfx/fx/lightning.2bpp.lz.a88fc131 | Bin 320 -> 0 bytes gfx/fx/lightning.png | Bin 820 -> 0 bytes gfx/fx/misc.2bpp.lz.4b20c3d7 | Bin 416 -> 0 bytes gfx/fx/misc.png | Bin 1082 -> 0 bytes gfx/fx/noise.2bpp.lz.acb4a76e | Bin 192 -> 0 bytes gfx/fx/noise.png | Bin 526 -> 0 bytes gfx/fx/objects.2bpp.lz.83f812de | Bin 224 -> 0 bytes gfx/fx/objects.png | Bin 705 -> 0 bytes gfx/fx/plant.2bpp.lz.4a00c417 | Bin 224 -> 0 bytes gfx/fx/plant.png | Bin 293 -> 0 bytes gfx/fx/poison.2bpp.lz.fc7dc9c1 | Bin 112 -> 0 bytes gfx/fx/poison.png | Bin 166 -> 0 bytes gfx/fx/pokeball.2bpp.lz.c58f7e01 | Bin 80 -> 0 bytes gfx/fx/pokeball.png | Bin 388 -> 0 bytes gfx/fx/powder.2bpp.lz.bfd566bb | Bin 32 -> 0 bytes gfx/fx/powder.png | Bin 100 -> 0 bytes gfx/fx/psychic.2bpp.lz.d80f285c | Bin 112 -> 0 bytes gfx/fx/psychic.png | Bin 175 -> 0 bytes gfx/fx/reflect.2bpp.lz.9a9c822d | Bin 112 -> 0 bytes gfx/fx/reflect.png | Bin 211 -> 0 bytes gfx/fx/rocks.2bpp.lz.73d0153e | Bin 240 -> 0 bytes gfx/fx/rocks.png | Bin 669 -> 0 bytes gfx/fx/rope.2bpp.lz.209d63dd | Bin 192 -> 0 bytes gfx/fx/rope.png | Bin 256 -> 0 bytes gfx/fx/sand.2bpp.lz.c87c0eaa | Bin 96 -> 0 bytes gfx/fx/sand.png | Bin 384 -> 0 bytes gfx/fx/shapes.2bpp.lz.262d77f0 | Bin 160 -> 0 bytes gfx/fx/shapes.png | Bin 237 -> 0 bytes gfx/fx/shine.2bpp.lz.5fb79056 | Bin 224 -> 0 bytes gfx/fx/shine.png | Bin 273 -> 0 bytes gfx/fx/skyattack.2bpp.lz.31738ab8 | Bin 352 -> 0 bytes gfx/fx/skyattack.png | Bin 393 -> 0 bytes gfx/fx/smoke.2bpp.lz.aa05905e | Bin 144 -> 0 bytes gfx/fx/smoke.png | Bin 191 -> 0 bytes gfx/fx/speed.2bpp.lz.1732b364 | Bin 80 -> 0 bytes gfx/fx/speed.png | Bin 136 -> 0 bytes gfx/fx/status.2bpp.lz.0c0aa13e | Bin 288 -> 0 bytes gfx/fx/status.png | Bin 364 -> 0 bytes gfx/fx/water.2bpp.lz.7b52ed12 | Bin 208 -> 0 bytes gfx/fx/water.png | Bin 277 -> 0 bytes gfx/fx/wave.2bpp.lz.bee99402 | Bin 160 -> 0 bytes gfx/fx/wave.png | Bin 205 -> 0 bytes gfx/fx/web.2bpp.lz.80e3d480 | Bin 128 -> 0 bytes gfx/fx/web.png | Bin 191 -> 0 bytes gfx/fx/whip.2bpp.lz.d80d8d6e | Bin 128 -> 0 bytes gfx/fx/whip.png | Bin 210 -> 0 bytes gfx/fx/wind.2bpp.lz.5a785180 | Bin 192 -> 0 bytes gfx/fx/wind.png | Bin 286 -> 0 bytes macros/scripts/effect_commands.asm | 2 +- macros/scripts/move_anim.asm | 2 +- main.asm | 70 +- pokecrystal.link | 2 +- text/battle_tower.asm | 1 - text/types.asm | 149 - 309 files changed, 53410 insertions(+), 53419 deletions(-) delete mode 100644 battle/ai/items.asm delete mode 100755 battle/ai/move.asm delete mode 100755 battle/ai/redundant.asm delete mode 100644 battle/ai/scoring.asm delete mode 100755 battle/ai/switch.asm delete mode 100644 battle/anim_commands.asm delete mode 100644 battle/anim_gfx.asm delete mode 100644 battle/anim_objects.asm delete mode 100644 battle/anims.asm delete mode 100644 battle/bg_effects.asm delete mode 100644 battle/core.asm delete mode 100644 battle/effect_command_pointers.asm delete mode 100644 battle/effect_commands.asm delete mode 100755 battle/effects/attract.asm delete mode 100644 battle/effects/curse.asm delete mode 100644 battle/effects/endure.asm delete mode 100644 battle/effects/foresight.asm delete mode 100644 battle/effects/metronome.asm delete mode 100644 battle/effects/mirror_move.asm delete mode 100644 battle/effects/nightmare.asm delete mode 100644 battle/effects/perish_song.asm delete mode 100755 battle/effects/present.asm delete mode 100644 battle/effects/protect.asm delete mode 100644 battle/effects/rollout.asm delete mode 100644 battle/effects/sandstorm.asm delete mode 100644 battle/effects/spikes.asm delete mode 100644 battle/effects/thief.asm delete mode 100755 battle/effects/transform.asm delete mode 100644 battle/hidden_power.asm delete mode 100755 battle/link_result.asm delete mode 100755 battle/menu.asm delete mode 100644 battle/misc.asm delete mode 100644 battle/move_names.asm delete mode 100644 battle/moves/move_descriptions.asm delete mode 100644 battle/moves/move_effects.asm delete mode 100644 battle/moves/move_effects_pointers.asm delete mode 100644 battle/moves/moves.asm delete mode 100755 battle/objects/data.asm delete mode 100755 battle/objects/engine.asm delete mode 100755 battle/objects/framesets.asm delete mode 100755 battle/objects/functions.asm delete mode 100755 battle/objects/helpers.asm delete mode 100755 battle/objects/oam.asm delete mode 100755 battle/objects/object_gfx.asm delete mode 100755 battle/sliding_intro.asm delete mode 100755 battle/trainer_huds.asm delete mode 100644 battle/type_matchup.asm delete mode 100755 battle/used_move_text.asm create mode 100644 constants/sprite_anim_constants.asm create mode 100644 data/anims/ball_colors.asm create mode 100755 data/anims/framesets.asm create mode 100755 data/anims/oam.asm create mode 100755 data/anims/object_gfx.asm create mode 100755 data/anims/objects.asm delete mode 100644 data/battle/ball_colors.asm delete mode 100644 data/battle/flee_mons.asm delete mode 100644 data/flypoints.asm create mode 100644 data/maps/flypoints.asm create mode 100644 data/maps/map_setup_scripts.asm create mode 100644 data/moves/effect_command_pointers.asm create mode 100644 data/moves/move_anims.asm create mode 100644 data/moves/move_descriptions.asm create mode 100644 data/moves/move_effects.asm create mode 100644 data/moves/move_effects_pointers.asm create mode 100644 data/moves/move_names.asm create mode 100644 data/moves/moves.asm create mode 100644 data/moves/tmhm_moves.asm delete mode 100644 data/mystery_gift/decos.asm delete mode 100644 data/mystery_gift/items.asm create mode 100644 data/mystery_gift_decos.asm create mode 100644 data/mystery_gift_items.asm delete mode 100755 data/sprite_anim_frames.asm delete mode 100644 data/sprite_anim_oam.asm delete mode 100644 data/sprite_anim_seqs.asm create mode 100755 data/sprites/framesets.asm create mode 100644 data/sprites/oam.asm create mode 100644 data/sprites/sequences.asm delete mode 100644 data/tmhm_moves.asm create mode 100644 data/type_matchups.asm create mode 100644 data/type_names.asm create mode 100644 data/wild/flee_mons.asm delete mode 100755 engine/anim_hp_bar.asm create mode 100644 engine/anims/anim_commands.asm create mode 100644 engine/anims/bg_effects.asm create mode 100755 engine/anims/engine.asm create mode 100755 engine/anims/functions.asm create mode 100755 engine/anims/helpers.asm create mode 100644 engine/battle/ai/items.asm create mode 100755 engine/battle/ai/move.asm create mode 100755 engine/battle/ai/redundant.asm create mode 100644 engine/battle/ai/scoring.asm create mode 100755 engine/battle/ai/switch.asm create mode 100755 engine/battle/anim_hp_bar.asm create mode 100644 engine/battle/battle_transition.asm create mode 100644 engine/battle/core.asm create mode 100644 engine/battle/effect_commands.asm create mode 100755 engine/battle/effect_commands/attract.asm create mode 100644 engine/battle/effect_commands/curse.asm create mode 100644 engine/battle/effect_commands/endure.asm create mode 100644 engine/battle/effect_commands/foresight.asm create mode 100644 engine/battle/effect_commands/metronome.asm create mode 100644 engine/battle/effect_commands/mirror_move.asm create mode 100644 engine/battle/effect_commands/nightmare.asm create mode 100644 engine/battle/effect_commands/perish_song.asm create mode 100755 engine/battle/effect_commands/present.asm create mode 100644 engine/battle/effect_commands/protect.asm create mode 100644 engine/battle/effect_commands/rollout.asm create mode 100644 engine/battle/effect_commands/sandstorm.asm create mode 100644 engine/battle/effect_commands/spikes.asm create mode 100644 engine/battle/effect_commands/thief.asm create mode 100755 engine/battle/effect_commands/transform.asm create mode 100644 engine/battle/hidden_power.asm create mode 100755 engine/battle/link_result.asm create mode 100755 engine/battle/menu.asm create mode 100644 engine/battle/misc.asm create mode 100644 engine/battle/read_trainer_attributes.asm create mode 100755 engine/battle/read_trainer_party.asm create mode 100755 engine/battle/sliding_intro.asm create mode 100644 engine/battle/start_battle.asm create mode 100755 engine/battle/trainer_huds.asm create mode 100644 engine/battle/trainer_scripts.asm create mode 100755 engine/battle/used_move_text.asm delete mode 100644 engine/battle_transition.asm delete mode 100644 engine/read_trainer_attributes.asm delete mode 100755 engine/read_trainer_party.asm delete mode 100644 engine/start_battle.asm delete mode 100644 engine/trainer_scripts.asm create mode 100644 engine/types.asm create mode 100644 gfx/anims.asm create mode 100644 gfx/anims/aeroblast.2bpp.lz.2f07c4ea create mode 100644 gfx/anims/aeroblast.png create mode 100644 gfx/anims/angels.2bpp.lz.b026d81e create mode 100644 gfx/anims/angels.png create mode 100644 gfx/anims/beam.2bpp.lz.80b6d613 create mode 100755 gfx/anims/beam.png create mode 100644 gfx/anims/bubble.2bpp.lz.03b8ac99 create mode 100644 gfx/anims/bubble.png create mode 100644 gfx/anims/charge.2bpp.lz.95d3ea98 create mode 100644 gfx/anims/charge.png create mode 100644 gfx/anims/cut.2bpp.lz.03d343ed create mode 100644 gfx/anims/cut.png create mode 100644 gfx/anims/egg.2bpp.lz.41dd1a53 create mode 100644 gfx/anims/egg.png create mode 100644 gfx/anims/explosion.2bpp.lz.55fc334f create mode 100644 gfx/anims/explosion.png create mode 100644 gfx/anims/fire.2bpp.lz.d7701cda create mode 100644 gfx/anims/fire.png create mode 100644 gfx/anims/flower.2bpp.lz.1bc2e9d2 create mode 100644 gfx/anims/flower.png create mode 100644 gfx/anims/globe.2bpp.lz.710dbb8e create mode 100644 gfx/anims/globe.png create mode 100644 gfx/anims/haze.2bpp.lz.91424607 create mode 100644 gfx/anims/haze.png create mode 100644 gfx/anims/hit.2bpp.lz.2b3c83f2 create mode 100644 gfx/anims/hit.png create mode 100644 gfx/anims/horn.2bpp.lz.48908aae create mode 100644 gfx/anims/horn.png create mode 100644 gfx/anims/ice.2bpp.lz.664d900f create mode 100644 gfx/anims/ice.png create mode 100644 gfx/anims/lightning.2bpp.lz.a88fc131 create mode 100755 gfx/anims/lightning.png create mode 100644 gfx/anims/misc.2bpp.lz.4b20c3d7 create mode 100755 gfx/anims/misc.png create mode 100644 gfx/anims/noise.2bpp.lz.acb4a76e create mode 100755 gfx/anims/noise.png create mode 100644 gfx/anims/objects.2bpp.lz.83f812de create mode 100755 gfx/anims/objects.png create mode 100644 gfx/anims/plant.2bpp.lz.4a00c417 create mode 100644 gfx/anims/plant.png create mode 100644 gfx/anims/poison.2bpp.lz.fc7dc9c1 create mode 100755 gfx/anims/poison.png create mode 100644 gfx/anims/pokeball.2bpp.lz.c58f7e01 create mode 100755 gfx/anims/pokeball.png create mode 100644 gfx/anims/powder.2bpp.lz.bfd566bb create mode 100644 gfx/anims/powder.png create mode 100644 gfx/anims/psychic.2bpp.lz.d80f285c create mode 100644 gfx/anims/psychic.png create mode 100644 gfx/anims/reflect.2bpp.lz.9a9c822d create mode 100644 gfx/anims/reflect.png create mode 100644 gfx/anims/rocks.2bpp.lz.73d0153e create mode 100755 gfx/anims/rocks.png create mode 100644 gfx/anims/rope.2bpp.lz.209d63dd create mode 100644 gfx/anims/rope.png create mode 100644 gfx/anims/sand.2bpp.lz.c87c0eaa create mode 100755 gfx/anims/sand.png create mode 100644 gfx/anims/shapes.2bpp.lz.262d77f0 create mode 100644 gfx/anims/shapes.png create mode 100644 gfx/anims/shine.2bpp.lz.5fb79056 create mode 100644 gfx/anims/shine.png create mode 100644 gfx/anims/skyattack.2bpp.lz.31738ab8 create mode 100644 gfx/anims/skyattack.png create mode 100644 gfx/anims/smoke.2bpp.lz.aa05905e create mode 100644 gfx/anims/smoke.png create mode 100644 gfx/anims/speed.2bpp.lz.1732b364 create mode 100644 gfx/anims/speed.png create mode 100644 gfx/anims/status.2bpp.lz.0c0aa13e create mode 100644 gfx/anims/status.png create mode 100644 gfx/anims/water.2bpp.lz.7b52ed12 create mode 100644 gfx/anims/water.png create mode 100644 gfx/anims/wave.2bpp.lz.bee99402 create mode 100644 gfx/anims/wave.png create mode 100644 gfx/anims/web.2bpp.lz.80e3d480 create mode 100644 gfx/anims/web.png create mode 100644 gfx/anims/whip.2bpp.lz.d80d8d6e create mode 100644 gfx/anims/whip.png create mode 100644 gfx/anims/wind.2bpp.lz.5a785180 create mode 100644 gfx/anims/wind.png delete mode 100644 gfx/fx/aeroblast.2bpp.lz.2f07c4ea delete mode 100644 gfx/fx/aeroblast.png delete mode 100644 gfx/fx/angels.2bpp.lz.b026d81e delete mode 100644 gfx/fx/angels.png delete mode 100644 gfx/fx/beam.2bpp.lz.80b6d613 delete mode 100755 gfx/fx/beam.png delete mode 100644 gfx/fx/bubble.2bpp.lz.03b8ac99 delete mode 100644 gfx/fx/bubble.png delete mode 100644 gfx/fx/charge.2bpp.lz.95d3ea98 delete mode 100644 gfx/fx/charge.png delete mode 100644 gfx/fx/cut.2bpp.lz.03d343ed delete mode 100644 gfx/fx/cut.png delete mode 100644 gfx/fx/egg.2bpp.lz.41dd1a53 delete mode 100644 gfx/fx/egg.png delete mode 100644 gfx/fx/explosion.2bpp.lz.55fc334f delete mode 100644 gfx/fx/explosion.png delete mode 100644 gfx/fx/fire.2bpp.lz.d7701cda delete mode 100644 gfx/fx/fire.png delete mode 100644 gfx/fx/flower.2bpp.lz.1bc2e9d2 delete mode 100644 gfx/fx/flower.png delete mode 100644 gfx/fx/globe.2bpp.lz.710dbb8e delete mode 100644 gfx/fx/globe.png delete mode 100644 gfx/fx/haze.2bpp.lz.91424607 delete mode 100644 gfx/fx/haze.png delete mode 100644 gfx/fx/hit.2bpp.lz.2b3c83f2 delete mode 100644 gfx/fx/hit.png delete mode 100644 gfx/fx/horn.2bpp.lz.48908aae delete mode 100644 gfx/fx/horn.png delete mode 100644 gfx/fx/ice.2bpp.lz.664d900f delete mode 100644 gfx/fx/ice.png delete mode 100644 gfx/fx/lightning.2bpp.lz.a88fc131 delete mode 100755 gfx/fx/lightning.png delete mode 100644 gfx/fx/misc.2bpp.lz.4b20c3d7 delete mode 100755 gfx/fx/misc.png delete mode 100644 gfx/fx/noise.2bpp.lz.acb4a76e delete mode 100755 gfx/fx/noise.png delete mode 100644 gfx/fx/objects.2bpp.lz.83f812de delete mode 100755 gfx/fx/objects.png delete mode 100644 gfx/fx/plant.2bpp.lz.4a00c417 delete mode 100644 gfx/fx/plant.png delete mode 100644 gfx/fx/poison.2bpp.lz.fc7dc9c1 delete mode 100755 gfx/fx/poison.png delete mode 100644 gfx/fx/pokeball.2bpp.lz.c58f7e01 delete mode 100755 gfx/fx/pokeball.png delete mode 100644 gfx/fx/powder.2bpp.lz.bfd566bb delete mode 100644 gfx/fx/powder.png delete mode 100644 gfx/fx/psychic.2bpp.lz.d80f285c delete mode 100644 gfx/fx/psychic.png delete mode 100644 gfx/fx/reflect.2bpp.lz.9a9c822d delete mode 100644 gfx/fx/reflect.png delete mode 100644 gfx/fx/rocks.2bpp.lz.73d0153e delete mode 100755 gfx/fx/rocks.png delete mode 100644 gfx/fx/rope.2bpp.lz.209d63dd delete mode 100644 gfx/fx/rope.png delete mode 100644 gfx/fx/sand.2bpp.lz.c87c0eaa delete mode 100755 gfx/fx/sand.png delete mode 100644 gfx/fx/shapes.2bpp.lz.262d77f0 delete mode 100644 gfx/fx/shapes.png delete mode 100644 gfx/fx/shine.2bpp.lz.5fb79056 delete mode 100644 gfx/fx/shine.png delete mode 100644 gfx/fx/skyattack.2bpp.lz.31738ab8 delete mode 100644 gfx/fx/skyattack.png delete mode 100644 gfx/fx/smoke.2bpp.lz.aa05905e delete mode 100644 gfx/fx/smoke.png delete mode 100644 gfx/fx/speed.2bpp.lz.1732b364 delete mode 100644 gfx/fx/speed.png delete mode 100644 gfx/fx/status.2bpp.lz.0c0aa13e delete mode 100644 gfx/fx/status.png delete mode 100644 gfx/fx/water.2bpp.lz.7b52ed12 delete mode 100644 gfx/fx/water.png delete mode 100644 gfx/fx/wave.2bpp.lz.bee99402 delete mode 100644 gfx/fx/wave.png delete mode 100644 gfx/fx/web.2bpp.lz.80e3d480 delete mode 100644 gfx/fx/web.png delete mode 100644 gfx/fx/whip.2bpp.lz.d80d8d6e delete mode 100644 gfx/fx/whip.png delete mode 100644 gfx/fx/wind.2bpp.lz.5a785180 delete mode 100644 gfx/fx/wind.png delete mode 100644 text/types.asm diff --git a/Makefile b/Makefile index c30d4a180..f507fa362 100644 --- a/Makefile +++ b/Makefile @@ -169,23 +169,23 @@ gfx/slots/slots_3.2bpp: tools/gfx += --interleave --png=$< --remove-duplicates - gfx/card_flip/card_flip_2.2bpp: tools/gfx += --remove-whitespace -gfx/fx/angels.2bpp: tools/gfx += --trim-whitespace -gfx/fx/beam.2bpp: tools/gfx += --remove-xflip --remove-yflip --remove-whitespace -gfx/fx/bubble.2bpp: tools/gfx += --trim-whitespace -gfx/fx/charge.2bpp: tools/gfx += --trim-whitespace -gfx/fx/egg.2bpp: tools/gfx += --remove-whitespace -gfx/fx/explosion.2bpp: tools/gfx += --remove-whitespace -gfx/fx/hit.2bpp: tools/gfx += --remove-whitespace -gfx/fx/horn.2bpp: tools/gfx += --remove-whitespace -gfx/fx/lightning.2bpp: tools/gfx += --remove-whitespace -gfx/fx/misc.2bpp: tools/gfx += --remove-duplicates --remove-xflip -gfx/fx/noise.2bpp: tools/gfx += --remove-whitespace -gfx/fx/objects.2bpp: tools/gfx += --remove-whitespace --remove-xflip -gfx/fx/pokeball.2bpp: tools/gfx += --remove-xflip --keep-whitespace -gfx/fx/reflect.2bpp: tools/gfx += --remove-whitespace -gfx/fx/rocks.2bpp: tools/gfx += --remove-whitespace -gfx/fx/skyattack.2bpp: tools/gfx += --remove-whitespace -gfx/fx/status.2bpp: tools/gfx += --remove-whitespace +gfx/anims/angels.2bpp: tools/gfx += --trim-whitespace +gfx/anims/beam.2bpp: tools/gfx += --remove-xflip --remove-yflip --remove-whitespace +gfx/anims/bubble.2bpp: tools/gfx += --trim-whitespace +gfx/anims/charge.2bpp: tools/gfx += --trim-whitespace +gfx/anims/egg.2bpp: tools/gfx += --remove-whitespace +gfx/anims/explosion.2bpp: tools/gfx += --remove-whitespace +gfx/anims/hit.2bpp: tools/gfx += --remove-whitespace +gfx/anims/horn.2bpp: tools/gfx += --remove-whitespace +gfx/anims/lightning.2bpp: tools/gfx += --remove-whitespace +gfx/anims/misc.2bpp: tools/gfx += --remove-duplicates --remove-xflip +gfx/anims/noise.2bpp: tools/gfx += --remove-whitespace +gfx/anims/objects.2bpp: tools/gfx += --remove-whitespace --remove-xflip +gfx/anims/pokeball.2bpp: tools/gfx += --remove-xflip --keep-whitespace +gfx/anims/reflect.2bpp: tools/gfx += --remove-whitespace +gfx/anims/rocks.2bpp: tools/gfx += --remove-whitespace +gfx/anims/skyattack.2bpp: tools/gfx += --remove-whitespace +gfx/anims/status.2bpp: tools/gfx += --remove-whitespace gfx/player/chris.2bpp: rgbgfx += -h gfx/player/chris_back.2bpp: rgbgfx += -h diff --git a/battle/ai/items.asm b/battle/ai/items.asm deleted file mode 100644 index 09595077a..000000000 --- a/battle/ai/items.asm +++ /dev/null @@ -1,882 +0,0 @@ -AI_SwitchOrTryItem: ; 38000 - and a - - ld a, [wBattleMode] - dec a - ret z - - ld a, [wLinkMode] - and a - ret nz - - farcall CheckEnemyLockedIn - ret nz - - ld a, [PlayerSubStatus5] - bit SUBSTATUS_CANT_RUN, a - jr nz, DontSwitch - - ld a, [wEnemyWrapCount] - and a - jr nz, DontSwitch - - ld hl, TrainerClassAttributes + TRNATTR_AI_ITEM_SWITCH - ld a, [InBattleTowerBattle] ; Load always the first TrainerClass for BattleTower-Trainers - and a - jr nz, .ok - - ld a, [TrainerClass] - dec a - ld bc, NUM_TRAINER_ATTRIBUTES - call AddNTimes -.ok - bit SWITCH_OFTEN_F, [hl] - jp nz, SwitchOften - bit SWITCH_RARELY_F, [hl] - jp nz, SwitchRarely - bit SWITCH_SOMETIMES_F, [hl] - jp nz, SwitchSometimes - ; fallthrough - -DontSwitch: ; 38041 - call AI_TryItem - ret -; 38045 - -SwitchOften: ; 38045 - callfar CheckAbleToSwitch - ld a, [wEnemySwitchMonParam] - and $f0 - jp z, DontSwitch - - cp $10 - jr nz, .not_10 - call Random - cp 1 + 50 percent - jr c, .switch - jp DontSwitch -.not_10 - - cp $20 - jr nz, .not_20 - call Random - cp -1 + 79 percent - jr c, .switch - jp DontSwitch -.not_20 - - ; $30 - call Random - cp 4 percent - jp c, DontSwitch - -.switch - ld a, [wEnemySwitchMonParam] - and $f - inc a - ; In register 'a' is the number (1-6) of the Pkmn to switch to - ld [wEnemySwitchMonIndex], a - jp AI_TrySwitch -; 38083 - -SwitchRarely: ; 38083 - callfar CheckAbleToSwitch - ld a, [wEnemySwitchMonParam] - and $f0 - jp z, DontSwitch - - cp $10 - jr nz, .not_10 - call Random - cp 8 percent - jr c, .switch - jp DontSwitch -.not_10 - - cp $20 - jr nz, .not_20 - call Random - cp 12 percent - jr c, .switch - jp DontSwitch -.not_20 - - ; $30 - call Random - cp -1 + 79 percent - jp c, DontSwitch - -.switch - ld a, [wEnemySwitchMonParam] - and $f - inc a - ld [wEnemySwitchMonIndex], a - jp AI_TrySwitch -; 380c1 - -SwitchSometimes: ; 380c1 - callfar CheckAbleToSwitch - ld a, [wEnemySwitchMonParam] - and $f0 - jp z, DontSwitch - - cp $10 - jr nz, .not_10 - call Random - cp -1 + 20 percent - jr c, .switch - jp DontSwitch -.not_10 - - cp $20 - jr nz, .not_20 - call Random - cp 1 + 50 percent - jr c, .switch - jp DontSwitch -.not_20 - - ; $30 - call Random - cp -1 + 20 percent - jp c, DontSwitch - -.switch - ld a, [wEnemySwitchMonParam] - and $f - inc a - ld [wEnemySwitchMonIndex], a - jp AI_TrySwitch -; 380ff - - -CheckSubstatusCantRun: ; 380ff - ld a, [EnemySubStatus5] - bit SUBSTATUS_CANT_RUN, a - ret -; 38105 - - -AI_TryItem: ; 38105 - ; items are not allowed in the BattleTower - ld a, [InBattleTowerBattle] - and a - ret nz - - ld a, [wEnemyTrainerItem1] - ld b, a - ld a, [wEnemyTrainerItem2] - or b - ret z - - call .IsHighestLevel - ret nc - - ld a, [TrainerClass] - dec a - ld hl, TrainerClassAttributes + TRNATTR_AI_ITEM_SWITCH - ld bc, NUM_TRAINER_ATTRIBUTES - call AddNTimes - ld b, h - ld c, l - ld hl, AI_Items - ld de, wEnemyTrainerItem1 -.loop - ld a, [hl] - and a - inc a - ret z - - ld a, [de] - cp [hl] - jr z, .has_item - inc de - ld a, [de] - cp [hl] - jr z, .has_item - - dec de - inc hl - inc hl - inc hl - jr .loop - -.has_item - inc hl - - push hl - push de - ld de, .callback - push de - ld a, [hli] - ld h, [hl] - ld l, a - jp hl -.callback - pop de - pop hl - - inc hl - inc hl - jr c, .loop - -.used_item - xor a - ld [de], a - inc a - ld [wEnemyGoesFirst], a - - ld hl, EnemySubStatus3 - res SUBSTATUS_BIDE, [hl] - - xor a - ld [EnemyFuryCutterCount], a - ld [EnemyProtectCount], a - ld [wEnemyRageCounter], a - - ld hl, EnemySubStatus4 - res SUBSTATUS_RAGE, [hl] - - xor a - ld [LastEnemyCounterMove], a - - scf - ret - - -.IsHighestLevel: ; 38170 - ld a, [OTPartyCount] - ld d, a - ld e, 0 - ld hl, OTPartyMon1Level - ld bc, PARTYMON_STRUCT_LENGTH -.next - ld a, [hl] - cp e - jr c, .ok - ld e, a -.ok - add hl, bc - dec d - jr nz, .next - - ld a, [CurOTMon] - ld hl, OTPartyMon1Level - call AddNTimes - ld a, [hl] - cp e - jr nc, .yes - -.no - and a - ret - -.yes - scf - ret -; 38196 - - -AI_Items: ; 39196 - dbw FULL_RESTORE, .FullRestore - dbw MAX_POTION, .MaxPotion - dbw HYPER_POTION, .HyperPotion - dbw SUPER_POTION, .SuperPotion - dbw POTION, .Potion - dbw X_ACCURACY, .XAccuracy - dbw FULL_HEAL, .FullHeal - dbw GUARD_SPEC, .GuardSpec - dbw DIRE_HIT, .DireHit - dbw X_ATTACK, .XAttack - dbw X_DEFEND, .XDefend - dbw X_SPEED, .XSpeed - dbw X_SPECIAL, .XSpecial - db $ff -; 381be - -.FullHeal: ; 381be - call .Status - jp c, .DontUse - call EnemyUsedFullHeal - jp .Use -; 381ca - -.Status: ; 381ca (e:41ca) - ld a, [EnemyMonStatus] - and a - jp z, .DontUse - - ld a, [bc] - bit CONTEXT_USE_F, a - jr nz, .StatusCheckContext - ld a, [bc] - bit ALWAYS_USE_F, a - jp nz, .Use - call Random - cp -1 + 20 percent - jp c, .Use - jp .DontUse - -.StatusCheckContext: - ld a, [EnemySubStatus5] - bit SUBSTATUS_TOXIC, a - jr z, .FailToxicCheck - ld a, [EnemyToxicCount] - cp 4 - jr c, .FailToxicCheck - call Random - cp 1 + 50 percent - jp c, .Use -.FailToxicCheck: - ld a, [EnemyMonStatus] - and 1 << FRZ | SLP - jp z, .DontUse - jp .Use -; 38208 - -.FullRestore: ; 38208 - call .HealItem - jp nc, .UseFullRestore - ld a, [bc] - bit CONTEXT_USE_F, a - jp z, .DontUse - call .Status - jp c, .DontUse - -.UseFullRestore: - call EnemyUsedFullRestore - jp .Use -; 38220 - -.MaxPotion: ; 38220 - call .HealItem - jp c, .DontUse - call EnemyUsedMaxPotion - jp .Use - -.HealItem: ; 3822c (e:422c) - ld a, [bc] - bit CONTEXT_USE_F, a - jr nz, .CheckHalfOrQuarterHP - callfar AICheckEnemyHalfHP - jp c, .DontUse - ld a, [bc] - bit UNKNOWN_USE_F, a - jp nz, .CheckQuarterHP - callfar AICheckEnemyQuarterHP - jp nc, .UseHealItem - call Random - cp 1 + 50 percent - jp c, .UseHealItem - jp .DontUse - -.CheckQuarterHP: ; 38254 (e:4254) - callfar AICheckEnemyQuarterHP - jp c, .DontUse - call Random - cp -1 + 20 percent - jp c, .DontUse - jr .UseHealItem - -.CheckHalfOrQuarterHP: ; 38267 (e:4267) - callfar AICheckEnemyHalfHP - jp c, .DontUse - callfar AICheckEnemyQuarterHP - jp nc, .UseHealItem - call Random - cp -1 + 20 percent - jp nc, .DontUse - -.UseHealItem: ; 38281 (e:4281) - jp .Use -; 38284 - -.HyperPotion: ; 38284 - call .HealItem - jp c, .DontUse - ld b, 200 - call EnemyUsedHyperPotion - jp .Use -; 38292 (e:4292) - -.SuperPotion: ; 38292 - call .HealItem - jp c, .DontUse - ld b, 50 - call EnemyUsedSuperPotion - jp .Use -; 382a0 - -.Potion: ; 382a0 - call .HealItem - jp c, .DontUse - ld b, 20 - call EnemyUsedPotion - jp .Use -; 382ae - -.asm_382ae ; This appears to be unused - callfar AICheckEnemyMaxHP - jr c, .dont_use - push bc - ld de, EnemyMonMaxHP + 1 - ld hl, EnemyMonHP + 1 - ld a, [de] - sub [hl] - jr z, .check_40_percent - dec hl - dec de - ld c, a - sbc [hl] - and a - jr nz, .check_40_percent - ld a, c - cp b - jp c, .check_50_percent - callfar AICheckEnemyQuarterHP - jr c, .check_40_percent - -.check_50_percent - pop bc - ld a, [bc] - bit UNKNOWN_USE_F, a - jp z, .Use - call Random - cp 1 + 50 percent - jp c, .Use - -.dont_use - jp .DontUse - -.check_40_percent - pop bc - ld a, [bc] - bit UNKNOWN_USE_F, a - jp z, .DontUse - call Random - cp 1 + 39 percent - jp c, .Use - jp .DontUse -; 382f9 - -.XAccuracy: ; 382f9 - call .XItem - jp c, .DontUse - call EnemyUsedXAccuracy - jp .Use -; 38305 - -.GuardSpec: ; 38305 - call .XItem - jp c, .DontUse - call EnemyUsedGuardSpec - jp .Use -; 38311 - -.DireHit: ; 38311 - call .XItem - jp c, .DontUse - call EnemyUsedDireHit - jp .Use -; 3831d (e:431d) - -.XAttack: ; 3831d - call .XItem - jp c, .DontUse - call EnemyUsedXAttack - jp .Use -; 38329 - -.XDefend: ; 38329 - call .XItem - jp c, .DontUse - call EnemyUsedXDefend - jp .Use -; 38335 - -.XSpeed: ; 38335 - call .XItem - jp c, .DontUse - call EnemyUsedXSpeed - jp .Use -; 38341 - -.XSpecial: ; 38341 - call .XItem - jp c, .DontUse - call EnemyUsedXSpecial - jp .Use -; 3834d - -.XItem: ; 3834d (e:434d) - ld a, [EnemyTurnsTaken] - and a - jr nz, .notfirstturnout - ld a, [bc] - bit ALWAYS_USE_F, a - jp nz, .Use - call Random - cp 1 + 50 percent - jp c, .DontUse - ld a, [bc] - bit CONTEXT_USE_F, a - jp nz, .Use - call Random - cp 1 + 50 percent - jp c, .DontUse - jp .Use -.notfirstturnout - ld a, [bc] - bit ALWAYS_USE_F, a - jp z, .DontUse - call Random - cp -1 + 20 percent - jp nc, .DontUse - jp .Use - -.DontUse: - scf - ret - -.Use: - and a - ret - - -AIUpdateHUD: ; 38387 - call UpdateEnemyMonInParty - farcall UpdateEnemyHUD - ld a, $1 - ld [hBGMapMode], a - ld hl, wEnemyItemState - dec [hl] - scf - ret -; 3839a - -AIUsedItemSound: ; 3839a - push de - ld de, SFX_FULL_HEAL - call PlaySFX - pop de - ret -; 383a3 - - -EnemyUsedFullHeal: ; 383a3 (e:43a3) - call AIUsedItemSound - call AI_HealStatus - ld a, FULL_HEAL - jp PrintText_UsedItemOn_AND_AIUpdateHUD - -EnemyUsedMaxPotion: ; 383ae (e:43ae) - ld a, MAX_POTION - ld [CurEnemyItem], a - jr FullRestoreContinue - -EnemyUsedFullRestore: ; 383b5 (e:43b5) - call AI_HealStatus - ld a, FULL_RESTORE - ld [CurEnemyItem], a - ld hl, EnemySubStatus3 - res SUBSTATUS_CONFUSED, [hl] - xor a - ld [EnemyConfuseCount], a - -FullRestoreContinue: ; 383c6 - ld de, wCurHPAnimOldHP - ld hl, EnemyMonHP + 1 - ld a, [hld] - ld [de], a - inc de - ld a, [hl] - ld [de], a - inc de - ld hl, EnemyMonMaxHP + 1 - ld a, [hld] - ld [de], a - inc de - ld [wCurHPAnimMaxHP], a - ld [EnemyMonHP + 1], a - ld a, [hl] - ld [de], a - ld [wCurHPAnimMaxHP + 1], a - ld [EnemyMonHP], a - jr EnemyPotionFinish -; 383e8 (e:43e8) - -EnemyUsedPotion: ; 383e8 - ld a, POTION - ld b, 20 - jr EnemyPotionContinue - -EnemyUsedSuperPotion: ; 383ee - ld a, SUPER_POTION - ld b, 50 - jr EnemyPotionContinue - -EnemyUsedHyperPotion: ; 383f4 (e:43f4) - ld a, HYPER_POTION - ld b, 200 - -EnemyPotionContinue: ; 383f8 - ld [CurEnemyItem], a - ld hl, EnemyMonHP + 1 - ld a, [hl] - ld [wCurHPAnimOldHP], a - add b - ld [hld], a - ld [wCurHPAnimNewHP], a - ld a, [hl] - ld [wCurHPAnimOldHP + 1], a - ld [wCurHPAnimNewHP + 1], a - jr nc, .ok - inc a - ld [hl], a - ld [wCurHPAnimNewHP + 1], a -.ok - inc hl - ld a, [hld] - ld b, a - ld de, EnemyMonMaxHP + 1 - ld a, [de] - dec de - ld [wCurHPAnimMaxHP], a - sub b - ld a, [hli] - ld b, a - ld a, [de] - ld [wCurHPAnimMaxHP + 1], a - sbc b - jr nc, EnemyPotionFinish - inc de - ld a, [de] - dec de - ld [hld], a - ld [wCurHPAnimNewHP], a - ld a, [de] - ld [hl], a - ld [wCurHPAnimNewHP + 1], a - -EnemyPotionFinish: ; 38436 - call PrintText_UsedItemOn - hlcoord 2, 2 - xor a - ld [wWhichHPBar], a - call AIUsedItemSound - predef AnimateHPBar - jp AIUpdateHUD - - -AI_TrySwitch: ; 3844b -; Determine whether the AI can switch based on how many Pokemon are still alive. -; If it can switch, it will. - ld a, [OTPartyCount] - ld c, a - ld hl, OTPartyMon1HP - ld d, 0 -.SwitchLoop: - ld a, [hli] - ld b, a - ld a, [hld] - or b - jr z, .fainted - inc d -.fainted - push bc - ld bc, PARTYMON_STRUCT_LENGTH - add hl, bc - pop bc - dec c - jr nz, .SwitchLoop - - ld a, d - cp 2 - jp nc, AI_Switch - and a - ret -; 3846c - -AI_Switch: ; 3846c - ld a, $1 - ld [wEnemyIsSwitching], a - ld [wEnemyGoesFirst], a - ld hl, EnemySubStatus4 - res SUBSTATUS_RAGE, [hl] - xor a - ld [hBattleTurn], a - callfar PursuitSwitch - - push af - ld a, [CurOTMon] - ld hl, OTPartyMon1Status - ld bc, PARTYMON_STRUCT_LENGTH - call AddNTimes - ld d, h - ld e, l - ld hl, EnemyMonStatus - ld bc, MON_MAXHP - MON_STATUS - call CopyBytes - pop af - - jr c, .skiptext - ld hl, TextJump_EnemyWithdrew - call PrintText - -.skiptext - ld a, 1 - ld [wBattleHasJustStarted], a - callfar NewEnemyMonStatus - callfar ResetEnemyStatLevels - ld hl, PlayerSubStatus1 - res SUBSTATUS_IN_LOVE, [hl] - farcall EnemySwitch - farcall ResetBattleParticipants - xor a - ld [wBattleHasJustStarted], a - ld a, [wLinkMode] - and a - ret nz - scf - ret -; 384d0 - -TextJump_EnemyWithdrew: ; 384d0 - text_jump Text_EnemyWithdrew - db "@" -; 384d5 - -Function384d5: ; This appears to be unused - call AIUsedItemSound - call AI_HealStatus - ld a, FULL_HEAL_RED ; X_SPEED - jp PrintText_UsedItemOn_AND_AIUpdateHUD -; 384e0 - -AI_HealStatus: ; 384e0 - ld a, [CurOTMon] - ld hl, OTPartyMon1Status - ld bc, PARTYMON_STRUCT_LENGTH - call AddNTimes - xor a - ld [hl], a - ld [EnemyMonStatus], a - ; Bug: this should reset SUBSTATUS_NIGHTMARE too - ; Uncomment the lines below to fix - ; ld hl, EnemySubStatus1 - ; res SUBSTATUS_NIGHTMARE, [hl] - ld hl, EnemySubStatus5 - res SUBSTATUS_TOXIC, [hl] - ret -; 384f7 - -EnemyUsedXAccuracy: ; 384f7 - call AIUsedItemSound - ld hl, EnemySubStatus4 - set SUBSTATUS_X_ACCURACY, [hl] - ld a, X_ACCURACY - jp PrintText_UsedItemOn_AND_AIUpdateHUD -; 38504 - -EnemyUsedGuardSpec: ; 38504 - call AIUsedItemSound - ld hl, EnemySubStatus4 - set SUBSTATUS_MIST, [hl] - ld a, GUARD_SPEC - jp PrintText_UsedItemOn_AND_AIUpdateHUD -; 38511 - -EnemyUsedDireHit: ; 38511 - call AIUsedItemSound - ld hl, EnemySubStatus4 - set SUBSTATUS_FOCUS_ENERGY, [hl] - ld a, DIRE_HIT - jp PrintText_UsedItemOn_AND_AIUpdateHUD -; 3851e - -Function3851e: ; This appears to be unused - ld [hDivisor], a - ld hl, EnemyMonMaxHP - ld a, [hli] - ld [hDividend], a - ld a, [hl] - ld [hDividend + 1], a - ld b, 2 - call Divide - ld a, [hQuotient + 2] - ld c, a - ld a, [hQuotient + 1] - ld b, a - ld hl, EnemyMonHP + 1 - ld a, [hld] - ld e, a - ld a, [hl] - ld d, a - ld a, d - sub b - ret nz - ld a, e - sub c - ret -; 38541 - -EnemyUsedXAttack: ; 38541 - ld b, ATTACK - ld a, X_ATTACK - jr EnemyUsedXItem -; 38547 - -EnemyUsedXDefend: ; 38547 - ld b, DEFENSE - ld a, X_DEFEND - jr EnemyUsedXItem -; 3854d - -EnemyUsedXSpeed: ; 3854d - ld b, SPEED - ld a, X_SPEED - jr EnemyUsedXItem -; 38553 - -EnemyUsedXSpecial: ; 38553 - ld b, SP_ATTACK - ld a, X_SPECIAL - - -; Parameter -; a = ITEM_CONSTANT -; b = BATTLE_CONSTANT (ATTACK, DEFENSE, SPEED, SP_ATTACK, SP_DEFENSE, ACCURACY, EVASION) -EnemyUsedXItem: - ld [CurEnemyItem], a - push bc - call PrintText_UsedItemOn - pop bc - farcall CheckIfStatCanBeRaised - jp AIUpdateHUD -; 38568 - - -; Parameter -; a = ITEM_CONSTANT -PrintText_UsedItemOn_AND_AIUpdateHUD: ; 38568 - ld [CurEnemyItem], a - call PrintText_UsedItemOn - jp AIUpdateHUD -; 38571 - -PrintText_UsedItemOn: ; 38571 - ld a, [CurEnemyItem] - ld [wd265], a - call GetItemName - ld hl, StringBuffer1 - ld de, wMonOrItemNameBuffer - ld bc, ITEM_NAME_LENGTH - call CopyBytes - ld hl, TextJump_EnemyUsedOn - jp PrintText -; 3858c - -TextJump_EnemyUsedOn: ; 3858c - text_jump Text_EnemyUsedOn - db "@" -; 38591 diff --git a/battle/ai/move.asm b/battle/ai/move.asm deleted file mode 100755 index 11586c0da..000000000 --- a/battle/ai/move.asm +++ /dev/null @@ -1,221 +0,0 @@ -AIChooseMove: ; 440ce -; Score each move in EnemyMonMoves starting from Buffer1. Lower is better. -; Pick the move with the lowest score. - -; Wildmons attack at random. - ld a, [wBattleMode] - dec a - ret z - - ld a, [wLinkMode] - and a - ret nz - -; No use picking a move if there's no choice. - farcall CheckEnemyLockedIn - ret nz - - -; The default score is 20. Unusable moves are given a score of 80. - ld a, 20 - ld hl, Buffer1 - ld [hli], a - ld [hli], a - ld [hli], a - ld [hl], a - -; Don't pick disabled moves. - ld a, [EnemyDisabledMove] - and a - jr z, .CheckPP - - ld hl, EnemyMonMoves - ld c, 0 -.CheckDisabledMove: - cp [hl] - jr z, .ScoreDisabledMove - inc c - inc hl - jr .CheckDisabledMove -.ScoreDisabledMove: - ld hl, Buffer1 - ld b, 0 - add hl, bc - ld [hl], 80 - -; Don't pick moves with 0 PP. -.CheckPP: - ld hl, Buffer1 - 1 - ld de, EnemyMonPP - ld b, 0 -.CheckMovePP: - inc b - ld a, b - cp EnemyMonMovesEnd - EnemyMonMoves + 1 - jr z, .ApplyLayers - inc hl - ld a, [de] - inc de - and $3f - jr nz, .CheckMovePP - ld [hl], 80 - jr .CheckMovePP - - -; Apply AI scoring layers depending on the trainer class. -.ApplyLayers: - ld hl, TrainerClassAttributes + TRNATTR_AI_MOVE_WEIGHTS - - ; If we have a battle in BattleTower just load the Attributes of the first TrainerClass (Falkner) - ; so we have always the same AI, regardless of the loaded class of trainer - ld a, [InBattleTowerBattle] - bit 0, a - jr nz, .battle_tower_skip - - ld a, [TrainerClass] - dec a - ld bc, 7 ; Trainer2AI - Trainer1AI - call AddNTimes - -.battle_tower_skip - lb bc, CHECK_FLAG, 0 - push bc - push hl - -.CheckLayer: - pop hl - pop bc - - ld a, c - cp 16 ; up to 16 scoring layers - jr z, .DecrementScores - - push bc - ld d, BANK(TrainerClassAttributes) - predef FlagPredef - ld d, c - pop bc - - inc c - push bc - push hl - - ld a, d - and a - jr z, .CheckLayer - - ld hl, AIScoringPointers - dec c - ld b, 0 - add hl, bc - add hl, bc - ld a, [hli] - ld h, [hl] - ld l, a - ld a, BANK(AIScoring) - call FarCall_hl - - jr .CheckLayer - -; Decrement the scores of all moves one by one until one reaches 0. -.DecrementScores: - ld hl, Buffer1 - ld de, EnemyMonMoves - ld c, EnemyMonMovesEnd - EnemyMonMoves - -.DecrementNextScore: - ; If the enemy has no moves, this will infinite. - ld a, [de] - inc de - and a - jr z, .DecrementScores - - ; We are done whenever a score reaches 0 - dec [hl] - jr z, .PickLowestScoreMoves - - ; If we just decremented the fourth move's score, go back to the first move - inc hl - dec c - jr z, .DecrementScores - - jr .DecrementNextScore - -; In order to avoid bias towards the moves located first in memory, increment the scores -; that were decremented one more time than the rest (in case there was a tie). -; This means that the minimum score will be 1. -.PickLowestScoreMoves: - ld a, c - -.move_loop - inc [hl] - dec hl - inc a - cp NUM_MOVES + 1 - jr nz, .move_loop - - ld hl, Buffer1 - ld de, EnemyMonMoves - ld c, NUM_MOVES - -; Give a score of 0 to a blank move -.loop2 - ld a, [de] - and a - jr nz, .skip_load - ld [hl], a - -; Disregard the move if its score is not 1 -.skip_load - ld a, [hl] - dec a - jr z, .keep - xor a - ld [hli], a - jr .after_toss - -.keep - ld a, [de] - ld [hli], a -.after_toss - inc de - dec c - jr nz, .loop2 - -; Randomly choose one of the moves with a score of 1 -.ChooseMove: - ld hl, Buffer1 - call Random - and 3 - ld c, a - ld b, 0 - add hl, bc - ld a, [hl] - and a - jr z, .ChooseMove - - ld [CurEnemyMove], a - ld a, c - ld [CurEnemyMoveNum], a - ret -; 441af - - -AIScoringPointers: ; 441af - dw AI_Basic - dw AI_Setup - dw AI_Types - dw AI_Offensive - dw AI_Smart - dw AI_Opportunist - dw AI_Aggressive - dw AI_Cautious - dw AI_Status - dw AI_Risky - dw AI_None - dw AI_None - dw AI_None - dw AI_None - dw AI_None - dw AI_None -; 441cf diff --git a/battle/ai/redundant.asm b/battle/ai/redundant.asm deleted file mode 100755 index 2e8f7c6df..000000000 --- a/battle/ai/redundant.asm +++ /dev/null @@ -1,198 +0,0 @@ -AI_Redundant: ; 2c41a -; Check if move effect c will fail because it's already been used. -; Return z if the move is a good choice. -; Return nz if the move is a bad choice. - ld a, c - ld de, 3 - ld hl, .Moves - call IsInArray - jp nc, .NotRedundant - inc hl - ld a, [hli] - ld h, [hl] - ld l, a - jp hl - -.Moves: ; 2c42c - dbw EFFECT_DREAM_EATER, .DreamEater - dbw EFFECT_HEAL, .Heal - dbw EFFECT_LIGHT_SCREEN, .LightScreen - dbw EFFECT_MIST, .Mist - dbw EFFECT_FOCUS_ENERGY, .FocusEnergy - dbw EFFECT_CONFUSE, .Confuse - dbw EFFECT_TRANSFORM, .Transform - dbw EFFECT_REFLECT, .Reflect - dbw EFFECT_SUBSTITUTE, .Substitute - dbw EFFECT_LEECH_SEED, .LeechSeed - dbw EFFECT_DISABLE, .Disable - dbw EFFECT_ENCORE, .Encore - dbw EFFECT_SNORE, .Snore - dbw EFFECT_SLEEP_TALK, .SleepTalk - dbw EFFECT_MEAN_LOOK, .MeanLook - dbw EFFECT_NIGHTMARE, .Nightmare - dbw EFFECT_SPIKES, .Spikes - dbw EFFECT_FORESIGHT, .Foresight - dbw EFFECT_PERISH_SONG, .PerishSong - dbw EFFECT_SANDSTORM, .Sandstorm - dbw EFFECT_ATTRACT, .Attract - dbw EFFECT_SAFEGUARD, .Safeguard - dbw EFFECT_RAIN_DANCE, .RainDance - dbw EFFECT_SUNNY_DAY, .SunnyDay - dbw EFFECT_TELEPORT, .Teleport - dbw EFFECT_MORNING_SUN, .MorningSun - dbw EFFECT_SYNTHESIS, .Synthesis - dbw EFFECT_MOONLIGHT, .Moonlight - dbw EFFECT_SWAGGER, .Swagger - dbw EFFECT_FUTURE_SIGHT, .FutureSight - db -1 - -.LightScreen: ; 2c487 - ld a, [EnemyScreens] - bit SCREENS_LIGHT_SCREEN, a - ret - -.Mist: ; 2c48d - ld a, [EnemySubStatus4] - bit SUBSTATUS_MIST, a - ret - -.FocusEnergy: ; 2c493 - ld a, [EnemySubStatus4] - bit SUBSTATUS_FOCUS_ENERGY, a - ret - -.Confuse: ; 2c499 - ld a, [PlayerSubStatus3] - bit SUBSTATUS_CONFUSED, a - ret nz - ld a, [PlayerScreens] - bit SCREENS_SAFEGUARD, a - ret - -.Transform: ; 2c4a5 - ld a, [EnemySubStatus5] - bit SUBSTATUS_TRANSFORMED, a - ret - -.Reflect: ; 2c4ab - ld a, [EnemyScreens] - bit SCREENS_REFLECT, a - ret - -.Substitute: ; 2c4b1 - ld a, [EnemySubStatus4] - bit SUBSTATUS_SUBSTITUTE, a - ret - -.LeechSeed: ; 2c4b7 - ld a, [PlayerSubStatus4] - bit SUBSTATUS_LEECH_SEED, a - ret - -.Disable: ; 2c4bd - ld a, [PlayerDisableCount] - and a - ret - -.Encore: ; 2c4c2 - ld a, [PlayerSubStatus5] - bit SUBSTATUS_ENCORED, a - ret - -.Snore: -.SleepTalk: ; 2c4c8 - ld a, [EnemyMonStatus] - and SLP - jr z, .Redundant - jr .NotRedundant - -.MeanLook: ; 2c4d1 - ld a, [EnemySubStatus5] - bit SUBSTATUS_CANT_RUN, a - ret - -.Nightmare: ; 2c4d7 - ld a, [BattleMonStatus] - and a - jr z, .Redundant - ld a, [PlayerSubStatus1] - bit SUBSTATUS_NIGHTMARE, a - ret - -.Spikes: ; 2c4e3 - ld a, [PlayerScreens] - bit SCREENS_SPIKES, a - ret - -.Foresight: ; 2c4e9 - ld a, [PlayerSubStatus1] - bit SUBSTATUS_IDENTIFIED, a - ret - -.PerishSong: ; 2c4ef - ld a, [PlayerSubStatus1] - bit SUBSTATUS_PERISH, a - ret - -.Sandstorm: ; 2c4f5 - ld a, [Weather] - cp WEATHER_SANDSTORM - jr z, .Redundant - jr .NotRedundant - -.Attract: ; 2c4fe - farcall CheckOppositeGender - jr c, .Redundant - ld a, [PlayerSubStatus1] - bit SUBSTATUS_IN_LOVE, a - ret - -.Safeguard: ; 2c50c - ld a, [EnemyScreens] - bit SCREENS_SAFEGUARD, a - ret - -.RainDance: ; 2c512 - ld a, [Weather] - cp WEATHER_RAIN - jr z, .Redundant - jr .NotRedundant - -.SunnyDay: ; 2c51b - ld a, [Weather] - cp WEATHER_SUN - jr z, .Redundant - jr .NotRedundant - -.DreamEater: ; 2c524 - ld a, [BattleMonStatus] - and SLP - jr z, .Redundant - jr .NotRedundant - -.Swagger: ; 2c52d - ld a, [PlayerSubStatus3] - bit SUBSTATUS_CONFUSED, a - ret - -.FutureSight: ; 2c533 - ld a, [EnemyScreens] - bit 5, a - ret - -.Heal: -.MorningSun: -.Synthesis: -.Moonlight: ; 2c539 - farcall AICheckEnemyMaxHP - jr nc, .NotRedundant - -.Teleport: -.Redundant: ; 2c541 - ld a, 1 - and a - ret - -.NotRedundant: ; 2c545 - xor a - ret diff --git a/battle/ai/scoring.asm b/battle/ai/scoring.asm deleted file mode 100644 index 44194d6f7..000000000 --- a/battle/ai/scoring.asm +++ /dev/null @@ -1,3598 +0,0 @@ -AIScoring: ; 38591 - -AI_Basic: ; 38591 -; Don't do anything redundant: -; -Using status-only moves if the player can't be statused -; -Using moves that fail if they've already been used - - ld hl, Buffer1 - 1 - ld de, EnemyMonMoves - ld b, EnemyMonMovesEnd - EnemyMonMoves + 1 -.checkmove - dec b - ret z - - inc hl - ld a, [de] - and a - ret z - - inc de - call AIGetEnemyMove - - ld a, [wEnemyMoveStruct + MOVE_EFFECT] - ld c, a - -; Dismiss moves with special effects if they are -; useless or not a good choice right now. -; For example, healing moves, weather moves, Dream Eater... - push hl - push de - push bc - farcall AI_Redundant - pop bc - pop de - pop hl - jr nz, .discourage - -; Dismiss status-only moves if the player can't be statused. - ld a, [wEnemyMoveStruct + MOVE_EFFECT] - push hl - push de - push bc - ld hl, .statusonlyeffects - ld de, 1 - call IsInArray - - pop bc - pop de - pop hl - jr nc, .checkmove - - ld a, [BattleMonStatus] - and a - jr nz, .discourage - -; Dismiss Safeguard if it's already active. - ld a, [PlayerScreens] - bit SCREENS_SAFEGUARD, a - jr z, .checkmove - -.discourage - call AIDiscourageMove - jr .checkmove -; 385db - -.statusonlyeffects - db EFFECT_SLEEP - db EFFECT_TOXIC - db EFFECT_POISON - db EFFECT_PARALYZE - db $ff -; 385e0 - - - -AI_Setup: ; 385e0 -; Use stat-modifying moves on turn 1. - -; 50% chance to greatly encourage stat-up moves during the first turn of enemy's Pokemon. -; 50% chance to greatly encourage stat-down moves during the first turn of player's Pokemon. -; Almost 90% chance to greatly discourage stat-modifying moves otherwise. - - ld hl, Buffer1 - 1 - ld de, EnemyMonMoves - ld b, EnemyMonMovesEnd - EnemyMonMoves + 1 -.checkmove - dec b - ret z - - inc hl - ld a, [de] - and a - ret z - - inc de - call AIGetEnemyMove - - ld a, [wEnemyMoveStruct + MOVE_EFFECT] - - cp EFFECT_ATTACK_UP - jr c, .checkmove - cp EFFECT_EVASION_UP + 1 - jr c, .statup - -; cp EFFECT_ATTACK_DOWN - 1 - jr z, .checkmove - cp EFFECT_EVASION_DOWN + 1 - jr c, .statdown - - cp EFFECT_ATTACK_UP_2 - jr c, .checkmove - cp EFFECT_EVASION_UP_2 + 1 - jr c, .statup - -; cp EFFECT_ATTACK_DOWN_2 - 1 - jr z, .checkmove - cp EFFECT_EVASION_DOWN_2 + 1 - jr c, .statdown - - jr .checkmove - -.statup - ld a, [EnemyTurnsTaken] - and a - jr nz, .discourage - - jr .encourage - -.statdown - ld a, [PlayerTurnsTaken] - and a - jr nz, .discourage - -.encourage - call AI_50_50 - jr c, .checkmove - - dec [hl] - dec [hl] - jr .checkmove - -.discourage - call Random - cp 12 percent - jr c, .checkmove - inc [hl] - inc [hl] - jr .checkmove -; 38635 - - - -AI_Types: ; 38635 -; Dismiss any move that the player is immune to. -; Encourage super-effective moves. -; Discourage not very effective moves unless -; all damaging moves are of the same type. - - ld hl, Buffer1 - 1 - ld de, EnemyMonMoves - ld b, EnemyMonMovesEnd - EnemyMonMoves + 1 -.checkmove - dec b - ret z - - inc hl - ld a, [de] - and a - ret z - - inc de - call AIGetEnemyMove - - push hl - push bc - push de - ld a, 1 - ld [hBattleTurn], a - callfar BattleCheckTypeMatchup - pop de - pop bc - pop hl - - ld a, [wd265] - and a - jr z, .immune - cp 10 ; 1.0 - jr z, .checkmove - jr c, .noteffective - -; effective - ld a, [wEnemyMoveStruct + MOVE_POWER] - and a - jr z, .checkmove - dec [hl] - jr .checkmove - -.noteffective -; Discourage this move if there are any moves -; that do damage of a different type. - push hl - push de - push bc - ld a, [wEnemyMoveStruct + MOVE_TYPE] - ld d, a - ld hl, EnemyMonMoves - ld b, EnemyMonMovesEnd - EnemyMonMoves + 1 - ld c, 0 -.checkmove2 - dec b - jr z, .asm_38693 - - ld a, [hli] - and a - jr z, .asm_38693 - - call AIGetEnemyMove - ld a, [wEnemyMoveStruct + MOVE_TYPE] - cp d - jr z, .checkmove2 - ld a, [wEnemyMoveStruct + MOVE_POWER] - and a - jr nz, .asm_38692 - jr .checkmove2 - -.asm_38692 - ld c, a -.asm_38693 - ld a, c - pop bc - pop de - pop hl - and a - jr z, .checkmove - inc [hl] - jr .checkmove - -.immune - call AIDiscourageMove - jr .checkmove -; 386a2 - - - -AI_Offensive: ; 386a2 -; Greatly discourage non-damaging moves. - - ld hl, Buffer1 - 1 - ld de, EnemyMonMoves - ld b, EnemyMonMovesEnd - EnemyMonMoves + 1 -.checkmove - dec b - ret z - - inc hl - ld a, [de] - and a - ret z - - inc de - call AIGetEnemyMove - - ld a, [wEnemyMoveStruct + MOVE_POWER] - and a - jr nz, .checkmove - - inc [hl] - inc [hl] - jr .checkmove -; 386be - - - -AI_Smart: ; 386be -; Context-specific scoring. - - ld hl, Buffer1 - ld de, EnemyMonMoves - ld b, EnemyMonMovesEnd - EnemyMonMoves + 1 -.checkmove - dec b - ret z - - ld a, [de] - inc de - and a - ret z - - push de - push bc - push hl - call AIGetEnemyMove - - ld a, [wEnemyMoveStruct + MOVE_EFFECT] - ld hl, .table_386f2 - ld de, 3 - call IsInArray - - inc hl - jr nc, .nextmove - - ld a, [hli] - ld e, a - ld d, [hl] - - pop hl - push hl - - ld bc, .nextmove - push bc - - push de - ret - -.nextmove - pop hl - pop bc - pop de - inc hl - jr .checkmove - -.table_386f2 - dbw EFFECT_SLEEP, AI_Smart_Sleep - dbw EFFECT_LEECH_HIT, AI_Smart_LeechHit - dbw EFFECT_SELFDESTRUCT, AI_Smart_Selfdestruct - dbw EFFECT_DREAM_EATER, AI_Smart_DreamEater - dbw EFFECT_MIRROR_MOVE, AI_Smart_MirrorMove - dbw EFFECT_EVASION_UP, AI_Smart_EvasionUp - dbw EFFECT_ALWAYS_HIT, AI_Smart_AlwaysHit - dbw EFFECT_ACCURACY_DOWN, AI_Smart_AccuracyDown - dbw EFFECT_RESET_STATS, AI_Smart_ResetStats - dbw EFFECT_BIDE, AI_Smart_Bide - dbw EFFECT_FORCE_SWITCH, AI_Smart_ForceSwitch - dbw EFFECT_HEAL, AI_Smart_Heal - dbw EFFECT_TOXIC, AI_Smart_Toxic - dbw EFFECT_LIGHT_SCREEN, AI_Smart_LightScreen - dbw EFFECT_OHKO, AI_Smart_Ohko - dbw EFFECT_RAZOR_WIND, AI_Smart_RazorWind - dbw EFFECT_SUPER_FANG, AI_Smart_SuperFang - dbw EFFECT_TRAP_TARGET, AI_Smart_TrapTarget - dbw EFFECT_UNUSED_2B, AI_Smart_Unused2B - dbw EFFECT_CONFUSE, AI_Smart_Confuse - dbw EFFECT_SP_DEF_UP_2, AI_Smart_SpDefenseUp2 - dbw EFFECT_REFLECT, AI_Smart_Reflect - dbw EFFECT_PARALYZE, AI_Smart_Paralyze - dbw EFFECT_SPEED_DOWN_HIT, AI_Smart_SpeedDownHit - dbw EFFECT_SUBSTITUTE, AI_Smart_Substitute - dbw EFFECT_HYPER_BEAM, AI_Smart_HyperBeam - dbw EFFECT_RAGE, AI_Smart_Rage - dbw EFFECT_MIMIC, AI_Smart_Mimic - dbw EFFECT_LEECH_SEED, AI_Smart_LeechSeed - dbw EFFECT_DISABLE, AI_Smart_Disable - dbw EFFECT_COUNTER, AI_Smart_Counter - dbw EFFECT_ENCORE, AI_Smart_Encore - dbw EFFECT_PAIN_SPLIT, AI_Smart_PainSplit - dbw EFFECT_SNORE, AI_Smart_Snore - dbw EFFECT_CONVERSION2, AI_Smart_Conversion2 - dbw EFFECT_LOCK_ON, AI_Smart_LockOn - dbw EFFECT_DEFROST_OPPONENT, AI_Smart_DefrostOpponent - dbw EFFECT_SLEEP_TALK, AI_Smart_SleepTalk - dbw EFFECT_DESTINY_BOND, AI_Smart_DestinyBond - dbw EFFECT_REVERSAL, AI_Smart_Reversal - dbw EFFECT_SPITE, AI_Smart_Spite - dbw EFFECT_HEAL_BELL, AI_Smart_HealBell - dbw EFFECT_PRIORITY_HIT, AI_Smart_PriorityHit - dbw EFFECT_THIEF, AI_Smart_Thief - dbw EFFECT_MEAN_LOOK, AI_Smart_MeanLook - dbw EFFECT_NIGHTMARE, AI_Smart_Nightmare - dbw EFFECT_FLAME_WHEEL, AI_Smart_FlameWheel - dbw EFFECT_CURSE, AI_Smart_Curse - dbw EFFECT_PROTECT, AI_Smart_Protect - dbw EFFECT_FORESIGHT, AI_Smart_Foresight - dbw EFFECT_PERISH_SONG, AI_Smart_PerishSong - dbw EFFECT_SANDSTORM, AI_Smart_Sandstorm - dbw EFFECT_ENDURE, AI_Smart_Endure - dbw EFFECT_ROLLOUT, AI_Smart_Rollout - dbw EFFECT_SWAGGER, AI_Smart_Swagger - dbw EFFECT_FURY_CUTTER, AI_Smart_FuryCutter - dbw EFFECT_ATTRACT, AI_Smart_Attract - dbw EFFECT_SAFEGUARD, AI_Smart_Safeguard - dbw EFFECT_MAGNITUDE, AI_Smart_Magnitude - dbw EFFECT_BATON_PASS, AI_Smart_BatonPass - dbw EFFECT_PURSUIT, AI_Smart_Pursuit - dbw EFFECT_RAPID_SPIN, AI_Smart_RapidSpin - dbw EFFECT_MORNING_SUN, AI_Smart_MorningSun - dbw EFFECT_SYNTHESIS, AI_Smart_Synthesis - dbw EFFECT_MOONLIGHT, AI_Smart_Moonlight - dbw EFFECT_HIDDEN_POWER, AI_Smart_HiddenPower - dbw EFFECT_RAIN_DANCE, AI_Smart_RainDance - dbw EFFECT_SUNNY_DAY, AI_Smart_SunnyDay - dbw EFFECT_BELLY_DRUM, AI_Smart_BellyDrum - dbw EFFECT_PSYCH_UP, AI_Smart_PsychUp - dbw EFFECT_MIRROR_COAT, AI_Smart_MirrorCoat - dbw EFFECT_SKULL_BASH, AI_Smart_SkullBash - dbw EFFECT_TWISTER, AI_Smart_Twister - dbw EFFECT_EARTHQUAKE, AI_Smart_Earthquake - dbw EFFECT_FUTURE_SIGHT, AI_Smart_FutureSight - dbw EFFECT_GUST, AI_Smart_Gust - dbw EFFECT_STOMP, AI_Smart_Stomp - dbw EFFECT_SOLARBEAM, AI_Smart_Solarbeam - dbw EFFECT_THUNDER, AI_Smart_Thunder - dbw EFFECT_FLY, AI_Smart_Fly - db $ff -; 387e3 - - -AI_Smart_Sleep: ; 387e3 -; Greatly encourage sleep inducing moves if the enemy has either Dream Eater or Nightmare. -; 50% chance to greatly encourage sleep inducing moves otherwise. - - ld b, EFFECT_DREAM_EATER - call AIHasMoveEffect - jr c, .asm_387f0 - - ld b, EFFECT_NIGHTMARE - call AIHasMoveEffect - ret nc - -.asm_387f0 - call AI_50_50 - ret c - dec [hl] - dec [hl] - ret -; 387f7 - - -AI_Smart_LeechHit: ; 387f7 - push hl - ld a, 1 - ld [hBattleTurn], a - callfar BattleCheckTypeMatchup - pop hl - -; 60% chance to discourage this move if not very effective. - ld a, [wd265] - cp 10 ; 1.0 - jr c, .asm_38815 - -; Do nothing if effectiveness is neutral. - ret z - -; Do nothing if enemy's HP is full. - call AICheckEnemyMaxHP - ret c - -; 80% chance to encourage this move otherwise. - call AI_80_20 - ret c - - dec [hl] - ret - -.asm_38815 - call Random - cp 39 percent + 1 - ret c - - inc [hl] - ret -; 3881d - - -AI_Smart_LockOn: ; 3881d - ld a, [PlayerSubStatus5] - bit SUBSTATUS_LOCK_ON, a - jr nz, .asm_38882 - - push hl - call AICheckEnemyQuarterHP - jr nc, .asm_38877 - - call AICheckEnemyHalfHP - jr c, .asm_38834 - - call AICompareSpeed - jr nc, .asm_38877 - -.asm_38834 - ld a, [PlayerEvaLevel] - cp $a - jr nc, .asm_3887a - cp $8 - jr nc, .asm_38875 - - ld a, [EnemyAccLevel] - cp $5 - jr c, .asm_3887a - cp $7 - jr c, .asm_38875 - - ld hl, EnemyMonMoves - ld c, EnemyMonMovesEnd - EnemyMonMoves + 1 -.asm_3884f - dec c - jr z, .asm_38877 - - ld a, [hli] - and a - jr z, .asm_38877 - - call AIGetEnemyMove - - ld a, [wEnemyMoveStruct + MOVE_ACC] - cp 180 - jr nc, .asm_3884f - - ld a, $1 - ld [hBattleTurn], a - - push hl - push bc - farcall BattleCheckTypeMatchup - ld a, [wd265] - cp $a - pop bc - pop hl - jr c, .asm_3884f - -.asm_38875 - pop hl - ret - -.asm_38877 - pop hl - inc [hl] - ret - -.asm_3887a - pop hl - call AI_50_50 - ret c - - dec [hl] - dec [hl] - ret - -.asm_38882 - push hl - ld hl, Buffer1 - 1 - ld de, EnemyMonMoves - ld c, EnemyMonMovesEnd - EnemyMonMoves + 1 - -.asm_3888b - inc hl - dec c - jr z, .asm_388a2 - - ld a, [de] - and a - jr z, .asm_388a2 - - inc de - call AIGetEnemyMove - - ld a, [wEnemyMoveStruct + MOVE_ACC] - cp 180 - jr nc, .asm_3888b - - dec [hl] - dec [hl] - jr .asm_3888b - -.asm_388a2 - pop hl - jp AIDiscourageMove -; 388a6 - - -AI_Smart_Selfdestruct: ; 388a6 -; Selfdestruct, Explosion - -; Unless this is the enemy's last Pokemon... - push hl - farcall FindAliveEnemyMons - pop hl - jr nc, .asm_388b7 - -; ...greatly discourage this move unless this is the player's last Pokemon too. - push hl - call AICheckLastPlayerMon - pop hl - jr nz, .asm_388c6 - -.asm_388b7 -; Greatly discourage this move if enemy's HP is above 50%. - call AICheckEnemyHalfHP - jr c, .asm_388c6 - -; Do nothing if enemy's HP is below 25%. - call AICheckEnemyQuarterHP - ret nc - -; If enemy's HP is between 25% and 50%, -; over 90% chance to greatly discourage this move. - call Random - cp 9 percent - 2 - ret c - -.asm_388c6 - inc [hl] - inc [hl] - inc [hl] - ret -; 388ca - - -AI_Smart_DreamEater: ; 388ca -; 90% chance to greatly encourage this move. -; The AI_Basic layer will make sure that -; Dream Eater is only used against sleeping targets. - call Random - cp 10 percent - ret c - dec [hl] - dec [hl] - dec [hl] - ret -; 388d4 - - -AI_Smart_EvasionUp: ; 388d4 - -; Dismiss this move if enemy's evasion can't raise anymore. - ld a, [EnemyEvaLevel] - cp $d - jp nc, AIDiscourageMove - -; If enemy's HP is full... - call AICheckEnemyMaxHP - jr nc, .asm_388f2 - -; ...greatly encourage this move if player is badly poisoned. - ld a, [PlayerSubStatus5] - bit SUBSTATUS_TOXIC, a - jr nz, .asm_388ef - -; ...70% chance to greatly encourage this move if player is not badly poisoned. - call Random - cp 70 percent - jr nc, .asm_38911 - -.asm_388ef - dec [hl] - dec [hl] - ret - -.asm_388f2 - -; Greatly discourage this move if enemy's HP is below 25%. - call AICheckEnemyQuarterHP - jr nc, .asm_3890f - -; If enemy's HP is above 25% but not full, 4% chance to greatly encourage this move. - call Random - cp 4 percent - jr c, .asm_388ef - -; If enemy's HP is between 25% and 50%,... - call AICheckEnemyHalfHP - jr nc, .asm_3890a - -; If enemy's HP is above 50% but not full, 20% chance to greatly encourage this move. - call AI_80_20 - jr c, .asm_388ef - jr .asm_38911 - -.asm_3890a -; ...50% chance to greatly discourage this move. - call AI_50_50 - jr c, .asm_38911 - -.asm_3890f - inc [hl] - inc [hl] - -; 30% chance to end up here if enemy's HP is full and player is not badly poisoned. -; 77% chance to end up here if enemy's HP is above 50% but not full. -; 96% chance to end up here if enemy's HP is between 25% and 50%. -; 100% chance to end up here if enemy's HP is below 25%. -; In other words, we only end up here if the move has not been encouraged or dismissed. -.asm_38911 - ld a, [PlayerSubStatus5] - bit SUBSTATUS_TOXIC, a - jr nz, .asm_38938 - - ld a, [PlayerSubStatus4] - bit SUBSTATUS_LEECH_SEED, a - jr nz, .asm_38941 - -; Discourage this move if enemy's evasion level is higher than player's accuracy level. - ld a, [EnemyEvaLevel] - ld b, a - ld a, [PlayerAccLevel] - cp b - jr c, .asm_38936 - -; Greatly encourage this move if the player is in the middle of Fury Cutter or Rollout. - ld a, [PlayerFuryCutterCount] - and a - jr nz, .asm_388ef - - ld a, [PlayerSubStatus1] - bit SUBSTATUS_ROLLOUT, a - jr nz, .asm_388ef - - -.asm_38936 - inc [hl] - ret - -; Player is badly poisoned. -; 70% chance to greatly encourage this move. -; This would counter any previous discouragement. -.asm_38938 - call Random - cp 31 percent + 1 - ret c - dec [hl] - dec [hl] - ret - -; Player is seeded. -; 50% chance to encourage this move. -; This would partly counter any previous discouragement. -.asm_38941 - call AI_50_50 - ret c - - dec [hl] - ret -; 38947 - - -AI_Smart_AlwaysHit: ; 38947 -; 80% chance to greatly encourage this move if either... - -; ...enemy's accuracy level has been lowered three or more stages - ld a, [EnemyAccLevel] - cp $5 - jr c, .asm_38954 - -; ...or player's evasion level has been raised three or more stages. - ld a, [PlayerEvaLevel] - cp $a - ret c - -.asm_38954 - call AI_80_20 - ret c - - dec [hl] - dec [hl] - ret -; 3895b - - -AI_Smart_MirrorMove: ; 3895b - -; If the player did not use any move last turn... - ld a, [LastPlayerCounterMove] - and a - jr nz, .asm_38968 - -; ...do nothing if enemy is slower than player - call AICompareSpeed - ret nc - -; ...or dismiss this move if enemy is faster than player. - jp AIDiscourageMove - -; If the player did use a move last turn... -.asm_38968 - push hl - ld hl, UsefulMoves - ld de, 1 - call IsInArray - pop hl - -; ...do nothing if he didn't use a useful move. - ret nc - -; If he did, 50% chance to encourage this move... - call AI_50_50 - ret c - - dec [hl] - -; ...and 90% chance to encourage this move again if the enemy is faster. - call AICompareSpeed - ret nc - - call Random - cp 10 percent - ret c - - dec [hl] - ret -; 38985 - - -AI_Smart_AccuracyDown: ; 38985 - -; If player's HP is full... - call AICheckPlayerMaxHP - jr nc, .asm_389a0 - -; ...and enemy's HP is above 50%... - call AICheckEnemyHalfHP - jr nc, .asm_389a0 - -; ...greatly encourage this move if player is badly poisoned. - ld a, [PlayerSubStatus5] - bit SUBSTATUS_TOXIC, a - jr nz, .asm_3899d - -; ...70% chance to greatly encourage this move if player is not badly poisoned. - call Random - cp 70 percent - jr nc, .asm_389bf - -.asm_3899d - dec [hl] - dec [hl] - ret - -.asm_389a0 - -; Greatly discourage this move if player's HP is below 25%. - call AICheckPlayerQuarterHP - jr nc, .asm_389bd - -; If player's HP is above 25% but not full, 4% chance to greatly encourage this move. - call Random - cp 4 percent - jr c, .asm_3899d - -; If player's HP is between 25% and 50%,... - call AICheckPlayerHalfHP - jr nc, .asm_389b8 - -; If player's HP is above 50% but not full, 20% chance to greatly encourage this move. - call AI_80_20 - jr c, .asm_3899d - jr .asm_389bf - -; ...50% chance to greatly discourage this move. -.asm_389b8 - call AI_50_50 - jr c, .asm_389bf - -.asm_389bd - inc [hl] - inc [hl] - -; We only end up here if the move has not been already encouraged. -.asm_389bf - ld a, [PlayerSubStatus5] - bit SUBSTATUS_TOXIC, a - jr nz, .asm_389e6 - - ld a, [PlayerSubStatus4] - bit SUBSTATUS_LEECH_SEED, a - jr nz, .asm_389ef - -; Discourage this move if enemy's evasion level is higher than player's accuracy level. - ld a, [EnemyEvaLevel] - ld b, a - ld a, [PlayerAccLevel] - cp b - jr c, .asm_389e4 - -; Greatly encourage this move if the player is in the middle of Fury Cutter or Rollout. - ld a, [PlayerFuryCutterCount] - and a - jr nz, .asm_3899d - - ld a, [PlayerSubStatus1] - bit SUBSTATUS_ROLLOUT, a - jr nz, .asm_3899d - -.asm_389e4 - inc [hl] - ret - -; Player is badly poisoned. -; 70% chance to greatly encourage this move. -; This would counter any previous discouragement. -.asm_389e6 - call Random - cp 31 percent + 1 - ret c - dec [hl] - dec [hl] - ret - -; Player is seeded. -; 50% chance to encourage this move. -; This would partly counter any previous discouragement. -.asm_389ef - call AI_50_50 - ret c - - dec [hl] - ret -; 389f5 - - -AI_Smart_ResetStats: ; 389f5 - -; 85% chance to encourage this move if any of enemy's stat levels is lower than -2. - push hl - ld hl, EnemyAtkLevel - ld c, $8 -.asm_389fb - dec c - jr z, .asm_38a05 - ld a, [hli] - cp $5 - jr c, .asm_38a12 - jr .asm_389fb - -; 85% chance to encourage this move if any of player's stat levels is higher than +2. -.asm_38a05 - ld hl, PlayerAtkLevel - ld c, $8 -.asm_38a0a - dec c - jr z, .asm_38a1b - ld a, [hli] - cp $a - jr c, .asm_38a0a - -.asm_38a12 - pop hl - call Random - cp 16 percent - ret c - dec [hl] - ret - -; Discourage this move if neither: -; Any of enemy's stat levels is lower than -2. -; Any of player's stat levels is higher than +2. -.asm_38a1b - pop hl - inc [hl] - ret -; 38a1e - - -AI_Smart_Bide: ; 38a1e -; 90% chance to discourage this move unless enemy's HP is full. - - call AICheckEnemyMaxHP - ret c - call Random - cp 10 percent - ret c - inc [hl] - ret -; 38a2a - - -AI_Smart_ForceSwitch: ; 38a2a -; Whirlwind, Roar. - -; Discourage this move if the player has not shown -; a super-effective move against the enemy. -; Consider player's type(s) if its moves are unknown. - - push hl - callfar CheckPlayerMoveTypeMatchups - ld a, [wEnemyAISwitchScore] - cp 10 ; neutral - pop hl - ret c - inc [hl] - ret -; 38a3a - - -AI_Smart_Heal: -AI_Smart_MorningSun: -AI_Smart_Synthesis: -AI_Smart_Moonlight: ; 38a3a -; 90% chance to greatly encourage this move if enemy's HP is below 25%. -; Discourage this move if enemy's HP is higher than 50%. -; Do nothing otherwise. - - call AICheckEnemyQuarterHP - jr nc, .asm_38a45 - call AICheckEnemyHalfHP - ret nc - inc [hl] - ret - -.asm_38a45 - call Random - cp 10 percent - ret c - dec [hl] - dec [hl] - ret -; 38a4e - - -AI_Smart_Toxic: -AI_Smart_LeechSeed: ; 38a4e -; Discourage this move if player's HP is below 50%. - - call AICheckPlayerHalfHP - ret c - inc [hl] - ret -; 38a54 - - -AI_Smart_LightScreen: -AI_Smart_Reflect: ; 38a54 -; Over 90% chance to discourage this move unless enemy's HP is full. - - call AICheckEnemyMaxHP - ret c - call Random - cp 8 percent - ret c - inc [hl] - ret -; 38a60 - - -AI_Smart_Ohko: ; 38a60 -; Dismiss this move if player's level is higher than enemy's level. -; Else, discourage this move is player's HP is below 50%. - - ld a, [BattleMonLevel] - ld b, a - ld a, [EnemyMonLevel] - cp b - jp c, AIDiscourageMove - call AICheckPlayerHalfHP - ret c - inc [hl] - ret -; 38a71 - - -AI_Smart_TrapTarget: ; 38a71 -; Bind, Wrap, Fire Spin, Clamp - -; 50% chance to discourage this move if the player is already trapped. - ld a, [wPlayerWrapCount] - and a - jr nz, .asm_38a8b - -; 50% chance to greatly encourage this move if player is either -; badly poisoned, in love, identified, stuck in Rollout, or has a Nightmare. - ld a, [PlayerSubStatus5] - bit SUBSTATUS_TOXIC, a - jr nz, .asm_38a91 - - ld a, [PlayerSubStatus1] - and 1< player's current HP]. - - push hl - ld hl, EnemyMonHP - ld b, [hl] - inc hl - ld c, [hl] - sla c - rl b - ld hl, BattleMonHP + 1 - ld a, [hld] - cp c - ld a, [hl] - sbc b - pop hl - ret nc - inc [hl] - ret -; 38cba - - -AI_Smart_Snore: -AI_Smart_SleepTalk: ; 38cba -; Greatly encourage this move if enemy is fast asleep. -; Greatly discourage this move otherwise. - - ld a, [EnemyMonStatus] - and $7 - cp $1 - jr z, .asm_38cc7 - - dec [hl] - dec [hl] - dec [hl] - ret - -.asm_38cc7 - inc [hl] - inc [hl] - inc [hl] - ret -; 38ccb - - -AI_Smart_DefrostOpponent: ; 38ccb -; Greatly encourage this move if enemy is frozen. -; No move has EFFECT_DEFROST_OPPONENT, so this layer is unused. - - ld a, [EnemyMonStatus] - and $20 - ret z - dec [hl] - dec [hl] - dec [hl] - ret -; 38cd5 - - -AI_Smart_Spite: ; 38cd5 - ld a, [LastPlayerCounterMove] - and a - jr nz, .asm_38ce7 - - call AICompareSpeed - jp c, AIDiscourageMove - - call AI_50_50 - ret c - inc [hl] - ret - -.asm_38ce7 - push hl - ld b, a - ld c, 4 - ld hl, BattleMonMoves - ld de, BattleMonPP - -.asm_38cf1 - ld a, [hli] - cp b - jr z, .asm_38cfb - - inc de - dec c - jr nz, .asm_38cf1 - - pop hl - ret - -.asm_38cfb - pop hl - ld a, [de] - cp $6 - jr c, .asm_38d0d - cp $f - jr nc, .asm_38d0b - - call Random - cp 39 percent + 1 - ret nc - -.asm_38d0b - inc [hl] - ret - -.asm_38d0d - call Random - cp 39 percent + 1 - ret c - dec [hl] - dec [hl] - ret -; 38d16 - - -Function_0x38d16; 38d16 - jp AIDiscourageMove -; 38d19 - - -AI_Smart_DestinyBond: -AI_Smart_Reversal: -AI_Smart_SkullBash: ; 38d19 -; Discourage this move if enemy's HP is above 25%. - - call AICheckEnemyQuarterHP - ret nc - inc [hl] - ret -; 38d1f - - -AI_Smart_HealBell: ; 38d1f -; Dismiss this move if none of the opponent's Pokemon is statused. -; Encourage this move if the enemy is statused. -; 50% chance to greatly encourage this move if the enemy is fast asleep or frozen. - - push hl - ld a, [OTPartyCount] - ld b, a - ld c, 0 - ld hl, OTPartyMon1HP - ld de, PARTYMON_STRUCT_LENGTH - -.loop - push hl - ld a, [hli] - or [hl] - jr z, .next - - ; status - dec hl - dec hl - dec hl - ld a, [hl] - or c - ld c, a - -.next - pop hl - add hl, de - dec b - jr nz, .loop - - pop hl - ld a, c - and a - jr z, .no_status - - ld a, [EnemyMonStatus] - and a - jr z, .ok - dec [hl] -.ok - and 1 << FRZ | SLP - ret z - call AI_50_50 - ret c - dec [hl] - dec [hl] - ret - -.no_status - ld a, [EnemyMonStatus] - and a - ret nz - jp AIDiscourageMove - -; 38d5a - - -AI_Smart_PriorityHit: ; 38d5a - call AICompareSpeed - ret c - -; Dismiss this move if the player is flying or underground. - ld a, [PlayerSubStatus3] - and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND - jp nz, AIDiscourageMove - -; Greatly encourage this move if it will KO the player. - ld a, $1 - ld [hBattleTurn], a - push hl - callfar EnemyAttackDamage - callfar BattleCommand_DamageCalc - callfar BattleCommand_Stab - pop hl - ld a, [CurDamage + 1] - ld c, a - ld a, [CurDamage] - ld b, a - ld a, [BattleMonHP + 1] - cp c - ld a, [BattleMonHP] - sbc b - ret nc - dec [hl] - dec [hl] - dec [hl] - ret -; 38d93 - - -AI_Smart_Thief: ; 38d93 -; Don't use Thief unless it's the only move available. - - ld a, [hl] - add $1e - ld [hl], a - ret -; 38d98 - - -AI_Smart_Conversion2: ; 38d98 - ld a, [LastPlayerMove] - and a - jr nz, .asm_38dc9 - - push hl - dec a - ld hl, Moves + MOVE_TYPE - ld bc, MOVE_LENGTH - call AddNTimes - - ld a, BANK(Moves) - call GetFarByte - ld [wPlayerMoveStruct + MOVE_TYPE], a - - xor a - ld [hBattleTurn], a - - callfar BattleCheckTypeMatchup - - ld a, [wd265] - cp $a - pop hl - jr c, .asm_38dc9 - ret z - - call AI_50_50 - ret c - - dec [hl] - ret - -.asm_38dc9 - call Random - cp 10 percent - ret c - inc [hl] - ret -; 38dd1 - - -AI_Smart_Disable: ; 38dd1 - call AICompareSpeed - jr nc, .asm_38df3 - - push hl - ld a, [LastPlayerCounterMove] - ld hl, UsefulMoves - ld de, 1 - call IsInArray - - pop hl - jr nc, .asm_38dee - - call Random - cp 39 percent + 1 - ret c - dec [hl] - ret - -.asm_38dee - ld a, [wEnemyMoveStruct + MOVE_POWER] - and a - ret nz - -.asm_38df3 - call Random - cp 8 percent - ret c - inc [hl] - ret -; 38dfb - - -AI_Smart_MeanLook: ; 38dfb - call AICheckEnemyHalfHP - jr nc, .asm_38e24 - - push hl - call AICheckLastPlayerMon - pop hl - jp z, AIDiscourageMove - -; 80% chance to greatly encourage this move if the enemy is badly poisoned (buggy). -; Should check PlayerSubStatus5 instead. - ld a, [EnemySubStatus5] - bit SUBSTATUS_TOXIC, a - jr nz, .asm_38e26 - -; 80% chance to greatly encourage this move if the player is either -; in love, identified, stuck in Rollout, or has a Nightmare. - ld a, [PlayerSubStatus1] - and 1<