• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Our weekly protagonist poll is now up! Vote for your favorite Trading Card Game 2 protagonist in the poll by clicking here.
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Script] [Pokeemerald] Making "Held Item" Evos into "Use" Evos (very minor issue)

  • 17
    Posts
    3
    Years
    • Seen Dec 14, 2022
    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:
    Spoiler:


    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:
    Spoiler:


    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:
    Code:
    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.
     
    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.
    https://github.com/LOuroboros/pokeemerald/commit/d9e0bb5b2e7c1ee63db94cf1b897073720d100a2
    Note: I think it can be guessed, but the max value for the ITEM_HAS_EFFECT macro is the last valid item that gItemEffectTable 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.
     

    Lunos had it right on his post. Currently, when trying to use the Upgrade on Porygon, your issue is occurring here in src/pokemon.c, specifically in the function "PokemonUseItemEffects":
    Code:
    // Skip using the item if it won't do anything
        if (!ITEM_HAS_EFFECT(item))
            return TRUE;
    ITEM_HAS_EFFECT is defined in include/constants/items.h, 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 ITEM_HAS_EFFECT to be this:
    Code:
    #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.
     
    Back
    Top