Skip to content

Commit

Permalink
Merge pull request #134 from ElectroDeoxys/master
Browse files Browse the repository at this point in the history
Document new bugs and clean bug documentation
  • Loading branch information
ElectroDeoxys authored Oct 22, 2023
2 parents 0a1a711 + 5853197 commit 705df56
Show file tree
Hide file tree
Showing 10 changed files with 239 additions and 170 deletions.
336 changes: 226 additions & 110 deletions bugs_and_glitches.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/data/booster_packs.asm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
BoosterSetRarityAmountsTable: ; 1e4d4 (7::64d4)
BoosterSetRarityAmountsTable:
; db energies, commons, uncommons, rares
; commons + uncommons + rares needs to be equal to 10 minus the number of energy cards
; defined in the pack's data below; otherwise, the number of cards in the pack won't be 10.
Expand Down
4 changes: 1 addition & 3 deletions src/engine/duel/ai/boss_deck_set_up.asm
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,7 @@ SetUpBossStartingHandAndDeck:

; expectation: return carry if card ID corresponding
; to the input deck index is listed in wAICardListAvoidPrize;
; reality: always returns no carry because when checking terminating
; 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.
; reality: always returns no carry
; input:
; - a = deck index of card to check
.CheckIfIDIsInList
Expand Down
10 changes: 1 addition & 9 deletions src/engine/duel/ai/decks/general.asm
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,6 @@ AIProcessRetreat:
and ~AI_FLAG_USED_SWITCH ; clear Switch flag
ld [wPreviousAIFlags], a

; bug, this doesn't make sense being here, since at this point
; Switch Trainer card was already used to retreat the Pokemon.
; what the routine will do is just transfer Energy cards to
; the Arena Pokemon for the purpose of retreating, and
; then not actually retreat, resulting in unusual behaviour.
; this would only work placed right after the AI checks whether
; they have Switch card in hand to use and doesn't have one.
; (and probably that was the original intention.)
ld a, AI_ENERGY_TRANS_RETREAT ; retreat
ld a, AI_ENERGY_TRANS_RETREAT
farcall HandleAIEnergyTrans
ret
10 changes: 0 additions & 10 deletions src/engine/duel/ai/decks/sams_practice.asm
Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,6 @@ AIPerformScriptedTurn:
ld e, FIGHTING_ENERGY
call AIAttachEnergyInHandToCardInBench

; this is a bug, it's attempting to compare a card ID with a deck index.
; the intention was to change the card to switch to depending on whether
; the first Machop was KO'd at this point in the Duel or not.
; because of the buggy comparison, this will always jump the
; 'inc a' instruction and switch to PLAY_AREA_BENCH_1.
; in a normal Practice Duel following Dr. Mason's instructions,
; this will always lead to the AI correctly switching Raticate with Machop,
; but in case of a "Free" Duel where the first Machop is not KO'd,
; the intention was to switch to PLAY_AREA_BENCH_2 instead.
; but due to 'inc a' always being skipped, it will switch to Raticate.
ld a, DUELVARS_ARENA_CARD
call GetTurnDuelistVariable
cp MACHOP ; wrong
Expand Down
3 changes: 0 additions & 3 deletions src/engine/duel/ai/energy.asm
Original file line number Diff line number Diff line change
Expand Up @@ -532,9 +532,6 @@ DetermineAIScoreOfAttackEnergyRequirement:
; this is possibly a bug.
; this is an identical check as above to test whether this card is active.
; in case it is active, the score gets added 10 more points,
; in addition to the 20 points already added above.
; what was probably intended was to add 20 points
; plus 10 in case it is the Arena card.
ldh a, [hTempPlayAreaLocation_ff9d]
or a
jr nz, .check_evolution
Expand Down
10 changes: 1 addition & 9 deletions src/engine/duel/ai/pkmn_powers.asm
Original file line number Diff line number Diff line change
Expand Up @@ -677,15 +677,7 @@ HandleAIShift:
jr z, .false
push bc
call GetCardIDFromDeckIndex
call GetCardType
; in case this is a Mysterious Fossil or Clefairy Doll card,
; AI might read the type of the card incorrectly here.
; uncomment the following lines to account for this
; cp TYPE_TRAINER
; jr nz, .not_trainer
; pop bc
; jr .loop_play_area
; .not_trainer
call GetCardType ; bug, this could be a Trainer card
call TranslateColorToWR
pop bc
and b
Expand Down
2 changes: 1 addition & 1 deletion src/engine/duel/ai/special_attacks.asm
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ HandleSpecialAIAttacks:
ret

