Shiny charm (#276)

* Shiny Charm Item

* Shiny Charm Rerolls
This commit is contained in:
Eduardo Alvaro Quezada D'Ottone 2020-02-17 07:08:06 -03:00 committed by GitHub
parent bf6aa6a176
commit 2c172a3636
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 60 additions and 4 deletions

View File

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 356 B

View File

@ -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

View File

@ -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

View File

@ -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[];

View File

@ -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");

View File

@ -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},

View File

@ -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,
},
};

View File

@ -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.");

View File

@ -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);