Hello,
It's more for network latency than the delay to interact with the game. In the bot, before/after action, I generally use code like "Sleep(Usefuls.Latency + XXms)".
Actual code used to get "Latency" :
/// <summary>
/// Gets the latency (between <see cref="wManagerSetting.LatencyMax"/> and <see cref="wManagerSetting.LatencyMin"/>, to get real latency use <see cref="LatencyReal"/>).
/// </summary>
/// <value>The latency.</value>
public static int Latency
{
get
{
lock (_lockLatency)
{
try
{
var real = LatencyReal;
if (real > wManagerSetting.CurrentSetting.LatencyMax)
real = wManagerSetting.CurrentSetting.LatencyMax;
if (real < wManagerSetting.CurrentSetting.LatencyMin)
real = wManagerSetting.CurrentSetting.LatencyMin;
return real;
}
catch (Exception e)
{
Logging.WriteError("Latency: " + e);
return 0;
}
}
}
}
private static readonly Object _lockLatencyReal = new Object();
/// <summary>
/// Gets the real latency (home+world)).
/// </summary>
/// <value>The real latency.</value>
public static int LatencyReal
{
get
{
lock (_lockLatencyReal)
{
try
{
if (!_timerLatency.IsReady || !Conditions.InGameAndConnectedAndAlive)
return _lastLatency;
_timerLatency = new Timer(30 * 1000);
var result = Lua.LuaDoString<int>("local _, _, lag = GetNetStats(); return lag;");
if (result > 0)
_lastLatency = result;
return _lastLatency;
}
catch (Exception e)
{
Logging.WriteError("LatencyReal: " + e);
return 0;
}
}
}
}