• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • 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

180
Posts
6
Years
    • Seen Apr 15, 2024
    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:
    247
    Posts
    6
    Years
    • Seen May 12, 2024

    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.
     
    180
    Posts
    6
    Years
    • Seen Apr 15, 2024
    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