Skip to content

Commit

Permalink
Fix status conditions and eggs
Browse files Browse the repository at this point in the history
Previous to this patch, status conditions were reset and eggs would be randomized.
  • Loading branch information
googleben committed Feb 12, 2020
1 parent 5b0d528 commit a613d72
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/party_randomizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ static void rndPkmn(struct Pokemon* mon) {
u32 xpa, xpb, xpc, xpd;
f32 hpr, xpr;
u16 prevHp;
u32 status;
u16 n = Random() % (NUM_SPECIES - 1) + 1;


Expand All @@ -173,6 +174,10 @@ static void rndPkmn(struct Pokemon* mon) {
u8 nickname[POKEMON_NAME_LENGTH];
s32 i;
u16 heldItem = GetMonData(mon, MON_DATA_HELD_ITEM, NULL);
species = GetMonData(mon, MON_DATA_SPECIES, 0);
//skip eggs
if (species == SPECIES_EGG || mon->box.isEgg) return;
status = mon->status;
GetMonData(mon, MON_DATA_NICKNAME, nickname);

//if we got bad species id (?? pokemon), try to random again. If that doesn't work, just choose one.
Expand All @@ -181,7 +186,7 @@ static void rndPkmn(struct Pokemon* mon) {
//calculate XP and HP percentages
level = mon->level;
exp = GetMonData(mon, MON_DATA_EXP, NULL);
species = GetMonData(mon, MON_DATA_SPECIES, 0);

nextLevel = GetMonData(mon, MON_DATA_LEVEL, 0) + 1;
xpa = gExperienceTables[gBaseStats[species].growthRate][level];
xpb = gExperienceTables[gBaseStats[species].growthRate][nextLevel];
Expand Down Expand Up @@ -230,4 +235,5 @@ static void rndPkmn(struct Pokemon* mon) {
CalculateMonStats(mon);
mon->hp = mon->maxHP * hpr + 0.5f;
if (mon->hp == 0 && prevHp > 0) mon->hp = 1;
mon->status = status;
}

0 comments on commit a613d72

Please sign in to comment.