diff options
-rw-r--r-- | battle/ai/items.asm | 40 | ||||
-rw-r--r-- | battle/ai/scoring.asm | 6 | ||||
-rwxr-xr-x | battle/ai/switch.asm | 132 | ||||
-rw-r--r-- | battle/core.asm | 144 | ||||
-rw-r--r-- | battle/effect_commands.asm | 22 | ||||
-rw-r--r-- | items/item_effects.asm | 2 | ||||
-rw-r--r-- | main.asm | 34 | ||||
-rw-r--r-- | misc/mobile_5f.asm | 10 | ||||
-rw-r--r-- | wram.asm | 28 |
9 files changed, 202 insertions, 216 deletions
diff --git a/battle/ai/items.asm b/battle/ai/items.asm index cf78980b3..56a95ac4d 100644 --- a/battle/ai/items.asm +++ b/battle/ai/items.asm @@ -45,14 +45,14 @@ DontSwitch: ; 38041 SwitchOften: ; 38045 callab CheckAbleToSwitch - ld a, [wc717] + ld a, [wEnemySwitchMonParam] and $f0 jp z, DontSwitch cp $10 jr nz, .not_10 call Random - cp $80 + cp 1 + 50 percent jr c, .switch jp DontSwitch .not_10 @@ -60,35 +60,35 @@ SwitchOften: ; 38045 cp $20 jr nz, .not_20 call Random - cp 200 + cp -1 + 79 percent jr c, .switch jp DontSwitch .not_20 ; $30 call Random - cp 10 + cp 4 percent jp c, DontSwitch .switch - ld a, [wc717] + ld a, [wEnemySwitchMonParam] and $f inc a ; In register 'a' is the number (1-6) of the Pkmn to switch to - ld [wc718], a + ld [wEnemySwitchMonIndex], a jp AI_TrySwitch ; 38083 SwitchRarely: ; 38083 callab CheckAbleToSwitch - ld a, [wc717] + ld a, [wEnemySwitchMonParam] and $f0 jp z, DontSwitch cp $10 jr nz, .not_10 call Random - cp 20 + cp 8 percent jr c, .switch jp DontSwitch .not_10 @@ -96,34 +96,34 @@ SwitchRarely: ; 38083 cp $20 jr nz, .not_20 call Random - cp 30 + cp 12 percent jr c, .switch jp DontSwitch .not_20 ; $30 call Random - cp 200 + cp -1 + 79 percent jp c, DontSwitch .switch - ld a, [wc717] + ld a, [wEnemySwitchMonParam] and $f inc a - ld [wc718], a + ld [wEnemySwitchMonIndex], a jp AI_TrySwitch ; 380c1 SwitchSometimes: ; 380c1 callab CheckAbleToSwitch - ld a, [wc717] + ld a, [wEnemySwitchMonParam] and $f0 jp z, DontSwitch cp $10 jr nz, .not_10 call Random - cp 50 + cp -1 + 20 percent jr c, .switch jp DontSwitch .not_10 @@ -131,21 +131,21 @@ SwitchSometimes: ; 380c1 cp $20 jr nz, .not_20 call Random - cp $80 + cp 1 + 50 percent jr c, .switch jp DontSwitch .not_20 ; $30 call Random - cp 50 + cp -1 + 20 percent jp c, DontSwitch .switch - ld a, [wc717] + ld a, [wEnemySwitchMonParam] and $f inc a - ld [wc718], a + ld [wEnemySwitchMonIndex], a jp AI_TrySwitch ; 380ff @@ -225,7 +225,7 @@ endr xor a ld [de], a inc a - ld [wc70f], a + ld [wEnemyGoesFirst], a ld hl, EnemySubStatus3 res SUBSTATUS_BIDE, [hl] @@ -701,7 +701,7 @@ AI_TrySwitch: ; 3844b AI_Switch: ; 3846c ld a, $1 ld [wEnemyIsSwitching], a - ld [wc70f], a + ld [wEnemyGoesFirst], a ld hl, EnemySubStatus4 res SUBSTATUS_RAGE, [hl] xor a diff --git a/battle/ai/scoring.asm b/battle/ai/scoring.asm index dbdbb9db8..7dd204978 100644 --- a/battle/ai/scoring.asm +++ b/battle/ai/scoring.asm @@ -576,7 +576,7 @@ AI_Smart_Explosion: ; 388a6 ; Unless this is the enemy's last Pokemon... push hl - callba CheckEnemyHasMonToSwitchTo + callba FindAliveEnemyMons pop hl jr nc, .asm_388b7 @@ -2028,7 +2028,7 @@ endr jp nz, AIDiscourageMove push hl - callba CheckEnemyHasMonToSwitchTo + callba FindAliveEnemyMons pop hl jr nc, .asm_38eb0 @@ -2160,7 +2160,7 @@ endr AI_Smart_PerishSong: ; 38f4a push hl - callab CheckEnemyHasMonToSwitchTo + callab FindAliveEnemyMons pop hl jr c, .no diff --git a/battle/ai/switch.asm b/battle/ai/switch.asm index c7fd696e1..62a6bcd83 100755 --- a/battle/ai/switch.asm +++ b/battle/ai/switch.asm @@ -183,8 +183,8 @@ endr CheckAbleToSwitch: ; 34941 xor a - ld [wc717], a - call CheckEnemyHasMonToSwitchTo + ld [wEnemySwitchMonParam], a + call FindAliveEnemyMons ret c ld a, [EnemySubStatus1] @@ -197,9 +197,9 @@ CheckAbleToSwitch: ; 34941 ; Perish count is 1 - call CheckEnemyHasMonToSwitchTo - call Function34b77 - call Function34b20 + call FindAliveEnemyMons + call FindEnemyMonsWithEnoughHP + call FindEnemyMonsThatResistPlayer call Function34a85 ld a, e @@ -208,11 +208,11 @@ CheckAbleToSwitch: ; 34941 ld a, [wc716] add $30 - ld [wc717], a + ld [wEnemySwitchMonParam], a ret .not_2 - call CheckEnemyHasMonToSwitchTo + call FindAliveEnemyMons sla c sla c ld b, $ff @@ -224,7 +224,7 @@ CheckAbleToSwitch: ; 34941 ld a, b add $30 - ld [wc717], a + ld [wEnemySwitchMonParam], a ret .no_perish @@ -236,12 +236,12 @@ CheckAbleToSwitch: ; 34941 ld a, [LastEnemyCounterMove] and a - jr z, .asm_349d2 + jr z, .no_last_counter_move call Function34a2a ld a, [wc716] and a - jr z, .asm_349d2 + jr z, .no_last_counter_move ld c, a call Function34aa7 @@ -252,7 +252,7 @@ CheckAbleToSwitch: ; 34941 ld b, a ld a, e cp 2 - jr z, .asm_349be + jr z, .not_2_again call CheckPlayerMoveTypeMatchups ld a, [wc716] @@ -261,32 +261,32 @@ CheckAbleToSwitch: ; 34941 ld a, b add $10 - ld [wc717], a + ld [wEnemySwitchMonParam], a ret -.asm_349be +.not_2_again ld c, $10 call CheckPlayerMoveTypeMatchups ld a, [wc716] cp 10 - jr nc, .asm_349cc + jr nc, .okay ld c, $20 -.asm_349cc +.okay ld a, b add c - ld [wc717], a + ld [wEnemySwitchMonParam], a ret -.asm_349d2 +.no_last_counter_move call CheckPlayerMoveTypeMatchups ld a, [wc716] cp 10 ret nc - call CheckEnemyHasMonToSwitchTo - call Function34b77 - call Function34b20 + call FindAliveEnemyMons + call FindEnemyMonsWithEnoughHP + call FindEnemyMonsThatResistPlayer call Function34a85 ld a, e @@ -295,12 +295,12 @@ CheckAbleToSwitch: ; 34941 ld a, [wc716] add $10 - ld [wc717], a + ld [wEnemySwitchMonParam], a ret ; 349f4 -CheckEnemyHasMonToSwitchTo: ; 349f4 +FindAliveEnemyMons: ; 349f4 ld a, [OTPartyCount] cp 2 jr c, .only_one @@ -421,23 +421,23 @@ Function34a85: ; 34a85 ld hl, OTPartyMon1HP ld b, 1 << (PARTY_LENGTH - 1) ld c, 0 -.asm_34a91 +.loop ld a, [hli] or [hl] - jr z, .asm_34a98 + jr z, .next ld a, b or c ld c, a -.asm_34a98 +.next srl b push bc ld bc, PartyMon2HP - (PartyMon1HP + 1) add hl, bc pop bc dec e - jr nz, .asm_34a91 + jr nz, .loop ld a, c pop bc @@ -456,26 +456,26 @@ Function34aa7: ; 34aa7 ld b, 1 << (PARTY_LENGTH - 1) ld d, 0 ld e, 0 -.asm_34ab5 +.loop ld a, b and c - jr z, .asm_34b00 + jr z, .next push hl push bc ld b, NUM_MOVES ld c, 0 -.asm_34abf +.loop3 ld a, [hli] and a push hl - jr z, .asm_34aef + jr z, .break3 dec a ld hl, Moves + MOVE_POWER call GetMoveAttr and a - jr z, .asm_34ae9 + jr z, .nope inc hl call GetMoveByte @@ -483,61 +483,61 @@ Function34aa7: ; 34aa7 call CheckTypeMatchup ld a, [wTypeMatchup] cp 10 - jr c, .asm_34ae9 + jr c, .nope ld e, 1 - cp 11 - jr c, .asm_34ae9 + cp 10 + 1 + jr c, .nope ld e, 2 - jr .asm_34aef + jr .break3 -.asm_34ae9 +.nope pop hl dec b - jr nz, .asm_34abf + jr nz, .loop3 - jr .asm_34af0 + jr .done -.asm_34aef +.break3 pop hl -.asm_34af0 +.done ld a, e pop bc pop hl cp $2 - jr z, .asm_34b0e + jr z, .done2 cp $1 - jr nz, .asm_34b00 + jr nz, .next ld a, d or b ld d, a - jr .asm_34b00 + jr .next -.asm_34b00 +.next push bc ld bc, PARTYMON_STRUCT_LENGTH add hl, bc pop bc srl b - jr nc, .asm_34ab5 + jr nc, .loop ld a, d ld b, a and a ret z -.asm_34b0e +.done2 push bc sla b sla b ld c, $ff -.asm_34b15 +.loop2 inc c sla b - jr nc, .asm_34b15 + jr nc, .loop2 ld a, c ld [wc716], a @@ -546,60 +546,60 @@ Function34aa7: ; 34aa7 ; 34b20 -Function34b20: ; 34b20 +FindEnemyMonsThatResistPlayer: ; 34b20 push bc ld hl, OTPartySpecies ld b, 1 << (PARTY_LENGTH - 1) ld c, 0 -.asm_34b28 +.loop ld a, [hli] cp $ff - jr z, .asm_34b72 + jr z, .done push hl ld [CurSpecies], a call GetBaseData ld a, [LastEnemyCounterMove] and a - jr z, .asm_34b4a + jr z, .skip_move dec a ld hl, Moves + MOVE_POWER call GetMoveAttr and a - jr z, .asm_34b4a + jr z, .skip_move inc hl call GetMoveByte - jr .asm_34b5d + jr .check_type -.asm_34b4a +.skip_move ld a, [BattleMonType1] ld hl, BaseType call CheckTypeMatchup ld a, [wTypeMatchup] - cp $b - jr nc, .asm_34b6d + cp 10 + 1 + jr nc, .dont_choose_mon ld a, [BattleMonType2] -.asm_34b5d +.check_type ld hl, BaseType call CheckTypeMatchup ld a, [wTypeMatchup] - cp $b - jr nc, .asm_34b6d + cp 10 + 1 + jr nc, .dont_choose_mon ld a, b or c ld c, a -.asm_34b6d +.dont_choose_mon srl b pop hl - jr .asm_34b28 + jr .loop -.asm_34b72 +.done ld a, c pop bc and c @@ -608,7 +608,7 @@ Function34b20: ; 34b20 ; 34b77 -Function34b77: ; 34b77 +FindEnemyMonsWithEnoughHP: ; 34b77 push bc ld de, OTPartySpecies ld b, 1 << (PARTY_LENGTH - 1) @@ -629,10 +629,14 @@ Function34b77: ; 34b77 rept 2 inc hl endr +; hl = MaxHP + 1 +; b = (4 * b) % $100 + (c & 3) +; c = c / 4 srl c rl b srl c rl b +; a = (MaxHP / $100) - b - (1 if c > (MaxHP % $100) else 0) ld a, [hld] cp c ld a, [hl] diff --git a/battle/core.asm b/battle/core.asm index a772794a1..0cfb585bf 100644 --- a/battle/core.asm +++ b/battle/core.asm @@ -38,7 +38,7 @@ Function3c000: ; 3c000 dec a jr z, .wild xor a - ld [wc718], a + ld [wEnemySwitchMonIndex], a call NewEnemyMonStatus call ResetEnemyStatLevels call BreakAttraction @@ -104,7 +104,7 @@ Function3c000: ; 3c000 cp $2 jr nz, .not_linked_2 xor a - ld [wc718], a + ld [wEnemySwitchMonIndex], a call NewEnemyMonStatus call ResetEnemyStatLevels call BreakAttraction @@ -136,7 +136,7 @@ WildFled_EnemyFled_LinkBattleCanceled: ; 3c0e5 and $c0 ld [wBattleResult], a ld hl, BattleText_EnemyFled - call Function3d2e0 + call CheckMobileBattleError jr nc, .asm_3c115 ld hl, wcd2a @@ -150,7 +150,7 @@ WildFled_EnemyFled_LinkBattleCanceled: ; 3c0e5 .asm_3c118 call StopDangerSound - call Function3d2e0 + call CheckMobileBattleError jr c, .asm_3c126 ld de, SFX_RUN @@ -179,7 +179,7 @@ Function3c12f: ; 3c12f ld [CurDamage], a ld [CurDamage + 1], a - call Function3c27c + call HandleBerserkGene call UpdateBattleMonInParty callba AIChooseMove @@ -191,7 +191,7 @@ Function3c12f: ; 3c12f jp c, .quit .not_disconnected - call Function3c410 + call CheckPlayerLockedIn jr c, .skip_iteration .loop1 call BattleMenu @@ -199,27 +199,27 @@ Function3c12f: ; 3c12f ld a, [BattleEnded] and a jr nz, .quit - ld a, [wd232] ; roared/whirlwinded/teleported + ld a, [wForcedSwitch] ; roared/whirlwinded/teleported and a jr nz, .quit .skip_iteration - call Function3c434 + call ParsePlayerAction jr nz, .loop1 - call Function3c300 + call EnemyTriesToFlee jr c, .quit call DetermineMoveOrder jr c, .false - call Function3c5fe + call Battle_EnemyFirst jr .proceed .false - call Function3c664 + call Battle_PlayerFirst .proceed - call Function3d2e0 + call CheckMobileBattleError jr c, .quit - ld a, [wd232] + ld a, [wForcedSwitch] and a jr nz, .quit @@ -355,7 +355,7 @@ CheckFaint_EnemyThenPlayer: ; 3c25c ret ; 3c27c -Function3c27c: ; 3c27c +HandleBerserkGene: ; 3c27c ld a, [hLinkPlayerNumber] cp $1 jr z, .reverse @@ -432,7 +432,7 @@ Function3c27c: ; 3c27c jp StdBattleTextBox ; 3c300 -Function3c300: ; 3c300 +EnemyTriesToFlee: ; 3c300 ld a, [wLinkMode] and a jr z, .not_linked @@ -592,7 +592,7 @@ CheckContestBattleOver: ; 3c3f5 ret ; 3c410 -Function3c410: ; 3c410 +CheckPlayerLockedIn: ; 3c410 ld a, [PlayerSubStatus4] and 1 << SUBSTATUS_RECHARGE jp nz, .quit @@ -618,25 +618,25 @@ Function3c410: ; 3c410 ret ; 3c434 -Function3c434: ; 3c434 - call Function3c410 - jp c, .asm_3c4ba +ParsePlayerAction: ; 3c434 + call CheckPlayerLockedIn + jp c, .locked_in ld hl, PlayerSubStatus5 bit SUBSTATUS_ENCORED, [hl] - jr z, .asm_3c449 + jr z, .not_encored ld a, [LastPlayerMove] ld [CurPlayerMove], a - jr .asm_3c47c + jr .encored -.asm_3c449 +.not_encored ld a, [wd0ec] cp $2 - jr z, .asm_3c4ce + jr z, .reset_rage and a - jr nz, .asm_3c4b5 + jr nz, .reset_bide ld a, [PlayerSubStatus3] and 1 << SUBSTATUS_BIDE - jr nz, .asm_3c4ba + jr nz, .locked_in xor a ld [wd235], a inc a ; POUND @@ -647,50 +647,50 @@ Function3c434: ; 3c434 call UpdateBattleHuds ld a, [CurPlayerMove] cp STRUGGLE - jr z, .asm_3c476 + jr z, .struggle call PlayClickSFX -.asm_3c476 +.struggle ld a, $1 ld [hBGMapMode], a pop af ret nz -.asm_3c47c +.encored call SetPlayerTurn callab UpdateMoveData xor a ld [wPlayerCharging], a ld a, [wPlayerMoveStruct + MOVE_EFFECT] cp EFFECT_FURY_CUTTER - jr z, .asm_3c494 + jr z, .continue_fury_cutter xor a ld [PlayerFuryCutterCount], a -.asm_3c494 +.continue_fury_cutter ld a, [wPlayerMoveStruct + MOVE_EFFECT] cp EFFECT_RAGE - jr z, .asm_3c4a4 + jr z, .continue_rage ld hl, PlayerSubStatus4 res SUBSTATUS_RAGE, [hl] xor a ld [wPlayerRageCounter], a -.asm_3c4a4 +.continue_rage ld a, [wPlayerMoveStruct + MOVE_EFFECT] cp EFFECT_PROTECT - jr z, .asm_3c4c9 + jr z, .continue_protect cp EFFECT_ENDURE - jr z, .asm_3c4c9 + jr z, .continue_protect xor a ld [PlayerProtectCount], a - jr .asm_3c4c9 + jr .continue_protect -.asm_3c4b5 +.reset_bide ld hl, PlayerSubStatus3 res SUBSTATUS_BIDE, [hl] -.asm_3c4ba +.locked_in xor a ld [PlayerFuryCutterCount], a ld [PlayerProtectCount], a @@ -698,12 +698,12 @@ Function3c434: ; 3c434 ld hl, PlayerSubStatus4 res SUBSTATUS_RAGE, [hl] -.asm_3c4c9 - call Function3e7c1 +.continue_protect + call ParseEnemyAction xor a ret -.asm_3c4ce +.reset_rage xor a ld [PlayerFuryCutterCount], a ld [PlayerProtectCount], a @@ -932,19 +932,19 @@ GetMoveEffect: ; 3c5ec ; 3c5fe -Function3c5fe: ; 3c5fe +Battle_EnemyFirst: ; 3c5fe call LoadTileMapToTempTileMap call TryEnemyFlee jp c, WildFled_EnemyFled_LinkBattleCanceled call SetEnemyTurn ld a, $1 - ld [wc70f], a + ld [wEnemyGoesFirst], a callab AI_SwitchOrTryItem jr c, .switch_item call EnemyTurn_EndOpponentProtectEndureDestinyBond - call Function3d2e0 + call CheckMobileBattleError ret c - ld a, [wd232] + ld a, [wForcedSwitch] and a ret nz call HasPlayerFainted @@ -958,9 +958,9 @@ Function3c5fe: ; 3c5fe jp z, HandleEnemyMonFaint call RefreshBattleHuds call PlayerTurn_EndOpponentProtectEndureDestinyBond - call Function3d2e0 + call CheckMobileBattleError ret c - ld a, [wd232] + ld a, [wForcedSwitch] and a ret nz call HasEnemyFainted @@ -976,18 +976,18 @@ Function3c5fe: ; 3c5fe ret ; 3c664 -Function3c664: ; 3c664 +Battle_PlayerFirst: ; 3c664 xor a - ld [wc70f], a + ld [wEnemyGoesFirst], a call SetEnemyTurn callab AI_SwitchOrTryItem push af call PlayerTurn_EndOpponentProtectEndureDestinyBond pop bc - ld a, [wd232] + ld a, [wForcedSwitch] and a ret nz - call Function3d2e0 + call CheckMobileBattleError ret c call HasEnemyFainted jp z, HandleEnemyMonFaint @@ -1006,9 +1006,9 @@ Function3c664: ; 3c664 call TryEnemyFlee jp c, WildFled_EnemyFled_LinkBattleCanceled call EnemyTurn_EndOpponentProtectEndureDestinyBond - call Function3d2e0 + call CheckMobileBattleError ret c - ld a, [wd232] + ld a, [wForcedSwitch] and a ret nz call HasPlayerFainted @@ -2154,7 +2154,7 @@ HandleEnemyMonFaint: ; 3cd55 .dont_flee call Function3d227 - call Function3d2e0 + call CheckMobileBattleError jp c, WildFled_EnemyFled_LinkBattleCanceled ld a, $1 @@ -2437,7 +2437,7 @@ Function3cf4a: ; 3cf4a EnemyPartyMonEntrance: ; 3cf78 push af xor a - ld [wc718], a + ld [wEnemySwitchMonIndex], a call NewEnemyMonStatus call ResetEnemyStatLevels call BreakAttraction @@ -2805,7 +2805,7 @@ HandlePlayerMonFaint: ; 3d14e .asm_3d190 call Function3d227 - call Function3d2e0 + call CheckMobileBattleError jp c, WildFled_EnemyFled_LinkBattleCanceled ld a, c and a @@ -2900,7 +2900,7 @@ Function3d227: ; 3d227 .skip_link xor a ld [wd0ec], a - call Function3d2e0 + call CheckMobileBattleError jr c, .asm_3d251 ld hl, EnemyMonHP ld a, [hli] @@ -2968,7 +2968,7 @@ Function3d2b3: ; 3d2b3 ; 3d2e0 -Function3d2e0: ; 3d2e0 +CheckMobileBattleError: ; 3d2e0 ld a, [wLinkMode] cp LINK_MOBILE jr nz, .not_mobile ; It's not a mobile battle @@ -3057,7 +3057,7 @@ ForcePickPartyMonInBattle: ; 3d362 .pick call PickPartyMonInBattle ret nc - call Function3d2e0 + call CheckMobileBattleError ret c ld de, SFX_WRONG @@ -3082,7 +3082,7 @@ ForcePickSwitchMonInBattle: ; 3d380 .pick call ForcePickPartyMonInBattle - call Function3d2e0 + call CheckMobileBattleError ret c call SwitchMonAlreadyOut jr c, .pick @@ -3306,7 +3306,7 @@ Function3d4ae: ; 3d4ae Function3d4c3: ; 3d4c3 call ResetEnemyBattleVars - ld a, [wc718] + ld a, [wEnemySwitchMonIndex] dec a ld b, a call LoadEnemyPkmnToSwitchTo @@ -3376,7 +3376,7 @@ Function3d533: ; 3d533 jr .return_carry .not_linked - ld a, [wc718] + ld a, [wEnemySwitchMonIndex] and a jr z, .check_wd264 @@ -4031,8 +4031,8 @@ TryToRunAwayFromBattle: ; 3d8b3 ld [CurPlayerMove], a call Function3e8e4 call Call_LoadTempTileMapToTileMap - call Function3d2e0 - jr c, .asm_3d9f5 + call CheckMobileBattleError + jr c, .mobile ; Got away safely ld a, [wBattleAction] @@ -4059,15 +4059,15 @@ TryToRunAwayFromBattle: ; 3d8b3 scf ret -.asm_3d9f5 +.mobile call StopDangerSound ld hl, wcd2a bit 4, [hl] - jr nz, .asm_3da05 + jr nz, .skip_link_error ld hl, BattleText_LinkErrorBattleCanceled call StdBattleTextBox -.asm_3da05 +.skip_link_error call WaitSFX call LoadTileMapToTempTileMap scf @@ -5353,13 +5353,13 @@ Function3e299: jr .asm_3e2a8 .asm_3e2c8 - call Function3d2e0 + call CheckMobileBattleError jr c, .asm_3e2da jr Function3e299 .asm_3e2cf call Function3e308 - call Function3d2e0 + call CheckMobileBattleError jr c, .asm_3e2da jp Function3e290 @@ -5470,7 +5470,7 @@ PlayerSwitch: ; 3e3ad call WriteBackup .not_linked - call Function3e7c1 + call ParseEnemyAction ld a, [wLinkMode] and a jr nz, .linked @@ -6070,7 +6070,7 @@ Function3e786: ; 3e786 -Function3e7c1: ; 3e7c1 +ParseEnemyAction: ; 3e7c1 ld a, [wEnemyIsSwitching] and a ret nz @@ -8740,7 +8740,7 @@ Function3f6d0: ; 3f6d0 ld [OtherTrainerClass], a ld [wd266], a ld [wd267], a - ld [wd232], a + ld [wForcedSwitch], a ld [wd0d8], a ld [wKeyItemsPocketCursor], a ld [wItemsPocketCursor], a @@ -8813,7 +8813,7 @@ Function3f759: ; 3f759 ; 3f77c Function3f77c: ; 3f77c - callba Function3d2e0 + callba CheckMobileBattleError jp c, Function3f80f call Function3f830 jr nz, .asm_3f797 diff --git a/battle/effect_commands.asm b/battle/effect_commands.asm index e93284c72..37e13d0bc 100644 --- a/battle/effect_commands.asm +++ b/battle/effect_commands.asm @@ -6530,7 +6530,7 @@ BattleCommand_Teleport: ; 36778 xor a ld [wcfca], a inc a - ld [wd232], a + ld [wForcedSwitch], a ld [wKickCounter], a call SetBattleDraw call BattleCommand_LowerSub @@ -6598,15 +6598,15 @@ BattleCommand_ForceSwitch: ; 3680f xor a ld [wcfca], a inc a - ld [wd232], a + ld [wForcedSwitch], a call SetBattleDraw ld a, [wPlayerMoveStruct + MOVE_ANIM] jp .succeed .trainer - call CheckEnemyHasMonToSwitchTo + call FindAliveEnemyMons jr c, .switch_fail ; 3686c $5c - ld a, [wc70f] + ld a, [wEnemyGoesFirst] and a jr z, .switch_fail ; 36872 $56 call UpdateEnemyMonInParty @@ -6643,7 +6643,7 @@ BattleCommand_ForceSwitch: ; 3680f jr z, .random_loop_trainer ; 368b1 $e7 ld a, d inc a - ld [wc718], a + ld [wEnemySwitchMonIndex], a callab Function3d4c3 ld hl, DraggedOutText @@ -6691,7 +6691,7 @@ BattleCommand_ForceSwitch: ; 3680f xor a ld [wcfca], a inc a - ld [wd232], a + ld [wForcedSwitch], a call SetBattleDraw ld a, [wEnemyMoveStruct + MOVE_ANIM] jr .succeed @@ -6700,7 +6700,7 @@ BattleCommand_ForceSwitch: ; 3680f call CheckPlayerHasMonToSwitchTo jr c, .fail - ld a, [wc70f] + ld a, [wEnemyGoesFirst] cp $1 jr z, .switch_fail @@ -6991,7 +6991,7 @@ Function36ab5: ; 36ab5 Function36abf: ; 36abf push bc - ld a, [wc70f] + ld a, [wEnemyGoesFirst] ld b, a ld a, [hBattleTurn] xor b @@ -8943,7 +8943,7 @@ BattleCommand_BatonPass: ; 379c9 call BatonPass_LinkPlayerSwitch ; Mobile link battles handle entrances differently - callba Function3d2e0 + callba CheckMobileBattleError jp c, EndMoveEffect ld hl, PassedBattleMonEntrance @@ -8968,12 +8968,12 @@ BattleCommand_BatonPass: ; 379c9 call BatonPass_LinkEnemySwitch ; Mobile link battles handle entrances differently - callba Function3d2e0 + callba CheckMobileBattleError jp c, EndMoveEffect ; Passed enemy PartyMon entrance xor a - ld [wc718], a + ld [wEnemySwitchMonIndex], a ld hl, EnemySwitch_SetMode call CallBattleCore ld hl, ResetBattleParticipants diff --git a/items/item_effects.asm b/items/item_effects.asm index 0c1fcc8ac..b2258b6d5 100644 --- a/items/item_effects.asm +++ b/items/item_effects.asm @@ -2288,7 +2288,7 @@ PokeDoll: ; f48f dec a jr nz, .asm_f4a6 inc a - ld [wd232], a + ld [wForcedSwitch], a ld a, [wBattleResult] and 3 << 6 or $2 @@ -32256,7 +32256,7 @@ endr ld [BattleMonSpecies], a ld [wBattleParticipantsNotFainted], a ld [CurBattleMon], a - ld [wd232], a + ld [wForcedSwitch], a ld [TimeOfDayPal], a ld [PlayerTurnsTaken], a ld [EnemyTurnsTaken], a @@ -33688,14 +33688,14 @@ endr ; so we have always the same AI, regardless of the loaded class of trainer ld a, [InBattleTowerBattle] bit 0, a - jr nz, .asm_4412f + jr nz, .battle_tower_skip ld a, [TrainerClass] dec a ld bc, 7 ; Trainer2AI - Trainer1AI call AddNTimes -.asm_4412f +.battle_tower_skip lb bc, CHECK_FLAG, 0 push bc push hl @@ -33766,40 +33766,40 @@ endr .PickLowestScoreMoves ld a, c -.asm_44175 +.move_loop inc [hl] dec hl inc a cp NUM_MOVES + 1 - jr nz, .asm_44175 + jr nz, .move_loop ld hl, Buffer1 ld de, EnemyMonMoves ld c, NUM_MOVES ; Give a score of 0 to a blank move -.asm_44184 +.loop2 ld a, [de] and a - jr nz, .asm_44189 + jr nz, .skip_load ld [hl], a ; Disregard the move if its score is not 1 -.asm_44189 +.skip_load ld a, [hl] dec a - jr z, .asm_44191 + jr z, .keep xor a ld [hli], a - jr .asm_44193 + jr .after_toss -.asm_44191 +.keep ld a, [de] ld [hli], a -.asm_44193 +.after_toss inc de dec c - jr nz, .asm_44184 + jr nz, .loop2 ; Randomly choose one of the moves with a score of 1 .ChooseMove @@ -60912,7 +60912,7 @@ Function92ed5: ; 92ed5 ; 92ee0 Function92ee0: ; 92ee0 - ld hl, wc70f + ld hl, wEnemyGoesFirst ld a, [wc700] cp [hl] call z, Function92f0c @@ -60920,7 +60920,7 @@ Function92ee0: ; 92ee0 ; 92eeb Function92eeb: ; 92eeb - ld hl, wc70f + ld hl, wEnemyGoesFirst ld a, [wc701] cp [hl] call z, Function92f0c @@ -60928,7 +60928,7 @@ Function92eeb: ; 92eeb ; 92ef6 Function92ef6: ; 92ef6 - ld hl, wc70f + ld hl, wEnemyGoesFirst ld a, [wc702] cp [hl] call z, Function92f0c @@ -61033,7 +61033,7 @@ Function92f70: ; 92f70 ; 92f80 Function92f80: ; 92f80 - ld hl, wc70f + ld hl, wEnemyGoesFirst ld a, [wc701] cp [hl] ret nz diff --git a/misc/mobile_5f.asm b/misc/mobile_5f.asm index 54b1d9203..8e89a648b 100644 --- a/misc/mobile_5f.asm +++ b/misc/mobile_5f.asm @@ -1928,7 +1928,7 @@ Function17dc1f: ; 17dc1f ld a, $5c ld [wc70e], a ld a, $1 - ld [wc70f], a + ld [wEnemyGoesFirst], a ld hl, wc708 call LoadMenuDataHeader call InterpretMenu2 @@ -2155,7 +2155,7 @@ Function17dd49: ; 17dd49 jr .asm_17ddc9 .asm_17ddb7 - ld a, [wc70f] + ld a, [wEnemyGoesFirst] ld l, a ld a, [wc710] ld h, a @@ -2219,7 +2219,7 @@ Function17ddcd: ; 17ddcd jr nz, .asm_17de26 ld a, [wc70e] ld l, a - ld a, [wc70f] + ld a, [wEnemyGoesFirst] ld h, a jr .asm_17de2e @@ -2277,7 +2277,7 @@ Function17de32: ; 17de32 .asm_17de78 ld a, [wc70e] ld l, a - ld a, [wc70f] + ld a, [wEnemyGoesFirst] ld h, a jr .asm_17de8a @@ -2879,7 +2879,7 @@ Function17e1a1: ; 17e1a1 jr .asm_17e250 .asm_17e23e - ld a, [wc70f] + ld a, [wEnemyGoesFirst] ld l, a ld a, [wc710] ld h, a @@ -452,7 +452,7 @@ wOddEggOTName:: ds PKMN_NAME_LENGTH ds -70 wBT_OTTemp:: battle_tower_struct wBT_OTTemp - ds -BATTLE_TOWER_STRUCT_LENGTH + ds wBT_OTTemp - @ wMisc:: wBattle:: @@ -818,7 +818,7 @@ wc70e:: FailedMessage:: ; c70e ds 1 -wc70f:: ds 1 +wEnemyGoesFirst:: ds 1 wc710:: wPlayerIsSwitching:: ds 1 ; c710 wc711:: @@ -831,8 +831,9 @@ PlayerUsedMoves:: ; c712 ds NUM_MOVES wc716:: ds 1 +wEnemySwitchMonParam:: wc717:: ds 1 -wc718:: ds 1 +wEnemySwitchMonIndex:: ds 1 wc719:: ds 1 LastPlayerMon:: ; c71a wc71a:: ds 1 @@ -912,25 +913,6 @@ wMiscEnd:: wc7e8:: ds 24 - -RSSET 0 ; Offsets for wBT_OTTemp:: @ $c608 -wBT_OTTemp_0 RB NAME_LENGTH + -1 ; $c608 -wBT_OTTemp_TrainerClass RB 1 ; $c608 + $a = $c612 -wBT_OTTemp_Pkmn1 RB $30 ; PARTYMON_STRUCT_LENGTH ; $c608 + $b = $c613 -wBT_OTTemp_Pkmn1Name RB PKMN_NAME_LENGTH + -1 ; $c608 + $45 = $c64d -wBT_OTTemp_45 RB 1 -wBT_OTTemp_Pkmn2 RB $30 ; PARTYMON_STRUCT_LENGTH ; $c608 + $46 = $c64e -wBT_OTTemp_Pkmn2Name RB PKMN_NAME_LENGTH + -1 ; $c608 + $76 = $c67e -wBT_OTTemp_80 RB 1 -wBT_OTTemp_Pkmn3 RB $30 ; PARTYMON_STRUCT_LENGTH ; $c608 + $81 = $c689 -wBT_OTTemp_Pkmn3Name RB PKMN_NAME_LENGTH + -1 ; $c608 + $b1 = $c6b9 -wBT_OTTemp_BB RB 1 - -GLOBAL wBT_OTTemp_TrainerClass, wBT_OTTemp_Pkmn1, wBT_OTTemp_Pkmn1Name, wBT_OTTemp_Pkmn2, wBT_OTTemp_Pkmn2Name, wBT_OTTemp_Pkmn3, wBT_OTTemp_Pkmn3Name -GLOBAL wBT_OTTemp_45, wBT_OTTemp_80, wBT_OTTemp_BB - - - SECTION "Overworld Map", WRAM0 [$c800] wc800:: @@ -1863,7 +1845,7 @@ OtherTrainerID:: ; d231 ; (Joey, Mikey, Albert, etc.) ds 1 -wd232:: ds 1 +wForcedSwitch:: ds 1 TrainerClass:: ; d233 ds 1 |