• 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?".
  • Staff applications for our PokéCommunity Daily and Social Media team are now open! Interested in joining staff? Then click here for more info!
  • 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] Deleting Pkmn After Fusion Evo

  • 10
    Posts
    5
    Years
    • Seen Jul 25, 2020
    I successfully created an evolution for Slowpoke that has him evolve at Lv 37 when you have a Shellder in the party. The only problem is, no matter how many different codes I tried, the single Shellder in the party would not delete after the evolution was complete.

    Can someone please give me code to erase the Shellder after evo, and where to place it in this base code of mine:
    Code:
        # Add code for custom evolution type 1
      when PBEvolution::Fusion
        for i in $Trainer.pokemonParty
          return poke if i.species==level && pokemon.level>=37
        end

    I've tried everything I could think of on my own and anything I could find online, including defining a new command. In fact, I'll place that code here, in case I did something wrong there:

    Code:
    def PBdeleteFirst(species)
      species = getConst(PBSpecies,species) if !species.is_a?(Numeric)
      for i in 0...$Trainer.party.size
    	$Trainer.party[i] = nil if $Trainer.party[i].species == species
    	break
      end
      $Trainer.party.compact!
    end

    I found that code somewhere online and I put it in its own section above Main, then placed the line PBdeleteFirst(:SHELLDER) under return poke if i.species==level && pokemon.level>=37
    Did I perhaps do something wrong here?


    Any help would be greatly appreciated!
     
    Add this script right above your Evolution Method

    Code:
    def removePkmn(pkmn)
      if $Trainer.party.length>0
        for i in 0...$Trainer.party.length
          if $Trainer.party[i].species==pkmn
            $Trainer.party.delete_at(i)
            $Trainer.party.compact!
            break
          end
        end
      end
    end


    Then add this script call above "return poke"
    Code:
    removePkmn(PBSpecies::SHELLDER)


    When the command return is used the program exits out of the function. So when you placed your script call below "return poke" Essentials goes through with the Evolution Function and reaches the return command and exits out of the function and gives the output poke( the evolution of the Pokémon), that's why your code wasn't working.
     
    I would say add this after the shellder is fused:
    Code:
    if $Trainer.party.length>0
        for i in 0...$Trainer.party.length
          if $Trainer.party[i].species==(PBSpecies::SHELLDER)
            $Trainer.party.delete_at(i)
            $Trainer.party.compact!
            break
          end
        end
    end
    EDIT: Just realized Golisopod User jas already given an answer.
     
    Add this script right above your Evolution Method

    Code:
    def removePkmn(pkmn)
      if $Trainer.party.length>0
        for i in 0...$Trainer.party.length
          if $Trainer.party[i].species==pkmn
            $Trainer.party.delete_at(i)
            $Trainer.party.compact!
            break
          end
        end
      end
    end


    Then add this script call above "return poke"
    Code:
    removePkmn(PBSpecies::SHELLDER)


    When the command return is used the program exits out of the function. So when you placed your script call below "return poke" Essentials goes through with the Evolution Function and reaches the return command and exits out of the function and gives the output poke( the evolution of the Pokémon), that's why your code wasn't working.

    Thanks for your help! I figured it had to be something simple, but boy did it frustrate me. Glad to know what the return function fully does now.

    The only problem is, if you cancel out the evolution, the Shellder still gets deleted (which I kinda knew was going to happen anyway)
    Do you know any way to prevent this? I know it's probably unlikely, so it's not a big deal, if not. I can put a disclaimer in the game so that it's fairer.
     
    Try to look when NINCADA evolves to NINJASK, a Shedinja will be added in your party. You just need to put that code to remove pokémon into the same place. We have the code to MOTHIM too, IIRC.
     
    Maybe in the code for evolving make a game variable called evo (e.g. $game_variables[999])and make it 1 if the evolution has worked and in the place where it checks if the player has clicked b add $game_variables[999]=0 and make the deleting this and call it after the evo:
    Spoiler:
     
    Back
    Top