-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Shuckle makes Berry Juice
Eduardo Quezada D'Ottone edited this page Oct 31, 2020
·
1 revision
In Gold, Silver and Crystal only, Shuckle could randomly make Berry Juice by holding a berry after winning a battle. Let's implement it back!
In src_battle_script_commands.c
, search for the function Cmd_pickup
and below both instances of if (ability == ABILITY_PICKUP
, add the following block:
static void Cmd_pickup(void)
{
s32 i;
u16 species, heldItem;
u8 ability;
if (InBattlePike())
{
}
else if (InBattlePyramid())
{
for (i = 0; i < PARTY_SIZE; i++)
{
species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2);
heldItem = GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM);
if (GetMonData(&gPlayerParty[i], MON_DATA_ABILITY_NUM))
ability = gBaseStats[species].abilities[1];
else
ability = gBaseStats[species].abilities[0];
if (ability == ABILITY_PICKUP
&& species != 0
&& species != SPECIES_EGG
&& heldItem == ITEM_NONE
&& (Random() % 10) == 0)
{
heldItem = GetBattlePyramidPickupItemId();
SetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM, &heldItem);
}
+ else if (species == SPECIES_SHUCKLE
+ && heldItem >= FIRST_BERRY_INDEX
+ && heldItem <= LAST_BERRY_INDEX)
+ {
+ if (!(Random() % 16))
+ {
+ heldItem = ITEM_BERRY_JUICE;
+ SetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM, &heldItem);
+ }
+ }
}
}
else
{
for (i = 0; i < PARTY_SIZE; i++)
{
species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2);
heldItem = GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM);
if (GetMonData(&gPlayerParty[i], MON_DATA_ABILITY_NUM))
ability = gBaseStats[species].abilities[1];
else
ability = gBaseStats[species].abilities[0];
if (ability == ABILITY_PICKUP
&& species != 0
&& species != SPECIES_EGG
&& heldItem == ITEM_NONE
&& (Random() % 10) == 0)
{
s32 j;
s32 rand = Random() % 100;
u8 lvlDivBy10 = (GetMonData(&gPlayerParty[i], MON_DATA_LEVEL) - 1) / 10;
if (lvlDivBy10 > 9)
lvlDivBy10 = 9;
for (j = 0; j < (int)ARRAY_COUNT(sPickupProbabilities); j++)
{
if (sPickupProbabilities[j] > rand)
{
SetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM, &sPickupItems[lvlDivBy10 + j]);
break;
}
else if (rand == 99 || rand == 98)
{
SetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM, &sRarePickupItems[lvlDivBy10 + (99 - rand)]);
break;
}
}
}
+ else if (species == SPECIES_SHUCKLE
+ && heldItem >= FIRST_BERRY_INDEX
+ && heldItem <= LAST_BERRY_INDEX)
+ {
+ if (!(Random() % 16))
+ {
+ heldItem = ITEM_BERRY_JUICE;
+ SetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM, &heldItem);
+ }
+ }
}
}
gBattlescriptCurrInstr++;
}
And that's it!
~AsparagusEduardo