SRL Archive - OSR Help

Private Server Randoms [Genie]


DannyRS

2013-02-10 20:53:52

Ok, so how can I get any of these below 100ms ^^ any idea's? how did SRL handle randoms back in the day?





program test;

{$I SRL/SRL/Misc/Debug.Simba}

Var
IntCounter: Integer;

Function P06_FindGenieMiddleBox: Boolean;
Var
TBP,TBB: Tbox;
IP,IB,IY,LY,LP,LB,XP,YP,XB,YB,XY,YY: Integer;
PurpleTPA,BlueTPA,YellowTPA: TPointArray;
PurpleATPA,BlueATPA,YellowATPA: T2DPointArray;
Begin
FindColorsTolerance(PurpleTPA, 8392314, 0, 0, 605, 357, 31);
//DebugTPA(PurpleTPA,'testgenie');
FindColorsTolerance(BlueTPA, 14717768, 0, 0, 605, 357, 64);
//DebugTPA(BlueTPA,'testgenie');
FindColorsTolerance(YellowTPA, 1353623, 0, 0, 605, 357, 47);
//DebugTPA(YellowTPA,'testgenie');
SplitTPAWrap(PurpleTPA, 22, PurpleATPA);
SortATPASize(PurpleATPA,True);
SplitTPAWrap(BlueTPA, 10, BlueATPA);
SortATPASize(BlueATPA,True);
SplitTPAWrap(YellowTPA, 10, YellowATPA);
SortATPASize(YellowATPA,True);
LP := High(PurpleATPA);
LB := High(BlueATPA);
LY := High(YellowATPA);
For IP := 0 to LP do
Begin
MiddleTPAEx(PurpleATPA[IP], XP, YP);
TBP:=IntToBox(XP-15, YP-15, XP+15, YP+15);
For IB := 0 to LB do
Begin
MiddleTPAEx(BlueATPA[IB], XB, YB);
If (PointInBox(Point(XB,YB), TBP)) Then
Begin
TBB:=IntToBox(XB-15, YB-15, XB+15, YB+15);
For IY := 0 to LY do
Begin
MiddleTPAEx(YellowATPA[IY], XY, YY);
If (PointInBox(Point(XY,YY), TBB)) Then
Begin
Result:=True;
//DebugTPA(BlueATPA[IB],'testgenie');
Exit;
End;
End;
End;
End;
End;
Result:=False;
End;

Function P06_FindGenieWidthHeight: Boolean;
Var
TBP,TBB: Tbox;
IP,IB,LP,LB,XB,YB: Integer;
PurpleTPA,BlueTPA: TPointArray;
PurpleATPA,BlueATPA: T2DPointArray;
Begin
FindColorsTolerance(PurpleTPA, 8392314, 0, 0, 605, 357, 31);
//DebugTPA(PurpleTPA,'testgenie');
FindColorsTolerance(BlueTPA, 14717768, 0, 0, 605, 357, 64);
//DebugTPA(BlueTPA,'testgenie');
SplitTPAWrap(PurpleTPA, 22, PurpleATPA);
SortATPASize(PurpleATPA,True);
SplitTPAWrap(BlueTPA, 10, BlueATPA);
SortATPASize(BlueATPA,True);
LP := High(PurpleATPA);
LB := High(BlueATPA);
For IP := 0 to LP do
Begin
TBP:=GetTPABounds(PurpleATPA[IP]);
If ((TBP.X2-TBP.X1)<12) Or ((TBP.Y2-TBP.Y1)<15) Then
Continue;
For IB := 0 to LB do
Begin
TBB:=GetTPABounds(BlueATPA[IB]);
If ((TBB.X2-TBB.X1)<7) Or ((TBB.Y2-TBB.Y1)<13) Then
Continue;
XB:=(TBB.X1+((TBB.X2-TBB.X1)/2));
YB:=(TBB.Y1+((TBB.Y2-TBB.Y1)/2));
If (PointInBox(Point(XB,YB), TBP)) Then
Begin
Result:=True;
//DebugTPA(BlueATPA[IB],'testgenie');
Exit;
End;
End;
End;
Result:=False;
End;

Function P06_FindGeniePixelDensity: Boolean;
Var
PAD,BAD,IP,IB,LP,LB,XB,YB: Integer;
PurpleTPA,BlueTPA: TPointArray;
PurpleATPA,BlueATPA: T2DPointArray;
Begin
FindColorsTolerance(PurpleTPA, 8392314, 0, 0, 605, 357, 31);
//DebugTPA(PurpleTPA,'testgenie');
FindColorsTolerance(BlueTPA, 14717768, 0, 0, 605, 357, 64);
//DebugTPA(BlueTPA,'testgenie');
SplitTPAWrap(PurpleTPA, 22, PurpleATPA);
SortATPASize(PurpleATPA,True);
SplitTPAWrap(BlueTPA, 10, BlueATPA);
SortATPASize(BlueATPA,True);
LP := High(PurpleATPA);
LB := High(BlueATPA);
For IP := 0 to LP do
Begin
PAD:=High(PurpleATPA[IP]);
If (PAD<50) Or (PAD>450) Then
Continue;
//Writeln('PAD: '+IntToStr(PAD));
For IB := 0 to LB do
Begin
BAD:=High(BlueATPA[IB]);
If (BAD<30) Or (BAD>450) Then
Continue;
//Writeln('BAD: '+IntToStr(BAD));
MiddleTPAEx(BlueATPA[IB], XB, YB);
If (PointInBox(Point(XB,YB), GetTPABounds(PurpleATPA[IP]))) Then
Begin
Result:=True;
//DebugTPA(BlueATPA[IB],'testgenie');
Exit;
End;
End;
End;
Result:=False;
End;

