diff options
| author | Rangi <remy.oukaour+rangi42@gmail.com> | 2019-01-07 18:12:00 -0500 | 
|---|---|---|
| committer | Rangi <remy.oukaour+rangi42@gmail.com> | 2019-01-07 18:12:00 -0500 | 
| commit | 1b1b0ac6ea1bb0ca11c2aa05411ece130f9cb98c (patch) | |
| tree | fdfdff71462b499a48f3b8da38e8e483681ee5ec /docs | |
| parent | 26fc7e2521bba2bd552fab7aed8a14fe15870598 (diff) | |
Document a bugfix: AI makes a false assumption about CheckTypeMatchup
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/bugs_and_glitches.md | 47 | 
1 files changed, 24 insertions, 23 deletions
| diff --git a/docs/bugs_and_glitches.md b/docs/bugs_and_glitches.md index 91c8dd578..f95d519cb 100644 --- a/docs/bugs_and_glitches.md +++ b/docs/bugs_and_glitches.md @@ -513,32 +513,33 @@ This bug existed for all battles in Gold and Silver, and was only fixed for sing  ## AI makes a false assumption about `CheckTypeMatchup` -In [engine/battle/effect_commands.asm](/engine/battle/effect_commands.asm). +**Fix:** Edit `BattleCheckTypeMatchup` in [engine/battle/effect_commands.asm](/engine/battle/effect_commands.asm): -```asm -BattleCheckTypeMatchup: -	ld hl, wEnemyMonType1 -	ldh a, [hBattleTurn] -	and a -	jr z, CheckTypeMatchup -	ld hl, wBattleMonType1 -CheckTypeMatchup: -; There is an incorrect assumption about this function made in the AI related code: when -; the AI calls CheckTypeMatchup (not BattleCheckTypeMatchup), it assumes that placing the -; offensive type in a will make this function do the right thing. Since a is overwritten, -; this assumption is incorrect. A simple fix would be to load the move type for the -; current move into a in BattleCheckTypeMatchup, before falling through, which is -; consistent with how the rest of the code assumes this code works like. -	push hl -	push de -	push bc -	ld a, BATTLE_VARS_MOVE_TYPE -	call GetBattleVar -	ld d, a +```diff + BattleCheckTypeMatchup: + 	ld hl, wEnemyMonType1 + 	ldh a, [hBattleTurn] + 	and a + 	jr z, CheckTypeMatchup + 	ld hl, wBattleMonType1 ++	ld a, BATTLE_VARS_MOVE_TYPE ++	call GetBattleVar ; preserves hl, de, and bc + CheckTypeMatchup: +-; There is an incorrect assumption about this function made in the AI related code: when +-; the AI calls CheckTypeMatchup (not BattleCheckTypeMatchup), it assumes that placing the +-; offensive type in a will make this function do the right thing. Since a is overwritten, +-; this assumption is incorrect. A simple fix would be to load the move type for the +-; current move into a in BattleCheckTypeMatchup, before falling through, which is +-; consistent with how the rest of the code assumes this code works like. + 	push hl + 	push de + 	push bc +-	ld a, BATTLE_VARS_MOVE_TYPE +-	call GetBattleVar + 	ld d, a + 	...  ``` -*To do:* Fix this bug. -  ## NPC use of Full Heal or Full Restore does not cure Nightmare status | 
