summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/engine/bank05.asm56
-rw-r--r--src/engine/deck_ai.asm192
-rw-r--r--src/wram.asm49
3 files changed, 158 insertions, 139 deletions
diff --git a/src/engine/bank05.asm b/src/engine/bank05.asm
index 8943187..5417ecc 100644
--- a/src/engine/bank05.asm
+++ b/src/engine/bank05.asm
@@ -2177,7 +2177,7 @@ RemoveCardIDInList: ; 157f3 (5:57f3)
; if Arena card could not be set (due to hand not having any card in its list)
; or if list is null, return carry and do not play any cards.
TrySetUpBossStartingPlayArea: ; 1581b (5:581b)
- ld de, wcdaa
+ ld de, wAICardListArenaPriority
ld a, d
or a
jr z, .set_carry ; return if null
@@ -2185,14 +2185,14 @@ TrySetUpBossStartingPlayArea: ; 1581b (5:581b)
; pick Arena card
call CreateHandCardList
ld hl, wDuelTempList
- ld de, wcdaa
+ ld de, wAICardListArenaPriority
call .PlayPokemonCardInOrder
ret c
; play Pokemon cards to Bench until there are
; a maximum of 3 cards in Play Area.
.loop
- ld de, wcdac
+ ld de, wAICardListBenchPriority
call .PlayPokemonCardInOrder
jr c, .done
cp 3
@@ -2960,18 +2960,18 @@ AIDecideBenchPokemonToSwitchTo: ; 15b72 (5:5b72)
cp MYSTERIOUS_FOSSIL
jr z, .lower_score_2
cp CLEFAIRY_DOLL
- jr nz, .asm_15d0c
+ jr nz, .ai_score_bonus
.lower_score_2
ld a, 10
call SubFromAIScore
-.asm_15d0c
+.ai_score_bonus
ld b, a
- ld a, [wcdb0 + 1]
+ ld a, [wAICardListRetreatBonus + 1]
or a
jr z, .store_score
ld h, a
- ld a, [wcdb0]
+ ld a, [wAICardListRetreatBonus]
ld l, a
.loop_ids
@@ -2982,11 +2982,11 @@ AIDecideBenchPokemonToSwitchTo: ; 15b72 (5:5b72)
jr nz, .next_id
ld a, [hl]
cp $80
- jr c, .asm_15d2b
+ jr c, .subtract_score
sub $80
call AddToAIScore
jr .next_id
-.asm_15d2b
+.subtract_score
ld c, a
ld a, $80
sub c
@@ -4085,17 +4085,17 @@ LookForEnergyNeededForMoveInHand: ; 16311 (5:6311)
; 0x1633f
; goes through $00 terminated list pointed
-; by wcdae and compares it to each card in hand.
+; by wAICardListPlayFromHandPriority and compares it to each card in hand.
; Sorts the hand in wDuelTempList so that the found card IDs
; are in the same order as the list pointed by de.
SortTempHandByIDList: ; 1633f (5:633f)
- ld a, [wcdae+1]
+ ld a, [wAICardListPlayFromHandPriority+1]
or a
ret z ; return if list is empty
; start going down the ID list
ld d, a
- ld a, [wcdae]
+ ld a, [wAICardListPlayFromHandPriority]
ld e, a
ld c, 0
.loop_list_id
@@ -4605,7 +4605,7 @@ AIProcessEnergyCards: ; 164fc (5:64fc)
jr .check_bench
.check_defending_can_ko
call CheckIfDefendingPokemonCanKnockOut
- jr nc, .asm_165e1
+ jr nc, .ai_score_bonus
ld a, 10
call SubFromAIScore
@@ -4616,10 +4616,10 @@ AIProcessEnergyCards: ; 164fc (5:64fc)
ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA
call GetTurnDuelistVariable
dec a
- jr nz, .asm_165e1
+ jr nz, .ai_score_bonus
ld a, 6
call AddToAIScore
- jr .asm_165e1
+ jr .ai_score_bonus
; lower AI score by 3 - (bench HP)/10
; if bench HP < 30
@@ -4628,20 +4628,20 @@ AIProcessEnergyCards: ; 164fc (5:64fc)
call GetTurnDuelistVariable
call CalculateByteTensDigit
cp 3
- jr nc, .asm_165e1
+ jr nc, .ai_score_bonus
; hp < 30
ld b, a
ld a, 3
sub b
call SubFromAIScore
-; check list in wcdb2
-.asm_165e1
- ld a, [wcdb3]
+; check list in wAICardListEnergyBonus
+.ai_score_bonus
+ ld a, [wAICardListEnergyBonus + 1]
or a
- jr z, .check_boss_deck
+ jr z, .check_boss_deck ; is null
ld h, a
- ld a, [wcdb2]
+ ld a, [wAICardListEnergyBonus]
ld l, a
push hl
@@ -7137,12 +7137,12 @@ SetUpBossStartingHandAndDeck: ; 172af (5:72af)
ld a, DUELVARS_HAND
call GetTurnDuelistVariable
ld b, STARTING_HAND_SIZE
-.asm_172b6
+.loop_hand
ld a, [hl]
call RemoveCardFromHand
call ReturnCardToDeck
dec b
- jr nz, .asm_172b6
+ jr nz, .loop_hand
jr .count_energy_basic
.shuffle_deck
@@ -7197,7 +7197,7 @@ SetUpBossStartingHandAndDeck: ; 172af (5:72af)
jr c, .shuffle_deck
; now check the following 6 cards (prize cards).
-; re-shuffle deck if any of these cards is listed in wcda8.
+; re-shuffle deck if any of these cards is listed in wAICardListAvoidPrize.
ld b, 6
.check_card_ids
ld a, [hli]
@@ -7263,20 +7263,20 @@ SetUpBossStartingHandAndDeck: ; 172af (5:72af)
; 0x17366
; expectation: return carry if card ID corresponding
-; to the input deck index is listed in wcda8;
+; to the input deck index is listed in wAICardListAvoidPrize;
; reality: always returns no carry because when checking terminating
-; byte in wcda8 ($00), it wrongfully uses 'cp a' instead of 'or a',
+; byte in wAICardListAvoidPrize ($00), it wrongfully uses 'cp a' instead of 'or a',
; so it always ends up returning in the first item in list.
; input:
; - a = deck index of card to check
.CheckIfIDIsInList ; 17366 (5:7366)
ld b, a
- ld a, [wcda8 + 1]
+ ld a, [wAICardListAvoidPrize + 1]
or a
ret z ; null
push hl
ld h, a
- ld a, [wcda8]
+ ld a, [wAICardListAvoidPrize]
ld l, a
ld a, b
diff --git a/src/engine/deck_ai.asm b/src/engine/deck_ai.asm
index 2a78848..dfa6820 100644
--- a/src/engine/deck_ai.asm
+++ b/src/engine/deck_ai.asm
@@ -262,12 +262,12 @@ AIActionTable_LegendaryMoltres: ; 149e8 (05:49e8)
db $00
.store_list_pointers ; 14a4a (5:4a4a)
- store_list_pointer wcda8, .list_prize
- store_list_pointer wcdaa, .list_arena
- store_list_pointer wcdac, .list_bench
- store_list_pointer wcdae, .list_play_hand
- store_list_pointer wcdb0, .list_retreat
- store_list_pointer wcdb2, .list_energy
+ store_list_pointer wAICardListAvoidPrize, .list_prize
+ store_list_pointer wAICardListArenaPriority, .list_arena
+ store_list_pointer wAICardListBenchPriority, .list_bench
+ store_list_pointer wAICardListPlayFromHandPriority, .list_play_hand
+ store_list_pointer wAICardListRetreatBonus, .list_retreat
+ store_list_pointer wAICardListEnergyBonus, .list_energy
ret
; 0x14a81
@@ -438,12 +438,12 @@ AIActionTable_LegendaryZapdos: ; 14b0f (05:4b0f)
db $00
.store_list_pointers ; 14b6c (5:4b6c)
- store_list_pointer wcda8, .list_prize
- store_list_pointer wcdaa, .list_arena
- store_list_pointer wcdac, .list_bench
- store_list_pointer wcdae, .list_bench
- ; missing store_list_pointer wcdb0, .list_retreat
- store_list_pointer wcdb2, .list_energy
+ store_list_pointer wAICardListAvoidPrize, .list_prize
+ store_list_pointer wAICardListArenaPriority, .list_arena
+ store_list_pointer wAICardListBenchPriority, .list_bench
+ store_list_pointer wAICardListPlayFromHandPriority, .list_bench
+ ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat
+ store_list_pointer wAICardListEnergyBonus, .list_energy
ret
; 0x14b9a
@@ -597,12 +597,12 @@ AIActionTable_LegendaryArticuno: ; 14c0b (5:4c0b)
db $00
.store_list_pointers ; 14c63 (5:4c63)
- store_list_pointer wcda8, .list_prize
- store_list_pointer wcdaa, .list_arena
- store_list_pointer wcdac, .list_bench
- store_list_pointer wcdae, .list_bench
- ; missing store_list_pointer wcdb0, .list_retreat
- store_list_pointer wcdb2, .list_energy
+ store_list_pointer wAICardListAvoidPrize, .list_prize
+ store_list_pointer wAICardListArenaPriority, .list_arena
+ store_list_pointer wAICardListBenchPriority, .list_bench
+ store_list_pointer wAICardListPlayFromHandPriority, .list_bench
+ ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat
+ store_list_pointer wAICardListEnergyBonus, .list_energy
ret
; 0x14c91
@@ -818,12 +818,12 @@ AIActionTable_LegendaryDragonite: ; 14d60 (05:4d60)
db $00
.store_list_pointers ; 14dc1 (5:4dc1)
- store_list_pointer wcda8, .list_prize
- store_list_pointer wcdaa, .list_arena
- store_list_pointer wcdac, .list_bench
- store_list_pointer wcdae, .list_bench
- ; missing store_list_pointer wcdb0, .list_retreat
- store_list_pointer wcdb2, .list_energy
+ store_list_pointer wAICardListAvoidPrize, .list_prize
+ store_list_pointer wAICardListArenaPriority, .list_arena
+ store_list_pointer wAICardListBenchPriority, .list_bench
+ store_list_pointer wAICardListPlayFromHandPriority, .list_bench
+ ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat
+ store_list_pointer wAICardListEnergyBonus, .list_energy
ret
; 0x14def
@@ -987,12 +987,12 @@ AIActionTable_FirstStrike: ; 14e89 (5:4e89)
db $00
.store_list_pointers ; 14ee0 (5:4ee0)
- store_list_pointer wcda8, .list_prize
- store_list_pointer wcdaa, .list_arena
- store_list_pointer wcdac, .list_bench
- store_list_pointer wcdae, .list_bench
- ; missing store_list_pointer wcdb0, .list_retreat
- store_list_pointer wcdb2, .list_energy
+ store_list_pointer wAICardListAvoidPrize, .list_prize
+ store_list_pointer wAICardListArenaPriority, .list_arena
+ store_list_pointer wAICardListBenchPriority, .list_bench
+ store_list_pointer wAICardListPlayFromHandPriority, .list_bench
+ ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat
+ store_list_pointer wAICardListEnergyBonus, .list_energy
ret
; 0x14f0e
@@ -1068,12 +1068,12 @@ AIActionTable_RockCrusher: ; 14f0e (5:4f0e)
db $00
.store_list_pointers ; 14f61 (5:4f61)
- store_list_pointer wcda8, .list_prize
- store_list_pointer wcdaa, .list_arena
- store_list_pointer wcdac, .list_bench
- store_list_pointer wcdae, .list_bench
- ; missing store_list_pointer wcdb0, .list_retreat
- store_list_pointer wcdb2, .list_energy
+ store_list_pointer wAICardListAvoidPrize, .list_prize
+ store_list_pointer wAICardListArenaPriority, .list_arena
+ store_list_pointer wAICardListBenchPriority, .list_bench
+ store_list_pointer wAICardListPlayFromHandPriority, .list_bench
+ ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat
+ store_list_pointer wAICardListEnergyBonus, .list_energy
ret
; 0x14f8f
@@ -1154,12 +1154,12 @@ AIActionTable_GoGoRainDance: ; 14f8f (5:4f8f)
db $00
.store_list_pointers ; 14feb (5:4feb)
- store_list_pointer wcda8, .list_prize
- store_list_pointer wcdaa, .list_arena
- store_list_pointer wcdac, .list_bench
- store_list_pointer wcdae, .list_bench
- ; missing store_list_pointer wcdb0, .list_retreat
- store_list_pointer wcdb2, .list_energy
+ store_list_pointer wAICardListAvoidPrize, .list_prize
+ store_list_pointer wAICardListArenaPriority, .list_arena
+ store_list_pointer wAICardListBenchPriority, .list_bench
+ store_list_pointer wAICardListPlayFromHandPriority, .list_bench
+ ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat
+ store_list_pointer wAICardListEnergyBonus, .list_energy
ret
; 0x15019
@@ -1236,12 +1236,12 @@ AIActionTable_ZappingSelfdestruct: ; 15019 (5:5019)
db $00
.store_list_pointers ; 1506d (5:506d)
- store_list_pointer wcda8, .list_prize
- store_list_pointer wcdaa, .list_arena
- store_list_pointer wcdac, .list_bench
- store_list_pointer wcdae, .list_bench
- ; missing store_list_pointer wcdb0, .list_retreat
- store_list_pointer wcdb2, .list_energy
+ store_list_pointer wAICardListAvoidPrize, .list_prize
+ store_list_pointer wAICardListArenaPriority, .list_arena
+ store_list_pointer wAICardListBenchPriority, .list_bench
+ store_list_pointer wAICardListPlayFromHandPriority, .list_bench
+ ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat
+ store_list_pointer wAICardListEnergyBonus, .list_energy
ret
; 0x1509b
@@ -1318,12 +1318,12 @@ AIActionTable_FlowerPower: ; 1509b (5:509b)
db $00
.store_list_pointers ; 150f4 (5:50f4)
- store_list_pointer wcda8, .list_prize
- store_list_pointer wcdaa, .list_arena
- store_list_pointer wcdac, .list_bench
- store_list_pointer wcdae, .list_bench
- ; missing store_list_pointer wcdb0, .list_retreat
- store_list_pointer wcdb2, .list_energy
+ store_list_pointer wAICardListAvoidPrize, .list_prize
+ store_list_pointer wAICardListArenaPriority, .list_arena
+ store_list_pointer wAICardListBenchPriority, .list_bench
+ store_list_pointer wAICardListPlayFromHandPriority, .list_bench
+ ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat
+ store_list_pointer wAICardListEnergyBonus, .list_energy
ret
; 0x15122
@@ -1406,12 +1406,12 @@ AIActionTable_StrangePsyshock: ; 15122 (5:5122)
db $00
.store_list_pointers ; 1517f (5:517f)
- store_list_pointer wcda8, .list_prize
- store_list_pointer wcdaa, .list_arena
- store_list_pointer wcdac, .list_bench
- store_list_pointer wcdae, .list_bench
- ; missing store_list_pointer wcdb0, .list_retreat
- store_list_pointer wcdb2, .list_energy
+ store_list_pointer wAICardListAvoidPrize, .list_prize
+ store_list_pointer wAICardListArenaPriority, .list_arena
+ store_list_pointer wAICardListBenchPriority, .list_bench
+ store_list_pointer wAICardListPlayFromHandPriority, .list_bench
+ ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat
+ store_list_pointer wAICardListEnergyBonus, .list_energy
ret
; 0x151ad
@@ -1490,12 +1490,12 @@ AIActionTable_WondersOfScience: ; 151ad (5:51ad)
db $00
.store_list_pointers ; 15204 (5:5204)
- store_list_pointer wcda8, .list_prize
- store_list_pointer wcdaa, .list_arena
- store_list_pointer wcdac, .list_bench
- store_list_pointer wcdae, .list_bench
- ; missing store_list_pointer wcdb0, .list_retreat
- store_list_pointer wcdb2, .list_energy
+ store_list_pointer wAICardListAvoidPrize, .list_prize
+ store_list_pointer wAICardListArenaPriority, .list_arena
+ store_list_pointer wAICardListBenchPriority, .list_bench
+ store_list_pointer wAICardListPlayFromHandPriority, .list_bench
+ ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat
+ store_list_pointer wAICardListEnergyBonus, .list_energy
ret
; 0x15232
@@ -1577,12 +1577,12 @@ AIActionTable_FireCharge: ; 15232 (5:5232)
db $00
.store_list_pointers ; 1528f (5:528f)
- store_list_pointer wcda8, .list_prize
- store_list_pointer wcdaa, .list_arena
- store_list_pointer wcdac, .list_bench
- store_list_pointer wcdae, .list_bench
- ; missing store_list_pointer wcdb0, .list_retreat
- store_list_pointer wcdb2, .list_energy
+ store_list_pointer wAICardListAvoidPrize, .list_prize
+ store_list_pointer wAICardListArenaPriority, .list_arena
+ store_list_pointer wAICardListBenchPriority, .list_bench
+ store_list_pointer wAICardListPlayFromHandPriority, .list_bench
+ ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat
+ store_list_pointer wAICardListEnergyBonus, .list_energy
ret
; 0x152bd
@@ -1664,12 +1664,12 @@ AIActionTable_ImRonald: ; 152bd (5:52bd)
db $00
.store_list_pointers ; 1531d (5:531d)
- store_list_pointer wcda8, .list_prize
- store_list_pointer wcdaa, .list_arena
- store_list_pointer wcdac, .list_bench
- store_list_pointer wcdae, .list_bench
- ; missing store_list_pointer wcdb0, .list_retreat
- store_list_pointer wcdb2, .list_energy
+ store_list_pointer wAICardListAvoidPrize, .list_prize
+ store_list_pointer wAICardListArenaPriority, .list_arena
+ store_list_pointer wAICardListBenchPriority, .list_bench
+ store_list_pointer wAICardListPlayFromHandPriority, .list_bench
+ ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat
+ store_list_pointer wAICardListEnergyBonus, .list_energy
ret
; 0x1534b
@@ -1763,12 +1763,12 @@ AIActionTable_PowerfulRonald: ; 1534b (5:534b)
db $00
.store_list_pointers ; 153ba (5:53ba)
- store_list_pointer wcda8, .list_prize
- store_list_pointer wcdaa, .list_arena
- store_list_pointer wcdac, .list_bench
- store_list_pointer wcdae, .list_bench
- ; missing store_list_pointer wcdb0, .list_retreat
- store_list_pointer wcdb2, .list_energy
+ store_list_pointer wAICardListAvoidPrize, .list_prize
+ store_list_pointer wAICardListArenaPriority, .list_arena
+ store_list_pointer wAICardListBenchPriority, .list_bench
+ store_list_pointer wAICardListPlayFromHandPriority, .list_bench
+ ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat
+ store_list_pointer wAICardListEnergyBonus, .list_energy
ret
; 0x153e8
@@ -1848,12 +1848,12 @@ AIActionTable_InvincibleRonald: ; 153e8 (5:53e8)
db $00
.store_list_pointers ; 15441 (5:5441)
- store_list_pointer wcda8, .list_prize
- store_list_pointer wcdaa, .list_arena
- store_list_pointer wcdac, .list_bench
- store_list_pointer wcdae, .list_bench
- ; missing store_list_pointer wcdb0, .list_retreat
- store_list_pointer wcdb2, .list_energy
+ store_list_pointer wAICardListAvoidPrize, .list_prize
+ store_list_pointer wAICardListArenaPriority, .list_arena
+ store_list_pointer wAICardListBenchPriority, .list_bench
+ store_list_pointer wAICardListPlayFromHandPriority, .list_bench
+ ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat
+ store_list_pointer wAICardListEnergyBonus, .list_energy
ret
; 0x1546f
@@ -1946,12 +1946,12 @@ AIActionTable_LegendaryRonald: ; 1546f (5:546f)
db $00
.store_list_pointers ; 154d9 (5:54d9)
- store_list_pointer wcda8, .list_prize
- store_list_pointer wcdaa, .list_arena
- store_list_pointer wcdac, .list_bench
- store_list_pointer wcdae, .list_play_hand
- ; missing store_list_pointer wcdb0, .list_retreat
- store_list_pointer wcdb2, .list_energy
+ store_list_pointer wAICardListAvoidPrize, .list_prize
+ store_list_pointer wAICardListArenaPriority, .list_arena
+ store_list_pointer wAICardListBenchPriority, .list_bench
+ store_list_pointer wAICardListPlayFromHandPriority, .list_play_hand
+ ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat
+ store_list_pointer wAICardListEnergyBonus, .list_energy
ret
; 0x15507
diff --git a/src/wram.asm b/src/wram.asm
index e4bf0b2..71830dd 100644
--- a/src/wram.asm
+++ b/src/wram.asm
@@ -1184,9 +1184,9 @@ wcda5:: ; cda5
; this is used by AI in order to determine whether
; it should use Pokedex Trainer card.
-; duel starts at 5 and counts up by one every turn.
+; starts with 5 when Duel starts and counts up by 1 every turn.
; only when it's higher than 5 is AI allowed to use Pokedex,
-; in which case it set the counter to 0.
+; in which case it sets the counter to 0.
; this stops the AI from using Pokedex right after using another one
; while still drawing cards that were ordered.
wAIPokedexCounter:: ; cda6
@@ -1201,28 +1201,47 @@ wAIPokedexCounter:: ; cda6
wAIBarrierFlagCounter:: ; cda7
ds $1
-wcda8:: ; cda8
+; pointer to $00-terminated list of card IDs
+; to avoid being placed as prize cards
+; when setting up AI duelist's cards at duel start.
+; (see SetUpBossStartingHandAndDeck)
+wAICardListAvoidPrize:: ; cda8
ds $2
-wcdaa:: ; cdaa
+; pointer to $00-terminated list of card IDs
+; sorted by priority of AI placing in the Arena
+; at duel start (see TrySetUpBossStartingPlayArea)
+wAICardListArenaPriority:: ; cdaa
ds $2
-wcdac:: ; cdac
+; pointer to $00-terminated list of card IDs
+; sorted by priority of AI placing in the Bench
+; at duel start (see TrySetUpBossStartingPlayArea)
+wAICardListBenchPriority:: ; cdac
ds $2
-; pointer to a list of card IDs for sorting AI hand
-wcdae:: ; cdae
+; pointer to $00-terminated list of card IDs
+; sorted by priority of AI playing it from Hand
+; to the Bench (see AIDecidePlayPokemonCard)
+wAICardListPlayFromHandPriority:: ; cdae
ds $2
-wcdb0:: ; cdb0
+; pointer to $00-terminated list of card IDs and AI scores.
+; these are for giving certain cards more or less
+; likelihood of being picked by AI to switch to.
+; (see AIDecideBenchPokemonToSwitchTo)
+wAICardListRetreatBonus:: ; cdb0
ds $2
-; these seem to hold pointer to some kind of
-; card ID list with attached energy and score
-wcdb2:: ; cdb2
- ds $1
-wcdb3:: ; cdb3
- ds $1
+; pointer to $00-terminated list of card IDs,
+; number of energy cards and AI score.
+; these are for giving certain cards more or less
+; likelihood of being picked for AI to attach energy.
+; also has the maximum number of energy cards that
+; the AI is willing to provide for it.
+; (see AIProcessEnergyCards)
+wAICardListEnergyBonus:: ; cdb2
+ ds $2
wcdb4:: ; cdb4
ds $1
@@ -1266,7 +1285,7 @@ wFirstAttackAIScore:: ; cdbf
ENDU
- ds $0a
+ ds $a
; information about the defending Pokémon and
; the prize card count on both sides for AI: