diff options
author | ElectroDeoxys <ElectroDeoxys@gmail.com> | 2019-12-30 13:50:08 +0000 |
---|---|---|
committer | ElectroDeoxys <ElectroDeoxys@gmail.com> | 2019-12-30 13:50:08 +0000 |
commit | a4ee5f64029e3c6dfc0a890aa0ac1b727127301b (patch) | |
tree | 5a5074ca0642d852de999155b2193f3c66cc8d33 /src | |
parent | 3d8c853f38eb4c9c782c7984bb9905fa76dbf625 (diff) |
Disassembe Switch AI routines
Diffstat (limited to 'src')
-rw-r--r-- | src/engine/bank05.asm | 10 | ||||
-rw-r--r-- | src/engine/bank08.asm | 64 | ||||
-rw-r--r-- | src/wram.asm | 1 |
3 files changed, 68 insertions, 7 deletions
diff --git a/src/engine/bank05.asm b/src/engine/bank05.asm index c9e0b53..6e060b2 100644 --- a/src/engine/bank05.asm +++ b/src/engine/bank05.asm @@ -1779,7 +1779,7 @@ AIDecideWhetherToRetreat: ; 158b2 (5:58b2) call LoadDefendingPokemonColorWRAndPrizeCards ld a, 128 ; initial retreat score ld [wAIScore], a - ld a, [$cdb4] + ld a, [wcdb4] or a jr z, .check_status srl a @@ -2530,7 +2530,7 @@ AIDecideBenchPokemonToSwitchTo: ; 15b72 (5:5b72) ; done xor a - ld [$cdb4], a + ld [wcdb4], a jp FindHighestBenchScore ; 0x15d4f @@ -5031,13 +5031,13 @@ Func_169f8: ; 169f8 (5:69f8) jr z, .asm_16a62 .asm_16a5c xor a - ld [$cdb4], a + ld [wcdb4], a jr .asm_16a6d .asm_16a62 ld a, MOVE_FLAG1_ADDRESS | DAMAGE_TO_OPPONENT_BENCH_F call CheckLoadedMoveFlag jr c, .asm_16a5c - ld hl, $cdb4 + ld hl, wcdb4 inc [hl] .asm_16a6d ld a, $01 @@ -5051,7 +5051,7 @@ Func_169f8: ; 169f8 (5:69f8) jr z, .asm_16a80 jp Func_169e3 .asm_16a80 - ld hl, $cdb4 + ld hl, wcdb4 inc [hl] or a ret diff --git a/src/engine/bank08.asm b/src/engine/bank08.asm index d2e0d9c..fbb7481 100644 --- a/src/engine/bank08.asm +++ b/src/engine/bank08.asm @@ -1007,8 +1007,68 @@ CheckIfSelectedMoveCannotKnockOutWithoutPluspowerBoost: ; 205a5 (8:45a5) ret ; 0x20612 -Func_20612: ; 20612 (8:4612) - INCROM $20612, $2282e +AIPlaySwitch: ; 20612 (8:4612) + ld a, [wce21] + or $02 + ld [wce21], a + ld a, [wce16] + ldh [hTempCardIndex_ff9f], a + ld a, [wce19] + ldh [hTemp_ffa0], a + ld a, OPPACTION_EXECUTE_TRAINER_EFFECTS + bank1call AIMakeDecision + xor a + ld [wcdb4], a + ret +; 0x2062e + +Func_2062e: ; 2062e (8:462e) +; check if card already has no retreat cost + ld a, [wAIPlayEnergyCardForRetreat] + or a + jr z, .asm_2064a + +; compare number of energy cards attached to retreat cost. + xor a ; PLAY_AREA_ARENA + ldh [hTempPlayAreaLocation_ff9d], a + call GetPlayAreaCardRetreatCost + push af + ld e, PLAY_AREA_ARENA + farcall CountNumberOfEnergyCardsAttached + ld b, a + pop af + sub b + ; jump if cards attached > retreat cost + jr c, .asm_2064a + cp 2 + ; jump if retreat cost is 2 more energy cards + ; than the number of cards attached + jr nc, .asm_20660 + +.asm_2064a + xor a ; PLAY_AREA_ARENA + ldh [hTempPlayAreaLocation_ff9d], a + call GetPlayAreaCardRetreatCost + cp 3 + ; jump if retreat cost >= 3 + jr nc, .asm_20660 + + push af + ld e, PLAY_AREA_ARENA + farcall CountNumberOfEnergyCardsAttached + pop bc + cp b + ; jump if + jr c, .asm_20660 + ret +.asm_20660 + farcall AIDecideBenchPokemonToSwitchTo + ccf + ret +; 0x20666 + +Func_20666: ; 20666 (8:4666) + INCROM $20666, $2282e ; returns in a the card index of energy card ; attached to Pokémon in Play Area location a, diff --git a/src/wram.asm b/src/wram.asm index 3bed41e..9b13642 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -1201,6 +1201,7 @@ wcdb2:: ; cdb2 wcdb3:: ; cdb3 ds $1 +wcdb4:: ; cdb4 ds $1 ; information about various properties of |