SRL Archive - SRL Suggestions

WalkTPAEx


3Garrett3

2010-08-22 17:36:10

So I just made this, and it was suggested that it could be added to MSI if it was working, then I thought it might be useful for people to use in SRL. Lots of people have problems using TPAs to walk, and this is a pretty good method with lots of options.

There are way too many options, but I expect it can be shortened however the Devs might like to. This is just the large version, it could be modified any way.


Function WalkTPAEx(C1, XMod, YMod, Tolerance, ColTolS, SplitMethod, SortMethod,
StartRadial, EndRadial, MinRadius, MaxRadius : Integer; HueMod, SatMod : Extended;
Filter : Boolean; SortPoint : TPoint; Dist : TIntegerArray) : Boolean;
Var
TPA: TPointArray;
TDPA: T2DPointArray;
I, H, X, Y, CTS: Integer;
Begin
If Not LoggedIn Then Exit;

cts := GetColorToleranceSpeed;
if ColTolS = 2 then
SetColorspeed2Modifiers(HueMod, SatMod);
ColorToleranceSpeed(ColTolS);

FindColorsTolerance(TPA, C1, MMX1, MMY1, MMX2, MMY2, Tolerance);

Writeln('Found colour, length of array = ' + IntToStr(Length(TPA)));
If Length(TPA) = 0 Then
begin
Writeln('Didn''t find the colour, quitting walktpa');
Exit;
end;

if Filter then
FilterPointsPie(TPA, StartRadial, EndRadial, MinRadius, MaxRadius, MMCx, MMCy);

Case SplitMethod of
1:
TDPA := TPAToATPA(TPA, Dist[0]);
2:
TDPA := TPAToATPAEx(TPA, Dist[0], Dist[1]);
3:
TDPA := SplitTPA(TPA, Dist[0]);
4:
TDPA := SplitTPAEx(TPA, Dist[0], Dist[1]);
end;

Case SortMethod of
1:
SortATPAFromFirstPoint(TDPA, SortPoint);
2:
SortATPASize(TDPA, True);
3:
SortATPASize(TDPA, False);
end;

Wait(10);
try
DebugATPABounds(TDPA);
except end;
H := High(TDPA);
For i := 0 To H Do
Begin
MiddleTPAEx(TDPA[i], x, y);
If rs_OnMinimap(x,y) Then
Begin
Mouse(x , y , 2, 2, True);
Wait(RandomRange(200,300));
FFlag(0);
Result := True;
Wait(200 + Random(80));
Exit;
End;
End;

Result := False;
End;

Camaro'

2010-08-22 21:03:19

From: 3Garrett3
So I just made this, and it was suggested that it could be added to MSI if it was working, then I thought it might be useful for people to use in SRL. Lots of people have problems using TPAs to walk, and this is a pretty good method with lots of options.

There are way too many options, but I expect it can be shortened however the Devs might like to. This is just the large version, it could be modified any way.


Function WalkTPAEx(C1, XMod, YMod, Tolerance, ColTolS, SplitMethod, SortMethod,
StartRadial, EndRadial, MinRadius, MaxRadius : Integer; HueMod, SatMod : Extended;
Filter : Boolean; SortPoint : TPoint; Dist : TIntegerArray) : Boolean;
Var
TPA: TPointArray;
TDPA: T2DPointArray;
I, H, X, Y, CTS: Integer;
Begin
If Not LoggedIn Then Exit;

cts := GetColorToleranceSpeed;
if ColTolS = 2 then
SetColorspeed2Modifiers(HueMod, SatMod);
ColorToleranceSpeed(ColTolS);

FindColorsTolerance(TPA, C1, MMX1, MMY1, MMX2, MMY2, Tolerance);

Writeln('Found colour, length of array = ' + IntToStr(Length(TPA)));
If Length(TPA) = 0 Then
begin
Writeln('Didn''t find the colour, quitting walktpa');
Exit;
end;

if Filter then
FilterPointsPie(TPA, StartRadial, EndRadial, MinRadius, MaxRadius, MMCx, MMCy);

