- Added OnlineGame info ( game name/pass ) (#32)

- Added IsInGame bool
- Added IsOnline bool :)
- Added IsInCharacterCreation bool
This commit is contained in:
Arto Simonyan
2024-08-16 12:29:50 +03:00
committed by GitHub
parent 52b0de329f
commit a356597630
2 changed files with 79 additions and 33 deletions

View File

@@ -28,21 +28,27 @@ type Data struct {
Corpse Corpse
Monsters Monsters
Corpses Monsters
Game OnlineGame
// First slice represents X and second Y
CollisionGrid [][]bool
PlayerUnit PlayerUnit
NPCs NPCs
Inventory Inventory
Objects Objects
AdjacentLevels []Level
Rooms []Room
OpenMenus OpenMenus
Roster Roster
HoverData HoverData
TerrorZones []area.ID
Quests quest.Quests
KeyBindings KeyBindings
LegacyGraphics bool
CollisionGrid [][]bool
PlayerUnit PlayerUnit
NPCs NPCs
Inventory Inventory
Objects Objects
AdjacentLevels []Level
Rooms []Room
OpenMenus OpenMenus
Roster Roster
HoverData HoverData
TerrorZones []area.ID
Quests quest.Quests
KeyBindings KeyBindings
LegacyGraphics bool
IsOnline bool
IsIngame bool
IsInCharCreationScreen bool
IsInCharSelectionScreen bool
IsInLobby bool
}
type Room struct {
@@ -57,6 +63,11 @@ type HoverData struct {
UnitType int
}
type OnlineGame struct {
LastGameName string
LastGamePassword string
}
func (r Room) GetCenter() Position {
return Position{
X: r.Position.X + r.Width/2,

View File

@@ -8,8 +8,7 @@ import (
)
type GameReader struct {
offset Offset
previousRead data.Data
offset Offset
Process
}
@@ -28,9 +27,6 @@ func (gd *GameReader) GetData() data.Data {
rawPlayerUnits := gd.GetRawPlayerUnits()
roster := gd.getRoster(rawPlayerUnits)
mainPlayerUnit := rawPlayerUnits.GetMainPlayer()
if mainPlayerUnit.Address == 0 {
return gd.previousRead
}
pu := gd.GetPlayerUnit(mainPlayerUnit)
hover := gd.hoveredData()
@@ -49,22 +45,29 @@ func (gd *GameReader) GetData() data.Data {
IsHovered: corpseUnit.IsHovered,
Position: corpseUnit.Position,
},
Monsters: gd.Monsters(pu.Position, hover),
Corpses: gd.Corpses(pu.Position, hover),
PlayerUnit: pu,
Inventory: gd.Inventory(rawPlayerUnits, hover),
Objects: gd.Objects(pu.Position, hover),
OpenMenus: gd.openMenus(),
Roster: roster,
HoverData: hover,
TerrorZones: gd.TerrorZones(),
Quests: gd.getQuests(gameQuestsBytes),
KeyBindings: gd.GetKeyBindings(),
LegacyGraphics: gd.LegacyGraphics(),
Game: data.OnlineGame{
LastGameName: gd.LastGameName(),
LastGamePassword: gd.LastGamePass(),
},
Monsters: gd.Monsters(pu.Position, hover),
Corpses: gd.Corpses(pu.Position, hover),
PlayerUnit: pu,
Inventory: gd.Inventory(rawPlayerUnits, hover),
Objects: gd.Objects(pu.Position, hover),
OpenMenus: gd.openMenus(),
Roster: roster,
HoverData: hover,
TerrorZones: gd.TerrorZones(),
Quests: gd.getQuests(gameQuestsBytes),
KeyBindings: gd.GetKeyBindings(),
LegacyGraphics: gd.LegacyGraphics(),
IsOnline: gd.IsOnline(),
IsIngame: gd.IsIngame(),
IsInCharCreationScreen: gd.IsInCharacterCreationScreen(),
//IsInLobby: gd.IsInLobby(),
//IsInCharSelectionScreen: gd.IsInCharacterSelectionScreen(),
}
gd.previousRead = d
return d
}
@@ -199,3 +202,35 @@ func (gd *GameReader) GetSelectedCharacterName() string {
func (gd *GameReader) LegacyGraphics() bool {
return gd.ReadUInt(gd.moduleBaseAddressPtr+0x21F6388, Uint64) == 1
}
func (gd *GameReader) IsOnline() bool {
// This represents which tab (Online/Offline) we're on in the Character Selection Screen
return gd.ReadUInt(gd.moduleBaseAddressPtr+0x2154F50, 1) == 1
}
func (gd *GameReader) IsIngame() bool {
return gd.ReadUInt(gd.moduleBaseAddressPtr+0x214CB48, 1) == 1
}
/*
func (gd *GameReader) IsInLobby() bool {
return gd.ReadUInt(gd.moduleBaseAddressPtr+0x21CF488, 1) == 1
}
func (gd *GameReader) IsInCharacterSelectionScreen() bool {
return gd.ReadUInt(gd.moduleBaseAddressPtr+0x1DC7276, 1) != 0
}
*/
func (gd *GameReader) IsInCharacterCreationScreen() bool {
// This will bug out if you switch to legacy graphics in the character select screen and return 1 until you go back to character screen with d2r graphics
return gd.ReadUInt(gd.moduleBaseAddressPtr+0x234A1CE, 1) == 1
}
func (gd *GameReader) LastGameName() string {
return gd.ReadStringFromMemory(gd.moduleBaseAddressPtr+0x29DBD10+0x8, 0)
}
func (gd *GameReader) LastGamePass() string {
return gd.ReadStringFromMemory(gd.moduleBaseAddressPtr+0x29DBD10+0x60, 0)
}