diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/constants/duel_constants.asm | 26 | ||||
-rw-r--r-- | src/engine/bank01.asm | 219 | ||||
-rw-r--r-- | src/engine/effect_functions.asm | 2 | ||||
-rw-r--r-- | src/engine/home.asm | 82 | ||||
-rw-r--r-- | src/hram.asm | 2 | ||||
-rw-r--r-- | src/wram.asm | 2 |
6 files changed, 193 insertions, 140 deletions
diff --git a/src/constants/duel_constants.asm b/src/constants/duel_constants.asm index 80fe3b0..dd448aa 100644 --- a/src/constants/duel_constants.asm +++ b/src/constants/duel_constants.asm @@ -167,6 +167,32 @@ EFFECTCMDTYPE_PKMN_POWER_TRIGGER EQU $07 EFFECTCMDTYPE_AI EQU $09 EFFECTCMDTYPE_UNKNOWN_08 EQU $08 +; OppAction_* constants (OppActionTable) + const_def + const OPPACTION_ERROR ; $00 + const OPPACTION_PLAY_BASIC_PKMN ; $01 + const OPPACTION_EVOLVE_PKMN ; $02 + const OPPACTION_PLAY_ENERGY ; $03 + const OPPACTION_ATTEMPT_RETREAT ; $04 + const OPPACTION_FINISH_NO_ATTACK ; $05 + const OPPACTION_PLAY_TRAINER ; $06 + const OPPACTION_EXECUTE_TRAINER_EFFECTS ; $07 + const OPPACTION_BEGIN_ATTACK ; $08 + const OPPACTION_USE_ATTACK ; $09 + const OPPACTION_DEAL_ATTACK_DAMAGE ; $0a + const OPPACTION_DRAW_CARD ; $0b + const OPPACTION_USE_PKMN_POWER ; $0c + const OPPACTION_EXECUTE_PKMN_POWER_EFFECT ; $0d + const OPPACTION_FORCE_SWITCH_ACTIVE ; $0e + const OPPACTION_NO_ACTION_0F ; $0f + const OPPACTION_NO_ACTION_10 ; $10 + const OPPACTION_TOSS_COIN_A_TIMES ; $11 + const OPPACTION_6B30 ; $12 + const OPPACTION_NO_ACTION_13 ; $13 + const OPPACTION_6B3E ; $14 + const OPPACTION_6B15 ; $15 + const OPPACTION_DUEL_MAIN_SCENE ; $16 + ; wNoDamageOrEffect constants NO_DAMAGE_OR_EFFECT_AGILITY EQU $01 NO_DAMAGE_OR_EFFECT_BARRIER EQU $02 diff --git a/src/engine/bank01.asm b/src/engine/bank01.asm index c08af4e..f0ac3ae 100644 --- a/src/engine/bank01.asm +++ b/src/engine/bank01.asm @@ -346,7 +346,7 @@ DuelMainInterface: ; 426d (1:426d) cp DUELIST_TYPE_PLAYER jr z, PrintDuelMenuAndHandleInput cp DUELIST_TYPE_LINK_OPP - jp z, Func_6911 + jp z, DoLinkOpponentTurn ; DUELIST_TYPE_AI_OPP xor a ld [wVBlankCounter], a @@ -417,8 +417,8 @@ DuelMenuFunctionTable: ; 42f1 (1:42f1) Func_42fd: ; 42fd (1:42fd) call DrawCardFromDeck call nc, AddCardToHand - ld a, $0b - call SetAIAction_SerialSendDuelData + ld a, OPPACTION_DRAW_CARD + call SetOppAction_SerialSendDuelData jp PrintDuelMenuAndHandleInput.menu_items_printed ; 0x430b @@ -532,8 +532,8 @@ DuelMenu_Done: ; 439a (1:439a) call DoPracticeDuelAction ; always jumps on practice duel (no action requires player to select Done) jp c, RestartPracticeDuelTurn - ld a, $05 - call SetAIAction_SerialSendDuelData + ld a, OPPACTION_FINISH_NO_ATTACK + call SetOppAction_SerialSendDuelData call ClearNonTurnTemporaryDuelvars ret @@ -559,8 +559,8 @@ DuelMenu_Retreat: ; 43ab (1:43ab) ld [wBenchSelectedPokemon], a ld a, [wBenchSelectedPokemon] ldh [hTempPlayAreaLocation_ffa1], a - ld a, $04 - call SetAIAction_SerialSendDuelData + ld a, OPPACTION_ATTEMPT_RETREAT + call SetOppAction_SerialSendDuelData call AttemptRetreat jr nc, .done call DrawDuelMainScene @@ -591,8 +591,8 @@ DuelMenu_Retreat: ; 43ab (1:43ab) call ReturnRetreatCostCardsToArena pop af jp c, DuelMainInterface - ld a, $04 - call SetAIAction_SerialSendDuelData + ld a, OPPACTION_ATTEMPT_RETREAT + call SetOppAction_SerialSendDuelData call AttemptRetreat .done @@ -636,18 +636,18 @@ OpenPlayerHandScreen: ; 4436 (1:4436) bit TYPE_TRAINER_F, c jr nz, .trainer_card bit TYPE_ENERGY_F, c - jr nz, UseEnergyCard - call UsePokemonCard + jr nz, PlayEnergyCard + call PlayPokemonCard jr c, ReloadCardListScreen ; jump if card not played jp DuelMainInterface .trainer_card - call UseTrainerCard + call PlayTrainerCard jr c, ReloadCardListScreen ; jump if card not played jp DuelMainInterface -; use the energy card with deck index at hTempCardIndex_ff98 +; play the energy card with deck index at hTempCardIndex_ff98 ; c contains the type of energy card being played -UseEnergyCard: ; 4477 (1:4477) +PlayEnergyCard: ; 4477 (1:4477) ld a, c cp TYPE_ENERGY_WATER jr nz, .not_water_energy @@ -672,8 +672,8 @@ UseEnergyCard: ; 4477 (1:4477) ldh [hTemp_ffa0], a call PutHandCardInPlayArea call PrintPlayAreaCardList_EnableLCD - ld a, $03 - call SetAIAction_SerialSendDuelData + ld a, OPPACTION_PLAY_ENERGY + call SetOppAction_SerialSendDuelData call PrintAttachedEnergyToPokemon jp DuelMainInterface @@ -703,11 +703,11 @@ ReloadCardListScreen: ; 44d2 (1:44d2) jp OpenPlayerHandScreen.handle_input ; 0x44db -; use a basic Pokemon card on the arena or bench, or place an stage 1 or 2 +; place a basic Pokemon card on the arena or bench, or place an stage 1 or 2 ; Pokemon card over a Pokemon card already in play to evolve it. ; the card to use is loaded in wLoadedCard1 and its deck index is at hTempCardIndex_ff98. ; return nc if the card was played, carry if it wasn't. -UsePokemonCard: ; 44db (1:44db) +PlayPokemonCard: ; 44db (1:44db) ld a, [wLoadedCard1Stage] or a ; BASIC jr nz, .try_evolve ; jump if the card being played is a Stage 1 or 2 Pokemon @@ -722,8 +722,8 @@ UsePokemonCard: ; 44db (1:44db) add DUELVARS_ARENA_CARD_STAGE call GetTurnDuelistVariable ld [hl], BASIC - ld a, $01 - call SetAIAction_SerialSendDuelData + ld a, OPPACTION_PLAY_BASIC_PKMN + call SetOppAction_SerialSendDuelData ldh a, [hTempCardIndex_ff98] call LoadCardDataToBuffer1_FromDeckIndex ld a, 20 @@ -793,8 +793,8 @@ UsePokemonCard: ; 44db (1:44db) ldh [hTempPlayAreaLocation_ffa1], a call EvolvePokemonCard jr c, .try_evolve_loop ; jump if evolution wasn't successsful somehow - ld a, $02 - call SetAIAction_SerialSendDuelData + ld a, OPPACTION_EVOLVE_PKMN + call SetOppAction_SerialSendDuelData call PrintPlayAreaCardList_EnableLCD call PrintPokemonEvolvedIntoPokemon call Func_161e @@ -5795,8 +5795,9 @@ ReturnRetreatCostCardsToArena: ; 6564 (1:6564) jr .loop ; 0x657a -; discard retreat cost energy cards and attempt retreat. +; discard retreat cost energy cards and attempt retreat of the arena card. ; return carry if unable to retreat this turn due to unsuccessful confusion check +; if successful, the retreated card is replaced with a bench Pokemon card AttemptRetreat: ; 657a (1:657a) call DiscardRetreatCostCards ldh a, [hTemp_ffa0] @@ -5934,7 +5935,9 @@ DrawHPBar: ; 6614 (1:6614) ret ; 0x6635 -Func_6635: ; 6635 (1:6635) +; when an opponent's Pokemon card attacks, this displays a screen +; containing the description and information of the used move +DisplayOpponentUsedMoveScreen: ; 6635 (1:6635) call ZeroObjectPositionsAndToggleOAMCopy call EmptyScreen call LoadDuelCardSymbolTiles @@ -6227,10 +6230,11 @@ CheckSkipDelayAllowed: ; 67b2 (1:67b2) ret ; 0x67be -; related to ai taking their turn in a duel -; called multiple times during one ai turn +; related to AI taking their turn in a duel +; called multiple times during one AI turn +; each call results in the execution of an OppActionTable function AIMakeDecision: ; 67be (1:67be) - ldh [hAIActionTableIndex], a + ldh [hOppActionTableIndex], a ld hl, wSkipDuelistIsThinkingDelay ld a, [hl] ld [hl], $0 @@ -6243,13 +6247,13 @@ AIMakeDecision: ; 67be (1:67be) jr c, .delay_loop .skip_delay - ldh a, [hAIActionTableIndex] - ld hl, wAITurnEnded + ldh a, [hOppActionTableIndex] + ld hl, wOpponentTurnEnded ld [hl], 0 - ld hl, AIActionTable + ld hl, OppActionTable call JumpToFunctionInTable ld a, [wDuelFinished] - ld hl, wAITurnEnded + ld hl, wOpponentTurnEnded or [hl] jr nz, .turn_ended ld a, [wSkipDuelistIsThinkingDelay] @@ -6438,12 +6442,14 @@ PrintPokemonEvolvedIntoPokemon: ; 68fa (1:68fa) ret ; 0x6911 -Func_6911: ; 6911 (1:6911) +; handle the opponent's turn in a link duel +; loop until either [wOpponentTurnEnded] or [wDuelFinished] is non-0 +DoLinkOpponentTurn: ; 6911 (1:6911) xor a - ld [wAITurnEnded], a + ld [wOpponentTurnEnded], a xor a ld [wSkipDuelistIsThinkingDelay], a -.asm_6919 +.link_opp_turn_loop ld a, [wSkipDuelistIsThinkingDelay] or a jr nz, .asm_6932 @@ -6464,60 +6470,64 @@ Func_6911: ; 6911 (1:6911) jp nz, DuelTransmissionError xor a ld [wSkipDuelistIsThinkingDelay], a - ldh a, [hAIActionTableIndex] + ldh a, [hOppActionTableIndex] cp $17 jp nc, DuelTransmissionError - ld hl, AIActionTable + ld hl, OppActionTable call JumpToFunctionInTable - ld hl, wAITurnEnded + ld hl, wOpponentTurnEnded ld a, [wDuelFinished] or [hl] - jr z, .asm_6919 + jr z, .link_opp_turn_loop ret ; 0x695e -AIActionTable: ; 695e (1:695e) +; actions for the opponent's turn +; on a link duel, this is referenced by DoLinkOpponentTurn in a loop (on each opponent's HandleTurn) +; on a non-link duel (vs AI opponent), this is referenced by AIMakeDecision +OppActionTable: ; 695e (1:695e) dw DuelTransmissionError - dw AIAction_PlayBenchPokemon - dw AIAction_EvolvePokemon - dw AIAction_UseEnergyCard - dw AIAction_TryRetreat - dw AIAction_FinishedTurnNoAttack - dw AIAction_UseTrainerCard - dw AIAction_TryExecuteEffect - dw AIAction_Attack - dw AIAction_AttackEffect - dw AIAction_AttackDamage - dw AIAction_DrawCard - dw AIAction_UsePokemonPower - dw AIAction_6b07 - dw AIAction_ForceOpponentSwitchActive - dw AIAction_NoAction - dw AIAction_NoAction - dw AIAction_TossCoinATimes - dw AIAction_6b30 - dw AIAction_NoAction - dw AIAction_6b3e - dw AIAction_6b15 - dw AIAction_DrawDuelMainScene - -AIAction_DrawCard: ; 698c (1:698c) + dw OppAction_PlayBasicPokemonCard + dw OppAction_EvolvePokemonCard + dw OppAction_PlayEnergyCard + dw OppAction_AttemptRetreat + dw OppAction_FinishTurnWithoutAttacking + dw OppAction_PlayTrainerCard + dw OppAction_ExecuteTrainerCardEffectCommands + dw OppAction_BeginUseAttack + dw OppAction_UseAttack + dw OppAction_DealAttackDamage + dw OppAction_DrawCard + dw OppAction_UsePokemonPower + dw OppAction_ExecutePokemonPowerEffect + dw OppAction_ForceSwitchActive + dw OppAction_NoAction + dw OppAction_NoAction + dw OppAction_TossCoinATimes + dw OppAction_6b30 + dw OppAction_NoAction + dw OppAction_6b3e + dw OppAction_6b15 + dw OppAction_DrawDuelMainScene + +OppAction_DrawCard: ; 698c (1:698c) call DrawCardFromDeck call nc, AddCardToHand ret ; 0x6993 -AIAction_FinishedTurnNoAttack: ; 6993 (1:6993) +OppAction_FinishTurnWithoutAttacking: ; 6993 (1:6993) call DrawDuelMainScene call ClearNonTurnTemporaryDuelvars ldtx hl, FinishedTurnWithoutAttackingText call DrawWideTextBox_WaitForInput ld a, 1 - ld [wAITurnEnded], a + ld [wOpponentTurnEnded], a ret ; 0x69a5 -AIAction_UseEnergyCard: ; 69a5 (1:69a5) +; attach an energy card from hand to the arena or a benched Pokemon +OppAction_PlayEnergyCard: ; 69a5 (1:69a5) ldh a, [hTempPlayAreaLocation_ffa1] ldh [hTempPlayAreaLocation_ff9d], a ld e, a @@ -6534,7 +6544,8 @@ AIAction_UseEnergyCard: ; 69a5 (1:69a5) ret ; 0x69c5 -AIAction_EvolvePokemon: ; 69c5 (1:69c5) +; evolve a Pokemon card in the arena or in the bench +OppAction_EvolvePokemonCard: ; 69c5 (1:69c5) ldh a, [hTempPlayAreaLocation_ffa1] ldh [hTempPlayAreaLocation_ff9d], a ldh a, [hTemp_ffa0] @@ -6548,7 +6559,8 @@ AIAction_EvolvePokemon: ; 69c5 (1:69c5) ret ; 0x69e0 -AIAction_PlayBenchPokemon: ; 69e0 (1:69e0) +; place a basic Pokemon card from hand in the bench +OppAction_PlayBasicPokemonCard: ; 69e0 (1:69e0) ldh a, [hTemp_ffa0] ldh [hTempCardIndex_ff98], a call PutHandPokemonCardInPlayArea @@ -6564,7 +6576,10 @@ AIAction_PlayBenchPokemon: ; 69e0 (1:69e0) ret ; 0x69ff -AIAction_TryRetreat: ; 69ff (1:69ff) +; attempt the retreat of the active Pokemon card +; if successful, discard the required energy cards for retreat and +; swap the retreated card with a Pokemon card from the bench +OppAction_AttemptRetreat: ; 69ff (1:69ff) ld a, DUELVARS_ARENA_CARD call GetTurnDuelistVariable push af @@ -6586,7 +6601,8 @@ AIAction_TryRetreat: ; 69ff (1:69ff) ret ; 0x6a23 -AIAction_UseTrainerCard: ; 6a23 (1:6a23) +; play trainer card from hand +OppAction_PlayTrainerCard: ; 6a23 (1:6a23) call LoadNonPokemonCardEffectCommands call DisplayUsedTrainerCardDetailScreen call PrintUsedTrainerCardDescription @@ -6596,8 +6612,9 @@ AIAction_UseTrainerCard: ; 6a23 (1:6a23) ret ; 0x6a35 -; for trainer card effects -AIAction_TryExecuteEffect: ; 6a35 (1:6a35) +; execute the effect commands of the trainer card that is being played +; used only for Trainer cards, as a continuation of OppAction_PlayTrainerCard +OppAction_ExecuteTrainerCardEffectCommands: ; 6a35 (1:6a35) ld a, EFFECTCMDTYPE_DISCARD_ENERGY call TryExecuteEffectCommandFunction ld a, EFFECTCMDTYPE_BEFORE_DAMAGE @@ -6610,10 +6627,9 @@ AIAction_TryExecuteEffect: ; 6a35 (1:6a35) ret ; 0x6a4e -; determine if an attack is successful -; if no, end the turn early -; if yes, AIAction_AttackEffect and AIAction_AttackDamage can be called next -AIAction_Attack: ; 6a4e (1:6a4e) +; begin the execution of an attack and handle the attack being +; possibly unsuccessful due to Sand Attack or Smokescreen +OppAction_BeginUseAttack: ; 6a4e (1:6a4e) ldh a, [hTempCardIndex_ff9f] ld d, a ldh a, [hTemp_ffa0] @@ -6623,34 +6639,39 @@ AIAction_Attack: ; 6a4e (1:6a4e) ld a, $01 ld [wSkipDuelistIsThinkingDelay], a call CheckSandAttackOrSmokescreenSubstatus - jr c, .has_status_effect + jr c, .has_status ld a, DUELVARS_ARENA_CARD_STATUS call GetTurnDuelistVariable and CNF_SLP_PRZ cp CONFUSED - jr z, .has_status_effect + jr z, .has_status call ExchangeRNG ret -.has_status_effect + +; we make it here is attacker is affected by +; Sand Attack, Smokescreen, or confusion +.has_status call DrawDuelMainScene call PrintPokemonsAttackText call WaitForWideTextBoxInput call ExchangeRNG call HandleSandAttackOrSmokescreenSubstatus - ret nc ; attack is successful + ret nc ; return if attack is successful (won the coin toss) call ClearNonTurnTemporaryDuelvars - ; only end the turn if the attack fails + ; end the turn if the attack fails ld a, 1 - ld [wAITurnEnded], a + ld [wOpponentTurnEnded], a ret ; 0x6a8c -AIAction_AttackEffect: ; 6a8c (1:6a8c) +; display the attack used by the opponent, and handle +; EFFECTCMDTYPE_DISCARD_ENERGY and confusion damage to self +OppAction_UseAttack: ; 6a8c (1:6a8c) ld a, EFFECTCMDTYPE_DISCARD_ENERGY call TryExecuteEffectCommandFunction call CheckSelfConfusionDamage jr c, .confusion_damage - call Func_6635 + call DisplayOpponentUsedMoveScreen call PrintPokemonsAttackText call WaitForWideTextBoxInput call ExchangeRNG @@ -6659,20 +6680,21 @@ AIAction_AttackEffect: ; 6a8c (1:6a8c) ret .confusion_damage call DealConfusionDamageToSelf - ; only end the turn if the attack fails + ; end the turn if dealing damage to self due to confusion ld a, 1 - ld [wAITurnEnded], a + ld [wOpponentTurnEnded], a ret ; 0x6ab1 -AIAction_AttackDamage: ; 6ab1 (1:6ab1) - call Func_179a +OppAction_DealAttackDamage: ; 6ab1 (1:6ab1) + call DealAttackDamage ld a, 1 - ld [wAITurnEnded], a + ld [wOpponentTurnEnded], a ret ; 0x6aba -AIAction_ForceOpponentSwitchActive: ; 6aba (1:6aba) +; force the player to switch the active Pokemon with a benched Pokemon +OppAction_ForceSwitchActive: ; 6aba (1:6aba) ldtx hl, SelectPkmnOnBenchToSwitchWithActiveText call DrawWideTextBox_WaitForInput call SwapTurn @@ -6688,7 +6710,7 @@ AIAction_ForceOpponentSwitchActive: ; 6aba (1:6aba) ret ; 0x6ad9 -AIAction_UsePokemonPower: ; 6ad9 (1:6ad9) +OppAction_UsePokemonPower: ; 6ad9 (1:6ad9) ldh a, [hTempCardIndex_ff9f] ld d, a ld e, $00 @@ -6711,7 +6733,8 @@ AIAction_UsePokemonPower: ; 6ad9 (1:6ad9) ret ; 0x6b07 -AIAction_6b07: ; 6b07 (1:6b07) +; execute the EFFECTCMDTYPE_BEFORE_DAMAGE command of the used Pokemon Power +OppAction_ExecutePokemonPowerEffect: ; 6b07 (1:6b07) call Func_7415 ld a, EFFECTCMDTYPE_BEFORE_DAMAGE call TryExecuteEffectCommandFunction @@ -6720,7 +6743,7 @@ AIAction_6b07: ; 6b07 (1:6b07) ret ; 0x6b15 -AIAction_6b15: ; 6b15 (1:6b15) +OppAction_6b15: ; 6b15 (1:6b15) ld a, EFFECTCMDTYPE_AFTER_DAMAGE call TryExecuteEffectCommandFunction ld a, $01 @@ -6728,12 +6751,12 @@ AIAction_6b15: ; 6b15 (1:6b15) ret ; 0x6b20 -AIAction_DrawDuelMainScene: ; 6b20 (1:6b20) +OppAction_DrawDuelMainScene: ; 6b20 (1:6b20) call DrawDuelMainScene ret ; 0x6b24 -AIAction_TossCoinATimes: ; 6b24 (1:6b24) +OppAction_TossCoinATimes: ; 6b24 (1:6b24) call SerialRecv8Bytes call TossCoinATimes ld a, $01 @@ -6741,7 +6764,7 @@ AIAction_TossCoinATimes: ; 6b24 (1:6b24) ret ; 0x6b30 -AIAction_6b30: ; 6b30 (1:6b30) +OppAction_6b30: ; 6b30 (1:6b30) ldh a, [hWhoseTurn] push af ldh a, [hTemp_ffa0] @@ -6752,7 +6775,7 @@ AIAction_6b30: ; 6b30 (1:6b30) ret ; 0x6b3e -AIAction_6b3e: ; 6b3e (1:6b3e) +OppAction_6b3e: ; 6b3e (1:6b3e) call DrawDuelMainScene ld a, DUELVARS_ARENA_CARD_STATUS call GetTurnDuelistVariable @@ -6782,7 +6805,7 @@ AIAction_6b3e: ; 6b3e (1:6b3e) ret ; 0x6b7d -AIAction_NoAction: ; 6b7d (1:6b7d) +OppAction_NoAction: ; 6b7d (1:6b7d) ret ; 0x6b7e diff --git a/src/engine/effect_functions.asm b/src/engine/effect_functions.asm index c8d8f24..ab7bd38 100644 --- a/src/engine/effect_functions.asm +++ b/src/engine/effect_functions.asm @@ -110,7 +110,7 @@ Func_2c08c: push de push af ld a, $11 - call SetAIAction_SerialSendDuelData + call SetOppAction_SerialSendDuelData pop af pop de call SerialSend8Bytes diff --git a/src/engine/home.asm b/src/engine/home.asm index 6f8f6d5..5271270 100644 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -2812,19 +2812,21 @@ ExchangeRNG: ; 0f58 (0:0f58) jp c, DuelTransmissionError ret -; sets hAIActionTableIndex to an AI action specified in register a. -; send 10 bytes of data to the other game from hAIActionTableIndex, hTempCardIndex_ff9f, +; sets hOppActionTableIndex to an AI action specified in register a. +; send 10 bytes of data to the other game from hOppActionTableIndex, hTempCardIndex_ff9f, ; hTemp_ffa0, and hTempPlayAreaLocation_ffa1, and hTempRetreatCostCards. ; finally exchange RNG data. -SetAIAction_SerialSendDuelData: ; 0f7f (0:0f7f) +; the receiving side will use this data to read the OPP_ACTION_* value in +; [hOppActionTableIndex] and match it by calling the correspoding OppAction* function +SetOppAction_SerialSendDuelData: ; 0f7f (0:0f7f) push hl push bc - ldh [hAIActionTableIndex], a + ldh [hOppActionTableIndex], a ld a, DUELVARS_DUELIST_TYPE call GetNonTurnDuelistVariable cp DUELIST_TYPE_LINK_OPP jr nz, .not_link - ld hl, hAIActionTableIndex + ld hl, hOppActionTableIndex ld bc, 10 call SerialSendBytes call ExchangeRNG @@ -2834,13 +2836,13 @@ SetAIAction_SerialSendDuelData: ; 0f7f (0:0f7f) ret ; 0xf9b -; receive 10 bytes of data from wSerialRecvBuf and store them into hAIActionTableIndex, +; receive 10 bytes of data from wSerialRecvBuf and store them into hOppActionTableIndex, ; hTempCardIndex_ff9f, hTemp_ffa0, and hTempPlayAreaLocation_ffa1, ; and hTempRetreatCostCards. also exchange RNG data. SerialRecvDuelData: ; 0f9b (0:0f9b) push hl push bc - ld hl, hAIActionTableIndex + ld hl, hOppActionTableIndex ld bc, 10 call SerialRecvBytes call ExchangeRNG @@ -3789,8 +3791,8 @@ EvolvePokemonCard: ; 13a2 (0:13a2) ldh a, [hTempCardIndex_ff98] call PutHandCardInPlayArea ; update the Pokemon's HP with the difference - ldh a, [hTempPlayAreaLocation_ff9d] - ld a, e ; derp + ldh a, [hTempPlayAreaLocation_ff9d] ; derp + ld a, e add DUELVARS_ARENA_CARD_HP call GetTurnDuelistVariable ld a, [wLoadedCard2HP] @@ -4461,7 +4463,7 @@ Func_16f6: ; 16f6 (0:16f6) bank1call ClearNonTurnTemporaryDuelvars_CopyStatus ret -; use attack or Pokemon Power +; Use an attack (from DuelMenu_Attack) or a Pokemon Power (from DuelMenu_PkmnPower) UseAttackOrPokemonPower: ; 1730 (0:1730) ld a, [wSelectedMoveIndex] ld [wPlayerAttackingMoveIndex], a @@ -4477,22 +4479,22 @@ UseAttackOrPokemonPower: ; 1730 (0:1730) call TryExecuteEffectCommandFunction jp c, DrawWideTextBox_WaitForInput_ReturnCarry call CheckSandAttackOrSmokescreenSubstatus - jr c, .asm_1766 + jr c, .sand_attack_smokescreen ld a, EFFECTCMDTYPE_INITIAL_EFFECT_2 call TryExecuteEffectCommandFunction jp c, ReturnCarry - call Func_1874 - jr .asm_1777 -.asm_1766 - call Func_1874 + call SendAttackDataToLinkOpponent + jr .next +.sand_attack_smokescreen + call SendAttackDataToLinkOpponent call HandleSandAttackOrSmokescreenSubstatus jp c, ClearNonTurnTemporaryDuelvars_ResetCarry ld a, EFFECTCMDTYPE_INITIAL_EFFECT_2 call TryExecuteEffectCommandFunction jp c, ReturnCarry -.asm_1777 - ld a, $9 - call SetAIAction_SerialSendDuelData +.next + ld a, OPPACTION_USE_ATTACK + call SetOppAction_SerialSendDuelData ld a, EFFECTCMDTYPE_DISCARD_ENERGY call TryExecuteEffectCommandFunction call CheckSelfConfusionDamage @@ -4502,20 +4504,19 @@ UseAttackOrPokemonPower: ; 1730 (0:1730) call ExchangeRNG ld a, EFFECTCMDTYPE_REQUIRE_SELECTION call TryExecuteEffectCommandFunction - ld a, $a - call SetAIAction_SerialSendDuelData + ld a, OPPACTION_DEAL_ATTACK_DAMAGE + call SetOppAction_SerialSendDuelData ; fallthrough -; deal attack damage -Func_179a: ; 179a (0:179a) +DealAttackDamage: ; 179a (0:179a) call Func_7415 ld a, [wLoadedMoveCategory] and RESIDUAL - jr nz, .asm_17ad + jr nz, .deal_damage call SwapTurn call HandleNoDamageOrEffectSubstatus call SwapTurn -.asm_17ad +.deal_damage xor a ldh [hTempPlayAreaLocation_ff9d], a ld a, EFFECTCMDTYPE_BEFORE_DAMAGE @@ -4616,18 +4617,21 @@ UsePokemonPower: ; 184b (0:184b) ld a, EFFECTCMDTYPE_REQUIRE_SELECTION call TryExecuteEffectCommandFunction jr c, ReturnCarry - ld a, $c - call SetAIAction_SerialSendDuelData + ld a, OPPACTION_USE_PKMN_POWER + call SetOppAction_SerialSendDuelData call ExchangeRNG - ld a, $d - call SetAIAction_SerialSendDuelData + ld a, OPPACTION_EXECUTE_PKMN_POWER_EFFECT + call SetOppAction_SerialSendDuelData ld a, EFFECTCMDTYPE_BEFORE_DAMAGE call TryExecuteEffectCommandFunction - ld a, $16 - call SetAIAction_SerialSendDuelData + ld a, OPPACTION_DUEL_MAIN_SCENE + call SetOppAction_SerialSendDuelData ret -Func_1874: ; 1874 (0:1874) +; called by UseAttackOrPokemonPower (on an attack only) +; in a link duel, it's used to send the other game data about the +; attack being in use, triggering a call to OppAction_BeginUseAttack in the receiver +SendAttackDataToLinkOpponent: ; 1874 (0:1874) ld a, [wccec] or a ret nz @@ -4641,8 +4645,8 @@ Func_1874: ; 1874 (0:1874) ldh [hTempCardIndex_ff9f], a ld a, [wPlayerAttackingMoveIndex] ldh [hTemp_ffa0], a - ld a, $8 - call SetAIAction_SerialSendDuelData + ld a, OPPACTION_BEGIN_ATTACK + call SetOppAction_SerialSendDuelData call ExchangeRNG pop af ldh [hTempCardIndex_ff9f], a @@ -4707,10 +4711,10 @@ CheckSelfConfusionDamage: ; 18d7 (0:18d7) ret ; 0x18f9 -; use the trainer card with deck index at hTempCardIndex_ff98. +; play the trainer card with deck index at hTempCardIndex_ff98. ; a trainer card is like a move effect, with its own effect commands. ; return nc if the card was played, carry if it wasn't. -UseTrainerCard: ; 18f9 (0:18f9) +PlayTrainerCard: ; 18f9 (0:18f9) call CheckCantUseTrainerDueToHeadache jr c, .cant_use ldh a, [hWhoseTurn] @@ -4729,16 +4733,16 @@ UseTrainerCard: ; 18f9 (0:18f9) ld a, EFFECTCMDTYPE_INITIAL_EFFECT_2 call TryExecuteEffectCommandFunction jr c, .done - ld a, $06 - call SetAIAction_SerialSendDuelData + ld a, OPPACTION_PLAY_TRAINER + call SetOppAction_SerialSendDuelData call DisplayUsedTrainerCardDetailScreen call ExchangeRNG ld a, EFFECTCMDTYPE_DISCARD_ENERGY call TryExecuteEffectCommandFunction ld a, EFFECTCMDTYPE_REQUIRE_SELECTION call TryExecuteEffectCommandFunction - ld a, $07 - call SetAIAction_SerialSendDuelData + ld a, OPPACTION_EXECUTE_TRAINER_EFFECTS + call SetOppAction_SerialSendDuelData ld a, EFFECTCMDTYPE_BEFORE_DAMAGE call TryExecuteEffectCommandFunction ldh a, [hTempCardIndex_ff9f] diff --git a/src/hram.asm b/src/hram.asm index bfdf81a..9cdba06 100644 --- a/src/hram.asm +++ b/src/hram.asm @@ -70,7 +70,7 @@ hTempPlayAreaLocation_ff9d:: ; ff9d ds $1 ; index for AIActionTable -hAIActionTableIndex:: ; ff9e +hOppActionTableIndex:: ; ff9e ds $1 ; deck index of a card (0-59) diff --git a/src/wram.asm b/src/wram.asm index d2821b2..4210cf7 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -730,7 +730,7 @@ wSortCardListByID:: ; cbdf wcbe0:: ; cbe0 ds $1 -wAITurnEnded:: ; cbe1 +wOpponentTurnEnded:: ; cbe1 ds $1 wOppRNG1:: ; cbe2 |