#Not Important
All hail the wishmaker
- 910
- Posts
- 5
- Years
- He/Him
- Hoenn
- Seen Jul 22, 2023
I DID NOT WRITE THIS, I ONLY ADAPTED IT TO v18.1 BECAUSE I WAS BORED
Call
Script:
Call
$scene = PokeDepot_Scene.new
to start the sceneScript:
Spoiler:
Code:
#=======================================
# =======================================#
# GB -> Essentials, by rigbycwts for v17 i think #
# Adapted by #Not Important to v18 #
#=======================================
# =======================================#
PluginManager.register({
:name => "GB -> Essentials v18.1",
:version => "1.0",
:credits => ["rigbycwts","#not important"],
:link => "file:///c:/"
})
class PokeBattle_Pokemon
attr_accessor(:generated) # Determines where the Pokemon is generated:
# 0 - fangames
# 1 - gen 1
# Returns the number corresponding to how the Pokemon is generated.
def generated
@generated=0 if !@generated
return
end
# Sets the number corresponding to how the Pokemon is generated.
def generated=(value)
@generated=value
end
# Creates a new Pokémon object.
# species - Pokémon species.
# level - Pokémon level.
# player - PokeBattle_Trainer object for the original trainer.
# withMoves - If false, this Pokémon has no moves.
def initialize(species,level,player=nil,withMoves=true)
ospecies = species.to_s
species = getID(PBSpecies,species)
cname = getConstantName(PBSpecies,species) rescue nil
realSpecies = pbGetSpeciesFromFSpecies(species)[0] if species && species>0
if !species || species<=0 || realSpecies>PBSpecies.maxValue || !cname
raise ArgumentError.new(_INTL("The species given ({1}) is invalid.",ospecies))
return nil
end
@species = realSpecies
@name = PBSpecies.getName(@species)
@personalID = rand(256)
@personalID |= rand(256)<<8
@personalID |= rand(256)<<16
@personalID |= rand(256)<<24
@hp = 1
@totalhp = 1
@iv = []
@ivMaxed = []
@ev = []
PBStats.eachStat do |s|
@iv[s] = rand(IV_STAT_LIMIT+1)
@ev[s] = 0
end
@moves = []
@status = PBStatuses::NONE
@statusCount = 0
@item = 0
@mail = nil
@fused = nil
@ribbons = []
@ballused = 0
@eggsteps = 0
if player
@trainerID = player.id
@ot = player.name
@otgender = player.gender
@language = player.language
else
@trainerID = 0
@ot = ""
@otgender = 2
end
@obtainMap = ($game_map) ? $game_map.map_id : 0
@obtainText = nil
@obtainLevel = level
@obtainMode = 0 # Met
@obtainMode = 4 if $game_switches && $game_switches[FATEFUL_ENCOUNTER_SWITCH]
@hatchedMap = 0
@timeReceived = pbGetTimeNow.to_i
self.level = level
calcStats
@generated=0
@hp = @totalhp
@happiness = pbGetSpeciesData(@species,formSimple,SpeciesHappiness)
if withMoves
self.resetMoves
else
for i in 0...4
@moves[i] = PBMove.new(0)
end
end
end
end
#==============================================================================#
# -- Savefile Reading -- #
#==============================================================================#
###############################################################################
# This script section contains methods that is used to read any save file.
###############################################################################
###############################################################################
# Hex methods are for the OT and Pokemon nicknames.
###############################################################################
def read_hex_io(io, offset, count)
io.seek offset, File::SEEK_SET
bytes = io.read count
bytes.unpack("H*").shift
end
def read_hex(file, offset, count)
File.open(file, "rb") do |io|
read_hex_io io, offset, count
end
end
###############################################################################
# Int methods are for the OT ID.
# Note that Gen 1 games use Big Endian.
###############################################################################
def read_intBigEndian_io(io, offset, count)
io.seek offset, File::SEEK_SET
bytes = io.read count
bytes.unpack("n").shift
end
def read_intBigEndian(file, offset, count)
File.open(file, "rb") do |io|
read_intBigEndian_io io, offset, count
end
end
###############################################################################
# Functions to determine which stat gets perfect IVs.
###############################################################################
def numGen(array)
random = rand(6)
if array.include?(random)
return numGen(array)
end
return random
end
def getIndexeswithPerfectIV(numPerfectIVs=3)
arrayPerfectIVindexes = []
for i in 0...numPerfectIVs
arrayPerfectIVindexes.push(numGen(arrayPerfectIVindexes))
end
return arrayPerfectIVindexes.sort
end
###############################################################################
# Outside of class functions necessary for converting hex to strings and more.
###############################################################################
# Converts the key to its ASCII equivalent on the table.
# If the hex string is 0xAB, the key is AB.
# Keys are treated as strings.
def getCorrespondingCharacter(key, table)
if table.include?(key)
return table[key]
end
end
# Converts bytes to integers.
# Gen 1 uses big endian.
def getBytesToInt16(savefile, offset, byteLength)
return read_intBigEndian(savefile, offset, byteLength)
end
# Gets a single key, treated as string.
def getSingleKeyInHex(savefile, offset, byteLength=2)
return read_hex(savefile, offset, byteLength)
end
# Returns an array of keys.
def getArrayOfKeys(savefile, offset, byteLength)
return read_hex(savefile, offset, byteLength).scan(/../)
end
# The array of keys are converted to an array of characters.
def getArrayOfCharacters(arrayOfKeys, table)
arrayOfChars = []
for i in 0...arrayOfKeys.length
arrayOfChars.insert(i, getCorrespondingCharacter(arrayOfKeys[i].upcase, table))
end
return arrayOfChars
end
# Language-related methods.
def isInternational(savefileName, japaneseOffsetChecker)
return !isJapanese(savefileName, japaneseOffsetChecker)
end
def isJapanese(savefileName, japaneseOffsetChecker)
partyPokemonList = getArrayOfKeys(savefileName, japaneseOffsetChecker[0], 30)
for i in 0...partyPokemonList.length
if partyPokemonList[i] != '00'
return true
end
end
return false
end
#==============================================================================#
# -- Gen 1 save functions -- #
#==============================================================================#
###############################################################################
# This script section contains classes that read the save files from RBY.
###############################################################################
# Constants for function use
GEN1SAVE_DIRNAME = "Gen 1 Save"
NULL_TERMINATOR = '\0'
GEN1_MET = "Relocated from Kanto in the good old days."
# Constants for box data manipulation
GEN1_CURRENT_BOX_OFFSET = 0x284C
ENTRIES_USED_OFFSET = 0x0000
SPECIES_LIST_OFFSET = 0x0001
POKEMON_LIST_OFFSET = 0x0016 # Multiply by 2, for example, to get 2nd Pokemon in the box
OT_NAMES_OFFSET = 0x02AA
POKEMON_NICKNAMES_OFFSET = 0x0386
# Reads the Gen 1 Data Structures.
SPECIES_INDEX_OFFSET = 0x00
SPECIES_MOVES_OFFSETS = [0x08, 0x09, 0x0A, 0x0B]
SPECIES_OT_ID_OFFSET = 0x0C # 2 bytes
SPECIES_EXP_OFFSET = 0x0E # 3 bytes
SPECIES_DV_OFFSET = 0x1B # 2 bytes, 4 bits for each DV/IV excluding HP
# Savefile language checker
US_OFFSET_CHECKER = [0x2F2C, 0x30C0]
JP_OFFSET_CHECKER = [0x2ED5, 0x302D]
###############################################################################
# Tables to be used by the hex and possibly int methods above.
###############################################################################
# Used for Pokemon nicknames and OT names
RBY_To_ASCII = {
'50' => '\0', # null terminator
'7F' => ' ', # space
'80' => 'A',
'81' => 'B',
'82' => 'C',
'83' => 'D',
'84' => 'E',
'85' => 'F',
'86' => 'G',
'87' => 'H',
'88' => 'I',
'89' => 'J',
'8A' => 'K',
'8B' => 'L',
'8C' => 'M',
'8D' => 'N',
'8E' => 'O',
'8F' => 'P',
'90' => 'Q',
'91' => 'R',
'92' => 'S',
'93' => 'T',
'94' => 'U',
'95' => 'V',
'96' => 'W',
'97' => 'X',
'98' => 'Y',
'99' => 'Z',
'9A' => '[',
'9B' => '\\',
'9C' => ']',
'9D' => '^',
'9E' => '_',
'9F' => '`',
'A0' => 'a',
'A1' => 'b',
'A2' => 'c',
'A3' => 'd',
'A4' => 'e',
'A5' => 'f',
'A6' => 'g',
'A7' => 'h',
'A8' => 'i',
'A9' => 'j',
'AA' => 'k',
'AB' => 'l',
'AC' => 'm',
'AD' => 'n',
'AE' => 'o',
'AF' => 'p',
'B0' => 'q',
'B1' => 'r',
'B2' => 's',
'B3' => 't',
'B4' => 'u',
'B5' => 'v',
'B6' => 'w',
'B7' => 'x',
'B8' => 'y',
'B9' => 'z',
'E3' => '-',
'E6' => '?',
'E7' => '!',
'E8' => '.',
'EF' => '♂', # Male Gender icon
'F2' => '.',
'F3' => '/',
'F4' => ',',
'F5' => '♀', # Female Gender icon
'F6' => '0',
'F7' => '1',
'F8' => '2',
'F9' => '3',
'FA' => '4',
'FB' => '5',
'FC' => '6',
'FD' => '7',
'FE' => '8',
'FF' => '9'
}
RBY_TO_CONVERTED_KANA = {
'05' => 'Ga',
'06' => 'Gi',
'07' => 'Gu',
'08' => 'Ge',
'09' => 'Go',
'0A' => 'Za',
'0B' => 'Zi',
'0C' => 'Zu',
'0D' => 'Ze',
'0E' => 'Zo',
'0F' => 'Da',
'10' => 'Di',
'11' => 'Dzu',
'12' => 'De',
'13' => 'Do',
'19' => 'Ba',
'1A' => 'Bi',
'1B' => 'Bu',
'1C' => 'Bo',
'26' => 'Ga',
'27' => 'Gi',
'28' => 'Gu',
'29' => 'Ge',
'2A' => 'Go',
'2B' => 'Za',
'2C' => 'Zi',
'2D' => 'Zu',
'2E' => 'Ze',
'2F' => 'Zo',
'30' => 'Da',
'31' => 'Di',
'32' => 'Dzu',
'33' => 'De',
'34' => 'Do',
'3A' => 'Ba',
'3B' => 'Bi',
'3C' => 'Bu',
'3D' => 'Be',
'3E' => 'Bo',
'40' => 'Pa',
'41' => 'Pi',
'42' => 'Pu',
'43' => 'Po',
'44' => 'Pa',
'45' => 'Pi',
'46' => 'Pu',
'47' => 'Pe',
'48' => 'Po',
'50' => '\0',
'80' => 'A',
'81' => 'I',
'82' => 'U',
'83' => 'E',
'84' => 'O',
'85' => 'Ka',
'86' => 'Ki',
'87' => 'Ku',
'88' => 'Ke',
'89' => 'Ko',
'8A' => 'Sa',
'8B' => 'Si',
'8C' => 'Su',
'8D' => 'Se',
'8E' => 'So',
'8F' => 'Ta',
'90' => 'Chi',
'91' => 'Tsu',
'92' => 'Te',
'93' => 'To',
'94' => 'Na',
'95' => 'Ni',
'96' => 'Nu',
'97' => 'Ne',
'98' => 'No',
'99' => 'Ha',
'9A' => 'Hi',
'9B' => 'Hu',
'9C' => 'Ho',
'9D' => 'Ma',
'9E' => 'Mi',
'9F' => 'Mu',
'A0' => 'Me',
'A1' => 'Mo',
'A2' => 'Ya',
'A3' => 'Yu',
'A4' => 'Yo',
'A5' => 'Ra',
'A6' => 'Ru',
'A7' => 'Re',
'A8' => 'Ro',
'A9' => 'Wa',
'AA' => 'Wo',
'AB' => 'n',
'AC' => '', # shortens sound
'AD' => 'ya',
'AE' => 'yu',
'AF' => 'yo',
'B0' => 'i',
'B1' => 'A',
'B2' => 'I',
'B3' => 'U',
'B4' => 'E',
'B5' => 'O',
'B6' => 'Ka',
'B7' => 'Ki',
'B8' => 'Ku',
'B9' => 'Ke',
'BA' => 'Ko',
'BB' => 'Sa',
'BC' => 'Shi',
'BD' => 'Su',
'BE' => 'Se',
'BF' => 'So',
'C0' => 'Ta',
'C1' => 'Chi',
'C2' => 'Tsu',
'C3' => 'Te',
'C4' => 'To',
'C5' => 'Na',
'C6' => 'Ni',
'C7' => 'Nu',
'C8' => 'Ne',
'C9' => 'No',
'CA' => 'Ha',
'CB' => 'Hi',
'CC' => 'Hu',
'CD' => 'He',
'CE' => 'Ho',
'CF' => 'Ma',
'D0' => 'Mi',
'D1' => 'Mu',
'D2' => 'Me',
'D3' => 'Mo',
'D4' => 'Ya',
'D5' => 'Yu',
'D6' => 'Yo',
'D7' => 'Ra',
'D8' => 'Ri',
'D9' => 'Ru',
'DA' => 'Re',
'DB' => 'Ro',
'DC' => 'Wa',
'DD' => 'Wo',
'DE' => 'n',
'DF' => '', # shortens sound
'E0' => 'ya',
'E1' => 'yu',
'E2' => 'yo',
'E3' => '', # prolongs sound
'E9' => 'a'
}
HEX_TO_PBSPECIES = {
'01' => :RHYDON,
'02' => :KANGASKHAN,
'03' => :NIDORANmA,
'04' => :CLEFAIRY,
'05' => :SPEAROW,
'06' => :VOLTORB,
'07' => :NIDOKING,
'08' => :SLOWBRO,
'09' => :IVYSAUR,
'0a' => :EXEGGUTOR,
'0b' => :LICKITUNG,
'0c' => :EXEGGCUTE,
'0d' => :GRIMER,
'0e' => :GENGAR,
'0f' => :NIDORANfE,
'10' => :NIDOQUEEN,
'11' => :CUBONE,
'12' => :RHYHORN,
'13' => :LAPRAS,
'14' => :ARCANINE,
'15' => :MEW,
'16' => :GYARADOS,
'17' => :SHELLDER,
'18' => :TENTACOOL,
'19' => :GASTLY,
'1a' => :SCYTHER,
'1b' => :STARYU,
'1c' => :BLASTOISE,
'1d' => :PINSIR,
'1e' => :TANGELA,
'21' => :GROWLITHE,
'22' => :ONIX,
'23' => :FEAROW,
'24' => :PIDGEY,
'25' => :SLOWPOKE,
'26' => :KADABRA,
'27' => :GRAVELER,
'28' => :CHANSEY,
'29' => :MACHOKE,
'2a' => :MRMIME,
'2b' => :HITMONLEE,
'2c' => :HITMONCHAN,
'2d' => :ARBOK,
'2e' => :PARASECT,
'2f' => :PSYDUCK,
'30' => :DROWZEE,
'31' => :GOLEM,
'33' => :MAGMAR,
'35' => :ELECTABUZZ,
'36' => :MAGNETON,
'37' => :KOFFING,
'39' => :MANKEY,
'3a' => :SEEL,
'3b' => :DIGLETT,
'3c' => :TAUROS,
'40' => :FARFETCHD,
'41' => :VENONAT,
'42' => :DRAGONITE,
'46' => :DODUO,
'47' => :POLIWAG,
'48' => :JYNX,
'49' => :MOLTRES,
'4a' => :ARTICUNO,
'4b' => :ZAPDOS,
'4c' => :DITTO,
'4d' => :MEOWTH,
'4e' => :KRABBY,
'52' => :VULPIX,
'53' => :NINETALES,
'54' => :PIKACHU,
'55' => :RAICHU,
'58' => :DRATINI,
'59' => :DRAGONAIR,
'5a' => :KABUTO,
'5b' => :KABUTOPS,
'5c' => :HORSEA,
'5d' => :SEADRA,
'60' => :SANDSHREW,
'61' => :SANDSLASH,
'62' => :OMANYTE,
'63' => :OMASTAR,
'64' => :JIGGLYPUFF,
'65' => :WIGGLYTUFF,
'66' => :EEVEE,
'67' => :FLAREON,
'68' => :JOLTEON,
'69' => :VAPOREON,
'6a' => :MACHOP,
'6b' => :ZUBAT,
'6c' => :EKANS,
'6d' => :PARAS,
'6e' => :POLIWHIRL,
'6f' => :POLIWRATH,
'70' => :WEEDLE,
'71' => :KAKUNA,
'72' => :BEEDRILL,
'74' => :DODRIO,
'75' => :PRIMEAPE,
'76' => :DUGTRIO,
'77' => :VENOMOTH,
'78' => :DEWGONG,
'7b' => :CATERPIE,
'7c' => :METAPOD,
'7d' => :BUTTERFREE,
'7e' => :MACHAMP,
'80' => :GOLDUCK,
'81' => :HYPNO,
'82' => :GOLBAT,
'83' => :MEWTWO,
'84' => :SNORLAX,
'85' => :MAGIKARP,
'88' => :MUK,
'8a' => :KINGLER,
'8b' => :CLOYSTER,
'8d' => :ELECTRODE,
'8e' => :CLEFABLE,
'8f' => :WEEZING,
'90' => :PERSIAN,
'91' => :MAROWAK,
'93' => :HAUNTER,
'94' => :ABRA,
'95' => :ALAKAZAM,
'96' => :PIDGEOTTO,
'97' => :PIDGEOT,
'98' => :STARMIE,
'99' => :BULBASAUR,
'9a' => :VENUSAUR,
'9b' => :TENTACRUEL,
'9d' => :GOLDEEN,
'9e' => :SEAKING,
'a3' => :PONYTA,
'a4' => :RAPIDASH,
'a5' => :RATTATA,
'a6' => :RATICATE,
'a7' => :NIDORINO,
'a8' => :NIDORINA,
'a9' => :GEODUDE,
'aa' => :PORYGON,
'ab' => :AERODACTYL,
'ad' => :MAGNEMITE,
'b0' => :CHARMANDER,
'b1' => :SQUIRTLE,
'b2' => :CHARMELEON,
'b3' => :WARTORTLE,
'b4' => :CHARIZARD,
'b9' => :ODDISH,
'ba' => :GLOOM,
'bb' => :VILEPLUME,
'bc' => :BELLSPROUT,
'bd' => :WEEPINBELL,
'be' => :VICTREEBEL
}
HEX_TO_MOVES = {
'01' => :POUND,
'02' => :KARATECHOP,
'03' => :DOUBLESLAP,
'04' => :COMETPUNCH,
'05' => :MEGAPUNCH,
'06' => :PAYDAY,
'07' => :FIREPUNCH,
'08' => :ICEPUNCH,
'09' => :THUNDERPUNCH,
'0a' => :SCRATCH,
'0b' => :VICEGRIP,
'0c' => :GUILLOTINE,
'0d' => :RAZORWIND,
'0e' => :SWORDSDANCE,
'0f' => :CUT,
'10' => :GUST,
'11' => :WINGATTACK,
'12' => :WHIRLWIND,
'13' => :FLY,
'14' => :BIND,
'15' => :SLAM,
'16' => :VINEWHIP,
'17' => :STOMP,
'18' => :DOUBLEKICK,
'19' => :MEGAKICK,
'1a' => :JUMPKICK,
'1b' => :ROLLINGKICK,
'1c' => :SANDATTACK,
'1d' => :HEADBUTT,
'1e' => :HORNATTACK,
'1f' => :FURYATTACK,
'20' => :HORNDRILL,
'21' => :TACKLE,
'22' => :BODYSLAM,
'23' => :WRAP,
'24' => :TAKEDOWN,
'25' => :THRASH,
'26' => :DOUBLEEDGE,
'27' => :TAILWHIP,
'28' => :POISONSTING,
'29' => :TWINEEDLE,
'2a' => :PINMISSILE,
'2b' => :LEER,
'2c' => :BITE,
'2d' => :GROWL,
'2e' => :ROAR,
'2f' => :SING,
'30' => :SUPERSONIC,
'31' => :SONICBOOM,
'32' => :DISABLE,
'33' => :ACID,
'34' => :EMBER,
'35' => :FLAMETHROWER,
'36' => :MIST,
'37' => :WATERGUN,
'38' => :HYDROPUMP,
'39' => :SURF,
'3a' => :ICEBEAM,
'3b' => :BLIZZARD,
'3c' => :PSYBEAM,
'3d' => :BUBBLEBEAM,
'3e' => :AURORABEAM,
'3f' => :HYPERBEAM,
'40' => :PECK,
'41' => :DRILLPECK,
'42' => :SUBMISSION,
'43' => :LOWKICK,
'44' => :COUNTER,
'45' => :SEISMICTOSS,
'46' => :STRENGTH,
'47' => :ABSORB,
'48' => :MEGADRAIN,
'49' => :LEECHSEED,
'4a' => :GROWTH,
'4b' => :RAZORLEAF,
'4c' => :SOLARBEAM,
'4d' => :POISONPOWDER,
'4e' => :STUNSPORE,
'4f' => :SLEEPPOWDER,
'50' => :PETALDANCE,
'51' => :STRINGSHOT,
'52' => :DRAGONRAGE,
'53' => :FIRESPIN,
'54' => :THUNDERSHOCK,
'55' => :THUNDERBOLT,
'56' => :THUNDERWAVE,
'57' => :THUNDER,
'58' => :ROCKTHROW,
'59' => :EARTHQUAKE,
'5a' => :FISSURE,
'5b' => :DIG,
'5c' => :TOXIC,
'5d' => :CONFUSION,
'5e' => :PSYCHIC,
'5f' => :HYPNOSIS,
'60' => :MEDITATE,
'61' => :AGILITY,
'62' => :QUICKATTACK,
'63' => :RAGE,
'64' => :TELEPORT,
'65' => :NIGHTSHADE,
'66' => :MIMIC,
'67' => :SCREECH,
'68' => :DOUBLETEAM,
'69' => :RECOVER,
'6a' => :HARDEN,
'6b' => :MINIMIZE,
'6c' => :SMOKESCREEN,
'6d' => :CONFUSERAY,
'6e' => :WITHDRAW,
'6f' => :DEFENSECURL,
'70' => :BARRIER,
'71' => :LIGHTSCREEN,
'72' => :HAZE,
'73' => :REFLECT,
'74' => :FOCUSENERGY,
'75' => :BIDE,
'76' => :METRONOME,
'77' => :MIRRORMOVE,
'78' => :SELFDESTRUCT,
'79' => :EGGBOMB,
'7a' => :LICK,
'7b' => :SMOG,
'7c' => :SLUDGE,
'7d' => :BONECLUB,
'7e' => :FIREBLAST,
'7f' => :WATERFALL,
'80' => :CLAMP,
'81' => :SWIFT,
'82' => :SKULLBASH,
'83' => :SPIKECANNON,
'84' => :CONSTRICT,
'85' => :AMNESIA,
'86' => :KINESIS,
'87' => :SOFTBOILED,
'88' => :HIGHJUMPKICK,
'89' => :GLARE,
'8a' => :DREAMEATER,
'8b' => :POISONGAS,
'8c' => :BARRAGE,
'8d' => :LEECHLIFE,
'8e' => :LOVELYKISS,
'8f' => :SKYATTACK,
'90' => :TRANSFORM,
'91' => :BUBBLE,
'92' => :DIZZYPUNCH,
'93' => :SPORE,
'94' => :FLASH,
'95' => :PSYWAVE,
'96' => :SPLASH,
'97' => :ACIDARMOR,
'98' => :CRABHAMMER,
'99' => :EXPLOSION,
'9a' => :FURYSWIPES,
'9b' => :BONEMERANG,
'9c' => :REST,
'9d' => :ROCKSLIDE,
'9e' => :HYPERFANG,
'9f' => :SHARPEN,
'a0' => :CONVERSION,
'a1' => :TRIATTACK,
'a2' => :SUPERFANG,
'a3' => :SLASH,
'a4' => :SUBSTITUTE
}
# This class handles the save file.
class Gen1Save
attr_accessor :filename
attr_accessor :box_offsets
attr_accessor :num_boxes
attr_accessor :ot_id_offset
def initialize(savefileName="rbsave.sa1")
if !FileTest.exist?("Gen 1 Save")
@filename = nil
else
if FileTest.directory?("Gen 1 Save")
if !FileTest.exist?("Gen 1 Save/" + savefileName)
@filename = nil
else
@filename = "Gen 1 Save/" + savefileName
@box_offsets = [0x4000, 0x4462, 0x48C4, 0x4D26, 0x5188, 0x55EA, 0x6000, 0x6462,
0x68C4, 0x6D26, 0x7188, 0x75EA]
@num_boxes = 12
@ot_id_offset = 0x2605
end
else
@filename = nil
end
end
end
# Getter for filename
def getSaveFileName
return self.filename
end
# Gets the Gen 1 player's OT name
def getSaveFileOTname
if !self.filename
return ""
else
keysArray = getArrayOfKeys(self.filename, 0x2598, 11)
charsArray = getArrayOfCharacters(keysArray, RBY_To_ASCII)
trainerName = ""
for i in 0...charsArray.index(NULL_TERMINATOR)
trainerName += charsArray[i]
end
return trainerName
end
end
# Gets the Gen 1 player's OT ID
def getSaveFileOTId
if !self.filename
return 0
else
return getBytesToInt16(self.filename, @ot_id_offset, 15)
end
end
# These two functions below will be used to get the Gen 1 player's current box.
# This will be used for mass transfer.
def getCurrentPCBoxIndex
if !self.filename
return 0
else
boxIndexKey = getSingleKeyInHex(self.filename, GEN1_CURRENT_BOX_OFFSET)
if BOXOFFSET_INDEX_TABLES.include?(boxIndexKey)
return BOXOFFSET_INDEX_TABLES[boxIndexKey]
else
return 0
end
end
end
def getPCBoxOffset(useCurrent=false,index=0)
if !self.filename
return 0
else
if useCurrent
return self.box_offsets[getCurrentPCBoxIndex]
else
return self.box_offsets[index]
end
end
end
def gen1ShinyCheck(dv_hash)
if !dv_hash.include?("dv_attack") && !dv_hash.include?("dv_defense") && !dv_hash.include?("dv_speed") && !dv_hash.include?("dv_special")
return false
end
# If the DVs (named IVs in modern gen games) are the following:
# Attack IV of 10,
# a Special IV of 10,
# a Speed IV of 10,
# and a particular Defense IV (2, 3, 6, 7, 10, 11, 14 or 15),
# the Pokemon is shiny.
return (dv_hash["dv_attack"] == 10) && (dv_hash["dv_special"] == 10) && (dv_hash["dv_speed"] == 10) && (dv_hash["dv_defense"] & 2)
end
# Reads a Pokemon from a box.
def getGen1PokemonDataStruct(boxoffset, position=1, scanForGlitched=false)
gen1poke = {}
species = getSingleKeyInHex(self.filename, boxoffset + (POKEMON_LIST_OFFSET * position), 1)
if HEX_TO_PBSPECIES.include?(species)
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)
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"])
else
if scanForGlitched
gen1poke["species"] = species
gen1poke["glitch"] = true
end
end
return gen1poke
end
def filterEmptySpots(arrayOfGen1RawData)
newGen1RawDataArray = []
for i in 0...arrayOfGen1RawData.length
if !arrayOfGen1RawData[i].empty?
newGen1RawDataArray.push(arrayOfGen1RawData[i])
end
end
return newGen1RawDataArray
end
# 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)
pokemon = HEX_TO_PBSPECIES[speciesArray["species"]] # Get the PBSpecies thing
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=0
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
if rand(50) == 1
pokemon.setAbility(2) # Give hidden ability
else
pokemon.setAbility(0)
end
# 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
#-------------------------------------------------------------------------------
# This is a subclass of Gen1Save that reads Japanese save files. (BETA)
#-------------------------------------------------------------------------------
class Gen1SaveJapanese < Gen1Save
def initialize(savefileName="rbsavejp.sa1")
super(savefileName)
@box_offsets = [0x4000, 0x4566, 0x4ACC, 0x5032, 0x6000, 0x6566, 0x6ACC, 0x7032]
@num_boxes = 8
@ot_id_offset = 0x25FB
end
# Gets the Gen 1 player's OT name.
# Katakana/Hiragana will be converted.
def getSaveFileOTname
if !self.filename
return ""
else
keysArray = getArrayOfKeys(self.filename, 0x2598, 11)
charsArray = getArrayOfCharacters(keysArray, RBY_TO_CONVERTED_KANA)
trainerName = ""
for i in 0...charsArray.index(NULL_TERMINATOR)
if i > 0
trainerName += charsArray[i].downcase
else
trainerName += charsArray[i]
end
end
return trainerName
end
end
end
#==============================================================================#
# i rly cant be bothered so have a quagsire edit: cant do quag have this crap
# instead
=begin
_._ _,._
_.' `. ' .' _`.
,"""/`""-.-.,/. ` V'\-,`.,--/"""."-..
,' `...,' . ,\-----._| `. / \
`. .` -'`"" .._ :> `-' `.
,' ,-. _,.-'| `..___ ,' |'-..__ .._ L
. \_ -' `-' .. `.-' `.`-.'_ .|
| ,',-,--.. ,--../ `. .-. , `-. ``.
`.,' , | | `. /'/,,.\/ | \| |
` `---' `j . \ . ' j
,__`" ,'|`'\_/`.'\' |\-'-, _,.
.--...`-. `-`. / '- .. _, /\ ,' .--"' ,'".
_'-""- -- _`'-.../ __ '.'`-^,_`-""""---....__ ' _,-`
_.----` _..--.' | "`-..-" __|'"' .""-. ""'--.._
/ ' / , _.+-.' ||._' """". . ` .__\
`--- / / / j' _/|..` -. `-`\ \ \ \ `. \ `-..
," _.-' / /` ./ /`_|_,-" ','| `. | -'`._, L \ . `. |
`"' / / / ,__...-----| _., ,' `|----.._`-.|' |. .` .. .
/ '| /.,/ \--.._ `-,' , . '`.' __,., ' ''``._ \ \`,'
/_,'--- , \`._,-` \ // / . \ `._, -`, / / _ | `-L -
/ `. , ..._ ' `_/ '| |\ `._' '-.' `.,' |
' / / .. `. `./ | ; `.' ,"" ,. `. \ |
`. ,' ,' | |\ | " | ,'\ | \ ` ,L
/|`. / ' | `-| ' /`-' | L `._/ \
/ | .`| | . `._.' `.__,' . | | (`
'-""-'_| `. `.__,._____ . _, ____ ,- j ".-'"'
\ `-. \/. `"--.._ _,.---'""\/ "_,.' /-'
) `-._ '-. `--" _.-'.-"" `.
./ `,. `".._________...""_.-"`. _j
/_\.__,"". ,.' "`-...________.---" .". ,. / \
\_/"""-' `-'--(_,`"`-
=end
#===============================================================================
# ** Scene_iPod (Basis for Poke Depot UI, used in Essentials)
# ** Created by xLeD (Scene_Jukebox)
# ** Modified by Harshboy
#-------------------------------------------------------------------------------
# This class performs menu screen processing.
#-------------------------------------------------------------------------------
# Adapted by rigbycwts for use with the Poketransfer Utilities for Essentials.
#===============================================================================
class PokeDepot_Scene
#-----------------------------------------------------------------------------
# * Object Initialization
# menu_index : command cursor's initial position
#-----------------------------------------------------------------------------
def initialize(menu_index = 0)
@menu_index = menu_index
end
#-----------------------------------------------------------------------------
# * Main Processing
#-----------------------------------------------------------------------------
def main
# Make command window
fadein = true
# Makes the text window
@sprites={}
@viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
@viewport.z=99999
@sprites["background"] = IconSprite.new(0,0)
@sprites["background"].setBitmap("Graphics/Pictures/PokeDepot/Choices")
@sprites["background"].z=255
@choices=[
_INTL("Start"),
# _INTL("Gen 2 Save Files"),
_INTL("Exit")
]
@sprites["header"]=Window_UnformattedTextPokemon.newWithSize(_INTL("Pokemon Depot"),
2,-18,200,64,@viewport)
@sprites["header"].baseColor=Color.new(248,248,248)
@sprites["header"].shadowColor=Color.new(0,0,0)
@sprites["header"].windowskin=nil
@sprites["command_window"] = Window_CommandPokemon.new(@choices,324)
@sprites["command_window"].windowskin=nil
@sprites["command_window"].index = @menu_index
@sprites["command_window"].height = 224
@sprites["command_window"].width = 324
@sprites["command_window"].x = 94
@sprites["command_window"].y = 92
@sprites["command_window"].z = 256
@custom = false
@generation = 0
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepares for transition
Graphics.freeze
# Disposes the windows
pbDisposeSpriteHash(@sprites)
@viewport.dispose
end
#-----------------------------------------------------------------------------
# * Frame Update
#-----------------------------------------------------------------------------
def update
# Update windows
pbUpdateSpriteHash(@sprites)
if @generation > 0
updateCustom
else
update_command
end
return
end
#-----------------------------------------------------------------------------
# * Frame Update (when command window is active)
#-----------------------------------------------------------------------------
def updateCustom
if Input.trigger?(Input::B)
@sprites["command_window"].commands=@choices
@sprites["command_window"].index=2
@custom = false
@generation = 0
return
end
if Input.trigger?(Input::C)
case @generation
when 1 # Pokemon Red, Blue, and Yellow
savefileName = @sprites["command_window"].commands[@sprites["command_window"].index].to_s
savefileObject = isJapanese("Gen 1 Save/" + savefileName, JP_OFFSET_CHECKER) ? Gen1SaveJapanese.new(savefileName) : Gen1Save.new(savefileName)
if pbConfirmMessage(_INTL("Load this Gen 1 save file?"))
if savefileName.is_a?(Gen1SaveJapanese)
pbMessage(_INTL("This is a Japanese save. Probably won't work."))
end
$scene = PokeDepot_BoxSelection.new(savefileObject)
end
end
end
end
def update_command
# If B button was pressed
if Input.trigger?(Input::B)
pbPlayCancelSE()
# Switch to map screen
$scene = Scene_Map.new
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by command window cursor position
case @sprites["command_window"].index
when 0 # Gen 1 saves
files=[]
Dir.chdir("Gen 1 Save/"){
Dir.glob("*.sav"){|f| files.push(f) }
Dir.glob("*.SAV"){|f| files.push(f) }
Dir.glob("*.sa1"){|f| files.push(f) }
Dir.glob("*.SA1"){|f| files.push(f) }
Dir.glob("*.sa2"){|f| files.push(f) }
Dir.glob("*.SA2"){|f| files.push(f) }
Dir.glob("*.sa3"){|f| files.push(f) }
Dir.glob("*.SA3"){|f| files.push(f) }
Dir.glob("*.sa4"){|f| files.push(f) }
Dir.glob("*.SA4"){|f| files.push(f) }
}
@sprites["command_window"].commands=files
@sprites["command_window"].index=0
@custom = true
@generation = 1
# when 1 # Gen 2 saves
# pbMessage(_INTL("This feature is coming soon."))
when 1 # Exit
pbPlayDecisionSE()
$scene = Scene_Map.new
end
return
end
end
end
# quack
=begin
___
,-"" `.
,' _ e )`-._
/ ,' `-._<.===-'
/ /
/ ;
_.--.__ / ;
(`._ _.-"" "--' |
<_ `-"" \
<`- :
(__ <__. ;
`-. '-.__. _.' /
\ `-.__,-' _,'
`._ , /__,-'
""._\__,'< <____
| | `----.`.
| | \ `.
; |___ \-``
\ --<
`.`.<
`-'
=end
#===============================================================================
# ** Scene_iPod (Basis for Poke Depot UI, used in Essentials)
# ** Created by xLeD (Scene_Jukebox)
# ** Modified by Harshboy
#-------------------------------------------------------------------------------
# This class performs menu screen processing.
#-------------------------------------------------------------------------------
# Adapted by rigbycwts for use with the Poketransfer Utilities for Essentials.
#===============================================================================
class PokeDepot_BoxSelection
#-----------------------------------------------------------------------------
# * Object Initialization
# savefile : the emulator save file to load
# menu_index : command cursor's initial position
#-----------------------------------------------------------------------------
def initialize(savefile, menu_index = 0)
@savefile = savefile
@menu_index = menu_index
end
#-----------------------------------------------------------------------------
# * Main Processing
#-----------------------------------------------------------------------------
def main
# Make command window
fadein = true
# Makes the text window
@sprites={}
@viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
@viewport.z=99999
@sprites["background"] = IconSprite.new(0,0)
@sprites["background"].setBitmap("Graphics/Pictures/PokeDepot/bg.png")
@sprites["background"].z=255
if @savefile.is_a?(Gen1Save)
@numBoxes = @savefile.num_boxes
else
@numBoxes = 14
end
@choices=[]
for i in 0...@numBoxes
@choices.push(_INTL("Box {1}", i+1))
end
@choices.push(_INTL("Exit"))
@sprites["header"]=Window_UnformattedTextPokemon.newWithSize(_INTL("Selection"),
2,-18,200,64,@viewport)
@sprites["header"].baseColor=Color.new(248,248,248)
@sprites["header"].shadowColor=Color.new(0,0,0)
@sprites["header"].windowskin=nil
@sprites["command_window"] = Window_CommandPokemon.new(@choices,324)
@sprites["command_window"].windowskin=nil
@sprites["command_window"].index = @menu_index
@sprites["command_window"].height = 224
@sprites["command_window"].width = 324
@sprites["command_window"].x = 94
@sprites["command_window"].y = 92
@sprites["command_window"].z = 256
@sprites["trinfo_header"]=Window_UnformattedTextPokemon.newWithSize(_INTL("TRAINER INFO"),
94,300,200,64,@viewport)
@sprites["trinfo_header"].baseColor=Color.new(248,248,248)
@sprites["trinfo_header"].shadowColor=Color.new(0,0,0)
@sprites["trinfo_header"].windowskin=nil
@sprites["trinfo_info"]=Window_UnformattedTextPokemon.newWithSize(_INTL("{1} / {2}",
@savefile.getSaveFileOTname, @savefile.getSaveFileOTId.to_s),
94,330,200,64,@viewport)
@sprites["trinfo_info"].baseColor=Color.new(248,248,248)
@sprites["trinfo_info"].shadowColor=Color.new(0,0,0)
@sprites["trinfo_info"].windowskin=nil
@custom = false
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepares for transition
Graphics.freeze
# Disposes the windows
pbDisposeSpriteHash(@sprites)
@viewport.dispose
end
#-----------------------------------------------------------------------------
# * Frame Update
#-----------------------------------------------------------------------------
def update
# Update windows
pbUpdateSpriteHash(@sprites)
update_command
return
end
#-----------------------------------------------------------------------------
# * Frame Update (when command window is active)
#-----------------------------------------------------------------------------
def update_command
# If B button was pressed
if Input.trigger?(Input::B)
pbPlayCancelSE()
# Switch to map screen
$scene = PokeDepot_Scene.new
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by command window cursor position
case @sprites["command_window"].index
when @numBoxes # Exit
pbPlayDecisionSE()
$scene = PokeDepot_Scene.new
else
currentBox = @sprites["command_window"].index
if pbConfirmMessage(_INTL("Load this?"))
pbPlayDecisionSE()
pbMessage(_INTL("Box {1} will be loaded.", (currentBox+1).to_s))
$scene = PokeDepot_BoxMigrate.new(@savefile, currentBox)
end
end
return
end
end
end
#RIP pogchamp
=begin
░░░░░▒░░▄██▄░▒░░░░░░
░░░▄██████████▄▒▒░░░
░▒▄████████████▓▓▒░░
▓███▓▓█████▀▀████▒░░
▄███████▀▀▒░░░░▀█▒░░
████████▄░░░░░░░▀▄░░
▀██████▀░░▄▀▀▄░░▄█▒░
░█████▀░░░░▄▄░░▒▄▀░░
░█▒▒██░░░░▀▄█░░▒▄█░░
░█░▓▒█▄░░░░░░░░░▒▓░░
░▀▄░░▀▀░▒░░░░░▄▄░▒░░ <== is that just me or is this kinda green (it might be mild colorblindness)
░░█▒▒▒▒▒▒▒▒▒░░░░▒░░░
░░░▓▒▒▒▒▒░▒▒▄██▀░░░░
░░░░▓▒▒▒░▒▒░▓▀▀▒░░░░
░░░░░▓▓▒▒░▒░░▓▓░░░░░
░░░░░░░▒▒▒▒▒▒▒░░░░░░
=end
def pbSaveAfterMigrate(consoleSavefile)
fangameName = "Collective/Mercantile"
oldscene=$scene
$scene=nil
if consoleSavefile.is_a?(Gen1Save)
pbMessage(_INTL("Saving data from Pokemon {1} and Pokemon Red/Blue/Yellow...", fangameName))
else
pbMessage(_INTL("Saving data from Pokemon {1}...", fangameName))
end
return if !$Trainer
$game_system.save_count+=1
#$game_system.last_saved=retTimeFormatOne
if safeExists?(RTP.getSaveFileName("Game.rxdata"))
File.open(RTP.getSaveFileName("Game.rxdata"), 'rb') {|r|
File.open(RTP.getSaveFileName("Game.rxdata.bak"), 'wb') {|w|
while s = r.read(4096)
w.write s
end
}
}
end
if pbSave
pbMessage(_INTL("\\se[]The game was saved.\\se[save]\\wtnp[30]"))
else
pbMessage(_INTL("\\se[]Save failed.\\wtnp[30]"))
end
$scene=oldscene
end
class PokeTransportPokemonIcon < IconSprite
def initialize(pokemon,viewport=nil)
super(0,0,viewport)
@release=Interpolator.new
@startRelease=false
@pokemon=pokemon
if pokemon
self.setBitmap(pbPokemonIconFile(pokemon))
else
self.setBitmap(pbPokemonIconFile(nil))
end
self.src_rect=Rect.new(0,0,64,64)
end
def release
self.ox=32
self.oy=32
self.x+=32
self.y+=32
@release.tween(self,[
[Interpolator::ZOOM_X,0],
[Interpolator::ZOOM_Y,0],
[Interpolator::OPACITY,0]
],100)
@startRelease=true
end
def releasing?
return @release.tweening?
end
def update
super
@release.update
self.color=Color.new(0,0,0,0)
dispose if @startRelease && !releasing?
end
end
#===============================================================================
# ** Scene_iPod (Basis for Poke Depot UI, used in Essentials)
# ** Created by xLeD (Scene_Jukebox)
# ** Modified by Harshboy
#-------------------------------------------------------------------------------
# This class performs menu screen processing.
#-------------------------------------------------------------------------------
# Adapted by rigbycwts for use with the Poketransfer Utilities for Essentials.
#===============================================================================
class PokeDepot_BoxMigrate
#-----------------------------------------------------------------------------
# * Object Initialization
# savefile : the emulator save file to load
# boxIndex : the index from 0 to number of boxes-1
# menu_index : command cursor's initial position
#-----------------------------------------------------------------------------
def initialize(savefile, boxIndex = 0, menu_index = 0)
@savefile = savefile
@boxIndex = boxIndex
@menu_index = menu_index
end
#-----------------------------------------------------------------------------
# * Main Processing
#-----------------------------------------------------------------------------
def main
# Make command window
fadein = true
# Makes the text window
@sprites={}
@viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
@viewport.z=99999
@sprites["background"] = IconSprite.new(0,0)
@sprites["background"].setBitmap("Graphics/Pictures/PokeDepot/bg.png")
@sprites["background"].z=255
@choices=[
_INTL("Migrate"),
_INTL("Cancel")
]
@sprites["header"]=Window_UnformattedTextPokemon.newWithSize(_INTL("Current Selection"),
2,-18,200,64,@viewport)
@sprites["header"].baseColor=Color.new(248,248,248)
@sprites["header"].shadowColor=Color.new(0,0,0)
@sprites["header"].windowskin=nil
@sprites["command_window"] = Window_CommandPokemon.new(@choices,324)
@sprites["command_window"].windowskin=nil
@sprites["command_window"].index = @menu_index
@sprites["command_window"].height = 224
@sprites["command_window"].width = 324
@sprites["command_window"].x = 94
@sprites["command_window"].y = 92
@sprites["command_window"].z = 256
@sprites["trinfo_header"]=Window_UnformattedTextPokemon.newWithSize(_INTL("TRAINER INFO"),
94,300,200,64,@viewport)
@sprites["trinfo_header"].baseColor=Color.new(248,248,248)
@sprites["trinfo_header"].shadowColor=Color.new(0,0,0)
@sprites["trinfo_header"].windowskin=nil
@sprites["trinfo_info"]=Window_UnformattedTextPokemon.newWithSize(_INTL("{1} / {2}",
@savefile.getSaveFileOTname, @savefile.getSaveFileOTId.to_s),
94,330,200,64,@viewport)
@sprites["trinfo_info"].baseColor=Color.new(248,248,248)
@sprites["trinfo_info"].shadowColor=Color.new(0,0,0)
@sprites["trinfo_info"].windowskin=nil
@custom = false
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepares for transition
Graphics.freeze
# Disposes the windows
pbDisposeSpriteHash(@sprites)
@viewport.dispose
end
#-----------------------------------------------------------------------------
# * Frame Update
#-----------------------------------------------------------------------------
def update
# Update windows
pbUpdateSpriteHash(@sprites)
update_command
return
end
#-----------------------------------------------------------------------------
# * Frame Update (when command window is active)
#-----------------------------------------------------------------------------
def update_command
# If B button was pressed
if Input.trigger?(Input::B)
pbPlayCancelSE()
# Switch to map screen
$scene = PokeDepot_BoxSelection.new(@savefile)
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by command window cursor position
case @sprites["command_window"].index
when 1 # Exit
pbPlayDecisionSE()
$scene = PokeDepot_BoxSelection.new(@savefile)
else
pbPlayDecisionSE()
if pbConfirmMessage(_INTL("Migrate all Pokemon in this Box?"))
if pbBatteryLow?
pbMessage(_INTL("WARNING!"))
pbMessage(_INTL("Both data on this fangame and in the emulator save will be overwritten after transfer."))
pbMessage(_INTL("In the event of a power failure, the save data of either game will be corrupted."))
if pbConfirmMessage(_INTL("Are you sure you want to proceed?"))
migrateWholeBox
pbSaveAfterMigrate(@savefile)
$scene = PokeDepot_BoxSelection.new(@savefile)
end
else
migrateWholeBox
pbSaveAfterMigrate(@savefile)
$scene = PokeDepot_BoxSelection.new(@savefile)
end
end
end
return
end
end
#-----------------------------------------------------------------------------
# * Migrate Whole Pokemon Box
#-----------------------------------------------------------------------------
def migrateWholeBox
boxIndex = @boxIndex
boxOffset = @savefile.box_offsets[boxIndex] if @savefile.is_a?(Gen1Save)
failed = false
unfilteredRawData = []
for i in 1..20
unfilteredRawData.push(@savefile.getGen1PokemonDataStruct(boxOffset + (33 * (i-1))))
end
filteredRawData = @savefile.filterEmptySpots(unfilteredRawData)
if filteredRawData.length > 0
for j in 0...filteredRawData.length
if @savefile.convertToGen7Pokemon(filteredRawData[j]) # Transfer failed
failed = false
else
if j==0
pbMessage("Box migration failed!") if !failed
else
pbMessage("Some Pokemon cannot be transferred!") if !failed
end
pbMessage("Please check if your PC Boxes are full!") if !failed
failed = true
end
end
pbMessage("Box migration complete.") if !failed
else
pbMessage("Cannot migrate this box, it's empty.")
$scene = PokeDepot_BoxSelection.new(@savefile)
end
end
end