Skip to content

Commit

Permalink
Add set_attributes_req
Browse files Browse the repository at this point in the history
`set_attributes_req` is a companion array to `set_attributes` that stores the number of items that need to be worn for the corresponding property list to be active

Example json output:
```
"set_attributes":[[{"id":43,"name":"Cold Resist +{0}%","values":[40]}]],"set_attributes_req":[3]
```

which means that set_attributes[0] requires >= 3 items (set_attributes_req[0] is 3) of the set to be worn to recieve those bonuses

Addresses nokka#5
  • Loading branch information
squeek502 committed Mar 18, 2019
1 parent db00d42 commit ecd732e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
13 changes: 12 additions & 1 deletion d2s.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,8 +588,9 @@ func parseItemList(bfr io.ByteReader, itemCount int) ([]item, error) {

// If the item is part of a set, these bit will tell us how many lists
// of magical properties follow the one regular magical property list.
var setListValue uint64 = 0
if parsed.Quality == partOfSet {
setListValue := reverseBits(ibr.ReadBits64(5, true), 5)
setListValue = reverseBits(ibr.ReadBits64(5, true), 5)
readBits += 5

listCount, ok := setListMap[setListValue]
Expand Down Expand Up @@ -623,6 +624,16 @@ func parseItemList(bfr io.ByteReader, itemCount int) ([]item, error) {

parsed.SetAttributes = append(parsed.SetAttributes, setAttrList)
}
// The bits set in setListValue correspond to the number
// of items that need to be worn for each list of magical properties
// to be active
for i := 0; i < 5; i++ {
if (setListValue & (1 << uint(i)) == 0) {
continue
}
// bit position 0 means it requires >= 2 items worn, etc
parsed.SetAttributesReq = append(parsed.SetAttributesReq, uint(i+2))
}
}

if parsed.GivenRuneword == 1 {
Expand Down
1 change: 1 addition & 0 deletions item.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type item struct {
SetName string `json:"set_name,omitempty"`
SetListCount uint64 `json:"set_list_count"`
SetAttributes [][]magicAttribute `json:"set_attributes"`
SetAttributesReq []uint `json:"set_attributes_req,omitempty"`
RareName string `json:"rare_name,omitempty"`
RareName2 string `json:"rare_name2,omitempty"`
MagicalNameIDs []uint64 `json:"magical_name_ids,omitempty"`
Expand Down

0 comments on commit ecd732e

Please sign in to comment.