2013-05-06 18:33:19 +00:00
|
|
|
AIScoring_RedStatus: ; 38591
|
2014-10-21 18:44:42 +00:00
|
|
|
; Handle the AI of status-only moves and moves with special effects.
|
2013-05-06 18:33:19 +00:00
|
|
|
|
2013-05-05 23:56:17 +00:00
|
|
|
ld hl, Buffer1 - 1
|
|
|
|
ld de, EnemyMonMoves
|
|
|
|
ld b, EnemyMonMovesEnd - EnemyMonMoves + 1
|
2013-05-06 18:33:19 +00:00
|
|
|
.checkmove
|
2013-05-05 23:56:17 +00:00
|
|
|
dec b
|
|
|
|
ret z
|
|
|
|
|
|
|
|
inc hl
|
|
|
|
ld a, [de]
|
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
|
|
|
inc de
|
2013-05-06 18:33:19 +00:00
|
|
|
call AIGetEnemyMove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2014-06-13 01:32:42 +00:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_EFFECT]
|
2013-05-05 23:56:17 +00:00
|
|
|
ld c, a
|
|
|
|
|
2014-10-21 17:21:13 +00:00
|
|
|
; Dismiss moves with special effects if they are
|
|
|
|
; useless or not a good choice right now.
|
|
|
|
; For example, healing moves, weather moves, Dream Eater...
|
2013-05-05 23:56:17 +00:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2014-10-21 17:21:13 +00:00
|
|
|
callba AISpecialEffects
|
2013-05-05 23:56:17 +00:00
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
2013-05-06 18:33:19 +00:00
|
|
|
jr nz, .discourage
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2014-10-21 17:21:13 +00:00
|
|
|
; Dismiss status-only moves if the player can't be statused.
|
2014-06-13 01:32:42 +00:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_EFFECT]
|
2013-05-05 23:56:17 +00:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2013-05-06 18:33:19 +00:00
|
|
|
ld hl, .statusonlyeffects
|
2013-05-05 23:56:17 +00:00
|
|
|
ld de, 1
|
|
|
|
call IsInArray
|
|
|
|
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
2013-05-06 18:33:19 +00:00
|
|
|
jr nc, .checkmove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
ld a, [BattleMonStatus]
|
|
|
|
and a
|
2013-05-06 18:33:19 +00:00
|
|
|
jr nz, .discourage
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2014-10-21 18:44:42 +00:00
|
|
|
; Dismiss Safeguard if it's already active.
|
2013-05-05 23:56:17 +00:00
|
|
|
ld a, [PlayerScreens]
|
2013-05-06 18:33:19 +00:00
|
|
|
bit SCREENS_SAFEGUARD, a
|
|
|
|
jr z, .checkmove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
.discourage
|
|
|
|
call AIDiscourageMove
|
|
|
|
jr .checkmove
|
2013-05-05 23:56:17 +00:00
|
|
|
; 385db
|
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
.statusonlyeffects
|
2013-05-05 23:56:17 +00:00
|
|
|
db EFFECT_SLEEP
|
|
|
|
db EFFECT_TOXIC
|
|
|
|
db EFFECT_POISON
|
|
|
|
db EFFECT_PARALYZE
|
|
|
|
db $ff
|
|
|
|
; 385e0
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
AIScoring_RedStatMods: ; 385e0
|
2014-10-21 18:44:42 +00:00
|
|
|
; 50% chance to greatly encourage stat-up moves during enemy's first turn.
|
|
|
|
; 50% chance to greatly encourage stat-down moves during player's first turn.
|
|
|
|
; Almost 90% chance to greatly discourage stat-modifying moves otherwise.
|
2013-05-06 18:33:19 +00:00
|
|
|
|
2013-05-05 23:56:17 +00:00
|
|
|
ld hl, Buffer1 - 1
|
|
|
|
ld de, EnemyMonMoves
|
|
|
|
ld b, EnemyMonMovesEnd - EnemyMonMoves + 1
|
2013-05-06 18:33:19 +00:00
|
|
|
.checkmove
|
2013-05-05 23:56:17 +00:00
|
|
|
dec b
|
|
|
|
ret z
|
|
|
|
|
|
|
|
inc hl
|
|
|
|
ld a, [de]
|
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
|
|
|
inc de
|
2013-05-06 18:33:19 +00:00
|
|
|
call AIGetEnemyMove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2014-06-13 01:32:42 +00:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_EFFECT]
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
cp EFFECT_ATTACK_UP
|
2013-05-06 18:33:19 +00:00
|
|
|
jr c, .checkmove
|
2013-05-05 23:56:17 +00:00
|
|
|
cp EFFECT_EVASION_UP + 1
|
|
|
|
jr c, .statup
|
|
|
|
|
|
|
|
; cp EFFECT_ATTACK_DOWN - 1
|
2014-10-21 22:28:51 +00:00
|
|
|
jr z, .checkmove ; ignore EFFECT_ALWAYS_HIT
|
2013-05-05 23:56:17 +00:00
|
|
|
cp EFFECT_EVASION_DOWN + 1
|
|
|
|
jr c, .statdown
|
|
|
|
|
|
|
|
cp EFFECT_ATTACK_UP_2
|
2013-05-06 18:33:19 +00:00
|
|
|
jr c, .checkmove
|
2013-05-05 23:56:17 +00:00
|
|
|
cp EFFECT_EVASION_UP_2 + 1
|
|
|
|
jr c, .statup
|
|
|
|
|
|
|
|
; cp EFFECT_ATTACK_DOWN_2 - 1
|
2014-10-21 22:28:51 +00:00
|
|
|
jr z, .checkmove ; ignore EFFECT_TRANSFROM
|
2013-05-05 23:56:17 +00:00
|
|
|
cp EFFECT_EVASION_DOWN_2 + 1
|
|
|
|
jr c, .statdown
|
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
jr .checkmove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
.statup
|
|
|
|
ld a, [EnemyTurnsTaken]
|
|
|
|
and a
|
2013-05-06 18:33:19 +00:00
|
|
|
jr nz, .discourage
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
jr .encourage
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
.statdown
|
|
|
|
ld a, [PlayerTurnsTaken]
|
|
|
|
and a
|
2013-05-06 18:33:19 +00:00
|
|
|
jr nz, .discourage
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
.encourage
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39527
|
2013-05-06 18:33:19 +00:00
|
|
|
jr c, .checkmove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
2013-05-06 18:33:19 +00:00
|
|
|
jr .checkmove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
.discourage
|
2013-08-31 02:59:40 +00:00
|
|
|
call Random
|
2013-05-06 18:33:19 +00:00
|
|
|
cp 30
|
|
|
|
jr c, .checkmove
|
2013-05-05 23:56:17 +00:00
|
|
|
inc [hl]
|
|
|
|
inc [hl]
|
2013-05-06 18:33:19 +00:00
|
|
|
jr .checkmove
|
2013-05-05 23:56:17 +00:00
|
|
|
; 38635
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
AIScoring_RedSuperEffective: ; 38635
|
2014-10-21 18:44:42 +00:00
|
|
|
; 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.
|
2013-05-06 18:33:19 +00:00
|
|
|
|
2013-05-05 23:56:17 +00:00
|
|
|
ld hl, Buffer1 - 1
|
|
|
|
ld de, EnemyMonMoves
|
|
|
|
ld b, EnemyMonMovesEnd - EnemyMonMoves + 1
|
2013-05-06 18:33:19 +00:00
|
|
|
.checkmove
|
2013-05-05 23:56:17 +00:00
|
|
|
dec b
|
|
|
|
ret z
|
|
|
|
|
|
|
|
inc hl
|
|
|
|
ld a, [de]
|
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
|
|
|
inc de
|
2013-05-06 18:33:19 +00:00
|
|
|
call AIGetEnemyMove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
push hl
|
|
|
|
push bc
|
|
|
|
push de
|
|
|
|
ld a, 1
|
|
|
|
ld [hBattleTurn], a
|
2013-12-31 09:10:49 +00:00
|
|
|
callab Function347c8
|
2013-05-05 23:56:17 +00:00
|
|
|
pop de
|
|
|
|
pop bc
|
|
|
|
pop hl
|
2013-05-06 18:33:19 +00:00
|
|
|
|
2013-05-05 23:56:17 +00:00
|
|
|
ld a, [$d265]
|
|
|
|
and a
|
2013-05-06 18:33:19 +00:00
|
|
|
jr z, .immune
|
|
|
|
cp 10 ; 1.0
|
|
|
|
jr z, .checkmove
|
|
|
|
jr c, .noteffective
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
; effective
|
2014-06-13 01:32:42 +00:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_POWER]
|
2013-05-05 23:56:17 +00:00
|
|
|
and a
|
2013-05-06 18:33:19 +00:00
|
|
|
jr z, .checkmove
|
2013-05-05 23:56:17 +00:00
|
|
|
dec [hl]
|
2013-05-06 18:33:19 +00:00
|
|
|
jr .checkmove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
.noteffective
|
|
|
|
; Discourage this move if there are any moves
|
|
|
|
; that do damage of a different type.
|
2013-05-05 23:56:17 +00:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2014-06-13 01:32:42 +00:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_TYPE]
|
2013-05-05 23:56:17 +00:00
|
|
|
ld d, a
|
|
|
|
ld hl, EnemyMonMoves
|
|
|
|
ld b, EnemyMonMovesEnd - EnemyMonMoves + 1
|
|
|
|
ld c, 0
|
2013-05-06 18:33:19 +00:00
|
|
|
.checkmove2
|
2013-05-05 23:56:17 +00:00
|
|
|
dec b
|
|
|
|
jr z, .asm_38693
|
|
|
|
|
|
|
|
ld a, [hli]
|
|
|
|
and a
|
|
|
|
jr z, .asm_38693
|
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
call AIGetEnemyMove
|
2014-06-13 01:32:42 +00:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_TYPE]
|
2013-05-05 23:56:17 +00:00
|
|
|
cp d
|
2013-05-06 18:33:19 +00:00
|
|
|
jr z, .checkmove2
|
2014-06-13 01:32:42 +00:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_POWER]
|
2013-05-05 23:56:17 +00:00
|
|
|
and a
|
|
|
|
jr nz, .asm_38692
|
2013-05-06 18:33:19 +00:00
|
|
|
jr .checkmove2
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
.asm_38692
|
|
|
|
ld c, a
|
|
|
|
.asm_38693
|
|
|
|
ld a, c
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
and a
|
2013-05-06 18:33:19 +00:00
|
|
|
jr z, .checkmove
|
2013-05-05 23:56:17 +00:00
|
|
|
inc [hl]
|
2013-05-06 18:33:19 +00:00
|
|
|
jr .checkmove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
.immune
|
|
|
|
call AIDiscourageMove
|
|
|
|
jr .checkmove
|
2013-05-05 23:56:17 +00:00
|
|
|
; 386a2
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
AIScoring_Offensive: ; 386a2
|
2014-10-21 18:44:42 +00:00
|
|
|
; Greatly discourage non-damaging moves.
|
2013-05-06 18:33:19 +00:00
|
|
|
|
2013-05-05 23:56:17 +00:00
|
|
|
ld hl, Buffer1 - 1
|
|
|
|
ld de, EnemyMonMoves
|
|
|
|
ld b, EnemyMonMovesEnd - EnemyMonMoves + 1
|
2013-05-06 18:33:19 +00:00
|
|
|
.checkmove
|
2013-05-05 23:56:17 +00:00
|
|
|
dec b
|
|
|
|
ret z
|
|
|
|
|
|
|
|
inc hl
|
|
|
|
ld a, [de]
|
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
|
|
|
inc de
|
2013-05-06 18:33:19 +00:00
|
|
|
call AIGetEnemyMove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2014-06-13 01:32:42 +00:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_POWER]
|
2013-05-05 23:56:17 +00:00
|
|
|
and a
|
2013-05-06 18:33:19 +00:00
|
|
|
jr nz, .checkmove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
inc [hl]
|
|
|
|
inc [hl]
|
2013-05-06 18:33:19 +00:00
|
|
|
jr .checkmove
|
2013-05-05 23:56:17 +00:00
|
|
|
; 386be
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
AIScoring_Smart: ; 386be
|
|
|
|
; Context-specific scoring.
|
|
|
|
|
2013-05-05 23:56:17 +00:00
|
|
|
ld hl, Buffer1
|
|
|
|
ld de, EnemyMonMoves
|
|
|
|
ld b, EnemyMonMovesEnd - EnemyMonMoves + 1
|
2013-05-06 18:33:19 +00:00
|
|
|
.checkmove
|
2013-05-05 23:56:17 +00:00
|
|
|
dec b
|
|
|
|
ret z
|
|
|
|
|
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
|
|
|
push de
|
|
|
|
push bc
|
|
|
|
push hl
|
2013-05-06 18:33:19 +00:00
|
|
|
call AIGetEnemyMove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2014-06-13 01:32:42 +00:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_EFFECT]
|
2013-05-05 23:56:17 +00:00
|
|
|
ld hl, .table_386f2
|
|
|
|
ld de, 3
|
|
|
|
call IsInArray
|
|
|
|
|
|
|
|
inc hl
|
2013-05-06 18:33:19 +00:00
|
|
|
jr nc, .nextmove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
ld a, [hli]
|
|
|
|
ld e, a
|
|
|
|
ld d, [hl]
|
2013-05-06 18:33:19 +00:00
|
|
|
|
2013-05-05 23:56:17 +00:00
|
|
|
pop hl
|
|
|
|
push hl
|
2013-05-06 18:33:19 +00:00
|
|
|
|
|
|
|
ld bc, .nextmove
|
2013-05-05 23:56:17 +00:00
|
|
|
push bc
|
2013-05-06 18:33:19 +00:00
|
|
|
|
2013-05-05 23:56:17 +00:00
|
|
|
push de
|
|
|
|
ret
|
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
.nextmove
|
2013-05-05 23:56:17 +00:00
|
|
|
pop hl
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
inc hl
|
2013-05-06 18:33:19 +00:00
|
|
|
jr .checkmove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
.table_386f2
|
2013-05-05 23:56:17 +00:00
|
|
|
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
|
2013-12-31 04:12:06 +00:00
|
|
|
dbw EFFECT_SP_DEF_UP_2, AIScoring_SpDefenseUp2
|
2013-05-05 23:56:17 +00:00
|
|
|
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
|
2014-10-21 18:44:42 +00:00
|
|
|
; Greatly encourage sleep inducing moves if the enemy has either Dream Eater or Nightmare.
|
|
|
|
; 50% chance to greatly encourage sleep inducing moves otherwise.
|
2014-10-21 11:54:04 +00:00
|
|
|
|
2013-05-07 04:58:35 +00:00
|
|
|
ld b, EFFECT_DREAM_EATER
|
|
|
|
call AIHasMove
|
2013-05-05 23:56:17 +00:00
|
|
|
jr c, .asm_387f0
|
|
|
|
|
2013-05-07 04:58:35 +00:00
|
|
|
ld b, EFFECT_NIGHTMARE
|
|
|
|
call AIHasMove
|
2013-05-05 23:56:17 +00:00
|
|
|
ret nc
|
|
|
|
|
|
|
|
.asm_387f0
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39527
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
; 387f7
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_LeechHit: ; 387f7
|
|
|
|
push hl
|
2013-05-07 04:58:35 +00:00
|
|
|
ld a, 1
|
2013-05-05 23:56:17 +00:00
|
|
|
ld [hBattleTurn], a
|
2013-12-31 09:10:49 +00:00
|
|
|
callab Function347c8
|
2013-05-05 23:56:17 +00:00
|
|
|
pop hl
|
2013-05-07 04:58:35 +00:00
|
|
|
|
2014-10-21 18:44:42 +00:00
|
|
|
; 60% chance to discourage this move if not very effective.
|
2013-05-05 23:56:17 +00:00
|
|
|
ld a, [$d265]
|
2013-05-07 04:58:35 +00:00
|
|
|
cp 10 ; 1.0
|
2013-05-05 23:56:17 +00:00
|
|
|
jr c, .asm_38815
|
|
|
|
|
2014-10-21 18:44:42 +00:00
|
|
|
; Do nothing if effectiveness is neutral.
|
2013-05-05 23:56:17 +00:00
|
|
|
ret z
|
|
|
|
|
2014-10-21 18:44:42 +00:00
|
|
|
; Do nothing if enemy's HP is full.
|
2014-10-21 11:54:04 +00:00
|
|
|
call AICheckEnemyMaxHP
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
|
|
|
|
2014-10-21 22:28:51 +00:00
|
|
|
; 80% chance to encourage this move otherwise.
|
2014-10-21 11:54:04 +00:00
|
|
|
call Function39521
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38815
|
2013-08-31 02:59:40 +00:00
|
|
|
call Random
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
cp $64
|
|
|
|
ret c
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
; 3881d
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_LockOn: ; 3881d
|
|
|
|
ld a, [PlayerSubStatus5]
|
2014-06-17 19:52:32 +00:00
|
|
|
bit SUBSTATUS_LOCK_ON, a
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nz, .asm_38882
|
|
|
|
|
|
|
|
push hl
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckEnemyQuarterHP
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nc, .asm_38877
|
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckEnemyHalfHP
|
2013-05-05 23:56:17 +00:00
|
|
|
jr c, .asm_38834
|
|
|
|
|
2013-05-07 00:51:07 +00:00
|
|
|
call AICompareSpeed
|
2013-05-05 23:56:17 +00:00
|
|
|
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
|
|
|
|
|
2013-05-06 06:39:01 +00:00
|
|
|
ld hl, EnemyMonMoves
|
|
|
|
ld c, EnemyMonMovesEnd - EnemyMonMoves + 1
|
2013-05-05 23:56:17 +00:00
|
|
|
.asm_3884f
|
|
|
|
dec c
|
|
|
|
jr z, .asm_38877
|
|
|
|
|
|
|
|
ld a, [hli]
|
|
|
|
and a
|
|
|
|
jr z, .asm_38877
|
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
call AIGetEnemyMove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2014-06-13 01:32:42 +00:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_ACC]
|
|
|
|
cp 180
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nc, .asm_3884f
|
|
|
|
|
|
|
|
ld a, $1
|
|
|
|
ld [hBattleTurn], a
|
2014-06-17 19:52:32 +00:00
|
|
|
|
2013-05-05 23:56:17 +00:00
|
|
|
push hl
|
|
|
|
push bc
|
2014-05-05 07:30:51 +00:00
|
|
|
callba Function347c8
|
2013-05-05 23:56:17 +00:00
|
|
|
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
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39527
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
2014-06-17 19:52:32 +00:00
|
|
|
|
2013-05-05 23:56:17 +00:00
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38882
|
|
|
|
push hl
|
2013-05-06 06:39:01 +00:00
|
|
|
ld hl, Buffer1 - 1
|
|
|
|
ld de, EnemyMonMoves
|
|
|
|
ld c, EnemyMonMovesEnd - EnemyMonMoves + 1
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
.asm_3888b
|
|
|
|
inc hl
|
|
|
|
dec c
|
|
|
|
jr z, .asm_388a2
|
|
|
|
|
|
|
|
ld a, [de]
|
|
|
|
and a
|
|
|
|
jr z, .asm_388a2
|
|
|
|
|
|
|
|
inc de
|
2013-05-06 18:33:19 +00:00
|
|
|
call AIGetEnemyMove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2014-06-13 01:32:42 +00:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_ACC]
|
|
|
|
cp 180
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nc, .asm_3888b
|
|
|
|
|
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
jr .asm_3888b
|
|
|
|
|
|
|
|
.asm_388a2
|
|
|
|
pop hl
|
2013-05-06 18:33:19 +00:00
|
|
|
jp AIDiscourageMove
|
2013-05-05 23:56:17 +00:00
|
|
|
; 388a6
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_Explosion: ; 388a6
|
2014-10-21 11:54:04 +00:00
|
|
|
|
|
|
|
; Unless this is the enemy's last Pokemon...
|
2013-05-05 23:56:17 +00:00
|
|
|
push hl
|
2013-12-31 09:10:49 +00:00
|
|
|
callba Function349f4
|
2013-05-05 23:56:17 +00:00
|
|
|
pop hl
|
|
|
|
jr nc, .asm_388b7
|
|
|
|
|
2014-10-21 18:44:42 +00:00
|
|
|
; ...greatly discourage this move unless this is the player's last Pokemon too.
|
2013-05-05 23:56:17 +00:00
|
|
|
push hl
|
2013-05-07 04:58:35 +00:00
|
|
|
call AICheckLastPlayerMon
|
2013-05-05 23:56:17 +00:00
|
|
|
pop hl
|
|
|
|
jr nz, .asm_388c6
|
|
|
|
|
|
|
|
.asm_388b7
|
2014-10-21 18:44:42 +00:00
|
|
|
; Greatly discourage this move if enemy's HP is above 50%.
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckEnemyHalfHP
|
2013-05-05 23:56:17 +00:00
|
|
|
jr c, .asm_388c6
|
|
|
|
|
2014-10-21 18:44:42 +00:00
|
|
|
; Do nothing if enemy's HP is below 25%.
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckEnemyQuarterHP
|
2013-05-05 23:56:17 +00:00
|
|
|
ret nc
|
|
|
|
|
2014-10-21 12:17:55 +00:00
|
|
|
; If enemy's HP is between 25% and 50%,
|
2014-10-21 18:44:42 +00:00
|
|
|
; over 90% chance to greatly discourage this move.
|
2013-08-31 02:59:40 +00:00
|
|
|
call Random
|
2013-05-07 04:58:35 +00:00
|
|
|
cp 20
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
|
|
|
|
|
|
|
.asm_388c6
|
|
|
|
inc [hl]
|
|
|
|
inc [hl]
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
; 388ca
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_DreamEater: ; 388ca
|
2014-10-21 18:44:42 +00:00
|
|
|
; 90% chance to greatly encourage this move.
|
|
|
|
; The AIScoring_RedStatus layer will make sure that
|
|
|
|
; Dream Eater is only used against sleeping targets.
|
2013-08-31 02:59:40 +00:00
|
|
|
call Random
|
2013-05-05 23:56:17 +00:00
|
|
|
cp $19
|
|
|
|
ret c
|
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
; 388d4
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_EvasionUp: ; 388d4
|
2014-10-22 12:47:33 +00:00
|
|
|
|
|
|
|
; Dismiss this move if enemy's evasion can't raise anymore.
|
2013-05-05 23:56:17 +00:00
|
|
|
ld a, [EnemyEvaLevel]
|
|
|
|
cp $d
|
2013-05-06 18:33:19 +00:00
|
|
|
jp nc, AIDiscourageMove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2014-10-22 12:47:33 +00:00
|
|
|
; If enemy's HP is full...
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckEnemyMaxHP
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nc, .asm_388f2
|
|
|
|
|
2014-10-22 12:47:33 +00:00
|
|
|
; ...greatly encourage this move if player is badly poisoned.
|
2013-05-05 23:56:17 +00:00
|
|
|
ld a, [PlayerSubStatus5]
|
2014-06-13 01:32:42 +00:00
|
|
|
bit SUBSTATUS_TOXIC, a
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nz, .asm_388ef
|
2014-10-22 12:47:33 +00:00
|
|
|
|
|
|
|
; ...70% chance to greatly encourage this move if player is not badly poisoned.
|
2013-08-31 02:59:40 +00:00
|
|
|
call Random
|
2013-05-05 23:56:17 +00:00
|
|
|
cp $b2
|
|
|
|
jr nc, .asm_38911
|
|
|
|
|
|
|
|
.asm_388ef
|
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_388f2
|
2014-10-22 12:47:33 +00:00
|
|
|
|
|
|
|
; Greatly discourage this move if enemy's HP is below 25%.
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckEnemyQuarterHP
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nc, .asm_3890f
|
|
|
|
|
2014-10-22 12:47:33 +00:00
|
|
|
; If enemy's HP is above 25% but not full, 4% chance to greatly encourage this move.
|
2013-08-31 02:59:40 +00:00
|
|
|
call Random
|
2013-05-05 23:56:17 +00:00
|
|
|
cp $a
|
|
|
|
jr c, .asm_388ef
|
|
|
|
|
2014-10-22 12:47:33 +00:00
|
|
|
; If enemy's HP is between 25% and 50%,...
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckEnemyHalfHP
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nc, .asm_3890a
|
|
|
|
|
2014-10-22 12:47:33 +00:00
|
|
|
; If enemy's HP is above 50% but not full, 20% chance to greatly encourage this move.
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39521
|
2013-05-05 23:56:17 +00:00
|
|
|
jr c, .asm_388ef
|
|
|
|
jr .asm_38911
|
|
|
|
|
|
|
|
.asm_3890a
|
2014-10-22 12:47:33 +00:00
|
|
|
; ...50% chance to greatly discourage this move.
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39527
|
2013-05-05 23:56:17 +00:00
|
|
|
jr c, .asm_38911
|
|
|
|
|
|
|
|
.asm_3890f
|
|
|
|
inc [hl]
|
|
|
|
inc [hl]
|
|
|
|
|
2014-10-22 12:47:33 +00:00
|
|
|
; 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.
|
2013-05-05 23:56:17 +00:00
|
|
|
.asm_38911
|
|
|
|
ld a, [PlayerSubStatus5]
|
2014-06-13 01:32:42 +00:00
|
|
|
bit SUBSTATUS_TOXIC, a
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nz, .asm_38938
|
|
|
|
|
|
|
|
ld a, [PlayerSubStatus4]
|
2014-06-13 01:32:42 +00:00
|
|
|
bit SUBSTATUS_LEECH_SEED, a
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nz, .asm_38941
|
|
|
|
|
2014-10-22 12:47:33 +00:00
|
|
|
; Discourage this move if enemy's evasion level is higher than player's accuracy level.
|
2013-05-05 23:56:17 +00:00
|
|
|
ld a, [EnemyEvaLevel]
|
|
|
|
ld b, a
|
|
|
|
ld a, [PlayerAccLevel]
|
|
|
|
cp b
|
|
|
|
jr c, .asm_38936
|
|
|
|
|
2014-10-22 12:47:33 +00:00
|
|
|
; Greatly encourage this move if the player is in the middle of Fury Cutter or Rollout.
|
2013-05-05 23:56:17 +00:00
|
|
|
ld a, [PlayerFuryCutterCount]
|
|
|
|
and a
|
|
|
|
jr nz, .asm_388ef
|
|
|
|
|
|
|
|
ld a, [PlayerSubStatus1]
|
2014-06-17 19:52:32 +00:00
|
|
|
bit SUBSTATUS_ROLLOUT, a
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nz, .asm_388ef
|
|
|
|
|
|
|
|
|
|
|
|
.asm_38936
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
2014-10-22 12:47:33 +00:00
|
|
|
; Player is badly poisoned.
|
|
|
|
; 80% chance to greatly encourage this move.
|
|
|
|
; This would counter any previous discouragement.
|
2013-05-05 23:56:17 +00:00
|
|
|
.asm_38938
|
2013-08-31 02:59:40 +00:00
|
|
|
call Random
|
2013-05-05 23:56:17 +00:00
|
|
|
cp $50
|
|
|
|
ret c
|
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
2014-10-22 12:47:33 +00:00
|
|
|
; Player is seeded.
|
|
|
|
; 50% chance to encourage this move.
|
|
|
|
; This would partly counter any previous discouragement.
|
2013-05-05 23:56:17 +00:00
|
|
|
.asm_38941
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39527
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
2014-06-17 19:52:32 +00:00
|
|
|
|
2013-05-05 23:56:17 +00:00
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
; 38947
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_AlwaysHit: ; 38947
|
2014-10-21 12:17:55 +00:00
|
|
|
; 80% chance to greatly encourage this move if either...
|
|
|
|
|
2014-10-21 22:28:51 +00:00
|
|
|
; ...enemy's accuracy level has been lowered three or more stages
|
2013-05-05 23:56:17 +00:00
|
|
|
ld a, [EnemyAccLevel]
|
|
|
|
cp $5
|
|
|
|
jr c, .asm_38954
|
|
|
|
|
2014-10-21 22:28:51 +00:00
|
|
|
; ...or player's evasion level has been raised three or more stages.
|
2013-05-05 23:56:17 +00:00
|
|
|
ld a, [PlayerEvaLevel]
|
|
|
|
cp $a
|
2014-10-21 17:21:13 +00:00
|
|
|
ret c
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
.asm_38954
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39521
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
ret c
|
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
; 3895b
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_MirrorMove: ; 3895b
|
2014-10-21 22:28:51 +00:00
|
|
|
|
|
|
|
; If the player did not use any move last turn...
|
2013-05-05 23:56:17 +00:00
|
|
|
ld a, [LastEnemyCounterMove]
|
|
|
|
and a
|
|
|
|
jr nz, .asm_38968
|
|
|
|
|
2014-10-21 22:28:51 +00:00
|
|
|
; ...do nothing if enemy is slower than player
|
|
|
|
call AICompareSpeed
|
2013-05-05 23:56:17 +00:00
|
|
|
ret nc
|
2014-10-21 22:28:51 +00:00
|
|
|
|
|
|
|
; ...or dismiss this move if enemy is faster than player.
|
2014-06-13 01:32:42 +00:00
|
|
|
jp AIDiscourageMove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2014-10-21 22:28:51 +00:00
|
|
|
; If the player did use a move last turn...
|
2013-05-05 23:56:17 +00:00
|
|
|
.asm_38968
|
|
|
|
push hl
|
2014-10-21 22:28:51 +00:00
|
|
|
ld hl, UsefulMoves
|
2013-05-06 06:39:01 +00:00
|
|
|
ld de, 1
|
2013-05-05 23:56:17 +00:00
|
|
|
call IsInArray
|
|
|
|
pop hl
|
2014-10-21 22:28:51 +00:00
|
|
|
|
|
|
|
; ...do nothing if he didn't use a useful move.
|
2013-05-05 23:56:17 +00:00
|
|
|
ret nc
|
|
|
|
|
2014-10-21 22:28:51 +00:00
|
|
|
; If he did, 50% chance to encourage this move...
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39527
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
|
|
|
dec [hl]
|
2014-10-21 22:28:51 +00:00
|
|
|
|
|
|
|
; ...and 90% chance to encourage this move again if the enemy is faster.
|
2013-05-07 00:51:07 +00:00
|
|
|
call AICompareSpeed
|
2013-05-05 23:56:17 +00:00
|
|
|
ret nc
|
|
|
|
|
2014-06-13 01:32:42 +00:00
|
|
|
call Random
|
2013-05-05 23:56:17 +00:00
|
|
|
cp $19
|
|
|
|
ret c
|
2014-06-13 01:32:42 +00:00
|
|
|
|
2013-05-05 23:56:17 +00:00
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
; 38985
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_AccuracyDown: ; 38985
|
2014-10-22 12:47:33 +00:00
|
|
|
|
|
|
|
; If player's HP is full...
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckPlayerMaxHP
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nc, .asm_389a0
|
|
|
|
|
2014-10-22 12:47:33 +00:00
|
|
|
; ...and enemy's HP is above 50%...
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckEnemyHalfHP
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nc, .asm_389a0
|
|
|
|
|
2014-10-22 12:47:33 +00:00
|
|
|
; ...greatly encourage this move if player is badly poisoned.
|
2013-05-05 23:56:17 +00:00
|
|
|
ld a, [PlayerSubStatus5]
|
2014-06-13 01:32:42 +00:00
|
|
|
bit SUBSTATUS_TOXIC, a
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nz, .asm_3899d
|
|
|
|
|
2014-10-22 12:47:33 +00:00
|
|
|
; ...70% chance to greatly encourage this move if player is not badly poisoned.
|
2013-08-31 02:59:40 +00:00
|
|
|
call Random
|
2013-05-05 23:56:17 +00:00
|
|
|
cp $b2
|
|
|
|
jr nc, .asm_389bf
|
|
|
|
|
|
|
|
.asm_3899d
|
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_389a0
|
2014-10-22 12:47:33 +00:00
|
|
|
|
|
|
|
; Greatly discourage this move if player's HP is below 25%.
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckPlayerQuarterHP
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nc, .asm_389bd
|
|
|
|
|
2014-10-22 12:47:33 +00:00
|
|
|
; If player's HP is above 25% but not full, 4% chance to greatly encourage this move.
|
2013-08-31 02:59:40 +00:00
|
|
|
call Random
|
2013-05-05 23:56:17 +00:00
|
|
|
cp $a
|
|
|
|
jr c, .asm_3899d
|
|
|
|
|
2014-10-22 12:47:33 +00:00
|
|
|
; If player's HP is between 25% and 50%,...
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckPlayerHalfHP
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nc, .asm_389b8
|
|
|
|
|
2014-10-22 12:47:33 +00:00
|
|
|
; If player's HP is above 50% but not full, 20% chance to greatly encourage this move.
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39521
|
2013-05-05 23:56:17 +00:00
|
|
|
jr c, .asm_3899d
|
|
|
|
jr .asm_389bf
|
|
|
|
|
2014-10-22 12:47:33 +00:00
|
|
|
; ...50% chance to greatly discourage this move.
|
2013-05-05 23:56:17 +00:00
|
|
|
.asm_389b8
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39527
|
2013-05-05 23:56:17 +00:00
|
|
|
jr c, .asm_389bf
|
|
|
|
|
|
|
|
.asm_389bd
|
|
|
|
inc [hl]
|
|
|
|
inc [hl]
|
|
|
|
|
2014-10-22 12:47:33 +00:00
|
|
|
; We only end up here if the move has not been already encouraged.
|
2013-05-05 23:56:17 +00:00
|
|
|
.asm_389bf
|
|
|
|
ld a, [PlayerSubStatus5]
|
2014-06-13 01:32:42 +00:00
|
|
|
bit SUBSTATUS_TOXIC, a
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nz, .asm_389e6
|
|
|
|
|
|
|
|
ld a, [PlayerSubStatus4]
|
2014-06-13 01:32:42 +00:00
|
|
|
bit SUBSTATUS_LEECH_SEED, a
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nz, .asm_389ef
|
|
|
|
|
2014-10-22 12:47:33 +00:00
|
|
|
; Discourage this move if enemy's evasion level is higher than player's accuracy level.
|
2013-05-05 23:56:17 +00:00
|
|
|
ld a, [EnemyEvaLevel]
|
|
|
|
ld b, a
|
|
|
|
ld a, [PlayerAccLevel]
|
|
|
|
cp b
|
|
|
|
jr c, .asm_389e4
|
|
|
|
|
2014-10-22 12:47:33 +00:00
|
|
|
; Greatly encourage this move if the player is in the middle of Fury Cutter or Rollout.
|
2013-05-05 23:56:17 +00:00
|
|
|
ld a, [PlayerFuryCutterCount]
|
|
|
|
and a
|
|
|
|
jr nz, .asm_3899d
|
|
|
|
|
|
|
|
ld a, [PlayerSubStatus1]
|
2014-06-17 19:52:32 +00:00
|
|
|
bit SUBSTATUS_ROLLOUT, a
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nz, .asm_3899d
|
|
|
|
|
|
|
|
.asm_389e4
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
2014-10-22 12:47:33 +00:00
|
|
|
; Player is badly poisoned.
|
|
|
|
; 80% chance to greatly encourage this move.
|
|
|
|
; This would counter any previous discouragement.
|
2013-05-05 23:56:17 +00:00
|
|
|
.asm_389e6
|
2013-08-31 02:59:40 +00:00
|
|
|
call Random
|
2013-05-05 23:56:17 +00:00
|
|
|
cp $50
|
|
|
|
ret c
|
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
2014-10-22 12:47:33 +00:00
|
|
|
; Player is seeded.
|
|
|
|
; 50% chance to encourage this move.
|
|
|
|
; This would partly counter any previous discouragement.
|
2013-05-05 23:56:17 +00:00
|
|
|
.asm_389ef
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39527
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
2014-06-13 01:32:42 +00:00
|
|
|
|
2013-05-05 23:56:17 +00:00
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
; 389f5
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_Haze: ; 389f5
|
2014-10-22 12:47:33 +00:00
|
|
|
|
|
|
|
; 85% chance to encourage this move if any of enemy's stat levels is lower than -2.
|
2013-05-05 23:56:17 +00:00
|
|
|
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
|
|
|
|
|
2014-10-22 12:47:33 +00:00
|
|
|
; 85% chance to encourage this move if any of player's stat levels is higher than +2.
|
2013-05-05 23:56:17 +00:00
|
|
|
.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
|
2013-08-31 02:59:40 +00:00
|
|
|
call Random
|
2013-05-05 23:56:17 +00:00
|
|
|
cp $28
|
|
|
|
ret c
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
2014-10-22 12:47:33 +00:00
|
|
|
; 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.
|
2013-05-05 23:56:17 +00:00
|
|
|
.asm_38a1b
|
|
|
|
pop hl
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
; 38a1e
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_Bide: ; 38a1e
|
2014-10-21 18:44:42 +00:00
|
|
|
; 90% chance to discourage this move unless enemy's HP is full.
|
2014-10-21 12:17:55 +00:00
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckEnemyMaxHP
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
2013-08-31 02:59:40 +00:00
|
|
|
call Random
|
2013-05-05 23:56:17 +00:00
|
|
|
cp $19
|
|
|
|
ret c
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
; 38a2a
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_Whirlwind: ; 38a2a
|
2014-10-22 12:47:33 +00:00
|
|
|
; Discourage this move if the player has not shown
|
|
|
|
; a super-effective move against the enemy.
|
|
|
|
; Consider player's type if its moves are unknown.
|
|
|
|
|
2013-05-05 23:56:17 +00:00
|
|
|
push hl
|
2013-12-31 09:10:49 +00:00
|
|
|
callab Function3484e
|
2013-05-05 23:56:17 +00:00
|
|
|
ld a, [$c716]
|
|
|
|
cp $a
|
|
|
|
pop hl
|
|
|
|
ret c
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
; 38a3a
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_Heal:
|
|
|
|
AIScoring_MorningSun:
|
|
|
|
AIScoring_Synthesis:
|
|
|
|
AIScoring_Moonlight: ; 38a3a
|
2014-10-21 22:28:51 +00:00
|
|
|
; 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.
|
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckEnemyQuarterHP
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nc, .asm_38a45
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckEnemyHalfHP
|
2013-05-05 23:56:17 +00:00
|
|
|
ret nc
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38a45
|
2013-08-31 02:59:40 +00:00
|
|
|
call Random
|
2013-05-05 23:56:17 +00:00
|
|
|
cp $19
|
|
|
|
ret c
|
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
; 38a4e
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_Toxic:
|
|
|
|
AIScoring_LeechSeed: ; 38a4e
|
2014-10-21 18:44:42 +00:00
|
|
|
; Discourage this move if player's HP is below 50%.
|
2014-10-21 12:17:55 +00:00
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckPlayerHalfHP
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
; 38a54
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_LightScreen:
|
|
|
|
AIScoring_Reflect: ; 38a54
|
2014-10-21 18:44:42 +00:00
|
|
|
; Over 90% chance to discourage this move unless enemy's HP is full.
|
2014-10-21 17:21:13 +00:00
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckEnemyMaxHP
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
2013-08-31 02:59:40 +00:00
|
|
|
call Random
|
2013-05-05 23:56:17 +00:00
|
|
|
cp $14
|
|
|
|
ret c
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
; 38a60
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_Ohko: ; 38a60
|
2014-10-21 22:28:51 +00:00
|
|
|
; Dismiss this move if player's level is higher than enemy's level
|
|
|
|
; Otherwise, discourage this move is player's HP is below 50%.
|
|
|
|
|
2013-05-05 23:56:17 +00:00
|
|
|
ld a, [BattleMonLevel]
|
|
|
|
ld b, a
|
|
|
|
ld a, [EnemyMonLevel]
|
|
|
|
cp b
|
2013-05-06 18:33:19 +00:00
|
|
|
jp c, AIDiscourageMove
|
|
|
|
call AICheckPlayerHalfHP
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
; 38a71
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_Bind: ; 38a71
|
|
|
|
ld a, [$c730]
|
|
|
|
and a
|
|
|
|
jr nz, .asm_38a8b
|
|
|
|
|
|
|
|
ld a, [PlayerSubStatus5]
|
2013-05-06 06:39:01 +00:00
|
|
|
bit SUBSTATUS_TOXIC, a
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nz, .asm_38a91
|
|
|
|
|
|
|
|
ld a, [PlayerSubStatus1]
|
2014-06-17 19:52:32 +00:00
|
|
|
and 1<<SUBSTATUS_IN_LOVE | 1<<SUBSTATUS_ROLLOUT | 1<<SUBSTATUS_IDENTIFIED | 1<<SUBSTATUS_NIGHTMARE
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nz, .asm_38a91
|
|
|
|
|
|
|
|
ld a, [PlayerTurnsTaken]
|
|
|
|
and a
|
|
|
|
jr z, .asm_38a91
|
|
|
|
|
|
|
|
.asm_38a8b
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39527
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38a91
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckEnemyQuarterHP
|
2013-05-05 23:56:17 +00:00
|
|
|
ret nc
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39527
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
; 38a9c
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_RazorWind:
|
|
|
|
AIScoring_Unused2B: ; 38a9c
|
|
|
|
ld a, [EnemySubStatus1]
|
2013-05-06 06:39:01 +00:00
|
|
|
bit SUBSTATUS_PERISH, a
|
2013-05-05 23:56:17 +00:00
|
|
|
jr z, .asm_38aaa
|
|
|
|
|
|
|
|
ld a, [EnemyPerishCount]
|
2013-05-06 06:39:01 +00:00
|
|
|
cp 3
|
2013-05-05 23:56:17 +00:00
|
|
|
jr c, .asm_38ad3
|
|
|
|
|
|
|
|
.asm_38aaa
|
|
|
|
push hl
|
|
|
|
ld hl, PlayerUsedMoves
|
2013-05-06 06:39:01 +00:00
|
|
|
ld c, 4
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
.asm_38ab0
|
|
|
|
ld a, [hli]
|
|
|
|
and a
|
|
|
|
jr z, .asm_38ac1
|
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
call AIGetEnemyMove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2014-06-13 01:32:42 +00:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_EFFECT]
|
2013-05-06 06:39:01 +00:00
|
|
|
cp EFFECT_PROTECT
|
2013-05-05 23:56:17 +00:00
|
|
|
jr z, .asm_38ad5
|
|
|
|
dec c
|
|
|
|
jr nz, .asm_38ab0
|
|
|
|
|
|
|
|
.asm_38ac1
|
|
|
|
pop hl
|
|
|
|
ld a, [EnemySubStatus3]
|
2013-05-06 06:39:01 +00:00
|
|
|
bit SUBSTATUS_CONFUSED, a
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nz, .asm_38acd
|
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckEnemyHalfHP
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
|
|
|
|
|
|
|
.asm_38acd
|
2013-08-31 02:59:40 +00:00
|
|
|
call Random
|
2013-05-05 23:56:17 +00:00
|
|
|
cp $c8
|
|
|
|
ret c
|
|
|
|
|
|
|
|
.asm_38ad3
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38ad5
|
|
|
|
pop hl
|
|
|
|
ld a, [hl]
|
2013-05-06 06:39:01 +00:00
|
|
|
add 6
|
2013-05-05 23:56:17 +00:00
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
; 38adb
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_Confuse: ; 38adb
|
2014-10-21 22:28:51 +00:00
|
|
|
|
|
|
|
; 90% chance to discourage this move if player's HP is between 25% and 50%.
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckPlayerHalfHP
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
2013-08-31 02:59:40 +00:00
|
|
|
call Random
|
2013-05-05 23:56:17 +00:00
|
|
|
cp $19
|
|
|
|
jr c, .asm_38ae7
|
|
|
|
inc [hl]
|
2014-10-21 22:28:51 +00:00
|
|
|
|
2013-05-05 23:56:17 +00:00
|
|
|
.asm_38ae7
|
2014-10-21 22:28:51 +00:00
|
|
|
; Discourage again if player's HP is below 25%.
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckPlayerQuarterHP
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
; 38aed
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_SpDefenseUp2: ; 38aed
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckEnemyHalfHP
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nc, .asm_38b10
|
|
|
|
|
|
|
|
ld a, [EnemySDefLevel]
|
|
|
|
cp $b
|
|
|
|
jr nc, .asm_38b10
|
|
|
|
cp $9
|
|
|
|
ret nc
|
2013-05-06 06:39:01 +00:00
|
|
|
|
2013-05-05 23:56:17 +00:00
|
|
|
ld a, [BattleMonType1]
|
2014-06-13 01:32:42 +00:00
|
|
|
cp SPECIAL
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nc, .asm_38b09
|
|
|
|
ld a, [BattleMonType2]
|
2014-06-13 01:32:42 +00:00
|
|
|
cp SPECIAL
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
|
|
|
|
|
|
|
.asm_38b09
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39521
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38b10
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
; 38b12
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_Fly: ; 38b12
|
2014-10-21 22:28:51 +00:00
|
|
|
; Greatly encourage this move if the player is
|
|
|
|
; flying or underground, and slower than the enemy.
|
|
|
|
|
2013-05-05 23:56:17 +00:00
|
|
|
ld a, [PlayerSubStatus3]
|
2014-05-05 07:30:51 +00:00
|
|
|
and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND
|
2013-05-05 23:56:17 +00:00
|
|
|
ret z
|
2013-05-07 00:51:07 +00:00
|
|
|
call AICompareSpeed
|
2013-05-05 23:56:17 +00:00
|
|
|
ret nc
|
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
; 38b20
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_SuperFang: ; 38b20
|
2014-10-21 22:28:51 +00:00
|
|
|
; Discourage this move if player's HP is below 25%.
|
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckPlayerQuarterHP
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
; 38b26
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_Paralyze: ; 38b26
|
2014-10-21 22:28:51 +00:00
|
|
|
|
|
|
|
; 50% chance to discourage this move if player's HP is below 25%.
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckPlayerQuarterHP
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nc, .asm_38b3a
|
2014-10-21 22:28:51 +00:00
|
|
|
|
|
|
|
; 80% chance to greatly encourage this move
|
|
|
|
; if enemy is slower than player and its HP is above 25%.
|
2013-05-07 00:51:07 +00:00
|
|
|
call AICompareSpeed
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckEnemyQuarterHP
|
2013-05-05 23:56:17 +00:00
|
|
|
ret nc
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39521
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38b3a
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39527
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
; 38b40
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_SpeedDownHit: ; 38b40
|
2014-06-13 01:32:42 +00:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_ANIM]
|
2013-05-07 00:51:07 +00:00
|
|
|
cp ICY_WIND
|
2013-05-05 23:56:17 +00:00
|
|
|
ret nz
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckEnemyQuarterHP
|
2013-05-05 23:56:17 +00:00
|
|
|
ret nc
|
|
|
|
ld a, [PlayerTurnsTaken]
|
|
|
|
and a
|
|
|
|
ret nz
|
2013-05-07 00:51:07 +00:00
|
|
|
call AICompareSpeed
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
2013-08-31 02:59:40 +00:00
|
|
|
call Random
|
2013-05-07 04:58:35 +00:00
|
|
|
cp 30
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
; 38b5c
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_Substitute: ; 38b5c
|
2014-10-21 22:28:51 +00:00
|
|
|
; Dismiss this move if enemy's HP is below 50%.
|
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckEnemyHalfHP
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
2013-05-06 18:33:19 +00:00
|
|
|
jp AIDiscourageMove
|
2013-05-05 23:56:17 +00:00
|
|
|
; 38b63
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_HyperBeam: ; 38b63
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckEnemyHalfHP
|
2013-05-05 23:56:17 +00:00
|
|
|
jr c, .asm_38b72
|
2014-10-21 22:28:51 +00:00
|
|
|
|
|
|
|
; 50% chance to encourage this move if enemy's HP is below 25%.
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckEnemyQuarterHP
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39527
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38b72
|
2014-10-21 22:28:51 +00:00
|
|
|
; If enemy's HP is above 50%, discourage this move at random
|
2013-08-31 02:59:40 +00:00
|
|
|
call Random
|
2013-05-07 04:58:35 +00:00
|
|
|
cp 40
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
|
|
|
inc [hl]
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39527
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
; 38b7f
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_Rage: ; 38b7f
|
|
|
|
ld a, [EnemySubStatus4]
|
2014-06-17 19:52:32 +00:00
|
|
|
bit SUBSTATUS_RAGE, a
|
2013-05-05 23:56:17 +00:00
|
|
|
jr z, .asm_38b9b
|
|
|
|
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39527
|
2013-05-05 23:56:17 +00:00
|
|
|
jr c, .asm_38b8c
|
|
|
|
|
|
|
|
dec [hl]
|
|
|
|
|
|
|
|
.asm_38b8c
|
|
|
|
ld a, [$c72c]
|
|
|
|
cp $2
|
|
|
|
ret c
|
|
|
|
dec [hl]
|
|
|
|
ld a, [$c72c]
|
|
|
|
cp $3
|
|
|
|
ret c
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38b9b
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckEnemyHalfHP
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nc, .asm_38ba6
|
|
|
|
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39521
|
2013-05-05 23:56:17 +00:00
|
|
|
ret nc
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38ba6
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
; 38ba8
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_Mimic: ; 38ba8
|
|
|
|
ld a, [LastEnemyCounterMove]
|
|
|
|
and a
|
|
|
|
jr z, .asm_38be9
|
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckEnemyHalfHP
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nc, .asm_38bef
|
|
|
|
|
|
|
|
push hl
|
|
|
|
ld a, [LastEnemyCounterMove]
|
2013-05-06 18:33:19 +00:00
|
|
|
call AIGetEnemyMove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
ld a, $1
|
|
|
|
ld [hBattleTurn], a
|
2014-05-05 07:30:51 +00:00
|
|
|
callab Function347c8
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
ld a, [$d265]
|
|
|
|
cp $a
|
|
|
|
pop hl
|
|
|
|
jr c, .asm_38bef
|
|
|
|
jr z, .asm_38bd4
|
|
|
|
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39527
|
2013-05-05 23:56:17 +00:00
|
|
|
jr c, .asm_38bd4
|
|
|
|
|
|
|
|
dec [hl]
|
|
|
|
|
|
|
|
.asm_38bd4
|
|
|
|
ld a, [LastEnemyCounterMove]
|
|
|
|
push hl
|
2014-10-21 22:28:51 +00:00
|
|
|
ld hl, UsefulMoves
|
2013-05-06 06:39:01 +00:00
|
|
|
ld de, 1
|
2013-05-05 23:56:17 +00:00
|
|
|
call IsInArray
|
|
|
|
|
|
|
|
pop hl
|
|
|
|
ret nc
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39527
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38be9
|
2013-05-07 00:51:07 +00:00
|
|
|
call AICompareSpeed
|
2013-05-06 18:33:19 +00:00
|
|
|
jp c, AIDiscourageMove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
.asm_38bef
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
; 38bf1
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_Counter: ; 38bf1
|
|
|
|
push hl
|
|
|
|
ld hl, PlayerUsedMoves
|
2013-05-06 06:39:01 +00:00
|
|
|
ld c, 4
|
|
|
|
ld b, 0
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
.asm_38bf9
|
|
|
|
ld a, [hli]
|
|
|
|
and a
|
|
|
|
jr z, .asm_38c0e
|
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
call AIGetEnemyMove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2014-06-13 01:32:42 +00:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_POWER]
|
2013-05-05 23:56:17 +00:00
|
|
|
and a
|
|
|
|
jr z, .asm_38c0e
|
|
|
|
|
2014-06-13 01:32:42 +00:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_TYPE]
|
|
|
|
cp SPECIAL
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nc, .asm_38c0e
|
|
|
|
|
|
|
|
inc b
|
|
|
|
|
|
|
|
.asm_38c0e
|
|
|
|
dec c
|
|
|
|
jr nz, .asm_38bf9
|
|
|
|
|
|
|
|
pop hl
|
|
|
|
ld a, b
|
|
|
|
and a
|
|
|
|
jr z, .asm_38c39
|
|
|
|
|
|
|
|
cp $3
|
|
|
|
jr nc, .asm_38c30
|
|
|
|
|
|
|
|
ld a, [LastEnemyCounterMove]
|
|
|
|
and a
|
|
|
|
jr z, .asm_38c38
|
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
call AIGetEnemyMove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2014-06-13 01:32:42 +00:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_POWER]
|
2013-05-05 23:56:17 +00:00
|
|
|
and a
|
|
|
|
jr z, .asm_38c38
|
|
|
|
|
2014-06-13 01:32:42 +00:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_TYPE]
|
|
|
|
cp SPECIAL
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nc, .asm_38c38
|
|
|
|
|
|
|
|
|
|
|
|
.asm_38c30
|
2013-08-31 02:59:40 +00:00
|
|
|
call Random
|
2013-05-05 23:56:17 +00:00
|
|
|
cp $64
|
|
|
|
jr c, .asm_38c38
|
|
|
|
|
|
|
|
dec [hl]
|
|
|
|
|
|
|
|
.asm_38c38
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38c39
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
; 38c3b
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_Encore: ; 38c3b
|
2013-05-07 00:51:07 +00:00
|
|
|
call AICompareSpeed
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nc, .asm_38c81
|
|
|
|
|
|
|
|
ld a, [LastPlayerMove]
|
|
|
|
and a
|
2013-05-06 18:33:19 +00:00
|
|
|
jp z, AIDiscourageMove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
call AIGetEnemyMove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2014-06-13 01:32:42 +00:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_POWER]
|
2013-05-05 23:56:17 +00:00
|
|
|
and a
|
|
|
|
jr z, .asm_38c68
|
|
|
|
|
|
|
|
push hl
|
2014-06-13 01:32:42 +00:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_TYPE]
|
2013-05-05 23:56:17 +00:00
|
|
|
ld hl, EnemyMonType1
|
2014-06-16 18:20:01 +00:00
|
|
|
predef Function347d3
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
pop hl
|
|
|
|
ld a, [$d265]
|
|
|
|
cp $a
|
|
|
|
jr nc, .asm_38c68
|
|
|
|
|
|
|
|
and a
|
|
|
|
ret nz
|
|
|
|
jr .asm_38c78
|
|
|
|
|
|
|
|
.asm_38c68
|
|
|
|
push hl
|
|
|
|
ld a, [LastEnemyCounterMove]
|
2013-05-06 06:39:01 +00:00
|
|
|
ld hl, .table_38c85
|
|
|
|
ld de, 1
|
2013-05-05 23:56:17 +00:00
|
|
|
call IsInArray
|
|
|
|
pop hl
|
|
|
|
jr nc, .asm_38c81
|
|
|
|
|
|
|
|
.asm_38c78
|
2013-08-31 02:59:40 +00:00
|
|
|
call Random
|
2013-05-05 23:56:17 +00:00
|
|
|
cp $46
|
|
|
|
ret c
|
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38c81
|
|
|
|
inc [hl]
|
|
|
|
inc [hl]
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
2013-05-06 06:39:01 +00:00
|
|
|
.table_38c85
|
|
|
|
db SWORDS_DANCE
|
|
|
|
db WHIRLWIND
|
|
|
|
db LEER
|
|
|
|
db ROAR
|
|
|
|
db DISABLE
|
|
|
|
db MIST
|
|
|
|
db LEECH_SEED
|
|
|
|
db GROWTH
|
|
|
|
db POISONPOWDER
|
|
|
|
db STRING_SHOT
|
|
|
|
db MEDITATE
|
|
|
|
db AGILITY
|
|
|
|
db TELEPORT
|
|
|
|
db SCREECH
|
|
|
|
db HAZE
|
|
|
|
db FOCUS_ENERGY
|
|
|
|
db DREAM_EATER
|
|
|
|
db POISON_GAS
|
|
|
|
db SPLASH
|
|
|
|
db SHARPEN
|
|
|
|
db CONVERSION
|
|
|
|
db SUPER_FANG
|
|
|
|
db SUBSTITUTE
|
|
|
|
db TRIPLE_KICK
|
|
|
|
db SPIDER_WEB
|
|
|
|
db MIND_READER
|
|
|
|
db FLAME_WHEEL
|
|
|
|
db AEROBLAST
|
|
|
|
db COTTON_SPORE
|
|
|
|
db POWDER_SNOW
|
|
|
|
db $ff
|
|
|
|
; 38ca4
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
AIScoring_PainSplit: ; 38ca4
|
|
|
|
push hl
|
2014-06-13 01:32:42 +00:00
|
|
|
ld hl, EnemyMonHP
|
2013-05-05 23:56:17 +00:00
|
|
|
ld b, [hl]
|
|
|
|
inc hl
|
|
|
|
ld c, [hl]
|
|
|
|
sla c
|
|
|
|
rl b
|
2014-05-05 07:30:51 +00:00
|
|
|
ld hl, BattleMonHP + 1
|
2013-05-05 23:56:17 +00:00
|
|
|
ld a, [hld]
|
|
|
|
cp c
|
|
|
|
ld a, [hl]
|
|
|
|
sbc b
|
|
|
|
pop hl
|
|
|
|
ret nc
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
; 38cba
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_Snore:
|
|
|
|
AIScoring_SleepTalk: ; 38cba
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_DefrostOpponent: ; 38ccb
|
|
|
|
ld a, [EnemyMonStatus]
|
|
|
|
and $20
|
|
|
|
ret z
|
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
; 38cd5
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_Spite: ; 38cd5
|
|
|
|
ld a, [LastEnemyCounterMove]
|
|
|
|
and a
|
|
|
|
jr nz, .asm_38ce7
|
|
|
|
|
2013-05-07 00:51:07 +00:00
|
|
|
call AICompareSpeed
|
2013-05-06 18:33:19 +00:00
|
|
|
jp c, AIDiscourageMove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39527
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38ce7
|
|
|
|
push hl
|
|
|
|
ld b, a
|
2013-05-06 06:39:01 +00:00
|
|
|
ld c, 4
|
|
|
|
ld hl, BattleMonMoves
|
|
|
|
ld de, BattleMonPP
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
.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
|
|
|
|
|
2013-08-31 02:59:40 +00:00
|
|
|
call Random
|
2013-05-05 23:56:17 +00:00
|
|
|
cp $64
|
|
|
|
ret nc
|
|
|
|
|
|
|
|
.asm_38d0b
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38d0d
|
2013-08-31 02:59:40 +00:00
|
|
|
call Random
|
2013-05-05 23:56:17 +00:00
|
|
|
cp $64
|
|
|
|
ret c
|
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
; 38d16
|
|
|
|
|
|
|
|
|
2013-05-06 06:39:01 +00:00
|
|
|
Function_0x38d16; 38d16
|
2013-05-06 18:33:19 +00:00
|
|
|
jp AIDiscourageMove
|
2013-05-06 06:39:01 +00:00
|
|
|
; 38d19
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
AIScoring_DestinyBond:
|
|
|
|
AIScoring_Reversal:
|
|
|
|
AIScoring_SkullBash: ; 38d19
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckEnemyQuarterHP
|
2013-05-05 23:56:17 +00:00
|
|
|
ret nc
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
; 38d1f
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_HealBell: ; 38d1f
|
|
|
|
push hl
|
|
|
|
ld a, [OTPartyCount]
|
|
|
|
ld b, a
|
2013-05-06 06:39:01 +00:00
|
|
|
ld c, 0
|
2014-02-23 05:37:09 +00:00
|
|
|
ld hl, OTPartyMon1HP
|
2014-06-23 19:45:30 +00:00
|
|
|
ld de, OTPartyMon2 - OTPartyMon1
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2014-06-23 19:45:30 +00:00
|
|
|
.loop
|
2013-05-05 23:56:17 +00:00
|
|
|
push hl
|
|
|
|
ld a, [hli]
|
|
|
|
or [hl]
|
2014-06-23 19:45:30 +00:00
|
|
|
jr z, .next
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
dec hl
|
|
|
|
dec hl
|
|
|
|
dec hl
|
|
|
|
ld a, [hl]
|
|
|
|
or c
|
|
|
|
ld c, a
|
|
|
|
|
2014-06-23 19:45:30 +00:00
|
|
|
.next
|
2013-05-05 23:56:17 +00:00
|
|
|
pop hl
|
|
|
|
add hl, de
|
|
|
|
dec b
|
2014-06-23 19:45:30 +00:00
|
|
|
jr nz, .loop
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
pop hl
|
|
|
|
ld a, c
|
|
|
|
and a
|
2014-06-23 19:45:30 +00:00
|
|
|
jr z, .no_status
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
ld a, [EnemyMonStatus]
|
|
|
|
and a
|
2014-06-23 19:45:30 +00:00
|
|
|
jr z, .ok
|
2013-05-05 23:56:17 +00:00
|
|
|
dec [hl]
|
2014-06-23 19:45:30 +00:00
|
|
|
.ok
|
|
|
|
and 1 << FRZ | SLP
|
2013-05-05 23:56:17 +00:00
|
|
|
ret z
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39527
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
2014-06-23 19:45:30 +00:00
|
|
|
.no_status
|
2013-05-05 23:56:17 +00:00
|
|
|
ld a, [EnemyMonStatus]
|
|
|
|
and a
|
|
|
|
ret nz
|
2013-05-06 18:33:19 +00:00
|
|
|
jp AIDiscourageMove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
; 38d5a
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_PriorityHit: ; 38d5a
|
2013-05-07 00:51:07 +00:00
|
|
|
call AICompareSpeed
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
ret c
|
|
|
|
ld a, [PlayerSubStatus3]
|
2014-05-05 07:30:51 +00:00
|
|
|
and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND
|
2013-05-06 18:33:19 +00:00
|
|
|
jp nz, AIDiscourageMove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
ld a, $1
|
|
|
|
ld [hBattleTurn], a
|
|
|
|
push hl
|
2014-05-05 07:30:51 +00:00
|
|
|
callab EnemyAttackDamage
|
|
|
|
callab BattleCommand62
|
|
|
|
callab BattleCommand07
|
2013-05-05 23:56:17 +00:00
|
|
|
pop hl
|
2014-05-05 07:30:51 +00:00
|
|
|
ld a, [CurDamage + 1]
|
2013-05-05 23:56:17 +00:00
|
|
|
ld c, a
|
|
|
|
ld a, [CurDamage]
|
|
|
|
ld b, a
|
2014-05-05 07:30:51 +00:00
|
|
|
ld a, [BattleMonHP + 1]
|
2013-05-05 23:56:17 +00:00
|
|
|
cp c
|
|
|
|
ld a, [BattleMonHP]
|
|
|
|
sbc b
|
|
|
|
ret nc
|
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
; 38d93
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_Thief: ; 38d93
|
2014-10-21 18:44:42 +00:00
|
|
|
; Don't use Thief unless it's the only move available.
|
2014-10-21 22:28:51 +00:00
|
|
|
|
2013-05-05 23:56:17 +00:00
|
|
|
ld a, [hl]
|
|
|
|
add $1e
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
; 38d98
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_Conversion2: ; 38d98
|
|
|
|
ld a, [LastPlayerMove]
|
|
|
|
and a
|
|
|
|
jr nz, .asm_38dc9
|
|
|
|
|
|
|
|
push hl
|
|
|
|
dec a
|
2014-06-11 06:23:55 +00:00
|
|
|
ld hl, Moves + MOVE_TYPE
|
|
|
|
ld bc, MOVE_LENGTH
|
2013-05-05 23:56:17 +00:00
|
|
|
call AddNTimes
|
|
|
|
|
2013-05-06 06:39:01 +00:00
|
|
|
ld a, BANK(Moves)
|
2013-05-05 23:56:17 +00:00
|
|
|
call GetFarByte
|
2014-06-13 01:32:42 +00:00
|
|
|
ld [wPlayerMoveStruct + MOVE_TYPE], a
|
2013-05-06 06:39:01 +00:00
|
|
|
|
2013-05-05 23:56:17 +00:00
|
|
|
xor a
|
|
|
|
ld [hBattleTurn], a
|
2013-05-06 06:39:01 +00:00
|
|
|
|
2014-05-05 07:30:51 +00:00
|
|
|
callab Function347c8
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
ld a, [$d265]
|
|
|
|
cp $a
|
|
|
|
pop hl
|
|
|
|
jr c, .asm_38dc9
|
|
|
|
|
|
|
|
ret z
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39527
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
ret c
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38dc9
|
2013-08-31 02:59:40 +00:00
|
|
|
call Random
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
cp $19
|
|
|
|
ret c
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
; 38dd1
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_Disable: ; 38dd1
|
2013-05-07 00:51:07 +00:00
|
|
|
call AICompareSpeed
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nc, .asm_38df3
|
|
|
|
|
|
|
|
push hl
|
|
|
|
ld a, [LastEnemyCounterMove]
|
2014-10-21 22:28:51 +00:00
|
|
|
ld hl, UsefulMoves
|
2013-05-06 06:39:01 +00:00
|
|
|
ld de, 1
|
2013-05-05 23:56:17 +00:00
|
|
|
call IsInArray
|
|
|
|
|
|
|
|
pop hl
|
|
|
|
jr nc, .asm_38dee
|
|
|
|
|
2013-08-31 02:59:40 +00:00
|
|
|
call Random
|
2013-05-07 04:58:35 +00:00
|
|
|
cp 100
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38dee
|
2014-06-13 01:32:42 +00:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_POWER]
|
2013-05-05 23:56:17 +00:00
|
|
|
and a
|
|
|
|
ret nz
|
|
|
|
|
|
|
|
.asm_38df3
|
2013-08-31 02:59:40 +00:00
|
|
|
call Random
|
2013-05-07 04:58:35 +00:00
|
|
|
cp 20
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
; 38dfb
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_MeanLook: ; 38dfb
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckEnemyHalfHP
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nc, .asm_38e24
|
|
|
|
|
|
|
|
push hl
|
2013-05-07 04:58:35 +00:00
|
|
|
call AICheckLastPlayerMon
|
2013-05-05 23:56:17 +00:00
|
|
|
pop hl
|
2013-05-06 18:33:19 +00:00
|
|
|
jp z, AIDiscourageMove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
ld a, [EnemySubStatus5]
|
2013-05-07 04:58:35 +00:00
|
|
|
bit SUBSTATUS_TOXIC, a
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nz, .asm_38e26
|
|
|
|
|
|
|
|
ld a, [PlayerSubStatus1]
|
2014-06-17 19:52:32 +00:00
|
|
|
and 1<<SUBSTATUS_IN_LOVE | 1<<SUBSTATUS_ROLLOUT | 1<<SUBSTATUS_IDENTIFIED | 1<<SUBSTATUS_NIGHTMARE
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nz, .asm_38e26
|
|
|
|
|
|
|
|
push hl
|
2013-12-31 09:10:49 +00:00
|
|
|
callab Function3484e
|
2013-05-05 23:56:17 +00:00
|
|
|
ld a, [$c716]
|
|
|
|
cp $b
|
|
|
|
pop hl
|
|
|
|
ret nc
|
|
|
|
|
|
|
|
.asm_38e24
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38e26
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39521
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
; 38e2e
|
|
|
|
|
|
|
|
|
2013-05-07 04:58:35 +00:00
|
|
|
AICheckLastPlayerMon: ; 38e2e
|
2013-05-06 06:39:01 +00:00
|
|
|
ld a, [PartyCount]
|
|
|
|
ld b, a
|
|
|
|
ld c, 0
|
2014-02-23 05:37:09 +00:00
|
|
|
ld hl, PartyMon1HP
|
2013-05-06 06:39:01 +00:00
|
|
|
ld de, PartyMon2 - PartyMon1
|
|
|
|
|
|
|
|
.loop
|
|
|
|
ld a, [CurBattleMon]
|
|
|
|
cp c
|
|
|
|
jr z, .asm_38e44
|
|
|
|
|
|
|
|
ld a, [hli]
|
|
|
|
or [hl]
|
|
|
|
ret nz
|
|
|
|
dec hl
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2013-05-06 06:39:01 +00:00
|
|
|
.asm_38e44
|
|
|
|
add hl, de
|
|
|
|
inc c
|
|
|
|
dec b
|
|
|
|
jr nz, .loop
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2013-05-06 06:39:01 +00:00
|
|
|
ret
|
|
|
|
; 38e4a
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
AIScoring_Nightmare: ; 38e4a
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39527
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
; 38e50
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_FlameWheel: ; 38e50
|
|
|
|
ld a, [EnemyMonStatus]
|
2013-05-07 04:58:35 +00:00
|
|
|
bit FRZ, a
|
2013-05-05 23:56:17 +00:00
|
|
|
ret z
|
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
; 38e5c
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_Curse: ; 38e5c
|
|
|
|
ld a, [EnemyMonType1]
|
2013-05-07 04:58:35 +00:00
|
|
|
cp GHOST
|
|
|
|
jr z, .ghostcurse
|
2013-05-05 23:56:17 +00:00
|
|
|
ld a, [EnemyMonType2]
|
2013-05-07 04:58:35 +00:00
|
|
|
cp GHOST
|
|
|
|
jr z, .ghostcurse
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckEnemyHalfHP
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nc, .asm_38e93
|
|
|
|
|
|
|
|
ld a, [EnemyAtkLevel]
|
|
|
|
cp $b
|
|
|
|
jr nc, .asm_38e93
|
|
|
|
cp $9
|
|
|
|
ret nc
|
2013-05-07 04:58:35 +00:00
|
|
|
|
2013-05-05 23:56:17 +00:00
|
|
|
ld a, [BattleMonType1]
|
2013-05-07 04:58:35 +00:00
|
|
|
cp GHOST
|
2013-05-05 23:56:17 +00:00
|
|
|
jr z, .asm_38e92
|
2014-06-13 01:32:42 +00:00
|
|
|
cp SPECIAL
|
2013-05-05 23:56:17 +00:00
|
|
|
ret nc
|
|
|
|
ld a, [BattleMonType2]
|
2014-06-13 01:32:42 +00:00
|
|
|
cp SPECIAL
|
2013-05-05 23:56:17 +00:00
|
|
|
ret nc
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39521
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38e90
|
|
|
|
inc [hl]
|
|
|
|
inc [hl]
|
|
|
|
.asm_38e92
|
|
|
|
inc [hl]
|
|
|
|
.asm_38e93
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
2013-05-07 04:58:35 +00:00
|
|
|
.ghostcurse
|
2013-05-05 23:56:17 +00:00
|
|
|
ld a, [PlayerSubStatus1]
|
2013-05-07 04:58:35 +00:00
|
|
|
bit SUBSTATUS_CURSE, a
|
2013-05-06 18:33:19 +00:00
|
|
|
jp nz, AIDiscourageMove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
push hl
|
2013-12-31 09:10:49 +00:00
|
|
|
callba Function349f4
|
2013-05-05 23:56:17 +00:00
|
|
|
pop hl
|
|
|
|
jr nc, .asm_38eb0
|
|
|
|
|
|
|
|
push hl
|
2013-05-07 04:58:35 +00:00
|
|
|
call AICheckLastPlayerMon
|
2013-05-05 23:56:17 +00:00
|
|
|
pop hl
|
|
|
|
jr nz, .asm_38e90
|
|
|
|
|
|
|
|
jr .asm_38eb7
|
|
|
|
|
|
|
|
|
|
|
|
.asm_38eb0
|
|
|
|
push hl
|
2013-05-07 04:58:35 +00:00
|
|
|
call AICheckLastPlayerMon
|
2013-05-05 23:56:17 +00:00
|
|
|
pop hl
|
|
|
|
jr z, .asm_38ecb
|
|
|
|
|
|
|
|
|
|
|
|
.asm_38eb7
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckEnemyQuarterHP
|
2013-05-06 06:39:01 +00:00
|
|
|
jp nc, .asm_38e90
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckEnemyHalfHP
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nc, .asm_38e92
|
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckEnemyMaxHP
|
2013-05-05 23:56:17 +00:00
|
|
|
ret nc
|
2013-05-07 04:58:35 +00:00
|
|
|
|
2013-05-05 23:56:17 +00:00
|
|
|
ld a, [PlayerTurnsTaken]
|
|
|
|
and a
|
|
|
|
ret nz
|
|
|
|
|
|
|
|
.asm_38ecb
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39527
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
ret c
|
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
; 38ed2
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_Protect: ; 38ed2
|
|
|
|
ld a, [$c681]
|
|
|
|
and a
|
|
|
|
jr nz, .asm_38f13
|
|
|
|
|
|
|
|
ld a, [PlayerSubStatus5]
|
2013-05-07 04:58:35 +00:00
|
|
|
bit SUBSTATUS_LOCK_ON, a
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nz, .asm_38f14
|
|
|
|
|
|
|
|
ld a, [PlayerFuryCutterCount]
|
2013-05-07 04:58:35 +00:00
|
|
|
cp 3
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nc, .asm_38f0d
|
|
|
|
|
|
|
|
ld a, [PlayerSubStatus3]
|
2013-05-07 04:58:35 +00:00
|
|
|
bit SUBSTATUS_CHARGED, a
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nz, .asm_38f0d
|
|
|
|
|
|
|
|
ld a, [PlayerSubStatus5]
|
2013-05-07 04:58:35 +00:00
|
|
|
bit SUBSTATUS_TOXIC, a
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nz, .asm_38f0d
|
|
|
|
ld a, [PlayerSubStatus4]
|
2013-05-07 04:58:35 +00:00
|
|
|
bit SUBSTATUS_LEECH_SEED, a
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nz, .asm_38f0d
|
|
|
|
ld a, [PlayerSubStatus1]
|
2013-05-07 04:58:35 +00:00
|
|
|
bit SUBSTATUS_CURSE, a
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nz, .asm_38f0d
|
|
|
|
|
2014-06-17 19:52:32 +00:00
|
|
|
bit SUBSTATUS_ROLLOUT, a
|
2013-05-05 23:56:17 +00:00
|
|
|
jr z, .asm_38f14
|
|
|
|
|
|
|
|
ld a, [PlayerRolloutCount]
|
2013-05-07 04:58:35 +00:00
|
|
|
cp 3
|
2013-05-05 23:56:17 +00:00
|
|
|
jr c, .asm_38f14
|
|
|
|
|
|
|
|
.asm_38f0d
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39521
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38f13
|
|
|
|
inc [hl]
|
|
|
|
|
|
|
|
.asm_38f14
|
2013-08-31 02:59:40 +00:00
|
|
|
call Random
|
2013-05-07 04:58:35 +00:00
|
|
|
cp 20
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
|
|
|
inc [hl]
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
; 38f1d
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_Foresight: ; 38f1d
|
|
|
|
ld a, [EnemyAccLevel]
|
|
|
|
cp $5
|
|
|
|
jr c, .asm_38f41
|
|
|
|
ld a, [PlayerEvaLevel]
|
|
|
|
cp $a
|
|
|
|
jr nc, .asm_38f41
|
|
|
|
|
|
|
|
ld a, [BattleMonType1]
|
2013-05-07 04:58:35 +00:00
|
|
|
cp GHOST
|
2013-05-05 23:56:17 +00:00
|
|
|
jr z, .asm_38f41
|
|
|
|
ld a, [BattleMonType2]
|
2013-05-07 04:58:35 +00:00
|
|
|
cp GHOST
|
2013-05-05 23:56:17 +00:00
|
|
|
jr z, .asm_38f41
|
|
|
|
|
2013-08-31 02:59:40 +00:00
|
|
|
call Random
|
2013-05-07 04:58:35 +00:00
|
|
|
cp 20
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38f41
|
2013-08-31 02:59:40 +00:00
|
|
|
call Random
|
2013-05-07 04:58:35 +00:00
|
|
|
cp 100
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
; 38f4a
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_PerishSong: ; 38f4a
|
|
|
|
push hl
|
2013-12-31 09:10:49 +00:00
|
|
|
callab Function349f4
|
2013-05-05 23:56:17 +00:00
|
|
|
pop hl
|
|
|
|
jr c, .asm_38f75
|
|
|
|
|
|
|
|
ld a, [PlayerSubStatus5]
|
2014-06-17 19:52:32 +00:00
|
|
|
bit SUBSTATUS_CANT_RUN, a
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nz, .asm_38f6f
|
|
|
|
|
|
|
|
push hl
|
2013-12-31 09:10:49 +00:00
|
|
|
callab Function3484e
|
2013-05-05 23:56:17 +00:00
|
|
|
ld a, [$c716]
|
2013-05-07 04:58:35 +00:00
|
|
|
cp 10 ; 1.0
|
2013-05-05 23:56:17 +00:00
|
|
|
pop hl
|
|
|
|
ret c
|
|
|
|
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39527
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
2013-05-07 04:58:35 +00:00
|
|
|
|
2013-05-05 23:56:17 +00:00
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38f6f
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39527
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
2014-06-17 19:52:32 +00:00
|
|
|
|
2013-05-05 23:56:17 +00:00
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38f75
|
|
|
|
ld a, [hl]
|
2013-05-07 04:58:35 +00:00
|
|
|
add 5
|
2013-05-05 23:56:17 +00:00
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
; 38f7a
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_Sandstorm: ; 38f7a
|
|
|
|
ld a, [BattleMonType1]
|
|
|
|
push hl
|
2013-05-06 06:39:01 +00:00
|
|
|
ld hl, .SandstormImmuneTypes
|
|
|
|
ld de, 1
|
2013-05-05 23:56:17 +00:00
|
|
|
call IsInArray
|
|
|
|
pop hl
|
|
|
|
jr c, .asm_38fa5
|
|
|
|
|
|
|
|
ld a, [BattleMonType2]
|
|
|
|
push hl
|
2013-05-06 06:39:01 +00:00
|
|
|
ld hl, .SandstormImmuneTypes
|
|
|
|
ld de, 1
|
2013-05-05 23:56:17 +00:00
|
|
|
call IsInArray
|
|
|
|
pop hl
|
|
|
|
jr c, .asm_38fa5
|
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckPlayerHalfHP
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nc, .asm_38fa6
|
|
|
|
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39527
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
2013-05-06 06:39:01 +00:00
|
|
|
|
2013-05-05 23:56:17 +00:00
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38fa5
|
|
|
|
inc [hl]
|
|
|
|
|
|
|
|
.asm_38fa6
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
2013-05-06 06:39:01 +00:00
|
|
|
.SandstormImmuneTypes
|
|
|
|
db ROCK
|
|
|
|
db GROUND
|
|
|
|
db STEEL
|
|
|
|
db $ff
|
|
|
|
; 38fac
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
AIScoring_Endure: ; 38fac
|
|
|
|
ld a, [$c681]
|
|
|
|
and a
|
|
|
|
jr nz, .asm_38fd8
|
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckEnemyMaxHP
|
2013-05-05 23:56:17 +00:00
|
|
|
jr c, .asm_38fd8
|
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckEnemyQuarterHP
|
2013-05-05 23:56:17 +00:00
|
|
|
jr c, .asm_38fd9
|
|
|
|
|
2013-05-07 04:58:35 +00:00
|
|
|
ld b, EFFECT_REVERSAL
|
|
|
|
call AIHasMove
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nc, .asm_38fcb
|
|
|
|
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39521
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
2013-05-07 04:58:35 +00:00
|
|
|
|
2013-05-05 23:56:17 +00:00
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38fcb
|
|
|
|
ld a, [EnemySubStatus5]
|
2013-05-07 04:58:35 +00:00
|
|
|
bit SUBSTATUS_LOCK_ON, a
|
2013-05-05 23:56:17 +00:00
|
|
|
ret z
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39527
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
ret c
|
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38fd8
|
|
|
|
inc [hl]
|
|
|
|
|
|
|
|
.asm_38fd9
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
; 38fdb
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_FuryCutter: ; 38fdb
|
|
|
|
ld a, [EnemyFuryCutterCount]
|
|
|
|
and a
|
2013-05-07 04:58:35 +00:00
|
|
|
jr z, .end
|
2013-05-05 23:56:17 +00:00
|
|
|
dec [hl]
|
|
|
|
|
2013-05-07 04:58:35 +00:00
|
|
|
cp 2
|
|
|
|
jr c, .end
|
2013-05-05 23:56:17 +00:00
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
|
2013-05-07 04:58:35 +00:00
|
|
|
cp 3
|
|
|
|
jr c, .end
|
2013-05-05 23:56:17 +00:00
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
|
2013-05-07 04:58:35 +00:00
|
|
|
.end
|
|
|
|
|
2013-05-05 23:56:17 +00:00
|
|
|
; fallthrough
|
|
|
|
; 38fef
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_Rollout: ; 38fef
|
|
|
|
ld a, [EnemySubStatus1]
|
2013-05-07 04:58:35 +00:00
|
|
|
bit SUBSTATUS_IN_LOVE, a
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nz, .asm_39020
|
|
|
|
|
|
|
|
ld a, [EnemySubStatus3]
|
2013-05-07 04:58:35 +00:00
|
|
|
bit SUBSTATUS_CONFUSED, a
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nz, .asm_39020
|
|
|
|
|
|
|
|
ld a, [EnemyMonStatus]
|
2013-05-07 04:58:35 +00:00
|
|
|
bit PAR, a
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nz, .asm_39020
|
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckEnemyQuarterHP
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nc, .asm_39020
|
|
|
|
|
|
|
|
ld a, [EnemyAccLevel]
|
2013-05-07 04:58:35 +00:00
|
|
|
cp 7
|
2013-05-05 23:56:17 +00:00
|
|
|
jr c, .asm_39020
|
|
|
|
ld a, [PlayerEvaLevel]
|
2013-05-07 04:58:35 +00:00
|
|
|
cp 8
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nc, .asm_39020
|
|
|
|
|
2013-08-31 02:59:40 +00:00
|
|
|
call Random
|
2013-05-07 04:58:35 +00:00
|
|
|
cp 200
|
2013-05-05 23:56:17 +00:00
|
|
|
ret nc
|
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_39020
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39521
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
; 39026
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_Swagger:
|
|
|
|
AIScoring_Attract: ; 39026
|
|
|
|
ld a, [PlayerTurnsTaken]
|
|
|
|
and a
|
2014-06-17 19:52:32 +00:00
|
|
|
jr z, .first_turn
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39521
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
2014-06-17 19:52:32 +00:00
|
|
|
.first_turn
|
2013-08-31 02:59:40 +00:00
|
|
|
call Random
|
2013-05-07 04:58:35 +00:00
|
|
|
cp 200
|
2013-05-05 23:56:17 +00:00
|
|
|
ret nc
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
; 3903a
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_Safeguard: ; 3903a
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckPlayerHalfHP
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39521
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
; 39044
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_Magnitude:
|
|
|
|
AIScoring_Earthquake: ; 39044
|
|
|
|
ld a, [LastEnemyCounterMove]
|
2013-05-07 04:58:35 +00:00
|
|
|
cp DIG
|
2013-05-05 23:56:17 +00:00
|
|
|
ret nz
|
2013-05-07 04:58:35 +00:00
|
|
|
|
2013-05-05 23:56:17 +00:00
|
|
|
ld a, [PlayerSubStatus3]
|
2013-05-07 04:58:35 +00:00
|
|
|
bit SUBSTATUS_UNDERGROUND, a
|
2014-06-17 19:52:32 +00:00
|
|
|
jr z, .could_dig
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2013-05-07 00:51:07 +00:00
|
|
|
call AICompareSpeed
|
2013-05-05 23:56:17 +00:00
|
|
|
ret nc
|
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
2014-06-17 19:52:32 +00:00
|
|
|
.could_dig
|
|
|
|
; Try to predict if the player
|
|
|
|
; will use Dig this turn.
|
2013-05-07 00:51:07 +00:00
|
|
|
call AICompareSpeed
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39527
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
; 39062
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_BatonPass: ; 39062
|
|
|
|
push hl
|
2013-12-31 09:10:49 +00:00
|
|
|
callab Function3484e
|
2013-05-05 23:56:17 +00:00
|
|
|
ld a, [$c716]
|
2013-05-07 04:58:35 +00:00
|
|
|
cp 10 ; 1.0
|
2013-05-05 23:56:17 +00:00
|
|
|
pop hl
|
|
|
|
ret c
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
; 39072
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_Pursuit: ; 39072
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckPlayerQuarterHP
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nc, .asm_3907d
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39521
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_3907d
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39527
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
; 39084
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_RapidSpin: ; 39084
|
|
|
|
ld a, [$c731]
|
|
|
|
and a
|
|
|
|
jr nz, .asm_39097
|
|
|
|
|
|
|
|
ld a, [EnemySubStatus4]
|
2013-05-07 04:58:35 +00:00
|
|
|
bit SUBSTATUS_LEECH_SEED, a
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nz, .asm_39097
|
|
|
|
|
|
|
|
ld a, [EnemyScreens]
|
2013-05-07 04:58:35 +00:00
|
|
|
bit SCREENS_SPIKES, a
|
2013-05-05 23:56:17 +00:00
|
|
|
ret z
|
|
|
|
|
|
|
|
.asm_39097
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39521
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
ret c
|
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
; 3909e
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_HiddenPower: ; 3909e
|
|
|
|
push hl
|
2013-05-07 04:58:35 +00:00
|
|
|
ld a, 1
|
2013-05-05 23:56:17 +00:00
|
|
|
ld [hBattleTurn], a
|
2014-10-21 18:44:42 +00:00
|
|
|
|
|
|
|
; Calculate Hidden Power's type and base power based on enemy's DVs.
|
2014-05-05 07:30:51 +00:00
|
|
|
callab HiddenPowerDamage
|
2013-12-31 09:10:49 +00:00
|
|
|
callab Function347c8
|
2013-05-05 23:56:17 +00:00
|
|
|
pop hl
|
2013-05-07 04:58:35 +00:00
|
|
|
|
2014-10-21 18:44:42 +00:00
|
|
|
; Discourage Hidden Power if not very effective.
|
2013-05-05 23:56:17 +00:00
|
|
|
ld a, [$d265]
|
|
|
|
cp $a
|
|
|
|
jr c, .asm_390c9
|
2014-10-21 18:44:42 +00:00
|
|
|
|
|
|
|
; Discourage Hidden Power if its base power is lower than 50.
|
2013-05-05 23:56:17 +00:00
|
|
|
ld a, d
|
2014-06-17 19:52:32 +00:00
|
|
|
cp 50
|
2013-05-05 23:56:17 +00:00
|
|
|
jr c, .asm_390c9
|
2014-10-21 18:44:42 +00:00
|
|
|
|
|
|
|
; Encourage Hidden Power if super-effective.
|
2013-05-05 23:56:17 +00:00
|
|
|
ld a, [$d265]
|
|
|
|
cp $b
|
|
|
|
jr nc, .asm_390c7
|
2014-10-21 18:44:42 +00:00
|
|
|
|
|
|
|
; Encourage Hidden Power if its base power is 70.
|
2013-05-05 23:56:17 +00:00
|
|
|
ld a, d
|
2014-10-21 18:44:42 +00:00
|
|
|
cp 70
|
|
|
|
|
|
|
|
; Do nothing if none of these conditions meet.
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
|
|
|
|
|
|
|
.asm_390c7
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_390c9
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
; 390cb
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_RainDance: ; 390cb
|
|
|
|
ld a, [BattleMonType1]
|
2013-05-06 06:39:01 +00:00
|
|
|
cp WATER
|
2013-05-07 04:58:35 +00:00
|
|
|
jr z, AIBadWeatherType
|
2013-05-06 06:39:01 +00:00
|
|
|
cp FIRE
|
2013-05-07 04:58:35 +00:00
|
|
|
jr z, AIGoodWeatherType
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
ld a, [BattleMonType2]
|
2013-05-06 06:39:01 +00:00
|
|
|
cp WATER
|
2013-05-07 04:58:35 +00:00
|
|
|
jr z, AIBadWeatherType
|
2013-05-06 06:39:01 +00:00
|
|
|
cp FIRE
|
2013-05-07 04:58:35 +00:00
|
|
|
jr z, AIGoodWeatherType
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
push hl
|
2013-05-06 06:39:01 +00:00
|
|
|
ld hl, RainDanceMoves
|
2013-05-07 04:58:35 +00:00
|
|
|
jr AIScoring_WeatherMove
|
2013-05-05 23:56:17 +00:00
|
|
|
; 390e7
|
|
|
|
|
2013-05-06 06:39:01 +00:00
|
|
|
RainDanceMoves: ; 390e7
|
|
|
|
db WATER_GUN
|
|
|
|
db HYDRO_PUMP
|
|
|
|
db SURF
|
|
|
|
db BUBBLEBEAM
|
|
|
|
db THUNDER
|
|
|
|
db WATERFALL
|
|
|
|
db CLAMP
|
|
|
|
db BUBBLE
|
|
|
|
db CRABHAMMER
|
|
|
|
db OCTAZOOKA
|
|
|
|
db WHIRLPOOL
|
|
|
|
db $ff
|
|
|
|
; 390f3
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
AIScoring_SunnyDay: ; 390f3
|
|
|
|
ld a, [BattleMonType1]
|
2013-05-06 06:39:01 +00:00
|
|
|
cp FIRE
|
2013-05-07 04:58:35 +00:00
|
|
|
jr z, AIBadWeatherType
|
2013-05-06 06:39:01 +00:00
|
|
|
cp WATER
|
2013-05-07 04:58:35 +00:00
|
|
|
jr z, AIGoodWeatherType
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
ld a, [BattleMonType2]
|
2013-05-06 06:39:01 +00:00
|
|
|
cp FIRE
|
2013-05-07 04:58:35 +00:00
|
|
|
jr z, AIBadWeatherType
|
2013-05-06 06:39:01 +00:00
|
|
|
cp WATER
|
2013-05-07 04:58:35 +00:00
|
|
|
jr z, AIGoodWeatherType
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
push hl
|
2013-05-06 06:39:01 +00:00
|
|
|
ld hl, SunnyDayMoves
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
; fallthrough
|
|
|
|
; 3910d
|
|
|
|
|
|
|
|
|
2013-05-07 04:58:35 +00:00
|
|
|
AIScoring_WeatherMove: ; 3910d
|
|
|
|
call AIHasMoveInArray
|
2013-05-05 23:56:17 +00:00
|
|
|
pop hl
|
2013-05-07 04:58:35 +00:00
|
|
|
jr nc, AIBadWeatherType
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckPlayerHalfHP
|
2013-05-07 04:58:35 +00:00
|
|
|
jr nc, AIBadWeatherType
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39527
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
2013-05-06 06:39:01 +00:00
|
|
|
|
2013-05-05 23:56:17 +00:00
|
|
|
dec [hl]
|
|
|
|
ret
|
2013-05-07 04:58:35 +00:00
|
|
|
; 3911e
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2013-05-07 04:58:35 +00:00
|
|
|
AIBadWeatherType: ; 3911e
|
2013-05-05 23:56:17 +00:00
|
|
|
inc [hl]
|
|
|
|
inc [hl]
|
|
|
|
inc [hl]
|
|
|
|
ret
|
2013-05-07 04:58:35 +00:00
|
|
|
; 39122
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2013-05-07 04:58:35 +00:00
|
|
|
AIGoodWeatherType: ; 39122
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckPlayerHalfHP
|
2013-05-05 23:56:17 +00:00
|
|
|
ret nc
|
2013-05-06 06:39:01 +00:00
|
|
|
|
2013-05-05 23:56:17 +00:00
|
|
|
ld a, [PlayerTurnsTaken]
|
|
|
|
and a
|
2013-05-07 04:58:35 +00:00
|
|
|
jr z, .good
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
ld a, [EnemyTurnsTaken]
|
|
|
|
and a
|
|
|
|
ret nz
|
|
|
|
|
2013-05-07 04:58:35 +00:00
|
|
|
.good
|
2013-05-05 23:56:17 +00:00
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
; 39134
|
|
|
|
|
|
|
|
|
2013-05-06 06:39:01 +00:00
|
|
|
SunnyDayMoves: ; 39134
|
|
|
|
db FIRE_PUNCH
|
|
|
|
db EMBER
|
|
|
|
db FLAMETHROWER
|
|
|
|
db FIRE_SPIN
|
|
|
|
db FIRE_BLAST
|
|
|
|
db SACRED_FIRE
|
|
|
|
db MORNING_SUN
|
|
|
|
db SYNTHESIS
|
|
|
|
db $ff
|
|
|
|
; 3913d
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
AIScoring_BellyDrum: ; 3913d
|
|
|
|
ld a, [EnemyAtkLevel]
|
|
|
|
cp $a
|
|
|
|
jr nc, .asm_3914d
|
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckEnemyMaxHP
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
ret c
|
|
|
|
inc [hl]
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckEnemyHalfHP
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
ret c
|
|
|
|
|
|
|
|
.asm_3914d
|
|
|
|
ld a, [hl]
|
|
|
|
add $5
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
; 39152
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_PsychUp: ; 39152
|
|
|
|
push hl
|
|
|
|
ld hl, EnemyAtkLevel
|
|
|
|
ld b, $8
|
|
|
|
ld c, $64
|
|
|
|
|
|
|
|
.asm_3915a
|
|
|
|
ld a, [hli]
|
|
|
|
sub $7
|
|
|
|
add c
|
|
|
|
ld c, a
|
|
|
|
dec b
|
|
|
|
jr nz, .asm_3915a
|
|
|
|
|
|
|
|
ld hl, PlayerAtkLevel
|
|
|
|
ld b, $8
|
|
|
|
ld d, $64
|
|
|
|
|
|
|
|
.asm_39169
|
|
|
|
ld a, [hli]
|
|
|
|
sub $7
|
|
|
|
add d
|
|
|
|
ld d, a
|
|
|
|
dec b
|
|
|
|
jr nz, .asm_39169
|
|
|
|
|
|
|
|
ld a, c
|
|
|
|
sub d
|
|
|
|
pop hl
|
|
|
|
jr nc, .asm_39188
|
|
|
|
|
|
|
|
ld a, [PlayerAccLevel]
|
|
|
|
cp $6
|
|
|
|
ret c
|
|
|
|
ld a, [EnemyEvaLevel]
|
|
|
|
cp $8
|
|
|
|
ret nc
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39521
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
ret c
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_39188
|
|
|
|
inc [hl]
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
; 3918b
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_MirrorCoat: ; 3918b
|
|
|
|
push hl
|
|
|
|
ld hl, PlayerUsedMoves
|
|
|
|
ld c, $4
|
|
|
|
ld b, $0
|
|
|
|
|
|
|
|
.asm_39193
|
|
|
|
ld a, [hli]
|
|
|
|
and a
|
|
|
|
jr z, .asm_391a8
|
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
call AIGetEnemyMove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2014-06-13 01:32:42 +00:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_POWER]
|
2013-05-05 23:56:17 +00:00
|
|
|
and a
|
|
|
|
jr z, .asm_391a8
|
|
|
|
|
2014-06-13 01:32:42 +00:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_TYPE]
|
|
|
|
cp SPECIAL
|
2013-05-05 23:56:17 +00:00
|
|
|
jr c, .asm_391a8
|
|
|
|
|
|
|
|
inc b
|
|
|
|
|
|
|
|
.asm_391a8
|
|
|
|
dec c
|
|
|
|
jr nz, .asm_39193
|
|
|
|
|
|
|
|
pop hl
|
|
|
|
ld a, b
|
|
|
|
and a
|
|
|
|
jr z, .asm_391d3
|
|
|
|
|
|
|
|
cp $3
|
|
|
|
jr nc, .asm_391ca
|
|
|
|
|
|
|
|
ld a, [LastEnemyCounterMove]
|
|
|
|
and a
|
|
|
|
jr z, .asm_391d2
|
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
call AIGetEnemyMove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2014-06-13 01:32:42 +00:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_POWER]
|
2013-05-05 23:56:17 +00:00
|
|
|
and a
|
|
|
|
jr z, .asm_391d2
|
|
|
|
|
2014-06-13 01:32:42 +00:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_TYPE]
|
|
|
|
cp SPECIAL
|
2013-05-05 23:56:17 +00:00
|
|
|
jr c, .asm_391d2
|
|
|
|
|
|
|
|
|
|
|
|
.asm_391ca
|
2013-08-31 02:59:40 +00:00
|
|
|
call Random
|
2013-05-07 04:58:35 +00:00
|
|
|
cp 100
|
2013-05-05 23:56:17 +00:00
|
|
|
jr c, .asm_391d2
|
|
|
|
dec [hl]
|
|
|
|
|
|
|
|
.asm_391d2
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_391d3
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
; 391d5
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_Twister:
|
|
|
|
AIScoring_Gust: ; 391d5
|
|
|
|
ld a, [LastEnemyCounterMove]
|
2013-05-07 04:58:35 +00:00
|
|
|
cp FLY
|
2013-05-05 23:56:17 +00:00
|
|
|
ret nz
|
2013-05-07 04:58:35 +00:00
|
|
|
|
2013-05-05 23:56:17 +00:00
|
|
|
ld a, [PlayerSubStatus3]
|
2013-05-07 04:58:35 +00:00
|
|
|
bit SUBSTATUS_FLYING, a
|
2013-05-05 23:56:17 +00:00
|
|
|
jr z, .asm_391e9
|
|
|
|
|
2013-05-07 00:51:07 +00:00
|
|
|
call AICompareSpeed
|
2013-05-05 23:56:17 +00:00
|
|
|
ret nc
|
2013-05-07 04:58:35 +00:00
|
|
|
|
2013-05-05 23:56:17 +00:00
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_391e9
|
2013-05-07 00:51:07 +00:00
|
|
|
call AICompareSpeed
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39527
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
; 391f3
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_FutureSight: ; 391f3
|
2013-05-07 00:51:07 +00:00
|
|
|
call AICompareSpeed
|
2013-05-05 23:56:17 +00:00
|
|
|
ret nc
|
2013-05-07 04:58:35 +00:00
|
|
|
|
2013-05-05 23:56:17 +00:00
|
|
|
ld a, [PlayerSubStatus3]
|
2014-05-05 07:30:51 +00:00
|
|
|
and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND
|
2013-05-05 23:56:17 +00:00
|
|
|
ret z
|
2013-05-07 04:58:35 +00:00
|
|
|
|
2013-05-05 23:56:17 +00:00
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
; 39200
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_Stomp: ; 39200
|
|
|
|
ld a, [$c6fe]
|
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39521
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
2013-05-07 04:58:35 +00:00
|
|
|
|
2013-05-05 23:56:17 +00:00
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
; 3920b
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_Solarbeam: ; 3920b
|
|
|
|
ld a, [Weather]
|
2013-05-06 06:39:01 +00:00
|
|
|
cp WEATHER_SUN
|
2013-05-05 23:56:17 +00:00
|
|
|
jr z, .asm_3921e
|
|
|
|
|
2013-05-06 06:39:01 +00:00
|
|
|
cp WEATHER_RAIN
|
2013-05-05 23:56:17 +00:00
|
|
|
ret nz
|
|
|
|
|
2013-08-31 02:59:40 +00:00
|
|
|
call Random
|
2013-05-06 06:39:01 +00:00
|
|
|
cp 25 ; 1/10
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
2013-05-06 06:39:01 +00:00
|
|
|
|
2013-05-05 23:56:17 +00:00
|
|
|
inc [hl]
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_3921e
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39521
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
2013-05-06 06:39:01 +00:00
|
|
|
|
2013-05-05 23:56:17 +00:00
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
; 39225
|
|
|
|
|
|
|
|
|
|
|
|
AIScoring_Thunder: ; 39225
|
2014-10-21 22:28:51 +00:00
|
|
|
; 90% chance to discourage this move when it's raining.
|
|
|
|
|
2013-05-05 23:56:17 +00:00
|
|
|
ld a, [Weather]
|
2013-05-06 06:39:01 +00:00
|
|
|
cp WEATHER_SUN
|
2013-05-05 23:56:17 +00:00
|
|
|
ret nz
|
|
|
|
|
2013-08-31 02:59:40 +00:00
|
|
|
call Random
|
2013-05-06 06:39:01 +00:00
|
|
|
cp 25 ; 1/10
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
2013-05-06 06:39:01 +00:00
|
|
|
|
2013-05-05 23:56:17 +00:00
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
; 39233
|
|
|
|
|
|
|
|
|
2013-05-07 00:51:07 +00:00
|
|
|
AICompareSpeed: ; 39233
|
2014-10-21 22:28:51 +00:00
|
|
|
; Return carry if enemy is faster than player
|
|
|
|
|
2013-05-06 06:39:01 +00:00
|
|
|
push bc
|
2014-06-13 01:32:42 +00:00
|
|
|
ld a, [EnemyMonSpeed + 1]
|
2013-05-06 06:39:01 +00:00
|
|
|
ld b, a
|
2014-06-13 01:32:42 +00:00
|
|
|
ld a, [BattleMonSpeed + 1]
|
2013-05-06 06:39:01 +00:00
|
|
|
cp b
|
2014-06-13 01:32:42 +00:00
|
|
|
ld a, [EnemyMonSpeed]
|
2013-05-06 06:39:01 +00:00
|
|
|
ld b, a
|
2014-06-13 01:32:42 +00:00
|
|
|
ld a, [BattleMonSpeed]
|
2013-05-06 06:39:01 +00:00
|
|
|
sbc b
|
|
|
|
pop bc
|
|
|
|
ret
|
|
|
|
; 39246
|
|
|
|
|
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
AICheckPlayerMaxHP: ; 39246
|
2013-05-06 06:39:01 +00:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
|
|
|
ld de, BattleMonHP
|
|
|
|
ld hl, BattleMonMaxHP
|
2013-05-06 18:33:19 +00:00
|
|
|
jr AICheckMaxHP
|
2013-05-06 06:39:01 +00:00
|
|
|
; 39251
|
|
|
|
|
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
AICheckEnemyMaxHP: ; 39251
|
2013-05-06 06:39:01 +00:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2014-06-13 01:32:42 +00:00
|
|
|
ld de, EnemyMonHP
|
|
|
|
ld hl, EnemyMonMaxHP
|
2013-05-06 06:39:01 +00:00
|
|
|
; fallthrough
|
|
|
|
; 3925a
|
|
|
|
|
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
AICheckMaxHP: ; 3925a
|
|
|
|
; Return carry if hp at de matches max hp at hl.
|
2014-10-21 18:44:42 +00:00
|
|
|
|
2013-05-06 06:39:01 +00:00
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
cp [hl]
|
|
|
|
jr nz, .asm_39269
|
|
|
|
|
|
|
|
inc hl
|
|
|
|
ld a, [de]
|
|
|
|
cp [hl]
|
|
|
|
jr nz, .asm_39269
|
|
|
|
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_39269
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
; 3926e
|
|
|
|
|
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
AICheckPlayerHalfHP: ; 3926e
|
2013-05-06 06:39:01 +00:00
|
|
|
push hl
|
|
|
|
ld hl, BattleMonHP
|
|
|
|
ld b, [hl]
|
|
|
|
inc hl
|
|
|
|
ld c, [hl]
|
|
|
|
sla c
|
|
|
|
rl b
|
|
|
|
inc hl
|
|
|
|
inc hl
|
|
|
|
ld a, [hld]
|
|
|
|
cp c
|
|
|
|
ld a, [hl]
|
|
|
|
sbc b
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
; 39281
|
|
|
|
|
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
AICheckEnemyHalfHP: ; 39281
|
2013-05-06 06:39:01 +00:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2014-06-13 01:32:42 +00:00
|
|
|
ld hl, EnemyMonHP
|
2013-05-06 06:39:01 +00:00
|
|
|
ld b, [hl]
|
|
|
|
inc hl
|
|
|
|
ld c, [hl]
|
|
|
|
sla c
|
|
|
|
rl b
|
|
|
|
inc hl
|
|
|
|
inc hl
|
|
|
|
ld a, [hld]
|
|
|
|
cp c
|
|
|
|
ld a, [hl]
|
|
|
|
sbc b
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
; 39298
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
AICheckEnemyQuarterHP: ; 39298
|
2013-05-06 06:39:01 +00:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2014-06-13 01:32:42 +00:00
|
|
|
ld hl, EnemyMonHP
|
2013-05-06 06:39:01 +00:00
|
|
|
ld b, [hl]
|
|
|
|
inc hl
|
|
|
|
ld c, [hl]
|
|
|
|
sla c
|
|
|
|
rl b
|
|
|
|
sla c
|
|
|
|
rl b
|
|
|
|
inc hl
|
|
|
|
inc hl
|
|
|
|
ld a, [hld]
|
|
|
|
cp c
|
|
|
|
ld a, [hl]
|
|
|
|
sbc b
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
; 392b3
|
|
|
|
|
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
AICheckPlayerQuarterHP: ; 392b3
|
2013-05-06 06:39:01 +00:00
|
|
|
push hl
|
|
|
|
ld hl, BattleMonHP
|
|
|
|
ld b, [hl]
|
|
|
|
inc hl
|
|
|
|
ld c, [hl]
|
|
|
|
sla c
|
|
|
|
rl b
|
|
|
|
sla c
|
|
|
|
rl b
|
|
|
|
inc hl
|
|
|
|
inc hl
|
|
|
|
ld a, [hld]
|
|
|
|
cp c
|
|
|
|
ld a, [hl]
|
|
|
|
sbc b
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
; 392ca
|
|
|
|
|
|
|
|
|
2013-05-07 04:58:35 +00:00
|
|
|
AIHasMove: ; 392ca
|
|
|
|
; Return carry if the enemy has move b.
|
2014-10-21 18:44:42 +00:00
|
|
|
|
2013-05-06 06:39:01 +00:00
|
|
|
push hl
|
|
|
|
ld hl, EnemyMonMoves
|
|
|
|
ld c, EnemyMonMovesEnd - EnemyMonMoves
|
|
|
|
|
2013-05-07 04:58:35 +00:00
|
|
|
.checkmove
|
2013-05-06 06:39:01 +00:00
|
|
|
ld a, [hli]
|
|
|
|
and a
|
|
|
|
jr z, .asm_392e0
|
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
call AIGetEnemyMove
|
2013-05-06 06:39:01 +00:00
|
|
|
|
2014-06-13 01:32:42 +00:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_EFFECT]
|
2013-05-06 06:39:01 +00:00
|
|
|
cp b
|
|
|
|
jr z, .asm_392e3
|
|
|
|
|
|
|
|
dec c
|
2013-05-07 04:58:35 +00:00
|
|
|
jr nz, .checkmove
|
2013-05-06 06:39:01 +00:00
|
|
|
|
|
|
|
.asm_392e0
|
|
|
|
pop hl
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_392e3
|
|
|
|
pop hl
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
; 392e6
|
|
|
|
|
|
|
|
|
2013-05-07 04:58:35 +00:00
|
|
|
AIHasMoveInArray: ; 392e6
|
|
|
|
; Return carry if the enemy has a move in array hl.
|
|
|
|
|
2013-05-06 06:39:01 +00:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
|
|
|
|
|
|
|
.asm_392e9
|
|
|
|
ld a, [hli]
|
|
|
|
cp $ff
|
|
|
|
jr z, .asm_392fd
|
|
|
|
|
|
|
|
ld b, a
|
|
|
|
ld c, EnemyMonMovesEnd - EnemyMonMoves + 1
|
|
|
|
ld de, EnemyMonMoves
|
|
|
|
|
|
|
|
.asm_392f4
|
|
|
|
dec c
|
|
|
|
jr z, .asm_392e9
|
|
|
|
|
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
cp b
|
|
|
|
jr nz, .asm_392f4
|
|
|
|
|
|
|
|
scf
|
|
|
|
|
|
|
|
.asm_392fd
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
; 39301
|
|
|
|
|
|
|
|
|
2014-10-21 22:28:51 +00:00
|
|
|
UsefulMoves: ; 39301
|
2013-05-06 06:39:01 +00:00
|
|
|
db DOUBLE_EDGE
|
|
|
|
db SING
|
|
|
|
db FLAMETHROWER
|
|
|
|
db HYDRO_PUMP
|
|
|
|
db SURF
|
|
|
|
db ICE_BEAM
|
|
|
|
db BLIZZARD
|
|
|
|
db HYPER_BEAM
|
|
|
|
db SLEEP_POWDER
|
|
|
|
db THUNDERBOLT
|
|
|
|
db THUNDER
|
|
|
|
db EARTHQUAKE
|
|
|
|
db TOXIC
|
|
|
|
db PSYCHIC_M
|
|
|
|
db HYPNOSIS
|
|
|
|
db RECOVER
|
|
|
|
db FIRE_BLAST
|
|
|
|
db SOFTBOILED
|
|
|
|
db SUPER_FANG
|
|
|
|
db $ff
|
|
|
|
; 39315
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
AIScoring_Opportunist: ; 39315
|
2014-10-21 18:44:42 +00:00
|
|
|
; Discourage stall moves when the enemy's HP is low.
|
2013-05-06 18:33:19 +00:00
|
|
|
|
2014-10-21 18:44:42 +00:00
|
|
|
; Do nothing if enemy's HP is above 50%.
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckEnemyHalfHP
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
|
|
|
|
2014-10-21 18:44:42 +00:00
|
|
|
; Discourage stall moves if enemy's HP is below 25%.
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckEnemyQuarterHP
|
2013-05-05 23:56:17 +00:00
|
|
|
jr nc, .asm_39322
|
2014-10-21 18:44:42 +00:00
|
|
|
|
|
|
|
; 50% chance to discourage stall moves if enemy's HP is between 25% and 50%.
|
2014-06-13 01:32:42 +00:00
|
|
|
call Function39527
|
2013-05-05 23:56:17 +00:00
|
|
|
ret c
|
|
|
|
|
|
|
|
.asm_39322
|
|
|
|
ld hl, Buffer1 - 1
|
|
|
|
ld de, EnemyMonMoves
|
|
|
|
ld c, EnemyMonMovesEnd - EnemyMonMoves + 1
|
2013-05-06 18:33:19 +00:00
|
|
|
.checkmove
|
2013-05-05 23:56:17 +00:00
|
|
|
inc hl
|
|
|
|
dec c
|
|
|
|
jr z, .asm_39347
|
|
|
|
|
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
and a
|
|
|
|
jr z, .asm_39347
|
|
|
|
|
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2013-05-06 18:33:19 +00:00
|
|
|
ld hl, .stallmoves
|
2013-05-05 23:56:17 +00:00
|
|
|
ld de, 1
|
|
|
|
call IsInArray
|
|
|
|
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
2013-05-06 18:33:19 +00:00
|
|
|
jr nc, .checkmove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
inc [hl]
|
2013-05-06 18:33:19 +00:00
|
|
|
jr .checkmove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
.asm_39347
|
|
|
|
ret
|
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
.stallmoves
|
2013-05-05 23:56:17 +00:00
|
|
|
db SWORDS_DANCE
|
|
|
|
db TAIL_WHIP
|
|
|
|
db LEER
|
|
|
|
db GROWL
|
|
|
|
db DISABLE
|
|
|
|
db MIST
|
|
|
|
db COUNTER
|
|
|
|
db LEECH_SEED
|
|
|
|
db GROWTH
|
|
|
|
db STRING_SHOT
|
|
|
|
db MEDITATE
|
|
|
|
db AGILITY
|
|
|
|
db RAGE
|
|
|
|
db MIMIC
|
|
|
|
db SCREECH
|
|
|
|
db HARDEN
|
|
|
|
db WITHDRAW
|
|
|
|
db DEFENSE_CURL
|
|
|
|
db BARRIER
|
|
|
|
db LIGHT_SCREEN
|
|
|
|
db HAZE
|
|
|
|
db REFLECT
|
|
|
|
db FOCUS_ENERGY
|
|
|
|
db BIDE
|
|
|
|
db AMNESIA
|
|
|
|
db TRANSFORM
|
|
|
|
db SPLASH
|
|
|
|
db ACID_ARMOR
|
|
|
|
db SHARPEN
|
|
|
|
db CONVERSION
|
|
|
|
db SUBSTITUTE
|
|
|
|
db FLAME_WHEEL
|
|
|
|
db $ff
|
|
|
|
; 39369
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
AIScoring_Aggressive: ; 39369
|
2014-10-21 17:21:13 +00:00
|
|
|
; Discourage all damaging moves but the one that does the most damage.
|
|
|
|
; If no damaging move deals damage to the player (immune),
|
|
|
|
; no move will be discouraged
|
2013-05-06 18:33:19 +00:00
|
|
|
|
|
|
|
; Figure out which attack does the most damage and put it in c.
|
2013-05-05 23:56:17 +00:00
|
|
|
ld hl, EnemyMonMoves
|
|
|
|
ld bc, 0
|
|
|
|
ld de, 0
|
2013-05-06 18:33:19 +00:00
|
|
|
.checkmove
|
2013-05-05 23:56:17 +00:00
|
|
|
inc b
|
|
|
|
ld a, b
|
|
|
|
cp EnemyMonMovesEnd - EnemyMonMoves + 1
|
2013-05-06 18:33:19 +00:00
|
|
|
jr z, .gotstrongestmove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
ld a, [hli]
|
|
|
|
and a
|
2013-05-06 18:33:19 +00:00
|
|
|
jr z, .gotstrongestmove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2013-05-06 18:33:19 +00:00
|
|
|
call AIGetEnemyMove
|
2014-06-13 01:32:42 +00:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_POWER]
|
2013-05-05 23:56:17 +00:00
|
|
|
and a
|
2013-05-06 18:33:19 +00:00
|
|
|
jr z, .nodamage
|
|
|
|
call AIDamageCalc
|
2013-05-05 23:56:17 +00:00
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
2013-05-06 18:33:19 +00:00
|
|
|
|
2014-10-21 17:21:13 +00:00
|
|
|
; Update current move if damage is highest so far
|
2013-05-05 23:56:17 +00:00
|
|
|
ld a, [CurDamage + 1]
|
|
|
|
cp e
|
|
|
|
ld a, [CurDamage]
|
|
|
|
sbc d
|
2013-05-06 18:33:19 +00:00
|
|
|
jr c, .checkmove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
ld a, [CurDamage + 1]
|
|
|
|
ld e, a
|
|
|
|
ld a, [CurDamage]
|
|
|
|
ld d, a
|
|
|
|
ld c, b
|
2013-05-06 18:33:19 +00:00
|
|
|
jr .checkmove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
.nodamage
|
2013-05-05 23:56:17 +00:00
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
2013-05-06 18:33:19 +00:00
|
|
|
jr .checkmove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
.gotstrongestmove
|
2014-10-21 22:28:51 +00:00
|
|
|
; Discourage moves that do less damage unless they're reckless too.
|
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
; Nothing we can do if no attacks did damage.
|
2013-05-05 23:56:17 +00:00
|
|
|
ld a, c
|
|
|
|
and a
|
2013-05-06 18:33:19 +00:00
|
|
|
jr z, .done
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
ld hl, Buffer1 - 1
|
|
|
|
ld de, EnemyMonMoves
|
2013-05-06 06:39:01 +00:00
|
|
|
ld b, 0
|
2013-05-06 18:33:19 +00:00
|
|
|
.checkmove2
|
2013-05-05 23:56:17 +00:00
|
|
|
inc b
|
|
|
|
ld a, b
|
|
|
|
cp EnemyMonMovesEnd - EnemyMonMoves + 1
|
2013-05-06 18:33:19 +00:00
|
|
|
jr z, .done
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2014-10-21 18:44:42 +00:00
|
|
|
; Ignore this move if it is the highest damaging one.
|
2013-05-05 23:56:17 +00:00
|
|
|
cp c
|
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
inc hl
|
2013-05-06 18:33:19 +00:00
|
|
|
jr z, .checkmove2
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
call AIGetEnemyMove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2014-10-21 18:44:42 +00:00
|
|
|
; Ignore this move if its power is 0 or 1.
|
|
|
|
; Moves such as Seismic Toss, Hidden Power,
|
|
|
|
; Counter and Fissure have a base power of 1.
|
2014-06-13 01:32:42 +00:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_POWER]
|
2013-05-06 18:33:19 +00:00
|
|
|
cp 2
|
|
|
|
jr c, .checkmove2
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2014-10-21 18:44:42 +00:00
|
|
|
; Ignore this move if it is reckless.
|
2013-05-05 23:56:17 +00:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2014-06-13 01:32:42 +00:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_EFFECT]
|
2014-10-21 17:21:13 +00:00
|
|
|
ld hl, .recklessmoves
|
2013-05-05 23:56:17 +00:00
|
|
|
ld de, 1
|
|
|
|
call IsInArray
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
2013-05-06 18:33:19 +00:00
|
|
|
jr c, .checkmove2
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2014-10-21 18:44:42 +00:00
|
|
|
; If we made it this far, discourage this move.
|
2013-05-05 23:56:17 +00:00
|
|
|
inc [hl]
|
2013-05-06 18:33:19 +00:00
|
|
|
jr .checkmove2
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
.done
|
2013-05-05 23:56:17 +00:00
|
|
|
ret
|
|
|
|
|
2014-10-21 17:21:13 +00:00
|
|
|
.recklessmoves
|
2013-05-06 06:39:01 +00:00
|
|
|
db EFFECT_EXPLOSION
|
|
|
|
db EFFECT_RAMPAGE
|
|
|
|
db EFFECT_MULTI_HIT
|
|
|
|
db EFFECT_DOUBLE_HIT
|
|
|
|
db $ff
|
|
|
|
; 393e7
|
|
|
|
|
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
AIDamageCalc: ; 393e7
|
2013-05-06 06:39:01 +00:00
|
|
|
ld a, 1
|
|
|
|
ld [hBattleTurn], a
|
2014-06-13 01:32:42 +00:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_EFFECT]
|
2013-05-06 06:39:01 +00:00
|
|
|
ld de, 1
|
|
|
|
ld hl, .ConstantDamageEffects
|
|
|
|
call IsInArray
|
|
|
|
jr nc, .asm_39400
|
|
|
|
callab BattleCommand3f
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_39400
|
|
|
|
callab EnemyAttackDamage
|
|
|
|
callab BattleCommand62
|
|
|
|
callab BattleCommand07
|
|
|
|
ret
|
|
|
|
|
|
|
|
.ConstantDamageEffects
|
|
|
|
db EFFECT_SUPER_FANG
|
|
|
|
db EFFECT_STATIC_DAMAGE
|
|
|
|
db EFFECT_LEVEL_DAMAGE
|
|
|
|
db EFFECT_PSYWAVE
|
|
|
|
db $ff
|
|
|
|
; 39418
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
AIScoring_Cautious: ; 39418
|
2014-10-21 22:28:51 +00:00
|
|
|
; 90% chance to discourage moves with residual effects after enemy's turn 1.
|
2013-05-06 18:33:19 +00:00
|
|
|
|
2013-05-05 23:56:17 +00:00
|
|
|
ld a, [EnemyTurnsTaken]
|
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
|
|
|
ld hl, Buffer1 - 1
|
|
|
|
ld de, EnemyMonMoves
|
|
|
|
ld c, EnemyMonMovesEnd - EnemyMonMoves + 1
|
|
|
|
.asm_39425
|
|
|
|
inc hl
|
|
|
|
dec c
|
|
|
|
ret z
|
|
|
|
|
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2013-05-06 18:33:19 +00:00
|
|
|
ld hl, .residualmoves
|
2013-05-05 23:56:17 +00:00
|
|
|
ld de, 1
|
|
|
|
call IsInArray
|
|
|
|
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
jr nc, .asm_39425
|
|
|
|
|
2013-08-31 02:59:40 +00:00
|
|
|
call Random
|
2013-05-06 18:33:19 +00:00
|
|
|
cp 230
|
2013-05-05 23:56:17 +00:00
|
|
|
ret nc
|
|
|
|
|
|
|
|
inc [hl]
|
|
|
|
jr .asm_39425
|
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
.residualmoves
|
2013-05-05 23:56:17 +00:00
|
|
|
db MIST
|
|
|
|
db LEECH_SEED
|
|
|
|
db POISONPOWDER
|
|
|
|
db STUN_SPORE
|
|
|
|
db THUNDER_WAVE
|
|
|
|
db FOCUS_ENERGY
|
|
|
|
db BIDE
|
|
|
|
db POISON_GAS
|
|
|
|
db TRANSFORM
|
|
|
|
db CONVERSION
|
|
|
|
db SUBSTITUTE
|
|
|
|
db SPIKES
|
|
|
|
db $ff
|
|
|
|
; 39453
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
AIScoring_StatusImmunity: ; 39453
|
2014-10-21 22:28:51 +00:00
|
|
|
; Dismiss status moves that don't affect the player.
|
2013-05-06 18:33:19 +00:00
|
|
|
|
2013-05-05 23:56:17 +00:00
|
|
|
ld hl, Buffer1 - 1
|
|
|
|
ld de, EnemyMonMoves
|
|
|
|
ld b, EnemyMonMovesEnd - EnemyMonMoves + 1
|
2013-05-06 18:33:19 +00:00
|
|
|
.checkmove
|
2013-05-05 23:56:17 +00:00
|
|
|
dec b
|
|
|
|
ret z
|
|
|
|
|
|
|
|
inc hl
|
|
|
|
ld a, [de]
|
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
|
|
|
inc de
|
2013-05-06 18:33:19 +00:00
|
|
|
call AIGetEnemyMove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2014-06-13 01:32:42 +00:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_EFFECT]
|
2013-05-05 23:56:17 +00:00
|
|
|
cp EFFECT_TOXIC
|
2013-05-06 18:33:19 +00:00
|
|
|
jr z, .poisonimmunity
|
2013-05-05 23:56:17 +00:00
|
|
|
cp EFFECT_POISON
|
2013-05-06 18:33:19 +00:00
|
|
|
jr z, .poisonimmunity
|
2013-05-05 23:56:17 +00:00
|
|
|
cp EFFECT_SLEEP
|
2013-05-06 18:33:19 +00:00
|
|
|
jr z, .typeimmunity
|
2013-05-05 23:56:17 +00:00
|
|
|
cp EFFECT_PARALYZE
|
2013-05-06 18:33:19 +00:00
|
|
|
jr z, .typeimmunity
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2014-06-13 01:32:42 +00:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_POWER]
|
2013-05-05 23:56:17 +00:00
|
|
|
and a
|
2013-05-06 18:33:19 +00:00
|
|
|
jr z, .checkmove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
jr .typeimmunity
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
.poisonimmunity
|
2013-05-05 23:56:17 +00:00
|
|
|
ld a, [BattleMonType1]
|
|
|
|
cp POISON
|
2013-05-06 18:33:19 +00:00
|
|
|
jr z, .immune
|
2013-05-05 23:56:17 +00:00
|
|
|
ld a, [BattleMonType2]
|
|
|
|
cp POISON
|
2013-05-06 18:33:19 +00:00
|
|
|
jr z, .immune
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
.typeimmunity
|
2013-05-05 23:56:17 +00:00
|
|
|
push hl
|
|
|
|
push bc
|
|
|
|
push de
|
|
|
|
ld a, 1
|
|
|
|
ld [hBattleTurn], a
|
2013-12-31 09:10:49 +00:00
|
|
|
callab Function347c8
|
2013-05-05 23:56:17 +00:00
|
|
|
pop de
|
|
|
|
pop bc
|
|
|
|
pop hl
|
|
|
|
|
|
|
|
ld a, [$d265]
|
|
|
|
and a
|
2013-05-06 18:33:19 +00:00
|
|
|
jr nz, .checkmove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
.immune
|
|
|
|
call AIDiscourageMove
|
|
|
|
jr .checkmove
|
2013-05-05 23:56:17 +00:00
|
|
|
; 394a9
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
AIScoring_Risky: ; 394a9
|
2014-10-21 22:28:51 +00:00
|
|
|
; Use any move that will KO the target.
|
|
|
|
; Risky moves will often be an exception (see below).
|
2013-05-06 18:33:19 +00:00
|
|
|
|
2013-05-05 23:56:17 +00:00
|
|
|
ld hl, Buffer1 - 1
|
|
|
|
ld de, EnemyMonMoves
|
|
|
|
ld c, EnemyMonMovesEnd - EnemyMonMoves + 1
|
2013-05-06 18:33:19 +00:00
|
|
|
.checkmove
|
2013-05-05 23:56:17 +00:00
|
|
|
inc hl
|
|
|
|
dec c
|
|
|
|
ret z
|
|
|
|
|
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
|
|
|
push de
|
|
|
|
push bc
|
|
|
|
push hl
|
2013-05-06 18:33:19 +00:00
|
|
|
call AIGetEnemyMove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2014-06-13 01:32:42 +00:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_POWER]
|
2013-05-05 23:56:17 +00:00
|
|
|
and a
|
2013-05-06 18:33:19 +00:00
|
|
|
jr z, .nextmove
|
2014-10-21 22:28:51 +00:00
|
|
|
|
2014-06-13 01:32:42 +00:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_EFFECT]
|
2013-05-05 23:56:17 +00:00
|
|
|
ld de, 1
|
2013-05-06 18:33:19 +00:00
|
|
|
ld hl, .riskymoves
|
2013-05-05 23:56:17 +00:00
|
|
|
call IsInArray
|
2013-05-06 18:33:19 +00:00
|
|
|
jr nc, .checkko
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2014-10-21 22:28:51 +00:00
|
|
|
; Exclude risky moves if enemy's HP is full.
|
2013-05-06 18:33:19 +00:00
|
|
|
call AICheckEnemyMaxHP
|
|
|
|
jr c, .nextmove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2014-10-21 22:28:51 +00:00
|
|
|
; Otherwise, 80% chance to exclude them.
|
2013-08-31 02:59:40 +00:00
|
|
|
call Random
|
2014-10-21 22:28:51 +00:00
|
|
|
cp 200
|
2013-05-06 18:33:19 +00:00
|
|
|
jr c, .nextmove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
.checkko
|
|
|
|
call AIDamageCalc
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
ld a, [CurDamage + 1]
|
|
|
|
ld e, a
|
|
|
|
ld a, [CurDamage]
|
|
|
|
ld d, a
|
|
|
|
ld a, [BattleMonHP + 1]
|
|
|
|
cp e
|
|
|
|
ld a, [BattleMonHP]
|
|
|
|
sbc d
|
2013-05-06 18:33:19 +00:00
|
|
|
jr nc, .nextmove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
|
|
|
pop hl
|
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
push hl
|
2013-05-06 18:33:19 +00:00
|
|
|
|
|
|
|
.nextmove
|
2013-05-05 23:56:17 +00:00
|
|
|
pop hl
|
|
|
|
pop bc
|
|
|
|
pop de
|
2013-05-06 18:33:19 +00:00
|
|
|
jr .checkmove
|
2013-05-05 23:56:17 +00:00
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
.riskymoves
|
2013-05-05 23:56:17 +00:00
|
|
|
db EFFECT_EXPLOSION
|
|
|
|
db EFFECT_OHKO
|
|
|
|
db $ff
|
|
|
|
; 39502
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
AIScoring_None: ; 39502
|
2013-05-05 23:56:17 +00:00
|
|
|
ret
|
|
|
|
; 39503
|
|
|
|
|
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
AIDiscourageMove: ; 39503
|
2013-05-06 06:39:01 +00:00
|
|
|
ld a, [hl]
|
|
|
|
add 10
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
; 39508
|
|
|
|
|
|
|
|
|
2013-05-06 18:33:19 +00:00
|
|
|
AIGetEnemyMove: ; 39508
|
2014-10-21 17:21:13 +00:00
|
|
|
; Load attributes of move a into ram
|
|
|
|
|
2013-05-06 06:39:01 +00:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
|
|
|
dec a
|
|
|
|
ld hl, Moves
|
2014-06-11 06:23:55 +00:00
|
|
|
ld bc, MOVE_LENGTH
|
2013-05-06 06:39:01 +00:00
|
|
|
call AddNTimes
|
|
|
|
|
2014-06-13 01:32:42 +00:00
|
|
|
ld de, wEnemyMoveStruct
|
2013-05-06 06:39:01 +00:00
|
|
|
ld a, BANK(Moves)
|
|
|
|
call FarCopyBytes
|
|
|
|
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
; 39521
|
|
|
|
|
|
|
|
|
2014-06-13 01:32:42 +00:00
|
|
|
Function39521: ; 39521
|
2013-08-31 02:59:40 +00:00
|
|
|
call Random
|
2013-05-06 06:39:01 +00:00
|
|
|
cp 50 ; 1/5
|
|
|
|
ret
|
|
|
|
; 39527
|
|
|
|
|
|
|
|
|
2014-06-13 01:32:42 +00:00
|
|
|
Function39527: ; 39527
|
2013-08-31 02:59:40 +00:00
|
|
|
call Random
|
2013-05-06 06:39:01 +00:00
|
|
|
cp $80 ; 1/2
|
|
|
|
ret
|
|
|
|
; 3952d
|
|
|
|
|
2013-05-05 23:56:17 +00:00
|
|
|
|