vulcandth / pokecrystal16

Pokémon Crystal mod that implements 16-bit IDs for the vanilla game (not relying on other mods' features)
18 stars 22 forks source link

item-newbox | Incorrect skipping of parameters in evolve.asm #24

Open MarioBones opened 5 days ago

MarioBones commented 5 days ago

There are a few spots in engine/pokemon/evolve.asm where hl is incremented the wrong number of times and so the Pokemon's evolutions are not checked properly. This is only really noticeable on Eevee and Tyrogue but any Pokemon using EVOLVE_HAPPINESS or EVOLVE_STAT can theoretically encounter the issue.

If you step through EvolveAfterBattle_MasterLoop.loop when Eevee levels up you can see incorrect and invalid values for evolution methods get passed into a:

pokecrystal evolve

The following changes need to be made in evolve.asm:

; EVOLVE_STAT
    call GetNextEvoAttackByte
    ld c, a
    ld a, [wTempMonLevel]
    cp c
-   jp c, .skip_evolution_species_parameter
+   jp c, .skip_half_species_parameter

    call IsMonHoldingEverstone
-   jp z, .skip_evolution_species_parameter
+   jp c, .skip_evolution_species

...

.happiness
    ld a, [wTempMonHappiness]
    cp HAPPINESS_TO_EVOLVE
-   jp c, .skip_evolution_species_parameter
+   jp c, .skip_half_species_parameter

...

; TR_NITE
    ld a, [wTimeOfDay]
    cp NITE_F
-   jp nz, .skip_half_species_parameter
+   jp nz, .skip_evolution_species
    jp .proceed

.happiness_daylight
    ld a, [wTimeOfDay]
    cp NITE_F
-   jp z, .skip_half_species_parameter
+   jp z, .skip_evolution_species
    jp .proceed

I haven't done any testing with trades so it's possible that there's issues with EVOLVE_TRADE that I'm not aware of.

Rangi42 commented 5 days ago

I think a good solution would just be making all evolutions three values: dbww method byte, 16-bit param, 16-bit species. The param could be an item ID, move ID, etc, or some combination of two bytes for more complex methods (e.g. dbbbw EVOLVE_STAT, 20, ATK_LT_DEF, HITMONCHAN or dbbbw EVOLVE_LEVEL, 35, IN_GALAR, GALARIAN_WEEZING).