remove unecessary code due to bad game update
This commit is contained in:
@@ -106,17 +106,6 @@ func run() error {
|
|||||||
|
|
||||||
import "strings"
|
import "strings"
|
||||||
|
|
||||||
const (
|
|
||||||
ExpCharItemIDThreshold = 508
|
|
||||||
ExpCharItemIDOffset = 15
|
|
||||||
)
|
|
||||||
|
|
||||||
var ExpChar uint16
|
|
||||||
|
|
||||||
func SetExpChar(expChar uint16) {
|
|
||||||
ExpChar = expChar
|
|
||||||
}
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ScrollOfTownPortal = "ScrollOfTownPortal"
|
ScrollOfTownPortal = "ScrollOfTownPortal"
|
||||||
ScrollOfIdentify = "ScrollOfIdentify"
|
ScrollOfIdentify = "ScrollOfIdentify"
|
||||||
@@ -126,22 +115,12 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func GetNameByEnum(itemNumber uint) Name {
|
func GetNameByEnum(itemNumber uint) Name {
|
||||||
idx := int(itemNumber)
|
return Name(Names[itemNumber])
|
||||||
if ExpChar >= 3 && idx >= ExpCharItemIDThreshold {
|
|
||||||
idx += ExpCharItemIDOffset
|
|
||||||
}
|
|
||||||
if idx < 0 || idx >= len(Names) {
|
|
||||||
return Name("")
|
|
||||||
}
|
|
||||||
return Name(Names[idx])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetIDByName(itemName string) int {
|
func GetIDByName(itemName string) int {
|
||||||
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 - ExpCharItemIDOffset
|
|
||||||
}
|
|
||||||
return i
|
return i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -151,7 +130,6 @@ func GetIDByName(itemName string) int {
|
|||||||
|
|
||||||
type Name string
|
type Name string
|
||||||
|
|
||||||
|
|
||||||
var Names = []string{
|
var Names = []string{
|
||||||
`)
|
`)
|
||||||
for _, n := range names {
|
for _, n := range names {
|
||||||
|
|||||||
@@ -1,15 +1,6 @@
|
|||||||
package item
|
package item
|
||||||
|
|
||||||
import (
|
import "strings"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/hectorgimenez/d2go/pkg/data/game"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
ExpCharItemIDThreshold = 508
|
|
||||||
ExpCharItemIDOffset = 15
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ScrollOfTownPortal = "ScrollOfTownPortal"
|
ScrollOfTownPortal = "ScrollOfTownPortal"
|
||||||
@@ -19,27 +10,18 @@ const (
|
|||||||
Key = "Key"
|
Key = "Key"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetNameByEnumWithExpChar(expChar uint16, itemNumber uint) Name {
|
func GetNameByEnum(itemNumber uint) Name {
|
||||||
idx := int(itemNumber)
|
return Name(Names[itemNumber])
|
||||||
if expChar >= game.CharDLC && idx >= ExpCharItemIDThreshold {
|
|
||||||
idx += ExpCharItemIDOffset
|
|
||||||
}
|
|
||||||
if idx < 0 || idx >= len(Names) {
|
|
||||||
return Name("")
|
|
||||||
}
|
|
||||||
return Name(Names[idx])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// DescIDByName returns the internal description/index ID for an item name.
|
func GetIDByName(itemName string) int {
|
||||||
// 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) {
|
||||||
return i, true
|
return i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1, false
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
type Name string
|
type Name string
|
||||||
|
|||||||
@@ -121,17 +121,7 @@ type Drop struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (i Item) Desc() item.Description {
|
func (i Item) Desc() item.Description {
|
||||||
if descID, ok := item.DescIDByName(string(i.Name)); ok {
|
return item.Desc[i.ID]
|
||||||
if desc, found := item.Desc[descID]; found {
|
|
||||||
return desc
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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 {
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ type GameReader struct {
|
|||||||
monstersLastUpdate time.Time
|
monstersLastUpdate time.Time
|
||||||
inventoryLastUpdate time.Time
|
inventoryLastUpdate time.Time
|
||||||
objectsLastUpdate time.Time
|
objectsLastUpdate time.Time
|
||||||
ExpChar uint16
|
|
||||||
|
|
||||||
cachedMonsters data.Monsters
|
cachedMonsters data.Monsters
|
||||||
cachedInventory data.Inventory
|
cachedInventory data.Inventory
|
||||||
|
|||||||
@@ -131,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.GetNameByEnumWithExpChar(gd.ExpChar, txtFileNo),
|
Name: item.GetNameByEnum(txtFileNo),
|
||||||
Quality: item.Quality(itemQuality),
|
Quality: item.Quality(itemQuality),
|
||||||
Position: data.Position{
|
Position: data.Position{
|
||||||
X: int(itemX),
|
X: int(itemX),
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ func (gd *GameReader) GetRawPlayerUnits() RawPlayerUnits {
|
|||||||
|
|
||||||
expCharPtr := uintptr(gd.Process.ReadUInt(gd.moduleBaseAddressPtr+gd.offset.Expansion, Uint64))
|
expCharPtr := uintptr(gd.Process.ReadUInt(gd.moduleBaseAddressPtr+gd.offset.Expansion, Uint64))
|
||||||
expChar := gd.Process.ReadUInt(expCharPtr+0x5C, Uint16)
|
expChar := gd.Process.ReadUInt(expCharPtr+0x5C, Uint16)
|
||||||
gd.ExpChar = uint16(expChar)
|
|
||||||
isMainPlayer := gd.Process.ReadUInt(inventoryAddr+0x30, Uint16)
|
isMainPlayer := gd.Process.ReadUInt(inventoryAddr+0x30, Uint16)
|
||||||
if expChar >= uint(game.CharLoD) {
|
if expChar >= uint(game.CharLoD) {
|
||||||
isMainPlayer = gd.Process.ReadUInt(inventoryAddr+0x70, Uint16)
|
isMainPlayer = gd.Process.ReadUInt(inventoryAddr+0x70, Uint16)
|
||||||
|
|||||||
@@ -250,11 +250,7 @@ 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"] = it.ID
|
||||||
stage1Props["name"] = descID
|
|
||||||
} else {
|
|
||||||
stage1Props["name"] = it.ID
|
|
||||||
}
|
|
||||||
case "flag":
|
case "flag":
|
||||||
// 0x400000 (eth) | 0x4000000 (runeword) kolbot style
|
// 0x400000 (eth) | 0x4000000 (runeword) kolbot style
|
||||||
currentFlag := 0
|
currentFlag := 0
|
||||||
@@ -491,8 +487,7 @@ 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":
|
||||||
descID, _ := item.DescIDByName(prop[4])
|
replaceWith = strings.ReplaceAll(prop[0], prop[4], fmt.Sprintf("%d", item.GetIDByName(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