byte ActionGetObject(ref int[] found, byte max, float ox, float oy, int objectid, byte metre)
{
byte founded = 1;
found[1] = Character.Action.Target;
try
{
float x = (float)ox - metre;
float y = (float)oy - metre;
for (int i = 0; i <= Systems.Objects.Count - 1; i++)
{
if (founded == max) return founded;
obj o = Systems.Objects[i];
if (!o.Die && o.LocalType == 1)
{
if (o.x >= x && o.x <= (x + (metre * 2)) && o.y >= y && o.y <= (y + (metre * 2)) && o.UniqueID != objectid)
{
founded++;
if (o.Agro == null) o.Agro = new List<_agro>();
found[founded] = o.UniqueID;
}
}
}
lock (Systems.clients)
{
for (int i = 0; i < Systems.clients.Count; i++)
{
try
{
if (founded == max) return founded;
Systems sys = Systems.clients[i];
if (sys.Character.Information.PvP)
{
if (sys.Character.Information.UniqueID != objectid && Character.Information.UniqueID != objectid && Systems.clients[i].Character.Information.UniqueID != this.Character.Information.UniqueID)
{
if (sys.Character.Position.x >= x && sys.Character.Position.x <= (x + (metre * 2)) && sys.Character.Position.y >= y && sys.Character.Position.y <= (y + (metre * 2)))
{
founded++;
found[founded] = sys.Character.Information.UniqueID;
}
}
}
}
catch (Exception ex)
{
Console.WriteLine("ActionGetObject Error on index {1}/{2}: {0}", ex, i, Systems.clients.Count);
Systems.Debugger.Write(ex);
}
}
}
}
catch (Exception ex)
{
Console.WriteLine("ActionGetObject()::error...");
Systems.Debugger.Write(ex);
}
return founded;
}