diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/data/effect_commands.asm | 6 | ||||
-rw-r--r-- | src/engine/effect_functions.asm | 147 | ||||
-rw-r--r-- | src/engine/home.asm | 22 | ||||
-rw-r--r-- | src/text/text1.asm | 2 | ||||
-rw-r--r-- | src/text/text_offsets.asm | 2 |
5 files changed, 165 insertions, 14 deletions
diff --git a/src/data/effect_commands.asm b/src/data/effect_commands.asm index 0e1886e..171c241 100644 --- a/src/data/effect_commands.asm +++ b/src/data/effect_commands.asm @@ -42,9 +42,9 @@ EkansWrapEffectCommands: db $00 ArbokTerrorStrikeEffectCommands: - dbw EFFECTCMDTYPE_AFTER_DAMAGE, $4726 - dbw EFFECTCMDTYPE_REQUIRE_SELECTION, $470a - dbw EFFECTCMDTYPE_SWITCH_DEFENDING_PKMN, $470a + dbw EFFECTCMDTYPE_AFTER_DAMAGE, TerrorStrike_SwitchDefendingPokemon + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, TerrorStrike_50PercentSelectSwitchPokemon + dbw EFFECTCMDTYPE_SWITCH_DEFENDING_PKMN, TerrorStrike_50PercentSelectSwitchPokemon db $00 ArbokPoisonFangEffectCommands: diff --git a/src/engine/effect_functions.asm b/src/engine/effect_functions.asm index 116d545..8832134 100644 --- a/src/engine/effect_functions.asm +++ b/src/engine/effect_functions.asm @@ -301,7 +301,111 @@ Func_2c166: ; 2c166 (b:4166) ret ; 0x2c174 - INCROM $2c174, $2c6f0 + INCROM $2c174, $2c1ec + +HandleSwitchDefendingPokemonEffect: ; 2c1ec (b:41ec) + ld e, a + cp $ff + ret z + +; check Defending Pokemon's HP + ld a, DUELVARS_ARENA_CARD_HP + call GetNonTurnDuelistVariable + or a + jr nz, .switch + +; if 0, handle Destiny Bond first + push de + bank1call HandleDestinyBondSubstatus + pop de + +.switch + call .HandleNoDamageOrEffect + ret c + +; attack was successful, switch Defending Pokemon + call SwapTurn + call SwapArenaWithBenchPokemon + call SwapTurn + + xor a + ld [wccc5], a + ld [wDuelDisplayedScreen], a + inc a + ld [wccef], a + ret +; 0x2c216 + +; returns carry if Defending has No Damage or Effect +; if so, print its appropriate text. +.HandleNoDamageOrEffect: ; 2c216 (b:4216) + call CheckNoDamageOrEffect + ret nc + ld a, l + or h + call nz, DrawWideTextBox_PrintText + scf + ret +; 0x2c221 + + INCROM $2c221, $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. +DuelistSelectForcedSwitch: ; 2c487 (b:4487) + ld a, DUELVARS_DUELIST_TYPE + call GetNonTurnDuelistVariable + cp DUELIST_TYPE_LINK_OPP + jr z, .link_opp + + cp DUELIST_TYPE_PLAYER + jr z, .player + +; AI opponent + call SwapTurn + bank1call Func_2bc7 + call SwapTurn + + ld a, [wPlayerAttackingMoveIndex] + ld e, a + ld a, [wPlayerAttackingCardIndex] + ld d, a + ld a, [wPlayerAttackingCardID] + call CopyMoveDataAndDamage_FromCardID + call Func_16f6 + ret + +.player + ldtx hl, SelectPkmnOnBenchToSwitchWithActiveText + call DrawWideTextBox_WaitForInput + call SwapTurn + bank1call HasAlivePokemonInBench + ld a, $01 + ld [wcbd4], a +.asm_2c4c0 + bank1call OpenPlayAreaScreenForSelection + jr c, .asm_2c4c0 + call SwapTurn + ret + +.link_opp +; get selection from link opponent + ld a, OPPACTION_FORCE_SWITCH_ACTIVE + call SetOppAction_SerialSendDuelData +.loop + call SerialRecvByte + jr nc, .received + halt + nop + jr .loop +.received + ldh [hTempPlayAreaLocation_ff9d], a + ret +; 0x2c4da + + INCROM $2c4da, $2c6f0 SpitPoison_AIEffect: ; 2c6f0 (b:46f0) ld a, 5 @@ -320,7 +424,44 @@ SpitPoison_Poison50PercentEffect: ; 2c6f8 (b:46f8) ret ; 0x2c70a - INCROM $2c70a, $2c730 +; 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. +TerrorStrike_50PercentSelectSwitchPokemon: ; 2c70a (b:470a) + xor a + ldh [hTemp_ffa0], a + +; return failure if no Pokemon to switch to + ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA + call GetNonTurnDuelistVariable + cp 2 + ret c + +; 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 + ldh [hTemp_ffa0], a + ret nc + + call DuelistSelectForcedSwitch + ldh a, [hTempPlayAreaLocation_ff9d] + ldh [hTempPlayAreaLocation_ffa1], a + ret +; 0x2c726 + +; if coin toss was heads and it's possible, +; switch Defending Pokemon +TerrorStrike_SwitchDefendingPokemon: ; 2c726 (b:4726) + ldh a, [hTemp_ffa0] + or a + ret z + ldh a, [hTempPlayAreaLocation_ffa1] + call HandleSwitchDefendingPokemonEffect + ret +; 0x2c730 PoisonFang_AIEffect: ; 2c730 (b:4730) ld a, 10 @@ -538,4 +679,4 @@ Toxic_DoublePoisonEffect: ; 2c994 (b:4994) ret ; 0x2c998 - INCROM $2c998, $30000 + INCROM $2c998, $30000
\ No newline at end of file diff --git a/src/engine/home.asm b/src/engine/home.asm index 545995a..4f9fc31 100644 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -8301,34 +8301,44 @@ Func_2bcf: ; 2bcf (0:2bcf) Func_2bd7: ; 2bd7 (0:2bd7) ld a, $5 - jr Func_2bdb + jr Func_2bdb ; this line is not needed Func_2bdb: ; 2bdb (0:2bdb) ld c, a + +; load bank for Opponent Deck pointer table ldh a, [hBankROM] push af ld a, BANK(PointerTable_14000) call BankswitchROM + +; load hl with the corresponding pointer ld a, [wOpponentDeckID] ld l, a ld h, $0 - add hl, hl + add hl, hl ; two bytes per deck ld de, PointerTable_14000 add hl, de ld a, [hli] ld h, [hl] ld l, a + ld a, c or a - jr nz, .asm_2bfe + jr nz, .not_zero + +; if input was 0, copy deck data of turn player ld e, [hl] inc hl ld d, [hl] call CopyDeckData - jr .asm_2c01 -.asm_2bfe + jr .done + +; jump to corresponding AI routine related to input +.not_zero call JumpToFunctionInTable -.asm_2c01 + +.done ld c, a pop af call BankswitchROM diff --git a/src/text/text1.asm b/src/text/text1.asm index 69f44f6..07d7a7a 100644 --- a/src/text/text1.asm +++ b/src/text/text1.asm @@ -1103,7 +1103,7 @@ Text00ea: ; 37e03 (d:7e03) line "Heads, damage to yours if Tails." done -Text00eb: ; 37e46 (d:7e46) +IfHeadsChangeOpponentsActivePokemonText: ; 37e46 (d:7e46) text "If Heads, change opponent's" line "Active Pokémon." done diff --git a/src/text/text_offsets.asm b/src/text/text_offsets.asm index 3149307..d027768 100644 --- a/src/text/text_offsets.asm +++ b/src/text/text_offsets.asm @@ -236,7 +236,7 @@ TextOffsets:: ; 34000 (d:40 textpointer Text00e8 ; 0x00e8 textpointer IfHeadPlus10IfTails10ToYourselfText ; 0x00e9 textpointer Text00ea ; 0x00ea - textpointer Text00eb ; 0x00eb + textpointer IfHeadsChangeOpponentsActivePokemonText ; 0x00eb textpointer Text00ec ; 0x00ec textpointer Text00ed ; 0x00ed textpointer Text00ee ; 0x00ee |