adjustement
This commit is contained in:
7
pkg/data/game/game.go
Normal file
7
pkg/data/game/game.go
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
package game
|
||||||
|
|
||||||
|
const (
|
||||||
|
CharClassic uint16 = 1
|
||||||
|
CharLoD uint16 = 2
|
||||||
|
CharDLC uint16 = 3
|
||||||
|
)
|
||||||
@@ -1,18 +1,16 @@
|
|||||||
package item
|
package item
|
||||||
|
|
||||||
import "strings"
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/hectorgimenez/d2go/pkg/data/game"
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ExpCharItemIDThreshold = 508
|
ExpCharItemIDThreshold = 508
|
||||||
ExpCharItemIDOffset = 15
|
ExpCharItemIDOffset = 15
|
||||||
)
|
)
|
||||||
|
|
||||||
var ExpChar uint16
|
|
||||||
|
|
||||||
func SetExpChar(expChar uint16) {
|
|
||||||
ExpChar = expChar
|
|
||||||
}
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ScrollOfTownPortal = "ScrollOfTownPortal"
|
ScrollOfTownPortal = "ScrollOfTownPortal"
|
||||||
ScrollOfIdentify = "ScrollOfIdentify"
|
ScrollOfIdentify = "ScrollOfIdentify"
|
||||||
@@ -21,9 +19,9 @@ const (
|
|||||||
Key = "Key"
|
Key = "Key"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetNameByEnum(itemNumber uint) Name {
|
func GetNameByEnumWithExpChar(expChar uint16, itemNumber uint) Name {
|
||||||
idx := int(itemNumber)
|
idx := int(itemNumber)
|
||||||
if ExpChar >= 3 && idx >= ExpCharItemIDThreshold {
|
if expChar >= game.CharDLC && idx >= ExpCharItemIDThreshold {
|
||||||
idx += ExpCharItemIDOffset
|
idx += ExpCharItemIDOffset
|
||||||
}
|
}
|
||||||
if idx < 0 || idx >= len(Names) {
|
if idx < 0 || idx >= len(Names) {
|
||||||
@@ -32,17 +30,16 @@ func GetNameByEnum(itemNumber uint) Name {
|
|||||||
return Name(Names[idx])
|
return Name(Names[idx])
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetIDByName(itemName string) int {
|
// DescIDByName returns the internal description/index ID for an item name.
|
||||||
|
// This ID matches the keys used by Desc and the indices in the Names slice.
|
||||||
|
func DescIDByName(itemName string) (int, bool) {
|
||||||
for i, name := range Names {
|
for i, name := range Names {
|
||||||
if strings.EqualFold(name, itemName) {
|
if strings.EqualFold(name, itemName) {
|
||||||
if ExpChar >= 3 && i >= ExpCharItemIDThreshold+ExpCharItemIDOffset {
|
return i, true
|
||||||
return i - ExpCharItemIDOffset
|
|
||||||
}
|
|
||||||
return i
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1
|
return -1, false
|
||||||
}
|
}
|
||||||
|
|
||||||
type Name string
|
type Name string
|
||||||
|
|||||||
@@ -121,11 +121,17 @@ type Drop struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (i Item) Desc() item.Description {
|
func (i Item) Desc() item.Description {
|
||||||
id := i.ID
|
if descID, ok := item.DescIDByName(string(i.Name)); ok {
|
||||||
if item.ExpChar >= 3 && id >= item.ExpCharItemIDThreshold {
|
if desc, found := item.Desc[descID]; found {
|
||||||
id += item.ExpCharItemIDOffset
|
return desc
|
||||||
}
|
}
|
||||||
return item.Desc[id]
|
}
|
||||||
|
|
||||||
|
if desc, found := item.Desc[i.ID]; found {
|
||||||
|
return desc
|
||||||
|
}
|
||||||
|
|
||||||
|
return item.Description{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i Item) Type() item.Type {
|
func (i Item) Type() item.Type {
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (gd *GameReader) Inventory(rawPlayerUnits RawPlayerUnits, hover data.HoverData) data.Inventory {
|
func (gd *GameReader) Inventory(rawPlayerUnits RawPlayerUnits, hover data.HoverData) data.Inventory {
|
||||||
item.SetExpChar(gd.ExpChar)
|
|
||||||
mainPlayer := rawPlayerUnits.GetMainPlayer()
|
mainPlayer := rawPlayerUnits.GetMainPlayer()
|
||||||
baseAddr := gd.Process.moduleBaseAddressPtr + gd.offset.UnitTable + (4 * 1024)
|
baseAddr := gd.Process.moduleBaseAddressPtr + gd.offset.UnitTable + (4 * 1024)
|
||||||
unitTableBuffer := gd.Process.ReadBytesFromMemory(baseAddr, 128*8)
|
unitTableBuffer := gd.Process.ReadBytesFromMemory(baseAddr, 128*8)
|
||||||
@@ -132,7 +131,7 @@ func (gd *GameReader) Inventory(rawPlayerUnits RawPlayerUnits, hover data.HoverD
|
|||||||
itm := &data.Item{
|
itm := &data.Item{
|
||||||
ID: int(txtFileNo),
|
ID: int(txtFileNo),
|
||||||
UnitID: data.UnitID(unitID),
|
UnitID: data.UnitID(unitID),
|
||||||
Name: item.GetNameByEnum(txtFileNo),
|
Name: item.GetNameByEnumWithExpChar(gd.ExpChar, txtFileNo),
|
||||||
Quality: item.Quality(itemQuality),
|
Quality: item.Quality(itemQuality),
|
||||||
Position: data.Position{
|
Position: data.Position{
|
||||||
X: int(itemX),
|
X: int(itemX),
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
|
|
||||||
"github.com/hectorgimenez/d2go/pkg/data"
|
"github.com/hectorgimenez/d2go/pkg/data"
|
||||||
"github.com/hectorgimenez/d2go/pkg/data/area"
|
"github.com/hectorgimenez/d2go/pkg/data/area"
|
||||||
|
"github.com/hectorgimenez/d2go/pkg/data/game"
|
||||||
"github.com/hectorgimenez/d2go/pkg/data/skill"
|
"github.com/hectorgimenez/d2go/pkg/data/skill"
|
||||||
"github.com/hectorgimenez/d2go/pkg/data/state"
|
"github.com/hectorgimenez/d2go/pkg/data/state"
|
||||||
)
|
)
|
||||||
@@ -40,7 +41,7 @@ func (gd *GameReader) GetRawPlayerUnits() RawPlayerUnits {
|
|||||||
expChar := gd.Process.ReadUInt(expCharPtr+0x5C, Uint16)
|
expChar := gd.Process.ReadUInt(expCharPtr+0x5C, Uint16)
|
||||||
gd.ExpChar = uint16(expChar)
|
gd.ExpChar = uint16(expChar)
|
||||||
isMainPlayer := gd.Process.ReadUInt(inventoryAddr+0x30, Uint16)
|
isMainPlayer := gd.Process.ReadUInt(inventoryAddr+0x30, Uint16)
|
||||||
if expChar >= 2 {
|
if expChar >= uint(game.CharLoD) {
|
||||||
isMainPlayer = gd.Process.ReadUInt(inventoryAddr+0x70, Uint16)
|
isMainPlayer = gd.Process.ReadUInt(inventoryAddr+0x70, Uint16)
|
||||||
}
|
}
|
||||||
isCorpse := gd.Process.ReadUInt(playerUnit+0x1AE, Uint8)
|
isCorpse := gd.Process.ReadUInt(playerUnit+0x1AE, Uint8)
|
||||||
|
|||||||
@@ -250,7 +250,11 @@ func (r Rule) Evaluate(it data.Item) (RuleResult, error) {
|
|||||||
case "class":
|
case "class":
|
||||||
stage1Props["class"] = int(it.Desc().Tier())
|
stage1Props["class"] = int(it.Desc().Tier())
|
||||||
case "name":
|
case "name":
|
||||||
|
if descID, ok := item.DescIDByName(string(it.Name)); ok {
|
||||||
|
stage1Props["name"] = descID
|
||||||
|
} else {
|
||||||
stage1Props["name"] = it.ID
|
stage1Props["name"] = it.ID
|
||||||
|
}
|
||||||
case "flag":
|
case "flag":
|
||||||
// 0x400000 (eth) | 0x4000000 (runeword) kolbot style
|
// 0x400000 (eth) | 0x4000000 (runeword) kolbot style
|
||||||
currentFlag := 0
|
currentFlag := 0
|
||||||
@@ -487,7 +491,8 @@ func replaceStringPropertiesInStage1(stage1 string) (string, error) {
|
|||||||
case "class":
|
case "class":
|
||||||
replaceWith = strings.ReplaceAll(prop[0], prop[4], fmt.Sprintf("%d", classAliases[prop[4]]))
|
replaceWith = strings.ReplaceAll(prop[0], prop[4], fmt.Sprintf("%d", classAliases[prop[4]]))
|
||||||
case "name":
|
case "name":
|
||||||
replaceWith = strings.ReplaceAll(prop[0], prop[4], fmt.Sprintf("%d", item.GetIDByName(prop[4])))
|
descID, _ := item.DescIDByName(prop[4])
|
||||||
|
replaceWith = strings.ReplaceAll(prop[0], prop[4], fmt.Sprintf("%d", descID))
|
||||||
case "flag":
|
case "flag":
|
||||||
val := 0
|
val := 0
|
||||||
switch strings.ToLower(prop[4]) {
|
switch strings.ToLower(prop[4]) {
|
||||||
|
|||||||
Reference in New Issue
Block a user