changed candy item parameters

This commit is contained in:
AgustinGDLV 2022-08-25 15:52:47 -07:00
parent a5e742afcd
commit e204527f43
4 changed files with 25 additions and 11 deletions

View File

@ -973,6 +973,13 @@
#define MACH_BIKE 0
#define ACRO_BIKE 1
// Item parameters for EXP Candies
#define EXP_100 1
#define EXP_800 2
#define EXP_3000 3
#define EXP_10000 4
#define EXP_30000 5
// Item type IDs (used to determine the exit callback)
#define ITEM_USE_MAIL 0
#define ITEM_USE_PARTY_MENU 1

View File

@ -1359,7 +1359,7 @@ const struct Item gItems[] =
.name = _("Rare Candy"),
.itemId = ITEM_RARE_CANDY,
.price = 10000,
.holdEffectParam = 0xFF,
.holdEffectParam = 0,
.description = sRareCandyDesc,
.pocket = POCKET_ITEMS,
.type = ITEM_USE_PARTY_MENU,
@ -1372,7 +1372,7 @@ const struct Item gItems[] =
.name = _("Exp.Candy XS"),
.itemId = ITEM_EXP_CANDY_XS,
.price = 20,
.holdEffectParam = 0,
.holdEffectParam = EXP_100,
.description = sExpCandyXSDesc,
.pocket = POCKET_ITEMS,
.type = ITEM_USE_PARTY_MENU,
@ -1385,7 +1385,7 @@ const struct Item gItems[] =
.name = _("Exp.Candy S"),
.itemId = ITEM_EXP_CANDY_S,
.price = 240,
.holdEffectParam = 1,
.holdEffectParam = EXP_800,
.description = sExpCandyXSDesc,
.pocket = POCKET_ITEMS,
.type = ITEM_USE_PARTY_MENU,
@ -1398,7 +1398,7 @@ const struct Item gItems[] =
.name = _("Exp.Candy M"),
.itemId = ITEM_EXP_CANDY_M,
.price = 1000,
.holdEffectParam = 2,
.holdEffectParam = EXP_3000,
.description = sExpCandyMDesc,
.pocket = POCKET_ITEMS,
.type = ITEM_USE_PARTY_MENU,
@ -1411,7 +1411,7 @@ const struct Item gItems[] =
.name = _("Exp.Candy L"),
.itemId = ITEM_EXP_CANDY_L,
.price = 3000,
.holdEffectParam = 3,
.holdEffectParam = EXP_10000,
.description = sExpCandyLDesc,
.pocket = POCKET_ITEMS,
.type = ITEM_USE_PARTY_MENU,
@ -1424,7 +1424,7 @@ const struct Item gItems[] =
.name = _("Exp.Candy XL"),
.itemId = ITEM_EXP_CANDY_XL,
.price = 10000,
.holdEffectParam = 4,
.holdEffectParam = EXP_30000,
.description = sExpCandyXLDesc,
.pocket = POCKET_ITEMS,
.type = ITEM_USE_PARTY_MENU,

View File

@ -5012,7 +5012,7 @@ void ItemUseCB_RareCandy(u8 taskId, TaskFunc task)
if (sFinalLevel > sInitialLevel)
{
PlayFanfareByFanfareNum(FANFARE_LEVEL_UP);
ConvertIntToDecimalStringN(gStringVar2, GetMonData(mon, MON_DATA_LEVEL), STR_CONV_MODE_LEFT_ALIGN, 3);
ConvertIntToDecimalStringN(gStringVar2, sFinalLevel, STR_CONV_MODE_LEFT_ALIGN, 3);
StringExpandPlaceholders(gStringVar4, gText_PkmnElevatedToLvVar2);
DisplayPartyMenuMessage(gStringVar4, TRUE);
ScheduleBgCopyTilemapToVram(2);

View File

@ -4709,7 +4709,13 @@ bool8 ExecuteTableBasedItemEffect(struct Pokemon *mon, u16 item, u8 partyIndex,
}
// EXP candies store an index for this table in their holdEffectParam.
static const u32 sExpCandyExperienceTable[] = {100, 800, 3000, 10000, 30000};
static const u32 sExpCandyExperienceTable[] = {
[EXP_100 - 1] = 100,
[EXP_800 - 1] = 800,
[EXP_3000 - 1] = 3000,
[EXP_10000 - 1] = 10000,
[EXP_30000 - 1] = 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)
@ -4881,15 +4887,16 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov
&& GetMonData(mon, MON_DATA_LEVEL, NULL) != MAX_LEVEL)
{
u8 param = ItemId_GetHoldEffectParam(item);
if (param == 0xFF) // Rare Candy
if (param == 0) // Rare Candy
{
dataUnsigned = gExperienceTables[gBaseStats[GetMonData(mon, MON_DATA_SPECIES, NULL)].growthRate][GetMonData(mon, MON_DATA_LEVEL, NULL) + 1];
}
else if (param < ARRAY_COUNT(sExpCandyExperienceTable)) // EXP Candies
{
u16 species = GetMonData(mon, MON_DATA_SPECIES, 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];
if (dataUnsigned > gExperienceTables[gBaseStats[species].growthRate][MAX_LEVEL])
dataUnsigned = gExperienceTables[gBaseStats[species].growthRate][MAX_LEVEL];
}
SetMonData(mon, MON_DATA_EXP, &dataUnsigned);
CalculateMonStats(mon);