2018-06-12 20:29:15 -07:00
|
|
|
AIScoring: ; used only for BANK(AIScoring)
|
2017-12-11 20:44:29 -08:00
|
|
|
|
2020-05-07 08:09:41 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Basic:
|
2014-08-13 19:44:56 -07:00
|
|
|
; Don't do anything redundant:
|
|
|
|
; -Using status-only moves if the player can't be statused
|
|
|
|
; -Using moves that fail if they've already been used
|
2013-05-06 11:33:19 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBuffer1 - 1
|
|
|
|
ld de, wEnemyMonMoves
|
|
|
|
ld b, wEnemyMonMovesEnd - wEnemyMonMoves + 1
|
2013-05-06 11:33:19 -07:00
|
|
|
.checkmove
|
2013-05-05 16:56:17 -07:00
|
|
|
dec b
|
|
|
|
ret z
|
|
|
|
|
|
|
|
inc hl
|
|
|
|
ld a, [de]
|
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
|
|
|
inc de
|
2013-05-06 11:33:19 -07:00
|
|
|
call AIGetEnemyMove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2014-06-12 18:32:42 -07:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_EFFECT]
|
2013-05-05 16:56:17 -07:00
|
|
|
ld c, a
|
|
|
|
|
2014-10-21 10:21:13 -07:00
|
|
|
; Dismiss moves with special effects if they are
|
|
|
|
; useless or not a good choice right now.
|
2016-04-10 11:42:14 -07:00
|
|
|
; For example, healing moves, weather moves, Dream Eater...
|
2013-05-05 16:56:17 -07:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall AI_Redundant
|
2013-05-05 16:56:17 -07:00
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
2013-05-06 11:33:19 -07:00
|
|
|
jr nz, .discourage
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
; Dismiss status-only moves if the player can't be statused.
|
2014-06-12 18:32:42 -07:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_EFFECT]
|
2013-05-05 16:56:17 -07:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2018-01-25 17:34:33 -08:00
|
|
|
ld hl, StatusOnlyEffects
|
2013-05-05 16:56:17 -07:00
|
|
|
ld de, 1
|
|
|
|
call IsInArray
|
|
|
|
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
2013-05-06 11:33:19 -07:00
|
|
|
jr nc, .checkmove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wBattleMonStatus]
|
2013-05-05 16:56:17 -07:00
|
|
|
and a
|
2013-05-06 11:33:19 -07:00
|
|
|
jr nz, .discourage
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2014-10-21 11:44:42 -07:00
|
|
|
; Dismiss Safeguard if it's already active.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerScreens]
|
2013-05-06 11:33:19 -07:00
|
|
|
bit SCREENS_SAFEGUARD, a
|
|
|
|
jr z, .checkmove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
.discourage
|
|
|
|
call AIDiscourageMove
|
|
|
|
jr .checkmove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2018-01-25 17:34:33 -08:00
|
|
|
INCLUDE "data/battle/ai/status_only_effects.asm"
|
2013-05-05 16:56:17 -07:00
|
|
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Setup:
|
2013-05-06 11:33:19 -07:00
|
|
|
; Use stat-modifying moves on turn 1.
|
|
|
|
|
2014-10-22 08:36:42 -07:00
|
|
|
; 50% chance to greatly encourage stat-up moves during the first turn of enemy's Pokemon.
|
|
|
|
; 50% chance to greatly encourage stat-down moves during the first turn of player's Pokemon.
|
2014-10-21 11:44:42 -07:00
|
|
|
; Almost 90% chance to greatly discourage stat-modifying moves otherwise.
|
2013-05-06 11:33:19 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBuffer1 - 1
|
|
|
|
ld de, wEnemyMonMoves
|
|
|
|
ld b, wEnemyMonMovesEnd - wEnemyMonMoves + 1
|
2013-05-06 11:33:19 -07:00
|
|
|
.checkmove
|
2013-05-05 16:56:17 -07:00
|
|
|
dec b
|
|
|
|
ret z
|
|
|
|
|
|
|
|
inc hl
|
|
|
|
ld a, [de]
|
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
|
|
|
inc de
|
2013-05-06 11:33:19 -07:00
|
|
|
call AIGetEnemyMove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2014-06-12 18:32:42 -07:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_EFFECT]
|
2013-05-05 16:56:17 -07:00
|
|
|
|
|
|
|
cp EFFECT_ATTACK_UP
|
2013-05-06 11:33:19 -07:00
|
|
|
jr c, .checkmove
|
2013-05-05 16:56:17 -07:00
|
|
|
cp EFFECT_EVASION_UP + 1
|
|
|
|
jr c, .statup
|
|
|
|
|
|
|
|
; cp EFFECT_ATTACK_DOWN - 1
|
2013-05-06 11:33:19 -07:00
|
|
|
jr z, .checkmove
|
2013-05-05 16:56:17 -07:00
|
|
|
cp EFFECT_EVASION_DOWN + 1
|
|
|
|
jr c, .statdown
|
|
|
|
|
|
|
|
cp EFFECT_ATTACK_UP_2
|
2013-05-06 11:33:19 -07:00
|
|
|
jr c, .checkmove
|
2013-05-05 16:56:17 -07:00
|
|
|
cp EFFECT_EVASION_UP_2 + 1
|
|
|
|
jr c, .statup
|
|
|
|
|
|
|
|
; cp EFFECT_ATTACK_DOWN_2 - 1
|
2013-05-06 11:33:19 -07:00
|
|
|
jr z, .checkmove
|
2013-05-05 16:56:17 -07:00
|
|
|
cp EFFECT_EVASION_DOWN_2 + 1
|
|
|
|
jr c, .statdown
|
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
jr .checkmove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
|
|
|
.statup
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyTurnsTaken]
|
2013-05-05 16:56:17 -07:00
|
|
|
and a
|
2013-05-06 11:33:19 -07:00
|
|
|
jr nz, .discourage
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
jr .encourage
|
2013-05-05 16:56:17 -07:00
|
|
|
|
|
|
|
.statdown
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerTurnsTaken]
|
2013-05-05 16:56:17 -07:00
|
|
|
and a
|
2013-05-06 11:33:19 -07:00
|
|
|
jr nz, .discourage
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
.encourage
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_50_50
|
2013-05-06 11:33:19 -07:00
|
|
|
jr c, .checkmove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
|
|
|
dec [hl]
|
2016-05-04 08:46:23 -07:00
|
|
|
dec [hl]
|
2013-05-06 11:33:19 -07:00
|
|
|
jr .checkmove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
.discourage
|
2013-08-30 19:59:40 -07:00
|
|
|
call Random
|
2017-12-25 13:18:05 -08:00
|
|
|
cp 12 percent
|
2013-05-06 11:33:19 -07:00
|
|
|
jr c, .checkmove
|
2013-05-05 16:56:17 -07:00
|
|
|
inc [hl]
|
2016-05-04 08:46:23 -07:00
|
|
|
inc [hl]
|
2013-05-06 11:33:19 -07:00
|
|
|
jr .checkmove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Types:
|
2014-10-21 11:44:42 -07:00
|
|
|
; Dismiss any move that the player is immune to.
|
|
|
|
; Encourage super-effective moves.
|
2015-07-18 20:45:39 -07:00
|
|
|
; Discourage not very effective moves unless
|
2014-10-21 11:44:42 -07:00
|
|
|
; all damaging moves are of the same type.
|
2013-05-06 11:33:19 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBuffer1 - 1
|
|
|
|
ld de, wEnemyMonMoves
|
|
|
|
ld b, wEnemyMonMovesEnd - wEnemyMonMoves + 1
|
2013-05-06 11:33:19 -07:00
|
|
|
.checkmove
|
2013-05-05 16:56:17 -07:00
|
|
|
dec b
|
|
|
|
ret z
|
|
|
|
|
|
|
|
inc hl
|
|
|
|
ld a, [de]
|
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
|
|
|
inc de
|
2013-05-06 11:33:19 -07:00
|
|
|
call AIGetEnemyMove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
|
|
|
push hl
|
|
|
|
push bc
|
|
|
|
push de
|
|
|
|
ld a, 1
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hBattleTurn], a
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar BattleCheckTypeMatchup
|
2013-05-05 16:56:17 -07:00
|
|
|
pop de
|
|
|
|
pop bc
|
|
|
|
pop hl
|
2013-05-06 11:33:19 -07:00
|
|
|
|
2018-07-28 16:27:34 -07:00
|
|
|
ld a, [wTypeMatchup]
|
2013-05-05 16:56:17 -07:00
|
|
|
and a
|
2013-05-06 11:33:19 -07:00
|
|
|
jr z, .immune
|
2018-07-28 16:27:34 -07:00
|
|
|
cp EFFECTIVE
|
2013-05-06 11:33:19 -07:00
|
|
|
jr z, .checkmove
|
|
|
|
jr c, .noteffective
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
; effective
|
2014-06-12 18:32:42 -07:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_POWER]
|
2013-05-05 16:56:17 -07:00
|
|
|
and a
|
2013-05-06 11:33:19 -07:00
|
|
|
jr z, .checkmove
|
2013-05-05 16:56:17 -07:00
|
|
|
dec [hl]
|
2013-05-06 11:33:19 -07:00
|
|
|
jr .checkmove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
.noteffective
|
|
|
|
; Discourage this move if there are any moves
|
|
|
|
; that do damage of a different type.
|
2013-05-05 16:56:17 -07:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2014-06-12 18:32:42 -07:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_TYPE]
|
2013-05-05 16:56:17 -07:00
|
|
|
ld d, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonMoves
|
|
|
|
ld b, wEnemyMonMovesEnd - wEnemyMonMoves + 1
|
2013-05-05 16:56:17 -07:00
|
|
|
ld c, 0
|
2013-05-06 11:33:19 -07:00
|
|
|
.checkmove2
|
2013-05-05 16:56:17 -07:00
|
|
|
dec b
|
|
|
|
jr z, .asm_38693
|
|
|
|
|
|
|
|
ld a, [hli]
|
|
|
|
and a
|
|
|
|
jr z, .asm_38693
|
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
call AIGetEnemyMove
|
2014-06-12 18:32:42 -07:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_TYPE]
|
2013-05-05 16:56:17 -07:00
|
|
|
cp d
|
2013-05-06 11:33:19 -07:00
|
|
|
jr z, .checkmove2
|
2014-06-12 18:32:42 -07:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_POWER]
|
2013-05-05 16:56:17 -07:00
|
|
|
and a
|
|
|
|
jr nz, .asm_38692
|
2013-05-06 11:33:19 -07:00
|
|
|
jr .checkmove2
|
2013-05-05 16:56:17 -07:00
|
|
|
|
|
|
|
.asm_38692
|
|
|
|
ld c, a
|
|
|
|
.asm_38693
|
|
|
|
ld a, c
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
and a
|
2013-05-06 11:33:19 -07:00
|
|
|
jr z, .checkmove
|
2013-05-05 16:56:17 -07:00
|
|
|
inc [hl]
|
2013-05-06 11:33:19 -07:00
|
|
|
jr .checkmove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
.immune
|
|
|
|
call AIDiscourageMove
|
|
|
|
jr .checkmove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Offensive:
|
2014-10-21 11:44:42 -07:00
|
|
|
; Greatly discourage non-damaging moves.
|
2013-05-06 11:33:19 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBuffer1 - 1
|
|
|
|
ld de, wEnemyMonMoves
|
|
|
|
ld b, wEnemyMonMovesEnd - wEnemyMonMoves + 1
|
2013-05-06 11:33:19 -07:00
|
|
|
.checkmove
|
2013-05-05 16:56:17 -07:00
|
|
|
dec b
|
|
|
|
ret z
|
|
|
|
|
|
|
|
inc hl
|
|
|
|
ld a, [de]
|
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
|
|
|
inc de
|
2013-05-06 11:33:19 -07:00
|
|
|
call AIGetEnemyMove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2014-06-12 18:32:42 -07:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_POWER]
|
2013-05-05 16:56:17 -07:00
|
|
|
and a
|
2013-05-06 11:33:19 -07:00
|
|
|
jr nz, .checkmove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
|
|
|
inc [hl]
|
2016-05-04 08:46:23 -07:00
|
|
|
inc [hl]
|
2013-05-06 11:33:19 -07:00
|
|
|
jr .checkmove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart:
|
2013-05-06 11:33:19 -07:00
|
|
|
; Context-specific scoring.
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBuffer1
|
|
|
|
ld de, wEnemyMonMoves
|
|
|
|
ld b, wEnemyMonMovesEnd - wEnemyMonMoves + 1
|
2013-05-06 11:33:19 -07:00
|
|
|
.checkmove
|
2013-05-05 16:56:17 -07:00
|
|
|
dec b
|
|
|
|
ret z
|
|
|
|
|
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
|
|
|
push de
|
|
|
|
push bc
|
|
|
|
push hl
|
2013-05-06 11:33:19 -07:00
|
|
|
call AIGetEnemyMove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2014-06-12 18:32:42 -07:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_EFFECT]
|
2013-05-05 16:56:17 -07:00
|
|
|
ld hl, .table_386f2
|
|
|
|
ld de, 3
|
|
|
|
call IsInArray
|
|
|
|
|
|
|
|
inc hl
|
2013-05-06 11:33:19 -07:00
|
|
|
jr nc, .nextmove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
|
|
|
ld a, [hli]
|
|
|
|
ld e, a
|
|
|
|
ld d, [hl]
|
2013-05-06 11:33:19 -07:00
|
|
|
|
2013-05-05 16:56:17 -07:00
|
|
|
pop hl
|
|
|
|
push hl
|
2013-05-06 11:33:19 -07:00
|
|
|
|
|
|
|
ld bc, .nextmove
|
2013-05-05 16:56:17 -07:00
|
|
|
push bc
|
2013-05-06 11:33:19 -07:00
|
|
|
|
2013-05-05 16:56:17 -07:00
|
|
|
push de
|
|
|
|
ret
|
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
.nextmove
|
2013-05-05 16:56:17 -07:00
|
|
|
pop hl
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
inc hl
|
2013-05-06 11:33:19 -07:00
|
|
|
jr .checkmove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
.table_386f2
|
2014-08-13 19:44:56 -07:00
|
|
|
dbw EFFECT_SLEEP, AI_Smart_Sleep
|
|
|
|
dbw EFFECT_LEECH_HIT, AI_Smart_LeechHit
|
2017-11-15 07:36:13 -08:00
|
|
|
dbw EFFECT_SELFDESTRUCT, AI_Smart_Selfdestruct
|
2014-08-13 19:44:56 -07:00
|
|
|
dbw EFFECT_DREAM_EATER, AI_Smart_DreamEater
|
|
|
|
dbw EFFECT_MIRROR_MOVE, AI_Smart_MirrorMove
|
|
|
|
dbw EFFECT_EVASION_UP, AI_Smart_EvasionUp
|
|
|
|
dbw EFFECT_ALWAYS_HIT, AI_Smart_AlwaysHit
|
|
|
|
dbw EFFECT_ACCURACY_DOWN, AI_Smart_AccuracyDown
|
2017-11-15 07:36:13 -08:00
|
|
|
dbw EFFECT_RESET_STATS, AI_Smart_ResetStats
|
2014-08-13 19:44:56 -07:00
|
|
|
dbw EFFECT_BIDE, AI_Smart_Bide
|
2017-11-15 07:36:13 -08:00
|
|
|
dbw EFFECT_FORCE_SWITCH, AI_Smart_ForceSwitch
|
2014-08-13 19:44:56 -07:00
|
|
|
dbw EFFECT_HEAL, AI_Smart_Heal
|
|
|
|
dbw EFFECT_TOXIC, AI_Smart_Toxic
|
|
|
|
dbw EFFECT_LIGHT_SCREEN, AI_Smart_LightScreen
|
|
|
|
dbw EFFECT_OHKO, AI_Smart_Ohko
|
|
|
|
dbw EFFECT_RAZOR_WIND, AI_Smart_RazorWind
|
|
|
|
dbw EFFECT_SUPER_FANG, AI_Smart_SuperFang
|
2017-11-15 07:36:13 -08:00
|
|
|
dbw EFFECT_TRAP_TARGET, AI_Smart_TrapTarget
|
2014-08-13 19:44:56 -07:00
|
|
|
dbw EFFECT_UNUSED_2B, AI_Smart_Unused2B
|
|
|
|
dbw EFFECT_CONFUSE, AI_Smart_Confuse
|
|
|
|
dbw EFFECT_SP_DEF_UP_2, AI_Smart_SpDefenseUp2
|
|
|
|
dbw EFFECT_REFLECT, AI_Smart_Reflect
|
|
|
|
dbw EFFECT_PARALYZE, AI_Smart_Paralyze
|
|
|
|
dbw EFFECT_SPEED_DOWN_HIT, AI_Smart_SpeedDownHit
|
|
|
|
dbw EFFECT_SUBSTITUTE, AI_Smart_Substitute
|
|
|
|
dbw EFFECT_HYPER_BEAM, AI_Smart_HyperBeam
|
|
|
|
dbw EFFECT_RAGE, AI_Smart_Rage
|
|
|
|
dbw EFFECT_MIMIC, AI_Smart_Mimic
|
|
|
|
dbw EFFECT_LEECH_SEED, AI_Smart_LeechSeed
|
|
|
|
dbw EFFECT_DISABLE, AI_Smart_Disable
|
|
|
|
dbw EFFECT_COUNTER, AI_Smart_Counter
|
|
|
|
dbw EFFECT_ENCORE, AI_Smart_Encore
|
|
|
|
dbw EFFECT_PAIN_SPLIT, AI_Smart_PainSplit
|
|
|
|
dbw EFFECT_SNORE, AI_Smart_Snore
|
|
|
|
dbw EFFECT_CONVERSION2, AI_Smart_Conversion2
|
|
|
|
dbw EFFECT_LOCK_ON, AI_Smart_LockOn
|
|
|
|
dbw EFFECT_DEFROST_OPPONENT, AI_Smart_DefrostOpponent
|
|
|
|
dbw EFFECT_SLEEP_TALK, AI_Smart_SleepTalk
|
|
|
|
dbw EFFECT_DESTINY_BOND, AI_Smart_DestinyBond
|
|
|
|
dbw EFFECT_REVERSAL, AI_Smart_Reversal
|
|
|
|
dbw EFFECT_SPITE, AI_Smart_Spite
|
|
|
|
dbw EFFECT_HEAL_BELL, AI_Smart_HealBell
|
|
|
|
dbw EFFECT_PRIORITY_HIT, AI_Smart_PriorityHit
|
|
|
|
dbw EFFECT_THIEF, AI_Smart_Thief
|
|
|
|
dbw EFFECT_MEAN_LOOK, AI_Smart_MeanLook
|
|
|
|
dbw EFFECT_NIGHTMARE, AI_Smart_Nightmare
|
|
|
|
dbw EFFECT_FLAME_WHEEL, AI_Smart_FlameWheel
|
|
|
|
dbw EFFECT_CURSE, AI_Smart_Curse
|
|
|
|
dbw EFFECT_PROTECT, AI_Smart_Protect
|
|
|
|
dbw EFFECT_FORESIGHT, AI_Smart_Foresight
|
|
|
|
dbw EFFECT_PERISH_SONG, AI_Smart_PerishSong
|
|
|
|
dbw EFFECT_SANDSTORM, AI_Smart_Sandstorm
|
|
|
|
dbw EFFECT_ENDURE, AI_Smart_Endure
|
|
|
|
dbw EFFECT_ROLLOUT, AI_Smart_Rollout
|
|
|
|
dbw EFFECT_SWAGGER, AI_Smart_Swagger
|
|
|
|
dbw EFFECT_FURY_CUTTER, AI_Smart_FuryCutter
|
|
|
|
dbw EFFECT_ATTRACT, AI_Smart_Attract
|
|
|
|
dbw EFFECT_SAFEGUARD, AI_Smart_Safeguard
|
|
|
|
dbw EFFECT_MAGNITUDE, AI_Smart_Magnitude
|
|
|
|
dbw EFFECT_BATON_PASS, AI_Smart_BatonPass
|
|
|
|
dbw EFFECT_PURSUIT, AI_Smart_Pursuit
|
|
|
|
dbw EFFECT_RAPID_SPIN, AI_Smart_RapidSpin
|
|
|
|
dbw EFFECT_MORNING_SUN, AI_Smart_MorningSun
|
|
|
|
dbw EFFECT_SYNTHESIS, AI_Smart_Synthesis
|
|
|
|
dbw EFFECT_MOONLIGHT, AI_Smart_Moonlight
|
|
|
|
dbw EFFECT_HIDDEN_POWER, AI_Smart_HiddenPower
|
|
|
|
dbw EFFECT_RAIN_DANCE, AI_Smart_RainDance
|
|
|
|
dbw EFFECT_SUNNY_DAY, AI_Smart_SunnyDay
|
|
|
|
dbw EFFECT_BELLY_DRUM, AI_Smart_BellyDrum
|
|
|
|
dbw EFFECT_PSYCH_UP, AI_Smart_PsychUp
|
|
|
|
dbw EFFECT_MIRROR_COAT, AI_Smart_MirrorCoat
|
|
|
|
dbw EFFECT_SKULL_BASH, AI_Smart_SkullBash
|
|
|
|
dbw EFFECT_TWISTER, AI_Smart_Twister
|
|
|
|
dbw EFFECT_EARTHQUAKE, AI_Smart_Earthquake
|
|
|
|
dbw EFFECT_FUTURE_SIGHT, AI_Smart_FutureSight
|
|
|
|
dbw EFFECT_GUST, AI_Smart_Gust
|
|
|
|
dbw EFFECT_STOMP, AI_Smart_Stomp
|
|
|
|
dbw EFFECT_SOLARBEAM, AI_Smart_Solarbeam
|
|
|
|
dbw EFFECT_THUNDER, AI_Smart_Thunder
|
|
|
|
dbw EFFECT_FLY, AI_Smart_Fly
|
2018-01-10 19:53:42 -08:00
|
|
|
db -1 ; end
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_Sleep:
|
2014-10-21 11:44:42 -07: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 04:54:04 -07:00
|
|
|
|
2013-05-06 21:58:35 -07:00
|
|
|
ld b, EFFECT_DREAM_EATER
|
2014-08-13 19:44:56 -07:00
|
|
|
call AIHasMoveEffect
|
2013-05-05 16:56:17 -07:00
|
|
|
jr c, .asm_387f0
|
|
|
|
|
2013-05-06 21:58:35 -07:00
|
|
|
ld b, EFFECT_NIGHTMARE
|
2014-08-13 19:44:56 -07:00
|
|
|
call AIHasMoveEffect
|
2013-05-05 16:56:17 -07:00
|
|
|
ret nc
|
|
|
|
|
|
|
|
.asm_387f0
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_50_50
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
dec [hl]
|
2016-05-04 08:46:23 -07:00
|
|
|
dec [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_LeechHit:
|
2013-05-05 16:56:17 -07:00
|
|
|
push hl
|
2013-05-06 21:58:35 -07:00
|
|
|
ld a, 1
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hBattleTurn], a
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar BattleCheckTypeMatchup
|
2013-05-05 16:56:17 -07:00
|
|
|
pop hl
|
2013-05-06 21:58:35 -07:00
|
|
|
|
2014-10-21 11:44:42 -07:00
|
|
|
; 60% chance to discourage this move if not very effective.
|
2018-07-28 16:27:34 -07:00
|
|
|
ld a, [wTypeMatchup]
|
|
|
|
cp EFFECTIVE
|
2013-05-05 16:56:17 -07:00
|
|
|
jr c, .asm_38815
|
|
|
|
|
2014-10-21 11:44:42 -07:00
|
|
|
; Do nothing if effectiveness is neutral.
|
2013-05-05 16:56:17 -07:00
|
|
|
ret z
|
|
|
|
|
2014-10-21 11:44:42 -07:00
|
|
|
; Do nothing if enemy's HP is full.
|
2014-08-13 19:44:56 -07:00
|
|
|
call AICheckEnemyMaxHP
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
|
2014-10-21 15:28:51 -07:00
|
|
|
; 80% chance to encourage this move otherwise.
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_80_20
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
2014-08-13 19:44:56 -07:00
|
|
|
|
2013-05-05 16:56:17 -07:00
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38815
|
2013-08-30 19:59:40 -07:00
|
|
|
call Random
|
2017-12-25 13:18:05 -08:00
|
|
|
cp 39 percent + 1
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
2014-08-13 19:44:56 -07:00
|
|
|
|
2013-05-05 16:56:17 -07:00
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_LockOn:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerSubStatus5]
|
2014-06-17 12:52:32 -07:00
|
|
|
bit SUBSTATUS_LOCK_ON, a
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nz, .asm_38882
|
|
|
|
|
|
|
|
push hl
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckEnemyQuarterHP
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nc, .asm_38877
|
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckEnemyHalfHP
|
2013-05-05 16:56:17 -07:00
|
|
|
jr c, .asm_38834
|
|
|
|
|
2013-05-06 17:51:07 -07:00
|
|
|
call AICompareSpeed
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nc, .asm_38877
|
|
|
|
|
|
|
|
.asm_38834
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerEvaLevel]
|
2020-05-07 08:09:41 -07:00
|
|
|
cp BASE_STAT_LEVEL + 3
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nc, .asm_3887a
|
2020-05-07 08:09:41 -07:00
|
|
|
cp BASE_STAT_LEVEL + 1
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nc, .asm_38875
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyAccLevel]
|
2020-05-07 08:09:41 -07:00
|
|
|
cp BASE_STAT_LEVEL - 2
|
2013-05-05 16:56:17 -07:00
|
|
|
jr c, .asm_3887a
|
2020-05-07 08:09:41 -07:00
|
|
|
cp BASE_STAT_LEVEL
|
2013-05-05 16:56:17 -07:00
|
|
|
jr c, .asm_38875
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonMoves
|
|
|
|
ld c, wEnemyMonMovesEnd - wEnemyMonMoves + 1
|
2013-05-05 16:56:17 -07:00
|
|
|
.asm_3884f
|
|
|
|
dec c
|
|
|
|
jr z, .asm_38877
|
|
|
|
|
|
|
|
ld a, [hli]
|
|
|
|
and a
|
|
|
|
jr z, .asm_38877
|
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
call AIGetEnemyMove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2014-06-12 18:32:42 -07:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_ACC]
|
|
|
|
cp 180
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nc, .asm_3884f
|
|
|
|
|
|
|
|
ld a, $1
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hBattleTurn], a
|
2014-06-17 12:52:32 -07:00
|
|
|
|
2013-05-05 16:56:17 -07:00
|
|
|
push hl
|
|
|
|
push bc
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall BattleCheckTypeMatchup
|
2018-07-28 16:27:34 -07:00
|
|
|
ld a, [wTypeMatchup]
|
|
|
|
cp EFFECTIVE
|
2013-05-05 16:56:17 -07:00
|
|
|
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-08-13 19:44:56 -07:00
|
|
|
call AI_50_50
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
2014-06-17 12:52:32 -07:00
|
|
|
|
2013-05-05 16:56:17 -07:00
|
|
|
dec [hl]
|
2016-05-04 08:46:23 -07:00
|
|
|
dec [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38882
|
|
|
|
push hl
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBuffer1 - 1
|
|
|
|
ld de, wEnemyMonMoves
|
|
|
|
ld c, wEnemyMonMovesEnd - wEnemyMonMoves + 1
|
2013-05-05 16:56:17 -07: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 11:33:19 -07:00
|
|
|
call AIGetEnemyMove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2014-06-12 18:32:42 -07:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_ACC]
|
|
|
|
cp 180
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nc, .asm_3888b
|
|
|
|
|
|
|
|
dec [hl]
|
2016-05-04 08:46:23 -07:00
|
|
|
dec [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
jr .asm_3888b
|
|
|
|
|
|
|
|
.asm_388a2
|
|
|
|
pop hl
|
2013-05-06 11:33:19 -07:00
|
|
|
jp AIDiscourageMove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_Selfdestruct:
|
2014-10-22 08:36:42 -07:00
|
|
|
; Selfdestruct, Explosion
|
2014-10-21 04:54:04 -07:00
|
|
|
|
|
|
|
; Unless this is the enemy's last Pokemon...
|
2013-05-05 16:56:17 -07:00
|
|
|
push hl
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall FindAliveEnemyMons
|
2013-05-05 16:56:17 -07:00
|
|
|
pop hl
|
|
|
|
jr nc, .asm_388b7
|
|
|
|
|
2014-10-21 11:44:42 -07:00
|
|
|
; ...greatly discourage this move unless this is the player's last Pokemon too.
|
2013-05-05 16:56:17 -07:00
|
|
|
push hl
|
2013-05-06 21:58:35 -07:00
|
|
|
call AICheckLastPlayerMon
|
2013-05-05 16:56:17 -07:00
|
|
|
pop hl
|
|
|
|
jr nz, .asm_388c6
|
|
|
|
|
|
|
|
.asm_388b7
|
2014-10-21 11:44:42 -07:00
|
|
|
; Greatly discourage this move if enemy's HP is above 50%.
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckEnemyHalfHP
|
2013-05-05 16:56:17 -07:00
|
|
|
jr c, .asm_388c6
|
|
|
|
|
2014-10-21 11:44:42 -07:00
|
|
|
; Do nothing if enemy's HP is below 25%.
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckEnemyQuarterHP
|
2013-05-05 16:56:17 -07:00
|
|
|
ret nc
|
|
|
|
|
2014-10-21 05:17:55 -07:00
|
|
|
; If enemy's HP is between 25% and 50%,
|
2014-10-21 11:44:42 -07:00
|
|
|
; over 90% chance to greatly discourage this move.
|
2013-08-30 19:59:40 -07:00
|
|
|
call Random
|
2020-05-07 08:09:41 -07:00
|
|
|
cp 8 percent
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
|
|
|
|
.asm_388c6
|
|
|
|
inc [hl]
|
2016-05-10 09:31:49 -07:00
|
|
|
inc [hl]
|
|
|
|
inc [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_DreamEater:
|
2014-10-21 11:44:42 -07:00
|
|
|
; 90% chance to greatly encourage this move.
|
2014-10-22 23:41:52 -07:00
|
|
|
; The AI_Basic layer will make sure that
|
2014-10-21 11:44:42 -07:00
|
|
|
; Dream Eater is only used against sleeping targets.
|
2013-08-30 19:59:40 -07:00
|
|
|
call Random
|
2017-12-25 13:18:05 -08:00
|
|
|
cp 10 percent
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
dec [hl]
|
2016-05-10 09:31:49 -07:00
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_EvasionUp:
|
2014-10-22 05:47:33 -07:00
|
|
|
; Dismiss this move if enemy's evasion can't raise anymore.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyEvaLevel]
|
2020-05-07 08:09:41 -07:00
|
|
|
cp MAX_STAT_LEVEL
|
2013-05-06 11:33:19 -07:00
|
|
|
jp nc, AIDiscourageMove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2014-10-22 05:47:33 -07:00
|
|
|
; If enemy's HP is full...
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckEnemyMaxHP
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nc, .asm_388f2
|
|
|
|
|
2014-10-22 05:47:33 -07:00
|
|
|
; ...greatly encourage this move if player is badly poisoned.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerSubStatus5]
|
2014-06-12 18:32:42 -07:00
|
|
|
bit SUBSTATUS_TOXIC, a
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nz, .asm_388ef
|
|
|
|
|
2014-10-22 05:47:33 -07:00
|
|
|
; ...70% chance to greatly encourage this move if player is not badly poisoned.
|
2013-08-30 19:59:40 -07:00
|
|
|
call Random
|
2017-12-25 13:18:05 -08:00
|
|
|
cp 70 percent
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nc, .asm_38911
|
|
|
|
|
|
|
|
.asm_388ef
|
|
|
|
dec [hl]
|
2016-05-04 08:46:23 -07:00
|
|
|
dec [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_388f2
|
2014-10-22 05:47:33 -07:00
|
|
|
|
|
|
|
; Greatly discourage this move if enemy's HP is below 25%.
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckEnemyQuarterHP
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nc, .asm_3890f
|
|
|
|
|
2014-10-22 05:47:33 -07:00
|
|
|
; If enemy's HP is above 25% but not full, 4% chance to greatly encourage this move.
|
2013-08-30 19:59:40 -07:00
|
|
|
call Random
|
2017-12-25 13:18:05 -08:00
|
|
|
cp 4 percent
|
2013-05-05 16:56:17 -07:00
|
|
|
jr c, .asm_388ef
|
|
|
|
|
2014-10-22 05:47:33 -07:00
|
|
|
; If enemy's HP is between 25% and 50%,...
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckEnemyHalfHP
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nc, .asm_3890a
|
|
|
|
|
2014-10-22 05:47:33 -07:00
|
|
|
; If enemy's HP is above 50% but not full, 20% chance to greatly encourage this move.
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_80_20
|
2013-05-05 16:56:17 -07:00
|
|
|
jr c, .asm_388ef
|
|
|
|
jr .asm_38911
|
|
|
|
|
|
|
|
.asm_3890a
|
2014-10-22 05:47:33 -07:00
|
|
|
; ...50% chance to greatly discourage this move.
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_50_50
|
2013-05-05 16:56:17 -07:00
|
|
|
jr c, .asm_38911
|
|
|
|
|
|
|
|
.asm_3890f
|
|
|
|
inc [hl]
|
2016-05-04 08:46:23 -07:00
|
|
|
inc [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
; 30% chance to end up here if enemy's HP is full and player is not badly poisoned.
|
2014-10-22 05:47:33 -07:00
|
|
|
; 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 16:56:17 -07:00
|
|
|
.asm_38911
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerSubStatus5]
|
2014-06-12 18:32:42 -07:00
|
|
|
bit SUBSTATUS_TOXIC, a
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nz, .asm_38938
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerSubStatus4]
|
2014-06-12 18:32:42 -07:00
|
|
|
bit SUBSTATUS_LEECH_SEED, a
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nz, .asm_38941
|
|
|
|
|
2014-10-22 05:47:33 -07:00
|
|
|
; Discourage this move if enemy's evasion level is higher than player's accuracy level.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyEvaLevel]
|
2013-05-05 16:56:17 -07:00
|
|
|
ld b, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerAccLevel]
|
2013-05-05 16:56:17 -07:00
|
|
|
cp b
|
|
|
|
jr c, .asm_38936
|
|
|
|
|
2014-10-22 05:47:33 -07:00
|
|
|
; Greatly encourage this move if the player is in the middle of Fury Cutter or Rollout.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerFuryCutterCount]
|
2013-05-05 16:56:17 -07:00
|
|
|
and a
|
|
|
|
jr nz, .asm_388ef
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerSubStatus1]
|
2014-06-17 12:52:32 -07:00
|
|
|
bit SUBSTATUS_ROLLOUT, a
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nz, .asm_388ef
|
|
|
|
|
|
|
|
.asm_38936
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
2014-10-22 05:47:33 -07:00
|
|
|
; Player is badly poisoned.
|
2017-12-25 13:18:05 -08:00
|
|
|
; 70% chance to greatly encourage this move.
|
2014-10-22 05:47:33 -07:00
|
|
|
; This would counter any previous discouragement.
|
2013-05-05 16:56:17 -07:00
|
|
|
.asm_38938
|
2013-08-30 19:59:40 -07:00
|
|
|
call Random
|
2017-12-25 13:18:05 -08:00
|
|
|
cp 31 percent + 1
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
dec [hl]
|
2016-05-04 08:46:23 -07:00
|
|
|
dec [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
ret
|
|
|
|
|
2014-10-22 05:47:33 -07:00
|
|
|
; Player is seeded.
|
|
|
|
; 50% chance to encourage this move.
|
|
|
|
; This would partly counter any previous discouragement.
|
2013-05-05 16:56:17 -07:00
|
|
|
.asm_38941
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_50_50
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
2014-06-17 12:52:32 -07:00
|
|
|
|
2013-05-05 16:56:17 -07:00
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_AlwaysHit:
|
2014-10-21 05:17:55 -07:00
|
|
|
; 80% chance to greatly encourage this move if either...
|
|
|
|
|
2014-10-21 15:28:51 -07:00
|
|
|
; ...enemy's accuracy level has been lowered three or more stages
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyAccLevel]
|
2020-05-07 08:09:41 -07:00
|
|
|
cp BASE_STAT_LEVEL - 2
|
2013-05-05 16:56:17 -07:00
|
|
|
jr c, .asm_38954
|
|
|
|
|
2014-10-21 15:28:51 -07:00
|
|
|
; ...or player's evasion level has been raised three or more stages.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerEvaLevel]
|
2020-05-07 08:09:41 -07:00
|
|
|
cp BASE_STAT_LEVEL + 3
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
|
|
|
|
.asm_38954
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_80_20
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
2014-08-13 19:44:56 -07:00
|
|
|
|
2013-05-05 16:56:17 -07:00
|
|
|
dec [hl]
|
2016-05-04 08:46:23 -07:00
|
|
|
dec [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_MirrorMove:
|
2014-10-21 15:28:51 -07:00
|
|
|
; If the player did not use any move last turn...
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wLastPlayerCounterMove]
|
2013-05-05 16:56:17 -07:00
|
|
|
and a
|
|
|
|
jr nz, .asm_38968
|
|
|
|
|
2014-10-21 15:28:51 -07:00
|
|
|
; ...do nothing if enemy is slower than player
|
2016-04-10 11:42:14 -07:00
|
|
|
call AICompareSpeed
|
2013-05-05 16:56:17 -07:00
|
|
|
ret nc
|
|
|
|
|
2014-10-21 15:28:51 -07:00
|
|
|
; ...or dismiss this move if enemy is faster than player.
|
2014-06-12 18:32:42 -07:00
|
|
|
jp AIDiscourageMove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2014-10-21 15:28:51 -07:00
|
|
|
; If the player did use a move last turn...
|
2013-05-05 16:56:17 -07:00
|
|
|
.asm_38968
|
|
|
|
push hl
|
2014-10-21 15:28:51 -07:00
|
|
|
ld hl, UsefulMoves
|
2013-05-05 23:39:01 -07:00
|
|
|
ld de, 1
|
2013-05-05 16:56:17 -07:00
|
|
|
call IsInArray
|
|
|
|
pop hl
|
2016-04-10 11:42:14 -07:00
|
|
|
|
2014-10-21 15:28:51 -07:00
|
|
|
; ...do nothing if he didn't use a useful move.
|
2013-05-05 16:56:17 -07:00
|
|
|
ret nc
|
|
|
|
|
2014-10-21 15:28:51 -07:00
|
|
|
; If he did, 50% chance to encourage this move...
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_50_50
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
2014-06-12 18:32:42 -07:00
|
|
|
|
2013-05-05 16:56:17 -07:00
|
|
|
dec [hl]
|
2014-10-21 15:28:51 -07:00
|
|
|
|
|
|
|
; ...and 90% chance to encourage this move again if the enemy is faster.
|
2013-05-06 17:51:07 -07:00
|
|
|
call AICompareSpeed
|
2013-05-05 16:56:17 -07:00
|
|
|
ret nc
|
|
|
|
|
2014-06-12 18:32:42 -07:00
|
|
|
call Random
|
2017-12-25 13:18:05 -08:00
|
|
|
cp 10 percent
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
2014-06-12 18:32:42 -07:00
|
|
|
|
2013-05-05 16:56:17 -07:00
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_AccuracyDown:
|
2014-10-22 05:47:33 -07:00
|
|
|
; If player's HP is full...
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckPlayerMaxHP
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nc, .asm_389a0
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
; ...and enemy's HP is above 50%...
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckEnemyHalfHP
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nc, .asm_389a0
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
; ...greatly encourage this move if player is badly poisoned.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerSubStatus5]
|
2014-06-12 18:32:42 -07:00
|
|
|
bit SUBSTATUS_TOXIC, a
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nz, .asm_3899d
|
|
|
|
|
2014-10-22 05:47:33 -07:00
|
|
|
; ...70% chance to greatly encourage this move if player is not badly poisoned.
|
2013-08-30 19:59:40 -07:00
|
|
|
call Random
|
2017-12-25 13:18:05 -08:00
|
|
|
cp 70 percent
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nc, .asm_389bf
|
|
|
|
|
|
|
|
.asm_3899d
|
|
|
|
dec [hl]
|
2016-05-04 08:46:23 -07:00
|
|
|
dec [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_389a0
|
2014-10-22 05:47:33 -07:00
|
|
|
|
|
|
|
; Greatly discourage this move if player's HP is below 25%.
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckPlayerQuarterHP
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nc, .asm_389bd
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
; If player's HP is above 25% but not full, 4% chance to greatly encourage this move.
|
2013-08-30 19:59:40 -07:00
|
|
|
call Random
|
2017-12-25 13:18:05 -08:00
|
|
|
cp 4 percent
|
2013-05-05 16:56:17 -07:00
|
|
|
jr c, .asm_3899d
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
; If player's HP is between 25% and 50%,...
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckPlayerHalfHP
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nc, .asm_389b8
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
; If player's HP is above 50% but not full, 20% chance to greatly encourage this move.
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_80_20
|
2013-05-05 16:56:17 -07:00
|
|
|
jr c, .asm_3899d
|
|
|
|
jr .asm_389bf
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
; ...50% chance to greatly discourage this move.
|
2013-05-05 16:56:17 -07:00
|
|
|
.asm_389b8
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_50_50
|
2013-05-05 16:56:17 -07:00
|
|
|
jr c, .asm_389bf
|
|
|
|
|
|
|
|
.asm_389bd
|
|
|
|
inc [hl]
|
2016-05-04 08:46:23 -07:00
|
|
|
inc [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
; We only end up here if the move has not been already encouraged.
|
2013-05-05 16:56:17 -07:00
|
|
|
.asm_389bf
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerSubStatus5]
|
2014-06-12 18:32:42 -07:00
|
|
|
bit SUBSTATUS_TOXIC, a
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nz, .asm_389e6
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerSubStatus4]
|
2014-06-12 18:32:42 -07:00
|
|
|
bit SUBSTATUS_LEECH_SEED, a
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nz, .asm_389ef
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
; Discourage this move if enemy's evasion level is higher than player's accuracy level.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyEvaLevel]
|
2013-05-05 16:56:17 -07:00
|
|
|
ld b, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerAccLevel]
|
2013-05-05 16:56:17 -07:00
|
|
|
cp b
|
|
|
|
jr c, .asm_389e4
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
; Greatly encourage this move if the player is in the middle of Fury Cutter or Rollout.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerFuryCutterCount]
|
2013-05-05 16:56:17 -07:00
|
|
|
and a
|
|
|
|
jr nz, .asm_3899d
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerSubStatus1]
|
2014-06-17 12:52:32 -07:00
|
|
|
bit SUBSTATUS_ROLLOUT, a
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nz, .asm_3899d
|
|
|
|
|
|
|
|
.asm_389e4
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
2014-10-22 05:47:33 -07:00
|
|
|
; Player is badly poisoned.
|
2017-12-25 13:18:05 -08:00
|
|
|
; 70% chance to greatly encourage this move.
|
2016-04-10 11:42:14 -07:00
|
|
|
; This would counter any previous discouragement.
|
2013-05-05 16:56:17 -07:00
|
|
|
.asm_389e6
|
2013-08-30 19:59:40 -07:00
|
|
|
call Random
|
2017-12-25 13:18:05 -08:00
|
|
|
cp 31 percent + 1
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
dec [hl]
|
2016-05-04 08:46:23 -07:00
|
|
|
dec [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
ret
|
|
|
|
|
2014-10-22 05:47:33 -07:00
|
|
|
; Player is seeded.
|
|
|
|
; 50% chance to encourage this move.
|
2016-04-10 11:42:14 -07:00
|
|
|
; This would partly counter any previous discouragement.
|
2013-05-05 16:56:17 -07:00
|
|
|
.asm_389ef
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_50_50
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
2014-06-12 18:32:42 -07:00
|
|
|
|
2013-05-05 16:56:17 -07:00
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_ResetStats:
|
2014-10-22 05:47:33 -07:00
|
|
|
; 85% chance to encourage this move if any of enemy's stat levels is lower than -2.
|
2013-05-05 16:56:17 -07:00
|
|
|
push hl
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyAtkLevel
|
2020-05-07 08:09:41 -07:00
|
|
|
ld c, NUM_LEVEL_STATS
|
2013-05-05 16:56:17 -07:00
|
|
|
.asm_389fb
|
|
|
|
dec c
|
|
|
|
jr z, .asm_38a05
|
|
|
|
ld a, [hli]
|
2020-05-07 08:09:41 -07:00
|
|
|
cp BASE_STAT_LEVEL - 2
|
2013-05-05 16:56:17 -07:00
|
|
|
jr c, .asm_38a12
|
|
|
|
jr .asm_389fb
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
; 85% chance to encourage this move if any of player's stat levels is higher than +2.
|
2013-05-05 16:56:17 -07:00
|
|
|
.asm_38a05
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPlayerAtkLevel
|
2013-05-05 16:56:17 -07:00
|
|
|
ld c, $8
|
|
|
|
.asm_38a0a
|
|
|
|
dec c
|
|
|
|
jr z, .asm_38a1b
|
|
|
|
ld a, [hli]
|
2020-05-07 08:09:41 -07:00
|
|
|
cp BASE_STAT_LEVEL + 3
|
2013-05-05 16:56:17 -07:00
|
|
|
jr c, .asm_38a0a
|
|
|
|
|
|
|
|
.asm_38a12
|
|
|
|
pop hl
|
2013-08-30 19:59:40 -07:00
|
|
|
call Random
|
2017-12-25 13:18:05 -08:00
|
|
|
cp 16 percent
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
2014-10-22 05:47:33 -07: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 16:56:17 -07:00
|
|
|
.asm_38a1b
|
|
|
|
pop hl
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_Bide:
|
2014-10-21 11:44:42 -07:00
|
|
|
; 90% chance to discourage this move unless enemy's HP is full.
|
2014-10-21 05:17:55 -07:00
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckEnemyMaxHP
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
2013-08-30 19:59:40 -07:00
|
|
|
call Random
|
2017-12-25 13:18:05 -08:00
|
|
|
cp 10 percent
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_ForceSwitch:
|
2014-10-22 08:36:42 -07:00
|
|
|
; Whirlwind, Roar.
|
|
|
|
|
2015-07-18 20:45:39 -07:00
|
|
|
; Discourage this move if the player has not shown
|
2014-10-22 05:47:33 -07:00
|
|
|
; a super-effective move against the enemy.
|
2015-07-18 20:45:39 -07:00
|
|
|
; Consider player's type(s) if its moves are unknown.
|
2014-10-22 05:47:33 -07:00
|
|
|
|
2013-05-05 16:56:17 -07:00
|
|
|
push hl
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar CheckPlayerMoveTypeMatchups
|
2016-01-12 09:46:18 -08:00
|
|
|
ld a, [wEnemyAISwitchScore]
|
2014-10-22 08:36:42 -07:00
|
|
|
cp 10 ; neutral
|
2013-05-05 16:56:17 -07:00
|
|
|
pop hl
|
|
|
|
ret c
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
AI_Smart_Heal:
|
|
|
|
AI_Smart_MorningSun:
|
|
|
|
AI_Smart_Synthesis:
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_Moonlight:
|
2014-10-21 15:28:51 -07: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 11:33:19 -07:00
|
|
|
call AICheckEnemyQuarterHP
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nc, .asm_38a45
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckEnemyHalfHP
|
2013-05-05 16:56:17 -07:00
|
|
|
ret nc
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38a45
|
2013-08-30 19:59:40 -07:00
|
|
|
call Random
|
2017-12-25 13:18:05 -08:00
|
|
|
cp 10 percent
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
dec [hl]
|
2016-05-04 08:46:23 -07:00
|
|
|
dec [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
ret
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
AI_Smart_Toxic:
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_LeechSeed:
|
2014-10-21 11:44:42 -07:00
|
|
|
; Discourage this move if player's HP is below 50%.
|
2014-10-21 05:17:55 -07:00
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckPlayerHalfHP
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
AI_Smart_LightScreen:
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_Reflect:
|
2014-10-21 11:44:42 -07:00
|
|
|
; Over 90% chance to discourage this move unless enemy's HP is full.
|
2014-10-21 10:21:13 -07:00
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckEnemyMaxHP
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
2013-08-30 19:59:40 -07:00
|
|
|
call Random
|
2017-12-25 13:18:05 -08:00
|
|
|
cp 8 percent
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_Ohko:
|
2014-10-22 08:36:42 -07:00
|
|
|
; Dismiss this move if player's level is higher than enemy's level.
|
2014-10-22 14:08:51 -07:00
|
|
|
; Else, discourage this move is player's HP is below 50%.
|
2014-10-21 15:28:51 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wBattleMonLevel]
|
2013-05-05 16:56:17 -07:00
|
|
|
ld b, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyMonLevel]
|
2013-05-05 16:56:17 -07:00
|
|
|
cp b
|
2013-05-06 11:33:19 -07:00
|
|
|
jp c, AIDiscourageMove
|
|
|
|
call AICheckPlayerHalfHP
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_TrapTarget:
|
2014-10-22 08:36:42 -07:00
|
|
|
; Bind, Wrap, Fire Spin, Clamp
|
|
|
|
|
2014-10-22 14:08:51 -07:00
|
|
|
; 50% chance to discourage this move if the player is already trapped.
|
2015-11-08 10:27:26 -08:00
|
|
|
ld a, [wPlayerWrapCount]
|
2013-05-05 16:56:17 -07:00
|
|
|
and a
|
|
|
|
jr nz, .asm_38a8b
|
|
|
|
|
2014-10-22 14:08:51 -07:00
|
|
|
; 50% chance to greatly encourage this move if player is either
|
|
|
|
; badly poisoned, in love, identified, stuck in Rollout, or has a Nightmare.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerSubStatus5]
|
2013-05-05 23:39:01 -07:00
|
|
|
bit SUBSTATUS_TOXIC, a
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nz, .asm_38a91
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerSubStatus1]
|
2018-05-23 09:48:14 -07:00
|
|
|
and 1 << SUBSTATUS_IN_LOVE | 1 << SUBSTATUS_ROLLOUT | 1 << SUBSTATUS_IDENTIFIED | 1 << SUBSTATUS_NIGHTMARE
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nz, .asm_38a91
|
|
|
|
|
2014-10-22 14:08:51 -07:00
|
|
|
; Else, 50% chance to greatly encourage this move if it's the player's Pokemon first turn.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerTurnsTaken]
|
2013-05-05 16:56:17 -07:00
|
|
|
and a
|
|
|
|
jr z, .asm_38a91
|
|
|
|
|
2014-10-22 14:08:51 -07:00
|
|
|
; 50% chance to discourage this move otherwise.
|
2013-05-05 16:56:17 -07:00
|
|
|
.asm_38a8b
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_50_50
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38a91
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckEnemyQuarterHP
|
2013-05-05 16:56:17 -07:00
|
|
|
ret nc
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_50_50
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
dec [hl]
|
2016-05-04 08:46:23 -07:00
|
|
|
dec [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
ret
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
AI_Smart_RazorWind:
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_Unused2B:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemySubStatus1]
|
2013-05-05 23:39:01 -07:00
|
|
|
bit SUBSTATUS_PERISH, a
|
2013-05-05 16:56:17 -07:00
|
|
|
jr z, .asm_38aaa
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyPerishCount]
|
2013-05-05 23:39:01 -07:00
|
|
|
cp 3
|
2013-05-05 16:56:17 -07:00
|
|
|
jr c, .asm_38ad3
|
|
|
|
|
|
|
|
.asm_38aaa
|
|
|
|
push hl
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPlayerUsedMoves
|
2020-05-17 17:59:15 -07:00
|
|
|
ld c, NUM_MOVES
|
2013-05-05 16:56:17 -07:00
|
|
|
|
|
|
|
.asm_38ab0
|
|
|
|
ld a, [hli]
|
|
|
|
and a
|
|
|
|
jr z, .asm_38ac1
|
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
call AIGetEnemyMove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2014-06-12 18:32:42 -07:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_EFFECT]
|
2013-05-05 23:39:01 -07:00
|
|
|
cp EFFECT_PROTECT
|
2013-05-05 16:56:17 -07:00
|
|
|
jr z, .asm_38ad5
|
|
|
|
dec c
|
|
|
|
jr nz, .asm_38ab0
|
|
|
|
|
|
|
|
.asm_38ac1
|
|
|
|
pop hl
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemySubStatus3]
|
2013-05-05 23:39:01 -07:00
|
|
|
bit SUBSTATUS_CONFUSED, a
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nz, .asm_38acd
|
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckEnemyHalfHP
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
|
|
|
|
.asm_38acd
|
2013-08-30 19:59:40 -07:00
|
|
|
call Random
|
2017-12-25 13:18:05 -08:00
|
|
|
cp 79 percent - 1
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
|
|
|
|
.asm_38ad3
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38ad5
|
|
|
|
pop hl
|
|
|
|
ld a, [hl]
|
2013-05-05 23:39:01 -07:00
|
|
|
add 6
|
2013-05-05 16:56:17 -07:00
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_Confuse:
|
2014-10-21 15:28:51 -07:00
|
|
|
; 90% chance to discourage this move if player's HP is between 25% and 50%.
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckPlayerHalfHP
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
2013-08-30 19:59:40 -07:00
|
|
|
call Random
|
2017-12-25 13:18:05 -08:00
|
|
|
cp 10 percent
|
2013-05-05 16:56:17 -07:00
|
|
|
jr c, .asm_38ae7
|
|
|
|
inc [hl]
|
2016-04-10 11:42:14 -07:00
|
|
|
|
2013-05-05 16:56:17 -07:00
|
|
|
.asm_38ae7
|
2014-10-21 15:28:51 -07:00
|
|
|
; Discourage again if player's HP is below 25%.
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckPlayerQuarterHP
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_SpDefenseUp2:
|
2014-10-22 08:36:42 -07:00
|
|
|
; Discourage this move if enemy's HP is lower than 50%.
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckEnemyHalfHP
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nc, .asm_38b10
|
|
|
|
|
2014-10-22 08:36:42 -07:00
|
|
|
; Discourage this move if enemy's special defense level is higher than +3.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemySDefLevel]
|
2020-05-07 08:09:41 -07:00
|
|
|
cp BASE_STAT_LEVEL + 4
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nc, .asm_38b10
|
2014-10-22 08:36:42 -07:00
|
|
|
|
|
|
|
; 80% chance to greatly encourage this move if
|
|
|
|
; enemy's Special Defense level is lower than +2, and the player is of a special type.
|
2020-05-07 08:09:41 -07:00
|
|
|
cp BASE_STAT_LEVEL + 2
|
2013-05-05 16:56:17 -07:00
|
|
|
ret nc
|
2013-05-05 23:39:01 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wBattleMonType1]
|
2014-06-12 18:32:42 -07:00
|
|
|
cp SPECIAL
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nc, .asm_38b09
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wBattleMonType2]
|
2014-06-12 18:32:42 -07:00
|
|
|
cp SPECIAL
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
|
|
|
|
.asm_38b09
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_80_20
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
dec [hl]
|
2016-05-04 08:46:23 -07:00
|
|
|
dec [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38b10
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_Fly:
|
2014-10-22 14:08:51 -07:00
|
|
|
; Fly, Dig
|
|
|
|
|
2014-10-21 15:28:51 -07:00
|
|
|
; Greatly encourage this move if the player is
|
|
|
|
; flying or underground, and slower than the enemy.
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerSubStatus3]
|
2014-05-05 00:30:51 -07:00
|
|
|
and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND
|
2013-05-05 16:56:17 -07:00
|
|
|
ret z
|
2016-04-10 11:42:14 -07:00
|
|
|
|
2013-05-06 17:51:07 -07:00
|
|
|
call AICompareSpeed
|
2013-05-05 16:56:17 -07:00
|
|
|
ret nc
|
2016-04-10 11:42:14 -07:00
|
|
|
|
2013-05-05 16:56:17 -07:00
|
|
|
dec [hl]
|
2016-05-10 09:31:49 -07:00
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_SuperFang:
|
2014-10-21 15:28:51 -07:00
|
|
|
; Discourage this move if player's HP is below 25%.
|
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckPlayerQuarterHP
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_Paralyze:
|
2014-10-21 15:28:51 -07:00
|
|
|
; 50% chance to discourage this move if player's HP is below 25%.
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckPlayerQuarterHP
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nc, .asm_38b3a
|
2016-04-10 11:42:14 -07:00
|
|
|
|
2015-07-18 20:45:39 -07:00
|
|
|
; 80% chance to greatly encourage this move
|
2016-04-10 11:42:14 -07:00
|
|
|
; if enemy is slower than player and its HP is above 25%.
|
2013-05-06 17:51:07 -07:00
|
|
|
call AICompareSpeed
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckEnemyQuarterHP
|
2013-05-05 16:56:17 -07:00
|
|
|
ret nc
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_80_20
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
dec [hl]
|
2016-05-04 08:46:23 -07:00
|
|
|
dec [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38b3a
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_50_50
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_SpeedDownHit:
|
2014-10-22 08:36:42 -07:00
|
|
|
; Icy Wind
|
|
|
|
|
|
|
|
; Almost 90% chance to greatly encourage this move if the following conditions all meet:
|
|
|
|
; Enemy's HP is higher than 25%.
|
|
|
|
; It's the first turn of player's Pokemon.
|
|
|
|
; Player is faster than enemy.
|
|
|
|
|
2014-06-12 18:32:42 -07:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_ANIM]
|
2013-05-06 17:51:07 -07:00
|
|
|
cp ICY_WIND
|
2013-05-05 16:56:17 -07:00
|
|
|
ret nz
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckEnemyQuarterHP
|
2013-05-05 16:56:17 -07:00
|
|
|
ret nc
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerTurnsTaken]
|
2013-05-05 16:56:17 -07:00
|
|
|
and a
|
|
|
|
ret nz
|
2013-05-06 17:51:07 -07:00
|
|
|
call AICompareSpeed
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
2013-08-30 19:59:40 -07:00
|
|
|
call Random
|
2017-12-25 13:18:05 -08:00
|
|
|
cp 12 percent
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
dec [hl]
|
2016-05-04 08:46:23 -07:00
|
|
|
dec [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_Substitute:
|
2014-10-21 15:28:51 -07:00
|
|
|
; Dismiss this move if enemy's HP is below 50%.
|
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckEnemyHalfHP
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
2013-05-06 11:33:19 -07:00
|
|
|
jp AIDiscourageMove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_HyperBeam:
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckEnemyHalfHP
|
2013-05-05 16:56:17 -07:00
|
|
|
jr c, .asm_38b72
|
2016-04-10 11:42:14 -07:00
|
|
|
|
|
|
|
; 50% chance to encourage this move if enemy's HP is below 25%.
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckEnemyQuarterHP
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_50_50
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38b72
|
2014-10-21 15:28:51 -07:00
|
|
|
; If enemy's HP is above 50%, discourage this move at random
|
2013-08-30 19:59:40 -07:00
|
|
|
call Random
|
2017-12-25 13:18:05 -08:00
|
|
|
cp 16 percent
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
inc [hl]
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_50_50
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_Rage:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemySubStatus4]
|
2014-06-17 12:52:32 -07:00
|
|
|
bit SUBSTATUS_RAGE, a
|
2013-05-05 16:56:17 -07:00
|
|
|
jr z, .asm_38b9b
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
; If enemy's Rage is building, 50% chance to encourage this move.
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_50_50
|
2013-05-05 16:56:17 -07:00
|
|
|
jr c, .asm_38b8c
|
|
|
|
|
|
|
|
dec [hl]
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
; Encourage this move based on Rage's counter.
|
2013-05-05 16:56:17 -07:00
|
|
|
.asm_38b8c
|
2015-11-05 16:13:09 -08:00
|
|
|
ld a, [wEnemyRageCounter]
|
2020-05-07 08:09:41 -07:00
|
|
|
cp 2
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
dec [hl]
|
2015-11-05 16:13:09 -08:00
|
|
|
ld a, [wEnemyRageCounter]
|
2020-05-07 08:09:41 -07:00
|
|
|
cp 3
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38b9b
|
2014-10-22 08:36:42 -07:00
|
|
|
; If enemy's Rage is not building, discourage this move if enemy's HP is below 50%.
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckEnemyHalfHP
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nc, .asm_38ba6
|
|
|
|
|
2014-10-22 08:36:42 -07:00
|
|
|
; 50% chance to encourage this move otherwise.
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_80_20
|
2013-05-05 16:56:17 -07:00
|
|
|
ret nc
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38ba6
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_Mimic:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wLastPlayerCounterMove]
|
2013-05-05 16:56:17 -07:00
|
|
|
and a
|
|
|
|
jr z, .asm_38be9
|
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckEnemyHalfHP
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nc, .asm_38bef
|
|
|
|
|
|
|
|
push hl
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wLastPlayerCounterMove]
|
2013-05-06 11:33:19 -07:00
|
|
|
call AIGetEnemyMove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
|
|
|
ld a, $1
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hBattleTurn], a
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar BattleCheckTypeMatchup
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2018-07-28 16:27:34 -07:00
|
|
|
ld a, [wTypeMatchup]
|
|
|
|
cp EFFECTIVE
|
2013-05-05 16:56:17 -07:00
|
|
|
pop hl
|
|
|
|
jr c, .asm_38bef
|
|
|
|
jr z, .asm_38bd4
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_50_50
|
2013-05-05 16:56:17 -07:00
|
|
|
jr c, .asm_38bd4
|
|
|
|
|
|
|
|
dec [hl]
|
|
|
|
|
|
|
|
.asm_38bd4
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wLastPlayerCounterMove]
|
2013-05-05 16:56:17 -07:00
|
|
|
push hl
|
2014-10-21 15:28:51 -07:00
|
|
|
ld hl, UsefulMoves
|
2013-05-05 23:39:01 -07:00
|
|
|
ld de, 1
|
2013-05-05 16:56:17 -07:00
|
|
|
call IsInArray
|
|
|
|
|
|
|
|
pop hl
|
|
|
|
ret nc
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_50_50
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38be9
|
2013-05-06 17:51:07 -07:00
|
|
|
call AICompareSpeed
|
2013-05-06 11:33:19 -07:00
|
|
|
jp c, AIDiscourageMove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
|
|
|
.asm_38bef
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_Counter:
|
2013-05-05 16:56:17 -07:00
|
|
|
push hl
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPlayerUsedMoves
|
2020-05-07 08:09:41 -07:00
|
|
|
ld c, NUM_MOVES
|
2013-05-05 23:39:01 -07:00
|
|
|
ld b, 0
|
2013-05-05 16:56:17 -07:00
|
|
|
|
|
|
|
.asm_38bf9
|
|
|
|
ld a, [hli]
|
|
|
|
and a
|
|
|
|
jr z, .asm_38c0e
|
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
call AIGetEnemyMove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2014-06-12 18:32:42 -07:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_POWER]
|
2013-05-05 16:56:17 -07:00
|
|
|
and a
|
|
|
|
jr z, .asm_38c0e
|
|
|
|
|
2014-06-12 18:32:42 -07:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_TYPE]
|
|
|
|
cp SPECIAL
|
2013-05-05 16:56:17 -07: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
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wLastPlayerCounterMove]
|
2013-05-05 16:56:17 -07:00
|
|
|
and a
|
|
|
|
jr z, .asm_38c38
|
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
call AIGetEnemyMove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2014-06-12 18:32:42 -07:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_POWER]
|
2013-05-05 16:56:17 -07:00
|
|
|
and a
|
|
|
|
jr z, .asm_38c38
|
|
|
|
|
2014-06-12 18:32:42 -07:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_TYPE]
|
|
|
|
cp SPECIAL
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nc, .asm_38c38
|
|
|
|
|
|
|
|
.asm_38c30
|
2013-08-30 19:59:40 -07:00
|
|
|
call Random
|
2017-12-25 13:18:05 -08:00
|
|
|
cp 39 percent + 1
|
2013-05-05 16:56:17 -07:00
|
|
|
jr c, .asm_38c38
|
|
|
|
|
|
|
|
dec [hl]
|
|
|
|
|
|
|
|
.asm_38c38
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38c39
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_Encore:
|
2013-05-06 17:51:07 -07:00
|
|
|
call AICompareSpeed
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nc, .asm_38c81
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wLastPlayerMove]
|
2013-05-05 16:56:17 -07:00
|
|
|
and a
|
2013-05-06 11:33:19 -07:00
|
|
|
jp z, AIDiscourageMove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
call AIGetEnemyMove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2014-06-12 18:32:42 -07:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_POWER]
|
2013-05-05 16:56:17 -07:00
|
|
|
and a
|
|
|
|
jr z, .asm_38c68
|
|
|
|
|
|
|
|
push hl
|
2014-06-12 18:32:42 -07:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_TYPE]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonType1
|
2018-01-16 11:30:10 -08:00
|
|
|
predef CheckTypeMatchup
|
2013-05-05 16:56:17 -07:00
|
|
|
|
|
|
|
pop hl
|
2018-07-28 16:27:34 -07:00
|
|
|
ld a, [wTypeMatchup]
|
|
|
|
cp EFFECTIVE
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nc, .asm_38c68
|
|
|
|
|
|
|
|
and a
|
|
|
|
ret nz
|
|
|
|
jr .asm_38c78
|
|
|
|
|
|
|
|
.asm_38c68
|
|
|
|
push hl
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wLastPlayerCounterMove]
|
2018-01-25 17:34:33 -08:00
|
|
|
ld hl, EncoreMoves
|
2013-05-05 23:39:01 -07:00
|
|
|
ld de, 1
|
2013-05-05 16:56:17 -07:00
|
|
|
call IsInArray
|
|
|
|
pop hl
|
|
|
|
jr nc, .asm_38c81
|
|
|
|
|
|
|
|
.asm_38c78
|
2013-08-30 19:59:40 -07:00
|
|
|
call Random
|
2017-12-25 13:18:05 -08:00
|
|
|
cp 28 percent - 1
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
dec [hl]
|
2016-05-04 08:46:23 -07:00
|
|
|
dec [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38c81
|
|
|
|
inc [hl]
|
2016-05-10 09:31:49 -07:00
|
|
|
inc [hl]
|
|
|
|
inc [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
ret
|
|
|
|
|
2018-01-25 17:34:33 -08:00
|
|
|
INCLUDE "data/battle/ai/encore_moves.asm"
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_PainSplit:
|
2014-10-22 08:36:42 -07:00
|
|
|
; Discourage this move if [enemy's current HP * 2 > player's current HP].
|
|
|
|
|
2013-05-05 16:56:17 -07:00
|
|
|
push hl
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonHP
|
2013-05-05 16:56:17 -07:00
|
|
|
ld b, [hl]
|
|
|
|
inc hl
|
|
|
|
ld c, [hl]
|
|
|
|
sla c
|
|
|
|
rl b
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonHP + 1
|
2013-05-05 16:56:17 -07:00
|
|
|
ld a, [hld]
|
|
|
|
cp c
|
|
|
|
ld a, [hl]
|
|
|
|
sbc b
|
|
|
|
pop hl
|
|
|
|
ret nc
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
AI_Smart_Snore:
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_SleepTalk:
|
2014-10-22 08:36:42 -07:00
|
|
|
; Greatly encourage this move if enemy is fast asleep.
|
|
|
|
; Greatly discourage this move otherwise.
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyMonStatus]
|
2020-05-07 08:09:41 -07:00
|
|
|
and SLP
|
|
|
|
cp 1
|
2013-05-05 16:56:17 -07:00
|
|
|
jr z, .asm_38cc7
|
|
|
|
|
|
|
|
dec [hl]
|
2016-05-10 09:31:49 -07:00
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38cc7
|
|
|
|
inc [hl]
|
2016-05-10 09:31:49 -07:00
|
|
|
inc [hl]
|
|
|
|
inc [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_DefrostOpponent:
|
2014-10-22 08:36:42 -07:00
|
|
|
; Greatly encourage this move if enemy is frozen.
|
|
|
|
; No move has EFFECT_DEFROST_OPPONENT, so this layer is unused.
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyMonStatus]
|
2018-05-19 10:11:50 -07:00
|
|
|
and 1 << FRZ
|
2013-05-05 16:56:17 -07:00
|
|
|
ret z
|
|
|
|
dec [hl]
|
2016-05-10 09:31:49 -07:00
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_Spite:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wLastPlayerCounterMove]
|
2013-05-05 16:56:17 -07:00
|
|
|
and a
|
|
|
|
jr nz, .asm_38ce7
|
|
|
|
|
2013-05-06 17:51:07 -07:00
|
|
|
call AICompareSpeed
|
2013-05-06 11:33:19 -07:00
|
|
|
jp c, AIDiscourageMove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_50_50
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38ce7
|
|
|
|
push hl
|
|
|
|
ld b, a
|
2020-05-17 17:59:15 -07:00
|
|
|
ld c, NUM_MOVES
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonMoves
|
|
|
|
ld de, wBattleMonPP
|
2013-05-05 16:56:17 -07: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]
|
2020-05-07 08:09:41 -07:00
|
|
|
cp 6
|
2013-05-05 16:56:17 -07:00
|
|
|
jr c, .asm_38d0d
|
2020-05-07 08:09:41 -07:00
|
|
|
cp 15
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nc, .asm_38d0b
|
|
|
|
|
2013-08-30 19:59:40 -07:00
|
|
|
call Random
|
2017-12-25 13:18:05 -08:00
|
|
|
cp 39 percent + 1
|
2013-05-05 16:56:17 -07:00
|
|
|
ret nc
|
|
|
|
|
|
|
|
.asm_38d0b
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38d0d
|
2013-08-30 19:59:40 -07:00
|
|
|
call Random
|
2017-12-25 13:18:05 -08:00
|
|
|
cp 39 percent + 1
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
dec [hl]
|
2016-05-04 08:46:23 -07:00
|
|
|
dec [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
ret
|
|
|
|
|
2018-07-15 04:18:28 -07:00
|
|
|
Function_0x38d16:
|
2013-05-06 11:33:19 -07:00
|
|
|
jp AIDiscourageMove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
AI_Smart_DestinyBond:
|
|
|
|
AI_Smart_Reversal:
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_SkullBash:
|
2014-10-22 08:36:42 -07:00
|
|
|
; Discourage this move if enemy's HP is above 25%.
|
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckEnemyQuarterHP
|
2013-05-05 16:56:17 -07:00
|
|
|
ret nc
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_HealBell:
|
2014-10-22 08:36:42 -07:00
|
|
|
; Dismiss this move if none of the opponent's Pokemon is statused.
|
|
|
|
; Encourage this move if the enemy is statused.
|
|
|
|
; 50% chance to greatly encourage this move if the enemy is fast asleep or frozen.
|
|
|
|
|
2013-05-05 16:56:17 -07:00
|
|
|
push hl
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wOTPartyCount]
|
2013-05-05 16:56:17 -07:00
|
|
|
ld b, a
|
2013-05-05 23:39:01 -07:00
|
|
|
ld c, 0
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wOTPartyMon1HP
|
2015-11-04 08:19:58 -08:00
|
|
|
ld de, PARTYMON_STRUCT_LENGTH
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2014-06-23 12:45:30 -07:00
|
|
|
.loop
|
2013-05-05 16:56:17 -07:00
|
|
|
push hl
|
|
|
|
ld a, [hli]
|
|
|
|
or [hl]
|
2014-06-23 12:45:30 -07:00
|
|
|
jr z, .next
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2014-10-22 23:41:52 -07:00
|
|
|
; status
|
2013-05-05 16:56:17 -07:00
|
|
|
dec hl
|
2016-05-10 09:31:49 -07:00
|
|
|
dec hl
|
|
|
|
dec hl
|
2013-05-05 16:56:17 -07:00
|
|
|
ld a, [hl]
|
|
|
|
or c
|
|
|
|
ld c, a
|
|
|
|
|
2014-06-23 12:45:30 -07:00
|
|
|
.next
|
2013-05-05 16:56:17 -07:00
|
|
|
pop hl
|
|
|
|
add hl, de
|
|
|
|
dec b
|
2014-06-23 12:45:30 -07:00
|
|
|
jr nz, .loop
|
2013-05-05 16:56:17 -07:00
|
|
|
|
|
|
|
pop hl
|
|
|
|
ld a, c
|
|
|
|
and a
|
2014-06-23 12:45:30 -07:00
|
|
|
jr z, .no_status
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyMonStatus]
|
2013-05-05 16:56:17 -07:00
|
|
|
and a
|
2014-06-23 12:45:30 -07:00
|
|
|
jr z, .ok
|
2013-05-05 16:56:17 -07:00
|
|
|
dec [hl]
|
2014-06-23 12:45:30 -07:00
|
|
|
.ok
|
|
|
|
and 1 << FRZ | SLP
|
2013-05-05 16:56:17 -07:00
|
|
|
ret z
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_50_50
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
dec [hl]
|
2016-05-04 08:46:23 -07:00
|
|
|
dec [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
ret
|
|
|
|
|
2014-06-23 12:45:30 -07:00
|
|
|
.no_status
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyMonStatus]
|
2013-05-05 16:56:17 -07:00
|
|
|
and a
|
|
|
|
ret nz
|
2013-05-06 11:33:19 -07:00
|
|
|
jp AIDiscourageMove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_PriorityHit:
|
2013-05-06 17:51:07 -07:00
|
|
|
call AICompareSpeed
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
2014-10-22 23:41:52 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
; Dismiss this move if the player is flying or underground.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerSubStatus3]
|
2014-05-05 00:30:51 -07:00
|
|
|
and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND
|
2013-05-06 11:33:19 -07:00
|
|
|
jp nz, AIDiscourageMove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
; Greatly encourage this move if it will KO the player.
|
2013-05-05 16:56:17 -07:00
|
|
|
ld a, $1
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hBattleTurn], a
|
2013-05-05 16:56:17 -07:00
|
|
|
push hl
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar EnemyAttackDamage
|
|
|
|
callfar BattleCommand_DamageCalc
|
|
|
|
callfar BattleCommand_Stab
|
2013-05-05 16:56:17 -07:00
|
|
|
pop hl
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurDamage + 1]
|
2013-05-05 16:56:17 -07:00
|
|
|
ld c, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurDamage]
|
2013-05-05 16:56:17 -07:00
|
|
|
ld b, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wBattleMonHP + 1]
|
2013-05-05 16:56:17 -07:00
|
|
|
cp c
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wBattleMonHP]
|
2013-05-05 16:56:17 -07:00
|
|
|
sbc b
|
|
|
|
ret nc
|
|
|
|
dec [hl]
|
2016-05-10 09:31:49 -07:00
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_Thief:
|
2014-10-21 11:44:42 -07:00
|
|
|
; Don't use Thief unless it's the only move available.
|
2014-10-21 15:28:51 -07:00
|
|
|
|
2013-05-05 16:56:17 -07:00
|
|
|
ld a, [hl]
|
|
|
|
add $1e
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_Conversion2:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wLastPlayerMove]
|
2013-05-05 16:56:17 -07:00
|
|
|
and a
|
|
|
|
jr nz, .asm_38dc9
|
|
|
|
|
|
|
|
push hl
|
|
|
|
dec a
|
2014-06-10 23:23:55 -07:00
|
|
|
ld hl, Moves + MOVE_TYPE
|
|
|
|
ld bc, MOVE_LENGTH
|
2013-05-05 16:56:17 -07:00
|
|
|
call AddNTimes
|
|
|
|
|
2013-05-05 23:39:01 -07:00
|
|
|
ld a, BANK(Moves)
|
2013-05-05 16:56:17 -07:00
|
|
|
call GetFarByte
|
2014-06-12 18:32:42 -07:00
|
|
|
ld [wPlayerMoveStruct + MOVE_TYPE], a
|
2013-05-05 23:39:01 -07:00
|
|
|
|
2013-05-05 16:56:17 -07:00
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hBattleTurn], a
|
2013-05-05 23:39:01 -07:00
|
|
|
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar BattleCheckTypeMatchup
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2018-07-28 16:27:34 -07:00
|
|
|
ld a, [wTypeMatchup]
|
|
|
|
cp EFFECTIVE
|
2013-05-05 16:56:17 -07:00
|
|
|
pop hl
|
|
|
|
jr c, .asm_38dc9
|
|
|
|
ret z
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_50_50
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
2014-08-13 19:44:56 -07:00
|
|
|
|
2013-05-05 16:56:17 -07:00
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38dc9
|
2013-08-30 19:59:40 -07:00
|
|
|
call Random
|
2017-12-25 13:18:05 -08:00
|
|
|
cp 10 percent
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_Disable:
|
2013-05-06 17:51:07 -07:00
|
|
|
call AICompareSpeed
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nc, .asm_38df3
|
|
|
|
|
|
|
|
push hl
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wLastPlayerCounterMove]
|
2014-10-21 15:28:51 -07:00
|
|
|
ld hl, UsefulMoves
|
2013-05-05 23:39:01 -07:00
|
|
|
ld de, 1
|
2013-05-05 16:56:17 -07:00
|
|
|
call IsInArray
|
|
|
|
|
|
|
|
pop hl
|
|
|
|
jr nc, .asm_38dee
|
|
|
|
|
2013-08-30 19:59:40 -07:00
|
|
|
call Random
|
2017-12-25 13:18:05 -08:00
|
|
|
cp 39 percent + 1
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38dee
|
2014-06-12 18:32:42 -07:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_POWER]
|
2013-05-05 16:56:17 -07:00
|
|
|
and a
|
|
|
|
ret nz
|
|
|
|
|
|
|
|
.asm_38df3
|
2013-08-30 19:59:40 -07:00
|
|
|
call Random
|
2017-12-25 13:18:05 -08:00
|
|
|
cp 8 percent
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_MeanLook:
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckEnemyHalfHP
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nc, .asm_38e24
|
|
|
|
|
|
|
|
push hl
|
2013-05-06 21:58:35 -07:00
|
|
|
call AICheckLastPlayerMon
|
2013-05-05 16:56:17 -07:00
|
|
|
pop hl
|
2013-05-06 11:33:19 -07:00
|
|
|
jp z, AIDiscourageMove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2017-12-12 19:58:20 -08:00
|
|
|
; 80% chance to greatly encourage this move if the enemy is badly poisoned (buggy).
|
2018-01-23 14:39:09 -08:00
|
|
|
; Should check wPlayerSubStatus5 instead.
|
|
|
|
ld a, [wEnemySubStatus5]
|
2013-05-06 21:58:35 -07:00
|
|
|
bit SUBSTATUS_TOXIC, a
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nz, .asm_38e26
|
|
|
|
|
2015-07-18 20:45:39 -07:00
|
|
|
; 80% chance to greatly encourage this move if the player is either
|
2016-04-10 11:42:14 -07:00
|
|
|
; in love, identified, stuck in Rollout, or has a Nightmare.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerSubStatus1]
|
2018-05-23 09:48:14 -07:00
|
|
|
and 1 << SUBSTATUS_IN_LOVE | 1 << SUBSTATUS_ROLLOUT | 1 << SUBSTATUS_IDENTIFIED | 1 << SUBSTATUS_NIGHTMARE
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nz, .asm_38e26
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
; Otherwise, discourage this move unless the player only has not very effective moves against the enemy.
|
2013-05-05 16:56:17 -07:00
|
|
|
push hl
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar CheckPlayerMoveTypeMatchups
|
2016-01-12 09:46:18 -08:00
|
|
|
ld a, [wEnemyAISwitchScore]
|
2014-10-22 08:36:42 -07:00
|
|
|
cp $b ; not very effective
|
2013-05-05 16:56:17 -07:00
|
|
|
pop hl
|
|
|
|
ret nc
|
|
|
|
|
|
|
|
.asm_38e24
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38e26
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_80_20
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
dec [hl]
|
2016-05-10 09:31:49 -07:00
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AICheckLastPlayerMon:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPartyCount]
|
2013-05-05 23:39:01 -07:00
|
|
|
ld b, a
|
|
|
|
ld c, 0
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPartyMon1HP
|
2015-11-04 08:19:58 -08:00
|
|
|
ld de, PARTYMON_STRUCT_LENGTH
|
2013-05-05 23:39:01 -07:00
|
|
|
|
|
|
|
.loop
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurBattleMon]
|
2013-05-05 23:39:01 -07:00
|
|
|
cp c
|
|
|
|
jr z, .asm_38e44
|
|
|
|
|
|
|
|
ld a, [hli]
|
|
|
|
or [hl]
|
|
|
|
ret nz
|
|
|
|
dec hl
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2013-05-05 23:39:01 -07:00
|
|
|
.asm_38e44
|
|
|
|
add hl, de
|
|
|
|
inc c
|
|
|
|
dec b
|
|
|
|
jr nz, .loop
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2013-05-05 23:39:01 -07:00
|
|
|
ret
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_Nightmare:
|
2014-10-22 08:36:42 -07:00
|
|
|
; 50% chance to encourage this move.
|
2014-10-22 23:41:52 -07:00
|
|
|
; The AI_Basic layer will make sure that
|
2014-10-22 08:36:42 -07:00
|
|
|
; Dream Eater is only used against sleeping targets.
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_50_50
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_FlameWheel:
|
2014-10-22 14:08:51 -07:00
|
|
|
; Use this move if the enemy is frozen.
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyMonStatus]
|
2013-05-06 21:58:35 -07:00
|
|
|
bit FRZ, a
|
2013-05-05 16:56:17 -07:00
|
|
|
ret z
|
2015-07-20 19:18:18 -07:00
|
|
|
rept 5
|
2013-05-05 16:56:17 -07:00
|
|
|
dec [hl]
|
2015-07-20 19:18:18 -07:00
|
|
|
endr
|
2013-05-05 16:56:17 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_Curse:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyMonType1]
|
2013-05-06 21:58:35 -07:00
|
|
|
cp GHOST
|
|
|
|
jr z, .ghostcurse
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyMonType2]
|
2013-05-06 21:58:35 -07:00
|
|
|
cp GHOST
|
|
|
|
jr z, .ghostcurse
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckEnemyHalfHP
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nc, .asm_38e93
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyAtkLevel]
|
2020-05-07 08:09:41 -07:00
|
|
|
cp BASE_STAT_LEVEL + 4
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nc, .asm_38e93
|
2020-05-07 08:09:41 -07:00
|
|
|
cp BASE_STAT_LEVEL + 2
|
2013-05-05 16:56:17 -07:00
|
|
|
ret nc
|
2013-05-06 21:58:35 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wBattleMonType1]
|
2013-05-06 21:58:35 -07:00
|
|
|
cp GHOST
|
2013-05-05 16:56:17 -07:00
|
|
|
jr z, .asm_38e92
|
2014-06-12 18:32:42 -07:00
|
|
|
cp SPECIAL
|
2013-05-05 16:56:17 -07:00
|
|
|
ret nc
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wBattleMonType2]
|
2014-06-12 18:32:42 -07:00
|
|
|
cp SPECIAL
|
2013-05-05 16:56:17 -07:00
|
|
|
ret nc
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_80_20
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
dec [hl]
|
2016-05-04 08:46:23 -07:00
|
|
|
dec [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38e90
|
|
|
|
inc [hl]
|
2016-05-04 08:46:23 -07:00
|
|
|
inc [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
.asm_38e92
|
|
|
|
inc [hl]
|
|
|
|
.asm_38e93
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
2013-05-06 21:58:35 -07:00
|
|
|
.ghostcurse
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerSubStatus1]
|
2013-05-06 21:58:35 -07:00
|
|
|
bit SUBSTATUS_CURSE, a
|
2013-05-06 11:33:19 -07:00
|
|
|
jp nz, AIDiscourageMove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
|
|
|
push hl
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall FindAliveEnemyMons
|
2013-05-05 16:56:17 -07:00
|
|
|
pop hl
|
|
|
|
jr nc, .asm_38eb0
|
|
|
|
|
|
|
|
push hl
|
2013-05-06 21:58:35 -07:00
|
|
|
call AICheckLastPlayerMon
|
2013-05-05 16:56:17 -07:00
|
|
|
pop hl
|
|
|
|
jr nz, .asm_38e90
|
|
|
|
|
|
|
|
jr .asm_38eb7
|
|
|
|
|
|
|
|
.asm_38eb0
|
|
|
|
push hl
|
2013-05-06 21:58:35 -07:00
|
|
|
call AICheckLastPlayerMon
|
2013-05-05 16:56:17 -07:00
|
|
|
pop hl
|
|
|
|
jr z, .asm_38ecb
|
|
|
|
|
|
|
|
.asm_38eb7
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckEnemyQuarterHP
|
2013-05-05 23:39:01 -07:00
|
|
|
jp nc, .asm_38e90
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckEnemyHalfHP
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nc, .asm_38e92
|
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckEnemyMaxHP
|
2013-05-05 16:56:17 -07:00
|
|
|
ret nc
|
2013-05-06 21:58:35 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerTurnsTaken]
|
2013-05-05 16:56:17 -07:00
|
|
|
and a
|
|
|
|
ret nz
|
|
|
|
|
|
|
|
.asm_38ecb
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_50_50
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
2014-08-13 19:44:56 -07:00
|
|
|
|
2013-05-05 16:56:17 -07:00
|
|
|
dec [hl]
|
2016-05-04 08:46:23 -07:00
|
|
|
dec [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_Protect:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyProtectCount]
|
2013-05-05 16:56:17 -07:00
|
|
|
and a
|
|
|
|
jr nz, .asm_38f13
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerSubStatus5]
|
2013-05-06 21:58:35 -07:00
|
|
|
bit SUBSTATUS_LOCK_ON, a
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nz, .asm_38f14
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerFuryCutterCount]
|
2013-05-06 21:58:35 -07:00
|
|
|
cp 3
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nc, .asm_38f0d
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerSubStatus3]
|
2013-05-06 21:58:35 -07:00
|
|
|
bit SUBSTATUS_CHARGED, a
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nz, .asm_38f0d
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerSubStatus5]
|
2013-05-06 21:58:35 -07:00
|
|
|
bit SUBSTATUS_TOXIC, a
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nz, .asm_38f0d
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerSubStatus4]
|
2013-05-06 21:58:35 -07:00
|
|
|
bit SUBSTATUS_LEECH_SEED, a
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nz, .asm_38f0d
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerSubStatus1]
|
2013-05-06 21:58:35 -07:00
|
|
|
bit SUBSTATUS_CURSE, a
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nz, .asm_38f0d
|
|
|
|
|
2014-06-17 12:52:32 -07:00
|
|
|
bit SUBSTATUS_ROLLOUT, a
|
2013-05-05 16:56:17 -07:00
|
|
|
jr z, .asm_38f14
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerRolloutCount]
|
2013-05-06 21:58:35 -07:00
|
|
|
cp 3
|
2013-05-05 16:56:17 -07:00
|
|
|
jr c, .asm_38f14
|
|
|
|
|
|
|
|
.asm_38f0d
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_80_20
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38f13
|
|
|
|
inc [hl]
|
|
|
|
|
|
|
|
.asm_38f14
|
2013-08-30 19:59:40 -07:00
|
|
|
call Random
|
2017-12-25 13:18:05 -08:00
|
|
|
cp 8 percent
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
inc [hl]
|
2016-05-04 08:46:23 -07:00
|
|
|
inc [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_Foresight:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyAccLevel]
|
2020-05-07 08:09:41 -07:00
|
|
|
cp BASE_STAT_LEVEL - 2
|
2013-05-05 16:56:17 -07:00
|
|
|
jr c, .asm_38f41
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerEvaLevel]
|
2020-05-07 08:09:41 -07:00
|
|
|
cp BASE_STAT_LEVEL + 3
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nc, .asm_38f41
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wBattleMonType1]
|
2013-05-06 21:58:35 -07:00
|
|
|
cp GHOST
|
2013-05-05 16:56:17 -07:00
|
|
|
jr z, .asm_38f41
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wBattleMonType2]
|
2013-05-06 21:58:35 -07:00
|
|
|
cp GHOST
|
2013-05-05 16:56:17 -07:00
|
|
|
jr z, .asm_38f41
|
|
|
|
|
2013-08-30 19:59:40 -07:00
|
|
|
call Random
|
2017-12-25 13:18:05 -08:00
|
|
|
cp 8 percent
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38f41
|
2013-08-30 19:59:40 -07:00
|
|
|
call Random
|
2017-12-25 13:18:05 -08:00
|
|
|
cp 39 percent + 1
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
dec [hl]
|
2016-05-04 08:46:23 -07:00
|
|
|
dec [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_PerishSong:
|
2013-05-05 16:56:17 -07:00
|
|
|
push hl
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar FindAliveEnemyMons
|
2013-05-05 16:56:17 -07:00
|
|
|
pop hl
|
2014-08-13 19:44:56 -07:00
|
|
|
jr c, .no
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerSubStatus5]
|
2014-06-17 12:52:32 -07:00
|
|
|
bit SUBSTATUS_CANT_RUN, a
|
2014-10-22 23:41:52 -07:00
|
|
|
jr nz, .yes
|
2013-05-05 16:56:17 -07:00
|
|
|
|
|
|
|
push hl
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar CheckPlayerMoveTypeMatchups
|
2016-01-12 09:46:18 -08:00
|
|
|
ld a, [wEnemyAISwitchScore]
|
2013-05-06 21:58:35 -07:00
|
|
|
cp 10 ; 1.0
|
2013-05-05 16:56:17 -07:00
|
|
|
pop hl
|
|
|
|
ret c
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_50_50
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
2013-05-06 21:58:35 -07:00
|
|
|
|
2013-05-05 16:56:17 -07:00
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
2014-10-22 23:41:52 -07:00
|
|
|
.yes
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_50_50
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
2014-06-17 12:52:32 -07:00
|
|
|
|
2013-05-05 16:56:17 -07:00
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
.no
|
2013-05-05 16:56:17 -07:00
|
|
|
ld a, [hl]
|
2013-05-06 21:58:35 -07:00
|
|
|
add 5
|
2013-05-05 16:56:17 -07:00
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_Sandstorm:
|
2014-10-22 14:08:51 -07:00
|
|
|
; Greatly discourage this move if the player is immune to Sandstorm damage.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wBattleMonType1]
|
2013-05-05 16:56:17 -07:00
|
|
|
push hl
|
2013-05-05 23:39:01 -07:00
|
|
|
ld hl, .SandstormImmuneTypes
|
|
|
|
ld de, 1
|
2013-05-05 16:56:17 -07:00
|
|
|
call IsInArray
|
|
|
|
pop hl
|
|
|
|
jr c, .asm_38fa5
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wBattleMonType2]
|
2013-05-05 16:56:17 -07:00
|
|
|
push hl
|
2013-05-05 23:39:01 -07:00
|
|
|
ld hl, .SandstormImmuneTypes
|
|
|
|
ld de, 1
|
2013-05-05 16:56:17 -07:00
|
|
|
call IsInArray
|
|
|
|
pop hl
|
|
|
|
jr c, .asm_38fa5
|
|
|
|
|
2014-10-22 14:08:51 -07:00
|
|
|
; Discourage this move if player's HP is below 50%.
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckPlayerHalfHP
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nc, .asm_38fa6
|
|
|
|
|
2014-10-22 14:08:51 -07:00
|
|
|
; 50% chance to encourage this move otherwise.
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_50_50
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
2013-05-05 23:39:01 -07:00
|
|
|
|
2013-05-05 16:56:17 -07:00
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38fa5
|
|
|
|
inc [hl]
|
|
|
|
|
|
|
|
.asm_38fa6
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.SandstormImmuneTypes:
|
2013-05-05 23:39:01 -07:00
|
|
|
db ROCK
|
|
|
|
db GROUND
|
|
|
|
db STEEL
|
2018-01-10 19:53:42 -08:00
|
|
|
db -1 ; end
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_Endure:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyProtectCount]
|
2013-05-05 16:56:17 -07:00
|
|
|
and a
|
|
|
|
jr nz, .asm_38fd8
|
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckEnemyMaxHP
|
2013-05-05 16:56:17 -07:00
|
|
|
jr c, .asm_38fd8
|
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckEnemyQuarterHP
|
2013-05-05 16:56:17 -07:00
|
|
|
jr c, .asm_38fd9
|
|
|
|
|
2013-05-06 21:58:35 -07:00
|
|
|
ld b, EFFECT_REVERSAL
|
2014-08-13 19:44:56 -07:00
|
|
|
call AIHasMoveEffect
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nc, .asm_38fcb
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_80_20
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
2013-05-06 21:58:35 -07:00
|
|
|
|
2013-05-05 16:56:17 -07:00
|
|
|
dec [hl]
|
2016-05-10 09:31:49 -07:00
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38fcb
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemySubStatus5]
|
2013-05-06 21:58:35 -07:00
|
|
|
bit SUBSTATUS_LOCK_ON, a
|
2013-05-05 16:56:17 -07:00
|
|
|
ret z
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_50_50
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
2014-08-13 19:44:56 -07:00
|
|
|
|
2013-05-05 16:56:17 -07:00
|
|
|
dec [hl]
|
2016-05-04 08:46:23 -07:00
|
|
|
dec [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_38fd8
|
|
|
|
inc [hl]
|
|
|
|
|
|
|
|
.asm_38fd9
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_FuryCutter:
|
2014-10-22 08:36:42 -07:00
|
|
|
; Encourage this move based on Fury Cutter's count.
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyFuryCutterCount]
|
2013-05-05 16:56:17 -07:00
|
|
|
and a
|
2013-05-06 21:58:35 -07:00
|
|
|
jr z, .end
|
2013-05-05 16:56:17 -07:00
|
|
|
dec [hl]
|
|
|
|
|
2013-05-06 21:58:35 -07:00
|
|
|
cp 2
|
|
|
|
jr c, .end
|
2013-05-05 16:56:17 -07:00
|
|
|
dec [hl]
|
2016-05-04 08:46:23 -07:00
|
|
|
dec [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2013-05-06 21:58:35 -07:00
|
|
|
cp 3
|
|
|
|
jr c, .end
|
2013-05-05 16:56:17 -07:00
|
|
|
dec [hl]
|
2016-05-10 09:31:49 -07:00
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2013-05-06 21:58:35 -07:00
|
|
|
.end
|
|
|
|
|
2013-05-05 16:56:17 -07:00
|
|
|
; fallthrough
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_Rollout:
|
2014-10-22 08:36:42 -07:00
|
|
|
; Rollout, Fury Cutter
|
|
|
|
|
|
|
|
; 80% chance to discourage this move if the enemy is in love, confused, or paralyzed.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemySubStatus1]
|
2013-05-06 21:58:35 -07:00
|
|
|
bit SUBSTATUS_IN_LOVE, a
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nz, .asm_39020
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemySubStatus3]
|
2013-05-06 21:58:35 -07:00
|
|
|
bit SUBSTATUS_CONFUSED, a
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nz, .asm_39020
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyMonStatus]
|
2013-05-06 21:58:35 -07:00
|
|
|
bit PAR, a
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nz, .asm_39020
|
|
|
|
|
2014-10-22 14:08:51 -07:00
|
|
|
; 80% chance to discourage this move if the enemy's HP is below 25%,
|
|
|
|
; or if accuracy or evasion modifiers favour the player.
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckEnemyQuarterHP
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nc, .asm_39020
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyAccLevel]
|
2020-05-17 17:59:15 -07:00
|
|
|
cp BASE_STAT_LEVEL
|
2013-05-05 16:56:17 -07:00
|
|
|
jr c, .asm_39020
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerEvaLevel]
|
2020-05-17 17:59:15 -07:00
|
|
|
cp BASE_STAT_LEVEL + 1
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nc, .asm_39020
|
|
|
|
|
2014-10-22 14:08:51 -07:00
|
|
|
; Otherwise, 80% chance to greatly encourage this move.
|
2013-08-30 19:59:40 -07:00
|
|
|
call Random
|
2017-12-25 13:18:05 -08:00
|
|
|
cp 79 percent - 1
|
2013-05-05 16:56:17 -07:00
|
|
|
ret nc
|
|
|
|
dec [hl]
|
2016-05-04 08:46:23 -07:00
|
|
|
dec [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_39020
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_80_20
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
AI_Smart_Swagger:
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_Attract:
|
2014-10-22 08:36:42 -07:00
|
|
|
; 80% chance to encourage this move during the first turn of player's Pokemon.
|
|
|
|
; 80% chance to discourage this move otherwise.
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerTurnsTaken]
|
2013-05-05 16:56:17 -07:00
|
|
|
and a
|
2014-06-17 12:52:32 -07:00
|
|
|
jr z, .first_turn
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_80_20
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
2014-06-17 12:52:32 -07:00
|
|
|
.first_turn
|
2013-08-30 19:59:40 -07:00
|
|
|
call Random
|
2017-12-25 13:18:05 -08:00
|
|
|
cp 79 percent - 1
|
2013-05-05 16:56:17 -07:00
|
|
|
ret nc
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_Safeguard:
|
2014-10-22 08:36:42 -07:00
|
|
|
; 80% chance to discourage this move if player's HP is below 50%.
|
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckPlayerHalfHP
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_80_20
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
AI_Smart_Magnitude:
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_Earthquake:
|
2014-10-22 14:08:51 -07:00
|
|
|
; Greatly encourage this move if the player is underground and the enemy is faster.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wLastPlayerCounterMove]
|
2013-05-06 21:58:35 -07:00
|
|
|
cp DIG
|
2013-05-05 16:56:17 -07:00
|
|
|
ret nz
|
2013-05-06 21:58:35 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerSubStatus3]
|
2013-05-06 21:58:35 -07:00
|
|
|
bit SUBSTATUS_UNDERGROUND, a
|
2014-06-17 12:52:32 -07:00
|
|
|
jr z, .could_dig
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2013-05-06 17:51:07 -07:00
|
|
|
call AICompareSpeed
|
2013-05-05 16:56:17 -07:00
|
|
|
ret nc
|
|
|
|
dec [hl]
|
2016-05-04 08:46:23 -07:00
|
|
|
dec [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
ret
|
|
|
|
|
2014-06-17 12:52:32 -07:00
|
|
|
.could_dig
|
2014-10-22 23:41:52 -07:00
|
|
|
; Try to predict if the player will use Dig this turn.
|
2014-10-22 08:36:42 -07:00
|
|
|
|
2014-10-22 23:41:52 -07:00
|
|
|
; 50% chance to encourage this move if the enemy is slower than the player.
|
2013-05-06 17:51:07 -07:00
|
|
|
call AICompareSpeed
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
2014-10-22 23:41:52 -07:00
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_50_50
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
2014-10-22 23:41:52 -07:00
|
|
|
|
2013-05-05 16:56:17 -07:00
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_BatonPass:
|
2014-10-22 08:36:42 -07:00
|
|
|
; Discourage this move if the player hasn't shown super-effective moves against the enemy.
|
2014-10-22 14:08:51 -07:00
|
|
|
; Consider player's type(s) if its moves are unknown.
|
2014-10-22 08:36:42 -07:00
|
|
|
|
2013-05-05 16:56:17 -07:00
|
|
|
push hl
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar CheckPlayerMoveTypeMatchups
|
2016-01-12 09:46:18 -08:00
|
|
|
ld a, [wEnemyAISwitchScore]
|
2014-10-22 08:36:42 -07:00
|
|
|
cp 10 ; neutral
|
2013-05-05 16:56:17 -07:00
|
|
|
pop hl
|
|
|
|
ret c
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_Pursuit:
|
2014-10-22 14:08:51 -07:00
|
|
|
; 50% chance to greatly encourage this move if player's HP is below 25%.
|
|
|
|
; 80% chance to discourage this move otherwise.
|
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckPlayerQuarterHP
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nc, .asm_3907d
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_80_20
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_3907d
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_50_50
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
dec [hl]
|
2016-05-04 08:46:23 -07:00
|
|
|
dec [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_RapidSpin:
|
2014-10-22 14:08:51 -07:00
|
|
|
; 80% chance to greatly encourage this move if the enemy is
|
|
|
|
; trapped (Bind effect), seeded, or scattered with spikes.
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
ld a, [wEnemyWrapCount]
|
2013-05-05 16:56:17 -07:00
|
|
|
and a
|
|
|
|
jr nz, .asm_39097
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemySubStatus4]
|
2013-05-06 21:58:35 -07:00
|
|
|
bit SUBSTATUS_LEECH_SEED, a
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nz, .asm_39097
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyScreens]
|
2013-05-06 21:58:35 -07:00
|
|
|
bit SCREENS_SPIKES, a
|
2013-05-05 16:56:17 -07:00
|
|
|
ret z
|
|
|
|
|
|
|
|
.asm_39097
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_80_20
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
2014-08-13 19:44:56 -07:00
|
|
|
|
2013-05-05 16:56:17 -07:00
|
|
|
dec [hl]
|
2016-05-04 08:46:23 -07:00
|
|
|
dec [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_HiddenPower:
|
2013-05-05 16:56:17 -07:00
|
|
|
push hl
|
2013-05-06 21:58:35 -07:00
|
|
|
ld a, 1
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hBattleTurn], a
|
2016-04-10 11:42:14 -07:00
|
|
|
|
2014-10-22 14:08:51 -07:00
|
|
|
; Calculate Hidden Power's type and base power based on enemy's DVs.
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar HiddenPowerDamage
|
|
|
|
callfar BattleCheckTypeMatchup
|
2013-05-05 16:56:17 -07:00
|
|
|
pop hl
|
2013-05-06 21:58:35 -07:00
|
|
|
|
2014-10-22 14:08:51 -07:00
|
|
|
; Discourage Hidden Power if not very effective.
|
2018-07-28 16:27:34 -07:00
|
|
|
ld a, [wTypeMatchup]
|
|
|
|
cp EFFECTIVE
|
2014-08-13 19:44:56 -07:00
|
|
|
jr c, .bad
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2014-10-21 11:44:42 -07:00
|
|
|
; Discourage Hidden Power if its base power is lower than 50.
|
2013-05-05 16:56:17 -07:00
|
|
|
ld a, d
|
2014-06-17 12:52:32 -07:00
|
|
|
cp 50
|
2014-08-13 19:44:56 -07:00
|
|
|
jr c, .bad
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2014-10-22 14:08:51 -07:00
|
|
|
; Encourage Hidden Power if super-effective.
|
2018-07-28 16:27:34 -07:00
|
|
|
ld a, [wTypeMatchup]
|
|
|
|
cp EFFECTIVE + 1
|
2014-08-13 19:44:56 -07:00
|
|
|
jr nc, .good
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2014-10-22 14:08:51 -07:00
|
|
|
; Encourage Hidden Power if its base power is 70.
|
2013-05-05 16:56:17 -07:00
|
|
|
ld a, d
|
2014-06-17 12:52:32 -07:00
|
|
|
cp 70
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
.good
|
2013-05-05 16:56:17 -07:00
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
.bad
|
2013-05-05 16:56:17 -07:00
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_RainDance:
|
2014-10-22 14:08:51 -07:00
|
|
|
; Greatly discourage this move if it would favour the player type-wise.
|
|
|
|
; Particularly, if the player is a Water-type.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wBattleMonType1]
|
2013-05-05 23:39:01 -07:00
|
|
|
cp WATER
|
2013-05-06 21:58:35 -07:00
|
|
|
jr z, AIBadWeatherType
|
2013-05-05 23:39:01 -07:00
|
|
|
cp FIRE
|
2013-05-06 21:58:35 -07:00
|
|
|
jr z, AIGoodWeatherType
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wBattleMonType2]
|
2013-05-05 23:39:01 -07:00
|
|
|
cp WATER
|
2013-05-06 21:58:35 -07:00
|
|
|
jr z, AIBadWeatherType
|
2013-05-05 23:39:01 -07:00
|
|
|
cp FIRE
|
2013-05-06 21:58:35 -07:00
|
|
|
jr z, AIGoodWeatherType
|
2013-05-05 16:56:17 -07:00
|
|
|
|
|
|
|
push hl
|
2013-05-05 23:39:01 -07:00
|
|
|
ld hl, RainDanceMoves
|
2014-08-13 19:44:56 -07:00
|
|
|
jr AI_Smart_WeatherMove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2018-01-25 17:34:33 -08:00
|
|
|
INCLUDE "data/battle/ai/rain_dance_moves.asm"
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_SunnyDay:
|
2014-10-22 14:08:51 -07:00
|
|
|
; Greatly discourage this move if it would favour the player type-wise.
|
|
|
|
; Particularly, if the player is a Fire-type.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wBattleMonType1]
|
2013-05-05 23:39:01 -07:00
|
|
|
cp FIRE
|
2013-05-06 21:58:35 -07:00
|
|
|
jr z, AIBadWeatherType
|
2013-05-05 23:39:01 -07:00
|
|
|
cp WATER
|
2013-05-06 21:58:35 -07:00
|
|
|
jr z, AIGoodWeatherType
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wBattleMonType2]
|
2013-05-05 23:39:01 -07:00
|
|
|
cp FIRE
|
2013-05-06 21:58:35 -07:00
|
|
|
jr z, AIBadWeatherType
|
2013-05-05 23:39:01 -07:00
|
|
|
cp WATER
|
2013-05-06 21:58:35 -07:00
|
|
|
jr z, AIGoodWeatherType
|
2013-05-05 16:56:17 -07:00
|
|
|
|
|
|
|
push hl
|
2013-05-05 23:39:01 -07:00
|
|
|
ld hl, SunnyDayMoves
|
2013-05-05 16:56:17 -07:00
|
|
|
|
|
|
|
; fallthrough
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_WeatherMove:
|
2014-10-22 14:08:51 -07:00
|
|
|
; Rain Dance, Sunny Day
|
|
|
|
|
|
|
|
; Greatly discourage this move if the enemy doesn't have
|
|
|
|
; one of the useful Rain Dance or Sunny Day moves.
|
2013-05-06 21:58:35 -07:00
|
|
|
call AIHasMoveInArray
|
2013-05-05 16:56:17 -07:00
|
|
|
pop hl
|
2013-05-06 21:58:35 -07:00
|
|
|
jr nc, AIBadWeatherType
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2014-10-22 14:08:51 -07:00
|
|
|
; Greatly discourage this move if player's HP is below 50%.
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckPlayerHalfHP
|
2013-05-06 21:58:35 -07:00
|
|
|
jr nc, AIBadWeatherType
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2014-10-22 14:08:51 -07:00
|
|
|
; 50% chance to encourage this move otherwise.
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_50_50
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
2013-05-05 23:39:01 -07:00
|
|
|
|
2013-05-05 16:56:17 -07:00
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AIBadWeatherType:
|
2013-05-05 16:56:17 -07:00
|
|
|
inc [hl]
|
2016-05-10 09:31:49 -07:00
|
|
|
inc [hl]
|
|
|
|
inc [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AIGoodWeatherType:
|
2014-10-22 14:08:51 -07:00
|
|
|
; Rain Dance, Sunny Day
|
|
|
|
|
|
|
|
; Greatly encourage this move if it would disfavour the player type-wise and player's HP is above 50%...
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckPlayerHalfHP
|
2013-05-05 16:56:17 -07:00
|
|
|
ret nc
|
2013-05-05 23:39:01 -07:00
|
|
|
|
2014-10-22 14:08:51 -07:00
|
|
|
; ...as long as one of the following conditions meet:
|
|
|
|
; It's the first turn of the player's Pokemon.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerTurnsTaken]
|
2013-05-05 16:56:17 -07:00
|
|
|
and a
|
2013-05-06 21:58:35 -07:00
|
|
|
jr z, .good
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2014-10-22 14:08:51 -07:00
|
|
|
; Or it's the first turn of the enemy's Pokemon.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyTurnsTaken]
|
2013-05-05 16:56:17 -07:00
|
|
|
and a
|
|
|
|
ret nz
|
|
|
|
|
2013-05-06 21:58:35 -07:00
|
|
|
.good
|
2013-05-05 16:56:17 -07:00
|
|
|
dec [hl]
|
2016-05-04 08:46:23 -07:00
|
|
|
dec [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
ret
|
|
|
|
|
2018-01-25 17:34:33 -08:00
|
|
|
INCLUDE "data/battle/ai/sunny_day_moves.asm"
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_BellyDrum:
|
2014-10-22 14:08:51 -07:00
|
|
|
; Dismiss this move if enemy's attack is higher than +2 or if enemy's HP is below 50%.
|
|
|
|
; Else, discourage this move if enemy's HP is not full.
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyAtkLevel]
|
2020-05-07 08:09:41 -07:00
|
|
|
cp BASE_STAT_LEVEL + 3
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nc, .asm_3914d
|
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckEnemyMaxHP
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
2014-10-22 23:41:52 -07:00
|
|
|
|
2013-05-05 16:56:17 -07:00
|
|
|
inc [hl]
|
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckEnemyHalfHP
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
|
|
|
|
.asm_3914d
|
|
|
|
ld a, [hl]
|
|
|
|
add $5
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_PsychUp:
|
2013-05-05 16:56:17 -07:00
|
|
|
push hl
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyAtkLevel
|
2013-05-05 16:56:17 -07:00
|
|
|
ld b, $8
|
2014-10-22 14:08:51 -07:00
|
|
|
ld c, 100
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2014-10-22 14:08:51 -07:00
|
|
|
; Calculate the sum of all enemy's stat level modifiers. Add 100 first to prevent underflow.
|
|
|
|
; Put the result in c. c will range between 58 and 142.
|
2013-05-05 16:56:17 -07:00
|
|
|
.asm_3915a
|
|
|
|
ld a, [hli]
|
|
|
|
sub $7
|
|
|
|
add c
|
|
|
|
ld c, a
|
|
|
|
dec b
|
|
|
|
jr nz, .asm_3915a
|
|
|
|
|
2014-10-22 14:08:51 -07:00
|
|
|
; Calculate the sum of all player's stat level modifiers. Add 100 first to prevent underflow.
|
2016-04-10 11:42:14 -07:00
|
|
|
; Put the result in d. d will range between 58 and 142.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPlayerAtkLevel
|
2013-05-05 16:56:17 -07:00
|
|
|
ld b, $8
|
2014-10-22 14:08:51 -07:00
|
|
|
ld d, 100
|
2013-05-05 16:56:17 -07:00
|
|
|
|
|
|
|
.asm_39169
|
|
|
|
ld a, [hli]
|
|
|
|
sub $7
|
|
|
|
add d
|
|
|
|
ld d, a
|
|
|
|
dec b
|
|
|
|
jr nz, .asm_39169
|
|
|
|
|
2014-10-22 14:08:51 -07:00
|
|
|
; Greatly discourage this move if enemy's stat levels are higher than player's (if c>=d).
|
2013-05-05 16:56:17 -07:00
|
|
|
ld a, c
|
|
|
|
sub d
|
|
|
|
pop hl
|
|
|
|
jr nc, .asm_39188
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
; Else, 80% chance to encourage this move unless player's accuracy level is lower than -1...
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerAccLevel]
|
2020-05-07 08:09:41 -07:00
|
|
|
cp BASE_STAT_LEVEL - 1
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
2016-04-10 11:42:14 -07:00
|
|
|
|
|
|
|
; ...or enemy's evasion level is higher than +0.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyEvaLevel]
|
2020-05-07 08:09:41 -07:00
|
|
|
cp BASE_STAT_LEVEL + 1
|
2013-05-05 16:56:17 -07:00
|
|
|
ret nc
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_80_20
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
2014-10-22 23:41:52 -07:00
|
|
|
|
2013-05-05 16:56:17 -07:00
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_39188
|
|
|
|
inc [hl]
|
2016-05-04 08:46:23 -07:00
|
|
|
inc [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_MirrorCoat:
|
2013-05-05 16:56:17 -07:00
|
|
|
push hl
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPlayerUsedMoves
|
2020-05-07 08:09:41 -07:00
|
|
|
ld c, NUM_MOVES
|
|
|
|
ld b, 0
|
2013-05-05 16:56:17 -07:00
|
|
|
|
|
|
|
.asm_39193
|
|
|
|
ld a, [hli]
|
|
|
|
and a
|
|
|
|
jr z, .asm_391a8
|
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
call AIGetEnemyMove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2014-06-12 18:32:42 -07:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_POWER]
|
2013-05-05 16:56:17 -07:00
|
|
|
and a
|
|
|
|
jr z, .asm_391a8
|
|
|
|
|
2014-06-12 18:32:42 -07:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_TYPE]
|
|
|
|
cp SPECIAL
|
2013-05-05 16:56:17 -07: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
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wLastPlayerCounterMove]
|
2013-05-05 16:56:17 -07:00
|
|
|
and a
|
|
|
|
jr z, .asm_391d2
|
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
call AIGetEnemyMove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2014-06-12 18:32:42 -07:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_POWER]
|
2013-05-05 16:56:17 -07:00
|
|
|
and a
|
|
|
|
jr z, .asm_391d2
|
|
|
|
|
2014-06-12 18:32:42 -07:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_TYPE]
|
|
|
|
cp SPECIAL
|
2013-05-05 16:56:17 -07:00
|
|
|
jr c, .asm_391d2
|
|
|
|
|
|
|
|
.asm_391ca
|
2013-08-30 19:59:40 -07:00
|
|
|
call Random
|
2013-05-06 21:58:35 -07:00
|
|
|
cp 100
|
2013-05-05 16:56:17 -07:00
|
|
|
jr c, .asm_391d2
|
|
|
|
dec [hl]
|
|
|
|
|
|
|
|
.asm_391d2
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_391d3
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
AI_Smart_Twister:
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_Gust:
|
2014-10-22 14:08:51 -07:00
|
|
|
; Greatly encourage this move if the player is flying and the enemy is faster.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wLastPlayerCounterMove]
|
2013-05-06 21:58:35 -07:00
|
|
|
cp FLY
|
2013-05-05 16:56:17 -07:00
|
|
|
ret nz
|
2013-05-06 21:58:35 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerSubStatus3]
|
2013-05-06 21:58:35 -07:00
|
|
|
bit SUBSTATUS_FLYING, a
|
2014-10-22 14:08:51 -07:00
|
|
|
jr z, .couldFly
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2013-05-06 17:51:07 -07:00
|
|
|
call AICompareSpeed
|
2013-05-05 16:56:17 -07:00
|
|
|
ret nc
|
2013-05-06 21:58:35 -07:00
|
|
|
|
2013-05-05 16:56:17 -07:00
|
|
|
dec [hl]
|
2016-05-04 08:46:23 -07:00
|
|
|
dec [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
; Try to predict if the player will use Fly this turn.
|
2014-10-22 14:08:51 -07:00
|
|
|
.couldFly
|
|
|
|
|
|
|
|
; 50% chance to encourage this move if the enemy is slower than the player.
|
2013-05-06 17:51:07 -07:00
|
|
|
call AICompareSpeed
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_50_50
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_FutureSight:
|
2014-10-22 14:08:51 -07:00
|
|
|
; Greatly encourage this move if the player is
|
|
|
|
; flying or underground, and slower than the enemy.
|
|
|
|
|
2013-05-06 17:51:07 -07:00
|
|
|
call AICompareSpeed
|
2013-05-05 16:56:17 -07:00
|
|
|
ret nc
|
2013-05-06 21:58:35 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerSubStatus3]
|
2014-05-05 00:30:51 -07:00
|
|
|
and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND
|
2013-05-05 16:56:17 -07:00
|
|
|
ret z
|
2013-05-06 21:58:35 -07:00
|
|
|
|
2013-05-05 16:56:17 -07:00
|
|
|
dec [hl]
|
2016-05-04 08:46:23 -07:00
|
|
|
dec [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_Stomp:
|
2014-10-22 14:08:51 -07:00
|
|
|
; 80% chance to encourage this move if the player has used Minimize.
|
|
|
|
|
2015-11-10 13:53:37 -08:00
|
|
|
ld a, [wPlayerMinimized]
|
2013-05-05 16:56:17 -07:00
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_80_20
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
2013-05-06 21:58:35 -07:00
|
|
|
|
2013-05-05 16:56:17 -07:00
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_Solarbeam:
|
2014-10-22 14:08:51 -07:00
|
|
|
; 80% chance to encourage this move when it's sunny.
|
|
|
|
; 90% chance to discourage this move when it's raining.
|
|
|
|
|
2018-01-23 13:45:34 -08:00
|
|
|
ld a, [wBattleWeather]
|
2013-05-05 23:39:01 -07:00
|
|
|
cp WEATHER_SUN
|
2013-05-05 16:56:17 -07:00
|
|
|
jr z, .asm_3921e
|
|
|
|
|
2013-05-05 23:39:01 -07:00
|
|
|
cp WEATHER_RAIN
|
2013-05-05 16:56:17 -07:00
|
|
|
ret nz
|
|
|
|
|
2013-08-30 19:59:40 -07:00
|
|
|
call Random
|
2017-12-25 13:18:05 -08:00
|
|
|
cp 10 percent
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
2013-05-05 23:39:01 -07:00
|
|
|
|
2013-05-05 16:56:17 -07:00
|
|
|
inc [hl]
|
2016-05-04 08:46:23 -07:00
|
|
|
inc [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_3921e
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_80_20
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
2013-05-05 23:39:01 -07:00
|
|
|
|
2013-05-05 16:56:17 -07:00
|
|
|
dec [hl]
|
2016-05-04 08:46:23 -07:00
|
|
|
dec [hl]
|
2013-05-05 16:56:17 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Smart_Thunder:
|
2014-10-22 14:08:51 -07:00
|
|
|
; 90% chance to discourage this move when it's sunny.
|
2014-10-21 15:28:51 -07:00
|
|
|
|
2018-01-23 13:45:34 -08:00
|
|
|
ld a, [wBattleWeather]
|
2013-05-05 23:39:01 -07:00
|
|
|
cp WEATHER_SUN
|
2013-05-05 16:56:17 -07:00
|
|
|
ret nz
|
|
|
|
|
2013-08-30 19:59:40 -07:00
|
|
|
call Random
|
2017-12-25 13:18:05 -08:00
|
|
|
cp 10 percent
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
2013-05-05 23:39:01 -07:00
|
|
|
|
2013-05-05 16:56:17 -07:00
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AICompareSpeed:
|
2014-10-22 14:08:51 -07:00
|
|
|
; Return carry if enemy is faster than player.
|
2014-10-21 15:28:51 -07:00
|
|
|
|
2013-05-05 23:39:01 -07:00
|
|
|
push bc
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyMonSpeed + 1]
|
2013-05-05 23:39:01 -07:00
|
|
|
ld b, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wBattleMonSpeed + 1]
|
2013-05-05 23:39:01 -07:00
|
|
|
cp b
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyMonSpeed]
|
2013-05-05 23:39:01 -07:00
|
|
|
ld b, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wBattleMonSpeed]
|
2013-05-05 23:39:01 -07:00
|
|
|
sbc b
|
|
|
|
pop bc
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AICheckPlayerMaxHP:
|
2013-05-05 23:39:01 -07:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wBattleMonHP
|
|
|
|
ld hl, wBattleMonMaxHP
|
2013-05-06 11:33:19 -07:00
|
|
|
jr AICheckMaxHP
|
2013-05-05 23:39:01 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AICheckEnemyMaxHP:
|
2013-05-05 23:39:01 -07:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wEnemyMonHP
|
|
|
|
ld hl, wEnemyMonMaxHP
|
2013-05-05 23:39:01 -07:00
|
|
|
; fallthrough
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AICheckMaxHP:
|
2013-05-06 11:33:19 -07:00
|
|
|
; Return carry if hp at de matches max hp at hl.
|
2014-10-21 11:44:42 -07:00
|
|
|
|
2013-05-05 23:39:01 -07: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
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AICheckPlayerHalfHP:
|
2013-05-05 23:39:01 -07:00
|
|
|
push hl
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonHP
|
2013-05-05 23:39:01 -07:00
|
|
|
ld b, [hl]
|
|
|
|
inc hl
|
|
|
|
ld c, [hl]
|
|
|
|
sla c
|
|
|
|
rl b
|
|
|
|
inc hl
|
2016-05-04 08:46:23 -07:00
|
|
|
inc hl
|
2013-05-05 23:39:01 -07:00
|
|
|
ld a, [hld]
|
|
|
|
cp c
|
|
|
|
ld a, [hl]
|
|
|
|
sbc b
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AICheckEnemyHalfHP:
|
2013-05-05 23:39:01 -07:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonHP
|
2013-05-05 23:39:01 -07:00
|
|
|
ld b, [hl]
|
|
|
|
inc hl
|
|
|
|
ld c, [hl]
|
|
|
|
sla c
|
|
|
|
rl b
|
|
|
|
inc hl
|
2016-05-04 08:46:23 -07:00
|
|
|
inc hl
|
2013-05-05 23:39:01 -07:00
|
|
|
ld a, [hld]
|
|
|
|
cp c
|
|
|
|
ld a, [hl]
|
|
|
|
sbc b
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AICheckEnemyQuarterHP:
|
2013-05-05 23:39:01 -07:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonHP
|
2013-05-05 23:39:01 -07:00
|
|
|
ld b, [hl]
|
|
|
|
inc hl
|
|
|
|
ld c, [hl]
|
|
|
|
sla c
|
|
|
|
rl b
|
|
|
|
sla c
|
|
|
|
rl b
|
|
|
|
inc hl
|
2016-05-04 08:46:23 -07:00
|
|
|
inc hl
|
2013-05-05 23:39:01 -07:00
|
|
|
ld a, [hld]
|
|
|
|
cp c
|
|
|
|
ld a, [hl]
|
|
|
|
sbc b
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AICheckPlayerQuarterHP:
|
2013-05-05 23:39:01 -07:00
|
|
|
push hl
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonHP
|
2013-05-05 23:39:01 -07:00
|
|
|
ld b, [hl]
|
|
|
|
inc hl
|
|
|
|
ld c, [hl]
|
|
|
|
sla c
|
|
|
|
rl b
|
|
|
|
sla c
|
|
|
|
rl b
|
|
|
|
inc hl
|
2016-05-04 08:46:23 -07:00
|
|
|
inc hl
|
2013-05-05 23:39:01 -07:00
|
|
|
ld a, [hld]
|
|
|
|
cp c
|
|
|
|
ld a, [hl]
|
|
|
|
sbc b
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AIHasMoveEffect:
|
2013-05-06 21:58:35 -07:00
|
|
|
; Return carry if the enemy has move b.
|
2014-10-21 11:44:42 -07:00
|
|
|
|
2013-05-05 23:39:01 -07:00
|
|
|
push hl
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonMoves
|
|
|
|
ld c, wEnemyMonMovesEnd - wEnemyMonMoves
|
2013-05-05 23:39:01 -07:00
|
|
|
|
2013-05-06 21:58:35 -07:00
|
|
|
.checkmove
|
2013-05-05 23:39:01 -07:00
|
|
|
ld a, [hli]
|
|
|
|
and a
|
2014-08-13 19:44:56 -07:00
|
|
|
jr z, .no
|
2013-05-05 23:39:01 -07:00
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
call AIGetEnemyMove
|
2013-05-05 23:39:01 -07:00
|
|
|
|
2014-06-12 18:32:42 -07:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_EFFECT]
|
2013-05-05 23:39:01 -07:00
|
|
|
cp b
|
2014-08-13 19:44:56 -07:00
|
|
|
jr z, .yes
|
2013-05-05 23:39:01 -07:00
|
|
|
|
|
|
|
dec c
|
2013-05-06 21:58:35 -07:00
|
|
|
jr nz, .checkmove
|
2013-05-05 23:39:01 -07:00
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
.no
|
2013-05-05 23:39:01 -07:00
|
|
|
pop hl
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
.yes
|
2013-05-05 23:39:01 -07:00
|
|
|
pop hl
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AIHasMoveInArray:
|
2013-05-06 21:58:35 -07:00
|
|
|
; Return carry if the enemy has a move in array hl.
|
|
|
|
|
2013-05-05 23:39:01 -07:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
.next
|
2013-05-05 23:39:01 -07:00
|
|
|
ld a, [hli]
|
2020-05-07 08:09:41 -07:00
|
|
|
cp -1
|
2014-08-13 19:44:56 -07:00
|
|
|
jr z, .done
|
2013-05-05 23:39:01 -07:00
|
|
|
|
|
|
|
ld b, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld c, wEnemyMonMovesEnd - wEnemyMonMoves + 1
|
|
|
|
ld de, wEnemyMonMoves
|
2013-05-05 23:39:01 -07:00
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
.check
|
2013-05-05 23:39:01 -07:00
|
|
|
dec c
|
2014-08-13 19:44:56 -07:00
|
|
|
jr z, .next
|
2013-05-05 23:39:01 -07:00
|
|
|
|
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
cp b
|
2014-08-13 19:44:56 -07:00
|
|
|
jr nz, .check
|
2013-05-05 23:39:01 -07:00
|
|
|
|
|
|
|
scf
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
.done
|
2013-05-05 23:39:01 -07:00
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2018-01-25 17:34:33 -08:00
|
|
|
INCLUDE "data/battle/ai/useful_moves.asm"
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Opportunist:
|
2014-10-21 11:44:42 -07:00
|
|
|
; Discourage stall moves when the enemy's HP is low.
|
2013-05-06 11:33:19 -07:00
|
|
|
|
2014-10-21 11:44:42 -07:00
|
|
|
; Do nothing if enemy's HP is above 50%.
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckEnemyHalfHP
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
; Discourage stall moves if enemy's HP is below 25%.
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckEnemyQuarterHP
|
2013-05-05 16:56:17 -07:00
|
|
|
jr nc, .asm_39322
|
2016-04-10 11:42:14 -07:00
|
|
|
|
2014-10-21 11:44:42 -07:00
|
|
|
; 50% chance to discourage stall moves if enemy's HP is between 25% and 50%.
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_50_50
|
2013-05-05 16:56:17 -07:00
|
|
|
ret c
|
|
|
|
|
|
|
|
.asm_39322
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBuffer1 - 1
|
|
|
|
ld de, wEnemyMonMoves
|
|
|
|
ld c, wEnemyMonMovesEnd - wEnemyMonMoves + 1
|
2013-05-06 11:33:19 -07:00
|
|
|
.checkmove
|
2013-05-05 16:56:17 -07: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
|
2018-01-25 17:34:33 -08:00
|
|
|
ld hl, StallMoves
|
2013-05-05 16:56:17 -07:00
|
|
|
ld de, 1
|
|
|
|
call IsInArray
|
|
|
|
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
2013-05-06 11:33:19 -07:00
|
|
|
jr nc, .checkmove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
|
|
|
inc [hl]
|
2013-05-06 11:33:19 -07:00
|
|
|
jr .checkmove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
|
|
|
.asm_39347
|
|
|
|
ret
|
|
|
|
|
2018-01-25 17:34:33 -08:00
|
|
|
INCLUDE "data/battle/ai/stall_moves.asm"
|
2013-05-05 16:56:17 -07:00
|
|
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Aggressive:
|
2013-05-06 11:33:19 -07:00
|
|
|
; Use whatever does the most damage.
|
|
|
|
|
2014-10-21 10:21:13 -07: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 11:33:19 -07:00
|
|
|
|
|
|
|
; Figure out which attack does the most damage and put it in c.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonMoves
|
2013-05-05 16:56:17 -07:00
|
|
|
ld bc, 0
|
|
|
|
ld de, 0
|
2013-05-06 11:33:19 -07:00
|
|
|
.checkmove
|
2013-05-05 16:56:17 -07:00
|
|
|
inc b
|
|
|
|
ld a, b
|
2018-01-23 14:39:09 -08:00
|
|
|
cp wEnemyMonMovesEnd - wEnemyMonMoves + 1
|
2013-05-06 11:33:19 -07:00
|
|
|
jr z, .gotstrongestmove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
|
|
|
ld a, [hli]
|
|
|
|
and a
|
2013-05-06 11:33:19 -07:00
|
|
|
jr z, .gotstrongestmove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2013-05-06 11:33:19 -07:00
|
|
|
call AIGetEnemyMove
|
2014-06-12 18:32:42 -07:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_POWER]
|
2013-05-05 16:56:17 -07:00
|
|
|
and a
|
2013-05-06 11:33:19 -07:00
|
|
|
jr z, .nodamage
|
|
|
|
call AIDamageCalc
|
2013-05-05 16:56:17 -07:00
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
2013-05-06 11:33:19 -07:00
|
|
|
|
2014-10-21 10:21:13 -07:00
|
|
|
; Update current move if damage is highest so far
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurDamage + 1]
|
2013-05-05 16:56:17 -07:00
|
|
|
cp e
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurDamage]
|
2013-05-05 16:56:17 -07:00
|
|
|
sbc d
|
2013-05-06 11:33:19 -07:00
|
|
|
jr c, .checkmove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurDamage + 1]
|
2013-05-05 16:56:17 -07:00
|
|
|
ld e, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurDamage]
|
2013-05-05 16:56:17 -07:00
|
|
|
ld d, a
|
|
|
|
ld c, b
|
2013-05-06 11:33:19 -07:00
|
|
|
jr .checkmove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
.nodamage
|
2013-05-05 16:56:17 -07:00
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
2013-05-06 11:33:19 -07:00
|
|
|
jr .checkmove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
.gotstrongestmove
|
|
|
|
; Nothing we can do if no attacks did damage.
|
2013-05-05 16:56:17 -07:00
|
|
|
ld a, c
|
|
|
|
and a
|
2013-05-06 11:33:19 -07:00
|
|
|
jr z, .done
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
; Discourage moves that do less damage unless they're reckless too.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBuffer1 - 1
|
|
|
|
ld de, wEnemyMonMoves
|
2013-05-05 23:39:01 -07:00
|
|
|
ld b, 0
|
2013-05-06 11:33:19 -07:00
|
|
|
.checkmove2
|
2013-05-05 16:56:17 -07:00
|
|
|
inc b
|
|
|
|
ld a, b
|
2018-01-23 14:39:09 -08:00
|
|
|
cp wEnemyMonMovesEnd - wEnemyMonMoves + 1
|
2013-05-06 11:33:19 -07:00
|
|
|
jr z, .done
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2014-10-21 11:44:42 -07:00
|
|
|
; Ignore this move if it is the highest damaging one.
|
2013-05-05 16:56:17 -07:00
|
|
|
cp c
|
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
inc hl
|
2013-05-06 11:33:19 -07:00
|
|
|
jr z, .checkmove2
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
call AIGetEnemyMove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2014-10-21 11:44:42 -07:00
|
|
|
; Ignore this move if its power is 0 or 1.
|
2015-07-18 20:45:39 -07:00
|
|
|
; Moves such as Seismic Toss, Hidden Power,
|
2016-04-10 11:42:14 -07:00
|
|
|
; Counter and Fissure have a base power of 1.
|
2014-06-12 18:32:42 -07:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_POWER]
|
2013-05-06 11:33:19 -07:00
|
|
|
cp 2
|
|
|
|
jr c, .checkmove2
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
; Ignore this move if it is reckless.
|
2013-05-05 16:56:17 -07:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2014-06-12 18:32:42 -07:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_EFFECT]
|
2018-01-25 17:34:33 -08:00
|
|
|
ld hl, RecklessMoves
|
2013-05-05 16:56:17 -07:00
|
|
|
ld de, 1
|
|
|
|
call IsInArray
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
2013-05-06 11:33:19 -07:00
|
|
|
jr c, .checkmove2
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
; If we made it this far, discourage this move.
|
2013-05-05 16:56:17 -07:00
|
|
|
inc [hl]
|
2013-05-06 11:33:19 -07:00
|
|
|
jr .checkmove2
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
.done
|
2013-05-05 16:56:17 -07:00
|
|
|
ret
|
|
|
|
|
2018-01-25 17:34:33 -08:00
|
|
|
INCLUDE "data/battle/ai/reckless_moves.asm"
|
2013-05-05 23:39:01 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AIDamageCalc:
|
2013-05-05 23:39:01 -07:00
|
|
|
ld a, 1
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hBattleTurn], a
|
2014-06-12 18:32:42 -07:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_EFFECT]
|
2013-05-05 23:39:01 -07:00
|
|
|
ld de, 1
|
2018-01-25 17:34:33 -08:00
|
|
|
ld hl, ConstantDamageEffects
|
2013-05-05 23:39:01 -07:00
|
|
|
call IsInArray
|
|
|
|
jr nc, .asm_39400
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar BattleCommand_ConstantDamage
|
2013-05-05 23:39:01 -07:00
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_39400
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar EnemyAttackDamage
|
|
|
|
callfar BattleCommand_DamageCalc
|
|
|
|
callfar BattleCommand_Stab
|
2013-05-05 23:39:01 -07:00
|
|
|
ret
|
|
|
|
|
2018-01-25 17:34:33 -08:00
|
|
|
INCLUDE "data/battle/ai/constant_damage_effects.asm"
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Cautious:
|
2014-10-22 23:41:52 -07:00
|
|
|
; 90% chance to discourage moves with residual effects after the first turn.
|
2013-05-06 11:33:19 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyTurnsTaken]
|
2013-05-05 16:56:17 -07:00
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBuffer1 - 1
|
|
|
|
ld de, wEnemyMonMoves
|
|
|
|
ld c, wEnemyMonMovesEnd - wEnemyMonMoves + 1
|
2013-05-05 16:56:17 -07:00
|
|
|
.asm_39425
|
|
|
|
inc hl
|
|
|
|
dec c
|
|
|
|
ret z
|
|
|
|
|
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2018-01-25 17:34:33 -08:00
|
|
|
ld hl, ResidualMoves
|
2013-05-05 16:56:17 -07:00
|
|
|
ld de, 1
|
|
|
|
call IsInArray
|
|
|
|
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
jr nc, .asm_39425
|
|
|
|
|
2013-08-30 19:59:40 -07:00
|
|
|
call Random
|
2017-12-25 13:18:05 -08:00
|
|
|
cp 90 percent + 1
|
2013-05-05 16:56:17 -07:00
|
|
|
ret nc
|
|
|
|
|
|
|
|
inc [hl]
|
|
|
|
jr .asm_39425
|
|
|
|
|
2018-01-25 17:34:33 -08:00
|
|
|
INCLUDE "data/battle/ai/residual_moves.asm"
|
2013-05-05 16:56:17 -07:00
|
|
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Status:
|
2014-10-21 15:28:51 -07:00
|
|
|
; Dismiss status moves that don't affect the player.
|
2013-05-06 11:33:19 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBuffer1 - 1
|
|
|
|
ld de, wEnemyMonMoves
|
|
|
|
ld b, wEnemyMonMovesEnd - wEnemyMonMoves + 1
|
2013-05-06 11:33:19 -07:00
|
|
|
.checkmove
|
2013-05-05 16:56:17 -07:00
|
|
|
dec b
|
|
|
|
ret z
|
|
|
|
|
|
|
|
inc hl
|
|
|
|
ld a, [de]
|
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
|
|
|
inc de
|
2013-05-06 11:33:19 -07:00
|
|
|
call AIGetEnemyMove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2014-06-12 18:32:42 -07:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_EFFECT]
|
2013-05-05 16:56:17 -07:00
|
|
|
cp EFFECT_TOXIC
|
2013-05-06 11:33:19 -07:00
|
|
|
jr z, .poisonimmunity
|
2013-05-05 16:56:17 -07:00
|
|
|
cp EFFECT_POISON
|
2013-05-06 11:33:19 -07:00
|
|
|
jr z, .poisonimmunity
|
2013-05-05 16:56:17 -07:00
|
|
|
cp EFFECT_SLEEP
|
2013-05-06 11:33:19 -07:00
|
|
|
jr z, .typeimmunity
|
2013-05-05 16:56:17 -07:00
|
|
|
cp EFFECT_PARALYZE
|
2013-05-06 11:33:19 -07:00
|
|
|
jr z, .typeimmunity
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2014-06-12 18:32:42 -07:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_POWER]
|
2013-05-05 16:56:17 -07:00
|
|
|
and a
|
2013-05-06 11:33:19 -07:00
|
|
|
jr z, .checkmove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
jr .typeimmunity
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
.poisonimmunity
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wBattleMonType1]
|
2013-05-05 16:56:17 -07:00
|
|
|
cp POISON
|
2013-05-06 11:33:19 -07:00
|
|
|
jr z, .immune
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wBattleMonType2]
|
2013-05-05 16:56:17 -07:00
|
|
|
cp POISON
|
2013-05-06 11:33:19 -07:00
|
|
|
jr z, .immune
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
.typeimmunity
|
2013-05-05 16:56:17 -07:00
|
|
|
push hl
|
|
|
|
push bc
|
|
|
|
push de
|
|
|
|
ld a, 1
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hBattleTurn], a
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar BattleCheckTypeMatchup
|
2013-05-05 16:56:17 -07:00
|
|
|
pop de
|
|
|
|
pop bc
|
|
|
|
pop hl
|
|
|
|
|
2018-07-28 16:27:34 -07:00
|
|
|
ld a, [wTypeMatchup]
|
2013-05-05 16:56:17 -07:00
|
|
|
and a
|
2013-05-06 11:33:19 -07:00
|
|
|
jr nz, .checkmove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
.immune
|
|
|
|
call AIDiscourageMove
|
|
|
|
jr .checkmove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Risky:
|
2014-10-21 15:28:51 -07:00
|
|
|
; Use any move that will KO the target.
|
|
|
|
; Risky moves will often be an exception (see below).
|
2013-05-06 11:33:19 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBuffer1 - 1
|
|
|
|
ld de, wEnemyMonMoves
|
|
|
|
ld c, wEnemyMonMovesEnd - wEnemyMonMoves + 1
|
2013-05-06 11:33:19 -07:00
|
|
|
.checkmove
|
2013-05-05 16:56:17 -07: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 11:33:19 -07:00
|
|
|
call AIGetEnemyMove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2014-06-12 18:32:42 -07:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_POWER]
|
2013-05-05 16:56:17 -07:00
|
|
|
and a
|
2013-05-06 11:33:19 -07:00
|
|
|
jr z, .nextmove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
; Don't use risky moves at max hp.
|
2014-06-12 18:32:42 -07:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_EFFECT]
|
2013-05-05 16:56:17 -07:00
|
|
|
ld de, 1
|
2018-01-25 17:34:33 -08:00
|
|
|
ld hl, RiskyEffects
|
2013-05-05 16:56:17 -07:00
|
|
|
call IsInArray
|
2013-05-06 11:33:19 -07:00
|
|
|
jr nc, .checkko
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
call AICheckEnemyMaxHP
|
|
|
|
jr c, .nextmove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
; Else, 80% chance to exclude them.
|
2013-08-30 19:59:40 -07:00
|
|
|
call Random
|
2017-12-25 13:18:05 -08:00
|
|
|
cp 79 percent - 1
|
2013-05-06 11:33:19 -07:00
|
|
|
jr c, .nextmove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2013-05-06 11:33:19 -07:00
|
|
|
.checkko
|
|
|
|
call AIDamageCalc
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurDamage + 1]
|
2013-05-05 16:56:17 -07:00
|
|
|
ld e, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurDamage]
|
2013-05-05 16:56:17 -07:00
|
|
|
ld d, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wBattleMonHP + 1]
|
2013-05-05 16:56:17 -07:00
|
|
|
cp e
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wBattleMonHP]
|
2013-05-05 16:56:17 -07:00
|
|
|
sbc d
|
2013-05-06 11:33:19 -07:00
|
|
|
jr nc, .nextmove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
|
|
|
pop hl
|
2015-07-20 19:18:18 -07:00
|
|
|
rept 5
|
2013-05-05 16:56:17 -07:00
|
|
|
dec [hl]
|
2015-07-20 19:18:18 -07:00
|
|
|
endr
|
2013-05-05 16:56:17 -07:00
|
|
|
push hl
|
2013-05-06 11:33:19 -07:00
|
|
|
|
|
|
|
.nextmove
|
2013-05-05 16:56:17 -07:00
|
|
|
pop hl
|
|
|
|
pop bc
|
|
|
|
pop de
|
2013-05-06 11:33:19 -07:00
|
|
|
jr .checkmove
|
2013-05-05 16:56:17 -07:00
|
|
|
|
2018-01-25 17:34:33 -08:00
|
|
|
INCLUDE "data/battle/ai/risky_effects.asm"
|
2013-05-05 16:56:17 -07:00
|
|
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_None:
|
2013-05-05 16:56:17 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AIDiscourageMove:
|
2013-05-05 23:39:01 -07:00
|
|
|
ld a, [hl]
|
|
|
|
add 10
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AIGetEnemyMove:
|
2014-10-21 10:21:13 -07:00
|
|
|
; Load attributes of move a into ram
|
|
|
|
|
2013-05-05 23:39:01 -07:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
|
|
|
dec a
|
|
|
|
ld hl, Moves
|
2014-06-10 23:23:55 -07:00
|
|
|
ld bc, MOVE_LENGTH
|
2013-05-05 23:39:01 -07:00
|
|
|
call AddNTimes
|
|
|
|
|
2014-06-12 18:32:42 -07:00
|
|
|
ld de, wEnemyMoveStruct
|
2013-05-05 23:39:01 -07:00
|
|
|
ld a, BANK(Moves)
|
|
|
|
call FarCopyBytes
|
|
|
|
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_80_20:
|
2013-08-30 19:59:40 -07:00
|
|
|
call Random
|
2017-12-25 13:18:05 -08:00
|
|
|
cp 20 percent - 1
|
2013-05-05 23:39:01 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_50_50:
|
2013-08-30 19:59:40 -07:00
|
|
|
call Random
|
2017-12-25 13:18:05 -08:00
|
|
|
cp 50 percent + 1
|
2013-05-05 23:39:01 -07:00
|
|
|
ret
|