Ejemplo n.º 1
0
        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);
                }
            }
        }
Ejemplo n.º 2
0
 public NationalPokedexBAndCBlockData(IGameSave gameSave, byte[] data, BlockDataCollection parent)
     : base(gameSave, data, parent)
 {
     if (parent.GameCode == GameCodes.RubySapphire)
     {
         if (parent.Inventory.Decorations == null)
         {
             parent.Inventory.AddDecorationInventory();
         }
         for (int i = 0; i < 16; i++)
         {
             byte id = raw[2714 + i];
             if (id != 0)
             {
                 byte x = ByteHelper.BitsToByte(raw, 2714 + 16 + i, 4, 4);
                 byte y = ByteHelper.BitsToByte(raw, 2714 + 16 + i, 0, 4);
                 parent.Inventory.Decorations.SecretBaseDecorations.Add(new PlacedDecoration(id, x, y));
             }
         }
     }
     else if (parent.GameCode == GameCodes.Emerald)
     {
         if (parent.Inventory.Decorations == null)
         {
             parent.Inventory.AddDecorationInventory();
         }
         for (int i = 0; i < 16; i++)
         {
             byte id = raw[2862 + i];
             if (id != 0)
             {
                 byte x = ByteHelper.BitsToByte(raw, 2862 + 16 + i, 4, 4);
                 byte y = ByteHelper.BitsToByte(raw, 2862 + 16 + i, 0, 4);
                 parent.Inventory.Decorations.SecretBaseDecorations.Add(new PlacedDecoration(id, x, y));
             }
         }
     }
 }
        public DecorationBlockData(IGameSave gameSave, byte[] data, BlockDataCollection parent)
            : base(gameSave, data, parent)
        {
            if (parent.GameCode == GameCodes.RubySapphire)
            {
                if (parent.Inventory.Decorations == null)
                {
                    parent.Inventory.AddDecorationInventory();
                }
                AddDecorationContainer(DecorationTypes.Desk, 1952, 10);
                AddDecorationContainer(DecorationTypes.Chair, 1962, 10);
                AddDecorationContainer(DecorationTypes.Plant, 1972, 10);
                AddDecorationContainer(DecorationTypes.Ornament, 1982, 30);
                AddDecorationContainer(DecorationTypes.Mat, 2012, 30);
                AddDecorationContainer(DecorationTypes.Poster, 2042, 10);
                AddDecorationContainer(DecorationTypes.Doll, 2052, 40);
                AddDecorationContainer(DecorationTypes.Cushion, 2092, 10);
                // TODO: Find where the XY values actually are stored.
                for (int i = 0; i < 12; i++)
                {
                    byte id = raw[1928 + i];
                    if (id != 0)
                    {
                        byte x = ByteHelper.BitsToByte(raw, 1928 + 12 + i, 4, 4);
                        byte y = ByteHelper.BitsToByte(raw, 1928 + 12 + i, 0, 4);
                        parent.Inventory.Decorations.BedroomDecorations.Add(new PlacedDecoration(id, x, y));
                    }
                }

                parent.Mailbox.Load(ByteHelper.SubByteArray(3148, raw, 16 * 36));
            }
            else if (parent.GameCode == GameCodes.Emerald)
            {
                if (parent.Inventory.Decorations == null)
                {
                    parent.Inventory.AddDecorationInventory();
                }
                AddDecorationContainer(DecorationTypes.Desk, 2100, 10);
                AddDecorationContainer(DecorationTypes.Chair, 2110, 10);
                AddDecorationContainer(DecorationTypes.Plant, 2120, 10);
                AddDecorationContainer(DecorationTypes.Ornament, 2130, 30);
                AddDecorationContainer(DecorationTypes.Mat, 2160, 30);
                AddDecorationContainer(DecorationTypes.Poster, 2190, 10);
                AddDecorationContainer(DecorationTypes.Doll, 2200, 40);
                AddDecorationContainer(DecorationTypes.Cushion, 2240, 10);
                // TODO: Find where the XY values actually are stored.
                for (int i = 0; i < 12; i++)
                {
                    byte id = raw[2076 + i];
                    if (id != 0)
                    {
                        byte x = ByteHelper.BitsToByte(raw, 2076 + 12 + i, 4, 4);
                        byte y = ByteHelper.BitsToByte(raw, 2076 + 12 + i, 0, 4);
                        parent.Inventory.Decorations.BedroomDecorations.Add(new PlacedDecoration(id, x, y));
                    }
                }

                parent.Mailbox.Load(ByteHelper.SubByteArray(3296, raw, 16 * 36));

                /*sharedSecretBases = new List<SharedSecretBase>();
                 * for (int i = 0; i < 3; i++) {
                 *      byte locationID = raw[1596 + i * 160];
                 *      if (SecretBaseDatabase.GetLocationFromID(locationID) != null)
                 *              sharedSecretBases.Add(new SharedSecretBase(ByteHelper.SubByteArray(1596 + i * 160, data, 160)));
                 * }*/
            }
            else if (parent.GameCode == GameCodes.FireRedLeafGreen)
            {
                parent.Mailbox.LoadPart1(ByteHelper.SubByteArray(3536, raw, 12 * 36));
            }
        }