2018-06-24 07:09:41 -07:00
|
|
|
AI_SwitchOrTryItem:
|
2014-06-14 15:03:23 -07:00
|
|
|
and a
|
2014-08-13 19:44:56 -07:00
|
|
|
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [wBattleMode]
|
2014-06-14 15:03:23 -07:00
|
|
|
dec a
|
|
|
|
ret z
|
2014-08-13 19:44:56 -07:00
|
|
|
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [wLinkMode]
|
2014-06-14 15:03:23 -07:00
|
|
|
and a
|
|
|
|
ret nz
|
2014-08-13 19:44:56 -07:00
|
|
|
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall CheckEnemyLockedIn
|
2014-06-14 15:03:23 -07:00
|
|
|
ret nz
|
2014-08-13 19:44:56 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerSubStatus5]
|
2014-06-14 15:03:23 -07:00
|
|
|
bit SUBSTATUS_CANT_RUN, a
|
2014-09-30 11:20:38 -07:00
|
|
|
jr nz, DontSwitch
|
2014-08-13 19:44:56 -07:00
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
ld a, [wEnemyWrapCount]
|
2014-06-14 15:03:23 -07:00
|
|
|
and a
|
2014-09-30 11:20:38 -07:00
|
|
|
jr nz, DontSwitch
|
2014-08-13 19:44:56 -07:00
|
|
|
|
2015-11-28 12:13:40 -08:00
|
|
|
ld hl, TrainerClassAttributes + TRNATTR_AI_ITEM_SWITCH
|
2018-01-30 11:05:25 -08:00
|
|
|
ld a, [wInBattleTowerBattle] ; always load the first trainer class in wTrainerClass for BattleTower-Trainers
|
2014-06-14 15:03:23 -07:00
|
|
|
and a
|
2014-08-13 19:44:56 -07:00
|
|
|
jr nz, .ok
|
2015-09-09 16:27:07 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTrainerClass]
|
2014-06-14 15:03:23 -07:00
|
|
|
dec a
|
2017-12-08 21:50:59 -08:00
|
|
|
ld bc, NUM_TRAINER_ATTRIBUTES
|
2014-06-14 15:03:23 -07:00
|
|
|
call AddNTimes
|
2014-08-13 19:44:56 -07:00
|
|
|
.ok
|
|
|
|
bit SWITCH_OFTEN_F, [hl]
|
2014-09-30 11:20:38 -07:00
|
|
|
jp nz, SwitchOften
|
2014-08-13 19:44:56 -07:00
|
|
|
bit SWITCH_RARELY_F, [hl]
|
2014-09-30 11:20:38 -07:00
|
|
|
jp nz, SwitchRarely
|
2014-08-13 19:44:56 -07:00
|
|
|
bit SWITCH_SOMETIMES_F, [hl]
|
2014-09-30 11:20:38 -07:00
|
|
|
jp nz, SwitchSometimes
|
2014-06-14 15:03:23 -07:00
|
|
|
; fallthrough
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
DontSwitch:
|
2014-09-30 11:20:38 -07:00
|
|
|
call AI_TryItem
|
2014-06-14 15:03:23 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SwitchOften:
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar CheckAbleToSwitch
|
2015-11-08 16:09:36 -08:00
|
|
|
ld a, [wEnemySwitchMonParam]
|
2014-06-14 15:03:23 -07:00
|
|
|
and $f0
|
2014-09-30 11:20:38 -07:00
|
|
|
jp z, DontSwitch
|
2014-08-13 19:44:56 -07:00
|
|
|
|
2014-06-14 15:03:23 -07:00
|
|
|
cp $10
|
2014-08-13 19:44:56 -07:00
|
|
|
jr nz, .not_10
|
2014-06-14 15:03:23 -07:00
|
|
|
call Random
|
2018-02-04 18:21:34 -08:00
|
|
|
cp 50 percent + 1
|
2014-08-13 19:44:56 -07:00
|
|
|
jr c, .switch
|
2014-09-30 11:20:38 -07:00
|
|
|
jp DontSwitch
|
2014-08-13 19:44:56 -07:00
|
|
|
.not_10
|
2014-06-14 15:03:23 -07:00
|
|
|
|
|
|
|
cp $20
|
2014-08-13 19:44:56 -07:00
|
|
|
jr nz, .not_20
|
2014-06-14 15:03:23 -07:00
|
|
|
call Random
|
2018-02-04 18:21:34 -08:00
|
|
|
cp 79 percent - 1
|
2014-08-13 19:44:56 -07:00
|
|
|
jr c, .switch
|
2014-09-30 11:20:38 -07:00
|
|
|
jp DontSwitch
|
2014-08-13 19:44:56 -07:00
|
|
|
.not_20
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
; $30
|
2014-06-14 15:03:23 -07:00
|
|
|
call Random
|
2015-11-08 16:09:36 -08:00
|
|
|
cp 4 percent
|
2014-09-30 11:20:38 -07:00
|
|
|
jp c, DontSwitch
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
.switch
|
2015-11-08 16:09:36 -08:00
|
|
|
ld a, [wEnemySwitchMonParam]
|
2014-06-14 15:03:23 -07:00
|
|
|
and $f
|
|
|
|
inc a
|
2018-02-22 08:13:29 -08:00
|
|
|
; In register 'a' is the number (1-6) of the mon to switch to
|
2015-11-08 16:09:36 -08:00
|
|
|
ld [wEnemySwitchMonIndex], a
|
2014-08-13 19:44:56 -07:00
|
|
|
jp AI_TrySwitch
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SwitchRarely:
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar CheckAbleToSwitch
|
2015-11-08 16:09:36 -08:00
|
|
|
ld a, [wEnemySwitchMonParam]
|
2014-06-14 15:03:23 -07:00
|
|
|
and $f0
|
2014-09-30 11:20:38 -07:00
|
|
|
jp z, DontSwitch
|
2014-08-13 19:44:56 -07:00
|
|
|
|
2014-06-14 15:03:23 -07:00
|
|
|
cp $10
|
2014-08-13 19:44:56 -07:00
|
|
|
jr nz, .not_10
|
2014-06-14 15:03:23 -07:00
|
|
|
call Random
|
2015-11-08 16:09:36 -08:00
|
|
|
cp 8 percent
|
2014-08-13 19:44:56 -07:00
|
|
|
jr c, .switch
|
2014-09-30 11:20:38 -07:00
|
|
|
jp DontSwitch
|
2014-08-13 19:44:56 -07:00
|
|
|
.not_10
|
2014-06-14 15:03:23 -07:00
|
|
|
|
|
|
|
cp $20
|
2014-08-13 19:44:56 -07:00
|
|
|
jr nz, .not_20
|
2014-06-14 15:03:23 -07:00
|
|
|
call Random
|
2015-11-08 16:09:36 -08:00
|
|
|
cp 12 percent
|
2014-08-13 19:44:56 -07:00
|
|
|
jr c, .switch
|
2014-09-30 11:20:38 -07:00
|
|
|
jp DontSwitch
|
2014-08-13 19:44:56 -07:00
|
|
|
.not_20
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
; $30
|
2014-06-14 15:03:23 -07:00
|
|
|
call Random
|
2018-02-04 18:21:34 -08:00
|
|
|
cp 79 percent - 1
|
2014-09-30 11:20:38 -07:00
|
|
|
jp c, DontSwitch
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
.switch
|
2015-11-08 16:09:36 -08:00
|
|
|
ld a, [wEnemySwitchMonParam]
|
2014-06-14 15:03:23 -07:00
|
|
|
and $f
|
|
|
|
inc a
|
2015-11-08 16:09:36 -08:00
|
|
|
ld [wEnemySwitchMonIndex], a
|
2014-08-13 19:44:56 -07:00
|
|
|
jp AI_TrySwitch
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SwitchSometimes:
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar CheckAbleToSwitch
|
2015-11-08 16:09:36 -08:00
|
|
|
ld a, [wEnemySwitchMonParam]
|
2014-06-14 15:03:23 -07:00
|
|
|
and $f0
|
2014-09-30 11:20:38 -07:00
|
|
|
jp z, DontSwitch
|
2014-08-13 19:44:56 -07:00
|
|
|
|
2014-06-14 15:03:23 -07:00
|
|
|
cp $10
|
2014-08-13 19:44:56 -07:00
|
|
|
jr nz, .not_10
|
2014-06-14 15:03:23 -07:00
|
|
|
call Random
|
2018-02-04 18:21:34 -08:00
|
|
|
cp 20 percent - 1
|
2014-08-13 19:44:56 -07:00
|
|
|
jr c, .switch
|
2014-09-30 11:20:38 -07:00
|
|
|
jp DontSwitch
|
2014-08-13 19:44:56 -07:00
|
|
|
.not_10
|
2014-06-14 15:03:23 -07:00
|
|
|
|
|
|
|
cp $20
|
2014-08-13 19:44:56 -07:00
|
|
|
jr nz, .not_20
|
2014-06-14 15:03:23 -07:00
|
|
|
call Random
|
2018-02-04 18:21:34 -08:00
|
|
|
cp 50 percent + 1
|
2014-08-13 19:44:56 -07:00
|
|
|
jr c, .switch
|
2014-09-30 11:20:38 -07:00
|
|
|
jp DontSwitch
|
2014-08-13 19:44:56 -07:00
|
|
|
.not_20
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
; $30
|
2014-06-14 15:03:23 -07:00
|
|
|
call Random
|
2018-02-04 18:21:34 -08:00
|
|
|
cp 20 percent - 1
|
2014-09-30 11:20:38 -07:00
|
|
|
jp c, DontSwitch
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
.switch
|
2015-11-08 16:09:36 -08:00
|
|
|
ld a, [wEnemySwitchMonParam]
|
2014-06-14 15:03:23 -07:00
|
|
|
and $f
|
|
|
|
inc a
|
2015-11-08 16:09:36 -08:00
|
|
|
ld [wEnemySwitchMonIndex], a
|
2014-08-13 19:44:56 -07:00
|
|
|
jp AI_TrySwitch
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CheckSubstatusCantRun:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemySubStatus5]
|
2014-06-14 15:03:23 -07:00
|
|
|
bit SUBSTATUS_CANT_RUN, a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_TryItem:
|
2015-09-04 13:30:40 -07:00
|
|
|
; items are not allowed in the BattleTower
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wInBattleTowerBattle]
|
2014-06-14 15:03:23 -07:00
|
|
|
and a
|
|
|
|
ret nz
|
2014-09-30 11:20:38 -07:00
|
|
|
|
2015-11-05 16:13:09 -08:00
|
|
|
ld a, [wEnemyTrainerItem1]
|
2014-06-14 15:03:23 -07:00
|
|
|
ld b, a
|
2015-11-05 16:13:09 -08:00
|
|
|
ld a, [wEnemyTrainerItem2]
|
2014-06-14 15:03:23 -07:00
|
|
|
or b
|
|
|
|
ret z
|
2014-09-30 11:20:38 -07:00
|
|
|
|
|
|
|
call .IsHighestLevel
|
2014-06-14 15:03:23 -07:00
|
|
|
ret nc
|
2014-09-30 11:20:38 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTrainerClass]
|
2014-06-14 15:03:23 -07:00
|
|
|
dec a
|
2017-12-08 21:50:59 -08:00
|
|
|
ld hl, TrainerClassAttributes + TRNATTR_AI_ITEM_SWITCH
|
|
|
|
ld bc, NUM_TRAINER_ATTRIBUTES
|
2014-06-14 15:03:23 -07:00
|
|
|
call AddNTimes
|
|
|
|
ld b, h
|
|
|
|
ld c, l
|
2014-09-30 11:20:38 -07:00
|
|
|
ld hl, AI_Items
|
2015-11-05 16:13:09 -08:00
|
|
|
ld de, wEnemyTrainerItem1
|
2014-09-30 11:20:38 -07:00
|
|
|
.loop
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, [hl]
|
|
|
|
and a
|
|
|
|
inc a
|
|
|
|
ret z
|
2014-09-30 11:20:38 -07:00
|
|
|
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, [de]
|
|
|
|
cp [hl]
|
2014-09-30 11:20:38 -07:00
|
|
|
jr z, .has_item
|
2014-06-14 15:03:23 -07:00
|
|
|
inc de
|
|
|
|
ld a, [de]
|
|
|
|
cp [hl]
|
2014-09-30 11:20:38 -07:00
|
|
|
jr z, .has_item
|
|
|
|
|
2014-06-14 15:03:23 -07:00
|
|
|
dec de
|
|
|
|
inc hl
|
2016-05-10 09:31:49 -07:00
|
|
|
inc hl
|
|
|
|
inc hl
|
2014-09-30 11:20:38 -07:00
|
|
|
jr .loop
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2014-09-30 11:20:38 -07:00
|
|
|
.has_item
|
2014-06-14 15:03:23 -07:00
|
|
|
inc hl
|
2014-09-30 11:20:38 -07:00
|
|
|
|
2014-06-14 15:03:23 -07:00
|
|
|
push hl
|
|
|
|
push de
|
2014-09-30 11:20:38 -07:00
|
|
|
ld de, .callback
|
2014-06-14 15:03:23 -07:00
|
|
|
push de
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2017-06-09 14:01:10 -07:00
|
|
|
jp hl
|
2014-09-30 11:20:38 -07:00
|
|
|
.callback
|
2014-06-14 15:03:23 -07:00
|
|
|
pop de
|
|
|
|
pop hl
|
2014-09-30 11:20:38 -07:00
|
|
|
|
2014-06-14 15:03:23 -07:00
|
|
|
inc hl
|
2016-05-04 08:46:23 -07:00
|
|
|
inc hl
|
2014-09-30 11:20:38 -07:00
|
|
|
jr c, .loop
|
|
|
|
|
|
|
|
.used_item
|
2014-06-14 15:03:23 -07:00
|
|
|
xor a
|
|
|
|
ld [de], a
|
|
|
|
inc a
|
2015-11-08 16:09:36 -08:00
|
|
|
ld [wEnemyGoesFirst], a
|
2014-09-30 11:20:38 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemySubStatus3
|
2014-06-14 15:03:23 -07:00
|
|
|
res SUBSTATUS_BIDE, [hl]
|
2014-09-30 11:20:38 -07:00
|
|
|
|
2014-06-14 15:03:23 -07:00
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wEnemyFuryCutterCount], a
|
|
|
|
ld [wEnemyProtectCount], a
|
2015-11-05 16:13:09 -08:00
|
|
|
ld [wEnemyRageCounter], a
|
2014-09-30 11:20:38 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemySubStatus4
|
2014-06-14 15:03:23 -07:00
|
|
|
res SUBSTATUS_RAGE, [hl]
|
2014-09-30 11:20:38 -07:00
|
|
|
|
2014-06-14 15:03:23 -07:00
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wLastEnemyCounterMove], a
|
2014-09-30 11:20:38 -07:00
|
|
|
|
2014-06-14 15:03:23 -07:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.IsHighestLevel:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wOTPartyCount]
|
2014-06-14 15:03:23 -07:00
|
|
|
ld d, a
|
|
|
|
ld e, 0
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wOTPartyMon1Level
|
2015-11-04 08:19:58 -08:00
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
2014-09-30 11:20:38 -07:00
|
|
|
.next
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, [hl]
|
|
|
|
cp e
|
2014-09-30 11:20:38 -07:00
|
|
|
jr c, .ok
|
2014-06-14 15:03:23 -07:00
|
|
|
ld e, a
|
2014-09-30 11:20:38 -07:00
|
|
|
.ok
|
2014-06-14 15:03:23 -07:00
|
|
|
add hl, bc
|
|
|
|
dec d
|
2014-09-30 11:20:38 -07:00
|
|
|
jr nz, .next
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurOTMon]
|
|
|
|
ld hl, wOTPartyMon1Level
|
2014-06-14 15:03:23 -07:00
|
|
|
call AddNTimes
|
|
|
|
ld a, [hl]
|
|
|
|
cp e
|
2014-09-30 11:20:38 -07:00
|
|
|
jr nc, .yes
|
|
|
|
|
|
|
|
.no
|
2014-06-14 15:03:23 -07:00
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2014-09-30 11:20:38 -07:00
|
|
|
.yes
|
2014-06-14 15:03:23 -07:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Items:
|
2014-08-13 19:44:56 -07:00
|
|
|
dbw FULL_RESTORE, .FullRestore
|
|
|
|
dbw MAX_POTION, .MaxPotion
|
|
|
|
dbw HYPER_POTION, .HyperPotion
|
|
|
|
dbw SUPER_POTION, .SuperPotion
|
|
|
|
dbw POTION, .Potion
|
|
|
|
dbw X_ACCURACY, .XAccuracy
|
|
|
|
dbw FULL_HEAL, .FullHeal
|
|
|
|
dbw GUARD_SPEC, .GuardSpec
|
|
|
|
dbw DIRE_HIT, .DireHit
|
|
|
|
dbw X_ATTACK, .XAttack
|
|
|
|
dbw X_DEFEND, .XDefend
|
|
|
|
dbw X_SPEED, .XSpeed
|
|
|
|
dbw X_SPECIAL, .XSpecial
|
2018-01-10 19:53:42 -08:00
|
|
|
db -1 ; end
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.FullHeal:
|
2014-08-13 19:44:56 -07:00
|
|
|
call .Status
|
|
|
|
jp c, .DontUse
|
2015-10-07 18:27:32 -07:00
|
|
|
call EnemyUsedFullHeal
|
2014-08-13 19:44:56 -07:00
|
|
|
jp .Use
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.Status:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyMonStatus]
|
2014-06-14 15:03:23 -07:00
|
|
|
and a
|
2014-08-13 19:44:56 -07:00
|
|
|
jp z, .DontUse
|
2014-06-14 15:03:23 -07:00
|
|
|
|
|
|
|
ld a, [bc]
|
2014-08-13 19:44:56 -07:00
|
|
|
bit CONTEXT_USE_F, a
|
2015-10-07 18:27:32 -07:00
|
|
|
jr nz, .StatusCheckContext
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, [bc]
|
2014-08-13 19:44:56 -07:00
|
|
|
bit ALWAYS_USE_F, a
|
|
|
|
jp nz, .Use
|
2014-06-14 15:03:23 -07:00
|
|
|
call Random
|
2018-02-04 18:21:34 -08:00
|
|
|
cp 20 percent - 1
|
2014-08-13 19:44:56 -07:00
|
|
|
jp c, .Use
|
|
|
|
jp .DontUse
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.StatusCheckContext:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemySubStatus5]
|
2014-06-14 15:03:23 -07:00
|
|
|
bit SUBSTATUS_TOXIC, a
|
2015-10-07 18:27:32 -07:00
|
|
|
jr z, .FailToxicCheck
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyToxicCount]
|
2014-08-13 19:44:56 -07:00
|
|
|
cp 4
|
2015-10-07 18:27:32 -07:00
|
|
|
jr c, .FailToxicCheck
|
2014-06-14 15:03:23 -07:00
|
|
|
call Random
|
2018-02-04 18:21:34 -08:00
|
|
|
cp 50 percent + 1
|
2014-08-13 19:44:56 -07:00
|
|
|
jp c, .Use
|
2016-04-10 11:42:14 -07:00
|
|
|
.FailToxicCheck:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyMonStatus]
|
2014-06-14 15:03:23 -07:00
|
|
|
and 1 << FRZ | SLP
|
2014-08-13 19:44:56 -07:00
|
|
|
jp z, .DontUse
|
|
|
|
jp .Use
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.FullRestore:
|
2014-08-13 19:44:56 -07:00
|
|
|
call .HealItem
|
2015-10-07 18:27:32 -07:00
|
|
|
jp nc, .UseFullRestore
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, [bc]
|
2014-08-13 19:44:56 -07:00
|
|
|
bit CONTEXT_USE_F, a
|
|
|
|
jp z, .DontUse
|
|
|
|
call .Status
|
|
|
|
jp c, .DontUse
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.UseFullRestore:
|
2015-10-07 18:27:32 -07:00
|
|
|
call EnemyUsedFullRestore
|
2014-08-13 19:44:56 -07:00
|
|
|
jp .Use
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.MaxPotion:
|
2014-08-13 19:44:56 -07:00
|
|
|
call .HealItem
|
|
|
|
jp c, .DontUse
|
2015-10-07 18:27:32 -07:00
|
|
|
call EnemyUsedMaxPotion
|
2014-08-13 19:44:56 -07:00
|
|
|
jp .Use
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.HealItem:
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, [bc]
|
2014-08-13 19:44:56 -07:00
|
|
|
bit CONTEXT_USE_F, a
|
2015-10-07 18:27:32 -07:00
|
|
|
jr nz, .CheckHalfOrQuarterHP
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar AICheckEnemyHalfHP
|
2014-08-13 19:44:56 -07:00
|
|
|
jp c, .DontUse
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, [bc]
|
2014-08-13 19:44:56 -07:00
|
|
|
bit UNKNOWN_USE_F, a
|
2015-10-07 18:27:32 -07:00
|
|
|
jp nz, .CheckQuarterHP
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar AICheckEnemyQuarterHP
|
2015-10-07 18:27:32 -07:00
|
|
|
jp nc, .UseHealItem
|
2014-06-14 15:03:23 -07:00
|
|
|
call Random
|
2018-02-04 18:21:34 -08:00
|
|
|
cp 50 percent + 1
|
2015-10-07 18:27:32 -07:00
|
|
|
jp c, .UseHealItem
|
2014-08-13 19:44:56 -07:00
|
|
|
jp .DontUse
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.CheckQuarterHP:
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar AICheckEnemyQuarterHP
|
2014-08-13 19:44:56 -07:00
|
|
|
jp c, .DontUse
|
2014-06-14 15:03:23 -07:00
|
|
|
call Random
|
2018-02-04 18:21:34 -08:00
|
|
|
cp 20 percent - 1
|
2014-08-13 19:44:56 -07:00
|
|
|
jp c, .DontUse
|
2015-10-07 18:27:32 -07:00
|
|
|
jr .UseHealItem
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.CheckHalfOrQuarterHP:
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar AICheckEnemyHalfHP
|
2014-08-13 19:44:56 -07:00
|
|
|
jp c, .DontUse
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar AICheckEnemyQuarterHP
|
2015-10-07 18:27:32 -07:00
|
|
|
jp nc, .UseHealItem
|
2014-06-14 15:03:23 -07:00
|
|
|
call Random
|
2018-02-04 18:21:34 -08:00
|
|
|
cp 20 percent - 1
|
2014-08-13 19:44:56 -07:00
|
|
|
jp nc, .DontUse
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.UseHealItem:
|
2014-08-13 19:44:56 -07:00
|
|
|
jp .Use
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.HyperPotion:
|
2014-08-13 19:44:56 -07:00
|
|
|
call .HealItem
|
|
|
|
jp c, .DontUse
|
2014-06-14 15:03:23 -07:00
|
|
|
ld b, 200
|
2015-10-07 18:27:32 -07:00
|
|
|
call EnemyUsedHyperPotion
|
2014-08-13 19:44:56 -07:00
|
|
|
jp .Use
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.SuperPotion:
|
2014-08-13 19:44:56 -07:00
|
|
|
call .HealItem
|
|
|
|
jp c, .DontUse
|
2014-06-14 15:03:23 -07:00
|
|
|
ld b, 50
|
2015-10-07 18:27:32 -07:00
|
|
|
call EnemyUsedSuperPotion
|
2014-08-13 19:44:56 -07:00
|
|
|
jp .Use
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.Potion:
|
2014-08-13 19:44:56 -07:00
|
|
|
call .HealItem
|
|
|
|
jp c, .DontUse
|
2014-06-14 15:03:23 -07:00
|
|
|
ld b, 20
|
2015-10-07 18:27:32 -07:00
|
|
|
call EnemyUsedPotion
|
2014-08-13 19:44:56 -07:00
|
|
|
jp .Use
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2016-04-10 12:01:49 -07:00
|
|
|
.asm_382ae ; This appears to be unused
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar AICheckEnemyMaxHP
|
2015-11-08 07:59:28 -08:00
|
|
|
jr c, .dont_use
|
2014-06-14 15:03:23 -07:00
|
|
|
push bc
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wEnemyMonMaxHP + 1
|
|
|
|
ld hl, wEnemyMonHP + 1
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, [de]
|
|
|
|
sub [hl]
|
2015-11-08 07:59:28 -08:00
|
|
|
jr z, .check_40_percent
|
2014-06-14 15:03:23 -07:00
|
|
|
dec hl
|
|
|
|
dec de
|
|
|
|
ld c, a
|
|
|
|
sbc [hl]
|
|
|
|
and a
|
2015-11-08 07:59:28 -08:00
|
|
|
jr nz, .check_40_percent
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, c
|
|
|
|
cp b
|
2015-11-08 07:59:28 -08:00
|
|
|
jp c, .check_50_percent
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar AICheckEnemyQuarterHP
|
2015-11-08 07:59:28 -08:00
|
|
|
jr c, .check_40_percent
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2015-11-08 07:59:28 -08:00
|
|
|
.check_50_percent
|
2014-06-14 15:03:23 -07:00
|
|
|
pop bc
|
|
|
|
ld a, [bc]
|
2014-08-13 19:44:56 -07:00
|
|
|
bit UNKNOWN_USE_F, a
|
|
|
|
jp z, .Use
|
2014-06-14 15:03:23 -07:00
|
|
|
call Random
|
2018-02-04 18:21:34 -08:00
|
|
|
cp 50 percent + 1
|
2014-08-13 19:44:56 -07:00
|
|
|
jp c, .Use
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2015-11-08 07:59:28 -08:00
|
|
|
.dont_use
|
2014-08-13 19:44:56 -07:00
|
|
|
jp .DontUse
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2015-11-08 07:59:28 -08:00
|
|
|
.check_40_percent
|
2014-06-14 15:03:23 -07:00
|
|
|
pop bc
|
|
|
|
ld a, [bc]
|
2014-08-13 19:44:56 -07:00
|
|
|
bit UNKNOWN_USE_F, a
|
|
|
|
jp z, .DontUse
|
2014-06-14 15:03:23 -07:00
|
|
|
call Random
|
2018-02-04 18:21:34 -08:00
|
|
|
cp 39 percent + 1
|
2014-08-13 19:44:56 -07:00
|
|
|
jp c, .Use
|
|
|
|
jp .DontUse
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.XAccuracy:
|
2014-08-13 19:44:56 -07:00
|
|
|
call .XItem
|
|
|
|
jp c, .DontUse
|
2015-10-07 18:27:32 -07:00
|
|
|
call EnemyUsedXAccuracy
|
2014-08-13 19:44:56 -07:00
|
|
|
jp .Use
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.GuardSpec:
|
2014-08-13 19:44:56 -07:00
|
|
|
call .XItem
|
|
|
|
jp c, .DontUse
|
2015-10-07 18:27:32 -07:00
|
|
|
call EnemyUsedGuardSpec
|
2014-08-13 19:44:56 -07:00
|
|
|
jp .Use
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.DireHit:
|
2014-08-13 19:44:56 -07:00
|
|
|
call .XItem
|
|
|
|
jp c, .DontUse
|
2015-10-07 18:27:32 -07:00
|
|
|
call EnemyUsedDireHit
|
2014-08-13 19:44:56 -07:00
|
|
|
jp .Use
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.XAttack:
|
2014-08-13 19:44:56 -07:00
|
|
|
call .XItem
|
|
|
|
jp c, .DontUse
|
2015-10-07 18:27:32 -07:00
|
|
|
call EnemyUsedXAttack
|
2014-08-13 19:44:56 -07:00
|
|
|
jp .Use
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.XDefend:
|
2014-08-13 19:44:56 -07:00
|
|
|
call .XItem
|
|
|
|
jp c, .DontUse
|
2015-10-07 18:27:32 -07:00
|
|
|
call EnemyUsedXDefend
|
2014-08-13 19:44:56 -07:00
|
|
|
jp .Use
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.XSpeed:
|
2014-08-13 19:44:56 -07:00
|
|
|
call .XItem
|
|
|
|
jp c, .DontUse
|
2015-10-07 18:27:32 -07:00
|
|
|
call EnemyUsedXSpeed
|
2014-08-13 19:44:56 -07:00
|
|
|
jp .Use
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.XSpecial:
|
2014-08-13 19:44:56 -07:00
|
|
|
call .XItem
|
|
|
|
jp c, .DontUse
|
2015-10-07 18:27:32 -07:00
|
|
|
call EnemyUsedXSpecial
|
2014-08-13 19:44:56 -07:00
|
|
|
jp .Use
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.XItem:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyTurnsTaken]
|
2014-06-14 15:03:23 -07:00
|
|
|
and a
|
2015-10-07 18:27:32 -07:00
|
|
|
jr nz, .notfirstturnout
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, [bc]
|
2014-08-13 19:44:56 -07:00
|
|
|
bit ALWAYS_USE_F, a
|
|
|
|
jp nz, .Use
|
2014-06-14 15:03:23 -07:00
|
|
|
call Random
|
2018-02-04 18:21:34 -08:00
|
|
|
cp 50 percent + 1
|
2014-08-13 19:44:56 -07:00
|
|
|
jp c, .DontUse
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, [bc]
|
2014-08-13 19:44:56 -07:00
|
|
|
bit CONTEXT_USE_F, a
|
|
|
|
jp nz, .Use
|
2014-06-14 15:03:23 -07:00
|
|
|
call Random
|
2018-02-04 18:21:34 -08:00
|
|
|
cp 50 percent + 1
|
2014-08-13 19:44:56 -07:00
|
|
|
jp c, .DontUse
|
|
|
|
jp .Use
|
2015-10-07 18:27:32 -07:00
|
|
|
.notfirstturnout
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, [bc]
|
2014-08-13 19:44:56 -07:00
|
|
|
bit ALWAYS_USE_F, a
|
|
|
|
jp z, .DontUse
|
2014-06-14 15:03:23 -07:00
|
|
|
call Random
|
2018-02-04 18:21:34 -08:00
|
|
|
cp 20 percent - 1
|
2014-08-13 19:44:56 -07:00
|
|
|
jp nc, .DontUse
|
|
|
|
jp .Use
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
.DontUse:
|
2014-06-14 15:03:23 -07:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
.Use:
|
2014-06-14 15:03:23 -07:00
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AIUpdateHUD:
|
2014-06-14 15:03:23 -07:00
|
|
|
call UpdateEnemyMonInParty
|
2018-01-16 11:30:10 -08:00
|
|
|
farcall UpdateEnemyHUD
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, $1
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hBGMapMode], a
|
2016-01-12 09:46:18 -08:00
|
|
|
ld hl, wEnemyItemState
|
2014-06-14 15:03:23 -07:00
|
|
|
dec [hl]
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AIUsedItemSound:
|
2014-06-14 15:03:23 -07:00
|
|
|
push de
|
|
|
|
ld de, SFX_FULL_HEAL
|
|
|
|
call PlaySFX
|
|
|
|
pop de
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
EnemyUsedFullHeal:
|
2014-08-13 19:44:56 -07:00
|
|
|
call AIUsedItemSound
|
|
|
|
call AI_HealStatus
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, FULL_HEAL
|
2015-08-24 16:56:30 -07:00
|
|
|
jp PrintText_UsedItemOn_AND_AIUpdateHUD
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
EnemyUsedMaxPotion:
|
2014-08-13 19:44:56 -07:00
|
|
|
ld a, MAX_POTION
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCurEnemyItem], a
|
2015-10-07 18:27:32 -07:00
|
|
|
jr FullRestoreContinue
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
EnemyUsedFullRestore:
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_HealStatus
|
|
|
|
ld a, FULL_RESTORE
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCurEnemyItem], a
|
|
|
|
ld hl, wEnemySubStatus3
|
2014-06-14 15:03:23 -07:00
|
|
|
res SUBSTATUS_CONFUSED, [hl]
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wEnemyConfuseCount], a
|
2014-08-13 19:44:56 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
FullRestoreContinue:
|
2016-05-16 06:36:24 -07:00
|
|
|
ld de, wCurHPAnimOldHP
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonHP + 1
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, [hld]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
ld a, [hl]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonMaxHP + 1
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, [hld]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
2016-05-16 06:36:24 -07:00
|
|
|
ld [wCurHPAnimMaxHP], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wEnemyMonHP + 1], a
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, [hl]
|
|
|
|
ld [de], a
|
2016-05-16 06:36:24 -07:00
|
|
|
ld [wCurHPAnimMaxHP + 1], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wEnemyMonHP], a
|
2015-10-07 18:27:32 -07:00
|
|
|
jr EnemyPotionFinish
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
EnemyUsedPotion:
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, POTION
|
|
|
|
ld b, 20
|
2015-10-07 18:27:32 -07:00
|
|
|
jr EnemyPotionContinue
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
EnemyUsedSuperPotion:
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, SUPER_POTION
|
|
|
|
ld b, 50
|
2015-10-07 18:27:32 -07:00
|
|
|
jr EnemyPotionContinue
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
EnemyUsedHyperPotion:
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, HYPER_POTION
|
|
|
|
ld b, 200
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
EnemyPotionContinue:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCurEnemyItem], a
|
|
|
|
ld hl, wEnemyMonHP + 1
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, [hl]
|
2016-05-16 06:36:24 -07:00
|
|
|
ld [wCurHPAnimOldHP], a
|
2014-06-14 15:03:23 -07:00
|
|
|
add b
|
|
|
|
ld [hld], a
|
2016-05-16 06:36:24 -07:00
|
|
|
ld [wCurHPAnimNewHP], a
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, [hl]
|
2016-05-16 06:36:24 -07:00
|
|
|
ld [wCurHPAnimOldHP + 1], a
|
|
|
|
ld [wCurHPAnimNewHP + 1], a
|
2015-10-07 18:27:32 -07:00
|
|
|
jr nc, .ok
|
2014-06-14 15:03:23 -07:00
|
|
|
inc a
|
|
|
|
ld [hl], a
|
2016-05-16 06:36:24 -07:00
|
|
|
ld [wCurHPAnimNewHP + 1], a
|
2015-10-07 18:27:32 -07:00
|
|
|
.ok
|
2014-06-14 15:03:23 -07:00
|
|
|
inc hl
|
|
|
|
ld a, [hld]
|
|
|
|
ld b, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wEnemyMonMaxHP + 1
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, [de]
|
|
|
|
dec de
|
2016-05-16 06:36:24 -07:00
|
|
|
ld [wCurHPAnimMaxHP], a
|
2014-06-14 15:03:23 -07:00
|
|
|
sub b
|
|
|
|
ld a, [hli]
|
|
|
|
ld b, a
|
|
|
|
ld a, [de]
|
2016-05-16 06:36:24 -07:00
|
|
|
ld [wCurHPAnimMaxHP + 1], a
|
2014-06-14 15:03:23 -07:00
|
|
|
sbc b
|
2015-10-07 18:27:32 -07:00
|
|
|
jr nc, EnemyPotionFinish
|
2014-06-14 15:03:23 -07:00
|
|
|
inc de
|
|
|
|
ld a, [de]
|
|
|
|
dec de
|
|
|
|
ld [hld], a
|
2016-05-16 06:36:24 -07:00
|
|
|
ld [wCurHPAnimNewHP], a
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, [de]
|
|
|
|
ld [hl], a
|
2016-05-16 06:36:24 -07:00
|
|
|
ld [wCurHPAnimNewHP + 1], a
|
2014-08-13 19:44:56 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
EnemyPotionFinish:
|
2015-08-24 16:56:30 -07:00
|
|
|
call PrintText_UsedItemOn
|
2014-06-14 15:03:23 -07:00
|
|
|
hlcoord 2, 2
|
|
|
|
xor a
|
2015-12-26 15:11:55 -08:00
|
|
|
ld [wWhichHPBar], a
|
2014-08-13 19:44:56 -07:00
|
|
|
call AIUsedItemSound
|
2018-01-16 11:30:10 -08:00
|
|
|
predef AnimateHPBar
|
2014-08-13 19:44:56 -07:00
|
|
|
jp AIUpdateHUD
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_TrySwitch:
|
2015-10-07 18:27:32 -07:00
|
|
|
; Determine whether the AI can switch based on how many Pokemon are still alive.
|
|
|
|
; If it can switch, it will.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wOTPartyCount]
|
2014-06-14 15:03:23 -07:00
|
|
|
ld c, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wOTPartyMon1HP
|
2014-06-14 15:03:23 -07:00
|
|
|
ld d, 0
|
2016-04-10 11:42:14 -07:00
|
|
|
.SwitchLoop:
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld b, a
|
|
|
|
ld a, [hld]
|
|
|
|
or b
|
2015-10-07 18:27:32 -07:00
|
|
|
jr z, .fainted
|
2014-06-14 15:03:23 -07:00
|
|
|
inc d
|
2015-10-07 18:27:32 -07:00
|
|
|
.fainted
|
2014-06-14 15:03:23 -07:00
|
|
|
push bc
|
2015-11-04 08:19:58 -08:00
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
2014-06-14 15:03:23 -07:00
|
|
|
add hl, bc
|
|
|
|
pop bc
|
|
|
|
dec c
|
2015-10-07 18:27:32 -07:00
|
|
|
jr nz, .SwitchLoop
|
2014-08-13 19:44:56 -07:00
|
|
|
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, d
|
2014-08-13 19:44:56 -07:00
|
|
|
cp 2
|
|
|
|
jp nc, AI_Switch
|
2014-06-14 15:03:23 -07:00
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_Switch:
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, $1
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wEnemyIsSwitching], a
|
2015-11-08 16:09:36 -08:00
|
|
|
ld [wEnemyGoesFirst], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemySubStatus4
|
2014-06-14 15:03:23 -07:00
|
|
|
res SUBSTATUS_RAGE, [hl]
|
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hBattleTurn], a
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar PursuitSwitch
|
2015-11-06 06:04:27 -08:00
|
|
|
|
2014-06-14 15:03:23 -07:00
|
|
|
push af
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurOTMon]
|
|
|
|
ld hl, wOTPartyMon1Status
|
2015-11-04 08:19:58 -08:00
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
2014-06-14 15:03:23 -07:00
|
|
|
call AddNTimes
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonStatus
|
2016-03-01 19:31:21 -08:00
|
|
|
ld bc, MON_MAXHP - MON_STATUS
|
2014-06-14 15:03:23 -07:00
|
|
|
call CopyBytes
|
|
|
|
pop af
|
2015-11-06 06:04:27 -08:00
|
|
|
|
2015-10-07 18:27:32 -07:00
|
|
|
jr c, .skiptext
|
2019-10-20 15:24:17 -07:00
|
|
|
ld hl, EnemyWithdrewText
|
2014-06-14 15:03:23 -07:00
|
|
|
call PrintText
|
2015-11-06 06:04:27 -08:00
|
|
|
|
2015-10-07 18:27:32 -07:00
|
|
|
.skiptext
|
2015-11-10 16:51:13 -08:00
|
|
|
ld a, 1
|
2016-08-07 15:14:20 -07:00
|
|
|
ld [wBattleHasJustStarted], a
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar NewEnemyMonStatus
|
|
|
|
callfar ResetEnemyStatLevels
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPlayerSubStatus1
|
2014-06-14 15:03:23 -07:00
|
|
|
res SUBSTATUS_IN_LOVE, [hl]
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall EnemySwitch
|
|
|
|
farcall ResetBattleParticipants
|
2014-06-14 15:03:23 -07:00
|
|
|
xor a
|
2016-08-07 15:14:20 -07:00
|
|
|
ld [wBattleHasJustStarted], a
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [wLinkMode]
|
2014-06-14 15:03:23 -07:00
|
|
|
and a
|
|
|
|
ret nz
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
EnemyWithdrewText:
|
|
|
|
text_far _EnemyWithdrewText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2015-10-07 18:27:32 -07:00
|
|
|
Function384d5: ; This appears to be unused
|
2014-08-13 19:44:56 -07:00
|
|
|
call AIUsedItemSound
|
|
|
|
call AI_HealStatus
|
2017-12-12 19:58:20 -08:00
|
|
|
ld a, FULL_HEAL_RED ; X_SPEED
|
2015-08-24 16:56:30 -07:00
|
|
|
jp PrintText_UsedItemOn_AND_AIUpdateHUD
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AI_HealStatus:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurOTMon]
|
|
|
|
ld hl, wOTPartyMon1Status
|
2015-11-04 08:19:58 -08:00
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
2014-06-14 15:03:23 -07:00
|
|
|
call AddNTimes
|
|
|
|
xor a
|
|
|
|
ld [hl], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wEnemyMonStatus], a
|
2020-01-04 13:52:08 -08:00
|
|
|
; Bug: this should reset SUBSTATUS_NIGHTMARE
|
|
|
|
; Uncomment the 2 lines below to fix
|
2018-01-23 14:39:09 -08:00
|
|
|
; ld hl, wEnemySubStatus1
|
2017-12-12 19:58:20 -08:00
|
|
|
; res SUBSTATUS_NIGHTMARE, [hl]
|
2020-01-04 13:52:08 -08:00
|
|
|
; Bug: this should reset SUBSTATUS_CONFUSED
|
|
|
|
; Uncomment the 2 lines below to fix
|
|
|
|
; ld hl, wEnemySubStatus3
|
|
|
|
; res SUBSTATUS_CONFUSED, [hl]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemySubStatus5
|
2014-06-14 15:03:23 -07:00
|
|
|
res SUBSTATUS_TOXIC, [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
EnemyUsedXAccuracy:
|
2014-08-13 19:44:56 -07:00
|
|
|
call AIUsedItemSound
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemySubStatus4
|
2014-08-13 19:44:56 -07:00
|
|
|
set SUBSTATUS_X_ACCURACY, [hl]
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, X_ACCURACY
|
2015-08-24 16:56:30 -07:00
|
|
|
jp PrintText_UsedItemOn_AND_AIUpdateHUD
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
EnemyUsedGuardSpec:
|
2014-08-13 19:44:56 -07:00
|
|
|
call AIUsedItemSound
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemySubStatus4
|
2014-06-14 15:03:23 -07:00
|
|
|
set SUBSTATUS_MIST, [hl]
|
|
|
|
ld a, GUARD_SPEC
|
2015-08-24 16:56:30 -07:00
|
|
|
jp PrintText_UsedItemOn_AND_AIUpdateHUD
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
EnemyUsedDireHit:
|
2014-08-13 19:44:56 -07:00
|
|
|
call AIUsedItemSound
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemySubStatus4
|
2014-06-14 15:03:23 -07:00
|
|
|
set SUBSTATUS_FOCUS_ENERGY, [hl]
|
|
|
|
ld a, DIRE_HIT
|
2015-08-24 16:56:30 -07:00
|
|
|
jp PrintText_UsedItemOn_AND_AIUpdateHUD
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2015-10-07 18:27:32 -07:00
|
|
|
Function3851e: ; This appears to be unused
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hDivisor], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonMaxHP
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, [hli]
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hDividend], a
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, [hl]
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hDividend + 1], a
|
2015-10-07 18:27:32 -07:00
|
|
|
ld b, 2
|
2014-06-14 15:03:23 -07:00
|
|
|
call Divide
|
2018-08-26 10:49:38 -07:00
|
|
|
ldh a, [hQuotient + 3]
|
2014-06-14 15:03:23 -07:00
|
|
|
ld c, a
|
2018-08-26 10:49:38 -07:00
|
|
|
ldh a, [hQuotient + 2]
|
2014-06-14 15:03:23 -07:00
|
|
|
ld b, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonHP + 1
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, [hld]
|
|
|
|
ld e, a
|
|
|
|
ld a, [hl]
|
|
|
|
ld d, a
|
|
|
|
ld a, d
|
|
|
|
sub b
|
|
|
|
ret nz
|
|
|
|
ld a, e
|
|
|
|
sub c
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
EnemyUsedXAttack:
|
2014-06-14 15:03:23 -07:00
|
|
|
ld b, ATTACK
|
|
|
|
ld a, X_ATTACK
|
2015-10-07 18:27:32 -07:00
|
|
|
jr EnemyUsedXItem
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
EnemyUsedXDefend:
|
2014-06-14 15:03:23 -07:00
|
|
|
ld b, DEFENSE
|
|
|
|
ld a, X_DEFEND
|
2015-10-07 18:27:32 -07:00
|
|
|
jr EnemyUsedXItem
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
EnemyUsedXSpeed:
|
2014-06-14 15:03:23 -07:00
|
|
|
ld b, SPEED
|
|
|
|
ld a, X_SPEED
|
2015-10-07 18:27:32 -07:00
|
|
|
jr EnemyUsedXItem
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
EnemyUsedXSpecial:
|
2014-06-14 15:03:23 -07:00
|
|
|
ld b, SP_ATTACK
|
|
|
|
ld a, X_SPECIAL
|
|
|
|
|
2015-08-24 16:56:30 -07:00
|
|
|
; Parameter
|
|
|
|
; a = ITEM_CONSTANT
|
|
|
|
; b = BATTLE_CONSTANT (ATTACK, DEFENSE, SPEED, SP_ATTACK, SP_DEFENSE, ACCURACY, EVASION)
|
2015-10-07 18:27:32 -07:00
|
|
|
EnemyUsedXItem:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCurEnemyItem], a
|
2014-06-14 15:03:23 -07:00
|
|
|
push bc
|
2015-08-24 16:56:30 -07:00
|
|
|
call PrintText_UsedItemOn
|
2014-06-14 15:03:23 -07:00
|
|
|
pop bc
|
2018-08-17 08:48:41 -07:00
|
|
|
farcall RaiseStat
|
2014-08-13 19:44:56 -07:00
|
|
|
jp AIUpdateHUD
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2015-08-24 16:56:30 -07:00
|
|
|
; Parameter
|
|
|
|
; a = ITEM_CONSTANT
|
2018-06-24 07:09:41 -07:00
|
|
|
PrintText_UsedItemOn_AND_AIUpdateHUD:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCurEnemyItem], a
|
2015-08-24 16:56:30 -07:00
|
|
|
call PrintText_UsedItemOn
|
2014-08-13 19:44:56 -07:00
|
|
|
jp AIUpdateHUD
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
PrintText_UsedItemOn:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurEnemyItem]
|
2018-07-28 16:27:34 -07:00
|
|
|
ld [wNamedObjectIndexBuffer], a
|
2014-06-14 15:03:23 -07:00
|
|
|
call GetItemName
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wStringBuffer1
|
2015-12-18 17:07:09 -08:00
|
|
|
ld de, wMonOrItemNameBuffer
|
2014-09-30 11:20:38 -07:00
|
|
|
ld bc, ITEM_NAME_LENGTH
|
2014-06-14 15:03:23 -07:00
|
|
|
call CopyBytes
|
2019-10-20 15:24:17 -07:00
|
|
|
ld hl, EnemyUsedOnText
|
2014-06-14 15:03:23 -07:00
|
|
|
jp PrintText
|
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
EnemyUsedOnText:
|
|
|
|
text_far _EnemyUsedOnText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|