Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SPECIES_TYPE1_OFFSET=0x05
- SPECIES_TYPE2_OFFSET=0x06
- def getGen1PokemonDataStruct(boxoffset, position=1, scanForGlitched=false)
- gen1poke = {}
- species = getSingleKeyInHex(self.filename, boxoffset + (POKEMON_LIST_OFFSET * position), 1)
- gen1poke["species"] = species
- moves = []
- for i in 0...SPECIES_MOVES_OFFSETS.length
- moves.push(getSingleKeyInHex(self.filename, boxoffset + (POKEMON_LIST_OFFSET * position) + SPECIES_MOVES_OFFSETS[i], 1))
- end
- gen1poke["moves"] = moves
- levelhex = getSingleKeyInHex(self.filename, boxoffset + (POKEMON_LIST_OFFSET * position) + 0x03, 1)
- levelString = levelhex
- gen1poke["level"] = levelString.to_i(16)
- experience = getSingleKeyInHex(self.filename, boxoffset + (POKEMON_LIST_OFFSET * position) + SPECIES_EXP_OFFSET, 3)
- gen1poke["experience"] = experience.to_i(16)
- determinantValuesBits = getSingleKeyInHex(self.filename, boxoffset + (POKEMON_LIST_OFFSET * position) + SPECIES_DV_OFFSET, 2).to_i(16)
- gen1poke["type1"] = getSingleKeyInHex(self.filename, boxoffset + (POKEMON_LIST_OFFSET * position) + SPECIES_TYPE1_OFFSET,1)
- gen1poke["type2"] = getSingleKeyInHex(self.filename, boxoffset + (POKEMON_LIST_OFFSET * position) + SPECIES_TYPE2_OFFSET,1)
- dvAttack = (determinantValuesBits >> 12) & 0xF
- dvDefense = (determinantValuesBits >> 8) & 0xF
- dvSpeed = (determinantValuesBits >> 4) & 0xF
- dvSpecial = (determinantValuesBits >> 0) & 0xF
- dvHP = ((dvAttack & 1) << 3) | ((dvDefense & 1) << 2) | ((dvSpeed & 1) << 1) | ((dvSpecial & 1) << 0)
- gen1poke["determinant_values"] = {}
- gen1poke["determinant_values"]["dv_hp"] = dvHP
- gen1poke["determinant_values"]["dv_defense"] = dvDefense
- gen1poke["determinant_values"]["dv_attack"] = dvAttack
- gen1poke["determinant_values"]["dv_speed"] = dvSpeed
- gen1poke["determinant_values"]["dv_special"] = dvSpecial
- gen1poke["shiny"] = gen1ShinyCheck(gen1poke["determinant_values"])
- return gen1poke
- end
- SPECIES_TYPES_TO_PBSPECIES_FORM={
- ['00','06','00']=>[:SPECIESHERE,FormHere],
- ['C3','07','03']=>[:BEEDRILL,2] #Z4
- }
- # Converts the Pokemon from a Gen 1 to a Gen 7 Pokemon.
- # Copied: Species, nickname, experience, moves, OT info.
- # Give a random nature to the Pokemon.
- # Give it a hidden Ability.
- # Set it to a normal-formed Pokemon. No Alolan forms!
- # Set the met location to "Seems to have traveled across both space and time
- # to reach you from the Kanto region in the good old days." FRLG only uses
- # "in the good old days." (Thanks to IcyCatElf for this info)
- # Give it 3 random perfect IVs, except for Mew, who will be given 5 random
- # perfect IVs instead.
- # NOTE: Bar MissingNo from being transferred.
- def convertToGen7Pokemon(speciesArray, language=2, removefromSave=false)
- if HEX_TO_PBSPECIES.include?(speciesArray["species"])
- pokemon = HEX_TO_PBSPECIES[speciesArray["species"]] # Get the PBSpecies thing
- else
- specform=SPECIES_TYPES_TO_PBSPECIES_FORM[[speciesArray["species"],speciesArray["type1"],speciesArray["type2"]]]
- pokemon=specform[0]
- end
- level = speciesArray["level"]
- 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