• 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-NPC] Check if ONLY a certain type is in player's team

Elfyer

Veteran
15
Posts
37
Days
    • Seen Apr 20, 2024
    Hi everyone!
    After getting great advice from @giradialkia (thanks man :coolrim: ), I decided to ask if this thing is possible in decomps pokeemerald.
    So: is there a script that can make a npc check if a certain type or pokémon is in the player's team?
    I'd like to make a fangame with a very specific feature: to become the very best (TM) you need to master your ability with every type of Pokémon, so you can fight gym leaders of a type only with Pokémons of that type. Let's suppose you wanna fight Brock/Takeshi: you need to have only rock type on your team (or, of course, Pokémon that are 2-types, one being rock).
    Is there anything that can do something useful for this purpose?
    As @giradialkia suggested, the only way on Binary was checking for specific pokémons, but in decomps is it possible to check for types in the team?
    Thanks y'all
     
    448
    Posts
    6
    Years
    • Seen May 6, 2024
    Hi everyone!
    After getting great advice from @giradialkia (thanks man :coolrim: ), I decided to ask if this thing is possible in decomps pokeemerald.
    So: is there a script that can make a npc check if a certain type or pokémon is in the player's team?
    I'd like to make a fangame with a very specific feature: to become the very best (TM) you need to master your ability with every type of Pokémon, so you can fight gym leaders of a type only with Pokémons of that type. Let's suppose you wanna fight Brock/Takeshi: you need to have only rock type on your team (or, of course, Pokémon that are 2-types, one being rock).
    Is there anything that can do something useful for this purpose?
    As @giradialkia suggested, the only way on Binary was checking for specific pokémons, but in decomps is it possible to check for types in the team?
    Thanks y'all
    Yes, it's possible to do that. The decomp makes it fairly easy to create new scripting commands with custom functionality. This wiki page has some examples on how you can create new specials and use them in scripts.

    To check if the player only has pokemon of a specific type, you could do something like:
    Code:
    bool8 CheckPartyHasOnlyMonsOfType(void)
    {
        u32 i;
        u32 type = VarGet(VAR_0x8000);
        for (i = 0; i < CalculatePlayerPartyCount(); i++)
        {
            u32 species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG);
            if(species != SPECIES_EGG
                && gSpeciesInfo[species].types[0] != type
                && gSpeciesInfo[species].types[1] != type)
                return FALSE;
        }
        return TRUE;
    }
     

    Elfyer

    Veteran
    15
    Posts
    37
    Days
    • Seen Apr 20, 2024
    Yes, it's possible to do that. The decomp makes it fairly easy to create new scripting commands with custom functionality. This wiki page has some examples on how you can create new specials and use them in scripts.

    To check if the player only has pokemon of a specific type, you could do something like:
    Code:
    bool8 CheckPartyHasOnlyMonsOfType(void)
    {
        u32 i;
        u32 type = VarGet(VAR_0x8000);
        for (i = 0; i < CalculatePlayerPartyCount(); i++)
        {
            u32 species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG);
            if(species != SPECIES_EGG
                && gSpeciesInfo[species].types[0] != type
                && gSpeciesInfo[species].types[1] != type)
                return FALSE;
        }
        return TRUE;
    }
    Thank you so much for being so quick and helpful
    So, being the noob I am: I need to associate through PoryMap a new script with a npc I placed (let's say the helper at the entrance of the gym), insert this script and add some text with the command .string "INSTERTTEXTHERE.$". But what type is the code you wrote check? And is the VAR always the same?
     
    448
    Posts
    6
    Years
    • Seen May 6, 2024
    Thank you so much for being so quick and helpful
    So, being the noob I am: I need to associate through PoryMap a new script with a npc I placed (let's say the helper at the entrance of the gym), insert this script and add some text with the command .string "INSTERTTEXTHERE.$". But what type is the code you wrote check? And is the VAR always the same?
    To clarify, the code I posted is C code and not a script. You need to put it in a C source file and add it to the special table to be able to use it in a script.
    The code checks for whichever type is stored in VAR_0x8000. For example if you wanted to check for rock types in your script, you would do:
    Code:
    setvar VAR_0x8000, TYPE_ROCK
    specialvar VAR_RESULT, CheckPartyHasOnlyMonsOfType
    and then check the value of VAR_RESULT to see the results.
     

    Elfyer

    Veteran
    15
    Posts
    37
    Days
    • Seen Apr 20, 2024
    Thank you so much, I think I got it. I'll do my best to not make a disaster :)
    Have a great day :plead:
     

    Elfyer

    Veteran
    15
    Posts
    37
    Days
    • Seen Apr 20, 2024
    Hi
    To clarify, the code I posted is C code and not a script. You need to put it in a C source file and add it to the special table to be able to use it in a script.
    The code checks for whichever type is stored in VAR_0x8000. For example if you wanted to check for rock types in your script, you would do:
    Code:
    setvar VAR_0x8000, TYPE_ROCK
    specialvar VAR_RESULT, CheckPartyHasOnlyMonsOfType
    and then check the value of VAR_RESULT to see the results.
    Hi, sorry to bother you again, but I can't make it work.:sadwick: I really hope you or some other user can help me; this script might be useful to others, I think! :plead:

    I'm trying a basic script at the beginning of the game just to test it out. In this case, I want an NPC to check if I have only fire type (as first or secondary type) in my team (e.g. Torchic, the only Fire Pokémon I can get in the first minutes), but any secondary type is okay, so that a FIRE-ROCK like Slugma is ok, but a GROUND-ROCK like Geodude is not.
    A) If I have only FIRE or FIRE-OTHERTYPE (or OTHERTYPE-FIRE) the NPC move away (just a step on the right) and says "Good, you only have Fire type! Enjoy the Gym!"
    B) If have one or more Pokémon without the FIRE type (as first or secondary type) the NPC doesn't move and says "You have Pokémon that are not FYRE type, so I can't make you pass"

    Sooo (I use Visual Code for Windows 10):
    1) I've put the "def_special CheckPartyHasOnlyMonsOfType" in data > specials.inc

    2) to define it, I've put your code (the one in the spoiler here) in src > field_specials.c. Is this right?
    Spoiler:


    3) After done all of this, I create the following script and associated with the NPC (yes, it can move to the right).
    Spoiler:

    What am I doing wrong?:sadwick: I didn't put a flag, as I want it to be able to check the team and, in case, move every time is needed.
     
    448
    Posts
    6
    Years
    • Seen May 6, 2024
    Hi

    Hi, sorry to bother you again, but I can't make it work.:sadwick: I really hope you or some other user can help me; this script might be useful to others, I think! :plead:

    I'm trying a basic script at the beginning of the game just to test it out. In this case, I want an NPC to check if I have only fire type (as first or secondary type) in my team (e.g. Torchic, the only Fire Pokémon I can get in the first minutes), but any secondary type is okay, so that a FIRE-ROCK like Slugma is ok, but a GROUND-ROCK like Geodude is not.
    A) If I have only FIRE or FIRE-OTHERTYPE (or OTHERTYPE-FIRE) the NPC move away (just a step on the right) and says "Good, you only have Fire type! Enjoy the Gym!"
    B) If have one or more Pokémon without the FIRE type (as first or secondary type) the NPC doesn't move and says "You have Pokémon that are not FYRE type, so I can't make you pass"

    Sooo (I use Visual Code for Windows 10):
    1) I've put the "def_special CheckPartyHasOnlyMonsOfType" in data > specials.inc

    2) to define it, I've put your code (the one in the spoiler here) in src > field_specials.c. Is this right?
    Spoiler:


    3) After done all of this, I create the following script and associated with the NPC (yes, it can move to the right).
    Spoiler:

    What am I doing wrong?:sadwick: I didn't put a flag, as I want it to be able to check the team and, in case, move every time is needed.
    The first two steps seem right but what's going on in that script? It looks like you've tried to write it for poryscript, but you've also just copy-pasted the snippet from my last message (which is not using poryscript). There are also other mistakes like the if-else statement's conditions being incorrect, the applymovement parameter and missing a '}' from the script statement. As a result the script doesn't even compile on poryscript playground.

    Based on that I'm guessing that your project isn't compiling, in which case it would've been good to state that in your message and include the compilation error.

    Consider reading poryscript's README file for info on how poryscript's syntax works.
     
    Back
    Top