Skip to content

Commit

Permalink
Merge pull request #113 from savaughn/112-dvs-randomization-is-not-ra…
Browse files Browse the repository at this point in the history
…ndom-on-trade-for-player2

fixed dv rand
  • Loading branch information
savaughn authored Nov 26, 2023
2 parents e8ec092 + d7eb6d9 commit 048ddf8
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions src/pksavhelper.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ enum eligible_evolution_status check_trade_evolution_gen2(PokemonSave *pkmn_save
// Species index of pokemon being checked
int species = pkmn_save->save.gen2_save.pokemon_storage.p_party->species[pkmn_party_index];
struct pkmn_evolution_pair_data evo_pair = pkmn_evolution_pairs_gen2[species];

// If the pkmn species has an initialized evolution pair
if (species == evo_pair.species_index)
{
Expand Down Expand Up @@ -199,13 +199,13 @@ uint8_t calculate_stat(uint8_t level, uint8_t base_stat, uint8_t dv, uint16_t st
/************************************************************************
* Simulate the random number generation for Generation 1
*/
uint8_t r_div = 0;
uint8_t carry_bit = 0;
uint8_t add_byte = 0;
uint8_t subtract_byte = 0;
static uint8_t r_div = 0;
static uint8_t carry_bit = 0;
static uint8_t add_byte = 0;
static uint8_t subtract_byte = 0;
// Simulated hardware registers
uint8_t h_random_add = 0; // h_random_add register
uint8_t h_random_sub = 0; // h_random_sub register
static uint8_t h_random_add = 0; // h_random_add register
static uint8_t h_random_sub = 0; // h_random_sub register

// Simulate one step of the random number generation process
void generate_random_number_step(void)
Expand Down Expand Up @@ -254,13 +254,16 @@ void generate_random_number_step_gen2(void)

void generate_rand_num_step(SaveGenerationType save_generation_type)
{
if (save_generation_type == SAVE_GENERATION_1)
{
generate_random_number_step();
}
else
for (int i = 0; i < rand(); i++)
{
generate_random_number_step_gen2();
if (save_generation_type == SAVE_GENERATION_1)
{
generate_random_number_step();
}
else
{
generate_random_number_step_gen2();
}
}
}

Expand Down

0 comments on commit 048ddf8

Please sign in to comment.