Read WP data (#7)
This commit is contained in:
@@ -167,6 +167,7 @@ type PlayerUnit struct {
|
|||||||
Class Class
|
Class Class
|
||||||
LeftSkill skill.Skill
|
LeftSkill skill.Skill
|
||||||
RightSkill skill.Skill
|
RightSkill skill.Skill
|
||||||
|
AvailableWaypoints []area.Area // Is only filled when WP menu is open and only for the specific selected tab
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pu PlayerUnit) MaxGold() int {
|
func (pu PlayerUnit) MaxGold() int {
|
||||||
|
|||||||
@@ -132,3 +132,10 @@ func (gd *GameReader) getStatsData(statCount uint, statPtr uintptr) []stat.Data
|
|||||||
|
|
||||||
return stats
|
return stats
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Take a look to better ways to get this data, now it's very flakky, is just a random memory position + not in game
|
||||||
|
func (gd *GameReader) InCharacterSelectionScreen() bool {
|
||||||
|
uiBase := gd.Process.moduleBaseAddressPtr + gd.offset.UI - 0xA
|
||||||
|
|
||||||
|
return gd.Process.ReadUInt(uiBase, Uint8) != 1 && gd.Process.ReadUInt(gd.moduleBaseAddressPtr+0x1EC5AA8, Uint64) == 0
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package memory
|
package memory
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/binary"
|
||||||
"github.com/hectorgimenez/d2go/pkg/data"
|
"github.com/hectorgimenez/d2go/pkg/data"
|
||||||
"github.com/hectorgimenez/d2go/pkg/data/area"
|
"github.com/hectorgimenez/d2go/pkg/data/area"
|
||||||
"github.com/hectorgimenez/d2go/pkg/data/skill"
|
"github.com/hectorgimenez/d2go/pkg/data/skill"
|
||||||
@@ -136,6 +137,17 @@ func (gd *GameReader) GetPlayerUnit(playerUnit uintptr) data.PlayerUnit {
|
|||||||
levelPtr := uintptr(gd.Process.ReadUInt(room2Ptr+0x90, Uint64))
|
levelPtr := uintptr(gd.Process.ReadUInt(room2Ptr+0x90, Uint64))
|
||||||
levelNo := gd.Process.ReadUInt(levelPtr+0x1F8, Uint32)
|
levelNo := gd.Process.ReadUInt(levelPtr+0x1F8, Uint32)
|
||||||
|
|
||||||
|
availableWPs := make([]area.Area, 0)
|
||||||
|
// Probably there is a better place to pick up those values, since this seems to be very tied to the UI
|
||||||
|
wpList := gd.Process.ReadBytesFromMemory(gd.moduleBaseAddressPtr+0x21AD220, 0x48)
|
||||||
|
for i := 0; i < 0x48; i = i + 8 {
|
||||||
|
a := binary.LittleEndian.Uint32(wpList[i : i+4])
|
||||||
|
available := binary.LittleEndian.Uint32(wpList[i+4 : i+8])
|
||||||
|
if available == 1 || area.Area(levelNo) == area.Area(a) {
|
||||||
|
availableWPs = append(availableWPs, area.Area(a))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return data.PlayerUnit{
|
return data.PlayerUnit{
|
||||||
Name: name,
|
Name: name,
|
||||||
ID: data.UnitID(unitID),
|
ID: data.UnitID(unitID),
|
||||||
@@ -150,6 +162,7 @@ func (gd *GameReader) GetPlayerUnit(playerUnit uintptr) data.PlayerUnit {
|
|||||||
Class: class,
|
Class: class,
|
||||||
LeftSkill: skill.Skill(leftSkillId),
|
LeftSkill: skill.Skill(leftSkillId),
|
||||||
RightSkill: skill.Skill(rightSkillId),
|
RightSkill: skill.Skill(rightSkillId),
|
||||||
|
AvailableWaypoints: availableWPs,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user