mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2025-01-15 16:12:12 +01:00
replaced bitfield with LUT
This commit is contained in:
parent
d385b838c8
commit
9c73cb322e
@ -1354,17 +1354,12 @@ const struct Item gItems[] =
|
||||
|
||||
// Candy
|
||||
|
||||
#define ONE_HUNDRED 1 << 4
|
||||
#define ONE_THOUSAND 1 << 5
|
||||
#define TEN_THOUSAND 1 << 6
|
||||
#define FULL_LEVEL 1 << 7
|
||||
|
||||
[ITEM_RARE_CANDY] =
|
||||
{
|
||||
.name = _("Rare Candy"),
|
||||
.itemId = ITEM_RARE_CANDY,
|
||||
.price = 10000,
|
||||
.holdEffectParam = FULL_LEVEL,
|
||||
.holdEffectParam = 0xFF,
|
||||
.description = sRareCandyDesc,
|
||||
.pocket = POCKET_ITEMS,
|
||||
.type = ITEM_USE_PARTY_MENU,
|
||||
@ -1377,7 +1372,7 @@ const struct Item gItems[] =
|
||||
.name = _("Exp.Candy XS"),
|
||||
.itemId = ITEM_EXP_CANDY_XS,
|
||||
.price = 20,
|
||||
.holdEffectParam = 1 | ONE_HUNDRED,
|
||||
.holdEffectParam = 0,
|
||||
.description = sExpCandyXSDesc,
|
||||
.pocket = POCKET_ITEMS,
|
||||
.type = ITEM_USE_PARTY_MENU,
|
||||
@ -1390,7 +1385,7 @@ const struct Item gItems[] =
|
||||
.name = _("Exp.Candy S"),
|
||||
.itemId = ITEM_EXP_CANDY_S,
|
||||
.price = 240,
|
||||
.holdEffectParam = 8 | ONE_HUNDRED,
|
||||
.holdEffectParam = 1,
|
||||
.description = sExpCandyXSDesc,
|
||||
.pocket = POCKET_ITEMS,
|
||||
.type = ITEM_USE_PARTY_MENU,
|
||||
@ -1403,7 +1398,7 @@ const struct Item gItems[] =
|
||||
.name = _("Exp.Candy M"),
|
||||
.itemId = ITEM_EXP_CANDY_M,
|
||||
.price = 1000,
|
||||
.holdEffectParam = 3 | ONE_THOUSAND,
|
||||
.holdEffectParam = 2,
|
||||
.description = sExpCandyMDesc,
|
||||
.pocket = POCKET_ITEMS,
|
||||
.type = ITEM_USE_PARTY_MENU,
|
||||
@ -1416,7 +1411,7 @@ const struct Item gItems[] =
|
||||
.name = _("Exp.Candy L"),
|
||||
.itemId = ITEM_EXP_CANDY_L,
|
||||
.price = 3000,
|
||||
.holdEffectParam = 1 | TEN_THOUSAND,
|
||||
.holdEffectParam = 3,
|
||||
.description = sExpCandyLDesc,
|
||||
.pocket = POCKET_ITEMS,
|
||||
.type = ITEM_USE_PARTY_MENU,
|
||||
@ -1429,7 +1424,7 @@ const struct Item gItems[] =
|
||||
.name = _("Exp.Candy XL"),
|
||||
.itemId = ITEM_EXP_CANDY_XL,
|
||||
.price = 10000,
|
||||
.holdEffectParam = 3 | TEN_THOUSAND,
|
||||
.holdEffectParam = 4,
|
||||
.description = sExpCandyXLDesc,
|
||||
.pocket = POCKET_ITEMS,
|
||||
.type = ITEM_USE_PARTY_MENU,
|
||||
@ -1449,11 +1444,6 @@ const struct Item gItems[] =
|
||||
.flingPower = 30,
|
||||
},
|
||||
|
||||
#undef ONE_HUNDRED
|
||||
#undef ONE_THOUSAND
|
||||
#undef TEN_THOUSAND
|
||||
#undef FULL_LEVEL
|
||||
|
||||
// Medicinal Flutes
|
||||
|
||||
[ITEM_BLUE_FLUTE] =
|
||||
|
@ -4708,10 +4708,9 @@ bool8 ExecuteTableBasedItemEffect(struct Pokemon *mon, u16 item, u8 partyIndex,
|
||||
} \
|
||||
}
|
||||
|
||||
#define ONE_HUNDRED 1 << 4
|
||||
#define ONE_THOUSAND 1 << 5
|
||||
#define TEN_THOUSAND 1 << 6
|
||||
#define FULL_LEVEL 1 << 7
|
||||
// EXP candies store an index for this table in their holdEffectParam.
|
||||
#define NUM_EXP_CANDY_SIZES 5
|
||||
static const u32 sExpCandyExperienceTable[] = {100, 800, 3000, 10000, 30000};
|
||||
|
||||
// Returns TRUE if the item has no effect on the Pokémon, FALSE otherwise
|
||||
bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 moveIndex, bool8 usedByAI)
|
||||
@ -4878,24 +4877,18 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov
|
||||
retVal = FALSE;
|
||||
}
|
||||
|
||||
// Rare Candy
|
||||
// Rare Candy / EXP Candy
|
||||
if ((itemEffect[i] & ITEM3_LEVEL_UP)
|
||||
&& GetMonData(mon, MON_DATA_LEVEL, NULL) != MAX_LEVEL)
|
||||
{
|
||||
if (ItemId_GetHoldEffectParam(item) & FULL_LEVEL)
|
||||
u8 param = ItemId_GetHoldEffectParam(item);
|
||||
if (param == 0xFF) // Rare Candy
|
||||
{
|
||||
dataUnsigned = gExperienceTables[gBaseStats[GetMonData(mon, MON_DATA_SPECIES, NULL)].growthRate][GetMonData(mon, MON_DATA_LEVEL, NULL) + 1];
|
||||
}
|
||||
else
|
||||
else if (param < NUM_EXP_CANDY_SIZES) // EXP Candies
|
||||
{
|
||||
temp1 = ItemId_GetHoldEffectParam(item) & 0x0F;
|
||||
if (ItemId_GetHoldEffectParam(item) & ONE_HUNDRED)
|
||||
temp1 *= 100;
|
||||
if (ItemId_GetHoldEffectParam(item) & ONE_THOUSAND)
|
||||
temp1 *= 1000;
|
||||
if (ItemId_GetHoldEffectParam(item) & TEN_THOUSAND)
|
||||
temp1 *= 10000;
|
||||
dataUnsigned = temp1 + GetMonData(mon, MON_DATA_EXP, NULL);
|
||||
dataUnsigned = sExpCandyExperienceTable[param] + GetMonData(mon, MON_DATA_EXP, NULL);
|
||||
if (dataUnsigned > gExperienceTables[gBaseStats[GetMonData(mon, MON_DATA_SPECIES, NULL)].growthRate][MAX_LEVEL])
|
||||
dataUnsigned = gExperienceTables[gBaseStats[GetMonData(mon, MON_DATA_SPECIES, NULL)].growthRate][MAX_LEVEL];
|
||||
}
|
||||
@ -5298,11 +5291,6 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov
|
||||
return retVal;
|
||||
}
|
||||
|
||||
#undef ONE_HUNDRED
|
||||
#undef ONE_THOUSAND
|
||||
#undef TEN_THOUSAND
|
||||
#undef FULL_LEVEL
|
||||
|
||||
bool8 HealStatusConditions(struct Pokemon *mon, u32 battlePartyId, u32 healMask, u8 battlerId)
|
||||
{
|
||||
u32 status = GetMonData(mon, MON_DATA_STATUS, 0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user