private void SetFinalPokemon(int index) { uint gainedExp = GetGainedExperience(index); GBAPokemon original = originalPokemon[index]; GBAPokemon output = (GBAPokemon)original.Clone(); output.PokeContainer = this; output.Experience += gainedExp; output.RecalculateStats(); ushort[] moves = PokemonDatabase.GetMovesLearnedAtLevelRange(original, (byte)(original.Level + 1), output.Level); // Teach the Pokemon all the new moves // Push the moves up just like the game does it to make room for the new move. Even HMs can be removed. foreach (ushort moveID in moves) { if (!PokemonDatabase.PokemonHasMove(output, moveID)) { if (output.NumMoves < 4) { output.SetMoveAt(output.NumMoves, new Move(moveID)); } else { for (int i = 0; i < 3; i++) { output.SetMoveAt(i, output.GetMoveAt(i + 1)); } output.SetMoveAt(3, new Move(moveID)); } } } finalPokemon[index] = output; }
public GBAPokeParty(IPokePC pokePC, byte[] data) { this.pokePC = pokePC; this.raw = data; this.party = new List <IPokemon>(); uint teamSize = LittleEndian.ToUInt32(data, 0); for (int i = 0; i < teamSize && i < 6; i++) { GBAPokemon pkm = new GBAPokemon(ByteHelper.SubByteArray(4 + 100 * i, data, 100)); if (pkm.DexID != 0 && pkm.Checksum != 0 && pkm.Experience != 0) { if (pkm.IsValid) { party.Add(pkm); } else { party.Add(GBAPokemon.CreateInvalidPokemon(pkm)); } party[party.Count - 1].PokeContainer = this; } else { break; } } }
public SharedSecretBase(byte[] data, SecretBaseManager secretBaseManager) { if (data.Length != 160) { throw new Exception("Shared Secret Base must be 160 bytes in length"); } this.secretBaseManager = secretBaseManager; this.raw = data; this.placedDecorations = new List <PlacedDecoration>(); this.pokemonTeam = new List <GBAPokemon>(); for (int i = 0; i < 16; i++) { byte id = raw[0x12 + i]; if (id != 0) { byte x = ByteHelper.BitsToByte(raw, 0x22 + i, 4, 4); byte y = ByteHelper.BitsToByte(raw, 0x22 + i, 0, 4); placedDecorations.Add(new PlacedDecoration(id, x, y)); } } for (int i = 0; i < 6; i++) { ushort species = LittleEndian.ToUInt16(raw, 0x7C + i * 2); if (species != 0 && PokemonDatabase.GetPokemonFromID(species) != null) { uint personality = LittleEndian.ToUInt32(raw, 0x34 + i * 4); ushort[] moves = new ushort[4]; for (int j = 0; j < 4; j++) { moves[j] = LittleEndian.ToUInt16(raw, 0x4C + j * 2 + i * 8); } ushort heldItem = LittleEndian.ToUInt16(raw, 0x88 + i * 2); byte level = raw[0x94 + i]; byte unknown = raw[0x9A + i]; GBAPokemon pokemon = new GBAPokemon(); pokemon.SpeciesID = species; pokemon.Personality = personality; pokemon.TrainerID = TrainerID; pokemon.SecretID = SecretID; pokemon.Nickname = pokemon.PokemonData.Name.ToUpper(); for (int j = 0; j < 4; j++) { pokemon.SetMoveAt(j, new Move(moves[j])); } pokemon.HeldItemID = heldItem; pokemon.Language = Languages.English; pokemon.Experience = PokemonDatabase.GetExperienceFromLevel(pokemon.PokemonData.ExperienceGroup, level); pokemon.Level = level; pokemon.RecalculateStats(); pokemonTeam.Add(pokemon); } } }
public ManagerPokeBox(IPokePC pokePC, uint version, uint boxNumber, string name, bool usingCustom, string wallpaperName, byte[] storage) { this.pokePC = pokePC; this.boxNumber = boxNumber; this.name = name; this.usingCustomWallpaper = usingCustom; this.wallpaperName = wallpaperName; this.pokemonList = new GBAPokemon[30]; if (version <= 1) { for (int i = 0; i < 30; i++) { GBAPokemon pkm = new GBAPokemon(ByteHelper.SubByteArray(i * 80, storage, 80)); if (!ByteHelper.CompareBytes(0, pkm.Raw)) { if (pkm.IsValid) { pokemonList[i] = pkm; } else { pokemonList[i] = GBAPokemon.CreateInvalidPokemon(pkm); } pokemonList[i].PokeContainer = this; } else { pokemonList[i] = null; } } } else if (version == 2) { for (int i = 0; i < 30; i++) { GBAPokemon pkm = new GBAPokemon(ByteHelper.SubByteArray(i * 100, storage, 80)); if (!ByteHelper.CompareBytes(0, pkm.Raw)) { if (pkm.IsValid) { pokemonList[i] = pkm; pkm.DeoxysForm = storage[i * 100 + 80]; } else { pokemonList[i] = GBAPokemon.CreateInvalidPokemon(pkm); } pokemonList[i].PokeContainer = this; } else { pokemonList[i] = null; } } } }
public byte[] GetFinalData() { for (int i = 0; i < 16; i++) { if (i < placedDecorations.Count) { raw[0x12 + i] = placedDecorations[i].ID; byte xy = 0; xy = ByteHelper.SetBits(xy, 4, ByteHelper.GetBits(placedDecorations[i].X, 0, 4)); xy = ByteHelper.SetBits(xy, 0, ByteHelper.GetBits(placedDecorations[i].Y, 0, 4)); raw[0x22 + i] = xy; } else { raw[0x12 + i] = 0; raw[0x22 + i] = 0; } } for (int i = 0; i < 6; i++) { if (i < pokemonTeam.Count) { GBAPokemon pokemon = pokemonTeam[i]; LittleEndian.WriteUInt32(pokemon.Personality, raw, 0x34 + i * 4); LittleEndian.WriteUInt16(pokemon.SpeciesID, raw, 0x7C + i * 2); for (int j = 0; j < 4; j++) { LittleEndian.WriteUInt16(pokemon.GetMoveIDAt(j), raw, 0x4C + j * 2 + i * 8); } LittleEndian.WriteUInt16(pokemon.HeldItemID, raw, 0x88 + i * 2); raw[0x94 + i] = pokemon.Level; } else { LittleEndian.WriteUInt32(0, raw, 0x34 + i * 4); LittleEndian.WriteUInt16(0, raw, 0x7C + i * 2); for (int j = 0; j < 4; j++) { LittleEndian.WriteUInt16(0, raw, 0x4C + j * 2 + i * 8); } LittleEndian.WriteUInt16(0, raw, 0x88 + i * 2); raw[0x94 + i] = 0; } } return(raw); }
public PokemonStorage(byte[] data, PokemonFormatTypes formatType, IPokeContainer container) { int formatSize = 0; this.formatType = formatType; if (formatType == PokemonFormatTypes.Gen3GBA) { formatSize = 80; if (data.Length % formatSize != 0) { throw new Exception("Pokemon Storage data size for GBA games should be divisible by 80"); } this.size = (uint)(data.Length / formatSize); for (int i = 0; i < size; i++) { GBAPokemon pkm = new GBAPokemon(ByteHelper.SubByteArray(i * formatSize, data, formatSize)); if (pkm.DexID != 0 && pkm.Checksum != 0 && pkm.Experience != 0) { if (pkm.IsValid) { Add(pkm); } else { Add(GBAPokemon.CreateInvalidPokemon(pkm)); } this[Count - 1].PokeContainer = container; } else { Add(null); } } } else if (formatType == PokemonFormatTypes.Gen3PokemonBox) { formatSize = 84; if (data.Length % formatSize != 0) { throw new Exception("Pokemon Storage data size for Pokemon Box games should be divisible by 84"); } this.size = (uint)(data.Length / formatSize); for (int i = 0; i < size; i++) { BoxPokemon pkm = new BoxPokemon(ByteHelper.SubByteArray(i * formatSize, data, formatSize)); if (pkm.DexID != 0 && pkm.Checksum != 0 && pkm.Experience != 0) { if (pkm.IsValid) { Add(pkm); } else { Add(BoxPokemon.CreateInvalidPokemon(pkm)); } this[Count - 1].PokeContainer = container; } else { Add(null); } } } else if (formatType == PokemonFormatTypes.Gen3Colosseum) { formatSize = 312; if (data.Length % formatSize != 0) { throw new Exception("Pokemon Storage data size for Colosseum should be divisible by 312"); } this.size = (uint)(data.Length / formatSize); for (int i = 0; i < size; i++) { ColosseumPokemon colopkm = new ColosseumPokemon(ByteHelper.SubByteArray(i * formatSize, data, formatSize)); if (colopkm.DexID != 0 && colopkm.Experience != 0) { if (colopkm.IsValid) { Add(colopkm); } else { Add(ColosseumPokemon.CreateInvalidPokemon(colopkm)); } this[Count - 1].PokeContainer = container; } else { Add(null); } } } else if (formatType == PokemonFormatTypes.Gen3XD) { formatSize = 196; if (data.Length % formatSize != 0) { throw new Exception("Pokemon Storage data size for XD should be divisible by 196"); } this.size = (uint)(data.Length / formatSize); for (int i = 0; i < size; i++) { XDPokemon xdpkm = new XDPokemon(ByteHelper.SubByteArray(i * formatSize, data, formatSize)); if (xdpkm.DexID != 0 && xdpkm.Experience != 0) { if (xdpkm.IsValid) { Add(xdpkm); } else { Add(XDPokemon.CreateInvalidPokemon(xdpkm)); } this[Count - 1].PokeContainer = container; } else { Add(null); } } } }
public GBADaycare(IPokePC pokePC, byte[] data, GameCodes gameCode) { this.gameCode = gameCode; this.pokePC = pokePC; this.raw = data; if (gameCode == GameCodes.FireRedLeafGreen) { originalPokemon = new GBAPokemon[3]; finalPokemon = new GBAPokemon[3]; GBAPokemon pkm = new GBAPokemon(ByteHelper.SubByteArray(0, raw, 80)); if (pkm.DexID != 0 && pkm.Checksum != 0 && pkm.Experience != 0) { if (pkm.IsValid) { originalPokemon[0] = pkm; } else { originalPokemon[0] = GBAPokemon.CreateInvalidPokemon(pkm); } SetFinalPokemon(0); } pkm = new GBAPokemon(ByteHelper.SubByteArray(140, raw, 80)); if (pkm.DexID != 0 && pkm.Checksum != 0 && pkm.Experience != 0) { if (pkm.IsValid) { originalPokemon[1] = pkm; } else { originalPokemon[1] = GBAPokemon.CreateInvalidPokemon(pkm); } SetFinalPokemon(1); } pkm = new GBAPokemon(ByteHelper.SubByteArray(3352, raw, 80)); if (pkm.DexID != 0 && pkm.Checksum != 0 && pkm.Experience != 0) { if (pkm.IsValid) { originalPokemon[2] = pkm; } else { originalPokemon[2] = GBAPokemon.CreateInvalidPokemon(pkm); } SetFinalPokemon(2); } } else if (gameCode == GameCodes.Emerald) { originalPokemon = new GBAPokemon[2]; finalPokemon = new GBAPokemon[2]; GBAPokemon pkm = new GBAPokemon(ByteHelper.SubByteArray(0, raw, 80)); if (pkm.DexID != 0 && pkm.Checksum != 0 && pkm.Experience != 0) { if (pkm.IsValid) { originalPokemon[0] = pkm; } else { originalPokemon[0] = GBAPokemon.CreateInvalidPokemon(pkm); } SetFinalPokemon(0); } pkm = new GBAPokemon(ByteHelper.SubByteArray(140, raw, 80)); if (pkm.DexID != 0 && pkm.Checksum != 0 && pkm.Experience != 0) { if (pkm.IsValid) { originalPokemon[1] = pkm; } else { originalPokemon[1] = GBAPokemon.CreateInvalidPokemon(pkm); } SetFinalPokemon(1); } } else if (gameCode == GameCodes.RubySapphire) { originalPokemon = new GBAPokemon[2]; finalPokemon = new GBAPokemon[2]; GBAPokemon pkm = new GBAPokemon(ByteHelper.SubByteArray(0, raw, 80)); if (pkm.DexID != 0 && pkm.Checksum != 0 && pkm.Experience != 0) { if (pkm.IsValid) { originalPokemon[0] = pkm; } else { originalPokemon[0] = GBAPokemon.CreateInvalidPokemon(pkm); } SetFinalPokemon(0); } pkm = new GBAPokemon(ByteHelper.SubByteArray(80, raw, 80)); if (pkm.DexID != 0 && pkm.Checksum != 0 && pkm.Experience != 0) { if (pkm.IsValid) { originalPokemon[1] = pkm; } else { originalPokemon[1] = GBAPokemon.CreateInvalidPokemon(pkm); } SetFinalPokemon(1); } } }
private void GeneratePID(GBAPokemon pkm, Random random) { PokemonData pokemonData = PokemonDatabase.GetPokemonFromDexID(DexID); byte genderByte = pokemonData.GenderRatio; BitArray bitsID = ByteHelper.GetBits((ushort)(pkm.TrainerID ^ pkm.SecretID)); BitArray bitsPID1 = new BitArray(16); BitArray bitsPID2 = new BitArray(16); uint pid = 0; int tryCount = 0; while (true) { if (IsShiny.HasValue && !IsEgg) { if (IsShiny.Value) { for (int i = 0; i < 3; i++) { bitsPID1[i] = random.Next(2) == 1; bitsPID2[i] = random.Next(2) == 1; } for (int i = 3; i < 16; i++) { bool bit = random.Next(2) == 1; bitsPID1[i] = (bitsID[i] ? !bit : bit); bitsPID2[i] = bit; } pid = 0; pid = ByteHelper.SetBits(pid, 16, bitsPID1); pid = ByteHelper.SetBits(pid, 0, bitsPID2); pkm.Personality = pid; } else { // The chances of this are astronamically low so we can be lazy and not use an algorithm while (pkm.IsShiny) { pkm.Personality = (uint)random.Next(); } } } else { pkm.Personality = (uint)random.Next(); } if ((!Gender.HasValue || pkm.Gender == Gender || genderByte == 255 || genderByte == 254 || genderByte == 0) && (!NatureID.HasValue || pkm.NatureID == NatureID)) { break; } tryCount++; // Let's give up (I haven't done the math to see if it's always possible to get all 3 combinations. Plus RNG is a bitch so... we need a failsafe) if (tryCount > 5000) { break; } } }
public override void GenerateReward(IGameSave gameSave) { Random random = new Random((int)DateTime.Now.Ticks); PokemonData pokemonData = PokemonDatabase.GetPokemonFromDexID(DexID); GBAPokemon pkm = new GBAPokemon(); pkm.DexID = DexID; pkm.Personality = (Personality.HasValue ? Personality.Value : (uint)random.Next()); pkm.Experience = PokemonDatabase.GetExperienceFromLevel(pokemonData.ExperienceGroup, (IsEgg ? (byte)5 : Level)); pkm.IsSecondAbility2 = (IsSecondAbility.HasValue ? IsSecondAbility.Value : (!pokemonData.CanOnlyHaveFirstAbility && random.Next(2) == 1)); pkm.Nickname = (Nickname != null ? Nickname : pokemonData.Name.ToUpper()); pkm.BallCaughtID = 4; pkm.MetLocationID = 255; if (DexID == 151 || DexID == 386) { pkm.IsFatefulEncounter = true; } pkm.LevelMet = (IsEgg ? (byte)0 : Level); pkm.Language = Languages.English; pkm.Friendship = (byte)(IsEgg ? 10 : 70); // Ownership pkm.TrainerName = (TrainerName != null ? TrainerName : PokeManager.ManagerGameSave.TrainerName); pkm.TrainerGender = (TrainerGender.HasValue ? TrainerGender.Value : PokeManager.ManagerGameSave.TrainerGender); pkm.TrainerID = (TrainerID.HasValue ? TrainerID.Value : PokeManager.ManagerGameSave.TrainerID); pkm.SecretID = (SecretID.HasValue ? SecretID.Value : PokeManager.ManagerGameSave.SecretID); if (TrainerGender.HasValue && TrainerGender.Value == Genders.Genderless) { pkm.TrainerGender = (random.Next(2) == 1 ? Genders.Female : Genders.Male); } if (!Personality.HasValue) { GeneratePID(pkm, random); } if (HeldItem != null) { pkm.HeldItemID = HeldItem[random.Next(HeldItem.Length)]; } if (Conditions != null) { pkm.Coolness = Conditions[0]; pkm.Beauty = Conditions[1]; pkm.Cuteness = Conditions[2]; pkm.Smartness = Conditions[3]; pkm.Toughness = Conditions[4]; pkm.Feel = Conditions[5]; } pkm.HPIV = (IVs != null ? IVs[0] : (byte)random.Next(32)); pkm.AttackIV = (IVs != null ? IVs[1] : (byte)random.Next(32)); pkm.DefenseIV = (IVs != null ? IVs[2] : (byte)random.Next(32)); pkm.SpAttackIV = (IVs != null ? IVs[3] : (byte)random.Next(32)); pkm.SpDefenseIV = (IVs != null ? IVs[4] : (byte)random.Next(32)); pkm.SpeedIV = (IVs != null ? IVs[5] : (byte)random.Next(32)); if (HiddenPowerDamage.HasValue) { pkm.SetHiddenPowerDamage(HiddenPowerDamage.Value); } if (HiddenPowerType.HasValue) { pkm.SetHiddenPowerType(HiddenPowerType.Value); } // Teach the Pokemon all of it's default moves ushort[] moves = PokemonDatabase.GetMovesLearnedAtLevelRange(pkm, 1, (IsEgg ? (byte)5 : Level)); foreach (ushort moveID in moves) { if (!PokemonDatabase.PokemonHasMove(pkm, moveID)) { if (pkm.NumMoves < 4) { pkm.SetMoveAt(pkm.NumMoves, new Move(moveID)); } else { for (int i = 0; i < 3; i++) { pkm.SetMoveAt(i, pkm.GetMoveAt(i + 1)); } pkm.SetMoveAt(3, new Move(moveID)); } } } if (Move1ID.HasValue) { pkm.SetMoveAt(0, new Move(Move1ID.Value)); } if (Move2ID.HasValue) { pkm.SetMoveAt(1, new Move(Move2ID.Value)); } if (Move3ID.HasValue) { pkm.SetMoveAt(2, new Move(Move3ID.Value)); } if (Move4ID.HasValue) { pkm.SetMoveAt(3, new Move(Move4ID.Value)); } GameTypes gameType = gameSave.GameType; if (gameType == GameTypes.Ruby) { pkm.GameOrigin = GameOrigins.Ruby; } else if (gameType == GameTypes.Sapphire) { pkm.GameOrigin = GameOrigins.Sapphire; } else if (gameType == GameTypes.Emerald) { pkm.GameOrigin = GameOrigins.Emerald; } else if (gameType == GameTypes.FireRed) { pkm.GameOrigin = GameOrigins.FireRed; } else if (gameType == GameTypes.LeafGreen) { pkm.GameOrigin = GameOrigins.LeafGreen; } else if (gameType == GameTypes.Colosseum || gameType == GameTypes.XD) { pkm.GameOrigin = GameOrigins.ColosseumXD; } else { pkm.GameOrigin = GameOrigins.Emerald; } pkm.GameType = gameType; pkm.Checksum = pkm.CalculateChecksum(); pkm.RecalculateStats(); reward = pkm; }
public override void GenerateReward(IGameSave gameSave) { Random random = new Random((int)DateTime.Now.Ticks); PokemonData pokemonData = PokemonDatabase.GetPokemonFromDexID(DexID); GBAPokemon pkm = new GBAPokemon(); pkm.DexID = DexID; pkm.Personality = (Personality.HasValue ? Personality.Value : (uint)random.Next()); pkm.Experience = PokemonDatabase.GetExperienceFromLevel(pokemonData.ExperienceGroup, (IsEgg ? (byte)5 : Level)); pkm.IsSecondAbility2 = (IsSecondAbility.HasValue ? IsSecondAbility.Value : (!pokemonData.CanOnlyHaveFirstAbility && random.Next(2) == 1)); pkm.Nickname = (Nickname != null ? Nickname : pokemonData.Name.ToUpper()); pkm.BallCaughtID = 4; pkm.MetLocationID = 255; if (DexID == 151 || DexID == 386) pkm.IsFatefulEncounter = true; pkm.LevelMet = (IsEgg ? (byte)0 : Level); pkm.Language = Languages.English; pkm.Friendship = (byte)(IsEgg ? 10 : 70); // Ownership pkm.TrainerName = (TrainerName != null ? TrainerName : PokeManager.ManagerGameSave.TrainerName); pkm.TrainerGender = (TrainerGender.HasValue ? TrainerGender.Value : PokeManager.ManagerGameSave.TrainerGender); pkm.TrainerID = (TrainerID.HasValue ? TrainerID.Value : PokeManager.ManagerGameSave.TrainerID); pkm.SecretID = (SecretID.HasValue ? SecretID.Value : PokeManager.ManagerGameSave.SecretID); if (TrainerGender.HasValue && TrainerGender.Value == Genders.Genderless) pkm.TrainerGender = (random.Next(2) == 1 ? Genders.Female : Genders.Male); if (!Personality.HasValue) GeneratePID(pkm, random); if (HeldItem != null) pkm.HeldItemID = HeldItem[random.Next(HeldItem.Length)]; if (Conditions != null) { pkm.Coolness = Conditions[0]; pkm.Beauty = Conditions[1]; pkm.Cuteness = Conditions[2]; pkm.Smartness = Conditions[3]; pkm.Toughness = Conditions[4]; pkm.Feel = Conditions[5]; } pkm.HPIV = (IVs != null ? IVs[0] : (byte)random.Next(32)); pkm.AttackIV = (IVs != null ? IVs[1] : (byte)random.Next(32)); pkm.DefenseIV = (IVs != null ? IVs[2] : (byte)random.Next(32)); pkm.SpAttackIV = (IVs != null ? IVs[3] : (byte)random.Next(32)); pkm.SpDefenseIV = (IVs != null ? IVs[4] : (byte)random.Next(32)); pkm.SpeedIV = (IVs != null ? IVs[5] : (byte)random.Next(32)); if (HiddenPowerDamage.HasValue) pkm.SetHiddenPowerDamage(HiddenPowerDamage.Value); if (HiddenPowerType.HasValue) pkm.SetHiddenPowerType(HiddenPowerType.Value); // Teach the Pokemon all of it's default moves ushort[] moves = PokemonDatabase.GetMovesLearnedAtLevelRange(pkm, 1, (IsEgg ? (byte)5 : Level)); foreach (ushort moveID in moves) { if (!PokemonDatabase.PokemonHasMove(pkm, moveID)) { if (pkm.NumMoves < 4) { pkm.SetMoveAt(pkm.NumMoves, new Move(moveID)); } else { for (int i = 0; i < 3; i++) { pkm.SetMoveAt(i, pkm.GetMoveAt(i + 1)); } pkm.SetMoveAt(3, new Move(moveID)); } } } if (Move1ID.HasValue) pkm.SetMoveAt(0, new Move(Move1ID.Value)); if (Move2ID.HasValue) pkm.SetMoveAt(1, new Move(Move2ID.Value)); if (Move3ID.HasValue) pkm.SetMoveAt(2, new Move(Move3ID.Value)); if (Move4ID.HasValue) pkm.SetMoveAt(3, new Move(Move4ID.Value)); GameTypes gameType = gameSave.GameType; if (gameType == GameTypes.Ruby) pkm.GameOrigin = GameOrigins.Ruby; else if (gameType == GameTypes.Sapphire) pkm.GameOrigin = GameOrigins.Sapphire; else if (gameType == GameTypes.Emerald) pkm.GameOrigin = GameOrigins.Emerald; else if (gameType == GameTypes.FireRed) pkm.GameOrigin = GameOrigins.FireRed; else if (gameType == GameTypes.LeafGreen) pkm.GameOrigin = GameOrigins.LeafGreen; else if (gameType == GameTypes.Colosseum || gameType == GameTypes.XD) pkm.GameOrigin = GameOrigins.ColosseumXD; else pkm.GameOrigin = GameOrigins.Emerald; pkm.GameType = gameType; pkm.Checksum = pkm.CalculateChecksum(); pkm.RecalculateStats(); reward = pkm; }
public GBAPokemon CreateGBAPokemon(GameTypes gameType, bool passFinder = true) { GBAPokemon pkm = new GBAPokemon(); if (passFinder) pkm.PokemonFinder = PokemonFinder; pkm.GameType = gameType; pkm.DeoxysForm = DeoxysForm; pkm.Language = Language; // Pokemon Info pkm.Personality = Personality; pkm.SpeciesID = SpeciesID; pkm.IsSecondAbility2 = IsSecondAbility2; // Met Info pkm.TrainerName = TrainerName; pkm.TrainerGender = TrainerGender; pkm.TrainerID = TrainerID; pkm.SecretID = SecretID; pkm.BallCaughtID = BallCaughtID; pkm.LevelMet = LevelMet; pkm.MetLocationID = MetLocationID; pkm.IsFatefulEncounter = IsFatefulEncounter; pkm.GameOrigin = GameOrigin; // Personalization Info pkm.Nickname = Nickname; pkm.HeldItemID = HeldItemID; pkm.Markings = Markings; // Stats Info pkm.Experience = Experience; pkm.Friendship = Friendship; pkm.HPEV = HPEV; pkm.AttackEV = AttackEV; pkm.DefenseEV = DefenseEV; pkm.SpeedEV = SpeedEV; pkm.SpAttackEV = SpAttackEV; pkm.SpDefenseEV = SpDefenseEV; pkm.HPIV = HPIV; pkm.AttackIV = AttackIV; pkm.DefenseIV = DefenseIV; pkm.SpeedIV = SpeedIV; pkm.SpAttackIV = SpAttackIV; pkm.SpDefenseIV = SpDefenseIV; // Status Info pkm.StatusCondition = StatusConditionFlags.None; pkm.TurnsOfSleepRemaining = 0; pkm.TurnsOfBadPoison = 0; pkm.PokerusStrain = PokerusStrain; pkm.PokerusDaysRemaining = PokerusDaysRemaining; pkm.PokerusRemaining = PokerusRemaining; // Contest Info pkm.Coolness = Coolness; pkm.Beauty = Beauty; pkm.Cuteness = Cuteness; pkm.Smartness = Smartness; pkm.Toughness = Toughness; pkm.Feel = Feel; pkm.CoolRibbonCount = CoolRibbonCount; pkm.BeautyRibbonCount = BeautyRibbonCount; pkm.CuteRibbonCount = CuteRibbonCount; pkm.SmartRibbonCount = SmartRibbonCount; pkm.ToughRibbonCount = ToughRibbonCount; pkm.HasChampionRibbon = HasChampionRibbon; pkm.HasWinningRibbon = HasWinningRibbon; pkm.HasVictoryRibbon = HasVictoryRibbon; pkm.HasArtistRibbon = HasArtistRibbon; pkm.HasEffortRibbon = HasEffortRibbon; pkm.HasMarineRibbon = HasMarineRibbon; pkm.HasLandRibbon = HasLandRibbon; pkm.HasSkyRibbon = HasSkyRibbon; pkm.HasCountryRibbon = HasCountryRibbon; pkm.HasNationalRibbon = HasNationalRibbon; pkm.HasEarthRibbon = HasEarthRibbon; pkm.HasWorldRibbon = HasWorldRibbon; // Move Info pkm.SetMoveAt(0, GetMoveAt(0)); pkm.SetMoveAt(1, GetMoveAt(1)); pkm.SetMoveAt(2, GetMoveAt(2)); pkm.SetMoveAt(3, GetMoveAt(3)); pkm.Checksum = pkm.CalculateChecksum(); // Recalculate Stats to make sure they're accurate pkm.RecalculateStats(); return pkm; }
public GBADaycare(IPokePC pokePC, byte[] data, GameCodes gameCode) { this.gameCode = gameCode; this.pokePC = pokePC; this.raw = data; if (gameCode == GameCodes.FireRedLeafGreen) { originalPokemon = new GBAPokemon[3]; finalPokemon = new GBAPokemon[3]; GBAPokemon pkm = new GBAPokemon(ByteHelper.SubByteArray(0, raw, 80)); if (pkm.DexID != 0 && pkm.Checksum != 0 && pkm.Experience != 0) { if (pkm.IsValid) originalPokemon[0] = pkm; else originalPokemon[0] = GBAPokemon.CreateInvalidPokemon(pkm); SetFinalPokemon(0); } pkm = new GBAPokemon(ByteHelper.SubByteArray(140, raw, 80)); if (pkm.DexID != 0 && pkm.Checksum != 0 && pkm.Experience != 0) { if (pkm.IsValid) originalPokemon[1] = pkm; else originalPokemon[1] = GBAPokemon.CreateInvalidPokemon(pkm); SetFinalPokemon(1); } pkm = new GBAPokemon(ByteHelper.SubByteArray(3352, raw, 80)); if (pkm.DexID != 0 && pkm.Checksum != 0 && pkm.Experience != 0) { if (pkm.IsValid) originalPokemon[2] = pkm; else originalPokemon[2] = GBAPokemon.CreateInvalidPokemon(pkm); SetFinalPokemon(2); } } else if (gameCode == GameCodes.Emerald) { originalPokemon = new GBAPokemon[2]; finalPokemon = new GBAPokemon[2]; GBAPokemon pkm = new GBAPokemon(ByteHelper.SubByteArray(0, raw, 80)); if (pkm.DexID != 0 && pkm.Checksum != 0 && pkm.Experience != 0) { if (pkm.IsValid) originalPokemon[0] = pkm; else originalPokemon[0] = GBAPokemon.CreateInvalidPokemon(pkm); SetFinalPokemon(0); } pkm = new GBAPokemon(ByteHelper.SubByteArray(140, raw, 80)); if (pkm.DexID != 0 && pkm.Checksum != 0 && pkm.Experience != 0) { if (pkm.IsValid) originalPokemon[1] = pkm; else originalPokemon[1] = GBAPokemon.CreateInvalidPokemon(pkm); SetFinalPokemon(1); } } else if (gameCode == GameCodes.RubySapphire) { originalPokemon = new GBAPokemon[2]; finalPokemon = new GBAPokemon[2]; GBAPokemon pkm = new GBAPokemon(ByteHelper.SubByteArray(0, raw, 80)); if (pkm.DexID != 0 && pkm.Checksum != 0 && pkm.Experience != 0) { if (pkm.IsValid) originalPokemon[0] = pkm; else originalPokemon[0] = GBAPokemon.CreateInvalidPokemon(pkm); SetFinalPokemon(0); } pkm = new GBAPokemon(ByteHelper.SubByteArray(80, raw, 80)); if (pkm.DexID != 0 && pkm.Checksum != 0 && pkm.Experience != 0) { if (pkm.IsValid) originalPokemon[1] = pkm; else originalPokemon[1] = GBAPokemon.CreateInvalidPokemon(pkm); SetFinalPokemon(1); } } }