public bool TalkToTrader(UInt32 id)
{
BotGameData.TalkedToNpc = false;
NpcEntity npc = BotGameData.Npcs[id];
double distance = BotGameData.Me.Location.Distance(npc.Location);
//if(debugging)
Console.WriteLine("{0}: [D2GS] Attempting to talk to NPC",Account);
SendPacket(0x59, GenericServer.one, BitConverter.GetBytes(id),
BitConverter.GetBytes((UInt16)BotGameData.Me.Location.X), GenericServer.zero, GenericServer.zero,
BitConverter.GetBytes((UInt16)BotGameData.Me.Location.Y), GenericServer.zero, GenericServer.zero);
int sleepStep = 200;
for (int timeDifference = (int)distance * 120; timeDifference > 0; timeDifference -= sleepStep)
{
SendPacket(0x04, GenericServer.one, BitConverter.GetBytes(id));
Thread.Sleep(Math.Min(sleepStep,timeDifference));
}
SendPacket(0x13, GenericServer.one, BitConverter.GetBytes(id));
Thread.Sleep(200);
SendPacket(0x2f, GenericServer.one, BitConverter.GetBytes(id));
int timeoutStep = 100;
for (long npc_timeout = 4000; npc_timeout > 0 && !BotGameData.TalkedToNpc; npc_timeout -= timeoutStep)
Thread.Sleep(timeoutStep);
if (!BotGameData.TalkedToNpc)
{
Console.WriteLine("{0}: [D2GS] Failed to talk to NPC", Account);
return false;
}
return true;
}