d2s

package module
v1.2.1-0...-7bc7525 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 30, 2021 License: MIT Imports: 9 Imported by: 0

README

This is a fork of the fantastic d2s parser https://github.com/nokka/d2s which will try to handle Project Diablo 2 https://www.projectdiablo2.com/ .d2s save files.

How to jumpstart:

Since I am on windows I downloaded and installed go1.15.6.windows-amd64.msi in the default path. I also downloaded and installed Visual Studio Code.

Now we are ready to fetch the repo. From a command line or powershell

go get github.com/xtsoler/d2s

This should download the repo in the "go" folder in the user directory. For windows it should be

C:\Users\{my_username}\go\src\github.com\xtsoler\d2s

This directory can be openned with git / gitExt etc.

Next we select "open folder" from Visual Studio Code or your favorite IDE. We can make changes in the files, for example in d2s.go or item.go. Then we can test our changes by running the following from the included in the repo corresponding directory with our CLI:

For windows batch:

set "GOARCH=amd64" && set "GOOS=windows" && go build d2s_pd2_run.go && d2s_pd2_run.exe ..\examples\pd2_thebow.d2s

This should give you the log output on the standard output of your cli. The output json file should also be created in the same directory.

To build for web

batch:

set "GOARCH=wasm" && set "GOOS=js" && go build -o pd2_d2s_parser_v001.wasm pd2_d2s_web.go

Documentation

Index

Constants

View Source
const (
	Amazon      = 0x00
	Sorceress   = 0x01
	Necromancer = 0x02
	Paladin     = 0x03
	Barbarian   = 0x04
	Druid       = 0x05
	Assassin    = 0x06
)

Mapper of the hex values of classes.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attributes

type Attributes struct {
	Strength          uint64 `json:"strength"`
	Energy            uint64 `json:"energy"`
	Dexterity         uint64 `json:"dexterity"`
	Vitality          uint64 `json:"vitality"`
	UnusedStats       uint64 `json:"unused_stats"`
	UnusedSkillPoints uint64 `json:"unused_skill_points"`
	CurrentHP         uint64 `json:"current_hp"`
	MaxHP             uint64 `json:"max_hp"`
	CurrentMana       uint64 `json:"current_mana"`
	MaxMana           uint64 `json:"max_mana"`
	CurrentStamina    uint64 `json:"current_stamina"`
	MaxStamina        uint64 `json:"max_stamina"`
	Level             uint64 `json:"level"`
	Experience        uint64 `json:"experience"`
	Gold              uint64 `json:"gold"`
	StashedGold       uint64 `json:"stashed_gold"`
}

Attributes are the different type of attributes a character can have.

type Character

type Character struct {
	Header      Header     `json:"header"`
	Attributes  Attributes `json:"attributes"`
	Skills      []Skill    `json:"skills"`
	Items       []Item     `json:"items"`
	CorpseItems []Item     `json:"corpse_items"`
	MercItems   []Item     `json:"merc_items"`
	GolemItem   *Item      `json:"golem_item"`
	IsDead      uint16     `json:"is_dead"`
}

Character represents all the d2s character data.

func Parse

func Parse(file io.Reader, debugOutput bool) (*Character, error)

Parse will read the data from a d2s character file and return a normalized struct.

func ParseFromContent

func ParseFromContent(data []byte) (*Character, error)

ParseFromContent will read the character from a byte slice.

type Header struct {
	Identifier  uint32      `json:"identifier"`
	Version     uint32      `json:"version"`
	FileSize    uint32      `json:"filesize"`
	CheckSum    uint32      `json:"checksum"`
	ActiveArms  uint32      `json:"active_arms"`
	Name        name        `json:"name"`
	Status      status      `json:"status"`
	Progression progression `json:"progression"`

	Class class `json:"class"`

	Level byte `json:"level"`

	LastPlayed uint32 `json:"last_played"`

	AssignedSkills [16]uint32 `json:"assigned_skills"`
	LeftSkill      uint32     `json:"left_skill"`
	RightSkill     uint32     `json:"right_skill"`
	LeftSwapSkill  uint32     `json:"left_swap_skill"`
	RightSwapSkill uint32     `json:"right_swap_skill"`

	CurrentDifficulty difficulty `json:"difficulty"`
	MapID             uint32     `json:"map_id"`

	DeadMerc   uint16 `json:"dead_merc"`
	MercID     uint32 `json:"merc_id"`
	MercNameID uint16 `json:"merc_name_id"`
	MercType   uint16 `json:"merc_type"`
	MercExp    uint32 `json:"merc_experience"`

	QuestHeader [4]byte `json:"-"`

	QuestsNormal   quests  `json:"quests_normal"`
	QuestsNm       quests  `json:"quests_nm"`
	QuestsHell     quests  `json:"quests_hell"`
	WaypointHeader [2]byte `json:"-"`

	WaypointsNormal [24]byte `json:"-"`
	WaypointsNm     [24]byte `json:"-"`
	WaypointsHell   [24]byte `json:"-"`
	WaypointTrailer byte     `json:"-"`
	NPCHeader       [2]byte  `json:"-"`

	NPCIntroNormal [5]byte `json:"-"`

	NPCIntroNm [5]byte `json:"-"`

	NPCIntroHell [5]byte `json:"-"`

	NPCReturnNorm [4]byte `json:"-"`

	NPCReturnNm [4]byte `json:"-"`

	NPCReturnHell [4]byte `json:"-"`

	StatHeader [2]byte `json:"-"`
	// contains filtered or unexported fields
}

