Ejemplo n.º 1
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
            });
        }
Ejemplo n.º 2
0
        public static void SetSkill(int ind, int lvl = 1, int skill = 0)
        {
            //level
            lvl = (lvl < 2) ? 0 : ((lvl > 5) ? 5 : lvl);    //hardcoded skill level to be 5 max
            int skilllvl = BitConverter.ToInt16(savedata, SkillLevel.Ofset(ind, skill));

            skilllvl = (skilllvl & ~(0x7 << SkillLevel.Shift(ind))) | (lvl << SkillLevel.Shift(ind));
            Array.Copy(BitConverter.GetBytes(skilllvl), 0, savedata, SkillLevel.Ofset(ind, skill), 2);

            //exp
            int entrylen = BitConverter.ToInt32(db.MonAbility, 0x4);

            savedata[SkillExp.Ofset(ind, skill)] = (lvl < 2) ? (byte)0 : db.MonAbility.Skip(0x50 + db.Mons[ind].Item6[skill] * entrylen).Take(entrylen).ToArray()[0x1A + lvl];
        }
Ejemplo n.º 3
0
        public static void SetSkill(int ind, int skind = 0, int lvl = 1, bool current = false)
        {
            //level
            lvl   = (lvl < 2) ? 0 : ((lvl > 5) ? 5 : lvl);       //hardcoded skill level to be 5 max
            skind = (skind < 0) ? 0 : ((skind > 4) ? 4 : skind); //hardcoded 5 skills maximum
            int skilllvl = BitConverter.ToInt16(savedata, SkillLevel.Ofset(ind, skind));

            skilllvl = (skilllvl & ~(0x7 << SkillLevel.Shift(ind))) | (lvl << SkillLevel.Shift(ind));
            Array.Copy(BitConverter.GetBytes(skilllvl), 0, savedata, SkillLevel.Ofset(ind, skind), 2);

            //exp
            int entrylen = BitConverter.ToInt32(db.MonAbility, 0x4);

            savedata[SkillExp.Ofset(ind, skind)] = (lvl < 2) ? (byte)0 : db.MonAbility.Skip(0x50 + db.Mons[ind].Item6[skind] * entrylen).Take(entrylen).ToArray()[0x1A + lvl];

            //current
            if (current)
            {
                int selskill = BitConverter.ToInt16(savedata, CurrentSkill.Ofset(ind));
                selskill = (selskill & ~(0x7 << CurrentSkill.Shift(ind))) | (skind << CurrentSkill.Shift(ind));
                Array.Copy(BitConverter.GetBytes(selskill), 0, savedata, CurrentSkill.Ofset(ind), 2);
            }
        }