Document Return/Frustration bug and its fix (#872)

Co-authored-by: Rangi <35663410+Rangi42@users.noreply.github.com>
This commit is contained in:
Idain 2022-01-24 21:48:21 -04:00 committed by GitHub
parent 1dc88cb585
commit e949477089
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 50 additions and 3 deletions

View File

@ -34,6 +34,7 @@ Fixes in the [multi-player battle engine](#multi-player-battle-engine) category
- [Beat Up may fail to raise Substitute](#beat-up-may-fail-to-raise-substitute) - [Beat Up may fail to raise Substitute](#beat-up-may-fail-to-raise-substitute)
- [Beat Up may trigger King's Rock even if it failed](#beat-up-may-trigger-kings-rock-even-if-it-failed) - [Beat Up may trigger King's Rock even if it failed](#beat-up-may-trigger-kings-rock-even-if-it-failed)
- [Present damage is incorrect in link battles](#present-damage-is-incorrect-in-link-battles) - [Present damage is incorrect in link battles](#present-damage-is-incorrect-in-link-battles)
- [Return and Frustration deal no damage when the user's happiness is low or high, respectively](#return-and-frustration-deal-no-damage-when-the-users-happiness-is-low-or-high-respectively)
- [Dragon Scale, not Dragon Fang, boosts Dragon-type moves](#dragon-scale-not-dragon-fang-boosts-dragon-type-moves) - [Dragon Scale, not Dragon Fang, boosts Dragon-type moves](#dragon-scale-not-dragon-fang-boosts-dragon-type-moves)
- [Switching out or switching against a Pokémon with max HP below 4 freezes the game](#switching-out-or-switching-against-a-pokémon-with-max-HP-below-4-freezes-the-game) - [Switching out or switching against a Pokémon with max HP below 4 freezes the game](#switching-out-or-switching-against-a-pokémon-with-max-HP-below-4-freezes-the-game)
- [Moves that do damage and increase your stats do not increase stats after a KO](#moves-that-do-damage-and-increase-your-stats-do-not-increase-stats-after-a-ko) - [Moves that do damage and increase your stats do not increase stats after a KO](#moves-that-do-damage-and-increase-your-stats-do-not-increase-stats-after-a-ko)
@ -700,6 +701,53 @@ This bug existed for all battles in Gold and Silver, and was only fixed for sing
``` ```
## Return and Frustration deal no damage when the user's happiness is low or high, respectively
This happens because the user's happiness (or 255 happiness for Frustration) is multiplied by 10 and divided by 25, which rounds down to zero when the happiness is 02 (or 253255 for Frustration).
**Fix:**
Edit [engine/battle/move_effects/return.asm](https://github.com/pret/pokecrystal/blob/master/engine/battle/move_effects/return.asm):
```diff
BattleCommand_HappinessPower:
...
call Multiply
ld a, 25
ldh [hDivisor], a
ld b, 4
call Divide
ldh a, [hQuotient + 3]
+ and a
+ jr nz, .done
+ inc a
+.done
ld d, a
pop bc
ret
```
And edit [engine/battle/move_effects/frustration.asm](https://github.com/pret/pokecrystal/blob/master/engine/battle/move_effects/frustration.asm):
```diff
BattleCommand_FrustrationPower:
...
call Multiply
ld a, 25
ldh [hDivisor], a
ld b, 4
call Divide
ldh a, [hQuotient + 3]
+ and a
+ jr nz, .done
+ inc a
+.done
ld d, a
pop bc
ret
```
### Dragon Scale, not Dragon Fang, boosts Dragon-type moves ### Dragon Scale, not Dragon Fang, boosts Dragon-type moves
**Fix:** Edit `ItemAttributes` in [data/items/attributes.asm](https://github.com/pret/pokecrystal/blob/master/data/items/attributes.asm): **Fix:** Edit `ItemAttributes` in [data/items/attributes.asm](https://github.com/pret/pokecrystal/blob/master/data/items/attributes.asm):

View File

@ -1,13 +1,12 @@
BattleCommand_FrustrationPower: BattleCommand_FrustrationPower:
; frustrationpower ; frustrationpower
push bc push bc
ld hl, wBattleMonHappiness ld hl, wBattleMonHappiness
ldh a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .got_happiness jr z, .ok
ld hl, wEnemyMonHappiness ld hl, wEnemyMonHappiness
.got_happiness .ok
ld a, $ff ld a, $ff
sub [hl] sub [hl]
ldh [hMultiplicand + 2], a ldh [hMultiplicand + 2], a