• 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.

How to delete Specific Pokémon from Party.

1,405
Posts
11
Years
  • I know you didn't ask for my help, but here's a small function:

    Code:
    WhiteListedPokemon = [PBSpecies::MAGIKARP] # change the pokemon here obviously.
    VariableID = 54 # change this to the variable ID you want to store the pokemon in
    
    def pbDeleteAndSavePartyPokemon
      $game_variables[VariableID] = [] if (!$game_variables[VariableID].is_a?(Array))
    
      for i in 0...$Trainer.party.length
        pokemon = $Trainer.party[i]
        if (!WhiteListedPokemon.include?(pokemon.species))
            $game_variables[VariableID].push(pokemon)
            pbRemovePokemonAt(i)
        end
    
      end
    
    end
    
    def pbRestoreAllDeletedPokemon
      return if (!$game_variables[VariableID].is_a?(Array))
    
      for pokemon in $game_variables[VariableID]
        pbAddPokemonSilent(pokemon)
      end
    
      $game_variables[VariableID] = []
    end

    This wasn't tested, but should work exactly how you want it. (Change the WhiteListedPokemon and VariableID variables to whatever suits you.)


    to delete the pokemon, just call "pbDeleteAndSavePartyPokemon" and to restore "pbRestoreAllDeletedPokemon"

    If you encounter errors, let me know.

    Edit: As for the problem with the other script, you forgot to store it into the PC.
    I get this error when the game starts

    Spoiler:


    As for mej71's script, i figured out it actually stored the clones into my party, and not the PC.
     
    1,224
    Posts
    10
    Years
  • As for mej71's script, i figured out it actually stored the clones into my party, and not the PC.

    I was thinking that it might have done that, but the way you put it initially led me to believe that it didn't work at all.


    Try adding this instead of the other store script.
    Code:
    $PokemonStorage.pbStoreCaught(clonedpkmn)
     
    1,405
    Posts
    11
    Years
  • I was thinking that it might have done that, but the way you put it initially led me to believe that it didn't work at all.


    Try adding this instead of the other store script.
    Code:
    $PokemonStorage.pbStoreCaught(clonedpkmn)


    That works thanks. Though if Umbreon posts a fix to his script i'm gonna use that instead because it's more convenient.
     
    1,405
    Posts
    11
    Years
  • It's saying "PBSpecies" is undefined. Did you insert the script below the compiler script?

    My bad, placing it under Compiler solves that error.

    But now i get a new one
    Spoiler:
     
    1,748
    Posts
    14
    Years
  • Give me a bit, sorry I'm using my phone and its hard to debug like this. XD (I'll post when I fixed it on my computer)

    Edit: add this directly under the for line: "break if i >= $Trainer.party.length"
     
    1,405
    Posts
    11
    Years
  • Give me a bit, sorry I'm using my phone and its hard to debug like this. XD (I'll post when I fixed it on my computer)

    Edit: add this directly under the for line: "break if i >= $Trainer.party.length"

    Works now, only deletes and saves 2 pokemon at a time, but i can simply use it multiple times and it will still bring them all back.

    Thanks!
     
    1,748
    Posts
    14
    Years
  • Here's the fixed up and less sloppy version:

    Code:
    WhiteListedPokemon = [PBSpecies::MAGIKARP] # change the pokemon here obviously.
    VariableID = 54 # change this to the variable ID you want to store the pokemon in
    
    def pbDeleteAndSavePartyPokemon
      $game_variables[VariableID] = [] if (!$game_variables[VariableID].is_a?(Array))
      for i in 0...$Trainer.party.length
        if (!WhiteListedPokemon.include?($Trainer.party[i].species))
            $game_variables[VariableID].push(pokemon)
            $Trainer.party[i] = nil
        end
      end
      $Trainer.party.compact!
    end
    
    def pbRestoreAllDeletedPokemon
      return if (!$game_variables[VariableID].is_a?(Array))
    
      for pokemon in $game_variables[VariableID]
        pbAddPokemonSilent(pokemon)
      end
    
      $game_variables[VariableID] = []
    end

    All you really need is the first function, but I added it all just for copy-paste simplicity.
     
    1,405
    Posts
    11
    Years
  • Here's the fixed up and less sloppy version:

    Code:
    WhiteListedPokemon = [PBSpecies::MAGIKARP] # change the pokemon here obviously.
    VariableID = 54 # change this to the variable ID you want to store the pokemon in
    
    def pbDeleteAndSavePartyPokemon
      $game_variables[VariableID] = [] if (!$game_variables[VariableID].is_a?(Array))
      for i in 0...$Trainer.party.length
        if (!WhiteListedPokemon.include?($Trainer.party[i].species))
            $game_variables[VariableID].push(pokemon)
            $Trainer.party[i] = nil
        end
      end
      $Trainer.party.compact!
    end
    
    def pbRestoreAllDeletedPokemon
      return if (!$game_variables[VariableID].is_a?(Array))
    
      for pokemon in $game_variables[VariableID]
        pbAddPokemonSilent(pokemon)
      end
    
      $game_variables[VariableID] = []
    end

    All you really need is the first function, but I added it all just for copy-paste simplicity.

    got an error at first but i added pokemon = $Trainer.party after for i in 0...$Trainer.party.length and it now works perfectly.

    Thanks a lot
     
    1,748
    Posts
    14
    Years
  • Whoops, I forgot to change the variable pokemon to $Trainer.party, here's the fixed version for anyone else.

    Code:
    WhiteListedPokemon = [PBSpecies::MAGIKARP] # change the pokemon here obviously.
    VariableID = 54 # change this to the variable ID you want to store the pokemon in
    
    def pbDeleteAndSavePartyPokemon
      $game_variables[VariableID] = [] if (!$game_variables[VariableID].is_a?(Array))
      for i in 0...$Trainer.party.length
        if (!WhiteListedPokemon.include?($Trainer.party[i].species))
            $game_variables[VariableID].push($Trainer.party[i])
            $Trainer.party[i] = nil
        end
      end
      $Trainer.party.compact!
    end
    
    def pbRestoreAllDeletedPokemon
      return if (!$game_variables[VariableID].is_a?(Array))
    
      for pokemon in $game_variables[VariableID]
        pbAddPokemonSilent(pokemon)
      end
    
      $game_variables[VariableID] = []
    end
     
    32
    Posts
    9
    Years
    • Seen Aug 16, 2016
    That doesn't do anything.

    My original thing was almost correct, I just derped
    Code:
    for i in 0..$Trainer.party.length-1
    if $Trainer.party[i].species==PBSpecies::MEOWTH
    Kernel.pbMessage(_INTL("{1} was removed from your party!",$Trainer.party[i].name))
    $Trainer.party[i]=nil
    $Trainer.party.compact!
    break
    end
    end

    here's another possibility. put this in poke utilities:

    def pbdelete(variableNumber,species)
    for i in 0...$Trainer.party.length
    species=getID(PBSpecies,species)
    p=$Trainer.party
    if p && p.species==species
    pbSet(variableNumber,i)
    return $Trainer.party
    end
    end
    pbSet(variableNumber,-1)
    return nil
    end

    then an event just needs two lines of script:
    pbdelete(1,:PIKACHU)
    pbRemovePokemonAt(pbGet(1))

    if you don't have a pikachu with you, this won't do anything. so a conditional branch with pbHasSpecies? would be useful. if you have many of them, it will delete the first one it finds in your party.
     
    Back
    Top