Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def convertToGen7Pokemon(speciesArray, language=2, removefromSave=false)
- keyspectype=[speciesArray["species"],speciesArray["type1"],speciesArray["type2"]]
- if HEX_TO_PBSPECIES.include?(speciesArray["species"])
- pokemon = HEX_TO_PBSPECIES[speciesArray["species"]] # Get the PBSpecies thing
- elsif SPECIES_TYPES_TO_PBSPECIES_FORM.include?(keyspectype)
- specform=SPECIES_TYPES_TO_PBSPECIES_FORM[keyspectype]
- pokemon=specform[0] if specform
- end
- level = [speciesArray["level"],1].max
- return true if !pokemon
- return false if pbBoxesFull? || !$Trainer || !speciesArray || speciesArray.empty?
- if pokemon.is_a?(String) || pokemon.is_a?(Symbol)
- pokemon=getID(PBSpecies,pokemon)
- end
- if pokemon.is_a?(Integer) && level.is_a?(Integer)
- pokemon=PokeBattle_Pokemon.new(pokemon,level,$Trainer)
- end
- $Trainer.seen[pokemon.species]=true
- $Trainer.owned[pokemon.species]=true
- pokemon.form=specform[1] if specform
- pbSeenForm(pokemon)
- pokemon.exp=speciesArray["experience"] # Get the EXP
- nature = (speciesArray["experience"] % 25)
- if nature.is_a?(Integer)
- pokemon.setNature(nature)
- end
- pokemon.ot=getSaveFileOTname
- pokemon.trainerID=getSaveFileOTId
- pokemon.obtainText=_INTL(GEN1_MET)
- pokemon.language=language
- pokemon.generated=1
- pokemon.setAbility(2) # Give hidden ability
- # Give some perfect IVs. The IVs are an array.
- if (pokemon.species==PBSpecies::MEW)
- perfectIVs = getIndexeswithPerfectIV(5)
- else
- perfectIVs = getIndexeswithPerfectIV
- end
- for i in 0...6
- if perfectIVs.include?(i)
- pokemon.iv[i]=31
- else
- pokemon.iv[i]=rand(32)
- end
- end
- moves = speciesArray["moves"]
- for i in 0...moves.length
- if moves[i] != '00'
- pokemon.pbLearnMove(HEX_TO_MOVES[moves[i]])
- end
- end
- pokemon.calcStats # Always calculate stats.
- $PokemonStorage.pbStoreCaught(pokemon)
- return true
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement