Evie (ChickasaurusGL) 🌺 | CoolTrainer♀ 10-20% HP switch chance coding flaw (Generation I) @ChickasaurusGL | Uploaded November 2021 | Updated October 2024, 13 hours ago.
Notes: This demonstration would be incomplete without a description, so recommend reading it. It was documented by invalio19 in January, and added as a comment in the disassembly project file github.com/pret/pokered/blob/master/engine/battle/trainer_ai.asm earlier today by Rangi42.
github.com/pret/pokered/issues/308
When a CoolTrainer♀ (specifically) has between 10-20% HP the (relative) chance of her switching is 100% rather than 25% because of faulty code (however, low HP does not guarantee it will happen because she can also use a Hyper Potion, I don't know sorry but perhaps that happens at 1/10 health so 10% and less). Adding a ret no carry flag will fix this.
CooltrainerFAI:
; The intended 25% chance to consider switching will not apply.
; Uncomment the line below to fix this.
cp 25 percent + 1
; ret nc
ld a, 10
call AICheckIfHPBelowFraction
jp c, AIUseHyperPotion
ld a, 5
call AICheckIfHPBelowFraction
ret nc
jp AISwitchIfEnoughMons
Notes: This demonstration would be incomplete without a description, so recommend reading it. It was documented by invalio19 in January, and added as a comment in the disassembly project file github.com/pret/pokered/blob/master/engine/battle/trainer_ai.asm earlier today by Rangi42.
github.com/pret/pokered/issues/308
When a CoolTrainer♀ (specifically) has between 10-20% HP the (relative) chance of her switching is 100% rather than 25% because of faulty code (however, low HP does not guarantee it will happen because she can also use a Hyper Potion, I don't know sorry but perhaps that happens at 1/10 health so 10% and less). Adding a ret no carry flag will fix this.
CooltrainerFAI:
; The intended 25% chance to consider switching will not apply.
; Uncomment the line below to fix this.
cp 25 percent + 1
; ret nc
ld a, 10
call AICheckIfHPBelowFraction
jp c, AIUseHyperPotion
ld a, 5
call AICheckIfHPBelowFraction
ret nc
jp AISwitchIfEnoughMons