2015-08-24 16:56:30 -07:00
|
|
|
AI_SwitchOrTryItem: ; 38000
|
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
|
|
|
|
2016-03-01 19:31:21 -08:00
|
|
|
callba CheckEnemyLockedIn
|
2014-06-14 15:03:23 -07:00
|
|
|
ret nz
|
2014-08-13 19:44:56 -07:00
|
|
|
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, [PlayerSubStatus5]
|
|
|
|
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
|
2015-09-04 13:30:40 -07:00
|
|
|
ld a, [InBattleTowerBattle] ; Load always the first TrainerClass 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
|
|
|
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, [TrainerClass]
|
|
|
|
dec a
|
|
|
|
ld bc, 7
|
|
|
|
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
|
|
|
|
|
2014-09-30 11:20:38 -07:00
|
|
|
DontSwitch: ; 38041
|
|
|
|
call AI_TryItem
|
2014-06-14 15:03:23 -07:00
|
|
|
ret
|
|
|
|
; 38045
|
|
|
|
|
2014-09-30 11:20:38 -07:00
|
|
|
SwitchOften: ; 38045
|
2015-11-07 05:05:57 -08:00
|
|
|
callab 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 1 + 50 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 -1 + 79 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
|
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
|
2015-08-24 16:56:30 -07:00
|
|
|
; In register 'a' is the number (1-6) of the Pkmn 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
|
|
|
; 38083
|
|
|
|
|
2014-09-30 11:20:38 -07:00
|
|
|
SwitchRarely: ; 38083
|
2015-11-07 05:05:57 -08:00
|
|
|
callab 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
|
2015-11-08 16:09:36 -08:00
|
|
|
cp -1 + 79 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
|
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
|
|
|
; 380c1
|
|
|
|
|
2014-09-30 11:20:38 -07:00
|
|
|
SwitchSometimes: ; 380c1
|
2015-11-07 05:05:57 -08:00
|
|
|
callab 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 -1 + 20 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 1 + 50 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
|
2015-11-08 16:09:36 -08:00
|
|
|
cp -1 + 20 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
|
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
|
|
|
; 380ff
|
|
|
|
|
|
|
|
|
2015-08-24 16:56:30 -07:00
|
|
|
CheckSubstatusCantRun: ; 380ff
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, [EnemySubStatus5]
|
|
|
|
bit SUBSTATUS_CANT_RUN, a
|
|
|
|
ret
|
|
|
|
; 38105
|
|
|
|
|
|
|
|
|
2014-09-30 11:20:38 -07:00
|
|
|
AI_TryItem: ; 38105
|
2015-09-04 13:30:40 -07:00
|
|
|
; items are not allowed in the BattleTower
|
|
|
|
ld a, [InBattleTowerBattle]
|
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
|
|
|
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, [TrainerClass]
|
|
|
|
dec a
|
|
|
|
ld hl, TrainerClassAttributes + 5
|
|
|
|
ld bc, 7
|
|
|
|
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
|
2015-07-20 19:18:18 -07:00
|
|
|
rept 3
|
2014-06-14 15:03:23 -07:00
|
|
|
inc hl
|
2015-07-20 19:18:18 -07:00
|
|
|
endr
|
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
|
|
|
|
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
|
|
|
|
2015-07-20 19:18:18 -07:00
|
|
|
rept 2
|
2014-06-14 15:03:23 -07:00
|
|
|
inc hl
|
2015-07-20 19:18:18 -07:00
|
|
|
endr
|
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
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
ld hl, EnemySubStatus3
|
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
|
2014-08-13 19:44:56 -07:00
|
|
|
ld [EnemyFuryCutterCount], a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [EnemyProtectCount], a
|
2015-11-05 16:13:09 -08:00
|
|
|
ld [wEnemyRageCounter], a
|
2014-09-30 11:20:38 -07:00
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
ld hl, EnemySubStatus4
|
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
|
2014-08-13 19:44:56 -07:00
|
|
|
ld [LastPlayerCounterMove], a
|
2014-09-30 11:20:38 -07:00
|
|
|
|
2014-06-14 15:03:23 -07:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
2014-09-30 11:20:38 -07:00
|
|
|
.IsHighestLevel: ; 38170
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, [OTPartyCount]
|
|
|
|
ld d, a
|
|
|
|
ld e, 0
|
|
|
|
ld hl, OTPartyMon1Level
|
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
|
|
|
|
|
|
|
ld a, [CurOTMon]
|
|
|
|
ld hl, OTPartyMon1Level
|
|
|
|
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
|
|
|
|
; 38196
|
|
|
|
|
2014-09-30 11:20:38 -07:00
|
|
|
|
|
|
|
AI_Items: ; 39196
|
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
|
2014-06-14 15:03:23 -07:00
|
|
|
db $ff
|
|
|
|
; 381be
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
.FullHeal: ; 381be
|
|
|
|
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
|
|
|
; 381ca
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
.Status: ; 381ca (e:41ca)
|
|
|
|
ld a, [EnemyMonStatus]
|
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
|
2015-11-08 07:59:28 -08:00
|
|
|
cp -1 + 20 percent
|
2014-08-13 19:44:56 -07:00
|
|
|
jp c, .Use
|
|
|
|
jp .DontUse
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2015-10-07 18:27:32 -07:00
|
|
|
.StatusCheckContext
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, [EnemySubStatus5]
|
|
|
|
bit SUBSTATUS_TOXIC, a
|
2015-10-07 18:27:32 -07:00
|
|
|
jr z, .FailToxicCheck
|
2014-08-13 19:44:56 -07:00
|
|
|
ld a, [EnemyToxicCount]
|
|
|
|
cp 4
|
2015-10-07 18:27:32 -07:00
|
|
|
jr c, .FailToxicCheck
|
2014-06-14 15:03:23 -07:00
|
|
|
call Random
|
2015-11-08 07:59:28 -08:00
|
|
|
cp 1 + 50 percent
|
2014-08-13 19:44:56 -07:00
|
|
|
jp c, .Use
|
2015-10-07 18:27:32 -07:00
|
|
|
.FailToxicCheck
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, [EnemyMonStatus]
|
|
|
|
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
|
|
|
; 38208
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
.FullRestore: ; 38208
|
|
|
|
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
|
|
|
|
2015-10-07 18:27:32 -07:00
|
|
|
.UseFullRestore
|
|
|
|
call EnemyUsedFullRestore
|
2014-08-13 19:44:56 -07:00
|
|
|
jp .Use
|
2014-06-14 15:03:23 -07:00
|
|
|
; 38220
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
.MaxPotion: ; 38220
|
|
|
|
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
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
.HealItem: ; 3822c (e:422c)
|
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
|
2014-06-14 15:03:23 -07:00
|
|
|
callab 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
|
2014-06-14 15:03:23 -07:00
|
|
|
callab AICheckEnemyQuarterHP
|
2015-10-07 18:27:32 -07:00
|
|
|
jp nc, .UseHealItem
|
2014-06-14 15:03:23 -07:00
|
|
|
call Random
|
2015-11-08 07:59:28 -08:00
|
|
|
cp 1 + 50 percent
|
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
|
|
|
|
2015-10-07 18:27:32 -07:00
|
|
|
.CheckQuarterHP: ; 38254 (e:4254)
|
2014-06-14 15:03:23 -07:00
|
|
|
callab AICheckEnemyQuarterHP
|
2014-08-13 19:44:56 -07:00
|
|
|
jp c, .DontUse
|
2014-06-14 15:03:23 -07:00
|
|
|
call Random
|
2015-11-08 07:59:28 -08:00
|
|
|
cp -1 + 20 percent
|
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
|
|
|
|
2015-10-07 18:27:32 -07:00
|
|
|
.CheckHalfOrQuarterHP: ; 38267 (e:4267)
|
2014-06-14 15:03:23 -07:00
|
|
|
callab AICheckEnemyHalfHP
|
2014-08-13 19:44:56 -07:00
|
|
|
jp c, .DontUse
|
2014-06-14 15:03:23 -07:00
|
|
|
callab AICheckEnemyQuarterHP
|
2015-10-07 18:27:32 -07:00
|
|
|
jp nc, .UseHealItem
|
2014-06-14 15:03:23 -07:00
|
|
|
call Random
|
2015-11-08 07:59:28 -08:00
|
|
|
cp -1 + 20 percent
|
2014-08-13 19:44:56 -07:00
|
|
|
jp nc, .DontUse
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2015-10-07 18:27:32 -07:00
|
|
|
.UseHealItem: ; 38281 (e:4281)
|
2014-08-13 19:44:56 -07:00
|
|
|
jp .Use
|
2014-06-14 15:03:23 -07:00
|
|
|
; 38284
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
.HyperPotion: ; 38284
|
|
|
|
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
|
|
|
; 38292 (e:4292)
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
.SuperPotion: ; 38292
|
|
|
|
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
|
|
|
; 382a0
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
.Potion: ; 382a0
|
|
|
|
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
|
|
|
; 382ae
|
|
|
|
|
2015-10-07 18:27:32 -07:00
|
|
|
.asm_382ae: ; This appears to be unused
|
2014-06-14 15:03:23 -07:00
|
|
|
callab AICheckEnemyMaxHP
|
2015-11-08 07:59:28 -08:00
|
|
|
jr c, .dont_use
|
2014-06-14 15:03:23 -07:00
|
|
|
push bc
|
|
|
|
ld de, EnemyMonMaxHP + 1
|
|
|
|
ld hl, EnemyMonHP + 1
|
|
|
|
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
|
2014-06-14 15:03:23 -07:00
|
|
|
callab 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
|
2015-11-08 07:59:28 -08:00
|
|
|
cp 1 + 50 percent
|
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
|
2015-11-08 07:59:28 -08:00
|
|
|
cp 1 + 39 percent
|
2014-08-13 19:44:56 -07:00
|
|
|
jp c, .Use
|
|
|
|
jp .DontUse
|
2014-06-14 15:03:23 -07:00
|
|
|
; 382f9
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
.XAccuracy: ; 382f9
|
|
|
|
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
|
|
|
; 38305
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
.GuardSpec: ; 38305
|
|
|
|
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
|
|
|
; 38311
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
.DireHit: ; 38311
|
|
|
|
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
|
|
|
; 3831d (e:431d)
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
.XAttack: ; 3831d
|
|
|
|
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
|
|
|
; 38329
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
.XDefend: ; 38329
|
|
|
|
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
|
|
|
; 38335
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
.XSpeed: ; 38335
|
|
|
|
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
|
|
|
; 38341
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
.XSpecial: ; 38341
|
|
|
|
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
|
|
|
; 3834d
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
.XItem: ; 3834d (e:434d)
|
|
|
|
ld a, [EnemyTurnsTaken]
|
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
|
2015-11-08 07:59:28 -08:00
|
|
|
cp 1 + 50 percent
|
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
|
2015-11-08 07:59:28 -08:00
|
|
|
cp 1 + 50 percent
|
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
|
2015-11-08 07:59:28 -08:00
|
|
|
cp -1 + 20 percent
|
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
|
|
|
|
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
AIUpdateHUD: ; 38387
|
2014-06-14 15:03:23 -07:00
|
|
|
call UpdateEnemyMonInParty
|
2014-06-16 22:52:59 -07:00
|
|
|
callba UpdateEnemyHUD
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, $1
|
|
|
|
ld [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
|
|
|
|
; 3839a
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
AIUsedItemSound: ; 3839a
|
2014-06-14 15:03:23 -07:00
|
|
|
push de
|
|
|
|
ld de, SFX_FULL_HEAL
|
|
|
|
call PlaySFX
|
|
|
|
pop de
|
|
|
|
ret
|
|
|
|
; 383a3
|
|
|
|
|
|
|
|
|
2015-10-07 18:27:32 -07:00
|
|
|
EnemyUsedFullHeal: ; 383a3 (e:43a3)
|
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
|
|
|
|
2015-10-07 18:27:32 -07:00
|
|
|
EnemyUsedMaxPotion: ; 383ae (e:43ae)
|
2014-08-13 19:44:56 -07:00
|
|
|
ld a, MAX_POTION
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd1f1], a
|
2015-10-07 18:27:32 -07:00
|
|
|
jr FullRestoreContinue
|
2014-06-14 15:03:23 -07:00
|
|
|
|
2015-10-07 18:27:32 -07:00
|
|
|
EnemyUsedFullRestore: ; 383b5 (e:43b5)
|
2014-08-13 19:44:56 -07:00
|
|
|
call AI_HealStatus
|
|
|
|
ld a, FULL_RESTORE
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd1f1], a
|
2014-08-13 19:44:56 -07:00
|
|
|
ld hl, EnemySubStatus3
|
2014-06-14 15:03:23 -07:00
|
|
|
res SUBSTATUS_CONFUSED, [hl]
|
|
|
|
xor a
|
2014-08-13 19:44:56 -07:00
|
|
|
ld [EnemyConfuseCount], a
|
|
|
|
|
2015-10-07 18:27:32 -07:00
|
|
|
FullRestoreContinue: ; 383c6
|
2015-02-08 00:03:32 -08:00
|
|
|
ld de, wd1ec
|
2014-08-13 19:44:56 -07:00
|
|
|
ld hl, EnemyMonHP + 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
|
2014-08-13 19:44:56 -07:00
|
|
|
ld hl, EnemyMonMaxHP + 1
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, [hld]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
2014-08-13 19:44:56 -07:00
|
|
|
ld [Buffer1], a
|
|
|
|
ld [EnemyMonHP + 1], a
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, [hl]
|
|
|
|
ld [de], a
|
2014-08-13 19:44:56 -07:00
|
|
|
ld [Buffer2], a
|
|
|
|
ld [EnemyMonHP], a
|
2015-10-07 18:27:32 -07:00
|
|
|
jr EnemyPotionFinish
|
2014-06-14 15:03:23 -07:00
|
|
|
; 383e8 (e:43e8)
|
|
|
|
|
2015-10-07 18:27:32 -07:00
|
|
|
EnemyUsedPotion: ; 383e8
|
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
|
|
|
|
2015-10-07 18:27:32 -07:00
|
|
|
EnemyUsedSuperPotion: ; 383ee
|
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
|
|
|
|
2015-10-07 18:27:32 -07:00
|
|
|
EnemyUsedHyperPotion: ; 383f4 (e:43f4)
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, HYPER_POTION
|
|
|
|
ld b, 200
|
|
|
|
|
2015-10-07 18:27:32 -07:00
|
|
|
EnemyPotionContinue: ; 383f8
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd1f1], a
|
2014-08-13 19:44:56 -07:00
|
|
|
ld hl, EnemyMonHP + 1
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, [hl]
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd1ec], a
|
2014-06-14 15:03:23 -07:00
|
|
|
add b
|
|
|
|
ld [hld], a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd1ee], a
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, [hl]
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd1ec + 1], a
|
|
|
|
ld [wd1ee + 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
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd1ee + 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
|
2014-08-13 19:44:56 -07:00
|
|
|
ld de, EnemyMonMaxHP + 1
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, [de]
|
|
|
|
dec de
|
2014-08-13 19:44:56 -07:00
|
|
|
ld [Buffer1], a
|
2014-06-14 15:03:23 -07:00
|
|
|
sub b
|
|
|
|
ld a, [hli]
|
|
|
|
ld b, a
|
|
|
|
ld a, [de]
|
2014-08-13 19:44:56 -07:00
|
|
|
ld [Buffer2], 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
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd1ee], a
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, [de]
|
|
|
|
ld [hl], a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd1ef], a
|
2014-08-13 19:44:56 -07:00
|
|
|
|
2015-10-07 18:27:32 -07:00
|
|
|
EnemyPotionFinish: ; 38436
|
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
|
2015-11-07 05:05:57 -08:00
|
|
|
predef AnimateHPBar
|
2014-08-13 19:44:56 -07:00
|
|
|
jp AIUpdateHUD
|
2014-06-14 15:03:23 -07:00
|
|
|
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
AI_TrySwitch: ; 3844b
|
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.
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, [OTPartyCount]
|
|
|
|
ld c, a
|
|
|
|
ld hl, OTPartyMon1HP
|
|
|
|
ld d, 0
|
2015-10-07 18:27:32 -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
|
|
|
|
; 3846c
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
AI_Switch: ; 3846c
|
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
|
2014-06-14 15:03:23 -07:00
|
|
|
ld hl, EnemySubStatus4
|
|
|
|
res SUBSTATUS_RAGE, [hl]
|
|
|
|
xor a
|
|
|
|
ld [hBattleTurn], a
|
2015-11-05 16:13:09 -08:00
|
|
|
callab PursuitSwitch
|
2015-11-06 06:04:27 -08:00
|
|
|
|
2014-06-14 15:03:23 -07:00
|
|
|
push af
|
|
|
|
ld a, [CurOTMon]
|
|
|
|
ld hl, OTPartyMon1Status
|
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
|
|
|
|
ld hl, EnemyMonStatus
|
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
|
2015-08-24 16:56:30 -07:00
|
|
|
ld hl, TextJump_EnemyWithdrew
|
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-03-01 19:31:21 -08:00
|
|
|
ld [wAISwitch], a
|
2014-06-14 15:03:23 -07:00
|
|
|
callab NewEnemyMonStatus
|
|
|
|
callab ResetEnemyStatLevels
|
|
|
|
ld hl, PlayerSubStatus1
|
|
|
|
res SUBSTATUS_IN_LOVE, [hl]
|
2015-11-07 18:04:54 -08:00
|
|
|
callba EnemySwitch
|
|
|
|
callba ResetBattleParticipants
|
2014-06-14 15:03:23 -07:00
|
|
|
xor a
|
2016-03-01 19:31:21 -08:00
|
|
|
ld [wAISwitch], 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
|
|
|
|
; 384d0
|
|
|
|
|
2015-08-24 16:56:30 -07:00
|
|
|
TextJump_EnemyWithdrew: ; 384d0
|
|
|
|
text_jump Text_EnemyWithdrew
|
2014-06-14 15:03:23 -07:00
|
|
|
db "@"
|
|
|
|
; 384d5
|
|
|
|
|
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
|
2015-10-07 18:27:32 -07:00
|
|
|
ld a, X_SPEED
|
2015-08-24 16:56:30 -07:00
|
|
|
jp PrintText_UsedItemOn_AND_AIUpdateHUD
|
2014-06-14 15:03:23 -07:00
|
|
|
; 384e0
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
AI_HealStatus: ; 384e0
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, [CurOTMon]
|
|
|
|
ld hl, OTPartyMon1Status
|
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
|
|
|
|
ld [EnemyMonStatus], a
|
|
|
|
ld hl, EnemySubStatus5
|
|
|
|
res SUBSTATUS_TOXIC, [hl]
|
|
|
|
ret
|
|
|
|
; 384f7
|
|
|
|
|
2015-10-07 18:27:32 -07:00
|
|
|
EnemyUsedXAccuracy: ; 384f7
|
2014-08-13 19:44:56 -07:00
|
|
|
call AIUsedItemSound
|
2014-06-14 15:03:23 -07:00
|
|
|
ld hl, EnemySubStatus4
|
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
|
|
|
; 38504
|
|
|
|
|
2015-10-07 18:27:32 -07:00
|
|
|
EnemyUsedGuardSpec: ; 38504
|
2014-08-13 19:44:56 -07:00
|
|
|
call AIUsedItemSound
|
2014-06-14 15:03:23 -07:00
|
|
|
ld hl, EnemySubStatus4
|
|
|
|
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
|
|
|
; 38511
|
|
|
|
|
2015-10-07 18:27:32 -07:00
|
|
|
EnemyUsedDireHit: ; 38511
|
2014-08-13 19:44:56 -07:00
|
|
|
call AIUsedItemSound
|
2014-06-14 15:03:23 -07:00
|
|
|
ld hl, EnemySubStatus4
|
|
|
|
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
|
|
|
; 3851e
|
|
|
|
|
2015-10-07 18:27:32 -07:00
|
|
|
Function3851e: ; This appears to be unused
|
2015-09-09 16:27:07 -07:00
|
|
|
ld [hDivisor], a
|
2014-06-14 15:03:23 -07:00
|
|
|
ld hl, EnemyMonMaxHP
|
|
|
|
ld a, [hli]
|
2015-10-07 10:19:41 -07:00
|
|
|
ld [hDividend], a
|
2014-06-14 15:03:23 -07:00
|
|
|
ld a, [hl]
|
2015-09-09 16:27:07 -07:00
|
|
|
ld [hDividend + 1], a
|
2015-10-07 18:27:32 -07:00
|
|
|
ld b, 2
|
2014-06-14 15:03:23 -07:00
|
|
|
call Divide
|
2015-09-09 16:27:07 -07:00
|
|
|
ld a, [hQuotient + 2]
|
2014-06-14 15:03:23 -07:00
|
|
|
ld c, a
|
2015-09-09 16:27:07 -07:00
|
|
|
ld a, [hQuotient + 1]
|
2014-06-14 15:03:23 -07:00
|
|
|
ld b, a
|
|
|
|
ld hl, EnemyMonHP + 1
|
|
|
|
ld a, [hld]
|
|
|
|
ld e, a
|
|
|
|
ld a, [hl]
|
|
|
|
ld d, a
|
|
|
|
ld a, d
|
|
|
|
sub b
|
|
|
|
ret nz
|
|
|
|
ld a, e
|
|
|
|
sub c
|
|
|
|
ret
|
|
|
|
; 38541
|
|
|
|
|
2015-10-07 18:27:32 -07:00
|
|
|
EnemyUsedXAttack: ; 38541
|
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
|
|
|
; 38547
|
|
|
|
|
2015-10-07 18:27:32 -07:00
|
|
|
EnemyUsedXDefend: ; 38547
|
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
|
|
|
; 3854d
|
|
|
|
|
2015-10-07 18:27:32 -07:00
|
|
|
EnemyUsedXSpeed: ; 3854d
|
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
|
|
|
; 38553
|
|
|
|
|
2015-10-07 18:27:32 -07:00
|
|
|
EnemyUsedXSpecial: ; 38553
|
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:
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd1f1], 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
|
2015-10-07 18:27:32 -07:00
|
|
|
callba CheckIfStatCanBeRaised
|
2014-08-13 19:44:56 -07:00
|
|
|
jp AIUpdateHUD
|
2014-06-14 15:03:23 -07:00
|
|
|
; 38568
|
|
|
|
|
|
|
|
|
2015-08-24 16:56:30 -07:00
|
|
|
; Parameter
|
|
|
|
; a = ITEM_CONSTANT
|
|
|
|
PrintText_UsedItemOn_AND_AIUpdateHUD: ; 38568
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd1f1], 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
|
|
|
; 38571
|
|
|
|
|
2015-08-24 16:56:30 -07:00
|
|
|
PrintText_UsedItemOn: ; 38571
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wd1f1]
|
|
|
|
ld [wd265], a
|
2014-06-14 15:03:23 -07:00
|
|
|
call GetItemName
|
|
|
|
ld hl, StringBuffer1
|
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
|
2015-08-24 16:56:30 -07:00
|
|
|
ld hl, TextJump_EnemyUsedOn
|
2014-06-14 15:03:23 -07:00
|
|
|
jp PrintText
|
|
|
|
; 3858c
|
|
|
|
|
2015-08-24 16:56:30 -07:00
|
|
|
TextJump_EnemyUsedOn: ; 3858c
|
|
|
|
text_jump Text_EnemyUsedOn
|
2014-06-14 15:03:23 -07:00
|
|
|
db "@"
|
|
|
|
; 38591
|