; checks player's active card color, then
; loops through bench looking for a Pokémon
; loops through own bench looking for a Pokémon
; with that same color.
; if none are found, returns score of $80 + 2.
.ChainLightning:
Expand Down
30 changes: 7 additions & 23 deletions src/engine/duel/ai/trainer_cards.asm
Original file line number Diff line number Diff line change
Expand Up @@ -2365,11 +2365,6 @@ AIDecide_ProfessorOak:
add $0a
ld [wce06], a

; this part seems buggy
; the AI loops through all the cards in hand and checks
; if any of them is not a Pokemon card and has Basic stage.
; it seems like the intention was that if there was
; any Basic Pokemon still in hand, the AI would add to the score.
.check_hand
call CreateHandCardList
ld hl, wDuelTempList
Expand Down Expand Up @@ -3828,11 +3823,16 @@ AIDecide_FullHeal:
jr c, .no_carry

.no_scoop_up_prz
; if card can damage defending Pokemon...
; return no carry if Arena card
; cannot damage the defending Pokémon

; this is a bug, since CheckIfCanDamageDefendingPokemon
; also takes into account whether card is paralyzed
xor a ; PLAY_AREA_ARENA
farcall CheckIfCanDamageDefendingPokemon
jr nc, .no_carry
; ...and can play an energy card to retreat, set carry.

; if it can play an energy card to retreat, set carry.
ld a, [wAIPlayEnergyCardForRetreat]
or a
jr nz, .set_carry
Expand Down Expand Up @@ -4634,15 +4634,6 @@ AIDecide_Revive:
jr z, .no_carry
ld b, a
call LoadCardDataToBuffer1_FromDeckIndex

; these checks have a bug.
; it works fine for Hitmonchan and Hitmonlee,
; but in case it's a Tauros card, the routine will fallthrough
; into the Kangaskhan check. since it will never be equal to Kangaskhan,
; it will fallthrough into the set carry branch.
; in case it's a Kangaskhan card, the check will fail in the Tauros check
; and jump back into the loop. so just by accident the Tauros check works,
; but Kangaskhan will never be correctly checked because of this.
cp HITMONCHAN
jr z, .set_carry
cp HITMONLEE
Expand Down Expand Up @@ -5906,13 +5897,6 @@ AIDecide_PokemonTrader_PowerGenerator:
jr c, .find_duplicates
; bug, missing jr .no_carry

; since this last check falls through regardless of result,
; register a might hold an invalid deck index,
; which might lead to hilarious results like Brandon
; trading a Pikachu with a Grass Energy from the deck.
; however, since it's deep in a tower of conditionals,
; reaching here is extremely unlikely.

; a card in deck was found to look for,
; check if there are duplicates in hand to trade with.
.find_duplicates
Expand Down
2 changes: 1 addition & 1 deletion src/engine/duel/effect_functions.asm
Original file line number Diff line number Diff line change
Expand Up @@ -3368,7 +3368,7 @@ Blizzard_BenchDamageEffect:
call SwapTurn
ret

; return carry if can use Cowardice
; return carry if can't use Cowardice
Cowardice_Check:
ldh a, [hTempPlayAreaLocation_ff9d]
ldh [hTemp_ffa0], a
Expand Down

0 comments on commit 705df56

Please sign in to comment.