This package contains a Diablo II save files (D2S) decoder and encoder written in golang
- krisives/d2s-format
- Diablo II Saved Game File Format
- nokka/d2s (see details)
- pairofdocs/d2s_edit_recalc
This project uses Data stream writer based on these used in OpenDiablo2 project for more informations, see here
for now (May 2021) the project is early in development. However, it is possible to:
- decode character save file into a (in a greater part) human-readable structure
- encoding file
for some reasons, this project isn't able to create a whole new file yet, but it is able to load modify and than encode D2S format
simple example
package main
import (
"fmt"
"ioutil"
"log"
"github.com/gucio321/d2d2s/pkg/d2s"
)
func main() {
data, err := ioutil.ReadFile("/path/to/file.d2s")
if err != nil {
log.Fatal(err)
}
character, err := d2s.Unmarshal(data)
if err != nil {
log.Fatal(err)
}
// some edits
newData, err := d2d2s.Encode(character)
if err != nil {
log.fatal(err)
}
if err := ioutil.WriteFile("/path/to/new/file.d2s", newData, 0o600); err != nil {
log.Fatal("error writing file")
}
}
for more examples, see here
this programm should be able to decode, encode and create a new D2S files
Diablo 2 and its content is ©2000 Blizzard Entertainment, Inc. All rights reserved. Diablo and Blizzard Entertainment are trademarks or registered trademarks of Blizzard Entertainment, Inc. in the U.S. and/or other countries.
This package is ABSOLUTLY NO WARRITY! The code developers aren't responsible for any damage caused by this software or illegal uses of it!
Sometimes, you may want to parse some custom d2s files. For example these created by certain d2 mods. They are not supported by default, however you can do some configuration to support them.
NOTE: add this code in your custom implementation of package or modify cmd/editor
NOTE: in case of any problems/errors please fill an issue in this repo!
myD2S := d2s.New()
m := map[d2sstats.StatID]int{
d2sstats.Strength: 11,
d2sstats.Energy: 11,
d2sstats.Dexterity: 11,
d2sstats.Vitality: 11,
d2sstats.UnusedStats: 11,
d2sstats.UnusedSkills: 8,
d2sstats.CurrentHP: 21,
d2sstats.MaxHP: 21,
d2sstats.CurrentMana: 21,
d2sstats.MaxMana: 21,
d2sstats.CurrentStamina: 21,
d2sstats.MaxStamina: 21,
d2sstats.Level: 8,
d2sstats.Experience: 32,
d2sstats.Gold: 22,
d2sstats.StashedGold: 25,
88: 48,
}
myD2S.Stats.UserStatMap(m)
myD2S.Skills.SetSkillsCount(95)
myD2S.Items.IgnoreErrors()