diff options
author | xCrystal <rgr.crystal@gmail.com> | 2020-12-15 20:47:13 +0100 |
---|---|---|
committer | xCrystal <rgr.crystal@gmail.com> | 2020-12-15 20:47:13 +0100 |
commit | 117efe39b6b297dc52c1b5ad4d3012e7b00c8bd7 (patch) | |
tree | 785195227b981bf4c4dab2fb8d56b1e8bc112a38 /src/engine | |
parent | d8f98d97bcd41f710d51925470dc799a6051f022 (diff) |
Misc progress related to duel effect functions
Diffstat (limited to 'src/engine')
-rw-r--r-- | src/engine/bank01.asm | 11 | ||||
-rw-r--r-- | src/engine/bank05.asm | 4 | ||||
-rw-r--r-- | src/engine/effect_functions.asm | 153 | ||||
-rw-r--r-- | src/engine/home.asm | 14 |
4 files changed, 132 insertions, 50 deletions
diff --git a/src/engine/bank01.asm b/src/engine/bank01.asm index c4a6b27..811f95b 100644 --- a/src/engine/bank01.asm +++ b/src/engine/bank01.asm @@ -1438,10 +1438,15 @@ CheckIfActiveCardParalyzedOrAsleep: ; 4918 (1:4918) scf ret -; display the animation of the turn duelist drawing a card at the beginning of the turn +; display the animation of the turn duelist drawing one card at the beginning of the turn ; if there isn't any card left in the deck, let the player know with a text message DisplayDrawOneCardScreen: ; 4933 (1:4933) ld a, 1 +; fallthrough + +; display the animation of the turn duelist drawing A cards at the beginning of the turn +; if there isn't any card left in the deck, let the player know with a text message +DisplayDrawACardsScreen: push hl push de push bc @@ -7386,9 +7391,9 @@ Func_6ff7: ; 6ff7 (1:6ff7) ret ; print one of the "There was no effect from" texts depending -; on the value at wNoEffectFromStatus (NO_STATUS or a status condition constant) +; on the value at wNoEffectFromWhichStatus (NO_STATUS or a status condition constant) PrintThereWasNoEffectFromStatusText: ; 700a (1:700a) - ld a, [wNoEffectFromStatus] + ld a, [wNoEffectFromWhichStatus] or a jr nz, .status ld hl, wLoadedMoveName diff --git a/src/engine/bank05.asm b/src/engine/bank05.asm index 6af2582..1a33d2f 100644 --- a/src/engine/bank05.asm +++ b/src/engine/bank05.asm @@ -190,7 +190,7 @@ AITryUseAttack: ; 14145 (5:4145) call AISelectSpecialAttackParameters jr c, .use_attack - ld a, OPPACTION_BEGIN_ATTACK + ld a, EFFECTCMDTYPE_AI_SELECTION call TryExecuteEffectCommandFunction .use_attack @@ -204,7 +204,7 @@ AITryUseAttack: ; 14145 (5:4145) bank1call AIMakeDecision ret c - ld a, OPPACTION_ATTACK_ANIM_AND_DAMAGE + ld a, EFFECTCMDTYPE_AI_SWITCH_DEFENDING_PKMN call TryExecuteEffectCommandFunction ld a, OPPACTION_ATTACK_ANIM_AND_DAMAGE bank1call AIMakeDecision diff --git a/src/engine/effect_functions.asm b/src/engine/effect_functions.asm index 4ed3dbe..7e8db45 100644 --- a/src/engine/effect_functions.asm +++ b/src/engine/effect_functions.asm @@ -57,7 +57,7 @@ ApplyStatusEffect: .cant_induce_status ld a, c - ld [wNoEffectFromStatus], a + ld [wNoEffectFromWhichStatus], a call SetNoEffectFromStatus or a ret @@ -154,7 +154,7 @@ Func_2c0c7: ; 2c0c7 (b:40c7) scf ret -; Sets some flags for AI use +; Sets some variables for AI use ; if target poisoned ; [wAIMinDamage] <- [wDamage] ; [wAIMaxDamage] <- [wDamage] @@ -162,19 +162,23 @@ Func_2c0c7: ; 2c0c7 (b:40c7) ; [wAIMinDamage] <- [wDamage] + d ; [wAIMaxDamage] <- [wDamage] + e ; [wDamage] <- [wDamage] + a -Func_2c0d4: ; 2c0d4 (b:40d4) +UpdateExpectedAIDamage_AccountForPoison: ; 2c0d4 (b:40d4) push af ld a, DUELVARS_ARENA_CARD_STATUS call GetNonTurnDuelistVariable and POISONED | DOUBLE_POISONED - jr z, Func_2c0e9.skip_push_af + jr z, UpdateExpectedAIDamage.skip_push_af pop af ld a, [wDamage] ld [wAIMinDamage], a ld [wAIMaxDamage], a ret -Func_2c0e9: ; 2c0e9 (b:40e9) +; Sets some variables for AI use +; [wAIMinDamage] <- [wDamage] + d +; [wAIMaxDamage] <- [wDamage] + e +; [wDamage] <- [wDamage] + a +UpdateExpectedAIDamage: ; 2c0e9 (b:40e9) push af .skip_push_af @@ -190,11 +194,11 @@ Func_2c0e9: ; 2c0e9 (b:40e9) ld [hl], a ret -; Sets some flags for AI use +; Sets some variables for AI use ; [wDamage] <- a ; [wAIMinDamage] <- d ; [wAIMaxDamage] <- e -Func_2c0fb: ; 2c0fb (b:40fb) +SetExpectedAIDamage: ; 2c0fb (b:40fb) ld [wDamage], a xor a ld [wDamage + 1], a @@ -268,7 +272,7 @@ ApplySubstatus2ToDefendingCard: ; 2c149 (b:4149) .no_damage_orEffect pop af push hl - bank1call $4f9d + bank1call DrawDuelMainScene pop hl ld a, l or h @@ -277,7 +281,7 @@ ApplySubstatus2ToDefendingCard: ; 2c149 (b:4149) ; overwrites in wDamage, wAIMinDamage and wAIMaxDamage ; with the value in a. -StoreDamageInfo: ; 2c166 (b:4166) +SetDefiniteDamage: ; 2c166 (b:4166) ld [wDamage], a ld [wAIMinDamage], a ld [wAIMaxDamage], a @@ -404,10 +408,8 @@ CreateEnergyCardListFromOpponentDiscardPile: ; 2c2a4 (b:42a4) INCROM $2c2e0, $2c487 -; handles the selection of a forced switch -; by link/AI opponent or by the player. -; outputs the Play Area location of the chosen -; bench card in hTempPlayAreaLocation_ff9d. +; handles the selection of a forced switch by link/AI opponent or by the player. +; outputs the Play Area location of the chosen bench card in hTempPlayAreaLocation_ff9d. DuelistSelectForcedSwitch: ; 2c487 (b:4487) ld a, DUELVARS_DUELIST_TYPE call GetNonTurnDuelistVariable @@ -459,12 +461,43 @@ DuelistSelectForcedSwitch: ; 2c487 (b:4487) ret ; 0x2c4da - INCROM $2c4da, $2c6f0 + INCROM $2c4da, $2c564 + +; Return in a the PLAY_AREA_* of the non-turn holder's Pokemon card in bench with the lowest HP +; if multiple cards are tied for the lowest HP, the one with the highest PLAY_AREA_* is returned. +Func_2c564: ; 2c564 (b:4564) + call SwapTurn + ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA + call GetTurnDuelistVariable + ld c, a + lb de, 0, -1 + ld b, d + ld a, DUELVARS_BENCH1_CARD_HP + call GetTurnDuelistVariable + jr .begin +.loop + ld a, e + cp [hl] + jr c, .next + ld e, [hl] + ld d, b +.next + inc hl +.begin + inc b + dec c + jr nz, .loop + ld a, d + call SwapTurn + ret +; 0x2c588 + + INCROM $2c588, $2c6f0 SpitPoison_AIEffect: ; 2c6f0 (b:46f0) ld a, 5 lb de, 0, 10 - jp Func_2c0fb + jp SetExpectedAIDamage ; If heads, defending Pokemon becomes poisoned SpitPoison_Poison50PercentEffect: ; 2c6f8 (b:46f8) @@ -476,10 +509,9 @@ SpitPoison_Poison50PercentEffect: ; 2c6f8 (b:46f8) call SetNoEffectFromStatus ret -; outputs in hTemp_ffa0 the result of the coin toss -; (0 = tails, 1 = heads) and, in case it was heads, -; stores in hTempPlayAreaLocation_ffa1 the location -; of the Bench Pokemon that was selected for switch. +; outputs in hTemp_ffa0 the result of the coin toss (0 = tails, 1 = heads). +; in case it was heads, stores in hTempPlayAreaLocation_ffa1 +; the PLAY_AREA_* location of the Bench Pokemon that was selected for switch. TerrorStrike_50PercentSelectSwitchPokemon: ; 2c70a (b:470a) xor a ldh [hTemp_ffa0], a @@ -490,8 +522,7 @@ TerrorStrike_50PercentSelectSwitchPokemon: ; 2c70a (b:470a) cp 2 ret c -; toss coin and store whether it was tails (0) -; or heads (1) in hTemp_ffa0 +; toss coin and store whether it was tails (0) or heads (1) in hTemp_ffa0. ; return if it was tails. ldtx de, IfHeadsChangeOpponentsActivePokemonText call Func_2c08a @@ -503,8 +534,8 @@ TerrorStrike_50PercentSelectSwitchPokemon: ; 2c70a (b:470a) ldh [hTempPlayAreaLocation_ffa1], a ret -; if coin toss was heads and it's possible, -; switch Defending Pokemon +; if coin toss at hTemp_ffa0 was heads and it's possible, +; switch the Defending Pokemon TerrorStrike_SwitchDefendingPokemon: ; 2c726 (b:4726) ldh a, [hTemp_ffa0] or a @@ -516,15 +547,57 @@ TerrorStrike_SwitchDefendingPokemon: ; 2c726 (b:4726) PoisonFang_AIEffect: ; 2c730 (b:4730) ld a, 10 lb de, 10, 10 - jp Func_2c0d4 + jp UpdateExpectedAIDamage_AccountForPoison WeepinbellPoisonPowder_AIEffect: ; 2c738 (b:4738) ld a, 5 lb de, 0, 10 - jp Func_2c0d4 + jp UpdateExpectedAIDamage_AccountForPoison ; 0x2c740 - INCROM $2c740, $2c77e +; return carry if there are no Pokemon cards in the non-turn holder's bench +Lure_AssertPokemonInBench: ; 2c740 (b:4740) + ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA + call GetNonTurnDuelistVariable + ldtx hl, NoPokemonOnTheBenchText_2 + cp 2 + ret +; 0x2c74b + +; return in hTempPlayAreaLocation_ffa1 the PLAY_AREA_* location +; of the Bench Pokemon that was selected for switch +Lure_SelectSwitchPokemon: ; 2c74b (b:474b) + ldtx hl, SelectPkmnOnBenchToSwitchWithActiveText + call DrawWideTextBox_WaitForInput + call SwapTurn + bank1call HasAlivePokemonInBench +.select_pokemon + bank1call OpenPlayAreaScreenForSelection + jr c, .select_pokemon + ldh a, [hTempPlayAreaLocation_ff9d] + ldh [hTemp_ffa0], a + call SwapTurn + ret +; 0x2c764 + +Func_2c764: ; 2c764 (b:4764) + call Func_2c564 + ldh [hTemp_ffa0], a + ret +; 0x2c76a + +; Defending Pokemon is swapped out for the one with the PLAY_AREA_* at hTemp_ffa0 +; unless Mew's Neutralizing Shield or Haunter's Transparency prevents it. +Lure_SwitchDefendingPokemon: ; 2c76a (b:476a) + call SwapTurn + ldh a, [hTemp_ffa0] + ld e, a + call HandleNShieldAndTransparency + call nc, SwapArenaWithBenchPokemon + call SwapTurn + xor a + ld [wDuelDisplayedScreen], a + ret ; If heads, defending Pokemon can't retreat next turn AcidEffect: ; 2c77e (b:477e) @@ -538,7 +611,7 @@ AcidEffect: ; 2c77e (b:477e) GloomPoisonPowder_AIEffect: ; 2c78b (b:478b) ld a, 10 lb de, 10, 10 - jp Func_2c0d4 + jp UpdateExpectedAIDamage_AccountForPoison ; Defending Pokemon and user become confused FoulOdorEffect: ; 2c793 (b:4793) @@ -562,7 +635,7 @@ KakunaStiffenEffect: ; 2c7a0 (b:47a0) KakunaPoisonPowder_AIEffect: ; 2c7b4 (b:47b4) ld a, 5 lb de, 0, 10 - jp Func_2c0d4 + jp UpdateExpectedAIDamage_AccountForPoison ; 0x2c7bc INCROM $2c7bc, $2c7d0 @@ -588,7 +661,7 @@ ZubatSupersonicEffect: ; 2c7dc (b:47dc) Twineedle_AIEffect: ; 2c7ed (b:47ed) ld a, 30 lb de, 0, 60 - jp Func_2c0fb + jp SetExpectedAIDamage ; Flip 2 coins; deal 30x number of heads Twineedle_MultiplierEffect: ; 2c7f5 (b:47f5) @@ -601,7 +674,7 @@ Twineedle_MultiplierEffect: ; 2c7f5 (b:47f5) add a add e call ATimes10 - call StoreDamageInfo + call SetDefiniteDamage ret ; 0x2c80d @@ -610,7 +683,7 @@ Twineedle_MultiplierEffect: ; 2c7f5 (b:47f5) FoulGas_AIEffect: ; 2c822 (b:4822) ld a, 5 lb de, 0, 10 - jp Func_2c0e9 + jp UpdateExpectedAIDamage ; If heads, defending Pokemon becomes poisoned. If tails, defending Pokemon becomes confused FoulGas_PoisonOrConfusionEffect: ; 2c82a (b:482a) @@ -683,7 +756,7 @@ SetDamageToATimes20: ; 2c958 (b:4958) Thrash_AIEffect: ; 2c96b (b:496b) ld a, 35 lb de, 30, 40 - jp Func_2c0fb + jp SetExpectedAIDamage ; If heads 10 more damage; if tails, 10 damage to itself Thrash_ModifierEffect: ; 2c973 (b:4973) @@ -695,20 +768,20 @@ Thrash_ModifierEffect: ; 2c973 (b:4973) call AddToDamage ret -Func_2c982: ; 2c982 (b:4982) +Thrash_LowRecoilEffect: ; 2c982 (b:4982) ldh a, [hTemp_ffa0] or a ret nz ld a, 10 - call Func_1955 + call DealRecoilDamageToSelf ret Toxic_AIEffect: ; 2c98c (b:498c) ld a, 20 lb de, 20, 20 - jp Func_2c0e9 + jp UpdateExpectedAIDamage -; Defending Pokémon becomes poisoned, but takes 20 damage (double poisoned) +; Defending Pokémon becomes double poisoned (takes 20 damage per turn rather than 10) Toxic_DoublePoisonEffect: ; 2c994 (b:4994) call DoublePoisonEffect ret @@ -727,7 +800,7 @@ Func_2cbfb: ; 2cbfb (b:4bfb) ; 0x2cc0a INCROM $2cc0a, $2f4e1 - + ImposterProfessorOakEffect: ; 2f4e1 (b:74e1) call SwapTurn call CreateHandCardList @@ -742,9 +815,9 @@ ImposterProfessorOakEffect: ; 2f4e1 (b:74e1) jr .return_hand_to_deck_loop .shuffle call Func_2c0bd - ld a, $07 - bank1call $4935 - ld c, $07 + ld a, 7 + bank1call DisplayDrawACardsScreen + ld c, 7 .draw_loop call DrawCardFromDeck jr c, .revert_turn_to_user diff --git a/src/engine/home.asm b/src/engine/home.asm index ff887fd..9ebb549 100644 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -2778,7 +2778,7 @@ ExchangeRNG: ; 0f58 (0:0f58) ; send 10 bytes of data to the other game from hOppActionTableIndex, hTempCardIndex_ff9f, ; hTemp_ffa0, and hTempPlayAreaLocation_ffa1, and hTempRetreatCostCards. ; finally exchange RNG data. -; the receiving side will use this data to read the OPP_ACTION_* value in +; the receiving side will use this data to read the OPPACTION_* value in ; [hOppActionTableIndex] and match it by calling the correspoding OppAction* function SetOppAction_SerialSendDuelData: ; 0f7f (0:0f7f) push hl @@ -4380,7 +4380,7 @@ Func_16f6: ; 16f6 (0:16f6) ld [wIsDamageToSelf], a ld [wccef], a ld [wccf0], a - ld [wNoEffectFromStatus], a + ld [wNoEffectFromWhichStatus], a bank1call ClearNonTurnTemporaryDuelvars_CopyStatus ret @@ -4516,7 +4516,7 @@ ClearNonTurnTemporaryDuelvars_ResetCarry: ; 1823 (0:1823) ret ; called when attacker deals damage to itself due to confusion -; display the corresponding animation and deal damage to self +; display the corresponding animation and deal 20 damage to self HandleConfusionDamageToSelf: ; 1828 (0:1828) bank1call DrawDuelMainScene ld a, 1 @@ -4690,13 +4690,17 @@ LoadNonPokemonCardEffectCommands: ; 1944 (0:1944) ld [de], a ret -Func_1955: ; 1955 (0:1955) +; Make turn holder deal A damage to self due to recoil (e.g. Thrash, Selfdestruct) +; display recoil animation +DealRecoilDamageToSelf: ; 1955 (0:1955) push af ld a, $7a ld [wLoadedMoveAnimation], a pop af ; fallthrough +; Make turn holder deal A damage to self due to confusion +; display animation at wLoadedMoveAnimation DealConfusionDamageToSelf: ; 195c (0:195c) ld hl, wDamage ld [hli], a @@ -11461,7 +11465,7 @@ DrawSpriteAnimationFrame: ; 3cc4 (0:3cc4) call BankswitchROM ret -; Loads a pointer to the current animation frame into SPRITE_ANIM_FRAME_DATA_POINTER using +; Loads a pointer to the current animation frame into SPRITE_ANIM_FRAME_DATA_POINTER using ; the current frame's offset ; [wd4ca] - current frame offset ; wTempPointer* - Pointer to current Animation |