Added shrines (#31)

* Added shrines, i think

* Fixed shrines

* Fix for actually determining a shrine the correct way

* Updated to use a Shrine object instead of a boring ID

* After deliberation, removed extra position thingamajigger
This commit is contained in:
Farmith
2024-08-15 19:38:14 +02:00
committed by GitHub
parent 8e67284940
commit 52b0de329f
4 changed files with 106 additions and 2 deletions

View File

@@ -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",
}

View File

@@ -8,6 +8,7 @@ type Object struct {
IsHovered bool IsHovered bool
Selectable bool Selectable bool
InteractType object.InteractType InteractType object.InteractType
Shrine object.ShrineData
Position Position Position Position
Owner string Owner string
} }
@@ -34,6 +35,35 @@ func (o Objects) FindByID(id UnitID) (Object, bool) {
return Object{}, false 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 { func (o Object) IsWaypoint() bool {
switch o.Name { switch o.Name {
case object.WaypointPortal, case object.WaypointPortal,

View File

@@ -1,9 +1,10 @@
package memory package memory
import ( import (
"math"
"github.com/hectorgimenez/d2go/pkg/data" "github.com/hectorgimenez/d2go/pkg/data"
"github.com/hectorgimenez/d2go/pkg/data/stat" "github.com/hectorgimenez/d2go/pkg/data/stat"
"math"
) )
type GameReader struct { type GameReader struct {

View File

@@ -29,7 +29,21 @@ func (gd *GameReader) Objects(playerPosition data.Position, hover data.HoverData
posY := gd.Process.ReadUInt(pathPtr+0x14, Uint16) posY := gd.Process.ReadUInt(pathPtr+0x14, Uint16)
unitDataPtr := uintptr(gd.Process.ReadUInt(objectUnitPtr+0x10, Uint64)) 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) owner := gd.Process.ReadStringFromMemory(unitDataPtr+0x34, 32)
obj := data.Object{ obj := data.Object{
@@ -37,6 +51,7 @@ func (gd *GameReader) Objects(playerPosition data.Position, hover data.HoverData
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),
Shrine: shrineData,
Selectable: mode == 0, Selectable: mode == 0,
Position: data.Position{ Position: data.Position{
X: int(posX), X: int(posX),