diff --git a/pkg/data/object/shrine_type.go b/pkg/data/object/shrine_type.go new file mode 100644 index 0000000..7c2addc --- /dev/null +++ b/pkg/data/object/shrine_type.go @@ -0,0 +1,58 @@ +package object + +type ShrineType uint + +type ShrineData struct { + ShrineName string + ShrineType ShrineType +} + +const ( + RefillShrine ShrineType = 0x01 + HealthShrine ShrineType = 0x02 + ManaShrine ShrineType = 0x03 + HPXChangeShrine ShrineType = 0x04 + ManaXChangeShrine ShrineType = 0x05 + ArmorShrine ShrineType = 0x06 + CombatShrine ShrineType = 0x07 + ResistFireShrine ShrineType = 0x08 + ResistColdShrine ShrineType = 0x09 + ResistLightningShrine ShrineType = 0x0A + ResistPoisonShrine ShrineType = 0x0B + SkillShrine ShrineType = 0x0C + ManaRegenShrine ShrineType = 0x0D + StaminaShrine ShrineType = 0x0E + ExperienceShrine ShrineType = 0x0F + UnknownShrine ShrineType = 0x10 + PortalShrine ShrineType = 0x11 + GemShrine ShrineType = 0x12 + FireShrine ShrineType = 0x13 + MonsterShrine ShrineType = 0x14 + ExplosiveShrine ShrineType = 0x15 + PoisonShrine ShrineType = 0x16 +) + +var ShrineTypeNames = map[ShrineType]string{ + RefillShrine: "Refill Shrine", + HealthShrine: "Health Shrine", + ManaShrine: "Mana Shrine", + HPXChangeShrine: "HP XChange Shrine", + ManaXChangeShrine: "Mana XChange Shrine", + ArmorShrine: "Armor Shrine", + CombatShrine: "Combat Shrine", + ResistFireShrine: "Resist Fire Shrine", + ResistColdShrine: "Resist Cold Shrine", + ResistLightningShrine: "Resist Lightning Shrine", + ResistPoisonShrine: "Resist Poison Shrine", + SkillShrine: "Skill Shrine", + ManaRegenShrine: "Mana Regen Shrine", + StaminaShrine: "Stamina Shrine", + ExperienceShrine: "Experience Shrine", + UnknownShrine: "Unknown Shrine", + PortalShrine: "Portal Shrine", + GemShrine: "Gem Shrine", + FireShrine: "Fire Shrine", + MonsterShrine: "Monster Shrine", + ExplosiveShrine: "Explosive Shrine", + PoisonShrine: "Poison Shrine", +} diff --git a/pkg/data/objects.go b/pkg/data/objects.go index 9bc548e..f3c1920 100644 --- a/pkg/data/objects.go +++ b/pkg/data/objects.go @@ -8,6 +8,7 @@ type Object struct { IsHovered bool Selectable bool InteractType object.InteractType + Shrine object.ShrineData Position Position Owner string } @@ -34,6 +35,35 @@ func (o Objects) FindByID(id UnitID) (Object, bool) { return Object{}, false } +func (o Object) IsShrine() bool { + switch o.Shrine.ShrineType { + case object.RefillShrine, + object.HealthShrine, + object.ManaShrine, + object.HPXChangeShrine, + object.ManaXChangeShrine, + object.ArmorShrine, + object.CombatShrine, + object.ResistFireShrine, + object.ResistColdShrine, + object.ResistLightningShrine, + object.ResistPoisonShrine, + object.SkillShrine, + object.ManaRegenShrine, + object.StaminaShrine, + object.ExperienceShrine, + object.UnknownShrine, + object.PortalShrine, + object.GemShrine, + object.FireShrine, + object.MonsterShrine, + object.ExplosiveShrine, + object.PoisonShrine: + return true + } + return false +} + func (o Object) IsWaypoint() bool { switch o.Name { case object.WaypointPortal, diff --git a/pkg/memory/game_reader.go b/pkg/memory/game_reader.go index ab5c835..a9170f5 100644 --- a/pkg/memory/game_reader.go +++ b/pkg/memory/game_reader.go @@ -1,9 +1,10 @@ package memory import ( + "math" + "github.com/hectorgimenez/d2go/pkg/data" "github.com/hectorgimenez/d2go/pkg/data/stat" - "math" ) type GameReader struct { diff --git a/pkg/memory/object.go b/pkg/memory/object.go index bb07045..1670751 100644 --- a/pkg/memory/object.go +++ b/pkg/memory/object.go @@ -29,7 +29,21 @@ func (gd *GameReader) Objects(playerPosition data.Position, hover data.HoverData posY := gd.Process.ReadUInt(pathPtr+0x14, Uint16) unitDataPtr := uintptr(gd.Process.ReadUInt(objectUnitPtr+0x10, Uint64)) - interactType := gd.Process.ReadUInt(unitDataPtr+0x08, Uint8) + // checking if this is a shrine + shrineTextPtr := uintptr(gd.Process.ReadUInt(objectUnitPtr+0x0A, Uint64)) + shrineType := uint(0) + interactType := uint(0) + shrineData := object.ShrineData{} + if shrineTextPtr > 0 { + shrineType = gd.Process.ReadUInt(unitDataPtr+0x08, Uint8) + shrineData = object.ShrineData{ + ShrineName: object.ShrineTypeNames[object.ShrineType(shrineType)], + ShrineType: object.ShrineType(shrineType), + } + + } else { + interactType = gd.Process.ReadUInt(unitDataPtr+0x08, Uint8) + } owner := gd.Process.ReadStringFromMemory(unitDataPtr+0x34, 32) obj := data.Object{ @@ -37,6 +51,7 @@ func (gd *GameReader) Objects(playerPosition data.Position, hover data.HoverData Name: object.Name(int(txtFileNo)), IsHovered: data.UnitID(unitID) == hover.UnitID && hover.UnitType == 2 && hover.IsHovered, InteractType: object.InteractType(interactType), + Shrine: shrineData, Selectable: mode == 0, Position: data.Position{ X: int(posX),