Vendily

convert poke

Jul 7th, 2018
138
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def convertToGen7Pokemon(speciesArray, language=2, removefromSave=false)
  2.     keyspectype=[speciesArray["species"],speciesArray["type1"],speciesArray["type2"]]
  3.     if HEX_TO_PBSPECIES.include?(speciesArray["species"])
  4.             pokemon = HEX_TO_PBSPECIES[speciesArray["species"]]  # Get the PBSpecies thing
  5.         elsif SPECIES_TYPES_TO_PBSPECIES_FORM.include?(keyspectype)
  6.             specform=SPECIES_TYPES_TO_PBSPECIES_FORM[keyspectype]
  7.             pokemon=specform[0] if specform
  8.         end
  9.     level = [speciesArray["level"],1].max
  10.     return true if !pokemon
  11.     return false if pbBoxesFull? || !$Trainer || !speciesArray || speciesArray.empty?
  12.     if pokemon.is_a?(String) || pokemon.is_a?(Symbol)
  13.       pokemon=getID(PBSpecies,pokemon)
  14.     end
  15.     if pokemon.is_a?(Integer) && level.is_a?(Integer)
  16.       pokemon=PokeBattle_Pokemon.new(pokemon,level,$Trainer)
  17.     end
  18.     $Trainer.seen[pokemon.species]=true
  19.     $Trainer.owned[pokemon.species]=true
  20.     pokemon.form=specform[1] if specform
  21.     pbSeenForm(pokemon)
  22.     pokemon.exp=speciesArray["experience"] # Get the EXP
  23.     nature = (speciesArray["experience"] % 25)
  24.     if nature.is_a?(Integer)
  25.       pokemon.setNature(nature)
  26.     end
  27.     pokemon.ot=getSaveFileOTname
  28.     pokemon.trainerID=getSaveFileOTId
  29.     pokemon.obtainText=_INTL(GEN1_MET)
  30.     pokemon.language=language
  31.     pokemon.generated=1
  32.     pokemon.setAbility(2) # Give hidden ability
  33.     # Give some perfect IVs. The IVs are an array.
  34.     if (pokemon.species==PBSpecies::MEW)
  35.       perfectIVs = getIndexeswithPerfectIV(5)
  36.     else
  37.       perfectIVs = getIndexeswithPerfectIV
  38.     end
  39.     for i in 0...6
  40.       if perfectIVs.include?(i)
  41.         pokemon.iv[i]=31
  42.       else
  43.         pokemon.iv[i]=rand(32)
  44.       end
  45.     end
  46.     moves = speciesArray["moves"]
  47.     for i in 0...moves.length
  48.       if moves[i] != '00'
  49.         pokemon.pbLearnMove(HEX_TO_MOVES[moves[i]])
  50.       end
  51.     end
  52.     pokemon.calcStats # Always calculate stats.
  53.     $PokemonStorage.pbStoreCaught(pokemon)
  54.     return true
  55.   end
  56. end
RAW Paste Data