Skip to content

Commit

Permalink
Document Day Care Exp bug (pret#895)
Browse files Browse the repository at this point in the history
  • Loading branch information
Idain authored Mar 21, 2022
1 parent 9b4ebe9 commit 5206ac6
Showing 1 changed file with 54 additions and 2 deletions.
56 changes: 54 additions & 2 deletions docs/bugs_and_glitches.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,11 @@ Fixes in the [multi-player battle engine](#multi-player-battle-engine) category
- [`RIVAL2` has lower DVs than `RIVAL1`](#rival2-has-lower-dvs-than-rival1)
- [`HELD_CATCH_CHANCE` has no effect](#held_catch_chance-has-no-effect)
- [Credits sequence changes move selection menu behavior](#credits-sequence-changes-move-selection-menu-behavior)
- [Overworld engine](#overworld-engine)
- [Game engine](#game-engine)
- [`LoadMetatiles` wraps around past 128 blocks](#loadmetatiles-wraps-around-past-128-blocks)
- [Surfing directly across a map connection does not load the new map](#surfing-directly-across-a-map-connection-does-not-load-the-new-map)
- [Swimming NPCs aren't limited by their movement radius](#swimming-npcs-arent-limited-by-their-movement-radius)
- [Pokémon deposited in the Day-Care might lose experience](#pokémon-deposited-in-the-day-care-might-lose-experience)
- [Graphics](#graphics)
- [In-battle “``” ellipsis is too high](#in-battle--ellipsis-is-too-high)
- [Two tiles in the `port` tileset are drawn incorrectly](#two-tiles-in-the-port-tileset-are-drawn-incorrectly)
Expand Down Expand Up @@ -1559,7 +1560,7 @@ The `[hInMenu]` value determines this button behavior. However, the battle moves
```


## Overworld engine
## Game engine


### `LoadMetatiles` wraps around past 128 blocks
Expand Down Expand Up @@ -1672,6 +1673,57 @@ This bug is why the Lapras in [maps/UnionCaveB2F.asm](https://github.com/pret/po
```


### Pokémon deposited in the Day-Care might lose experience

This happens because when a Pokémon is withdrawn from the Day-Care, its Exp. Points are reset to the minimum required for its level. This means that if it hasn't gained any levels, it may lose experience.

**Fix**: Edit `RetrieveBreedmon` in [engine/pokemon/move_mon.asm](https://github.com/pret/pokecrystal/blob/master/engine/pokemon/move_mon.asm):

```diff
RetrieveBreedmon:

...

ld a, [wPartyCount]
dec a
ld [wCurPartyMon], a
farcall HealPartyMon
- ld a, [wCurPartyLevel]
- ld d, a
+ ; Check if there's an exp overflow
+ ld d, MAX_LEVEL
callfar CalcExpAtLevel
pop bc
- ld hl, MON_EXP
+ ld hl, MON_EXP + 2
add hl, bc
ldh a, [hMultiplicand]
- ld [hli], a
+ ld b, a
ldh a, [hMultiplicand + 1]
- ld [hli], a
+ ld c, a
ldh a, [hMultiplicand + 2]
+ ld d, a
+ ld a, [hld]
+ sub d
+ ld a, [hld]
+ sbc c
+ ld a, [hl]
+ sbc b
+ jr c, .not_max_exp
+ ld a, b
+ ld [hli], a
+ ld a, c
+ ld [hli], a
+ ld a, d
ld [hl], a
+.not_max_exp
and a
ret
```


## Graphics


Expand Down

0 comments on commit 5206ac6

Please sign in to comment.