Document a bugfix: AI makes a false assumption about CheckTypeMatchup

This commit is contained in:
Rangi 2019-01-07 18:12:00 -05:00
parent 26fc7e2521
commit 1b1b0ac6ea
1 changed files with 24 additions and 23 deletions

View File

@ -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` ## 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 ```diff
BattleCheckTypeMatchup: BattleCheckTypeMatchup:
ld hl, wEnemyMonType1 ld hl, wEnemyMonType1
ldh a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, CheckTypeMatchup jr z, CheckTypeMatchup
ld hl, wBattleMonType1 ld hl, wBattleMonType1
CheckTypeMatchup: + ld a, BATTLE_VARS_MOVE_TYPE
; There is an incorrect assumption about this function made in the AI related code: when + call GetBattleVar ; preserves hl, de, and bc
; the AI calls CheckTypeMatchup (not BattleCheckTypeMatchup), it assumes that placing the CheckTypeMatchup:
; offensive type in a will make this function do the right thing. Since a is overwritten, -; There is an incorrect assumption about this function made in the AI related code: when
; this assumption is incorrect. A simple fix would be to load the move type for the -; the AI calls CheckTypeMatchup (not BattleCheckTypeMatchup), it assumes that placing the
; current move into a in BattleCheckTypeMatchup, before falling through, which is -; offensive type in a will make this function do the right thing. Since a is overwritten,
; consistent with how the rest of the code assumes this code works like. -; this assumption is incorrect. A simple fix would be to load the move type for the
push hl -; current move into a in BattleCheckTypeMatchup, before falling through, which is
push de -; consistent with how the rest of the code assumes this code works like.
push bc push hl
ld a, BATTLE_VARS_MOVE_TYPE push de
call GetBattleVar push bc
ld d, a - 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 ## NPC use of Full Heal or Full Restore does not cure Nightmare status