Merge remote-tracking branch 'origin/main' into pr/CarlPoppa1/9

This commit is contained in:
guiyomu-dev
2025-10-19 19:05:49 +02:00
8 changed files with 153 additions and 15 deletions

View File

@@ -2,5 +2,4 @@ package memory
const (
tzOffline = 0x29B3208
tzOnline = 0x29B3188
)

View File

@@ -109,6 +109,7 @@ func (gd *GameReader) GetData() data.Data {
LastGameName: gd.LastGameName(),
LastGamePassword: gd.LastGamePass(),
FPS: gd.FPS(),
Ping: gd.Ping(),
},
Monsters: monsters,
Corpses: gd.Corpses(pu.Position, hover),
@@ -312,7 +313,7 @@ func (gd *GameReader) GetSelectedCharacterName() string {
}
func (gd *GameReader) LegacyGraphics() bool {
return gd.ReadUInt(gd.Process.moduleBaseAddressPtr+0x22D845F, Uint8) != 0
return gd.ReadUInt(gd.Process.moduleBaseAddressPtr+gd.offset.LegacyGraphics, Uint8) != 0
}
func (gd *GameReader) IsOnline() bool {
@@ -428,17 +429,23 @@ func (gd *GameReader) IsDismissableModalPresent() (bool, string) {
}
func (gd *GameReader) LastGameName() string {
return gd.ReadStringFromMemory(gd.moduleBaseAddressPtr+0x2587FB8, 0)
return gd.ReadStringFromMemory(gd.moduleBaseAddressPtr+0x256E668, 0)
}
func (gd *GameReader) LastGamePass() string {
return gd.ReadStringFromMemory(gd.moduleBaseAddressPtr+0x2588018, 0)
return gd.ReadStringFromMemory(gd.moduleBaseAddressPtr+0x256E6C8, 0)
}
func (gd *GameReader) FPS() int {
return int(gd.ReadUInt(gd.moduleBaseAddressPtr+gd.offset.FPS, Uint32))
}
func (gd *GameReader) Ping() int {
ptrToStructPtr := gd.moduleBaseAddressPtr + gd.offset.Ping
structPtrAddr := gd.ReadUInt(ptrToStructPtr, Uint64)
return int(gd.ReadUInt(uintptr(structPtrAddr+36), Uint32))
}
func (gd *GameReader) HasMerc() bool {
return gd.ReadUInt(gd.Process.moduleBaseAddressPtr+gd.offset.UI+0x8, Uint8) != 0
}

View File

@@ -8,7 +8,7 @@ import (
)
func (gd *GameReader) GetKeyBindings() data.KeyBindings {
blob := gd.ReadBytesFromMemory(gd.moduleBaseAddressPtr+0x1DE5C24, 0x500)
blob := gd.ReadBytesFromMemory(gd.moduleBaseAddressPtr+gd.offset.KeyBindingsOffset, 0x500)
blobSkills := gd.ReadBytesFromMemory(gd.offset.KeyBindingsSkillsOffset, 0x500)
skillsKB := [16]data.SkillBinding{}

View File

@@ -18,6 +18,10 @@ type Offset struct {
KeyBindingsOffset uintptr
KeyBindingsSkillsOffset uintptr
QuestInfo uintptr
TZ uintptr
Quests uintptr
Ping uintptr
LegacyGraphics uintptr
}
func calculateOffsets(process *Process) Offset {
@@ -75,14 +79,16 @@ func calculateOffsets(process *Process) Offset {
fpsOffset := pattern - process.moduleBaseAddressPtr + 6 + fpsOffsetPtr
// Keybindings
pattern = process.FindPattern(memory, "\x00\xA8\x00\x00\x00\x00\x7F\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x0F\x00\x00\x00\x00\x00\x00\x80\x4C\x6F\x00\x00\x79\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x52", "xx????x?xx????xxxxxxxxxxxxx??x?xxxxxxxxxxx")
keyBindingsOffset := pattern + 0x65
pattern = process.FindPattern(memory, "\x48\x8D\x05\xAF\xEE", "xxxxx")
bytes = process.ReadBytesFromMemory(pattern+3, 4)
relativeOffset := int32(binary.LittleEndian.Uint32(bytes))
keyBindingsOffset := pattern - process.moduleBaseAddressPtr + 7 + uintptr(relativeOffset)
// KeyBindings Skills
pattern = process.FindPattern(memory, "\x0F\x10\x04\x24\x48\x6B\xC8\x1C\x48\x8D\x05", "xxxxxxxxxxx")
var keyBindingsSkillsOffset uintptr
bytes = process.ReadBytesFromMemory(pattern+11, 4)
relativeOffset := int32(binary.LittleEndian.Uint32(bytes))
relativeOffset = int32(binary.LittleEndian.Uint32(bytes))
keyBindingsSkillsOffset = uintptr(int64(pattern) + 15 + int64(relativeOffset))
// QuestInfo
@@ -90,6 +96,28 @@ func calculateOffsets(process *Process) Offset {
questInfoOffsetPtr := uintptr(process.ReadUInt(pattern+3, Uint32))
questInfoOffset := pattern - process.moduleBaseAddressPtr + 7 + questInfoOffsetPtr
// Terror Zones
pattern = process.FindPattern(memory, "\x48\x89\x05\xCC\xCC\xCC\xCC\x48\x8D\x05\xCC\xCC\xCC\xCC\x48\x89\x05\xCC\xCC\xCC\xCC\x48\x8D\x05\xCC\xCC\xCC\xCC\x48\x89\x15\xCC\xCC\xCC\xCC\x48\x89\x15", "xxx????xxx????xxx????xxx????xxx????xxx")
tzPtr := process.ReadUInt(pattern+3, Uint32)
tzOffset := pattern - process.moduleBaseAddressPtr + 7 + uintptr(tzPtr)
// Quest Bytes Data
pattern = process.FindPattern(memory, "\x42\xc6\x84\x28\x00\x00\x00\x00\x00\x49\xff\xc5\x49\x83\xfd\x29", "xxxx?????xxxxxxx")
bytes = process.ReadBytesFromMemory(pattern+4, 4)
questOffset := uintptr(binary.LittleEndian.Uint32(bytes))
questDataOffset := questOffset + 1
// Ping
pattern = process.FindPattern(memory, "\x48\x8B\x0D\xCC\xCC\xCC\xCC\x49\x2B\xC7", "xxx????xxx")
bytes = process.ReadBytesFromMemory(pattern+3, 4)
relativeOffset = int32(binary.LittleEndian.Uint32(bytes))
pingOffset := pattern - process.moduleBaseAddressPtr + 7 + uintptr(relativeOffset)
// LegacyGraphics
pattern = process.FindPattern(memory, "\x80\x3D\x00\x00\x00\x00\x00\x48\x8D\x54\x24\x30", "xx?????xxxxx")
legacyGfxPtr := uintptr(process.ReadUInt(pattern+2, Uint32))
legacyGfxOffset := pattern - process.moduleBaseAddressPtr + 7 + legacyGfxPtr
return Offset{
GameData: gameDataOffset,
UnitTable: unitTableOffset,
@@ -104,5 +132,9 @@ func calculateOffsets(process *Process) Offset {
KeyBindingsOffset: keyBindingsOffset,
KeyBindingsSkillsOffset: keyBindingsSkillsOffset,
QuestInfo: questInfoOffset,
TZ: tzOffset,
Quests: questDataOffset,
Ping: pingOffset,
LegacyGraphics: legacyGfxOffset,
}
}

View File

@@ -133,10 +133,20 @@ func (gd *GameReader) getSkills(skillListPtr uintptr) map[skill.ID]skill.Points
quantity := gd.Process.ReadUInt(skillPtr+0x40, Uint16)
charges := gd.Process.ReadUInt(skillPtr+0x48, Uint16)
skills[skill.ID(skillTxt)] = skill.Points{
Level: lvl,
Quantity: quantity,
Charges: charges,
shouldSetSkill := true
existingSkill, exists := skills[skill.ID(skillTxt)]
if exists {
if existingSkill.Charges == 0 && charges > 0 {
shouldSetSkill = false
}
}
if shouldSetSkill {
skills[skill.ID(skillTxt)] = skill.Points{
Level: lvl,
Quantity: quantity,
Charges: charges,
}
}
skillPtr = uintptr(gd.Process.ReadUInt(skillPtr+0x08, Uint64))

View File

@@ -5,10 +5,12 @@ import (
)
func (gd *GameReader) TerrorZones() (areas []area.ID) {
tz := gd.moduleBaseAddressPtr + tzOnline
structPtr := gd.moduleBaseAddressPtr + gd.offset.TZ
zonesPtr := uintptr(gd.ReadUInt(structPtr, Uint64))
actualActiveZoneCount := int(gd.ReadUInt(structPtr+0x8, Uint8))
for i := 0; i < 8; i++ {
tzArea := gd.ReadUInt(tz+uintptr(i*Uint32), Uint32)
for i := 0; i < actualActiveZoneCount; i++ {
tzArea := gd.ReadUInt(zonesPtr+uintptr(i*Uint32), Uint32)
if tzArea != 0 {
areas = append(areas, area.ID(tzArea))
}