Example #1
0
        public void RemoveArmletMateria(CharNames charNames, int keep = 0)
        {
            CharMemLoc charMemLoc = CharMemLoc.ByName(charNames);

            byte[] emptyRow = { byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue };

            for (int i = ItemSize * keep; i < charMemLoc.ArmorMateria.NumBytes; i += ItemSize)
            {
                IntPtr address = IntPtr.Add(charMemLoc.ArmorMateria.Address, i);
                var    bytes   = new byte[ItemSize];
                _memory.ReadMem(Settings.ProcessName, address, bytes);
                var materia = new MateriaSlot(bytes);
                AddMateria(materia.MateriaId, materia.Experience);
                _memory.WriteMem(Settings.ProcessName, address, emptyRow);
            }
        }
Example #2
0
        public void AddMateria(byte materiaId, uint experience = 0)
        {
            var scanResult = _memory.ScanMem(Settings.ProcessName,
                                             FirstAddress, ItemSize, InvCapacity, IsEmpty);

            if (scanResult.BaseAddrOffset == -1)
            {
                return;
            }

            IntPtr address     = IntPtr.Add(FirstAddress, scanResult.BaseAddrOffset);
            var    materiaSlot = new MateriaSlot(materiaId, experience);

            _memory.WriteMem(Settings.ProcessName, address, materiaSlot.AsBytes());

            bool IsEmpty(byte[] bytes) => bytes.All(b => b == byte.MaxValue);
        }