diff --git a/graphics/items/icon_palettes/shiny_charm.pal b/graphics/items/icon_palettes/shiny_charm.pal new file mode 100644 index 0000000000..ab6e64a6e8 --- /dev/null +++ b/graphics/items/icon_palettes/shiny_charm.pal @@ -0,0 +1,19 @@ +JASC-PAL +0100 +16 +245 218 38 +82 123 230 +90 156 246 +156 255 106 +41 115 148 +156 246 246 +57 205 246 +132 214 255 +189 189 239 +222 222 255 +90 90 90 +32 32 32 +206 173 247 +140 140 247 +173 107 255 +230 206 255 diff --git a/graphics/items/icons/shiny_charm.png b/graphics/items/icons/shiny_charm.png new file mode 100644 index 0000000000..3829154cd5 Binary files /dev/null and b/graphics/items/icons/shiny_charm.png differ diff --git a/include/constants/items.h b/include/constants/items.h index 32c36a357c..262219a593 100644 --- a/include/constants/items.h +++ b/include/constants/items.h @@ -700,7 +700,9 @@ #define ITEM_MAGMA_EMBLEM 614 #define ITEM_OLD_SEA_MAP 615 -#define ITEMS_COUNT 616 +#define ITEM_SHINY_CHARM 616 + +#define ITEMS_COUNT 617 #define ITEM_FIELD_ARROW ITEMS_COUNT #define FIRST_BERRY_INDEX ITEM_CHERI_BERRY diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index 6c82404a13..9179658b0b 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -86,6 +86,7 @@ // Shiny odds #define SHINY_ODDS 8 // Actual probability is SHINY_ODDS/65536 +#define SHINY_CHARM_REROLLS 3 // Amount of re-rolls if has Shiny Charm. // Flags for Get(Box)MonData / Set(Box)MonData #define MON_DATA_PERSONALITY 0 diff --git a/include/graphics.h b/include/graphics.h index 3e25aa210c..9e4e124865 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -4056,6 +4056,8 @@ extern const u32 gItemIcon_NormalGem[]; extern const u32 gItemIconPalette_NormalGem[]; extern const u32 gItemIcon_FairyGem[]; extern const u32 gItemIconPalette_FairyGem[]; +extern const u32 gItemIcon_ShinyCharm[]; +extern const u32 gItemIconPalette_ShinyCharm[]; // Gen 6 Items extern const u32 gItemIcon_AssaultVest[]; extern const u32 gItemIconPalette_AssaultVest[]; diff --git a/src/data/graphics/items.h b/src/data/graphics/items.h index 701e23e4a5..8e6fe9012f 100644 --- a/src/data/graphics/items.h +++ b/src/data/graphics/items.h @@ -1002,6 +1002,9 @@ const u32 gItemIconPalette_NormalGem[] = INCBIN_U32("graphics/items/icon_palette const u32 gItemIcon_FairyGem[] = INCBIN_U32("graphics/items/icons/fairy_gem.4bpp.lz"); const u32 gItemIconPalette_FairyGem[] = INCBIN_U32("graphics/items/icon_palettes/fairy_gem.gbapal.lz"); +const u32 gItemIcon_ShinyCharm[] = INCBIN_U32("graphics/items/icons/shiny_charm.4bpp.lz"); +const u32 gItemIconPalette_ShinyCharm[] = INCBIN_U32("graphics/items/icon_palettes/shiny_charm.gbapal.lz"); + // Gen 6 Items const u32 gItemIcon_AssaultVest[] = INCBIN_U32("graphics/items/icons/assault_vest.4bpp.lz"); diff --git a/src/data/item_icon_table.h b/src/data/item_icon_table.h index a5d3afd331..a53afe88d5 100644 --- a/src/data/item_icon_table.h +++ b/src/data/item_icon_table.h @@ -417,6 +417,7 @@ const u32 *const gItemIconTable[][2] = [ITEM_STEEL_GEM] = {gItemIcon_SteelGem, gItemIconPalette_SteelGem}, [ITEM_NORMAL_GEM] = {gItemIcon_NormalGem, gItemIconPalette_NormalGem}, [ITEM_FAIRY_GEM] = {gItemIcon_FairyGem, gItemIconPalette_FairyGem}, + [ITEM_SHINY_CHARM] = {gItemIcon_ShinyCharm, gItemIconPalette_ShinyCharm}, // Gen 6 Items [ITEM_ASSAULT_VEST] = {gItemIcon_AssaultVest, gItemIconPalette_AssaultVest}, [ITEM_PIXIE_PLATE] = {gItemIcon_PixiePlate, gItemIconPalette_PixiePlate}, diff --git a/src/data/items.h b/src/data/items.h index c359d1c960..9940f2ee3b 100644 --- a/src/data/items.h +++ b/src/data/items.h @@ -7448,5 +7448,17 @@ const struct Item gItems[] = .type = 4, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, .secondaryId = 0, - } + }, + + [ITEM_SHINY_CHARM] = + { + .name = _("Shiny Charm"), + .itemId = ITEM_SHINY_CHARM, + .price = 0, + .description = sShinyCharmDesc, + .pocket = POCKET_KEY_ITEMS, + .type = 4, + .fieldUseFunc = ItemUseOutOfBattle_CannotUse, + .secondaryId = 0, + }, }; diff --git a/src/data/text/item_descriptions.h b/src/data/text/item_descriptions.h index 9c722e4dca..d159eab23d 100644 --- a/src/data/text/item_descriptions.h +++ b/src/data/text/item_descriptions.h @@ -2788,3 +2788,8 @@ static const u8 sPrettyWingDesc[] = _( "A beautiful yet\n" "plain feather that\n" "does nothing."); + +static const u8 sShinyCharmDesc[] = _( + "A charm that will\n" + "raise the chance\n" + "of Shiny Pokémon."); diff --git a/src/pokemon.c b/src/pokemon.c index 2504d1a3c1..94634cacde 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -2175,8 +2175,6 @@ void CreateBoxMon(struct BoxPokemon *boxMon, u16 species, u8 level, u8 fixedIV, else personality = Random32(); - SetBoxMonData(boxMon, MON_DATA_PERSONALITY, &personality); - //Determine original trainer ID if (otIdType == OT_ID_RANDOM_NO_SHINY) //Pokemon cannot be shiny { @@ -2197,8 +2195,21 @@ void CreateBoxMon(struct BoxPokemon *boxMon, u16 species, u8 level, u8 fixedIV, | (gSaveBlock2Ptr->playerTrainerId[1] << 8) | (gSaveBlock2Ptr->playerTrainerId[2] << 16) | (gSaveBlock2Ptr->playerTrainerId[3] << 24); + + if (CheckBagHasItem(ITEM_SHINY_CHARM, 1)) + { + u32 shinyValue; + u32 rolls = 0; + do + { + personality = Random32(); + shinyValue = HIHALF(value) ^ LOHALF(value) ^ HIHALF(personality) ^ LOHALF(personality); + rolls++; + } while (shinyValue >= SHINY_ODDS && rolls < SHINY_CHARM_REROLLS); + } } + SetBoxMonData(boxMon, MON_DATA_PERSONALITY, &personality); SetBoxMonData(boxMon, MON_DATA_OT_ID, &value); checksum = CalculateBoxMonChecksum(boxMon);