Vendily

poke export glitch

Jul 7th, 2018
149
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  SPECIES_TYPE1_OFFSET=0x05
  2.  SPECIES_TYPE2_OFFSET=0x06
  3.  def getGen1PokemonDataStruct(boxoffset, position=1, scanForGlitched=false)
  4.     gen1poke = {}
  5.     species = getSingleKeyInHex(self.filename, boxoffset + (POKEMON_LIST_OFFSET * position), 1)
  6.     gen1poke["species"] = species
  7.     moves = []
  8.     for i in 0...SPECIES_MOVES_OFFSETS.length
  9.       moves.push(getSingleKeyInHex(self.filename, boxoffset + (POKEMON_LIST_OFFSET * position) + SPECIES_MOVES_OFFSETS[i], 1))
  10.         end
  11.         gen1poke["moves"] = moves
  12.         levelhex = getSingleKeyInHex(self.filename, boxoffset + (POKEMON_LIST_OFFSET * position) + 0x03, 1)
  13.         levelString = levelhex
  14.         gen1poke["level"] = levelString.to_i(16)
  15.         experience = getSingleKeyInHex(self.filename, boxoffset + (POKEMON_LIST_OFFSET * position) + SPECIES_EXP_OFFSET, 3)
  16.         gen1poke["experience"] = experience.to_i(16)
  17.         determinantValuesBits = getSingleKeyInHex(self.filename, boxoffset + (POKEMON_LIST_OFFSET * position) + SPECIES_DV_OFFSET, 2).to_i(16)
  18.         gen1poke["type1"] = getSingleKeyInHex(self.filename, boxoffset + (POKEMON_LIST_OFFSET * position) + SPECIES_TYPE1_OFFSET,1)
  19.         gen1poke["type2"] = getSingleKeyInHex(self.filename, boxoffset + (POKEMON_LIST_OFFSET * position) + SPECIES_TYPE2_OFFSET,1)
  20.         dvAttack = (determinantValuesBits >> 12) & 0xF
  21.         dvDefense = (determinantValuesBits >> 8) & 0xF
  22.         dvSpeed = (determinantValuesBits >> 4) & 0xF
  23.         dvSpecial = (determinantValuesBits >> 0) & 0xF
  24.         dvHP = ((dvAttack & 1) << 3) | ((dvDefense & 1) << 2) | ((dvSpeed & 1) << 1) | ((dvSpecial & 1) << 0)
  25.         gen1poke["determinant_values"] = {}
  26.         gen1poke["determinant_values"]["dv_hp"] = dvHP
  27.         gen1poke["determinant_values"]["dv_defense"] = dvDefense
  28.         gen1poke["determinant_values"]["dv_attack"] = dvAttack
  29.         gen1poke["determinant_values"]["dv_speed"] = dvSpeed
  30.         gen1poke["determinant_values"]["dv_special"] = dvSpecial
  31.         gen1poke["shiny"] = gen1ShinyCheck(gen1poke["determinant_values"])
  32.     return gen1poke
  33.   end
  34.    
  35.     SPECIES_TYPES_TO_PBSPECIES_FORM={
  36.         ['00','06','00']=>[:SPECIESHERE,FormHere],
  37.         ['C3','07','03']=>[:BEEDRILL,2] #Z4
  38.     }
  39.      # Converts the Pokemon from a Gen 1 to a Gen 7 Pokemon.
  40.   # Copied: Species, nickname, experience, moves, OT info.
  41.   # Give a random nature to the Pokemon.
  42.   # Give it a hidden Ability.
  43.   # Set it to a normal-formed Pokemon. No Alolan forms!
  44.   # Set the met location to "Seems to have traveled across both space and time
  45.   # to reach you from the Kanto region in the good old days." FRLG only uses
  46.   # "in the good old days." (Thanks to IcyCatElf for this info)
  47.   # Give it 3 random perfect IVs, except for Mew, who will be given 5 random
  48.   #    perfect IVs instead.
  49.   # NOTE: Bar MissingNo from being transferred.
  50.   def convertToGen7Pokemon(speciesArray, language=2, removefromSave=false)
  51.     if HEX_TO_PBSPECIES.include?(speciesArray["species"])
  52.             pokemon = HEX_TO_PBSPECIES[speciesArray["species"]]  # Get the PBSpecies thing
  53.         else
  54.             specform=SPECIES_TYPES_TO_PBSPECIES_FORM[[speciesArray["species"],speciesArray["type1"],speciesArray["type2"]]]
  55.             pokemon=specform[0]
  56.         end
  57.     level = speciesArray["level"]
  58.     return false if pbBoxesFull? || !$Trainer || !speciesArray || speciesArray.empty?
  59.     if pokemon.is_a?(String) || pokemon.is_a?(Symbol)
  60.       pokemon=getID(PBSpecies,pokemon)
  61.     end
  62.     if pokemon.is_a?(Integer) && level.is_a?(Integer)
  63.       pokemon=PokeBattle_Pokemon.new(pokemon,level,$Trainer)
  64.     end
  65.     $Trainer.seen[pokemon.species]=true
  66.     $Trainer.owned[pokemon.species]=true
  67.     pokemon.form=specform[1] if specform
  68.     pbSeenForm(pokemon)
  69.     pokemon.exp=speciesArray["experience"] # Get the EXP
  70.     nature = (speciesArray["experience"] % 25)
  71.     if nature.is_a?(Integer)
  72.       pokemon.setNature(nature)
  73.     end
  74.     pokemon.ot=getSaveFileOTname
  75.     pokemon.trainerID=getSaveFileOTId
  76.     pokemon.obtainText=_INTL(GEN1_MET)
  77.     pokemon.language=language
  78.     pokemon.generated=1
  79.     pokemon.setAbility(2) # Give hidden ability
  80.     # Give some perfect IVs. The IVs are an array.
  81.     if (pokemon.species==PBSpecies::MEW)
  82.       perfectIVs = getIndexeswithPerfectIV(5)
  83.     else
  84.       perfectIVs = getIndexeswithPerfectIV
  85.     end
  86.     for i in 0...6
  87.       if perfectIVs.include?(i)
  88.         pokemon.iv[i]=31
  89.       else
  90.         pokemon.iv[i]=rand(32)
  91.       end
  92.     end
  93.     moves = speciesArray["moves"]
  94.     for i in 0...moves.length
  95.       if moves[i] != '00'
  96.         pokemon.pbLearnMove(HEX_TO_MOVES[moves[i]])
  97.       end
  98.     end
  99.     pokemon.calcStats # Always calculate stats.
  100.     $PokemonStorage.pbStoreCaught(pokemon)
  101.     return true
  102.   end
  103. end
RAW Paste Data