SRL Archive - Help and Support

TPA Epic Lag.


Torrent of Flame

2009-05-27 20:19:06

This is my script and the TPA Works, but at the cost of about 15 seconds of extreme lag before clicking a Warrior. Is there a way to still use a TPA to find said Warrior but without the cost of a huge amount of lag?

program WarriorKillerATM;
{$DEFINE SMART} {To Remove SMART, Comment this out with //}

{$IFDEF SMART}
{.include SRL/SRL/Misc/SMART.scar}
{$ENDIF}

{.include SRL/SRL.scar}

procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

with Players[0] do
begin
Name :='';
Pass :='';
Nick :='';
Active := true;
BoxRewards := ['Xp', 'ostume', 'gem', 'mote', 'ithril', 'oal'];
end;
end;

var
Warrior: array [0..11] of integer;
Ups: array of string;
{::::::::::::::::::::::: TPA Mod, by Torrent of Flame :::::::::::::::::::::}
function TPAMod(var MidColour, Tolerance: integer; var HueMod, SatMod: Extended; Colors: TIntegerArray): boolean;
var
H, S, L, Tol: Extended;
i, ii: integer;
HSLColor: Array[1..3] of Extended;
HSL: Array[0..1] of Array[1..3] of Extended;
begin
for i := 0 to High(Colors) do
begin
ColortoHSL(Colors[i], HSLColor[1], HSLColor[2], HSLColor[3]);
for ii:= 1 to 3 do
begin
HSL[0][ii] := MinE(HSLColor[ii], HSL[0][ii]);
HSL[1][ii] := MaxE(HSLColor[ii], HSL[1][ii]);
end;
end;
H := HSL[1][1] - HSL[0][1];
S := HSL[1][2] - HSL[0][2];
L := HSL[1][3] - HSL[0][3];
MidColour := HSLToColor((HSL[1][1] + HSL[0][1]) div 2,(HSL[1][2] + HSL[0][2]) div 2,(HSL[1][3] + HSL[0][3]) div 2);
HueMod := (H/L);
SatMod := (S/L);
Tol := L;
if (MidColour <= 0) then
begin
WriteLn('TPA Variables not found.');
Result := False;
end else
Result := True;
Tolerance := Trunc(Tol + 0.5);
end;

{:::::::::::::::::::::::::: Warrior Variables :::::::::::::::::::::::::::::}
procedure WarriorVariables;
begin
Warrior[0] := 4876399; Warrior[1] := 3097671; Warrior[2] := 3430748; Warrior[3] := 4414308;
Warrior[4] := 5272439; Warrior[5] := 5871775; Warrior[6] := 5981728; Warrior[7] := 7032858;
Warrior[8] := 1845289; Warrior[9] := 5729921; Warrior[10] := 4018779; Warrior[11] := 4809324;
Ups := ['harid', 'arrior'];
end;

{:::::::::::::::::::::::::::: Find Willow Tree :::::::::::::::::::::::::::::}
function FindWarrior: boolean;
var
CTS, i, x, y, Px, Py, MiddleColour, Tolerance: Integer;
TPA: TPointArray;
ATPA: Array of TPointArray;
HueModifier, SatModifier: Extended;
begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
//WarriorVariables;
//for i := 0 to High(Warrior) do
begin
//TPAMod(MiddleColour, Tolerance, HueModifier, SatModifier,[Warrior[i]]);
SetColorSpeed2Modifiers(0.38, 0.50);
{ClearDebug;
ClearReport;
Writeln('Hue Modifier is: '+FloatToStr(HueModifier)+'');
Writeln('Saturation Modifier is: '+FloatToStr(SatModifier)+'');
Writeln('Mid Colour is: '+IntToStr(MiddleColour)+'');
Writeln('Tolerance is: '+IntToStr(Tolerance)+''); }
FindColorsSpiralTolerance(MSCX, MSCY, TPA, 2961719, MSX1, MSY1, MSX2, MSY2, 39);
SetColorSpeed2Modifiers(0.2, 0.2);
ColorToleranceSpeed(CTS);
SortTPAFrom(TPA, Point(MSCX, MSCY));
ATPA := SplitTPAEx(TPA, 5, 5);
for i := 0 to High(ATPA) do
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y, 2, 2);
GetMousePos(Px, Py);
Wait(500 + random(350))
if(IsUpText('arrior')) then
begin
AddToReport('Attacking Using the TPA');
GetMousePos(Px, Py);
case Random(5) of
0:
begin
Mouse(Px, Py, 4, 4, False);
Wait(250 + Random(200));
ChooseOption('ttack');
Result := True;
Exit;
end;
1..4:
begin
Mouse(Px, Py, 4, 4, True);
Result := True;
Exit;
end;
end;
end;
end;
end;
begin
AddToReport('TPA Failed, attacking with FindObjTPA');
if FindObjTPA(x, y, Warrior[i], 20, 2, 15, 15, 7, [Ups]) then
begin
GetMousePos(Px, Py);
case Random(5) of
0:
begin
Mouse(Px, Py, 4, 4, False);
Wait(250 + Random(200));
ChooseOption('ttack');
Exit;
end;
1..4:
begin
Mouse(Px, Py, 4, 4, True);
Exit;
end;
end;
end;
end;
end;

begin
{$IFDEF SMART}
SMARTSetupEx(133, False, True, False);
Wait(5000);
SetTargetDC(SmartGetDC);
repeat
Wait(100);
until (SmartGetColor(253, 233) <> 1118604);
{$ENDIF}
SetupSRL;
DeclarePlayers;
LoginPlayer;
Wait(5000 + Random(350));
FindWarrior;
end.

Naike

2009-05-27 20:23:39

I say add Writeln's after each line, where it lags(and the Writeln stops) theres your problem..

Then just add Wait(20); or something cleaver :)

Torrent of Flame

2009-05-27 20:30:57

    SortTPAFrom(TPA, Point(MSCX, MSCY));
writeln('sorted TPA');
ATPA := SplitTPAEx(TPA, 5, 5);
writeln('split tpa');

Lags at the SplitTPAEx ;)


EDIT:

ATPA := TPAToATPAEx(TPA, 15, 15);

It doesnt lag now, but it is less fast. It is really a bit slow tbh, it just searches about my RS char in the middle..

Camaro'

2009-05-27 20:51:22

Like it doesnt lag , but it finds it after awhile of waiting?

Naum

2009-05-27 20:51:27

Maybe it lagged because there was a lot of points to split?

Also try using DebugATPA or DebugATPABounds and play about with the color. Once I found my finder couldn't find a cow because the tolerance was 3 or 4 somethings too high.

Naike

2009-05-27 21:05:16

If you got way to many points then it will result in lag..

But you want the opposite of that, try picking a new color and see if it still lags.

Torrent of Flame

2009-05-27 21:19:52

It finds the thing now, but after a long time of moving the mouse about in circles.

senrath

2009-05-27 21:49:01

From: Torrent of Flame
It finds the thing now, but after a long time of moving the mouse about in circles.


That means that it's finding lots of other points that match the color and tolerance you set. Try redoing the color and/or tolerance and see if that helps.

Da 0wner

2009-05-28 09:47:56

Well if you are using one color, lower the tolerance = less points. And if you are using multiple, then use less :p.

Torrent of Flame

2009-05-28 20:46:09

So Im making a TPA For this:


Should I pick the blue belt colour for the TPA as it is unique in their area.