From 327338a13635692027f10328c28ce773a06d8cb9 Mon Sep 17 00:00:00 2001 From: Electro Date: Wed, 3 Dec 2025 15:22:09 +0000 Subject: [PATCH] Improve effect commands documentation, misc improvements --- CONTRIBUTING.md | 4 +- bugs_and_glitches.md | 2 +- src/constants/deck_ai_constants.asm | 4 +- src/constants/duel_constants.asm | 38 +-- src/data/cards.asm | 4 +- src/data/duel/ai_trainer_card_logic.asm | 4 +- src/engine/duel/ai/attacks.asm | 4 +- src/engine/duel/ai/damage_calculation.asm | 4 +- src/engine/duel/ai/trainer_cards.asm | 34 +-- src/engine/duel/core.asm | 28 +- src/engine/duel/effect_commands.asm | 24 +- src/engine/duel/effect_functions.asm | 299 ++++++++++++---------- src/engine/menus/duel.asm | 2 +- src/home/duel.asm | 16 +- src/home/substatus.asm | 10 +- src/hram.asm | 13 +- src/macros/wram.asm | 12 +- src/wram.asm | 8 +- 18 files changed, 268 insertions(+), 242 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3137de5..f3dcf4d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -139,7 +139,7 @@ CopyLine:: ; e = attack index (0 or 1) ; wAttachedEnergies and wTotalAttachedEnergies ; returns: carry if not enough energy, nc if enough energy. -_CheckIfEnoughEnergiesToAttack: +CheckIfEnoughEnergiesForGivenAttack: ``` ```asm @@ -258,7 +258,7 @@ wTextHeader4:: ; ce3a ; such as PrintPlayAreaCardLocation, PrintPlayAreaCardInformation and PrintPlayAreaCardHeader wCurPlayAreaSlot:: ; cbc9 -; X position to display the attached energies, HP bar, and Pluspower/Defender icons +; X position to display the attached energies, HP bar, and PlusPower/Defender icons ; obviously different for player and opponent side. used by DrawDuelHUD. wHUDEnergyAndHPBarsX:: ; cbc9 ds $1 diff --git a/bugs_and_glitches.md b/bugs_and_glitches.md index 54fd2e6..26b3509 100644 --- a/bugs_and_glitches.md +++ b/bugs_and_glitches.md @@ -412,7 +412,7 @@ AIDecide_FullHeal: ### AI might use a Pkmn Power as an attack -Under very specific conditions, the AI might attempt to use its Arena card's Pkmn Power as an attack. This is because when the AI plays Pluspower, it is hardcoding which attack to use when it finally decides to attack. This does not account for the case where afterwards, for example, the AI plays a Professor Oak and obtains an evolution of that card, and then evolves that card. If the new evolved Pokémon has Pkmn Power on the first "attack slot", and the AI hardcoded to use that attack, then it will be used. This specific combination can be seen when playing with John, since his deck contains Professor Oak, Pluspower, and Doduo and its evolution Dodrio (which has the Pkmn Power Retreat Aid). +Under very specific conditions, the AI might attempt to use its Arena card's Pkmn Power as an attack. This is because when the AI plays PlusPower, it is hardcoding which attack to use when it finally decides to attack. This does not account for the case where afterwards, for example, the AI plays a Professor Oak and obtains an evolution of that card, and then evolves that card. If the new evolved Pokémon has Pkmn Power on the first "attack slot", and the AI hardcoded to use that attack, then it will be used. This specific combination can be seen when playing with John, since his deck contains Professor Oak, PlusPower, and Doduo and its evolution Dodrio (which has the Pkmn Power Retreat Aid). **Fix:** Edit `AIDecideEvolution` in [src/engine/duel/ai/hand_pokemon.asm](https://github.com/pret/poketcg/blob/master/src/engine/duel/ai/hand_pokemon.asm): ```diff diff --git a/src/constants/deck_ai_constants.asm b/src/constants/deck_ai_constants.asm index 7480314..1f7b447 100644 --- a/src/constants/deck_ai_constants.asm +++ b/src/constants/deck_ai_constants.asm @@ -80,13 +80,13 @@ DEF AI_ENERGY_FLAG_SKIP_ARENA_CARD EQU 1 << 7 ; whether to include Arena card in const AI_TRAINER_CARD_PHASE_13 ; $d ; Defender - ; Pluspower + ; PlusPower ; Lass ; Pokémon Flute const AI_TRAINER_CARD_PHASE_14 ; $e ; Defender - ; Pluspower + ; PlusPower const AI_TRAINER_CARD_PHASE_15 ; $f ; Professor Oak diff --git a/src/constants/duel_constants.asm b/src/constants/duel_constants.asm index 9032d8d..0a73b4e 100644 --- a/src/constants/duel_constants.asm +++ b/src/constants/duel_constants.asm @@ -57,12 +57,12 @@ DEF DUELVARS_BENCH2_CARD_ATTACHED_DEFENDER EQUS "LOW(wPlayerBench2CardAttache DEF DUELVARS_BENCH3_CARD_ATTACHED_DEFENDER EQUS "LOW(wPlayerBench3CardAttachedDefender)" ; dd DEF DUELVARS_BENCH4_CARD_ATTACHED_DEFENDER EQUS "LOW(wPlayerBench4CardAttachedDefender)" ; de DEF DUELVARS_BENCH5_CARD_ATTACHED_DEFENDER EQUS "LOW(wPlayerBench5CardAttachedDefender)" ; df -DEF DUELVARS_ARENA_CARD_ATTACHED_PLUSPOWER EQUS "LOW(wPlayerArenaCardAttachedPluspower)" ; e0 -DEF DUELVARS_BENCH1_CARD_ATTACHED_PLUSPOWER EQUS "LOW(wPlayerBench1CardAttachedPluspower)" ; e1 -DEF DUELVARS_BENCH2_CARD_ATTACHED_PLUSPOWER EQUS "LOW(wPlayerBench2CardAttachedPluspower)" ; e2 -DEF DUELVARS_BENCH3_CARD_ATTACHED_PLUSPOWER EQUS "LOW(wPlayerBench3CardAttachedPluspower)" ; e3 -DEF DUELVARS_BENCH4_CARD_ATTACHED_PLUSPOWER EQUS "LOW(wPlayerBench4CardAttachedPluspower)" ; e4 -DEF DUELVARS_BENCH5_CARD_ATTACHED_PLUSPOWER EQUS "LOW(wPlayerBench5CardAttachedPluspower)" ; e5 +DEF DUELVARS_ARENA_CARD_ATTACHED_PLUSPOWER EQUS "LOW(wPlayerArenaCardAttachedPlusPower)" ; e0 +DEF DUELVARS_BENCH1_CARD_ATTACHED_PLUSPOWER EQUS "LOW(wPlayerBench1CardAttachedPlusPower)" ; e1 +DEF DUELVARS_BENCH2_CARD_ATTACHED_PLUSPOWER EQUS "LOW(wPlayerBench2CardAttachedPlusPower)" ; e2 +DEF DUELVARS_BENCH3_CARD_ATTACHED_PLUSPOWER EQUS "LOW(wPlayerBench3CardAttachedPlusPower)" ; e3 +DEF DUELVARS_BENCH4_CARD_ATTACHED_PLUSPOWER EQUS "LOW(wPlayerBench4CardAttachedPlusPower)" ; e4 +DEF DUELVARS_BENCH5_CARD_ATTACHED_PLUSPOWER EQUS "LOW(wPlayerBench5CardAttachedPlusPower)" ; e5 DEF DUELVARS_ARENA_CARD_SUBSTATUS1 EQUS "LOW(wPlayerArenaCardSubstatus1)" ; e7 DEF DUELVARS_ARENA_CARD_SUBSTATUS2 EQUS "LOW(wPlayerArenaCardSubstatus2)" ; e8 DEF DUELVARS_ARENA_CARD_CHANGED_WEAKNESS EQUS "LOW(wPlayerArenaCardChangedWeakness)" ; e9 @@ -134,19 +134,19 @@ DEF DBLPSN_DAMAGE EQU 20 ; substatus conditions (DUELVARS_ARENA_CARD_SUBSTATUS*) ; SUBSTATUS1 are checked on a defending Pokemon -DEF SUBSTATUS1_AGILITY EQU $0c -DEF SUBSTATUS1_FLY EQU $0d -DEF SUBSTATUS1_HARDEN EQU $0e -DEF SUBSTATUS1_NO_DAMAGE_STIFFEN EQU $0f -DEF SUBSTATUS1_NO_DAMAGE_10 EQU $10 -DEF SUBSTATUS1_NO_DAMAGE_11 EQU $11 -DEF SUBSTATUS1_REDUCE_BY_20 EQU $13 -DEF SUBSTATUS1_BARRIER EQU $14 -DEF SUBSTATUS1_HALVE_DAMAGE EQU $15 -DEF SUBSTATUS1_DESTINY_BOND EQU $16 -DEF SUBSTATUS1_NO_DAMAGE_17 EQU $17 +DEF SUBSTATUS1_AGILITY EQU $0c +DEF SUBSTATUS1_FLY EQU $0d +DEF SUBSTATUS1_PREVENT_LESS_THAN_40 EQU $0e +DEF SUBSTATUS1_NO_DAMAGE_STIFFEN EQU $0f +DEF SUBSTATUS1_NO_DAMAGE_WITHDRAW EQU $10 +DEF SUBSTATUS1_NO_DAMAGE_HIDE_IN_SHELL EQU $11 +DEF SUBSTATUS1_REDUCE_BY_20 EQU $13 +DEF SUBSTATUS1_BARRIER EQU $14 +DEF SUBSTATUS1_HALVE_DAMAGE EQU $15 +DEF SUBSTATUS1_DESTINY_BOND EQU $16 +DEF SUBSTATUS1_NO_DAMAGE_SCRUNCH EQU $17 DEF SUBSTATUS1_NEXT_TURN_DOUBLE_DAMAGE EQU $19 -DEF SUBSTATUS1_REDUCE_BY_10 EQU $1e +DEF SUBSTATUS1_REDUCE_BY_10 EQU $1e ; SUBSTATUS2 are checked on an attacking Pokemon DEF SUBSTATUS2_SMOKESCREEN EQU $01 @@ -157,7 +157,7 @@ DEF SUBSTATUS2_TAIL_WAG EQU $05 DEF SUBSTATUS2_LEER EQU $06 DEF SUBSTATUS2_POUNCE EQU $07 DEF SUBSTATUS2_CONVERSION2 EQU $08 -DEF SUBSTATUS2_UNABLE_RETREAT EQU $09 +DEF SUBSTATUS2_ACID EQU $09 DEF SUBSTATUS2_BONE_ATTACK EQU $0b DEF SUBSTATUS2_GROWL EQU $12 diff --git a/src/data/cards.asm b/src/data/cards.asm index cd40e8e..8baf255 100644 --- a/src/data/cards.asm +++ b/src/data/cards.asm @@ -7903,7 +7903,7 @@ MewtwoLv60Card: dw NONE ; description (cont) db 0 ; damage db RESIDUAL ; category - dw MewtwoLv60EnergyAbsorptionEffectCommands ; effect commands + dw MewtwoEnergyAbsorptionEffectCommands ; effect commands db NONE ; flags 1 db NONE ; flags 2 db SPECIAL_AI_HANDLING ; flags 3 @@ -7954,7 +7954,7 @@ MewtwoAltLV60Card: dw NONE ; description (cont) db 0 ; damage db RESIDUAL ; category - dw MewtwoAltLV60EnergyAbsorptionEffectCommands ; effect commands + dw MewtwoAltEnergyAbsorptionEffectCommands ; effect commands db NONE ; flags 1 db NONE ; flags 2 db SPECIAL_AI_HANDLING ; flags 3 diff --git a/src/data/duel/ai_trainer_card_logic.asm b/src/data/duel/ai_trainer_card_logic.asm index c950bca..c841924 100644 --- a/src/data/duel/ai_trainer_card_logic.asm +++ b/src/data/duel/ai_trainer_card_logic.asm @@ -12,8 +12,8 @@ AITrainerCardLogic: ai_trainer_card_logic AI_TRAINER_CARD_PHASE_11, SUPER_POTION, AIDecide_SuperPotion2, AIPlay_SuperPotion ai_trainer_card_logic AI_TRAINER_CARD_PHASE_13, DEFENDER, AIDecide_Defender1, AIPlay_Defender ai_trainer_card_logic AI_TRAINER_CARD_PHASE_14, DEFENDER, AIDecide_Defender2, AIPlay_Defender - ai_trainer_card_logic AI_TRAINER_CARD_PHASE_13, PLUSPOWER, AIDecide_Pluspower1, AIPlay_Pluspower - ai_trainer_card_logic AI_TRAINER_CARD_PHASE_14, PLUSPOWER, AIDecide_Pluspower2, AIPlay_Pluspower + ai_trainer_card_logic AI_TRAINER_CARD_PHASE_13, PLUSPOWER, AIDecide_PlusPower1, AIPlay_PlusPower + ai_trainer_card_logic AI_TRAINER_CARD_PHASE_14, PLUSPOWER, AIDecide_PlusPower2, AIPlay_PlusPower ai_trainer_card_logic AI_TRAINER_CARD_PHASE_09, SWITCH, AIDecide_Switch, AIPlay_Switch ai_trainer_card_logic AI_TRAINER_CARD_PHASE_07, GUST_OF_WIND, AIDecide_GustOfWind, AIPlay_GustOfWind ai_trainer_card_logic AI_TRAINER_CARD_PHASE_10, GUST_OF_WIND, AIDecide_GustOfWind, AIPlay_GustOfWind diff --git a/src/engine/duel/ai/attacks.asm b/src/engine/duel/ai/attacks.asm index 39a96f5..cd7cb3b 100644 --- a/src/engine/duel/ai/attacks.asm +++ b/src/engine/duel/ai/attacks.asm @@ -52,11 +52,11 @@ AIProcessAndTryToUseAttack: ; AI will use it if wAIExecuteProcessedAttack is 0. ; in either case, return carry if an attack is chosen to be used. AIProcessAttacks: -; if AI used Pluspower, load its attack index +; if AI used PlusPower, load its attack index ld a, [wPreviousAIFlags] and AI_FLAG_USED_PLUSPOWER jr z, .no_pluspower - ld a, [wAIPluspowerAttack] + ld a, [wAIPlusPowerAttack] ld [wSelectedAttack], a jr .attack_chosen diff --git a/src/engine/duel/ai/damage_calculation.asm b/src/engine/duel/ai/damage_calculation.asm index 9a7ee12..8134d42 100644 --- a/src/engine/duel/ai/damage_calculation.asm +++ b/src/engine/duel/ai/damage_calculation.asm @@ -167,7 +167,7 @@ CalculateDamage_VersusDefendingPokemon: ldh a, [hTempPlayAreaLocation_ff9d] add CARD_LOCATION_ARENA ld b, a - call ApplyAttachedPluspower + call ApplyAttachedPlusPower call SwapTurn ld b, CARD_LOCATION_ARENA call ApplyAttachedDefender @@ -404,7 +404,7 @@ CalculateDamage_FromDefendingPokemon: ; apply pluspower and defender boosts call SwapTurn ld b, CARD_LOCATION_ARENA - call ApplyAttachedPluspower + call ApplyAttachedPlusPower call SwapTurn ldh a, [hTempPlayAreaLocation_ff9d] add CARD_LOCATION_ARENA diff --git a/src/engine/duel/ai/trainer_cards.asm b/src/engine/duel/ai/trainer_cards.asm index c7bd8ae..b13daa4 100644 --- a/src/engine/duel/ai/trainer_cards.asm +++ b/src/engine/duel/ai/trainer_cards.asm @@ -755,22 +755,22 @@ AIDecide_Defender2: or a ret -AIPlay_Pluspower: +AIPlay_PlusPower: ld a, [wCurrentAIFlags] or AI_FLAG_USED_PLUSPOWER ld [wCurrentAIFlags], a ld a, [wAITrainerCardParameter] - ld [wAIPluspowerAttack], a + ld [wAIPlusPowerAttack], a ld a, [wAITrainerCardToPlay] ldh [hTempCardIndex_ff9f], a ld a, OPPACTION_EXECUTE_TRAINER_EFFECTS bank1call AIMakeDecision ret -; returns carry if using a Pluspower can KO defending Pokémon +; 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: +AIDecide_PlusPower1: ; this is mistakenly duplicated xor a ; PLAY_AREA_ARENA ldh [hTempPlayAreaLocation_ff9d], a @@ -811,7 +811,7 @@ AIDecide_Pluspower1: jr c, .no_carry ; check both attacks and decide which one -; can KO with Pluspower boost. +; can KO with PlusPower boost. ; if neither can KO, return no carry. xor a ; FIRST_ATTACK_OR_PKMN_POWER ld [wSelectedAttack], a @@ -826,14 +826,14 @@ AIDecide_Pluspower1: or a ret -; first attack can KO with Pluspower. +; first attack can KO with PlusPower. .kos_with_pluspower_1 call .check_mr_mime jr nc, .no_carry xor a ; FIRST_ATTACK_OR_PKMN_POWER scf ret -; second attack can KO with Pluspower. +; second attack can KO with PlusPower. .kos_with_pluspower_2 call .check_mr_mime jr nc, .no_carry @@ -842,7 +842,7 @@ AIDecide_Pluspower1: ret ; return carry if attack is useable and KOs -; defending Pokémon with Pluspower boost. +; defending Pokémon with PlusPower boost. .check_ko_with_pluspower farcall CheckIfSelectedAttackIsUnusable jr c, .unusable @@ -856,23 +856,23 @@ AIDecide_Pluspower1: jr c, .no_carry jr z, .no_carry ld a, [hl] - add 10 ; add Pluspower boost + add 10 ; add PlusPower boost ld c, a ld a, b sub c ret c ; return carry if damage > HP left ret nz ; does not KO scf - ret ; KOs with Pluspower boost + ret ; KOs with PlusPower boost .unusable or a ret -; returns carry if Pluspower boost does +; returns carry if PlusPower boost does ; not exceed 30 damage when facing Mr. Mime. .check_mr_mime ld a, [wDamage] - add 10 ; add Pluspower boost + add 10 ; add PlusPower boost cp 30 ; no danger in preventing damage ret c call SwapTurn @@ -888,11 +888,11 @@ AIDecide_Pluspower1: ret ; returns carry 7/10 of the time -; if selected attack is useable, can't KO without Pluspower boost -; can damage Mr. Mime even with Pluspower boost +; if selected attack is useable, can't KO without PlusPower boost +; can damage Mr. Mime even with PlusPower boost ; and has a minimum damage > 0. ; outputs in a the attack to use. -AIDecide_Pluspower2: +AIDecide_PlusPower2: xor a ; PLAY_AREA_ARENA ldh [hTempPlayAreaLocation_ff9d], a call .check_can_ko @@ -907,11 +907,11 @@ AIDecide_Pluspower2: or a ret -; returns carry if Pluspower boost does +; returns carry if PlusPower boost does ; not exceed 30 damage when facing Mr. Mime. .check_mr_mime ld a, [wDamage] - add 10 ; add Pluspower boost + add 10 ; add PlusPower boost cp 30 ; no danger in preventing damage ret c call SwapTurn diff --git a/src/engine/duel/core.asm b/src/engine/duel/core.asm index 1a3dad8..cdbe02d 100644 --- a/src/engine/duel/core.asm +++ b/src/engine/duel/core.asm @@ -1268,7 +1268,7 @@ CheckIfEnoughEnergiesToAttack: ld d, [hl] ; card's deck index (0 to 59) inc hl ld e, [hl] ; attack index (0 or 1) - call _CheckIfEnoughEnergiesToAttack + call CheckIfEnoughEnergiesForGivenAttack pop bc pop hl ret @@ -1276,10 +1276,10 @@ CheckIfEnoughEnergiesToAttack: ; check if a pokemon card has enough energy attached to it in order to use an attack ; input: ; d = deck index of card (0 to 59) -; e = attack index (0 or 1) +; e = attack index (SECOND_ATTACK or FIRST_ATTACK_OR_PKMN_POWER) ; wAttachedEnergies and wTotalAttachedEnergies ; returns: carry if not enough energy, nc if enough energy. -_CheckIfEnoughEnergiesToAttack: +CheckIfEnoughEnergiesForGivenAttack: push de ld a, d call LoadCardDataToBuffer1_FromDeckIndex @@ -2290,12 +2290,10 @@ PlayDeckShuffleAnimation: ld e, DUEL_ANIM_OPP_SHUFFLE .load_anim ; play animation 3 times +REPT 3 ld a, e call PlayDuelAnimation - ld a, e - call PlayDuelAnimation - ld a, e - call PlayDuelAnimation +ENDR .loop_anim call DoFrame @@ -2543,7 +2541,7 @@ DrawDuelHUD: ld b, HP_BAR_LENGTH / 2 ; second row of the HP bar call SafeCopyDataHLtoDE - ; print number of attached Pluspower and Defender with respective icon, if any + ; print number of attached PlusPower and Defender with respective icon, if any ld hl, wHUDEnergyAndHPBarsX ld a, [hli] add 6 @@ -2557,7 +2555,7 @@ DrawDuelHUD: ld a, SYM_PLUSPOWER call WriteByteToBGMap0 inc b - ld a, [hl] ; number of attached Pluspower + ld a, [hl] ; number of attached PlusPower add SYM_0 call WriteByteToBGMap0 dec b @@ -3256,7 +3254,7 @@ DisplayCardList: ld hl, wSelectedDuelSubMenuItem ld [hli], a ld [hl], a - ld a, 1 + ld a, TRUE ld [wSortCardListByID], a call EraseCursor jr .reload_list @@ -3423,7 +3421,7 @@ PrintSortNumberInCardList_SetPointer: ld [hl], e inc hl ld [hl], d - ld a, 1 + ld a, TRUE ld [wSortCardListByID], a ret @@ -5474,7 +5472,7 @@ PrintPlayAreaCardHeader: call CheckPrintDoublePoisoned .skip_status - ; finally check whether to print the Pluspower and/or Defender symbols + ; finally check whether to print the PlusPower and/or Defender symbols ld a, [wCurPlayAreaSlot] add DUELVARS_ARENA_CARD_ATTACHED_PLUSPOWER call GetTurnDuelistVariable @@ -6830,7 +6828,7 @@ HandleBetweenTurnsEvents: call IsArenaPokemonAsleepOrPoisoned call SwapTurn jr c, .something_to_handle - call DiscardAttachedPluspowers + call DiscardAttachedPlusPowers call SwapTurn call DiscardAttachedDefenders call SwapTurn @@ -6877,7 +6875,7 @@ HandleBetweenTurnsEvents: call WaitForWideTextBoxInput .discard_pluspower - call DiscardAttachedPluspowers + call DiscardAttachedPlusPowers call SwapTurn ld a, DUELVARS_ARENA_CARD call GetTurnDuelistVariable @@ -6898,7 +6896,7 @@ HandleBetweenTurnsEvents: ret ; discard any PLUSPOWER attached to the turn holder's arena and/or bench Pokemon -DiscardAttachedPluspowers: +DiscardAttachedPlusPowers: ld a, DUELVARS_ARENA_CARD_ATTACHED_PLUSPOWER call GetTurnDuelistVariable ld e, MAX_PLAY_AREA_POKEMON diff --git a/src/engine/duel/effect_commands.asm b/src/engine/duel/effect_commands.asm index 2a3d3bb..b2db771 100644 --- a/src/engine/duel/effect_commands.asm +++ b/src/engine/duel/effect_commands.asm @@ -524,8 +524,8 @@ ArticunoBlizzardEffectCommands: db $00 TentacoolCowardiceEffectCommands: - dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, Cowardice_Check - dbw EFFECTCMDTYPE_BEFORE_DAMAGE, Cowardice_RemoveFromPlayAreaEffect + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, Cowardice_CheckUseAndBench + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, Cowardice_ReturnToHandEffect dbw EFFECTCMDTYPE_REQUIRE_SELECTION, Cowardice_PlayerSelectEffect db $00 @@ -818,18 +818,18 @@ MewtwoBarrierEffectCommands: dbw EFFECTCMDTYPE_AI_SELECTION, Barrier_AISelectEffect db $00 -MewtwoAltLV60EnergyAbsorptionEffectCommands: - dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, MewtwoAltLV60EnergyAbsorption_CheckDiscardPile - dbw EFFECTCMDTYPE_AFTER_DAMAGE, MewtwoAltLV60EnergyAbsorption_AddToHandEffect - dbw EFFECTCMDTYPE_REQUIRE_SELECTION, MewtwoAltLV60EnergyAbsorption_PlayerSelectEffect - dbw EFFECTCMDTYPE_AI_SELECTION, MewtwoAltLV60EnergyAbsorption_AISelectEffect +MewtwoAltEnergyAbsorptionEffectCommands: + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, MewtwoAltEnergyAbsorption_CheckDiscardPile + dbw EFFECTCMDTYPE_AFTER_DAMAGE, MewtwoAltEnergyAbsorption_AddToHandEffect + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, MewtwoAltEnergyAbsorption_PlayerSelectEffect + dbw EFFECTCMDTYPE_AI_SELECTION, MewtwoAltEnergyAbsorption_AISelectEffect db $00 -MewtwoLv60EnergyAbsorptionEffectCommands: - dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, MewtwoLv60EnergyAbsorption_CheckDiscardPile - dbw EFFECTCMDTYPE_AFTER_DAMAGE, MewtwoLv60EnergyAbsorption_AddToHandEffect - dbw EFFECTCMDTYPE_REQUIRE_SELECTION, MewtwoLv60EnergyAbsorption_PlayerSelectEffect - dbw EFFECTCMDTYPE_AI_SELECTION, MewtwoLv60EnergyAbsorption_AISelectEffect +MewtwoEnergyAbsorptionEffectCommands: + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, MewtwoEnergyAbsorption_CheckDiscardPile + dbw EFFECTCMDTYPE_AFTER_DAMAGE, MewtwoEnergyAbsorption_AddToHandEffect + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, MewtwoEnergyAbsorption_PlayerSelectEffect + dbw EFFECTCMDTYPE_AI_SELECTION, MewtwoEnergyAbsorption_AISelectEffect db $00 SlowbroStrangeBehaviorEffectCommands: diff --git a/src/engine/duel/effect_functions.asm b/src/engine/duel/effect_functions.asm index e0f2ed7..643229a 100644 --- a/src/engine/duel/effect_functions.asm +++ b/src/engine/duel/effect_functions.asm @@ -98,13 +98,20 @@ TossCoinATimes_BankB: CommentedOut_2c086: ret +; unreferenced Serial_TossZeroCoins: xor a jr Serial_TossCoinATimes Serial_TossCoin: ld a, $1 +; fallthrough +; input: +; - a = number of coin flips +; - de = text ID +; output: +; - a = number of heads Serial_TossCoinATimes: push de push af @@ -240,6 +247,8 @@ DealDamageToAllBenchedPokemon: jr nz, .loop ret +; plays animation given in register a (ATK_ANIM_* constant) +; on top of the Pokémon that is attacking PlayAttackAnimationOverAttackingPokemon: ld [wLoadedAttackAnimation], a ldh a, [hTempPlayAreaLocation_ff9d] @@ -265,7 +274,7 @@ ApplySubstatus1ToAttackingCard: ApplySubstatus2ToDefendingCard: push af call CheckNoDamageOrEffect - jr c, .no_damage_orEffect + jr c, .no_damage_or_effect ld a, DUELVARS_ARENA_CARD_SUBSTATUS2 call GetNonTurnDuelistVariable pop af @@ -274,7 +283,7 @@ ApplySubstatus2ToDefendingCard: ld [hl], a ret -.no_damage_orEffect +.no_damage_or_effect pop af push hl bank1call DrawDuelMainScene @@ -452,8 +461,7 @@ HandleNoDamageOrEffect: ; applies HP recovery on Pokemon after an attack ; with HP recovery effect, and handles its animation. ; input: -; d = damage effectiveness -; e = HP amount to recover +; de = HP amount to recover ApplyAndAnimateHPRecovery: push de ld hl, wccbd @@ -697,11 +705,11 @@ LookForCardsInDeck: ret .search_table - dw .SearchDeckForCardID - dw .SearchDeckForNidoran - dw .SearchDeckForBasicFighting - dw .SearchDeckForBasicEnergy - dw .SearchDeckForPokemon + dw .SearchDeckForCardID ; SEARCHEFFECT_CARD_ID + dw .SearchDeckForNidoran ; SEARCHEFFECT_NIDORAN + dw .SearchDeckForBasicFighting ; SEARCHEFFECT_BASIC_FIGHTING + dw .SearchDeckForBasicEnergy ; SEARCHEFFECT_BASIC_ENERGY + dw .SearchDeckForPokemon ; SEARCHEFFECT_POKEMON .set_carry scf @@ -914,12 +922,14 @@ UpdateDevolvedCardHPAndStage: ld e, a call GetCardDamageAndMaxHP ld b, a ; store damage + + ; set this card index to duelist's Play Area ld a, e add DUELVARS_ARENA_CARD call GetTurnDuelistVariable pop af - ld [hl], a + call LoadCardDataToBuffer2_FromDeckIndex ld a, e add DUELVARS_ARENA_CARD_HP @@ -954,7 +964,7 @@ ResetDevolvedCardStatus: add DUELVARS_ARENA_CARD_CHANGED_TYPE call GetTurnDuelistVariable ld [hl], $00 -; reset C2 flags +; reset flags ldh a, [hTempPlayAreaLocation_ff9d] add DUELVARS_ARENA_CARD_FLAGS ld l, a @@ -1035,7 +1045,7 @@ DuelistSelectForcedSwitch: ; returns in a the card index of energy card ; attached to Defending Pokemon ; that is to be discarded by the AI for an effect. -; outputs $ff is none was found. +; outputs -1 is none was found. ; output: ; a = deck index of attached energy card chosen AIPickEnergyCardToDiscardFromDefendingPokemon: @@ -1047,7 +1057,7 @@ AIPickEnergyCardToDiscardFromDefendingPokemon: call CreateArenaOrBenchEnergyCardList jr nc, .has_energy ; no energy, return - ld a, $ff + ld a, -1 jr .done .has_energy @@ -1077,8 +1087,8 @@ AIPickEnergyCardToDiscardFromDefendingPokemon: or a jr z, .choose_random -; pick attached card with same color as e .pick_color +; pick attached card with same color as e ld hl, wDuelTempList .loop_energy ld a, [hli] @@ -1122,7 +1132,7 @@ AIPickAttackForAmnesia: ; if Defending Pokemon has enough energy for second attack, choose it ld e, SECOND_ATTACK - bank1call _CheckIfEnoughEnergiesToAttack + bank1call CheckIfEnoughEnergiesForGivenAttack jr nc, .chosen ; otherwise if first attack isn't a Pkmn Power, choose it instead. ld e, FIRST_ATTACK_OR_PKMN_POWER @@ -1138,12 +1148,12 @@ AIPickAttackForAmnesia: ; Return in a the PLAY_AREA_* of the non-turn holder's Pokemon card in bench with the lowest (remaining) HP. ; if multiple cards are tied for the lowest HP, the one with the highest PLAY_AREA_* is returned. -GetBenchPokemonWithLowestHP: +AIFindTargetForBenchAttack: call SwapTurn ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA call GetTurnDuelistVariable ld c, a - lb de, PLAY_AREA_ARENA, $ff + lb de, PLAY_AREA_ARENA, 255 ld b, d ld a, DUELVARS_BENCH1_CARD_HP call GetTurnDuelistVariable @@ -1252,7 +1262,7 @@ HandleColorChangeScreen: ; print card name and level at the top ld a, 16 call CopyCardNameAndLevel - ld [hl], $00 + ld [hl], TX_END lb de, 7, 0 call InitTextPrinting ld hl, wDefaultText @@ -1365,7 +1375,7 @@ ColorTileAndBGP: ; tile, BG db $e4, $02 db $e0, $01 - db $eC, $02 + db $ec, $02 db $e8, $01 db $f0, $03 db $f4, $03 @@ -1476,7 +1486,7 @@ PoisonFang_AIEffect: jp UpdateExpectedAIDamage_AccountForPoison WeepinbellPoisonPowder_AIEffect: - ld a, 5 + ld a, 10 / 2 lb de, 0, 10 jp UpdateExpectedAIDamage_AccountForPoison @@ -1506,7 +1516,7 @@ VictreebelLure_SelectSwitchPokemon: ; Return in hTemp_ffa0 the PLAY_AREA_* of the non-turn holder's Pokemon card in bench with the lowest (remaining) HP. ; if multiple cards are tied for the lowest HP, the one with the highest PLAY_AREA_* is returned. VictreebelLure_GetBenchPokemonWithLowestHP: - call GetBenchPokemonWithLowestHP + call AIFindTargetForBenchAttack ldh [hTemp_ffa0], a ret @@ -1528,7 +1538,7 @@ AcidEffect: ldtx de, AcidCheckText call TossCoin_BankB ret nc - ld a, SUBSTATUS2_UNABLE_RETREAT + ld a, SUBSTATUS2_ACID call ApplySubstatus2ToDefendingCard ret @@ -1557,7 +1567,7 @@ KakunaStiffenEffect: ret KakunaPoisonPowder_AIEffect: - ld a, 5 + ld a, 10 / 2 lb de, 0, 10 jp UpdateExpectedAIDamage_AccountForPoison @@ -1620,7 +1630,7 @@ Twineedle_MultiplierEffect: ret BeedrillPoisonSting_AIEffect: - ld a, 5 + ld a, 10 / 2 lb de, 0, 10 jp UpdateExpectedAIDamage_AccountForPoison @@ -1634,7 +1644,7 @@ ExeggcuteLeechSeedEffect: ret FoulGas_AIEffect: - ld a, 5 + ld a, 10 / 2 lb de, 0, 10 jp UpdateExpectedAIDamage @@ -1783,6 +1793,7 @@ Teleport_PlayerSelectEffect: ldh [hTemp_ffa0], a ret +; selects a random card from the bench to switch to Teleport_AISelectEffect: ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA call GetTurnDuelistVariable @@ -1808,10 +1819,13 @@ BigEggsplosion_AIEffect: jr nz, .capped ld l, 255 .capped + ; sets max damage as (num energy cards) * 20 ld a, l ld [wAIMaxDamage], a - srl a + ; sets expected damage as half max amount + srl a ; /2 ld [wDamage], a + ; sets min damage as 0 xor a ld [wAIMinDamage], a ret @@ -1885,6 +1899,7 @@ BoyfriendsEffect: ld a, [hl] cp $ff jr z, .done + ; is this card Nidoking? call GetCardIDFromDeckIndex ld a, e cp NIDOKING @@ -2128,7 +2143,7 @@ ButterfreeMegaDrainEffect: ret WeedlePoisonSting_AIEffect: - ld a, 5 + ld a, 10 / 2 lb de, 0, 10 jp UpdateExpectedAIDamage_AccountForPoison @@ -2142,7 +2157,7 @@ BulbasaurLeechSeedEffect: ld a, [hli] or [hl] ret z ; return if no damage dealt - lb de, 0, 10 + ld de, 10 call ApplyAndAnimateHPRecovery ret @@ -2324,7 +2339,7 @@ ToxicGasEffect: ret Sludge_AIEffect: - ld a, 5 + ld a, 10 / 2 lb de, 0, 10 jp UpdateExpectedAIDamage_AccountForPoison @@ -2433,7 +2448,7 @@ BellsproutCallForFamily_PutInPlayAreaEffect: ret WeezingSmog_AIEffect: - ld a, 5 + ld a, 10 / 2 lb de, 0, 10 jp UpdateExpectedAIDamage_AccountForPoison @@ -2468,6 +2483,7 @@ Shift_OncePerTurnCheck: ret Shift_PlayerSelectEffect: +.loop ldtx hl, ChoosePokemonWishToColorChangeText ldh a, [hTemp_ffa0] or $80 @@ -2487,7 +2503,7 @@ Shift_PlayerSelectEffect: ; not found in either Duelist's Play Area ldtx hl, UnableToSelectText call DrawWideTextBox_WaitForInput - jr Shift_PlayerSelectEffect ; loop back to start + jr .loop ; loop back to start ; checks in input color in a exists in Turn Duelist's Play Area ; returns carry if not found. @@ -2534,7 +2550,7 @@ Shift_ChangeColorEffect: ret VenomPowder_AIEffect: - ld a, 5 + ld a, 10 / 2 lb de, 0, 10 jp UpdateExpectedAIDamage @@ -2552,7 +2568,7 @@ VenomPowder_PoisonConfusion50PercentEffect: ret TangelaPoisonPowder_AIEffect: - ld a, 5 + ld a, 10 / 2 lb de, 0, 10 jp UpdateExpectedAIDamage_AccountForPoison @@ -2829,7 +2845,7 @@ WartortleWithdrawEffect: jp nc, SetWasUnsuccessful ld a, ATK_ANIM_PROTECT ld [wLoadedAttackAnimation], a - ld a, SUBSTATUS1_NO_DAMAGE_10 + ld a, SUBSTATUS1_NO_DAMAGE_WITHDRAW call ApplySubstatus1ToAttackingCard ret @@ -3013,7 +3029,7 @@ GolduckHyperBeam_PlayerSelectEffect: .no_energy call SwapTurn - ld a, $ff + ld a, -1 ldh [hTemp_ffa0], a or a ret @@ -3029,7 +3045,7 @@ GolduckHyperBeam_DiscardEffect: ; check if energy card was chosen to discard ldh a, [hTemp_ffa0] - cp $ff + cp -1 ret z ; return if none selected ; discard Defending card's energy @@ -3066,7 +3082,7 @@ HideInShellEffect: jp nc, SetWasUnsuccessful ld a, ATK_ANIM_PROTECT ld [wLoadedAttackAnimation], a - ld a, SUBSTATUS1_NO_DAMAGE_11 + ld a, SUBSTATUS1_NO_DAMAGE_HIDE_IN_SHELL call ApplySubstatus1ToAttackingCard ret @@ -3141,7 +3157,7 @@ SquirtleWithdrawEffect: jp nc, SetWasUnsuccessful ld a, ATK_ANIM_PROTECT ld [wLoadedAttackAnimation], a - ld a, SUBSTATUS1_NO_DAMAGE_10 + ld a, SUBSTATUS1_NO_DAMAGE_WITHDRAW call ApplySubstatus1ToAttackingCard ret @@ -3370,7 +3386,7 @@ Blizzard_BenchDamageEffect: ret ; return carry if can't use Cowardice -Cowardice_Check: +Cowardice_CheckUseAndBench: ldh a, [hTempPlayAreaLocation_ff9d] ldh [hTemp_ffa0], a call CheckIsIncapableOfUsingPkmnPower @@ -3405,7 +3421,7 @@ Cowardice_PlayerSelectEffect: ldh [hAIPkmnPowerEffectParam], a ret -Cowardice_RemoveFromPlayAreaEffect: +Cowardice_ReturnToHandEffect: ldh a, [hTemp_ffa0] add DUELVARS_ARENA_CARD call GetTurnDuelistVariable @@ -3502,13 +3518,13 @@ PlayerPickFireEnergyCardToDiscard: bank1call DisplayEnergyDiscardScreen bank1call HandleEnergyDiscardMenuInput ldh a, [hTempCardIndex_ff98] - ldh [hTempList], a + ldh [hTemp_ffa0], a ret AIPickFireEnergyCardToDiscard: call CreateListOfFireEnergyAttachedToArena ld a, [wDuelTempList] - ldh [hTempList], a ; pick first in list + ldh [hTemp_ffa0], a ; pick first in list ret ; returns carry if Arena card has no Fire Energy cards @@ -3529,7 +3545,7 @@ ArcanineFlamethrower_AISelectEffect: ret ArcanineFlamethrower_DiscardEffect: - ldh a, [hTempList] + ldh a, [hTemp_ffa0] call PutCardInDiscardPile ret @@ -3654,7 +3670,7 @@ NinetalesLure_PlayerSelectEffect: ret NinetalesLure_AISelectEffect: - call GetBenchPokemonWithLowestHP + call AIFindTargetForBenchAttack ldh [hTemp_ffa0], a ret @@ -3687,7 +3703,7 @@ FireBlast_AISelectEffect: ret FireBlast_DiscardEffect: - ldh a, [hTempList] + ldh a, [hTemp_ffa0] call PutCardInDiscardPile ret @@ -3709,7 +3725,7 @@ Ember_AISelectEffect: ret Ember_DiscardEffect: - ldh a, [hTempList] + ldh a, [hTemp_ffa0] call PutCardInDiscardPile ret @@ -3871,7 +3887,7 @@ FlareonFlamethrower_AISelectEffect: ret FlareonFlamethrower_DiscardEffect: - ldh a, [hTempList] + ldh a, [hTemp_ffa0] call PutCardInDiscardPile ret @@ -3893,7 +3909,7 @@ MagmarFlamethrower_AISelectEffect: ret MagmarFlamethrower_DiscardEffect: - ldh a, [hTempList] + ldh a, [hTemp_ffa0] call PutCardInDiscardPile ret @@ -3903,7 +3919,7 @@ MagmarSmokescreenEffect: ret MagmarSmog_AIEffect: - ld a, 5 + ld a, 10 / 2 lb de, 0, 10 jp UpdateExpectedAIDamage_AccountForPoison @@ -3925,7 +3941,7 @@ CharmeleonFlamethrower_AISelectEffect: ret CharmeleonFlamethrower_DiscardEffect: - ldh a, [hTempList] + ldh a, [hTemp_ffa0] call PutCardInDiscardPile ret @@ -3996,7 +4012,7 @@ FireSpin_DiscardEffect: ; returns carry if Pkmn Power cannot be used ; or if Arena card is not Charizard. -; this is unused. +; unreferenced EnergyBurnCheck_Unreferenced: xor a ; PLAY_AREA_ARENA bank1call CheckIsIncapableOfUsingPkmnPower @@ -4069,12 +4085,12 @@ MixUpEffect: .loop_deck ld a, [hl] call .CheckIfCardIsPkmnCard - jr nc, .next_deck + jr nc, .next_deck_card dec c ld a, [hl] call SearchCardInDeckAndAddToHand call AddCardToHand -.next_deck +.next_deck_card inc hl ld a, c or a @@ -4281,8 +4297,8 @@ GetEnergyAttachedMultiplierDamage: call SwapTurn ld l, c - ld h, $00 - ld b, $00 + ld h, 0 + ld b, 0 add hl, hl ; hl = 2 * c add hl, hl ; hl = 4 * c add hl, bc ; hl = 5 * c @@ -4552,7 +4568,7 @@ GengarDarkMind_AISelectEffect: cp 2 ret c ; return if no Bench Pokemon ; just pick Pokemon with lowest remaining HP. - call GetBenchPokemonWithLowestHP + call AIFindTargetForBenchAttack ldh [hTemp_ffa0], a ret @@ -4701,6 +4717,7 @@ Prophecy_CheckDeck: ret Prophecy_PlayerSelectEffect: +.start ldtx hl, ProcedureForProphecyText bank1call DrawWholeScreenTextBox .select_deck @@ -4709,7 +4726,7 @@ Prophecy_PlayerSelectEffect: call TwoItemHorizontalMenu ldh a, [hKeysHeld] and PAD_B - jr nz, Prophecy_PlayerSelectEffect ; loop back to start + jr nz, .start ; loop back to start ldh a, [hCurMenuItem] ldh [hTempList], a ; store selection in first position in list @@ -4755,7 +4772,7 @@ Prophecy_ReorderDeckEffect: call SwapTurn ret -.ReorderCards +.ReorderCards: ld c, 0 ; add selected cards to hand in the specified order .loop_add_hand @@ -4962,7 +4979,7 @@ HypnoDarkMind_AISelectEffect: cp 2 ret c ; return if no Bench Pokemon ; just pick Pokemon with lowest remaining HP. - call GetBenchPokemonWithLowestHP + call AIFindTargetForBenchAttack ldh [hTemp_ffa0], a ret @@ -5197,7 +5214,7 @@ DevolutionBeam_PlayerSelectEffect: ret DevolutionBeam_AISelectEffect: - ld a, $01 + ld a, $01 ; always choose player's side ldh [hTemp_ffa0], a call SwapTurn call FindFirstNonBasicCardInPlayArea @@ -5234,7 +5251,7 @@ DevolutionBeam_DevolveEffect: call SwapTurn ret -.DevolvePokemon +.DevolvePokemon: ld a, ATK_ANIM_DEVOLUTION_BEAM ld [wLoadedAttackAnimation], a ldh a, [hTempPlayAreaLocation_ffa1] @@ -5253,7 +5270,7 @@ DevolutionBeam_DevolveEffect: call GetTurnDuelistVariable call LoadCardDataToBuffer1_FromDeckIndex -; check if car is affected +; check if card is affected ld a, [wLoadedCard1ID] ld [wTempNonTurnDuelistCardID], a ld de, $0 @@ -5410,17 +5427,17 @@ Barrier_BarrierEffect: call ApplySubstatus1ToAttackingCard ret -MewtwoAltLV60EnergyAbsorption_CheckDiscardPile: +MewtwoAltEnergyAbsorption_CheckDiscardPile: call CreateEnergyCardListFromDiscardPile_AllEnergy ldtx hl, ThereAreNoEnergyCardsInDiscardPileText ret -MewtwoAltLV60EnergyAbsorption_PlayerSelectEffect: +MewtwoAltEnergyAbsorption_PlayerSelectEffect: ldtx hl, Choose2EnergyCardsFromDiscardPileToAttachText call HandleEnergyCardsInDiscardPileSelection ret -MewtwoAltLV60EnergyAbsorption_AISelectEffect: +MewtwoAltEnergyAbsorption_AISelectEffect: ; AI picks first 2 energy cards call CreateEnergyCardListFromDiscardPile_AllEnergy ld hl, wDuelTempList @@ -5439,7 +5456,7 @@ MewtwoAltLV60EnergyAbsorption_AISelectEffect: ld [de], a ret -MewtwoAltLV60EnergyAbsorption_AddToHandEffect: +MewtwoAltEnergyAbsorption_AddToHandEffect: ld hl, hTempList .loop ld a, [hli] @@ -5452,17 +5469,17 @@ MewtwoAltLV60EnergyAbsorption_AddToHandEffect: pop hl jr .loop -MewtwoLv60EnergyAbsorption_CheckDiscardPile: +MewtwoEnergyAbsorption_CheckDiscardPile: call CreateEnergyCardListFromDiscardPile_AllEnergy ldtx hl, ThereAreNoEnergyCardsInDiscardPileText ret -MewtwoLv60EnergyAbsorption_PlayerSelectEffect: +MewtwoEnergyAbsorption_PlayerSelectEffect: ldtx hl, Choose2EnergyCardsFromDiscardPileToAttachText call HandleEnergyCardsInDiscardPileSelection ret -MewtwoLv60EnergyAbsorption_AISelectEffect: +MewtwoEnergyAbsorption_AISelectEffect: ; AI picks first 2 energy cards call CreateEnergyCardListFromDiscardPile_AllEnergy ld hl, wDuelTempList @@ -5481,7 +5498,7 @@ MewtwoLv60EnergyAbsorption_AISelectEffect: ld [de], a ret -MewtwoLv60EnergyAbsorption_AddToHandEffect: +MewtwoEnergyAbsorption_AddToHandEffect: ld hl, hTempList .loop ld a, [hli] @@ -5624,6 +5641,8 @@ SpacingOut_HealEffect: ldh a, [hTemp_ffa0] or a ret z ; coin toss was tails + ; unnecessary damage check, this was already + ; checked in SpacingOut_CheckDamage ld e, PLAY_AREA_ARENA call GetCardDamageAndMaxHP or a @@ -5812,7 +5831,7 @@ MysteryAttack_RandomEffect: dw PoisonEffect dw SleepEffect dw ConfusionEffect - dw .no_effect ; this will actually activate recovery effect afterwards + dw .recover dw .no_effect dw .more_damage dw .no_damage @@ -5828,6 +5847,12 @@ MysteryAttack_RandomEffect: xor a call SetDefiniteDamage call SetNoEffectFromStatus +; fallthrough + +.recover +; this will actually activate recovery effect afterwards +; for this command do nothing + .no_effect ret @@ -5837,7 +5862,7 @@ MysteryAttack_RecoverEffect: ldh a, [hTemp_ffa0] cp 4 ret nz - lb de, 0, 10 + ld de, 10 call ApplyAndAnimateHPRecovery ret @@ -5873,7 +5898,7 @@ StoneBarrage_MultiplierEffect: ret OnixHardenEffect: - ld a, SUBSTATUS1_HARDEN + ld a, SUBSTATUS1_PREVENT_LESS_THAN_40 call ApplySubstatus1ToAttackingCard ret @@ -6120,7 +6145,7 @@ GolemSelfdestructEffect: ret GravelerHardenEffect: - ld a, SUBSTATUS1_HARDEN + ld a, SUBSTATUS1_PREVENT_LESS_THAN_40 call ApplySubstatus1ToAttackingCard ret @@ -6178,7 +6203,7 @@ StretchKick_PlayerSelectEffect: StretchKick_AISelectEffect: ; chooses Bench Pokemon with least amount of remaining HP - call GetBenchPokemonWithLowestHP + call AIFindTargetForBenchAttack ldh [hTemp_ffa0], a ret @@ -6342,7 +6367,7 @@ Wail_FillBenchEffect: call SwapTurn ret -.FillBench +.FillBench: call CreateDeckCardList ret c ld hl, wDuelTempList @@ -6546,16 +6571,16 @@ ThunderstormEffect: ; displays text for current Bench Pokemon, ; printing its Bench number and name. -.DisplayText +.DisplayText: ld b, e ldtx hl, BenchText ld de, wDefaultText call CopyText - ld a, $30 ; 0 FW character + ld a, '0' add b ld [de], a inc de - ld a, $20 ; space FW character + ld a, ' ' ld [de], a inc de @@ -6677,7 +6702,7 @@ Spark_AISelectEffect: cp 2 ret c ; has no Bench Pokemon ; AI always picks Pokemon with lowest HP remaining - call GetBenchPokemonWithLowestHP + call AIFindTargetForBenchAttack ldh [hTemp_ffa0], a ret @@ -6724,7 +6749,7 @@ ChainLightningEffect: call .DamageSameColorBench ret -.DamageSameColorBench +.DamageSameColorBench: ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA call GetTurnDuelistVariable ld e, a @@ -7074,6 +7099,7 @@ PealOfThunder_RandomlyDamageEffect: ; input: ; de = amount of damage to deal RandomlyDamagePlayAreaPokemon: +.sample xor a ld [wNoDamageOrEffect], a @@ -7092,9 +7118,9 @@ RandomlyDamagePlayAreaPokemon: ; can't select Zapdos ldh a, [hTempPlayAreaLocation_ff9d] cp b - jr z, RandomlyDamagePlayAreaPokemon ; re-roll Pokemon to attack + jr z, .sample ; re-roll Pokemon to attack -.damage +.DoDamage: ld a, ATK_ANIM_THUNDER_PLAY_AREA ld [wLoadedAttackAnimation], a call DealDamageToPlayAreaPokemon @@ -7108,7 +7134,7 @@ RandomlyDamagePlayAreaPokemon: call GetTurnDuelistVariable call Random ld b, a - call .damage + call .DoDamage call SwapTurn ret @@ -7335,7 +7361,8 @@ EnergySpike_PlayerSelectEffect: ret EnergySpike_AISelectEffect: -; AI doesn't select any card +; AI doesn't choose card here, +; instead this is handled in AISelectSpecialAttackParameters ld a, $ff ldh [hTemp_ffa0], a ret @@ -7418,32 +7445,32 @@ EeveeQuickAttack_DamageBoostEffect: ret SpearowMirrorMove_AIEffect: - jr MirrorMoveEffects.AIEffect + jr MirrorMove_AIEffect SpearowMirrorMove_InitialEffect1: - jr MirrorMoveEffects.InitialEffect1 + jr MirrorMove_InitialEffect1 SpearowMirrorMove_InitialEffect2: - jr MirrorMoveEffects.InitialEffect2 + jr MirrorMove_InitialEffect2 SpearowMirrorMove_PlayerSelection: - jr MirrorMoveEffects.PlayerSelection + jr MirrorMove_PlayerSelection SpearowMirrorMove_AISelection: - jr MirrorMoveEffects.AISelection + jr MirrorMove_AISelection SpearowMirrorMove_BeforeDamage: - jr MirrorMoveEffects.BeforeDamage + jr MirrorMove_BeforeDamage SpearowMirrorMove_AfterDamage: - jp MirrorMoveEffects.AfterDamage + jp MirrorMove_AfterDamage ; these are effect commands that Mirror Move uses ; in order to mimic last turn's attack. ; it covers all possible effect steps to perform its commands ; (i.e. selection for Amnesia and Energy discarding attacks, etc) -MirrorMoveEffects: -.AIEffect + +MirrorMove_AIEffect: ld a, DUELVARS_ARENA_CARD_LAST_TURN_DAMAGE call GetTurnDuelistVariable ld a, [hl] @@ -7451,24 +7478,24 @@ MirrorMoveEffects: ld [wAIMaxDamage], a ret -.InitialEffect1 +MirrorMove_InitialEffect1: ld a, DUELVARS_ARENA_CARD_LAST_TURN_DAMAGE call GetTurnDuelistVariable - ld a, [hli] - or [hl] + ld a, [hli] ; DUELVARS_ARENA_CARD_LAST_TURN_DAMAGE + or [hl] ; inc hl - or [hl] + or [hl] ; DUELVARS_ARENA_CARD_LAST_TURN_STATUS inc hl - ret nz ; return if has last turn damage - ld a, [hli] + ret nz ; return if has last turn damage or status + ld a, [hli] ; DUELVARS_ARENA_CARD_LAST_TURN_SUBSTATUS2 or a - ret nz ; return if has last turn status + ret nz ; return if has last turn substatus ; no attack received last turn ldtx hl, YouDidNotReceiveAnAttackToMirrorMoveText scf ret -.InitialEffect2 +MirrorMove_InitialEffect2: ld a, $ff ldh [hTemp_ffa0], a ld a, DUELVARS_ARENA_CARD_LAST_TURN_EFFECT @@ -7480,7 +7507,7 @@ MirrorMoveEffects: or a ret -.PlayerSelection +MirrorMove_PlayerSelection: ld a, DUELVARS_ARENA_CARD_LAST_TURN_EFFECT call GetTurnDuelistVariable or a @@ -7490,7 +7517,7 @@ MirrorMoveEffects: jp z, HandleEnergyDiscardEffectSelection ret -.AISelection +MirrorMove_AISelection: ld a, $ff ldh [hTemp_ffa0], a ld a, DUELVARS_ARENA_CARD_LAST_TURN_EFFECT @@ -7513,7 +7540,7 @@ MirrorMoveEffects: ldh [hTemp_ffa0], a ret -.BeforeDamage +MirrorMove_BeforeDamage: ; if was attacked with Amnesia, apply it to the selected attack ld a, DUELVARS_ARENA_CARD_LAST_TURN_EFFECT call GetTurnDuelistVariable @@ -7550,12 +7577,12 @@ MirrorMoveEffects: jr z, .no_status push hl push de - call .ExecuteStatusEffect + call MirrorMove_ExecuteStatusEffect pop de pop hl .no_status ; hl is at DUELVARS_ARENA_CARD_LAST_TURN_SUBSTATUS2 -; apply substatus2 to self +; apply substatus2 to defending card ld e, DUELVARS_ARENA_CARD_SUBSTATUS2 ld a, [hli] ld [de], a @@ -7565,7 +7592,7 @@ MirrorMoveEffects: call ApplyAmnesiaToAttack ret -.AfterDamage: +MirrorMove_AfterDamage: ld a, [wNoDamageOrEffect] or a ret nz ; is unaffected @@ -7629,7 +7656,7 @@ MirrorMoveEffects: call SwapTurn ret -.ExecuteStatusEffect: +MirrorMove_ExecuteStatusEffect: ld c, a and PSN_DBLPSN jr z, .cnf_slp_prz @@ -8013,25 +8040,25 @@ PidgeottoWhirlwind_SwitchEffect: ret PidgeottoMirrorMove_AIEffect: - jp MirrorMoveEffects.AIEffect + jp MirrorMove_AIEffect PidgeottoMirrorMove_InitialEffect1: - jp MirrorMoveEffects.InitialEffect1 + jp MirrorMove_InitialEffect1 PidgeottoMirrorMove_InitialEffect2: - jp MirrorMoveEffects.InitialEffect2 + jp MirrorMove_InitialEffect2 PidgeottoMirrorMove_PlayerSelection: - jp MirrorMoveEffects.PlayerSelection + jp MirrorMove_PlayerSelection PidgeottoMirrorMove_AISelection: - jp MirrorMoveEffects.AISelection + jp MirrorMove_AISelection PidgeottoMirrorMove_BeforeDamage: - jp MirrorMoveEffects.BeforeDamage + jp MirrorMove_BeforeDamage PidgeottoMirrorMove_AfterDamage: - jp MirrorMoveEffects.AfterDamage + jp MirrorMove_AfterDamage SingEffect: call Sleep50PercentEffect @@ -8106,6 +8133,9 @@ HandlePlayerMetronomeEffect: ld a, EFFECTCMDTYPE_INITIAL_EFFECT_1 call TryExecuteEffectCommandFunction jr c, .failed + +; run initial effect 2 where player selection +; happens for some attacks ld a, EFFECTCMDTYPE_INITIAL_EFFECT_2 call TryExecuteEffectCommandFunction jr c, .set_carry @@ -8153,7 +8183,7 @@ FirstAid_DamageCheck: ret FirstAid_HealEffect: - lb de, 0, 10 + ld de, 10 call ApplyAndAnimateHPRecovery ret @@ -8333,10 +8363,10 @@ AISelectConversionColor: cp COLORLESS jr z, .skip_pkmn_atk ; skip colorless Pokemon ld e, FIRST_ATTACK_OR_PKMN_POWER - bank1call _CheckIfEnoughEnergiesToAttack + bank1call CheckIfEnoughEnergiesForGivenAttack jr nc, .found ld e, SECOND_ATTACK - bank1call _CheckIfEnoughEnergiesToAttack + bank1call CheckIfEnoughEnergiesForGivenAttack jr nc, .found .skip_pkmn_atk pop de @@ -8392,7 +8422,7 @@ ScrunchEffect: jp nc, SetWasUnsuccessful ld a, ATK_ANIM_SCRUNCH ld [wLoadedAttackAnimation], a - ld a, SUBSTATUS1_NO_DAMAGE_17 + ld a, SUBSTATUS1_NO_DAMAGE_SCRUNCH call ApplySubstatus1ToAttackingCard ret @@ -8470,7 +8500,6 @@ HealingWind_PlayAreaHealEffect: ld a, ATK_ANIM_HEALING_WIND_PLAY_AREA ld [wLoadedAttackAnimation], a - ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA call GetTurnDuelistVariable ld d, a @@ -8510,7 +8539,6 @@ HealingWind_PlayAreaHealEffect: inc e dec d jr nz, .loop_play_area - ret DragoniteLv41Slam_AIEffect: @@ -8551,12 +8579,12 @@ CopyPlayAreaHPFromBackup_Unreferenced: ld c, a ld l, DUELVARS_ARENA_CARD_HP ld de, wBackupPlayerAreaHP -.asm_2efd9 +.loop ld a, [de] inc de ld [hli], a dec c - jr nz, .asm_2efd9 + jr nz, .loop ret CatPunchEffect: @@ -8649,7 +8677,7 @@ MorphEffect: ; picks a random Pokemon in the Deck to morph. ; needs to be a Basic Pokemon that isn't Ditto ; returns carry if no Pokemon were found. -.PickRandomBasicPokemonFromDeck +.PickRandomBasicPokemonFromDeck: call CreateDeckCardList ret c ; empty deck ld hl, wDuelTempList @@ -8911,6 +8939,7 @@ CheckIfThereAreAnyEnergyCardsAttached: ; [hTemp_ffa0] = play area location ; [hTempPlayAreaLocation_ffa1] = index of energy card HandlePokemonAndEnergySelectionScreen: +.start bank1call HasAlivePokemonInPlayArea bank1call OpenPlayAreaScreenForSelection ret c ; exit if B is pressed @@ -8921,7 +8950,7 @@ HandlePokemonAndEnergySelectionScreen: jr nz, .has_energy ldtx hl, NoEnergyCardsText call DrawWideTextBox_WaitForInput - jr HandlePokemonAndEnergySelectionScreen ; loop back to start + jr .start ; loop back to start .has_energy ldh a, [hCurMenuItem] @@ -9623,7 +9652,7 @@ PokemonCenter_HealDiscardEnergyEffect: ldh a, [hTempPlayAreaLocation_ff9d] or CARD_LOCATION_PLAY_AREA ld e, a - ld a, $00 + ld a, DUELVARS_CARD_LOCATIONS call GetTurnDuelistVariable .loop_deck ld a, [hl] @@ -9830,7 +9859,7 @@ CreatePlayableStage2PokemonCardListFromHand: ; return carry if Stage2 card in a cannot evolve any ; of the Basic Pokemon in Play Area through Pokemon Breeder. -.CheckIfCanEvolveAnyPlayAreaBasicCard +.CheckIfCanEvolveAnyPlayAreaBasicCard: push de ld d, a call LoadCardDataToBuffer2_FromDeckIndex @@ -10251,12 +10280,12 @@ Pokedex_PlayerSelection: ld [hl], a ld c, a ld hl, wDuelTempList + 10 -.asm_2f99e +.loop_find_last_entry ld a, [hli] cp c - jr nz, .asm_2f99e + jr nz, .loop_find_last_entry dec hl - ld [hl], $00 ; overwrite order number with 0 + ld [hl], 0 ; overwrite order number with 0 bank1call PrintSortNumberInCardList_CallFromPointer jr .read_input @@ -10321,15 +10350,15 @@ LassEffect: ; do for Turn Duelist ; fallthrough -.ShuffleDuelistHandTrainerCardsInDeck +.ShuffleDuelistHandTrainerCardsInDeck: call CreateHandCardList call SortCardsInDuelTempListByID xor a ldh [hCurSelectionItem], a - ld hl, wDuelTempList ; go through all cards in hand ; and any Trainer card is returned to deck. + ld hl, wDuelTempList .loop_hand ld a, [hli] ldh [hTempCardIndex_ff98], a @@ -10354,7 +10383,7 @@ LassEffect: call nz, ShuffleCardsInDeck ; only show list if there were any Trainer cards ret -.DisplayLinkOrCPUHand +.DisplayLinkOrCPUHand: ld a, [wDuelType] or a jr z, .cpu_opp @@ -10375,7 +10404,7 @@ LassEffect: call SwapTurn ret -.DisplayOppHand +.DisplayOppHand: call CreateHandCardList jr c, .no_cards bank1call InitAndDrawCardListScreenLayout diff --git a/src/engine/menus/duel.asm b/src/engine/menus/duel.asm index 6d623ff..20e99ec 100644 --- a/src/engine/menus/duel.asm +++ b/src/engine/menus/duel.asm @@ -2164,7 +2164,7 @@ GetFirstSetPrizeCard: ret ; returns 1 shifted left by c bits -.GetPrizeMask +.GetPrizeMask: push bc ld a, c ld b, $1 diff --git a/src/home/duel.asm b/src/home/duel.asm index 13c107a..94ac9b1 100644 --- a/src/home/duel.asm +++ b/src/home/duel.asm @@ -1844,7 +1844,7 @@ DealConfusionDamageToSelf:: ; given a damage value at wDamage: ; - if the non-turn holder's arena card is weak to the turn holder's arena card color: double damage ; - if the non-turn holder's arena card resists the turn holder's arena card color: reduce damage by 30 -; - also apply Pluspower, Defender, and other kinds of damage reduction accordingly +; - also apply PlusPower, Defender, and other kinds of damage reduction accordingly ; return resulting damage in de ApplyDamageModifiers_DamageToTarget:: xor a @@ -1900,7 +1900,7 @@ ApplyDamageModifiers_DamageToTarget:: set RESISTANCE, [hl] .check_pluspower_and_defender ld b, CARD_LOCATION_ARENA - call ApplyAttachedPluspower + call ApplyAttachedPlusPower call SwapTurn ld b, CARD_LOCATION_ARENA call ApplyAttachedDefender @@ -1964,7 +1964,7 @@ ApplyDamageModifiers_DamageToSelf:: set RESISTANCE, [hl] .not_resistant ld b, CARD_LOCATION_ARENA - call ApplyAttachedPluspower + call ApplyAttachedPlusPower ld b, CARD_LOCATION_ARENA call ApplyAttachedDefender bit 7, d ; test for underflow @@ -1973,8 +1973,8 @@ ApplyDamageModifiers_DamageToSelf:: ld de, 0 ret -; increases de by 10 points for each Pluspower found in location b -ApplyAttachedPluspower:: +; increases de by 10 points for each PlusPower found in location b +ApplyAttachedPlusPower:: push de call GetTurnDuelistVariable ld de, PLUSPOWER @@ -2122,12 +2122,12 @@ DealDamageToPlayAreaPokemon:: or a jr z, .turn_swapped ld b, CARD_LOCATION_ARENA - call ApplyAttachedPluspower + call ApplyAttachedPlusPower jr .next .turn_swapped call SwapTurn ld b, CARD_LOCATION_ARENA - call ApplyAttachedPluspower + call ApplyAttachedPlusPower call SwapTurn .next ld a, [wLoadedAttackCategory] @@ -2270,7 +2270,7 @@ GetPlayAreaCardRetreatCost:: ; move all turn holder's card with ID at de to the discard pile ; that are currently in the Play Area -; this is used to discard all attached Pluspowers and Defenders +; this is used to discard all attached PlusPowers and Defenders MoveCardToDiscardPileIfInPlayArea:: ld c, e ld b, d diff --git a/src/home/substatus.asm b/src/home/substatus.asm index 963baab..007f422 100644 --- a/src/home/substatus.asm +++ b/src/home/substatus.asm @@ -71,17 +71,17 @@ HandleDamageReductionExceptSubstatus2:: cp SUBSTATUS1_NO_DAMAGE_STIFFEN jr z, .no_damage - cp SUBSTATUS1_NO_DAMAGE_10 + cp SUBSTATUS1_NO_DAMAGE_WITHDRAW jr z, .no_damage - cp SUBSTATUS1_NO_DAMAGE_11 + cp SUBSTATUS1_NO_DAMAGE_HIDE_IN_SHELL jr z, .no_damage - cp SUBSTATUS1_NO_DAMAGE_17 + cp SUBSTATUS1_NO_DAMAGE_SCRUNCH jr z, .no_damage cp SUBSTATUS1_REDUCE_BY_10 jr z, .reduce_damage_by_10 cp SUBSTATUS1_REDUCE_BY_20 jr z, .reduce_damage_by_20 - cp SUBSTATUS1_HARDEN + cp SUBSTATUS1_PREVENT_LESS_THAN_40 jr z, .prevent_less_than_40_damage cp SUBSTATUS1_HALVE_DAMAGE jr z, .halve_damage @@ -627,7 +627,7 @@ CheckUnableToRetreatDueToEffect:: call GetTurnDuelistVariable or a ret z - cp SUBSTATUS2_UNABLE_RETREAT + cp SUBSTATUS2_ACID jr z, .cant_retreat or a ret diff --git a/src/hram.asm b/src/hram.asm index bee2cbc..dc11faf 100644 --- a/src/hram.asm +++ b/src/hram.asm @@ -85,19 +85,20 @@ hTemp_ffa0:: ; ffa0 ; a PLAY_AREA_* constant (0: arena card, 1-5: bench card) hTempPlayAreaLocation_ffa1:: ; ffa1 - -; parameter to be used by the AI's Pkmn Power effect -hAIPkmnPowerEffectParam:: ; ffa1 ds $1 -UNION - ; $ff-terminated list of cards to be discarded upon retreat hTempRetreatCostCards:: ; ffa2 ds $6 NEXTU + ds $1 + +; parameter to be used by the AI's Pkmn Power effect +hAIPkmnPowerEffectParam:: ; ffa1 + ds $1 + ; parameters chosen by AI in Energy Trans routine. ; the deck index (0-59) of the energy card to transfer ; and the Play Area location (PLAY_AREA_*) of card to receive that energy card. @@ -111,8 +112,6 @@ hPlayAreaEffectTarget:: ; ffa2 hAIEnergyTransPlayAreaLocation:: ; ffa3 ds $1 -ENDU - NEXTU ; list of various items, such as diff --git a/src/macros/wram.asm b/src/macros/wram.asm index 1d4eec7..321b925 100644 --- a/src/macros/wram.asm +++ b/src/macros/wram.asm @@ -168,12 +168,12 @@ MACRO duel_vars \1Bench4CardAttachedDefender:: ds $1 \1Bench5CardAttachedDefender:: ds $1 -\1ArenaCardAttachedPluspower:: ds $1 -\1Bench1CardAttachedPluspower:: ds $1 -\1Bench2CardAttachedPluspower:: ds $1 -\1Bench3CardAttachedPluspower:: ds $1 -\1Bench4CardAttachedPluspower:: ds $1 -\1Bench5CardAttachedPluspower:: ds $1 +\1ArenaCardAttachedPlusPower:: ds $1 +\1Bench1CardAttachedPlusPower:: ds $1 +\1Bench2CardAttachedPlusPower:: ds $1 +\1Bench3CardAttachedPlusPower:: ds $1 +\1Bench4CardAttachedPlusPower:: ds $1 +\1Bench5CardAttachedPlusPower:: ds $1 ds $1 diff --git a/src/wram.asm b/src/wram.asm index a2568ab..3acb74e 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -432,7 +432,7 @@ wNumPlayAreaItems:: ; cbc8 ; such as PrintPlayAreaCardLocation, PrintPlayAreaCardInformation and PrintPlayAreaCardHeader wCurPlayAreaSlot:: ; cbc9 -; X position to display the attached energies, HP bar, and Pluspower/Defender icons +; X position to display the attached energies, HP bar, and PlusPower/Defender icons ; obviously different for player and opponent side. used by DrawDuelHUD. wHUDEnergyAndHPBarsX:: ; cbc9 ds $1 @@ -441,7 +441,7 @@ wHUDEnergyAndHPBarsX:: ; cbc9 ; such as PrintPlayAreaCardLocation, PrintPlayAreaCardInformation and PrintPlayAreaCardHeader wCurPlayAreaY:: ; cbca -; Y position to display the attached energies, HP bar, and Pluspower/Defender icons +; Y position to display the attached energies, HP bar, and PlusPower/Defender icons ; obviously different for player and opponent side. used by DrawDuelHUD. wHUDEnergyAndHPBarsY:: ; cbca @@ -1150,8 +1150,8 @@ wAIPlayAreaCardToSwitch:: ; cdd5 ds $1 ; the index of attack chosen by AI -; to use with Pluspower. -wAIPluspowerAttack:: ; cdd6 +; to use with PlusPower. +wAIPlusPowerAttack:: ; cdd6 ds $1 ; whether AI is allowed to play an energy card