Case SplitMethod of
1:
TDPA := TPAToATPA(TPA, Dist[0]);
2:
TDPA := TPAToATPAEx(TPA, Dist[0], Dist[1]);
3:
TDPA := SplitTPA(TPA, Dist[0]);
4:
TDPA := SplitTPAEx(TPA, Dist[0], Dist[1]);
end;

Case SortMethod of
1:
SortATPAFromFirstPoint(TDPA, SortPoint);
2:
SortATPASize(TDPA, True);
3:
SortATPASize(TDPA, False);
end;

Wait(10);
try
DebugATPABounds(TDPA);
except end;
H := High(TDPA);
For i := 0 To H Do
Begin
MiddleTPAEx(TDPA[i], x, y);
If rs_OnMinimap(x,y) Then
Begin
Mouse(x , y , 2, 2, True);
Wait(RandomRange(200,300));
FFlag(0);
Result := True;
Wait(200 + Random(80));
Exit;
End;
End;

Result := False;
End;


Looks excellent, I am going to test it when I get home from vacation.

Sir R. M8gic1an

2010-08-22 23:26:07

Constants for the cases, otherwise looks good.

A lot of options, as you said.

~RM

marpis

2010-08-23 07:23:10

Umm, I don't think this would be much used.
People rather make their own custom TPA functions.

Naum

2010-08-23 09:25:55

From: marpis
Umm, I don't think this would be much used.
People rather make their own custom TPA functions.


This.

Camaro'

2010-08-23 10:21:30

I'm definitely am going to attempt to use this because of all the variety in the options.

3Garrett3

2010-08-23 13:56:48

From: marpis
Umm, I don't think this would be much used.
People rather make their own custom TPA functions.


Yet there is FindObjTPA in SRL, is there not? ;)

marpis

2010-08-23 14:18:26

From: 3Garrett3
Yet there is FindObjTPA in SRL, is there not? ;)


I meant for walking.
Nearly all walking needs custom functions anyways.

3Garrett3

2010-08-23 15:12:24

From: marpis
I meant for walking.
Nearly all walking needs custom functions anyways.


I was thinking of making this capable with the new SRLAutocolor, there is a type for a lot of the vars in the function, isn't there? It would remove a lot of crap that isn't needed, and make it more functionable as a part of SRL.

Coh3n

2010-08-23 19:31:17

From: Rasta Magician
Constants for the cases, otherwise looks good.

A lot of options, as you said.

~RM

This (I think I already told you?). Also, why not just use a type instead of having 100 parameters?

Oh and congrats on the scripter's cup. :)

E: Also, what kind of areas have you tested it on? I know a few people said most people use custom functions, but I'm sure there are several instances where this would work, and if not, then a custom function can still be made.

3Garrett3

2010-08-23 20:48:11

From: Coh3n
This (I think I already told you?). Also, why not just use a type instead of having 100 parameters?

Oh and congrats on the scripter's cup. :)

E: Also, what kind of areas have you tested it on? I know a few people said most people use custom functions, but I'm sure there are several instances where this would work, and if not, then a custom function can still be made.


@E:

Technically it is the ultimate custom function, I haven't ever used anything else in my custom functions. It just seems easier to have lots of WalkTPA() rather than multiple functions with almost the same bases to them.

@Params:

I mentioned SRLAutocolor, isn't there a type for that or something? I'll have to look up a tut on it for now.

Wait, whaoot? Scripters cup? Almost like I was just talking to you about this, you cunning fox, you. <3

Blumblebee

2010-08-23 21:45:03

I too feel like this wouldn't be used much. Just in the fact that it in the ability to understand all the parameters you would have the knowledge to make a custom TPA function that is better suited for a script.

But then again that's just me. Looks nice regardless.

marpis

2010-08-24 01:59:18

From: 3Garrett3
I was thinking of making this capable with the new SRLAutocolor, there is a type for a lot of the vars in the function, isn't there? It would remove a lot of crap that isn't needed, and make it more functionable as a part of SRL.


I mean, people really should use this, but would people really? I don't think so.

Nava2

2010-08-24 09:34:23

I like it.

I think the constants, as well there FFlag should be param.

