• 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!
  • Which Pokémon Masters protagonist do you like most? Let us know by casting a vote in our Masters favorite protagonist poll 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.

[Scripting Question] Delete specific pokemon from party

  • 36
    Posts
    9
    Years
    • Seen May 3, 2025
    Hello! Pls How to make it, if I want delete specific pokemon from my party? "For example some NPC Trainer wants Rattata, so I give him rattata if it's member of my party." I know about pbRemovePokemonAt(index) but I want remove specific pokemon. Thank you!!
     
    The answer is in the wiki. It should look like this. Just copy/paste from 0 to 5.

    @>Conditional Branch: Script: $Trainer.pokemonParty[0].species==PBSpecies::RATTATA
    @>pbRemovePokemonAt(0)
    : Else
    : Branch End
     
    The answer is in the wiki. It should look like this. Just copy/paste from 0 to 5.
    There is a more simple way.
    Raki07, you can put a script event command into your NPC with this code:
    Code:
    for i in 0...$Trainer.party.length
    if $Trainer.party[i].species==PBSpecies::RATTATA
    $Trainer.party[i]=nil
    $Trainer.party.compact
    break
    end
    end
     
    Give a conditional branch saying

    @>Conditional Branch: Script: $Trainer.pokemonParty[0].species==PBSpecies::RATTATA
    @>
    : Else
    : Branch End

    Then add a new script into the conditional branch the script is--

    @>pbRemovePokemonAt(0)

    The final result will be like this

    @>Conditional Branch: Script: $Trainer.pokemonParty[0].species==PBSpecies::RATTATA
    @>pbRemovePokemonAt(0)
    : Else
    : Branch End


    Give credit if you want to.
     
    Give a conditional branch saying

    @>Conditional Branch: Script: $Trainer.pokemonParty[0].species==PBSpecies::RATTATA
    @>
    : Else
    : Branch End

    Then add a new script into the conditional branch the script is--

    @>pbRemovePokemonAt(0)

    The final result will be like this

    @>Conditional Branch: Script: $Trainer.pokemonParty[0].species==PBSpecies::RATTATA
    @>pbRemovePokemonAt(0)
    : Else
    : Branch End


    Give credit if you want to.


    Working only if is Rattata on first place. Is it possible make script if rattata is at another place in party (it doesn matter what it is) ?
     
    Last edited:
    There is a more simple way.
    Raki07, you can put a script event command into your NPC with this code:
    Code:
    for i in 0...$Trainer.party.length
    if $Trainer.party[i].species==PBSpecies::RATTATA
    $Trainer.party[i]=nil
    $Trainer.party.compact
    break
    end
    end

    I don't know what is bad but:

    Exception: RuntimeError
    Message: Script error within event 5, map 55 (Viridian Forest House):
    Exception: NoMethodError
    Message: (eval):3:in `pbExecuteScript'undefined method `species' for [0]:Array
    ***Full script:
    for i in 0...$Trainer.party.length
    if $Trainer.party
    .species==PBSpecies::RATTATA
    $Trainer.party=nil
    $Trainer.party.compact
    break
    end
    end

    Interpreter:243:in `pbExecuteScript'
    (eval):1:in `each'
    (eval):1:in `pbExecuteScript'
    Interpreter:1600:in `eval'
    Interpreter:243:in `pbExecuteScript'
    Interpreter:1600:in `command_355'
    Interpreter:494:in `execute_command'
    Interpreter:193:in `update'
    Interpreter:106:in `loop'
    Interpreter:198:in `update'

    Interpreter:276:in `pbExecuteScript'
    Interpreter:1600:in `command_355'
    Interpreter:494:in `execute_command'
    Interpreter:193:in `update'
    Interpreter:106:in `loop'
    Interpreter:198:in `update'
    Scene_Map:103:in `update'
    Scene_Map:101:in `loop'
    Scene_Map:114:in `update'
    Scene_Map:68:in `main'
     
    Forgive me, but wouldn't it be simpler to hijack the trade scripts, so that the player chooses a pokemon, then that's checked to see if it's a Ratatta, and if it is, delete it?

    From the OP it sounds like a trade, sans actually receiving a pokemon.
     
    Forgive me, but wouldn't it be simpler to hijack the trade scripts, so that the player chooses a pokemon, then that's checked to see if it's a Ratatta, and if it is, delete it?

    From the OP it sounds like a trade, sans actually receiving a pokemon.

    Well, good idea! It can be like you say.

    Anyone know how to do it?
     
    Last edited by a moderator:
    Working only if is Rattata on first place. Is it possible make script if rattata is at another place in party (it doesn matter what it is) ?

    Just make a bunch of this conditional branch saying from (0) to (5) just keep changing the (0) until you reach 5
     
    Just make a bunch of this conditional branch saying from (0) to (5) just keep changing the (0) until you reach 5

    Well, this is possible when I have 6 pokemons in party.
    If I have only 5, conditional branch makes error:

    [PokeCommunity.com] Delete specific pokemon from party


    [PokeCommunity.com] Delete specific pokemon from party
     
    Last edited:
    you reply 1yr later lol anyway i'll share you one script in the game i'm making.

    Spoiler:

    paste it somewhere above main.

    to use just write in event script section [S-HIGHLIGHT]removePkmn(:BULBASAUR)[/S-HIGHLIGHT] or whatever pokemon you want and you can use it many times as you want.
     
    Last edited:
    you reply 1yr later lol anyway i'll share you one script in the game i'm making.

    Spoiler:

    paste it somewhere above main.

    to use just write in event script section [S-HIGHLIGHT]removePkmn(:BULBASAUR)[/S-HIGHLIGHT] or whatever pokemon you want and you can use it many times as you want.


    Hello!
    Yeap! I forgot i! :laugh-squinted: Yesterday I found this same question on another forum and I would done it :smile:

    Your script doesn't work me. Script doesn't make any error, but do nothing.
    Script:
    Spoiler:

    CB:
    Spoiler:


    BUT

    This script:

    Spoiler:

    with call:
    Spoiler:

    by Leilou
    Spoiler:

    Working!!

    So lets work with this because it needs little bit edit.
    This script delete all specific pokemons in party that you have 2 or more.
    I need delete only one.
    Also If you have only one pokemon do nothing. It will be good show in Kernel.pbMessage something like "You have only one pokemon!"

    At end this post I would say: Thank you all people, who post here any solution. I really appreciate it
     
    Last edited:
    !SOLVED!

    This script is finally what I want.
    100% working.


    Spoiler:


    Thank you all!
    Script made by Leilou
     
    ahh sorry I made a shortcut in scriptcall it should be removePkmn(PBSpecies::BULBASAUR)
    but anyway good that something work on you!
     
    Back
    Top