begin

MarkTime(IntCounter);
If P06_FindGenieMiddleBox Then
Writeln('Saw Genie');
Writeln('Took: '+inttostr(TimeFromMark(IntCounter)));

MarkTime(IntCounter);
If P06_FindGenieWidthHeight Then
Writeln('Saw Genie');
Writeln('Took: '+inttostr(TimeFromMark(IntCounter)));

MarkTime(IntCounter);
If P06_FindGeniePixelDensity Then
Writeln('Saw Genie');
Writeln('Took: '+inttostr(TimeFromMark(IntCounter)));

end.


Saw Genie
Took: 156
Saw Genie
Took: 140
Saw Genie
Took: 125

Justin

2013-02-10 21:27:06

Why do you need to find the random event in under 100ms on a private server?

DannyRS

2013-02-10 21:29:51

From: Justin
Why do you need to find the random event in under 100ms on a private server?


Fun, Idk, trying to make an AIO finder under 1000ms total

Olly

2013-02-10 21:37:51

woah man…. Look at some of the tpa functions there's some really neat ones for detecting if points are near or not.

DannyRS

2013-02-10 21:54:44

From: Ollybest
woah man…. Look at some of the tpa functions there's some really neat ones for detecting if points are near or not.


looked through em all hundreds of times, any specific suggestions to try? :p need some kinda count too so it would not pick up just three pixels next to each other

Wardancer

2013-02-11 17:49:53

A function I like to use for this is FilterTPADistTPA, written by beginner5. I use it in conjunction with a generic FindObject function for this purpose.


procedure FilterTPADistTPA(var TPA1: TPointArray; const MinDist, //Credits to beginner5 for this function.
MaxDist: Extended; TPA2 : TPointArray);
var
c,i,j,h,hh : integer;
d : extended;
mind ,maxd :extended;
begin
h := high(TPA1);
hh := high(TPA2);
c := 0;
mind := sqr(MinDist);
maxd := sqr(MaxDist);
for i := 0 to h do
begin
for j := 0 to hh do
begin
d := sqr(TPA1[i].x - TPA2[j].x) + sqr(TPA1[i].y - TPA2[j].y);
if (d >= mind) and (d <= maxd) then
begin
TPA1[c] := TPA1[i];
inc(c);
break;
end;
end;
end;
setlength(TPA1,c);
end;

function MultiFindObject(var x, y : Integer; Obj: MSObject; X1, Y1, X2, Y2:integer) : Boolean; //Same function as above, but use 2 colours and check the distance between them. It's an application of beginner5's function.
var
CTS, A : Integer;
TPA1, TPA2 : TPointArray;
ATPA: array of TPointArray;
MP : TPoint;
begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(Obj.Hue, Obj.Sat);
if FindColorsSpiralTolerance(MSCX, MSCY, TPA1, Obj.Col, X1, Y1, X2, Y2, Obj.Tol) then
begin
SetColorSpeed2Modifiers(Obj.HueTwo, Obj.SatTwo);
if FindColorsSpiralTolerance(MSCX, MSCY, TPA2, Obj.ColTwo, X1, Y1, X2, Y2, Obj.TolTwo) then
begin
SetArrayLength(TPA1, 100);
SetArrayLength(TPA2, 100);
RAaSTPAEx(TPA1, 2, 2);
RAaSTPAEx(TPA2, 2, 2);
FilterTPADistTPA(TPA1, 0, 15, TPA2);
SplitTPAWrap(TPA1, 15, ATPA);
for A := 0 to high(ATPA) do
begin
MP := MiddleTPA(ATPA[A]);
MMouse(MP.x, MP.y, 4, 4);
if(WaitUpText(Obj.UpText, 400))then
begin
x := MP.x; y := MP.y;
Result := True;
Break;
end;
end;
end;
end;
ColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(0.2,0.2);
end;

MSObject is a record containing a lot of information:


type
MSObject = record
Col, ColTwo, Tol, TolTwo : Integer;
Hue, HueTwo, Sat, SatTwo: Extended;
Uptext: String;
end;

You can make any procedure to load all your MSObjects. Example:


var
AK_Bank, Tanner, EnergyPotion : MSObject;
procedure LoadObjectz;
begin
with AK_Bank do
begin
Col := 12102838;
Tol := 14;
Hue := 0.10;
Sat := 0.34;
ColTwo := 2242328;
TolTwo := 5;
HueTwo := 0.18;
SatTwo := 0.50;
UpText := 'Bank'
end;
with Tanner do //Credit to Topic for finding these colors. All other colours I tried weren't as accurate.
begin
Col := 2107945;
Tol := 10;
Hue := 0.4;
Sat := 0.4;
ColTwo := 12103350;
TolTwo := 22;
HueTwo := 0.2;
SatTwo := 1.05;
UpText := 'llis'
end;
with EnergyPotion do
begin
Col := 5261184;
Tol := 5;
Hue := 0.06;
Sat := 0.09;
UpText := 'nerg'
end;
end;

Hope this helps.