But, I would rather see this return an X,Y then have it do the walking. Although, I guess that kinda defeats much of the purpose.

Lastly, what you are looking for is the TAutoColorInfo.

3Garrett3

2010-08-24 10:13:19

Does this look maybe any better?


const
Split_TPAtoATPA = 1;
Split_TPAtoATPAEx = 2;
Split_SplitTPA = 3;
Split_SplitTPAEx = 4;

const
Sort_ATPAFrom = 1;
Sort_LargeFirst = 2;
Sort_SmallFirst = 3;


{*******************************************************************************
function WalkTPAFilter(...) : Boolean;
by: 3Garrett3
Description: Uses TPA methods to walk to a point based on various info.
*******************************************************************************}
Function WalkTPAFilter(AutoColor : TAutoColorInfo;XMod, YMod, FlagDist, SplitMethod, SortMethod,
StartRadial, EndRadial, MinRadius, MaxRadius : Integer; Filter : Boolean;
SortPoint : TPoint; Distance : TIntegerArray) : Boolean;
Var
TPA: TPointArray;
TDPA: T2DPointArray;
I, H, X, Y, CTS: Integer;
Begin
If Not LoggedIn Then Exit;

cts := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorspeed2Modifiers(AutoColor.HueMod, AutoColor.SatMod);

FindColorsTolerance(TPA, AutoColor.color, MMX1, MMY1, MMX2, MMY2, 2);

If Length(TPA) = 0 Then
begin
Writeln('Didn''t find the colour, quitting walktpa');
Exit;
end;
Writeln('Found colour, length of array = ' + IntToStr(Length(TPA)));

if Filter then
FilterPointsPie(TPA, StartRadial, EndRadial, MinRadius, MaxRadius, MMCx, MMCy);

Case SplitMethod of
Split_TPAtoATPA:
TDPA := TPAToATPA(TPA, Distance[0]);
Split_TPAtoATPAEx:
TDPA := TPAToATPAEx(TPA, Distance[0], Distance[1]);
Split_SplitTPA:
TDPA := SplitTPA(TPA, Distance[0]);
Split_SplitTPAEx:
TDPA := SplitTPAEx(TPA, Distance[0], Distance[1]);
end;

Case SortMethod of
Sort_ATPAFrom:
SortATPAFromFirstPoint(TDPA, SortPoint);
Sort_LargeFirst:
SortATPASize(TDPA, True);
Sort_SmallFirst:
SortATPASize(TDPA, False);
end;

Wait(10);
try
DebugATPABounds(TDPA);
except end;
H := High(TDPA);
For i := 0 To H Do
Begin
MiddleTPAEx(TDPA[i], x, y);
If rs_OnMinimap(x,y) Then
Begin
Mouse(x + XMod , y + YMod, 2, 2, True);
Wait(RandomRange(200,300));
FFlag(FlagDist);
Result := True;
Wait(200 + Random(80));
Exit;
End;
End;

Result := False;
End;


{*******************************************************************************
function WalkTPA(...) : Boolean;
by: 3Garrett3
Description: Uses WalkTPAFilter without FilterPointsPie, which eliminates many variables.
*******************************************************************************}
Function WalkTPA(AutoColor : TAutoColorInfo;XMod, YMod, FlagDist, SplitMethod, SortMethod : Integer;
SortPoint : TPoint; Distance : TIntegerArray) : Boolean;
Begin
Result := WalkTPAFilter(AutoColor, XMod, YMod, FlagDist, SplitMethod, SortMethod, 0, 0, 0, 0, False, SortPoint, Distance);
End;

Too many variables still..

Blumblebee

2010-08-24 20:24:05

use a type! It would look cool and be awesome :3

Function WalkTPAEx(WalkInfo: tWalkInfo): Boolean

Boreas

2010-08-24 23:13:27

From: Blumblebee
use a type! It would look cool and be awesome :3

Function WalkTPAEx(WalkInfo: tWalkInfo): Boolean


Agreed, anything with as many parameters as GetTextAtEx would look better. Would have been nice for RadialRoadWalk etc too.