Seen 2 Days Ago
Posted 1 Week Ago
13 posts
28 Days
So I wanted to change the "held items and trade" evolutions to "use" evolutions like the evolution stones, but I'm running into an unexpected problem. Using the Up-grade as an example, I changed the Porygon line in src/data/pokemon to {{EVO_ITEM, ITEM_UP_GRADE, SPECIES_PORYGON2}}, as well as changing the Up-grade's code in src/data/items.h to .type = ITEM_USE_PARTY_MENU and .fieldUseFunc = ItemUseOutOfBattle_EvolutionStone. Additionally, in src/data/pokemon/item_effects.h I added the line [ITEM_UP_GRADE - ITEM_POTION] = gItemEffect_EvoStone.

However, this code produces the following problem:

As you can see, it is alllllllmost working, given that we get the HP display for the correct Pokemon like you see with evolution stones. But then we get the same message: It won't have any effect. I've tracked down the bit of code that does this last message, located in src/party_menu.c:

However, this is where I hit a brick wall. I have no idea why the above if statement evaluates to true for Porygon. The ExecuteTableBasedItemEffect_ function only exists in this file and nowhere else in the decomp, and has 3 arguments:
static bool8 ExecuteTableBasedItemEffect_(u8 partyMonIndex, u16 item, u8 monMoveIndex)
The first two don't really matter for our purposes (I think) but it's the last one that I am tearing my hair out about. monMoveIndex only exists in this file, and as such I have no idea what it is, what it does, how it decides when to be = 0 and when not to be, nor what that even means. I am totally stuck.


Random Uruguayan User

Montevideo (Uruguay)
Seen 1 Hour Ago
Posted 1 Hour Ago
2,807 posts
13 Years
So I wanted to change the "held items and trade" evolutions to "use" evolutions like the evolution stones
I don't know the exact changes you did, so here's a commit I cooked up in a moment.
You can use it to check whatever changes you may have missed.
Note: I think it can be guessed, but the max value for the
macro is the last valid item that
will take into account.
Naturally, if you intend to use items beyond the Metal Coat, you'll have to set said max value to a different item.
Seen 2 Hours Ago
Posted 3 Hours Ago
123 posts
4.2 Years
Lunos had it right on his post. Currently, when trying to use the Upgrade on Porygon, your issue is occurring here in
, specifically in the function "PokemonUseItemEffects":
// Skip using the item if it won't do anything
    if (!ITEM_HAS_EFFECT(item))
        return TRUE;
is defined in
, which rejects any items with an id higher than LAST_BERRY_INDEX, which is set to be equal to ITEM_MARANGA_BERRY higher up in the same file. Upgrade has a higher id, and thus, it is rejected. You can change the definition of
to be this:
#define ITEM_HAS_EFFECT(item) ((item) >= ITEM_POTION && (item) <= ITEM_UP_GRADE)
I don't know if this will have any other strange effects, but it should allow you to evolve Porygon with the Upgrade.