Beispiel #1
0
        private D2MemoryTable GetVersionMemoryTable(string version)
        {
            D2MemoryTable memoryTable = new D2MemoryTable();

            // Offsets are the same for all versions so far.
            memoryTable.Offset.Quests = new int[] { 0x264, 0x450, 0x20, 0x00 };

            switch (version)
            {
            case "1.14c":
                memoryTable.Address.World      = new IntPtr(0x0047ACC0);
                memoryTable.Address.GameId     = new IntPtr(0x00479C94);
                memoryTable.Address.PlayerUnit = new IntPtr(0x0039CEFC);     //(0x39DAF8);
                memoryTable.Address.Area       = new IntPtr(0x0039A1C8);

                memoryTable.Address.GlobalData         = new IntPtr(0x33FD78);
                memoryTable.Address.LowQualityItems    = new IntPtr(0x563BE0);
                memoryTable.Address.ItemDescriptions   = new IntPtr(0x5639E0);
                memoryTable.Address.MagicModifierTable = new IntPtr(0x563A04);
                memoryTable.Address.RareModifierTable  = new IntPtr(0x563A28);

                memoryTable.Address.StringIndexerTable          = new IntPtr(0x479A3C);
                memoryTable.Address.StringAddressTable          = new IntPtr(0x479A40);
                memoryTable.Address.PatchStringIndexerTable     = new IntPtr(0x479A58);
                memoryTable.Address.PatchStringAddressTable     = new IntPtr(0x479A44);
                memoryTable.Address.ExpansionStringIndexerTable = new IntPtr(0x479A5C);
                memoryTable.Address.ExpansionStringAddressTable = new IntPtr(0x479A48);

                break;

            case "1.14d":
            default:
                memoryTable.Address.World      = new IntPtr(0x00483D38);
                memoryTable.Address.GameId     = new IntPtr(0x00482D0C);
                memoryTable.Address.PlayerUnit = new IntPtr(0x003A5E74);
                memoryTable.Address.Area       = new IntPtr(0x003A3140);

                memoryTable.Address.GlobalData         = new IntPtr(0x344304);
                memoryTable.Address.LowQualityItems    = new IntPtr(0x56CC58);
                memoryTable.Address.ItemDescriptions   = new IntPtr(0x56CA58);
                memoryTable.Address.MagicModifierTable = new IntPtr(0x56CA7C);
                memoryTable.Address.RareModifierTable  = new IntPtr(0x56CAA0);

                memoryTable.Address.StringIndexerTable          = new IntPtr(0x4829B4);
                memoryTable.Address.StringAddressTable          = new IntPtr(0x4829B8);
                memoryTable.Address.PatchStringAddressTable     = new IntPtr(0x4829BC);
                memoryTable.Address.ExpansionStringAddressTable = new IntPtr(0x4829C0);
                memoryTable.Address.PatchStringIndexerTable     = new IntPtr(0x4829D0);
                memoryTable.Address.ExpansionStringIndexerTable = new IntPtr(0x4829D4);

                break;
            }

            return(memoryTable);
        }
Beispiel #2
0
        public ItemReader(ProcessMemoryReader reader, D2MemoryTable memory) : base(reader, memory)
        {
            cachedItemData     = new Dictionary <IntPtr, D2ItemData>();
            cachedDescriptions = new Dictionary <int, D2ItemDescription>();

            globals          = reader.Read <D2GlobalData>(reader.ReadAddress32(memory.Address.GlobalData, AddressingMode.Relative));
            lowQualityTable  = reader.Read <D2SafeArray>(memory.Address.LowQualityItems, AddressingMode.Relative);
            descriptionTable = reader.Read <D2SafeArray>(memory.Address.ItemDescriptions, AddressingMode.Relative);
            magicModifiers   = reader.Read <ModifierTable>(memory.Address.MagicModifierTable, AddressingMode.Relative);
            rareModifiers    = reader.Read <ModifierTable>(memory.Address.RareModifierTable, AddressingMode.Relative);
            if (globals != null)
            {
                opNestings = reader.ReadArray <ushort>(globals.OpStatNesting, (int)globals.OpStatNestingCount);

                if (ItemStatCost == null && !globals.ItemStatCost.IsNull)
                {
                    ItemStatCost = reader.ReadArray <D2ItemStatCost>(globals.ItemStatCost, (int)globals.ItemStatCostCount);
                }
            }
        }
Beispiel #3
0
 public InventoryReader(ProcessMemoryReader reader, D2MemoryTable memory)
 {
     processReader = reader;
     this.memory   = memory;
     itemReader    = new ItemReader(processReader, memory);
 }
Beispiel #4
0
        public void UpdateItemStats(ProcessMemoryReader r, D2MemoryTable memory, D2Unit pl)
        {
            InventoryReader inventoryReader = new InventoryReader(r, memory);
            UnitReader      unitReader      = new UnitReader(r, memory);

            // Build filter to get only equipped items.
            Func <D2ItemData, bool> filter = data => data.BodyLoc != BodyLocation.None;

            foreach (D2Unit item in inventoryReader.EnumerateInventory(filter))
            {
                List <D2Stat> itemStats = unitReader.GetStats(item);
                if (itemStats == null)
                {
                    continue;
                }

                StringBuilder statBuilder = new StringBuilder();
                statBuilder.Append(inventoryReader.ItemReader.GetFullItemName(item));

                statBuilder.Append("\n");
                List <string> magicalStrings = inventoryReader.ItemReader.GetMagicalStrings(item);
                foreach (string str in magicalStrings)
                {
                    statBuilder.Append("    ");
                    statBuilder.Append(str);
                    statBuilder.Append("\n");
                }

                Control    c        = null;
                D2ItemData itemData = r.Read <D2ItemData>(item.UnitData);
                switch (itemData.BodyLoc)
                {
                case BodyLocation.Head: c = tabPageHead; break;

                case BodyLocation.Amulet: c = tabPageAmulet; break;

                case BodyLocation.BodyArmor: c = tabPageBody; break;

                case BodyLocation.PrimaryRight: c = tabPageWeaponRight; break;

                case BodyLocation.PrimaryLeft: c = tabPageWeaponLeft; break;

                case BodyLocation.RingRight: c = tabPageRingRight; break;

                case BodyLocation.RingLeft: c = tabPageRingLeft; break;

                //case BodyLocation.SecondaryLeft: c = tabPageRingRight; break;
                //case BodyLocation.SecondaryRight: c = tabPageRingLeft; break;
                case BodyLocation.Belt: c = tabPageBelt; break;

                case BodyLocation.Boots: c = tabPageFeet; break;

                case BodyLocation.Gloves: c = tabPageHand; break;
                }
                if (c != null)
                {
                    if (c.Controls.Count == 0)
                    {
                        c.Invoke(new Action(delegate() {
                            c.Controls.Add(new RichTextBox());
                            c.Controls[0].Dock = DockStyle.Fill;
                        }));
                    }
                    c.Controls[0].Invoke(new Action(() => c.Controls[0].Text = statBuilder.ToString()));
                }
            }
        }
Beispiel #5
0
 public UnitReader(ProcessMemoryReader reader, D2MemoryTable memory)
 {
     this.reader  = reader;
     this.memory  = memory;
     stringReader = new StringLookupTable(reader, memory.Address);
 }