Skip to content

Commit

Permalink
Make d2info work in multiplayer (LAN/private servers)
Browse files Browse the repository at this point in the history
  • Loading branch information
squeek502 committed Feb 7, 2019
1 parent 217e06b commit 1f12234
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Currently, it provides the following information:
- Number of experience 'ticks' gained (pixels filled in the experience bar)
- Information about the current area, like monster level and % xp gain (unfinished, disabled by default; see `SHOW_AREA_INFORMATION` in the config)

Supports Diablo II versions 1.13c, 1.13d, 1.14b, 1.14c, and 1.14d (D2SE and/or PlugY are also supported)
Supports Diablo II versions 1.13c, 1.13d, 1.14b, 1.14c, and 1.14d (D2SE and/or PlugY are also supported). It can also be used on LAN and private multiplayer servers (if it's allowed), however **it is not recommended to use it on Battle.net**, as it will most likely be considered a cheat and could result in a ban.

## Installation

Expand Down
13 changes: 9 additions & 4 deletions d2info/gamestate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,20 @@ function GameState.new(reader, config, output)
return self
end

function GameState:inValidGame()
return self.reader:getGamePointer() ~= nil and self.reader:getExperience() ~= nil
function GameState:inValidGame(multiplayer)
return (multiplayer or self.reader:getGamePointer() ~= nil) and self.reader:getExperience() ~= nil
end

function GameState:inMultiplayerGame()
return self.reader:getGamePointer() == nil and self.reader:getExperience() ~= nil
end

function GameState:inTown()
return self.area and self.area.town == true
end

function GameState:isPaused()
return self.ingame and self.lastFrameNumber and self.lastFrameNumber == self.frameNumber
return not self.multiplayer and self.ingame and self.lastFrameNumber and self.lastFrameNumber == self.frameNumber
end

function GameState:setupCurrentSession()
Expand Down Expand Up @@ -57,7 +61,8 @@ function GameState:getSessions()
end

function GameState:tick(ms)
self.ingame = self:inValidGame()
self.multiplayer = self:inMultiplayerGame()
self.ingame = self:inValidGame(self.multiplayer)
if self.ingame then
-- read current state
self.player = self.reader:getPlayerName()
Expand Down
8 changes: 6 additions & 2 deletions d2info/output.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local utils = require('d2info.utils')
local lfs = require('lfs')
local printf, friendlyNumber, friendlyTime, toFile = utils.printf, utils.friendlyNumber, utils.friendlyTime, utils.toFile
local friendlyNumber, friendlyTime, toFile = utils.friendlyNumber, utils.friendlyTime, utils.toFile
local expToPercentLeveled = utils.expToPercentLeveled

local Output = {}
Expand All @@ -26,7 +26,11 @@ function Output:toScreen(state)
local sessions = state:getSessions()
local total, current, last = sessions.total, sessions.current, sessions.last
self:buffer("%s (level %d & %.2f%%)", state.player, state.level, expToPercentLeveled(state.exp, state.level)*100)
self:buffer("/players %d", state.playersX)
if state.multiplayer then
self:buffer("Multiplayer")
else
self:buffer("/players %d", state.playersX)
end

if current then
self:buffer("\nRun #%d:", total.runs+1)
Expand Down

0 comments on commit 1f12234

Please sign in to comment.