Header determines the header data of a d2s file.

func (*Header) MarshalJSON

func (h *Header) MarshalJSON() ([]byte, error)

MarshalJSON ...

type Item

type Item struct {
	Identified          uint64             `json:"identified"`
	Socketed            uint64             `json:"socketed"`
	New                 uint64             `json:"new"`
	IsEar               uint64             `json:"is_ear"`
	StarterItem         uint64             `json:"starter_item"`
	SimpleItem          uint64             `json:"simple_item"`
	Ethereal            uint64             `json:"ethereal"`
	Personalized        uint64             `json:"personalized"`
	PersonalizedName    string             `json:"personalized_name,omitempty"`
	GivenRuneword       uint64             `json:"given_runeword"`
	Version             uint64             `json:"version"`
	LocationID          uint64             `json:"location_id"`
	EquippedID          uint64             `json:"equipped_id,omitempty"`
	PositionX           uint64             `json:"position_x"`
	PositionY           uint64             `json:"position_y"`
	AltPositionID       uint64             `json:"alt_position_id"`
	Type                string             `json:"type"`
	TypeID              uint64             `json:"type_id"`
	TypeName            string             `json:"type_name"`
	NrOfItemsInSockets  uint64             `json:"nr_of_items_in_sockets"`
	ID                  uint64             `json:"id"`
	Level               uint64             `json:"level"`
	Quality             uint64             `json:"quality"`
	MultiplePictures    uint64             `json:"multiple_pictures"`
	PictureID           uint64             `json:"picture_id"`
	ClassSpecific       uint64             `json:"class_specific"`
	LowQualityID        uint64             `json:"low_quality_id"`
	Timestamp           uint64             `json:"timestamp"`
	EarAttributes       earAttributes      `json:"ear_attributes"`
	DefenseRating       int64              `json:"defense_rating,omitempty"`
	MaxDurability       uint64             `json:"max_durability,omitempty"`
	CurrentDurability   uint64             `json:"current_durability,omitempty"`
	TotalNrOfSockets    uint64             `json:"total_nr_of_sockets"`
	Quantity            uint64             `json:"quantity,omitempty"`
	MagicPrefix         uint64             `json:"magic_prefix,omitempty"`
	MagicPrefixName     string             `json:"magic_prefix_name,omitempty"`
	MagicSuffix         uint64             `json:"magic_suffix,omitempty"`
	MagicSuffixName     string             `json:"magic_suffix_name,omitempty"`
	RunewordID          uint64             `json:"runeword_id,omitempty"`
	RunewordName        string             `json:"runeword_name,omitempty"`
	RunewordAttributes  []magicAttribute   `json:"runeword_attributes"`
	SetID               uint64             `json:"set_id,omitempty"`
	SetName             string             `json:"set_name,omitempty"`
	SetListCount        uint64             `json:"set_list_count"`
	SetAttributes       [][]magicAttribute `json:"set_attributes"`
	SetAttributesNumReq []uint             `json:"set_attributes_num_req,omitempty"`
	SetAttributesIDsReq []uint64           `json:"set_attributes_ids_req,omitempty"`
	RareName            string             `json:"rare_name,omitempty"`
	RareName2           string             `json:"rare_name2,omitempty"`
	MagicalNameIDs      []uint64           `json:"magical_name_ids,omitempty"`
	UniqueID            uint64             `json:"unique_id,omitempty"`
	UniqueName          string             `json:"unique_name,omitempty"`
	MagicAttributes     []magicAttribute   `json:"magic_attributes"`
	SocketedItems       []Item             `json:"socketed_items"`
	BaseDamage          *weaponDamage      `json:"base_damage,omitempty"`
}

Item describes any type of item and all it's data.

type Skill

type Skill struct {
	ID     int    `json:"id"`
	Points int    `json:"points"`
	Name   string `json:"name"`
}

Skill represents an available character skill in d2.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL