• 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.
  • Dawn, Gloria, Juliana, or Summer - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • 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] Allow trade evolutions without needing to trade

LatiusAuro

The Lati Hybrid
  • 8
    Posts
    6
    Years
    • Seen Dec 4, 2018
    I am currently working on a fangame, and one of the things we want to change is how Trade Evolutions can happen. Obviously, I'd like to keep the ability to trade them to evolve them, just in case we do include NPCs who offer to make trades which result in evolutions, but I also want to be able to have someone in, say, certain Pok?mon Centres who would be able to 'trade' to you an exact copy of the Pok?mon you 'trade' with them (even though I'd rather not show the trading sequence for this kind of 'trade') so that they can evolve. How would I go about setting that up in order for that to work?
     
    Code:
    def pbEvolveTrading()
    
    choices=[
    
      _INTL("Yes"),
    
      _INTL("No")
    
    ]
    
    choice=Kernel.pbMessage("Would you like me to evolve one of your pokemon?",choices,0)
    
    if choice == 0
    
            
    
      pbChoosePokemon(1,2,
    
        proc {|poke|
    
        poke.species==PBSpecies::BOLDORE ||
    
        poke.species==PBSpecies::CLAMPERL ||
    
        poke.species==PBSpecies::DUSCLOPS ||
    
        poke.species==PBSpecies::ELECTABUZZ ||
    
        poke.species==PBSpecies::FEEBAS ||
    
        poke.species==PBSpecies::GRAVELER ||
    
        poke.species==PBSpecies::GURDURR ||
    
        poke.species==PBSpecies::HAUNTER ||
    
        poke.species==PBSpecies::KADABRA ||
    
        poke.species==PBSpecies::KARRABLAST ||
    
        poke.species==PBSpecies::MACHOKE ||
    
        poke.species==PBSpecies::MAGMAR ||
    
        poke.species==PBSpecies::ONIX ||
    
        poke.species==PBSpecies::PHANTUMP ||
    
        poke.species==PBSpecies::POLIWHIRL ||
    
        poke.species==PBSpecies::PORYGON ||
    
        poke.species==PBSpecies::PORYGON2 ||
    
        poke.species==PBSpecies::PUMPKABOO ||
    
        poke.species==PBSpecies::RHYDON ||
    
        poke.species==PBSpecies::SCYTHER ||
    
        poke.species==PBSpecies::SEADRA ||
    
        poke.species==PBSpecies::SHELMET ||
    
        poke.species==PBSpecies::SLOWPOKE ||
    
        poke.species==PBSpecies::SPRITZEE ||
    
        poke.species==PBSpecies::SWIRLIX
    
        })
    
        
    
      if pbGet(1) > 0
    
      
    
        pokemon = $Trainer.pokemonParty[pbGet(1)]
    
        po = $Trainer.pokemonParty[pbGet(1)]
    
        
    
        pbStartTrade(pbGet(1), PBSpecies::RATTATA, "Rattata","Melvin")
    
          
    
        Kernel.pbMessage("Thanks, now to trade back")
    
      
    
        pbStartTradeEvo(pbGet(1), pokemon, "Melvin")
    
        
    
      end
    
    end
    
      
    
    end
    
      
    
    def pbStartTradeEvo(pokemonIndex,newpoke,name)
    
    myPokemon=$Trainer.party[pokemonIndex]
    
    opponent=PokeBattle_Trainer.new($Trainer.name,$Trainer.gender)
    
    yourPokemon=nil; resetmoves=true
    
    if newpoke.is_a?(PokeBattle_Pokemon)
    
      yourPokemon=newpoke
    
    else
    
      if newpoke.is_a?(String) || newpoke.is_a?(Symbol)
    
        raise _INTL("Species does not exist ({1}).",newpoke) if !hasConst?(PBSpecies,newpoke)
    
        newpoke=getID(PBSpecies,newpoke)
    
      end
    
      yourPokemon=PokeBattle_Pokemon.new(newpoke,myPokemon.level,opponent)
    
    end
    
    yourPokemon.pbRecordFirstMoves
    
    $Trainer.seen[yourPokemon.species]=true
    
    $Trainer.owned[yourPokemon.species]=true
    
    pbSeenForm(yourPokemon)
    
    pbFadeOutInWithMusic(99999){
    
      evo=PokemonTradeScene.new
    
      evo.pbStartScreen(myPokemon,yourPokemon,$Trainer.name,name)
    
      evo.pbTrade
    
      evo.pbEndScreen
    
    }
    
    $Trainer.party[pokemonIndex]=yourPokemon
    
    end
     
    Code:
    def pbEvolveTrading()
    
    choices=[
    
      _INTL("Yes"),
    
      _INTL("No")
    
    ]
    
    choice=Kernel.pbMessage("Would you like me to evolve one of your pokemon?",choices,0)
    
    if choice == 0
    
            
    
      pbChoosePokemon(1,2,
    
        proc {|poke|
    
        poke.species==PBSpecies::BOLDORE ||
    
        poke.species==PBSpecies::CLAMPERL ||
    
        poke.species==PBSpecies::DUSCLOPS ||
    
        poke.species==PBSpecies::ELECTABUZZ ||
    
        poke.species==PBSpecies::FEEBAS ||
    
        poke.species==PBSpecies::GRAVELER ||
    
        poke.species==PBSpecies::GURDURR ||
    
        poke.species==PBSpecies::HAUNTER ||
    
        poke.species==PBSpecies::KADABRA ||
    
        poke.species==PBSpecies::KARRABLAST ||
    
        poke.species==PBSpecies::MACHOKE ||
    
        poke.species==PBSpecies::MAGMAR ||
    
        poke.species==PBSpecies::ONIX ||
    
        poke.species==PBSpecies::PHANTUMP ||
    
        poke.species==PBSpecies::POLIWHIRL ||
    
        poke.species==PBSpecies::PORYGON ||
    
        poke.species==PBSpecies::PORYGON2 ||
    
        poke.species==PBSpecies::PUMPKABOO ||
    
        poke.species==PBSpecies::RHYDON ||
    
        poke.species==PBSpecies::SCYTHER ||
    
        poke.species==PBSpecies::SEADRA ||
    
        poke.species==PBSpecies::SHELMET ||
    
        poke.species==PBSpecies::SLOWPOKE ||
    
        poke.species==PBSpecies::SPRITZEE ||
    
        poke.species==PBSpecies::SWIRLIX
    
        })
    
        
    
      if pbGet(1) > 0
    
      
    
        pokemon = $Trainer.pokemonParty[pbGet(1)]
    
        po = $Trainer.pokemonParty[pbGet(1)]
    
        
    
        pbStartTrade(pbGet(1), PBSpecies::RATTATA, "Rattata","Melvin")
    
          
    
        Kernel.pbMessage("Thanks, now to trade back")
    
      
    
        pbStartTradeEvo(pbGet(1), pokemon, "Melvin")
    
        
    
      end
    
    end
    
      
    
    end
    
      
    
    def pbStartTradeEvo(pokemonIndex,newpoke,name)
    
    myPokemon=$Trainer.party[pokemonIndex]
    
    opponent=PokeBattle_Trainer.new($Trainer.name,$Trainer.gender)
    
    yourPokemon=nil; resetmoves=true
    
    if newpoke.is_a?(PokeBattle_Pokemon)
    
      yourPokemon=newpoke
    
    else
    
      if newpoke.is_a?(String) || newpoke.is_a?(Symbol)
    
        raise _INTL("Species does not exist ({1}).",newpoke) if !hasConst?(PBSpecies,newpoke)
    
        newpoke=getID(PBSpecies,newpoke)
    
      end
    
      yourPokemon=PokeBattle_Pokemon.new(newpoke,myPokemon.level,opponent)
    
    end
    
    yourPokemon.pbRecordFirstMoves
    
    $Trainer.seen[yourPokemon.species]=true
    
    $Trainer.owned[yourPokemon.species]=true
    
    pbSeenForm(yourPokemon)
    
    pbFadeOutInWithMusic(99999){
    
      evo=PokemonTradeScene.new
    
      evo.pbStartScreen(myPokemon,yourPokemon,$Trainer.name,name)
    
      evo.pbTrade
    
      evo.pbEndScreen
    
    }
    
    $Trainer.party[pokemonIndex]=yourPokemon
    
    end

    Um... Having a look at this, I'm not sure if that resets the moves of the Pok?mon in qyestion, but I'll give it a try.
     
    I just tried it, and... It crashed on me when I tried to trade back. Here's the error I got:



    Spoiler:


    Edit: turned out it was because I put the script above the trading script. Trying again now.

    Edit 2: Nope, still doesn't work, and with a new error:

    Spoiler:
     
    Last edited:
    some things may have been changed from 16.2 ->17.2
    like "PokemonTradeScene"
     
    Well, that's no real help for me. I'm using the most recent Essentials version, after all. And I don't know what they changed that to.
     
    change "PokemonTradeScene" to "PokemonTrade_Scene" ...

    That indeed does work. At least, when I tested it with a Pok?mon who only needed trading to evolve. And the moves and items seem to stick with them.

    I'll need to look into the trade with item stuff - see if it tries to do the trade when the items aren't set up right. If so, I'll need to make a way to check that they are holding the right item before they can be traded. The same with getting a Miltioc - I need to make sure they have enough Beauty before they can be traded.

    Finally, this service won't be free - they'd charge a small number of Coins (although in my game, I've converted Coins to BP) for this service. That's why I want to check that the Pok?mon can evolve through the trade before the trade is made, so that people don't waste BP on trades which don't evolve a Pok?mon.
     
    Back
    Top