Exemple #1
0
        public static void SetLevel(int ind, int lev = 1, int set_rml = -1, int set_exp = -1)
        {
            //level patcher
            lev = (lev < 2) ? 0 : Math.Min(10 + db.Mons[ind].Item4, lev);    //level capped to 10 + max nb of lollipops for that pokemon
            short level1 = (short)((BitConverter.ToInt16(savedata, Level1.Ofset(ind)) & ~(0xF << Level1.Shift(ind))) | (Math.Min(lev, 0xF) << Level1.Shift(ind)));

            Array.Copy(BitConverter.GetBytes(level1), 0, savedata, Level1.Ofset(ind), 2);    //write to original ofsets ( <= 15)
            short level2 = (short)((BitConverter.ToInt16(savedata, Level2.Ofset(ind)) & ~(0x3F << Level2.Shift(ind))) | ((lev >= 15 ? Math.Min(lev, 0x3F) : 0) << Level2.Shift(ind)));

            Array.Copy(BitConverter.GetBytes(level2), 0, savedata, Level2.Ofset(ind), 2);    //write to 1.3.25 ofsets ( >= 15, 0 if below)

            //lollipop patcher
            set_rml = (set_rml < 0 || (set_rml < lev - 10) ? ((lev - 10 < 0) ? 0 : lev - 10) : set_rml);
            short numRaiseMaxLevel = (short)((BitConverter.ToInt16(savedata, Lollipop.Ofset(ind)) & ~(0x3F << Lollipop.Shift(ind))) | (set_rml << Lollipop.Shift(ind)));

            Array.Copy(BitConverter.GetBytes(numRaiseMaxLevel), 0, savedata, Lollipop.Ofset(ind), 2);

            //experience patcher
            int entrylen = BitConverter.ToInt32(db.MonLevel, 0x4);

            byte[] data = db.MonLevel.Skip(0x50 + ((((lev < 2) ? 1 : lev) - 1) * entrylen)).Take(entrylen).ToArray(); //corrected level value, because if it's 0 then it means 1
            set_exp = (set_exp < 0) ? BitConverter.ToInt32(data, 0x4 * (db.Mons[ind].Item5 - 1)) : set_exp;
            int exp = (BitConverter.ToInt32(savedata, Experience.Ofset(ind)) & ~(0xFFFFFF << Experience.Shift(ind))) | (set_exp << Experience.Shift(ind));

            Array.Copy(BitConverter.GetBytes(exp), 0, savedata, Experience.Ofset(ind), 4);
        }
Exemple #2
0
        public static void SetLevel(int ind, int lev = 1, int set_rml = -1, int set_exp = -1)
        {
            //level patcher
            lev = (lev < 2) ? 0 : lev;
            short level1 = (short)((BitConverter.ToInt16(savedata, Level1.Ofset(ind)) & ~(0xF << Level1.Shift(ind))) | (Math.Min(lev, 0xF) << Level1.Shift(ind)));

            Array.Copy(BitConverter.GetBytes(level1), 0, savedata, Level1.Ofset(ind), 2);    //write to original ofsets ( <= 15)
            short level2 = (short)((BitConverter.ToInt16(savedata, Level2.Ofset(ind)) & ~(0x3F << Level2.Shift(ind))) | ((lev < 15) ? 0 : Math.Min(lev, 0x3F) << Level2.Shift(ind)));

            Array.Copy(BitConverter.GetBytes(level2), 0, savedata, Level2.Ofset(ind), 2);    //write to 1.3.25 ofsets ( >= 15, 0 if below)

            //lollipop patcher
            set_rml = (set_rml < 0 || (set_rml < lev - 10) ? Math.Max(0, lev - 10) : set_rml);
            short numRaiseMaxLevel = (short)((BitConverter.ToInt16(savedata, Lollipop.Ofset(ind)) & ~(0x3F << Lollipop.Shift(ind))) | (Math.Min(set_rml, 0x3F) << Lollipop.Shift(ind)));

            Array.Copy(BitConverter.GetBytes(numRaiseMaxLevel), 0, savedata, Lollipop.Ofset(ind), 2);

            //experience patcher
            int entrylen = BitConverter.ToInt32(db.MonLevelBin, 0x4);

            byte[] data = db.MonLevelBin.Skip(0x50 + (Math.Min(db.Mons[ind].MaxLollipops + 10, (Math.Max(0, lev - 1))) * entrylen)).Take(entrylen).ToArray(); //makes sure to read exp values within the correct range (0 to max level)
            set_exp = (set_exp < 0) ? BitConverter.ToInt32(data, 0x4 * (db.Mons[ind].BasePower - 1)) : set_exp;
            int exp = (BitConverter.ToInt32(savedata, Experience.Ofset(ind)) & ~(0xFFFFFF << Experience.Shift(ind))) | (Math.Min(set_exp, 0xFFFFFF) << Experience.Shift(ind));

            Array.Copy(BitConverter.GetBytes(exp), 0, savedata, Experience.Ofset(ind), 4);
        }
Exemple #3
0
        public static monItem GetMon(int ind)
        {
            bool caught = true;

            foreach (int array in Caught.Ofset(ind))
            {
                if (((savedata[array] >> Caught.Shift(ind)) & 1) != 1)
                {
                    caught = false;
                }
            }
            int lev = Math.Max((BitConverter.ToUInt16(savedata, Level1.Ofset(ind)) >> Level1.Shift(ind)) & 0xF, (BitConverter.ToUInt16(savedata, Level2.Ofset(ind)) >> Level2.Shift(ind)) & 0x3F);

            lev = (lev == 0) ? 1 : lev;
            int   rml      = (BitConverter.ToUInt16(savedata, Lollipop.Ofset(ind)) >> Lollipop.Shift(ind)) & 0x3F;
            int   exp      = (BitConverter.ToInt32(savedata, Experience.Ofset(ind)) >> Experience.Shift(ind)) & 0xFFFFFF;
            short stone    = (short)((savedata[Mega.Ofset(ind)] >> Mega.Shift(ind)) & 3); //0 = 00, 1 = X0, 2 = 0Y, 3 = XY
            short speedUpX = (short)(db.HasMega[ind][0] ? (BitConverter.ToInt16(savedata, SpeedUpX.Ofset(ind)) >> SpeedUpX.Shift(ind)) & 0x7F : 0);
            short speedUpY = (short)(db.HasMega[ind][1] ? (BitConverter.ToInt32(savedata, SpeedUpY.Ofset(ind)) >> SpeedUpY.Shift(ind)) & 0x7F : 0);
            short selSkill = (short)((BitConverter.ToInt16(savedata, CurrentSkill.Ofset(ind)) >> CurrentSkill.Shift(ind)) & 0x7);

            int[] skillLvl = new int[5], skillExp = new int[5];
            for (int i = 0; i < db.Rest[ind].Item2; i++)
            {
                int sLv = (BitConverter.ToInt16(savedata, SkillLevel.Ofset(ind, i)) >> SkillLevel.Shift(ind)) & 0x7;
                skillLvl[i] = (sLv < 2) ? 1 : sLv;
                skillExp[i] = savedata[SkillExp.Ofset(ind, i)];
            }

            return(new monItem {
                Caught = caught, Level = lev, Lollipops = rml, Exp = exp, Stone = stone, SpeedUpX = speedUpX, SpeedUpY = speedUpY, CurrentSkill = selSkill, SkillLevel = skillLvl, SkillExp = skillExp
            });
        }