diff options
Diffstat (limited to 'src/engine')
32 files changed, 507 insertions, 506 deletions
| diff --git a/src/engine/duel/ai/attacks.asm b/src/engine/duel/ai/attacks.asm index 69ae2e1..604d42e 100644 --- a/src/engine/duel/ai/attacks.asm +++ b/src/engine/duel/ai/attacks.asm @@ -1,6 +1,6 @@  ; have AI choose an attack to use, but do not execute it.  ; return carry if an attack is chosen. -AIProcessButDontUseAttack: ; 169ca (5:69ca) +AIProcessButDontUseAttack:  	ld a, $01  	ld [wAIExecuteProcessedAttack], a @@ -23,7 +23,7 @@ AIProcessButDontUseAttack: ; 169ca (5:69ca)  ; copies wTempPlayAreaAIScore to wPlayAreaAIScore  ; and loads wAIScore with value in wTempAIScore.  ; identical to RetrievePlayAreaAIScoreFromBackup1. -RetrievePlayAreaAIScoreFromBackup2: ; 169e3 (5:69e3) +RetrievePlayAreaAIScoreFromBackup2:  	push af  	ld de, wPlayAreaAIScore  	ld hl, wTempPlayAreaAIScore @@ -42,7 +42,7 @@ RetrievePlayAreaAIScoreFromBackup2: ; 169e3 (5:69e3)  ; have AI choose and execute an attack.  ; return carry if an attack was chosen and attempted. -AIProcessAndTryToUseAttack: ; 169f8 (5:69f8) +AIProcessAndTryToUseAttack:  	xor a  	ld [wAIExecuteProcessedAttack], a  	; fallthrough @@ -51,7 +51,7 @@ AIProcessAndTryToUseAttack: ; 169f8 (5:69f8)  ; If any of the attacks has enough AI score to be used,  ; AI will use it if wAIExecuteProcessedAttack is 0.  ; in either case, return carry if an attack is chosen to be used. -AIProcessAttacks: ; 169fc (5:69fc) +AIProcessAttacks:  ; if AI used Pluspower, load its attack index  	ld a, [wPreviousAIFlags]  	and AI_FLAG_USED_PLUSPOWER @@ -131,7 +131,7 @@ AIProcessAttacks: ; 169fc (5:69fc)  .can_damage  	xor a -	ld [wcdb4], a +	ld [wAIRetreatScore], a  	jr .use_attack  .check_damage_bench @@ -141,7 +141,7 @@ AIProcessAttacks: ; 169fc (5:69fc)  	jr c, .can_damage  ; cannot damage either Defending Pokemon or Bench -	ld hl, wcdb4 +	ld hl, wAIRetreatScore  	inc [hl]  ; return carry if attack is chosen @@ -157,21 +157,20 @@ AIProcessAttacks: ; 169fc (5:69fc)  	ld a, [wAIExecuteProcessedAttack]  	or a  	jr z, .failed_to_use -  ; reset Play Area AI score  ; to the previous values.  	jp RetrievePlayAreaAIScoreFromBackup2  ; return no carry if no viable attack.  .failed_to_use -	ld hl, wcdb4 +	ld hl, wAIRetreatScore  	inc [hl]  	or a  	ret  ; determines the AI score of attack index in a  ; of card in Play Area location hTempPlayAreaLocation_ff9d. -GetAIScoreOfAttack: ; 16a86 (5:6a86) +GetAIScoreOfAttack:  ; initialize AI score.  	ld [wSelectedAttack], a  	ld a, $50 diff --git a/src/engine/duel/ai/boss_deck_set_up.asm b/src/engine/duel/ai/boss_deck_set_up.asm index ebcd2ea..5d0e8c8 100644 --- a/src/engine/duel/ai/boss_deck_set_up.asm +++ b/src/engine/duel/ai/boss_deck_set_up.asm @@ -2,7 +2,7 @@  ; always draws at least 2 Basic Pokemon cards and 2 Energy cards.  ; also sets up so that the next cards to be drawn have  ; some minimum number of Basic Pokemon and Energy cards. -SetUpBossStartingHandAndDeck: ; 172af (5:72af) +SetUpBossStartingHandAndDeck:  ; shuffle all hand cards in deck  	ld a, DUELVARS_HAND  	call GetTurnDuelistVariable @@ -22,8 +22,8 @@ SetUpBossStartingHandAndDeck: ; 172af (5:72af)  ; in the first STARTING_HAND_SIZE in deck.  .count_energy_basic  	xor a -	ld [wce06], a -	ld [wce08], a +	ld [wAISetupBasicPokemonCount], a +	ld [wAISetupEnergyCount], a  	ld a, DUELVARS_DECK_CARDS  	call GetTurnDuelistVariable @@ -40,18 +40,18 @@ SetUpBossStartingHandAndDeck: ; 172af (5:72af)  	jr z, .next_card_deck_1  ; energy card -	ld a, [wce08] +	ld a, [wAISetupEnergyCount]  	inc a -	ld [wce08], a +	ld [wAISetupEnergyCount], a  	jr .next_card_deck_1  .pokemon_card_1  	ld a, [wLoadedCard1Stage]  	or a  	jr nz, .next_card_deck_1 ; not basic -	ld a, [wce06] +	ld a, [wAISetupBasicPokemonCount]  	inc a -	ld [wce06], a +	ld [wAISetupBasicPokemonCount], a  .next_card_deck_1  	dec b @@ -59,10 +59,10 @@ SetUpBossStartingHandAndDeck: ; 172af (5:72af)  ; tally the number of Energy and basic Pokemon cards  ; and if any of them is smaller than 2, re-shuffle deck. -	ld a, [wce06] +	ld a, [wAISetupBasicPokemonCount]  	cp 2  	jr c, .shuffle_deck -	ld a, [wce08] +	ld a, [wAISetupEnergyCount]  	cp 2  	jr c, .shuffle_deck @@ -95,27 +95,27 @@ SetUpBossStartingHandAndDeck: ; 172af (5:72af)  	jr z, .next_card_deck_2  ; energy card -	ld a, [wce08] +	ld a, [wAISetupEnergyCount]  	inc a -	ld [wce08], a +	ld [wAISetupEnergyCount], a  	jr .next_card_deck_2  .pokemon_card_2  	ld a, [wLoadedCard1Stage]  	or a  	jr nz, .next_card_deck_2 -	ld a, [wce06] +	ld a, [wAISetupBasicPokemonCount]  	inc a -	ld [wce06], a +	ld [wAISetupBasicPokemonCount], a  .next_card_deck_2  	dec b  	jr nz, .loop_deck_2 -	ld a, [wce06] +	ld a, [wAISetupBasicPokemonCount]  	cp 4  	jp c, .shuffle_deck -	ld a, [wce08] +	ld a, [wAISetupEnergyCount]  	cp 4  	jp c, .shuffle_deck diff --git a/src/engine/duel/ai/common.asm b/src/engine/duel/ai/common.asm index d4f1da4..7264170 100644 --- a/src/engine/duel/ai/common.asm +++ b/src/engine/duel/ai/common.asm @@ -1,7 +1,7 @@  ; runs through Player's whole deck and  ; sets carry if there's any Pokemon other  ; than Mewtwo1. -CheckIfPlayerHasPokemonOtherThanMewtwo1: ; 227a9 (8:67a9) +CheckIfPlayerHasPokemonOtherThanMewtwo1:  	call SwapTurn  	ld e, 0  .loop_deck diff --git a/src/engine/duel/ai/core.asm b/src/engine/duel/ai/core.asm index 9604322..fb14747 100644 --- a/src/engine/duel/ai/core.asm +++ b/src/engine/duel/ai/core.asm @@ -7,14 +7,14 @@ INCLUDE "engine/duel/ai/decks/unreferenced.asm"  ;	[hTempPlayAreaLocation_ff9d] = location of attacking card to consider  ; output:  ;	[wSelectedAttack] = attack index that KOs -CheckIfAnyAttackKnocksOutDefendingCard: ; 140ae (5:40ae) +CheckIfAnyAttackKnocksOutDefendingCard:  	xor a ; first attack  	call CheckIfAttackKnocksOutDefendingCard  	ret c  	ld a, SECOND_ATTACK  ;	fallthrough -CheckIfAttackKnocksOutDefendingCard: ; 140b5 (5:40b5) +CheckIfAttackKnocksOutDefendingCard:  	call EstimateDamage_VersusDefendingCard  	ld a, DUELVARS_ARENA_CARD_HP  	call GetNonTurnDuelistVariable @@ -29,7 +29,7 @@ CheckIfAttackKnocksOutDefendingCard: ; 140b5 (5:40b5)  ; brings card at hTempPlayAreaLocation_ff9d down  ; to exactly 0 HP.  ; outputs that attack index in wSelectedAttack. -CheckIfAnyDefendingPokemonAttackDealsSameDamageAsHP: ; 140c5 (5:40c5) +CheckIfAnyDefendingPokemonAttackDealsSameDamageAsHP:  	xor a ; FIRST_ATTACK_OR_PKMN_POWER  	call .check_damage  	ret c @@ -51,7 +51,7 @@ CheckIfAnyDefendingPokemonAttackDealsSameDamageAsHP: ; 140c5 (5:40c5)  ; checks AI scores for all benched Pokémon  ; returns the location of the card with highest score  ; in a and [hTempPlayAreaLocation_ff9d] -FindHighestBenchScore: ; 140df (5:40df) +FindHighestBenchScore:  	ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA  	call GetTurnDuelistVariable  	ld b, a @@ -81,7 +81,7 @@ FindHighestBenchScore: ; 140df (5:40df)  ; if there's overflow, it's capped at $ff  ; output:  ;	a = a + wAIScore (capped at $ff) -AddToAIScore: ; 140fe (5:40fe) +AddToAIScore:  	push hl  	ld hl, wAIScore  	add [hl] @@ -94,7 +94,7 @@ AddToAIScore: ; 140fe (5:40fe)  ; subs a from wAIScore  ; if there's underflow, it's capped at $00 -SubFromAIScore: ; 1410a (5:410a) +SubFromAIScore:  	push hl  	push de  	ld e, a @@ -113,7 +113,7 @@ SubFromAIScore: ; 1410a (5:410a)  ; loads defending Pokémon's weakness/resistance  ; and the number of prize cards in both sides -LoadDefendingPokemonColorWRAndPrizeCards: ; 1411d (5:411d) +LoadDefendingPokemonColorWRAndPrizeCards:  	call SwapTurn  	call GetArenaCardColor  	call TranslateColorToWR @@ -132,7 +132,7 @@ LoadDefendingPokemonColorWRAndPrizeCards: ; 1411d (5:411d)  ; called when AI has chosen its attack.  ; executes all effects and damage.  ; handles AI choosing parameters for certain attacks as well. -AITryUseAttack: ; 14145 (5:4145) +AITryUseAttack:  	ld a, [wSelectedAttack]  	ldh [hTemp_ffa0], a  	ld e, a @@ -182,7 +182,7 @@ AITryUseAttack: ; 14145 (5:4145)  ;	a = energy card attached to Pokémon to check  ;	[wTempCardType] = TYPE_ENERGY_* of given Pokémon  ;	[wTempCardID] = card index of Pokémon card to check -CheckIfEnergyIsUseful: ; 14184 (5:4184) +CheckIfEnergyIsUseful:  	push de  	call GetCardIDFromDeckIndex  	ld a, e @@ -242,7 +242,7 @@ CheckIfEnergyIsUseful: ; 14184 (5:4184)  ; pick a random Pokemon in the bench.  ; output:  ;	- a = PLAY_AREA_* of Bench Pokemon picked. -PickRandomBenchPokemon: ; 141da (5:41da) +PickRandomBenchPokemon:  	ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA  	call GetTurnDuelistVariable  	dec a @@ -250,7 +250,7 @@ PickRandomBenchPokemon: ; 141da (5:41da)  	inc a  	ret -AIPickPrizeCards: ; 141e5 (5:41e5) +AIPickPrizeCards:  	ld a, [wNumberPrizeCardsToTake]  	ld b, a  .loop @@ -266,7 +266,7 @@ AIPickPrizeCards: ; 141e5 (5:41e5)  ; picks a prize card at random  ; and adds it to the hand. -.PickPrizeCard: ; 141f8 (5:41f8) +.PickPrizeCard:  	ld a, DUELVARS_PRIZES  	call GetTurnDuelistVariable  	push hl @@ -312,7 +312,7 @@ AIPickPrizeCards: ; 141e5 (5:41e5)  ; routine for AI to play all Basic cards from its hand  ; in the beginning of the Duel. -AIPlayInitialBasicCards: ; 14226 (5:4226) +AIPlayInitialBasicCards:  	call CreateHandCardList  	ld hl, wDuelTempList  .check_for_next_card @@ -341,7 +341,7 @@ AIPlayInitialBasicCards: ; 14226 (5:4226)  ; input:  ;	[hTempPlayAreaLocation_ff9d] = location of Pokémon card  ;	[wSelectedAttack]         = selected attack to examine -CheckIfSelectedAttackIsUnusable: ; 1424b (5:424b) +CheckIfSelectedAttackIsUnusable:  	ldh a, [hTempPlayAreaLocation_ff9d]  	or a  	jr nz, .bench @@ -382,7 +382,7 @@ CheckIfSelectedAttackIsUnusable: ; 1424b (5:424b)  ;	carry set if no attack  ;	       OR if it's a Pokémon Power  ;	       OR if not enough energy for attack -CheckEnergyNeededForAttack: ; 14279 (5:4279) +CheckEnergyNeededForAttack:  	ldh a, [hTempPlayAreaLocation_ff9d]  	add DUELVARS_ARENA_CARD  	call GetTurnDuelistVariable @@ -484,7 +484,7 @@ CheckEnergyNeededForAttack: ; 14279 (5:4279)  ;	[hl] = attached energy  ; output:  ;	carry set if not enough of this energy type attached -CheckIfEnoughParticularAttachedEnergy: ; 142f4 (5:42f4) +CheckIfEnoughParticularAttachedEnergy:  	and %00001111  	jr nz, .check  .has_enough @@ -512,7 +512,7 @@ CheckIfEnoughParticularAttachedEnergy: ; 142f4 (5:42f4)  ;	a = energy type  ; output:  ;	a = energy card ID -ConvertColorToEnergyCardID: ; 1430f (5:430f) +ConvertColorToEnergyCardID:  	push hl  	push de  	ld e, a @@ -536,7 +536,7 @@ ConvertColorToEnergyCardID: ; 1430f (5:430f)  ; returns carry if loaded attack effect has  ; an "initial effect 2" or "require selection" command type  ; unreferenced -Func_14323: ; 14323 (5:4323) +Func_14323:  	ld hl, wLoadedAttackEffectCommands  	ld a, [hli]  	ld h, [hl] @@ -563,7 +563,7 @@ Func_14323: ; 14323 (5:4323)  ;	- if trainer card, return carry if it can be used  ; input:  ;	a = card index to check -CheckIfCardCanBePlayed: ; 1433d (5:433d) +CheckIfCardCanBePlayed:  	ldh [hTempCardIndex_ff9f], a  	call LoadCardDataToBuffer1_FromDeckIndex  	ld a, [wLoadedCard1Type] @@ -621,7 +621,7 @@ CheckIfCardCanBePlayed: ; 1433d (5:433d)  ; loads all the energy cards  ; in hand in wDuelTempList  ; return carry if no energy cards found -CreateEnergyCardListFromHand: ; 1438c (5:438c) +CreateEnergyCardListFromHand:  	push hl  	push de  	push bc @@ -670,7 +670,7 @@ CreateEnergyCardListFromHand: ; 1438c (5:438c)  ; output:  ;	a = card deck index, if found  ;	carry set if NOT found -LookForCardIDInHand: ; 143bf (5:43bf) +LookForCardIDInHand:  	push hl  	push de  	push bc @@ -709,7 +709,7 @@ LookForCardIDInHand: ; 143bf (5:43bf)  INCLUDE "engine/duel/ai/damage_calculation.asm" -AIProcessHandTrainerCards: ; 14663 (5:4663) +AIProcessHandTrainerCards:  	farcall _AIProcessHandTrainerCards  	ret @@ -724,7 +724,7 @@ INCLUDE "engine/duel/ai/deck_ai.asm"  ; output:  ;	a = card deck index, if found  ;	carry set if found -LookForCardIDInHandList_Bank5: ; 155d2 (5:55d2) +LookForCardIDInHandList_Bank5:  	ld [wTempCardIDToLook], a  	call CreateHandCardList  	ld hl, wDuelTempList @@ -753,7 +753,7 @@ LookForCardIDInHandList_Bank5: ; 155d2 (5:55d2)  ; output:  ;	a = PLAY_AREA_* of found card  ;	carry set if found -LookForCardIDInPlayArea_Bank5: ; 155ef (5:55ef) +LookForCardIDInPlayArea_Bank5:  	ld [wTempCardIDToLook], a  .loop @@ -785,7 +785,7 @@ LookForCardIDInPlayArea_Bank5: ; 155ef (5:55ef)  ; input:  ;	e = Energy card ID  ;	d = Pokemon card ID -AIAttachEnergyInHandToCardInPlayArea: ; 15612 (5:5612) +AIAttachEnergyInHandToCardInPlayArea:  	ld a, e  	push de  	call LookForCardIDInHandList_Bank5 @@ -806,7 +806,7 @@ AIAttachEnergyInHandToCardInPlayArea: ; 15612 (5:5612)  ; same as AIAttachEnergyInHandToCardInPlayArea but  ; only look for card ID in the Bench. -AIAttachEnergyInHandToCardInBench: ; 1562b (5:562b) +AIAttachEnergyInHandToCardInBench:  	ld a, e  	push de  	call LookForCardIDInHandList_Bank5 @@ -831,7 +831,7 @@ INCLUDE "engine/duel/ai/init.asm"  ;	carry set if no attack  ;	       OR if it's a Pokémon Power  ;	       OR if not enough energy for attack -CheckEnergyNeededForAttackAfterDiscard: ; 156c3 (5:56c3) +CheckEnergyNeededForAttackAfterDiscard:  	ldh a, [hTempPlayAreaLocation_ff9d]  	add DUELVARS_ARENA_CARD  	call GetTurnDuelistVariable @@ -934,7 +934,7 @@ CheckEnergyNeededForAttackAfterDiscard: ; 156c3 (5:56c3)  	ret  ; zeroes a bytes starting at hl -ClearMemory_Bank5: ; 1575e (5:575e) +ClearMemory_Bank5:  	push af  	push bc  	push hl @@ -950,7 +950,7 @@ ClearMemory_Bank5: ; 1575e (5:575e)  	ret  ; returns in a the tens digit of value in a -CalculateByteTensDigit: ; 1576b (5:576b) +CalculateByteTensDigit:  	push bc  	ld c, 0  .loop @@ -968,7 +968,7 @@ CalculateByteTensDigit: ; 1576b (5:576b)  ; input:  ;	a = divisor  ;	b = dividend -CalculateBDividedByA_Bank5: ; 15778 (5:5778) +CalculateBDividedByA_Bank5:  	push bc  	ld c, a  	ld a, b @@ -992,7 +992,7 @@ CalculateBDividedByA_Bank5: ; 15778 (5:5778)  ;	e = location to check, i.e. PLAY_AREA_*  ; output:  ;	a = number of energy cards attached -CountNumberOfEnergyCardsAttached: ; 15787 (5:5787) +CountNumberOfEnergyCardsAttached:  	call GetPlayAreaCardAttachedEnergies  	ld a, [wTotalAttachedEnergies]  	or a @@ -1025,7 +1025,7 @@ CountNumberOfEnergyCardsAttached: ; 15787 (5:5787)  ;	e = card ID to look for.  ; output:  ;	a = deck index of card found, if any -CheckIfAnyCardIDinLocation: ; 157a3 (5:57a3) +CheckIfAnyCardIDinLocation:  	ld b, a  	ld c, e  	lb de, 0, 0 @@ -1058,7 +1058,7 @@ CheckIfAnyCardIDinLocation: ; 157a3 (5:57a3)  ; plus all the cards attached in Turn Duelist's Play Area.  ; output:  ;	a and wTempAI = total number of energy cards. -CountOppEnergyCardsInHandAndAttached: ; 157c6 (5:57c6) +CountOppEnergyCardsInHandAndAttached:  	xor a  	ld [wTempAI], a  	call CreateEnergyCardListFromHand @@ -1098,7 +1098,7 @@ CountOppEnergyCardsInHandAndAttached: ; 157c6 (5:57c6)  ; input:  ;   e  = card ID to look for.  ;   hl = list to look in -RemoveCardIDInList: ; 157f3 (5:57f3) +RemoveCardIDInList:  	push hl  	push de  	push bc @@ -1149,7 +1149,7 @@ RemoveCardIDInList: ; 157f3 (5:57f3)  ; one list is for the Arena card is the other is for the Bench cards.  ; 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) +TrySetUpBossStartingPlayArea:  	ld de, wAICardListArenaPriority  	ld a, d  	or a @@ -1222,7 +1222,7 @@ TrySetUpBossStartingPlayArea: ; 1581b (5:581b)  ; returns carry if a card ID is found in bench with at least the  ; listed number of energy cards  ; unreferenced -Func_1585b: ; 1585b (5:585b) +Func_1585b:  	ld a, [hli]  	or a  	jr z, .no_carry @@ -1271,7 +1271,7 @@ Func_1585b: ; 1585b (5:585b)  ; with less than the number of energy cards corresponding to its entry  ; then have AI try to play an energy card from the hand to it  ; unreferenced -Func_15886: ; 15886 (5:5886) +Func_15886:  	push hl  	call CreateEnergyCardListFromHand  	pop hl @@ -1309,7 +1309,7 @@ Func_15886: ; 15886 (5:5886)  INCLUDE "engine/duel/ai/retreat.asm"  ; Copy cards from wDuelTempList in hl to wHandTempList in de -CopyHandCardList: ; 15ea6 (5:5ea6) +CopyHandCardList:  	ld a, [hli]  	ld [de], a  	cp $ff @@ -1325,7 +1325,7 @@ INCLUDE "engine/duel/ai/hand_pokemon.asm"  ; can damage it, and if it can, set carry  ; input:  ;	a = location of Pokémon card -CheckDamageToMrMime: ; 16270 (5:6270) +CheckDamageToMrMime:  	push af  	ld a, DUELVARS_ARENA_CARD  	call GetNonTurnDuelistVariable @@ -1347,7 +1347,7 @@ CheckDamageToMrMime: ; 16270 (5:6270)  ; returns carry if arena card  ; can knock out defending Pokémon -CheckIfActiveCardCanKnockOut: ; 1628f (5:628f) +CheckIfActiveCardCanKnockOut:  	xor a  	ldh [hTempPlayAreaLocation_ff9d], a  	call CheckIfAnyAttackKnocksOutDefendingCard @@ -1363,7 +1363,7 @@ CheckIfActiveCardCanKnockOut: ; 1628f (5:628f)  ; outputs carry if any of the active Pokémon attacks  ; can be used and are not residual -CheckIfActivePokemonCanUseAnyNonResidualAttack: ; 162a1 (5:62a1) +CheckIfActivePokemonCanUseAnyNonResidualAttack:  	xor a ; active card  	ldh [hTempPlayAreaLocation_ff9d], a  ; first atk @@ -1400,7 +1400,7 @@ CheckIfActivePokemonCanUseAnyNonResidualAttack: ; 162a1 (5:62a1)  ; return carry if successful in finding card  ; input:  ;	[hTempPlayAreaLocation_ff9d] = location of Pokémon card -LookForEnergyNeededInHand: ; 162c8 (5:62c8) +LookForEnergyNeededInHand:  	xor a ; first attack  	ld [wSelectedAttack], a  	call CheckEnergyNeededForAttack @@ -1462,7 +1462,7 @@ LookForEnergyNeededInHand: ; 162c8 (5:62c8)  ; input:  ;	[hTempPlayAreaLocation_ff9d] = location of Pokémon card  ;	[wSelectedAttack]         = selected attack to examine -LookForEnergyNeededForAttackInHand: ; 16311 (5:6311) +LookForEnergyNeededForAttackInHand:  	call CheckEnergyNeededForAttack  	ld a, b  	add c @@ -1502,7 +1502,7 @@ LookForEnergyNeededForAttackInHand: ; 16311 (5:6311)  ; 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) +SortTempHandByIDList:  	ld a, [wAICardListPlayFromHandPriority+1]  	or a  	ret z ; return if list is empty @@ -1563,7 +1563,7 @@ SortTempHandByIDList: ; 1633f (5:633f)  ; return carry if successful in finding card  ; input:  ;	a = energy flags needed -CheckEnergyFlagsNeededInList: ; 1637b (5:637b) +CheckEnergyFlagsNeededInList:  	ld e, a  	ld hl, wDuelTempList  .next_card @@ -1630,7 +1630,7 @@ CheckEnergyFlagsNeededInList: ; 1637b (5:637b)  ;	a = card index  ; output:  ;	a = bits of each energy requirement -GetAttacksEnergyCostBits: ; 163c9 (5:63c9) +GetAttacksEnergyCostBits:  	call LoadCardDataToBuffer2_FromDeckIndex  	ld hl, wLoadedCard2Atk1EnergyCost  	call GetEnergyCostBits @@ -1651,7 +1651,7 @@ GetAttacksEnergyCostBits: ; 163c9 (5:63c9)  ;	[hl] = Loaded card attack energy cost  ; output:  ;	a = bits of each energy requirement -GetEnergyCostBits: ; 163dd (5:63dd) +GetEnergyCostBits:  	ld c, $00  	ld a, [hli]  	ld b, a @@ -1716,7 +1716,7 @@ GetEnergyCostBits: ; 163dd (5:63dd)  ;	a = card index to check evolution  ; output:  ;	a = card index of evolution found -CheckForEvolutionInList: ; 16422 (5:6422) +CheckForEvolutionInList:  	ld b, a  	ld a, DUELVARS_ARENA_CARD  	call GetTurnDuelistVariable @@ -1760,7 +1760,7 @@ CheckForEvolutionInList: ; 16422 (5:6422)  ;	a = card index to check evolution  ; output:  ;	a = card index of evolution found -CheckForEvolutionInDeck: ; 16451 (5:6451) +CheckForEvolutionInDeck:  	ld b, a  	ld a, DUELVARS_ARENA_CARD  	call GetTurnDuelistVariable @@ -1818,7 +1818,7 @@ INCLUDE "engine/duel/ai/special_attacks.asm"  ; output:  ;	a = card location of Pokémon card, if found;  ;	carry set if such a card is found. -LookForCardThatIsKnockedOutOnDevolution: ; 17080 (5:7080) +LookForCardThatIsKnockedOutOnDevolution:  	ldh a, [hTempPlayAreaLocation_ff9d]  	push af  	call SwapTurn @@ -1876,7 +1876,7 @@ LookForCardThatIsKnockedOutOnDevolution: ; 17080 (5:7080)  ;	- arena card Unknown2's 4 bit is not set or  ;	  is set but there's no evolution of card in hand/deck  ;	- arena card can use second attack -CheckIfArenaCardIsAtHalfHPCanEvolveAndUseSecondAttack: ; 170c9 (5:70c9) +CheckIfArenaCardIsAtHalfHPCanEvolveAndUseSecondAttack:  	ld a, DUELVARS_ARENA_CARD  	call GetTurnDuelistVariable  	ld d, a @@ -1922,7 +1922,7 @@ CheckIfArenaCardIsAtHalfHPCanEvolveAndUseSecondAttack: ; 170c9 (5:70c9)  ; Outputs the number of Pokémon in bench  ; that meet these requirements in a  ; and returns carry if at least one is found -CountNumberOfSetUpBenchPokemon: ; 17101 (5:7101) +CountNumberOfSetUpBenchPokemon:  	ldh a, [hTempPlayAreaLocation_ff9d]  	ld d, a  	ld a, [wSelectedAttack] @@ -2004,7 +2004,7 @@ CountNumberOfSetUpBenchPokemon: ; 17101 (5:7101)  ; returns carry if selection was successful,  ; and no carry if unable to make one.  ; outputs in hTempPlayAreaLocation_ffa1 the chosen parameter. -AISelectSpecialAttackParameters: ; 17161 (5:7161) +AISelectSpecialAttackParameters:  	ld a, [wSelectedAttack]  	push af  	call .SelectAttackParameters @@ -2013,7 +2013,7 @@ AISelectSpecialAttackParameters: ; 17161 (5:7161)  	ld [wSelectedAttack], a  	ret -.SelectAttackParameters: ; 1716e (5:716e) +.SelectAttackParameters:  	ld a, DUELVARS_ARENA_CARD  	call GetTurnDuelistVariable  	call GetCardIDFromDeckIndex @@ -2139,7 +2139,7 @@ AISelectSpecialAttackParameters: ; 17161 (5:7161)  ;	[wSelectedAttack]         = attack index to check  ; output:  ;	a = number of extra energy cards attached -CheckIfNoSurplusEnergyForAttack: ; 171fb (5:71fb) +CheckIfNoSurplusEnergyForAttack:  	ldh a, [hTempPlayAreaLocation_ff9d]  	add DUELVARS_ARENA_CARD  	call GetTurnDuelistVariable @@ -2211,7 +2211,7 @@ CheckIfNoSurplusEnergyForAttack: ; 171fb (5:71fb)  ;	[hl] = attached energy  ; output:  ;	carry set if not enough of this energy type attached -CalculateParticularAttachedEnergyNeeded: ; 17258 (5:7258) +CalculateParticularAttachedEnergyNeeded:  	and %00001111  	jr nz, .check  .done @@ -2240,7 +2240,7 @@ CalculateParticularAttachedEnergyNeeded: ; 17258 (5:7258)  ; output:  ;	a = deck index of evolution in hand, if found;  ;	carry set if there's a card in hand that can evolve. -CheckCardEvolutionInHandOrDeck: ; 17274 (5:7274) +CheckCardEvolutionInHandOrDeck:  	ld b, a  	ld a, DUELVARS_ARENA_CARD  	call GetTurnDuelistVariable @@ -2291,7 +2291,7 @@ INCLUDE "engine/duel/ai/boss_deck_set_up.asm"  ; can damage defending Pokémon with any of its attacks  ; input:  ;	a = location of card to check -CheckIfCanDamageDefendingPokemon: ; 17383 (5:7383) +CheckIfCanDamageDefendingPokemon:  	ldh [hTempPlayAreaLocation_ff9d], a  	xor a ; first attack  	ld [wSelectedAttack], a @@ -2323,7 +2323,7 @@ CheckIfCanDamageDefendingPokemon: ; 17383 (5:7383)  ; checks if defending Pokémon can knock out  ; card at hTempPlayAreaLocation_ff9d with any of its attacks -; and if so, stores the damage to wce00 and wce01 +; and if so, stores the damage to wAIFirstAttackDamage and wAISecondAttackDamage  ; sets carry if any on the attacks knocks out  ; also outputs the largest damage dealt in a  ; input: @@ -2331,34 +2331,35 @@ CheckIfCanDamageDefendingPokemon: ; 17383 (5:7383)  ; output:  ;	a = largest damage of both attacks  ;	carry set if can knock out -CheckIfDefendingPokemonCanKnockOut: ; 173b1 (5:73b1) -	xor a ; first attack -	ld [wce00], a -	ld [wce01], a +CheckIfDefendingPokemonCanKnockOut: +	xor a +	ld [wAIFirstAttackDamage], a +	ld [wAISecondAttackDamage], a + +	; first attack  	call CheckIfDefendingPokemonCanKnockOutWithAttack  	jr nc, .second_attack  	ld a, [wDamage] -	ld [wce00], a - +	ld [wAIFirstAttackDamage], a  .second_attack  	ld a, SECOND_ATTACK  	call CheckIfDefendingPokemonCanKnockOutWithAttack  	jr nc, .return_if_neither_kos  	ld a, [wDamage] -	ld [wce01], a +	ld [wAISecondAttackDamage], a  	jr .compare  .return_if_neither_kos -	ld a, [wce00] +	ld a, [wAIFirstAttackDamage]  	or a  	ret z  .compare -	ld a, [wce00] +	ld a, [wAIFirstAttackDamage]  	ld b, a -	ld a, [wce01] +	ld a, [wAISecondAttackDamage]  	cp b -	jr nc, .set_carry +	jr nc, .set_carry ; wAIFirstAttackDamage < wAISecondAttackDamage  	ld a, b  .set_carry  	scf @@ -2369,7 +2370,7 @@ CheckIfDefendingPokemonCanKnockOut: ; 173b1 (5:73b1)  ; input:  ;	a = attack index  ;	[hTempPlayAreaLocation_ff9d] = location of card to check -CheckIfDefendingPokemonCanKnockOutWithAttack: ; 173e4 (5:73e4) +CheckIfDefendingPokemonCanKnockOutWithAttack:  	ld [wSelectedAttack], a  	ldh a, [hTempPlayAreaLocation_ff9d]  	push af @@ -2406,7 +2407,7 @@ CheckIfDefendingPokemonCanKnockOutWithAttack: ; 173e4 (5:73e4)  ; is between LEGENDARY_MOLTRES_DECK_ID (inclusive)  ; and MUSCLES_FOR_BRAINS_DECK_ID (exclusive)  ; these are the decks for Grandmaster/Club Master/Ronald -CheckIfOpponentHasBossDeckID: ; 17414 (5:7414) +CheckIfOpponentHasBossDeckID:  	push af  	ld a, [wOpponentDeckID]  	cp LEGENDARY_MOLTRES_DECK_ID @@ -2424,7 +2425,7 @@ CheckIfOpponentHasBossDeckID: ; 17414 (5:7414)  ; sets carry if not a boss fight  ; and if hasn't received legendary cards yet -CheckIfNotABossDeckID: ; 17426 (5:7426) +CheckIfNotABossDeckID:  	call EnableSRAM  	ld a, [sReceivedLegendaryCards]  	call DisableSRAM @@ -2446,7 +2447,7 @@ CheckIfNotABossDeckID: ; 17426 (5:7426)  ; - 0% for boss decks.  ; used for certain decks to randomly choose  ; not to play Trainer card or use PKMN Power -AIChooseRandomlyNotToDoAction: ; 1743b (5:743b) +AIChooseRandomlyNotToDoAction:  ; boss decks always use Trainer cards.  	push hl  	push de @@ -2494,7 +2495,7 @@ AIChooseRandomlyNotToDoAction: ; 1743b (5:743b)  ;	a = card ID to check for  ; output:  ;	carry set if the above requirements are met -CheckForBenchIDAtHalfHPAndCanUseSecondAttack: ; 17474 (5:7474) +CheckForBenchIDAtHalfHPAndCanUseSecondAttack:  	ld [wcdf9], a  	ldh a, [hTempPlayAreaLocation_ff9d]  	ld d, a @@ -2559,7 +2560,7 @@ CheckForBenchIDAtHalfHPAndCanUseSecondAttack: ; 17474 (5:7474)  ; in bench that have same ID as register a  ; input:  ;	a = card ID to look for -RaiseAIScoreToAllMatchingIDsInBench: ; 174cd (5:74cd) +RaiseAIScoreToAllMatchingIDsInBench:  	ld d, a  	ld a, DUELVARS_BENCH  	call GetTurnDuelistVariable @@ -2591,7 +2592,7 @@ RaiseAIScoreToAllMatchingIDsInBench: ; 174cd (5:74cd)  ; card has highest value calculated from Func_17583  ; the card with highest value gets increased wPlayAreaEnergyAIScore  ; while all others get decreased wPlayAreaEnergyAIScore -Func_174f2: ; 174f2 (5:74f2) +Func_174f2:  	ld a, MAX_PLAY_AREA_POKEMON  	ld hl, wcdfa  	call ClearMemory_Bank5 @@ -2713,7 +2714,7 @@ Func_174f2: ; 174f2 (5:74f2)  ; with energy  * 2 + $80 - floor(dam / 10)  ; loads wcdfa + play area location in e  ; with $01 -Func_17583: ; 17583 (5:7583) +Func_17583:  	push hl  	push de  	call GetCardDamageAndMaxHP @@ -2741,7 +2742,7 @@ Func_17583: ; 17583 (5:7583)  ; counts how many play area locations in wcdea  ; are != 0, and outputs result in a  ; also returns carry if result is < 2 -Func_175a8: ; 175a8 (5:75a8) +Func_175a8:  	ld hl, wcdea  	ld d, $00  	ld e, MAX_PLAY_AREA_POKEMON + 1 @@ -2760,7 +2761,7 @@ Func_175a8: ; 175a8 (5:75a8)  ; handle how AI scores giving out Energy Cards  ; when using Legendary Articuno deck -HandleLegendaryArticunoEnergyScoring: ; 175bd (5:75bd) +HandleLegendaryArticunoEnergyScoring:  	ld a, [wOpponentDeckID]  	cp LEGENDARY_ARTICUNO_DECK_ID  	jr z, .articuno_deck diff --git a/src/engine/duel/ai/damage_calculation.asm b/src/engine/duel/ai/damage_calculation.asm index 97c24b6..9660c9d 100644 --- a/src/engine/duel/ai/damage_calculation.asm +++ b/src/engine/duel/ai/damage_calculation.asm @@ -3,7 +3,7 @@  ; input:  ;	a = attack index to take into account  ;	[hTempPlayAreaLocation_ff9d] = location of attacking card to consider -EstimateDamage_VersusDefendingCard: ; 143e5 (5:43e5) +EstimateDamage_VersusDefendingCard:  	ld [wSelectedAttack], a  	ld e, a  	ldh a, [hTempPlayAreaLocation_ff9d] diff --git a/src/engine/duel/ai/decks/fire_charge.asm b/src/engine/duel/ai/decks/fire_charge.asm index f5b347b..ff8d11e 100644 --- a/src/engine/duel/ai/decks/fire_charge.asm +++ b/src/engine/duel/ai/decks/fire_charge.asm @@ -1,4 +1,4 @@ -AIActionTable_FireCharge: ; 15232 (5:5232) +AIActionTable_FireCharge:  	dw .do_turn ; unused  	dw .do_turn  	dw .start_duel @@ -6,11 +6,11 @@ AIActionTable_FireCharge: ; 15232 (5:5232)  	dw .ko_switch  	dw .take_prize -.do_turn ; 1523e (5:523e) +.do_turn  	call AIMainTurnLogic  	ret -.start_duel ; 15242 (5:5242) +.start_duel  	call InitAIDuelVars  	call .store_list_pointers  	call SetUpBossStartingHandAndDeck @@ -19,19 +19,19 @@ AIActionTable_FireCharge: ; 15232 (5:5232)  	call AIPlayInitialBasicCards  	ret -.forced_switch ; 15253 (5:5253) +.forced_switch  	call AIDecideBenchPokemonToSwitchTo  	ret -.ko_switch ; 15257 (5:5257) +.ko_switch  	call AIDecideBenchPokemonToSwitchTo  	ret -.take_prize ; 1525b (5:525b) +.take_prize  	call AIPickPrizeCards  	ret -.list_arena ; 1525f (5:525f) +.list_arena  	db JIGGLYPUFF3  	db CHANSEY  	db TAUROS @@ -40,7 +40,7 @@ AIActionTable_FireCharge: ; 15232 (5:5232)  	db GROWLITHE  	db $00 -.list_bench ; 15266 (5:5266) +.list_bench  	db JIGGLYPUFF3  	db CHANSEY  	db GROWLITHE @@ -49,13 +49,13 @@ AIActionTable_FireCharge: ; 15232 (5:5232)  	db TAUROS  	db $00 -.list_retreat ; 1526e (5:526e) +.list_retreat  	ai_retreat JIGGLYPUFF1, -1  	ai_retreat CHANSEY,     -1  	ai_retreat GROWLITHE,   -1  	db $00 -.list_energy ; 15274 (5:5274) +.list_energy  	ai_energy GROWLITHE,   3, +0  	ai_energy ARCANINE2,   4, +0  	ai_energy MAGMAR1,     3, +0 @@ -66,11 +66,11 @@ AIActionTable_FireCharge: ; 15232 (5:5232)  	ai_energy TAUROS,      3, +0  	db $00 -.list_prize ; 1528d (5:528d) +.list_prize  	db GAMBLER  	db $00 -.store_list_pointers ; 1528f (5:528f) +.store_list_pointers  	store_list_pointer wAICardListAvoidPrize, .list_prize  	store_list_pointer wAICardListArenaPriority, .list_arena  	store_list_pointer wAICardListBenchPriority, .list_bench diff --git a/src/engine/duel/ai/decks/first_strike.asm b/src/engine/duel/ai/decks/first_strike.asm index 2e636e1..6d5d7c5 100644 --- a/src/engine/duel/ai/decks/first_strike.asm +++ b/src/engine/duel/ai/decks/first_strike.asm @@ -1,4 +1,4 @@ -AIActionTable_FirstStrike: ; 14e89 (5:4e89) +AIActionTable_FirstStrike:  	dw .do_turn ; unused  	dw .do_turn  	dw .start_duel @@ -6,11 +6,11 @@ AIActionTable_FirstStrike: ; 14e89 (5:4e89)  	dw .ko_switch  	dw .take_prize -.do_turn ; 14e95 (5:4e95) +.do_turn  	call AIMainTurnLogic  	ret -.start_duel ; 14e99 (5:4e99) +.start_duel  	call InitAIDuelVars  	call .store_list_pointers  	call SetUpBossStartingHandAndDeck @@ -19,39 +19,39 @@ AIActionTable_FirstStrike: ; 14e89 (5:4e89)  	call AIPlayInitialBasicCards  	ret -.forced_switch ; 14eaa (5:4eaa) +.forced_switch  	call AIDecideBenchPokemonToSwitchTo  	ret -.ko_switch ; 14eae (5:4eae) +.ko_switch  	call AIDecideBenchPokemonToSwitchTo  	ret -.take_prize ; 14eb2 (5:4eb2) +.take_prize  	call AIPickPrizeCards  	ret -.list_arena ; 14eb6 (5:1eb6) +.list_arena  	db HITMONCHAN  	db MACHOP  	db HITMONLEE  	db MANKEY  	db $00 -.list_bench ; 14ebb (5:1ebb) +.list_bench  	db MACHOP  	db HITMONLEE  	db HITMONCHAN  	db MANKEY  	db $00 -.list_retreat ; 14ec0 (5:1ec0) +.list_retreat  	ai_retreat MACHOP,  -1  	ai_retreat MACHOKE, -1  	ai_retreat MANKEY,  -2  	db $00 -.list_energy ; 14ec7 (5:1ec7) +.list_energy  	ai_energy MACHOP,     3, +0  	ai_energy MACHOKE,    4, +0  	ai_energy MACHAMP,    4, -1 @@ -61,12 +61,12 @@ AIActionTable_FirstStrike: ; 14e89 (5:4e89)  	ai_energy PRIMEAPE,   3, -1  	db $00 -.list_prize ; 14edd (5:1edd) +.list_prize  	db HITMONLEE  	db HITMONCHAN  	db $00 -.store_list_pointers ; 14ee0 (5:4ee0) +.store_list_pointers  	store_list_pointer wAICardListAvoidPrize, .list_prize  	store_list_pointer wAICardListArenaPriority, .list_arena  	store_list_pointer wAICardListBenchPriority, .list_bench diff --git a/src/engine/duel/ai/decks/flower_power.asm b/src/engine/duel/ai/decks/flower_power.asm index 4d423a3..f513c2e 100644 --- a/src/engine/duel/ai/decks/flower_power.asm +++ b/src/engine/duel/ai/decks/flower_power.asm @@ -1,4 +1,4 @@ -AIActionTable_FlowerPower: ; 1509b (5:509b) +AIActionTable_FlowerPower:  	dw .do_turn ; unused  	dw .do_turn  	dw .start_duel @@ -6,11 +6,11 @@ AIActionTable_FlowerPower: ; 1509b (5:509b)  	dw .ko_switch  	dw .take_prize -.do_turn ; 150a7 (5:50a7) +.do_turn  	call AIMainTurnLogic  	ret -.start_duel ; 150ab (5:50ab) +.start_duel  	call InitAIDuelVars  	call .store_list_pointers  	call SetUpBossStartingHandAndDeck @@ -19,38 +19,38 @@ AIActionTable_FlowerPower: ; 1509b (5:509b)  	call AIPlayInitialBasicCards  	ret -.forced_switch ; 150bc (5:50bc) +.forced_switch  	call AIDecideBenchPokemonToSwitchTo  	ret -.ko_switch ; 150c0 (5:50c0) +.ko_switch  	call AIDecideBenchPokemonToSwitchTo  	ret -.take_prize ; 150c4 (5:50c4) +.take_prize  	call AIPickPrizeCards  	ret -.list_arena ; 150c8 (5:50c8) +.list_arena  	db ODDISH  	db EXEGGCUTE  	db BULBASAUR  	db $00 -.list_bench ; 150cc (5:50cc) +.list_bench  	db BULBASAUR  	db EXEGGCUTE  	db ODDISH  	db $00 -.list_retreat ; 150cf (5:50cf) +.list_retreat  	ai_retreat GLOOM,     -2  	ai_retreat VILEPLUME, -2  	ai_retreat BULBASAUR, -2  	ai_retreat IVYSAUR,   -2  	db $00 -.list_energy ; 150d9 (5:50d9) +.list_energy  	ai_energy BULBASAUR,  3, +0  	ai_energy IVYSAUR,    4, +0  	ai_energy VENUSAUR2,  4, +0 @@ -61,11 +61,11 @@ AIActionTable_FlowerPower: ; 1509b (5:509b)  	ai_energy EXEGGUTOR, 22, +0  	db $00 -.list_prize ; 150f2 (5:50f2) +.list_prize  	db VENUSAUR2  	db $00 -.store_list_pointers ; 150f4 (5:50f4) +.store_list_pointers  	store_list_pointer wAICardListAvoidPrize, .list_prize  	store_list_pointer wAICardListArenaPriority, .list_arena  	store_list_pointer wAICardListBenchPriority, .list_bench diff --git a/src/engine/duel/ai/decks/general.asm b/src/engine/duel/ai/decks/general.asm index 039e101..eed4cdc 100644 --- a/src/engine/duel/ai/decks/general.asm +++ b/src/engine/duel/ai/decks/general.asm @@ -1,5 +1,5 @@  ; AI logic used by general decks -AIActionTable_GeneralDecks: ; 14668 (05:4668) +AIActionTable_GeneralDecks:  	dw .do_turn ; unused  	dw .do_turn  	dw .start_duel @@ -7,29 +7,29 @@ AIActionTable_GeneralDecks: ; 14668 (05:4668)  	dw .ko_switch  	dw .take_prize -.do_turn ; 14674 (5:4674) +.do_turn  	call AIMainTurnLogic  	ret -.start_duel ; 14678 (5:4678) +.start_duel  	call InitAIDuelVars  	call AIPlayInitialBasicCards  	ret -.forced_switch ; 1467f (5:467f) +.forced_switch  	call AIDecideBenchPokemonToSwitchTo  	ret -.ko_switch ; 14683 (5:4683) +.ko_switch  	call AIDecideBenchPokemonToSwitchTo  	ret -.take_prize: ; 14687 (5:4687) +.take_prize:  	call AIPickPrizeCards  	ret  ; handle AI routines for a whole turn -AIMainTurnLogic: ; 1468b (5:468b) +AIMainTurnLogic:  ; initialize variables  	call InitAITurnVars  	ld a, AI_TRAINER_CARD_PHASE_01 @@ -147,7 +147,7 @@ AIMainTurnLogic: ; 1468b (5:468b)  	ret  ; handles AI retreating logic -AIProcessRetreat: ; 14786 (5:4786) +AIProcessRetreat:  	ld a, [wAIRetreatedThisTurn]  	or a  	ret nz ; return, already retreated this turn diff --git a/src/engine/duel/ai/decks/general_no_retreat.asm b/src/engine/duel/ai/decks/general_no_retreat.asm index 20d84e3..a6e5cb3 100644 --- a/src/engine/duel/ai/decks/general_no_retreat.asm +++ b/src/engine/duel/ai/decks/general_no_retreat.asm @@ -1,5 +1,5 @@  ; acts just like a general deck AI except never retreats -AIActionTable_GeneralNoRetreat: ; 148dc (5:48dc) +AIActionTable_GeneralNoRetreat:  	dw .do_turn ; unused  	dw .do_turn  	dw .start_duel @@ -7,28 +7,28 @@ AIActionTable_GeneralNoRetreat: ; 148dc (5:48dc)  	dw .ko_switch  	dw .take_prize -.do_turn ; 148e8 (5:48e8) +.do_turn  	call AIDoTurn_GeneralNoRetreat  	ret -.start_duel ; 148ec (5:48ec) +.start_duel  	call InitAIDuelVars  	call AIPlayInitialBasicCards  	ret -.forced_switch ; 148f3 (5:48f3) +.forced_switch  	call AIDecideBenchPokemonToSwitchTo  	ret -.ko_switch ; 148f7 (5:48f7) +.ko_switch  	call AIDecideBenchPokemonToSwitchTo  	ret -.take_prize ; 148fb (5:48fb) +.take_prize  	call AIPickPrizeCards  	ret -AIDoTurn_GeneralNoRetreat: ; 148ff (5:48ff) +AIDoTurn_GeneralNoRetreat:  ; initialize variables  	call InitAITurnVars  	ld a, AI_TRAINER_CARD_PHASE_01 diff --git a/src/engine/duel/ai/decks/go_go_rain_dance.asm b/src/engine/duel/ai/decks/go_go_rain_dance.asm index 23547e2..ba0c5c5 100644 --- a/src/engine/duel/ai/decks/go_go_rain_dance.asm +++ b/src/engine/duel/ai/decks/go_go_rain_dance.asm @@ -1,4 +1,4 @@ -AIActionTable_GoGoRainDance: ; 14f8f (5:4f8f) +AIActionTable_GoGoRainDance:  	dw .do_turn ; unused  	dw .do_turn  	dw .start_duel @@ -6,11 +6,11 @@ AIActionTable_GoGoRainDance: ; 14f8f (5:4f8f)  	dw .ko_switch  	dw .take_prize -.do_turn ; 14f9b (5:4f9b) +.do_turn  	call AIMainTurnLogic  	ret -.start_duel ; 14f9f (5:4f9f) +.start_duel  	call InitAIDuelVars  	call .store_list_pointers  	call SetUpBossStartingHandAndDeck @@ -19,39 +19,39 @@ AIActionTable_GoGoRainDance: ; 14f8f (5:4f8f)  	call AIPlayInitialBasicCards  	ret -.forced_switch ; 14fb0 (5:4fb0) +.forced_switch  	call AIDecideBenchPokemonToSwitchTo  	ret -.ko_switch ; 14fb4 (5:4fb4) +.ko_switch  	call AIDecideBenchPokemonToSwitchTo  	ret -.take_prize ; 14fb8 (5:4fb8) +.take_prize  	call AIPickPrizeCards  	ret -.list_arena ; 14fbc (5:4fbc) +.list_arena  	db LAPRAS  	db HORSEA  	db GOLDEEN  	db SQUIRTLE  	db $00 -.list_bench ; 14fc1 (5:4fc1) +.list_bench  	db SQUIRTLE  	db HORSEA  	db GOLDEEN  	db LAPRAS  	db $00 -.list_retreat ; 14fc6 (5:4fc6) +.list_retreat  	ai_retreat SQUIRTLE,  -3  	ai_retreat WARTORTLE, -2  	ai_retreat HORSEA,    -1  	db $00 -.list_energy ; 14fcd (5:4fcd) +.list_energy  	ai_energy SQUIRTLE,  2, +0  	ai_energy WARTORTLE, 3, +0  	ai_energy BLASTOISE, 5, +0 @@ -62,14 +62,14 @@ AIActionTable_GoGoRainDance: ; 14f8f (5:4f8f)  	ai_energy LAPRAS,    3, +0  	db $00 -.list_prize ; 14fe6 (5:4fe6) +.list_prize  	db GAMBLER  	db ENERGY_RETRIEVAL  	db SUPER_ENERGY_RETRIEVAL  	db BLASTOISE  	db $00 -.store_list_pointers ; 14feb (5:4feb) +.store_list_pointers  	store_list_pointer wAICardListAvoidPrize, .list_prize  	store_list_pointer wAICardListArenaPriority, .list_arena  	store_list_pointer wAICardListBenchPriority, .list_bench diff --git a/src/engine/duel/ai/decks/im_ronald.asm b/src/engine/duel/ai/decks/im_ronald.asm index b002d83..ad55c16 100644 --- a/src/engine/duel/ai/decks/im_ronald.asm +++ b/src/engine/duel/ai/decks/im_ronald.asm @@ -1,4 +1,4 @@ -AIActionTable_ImRonald: ; 152bd (5:52bd) +AIActionTable_ImRonald:  	dw .do_turn ; unused  	dw .do_turn  	dw .start_duel @@ -6,11 +6,11 @@ AIActionTable_ImRonald: ; 152bd (5:52bd)  	dw .ko_switch  	dw .take_prize -.do_turn ; 152c9 (5:52c9) +.do_turn  	call AIMainTurnLogic  	ret -.start_duel ; 152cd (5:52cd) +.start_duel  	call InitAIDuelVars  	call .store_list_pointers  	call SetUpBossStartingHandAndDeck @@ -19,19 +19,19 @@ AIActionTable_ImRonald: ; 152bd (5:52bd)  	call AIPlayInitialBasicCards  	ret -.forced_switch ; 152de (5:52de) +.forced_switch  	call AIDecideBenchPokemonToSwitchTo  	ret -.ko_switch ; 152e2 (5:52e2) +.ko_switch  	call AIDecideBenchPokemonToSwitchTo  	ret -.take_prize ; 152e6 (5:52e6) +.take_prize  	call AIPickPrizeCards  	ret -.list_arena ; 152ea (5:52ea) +.list_arena  	db LAPRAS  	db SEEL  	db CHARMANDER @@ -40,7 +40,7 @@ AIActionTable_ImRonald: ; 152bd (5:52bd)  	db GROWLITHE  	db $00 -.list_bench ; 152f1 (5:52f1) +.list_bench  	db CHARMANDER  	db SQUIRTLE  	db SEEL @@ -49,10 +49,10 @@ AIActionTable_ImRonald: ; 152bd (5:52bd)  	db LAPRAS  	db $00 -.list_retreat ; 152f8 (5:52f8) +.list_retreat  	db $00 -.list_energy ; 152f9 (5:52f9) +.list_energy  	ai_energy CHARMANDER, 3, +0  	ai_energy CHARMELEON, 5, +0  	ai_energy GROWLITHE,  2, +0 @@ -66,11 +66,11 @@ AIActionTable_ImRonald: ; 152bd (5:52bd)  	ai_energy MAROWAK1,   3, +0  	db $00 -.list_prize ; 1531b (5:531b) +.list_prize  	db LAPRAS  	db $00 -.store_list_pointers ; 1531d (5:531d) +.store_list_pointers  	store_list_pointer wAICardListAvoidPrize, .list_prize  	store_list_pointer wAICardListArenaPriority, .list_arena  	store_list_pointer wAICardListBenchPriority, .list_bench diff --git a/src/engine/duel/ai/decks/invincible_ronald.asm b/src/engine/duel/ai/decks/invincible_ronald.asm index 463560b..4095de6 100644 --- a/src/engine/duel/ai/decks/invincible_ronald.asm +++ b/src/engine/duel/ai/decks/invincible_ronald.asm @@ -1,4 +1,4 @@ -AIActionTable_InvincibleRonald: ; 153e8 (5:53e8) +AIActionTable_InvincibleRonald:  	dw .do_turn ; unused  	dw .do_turn  	dw .start_duel @@ -6,11 +6,11 @@ AIActionTable_InvincibleRonald: ; 153e8 (5:53e8)  	dw .ko_switch  	dw .take_prize -.do_turn ; 153f4 (5:53f4) +.do_turn  	call AIMainTurnLogic  	ret -.start_duel ; 153f8 (5:53f8) +.start_duel  	call InitAIDuelVars  	call .store_list_pointers  	call SetUpBossStartingHandAndDeck @@ -19,19 +19,19 @@ AIActionTable_InvincibleRonald: ; 153e8 (5:53e8)  	call AIPlayInitialBasicCards  	ret -.forced_switch ; 15409 (5:5409) +.forced_switch  	call AIDecideBenchPokemonToSwitchTo  	ret -.ko_switch ; 1540d (5:540d) +.ko_switch  	call AIDecideBenchPokemonToSwitchTo  	ret -.take_prize ; 15411 (5:5411) +.take_prize  	call AIPickPrizeCards  	ret -.list_arena ; 15415 (5:5415) +.list_arena  	db KANGASKHAN  	db MAGMAR2  	db CHANSEY @@ -40,7 +40,7 @@ AIActionTable_InvincibleRonald: ; 153e8 (5:53e8)  	db GRIMER  	db $00 -.list_bench ; 1541c (5:541c) +.list_bench  	db GRIMER  	db SCYTHER  	db GEODUDE @@ -49,11 +49,11 @@ AIActionTable_InvincibleRonald: ; 153e8 (5:53e8)  	db KANGASKHAN  	db $00 -.list_retreat ; 15423 (5:5423) +.list_retreat  	ai_retreat GRIMER, -1  	db $00 -.list_energy ; 15426 (5:5426) +.list_energy  	ai_energy GRIMER,     1, -1  	ai_energy MUK,        3, -1  	ai_energy SCYTHER,    4, +1 @@ -64,11 +64,11 @@ AIActionTable_InvincibleRonald: ; 153e8 (5:53e8)  	ai_energy KANGASKHAN, 4, -1  	db $00 -.list_prize ; 1543f (5:543f) +.list_prize  	db GAMBLER  	db $00 -.store_list_pointers ; 15441 (5:5441) +.store_list_pointers  	store_list_pointer wAICardListAvoidPrize, .list_prize  	store_list_pointer wAICardListArenaPriority, .list_arena  	store_list_pointer wAICardListBenchPriority, .list_bench diff --git a/src/engine/duel/ai/decks/legendary_articuno.asm b/src/engine/duel/ai/decks/legendary_articuno.asm index 6409330..1070fc3 100644 --- a/src/engine/duel/ai/decks/legendary_articuno.asm +++ b/src/engine/duel/ai/decks/legendary_articuno.asm @@ -1,4 +1,4 @@ -AIActionTable_LegendaryArticuno: ; 14c0b (5:4c0b) +AIActionTable_LegendaryArticuno:  	dw .do_turn ; unused  	dw .do_turn  	dw .start_duel @@ -6,11 +6,11 @@ AIActionTable_LegendaryArticuno: ; 14c0b (5:4c0b)  	dw .ko_switch  	dw .take_prize -.do_turn ; 14c17 (5:4c17) +.do_turn  	call AIDoTurn_LegendaryArticuno  	ret -.start_duel ; 14c1b (5:4c1b) +.start_duel  	call InitAIDuelVars  	call .store_list_pointers  	call SetUpBossStartingHandAndDeck @@ -19,19 +19,19 @@ AIActionTable_LegendaryArticuno: ; 14c0b (5:4c0b)  	call AIPlayInitialBasicCards  	ret -.forced_switch ; 14c2c (5:4c2c) +.forced_switch  	call AIDecideBenchPokemonToSwitchTo  	ret -.ko_switch ; 14c30 (5:4c30) +.ko_switch  	call AIDecideBenchPokemonToSwitchTo  	ret -.take_prize ; 14c34 (5:4c34) +.take_prize  	call AIPickPrizeCards  	ret -.list_arena ; 14c38 (5:4c38) +.list_arena  	db CHANSEY  	db LAPRAS  	db DITTO @@ -40,7 +40,7 @@ AIActionTable_LegendaryArticuno: ; 14c0b (5:4c0b)  	db ARTICUNO2  	db $00 -.list_bench ; 14c3f (5:4c3f) +.list_bench  	db ARTICUNO1  	db SEEL  	db LAPRAS @@ -48,12 +48,12 @@ AIActionTable_LegendaryArticuno: ; 14c0b (5:4c0b)  	db DITTO  	db $00 -.list_retreat ; 14c45 (5:4c45) +.list_retreat  	ai_retreat SEEL,  -3  	ai_retreat DITTO, -3  	db $00 -.list_energy ; 14c4a (5:4c4a) +.list_energy  	ai_energy SEEL,      3, +1  	ai_energy DEWGONG,   4, +0  	ai_energy LAPRAS,    3, +0 @@ -63,12 +63,12 @@ AIActionTable_LegendaryArticuno: ; 14c0b (5:4c0b)  	ai_energy DITTO,     3, +0  	db $00 -.list_prize ; 14c60 (5:4c60) +.list_prize  	db GAMBLER  	db ARTICUNO2  	db $00 -.store_list_pointers ; 14c63 (5:4c63) +.store_list_pointers  	store_list_pointer wAICardListAvoidPrize, .list_prize  	store_list_pointer wAICardListArenaPriority, .list_arena  	store_list_pointer wAICardListBenchPriority, .list_bench @@ -82,7 +82,7 @@ AIActionTable_LegendaryArticuno: ; 14c0b (5:4c0b)  ; first, it makes sure that all Lapras have at least  ; 3 energy cards before moving on to Articuno,  ; and then to Dewgong and Seel -ScoreLegendaryArticunoCards: ; 14c91 (5:4c91) +ScoreLegendaryArticunoCards:  	call SwapTurn  	call CountPrizes  	call SwapTurn @@ -151,7 +151,7 @@ ScoreLegendaryArticunoCards: ; 14c91 (5:4c91)  	call RaiseAIScoreToAllMatchingIDsInBench  	ret -AIDoTurn_LegendaryArticuno: ; 14cf7 (5:4cf7) +AIDoTurn_LegendaryArticuno:  ; initialize variables  	call InitAITurnVars  	ld a, AI_TRAINER_CARD_PHASE_01 diff --git a/src/engine/duel/ai/decks/legendary_dragonite.asm b/src/engine/duel/ai/decks/legendary_dragonite.asm index 597f72c..7417287 100644 --- a/src/engine/duel/ai/decks/legendary_dragonite.asm +++ b/src/engine/duel/ai/decks/legendary_dragonite.asm @@ -1,4 +1,4 @@ -AIActionTable_LegendaryDragonite: ; 14d60 (05:4d60) +AIActionTable_LegendaryDragonite:  	dw .do_turn ; unused  	dw .do_turn  	dw .start_duel @@ -6,11 +6,11 @@ AIActionTable_LegendaryDragonite: ; 14d60 (05:4d60)  	dw .ko_switch  	dw .take_prize -.do_turn ; 14d6c (5:4d6c) +.do_turn  	call AIDoTurn_LegendaryDragonite  	ret -.start_duel ; 14d70 (5:4d70) +.start_duel  	call InitAIDuelVars  	call .store_list_pointers  	call SetUpBossStartingHandAndDeck @@ -19,19 +19,19 @@ AIActionTable_LegendaryDragonite: ; 14d60 (05:4d60)  	call AIPlayInitialBasicCards  	ret -.forced_switch ; 14d81 (5:4d81) +.forced_switch  	call AIDecideBenchPokemonToSwitchTo  	ret -.ko_switch ; 14d85 (5:4d85) +.ko_switch  	call AIDecideBenchPokemonToSwitchTo  	ret -.take_prize ; 14d89 (5:4d89) +.take_prize  	call AIPickPrizeCards  	ret -.list_arena ; 14d8d (5:4d8d) +.list_arena  	db KANGASKHAN  	db LAPRAS  	db CHARMANDER @@ -39,7 +39,7 @@ AIActionTable_LegendaryDragonite: ; 14d60 (05:4d60)  	db MAGIKARP  	db $00 -.list_bench ; 14d93 (5:4d93) +.list_bench  	db CHARMANDER  	db MAGIKARP  	db DRATINI @@ -47,12 +47,12 @@ AIActionTable_LegendaryDragonite: ; 14d60 (05:4d60)  	db KANGASKHAN  	db $00 -.list_retreat ; 14d99 (5:4d99) +.list_retreat  	ai_retreat CHARMANDER, -1  	ai_retreat MAGIKARP,   -5  	db $00 -.list_energy ; 14d9e (5:4d9e) +.list_energy  	ai_energy CHARMANDER, 3, +1  	ai_energy CHARMELEON, 4, +1  	ai_energy CHARIZARD,  5, +0 @@ -65,13 +65,13 @@ AIActionTable_LegendaryDragonite: ; 14d60 (05:4d60)  	ai_energy LAPRAS,     3, +0  	db $00 -.list_prize ; 14dbd (5:4dbd) +.list_prize  	db GAMBLER  	db DRAGONITE1  	db KANGASKHAN  	db $00 -.store_list_pointers ; 14dc1 (5:4dc1) +.store_list_pointers  	store_list_pointer wAICardListAvoidPrize, .list_prize  	store_list_pointer wAICardListArenaPriority, .list_arena  	store_list_pointer wAICardListBenchPriority, .list_bench @@ -80,7 +80,7 @@ AIActionTable_LegendaryDragonite: ; 14d60 (05:4d60)  	store_list_pointer wAICardListEnergyBonus, .list_energy  	ret -AIDoTurn_LegendaryDragonite: ; 14def (5:4def) +AIDoTurn_LegendaryDragonite:  ; initialize variables  	call InitAITurnVars  	ld a, AI_TRAINER_CARD_PHASE_01 diff --git a/src/engine/duel/ai/decks/legendary_moltres.asm b/src/engine/duel/ai/decks/legendary_moltres.asm index c2a3882..6e870c5 100644 --- a/src/engine/duel/ai/decks/legendary_moltres.asm +++ b/src/engine/duel/ai/decks/legendary_moltres.asm @@ -1,4 +1,4 @@ -AIActionTable_LegendaryMoltres: ; 149e8 (05:49e8) +AIActionTable_LegendaryMoltres:  	dw .do_turn ; unused  	dw .do_turn  	dw .start_duel @@ -6,11 +6,11 @@ AIActionTable_LegendaryMoltres: ; 149e8 (05:49e8)  	dw .ko_switch  	dw .take_prize -.do_turn ; 149f4 (5:49f4) +.do_turn  	call AIDoTurn_LegendaryMoltres  	ret -.start_duel ; 149f8 (5:49f8) +.start_duel  	call InitAIDuelVars  	call .store_list_pointers  	call SetUpBossStartingHandAndDeck @@ -19,19 +19,19 @@ AIActionTable_LegendaryMoltres: ; 149e8 (05:49e8)  	call AIPlayInitialBasicCards  	ret -.forced_switch ; 14a09 (5:4a09) +.forced_switch  	call AIDecideBenchPokemonToSwitchTo  	ret -.ko_switch ; 14a0d (5:4a0d) +.ko_switch  	call AIDecideBenchPokemonToSwitchTo  	ret -.take_prize ; 14a11 (5:4a11) +.take_prize  	call AIPickPrizeCards  	ret -.list_arena ; 14a15 (5:4a15) +.list_arena  	db MAGMAR2  	db GROWLITHE  	db VULPIX @@ -40,7 +40,7 @@ AIActionTable_LegendaryMoltres: ; 149e8 (05:49e8)  	db MOLTRES2  	db $00 -.list_bench ; 14a1c (5:4a1c) +.list_bench  	db MOLTRES1  	db VULPIX  	db GROWLITHE @@ -48,7 +48,7 @@ AIActionTable_LegendaryMoltres: ; 149e8 (05:49e8)  	db MAGMAR1  	db $00 -.list_play_hand ; 14a22 (5:4a22) +.list_play_hand  	db MOLTRES2  	db MOLTRES1  	db VULPIX @@ -57,12 +57,12 @@ AIActionTable_LegendaryMoltres: ; 149e8 (05:49e8)  	db MAGMAR1  	db $00 -.list_retreat ; 14a29 (5:4a29) +.list_retreat  	ai_retreat GROWLITHE, -5  	ai_retreat VULPIX,    -5  	db $00 -.list_energy ; 14a2e (5:4a2e) +.list_energy  	ai_energy VULPIX,     3, +0  	ai_energy NINETALES2, 3, +1  	ai_energy GROWLITHE,  3, +1 @@ -73,12 +73,12 @@ AIActionTable_LegendaryMoltres: ; 149e8 (05:49e8)  	ai_energy MOLTRES1,   4, +2  	db $00 -.list_prize ; 14a47 (5:4a47) +.list_prize  	db ENERGY_REMOVAL  	db MOLTRES2  	db $00 -.store_list_pointers ; 14a4a (5:4a4a) +.store_list_pointers  	store_list_pointer wAICardListAvoidPrize, .list_prize  	store_list_pointer wAICardListArenaPriority, .list_arena  	store_list_pointer wAICardListBenchPriority, .list_bench @@ -87,7 +87,7 @@ AIActionTable_LegendaryMoltres: ; 149e8 (05:49e8)  	store_list_pointer wAICardListEnergyBonus, .list_energy  	ret -AIDoTurn_LegendaryMoltres: ; 14a81 (5:4a81) +AIDoTurn_LegendaryMoltres:  ; initialize variables  	call InitAITurnVars  	farcall HandleAIAntiMewtwoDeckStrategy diff --git a/src/engine/duel/ai/decks/legendary_ronald.asm b/src/engine/duel/ai/decks/legendary_ronald.asm index 3356838..1a2c8dd 100644 --- a/src/engine/duel/ai/decks/legendary_ronald.asm +++ b/src/engine/duel/ai/decks/legendary_ronald.asm @@ -1,4 +1,4 @@ -AIActionTable_LegendaryRonald: ; 1546f (5:546f) +AIActionTable_LegendaryRonald:  	dw .do_turn ; unused  	dw .do_turn  	dw .start_duel @@ -6,11 +6,11 @@ AIActionTable_LegendaryRonald: ; 1546f (5:546f)  	dw .ko_switch  	dw .take_prize -.do_turn ; 1547b (5:547b) +.do_turn  	call AIDoTurn_LegendaryRonald  	ret -.start_duel ; 1547f (5:547f) +.start_duel  	call InitAIDuelVars  	call .store_list_pointers  	call SetUpBossStartingHandAndDeck @@ -19,19 +19,19 @@ AIActionTable_LegendaryRonald: ; 1546f (5:546f)  	call AIPlayInitialBasicCards  	ret -.forced_switch ; 15490 (5:5490) +.forced_switch  	call AIDecideBenchPokemonToSwitchTo  	ret -.ko_switch ; 15494 (5:5494) +.ko_switch  	call AIDecideBenchPokemonToSwitchTo  	ret -.take_prize ; 15498 (5:5498) +.take_prize  	call AIPickPrizeCards  	ret -.list_arena ; 1549c (5:549c) +.list_arena  	db KANGASKHAN  	db DRATINI  	db EEVEE @@ -40,13 +40,13 @@ AIActionTable_LegendaryRonald: ; 1546f (5:546f)  	db MOLTRES2  	db $00 -.list_bench ; 154a3 (5:54a3) +.list_bench  	db KANGASKHAN  	db DRATINI  	db EEVEE  	db $00 -.list_play_hand ; 154a7 (5:54a7) +.list_play_hand  	db MOLTRES2  	db ZAPDOS3  	db KANGASKHAN @@ -55,11 +55,11 @@ AIActionTable_LegendaryRonald: ; 1546f (5:546f)  	db ARTICUNO2  	db $00 -.list_retreat ; 154ae (5:54ae) +.list_retreat  	ai_retreat EEVEE, -2  	db $00 -.list_energy ; 154b1 (5:54b1) +.list_energy  	ai_energy FLAREON1,   3, +0  	ai_energy MOLTRES2,   3, +0  	ai_energy VAPOREON1,  3, +0 @@ -73,7 +73,7 @@ AIActionTable_LegendaryRonald: ; 1546f (5:546f)  	ai_energy DRAGONITE1, 3, +0  	db $00 -.list_prize ; 154d3 (5:54d3) +.list_prize  	db MOLTRES2  	db ARTICUNO2  	db ZAPDOS3 @@ -81,7 +81,7 @@ AIActionTable_LegendaryRonald: ; 1546f (5:546f)  	db GAMBLER  	db $00 -.store_list_pointers ; 154d9 (5:54d9) +.store_list_pointers  	store_list_pointer wAICardListAvoidPrize, .list_prize  	store_list_pointer wAICardListArenaPriority, .list_arena  	store_list_pointer wAICardListBenchPriority, .list_bench @@ -90,7 +90,7 @@ AIActionTable_LegendaryRonald: ; 1546f (5:546f)  	store_list_pointer wAICardListEnergyBonus, .list_energy  	ret -AIDoTurn_LegendaryRonald: ; 15507 (5:5507) +AIDoTurn_LegendaryRonald:  ; initialize variables  	call InitAITurnVars  ; process Trainer cards diff --git a/src/engine/duel/ai/decks/legendary_zapdos.asm b/src/engine/duel/ai/decks/legendary_zapdos.asm index cc99f0c..2298fe2 100644 --- a/src/engine/duel/ai/decks/legendary_zapdos.asm +++ b/src/engine/duel/ai/decks/legendary_zapdos.asm @@ -1,4 +1,4 @@ -AIActionTable_LegendaryZapdos: ; 14b0f (05:4b0f) +AIActionTable_LegendaryZapdos:  	dw .do_turn ; unused  	dw .do_turn  	dw .start_duel @@ -6,11 +6,11 @@ AIActionTable_LegendaryZapdos: ; 14b0f (05:4b0f)  	dw .ko_switch  	dw .take_prize -.do_turn ; 14b1b (5:4b1b) +.do_turn  	call AIDoTurn_LegendaryZapdos  	ret -.start_duel ; 14b1f (5:4b1f) +.start_duel  	call InitAIDuelVars  	call .store_list_pointers  	call SetUpBossStartingHandAndDeck @@ -19,19 +19,19 @@ AIActionTable_LegendaryZapdos: ; 14b0f (05:4b0f)  	call AIPlayInitialBasicCards  	ret -.forced_switch ; 14b30 (5:4b30) +.forced_switch  	call AIDecideBenchPokemonToSwitchTo  	ret -.ko_switch ; 14b34 (5:4b34) +.ko_switch  	call AIDecideBenchPokemonToSwitchTo  	ret -.take_prize ; 14b38 (5:4b38) +.take_prize  	call AIPickPrizeCards  	ret -.list_arena ; 14b3c (5:4b3c) +.list_arena  	db ELECTABUZZ2  	db VOLTORB  	db EEVEE @@ -40,7 +40,7 @@ AIActionTable_LegendaryZapdos: ; 14b0f (05:4b0f)  	db ZAPDOS3  	db $00 -.list_bench ; 14b43 (5:4b43) +.list_bench  	db ZAPDOS2  	db ZAPDOS1  	db EEVEE @@ -48,13 +48,13 @@ AIActionTable_LegendaryZapdos: ; 14b0f (05:4b0f)  	db ELECTABUZZ2  	db $00 -.list_retreat ; 14b49 (5:4b49) +.list_retreat  	ai_retreat EEVEE,       -5  	ai_retreat VOLTORB,     -5  	ai_retreat ELECTABUZZ2, -5  	db $00 -.list_energy ; 14b50 (5:4b50) +.list_energy  	ai_energy VOLTORB,     1, -1  	ai_energy ELECTRODE1,  3, +0  	ai_energy ELECTABUZZ2, 2, -1 @@ -65,12 +65,12 @@ AIActionTable_LegendaryZapdos: ; 14b0f (05:4b0f)  	ai_energy EEVEE,       3, +0  	db $00 -.list_prize ; 14b69 (5:4b69) +.list_prize  	db GAMBLER  	db ZAPDOS3  	db $00 -.store_list_pointers ; 14b6c (5:4b6c) +.store_list_pointers  	store_list_pointer wAICardListAvoidPrize, .list_prize  	store_list_pointer wAICardListArenaPriority, .list_arena  	store_list_pointer wAICardListBenchPriority, .list_bench @@ -79,7 +79,7 @@ AIActionTable_LegendaryZapdos: ; 14b0f (05:4b0f)  	store_list_pointer wAICardListEnergyBonus, .list_energy  	ret -AIDoTurn_LegendaryZapdos: ; 14b9a (5:4b9a) +AIDoTurn_LegendaryZapdos:  ; initialize variables  	call InitAITurnVars  	farcall HandleAIAntiMewtwoDeckStrategy diff --git a/src/engine/duel/ai/decks/powerful_ronald.asm b/src/engine/duel/ai/decks/powerful_ronald.asm index 096fbea..63ce1cd 100644 --- a/src/engine/duel/ai/decks/powerful_ronald.asm +++ b/src/engine/duel/ai/decks/powerful_ronald.asm @@ -1,4 +1,4 @@ -AIActionTable_PowerfulRonald: ; 1534b (5:534b) +AIActionTable_PowerfulRonald:  	dw .do_turn ; unused  	dw .do_turn  	dw .start_duel @@ -6,11 +6,11 @@ AIActionTable_PowerfulRonald: ; 1534b (5:534b)  	dw .ko_switch  	dw .take_prize -.do_turn ; 15357 (5:5357) +.do_turn  	call AIMainTurnLogic  	ret -.start_duel ; 1535b (5:535b) +.start_duel  	call InitAIDuelVars  	call .store_list_pointers  	call SetUpBossStartingHandAndDeck @@ -19,19 +19,19 @@ AIActionTable_PowerfulRonald: ; 1534b (5:534b)  	call AIPlayInitialBasicCards  	ret -.forced_switch ; 1536c (5:536c) +.forced_switch  	call AIDecideBenchPokemonToSwitchTo  	ret -.ko_switch ; 15370 (5:5370) +.ko_switch  	call AIDecideBenchPokemonToSwitchTo  	ret -.take_prize ; 15374 (5:5374) +.take_prize  	call AIPickPrizeCards  	ret -.list_arena ; 15378 (5:5378) +.list_arena  	db KANGASKHAN  	db ELECTABUZZ2  	db HITMONCHAN @@ -44,7 +44,7 @@ AIActionTable_PowerfulRonald: ; 1534b (5:534b)  	db DODUO  	db $00 -.list_bench ; 15383 (5:5383) +.list_bench  	db KANGASKHAN  	db HITMONLEE  	db HITMONCHAN @@ -57,13 +57,13 @@ AIActionTable_PowerfulRonald: ; 1534b (5:534b)  	db LICKITUNG  	db $00 -.list_retreat ; 1538e (5:538e) +.list_retreat  	ai_retreat KANGASKHAN, -1  	ai_retreat DODUO,      -1  	ai_retreat DODRIO,     -1  	db $00 -.list_energy ; 15395 (5:5395) +.list_energy  	ai_energy ELECTABUZZ2, 2, +1  	ai_energy HITMONLEE,   3, +1  	ai_energy HITMONCHAN,  3, +1 @@ -77,12 +77,12 @@ AIActionTable_PowerfulRonald: ; 1534b (5:534b)  	ai_energy TAUROS,      3, +0  	db $00 -.list_prize ; 153b7 (5:53b7) +.list_prize  	db GAMBLER  	db ENERGY_REMOVAL  	db $00 -.store_list_pointers ; 153ba (5:53ba) +.store_list_pointers  	store_list_pointer wAICardListAvoidPrize, .list_prize  	store_list_pointer wAICardListArenaPriority, .list_arena  	store_list_pointer wAICardListBenchPriority, .list_bench diff --git a/src/engine/duel/ai/decks/rock_crusher.asm b/src/engine/duel/ai/decks/rock_crusher.asm index 41a50fa..0fca721 100644 --- a/src/engine/duel/ai/decks/rock_crusher.asm +++ b/src/engine/duel/ai/decks/rock_crusher.asm @@ -1,4 +1,4 @@ -AIActionTable_RockCrusher: ; 14f0e (5:4f0e) +AIActionTable_RockCrusher:  	dw .do_turn ; unused  	dw .do_turn  	dw .start_duel @@ -6,11 +6,11 @@ AIActionTable_RockCrusher: ; 14f0e (5:4f0e)  	dw .ko_switch  	dw .take_prize -.do_turn ; 14f1a (5:4f1a) +.do_turn  	call AIMainTurnLogic  	ret -.start_duel ; 14f1e (5:4f1e) +.start_duel  	call InitAIDuelVars  	call .store_list_pointers  	call SetUpBossStartingHandAndDeck @@ -19,37 +19,37 @@ AIActionTable_RockCrusher: ; 14f0e (5:4f0e)  	call AIPlayInitialBasicCards  	ret -.forced_switch ; 14f2f (5:4f2f) +.forced_switch  	call AIDecideBenchPokemonToSwitchTo  	ret -.ko_switch ; 14f33 (5:4f33) +.ko_switch  	call AIDecideBenchPokemonToSwitchTo  	ret -.take_prize ; 14f37 (5:4f37) +.take_prize  	call AIPickPrizeCards  	ret -.list_arena ; 14f3b (5:4f3b) +.list_arena  	db RHYHORN  	db ONIX  	db GEODUDE  	db DIGLETT  	db $00 -.list_bench ; 14f40 (5:4f40) +.list_bench  	db DIGLETT  	db GEODUDE  	db RHYHORN  	db ONIX  	db $00 -.list_retreat ; 14f45 (5:4f45) +.list_retreat  	ai_retreat DIGLETT, -1  	db $00 -.list_energy ; 14f48 (5:4f48) +.list_energy  	ai_energy DIGLETT,  3, +1  	ai_energy DUGTRIO,  4, +0  	ai_energy GEODUDE,  2, +1 @@ -59,12 +59,12 @@ AIActionTable_RockCrusher: ; 14f0e (5:4f0e)  	ai_energy RHYHORN,  3, +0  	db $00 -.list_prize ; 14f5e (5:4f5e) +.list_prize  	db ENERGY_REMOVAL  	db RHYHORN  	db $00 -.store_list_pointers ; 14f61 (5:4f61) +.store_list_pointers  	store_list_pointer wAICardListAvoidPrize, .list_prize  	store_list_pointer wAICardListArenaPriority, .list_arena  	store_list_pointer wAICardListBenchPriority, .list_bench diff --git a/src/engine/duel/ai/decks/sams_practice.asm b/src/engine/duel/ai/decks/sams_practice.asm index dddce61..cd12220 100644 --- a/src/engine/duel/ai/decks/sams_practice.asm +++ b/src/engine/duel/ai/decks/sams_practice.asm @@ -1,6 +1,6 @@  ; AI for Sam's practice duel, which handles his scripted actions.  ; will act as a normal duelist AI after turn 7. -AIActionTable_SamPractice: ; 147bd (05:47bd) +AIActionTable_SamPractice:  	dw .do_turn ; unused  	dw .do_turn  	dw .start_duel @@ -8,7 +8,7 @@ AIActionTable_SamPractice: ; 147bd (05:47bd)  	dw .ko_switch  	dw .take_prize -.do_turn ; 147c9 (5:47c9) +.do_turn  	call IsAIPracticeScriptedTurn  	jr nc, .scripted_1  ; not scripted, use AI main turn logic @@ -18,11 +18,11 @@ AIActionTable_SamPractice: ; 147bd (05:47bd)  	call AIPerformScriptedTurn  	ret -.start_duel ; 147d6 (5:47d6) +.start_duel  	call SetSamsStartingPlayArea  	ret -.forced_switch ; 147da (5:47da) +.forced_switch  	call IsAIPracticeScriptedTurn  	jr nc, .scripted_2  	call AIDecideBenchPokemonToSwitchTo @@ -31,7 +31,7 @@ AIActionTable_SamPractice: ; 147bd (05:47bd)  	call PickRandomBenchPokemon  	ret -.ko_switch: ; 147e7 (5:47e7) +.ko_switch:  	call IsAIPracticeScriptedTurn  	jr nc, .scripted_3  	call AIDecideBenchPokemonToSwitchTo @@ -40,7 +40,7 @@ AIActionTable_SamPractice: ; 147bd (05:47bd)  	call GetPlayAreaLocationOfRaticateOrRattata  	ret -.take_prize: ; 147f4 (5:47f4) +.take_prize:  	call AIPickPrizeCards  	ret @@ -48,7 +48,7 @@ AIActionTable_SamPractice: ; 147bd (05:47bd)  ; the AI has taken >= 7.  ; used to know whether AI Sam is still  ; doing scripted turns. -IsAIPracticeScriptedTurn: ; 147f8 (5:47f8) +IsAIPracticeScriptedTurn:  	ld a, [wDuelTurns]  	srl a  	cp 7 @@ -57,7 +57,7 @@ IsAIPracticeScriptedTurn: ; 147f8 (5:47f8)  ; places one Machop from the hand to the Play Area  ; and sets the number of prizes to 2. -SetSamsStartingPlayArea: ; 14801 (5:4801) +SetSamsStartingPlayArea:  	call CreateHandCardList  	ld hl, wDuelTempList  .loop_hand @@ -76,7 +76,7 @@ SetSamsStartingPlayArea: ; 14801 (5:4801)  ; outputs in a Play Area location of Raticate or Rattata  ; in the Bench. If neither is found, just output PLAY_AREA_BENCH_1. -GetPlayAreaLocationOfRaticateOrRattata: ; 1481f (5:481f) +GetPlayAreaLocationOfRaticateOrRattata:  	ld a, RATICATE  	ld b, PLAY_AREA_BENCH_1  	call LookForCardIDInPlayArea_Bank5 @@ -93,7 +93,7 @@ GetPlayAreaLocationOfRaticateOrRattata: ; 1481f (5:481f)  	ret  ; has AI execute some scripted actions depending on Duel turn. -AIPerformScriptedTurn: ; 1483a (5:483a) +AIPerformScriptedTurn:  	ld a, [wDuelTurns]  	srl a  	ld hl, .scripted_actions_list @@ -114,7 +114,7 @@ AIPerformScriptedTurn: ; 1483a (5:483a)  	bank1call AIMakeDecision  	ret -.scripted_actions_list ; 1485a (05:485a) +.scripted_actions_list  	dw .turn_1  	dw .turn_2  	dw .turn_3 @@ -123,13 +123,13 @@ AIPerformScriptedTurn: ; 1483a (5:483a)  	dw .turn_6  	dw .turn_7 -.turn_1 ; 14868 (5:4868) +.turn_1  	ld d, MACHOP  	ld e, FIGHTING_ENERGY  	call AIAttachEnergyInHandToCardInPlayArea  	ret -.turn_2 ; 14870 (5:4870) +.turn_2  	ld a, RATTATA  	call LookForCardIDInHandList_Bank5  	ldh [hTemp_ffa0], a @@ -140,7 +140,7 @@ AIPerformScriptedTurn: ; 1483a (5:483a)  	call AIAttachEnergyInHandToCardInPlayArea  	ret -.turn_3 ; 14884 (5:4884) +.turn_3  	ld a, RATTATA  	ld b, PLAY_AREA_ARENA  	call LookForCardIDInPlayArea_Bank5 @@ -155,13 +155,13 @@ AIPerformScriptedTurn: ; 1483a (5:483a)  	call AIAttachEnergyInHandToCardInPlayArea  	ret -.turn_4 ; 148a1 (5:48a1) +.turn_4  	ld d, RATICATE  	ld e, LIGHTNING_ENERGY  	call AIAttachEnergyInHandToCardInPlayArea  	ret -.turn_5 ; 148a9 (5:48a9) +.turn_5  	ld a, MACHOP  	call LookForCardIDInHandList_Bank5  	ldh [hTemp_ffa0], a @@ -192,13 +192,13 @@ AIPerformScriptedTurn: ; 1483a (5:483a)  	call AITryToRetreat  	ret -.turn_6 ; 148cc (5:48cc) +.turn_6  	ld d, MACHOP  	ld e, FIGHTING_ENERGY  	call AIAttachEnergyInHandToCardInPlayArea  	ret -.turn_7 ; 148d4 (5:48d4) +.turn_7  	ld d, MACHOP  	ld e, FIGHTING_ENERGY  	call AIAttachEnergyInHandToCardInPlayArea diff --git a/src/engine/duel/ai/decks/strange_psyshock.asm b/src/engine/duel/ai/decks/strange_psyshock.asm index ef378b0..b17d9e1 100644 --- a/src/engine/duel/ai/decks/strange_psyshock.asm +++ b/src/engine/duel/ai/decks/strange_psyshock.asm @@ -1,4 +1,4 @@ -AIActionTable_StrangePsyshock: ; 15122 (5:5122) +AIActionTable_StrangePsyshock:  	dw .do_turn ; unused  	dw .do_turn  	dw .start_duel @@ -6,11 +6,11 @@ AIActionTable_StrangePsyshock: ; 15122 (5:5122)  	dw .ko_switch  	dw .take_prize -.do_turn ; 1512e (5:512e) +.do_turn  	call AIMainTurnLogic  	ret -.start_duel ; 15132 (5:5132) +.start_duel  	call InitAIDuelVars  	call .store_list_pointers  	call SetUpBossStartingHandAndDeck @@ -19,19 +19,19 @@ AIActionTable_StrangePsyshock: ; 15122 (5:5122)  	call AIPlayInitialBasicCards  	ret -.forced_switch ; 15143 (5:5143) +.forced_switch  	call AIDecideBenchPokemonToSwitchTo  	ret -.ko_switch ; 15147 (5:5147) +.ko_switch  	call AIDecideBenchPokemonToSwitchTo  	ret -.take_prize ; 1514b (5:514b) +.take_prize  	call AIPickPrizeCards  	ret -.list_arena ; 1514f (5:514f) +.list_arena  	db KANGASKHAN  	db CHANSEY  	db SNORLAX @@ -39,7 +39,7 @@ AIActionTable_StrangePsyshock: ; 15122 (5:5122)  	db ABRA  	db $00 -.list_bench ; 15155 (5:5155) +.list_bench  	db ABRA  	db MR_MIME  	db KANGASKHAN @@ -47,14 +47,14 @@ AIActionTable_StrangePsyshock: ; 15122 (5:5122)  	db CHANSEY  	db $00 -.list_retreat ; 1515b (5:515b) +.list_retreat  	ai_retreat ABRA,       -3  	ai_retreat SNORLAX,    -3  	ai_retreat KANGASKHAN, -1  	ai_retreat CHANSEY,    -1  	db $00 -.list_energy ; 15164 (5:5164) +.list_energy  	ai_energy ABRA,       3, +1  	ai_energy KADABRA,    3, +0  	ai_energy ALAKAZAM,   3, +0 @@ -64,14 +64,14 @@ AIActionTable_StrangePsyshock: ; 15122 (5:5122)  	ai_energy SNORLAX,    0, -8  	db $00 -.list_prize ; 1517a (5:517a) +.list_prize  	db GAMBLER  	db MR_MIME  	db ALAKAZAM  	db SWITCH  	db $00 -.store_list_pointers ; 1517f (5:517f) +.store_list_pointers  	store_list_pointer wAICardListAvoidPrize, .list_prize  	store_list_pointer wAICardListArenaPriority, .list_arena  	store_list_pointer wAICardListBenchPriority, .list_bench diff --git a/src/engine/duel/ai/decks/unreferenced.asm b/src/engine/duel/ai/decks/unreferenced.asm index 8722a27..d4d8513 100644 --- a/src/engine/duel/ai/decks/unreferenced.asm +++ b/src/engine/duel/ai/decks/unreferenced.asm @@ -1,4 +1,4 @@ -AIActionTable_Unreferenced: ; 1406a (5:406a) +AIActionTable_Unreferenced: ; unreferenced  	dw $406c  	dw .do_turn  	dw .do_turn diff --git a/src/engine/duel/ai/decks/wonders_of_science.asm b/src/engine/duel/ai/decks/wonders_of_science.asm index 706a7e6..adc54ff 100644 --- a/src/engine/duel/ai/decks/wonders_of_science.asm +++ b/src/engine/duel/ai/decks/wonders_of_science.asm @@ -1,4 +1,4 @@ -AIActionTable_WondersOfScience: ; 151ad (5:51ad) +AIActionTable_WondersOfScience:  	dw .do_turn ; unused  	dw .do_turn  	dw .start_duel @@ -6,11 +6,11 @@ AIActionTable_WondersOfScience: ; 151ad (5:51ad)  	dw .ko_switch  	dw .take_prize -.do_turn ; 151b9 (5:51b9) +.do_turn  	call AIMainTurnLogic  	ret -.start_duel ; 151bd (5:51bd) +.start_duel  	call InitAIDuelVars  	call .store_list_pointers  	call SetUpBossStartingHandAndDeck @@ -19,19 +19,19 @@ AIActionTable_WondersOfScience: ; 151ad (5:51ad)  	call AIPlayInitialBasicCards  	ret -.forced_switch ; 151ce (5:51ce) +.forced_switch  	call AIDecideBenchPokemonToSwitchTo  	ret -.ko_switch ; 151d2 (5:51d2) +.ko_switch  	call AIDecideBenchPokemonToSwitchTo  	ret -.take_prize ; 151d6 (5:51d6) +.take_prize  	call AIPickPrizeCards  	ret -.list_arena ; 151da (5:51da) +.list_arena  	db MEWTWO1  	db MEWTWO3  	db MEWTWO2 @@ -40,7 +40,7 @@ AIActionTable_WondersOfScience: ; 151ad (5:51ad)  	db PORYGON  	db $00 -.list_bench ; 151e1 (5:51e1) +.list_bench  	db GRIMER  	db KOFFING  	db MEWTWO3 @@ -49,10 +49,10 @@ AIActionTable_WondersOfScience: ; 151ad (5:51ad)  	db PORYGON  	db $00 -.list_retreat ; 151e8 (5:51e8) +.list_retreat  	db $00 -.list_energy ; 151e9 (5:51e9) +.list_energy  	ai_energy GRIMER,  3, +0  	ai_energy MUK,     4, +0  	ai_energy KOFFING, 2, +0 @@ -63,11 +63,11 @@ AIActionTable_WondersOfScience: ; 151ad (5:51ad)  	ai_energy PORYGON, 2, -1  	db $00 -.list_prize ; 15202 (5:5202) +.list_prize  	db MUK  	db $00 -.store_list_pointers ; 15204 (5:5204) +.store_list_pointers  	store_list_pointer wAICardListAvoidPrize, .list_prize  	store_list_pointer wAICardListArenaPriority, .list_arena  	store_list_pointer wAICardListBenchPriority, .list_bench diff --git a/src/engine/duel/ai/decks/zapping_selfdestruct.asm b/src/engine/duel/ai/decks/zapping_selfdestruct.asm index da5e7c6..b283395 100644 --- a/src/engine/duel/ai/decks/zapping_selfdestruct.asm +++ b/src/engine/duel/ai/decks/zapping_selfdestruct.asm @@ -1,4 +1,4 @@ -AIActionTable_ZappingSelfdestruct: ; 15019 (5:5019) +AIActionTable_ZappingSelfdestruct:  	dw .do_turn ; unused  	dw .do_turn  	dw .start_duel @@ -6,11 +6,11 @@ AIActionTable_ZappingSelfdestruct: ; 15019 (5:5019)  	dw .ko_switch  	dw .take_prize -.do_turn ; 15025 (5:5025) +.do_turn  	call AIMainTurnLogic  	ret -.start_duel ; 15029 (5:5029) +.start_duel  	call InitAIDuelVars  	call .store_list_pointers  	call SetUpBossStartingHandAndDeck @@ -19,19 +19,19 @@ AIActionTable_ZappingSelfdestruct: ; 15019 (5:5019)  	call AIPlayInitialBasicCards  	ret -.forced_switch ; 1503a (5:503a) +.forced_switch  	call AIDecideBenchPokemonToSwitchTo  	ret -.ko_switch ; 1503e (5:503e) +.ko_switch  	call AIDecideBenchPokemonToSwitchTo  	ret -.take_prize ; 15042 (5:5042) +.take_prize  	call AIPickPrizeCards  	ret -.list_arena ; 15046 (5:5046) +.list_arena  	db KANGASKHAN  	db ELECTABUZZ2  	db TAUROS @@ -39,7 +39,7 @@ AIActionTable_ZappingSelfdestruct: ; 15019 (5:5019)  	db VOLTORB  	db $00 -.list_bench ; 1504c (5:504c) +.list_bench  	db MAGNEMITE1  	db VOLTORB  	db ELECTABUZZ2 @@ -47,11 +47,11 @@ AIActionTable_ZappingSelfdestruct: ; 15019 (5:5019)  	db KANGASKHAN  	db $00 -.list_retreat ; 15052 (5:5052) +.list_retreat  	ai_retreat VOLTORB, -1  	db $00 -.list_energy ; 15055 (5:5055) +.list_energy  	ai_energy MAGNEMITE1,  3, +1  	ai_energy MAGNETON1,   4, +0  	ai_energy VOLTORB,     3, +1 @@ -61,11 +61,11 @@ AIActionTable_ZappingSelfdestruct: ; 15019 (5:5019)  	ai_energy TAUROS,      3, +0  	db $00 -.list_prize ; 1506b (5:506b) +.list_prize  	db KANGASKHAN  	db $00 -.store_list_pointers ; 1506d (5:506d) +.store_list_pointers  	store_list_pointer wAICardListAvoidPrize, .list_prize  	store_list_pointer wAICardListArenaPriority, .list_arena  	store_list_pointer wAICardListBenchPriority, .list_bench diff --git a/src/engine/duel/ai/energy.asm b/src/engine/duel/ai/energy.asm index ce8c037..ff9c369 100644 --- a/src/engine/duel/ai/energy.asm +++ b/src/engine/duel/ai/energy.asm @@ -1,7 +1,7 @@  ; processes AI energy card playing logic  ; with AI_ENERGY_FLAG_DONT_PLAY flag on  ; unreferenced -Func_16488: ; 16488 (5:6488) +Func_16488:  	ld a, AI_ENERGY_FLAG_DONT_PLAY  	ld [wAIEnergyAttachLogicFlags], a  	ld de, wTempPlayAreaAIScore diff --git a/src/engine/duel/ai/hand_pokemon.asm b/src/engine/duel/ai/hand_pokemon.asm index 27a4176..d9728b2 100644 --- a/src/engine/duel/ai/hand_pokemon.asm +++ b/src/engine/duel/ai/hand_pokemon.asm @@ -1,6 +1,6 @@  ; determine whether AI plays  ; basic cards from hand -AIDecidePlayPokemonCard: ; 15eae (5:5eae) +AIDecidePlayPokemonCard:  	call CreateHandCardList  	call SortTempHandByIDList  	ld hl, wDuelTempList @@ -101,7 +101,7 @@ AIDecidePlayPokemonCard: ; 15eae (5:5eae)  ; determine whether AI evolves  ; Pokémon in the Play Area -AIDecideEvolution: ; 15f4c (5:5f4c) +AIDecideEvolution:  	call CreateHandCardList  	ld hl, wDuelTempList  	ld de, wHandTempList @@ -388,7 +388,7 @@ AIDecideEvolution: ; 15f4c (5:5f4c)  ; determine AI score for evolving  ; Charmeleon, Magikarp, Dragonair and Grimer  ; in certain decks -AIDecideSpecialEvolutions: ; 16120 (5:6120) +AIDecideSpecialEvolutions:  ; check if deck applies  	ld a, [wOpponentDeckID]  	cp LEGENDARY_DRAGONITE_DECK_ID @@ -525,7 +525,7 @@ AIDecideSpecialEvolutions: ; 16120 (5:6120)  ; determine AI score for the legendary cards  ; Moltres, Zapdos and Articuno -AIDecidePlayLegendaryBirds: ; 161d5 (5:61d5) +AIDecidePlayLegendaryBirds:  ; check if deck applies  	ld a, [wOpponentDeckID]  	cp LEGENDARY_ZAPDOS_DECK_ID diff --git a/src/engine/duel/ai/init.asm b/src/engine/duel/ai/init.asm index 33132cf..b4a14bd 100644 --- a/src/engine/duel/ai/init.asm +++ b/src/engine/duel/ai/init.asm @@ -1,4 +1,4 @@ -InitAIDuelVars: ; 15636 (5:5636) +InitAIDuelVars:  	ld a, wAIDuelVarsEnd - wAIDuelVars  	ld hl, wAIDuelVars  	call ClearMemory_Bank5 @@ -11,7 +11,7 @@ InitAIDuelVars: ; 15636 (5:5636)  ; initializes some variables and sets value of wAIBarrierFlagCounter.  ; if Player uses Barrier 3 times in a row, AI checks if Player's deck  ; has only Mewtwo1 Pokemon cards (running a Mewtwo1 mill deck). -InitAITurnVars: ; 15649 (5:5649) +InitAITurnVars:  ; increase Pokedex counter by 1  	ld a, [wAIPokedexCounter]  	inc a diff --git a/src/engine/duel/ai/pkmn_powers.asm b/src/engine/duel/ai/pkmn_powers.asm index 8ae629a..76135f1 100644 --- a/src/engine/duel/ai/pkmn_powers.asm +++ b/src/engine/duel/ai/pkmn_powers.asm @@ -6,7 +6,7 @@  ;	Arena Pokemon for it to be able to use its second attack;  ;	- AI_ENERGY_TRANS_TO_BENCH: transfers all Grass Energy cards from  ;	Arena Pokemon to Bench in case Arena card will be KO'd. -HandleAIEnergyTrans: ; 2219b (8:619b) +HandleAIEnergyTrans:  	ld [wce06], a  ; choose to randomly return @@ -266,7 +266,7 @@ HandleAIEnergyTrans: ; 2219b (8:619b)  ; AI logic to determine whether to use Energy Trans Pkmn Power  ; to transfer energy cards attached from the Arena Pokemon to  ; some card in the Bench. -AIEnergyTransTransferEnergyToBench: ; 222ca (8:62ca) +AIEnergyTransTransferEnergyToBench:  	xor a ; PLAY_AREA_ARENA  	ldh [hTempPlayAreaLocation_ff9d], a  	farcall CheckIfDefendingPokemonCanKnockOut @@ -409,7 +409,7 @@ AIEnergyTransTransferEnergyToBench: ; 222ca (8:62ca)  ;	- Strange Behavior;  ;	- Curse.  ; returns carry if turn ended. -HandleAIPkmnPowers: ; 2237f (8:637f) +HandleAIPkmnPowers:  	ld a, MUK  	call CountPokemonIDInBothPlayAreas  	ccf @@ -506,7 +506,7 @@ HandleAIPkmnPowers: ; 2237f (8:637f)  ; checks whether AI uses Heal on Pokemon in Play Area.  ; input:  ;	c = Play Area location (PLAY_AREA_*) of Vileplume. -HandleAIHeal: ; 22402 (8:6402) +HandleAIHeal:  	ld a, c  	ldh [hTemp_ffa0], a  	call .CheckHealTarget @@ -611,7 +611,7 @@ HandleAIHeal: ; 22402 (8:6402)  ; checks whether AI uses Shift.  ; input:  ;	c = Play Area location (PLAY_AREA_*) of Venomoth -HandleAIShift: ; 22476 (8:6476) +HandleAIShift:  	ld a, c  	or a  	ret nz ; return if Venomoth is not Arena card @@ -700,7 +700,7 @@ HandleAIShift: ; 22476 (8:6476)  ; checks whether AI uses Peek.  ; input:  ;	c = Play Area location (PLAY_AREA_*) of Mankey. -HandleAIPeek: ; 224e6 (8:64e6) +HandleAIPeek:  	ld a, c  	ldh [hTemp_ffa0], a  	ld a, 50 @@ -783,7 +783,7 @@ HandleAIPeek: ; 224e6 (8:64e6)  ; checks whether AI uses Strange Behavior.  ; input:  ;	c = Play Area location (PLAY_AREA_*) of Slowbro. -HandleAIStrangeBehavior: ; 2255d (8:655d) +HandleAIStrangeBehavior:  	ld a, c  	or a  	ret z ; return if Slowbro is Arena card @@ -849,7 +849,7 @@ HandleAIStrangeBehavior: ; 2255d (8:655d)  ; checks whether AI uses Curse.  ; input:  ;	c = Play Area location (PLAY_AREA_*) of Gengar. -HandleAICurse: ; 225b5 (8:65b5) +HandleAICurse:  	ld a, c  	ldh [hTemp_ffa0], a @@ -950,7 +950,7 @@ HandleAICurse: ; 225b5 (8:65b5)  	ret  ; handles AI logic for Cowardice -HandleAICowardice: ; 2262d (8:662d) +HandleAICowardice:  	ld a, MUK  	call CountPokemonIDInBothPlayAreas  	ret c ; return if there's Muk in play @@ -1039,7 +1039,7 @@ HandleAICowardice: ; 2262d (8:662d)  ; AI logic for Damage Swap to transfer damage from Arena card  ; to a card in Bench with more than 10 HP remaining  ; and with no energy cards attached. -HandleAIDamageSwap: ; 226a3 (8:66a3) +HandleAIDamageSwap:  	ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA  	call GetTurnDuelistVariable  	dec a @@ -1209,7 +1209,7 @@ HandleAIDamageSwap: ; 226a3 (8:66a3)  ; handles AI logic for attaching energy cards  ; in Go Go Rain Dance deck. -HandleAIGoGoRainDanceEnergy: ; 22790 (8:6790) +HandleAIGoGoRainDanceEnergy:  	ld a, [wOpponentDeckID]  	cp GO_GO_RAIN_DANCE_DECK_ID  	ret nz ; return if not Go Go Rain Dance deck diff --git a/src/engine/duel/ai/retreat.asm b/src/engine/duel/ai/retreat.asm index 768a48b..b7decbe 100644 --- a/src/engine/duel/ai/retreat.asm +++ b/src/engine/duel/ai/retreat.asm @@ -1,6 +1,6 @@  ; determine AI score for retreating  ; return carry if AI decides to retreat -AIDecideWhetherToRetreat: ; 158b2 (5:58b2) +AIDecideWhetherToRetreat:  	ld a, [wGotHeadsFromConfusionCheckDuringRetreat]  	or a  	jp nz, .no_carry @@ -9,12 +9,13 @@ AIDecideWhetherToRetreat: ; 158b2 (5:58b2)  	call LoadDefendingPokemonColorWRAndPrizeCards  	ld a, $80 ; initial retreat score  	ld [wAIScore], a -	ld a, [wcdb4] +	ld a, [wAIRetreatScore]  	or a  	jr z, .check_status +	; add wAIRetreatScore * 8 to score  	srl a  	srl a -	sla a +	sla a ; *8  	call AddToAIScore  .check_status @@ -436,7 +437,7 @@ AIDecideWhetherToRetreat: ; 158b2 (5:58b2)  ; if player's turn and loaded attack is not a Pokémon Power OR  ; if opponent's turn and wAITriedAttack == 0  ; set wcdda's bit 7 flag -Func_15b54: ; 15b54 (5:5b54) +Func_15b54:  	xor a  	ld [wcdda], a  	ld a, [wWhoseTurn] @@ -463,7 +464,7 @@ Func_15b54: ; 15b54 (5:5b54)  ; returns in a and [hTempPlayAreaLocation_ff9d] the  ; Play Area location of best card to switch to.  ; returns carry if no Bench Pokemon. -AIDecideBenchPokemonToSwitchTo: ; 15b72 (5:5b72) +AIDecideBenchPokemonToSwitchTo:  	xor a  	ldh [hTempPlayAreaLocation_ff9d], a  	ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA @@ -759,7 +760,7 @@ AIDecideBenchPokemonToSwitchTo: ; 15b72 (5:5b72)  ; done  	xor a -	ld [wcdb4], a +	ld [wAIRetreatScore], a  	jp FindHighestBenchScore  ; handles AI action of retreating Arena Pokémon @@ -769,7 +770,7 @@ AIDecideBenchPokemonToSwitchTo: ; 15b72 (5:5b72)  ; handle its effect to discard itself instead of retreating.  ; input:  ;	- a = Play Area location (PLAY_AREA_*) of card to retreat to. -AITryToRetreat: ; 15d4f (5:5d4f) +AITryToRetreat:  	push af  	ld a, [wAIPlayEnergyCardForRetreat]  	or a diff --git a/src/engine/duel/ai/special_attacks.asm b/src/engine/duel/ai/special_attacks.asm index 770324e..5491bdc 100644 --- a/src/engine/duel/ai/special_attacks.asm +++ b/src/engine/duel/ai/special_attacks.asm @@ -4,7 +4,7 @@  ; or a negative score (value below $80).  ; input:  ;	hTempPlayAreaLocation_ff9d = location of card with attack. -HandleSpecialAIAttacks: ; 16dcd (5:6dcd) +HandleSpecialAIAttacks:  	ldh a, [hTempPlayAreaLocation_ff9d]  	add DUELVARS_ARENA_CARD  	call GetTurnDuelistVariable @@ -61,7 +61,7 @@ HandleSpecialAIAttacks: ; 16dcd (5:6dcd)  ; if any of card ID in a is found in deck,  ; return a score of $80 + slots available in bench. -.CallForFamily: ; 16e3e (5:6e3e) +.CallForFamily:  	ld a, CARD_LOCATION_DECK  	call CheckIfAnyCardIDinLocation  	jr nc, .zero_score @@ -77,7 +77,7 @@ HandleSpecialAIAttacks: ; 16dcd (5:6dcd)  ; if any of NidoranM or NidoranF is found in deck,  ; return a score of $80 + slots available in bench. -.NidoranFCallForFamily: ; 16e55 (5:6e55) +.NidoranFCallForFamily:  	ld e, NIDORANM  	ld a, CARD_LOCATION_DECK  	call CheckIfAnyCardIDinLocation @@ -100,7 +100,7 @@ HandleSpecialAIAttacks: ; 16dcd (5:6dcd)  ; checks for certain card IDs of Fighting color in deck.  ; if any of them are found, return a score of  ; $80 + slots available in bench. -.CallForFriend: ; 16e77 (5:6e77) +.CallForFriend:  	ld e, GEODUDE  	ld a, CARD_LOCATION_DECK  	call CheckIfAnyCardIDinLocation @@ -131,7 +131,7 @@ HandleSpecialAIAttacks: ; 16dcd (5:6dcd)  ; if any basic cards are found in deck,  ; return a score of $80 + slots available in bench. -.FriendshipSong: ; 16ead (5:6ead) +.FriendshipSong:  	call CheckIfAnyBasicPokemonInDeck  	jr nc, .zero_score  	ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA @@ -145,7 +145,7 @@ HandleSpecialAIAttacks: ; 16dcd (5:6dcd)  	ret  ; if AI decides to retreat, return a score of $80 + 10. -.Teleport: ; 16ec2 (5:6ec2) +.Teleport:  	call AIDecideWhetherToRetreat  	jp nc, .zero_score  	ld a, $8a @@ -156,7 +156,7 @@ HandleSpecialAIAttacks: ; 16dcd (5:6dcd)  ; - second attack is unusable;  ; - second attack deals no damage;  ; if any are true, returns score of $80 + 5. -.SwordsDanceAndFocusEnergy: ; 16ecb (5:6ecb) +.SwordsDanceAndFocusEnergy:  	ld a, [wAICannotDamage]  	or a  	jr nz, .swords_dance_focus_energy_success @@ -177,7 +177,7 @@ HandleSpecialAIAttacks: ; 16dcd (5:6dcd)  ; loops through bench looking for a Pokémon  ; with that same color.  ; if none are found, returns score of $80 + 2. -.ChainLightning: ; 16eea (5:6eea) +.ChainLightning:  	call SwapTurn  	call GetArenaCardColor  	call SwapTurn @@ -199,7 +199,7 @@ HandleSpecialAIAttacks: ; 16dcd (5:6dcd)  	ld a, $82  	ret -.DevolutionBeam: ; 16f0f (5:6f0f) +.DevolutionBeam:  	call LookForCardThatIsKnockedOutOnDevolution  	jp nc, .zero_score  	ld a, $85 @@ -211,7 +211,7 @@ HandleSpecialAIAttacks: ; 16dcd (5:6dcd)  ; - if that number is >= 2 and this attack is Conversion 2  ; then return score of $80 + 2.  ; otherwise return score of $80 + 1. -.Conversion: ; 16f18 (5:6f18) +.Conversion:  	ld a, DUELVARS_ARENA_CARD_STATUS  	call GetTurnDuelistVariable  	and CNF_SLP_PRZ @@ -242,7 +242,7 @@ HandleSpecialAIAttacks: ; 16dcd (5:6dcd)  ; if any Psychic Energy is found in the Discard Pile,  ; return a score of $80 + 2. -.EnergyAbsorption: ; 16f41 (5:6f41) +.EnergyAbsorption:  	ld e, PSYCHIC_ENERGY  	ld a, CARD_LOCATION_DISCARD_PILE  	call CheckIfAnyCardIDinLocation @@ -259,7 +259,7 @@ HandleSpecialAIAttacks: ; 16dcd (5:6dcd)  ; otherwise, if it finds an evolution card in hand that  ; can evolve a card in player's deck, encourage.  ; if encouraged, returns a score of $80 + 3. -.MixUp: ; 16f4e (5:6f4e) +.MixUp:  	ld a, DUELVARS_NUMBER_OF_CARDS_IN_HAND  	call GetNonTurnDuelistVariable  	or a @@ -326,13 +326,13 @@ HandleSpecialAIAttacks: ; 16dcd (5:6dcd)  	ret  ; return score of $80 + 3. -.BigThunder: ; 16fb8 (5:6fb8) +.BigThunder:  	ld a, $83  	ret  ; dismiss attack if cards in deck <= 20.  ; otherwise return a score of $80 + 0. -.Fetch: ; 16fbb (5:6fbb) +.Fetch:  	ld a, DUELVARS_NUMBER_OF_CARDS_NOT_IN_DECK  	call GetTurnDuelistVariable  	cp 41 @@ -343,7 +343,7 @@ HandleSpecialAIAttacks: ; 16dcd (5:6dcd)  ; dismiss attack if number of own benched cards which would  ; be KOd is greater than or equal to the number  ; of prize cards left for player. -.Earthquake: ; 16fc8 (5:6fc8) +.Earthquake:  	ld a, DUELVARS_BENCH  	call GetTurnDuelistVariable @@ -373,7 +373,7 @@ HandleSpecialAIAttacks: ; 16dcd (5:6dcd)  ; if there's any lightning energy cards in deck,  ; return a score of $80 + 3. -.EnergySpike: ; 16ff2 (5:6ff2) +.EnergySpike:  	ld a, CARD_LOCATION_DECK  	ld e, LIGHTNING_ENERGY  	call CheckIfAnyCardIDinLocation @@ -386,7 +386,7 @@ HandleSpecialAIAttacks: ; 16dcd (5:6dcd)  ; only incentivize attack if player's active card,  ; has any energy cards attached, and if so,  ; return a score of $80 + 3. -.HyperBeam: ; 17005 (5:7005) +.HyperBeam:  	call SwapTurn  	ld e, PLAY_AREA_ARENA  	call CountNumberOfEnergyCardsAttached @@ -402,7 +402,7 @@ HandleSpecialAIAttacks: ; 16dcd (5:6dcd)  ; called when second attack is determined by AI to have  ; more AI score than the first attack, so that it checks  ; whether the first attack is a better alternative. -CheckWhetherToSwitchToFirstAttack: ; 17019 (5:7019) +CheckWhetherToSwitchToFirstAttack:  ; this checks whether the first attack is also viable  ; (has more than minimum score to be used)  	ld a, [wFirstAttackAIScore] @@ -451,7 +451,7 @@ CheckWhetherToSwitchToFirstAttack: ; 17019 (5:7019)  ; returns carry if there are  ; any basic Pokémon cards in deck. -CheckIfAnyBasicPokemonInDeck: ; 17057 (5:7057) +CheckIfAnyBasicPokemonInDeck:  	ld e, 0  .loop  	ld a, DUELVARS_CARD_LOCATIONS diff --git a/src/engine/duel/ai/trainer_cards.asm b/src/engine/duel/ai/trainer_cards.asm index 4bee001..ce7e69e 100644 --- a/src/engine/duel/ai/trainer_cards.asm +++ b/src/engine/duel/ai/trainer_cards.asm @@ -1,6 +1,6 @@  INCLUDE "data/duel/ai_trainer_card_logic.asm" -_AIProcessHandTrainerCards: ; 200e5 (8:40e5) +_AIProcessHandTrainerCards:  	ld [wAITrainerCardPhase], a  ; create hand list in wDuelTempList and wTempHandCardList.  	call CreateHandCardList @@ -150,7 +150,7 @@ _AIProcessHandTrainerCards: ; 200e5 (8:40e5)  	jp .loop_hand  ; makes AI use Potion card. -AIPlay_Potion: ; 201b5 (8:41b5) +AIPlay_Potion:  	ld a, [wAITrainerCardToPlay]  	ldh [hTempCardIndex_ff9f], a  	ld a, [wAITrainerCardParameter] @@ -171,7 +171,7 @@ AIPlay_Potion: ; 201b5 (8:41b5)  ; next turn after using Potion.  ; if it cannot, return carry.  ; also take into account whether attack is high recoil. -AIDecide_Potion1: ; 201d1 (8:41d1) +AIDecide_Potion1:  	farcall AIDecideWhetherToRetreat  	jr c, .no_carry  	call AICheckIfAttackIsHighRecoil @@ -213,7 +213,7 @@ AIDecide_Potion1: ; 201d1 (8:41d1)  ; output:  ;	a = card to use Potion on;  ;	carry set if Potion should be used. -AIDecide_Potion2: ; 20204 (8:4204) +AIDecide_Potion2:  	xor a  	ldh [hTempPlayAreaLocation_ff9d], a  	farcall CheckIfDefendingPokemonCanKnockOut @@ -310,7 +310,7 @@ AIDecide_Potion2: ; 20204 (8:4204)  ; return carry if either of the attacks are usable  ; and have the BOOST_IF_TAKEN_DAMAGE effect. -.check_boost_if_taken_damage ; 2027e (8:427e) +.check_boost_if_taken_damage  	push de  	xor a ; FIRST_ATTACK_OR_PKMN_POWER  	ld [wSelectedAttack], a @@ -337,7 +337,7 @@ AIDecide_Potion2: ; 20204 (8:4204)  	ret  ; makes AI use Super Potion card. -AIPlay_SuperPotion: ; 202a8 (8:42a8) +AIPlay_SuperPotion:  	ld a, [wAITrainerCardToPlay]  	ldh [hTempCardIndex_ff9f], a  	ld a, [wAITrainerCardParameter] @@ -361,7 +361,7 @@ AIPlay_SuperPotion: ; 202a8 (8:42a8)  ; active card next turn after using Super Potion.  ; if it cannot, return carry.  ; also take into account whether attack is high recoil. -AIDecide_SuperPotion1: ; 202cc (8:42cc) +AIDecide_SuperPotion1:  	farcall AIDecideWhetherToRetreat  	jr c, .no_carry  	call AICheckIfAttackIsHighRecoil @@ -401,7 +401,7 @@ AIDecide_SuperPotion1: ; 202cc (8:42cc)  	ret  ; returns carry if card has energies attached. -.check_attached_energy ; 20305 (8:4305) +.check_attached_energy  	call GetPlayAreaCardAttachedEnergies  	ld a, [wTotalAttachedEnergies]  	or a @@ -413,7 +413,7 @@ AIDecide_SuperPotion1: ; 202cc (8:42cc)  ; output:  ;	a = card to use Super Potion on;  ;	carry set if Super Potion should be used. -AIDecide_SuperPotion2: ; 2030f (8:430f) +AIDecide_SuperPotion2:  	xor a  	ldh [hTempPlayAreaLocation_ff9d], a  	farcall CheckIfDefendingPokemonCanKnockOut @@ -516,7 +516,7 @@ AIDecide_SuperPotion2: ; 2030f (8:430f)  	ret  ; returns carry if card has energies attached. -.check_attached_energy ; 20394 (8:4394) +.check_attached_energy  	call GetPlayAreaCardAttachedEnergies  	ld a, [wTotalAttachedEnergies]  	or a @@ -526,7 +526,7 @@ AIDecide_SuperPotion2: ; 2030f (8:430f)  ; return carry if either of the attacks are usable  ; and have the BOOST_IF_TAKEN_DAMAGE effect. -.check_boost_if_taken_damage ; 2039e (8:439e) +.check_boost_if_taken_damage  	push de  	xor a ; FIRST_ATTACK_OR_PKMN_POWER  	ld [wSelectedAttack], a @@ -554,7 +554,7 @@ AIDecide_SuperPotion2: ; 2030f (8:430f)  ; returns carry if discarding energy card renders any attack unusable,  ; given that they have enough energy to be used before discarding. -.check_energy_cost ; 203c8 (8:43c8) +.check_energy_cost  	push de  	xor a ; FIRST_ATTACK_OR_PKMN_POWER  	ld [wSelectedAttack], a @@ -586,7 +586,7 @@ AIDecide_SuperPotion2: ; 2030f (8:430f)  	scf  	ret -AIPlay_Defender: ; 203f8 (8:43f8) +AIPlay_Defender:  	ld a, [wAITrainerCardToPlay]  	ldh [hTempCardIndex_ff9f], a  	xor a @@ -598,7 +598,7 @@ AIPlay_Defender: ; 203f8 (8:43f8)  ; returns carry if using Defender can prevent a KO  ; by the defending Pokémon.  ; this takes into account both attacks and whether they're useable. -AIDecide_Defender1: ; 20406 (8:4406) +AIDecide_Defender1:  	xor a ; PLAY_AREA_ARENA  	ldh [hTempPlayAreaLocation_ff9d], a  	farcall CheckIfAnyAttackKnocksOutDefendingCard @@ -682,7 +682,7 @@ AIDecide_Defender1: ; 20406 (8:4406)  ; return carry if using Defender prevents Pokémon  ; from being knocked out by an attack with recoil. -AIDecide_Defender2: ; 20486 (8:4486) +AIDecide_Defender2:  	ld a, ATTACK_FLAG1_ADDRESS | HIGH_RECOIL_F  	call CheckLoadedAttackFlag  	jr c, .recoil @@ -754,7 +754,7 @@ AIDecide_Defender2: ; 20486 (8:4486)  	or a  	ret -AIPlay_Pluspower: ; 204e8 (8:44e8) +AIPlay_Pluspower:  	ld a, [wCurrentAIFlags]  	or AI_FLAG_USED_PLUSPOWER  	ld [wCurrentAIFlags], a @@ -769,7 +769,7 @@ AIPlay_Pluspower: ; 204e8 (8:44e8)  ; returns carry if using a Pluspower can KO defending Pokémon  ; if active card cannot KO without the boost.  ; outputs in a the attack to use. -AIDecide_Pluspower1: ; 20501 (8:4501) +AIDecide_Pluspower1:  ; this is mistakenly duplicated  	xor a  	ldh [hTempPlayAreaLocation_ff9d], a @@ -842,7 +842,7 @@ AIDecide_Pluspower1: ; 20501 (8:4501)  ; return carry if attack is useable and KOs  ; defending Pokémon with Pluspower boost. -.check_ko_with_pluspower ; 20562 (8:4562) +.check_ko_with_pluspower  	farcall CheckIfSelectedAttackIsUnusable  	jr c, .unusable  	ld a, [wSelectedAttack] @@ -869,7 +869,7 @@ AIDecide_Pluspower1: ; 20501 (8:4501)  ; returns carry if Pluspower boost does  ; not exceed 30 damage when facing Mr. Mime. -.check_mr_mime ; 20589 (8:4589) +.check_mr_mime  	ld a, [wDamage]  	add 10 ; add Pluspower boost  	cp 30 ; no danger in preventing damage @@ -891,7 +891,7 @@ AIDecide_Pluspower1: ; 20501 (8:4501)  ; can damage Mr. Mime even with Pluspower boost  ; and has a minimum damage > 0.  ; outputs in a the attack to use. -AIDecide_Pluspower2: ; 205a5 (8:45a5) +AIDecide_Pluspower2:  	xor a  	ldh [hTempPlayAreaLocation_ff9d], a  	call .check_can_ko @@ -908,7 +908,7 @@ AIDecide_Pluspower2: ; 205a5 (8:45a5)  ; returns carry if Pluspower boost does  ; not exceed 30 damage when facing Mr. Mime. -.check_mr_mime ; 205bb (8:45bb) +.check_mr_mime  	ld a, [wDamage]  	add 10 ; add Pluspower boost  	cp 30 ; no danger in preventing damage @@ -926,7 +926,7 @@ AIDecide_Pluspower2: ; 205a5 (8:45a5)  	ret  ; return carry if attack is useable but cannot KO. -.check_can_ko ; 205d7 (8:45d7) +.check_can_ko  	farcall CheckIfSelectedAttackIsUnusable  	jr c, .unusable  	ld a, [wSelectedAttack] @@ -947,7 +947,7 @@ AIDecide_Pluspower2: ; 205a5 (8:45a5)  ; return carry 7/10 of the time if  ; attack is useable and minimum damage > 0. -.check_random ; 205f6 (8:45f6) +.check_random  	farcall CheckIfSelectedAttackIsUnusable  	jr c, .unusable  	ld a, [wSelectedAttack] @@ -960,7 +960,7 @@ AIDecide_Pluspower2: ; 205a5 (8:45a5)  	cp 3  	ret -AIPlay_Switch: ; 20612 (8:4612) +AIPlay_Switch:  	ld a, [wCurrentAIFlags]  	or AI_FLAG_USED_SWITCH  	ld [wCurrentAIFlags], a @@ -971,13 +971,13 @@ AIPlay_Switch: ; 20612 (8:4612)  	ld a, OPPACTION_EXECUTE_TRAINER_EFFECTS  	bank1call AIMakeDecision  	xor a -	ld [wcdb4], a +	ld [wAIRetreatScore], a  	ret  ; returns carry if the active card has less energy cards  ; than the retreat cost and if AI can't play an energy  ; card from the hand to fulfill the cost -AIDecide_Switch: ; 2062e (8:462e) +AIDecide_Switch:  ; check if AI can already play an energy card from hand to retreat  	ld a, [wAIPlayEnergyCardForRetreat]  	or a @@ -1023,7 +1023,7 @@ AIDecide_Switch: ; 2062e (8:462e)  	ccf  	ret -AIPlay_GustOfWind: ; 20666 (8:4666) +AIPlay_GustOfWind:  	ld a, [wCurrentAIFlags]  	or AI_FLAG_USED_GUST_OF_WIND  	ld [wCurrentAIFlags], a @@ -1035,7 +1035,7 @@ AIPlay_GustOfWind: ; 20666 (8:4666)  	bank1call AIMakeDecision  	ret -AIDecide_GustOfWind: ; 2067e (8:467e) +AIDecide_GustOfWind:  	ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA  	call GetNonTurnDuelistVariable  	dec a @@ -1187,7 +1187,7 @@ AIDecide_GustOfWind: ; 2067e (8:467e)  ; returns carry if any of the player's  ; benched cards is weak to color in b  ; and has a way to damage it -.FindBenchCardWithWeakness ; 2074d (8:474d) +.FindBenchCardWithWeakness  	ld a, DUELVARS_BENCH  	call GetNonTurnDuelistVariable  	ld c, PLAY_AREA_ARENA @@ -1205,7 +1205,7 @@ AIDecide_GustOfWind: ; 2067e (8:467e)  	jr .loop_3  ; returns carry if neither attack can deal damage -.CheckIfNoAttackDealsDamage ; 2076b (8:476b) +.CheckIfNoAttackDealsDamage  	xor a ; FIRST_ATTACK_OR_PKMN_POWER  	ld [wSelectedAttack], a  	call .CheckIfAttackDealsNoDamage @@ -1223,7 +1223,7 @@ AIDecide_GustOfWind: ; 2067e (8:467e)  ; returns carry if attack is Pokemon Power  ; or otherwise doesn't deal any damage -.CheckIfAttackDealsNoDamage ; 20782 (8:4782) +.CheckIfAttackDealsNoDamage  	ld a, [wSelectedAttack]  	ld e, a  	ld a, DUELVARS_ARENA_CARD @@ -1252,7 +1252,7 @@ AIDecide_GustOfWind: ; 2067e (8:467e)  ; returns carry if there is a player's bench card that  ; the opponent's current active card can KO -.FindBenchCardToKnockOut ; 207a9 (8:47a9) +.FindBenchCardToKnockOut  	ld a, DUELVARS_BENCH  	call GetNonTurnDuelistVariable  	ld e, PLAY_AREA_BENCH_1 @@ -1323,7 +1323,7 @@ AIDecide_GustOfWind: ; 2067e (8:467e)  ; returns carry if any of arena card's attacks  ; KOs player card in location stored in e -.CheckIfAnyAttackKnocksOut ; 20806 (8:4806) +.CheckIfAnyAttackKnocksOut  	xor a ; FIRST_ATTACK_OR_PKMN_POWER  	call .CheckIfAttackKnocksOut  	ret c @@ -1348,7 +1348,7 @@ AIDecide_GustOfWind: ; 2067e (8:467e)  ; returns carry if opponent's arena card can damage  ; this benched card if it were switched with  ; the player's arena card -.CheckIfCanDamageBenchedCard ; 20821 (8:4821) +.CheckIfCanDamageBenchedCard  	push bc  	push de  	push hl @@ -1410,7 +1410,7 @@ AIDecide_GustOfWind: ; 2067e (8:467e)  	scf  	ret -AIPlay_Bill: ; 2086d (8:486d) +AIPlay_Bill:  	ld a, [wAITrainerCardToPlay]  	ldh [hTempCardIndex_ff9f], a  	ld a, OPPACTION_EXECUTE_TRAINER_EFFECTS @@ -1418,13 +1418,13 @@ AIPlay_Bill: ; 2086d (8:486d)  	ret  ; return carry if cards in deck > 9 -AIDecide_Bill: ; 20878 (8:4878) +AIDecide_Bill:  	ld a, DUELVARS_NUMBER_OF_CARDS_NOT_IN_DECK  	call GetTurnDuelistVariable  	cp DECK_SIZE - 9  	ret -AIPlay_EnergyRemoval: ; 20880 (8:4880) +AIPlay_EnergyRemoval:  	ld a, [wAITrainerCardToPlay]  	ldh [hTempCardIndex_ff9f], a  	ld a, [wAITrainerCardParameter] @@ -1436,7 +1436,7 @@ AIPlay_EnergyRemoval: ; 20880 (8:4880)  	ret  ; picks an energy card in the player's Play Area to remove -AIDecide_EnergyRemoval: ; 20895 (8:4895) +AIDecide_EnergyRemoval:  ; check if the current active card can KO player's card  ; if it's possible to KO, then do not consider the player's  ; active card to remove its attached energy @@ -1539,7 +1539,7 @@ AIDecide_EnergyRemoval: ; 20895 (8:4895)  	ret  ; returns carry if this card has any energy cards attached -.CheckIfCardHasEnergyAttached ; 2091a (8:491a) +.CheckIfCardHasEnergyAttached  	call GetPlayAreaCardAttachedEnergies  	ld a, [wTotalAttachedEnergies]  	or a @@ -1549,7 +1549,7 @@ AIDecide_EnergyRemoval: ; 20895 (8:4895)  ; returns carry if this card does not  ; have enough energy for either of its attacks -.CheckIfNotEnoughEnergyToAttack ; 20924 (8:4924) +.CheckIfNotEnoughEnergyToAttack  	push de  	xor a ; FIRST_ATTACK_OR_PKMN_POWER  	ld [wSelectedAttack], a @@ -1589,7 +1589,7 @@ AIDecide_EnergyRemoval: ; 20895 (8:4895)  ; stores in wce06 the highest damaging attack  ; for the card in play area location in e  ; and stores this card's location in wce08 -.FindHighestDamagingAttack ; 2094f (8:494f) +.FindHighestDamagingAttack  	push de  	ld a, e  	ldh [hTempPlayAreaLocation_ff9d], a @@ -1637,7 +1637,7 @@ AIDecide_EnergyRemoval: ; 20895 (8:4895)  	pop de  	ret -AIPlay_SuperEnergyRemoval: ; 20994 (8:4994) +AIPlay_SuperEnergyRemoval:  	ld a, [wAITrainerCardToPlay]  	ldh [hTempCardIndex_ff9f], a  	ld a, [wAITrainerCardParameter] @@ -1657,7 +1657,7 @@ AIPlay_SuperEnergyRemoval: ; 20994 (8:4994)  	ret  ; picks two energy cards in the player's Play Area to remove -AIDecide_SuperEnergyRemoval: ; 209bc (8:49bc) +AIDecide_SuperEnergyRemoval:  	ld e, PLAY_AREA_BENCH_1  .loop_1  ; first find an Arena card with a color energy card @@ -1807,7 +1807,7 @@ AIDecide_SuperEnergyRemoval: ; 209bc (8:49bc)  ; returns carry if the number of energy cards attached  ; is fewer than 2, or if all energy combined yields  ; fewer than 2 energy -.CheckIfFewerThanTwoEnergyCards ; 20a77 (8:4a77) +.CheckIfFewerThanTwoEnergyCards  	call GetPlayAreaCardAttachedEnergies  	ld a, [wTotalAttachedEnergies]  	cp 2 @@ -1832,7 +1832,7 @@ AIDecide_SuperEnergyRemoval: ; 209bc (8:49bc)  ; returns carry if this card does not  ; have enough energy for either of its attacks -.CheckIfNotEnoughEnergyToAttack ; 20a92 (8:4a92) +.CheckIfNotEnoughEnergyToAttack  	push de  	xor a ; FIRST_ATTACK_OR_PKMN_POWER  	ld [wSelectedAttack], a @@ -1875,7 +1875,7 @@ AIDecide_SuperEnergyRemoval: ; 209bc (8:49bc)  ; stores in wce06 the highest damaging attack  ; for the card in play area location in e  ; and stores this card's location in wce08 -.FindHighestDamagingAttack ; 20ac1 (8:4ac1) +.FindHighestDamagingAttack  	push de  	ld a, e  	ldh [hTempPlayAreaLocation_ff9d], a @@ -1923,7 +1923,7 @@ AIDecide_SuperEnergyRemoval: ; 209bc (8:49bc)  	pop de  	ret -AIPlay_PokemonBreeder: ; 20b06 (8:4b06) +AIPlay_PokemonBreeder:  	ld a, [wAITrainerCardToPlay]  	ldh [hTempCardIndex_ff9f], a  	ld a, [wAITrainerCardParameter] @@ -1934,7 +1934,7 @@ AIPlay_PokemonBreeder: ; 20b06 (8:4b06)  	bank1call AIMakeDecision  	ret -AIDecide_PokemonBreeder: ; 20b1b (8:4b1b) +AIDecide_PokemonBreeder:  	call IsPrehistoricPowerActive  	jp c, .done @@ -2197,7 +2197,7 @@ AIDecide_PokemonBreeder: ; 20b1b (8:4b1b)  ;   number of damage counters in Play Area is under 8;  ; - the card that is evolving is Arena card and has under 5  ;   damage counters or has less than 3 energy cards attached. -.HandleDragonite1Evolution ; 20c5c (8:4c5c) +.HandleDragonite1Evolution  	push af  	push bc  	push de @@ -2277,7 +2277,7 @@ AIDecide_PokemonBreeder: ; 20b1b (8:4b1b)  	scf  	ret -AIPlay_ProfessorOak: ; 20cae (8:4cae) +AIPlay_ProfessorOak:  	ld a, [wCurrentAIFlags]  	or AI_FLAG_USED_PROFESSOR_OAK | AI_FLAG_MODIFIED_HAND  	ld [wCurrentAIFlags], a @@ -2289,7 +2289,7 @@ AIPlay_ProfessorOak: ; 20cae (8:4cae)  ; sets carry if AI determines a score of playing  ; Professor Oak is over a certain threshold. -AIDecide_ProfessorOak: ; 20cc1 (8:4cc1) +AIDecide_ProfessorOak:  ; return if cards in deck <= 6  	ld a, DUELVARS_NUMBER_OF_CARDS_NOT_IN_DECK  	call GetTurnDuelistVariable @@ -2459,7 +2459,7 @@ AIDecide_ProfessorOak: ; 20cc1 (8:4cc1)  ; can evolve the card in Play Area location in e.  ; sets wce08 to $01 if any card is found that can  ; evolve regardless of card location. -.LookForEvolution ; 20d9d (8:4d9d) +.LookForEvolution  	xor a  	ld [wce08], a  	ld d, 0 @@ -2496,7 +2496,7 @@ AIDecide_ProfessorOak: ; 20cc1 (8:4cc1)  	ret  ; handles Legendary Articuno Deck AI logic. -.HandleLegendaryArticunoDeck ; 20dc3 (8:4dc3) +.HandleLegendaryArticunoDeck  	ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA  	call GetTurnDuelistVariable  	cp 3 @@ -2565,7 +2565,7 @@ AIDecide_ProfessorOak: ; 20cc1 (8:4cc1)  ; handles Excavation deck AI logic.  ; sets score depending on whether there's no  ; Mysterious Fossil in play and in hand. -.HandleExcavationDeck ; 20e11 (8:4e11) +.HandleExcavationDeck  ; return no carry if cards in deck < 15  	ld a, [hl]  	cp 46 @@ -2586,7 +2586,7 @@ AIDecide_ProfessorOak: ; 20cc1 (8:4cc1)  ; handles Wonders of Science AI logic.  ; if there's either Grimer or Muk in hand,  ; do not play Professor Oak. -.HandleWondersOfScienceDeck ; 20e2c (8:4e2c) +.HandleWondersOfScienceDeck  	ld a, GRIMER  	call LookForCardIDInHandList_Bank8  	jr c, .found_grimer_or_muk @@ -2602,7 +2602,7 @@ AIDecide_ProfessorOak: ; 20cc1 (8:4cc1)  	or a  	ret -AIPlay_EnergyRetrieval: ; 20e44 (8:4e44) +AIPlay_EnergyRetrieval:  	ld a, [wCurrentAIFlags]  	or AI_FLAG_MODIFIED_HAND  	ld [wCurrentAIFlags], a @@ -2626,7 +2626,7 @@ AIPlay_EnergyRetrieval: ; 20e44 (8:4e44)  ; checks whether AI can play Energy Retrieval and  ; picks the energy cards from the discard pile,  ; and duplicate cards in hand to discard. -AIDecide_EnergyRetrieval: ; 20e6e (8:4e6e) +AIDecide_EnergyRetrieval:  ; return no carry if no cards in hand  	farcall CreateEnergyCardListFromHand  	jp nc, .no_carry @@ -2763,7 +2763,7 @@ AIDecide_EnergyRetrieval: ; 20e6e (8:4e6e)  ; and shortens it accordingly  ; input:  ;   hl = pointer to element after the one to remove -RemoveCardFromList: ; 20f27 (8:4f27) +RemoveCardFromList:  	push de  	ld d, h  	ld e, l @@ -2791,7 +2791,7 @@ RemoveCardFromList: ; 20f27 (8:4f27)  ;   hl = list to look in  ; output:  ;   a = deck index of duplicate card -FindDuplicateCards: ; 20f38 (8:4f38) +FindDuplicateCards:  	ld a, $ff  	ld [wce0f], a  	ld [wce0f + 1], a @@ -2857,7 +2857,7 @@ FindDuplicateCards: ; 20f38 (8:4f38)  	or a  	ret -AIPlay_SuperEnergyRetrieval: ; 20f80 (8:4f80) +AIPlay_SuperEnergyRetrieval:  	ld a, [wCurrentAIFlags]  	or AI_FLAG_MODIFIED_HAND  	ld [wCurrentAIFlags], a @@ -2888,7 +2888,7 @@ AIPlay_SuperEnergyRetrieval: ; 20f80 (8:4f80)  	bank1call AIMakeDecision  	ret -AIDecide_SuperEnergyRetrieval: ; 20fc1 (8:4fc1) +AIDecide_SuperEnergyRetrieval:  ; return no carry if no cards in hand  	farcall CreateEnergyCardListFromHand  	jp nc, .no_carry @@ -3075,7 +3075,7 @@ AIDecide_SuperEnergyRetrieval: ; 20fc1 (8:4fc1)  ; input:  ;   a  = card deck index to look  ;   hl = pointer to list of cards -FindAndRemoveCardFromList: ; 210d5 (8:50d5) +FindAndRemoveCardFromList:  	push hl  	ld b, a  .loop_duplicate @@ -3086,14 +3086,14 @@ FindAndRemoveCardFromList: ; 210d5 (8:50d5)  	pop hl  	ret -AIPlay_PokemonCenter: ; 210e0 (8:50e0) +AIPlay_PokemonCenter:  	ld a, [wAITrainerCardToPlay]  	ldh [hTempCardIndex_ff9f], a  	ld a, OPPACTION_EXECUTE_TRAINER_EFFECTS  	bank1call AIMakeDecision  	ret -AIDecide_PokemonCenter: ; 210eb (8:50eb) +AIDecide_PokemonCenter:  	xor a  	ldh [hTempPlayAreaLocation_ff9d], a @@ -3185,7 +3185,7 @@ AIDecide_PokemonCenter: ; 210eb (8:50eb)  	or a  	ret -AIPlay_ImposterProfessorOak: ; 21170 (8:5170) +AIPlay_ImposterProfessorOak:  	ld a, [wAITrainerCardToPlay]  	ldh [hTempCardIndex_ff9f], a  	ld a, OPPACTION_EXECUTE_TRAINER_EFFECTS @@ -3194,7 +3194,7 @@ AIPlay_ImposterProfessorOak: ; 21170 (8:5170)  ; sets carry depending on player's number of cards  ; in deck in in hand. -AIDecide_ImposterProfessorOak: ; 2117b (8:517b) +AIDecide_ImposterProfessorOak:  	ld a, DUELVARS_NUMBER_OF_CARDS_NOT_IN_DECK  	call GetNonTurnDuelistVariable  	cp DECK_SIZE - 14 @@ -3221,7 +3221,7 @@ AIDecide_ImposterProfessorOak: ; 2117b (8:517b)  	scf  	ret -AIPlay_EnergySearch: ; 2119a (8:519a) +AIPlay_EnergySearch:  	ld a, [wAITrainerCardToPlay]  	ldh [hTempCardIndex_ff9f], a  	ld a, [wAITrainerCardParameter] @@ -3231,7 +3231,7 @@ AIPlay_EnergySearch: ; 2119a (8:519a)  	ret  ; AI checks for playing Energy Search -AIDecide_EnergySearch: ; 211aa (8:51aa) +AIDecide_EnergySearch:  	farcall CreateEnergyCardListFromHand  	jr c, .start  	call .CheckForUsefulEnergyCards @@ -3293,7 +3293,7 @@ AIDecide_EnergySearch: ; 211aa (8:51aa)  ; return carry if cards in wDuelTempList are not  ; useful to any of the Play Area Pokemon -.CheckForUsefulEnergyCards ; 211f1 (8:51f1) +.CheckForUsefulEnergyCards  	ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA  	call GetTurnDuelistVariable  	ld d, a @@ -3344,7 +3344,7 @@ AIDecide_EnergySearch: ; 211aa (8:51aa)  ; checks whether there are useful energies  ; only for Fire and Lightning type Pokemon cards  ; in Play Area. If none found, return carry. -.CheckUsefulFireOrLightningEnergy ; 2122e (8:522e) +.CheckUsefulFireOrLightningEnergy  	ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA  	call GetTurnDuelistVariable  	ld d, a @@ -3407,7 +3407,7 @@ AIDecide_EnergySearch: ; 211aa (8:51aa)  ; checks whether there are useful energies  ; only for Grass type Pokemon cards  ; in Play Area. If none found, return carry. -.CheckUsefulGrassEnergy ; 21273 (8:5273) +.CheckUsefulGrassEnergy  ; unreferenced  	ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA  	call GetTurnDuelistVariable @@ -3464,7 +3464,7 @@ AIDecide_EnergySearch: ; 211aa (8:51aa)  	scf  	ret -AIPlay_Pokedex: ; 212b4 (8:52b4) +AIPlay_Pokedex:  	ld a, [wAITrainerCardToPlay]  	ldh [hTempCardIndex_ff9f], a  	ld a, [wce1a] @@ -3483,7 +3483,7 @@ AIPlay_Pokedex: ; 212b4 (8:52b4)  	bank1call AIMakeDecision  	ret -AIDecide_Pokedex: ; 212dc (8:52dc) +AIDecide_Pokedex:  	ld a, [wAIPokedexCounter]  	cp 5 + 1  	jr c, .no_carry ; return if counter hasn't reached 6 yet @@ -3515,7 +3515,7 @@ AIDecide_Pokedex: ; 212dc (8:52dc)  ; picks order of the cards in deck from the effects of Pokedex.  ; prioritizes Pokemon cards, then Trainer cards, then energy cards.  ; stores the resulting order in wce1a. -PickPokedexCards_Unreferenced: ; 212ff (8:52ff) +PickPokedexCards_Unreferenced:  ; unreferenced  	xor a  	ld [wAIPokedexCounter], a ; reset counter @@ -3634,7 +3634,7 @@ PickPokedexCards_Unreferenced: ; 212ff (8:52ff)  	scf  	ret -.GetCardType ; 21383 (8:5383) +.GetCardType  	push bc  	push de  	call GetCardIDFromDeckIndex @@ -3646,7 +3646,7 @@ PickPokedexCards_Unreferenced: ; 212ff (8:52ff)  ; picks order of the cards in deck from the effects of Pokedex.  ; prioritizes energy cards, then Pokemon cards, then Trainer cards.  ; stores the resulting order in wce1a. -PickPokedexCards: ; 2138e (8:538e) +PickPokedexCards:  	xor a  	ld [wAIPokedexCounter], a ; reset counter ; reset counter @@ -3764,7 +3764,7 @@ PickPokedexCards: ; 2138e (8:538e)  	scf  	ret -.GetCardType ; 21412 (8:5412) +.GetCardType  	push bc  	push de  	call GetCardIDFromDeckIndex @@ -3773,14 +3773,14 @@ PickPokedexCards: ; 2138e (8:538e)  	pop bc  	ret -AIPlay_FullHeal: ; 2141d (8:541d) +AIPlay_FullHeal:  	ld a, [wAITrainerCardToPlay]  	ldh [hTempCardIndex_ff9f], a  	ld a, OPPACTION_EXECUTE_TRAINER_EFFECTS  	bank1call AIMakeDecision  	ret -AIDecide_FullHeal: ; 21428 (8:5428) +AIDecide_FullHeal:  	ld a, DUELVARS_ARENA_CARD_STATUS  	call GetTurnDuelistVariable @@ -3866,7 +3866,7 @@ AIDecide_FullHeal: ; 21428 (8:5428)  ; if not, return no carry.  	jr .no_carry -AIPlay_MrFuji: ; 21497 (8:5497) +AIPlay_MrFuji:  	ld a, [wAITrainerCardToPlay]  	ldh [hTempCardIndex_ff9f], a  	ld a, [wAITrainerCardParameter] @@ -3876,7 +3876,7 @@ AIPlay_MrFuji: ; 21497 (8:5497)  	ret  ; AI logic for playing Mr Fuji -AIDecide_MrFuji: ; 214a7 (8:54a7) +AIDecide_MrFuji:  	ld a, $ff  	ld [wce06], a  	ld [wce08], a @@ -3938,7 +3938,7 @@ AIDecide_MrFuji: ; 214a7 (8:54a7)  	scf  	ret -AIPlay_ScoopUp: ; 214f1 (8:54f1) +AIPlay_ScoopUp:  	ld a, [wAITrainerCardToPlay]  	ldh [hTempCardIndex_ff9f], a  	ld a, [wAITrainerCardParameter] @@ -3949,7 +3949,7 @@ AIPlay_ScoopUp: ; 214f1 (8:54f1)  	bank1call AIMakeDecision  	ret -AIDecide_ScoopUp: ; 21506 (8:5506) +AIDecide_ScoopUp:  	xor a  	ldh [hTempPlayAreaLocation_ff9d], a @@ -4124,7 +4124,7 @@ AIDecide_ScoopUp: ; 21506 (8:5506)  ; this deck will use Scoop Up on a benched Articuno2, Zapdos3 or Moltres2.  ; interestingly, does not check for Muk in both Play Areas. -.HandleLegendaryRonald ; 215e7 (8:55e7) +.HandleLegendaryRonald  ; if less than 3 Play Area Pokemon cards, skip.  	ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA  	call GetTurnDuelistVariable @@ -4145,7 +4145,7 @@ AIDecide_ScoopUp: ; 21506 (8:5506)  	jr c, .check_attached_energy  	jp .no_carry -AIPlay_Maintenance: ; 2160f (8:560f) +AIPlay_Maintenance:  	ld a, [wCurrentAIFlags]  	or AI_FLAG_MODIFIED_HAND  	ld [wCurrentAIFlags], a @@ -4160,7 +4160,7 @@ AIPlay_Maintenance: ; 2160f (8:560f)  	ret  ; AI logic for playing Maintenance -AIDecide_Maintenance: ; 2162c (8:562c) +AIDecide_Maintenance:  ; Imakuni? has his own thing  	ld a, [wOpponentDeckID]  	cp IMAKUNI_DECK_ID @@ -4242,7 +4242,7 @@ AIDecide_Maintenance: ; 2162c (8:562c)  	scf  	ret -AIPlay_Recycle: ; 2169a (8:569a) +AIPlay_Recycle:  	ld a, [wAITrainerCardToPlay]  	ldh [hTempCardIndex_ff9f], a  	ldtx de, TrainerCardSuccessCheckText @@ -4263,7 +4263,7 @@ AIPlay_Recycle: ; 2169a (8:569a)  ; has priorities for Ghost Deck, and a "default" priority list  ; (which is the Fire Charge deck, since it's the only other  ; deck that runs a Recycle card in it.) -AIDecide_Recycle: ; 216b8 (8:56b8) +AIDecide_Recycle:  ; no use checking if no cards in Discard Pile  	call CreateDiscardPileCardList  	jr c, .no_carry @@ -4381,7 +4381,7 @@ AIDecide_Recycle: ; 216b8 (8:56b8)  	ld [wce08 + 4], a  	jr .loop_2 -AIPlay_Lass: ; 21755 (8:5755) +AIPlay_Lass:  	ld a, [wCurrentAIFlags]  	or AI_FLAG_MODIFIED_HAND  	ld [wCurrentAIFlags], a @@ -4391,7 +4391,7 @@ AIPlay_Lass: ; 21755 (8:5755)  	bank1call AIMakeDecision  	ret -AIDecide_Lass: ; 21768 (8:5768) +AIDecide_Lass:  ; skip if player has less than 7 cards in hand  	ld a, DUELVARS_NUMBER_OF_CARDS_IN_HAND  	call GetNonTurnDuelistVariable @@ -4421,7 +4421,7 @@ AIDecide_Lass: ; 21768 (8:5768)  	scf  	ret -AIPlay_ItemFinder: ; 2178f (8:578f) +AIPlay_ItemFinder:  	ld a, [wCurrentAIFlags]  	or AI_FLAG_MODIFIED_HAND  	ld [wCurrentAIFlags], a @@ -4441,7 +4441,7 @@ AIPlay_ItemFinder: ; 2178f (8:578f)  ; if so, find duplicate cards in hand to discard  ; that are not Mr Mime and Pokemon Trader cards.  ; this logic is suitable only for Strange Psyshock deck. -AIDecide_ItemFinder: ; 217b1 (8:57b1) +AIDecide_ItemFinder:  ; skip if no Discard Pile.  	call CreateDiscardPileCardList  	jr c, .no_carry @@ -4512,7 +4512,7 @@ AIDecide_ItemFinder: ; 217b1 (8:57b1)  	or a  	ret -AIPlay_Imakuni: ; 21813 (8:5813) +AIPlay_Imakuni:  	ld a, [wAITrainerCardToPlay]  	ldh [hTempCardIndex_ff9f], a  	ld a, OPPACTION_EXECUTE_TRAINER_EFFECTS @@ -4520,7 +4520,7 @@ AIPlay_Imakuni: ; 21813 (8:5813)  	ret  ; only sets carry if Active card is not confused. -AIDecide_Imakuni: ; 2181e (8:581e) +AIDecide_Imakuni:  	ld a, DUELVARS_ARENA_CARD_STATUS  	call GetTurnDuelistVariable  	and CNF_SLP_PRZ @@ -4532,7 +4532,7 @@ AIDecide_Imakuni: ; 2181e (8:581e)  	or a  	ret -AIPlay_Gambler: ; 2182d (8:582d) +AIPlay_Gambler:  	ld a, [wCurrentAIFlags]  	or AI_FLAG_MODIFIED_HAND  	ld [wCurrentAIFlags], a @@ -4572,7 +4572,7 @@ AIPlay_Gambler: ; 2182d (8:582d)  ; checks whether to play Gambler.  ; aside from Imakuni?, all other opponents only  ; play this card if Player is running Mewtwo1-only deck. -AIDecide_Gambler: ; 21875 (8:5875) +AIDecide_Gambler:  ; Imakuni? has his own routine  	ld a, [wOpponentDeckID]  	cp IMAKUNI_DECK_ID @@ -4604,7 +4604,7 @@ AIDecide_Gambler: ; 21875 (8:5875)  	scf  	ret -AIPlay_Revive: ; 21899 (8:5899) +AIPlay_Revive:  	ld a, [wAITrainerCardToPlay]  	ldh [hTempCardIndex_ff9f], a  	ld a, [wAITrainerCardParameter] @@ -4615,7 +4615,7 @@ AIPlay_Revive: ; 21899 (8:5899)  ; checks certain cards in Discard Pile to use Revive on.  ; suitable for Muscle For Brains deck only. -AIDecide_Revive: ; 218a9 (8:58a9) +AIDecide_Revive:  ; skip if no cards in Discard Pile  	call CreateDiscardPileCardList  	jr c, .no_carry @@ -4660,7 +4660,7 @@ AIDecide_Revive: ; 218a9 (8:58a9)  	or a  	ret -AIPlay_PokemonFlute: ; 218d8 (8:58d8) +AIPlay_PokemonFlute:  	ld a, [wAITrainerCardToPlay]  	ldh [hTempCardIndex_ff9f], a  	ld a, [wAITrainerCardParameter] @@ -4669,7 +4669,7 @@ AIPlay_PokemonFlute: ; 218d8 (8:58d8)  	bank1call AIMakeDecision  	ret -AIDecide_PokemonFlute: ; 218e8 (8:58e8) +AIDecide_PokemonFlute:  ; if player has no Discard Pile, skip.  	call SwapTurn  	call CreateDiscardPileCardList @@ -4765,7 +4765,7 @@ AIDecide_PokemonFlute: ; 218e8 (8:58e8)  	scf  	ret -AIPlay_ClefairyDollOrMysteriousFossil: ; 21977 (8:5977) +AIPlay_ClefairyDollOrMysteriousFossil:  	ld a, [wAITrainerCardToPlay]  	ldh [hTempCardIndex_ff9f], a  	ld a, OPPACTION_EXECUTE_TRAINER_EFFECTS @@ -4773,7 +4773,7 @@ AIPlay_ClefairyDollOrMysteriousFossil: ; 21977 (8:5977)  	ret  ; AI logic for playing Clefairy Doll -AIDecide_ClefairyDollOrMysteriousFossil: ; 21982 (8:5982) +AIDecide_ClefairyDollOrMysteriousFossil:  ; if has max number of Play Area Pokemon, skip  	ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA  	call GetTurnDuelistVariable @@ -4803,7 +4803,7 @@ AIDecide_ClefairyDollOrMysteriousFossil: ; 21982 (8:5982)  	or a  	ret -AIPlay_Pokeball: ; 219a6 (8:59a6) +AIPlay_Pokeball:  	ld a, [wAITrainerCardToPlay]  	ldh [hTempCardIndex_ff9f], a  	ldtx de, TrainerCardSuccessCheckText @@ -4821,7 +4821,7 @@ AIPlay_Pokeball: ; 219a6 (8:59a6)  	bank1call AIMakeDecision  	ret -AIDecide_Pokeball: ; 219c6 (8:59c6) +AIDecide_Pokeball:  ; go to the routines associated with deck ID  	ld a, [wOpponentDeckID]  	cp FIRE_CHARGE_DECK_ID @@ -5022,7 +5022,7 @@ AIDecide_Pokeball: ; 219c6 (8:59c6)  	ret c  	ret -AIPlay_ComputerSearch: ; 21b12 (8:5b12) +AIPlay_ComputerSearch:  	ld a, [wCurrentAIFlags]  	or AI_FLAG_MODIFIED_HAND  	ld [wCurrentAIFlags], a @@ -5040,7 +5040,7 @@ AIPlay_ComputerSearch: ; 21b12 (8:5b12)  ; checks what Deck ID AI is playing and handle  ; them in their own routine. -AIDecide_ComputerSearch: ; 21b34 (8:5b34) +AIDecide_ComputerSearch:  ; skip if number of cards in hand < 3  	ld a, DUELVARS_NUMBER_OF_CARDS_IN_HAND  	call GetTurnDuelistVariable @@ -5061,7 +5061,7 @@ AIDecide_ComputerSearch: ; 21b34 (8:5b34)  	or a  	ret -AIDecide_ComputerSearch_RockCrusher: ; 21b55 (8:5b55) +AIDecide_ComputerSearch_RockCrusher:  ; if number of cards in hand is equal to 3,  ; target Professor Oak in deck  	ld a, DUELVARS_NUMBER_OF_CARDS_IN_HAND @@ -5239,7 +5239,7 @@ AIDecide_ComputerSearch_RockCrusher: ; 21b55 (8:5b55)  	scf  	ret -AIDecide_ComputerSearch_WondersOfScience: ; 21c56 (8:5c56) +AIDecide_ComputerSearch_WondersOfScience:  ; if number of cards in hand < 5, target Professor Oak in deck  	ld a, DUELVARS_NUMBER_OF_CARDS_IN_HAND  	call GetTurnDuelistVariable @@ -5312,7 +5312,7 @@ AIDecide_ComputerSearch_WondersOfScience: ; 21c56 (8:5c56)  	scf  	ret -AIDecide_ComputerSearch_FireCharge: ; 21cbb (8:5cbb) +AIDecide_ComputerSearch_FireCharge:  ; pick target card in deck from highest to lowest priority.  ; if not found in hand, go to corresponding branch.  	ld a, CHANSEY @@ -5377,7 +5377,7 @@ AIDecide_ComputerSearch_FireCharge: ; 21cbb (8:5cbb)  	scf  	ret -AIDecide_ComputerSearch_Anger: ; 21d1e (8:5d1e) +AIDecide_ComputerSearch_Anger:  ; for each of the following cards,  ; first run a check if there's a pre-evolution in  ; Play Area or in the hand. If there is, choose it as target. @@ -5437,7 +5437,7 @@ AIDecide_ComputerSearch_Anger: ; 21d1e (8:5d1e)  	scf  	ret -AIPlay_PokemonTrader: ; 21d7a (8:5d7a) +AIPlay_PokemonTrader:  	ld a, [wAITrainerCardToPlay]  	ldh [hTempCardIndex_ff9f], a  	ld a, [wAITrainerCardParameter] @@ -5448,7 +5448,7 @@ AIPlay_PokemonTrader: ; 21d7a (8:5d7a)  	bank1call AIMakeDecision  	ret -AIDecide_PokemonTrader: ; 21d8f (8:5d8f) +AIDecide_PokemonTrader:  ; each deck has their own routine for picking  ; what Pokemon to look for.  	ld a, [wOpponentDeckID] @@ -5475,7 +5475,7 @@ AIDecide_PokemonTrader: ; 21d8f (8:5d8f)  	or a  	ret -AIDecide_PokemonTrader_LegendaryMoltres: ; 21dc4 (8:5dc4) +AIDecide_PokemonTrader_LegendaryMoltres:  ; look for Moltres2 card in deck to trade with a  ; card in hand different from Moltres1.  	ld a, MOLTRES2 @@ -5491,7 +5491,7 @@ AIDecide_PokemonTrader_LegendaryMoltres: ; 21dc4 (8:5dc4)  	or a  	ret -AIDecide_PokemonTrader_LegendaryArticuno: ; 21dd5 (8:5dd5) +AIDecide_PokemonTrader_LegendaryArticuno:  ; if has none of these cards in Hand or Play Area, proceed  	ld a, ARTICUNO1  	call LookForCardIDInHandAndPlayArea @@ -5546,7 +5546,7 @@ AIDecide_PokemonTrader_LegendaryArticuno: ; 21dd5 (8:5dd5)  	scf  	ret -AIDecide_PokemonTrader_LegendaryDragonite: ; 21e24 (8:5e24) +AIDecide_PokemonTrader_LegendaryDragonite:  ; if has less than 5 cards of energy  ; and of Pokemon in hand/Play Area,  ; target a Kangaskhan in deck. @@ -5643,7 +5643,7 @@ AIDecide_PokemonTrader_LegendaryDragonite: ; 21e24 (8:5e24)  	scf  	ret -AIDecide_PokemonTrader_LegendaryRonald: ; 21ec9 (8:5ec9) +AIDecide_PokemonTrader_LegendaryRonald:  ; for each of the following cards,  ; first run a check if there's a pre-evolution in  ; Play Area or in the hand. If there is, choose it as target. @@ -5713,7 +5713,7 @@ AIDecide_PokemonTrader_LegendaryRonald: ; 21ec9 (8:5ec9)  	scf  	ret -AIDecide_PokemonTrader_BlisteringPokemon: ; 21f41 (8:5f41) +AIDecide_PokemonTrader_BlisteringPokemon:  ; for each of the following cards,  ; first run a check if there's a pre-evolution in  ; Play Area or in the hand. If there is, choose it as target. @@ -5758,7 +5758,7 @@ AIDecide_PokemonTrader_BlisteringPokemon: ; 21f41 (8:5f41)  	scf  	ret -AIDecide_PokemonTrader_SoundOfTheWaves: ; 21f85 (8:5f85) +AIDecide_PokemonTrader_SoundOfTheWaves:  ; for each of the following cards,  ; first run a check if there's a pre-evolution in  ; Play Area or in the hand. If there is, choose it as target. @@ -5834,7 +5834,7 @@ AIDecide_PokemonTrader_SoundOfTheWaves: ; 21f85 (8:5f85)  	scf  	ret -AIDecide_PokemonTrader_PowerGenerator: ; 2200b (8:600b) +AIDecide_PokemonTrader_PowerGenerator:  ; for each of the following cards,  ; first run a check if there's a pre-evolution in  ; Play Area or in the hand. If there is, choose it as target. @@ -5925,7 +5925,7 @@ AIDecide_PokemonTrader_PowerGenerator: ; 2200b (8:600b)  	scf  	ret -AIDecide_PokemonTrader_FlowerGarden: ; 220a8 (8:60a8) +AIDecide_PokemonTrader_FlowerGarden:  ; for each of the following cards,  ; first run a check if there's a pre-evolution in  ; Play Area or in the hand. If there is, choose it as target. @@ -5994,7 +5994,7 @@ AIDecide_PokemonTrader_FlowerGarden: ; 220a8 (8:60a8)  	scf  	ret -AIDecide_PokemonTrader_StrangePower: ; 22122 (8:6122) +AIDecide_PokemonTrader_StrangePower:  ; looks for a Pokemon in hand to trade with Mr Mime in deck.  ; inputting Mr Mime in register e for the function is redundant  ; since it already checks whether a Mr Mime exists in the hand. @@ -6011,7 +6011,7 @@ AIDecide_PokemonTrader_StrangePower: ; 22122 (8:6122)  	or a  	ret -AIDecide_PokemonTrader_Flamethrower: ; 22133 (8:6133) +AIDecide_PokemonTrader_Flamethrower:  ; for each of the following cards,  ; first run a check if there's a pre-evolution in  ; Play Area or in the hand. If there is, choose it as target. | 
