add object owner

This commit is contained in:
Héctor Giménez
2024-04-10 08:53:45 +09:00
parent 58b995842d
commit c7aeb01089
2 changed files with 5 additions and 0 deletions

View File

@@ -3,11 +3,13 @@ package data
import "github.com/hectorgimenez/d2go/pkg/data/object" import "github.com/hectorgimenez/d2go/pkg/data/object"
type Object struct { type Object struct {
ID UnitID
Name object.Name Name object.Name
IsHovered bool IsHovered bool
Selectable bool Selectable bool
InteractType object.InteractType InteractType object.InteractType
Position Position Position Position
Owner string
} }
type Objects []Object type Objects []Object

View File

@@ -30,8 +30,10 @@ func (gd *GameReader) Objects(playerPosition data.Position, hover data.HoverData
unitDataPtr := uintptr(gd.Process.ReadUInt(objectUnitPtr+0x10, Uint64)) unitDataPtr := uintptr(gd.Process.ReadUInt(objectUnitPtr+0x10, Uint64))
interactType := gd.Process.ReadUInt(unitDataPtr+0x08, Uint8) interactType := gd.Process.ReadUInt(unitDataPtr+0x08, Uint8)
owner := gd.Process.ReadStringFromMemory(unitDataPtr+0x34, 32)
obj := data.Object{ obj := data.Object{
ID: data.UnitID(unitID),
Name: object.Name(int(txtFileNo)), Name: object.Name(int(txtFileNo)),
IsHovered: data.UnitID(unitID) == hover.UnitID && hover.UnitType == 2 && hover.IsHovered, IsHovered: data.UnitID(unitID) == hover.UnitID && hover.UnitType == 2 && hover.IsHovered,
InteractType: object.InteractType(interactType), InteractType: object.InteractType(interactType),
@@ -40,6 +42,7 @@ func (gd *GameReader) Objects(playerPosition data.Position, hover data.HoverData
X: int(posX), X: int(posX),
Y: int(posY), Y: int(posY),
}, },
Owner: owner,
} }
objects = append(objects, obj) objects = append(objects, obj)
} }