From 75f165ed746cbc33cf9d0b9181abd9e861264f56 Mon Sep 17 00:00:00 2001 From: Gudf <28691694+Gudf@users.noreply.github.com> Date: Thu, 11 Jul 2019 20:16:39 +0200 Subject: [PATCH] Use a constant instead of integer literals when checking for shinyness --- include/constants/pokemon.h | 3 +++ src/battle_anim_special.c | 2 +- src/pokemon.c | 8 ++++---- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index f63d755ad..5d0e562bc 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -82,4 +82,7 @@ #define NUM_STATS 6 #define NUM_BATTLE_STATS 8 +// Shiny odds +#define SHINY_ODDS 8 // Actual probability is SHINY_ODDS/65536 + #endif // GUARD_CONSTANTS_POKEMON_H diff --git a/src/battle_anim_special.c b/src/battle_anim_special.c index 740340d14..6780f0a32 100755 --- a/src/battle_anim_special.c +++ b/src/battle_anim_special.c @@ -2029,7 +2029,7 @@ void sub_8172EF0(u8 battler, struct Pokemon *mon) if (IsBattlerSpriteVisible(battler)) { shinyValue = HIHALF(otId) ^ LOHALF(otId) ^ HIHALF(personality) ^ LOHALF(personality); - if (shinyValue < 8) + if (shinyValue < SHINY_ODDS) isShiny = TRUE; if (isShiny) diff --git a/src/pokemon.c b/src/pokemon.c index c54e8ad2c..6ad47d346 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -2183,7 +2183,7 @@ void CreateBoxMon(struct BoxPokemon *boxMon, u16 species, u8 level, u8 fixedIV, { value = Random32(); shinyValue = HIHALF(value) ^ LOHALF(value) ^ HIHALF(personality) ^ LOHALF(personality); - } while (shinyValue < 8); + } while (shinyValue < SHINY_ODDS); } else if (otIdType == OT_ID_PRESET) //Pokemon has a preset OT ID { @@ -6332,7 +6332,7 @@ const u32 *GetFrontSpritePalFromSpeciesAndPersonality(u16 species, u32 otId, u32 return gMonPaletteTable[0].data; shinyValue = HIHALF(otId) ^ LOHALF(otId) ^ HIHALF(personality) ^ LOHALF(personality); - if (shinyValue < 8) + if (shinyValue < SHINY_ODDS) return gMonShinyPaletteTable[species].data; else return gMonPaletteTable[species].data; @@ -6351,7 +6351,7 @@ const struct CompressedSpritePalette *GetMonSpritePalStructFromOtIdPersonality(u u32 shinyValue; shinyValue = HIHALF(otId) ^ LOHALF(otId) ^ HIHALF(personality) ^ LOHALF(personality); - if (shinyValue < 8) + if (shinyValue < SHINY_ODDS) return &gMonShinyPaletteTable[species]; else return &gMonPaletteTable[species]; @@ -6525,7 +6525,7 @@ bool8 IsShinyOtIdPersonality(u32 otId, u32 personality) { bool8 retVal = FALSE; u32 shinyValue = HIHALF(otId) ^ LOHALF(otId) ^ HIHALF(personality) ^ LOHALF(personality); - if (shinyValue < 8) + if (shinyValue < SHINY_ODDS) retVal = TRUE; return retVal; }