• 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.
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • Serena, Kris, Dawn, Red - which Pokémon protagonist is your favorite? Let us know by voting in our grand final favorite protagonist poll!
  • 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✓] Check to see if the player possesses a Pokémon of certain type in the team

  • 182
    Posts
    7
    Years
    • Seen Jan 22, 2025
    I've been trying to do this, at first, I grabbed the code from the Hidden Moves that check if you have the required move, "ScrCmd_checkpartymove", but i can't seem to get it to work. It just returns the first pokémon of the team without any comparation.

    This is the code i used:


    Code:
    bool8 ScrCmd_checkpartytype(struct ScriptContext *ctx)
    {
        u8 i;
        u16 type = ScriptReadHalfword(ctx);
    
        gSpecialVar_Result = PARTY_SIZE;
        for (i = 0; i < PARTY_SIZE; i++)
        {
            u16 species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES, NULL);
            if (!species)
                break;
            if (!GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG) && MonIsType(&gPlayerParty[i], type) == TRUE)
            {
                gSpecialVar_Result = i;
                gSpecialVar_0x8004 = species;
                break;
            }
        }
        return FALSE;
    }
    and

    Code:
    bool8 MonIsType(struct Pokemon *mon, u16 type)
    {
        u8 i;
    	u16 species = GetMonData(mon, MON_DATA_SPECIES);
        if (IS_BATTLER_OF_TYPE(species, type))
                return TRUE;
        return FALSE;
    }
     
    Last edited:

    IS_BATTLER_OF_TYPE takes in the battlerId of the Pokémon as the first parameter, not the species. gBaseStats[species].type1 and gBaseStats[species].type2 will give you each of the types of the given Pokémon species. The if-statement in MonIsType should look more like this:
    Code:
    if (gBaseStats[species].type1 == type || gBaseStats[species].type2 == type)
    You could also have MonIsType take in the species of the Pokémon as the first parameter rather than the entire Pokémon, since you've already found the species earlier on in ScrCmd_checkpartytype.
     
    IS_BATTLER_OF_TYPE takes in the battlerId of the Pokémon as the first parameter, not the species. gBaseStats[species].type1 and gBaseStats[species].type2 will give you each of the types of the given Pokémon species. The if-statement in MonIsType should look more like this:
    Code:
    if (gBaseStats[species].type1 == type || gBaseStats[species].type2 == type)
    You could also have MonIsType take in the species of the Pokémon as the first parameter rather than the entire Pokémon, since you've already found the species earlier on in ScrCmd_checkpartytype.
    Thank you so much!
    I'll try!
    EDIT: IT WORKED PERFECTLY! THANK YOU SO SO MUCH!!
     
    Last edited:
    Back
    Top