diff --git a/pkg/data/data.go b/pkg/data/data.go index dcbb68a..8697386 100644 --- a/pkg/data/data.go +++ b/pkg/data/data.go @@ -1,6 +1,7 @@ package data import ( + "github.com/hectorgimenez/d2go/pkg/data/mode" "math" "strings" @@ -161,6 +162,7 @@ type PlayerUnit struct { LeftSkill skill.ID RightSkill skill.ID AvailableWaypoints []area.ID // Is only filled when WP menu is open and only for the specific selected tab + Mode mode.PlayerMode } func (pu PlayerUnit) FindStat(id stat.ID, layer int) (stat.Data, bool) { diff --git a/pkg/data/mode/player_mode.go b/pkg/data/mode/player_mode.go new file mode 100644 index 0000000..7e45451 --- /dev/null +++ b/pkg/data/mode/player_mode.go @@ -0,0 +1,26 @@ +package mode + +type PlayerMode uint32 + +const ( + Death PlayerMode = iota + StandingOutsideTown + Walking + Running + GettingHit + StandingInTown + WalkingInTown + Attacking1 + Attacking2 + Blocking + CastingSkill + ThrowingItem + Kicking + UsingSkill1 + UsingSkill2 + UsingSkill3 + UsingSkill4 + Dead + SkillActionSequence + KnockedBack +) diff --git a/pkg/memory/player.go b/pkg/memory/player.go index 8ba9514..2bbae4b 100644 --- a/pkg/memory/player.go +++ b/pkg/memory/player.go @@ -2,6 +2,7 @@ package memory import ( "encoding/binary" + "github.com/hectorgimenez/d2go/pkg/data/mode" "github.com/hectorgimenez/d2go/pkg/data" "github.com/hectorgimenez/d2go/pkg/data/area" @@ -46,6 +47,7 @@ func (gd *GameReader) GetRawPlayerUnits() RawPlayerUnits { baseStats := gd.getStatsList(statsListExPtr + 0x30) stats := gd.getStatsList(statsListExPtr + 0x88) states := gd.GetStates(statsListExPtr) + playerMode := mode.PlayerMode(gd.Process.ReadUInt(playerUnit+0x0c, Uint32)) rawPlayerUnits = append(rawPlayerUnits, RawPlayerUnit{ UnitID: data.UnitID(unitID), @@ -62,6 +64,7 @@ func (gd *GameReader) GetRawPlayerUnits() RawPlayerUnits { States: states, Stats: stats, BaseStats: baseStats, + Mode: playerMode, }) playerUnit = uintptr(gd.Process.ReadUInt(playerUnit+0x150, Uint64)) } @@ -111,6 +114,7 @@ func (gd *GameReader) GetPlayerUnit(mainPlayerUnit RawPlayerUnit) data.PlayerUni LeftSkill: skill.ID(leftSkillId), RightSkill: skill.ID(rightSkillId), AvailableWaypoints: availableWPs, + Mode: mainPlayerUnit.Mode, } return d diff --git a/pkg/memory/player_unit.go b/pkg/memory/player_unit.go index 1c2b9f4..0e03274 100644 --- a/pkg/memory/player_unit.go +++ b/pkg/memory/player_unit.go @@ -3,6 +3,7 @@ package memory import ( "github.com/hectorgimenez/d2go/pkg/data" "github.com/hectorgimenez/d2go/pkg/data/area" + "github.com/hectorgimenez/d2go/pkg/data/mode" "github.com/hectorgimenez/d2go/pkg/data/stat" "github.com/hectorgimenez/d2go/pkg/data/state" ) @@ -19,6 +20,7 @@ type RawPlayerUnit struct { States state.States Stats stat.Stats BaseStats stat.Stats + Mode mode.PlayerMode } type RawPlayerUnits []RawPlayerUnit