Function_0x38591: ; 38591 ld hl, Buffer1 - 1 ld de, EnemyMonMoves ld b, EnemyMonMovesEnd - EnemyMonMoves + 1 .asm_38599 dec b ret z inc hl ld a, [de] and a ret z inc de call Function_0x39508 ld a, [EnemyMoveEffect] ld c, a push hl push de push bc ld a, $b ld hl, $441a rst FarCall pop bc pop de pop hl jr nz, .asm_385d6 ld a, [EnemyMoveEffect] push hl push de push bc ld hl, .table_385db ld de, 1 call IsInArray pop bc pop de pop hl jr nc, .asm_38599 ld a, [BattleMonStatus] and a jr nz, .asm_385d6 ld a, [PlayerScreens] bit 2, a jr z, .asm_38599 .asm_385d6 call Function_0x39503 jr .asm_38599 ; 385db .table_385db db EFFECT_SLEEP db EFFECT_TOXIC db EFFECT_POISON db EFFECT_PARALYZE db $ff ; 385e0 Function_0x385e0: ; 385e0 ld hl, Buffer1 - 1 ld de, EnemyMonMoves ld b, EnemyMonMovesEnd - EnemyMonMoves + 1 .next dec b ret z inc hl ld a, [de] and a ret z inc de call Function_0x39508 ld a, [EnemyMoveEffect] cp EFFECT_ATTACK_UP jr c, .next cp EFFECT_EVASION_UP + 1 jr c, .statup ; cp EFFECT_ATTACK_DOWN - 1 jr z, .next cp EFFECT_EVASION_DOWN + 1 jr c, .statdown cp EFFECT_ATTACK_UP_2 jr c, .next cp EFFECT_EVASION_UP_2 + 1 jr c, .statup ; cp EFFECT_ATTACK_DOWN_2 - 1 jr z, .next cp EFFECT_EVASION_DOWN_2 + 1 jr c, .statdown jr .next .statup ld a, [EnemyTurnsTaken] and a jr nz, .asm_3862a jr .asm_38621 .statdown ld a, [PlayerTurnsTaken] and a jr nz, .asm_3862a .asm_38621 call Function_0x39527 jr c, .next dec [hl] dec [hl] jr .next .asm_3862a call RNG cp $1e jr c, .next inc [hl] inc [hl] jr .next ; 38635 Function_0x38635: ; 38635 ld hl, Buffer1 - 1 ld de, EnemyMonMoves ld b, EnemyMonMovesEnd - EnemyMonMoves + 1 .asm_3863d dec b ret z inc hl ld a, [de] and a ret z inc de call Function_0x39508 push hl push bc push de ld a, 1 ld [hBattleTurn], a ld hl, $47c8 ld a, $d rst FarCall pop de pop bc pop hl ld a, [$d265] and a jr z, .asm_3869d cp $a jr z, .asm_3863d jr c, .asm_3866c ld a, [EnemyMovePower] and a jr z, .asm_3863d dec [hl] jr .asm_3863d .asm_3866c push hl push de push bc ld a, [EnemyMoveType] ld d, a ld hl, EnemyMonMoves ld b, EnemyMonMovesEnd - EnemyMonMoves + 1 ld c, 0 .asm_3867a dec b jr z, .asm_38693 ld a, [hli] and a jr z, .asm_38693 call Function_0x39508 ld a, [EnemyMoveType] cp d jr z, .asm_3867a ld a, [EnemyMovePower] and a jr nz, .asm_38692 jr .asm_3867a .asm_38692 ld c, a .asm_38693 ld a, c pop bc pop de pop hl and a jr z, .asm_3863d inc [hl] jr .asm_3863d .asm_3869d call Function_0x39503 jr .asm_3863d ; 386a2 Function_0x386a2: ; 386a2 ld hl, Buffer1 - 1 ld de, EnemyMonMoves ld b, EnemyMonMovesEnd - EnemyMonMoves + 1 .asm_386aa dec b ret z inc hl ld a, [de] and a ret z inc de call Function_0x39508 ld a, [EnemyMovePower] and a jr nz, .asm_386aa inc [hl] inc [hl] jr .asm_386aa ; 386be Function_0x386be: ; 386be ld hl, Buffer1 ld de, EnemyMonMoves ld b, EnemyMonMovesEnd - EnemyMonMoves + 1 .asm_386c6 dec b ret z ld a, [de] inc de and a ret z push de push bc push hl call Function_0x39508 ld a, [EnemyMoveEffect] ld hl, .table_386f2 ld de, 3 call IsInArray inc hl jr nc, .asm_386ec ld a, [hli] ld e, a ld d, [hl] pop hl push hl ld bc, .asm_386ec push bc push de ret .asm_386ec pop hl pop bc pop de inc hl jr .asm_386c6 ; 386f2 .table_386f2 ; 386f2 dbw EFFECT_SLEEP, AIScoring_Sleep dbw EFFECT_LEECH_HIT, AIScoring_LeechHit dbw EFFECT_EXPLOSION, AIScoring_Explosion dbw EFFECT_DREAM_EATER, AIScoring_DreamEater dbw EFFECT_MIRROR_MOVE, AIScoring_MirrorMove dbw EFFECT_EVASION_UP, AIScoring_EvasionUp dbw EFFECT_ALWAYS_HIT, AIScoring_AlwaysHit dbw EFFECT_ACCURACY_DOWN, AIScoring_AccuracyDown dbw EFFECT_HAZE, AIScoring_Haze dbw EFFECT_BIDE, AIScoring_Bide dbw EFFECT_WHIRLWIND, AIScoring_Whirlwind dbw EFFECT_HEAL, AIScoring_Heal dbw EFFECT_TOXIC, AIScoring_Toxic dbw EFFECT_LIGHT_SCREEN, AIScoring_LightScreen dbw EFFECT_OHKO, AIScoring_Ohko dbw EFFECT_RAZOR_WIND, AIScoring_RazorWind dbw EFFECT_SUPER_FANG, AIScoring_SuperFang dbw EFFECT_BIND, AIScoring_Bind dbw EFFECT_UNUSED_2B, AIScoring_Unused2B dbw EFFECT_CONFUSE, AIScoring_Confuse dbw EFFECT_SP_DEFENSE_UP_2, AIScoring_SpDefenseUp2 dbw EFFECT_REFLECT, AIScoring_Reflect dbw EFFECT_PARALYZE, AIScoring_Paralyze dbw EFFECT_SPEED_DOWN_HIT, AIScoring_SpeedDownHit dbw EFFECT_SUBSTITUTE, AIScoring_Substitute dbw EFFECT_HYPER_BEAM, AIScoring_HyperBeam dbw EFFECT_RAGE, AIScoring_Rage dbw EFFECT_MIMIC, AIScoring_Mimic dbw EFFECT_LEECH_SEED, AIScoring_LeechSeed dbw EFFECT_DISABLE, AIScoring_Disable dbw EFFECT_COUNTER, AIScoring_Counter dbw EFFECT_ENCORE, AIScoring_Encore dbw EFFECT_PAIN_SPLIT, AIScoring_PainSplit dbw EFFECT_SNORE, AIScoring_Snore dbw EFFECT_CONVERSION2, AIScoring_Conversion2 dbw EFFECT_LOCK_ON, AIScoring_LockOn dbw EFFECT_DEFROST_OPPONENT, AIScoring_DefrostOpponent dbw EFFECT_SLEEP_TALK, AIScoring_SleepTalk dbw EFFECT_DESTINY_BOND, AIScoring_DestinyBond dbw EFFECT_REVERSAL, AIScoring_Reversal dbw EFFECT_SPITE, AIScoring_Spite dbw EFFECT_HEAL_BELL, AIScoring_HealBell dbw EFFECT_PRIORITY_HIT, AIScoring_PriorityHit dbw EFFECT_THIEF, AIScoring_Thief dbw EFFECT_MEAN_LOOK, AIScoring_MeanLook dbw EFFECT_NIGHTMARE, AIScoring_Nightmare dbw EFFECT_FLAME_WHEEL, AIScoring_FlameWheel dbw EFFECT_CURSE, AIScoring_Curse dbw EFFECT_PROTECT, AIScoring_Protect dbw EFFECT_FORESIGHT, AIScoring_Foresight dbw EFFECT_PERISH_SONG, AIScoring_PerishSong dbw EFFECT_SANDSTORM, AIScoring_Sandstorm dbw EFFECT_ENDURE, AIScoring_Endure dbw EFFECT_ROLLOUT, AIScoring_Rollout dbw EFFECT_SWAGGER, AIScoring_Swagger dbw EFFECT_FURY_CUTTER, AIScoring_FuryCutter dbw EFFECT_ATTRACT, AIScoring_Attract dbw EFFECT_SAFEGUARD, AIScoring_Safeguard dbw EFFECT_MAGNITUDE, AIScoring_Magnitude dbw EFFECT_BATON_PASS, AIScoring_BatonPass dbw EFFECT_PURSUIT, AIScoring_Pursuit dbw EFFECT_RAPID_SPIN, AIScoring_RapidSpin dbw EFFECT_MORNING_SUN, AIScoring_MorningSun dbw EFFECT_SYNTHESIS, AIScoring_Synthesis dbw EFFECT_MOONLIGHT, AIScoring_Moonlight dbw EFFECT_HIDDEN_POWER, AIScoring_HiddenPower dbw EFFECT_RAIN_DANCE, AIScoring_RainDance dbw EFFECT_SUNNY_DAY, AIScoring_SunnyDay dbw EFFECT_BELLY_DRUM, AIScoring_BellyDrum dbw EFFECT_PSYCH_UP, AIScoring_PsychUp dbw EFFECT_MIRROR_COAT, AIScoring_MirrorCoat dbw EFFECT_SKULL_BASH, AIScoring_SkullBash dbw EFFECT_TWISTER, AIScoring_Twister dbw EFFECT_EARTHQUAKE, AIScoring_Earthquake dbw EFFECT_FUTURE_SIGHT, AIScoring_FutureSight dbw EFFECT_GUST, AIScoring_Gust dbw EFFECT_STOMP, AIScoring_Stomp dbw EFFECT_SOLARBEAM, AIScoring_Solarbeam dbw EFFECT_THUNDER, AIScoring_Thunder dbw EFFECT_FLY, AIScoring_Fly db $ff ; 387e3 AIScoring_Sleep: ; 387e3 ld b, $8 call Function_0x392ca jr c, .asm_387f0 ld b, $6b call Function_0x392ca ret nc .asm_387f0 call Function_0x39527 ret c dec [hl] dec [hl] ret ; 387f7 AIScoring_LeechHit: ; 387f7 push hl ld a, $1 ld [hBattleTurn], a ld hl, $47c8 ld a, $d rst FarCall pop hl ld a, [$d265] cp $a jr c, .asm_38815 ret z call Function_0x39251 ret c call Function_0x39521 ret c dec [hl] ret .asm_38815 call RNG cp $64 ret c inc [hl] ret ; 3881d AIScoring_LockOn: ; 3881d ld a, [PlayerSubStatus5] bit 5, a jr nz, .asm_38882 push hl call Function_0x39298 jr nc, .asm_38877 call Function_0x39281 jr c, .asm_38834 call Function_0x39233 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 Function_0x39508 ld a, [EnemyMoveAccuracy] cp $b4 jr nc, .asm_3884f ld a, $1 ld [hBattleTurn], a push hl push bc ld a, $d ld hl, $47c8 rst FarCall ld a, [$d265] 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 Function_0x39527 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 Function_0x39508 ld a, [EnemyMoveAccuracy] cp $b4 jr nc, .asm_3888b dec [hl] dec [hl] jr .asm_3888b .asm_388a2 pop hl jp Function_0x39503 ; 388a6 AIScoring_Explosion: ; 388a6 push hl ld a, $d ld hl, $49f4 rst FarCall pop hl jr nc, .asm_388b7 push hl call Function_0x38e2e pop hl jr nz, .asm_388c6 .asm_388b7 call Function_0x39281 jr c, .asm_388c6 call Function_0x39298 ret nc call RNG cp $14 ret c .asm_388c6 inc [hl] inc [hl] inc [hl] ret ; 388ca AIScoring_DreamEater: ; 388ca call RNG cp $19 ret c dec [hl] dec [hl] dec [hl] ret ; 388d4 AIScoring_EvasionUp: ; 388d4 ld a, [EnemyEvaLevel] cp $d jp nc, Function_0x39503 call Function_0x39251 jr nc, .asm_388f2 ld a, [PlayerSubStatus5] bit 0, a jr nz, .asm_388ef call RNG cp $b2 jr nc, .asm_38911 .asm_388ef dec [hl] dec [hl] ret .asm_388f2 call Function_0x39298 jr nc, .asm_3890f call RNG cp $a jr c, .asm_388ef call Function_0x39281 jr nc, .asm_3890a call Function_0x39521 jr c, .asm_388ef jr .asm_38911 .asm_3890a call Function_0x39527 jr c, .asm_38911 .asm_3890f inc [hl] inc [hl] .asm_38911 ld a, [PlayerSubStatus5] bit 0, a jr nz, .asm_38938 ld a, [PlayerSubStatus4] bit 7, a jr nz, .asm_38941 ld a, [EnemyEvaLevel] ld b, a ld a, [PlayerAccLevel] cp b jr c, .asm_38936 ld a, [PlayerFuryCutterCount] and a jr nz, .asm_388ef ld a, [PlayerSubStatus1] bit 6, a jr nz, .asm_388ef .asm_38936 inc [hl] ret .asm_38938 call RNG cp $50 ret c dec [hl] dec [hl] ret .asm_38941 call Function_0x39527 ret c dec [hl] ret ; 38947 AIScoring_AlwaysHit: ; 38947 ld a, [EnemyAccLevel] cp $5 jr c, .asm_38954 ld a, [PlayerEvaLevel] cp $a ret c .asm_38954 call Function_0x39521 ret c dec [hl] dec [hl] ret ; 3895b AIScoring_MirrorMove: ; 3895b ld a, [LastEnemyCounterMove] and a jr nz, .asm_38968 call Function_0x39233 ret nc jp Function_0x39503 .asm_38968 push hl ld hl, Table_0x39301 ld de, 1 call IsInArray pop hl ret nc call Function_0x39527 ret c dec [hl] call Function_0x39233 ret nc call RNG cp $19 ret c dec [hl] ret ; 38985 AIScoring_AccuracyDown: ; 38985 call Function_0x39246 jr nc, .asm_389a0 call Function_0x39281 jr nc, .asm_389a0 ld a, [PlayerSubStatus5] bit 0, a jr nz, .asm_3899d call RNG cp $b2 jr nc, .asm_389bf .asm_3899d dec [hl] dec [hl] ret .asm_389a0 call Function_0x392b3 jr nc, .asm_389bd call RNG cp $a jr c, .asm_3899d call Function_0x3926e jr nc, .asm_389b8 call Function_0x39521 jr c, .asm_3899d jr .asm_389bf .asm_389b8 call Function_0x39527 jr c, .asm_389bf .asm_389bd inc [hl] inc [hl] .asm_389bf ld a, [PlayerSubStatus5] bit 0, a jr nz, .asm_389e6 ld a, [PlayerSubStatus4] bit 7, a jr nz, .asm_389ef ld a, [EnemyEvaLevel] ld b, a ld a, [PlayerAccLevel] cp b jr c, .asm_389e4 ld a, [PlayerFuryCutterCount] and a jr nz, .asm_3899d ld a, [PlayerSubStatus1] bit 6, a jr nz, .asm_3899d .asm_389e4 inc [hl] ret .asm_389e6 call RNG cp $50 ret c dec [hl] dec [hl] ret .asm_389ef call Function_0x39527 ret c dec [hl] ret ; 389f5 AIScoring_Haze: ; 389f5 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 .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 RNG cp $28 ret c dec [hl] ret .asm_38a1b pop hl inc [hl] ret ; 38a1e AIScoring_Bide: ; 38a1e call Function_0x39251 ret c call RNG cp $19 ret c inc [hl] ret ; 38a2a AIScoring_Whirlwind: ; 38a2a push hl ld hl, $484e ld a, $d rst FarCall ld a, [$c716] cp $a pop hl ret c inc [hl] ret ; 38a3a AIScoring_Heal: AIScoring_MorningSun: AIScoring_Synthesis: AIScoring_Moonlight: ; 38a3a call Function_0x39298 jr nc, .asm_38a45 call Function_0x39281 ret nc inc [hl] ret .asm_38a45 call RNG cp $19 ret c dec [hl] dec [hl] ret ; 38a4e AIScoring_Toxic: AIScoring_LeechSeed: ; 38a4e call Function_0x3926e ret c inc [hl] ret ; 38a54 AIScoring_LightScreen: AIScoring_Reflect: ; 38a54 call Function_0x39251 ret c call RNG cp $14 ret c inc [hl] ret ; 38a60 AIScoring_Ohko: ; 38a60 ld a, [BattleMonLevel] ld b, a ld a, [EnemyMonLevel] cp b jp c, Function_0x39503 call Function_0x3926e ret c inc [hl] ret ; 38a71 AIScoring_Bind: ; 38a71 ld a, [$c730] and a jr nz, .asm_38a8b ld a, [PlayerSubStatus5] bit SUBSTATUS_TOXIC, a jr nz, .asm_38a91 ld a, [PlayerSubStatus1] and 1<