Read and write saves from Diablo 2. Supports versions 1.10 through Diablo II: Resurrected (2.50). Supports both d2s (player saves) and d2i (shared stash).
$ dotnet add package TXC.D2SLibC# library for reading and writing Diablo 2 saves. Supports version 1.10 through Diablo II: Resurrected (2.50). Supports reading both d2s (player saves) and d2i (shared stash) files.
Use Nuget to add D2SLib to your project.
using D2SLib;
using D2SLib.Model.Save;
using D2Shared.Enums;
....
var CharacterName = "Flibidy";
var SaveGamePath = Environment.ExpandEnvironmentVariables($"%userprofile%/Saved Games/Diablo II Resurrected/");
//read a save
D2S character = Core.ReadD2S(File.ReadAllBytes($"{SaveGamePath}/{CharacterName}.d2s"));
//outputs: DannyIsGreat
Console.WriteLine(character.Name);
//convert 1.10-1.114d save to d2r 2.00
character.Header.Version = SaveVersion.v200;
//set all skills to have 20 points
character.ClassSkills.Skills.ForEach(skill => skill.Points = 20);
//add lvl 31 conviction arua to the first statlist on the first item in your chars inventory
character.PlayerItemList.Items[0].StatLists[0].Stats.Add(new ItemStat { Stat = "item_aura", Param = 123, Value = 31 });
//write save
File.WriteAllBytes($"{SaveGamePath}/{CharacterName}_new_.d2s", Core.WriteD2S(character));
How to seed the library with your own TXT files
// Location where ItemStatCost.txt, Armor.txt, etc.. exists
var PathToExcelFiles = @"../../EXCEL/";
// Location where string.tbl, expansionstring.tbl & patchstring.tbl exists
var PathToTableFiles = @"../../Table/";
FromPathImporter importer = new FromPathImporter(PathToExcelFiles, PathToTableFiles);
importer.LoadData();
Core.Importer = importer;
D2S character = Core.ReadD2S(File.ReadAllBytes(@"Flibidy.d2s"));