2014-05-22 22:13:20 +00:00
|
|
|
; creates a set of moves that may be used and returns its address in hl
|
|
|
|
; unused slots are filled with 0, all used slots may be chosen with equal probability
|
2016-06-12 00:24:04 +00:00
|
|
|
AIEnemyTrainerChooseMoves:
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, $a
|
2015-07-25 03:27:59 +00:00
|
|
|
ld hl, wBuffer ; init temporary move selection array. Only the moves with the lowest numbers are chosen in the end
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [hli], a ; move 1
|
|
|
|
ld [hli], a ; move 2
|
|
|
|
ld [hli], a ; move 3
|
|
|
|
ld [hl], a ; move 4
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a, [wEnemyDisabledMove] ; forbid disabled move (if any)
|
2014-05-22 22:13:20 +00:00
|
|
|
swap a
|
|
|
|
and $f
|
|
|
|
jr z, .noMoveDisabled
|
2015-07-25 03:27:59 +00:00
|
|
|
ld hl, wBuffer
|
2014-05-22 22:13:20 +00:00
|
|
|
dec a
|
|
|
|
ld c, a
|
|
|
|
ld b, $0
|
|
|
|
add hl, bc ; advance pointer to forbidden move
|
|
|
|
ld [hl], $50 ; forbid (highly discourage) disabled move
|
|
|
|
.noMoveDisabled
|
2015-07-25 03:27:59 +00:00
|
|
|
ld hl, TrainerClassMoveChoiceModifications
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a, [wTrainerClass]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld b, a
|
|
|
|
.loopTrainerClasses
|
|
|
|
dec b
|
|
|
|
jr z, .readTrainerClassData
|
|
|
|
.loopTrainerClassData
|
|
|
|
ld a, [hli]
|
|
|
|
and a
|
|
|
|
jr nz, .loopTrainerClassData
|
|
|
|
jr .loopTrainerClasses
|
|
|
|
.readTrainerClassData
|
|
|
|
ld a, [hl]
|
|
|
|
and a
|
|
|
|
jp z, .useOriginalMoveSet
|
|
|
|
push hl
|
|
|
|
.nextMoveChoiceModification
|
|
|
|
pop hl
|
|
|
|
ld a, [hli]
|
|
|
|
and a
|
|
|
|
jr z, .loopFindMinimumEntries
|
|
|
|
push hl
|
2015-07-03 19:37:53 +00:00
|
|
|
ld hl, AIMoveChoiceModificationFunctionPointers
|
2014-05-22 22:13:20 +00:00
|
|
|
dec a
|
|
|
|
add a
|
|
|
|
ld c, a
|
2015-07-25 03:27:59 +00:00
|
|
|
ld b, 0
|
2014-05-22 22:13:20 +00:00
|
|
|
add hl, bc ; skip to pointer
|
|
|
|
ld a, [hli] ; read pointer into hl
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
ld de, .nextMoveChoiceModification ; set return address
|
|
|
|
push de
|
2017-06-09 21:54:09 +00:00
|
|
|
jp hl ; execute modification function
|
2014-05-22 22:13:20 +00:00
|
|
|
.loopFindMinimumEntries ; all entries will be decremented sequentially until one of them is zero
|
2015-07-25 03:27:59 +00:00
|
|
|
ld hl, wBuffer ; temp move selection array
|
2014-06-14 11:12:40 +00:00
|
|
|
ld de, wEnemyMonMoves ; enemy moves
|
2015-07-25 03:27:59 +00:00
|
|
|
ld c, NUM_MOVES
|
2014-05-22 22:13:20 +00:00
|
|
|
.loopDecrementEntries
|
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
and a
|
|
|
|
jr z, .loopFindMinimumEntries
|
|
|
|
dec [hl]
|
|
|
|
jr z, .minimumEntriesFound
|
|
|
|
inc hl
|
|
|
|
dec c
|
|
|
|
jr z, .loopFindMinimumEntries
|
|
|
|
jr .loopDecrementEntries
|
|
|
|
.minimumEntriesFound
|
|
|
|
ld a, c
|
|
|
|
.loopUndoPartialIteration ; undo last (partial) loop iteration
|
|
|
|
inc [hl]
|
|
|
|
dec hl
|
|
|
|
inc a
|
2015-07-25 03:27:59 +00:00
|
|
|
cp NUM_MOVES + 1
|
2014-05-22 22:13:20 +00:00
|
|
|
jr nz, .loopUndoPartialIteration
|
2015-07-25 03:27:59 +00:00
|
|
|
ld hl, wBuffer ; temp move selection array
|
2014-06-14 11:12:40 +00:00
|
|
|
ld de, wEnemyMonMoves ; enemy moves
|
2015-07-25 03:27:59 +00:00
|
|
|
ld c, NUM_MOVES
|
2014-05-22 22:13:20 +00:00
|
|
|
.filterMinimalEntries ; all minimal entries now have value 1. All other slots will be disabled (move set to 0)
|
|
|
|
ld a, [de]
|
|
|
|
and a
|
2015-07-03 19:37:53 +00:00
|
|
|
jr nz, .moveExisting
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [hl], a
|
|
|
|
.moveExisting
|
|
|
|
ld a, [hl]
|
|
|
|
dec a
|
|
|
|
jr z, .slotWithMinimalValue
|
|
|
|
xor a
|
|
|
|
ld [hli], a ; disable move slot
|
|
|
|
jr .next
|
|
|
|
.slotWithMinimalValue
|
|
|
|
ld a, [de]
|
|
|
|
ld [hli], a ; enable move slot
|
|
|
|
.next
|
|
|
|
inc de
|
|
|
|
dec c
|
|
|
|
jr nz, .filterMinimalEntries
|
2015-07-25 03:27:59 +00:00
|
|
|
ld hl, wBuffer ; use created temporary array as move set
|
2014-05-22 22:13:20 +00:00
|
|
|
ret
|
|
|
|
.useOriginalMoveSet
|
2014-06-14 11:12:40 +00:00
|
|
|
ld hl, wEnemyMonMoves ; use original move set
|
2014-05-22 22:13:20 +00:00
|
|
|
ret
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
AIMoveChoiceModificationFunctionPointers:
|
2014-05-22 22:13:20 +00:00
|
|
|
dw AIMoveChoiceModification1
|
|
|
|
dw AIMoveChoiceModification2
|
|
|
|
dw AIMoveChoiceModification3
|
|
|
|
dw AIMoveChoiceModification4 ; unused, does nothing
|
|
|
|
|
|
|
|
; discourages moves that cause no damage but only a status ailment if player's mon already has one
|
2016-06-12 00:24:04 +00:00
|
|
|
AIMoveChoiceModification1:
|
2014-06-14 11:12:40 +00:00
|
|
|
ld a, [wBattleMonStatus]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
2015-03-31 18:40:22 +00:00
|
|
|
ret z ; return if no status ailment on player's mon
|
2017-06-24 20:01:43 +00:00
|
|
|
ld hl, wBuffer - 1 ; temp move selection array (-1 byte offset)
|
2015-03-31 18:40:22 +00:00
|
|
|
ld de, wEnemyMonMoves ; enemy moves
|
|
|
|
ld b, NUM_MOVES + 1
|
2014-05-22 22:13:20 +00:00
|
|
|
.nextMove
|
|
|
|
dec b
|
2015-03-31 18:40:22 +00:00
|
|
|
ret z ; processed all 4 moves
|
2014-05-22 22:13:20 +00:00
|
|
|
inc hl
|
|
|
|
ld a, [de]
|
|
|
|
and a
|
2015-03-31 18:40:22 +00:00
|
|
|
ret z ; no more moves in move set
|
2014-05-22 22:13:20 +00:00
|
|
|
inc de
|
|
|
|
call ReadMove
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a, [wEnemyMovePower]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
|
|
|
jr nz, .nextMove
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a, [wEnemyMoveEffect]
|
2014-05-22 22:13:20 +00:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
|
|
|
ld hl, StatusAilmentMoveEffects
|
|
|
|
ld de, $0001
|
|
|
|
call IsInArray
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
jr nc, .nextMove
|
|
|
|
ld a, [hl]
|
2015-03-31 18:40:22 +00:00
|
|
|
add $5 ; heavily discourage move
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [hl], a
|
|
|
|
jr .nextMove
|
|
|
|
|
2016-06-12 07:19:19 +00:00
|
|
|
StatusAilmentMoveEffects:
|
2015-03-31 18:40:22 +00:00
|
|
|
db $01 ; unused sleep effect
|
2014-05-22 22:13:20 +00:00
|
|
|
db SLEEP_EFFECT
|
|
|
|
db POISON_EFFECT
|
|
|
|
db PARALYZE_EFFECT
|
|
|
|
db $FF
|
|
|
|
|
2015-03-31 18:40:22 +00:00
|
|
|
; slightly encourage moves with specific effects.
|
|
|
|
; in particular, stat-modifying moves and other move effects
|
2017-06-24 20:01:43 +00:00
|
|
|
; that fall in-between
|
2016-06-12 00:24:04 +00:00
|
|
|
AIMoveChoiceModification2:
|
2015-03-31 18:40:22 +00:00
|
|
|
ld a, [wAILayer2Encouragement]
|
2015-06-11 22:41:33 +00:00
|
|
|
cp $1
|
2014-05-22 22:13:20 +00:00
|
|
|
ret nz
|
2015-03-31 20:22:12 +00:00
|
|
|
ld hl, wBuffer - 1 ; temp move selection array (-1 byte offset)
|
2015-03-31 18:40:22 +00:00
|
|
|
ld de, wEnemyMonMoves ; enemy moves
|
|
|
|
ld b, NUM_MOVES + 1
|
2014-05-22 22:13:20 +00:00
|
|
|
.nextMove
|
|
|
|
dec b
|
2015-03-31 18:40:22 +00:00
|
|
|
ret z ; processed all 4 moves
|
2014-05-22 22:13:20 +00:00
|
|
|
inc hl
|
|
|
|
ld a, [de]
|
|
|
|
and a
|
2015-03-31 18:40:22 +00:00
|
|
|
ret z ; no more moves in move set
|
2014-05-22 22:13:20 +00:00
|
|
|
inc de
|
|
|
|
call ReadMove
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a, [wEnemyMoveEffect]
|
2014-05-22 22:13:20 +00:00
|
|
|
cp ATTACK_UP1_EFFECT
|
|
|
|
jr c, .nextMove
|
|
|
|
cp BIDE_EFFECT
|
|
|
|
jr c, .preferMove
|
|
|
|
cp ATTACK_UP2_EFFECT
|
|
|
|
jr c, .nextMove
|
|
|
|
cp POISON_EFFECT
|
|
|
|
jr c, .preferMove
|
|
|
|
jr .nextMove
|
|
|
|
.preferMove
|
2016-06-12 04:30:05 +00:00
|
|
|
dec [hl] ; slightly encourage this move
|
2014-05-22 22:13:20 +00:00
|
|
|
jr .nextMove
|
|
|
|
|
2015-03-31 18:40:22 +00:00
|
|
|
; encourages moves that are effective against the player's mon (even if non-damaging).
|
|
|
|
; discourage damaging moves that are ineffective or not very effective against the player's mon,
|
|
|
|
; unless there's no damaging move that deals at least neutral damage
|
2016-06-12 00:24:04 +00:00
|
|
|
AIMoveChoiceModification3:
|
2015-03-31 20:22:12 +00:00
|
|
|
ld hl, wBuffer - 1 ; temp move selection array (-1 byte offset)
|
2015-03-31 18:40:22 +00:00
|
|
|
ld de, wEnemyMonMoves ; enemy moves
|
2015-08-07 19:39:29 +00:00
|
|
|
ld b, NUM_MOVES + 1
|
2014-05-22 22:13:20 +00:00
|
|
|
.nextMove
|
|
|
|
dec b
|
2015-03-31 18:40:22 +00:00
|
|
|
ret z ; processed all 4 moves
|
2014-05-22 22:13:20 +00:00
|
|
|
inc hl
|
|
|
|
ld a, [de]
|
|
|
|
and a
|
2015-03-31 18:40:22 +00:00
|
|
|
ret z ; no more moves in move set
|
2014-05-22 22:13:20 +00:00
|
|
|
inc de
|
|
|
|
call ReadMove
|
|
|
|
push hl
|
|
|
|
push bc
|
|
|
|
push de
|
|
|
|
callab AIGetTypeEffectiveness
|
|
|
|
pop de
|
|
|
|
pop bc
|
|
|
|
pop hl
|
2015-08-07 19:39:29 +00:00
|
|
|
ld a, [wTypeEffectiveness]
|
2014-05-22 22:13:20 +00:00
|
|
|
cp $10
|
|
|
|
jr z, .nextMove
|
|
|
|
jr c, .notEffectiveMove
|
2017-06-24 20:01:43 +00:00
|
|
|
dec [hl] ; slightly encourage this move
|
2014-05-22 22:13:20 +00:00
|
|
|
jr .nextMove
|
2015-03-31 18:40:22 +00:00
|
|
|
.notEffectiveMove ; discourages non-effective moves if better moves are available
|
2014-05-22 22:13:20 +00:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a, [wEnemyMoveType]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld d, a
|
2014-06-14 11:12:40 +00:00
|
|
|
ld hl, wEnemyMonMoves ; enemy moves
|
2015-04-01 09:23:27 +00:00
|
|
|
ld b, NUM_MOVES + 1
|
2014-05-22 22:13:20 +00:00
|
|
|
ld c, $0
|
|
|
|
.loopMoves
|
|
|
|
dec b
|
|
|
|
jr z, .done
|
|
|
|
ld a, [hli]
|
|
|
|
and a
|
|
|
|
jr z, .done
|
|
|
|
call ReadMove
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a, [wEnemyMoveEffect]
|
2014-05-22 22:13:20 +00:00
|
|
|
cp SUPER_FANG_EFFECT
|
2015-03-31 18:40:22 +00:00
|
|
|
jr z, .betterMoveFound ; Super Fang is considered to be a better move
|
2014-05-22 22:13:20 +00:00
|
|
|
cp SPECIAL_DAMAGE_EFFECT
|
2015-03-31 18:40:22 +00:00
|
|
|
jr z, .betterMoveFound ; any special damage moves are considered to be better moves
|
2014-05-22 22:13:20 +00:00
|
|
|
cp FLY_EFFECT
|
2015-03-31 18:40:22 +00:00
|
|
|
jr z, .betterMoveFound ; Fly is considered to be a better move
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a, [wEnemyMoveType]
|
2014-05-22 22:13:20 +00:00
|
|
|
cp d
|
|
|
|
jr z, .loopMoves
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a, [wEnemyMovePower]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
2015-03-31 18:40:22 +00:00
|
|
|
jr nz, .betterMoveFound ; damaging moves of a different type are considered to be better moves
|
2014-05-22 22:13:20 +00:00
|
|
|
jr .loopMoves
|
|
|
|
.betterMoveFound
|
|
|
|
ld c, a
|
|
|
|
.done
|
|
|
|
ld a, c
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
and a
|
|
|
|
jr z, .nextMove
|
2017-06-24 20:01:43 +00:00
|
|
|
inc [hl] ; slightly discourage this move
|
2014-05-22 22:13:20 +00:00
|
|
|
jr .nextMove
|
2016-06-12 00:24:04 +00:00
|
|
|
AIMoveChoiceModification4:
|
2014-05-22 22:13:20 +00:00
|
|
|
ret
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ReadMove:
|
2014-05-22 22:13:20 +00:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
|
|
|
dec a
|
2017-12-30 00:54:27 +00:00
|
|
|
ld hl, Moves
|
|
|
|
ld bc, MoveEnd - Moves
|
2014-05-22 22:13:20 +00:00
|
|
|
call AddNTimes
|
2017-12-30 00:54:27 +00:00
|
|
|
ld de, wEnemyMoveNum
|
2014-05-22 22:13:20 +00:00
|
|
|
call CopyData
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
|
|
|
; move choice modification methods that are applied for each trainer class
|
|
|
|
; 0 is sentinel value
|
2016-06-12 00:24:04 +00:00
|
|
|
TrainerClassMoveChoiceModifications:
|
2014-05-22 22:13:20 +00:00
|
|
|
db 0 ; YOUNGSTER
|
|
|
|
db 1,0 ; BUG CATCHER
|
|
|
|
db 1,0 ; LASS
|
|
|
|
db 1,3,0 ; SAILOR
|
2015-12-15 04:09:30 +00:00
|
|
|
db 1,0 ; JR_TRAINER_M
|
|
|
|
db 1,0 ; JR_TRAINER_F
|
2014-05-22 22:13:20 +00:00
|
|
|
db 1,2,3,0; POKEMANIAC
|
|
|
|
db 1,2,0 ; SUPER_NERD
|
|
|
|
db 1,0 ; HIKER
|
|
|
|
db 1,0 ; BIKER
|
|
|
|
db 1,3,0 ; BURGLAR
|
|
|
|
db 1,0 ; ENGINEER
|
|
|
|
db 1,2,0 ; JUGGLER_X
|
|
|
|
db 1,3,0 ; FISHER
|
|
|
|
db 1,3,0 ; SWIMMER
|
|
|
|
db 0 ; CUE_BALL
|
|
|
|
db 1,0 ; GAMBLER
|
|
|
|
db 1,3,0 ; BEAUTY
|
|
|
|
db 1,2,0 ; PSYCHIC_TR
|
|
|
|
db 1,3,0 ; ROCKER
|
|
|
|
db 1,0 ; JUGGLER
|
|
|
|
db 1,0 ; TAMER
|
|
|
|
db 1,0 ; BIRD_KEEPER
|
|
|
|
db 1,0 ; BLACKBELT
|
|
|
|
db 1,0 ; SONY1
|
|
|
|
db 1,3,0 ; PROF_OAK
|
|
|
|
db 1,2,0 ; CHIEF
|
|
|
|
db 1,2,0 ; SCIENTIST
|
|
|
|
db 1,3,0 ; GIOVANNI
|
|
|
|
db 1,0 ; ROCKET
|
|
|
|
db 1,3,0 ; COOLTRAINER_M
|
|
|
|
db 1,3,0 ; COOLTRAINER_F
|
|
|
|
db 1,0 ; BRUNO
|
|
|
|
db 1,0 ; BROCK
|
|
|
|
db 1,3,0 ; MISTY
|
2015-12-15 04:09:30 +00:00
|
|
|
db 1,3,0 ; LT_SURGE
|
2014-05-22 22:13:20 +00:00
|
|
|
db 1,3,0 ; ERIKA
|
|
|
|
db 1,3,0 ; KOGA
|
|
|
|
db 1,3,0 ; BLAINE
|
|
|
|
db 1,3,0 ; SABRINA
|
|
|
|
db 1,2,0 ; GENTLEMAN
|
|
|
|
db 1,3,0 ; SONY2
|
|
|
|
db 1,3,0 ; SONY3
|
|
|
|
db 1,2,3,0; LORELEI
|
|
|
|
db 1,0 ; CHANNELER
|
|
|
|
db 1,0 ; AGATHA
|
|
|
|
db 1,3,0 ; LANCE
|
|
|
|
|
2015-04-01 15:27:51 +00:00
|
|
|
INCLUDE "engine/battle/trainer_pic_money_pointers.asm"
|
2015-06-11 22:41:33 +00:00
|
|
|
|
|
|
|
INCLUDE "text/trainer_names.asm"
|
2014-05-22 22:13:20 +00:00
|
|
|
|
2015-04-01 15:27:51 +00:00
|
|
|
INCLUDE "engine/battle/bank_e_misc.asm"
|
2014-05-22 22:13:20 +00:00
|
|
|
|
2015-04-01 15:27:51 +00:00
|
|
|
INCLUDE "engine/battle/read_trainer_party.asm"
|
2014-05-22 22:13:20 +00:00
|
|
|
|
|
|
|
INCLUDE "data/trainer_moves.asm"
|
|
|
|
|
|
|
|
INCLUDE "data/trainer_parties.asm"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
TrainerAI:
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [wIsInBattle]
|
2014-05-22 22:13:20 +00:00
|
|
|
dec a
|
|
|
|
ret z ; if not a trainer, we're done here
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [wLinkState]
|
2015-02-07 10:43:08 +00:00
|
|
|
cp LINK_STATE_BATTLING
|
2014-05-22 22:13:20 +00:00
|
|
|
ret z
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [wTrainerClass] ; what trainer class is this?
|
2014-05-22 22:13:20 +00:00
|
|
|
dec a
|
2017-12-30 00:54:27 +00:00
|
|
|
ld c, a
|
|
|
|
ld b, 0
|
|
|
|
ld hl, TrainerAIPointers
|
|
|
|
add hl, bc
|
|
|
|
add hl, bc
|
|
|
|
add hl, bc
|
|
|
|
ld a, [wAICount]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
|
|
|
ret z ; if no AI uses left, we're done here
|
|
|
|
inc hl
|
|
|
|
inc a
|
2017-12-30 00:54:27 +00:00
|
|
|
jr nz, .getpointer
|
2014-05-22 22:13:20 +00:00
|
|
|
dec hl
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [hli]
|
|
|
|
ld [wAICount], a
|
2014-05-22 22:13:20 +00:00
|
|
|
.getpointer
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2014-05-24 18:40:38 +00:00
|
|
|
call Random
|
2017-06-09 21:54:09 +00:00
|
|
|
jp hl
|
2014-05-22 22:13:20 +00:00
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
TrainerAIPointers:
|
2014-05-22 22:13:20 +00:00
|
|
|
; one entry per trainer class
|
|
|
|
; first byte, number of times (per Pokémon) it can occur
|
|
|
|
; next two bytes, pointer to AI subroutine for trainer class
|
|
|
|
dbw 3,GenericAI
|
|
|
|
dbw 3,GenericAI
|
|
|
|
dbw 3,GenericAI
|
|
|
|
dbw 3,GenericAI
|
|
|
|
dbw 3,GenericAI
|
|
|
|
dbw 3,GenericAI
|
|
|
|
dbw 3,GenericAI
|
|
|
|
dbw 3,GenericAI
|
|
|
|
dbw 3,GenericAI
|
|
|
|
dbw 3,GenericAI
|
|
|
|
dbw 3,GenericAI
|
|
|
|
dbw 3,GenericAI
|
|
|
|
dbw 3,JugglerAI ; juggler_x
|
|
|
|
dbw 3,GenericAI
|
|
|
|
dbw 3,GenericAI
|
|
|
|
dbw 3,GenericAI
|
|
|
|
dbw 3,GenericAI
|
|
|
|
dbw 3,GenericAI
|
|
|
|
dbw 3,GenericAI
|
|
|
|
dbw 3,GenericAI
|
|
|
|
dbw 3,JugglerAI ; juggler
|
|
|
|
dbw 3,GenericAI
|
|
|
|
dbw 3,GenericAI
|
|
|
|
dbw 2,BlackbeltAI ; blackbelt
|
|
|
|
dbw 3,GenericAI
|
|
|
|
dbw 3,GenericAI
|
|
|
|
dbw 1,GenericAI ; chief
|
|
|
|
dbw 3,GenericAI
|
|
|
|
dbw 1,GiovanniAI ; giovanni
|
|
|
|
dbw 3,GenericAI
|
|
|
|
dbw 2,CooltrainerMAI ; cooltrainerm
|
|
|
|
dbw 1,CooltrainerFAI ; cooltrainerf
|
|
|
|
dbw 2,BrunoAI ; bruno
|
|
|
|
dbw 5,BrockAI ; brock
|
|
|
|
dbw 1,MistyAI ; misty
|
|
|
|
dbw 1,LtSurgeAI ; surge
|
|
|
|
dbw 1,ErikaAI ; erika
|
|
|
|
dbw 2,KogaAI ; koga
|
|
|
|
dbw 2,BlaineAI ; blaine
|
|
|
|
dbw 1,SabrinaAI ; sabrina
|
|
|
|
dbw 3,GenericAI
|
|
|
|
dbw 1,Sony2AI ; sony2
|
|
|
|
dbw 1,Sony3AI ; sony3
|
|
|
|
dbw 2,LoreleiAI ; lorelei
|
|
|
|
dbw 3,GenericAI
|
|
|
|
dbw 2,AgathaAI ; agatha
|
|
|
|
dbw 1,LanceAI ; lance
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
JugglerAI:
|
2014-05-22 22:13:20 +00:00
|
|
|
cp $40
|
|
|
|
ret nc
|
2015-02-08 09:44:41 +00:00
|
|
|
jp AISwitchIfEnoughMons
|
2014-05-22 22:13:20 +00:00
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
BlackbeltAI:
|
2014-05-22 22:13:20 +00:00
|
|
|
cp $20
|
|
|
|
ret nc
|
|
|
|
jp AIUseXAttack
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
GiovanniAI:
|
2014-05-22 22:13:20 +00:00
|
|
|
cp $40
|
|
|
|
ret nc
|
|
|
|
jp AIUseGuardSpec
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
CooltrainerMAI:
|
2014-05-22 22:13:20 +00:00
|
|
|
cp $40
|
|
|
|
ret nc
|
|
|
|
jp AIUseXAttack
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
CooltrainerFAI:
|
2014-05-22 22:13:20 +00:00
|
|
|
cp $40
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, $A
|
2015-02-08 09:44:41 +00:00
|
|
|
call AICheckIfHPBelowFraction
|
2017-12-30 00:54:27 +00:00
|
|
|
jp c, AIUseHyperPotion
|
|
|
|
ld a, 5
|
2015-02-08 09:44:41 +00:00
|
|
|
call AICheckIfHPBelowFraction
|
2014-05-22 22:13:20 +00:00
|
|
|
ret nc
|
2015-02-08 09:44:41 +00:00
|
|
|
jp AISwitchIfEnoughMons
|
2014-05-22 22:13:20 +00:00
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
BrockAI:
|
2014-05-22 22:13:20 +00:00
|
|
|
; if his active monster has a status condition, use a full heal
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [wEnemyMonStatus]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
jp AIUseFullHeal
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
MistyAI:
|
2014-05-22 22:13:20 +00:00
|
|
|
cp $40
|
|
|
|
ret nc
|
|
|
|
jp AIUseXDefend
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
LtSurgeAI:
|
2014-05-22 22:13:20 +00:00
|
|
|
cp $40
|
|
|
|
ret nc
|
|
|
|
jp AIUseXSpeed
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ErikaAI:
|
2014-05-22 22:13:20 +00:00
|
|
|
cp $80
|
|
|
|
ret nc
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, $A
|
2015-02-08 09:44:41 +00:00
|
|
|
call AICheckIfHPBelowFraction
|
2014-05-22 22:13:20 +00:00
|
|
|
ret nc
|
|
|
|
jp AIUseSuperPotion
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
KogaAI:
|
2014-05-22 22:13:20 +00:00
|
|
|
cp $40
|
|
|
|
ret nc
|
|
|
|
jp AIUseXAttack
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
BlaineAI:
|
2014-05-22 22:13:20 +00:00
|
|
|
cp $40
|
|
|
|
ret nc
|
|
|
|
jp AIUseSuperPotion
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
SabrinaAI:
|
2014-05-22 22:13:20 +00:00
|
|
|
cp $40
|
|
|
|
ret nc
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, $A
|
2015-02-08 09:44:41 +00:00
|
|
|
call AICheckIfHPBelowFraction
|
2014-05-22 22:13:20 +00:00
|
|
|
ret nc
|
|
|
|
jp AIUseHyperPotion
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
Sony2AI:
|
2014-05-22 22:13:20 +00:00
|
|
|
cp $20
|
|
|
|
ret nc
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, 5
|
2015-02-08 09:44:41 +00:00
|
|
|
call AICheckIfHPBelowFraction
|
2014-05-22 22:13:20 +00:00
|
|
|
ret nc
|
|
|
|
jp AIUsePotion
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
Sony3AI:
|
2014-05-22 22:13:20 +00:00
|
|
|
cp $20
|
|
|
|
ret nc
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, 5
|
2015-02-08 09:44:41 +00:00
|
|
|
call AICheckIfHPBelowFraction
|
2014-05-22 22:13:20 +00:00
|
|
|
ret nc
|
|
|
|
jp AIUseFullRestore
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
LoreleiAI:
|
2014-05-22 22:13:20 +00:00
|
|
|
cp $80
|
|
|
|
ret nc
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, 5
|
2015-02-08 09:44:41 +00:00
|
|
|
call AICheckIfHPBelowFraction
|
2014-05-22 22:13:20 +00:00
|
|
|
ret nc
|
|
|
|
jp AIUseSuperPotion
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
BrunoAI:
|
2014-05-22 22:13:20 +00:00
|
|
|
cp $40
|
|
|
|
ret nc
|
|
|
|
jp AIUseXDefend
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
AgathaAI:
|
2014-05-22 22:13:20 +00:00
|
|
|
cp $14
|
2017-12-30 00:54:27 +00:00
|
|
|
jp c, AISwitchIfEnoughMons
|
2014-05-22 22:13:20 +00:00
|
|
|
cp $80
|
|
|
|
ret nc
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, 4
|
2015-02-08 09:44:41 +00:00
|
|
|
call AICheckIfHPBelowFraction
|
2014-05-22 22:13:20 +00:00
|
|
|
ret nc
|
|
|
|
jp AIUseSuperPotion
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
LanceAI:
|
2014-05-22 22:13:20 +00:00
|
|
|
cp $80
|
|
|
|
ret nc
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, 5
|
2015-02-08 09:44:41 +00:00
|
|
|
call AICheckIfHPBelowFraction
|
2014-05-22 22:13:20 +00:00
|
|
|
ret nc
|
|
|
|
jp AIUseHyperPotion
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
GenericAI:
|
2014-05-22 22:13:20 +00:00
|
|
|
and a ; clear carry
|
|
|
|
ret
|
|
|
|
|
|
|
|
; end of individual trainer AI routines
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
DecrementAICount:
|
2017-12-30 00:54:27 +00:00
|
|
|
ld hl, wAICount
|
2014-05-22 22:13:20 +00:00
|
|
|
dec [hl]
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
AIPlayRestoringSFX:
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, SFX_HEAL_AILMENT
|
2014-05-22 22:13:20 +00:00
|
|
|
jp PlaySoundWaitForCurrent
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
AIUseFullRestore:
|
2014-05-22 22:13:20 +00:00
|
|
|
call AICureStatus
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, FULL_RESTORE
|
|
|
|
ld [wAIItem], a
|
|
|
|
ld de, wHPBarOldHP
|
|
|
|
ld hl, wEnemyMonHP + 1
|
|
|
|
ld a, [hld]
|
|
|
|
ld [de], a
|
2014-05-22 22:13:20 +00:00
|
|
|
inc de
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [hl]
|
|
|
|
ld [de], a
|
2014-05-22 22:13:20 +00:00
|
|
|
inc de
|
2017-12-30 00:54:27 +00:00
|
|
|
ld hl, wEnemyMonMaxHP + 1
|
|
|
|
ld a, [hld]
|
|
|
|
ld [de], a
|
2014-05-22 22:13:20 +00:00
|
|
|
inc de
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [wHPBarMaxHP], a
|
|
|
|
ld [wEnemyMonHP + 1], a
|
|
|
|
ld a, [hl]
|
|
|
|
ld [de], a
|
|
|
|
ld [wHPBarMaxHP+1], a
|
|
|
|
ld [wEnemyMonHP], a
|
2015-02-08 09:44:41 +00:00
|
|
|
jr AIPrintItemUseAndUpdateHPBar
|
2014-05-22 22:13:20 +00:00
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
AIUsePotion:
|
2014-05-22 22:13:20 +00:00
|
|
|
; enemy trainer heals his monster with a potion
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, POTION
|
|
|
|
ld b, 20
|
2014-05-22 22:13:20 +00:00
|
|
|
jr AIRecoverHP
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
AIUseSuperPotion:
|
2014-05-22 22:13:20 +00:00
|
|
|
; enemy trainer heals his monster with a super potion
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, SUPER_POTION
|
|
|
|
ld b, 50
|
2014-05-22 22:13:20 +00:00
|
|
|
jr AIRecoverHP
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
AIUseHyperPotion:
|
2014-05-22 22:13:20 +00:00
|
|
|
; enemy trainer heals his monster with a hyper potion
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, HYPER_POTION
|
|
|
|
ld b, 200
|
2014-05-22 22:13:20 +00:00
|
|
|
; fallthrough
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
AIRecoverHP:
|
2014-05-22 22:13:20 +00:00
|
|
|
; heal b HP and print "trainer used $(a) on pokemon!"
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [wAIItem], a
|
|
|
|
ld hl, wEnemyMonHP + 1
|
|
|
|
ld a, [hl]
|
|
|
|
ld [wHPBarOldHP], a
|
2014-05-22 22:13:20 +00:00
|
|
|
add b
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [hld], a
|
|
|
|
ld [wHPBarNewHP], a
|
|
|
|
ld a, [hl]
|
|
|
|
ld [wHPBarOldHP+1], a
|
|
|
|
ld [wHPBarNewHP+1], a
|
|
|
|
jr nc, .next
|
2014-05-22 22:13:20 +00:00
|
|
|
inc a
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [hl], a
|
|
|
|
ld [wHPBarNewHP+1], a
|
2014-05-22 22:13:20 +00:00
|
|
|
.next
|
|
|
|
inc hl
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [hld]
|
|
|
|
ld b, a
|
|
|
|
ld de, wEnemyMonMaxHP + 1
|
|
|
|
ld a, [de]
|
2014-05-22 22:13:20 +00:00
|
|
|
dec de
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [wHPBarMaxHP], a
|
2014-05-22 22:13:20 +00:00
|
|
|
sub b
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [hli]
|
|
|
|
ld b, a
|
|
|
|
ld a, [de]
|
|
|
|
ld [wHPBarMaxHP+1], a
|
2014-05-22 22:13:20 +00:00
|
|
|
sbc b
|
2017-12-30 00:54:27 +00:00
|
|
|
jr nc, AIPrintItemUseAndUpdateHPBar
|
2014-05-22 22:13:20 +00:00
|
|
|
inc de
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [de]
|
2014-05-22 22:13:20 +00:00
|
|
|
dec de
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [hld], a
|
|
|
|
ld [wHPBarNewHP], a
|
|
|
|
ld a, [de]
|
|
|
|
ld [hl], a
|
|
|
|
ld [wHPBarNewHP+1], a
|
2014-05-22 22:13:20 +00:00
|
|
|
; fallthrough
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
AIPrintItemUseAndUpdateHPBar:
|
2014-05-22 22:13:20 +00:00
|
|
|
call AIPrintItemUse_
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 2, 2
|
2014-05-22 22:13:20 +00:00
|
|
|
xor a
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [wHPBarType], a
|
2014-06-16 20:57:26 +00:00
|
|
|
predef UpdateHPBar2
|
2014-05-22 22:13:20 +00:00
|
|
|
jp DecrementAICount
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
AISwitchIfEnoughMons:
|
2015-02-08 09:44:41 +00:00
|
|
|
; enemy trainer switches if there are 3 or more unfainted mons in party
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [wEnemyPartyCount]
|
|
|
|
ld c, a
|
|
|
|
ld hl, wEnemyMon1HP
|
2014-05-22 22:13:20 +00:00
|
|
|
|
2017-12-30 00:54:27 +00:00
|
|
|
ld d, 0 ; keep count of unfainted monsters
|
2014-05-22 22:13:20 +00:00
|
|
|
|
|
|
|
; count how many monsters haven't fainted yet
|
|
|
|
.loop
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [hli]
|
|
|
|
ld b, a
|
|
|
|
ld a, [hld]
|
2014-05-22 22:13:20 +00:00
|
|
|
or b
|
2017-12-30 00:54:27 +00:00
|
|
|
jr z, .Fainted ; has monster fainted?
|
2014-05-22 22:13:20 +00:00
|
|
|
inc d
|
|
|
|
.Fainted
|
|
|
|
push bc
|
2015-08-05 21:20:29 +00:00
|
|
|
ld bc, wEnemyMon2 - wEnemyMon1
|
2017-12-30 00:54:27 +00:00
|
|
|
add hl, bc
|
2014-05-22 22:13:20 +00:00
|
|
|
pop bc
|
|
|
|
dec c
|
2017-12-30 00:54:27 +00:00
|
|
|
jr nz, .loop
|
2014-05-22 22:13:20 +00:00
|
|
|
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, d ; how many available monsters are there?
|
2014-05-22 22:13:20 +00:00
|
|
|
cp 2 ; don't bother if only 1 or 2
|
2017-12-30 00:54:27 +00:00
|
|
|
jp nc, SwitchEnemyMon
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
SwitchEnemyMon:
|
2014-05-22 22:13:20 +00:00
|
|
|
|
|
|
|
; prepare to withdraw the active monster: copy hp, number, and status to roster
|
|
|
|
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [wEnemyMonPartyPos]
|
|
|
|
ld hl, wEnemyMon1HP
|
|
|
|
ld bc, wEnemyMon2 - wEnemyMon1
|
2014-05-22 22:13:20 +00:00
|
|
|
call AddNTimes
|
2017-12-30 00:54:27 +00:00
|
|
|
ld d, h
|
|
|
|
ld e, l
|
|
|
|
ld hl, wEnemyMonHP
|
|
|
|
ld bc, 4
|
2014-05-22 22:13:20 +00:00
|
|
|
call CopyData
|
|
|
|
|
|
|
|
ld hl, AIBattleWithdrawText
|
|
|
|
call PrintText
|
|
|
|
|
2015-07-25 03:27:59 +00:00
|
|
|
; This wFirstMonsNotOutYet variable is abused to prevent the player from
|
|
|
|
; switching in a new mon in response to this switch.
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, 1
|
|
|
|
ld [wFirstMonsNotOutYet], a
|
2014-05-22 22:13:20 +00:00
|
|
|
callab EnemySendOut
|
|
|
|
xor a
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [wFirstMonsNotOutYet], a
|
2014-05-22 22:13:20 +00:00
|
|
|
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [wLinkState]
|
2015-02-07 10:43:08 +00:00
|
|
|
cp LINK_STATE_BATTLING
|
2014-05-22 22:13:20 +00:00
|
|
|
ret z
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
AIBattleWithdrawText:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _AIBattleWithdrawText
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
AIUseFullHeal:
|
2015-07-03 19:37:53 +00:00
|
|
|
call AIPlayRestoringSFX
|
2014-05-22 22:13:20 +00:00
|
|
|
call AICureStatus
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, FULL_HEAL
|
2014-05-22 22:13:20 +00:00
|
|
|
jp AIPrintItemUse
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
AICureStatus:
|
2014-05-22 22:13:20 +00:00
|
|
|
; cures the status of enemy's active pokemon
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [wEnemyMonPartyPos]
|
|
|
|
ld hl, wEnemyMon1Status
|
|
|
|
ld bc, wEnemyMon2 - wEnemyMon1
|
2014-05-22 22:13:20 +00:00
|
|
|
call AddNTimes
|
|
|
|
xor a
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [hl], a ; clear status in enemy team roster
|
|
|
|
ld [wEnemyMonStatus], a ; clear status of active enemy
|
|
|
|
ld hl, wEnemyBattleStatus3
|
|
|
|
res 0, [hl]
|
2014-05-22 22:13:20 +00:00
|
|
|
ret
|
|
|
|
|
2016-06-12 07:19:19 +00:00
|
|
|
AIUseXAccuracy: ; unused
|
2015-07-03 19:37:53 +00:00
|
|
|
call AIPlayRestoringSFX
|
2017-12-30 00:54:27 +00:00
|
|
|
ld hl, wEnemyBattleStatus2
|
|
|
|
set 0, [hl]
|
|
|
|
ld a, X_ACCURACY
|
2014-05-22 22:13:20 +00:00
|
|
|
jp AIPrintItemUse
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
AIUseGuardSpec:
|
2015-07-03 19:37:53 +00:00
|
|
|
call AIPlayRestoringSFX
|
2017-12-30 00:54:27 +00:00
|
|
|
ld hl, wEnemyBattleStatus2
|
|
|
|
set 1, [hl]
|
|
|
|
ld a, GUARD_SPEC
|
2014-05-22 22:13:20 +00:00
|
|
|
jp AIPrintItemUse
|
|
|
|
|
2016-06-12 07:19:19 +00:00
|
|
|
AIUseDireHit: ; unused
|
2015-07-03 19:37:53 +00:00
|
|
|
call AIPlayRestoringSFX
|
2017-12-30 00:54:27 +00:00
|
|
|
ld hl, wEnemyBattleStatus2
|
|
|
|
set 2, [hl]
|
|
|
|
ld a, DIRE_HIT
|
2014-05-22 22:13:20 +00:00
|
|
|
jp AIPrintItemUse
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
AICheckIfHPBelowFraction:
|
2015-02-08 09:44:41 +00:00
|
|
|
; return carry if enemy trainer's current HP is below 1 / a of the maximum
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [H_DIVISOR], a
|
|
|
|
ld hl, wEnemyMonMaxHP
|
|
|
|
ld a, [hli]
|
|
|
|
ld [H_DIVIDEND], a
|
|
|
|
ld a, [hl]
|
|
|
|
ld [H_DIVIDEND + 1], a
|
|
|
|
ld b, 2
|
2014-05-22 22:13:20 +00:00
|
|
|
call Divide
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [H_QUOTIENT + 3]
|
|
|
|
ld c, a
|
|
|
|
ld a, [H_QUOTIENT + 2]
|
|
|
|
ld b, a
|
|
|
|
ld hl, wEnemyMonHP + 1
|
|
|
|
ld a, [hld]
|
|
|
|
ld e, a
|
|
|
|
ld a, [hl]
|
|
|
|
ld d, a
|
|
|
|
ld a, d
|
2014-05-22 22:13:20 +00:00
|
|
|
sub b
|
|
|
|
ret nz
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, e
|
2014-05-22 22:13:20 +00:00
|
|
|
sub c
|
|
|
|
ret
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
AIUseXAttack:
|
2017-12-30 00:54:27 +00:00
|
|
|
ld b, $A
|
|
|
|
ld a, X_ATTACK
|
2014-05-22 22:13:20 +00:00
|
|
|
jr AIIncreaseStat
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
AIUseXDefend:
|
2017-12-30 00:54:27 +00:00
|
|
|
ld b, $B
|
|
|
|
ld a, X_DEFEND
|
2014-05-22 22:13:20 +00:00
|
|
|
jr AIIncreaseStat
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
AIUseXSpeed:
|
2017-12-30 00:54:27 +00:00
|
|
|
ld b, $C
|
|
|
|
ld a, X_SPEED
|
2014-05-22 22:13:20 +00:00
|
|
|
jr AIIncreaseStat
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
AIUseXSpecial:
|
2017-12-30 00:54:27 +00:00
|
|
|
ld b, $D
|
|
|
|
ld a, X_SPECIAL
|
2014-05-22 22:13:20 +00:00
|
|
|
; fallthrough
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
AIIncreaseStat:
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [wAIItem], a
|
2014-05-22 22:13:20 +00:00
|
|
|
push bc
|
|
|
|
call AIPrintItemUse_
|
|
|
|
pop bc
|
2017-12-30 00:54:27 +00:00
|
|
|
ld hl, wEnemyMoveEffect
|
|
|
|
ld a, [hld]
|
2014-05-22 22:13:20 +00:00
|
|
|
push af
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [hl]
|
2014-05-22 22:13:20 +00:00
|
|
|
push af
|
|
|
|
push hl
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, ANIM_AF
|
|
|
|
ld [hli], a
|
|
|
|
ld [hl], b
|
2014-05-22 22:13:20 +00:00
|
|
|
callab StatModifierUpEffect
|
|
|
|
pop hl
|
|
|
|
pop af
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [hli], a
|
2014-05-22 22:13:20 +00:00
|
|
|
pop af
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [hl], a
|
2014-05-22 22:13:20 +00:00
|
|
|
jp DecrementAICount
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
AIPrintItemUse:
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [wAIItem], a
|
2014-05-22 22:13:20 +00:00
|
|
|
call AIPrintItemUse_
|
|
|
|
jp DecrementAICount
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
AIPrintItemUse_:
|
2015-07-15 06:16:06 +00:00
|
|
|
; print "x used [wAIItem] on z!"
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [wAIItem]
|
|
|
|
ld [wd11e], a
|
2014-05-22 22:13:20 +00:00
|
|
|
call GetItemName
|
|
|
|
ld hl, AIBattleUseItemText
|
|
|
|
jp PrintText
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
AIBattleUseItemText:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _AIBattleUseItemText
|
|
|
|
db "@"
|