diff options
Diffstat (limited to 'battle/ai')
-rw-r--r-- | battle/ai/items.asm | 847 | ||||
-rw-r--r-- | battle/ai/scoring.asm | 316 |
2 files changed, 987 insertions, 176 deletions
diff --git a/battle/ai/items.asm b/battle/ai/items.asm new file mode 100644 index 000000000..6cd1cad2d --- /dev/null +++ b/battle/ai/items.asm @@ -0,0 +1,847 @@ +Function38000: ; 38000 + and a + ld a, [IsInBattle] + dec a + ret z + ld a, [InLinkBattle] + and a + ret nz + callba Function3e8d1 + ret nz + ld a, [PlayerSubStatus5] + bit SUBSTATUS_CANT_RUN, a + jr nz, Function38041 + ld a, [$c731] + and a + jr nz, Function38041 + ld hl, TrainerClassAttributes + 5 + ld a, [$cfc0] + and a + jr nz, .asm_38032 + ld a, [TrainerClass] + dec a + ld bc, 7 + call AddNTimes + +.asm_38032 + bit 0, [hl] + jp nz, Function38045 + bit 1, [hl] + jp nz, Function38083 + bit 2, [hl] + jp nz, Function380c1 + ; fallthrough +; 38041 + +Function38041: ; 38041 + call Function38105 + ret +; 38045 + +Function38045: ; 38045 + callab Function34941 + ld a, [$c717] + and $f0 + jp z, Function38041 + cp $10 + jr nz, .asm_38061 + call Random + cp $80 + jr c, .asm_38077 + jp Function38041 + +.asm_38061 + cp $20 + jr nz, .asm_3806f + call Random + cp $c8 + jr c, .asm_38077 + jp Function38041 + +.asm_3806f + call Random + cp $a + jp c, Function38041 + +.asm_38077 + ld a, [$c717] + and $f + inc a + ld [$c718], a + jp Function3844b +; 38083 + +Function38083: ; 38083 + callab Function34941 + ld a, [$c717] + and $f0 + jp z, Function38041 + cp $10 + jr nz, .asm_3809f + call Random + cp $14 + jr c, .asm_380b5 + jp Function38041 + +.asm_3809f + cp $20 + jr nz, .asm_380ad + call Random + cp $1e + jr c, .asm_380b5 + jp Function38041 + +.asm_380ad + call Random + cp $c8 + jp c, Function38041 + +.asm_380b5 + ld a, [$c717] + and $f + inc a + ld [$c718], a + jp Function3844b +; 380c1 + +Function380c1: ; 380c1 + callab Function34941 + ld a, [$c717] + and $f0 + jp z, Function38041 + cp $10 + jr nz, .asm_380dd + call Random + cp $32 + jr c, .asm_380f3 + jp Function38041 + +.asm_380dd + cp $20 + jr nz, .asm_380eb + call Random + cp $80 + jr c, .asm_380f3 + jp Function38041 + +.asm_380eb + call Random + cp $32 + jp c, Function38041 + +.asm_380f3 + ld a, [$c717] + and $f + inc a + ld [$c718], a + jp Function3844b +; 380ff + + +Function380ff: ; 380ff + ld a, [EnemySubStatus5] + bit SUBSTATUS_CANT_RUN, a + ret +; 38105 + + +Function38105: ; 38105 + ld a, [$cfc0] + and a + ret nz + ld a, [$c650] + ld b, a + ld a, [$c651] + or b + ret z + call Function38170 + ret nc + ld a, [TrainerClass] + dec a + ld hl, TrainerClassAttributes + 5 + ld bc, 7 + call AddNTimes + ld b, h + ld c, l + ld hl, Unknown_38196 + ld de, $c650 +.asm_3812c + ld a, [hl] + and a + inc a + ret z + ld a, [de] + cp [hl] + jr z, .asm_3813f + inc de + ld a, [de] + cp [hl] + jr z, .asm_3813f + dec de + inc hl + inc hl + inc hl + jr .asm_3812c + +.asm_3813f + inc hl + push hl + push de + ld de, .asm_3814a + push de + ld a, [hli] + ld h, [hl] + ld l, a + jp [hl] + +.asm_3814a + pop de + pop hl + inc hl + inc hl + jr c, .asm_3812c + xor a + ld [de], a + inc a + ld [$c70f], a + ld hl, EnemySubStatus3 ; $c66f + res SUBSTATUS_BIDE, [hl] + xor a + ld [EnemyFuryCutterCount], a ; $c680 + ld [$c681], a + ld [$c72c], a + ld hl, EnemySubStatus4 ; $c670 + res SUBSTATUS_RAGE, [hl] + xor a + ld [LastPlayerCounterMove], a ; $c6f9 + scf + ret + + +Function38170: ; 38170 + ld a, [OTPartyCount] + ld d, a + ld e, 0 + ld hl, OTPartyMon1Level + ld bc, OTPartyMon2 - OTPartyMon1 +.asm_3817c + ld a, [hl] + cp e + jr c, .asm_38181 + ld e, a +.asm_38181 + add hl, bc + dec d + jr nz, .asm_3817c + + ld a, [CurOTMon] + ld hl, OTPartyMon1Level + call AddNTimes + ld a, [hl] + cp e + jr nc, .asm_38194 + and a + ret + +.asm_38194 + scf + ret +; 38196 + +Unknown_38196: ; 39196 + dbw FULL_RESTORE, Function38208 + dbw MAX_POTION, Function38220 + dbw HYPER_POTION, Function38284 + dbw SUPER_POTION, Function38292 + dbw POTION, Function382a0 + dbw X_ACCURACY, Function382f9 + dbw FULL_HEAL, Function381be + dbw GUARD_SPEC, Function38305 + dbw DIRE_HIT, Function38311 + dbw X_ATTACK, Function3831d + dbw X_DEFEND, Function38329 + dbw X_SPEED, Function38335 + dbw X_SPECIAL, Function38341 + db $ff +; 381be + +Function381be: ; 381be + call Function381ca + jp c, Function38383 + call Function383a3 + jp Function38385 +; 381ca + +; known jump sources: 381be (e:41be), 38214 (e:4214) +Function381ca: ; 381ca (e:41ca) + ld a, [EnemyMonStatus] ; $d214 + and a + jp z, Function38383 + + ld a, [bc] + bit 6, a + jr nz, .asm_381e7 + ld a, [bc] + bit 4, a + jp nz, Function38385 + call Random + cp $32 + jp c, Function38385 + jp Function38383 + +.asm_381e7 + ld a, [EnemySubStatus5] + bit SUBSTATUS_TOXIC, a + jr z, .asm_381fd + ld a, [$c67c] + cp $4 + jr c, .asm_381fd + call Random + cp $80 + jp c, Function38385 +.asm_381fd + ld a, [EnemyMonStatus] + and 1 << FRZ | SLP + jp z, Function38383 + jp Function38385 +; 38208 + +Function38208: ; 38208 + call Function3822c + jp nc, Function3821a + ld a, [bc] + bit 6, a + jp z, Function38383 + call Function381ca + jp c, Function38383 + +; known jump sources: 3820b (e:420b) +Function3821a: ; 3821a (e:421a) + call Function383b5 + jp Function38385 +; 38220 + +Function38220: ; 38220 + call Function3822c + jp c, Function38383 + call Function383ae + jp Function38385 + +; known jump sources: 38208 (e:4208), 38220 (e:4220), 38284 (e:4284) +Function3822c: ; 3822c (e:422c) + ld a, [bc] + bit 6, a + jr nz, Function38267 + callab AICheckEnemyHalfHP + jp c, Function38383 + ld a, [bc] + bit 5, a + jp nz, Function38254 + callab AICheckEnemyQuarterHP + jp nc, Function38281 + call Random + cp $80 + jp c, Function38281 + jp Function38383 + +Function38254: ; 38254 (e:4254) + callab AICheckEnemyQuarterHP + jp c, Function38383 + call Random + cp $32 + jp c, Function38383 + jr Function38281 + +Function38267: ; 38267 (e:4267) + callab AICheckEnemyHalfHP + jp c, Function38383 + callab AICheckEnemyQuarterHP + jp nc, Function38281 + call Random + cp $32 + jp nc, Function38383 + +Function38281: ; 38281 (e:4281) + jp Function38385 +; 38284 + +Function38284: ; 38284 + call Function3822c + jp c, Function38383 + ld b, 200 + call Function383f4 + jp Function38385 +; 38292 (e:4292) + +Function38292: ; 38292 + call Function3822c + jp c, Function38383 + +Function38298: ; 38298 + ld b, 50 + call Function383ee + jp Function38385 +; 382a0 + +Function382a0: ; 382a0 + call Function3822c + jp c, Function38383 + ld b, 20 + call Function383e8 + jp Function38385 +; 382ae + +Function382ae: ; 382ae + callab AICheckEnemyMaxHP + jr c, .asm_382e4 + push bc + ld de, EnemyMonMaxHP + 1 + ld hl, EnemyMonHP + 1 + ld a, [de] + sub [hl] + jr z, .asm_382e7 + dec hl + dec de + ld c, a + sbc [hl] + and a + jr nz, .asm_382e7 + ld a, c + cp b + jp c, .asm_382d5 + callab AICheckEnemyQuarterHP + jr c, .asm_382e7 + +.asm_382d5 + pop bc + ld a, [bc] + bit 5, a + jp z, Function38385 + call Random + cp $80 + jp c, Function38385 + +.asm_382e4 + jp Function38383 + +.asm_382e7 + pop bc + ld a, [bc] + bit 5, a + jp z, Function38383 + call Random + cp $64 + jp c, Function38385 + jp Function38383 +; 382f9 + +Function382f9: ; 382f9 + call Function3834d + jp c, Function38383 + call Function384f7 + jp Function38385 +; 38305 + +Function38305: ; 38305 + call Function3834d + jp c, Function38383 + call Function38504 + jp Function38385 +; 38311 + +Function38311: ; 38311 + call Function3834d + jp c, Function38383 + call Function38511 + jp Function38385 +; 3831d (e:431d) + +Function3831d: ; 3831d + call Function3834d + jp c, Function38383 + call Function38541 + jp Function38385 +; 38329 + +Function38329: ; 38329 + call Function3834d + jp c, Function38383 + call Function38547 + jp Function38385 +; 38335 + +Function38335: ; 38335 + call Function3834d + jp c, Function38383 + call Function3854d + jp Function38385 +; 38341 + +Function38341: ; 38341 + call Function3834d + jp c, Function38383 + call Function38553 + jp Function38385 +; 3834d + +; known jump sources: 38311 (e:4311) +Function3834d: ; 3834d (e:434d) + ld a, [EnemyTurnsTaken] ; $c6dc + and a + jr nz, .asm_38372 + ld a, [bc] + bit 4, a + jp nz, Function38385 + call Random + cp $80 + jp c, Function38383 + ld a, [bc] + bit 6, a + jp nz, Function38385 + call Random + cp $80 + jp c, Function38383 + jp Function38385 +.asm_38372 + ld a, [bc] + bit 4, a + jp z, Function38383 + call Random + cp $32 + jp nc, Function38383 + jp Function38385 + +Function38383: ; 38383 (e:4383) + scf + ret + +Function38385: ; 38385 (e:4385) + and a + ret + + +Function38387: ; 38387 + call UpdateEnemyMonInParty + callba UpdateEnemyHUD + ld a, $1 + ld [hBGMapMode], a + ld hl, $c6e6 + dec [hl] + scf + ret +; 3839a + +Function3839a: ; 3839a + push de + ld de, SFX_FULL_HEAL + call PlaySFX + pop de + ret +; 383a3 + + +; known jump sources: 381c4 (e:41c4) +Function383a3: ; 383a3 (e:43a3) + call Function3839a + call Function384e0 + ld a, FULL_HEAL + jp Function38568 + +; known jump sources: 38226 (e:4226) +Function383ae: ; 383ae (e:43ae) + ld a, $f + ld [$d1f1], a + jr asm_383c6 + +; known jump sources: 3821a (e:421a) +Function383b5: ; 383b5 (e:43b5) + call Function384e0 + ld a, $e + ld [$d1f1], a + ld hl, EnemySubStatus3 ; $c66f + res SUBSTATUS_CONFUSED, [hl] + xor a + ld [EnemyConfuseCount], a ; $c67b +asm_383c6: ; 383c6 (e:43c6) + ld de, $d1ec + ld hl, EnemyMonHP + 1 ; $d217 + ld a, [hld] + ld [de], a + inc de + ld a, [hl] + ld [de], a + inc de + ld hl, EnemyMonMaxHP + 1 ; $d219 + ld a, [hld] + ld [de], a + inc de + ld [Buffer1], a ; $d1ea (aliases: MagikarpLength) + ld [EnemyMonHP + 1], a ; $d217 + ld a, [hl] + ld [de], a + ld [Buffer2], a ; $d1eb (aliases: MovementType) + ld [EnemyMonHP], a ; $d216 (aliases: EnemyMonHP) + jr asm_38436 +; 383e8 (e:43e8) + +Function383e8: ; 383e8 + ld a, POTION + ld b, 20 + jr Function383f8 + +Function383ee: ; 383ee + ld a, SUPER_POTION + ld b, 50 + jr Function383f8 + +; known jump sources: 3828c (e:428c) +Function383f4: ; 383f4 (e:43f4) + ld a, HYPER_POTION + ld b, 200 + +Function383f8: ; 383f8 + ld [$d1f1], a + ld hl, EnemyMonHP + 1 ; $d217 + ld a, [hl] + ld [$d1ec], a + add b + ld [hld], a + ld [$d1ee], a + ld a, [hl] + ld [$d1ed], a + ld [$d1ef], a + jr nc, .asm_38415 + inc a + ld [hl], a + ld [$d1ef], a +.asm_38415 + inc hl + ld a, [hld] + ld b, a + ld de, EnemyMonMaxHP + 1 ; $d219 + ld a, [de] + dec de + ld [Buffer1], a ; $d1ea (aliases: MagikarpLength) + sub b + ld a, [hli] + ld b, a + ld a, [de] + ld [Buffer2], a ; $d1eb (aliases: MovementType) + sbc b + jr nc, asm_38436 + inc de + ld a, [de] + dec de + ld [hld], a + ld [$d1ee], a + ld a, [de] + ld [hl], a + ld [$d1ef], a +asm_38436: ; 38436 (e:4436) + call Function38571 + hlcoord 2, 2 + xor a + ld [$d10a], a + call Function3839a + predef Functionc6e0 + jp Function38387 + + +Function3844b: ; 3844b + ld a, [OTPartyCount] + ld c, a + ld hl, OTPartyMon1HP + ld d, 0 +.asm_38454 + ld a, [hli] + ld b, a + ld a, [hld] + or b + jr z, .asm_3845b + inc d + +.asm_3845b + push bc + ld bc, PartyMon2 - PartyMon1 + add hl, bc + pop bc + dec c + jr nz, .asm_38454 + ld a, d + cp $2 + jp nc, Function3846c + and a + ret +; 3846c + +Function3846c: ; 3846c + ld a, $1 + ld [$c711], a + ld [$c70f], a + ld hl, EnemySubStatus4 + res SUBSTATUS_RAGE, [hl] + xor a + ld [hBattleTurn], a + callab Function3dc5b + push af + ld a, [CurOTMon] + ld hl, OTPartyMon1Status + ld bc, PartyMon2 - PartyMon1 + call AddNTimes + ld d, h + ld e, l + ld hl, EnemyMonStatus + ld bc, $0004 + call CopyBytes + pop af + jr c, .asm_384a3 + ld hl, UnknownText_0x384d0 + call PrintText + +.asm_384a3 + ld a, $1 + ld [$d264], a + callab NewEnemyMonStatus + callab ResetEnemyStatLevels + ld hl, PlayerSubStatus1 + res SUBSTATUS_IN_LOVE, [hl] + callba Function3d4e1 + callba Function3d57a + xor a + ld [$d264], a + ld a, [InLinkBattle] + and a + ret nz + scf + ret +; 384d0 + +UnknownText_0x384d0: ; 384d0 + text_jump UnknownText_0x1bcf9c + db "@" +; 384d5 + +Function384d5: ; 384d5 + call Function3839a + call Function384e0 + ld a, X_SPEED + jp Function38568 +; 384e0 + +Function384e0: ; 384e0 + ld a, [CurOTMon] + ld hl, OTPartyMon1Status + ld bc, PartyMon2 - PartyMon1 + call AddNTimes + xor a + ld [hl], a + ld [EnemyMonStatus], a + ld hl, EnemySubStatus5 + res SUBSTATUS_TOXIC, [hl] + ret +; 384f7 + +Function384f7: ; 384f7 + call Function3839a + ld hl, EnemySubStatus4 + set SUBSTATUS_UNLEASH, [hl] + ld a, X_ACCURACY + jp Function38568 +; 38504 + +Function38504: ; 38504 + call Function3839a + ld hl, EnemySubStatus4 + set SUBSTATUS_MIST, [hl] + ld a, GUARD_SPEC + jp Function38568 +; 38511 + +Function38511: ; 38511 + call Function3839a + ld hl, EnemySubStatus4 + set SUBSTATUS_FOCUS_ENERGY, [hl] + ld a, DIRE_HIT + jp Function38568 +; 3851e + +Function3851e: ; 3851e + ld [hMultiplier], a + ld hl, EnemyMonMaxHP + ld a, [hli] + ld [hProduct], a + ld a, [hl] + ld [hMultiplicand], a + ld b, $2 + call Divide + ld a, [$ffb6] + ld c, a + ld a, [$ffb5] + 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 + +Function38541: ; 38541 + ld b, ATTACK + ld a, X_ATTACK + jr Function38557 +; 38547 + +Function38547: ; 38547 + ld b, DEFENSE + ld a, X_DEFEND + jr Function38557 +; 3854d + +Function3854d: ; 3854d + ld b, SPEED + ld a, X_SPEED + jr Function38557 +; 38553 + +Function38553: ; 38553 + ld b, SP_ATTACK + ld a, X_SPECIAL + +Function38557 + ld [$d1f1], a + push bc + call Function38571 + pop bc + callba Function361ef + jp Function38387 +; 38568 + + +Function38568: ; 38568 + ld [$d1f1], a + call Function38571 + jp Function38387 +; 38571 + +Function38571: ; 38571 + ld a, [$d1f1] + ld [$d265], a + call GetItemName + ld hl, StringBuffer1 + ld de, $d050 + ld bc, $000d + call CopyBytes + ld hl, UnknownText_0x3858c + jp PrintText +; 3858c + +UnknownText_0x3858c: ; 3858c + text_jump UnknownText_0x1bcfaf + db "@" +; 38591 diff --git a/battle/ai/scoring.asm b/battle/ai/scoring.asm index 19c652370..7ea1ec8fe 100644 --- a/battle/ai/scoring.asm +++ b/battle/ai/scoring.asm @@ -16,7 +16,7 @@ AIScoring_RedStatus: ; 38591 inc de call AIGetEnemyMove - ld a, [EnemyMoveEffect] + ld a, [wEnemyMoveStruct + MOVE_EFFECT] ld c, a push hl @@ -28,7 +28,7 @@ AIScoring_RedStatus: ; 38591 pop hl jr nz, .discourage - ld a, [EnemyMoveEffect] + ld a, [wEnemyMoveStruct + MOVE_EFFECT] push hl push de push bc @@ -82,7 +82,7 @@ AIScoring_RedStatMods: ; 385e0 inc de call AIGetEnemyMove - ld a, [EnemyMoveEffect] + ld a, [wEnemyMoveStruct + MOVE_EFFECT] cp EFFECT_ATTACK_UP jr c, .checkmove @@ -119,7 +119,7 @@ AIScoring_RedStatMods: ; 385e0 jr nz, .discourage .encourage - call Function_0x39527 + call Function39527 jr c, .checkmove dec [hl] @@ -173,7 +173,7 @@ AIScoring_RedSuperEffective: ; 38635 jr c, .noteffective ; effective - ld a, [EnemyMovePower] + ld a, [wEnemyMoveStruct + MOVE_POWER] and a jr z, .checkmove dec [hl] @@ -185,7 +185,7 @@ AIScoring_RedSuperEffective: ; 38635 push hl push de push bc - ld a, [EnemyMoveType] + ld a, [wEnemyMoveStruct + MOVE_TYPE] ld d, a ld hl, EnemyMonMoves ld b, EnemyMonMovesEnd - EnemyMonMoves + 1 @@ -199,10 +199,10 @@ AIScoring_RedSuperEffective: ; 38635 jr z, .asm_38693 call AIGetEnemyMove - ld a, [EnemyMoveType] + ld a, [wEnemyMoveStruct + MOVE_TYPE] cp d jr z, .checkmove2 - ld a, [EnemyMovePower] + ld a, [wEnemyMoveStruct + MOVE_POWER] and a jr nz, .asm_38692 jr .checkmove2 @@ -244,7 +244,7 @@ AIScoring_Offensive: ; 386a2 inc de call AIGetEnemyMove - ld a, [EnemyMovePower] + ld a, [wEnemyMoveStruct + MOVE_POWER] and a jr nz, .checkmove @@ -275,7 +275,7 @@ AIScoring_Smart: ; 386be push hl call AIGetEnemyMove - ld a, [EnemyMoveEffect] + ld a, [wEnemyMoveStruct + MOVE_EFFECT] ld hl, .table_386f2 ld de, 3 call IsInArray @@ -398,7 +398,7 @@ AIScoring_Sleep: ; 387e3 ret nc .asm_387f0 - call Function_0x39527 + call Function39527 ret c dec [hl] dec [hl] @@ -421,7 +421,7 @@ AIScoring_LeechHit: ; 387f7 call AICheckEnemyMaxHP ret c - call Function_0x39521 + call Function39521 ret c dec [hl] @@ -439,41 +439,34 @@ AIScoring_LeechHit: ; 387f7 AIScoring_LockOn: ; 3881d ld a, [PlayerSubStatus5] - bit 5, a + 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 @@ -484,24 +477,22 @@ AIScoring_LockOn: ; 3881d call AIGetEnemyMove - ld a, [EnemyMoveAccuracy] - cp $b4 + ld a, [wEnemyMoveStruct + MOVE_ACC] + cp 180 jr nc, .asm_3884f ld a, $1 ld [hBattleTurn], a + push hl push bc - callba Function347c8 - ld a, [$d265] cp $a pop bc pop hl jr c, .asm_3884f - .asm_38875 pop hl ret @@ -513,9 +504,9 @@ AIScoring_LockOn: ; 3881d .asm_3887a pop hl - call Function_0x39527 - + call Function39527 ret c + dec [hl] dec [hl] ret @@ -538,19 +529,17 @@ AIScoring_LockOn: ; 3881d inc de call AIGetEnemyMove - ld a, [EnemyMoveAccuracy] - cp $b4 + 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 @@ -602,19 +591,16 @@ AIScoring_EvasionUp: ; 388d4 jp nc, AIDiscourageMove call AICheckEnemyMaxHP - jr nc, .asm_388f2 ld a, [PlayerSubStatus5] - bit 0, a + bit SUBSTATUS_TOXIC, a jr nz, .asm_388ef call Random - cp $b2 jr nc, .asm_38911 - .asm_388ef dec [hl] dec [hl] @@ -622,42 +608,34 @@ AIScoring_EvasionUp: ; 388d4 .asm_388f2 call AICheckEnemyQuarterHP - jr nc, .asm_3890f call Random - cp $a jr c, .asm_388ef call AICheckEnemyHalfHP - jr nc, .asm_3890a - call Function_0x39521 - + call Function39521 jr c, .asm_388ef - jr .asm_38911 - .asm_3890a - call Function_0x39527 - + call Function39527 jr c, .asm_38911 - .asm_3890f inc [hl] inc [hl] .asm_38911 ld a, [PlayerSubStatus5] - bit 0, a + bit SUBSTATUS_TOXIC, a jr nz, .asm_38938 ld a, [PlayerSubStatus4] - bit 7, a + bit SUBSTATUS_LEECH_SEED, a jr nz, .asm_38941 ld a, [EnemyEvaLevel] @@ -671,7 +649,7 @@ AIScoring_EvasionUp: ; 388d4 jr nz, .asm_388ef ld a, [PlayerSubStatus1] - bit 6, a + bit SUBSTATUS_ROLLOUT, a jr nz, .asm_388ef @@ -688,9 +666,9 @@ AIScoring_EvasionUp: ; 388d4 ret .asm_38941 - call Function_0x39527 - + call Function39527 ret c + dec [hl] ret ; 38947 @@ -706,7 +684,7 @@ AIScoring_AlwaysHit: ; 38947 ret c .asm_38954 - call Function_0x39521 + call Function39521 ret c dec [hl] @@ -721,30 +699,29 @@ AIScoring_MirrorMove: ; 3895b jr nz, .asm_38968 call AICompareSpeed - ret nc - jp AIDiscourageMove + jp AIDiscourageMove .asm_38968 push hl ld hl, Table_0x39301 ld de, 1 call IsInArray - pop hl ret nc - call Function_0x39527 + call Function39527 ret c + dec [hl] call AICompareSpeed - ret nc - call Random + call Random cp $19 ret c + dec [hl] ret ; 38985 @@ -752,23 +729,19 @@ AIScoring_MirrorMove: ; 3895b AIScoring_AccuracyDown: ; 38985 call AICheckPlayerMaxHP - jr nc, .asm_389a0 call AICheckEnemyHalfHP - jr nc, .asm_389a0 ld a, [PlayerSubStatus5] - bit 0, a + bit SUBSTATUS_TOXIC, a jr nz, .asm_3899d call Random - cp $b2 jr nc, .asm_389bf - .asm_3899d dec [hl] dec [hl] @@ -776,42 +749,34 @@ AIScoring_AccuracyDown: ; 38985 .asm_389a0 call AICheckPlayerQuarterHP - jr nc, .asm_389bd call Random - cp $a jr c, .asm_3899d call AICheckPlayerHalfHP - jr nc, .asm_389b8 - call Function_0x39521 - + call Function39521 jr c, .asm_3899d - jr .asm_389bf - .asm_389b8 - call Function_0x39527 - + call Function39527 jr c, .asm_389bf - .asm_389bd inc [hl] inc [hl] .asm_389bf ld a, [PlayerSubStatus5] - bit 0, a + bit SUBSTATUS_TOXIC, a jr nz, .asm_389e6 ld a, [PlayerSubStatus4] - bit 7, a + bit SUBSTATUS_LEECH_SEED, a jr nz, .asm_389ef ld a, [EnemyEvaLevel] @@ -825,10 +790,9 @@ AIScoring_AccuracyDown: ; 38985 jr nz, .asm_3899d ld a, [PlayerSubStatus1] - bit 6, a + bit SUBSTATUS_ROLLOUT, a jr nz, .asm_3899d - .asm_389e4 inc [hl] ret @@ -842,9 +806,9 @@ AIScoring_AccuracyDown: ; 38985 ret .asm_389ef - call Function_0x39527 - + call Function39527 ret c + dec [hl] ret ; 389f5 @@ -862,7 +826,6 @@ AIScoring_Haze: ; 389f5 jr c, .asm_38a12 jr .asm_389fb - .asm_38a05 ld hl, PlayerAtkLevel ld c, $8 @@ -976,7 +939,7 @@ AIScoring_Bind: ; 38a71 jr nz, .asm_38a91 ld a, [PlayerSubStatus1] - and 1<<SUBSTATUS_IN_LOVE | 1<<SUBSTATUS_ENCORED | 1<<SUBSTATUS_IDENTIFIED | 1<<SUBSTATUS_NIGHTMARE + and 1<<SUBSTATUS_IN_LOVE | 1<<SUBSTATUS_ROLLOUT | 1<<SUBSTATUS_IDENTIFIED | 1<<SUBSTATUS_NIGHTMARE jr nz, .asm_38a91 ld a, [PlayerTurnsTaken] @@ -984,7 +947,7 @@ AIScoring_Bind: ; 38a71 jr z, .asm_38a91 .asm_38a8b - call Function_0x39527 + call Function39527 ret c inc [hl] ret @@ -992,7 +955,7 @@ AIScoring_Bind: ; 38a71 .asm_38a91 call AICheckEnemyQuarterHP ret nc - call Function_0x39527 + call Function39527 ret c dec [hl] dec [hl] @@ -1022,7 +985,7 @@ AIScoring_Unused2B: ; 38a9c call AIGetEnemyMove - ld a, [EnemyMoveEffect] + ld a, [wEnemyMoveStruct + MOVE_EFFECT] cp EFFECT_PROTECT jr z, .asm_38ad5 dec c @@ -1081,14 +1044,14 @@ AIScoring_SpDefenseUp2: ; 38aed ret nc ld a, [BattleMonType1] - cp FIRE + cp SPECIAL jr nc, .asm_38b09 ld a, [BattleMonType2] - cp FIRE + cp SPECIAL ret c .asm_38b09 - call Function_0x39521 + call Function39521 ret c dec [hl] dec [hl] @@ -1128,14 +1091,14 @@ AIScoring_Paralyze: ; 38b26 ret c call AICheckEnemyQuarterHP ret nc - call Function_0x39521 + call Function39521 ret c dec [hl] dec [hl] ret .asm_38b3a - call Function_0x39527 + call Function39527 ret c inc [hl] ret @@ -1143,7 +1106,7 @@ AIScoring_Paralyze: ; 38b26 AIScoring_SpeedDownHit: ; 38b40 - ld a, [EnemyMoveAnimation] + ld a, [wEnemyMoveStruct + MOVE_ANIM] cp ICY_WIND ret nz call AICheckEnemyQuarterHP @@ -1174,7 +1137,7 @@ AIScoring_HyperBeam: ; 38b63 jr c, .asm_38b72 call AICheckEnemyQuarterHP ret c - call Function_0x39527 + call Function39527 ret c dec [hl] ret @@ -1184,7 +1147,7 @@ AIScoring_HyperBeam: ; 38b63 cp 40 ret c inc [hl] - call Function_0x39527 + call Function39527 ret c inc [hl] ret @@ -1193,10 +1156,10 @@ AIScoring_HyperBeam: ; 38b63 AIScoring_Rage: ; 38b7f ld a, [EnemySubStatus4] - bit 6, a + bit SUBSTATUS_RAGE, a jr z, .asm_38b9b - call Function_0x39527 + call Function39527 jr c, .asm_38b8c dec [hl] @@ -1216,7 +1179,7 @@ AIScoring_Rage: ; 38b7f call AICheckEnemyHalfHP jr nc, .asm_38ba6 - call Function_0x39521 + call Function39521 ret nc dec [hl] ret @@ -1249,7 +1212,7 @@ AIScoring_Mimic: ; 38ba8 jr c, .asm_38bef jr z, .asm_38bd4 - call Function_0x39527 + call Function39527 jr c, .asm_38bd4 dec [hl] @@ -1263,7 +1226,7 @@ AIScoring_Mimic: ; 38ba8 pop hl ret nc - call Function_0x39527 + call Function39527 ret c dec [hl] ret @@ -1291,12 +1254,12 @@ AIScoring_Counter: ; 38bf1 call AIGetEnemyMove - ld a, [EnemyMovePower] + ld a, [wEnemyMoveStruct + MOVE_POWER] and a jr z, .asm_38c0e - ld a, [EnemyMoveType] - cp $14 + ld a, [wEnemyMoveStruct + MOVE_TYPE] + cp SPECIAL jr nc, .asm_38c0e inc b @@ -1319,12 +1282,12 @@ AIScoring_Counter: ; 38bf1 call AIGetEnemyMove - ld a, [EnemyMovePower] + ld a, [wEnemyMoveStruct + MOVE_POWER] and a jr z, .asm_38c38 - ld a, [EnemyMoveType] - cp $14 + ld a, [wEnemyMoveStruct + MOVE_TYPE] + cp SPECIAL jr nc, .asm_38c38 @@ -1354,15 +1317,14 @@ AIScoring_Encore: ; 38c3b call AIGetEnemyMove - ld a, [EnemyMovePower] + ld a, [wEnemyMoveStruct + MOVE_POWER] and a jr z, .asm_38c68 push hl - ld a, [EnemyMoveType] + ld a, [wEnemyMoveStruct + MOVE_TYPE] ld hl, EnemyMonType1 - ld a, $41 - call Predef + predef Function347d3 pop hl ld a, [$d265] @@ -1433,7 +1395,7 @@ AIScoring_Encore: ; 38c3b AIScoring_PainSplit: ; 38ca4 push hl - ld hl, EnemyMonHPHi + ld hl, EnemyMonHP ld b, [hl] inc hl ld c, [hl] @@ -1490,7 +1452,7 @@ AIScoring_Spite: ; 38cd5 call AICompareSpeed jp c, AIDiscourageMove - call Function_0x39527 + call Function39527 ret c inc [hl] ret @@ -1596,7 +1558,7 @@ AIScoring_HealBell: ; 38d1f .asm_38d48 and $27 ret z - call Function_0x39527 + call Function39527 ret c dec [hl] @@ -1658,13 +1620,13 @@ AIScoring_Conversion2: ; 38d98 push hl dec a - ld hl, Moves + PlayerMoveType - PlayerMoveStruct - ld bc, Move2 - Move1 + ld hl, Moves + MOVE_TYPE + ld bc, MOVE_LENGTH call AddNTimes ld a, BANK(Moves) call GetFarByte - ld [PlayerMoveType], a + ld [wPlayerMoveStruct + MOVE_TYPE], a xor a ld [hBattleTurn], a @@ -1677,7 +1639,7 @@ AIScoring_Conversion2: ; 38d98 jr c, .asm_38dc9 ret z - call Function_0x39527 + call Function39527 ret c dec [hl] @@ -1713,7 +1675,7 @@ AIScoring_Disable: ; 38dd1 ret .asm_38dee - ld a, [EnemyMovePower] + ld a, [wEnemyMoveStruct + MOVE_POWER] and a ret nz @@ -1740,7 +1702,7 @@ AIScoring_MeanLook: ; 38dfb jr nz, .asm_38e26 ld a, [PlayerSubStatus1] - and 1<<SUBSTATUS_IN_LOVE | 1<<SUBSTATUS_ENCORED | 1<<SUBSTATUS_IDENTIFIED | 1<<SUBSTATUS_NIGHTMARE + and 1<<SUBSTATUS_IN_LOVE | 1<<SUBSTATUS_ROLLOUT | 1<<SUBSTATUS_IDENTIFIED | 1<<SUBSTATUS_NIGHTMARE jr nz, .asm_38e26 push hl @@ -1755,7 +1717,7 @@ AIScoring_MeanLook: ; 38dfb ret .asm_38e26 - call Function_0x39521 + call Function39521 ret c dec [hl] dec [hl] @@ -1792,7 +1754,7 @@ AICheckLastPlayerMon: ; 38e2e AIScoring_Nightmare: ; 38e4a - call Function_0x39527 + call Function39527 ret c dec [hl] ret @@ -1832,12 +1794,12 @@ AIScoring_Curse: ; 38e5c ld a, [BattleMonType1] cp GHOST jr z, .asm_38e92 - cp FIRE + cp SPECIAL ret nc ld a, [BattleMonType2] - cp FIRE + cp SPECIAL ret nc - call Function_0x39521 + call Function39521 ret c dec [hl] dec [hl] @@ -1892,7 +1854,7 @@ AIScoring_Curse: ; 38e5c ret nz .asm_38ecb - call Function_0x39527 + call Function39527 ret c dec [hl] @@ -1928,7 +1890,7 @@ AIScoring_Protect: ; 38ed2 bit SUBSTATUS_CURSE, a jr nz, .asm_38f0d - bit SUBSTATUS_ENCORED, a + bit SUBSTATUS_ROLLOUT, a jr z, .asm_38f14 ld a, [PlayerRolloutCount] @@ -1936,7 +1898,7 @@ AIScoring_Protect: ; 38ed2 jr c, .asm_38f14 .asm_38f0d - call Function_0x39521 + call Function39521 ret c dec [hl] ret @@ -1992,7 +1954,7 @@ AIScoring_PerishSong: ; 38f4a jr c, .asm_38f75 ld a, [PlayerSubStatus5] - bit 7, a + bit SUBSTATUS_CANT_RUN, a jr nz, .asm_38f6f push hl @@ -2002,16 +1964,16 @@ AIScoring_PerishSong: ; 38f4a pop hl ret c - call Function_0x39527 + call Function39527 ret c inc [hl] ret .asm_38f6f - call Function_0x39527 - + call Function39527 ret c + dec [hl] ret @@ -2043,7 +2005,7 @@ AIScoring_Sandstorm: ; 38f7a call AICheckPlayerHalfHP jr nc, .asm_38fa6 - call Function_0x39527 + call Function39527 ret c dec [hl] @@ -2079,7 +2041,7 @@ AIScoring_Endure: ; 38fac call AIHasMove jr nc, .asm_38fcb - call Function_0x39521 + call Function39521 ret c dec [hl] @@ -2091,7 +2053,7 @@ AIScoring_Endure: ; 38fac ld a, [EnemySubStatus5] bit SUBSTATUS_LOCK_ON, a ret z - call Function_0x39527 + call Function39527 ret c dec [hl] @@ -2161,7 +2123,7 @@ AIScoring_Rollout: ; 38fef ret .asm_39020 - call Function_0x39521 + call Function39521 ret c inc [hl] ret @@ -2172,14 +2134,14 @@ AIScoring_Swagger: AIScoring_Attract: ; 39026 ld a, [PlayerTurnsTaken] and a - jr z, .asm_39032 + jr z, .first_turn - call Function_0x39521 + call Function39521 ret c inc [hl] ret -.asm_39032 +.first_turn call Random cp 200 ret nc @@ -2191,7 +2153,7 @@ AIScoring_Attract: ; 39026 AIScoring_Safeguard: ; 3903a call AICheckPlayerHalfHP ret c - call Function_0x39521 + call Function39521 ret c inc [hl] ret @@ -2206,7 +2168,7 @@ AIScoring_Earthquake: ; 39044 ld a, [PlayerSubStatus3] bit SUBSTATUS_UNDERGROUND, a - jr z, .asm_39058 + jr z, .could_dig call AICompareSpeed ret nc @@ -2214,10 +2176,12 @@ AIScoring_Earthquake: ; 39044 dec [hl] ret -.asm_39058 +.could_dig + ; Try to predict if the player + ; will use Dig this turn. call AICompareSpeed ret c - call Function_0x39527 + call Function39527 ret c dec [hl] ret @@ -2239,13 +2203,13 @@ AIScoring_BatonPass: ; 39062 AIScoring_Pursuit: ; 39072 call AICheckPlayerQuarterHP jr nc, .asm_3907d - call Function_0x39521 + call Function39521 ret c inc [hl] ret .asm_3907d - call Function_0x39527 + call Function39527 ret c dec [hl] dec [hl] @@ -2267,7 +2231,7 @@ AIScoring_RapidSpin: ; 39084 ret z .asm_39097 - call Function_0x39521 + call Function39521 ret c dec [hl] @@ -2289,7 +2253,7 @@ AIScoring_HiddenPower: ; 3909e jr c, .asm_390c9 ld a, d - cp $32 + cp 50 jr c, .asm_390c9 ld a, [$d265] @@ -2297,7 +2261,7 @@ AIScoring_HiddenPower: ; 3909e jr nc, .asm_390c7 ld a, d - cp $46 + cp 70 ret c .asm_390c7 @@ -2372,7 +2336,7 @@ AIScoring_WeatherMove: ; 3910d call AICheckPlayerHalfHP jr nc, AIBadWeatherType - call Function_0x39527 + call Function39527 ret c dec [hl] @@ -2476,7 +2440,7 @@ AIScoring_PsychUp: ; 39152 ld a, [EnemyEvaLevel] cp $8 ret nc - call Function_0x39521 + call Function39521 ret c dec [hl] @@ -2502,12 +2466,12 @@ AIScoring_MirrorCoat: ; 3918b call AIGetEnemyMove - ld a, [EnemyMovePower] + ld a, [wEnemyMoveStruct + MOVE_POWER] and a jr z, .asm_391a8 - ld a, [EnemyMoveType] - cp FIRE + ld a, [wEnemyMoveStruct + MOVE_TYPE] + cp SPECIAL jr c, .asm_391a8 inc b @@ -2530,12 +2494,12 @@ AIScoring_MirrorCoat: ; 3918b call AIGetEnemyMove - ld a, [EnemyMovePower] + ld a, [wEnemyMoveStruct + MOVE_POWER] and a jr z, .asm_391d2 - ld a, [EnemyMoveType] - cp FIRE + ld a, [wEnemyMoveStruct + MOVE_TYPE] + cp SPECIAL jr c, .asm_391d2 @@ -2574,7 +2538,7 @@ AIScoring_Gust: ; 391d5 .asm_391e9 call AICompareSpeed ret c - call Function_0x39527 + call Function39527 ret c dec [hl] ret @@ -2600,7 +2564,7 @@ AIScoring_Stomp: ; 39200 and a ret z - call Function_0x39521 + call Function39521 ret c dec [hl] @@ -2625,7 +2589,7 @@ AIScoring_Solarbeam: ; 3920b ret .asm_3921e - call Function_0x39521 + call Function39521 ret c dec [hl] @@ -2650,13 +2614,13 @@ AIScoring_Thunder: ; 39225 AICompareSpeed: ; 39233 push bc - ld a, [EnemyMonSpd + 1] + ld a, [EnemyMonSpeed + 1] ld b, a - ld a, [BattleMonSpd + 1] + ld a, [BattleMonSpeed + 1] cp b - ld a, [EnemyMonSpd] + ld a, [EnemyMonSpeed] ld b, a - ld a, [BattleMonSpd] + ld a, [BattleMonSpeed] sbc b pop bc ret @@ -2677,8 +2641,8 @@ AICheckEnemyMaxHP: ; 39251 push hl push de push bc - ld de, EnemyMonHPHi - ld hl, EnemyMonMaxHPHi + ld de, EnemyMonHP + ld hl, EnemyMonMaxHP ; fallthrough ; 3925a @@ -2733,7 +2697,7 @@ AICheckEnemyHalfHP: ; 39281 push hl push de push bc - ld hl, EnemyMonHPHi + ld hl, EnemyMonHP ld b, [hl] inc hl ld c, [hl] @@ -2756,7 +2720,7 @@ AICheckEnemyQuarterHP: ; 39298 push hl push de push bc - ld hl, EnemyMonHPHi + ld hl, EnemyMonHP ld b, [hl] inc hl ld c, [hl] @@ -2811,7 +2775,7 @@ AIHasMove: ; 392ca call AIGetEnemyMove - ld a, [EnemyMoveEffect] + ld a, [wEnemyMoveStruct + MOVE_EFFECT] cp b jr z, .asm_392e3 @@ -2898,7 +2862,7 @@ AIScoring_Opportunist: ; 39315 call AICheckEnemyQuarterHP jr nc, .asm_39322 - call Function_0x39527 + call Function39527 ret c .asm_39322 @@ -2992,7 +2956,7 @@ AIScoring_Aggressive: ; 39369 push de push bc call AIGetEnemyMove - ld a, [EnemyMovePower] + ld a, [wEnemyMoveStruct + MOVE_POWER] and a jr z, .nodamage call AIDamageCalc @@ -3043,14 +3007,14 @@ AIScoring_Aggressive: ; 39369 call AIGetEnemyMove - ld a, [EnemyMovePower] + ld a, [wEnemyMoveStruct + MOVE_POWER] cp 2 jr c, .checkmove2 push hl push de push bc - ld a, [EnemyMoveEffect] + ld a, [wEnemyMoveStruct + MOVE_EFFECT] ld hl, .aggressivemoves ld de, 1 call IsInArray @@ -3077,7 +3041,7 @@ AIScoring_Aggressive: ; 39369 AIDamageCalc: ; 393e7 ld a, 1 ld [hBattleTurn], a - ld a, [EnemyMoveEffect] + ld a, [wEnemyMoveStruct + MOVE_EFFECT] ld de, 1 ld hl, .ConstantDamageEffects call IsInArray @@ -3175,7 +3139,7 @@ AIScoring_StatusImmunity: ; 39453 inc de call AIGetEnemyMove - ld a, [EnemyMoveEffect] + ld a, [wEnemyMoveStruct + MOVE_EFFECT] cp EFFECT_TOXIC jr z, .poisonimmunity cp EFFECT_POISON @@ -3185,7 +3149,7 @@ AIScoring_StatusImmunity: ; 39453 cp EFFECT_PARALYZE jr z, .typeimmunity - ld a, [EnemyMovePower] + ld a, [wEnemyMoveStruct + MOVE_POWER] and a jr z, .checkmove @@ -3242,12 +3206,12 @@ AIScoring_Risky: ; 394a9 push hl call AIGetEnemyMove - ld a, [EnemyMovePower] + ld a, [wEnemyMoveStruct + MOVE_POWER] and a jr z, .nextmove ; Don't use risky moves at max hp. - ld a, [EnemyMoveEffect] + ld a, [wEnemyMoveStruct + MOVE_EFFECT] ld de, 1 ld hl, .riskymoves call IsInArray @@ -3314,10 +3278,10 @@ AIGetEnemyMove: ; 39508 push bc dec a ld hl, Moves - ld bc, Move2 - Move1 + ld bc, MOVE_LENGTH call AddNTimes - ld de, EnemyMoveStruct + ld de, wEnemyMoveStruct ld a, BANK(Moves) call FarCopyBytes @@ -3328,14 +3292,14 @@ AIGetEnemyMove: ; 39508 ; 39521 -Function_0x39521: ; 39521 +Function39521: ; 39521 call Random cp 50 ; 1/5 ret ; 39527 -Function_0x39527: ; 39527 +Function39527: ; 39527 call Random cp $80 ; 1/2 ret |