SRL Archive - SRL Suggestions

TPA walking function


kanah

2011-12-23 07:27:17

This function is an alternative to the radial walk.


It finds colors using either a standard color and tolerance for CTS 1 or can use HSL modifiers for CTS 2. It finds all the instances of that color and clicks the closest point to the target tpoint that is within some distance defined by dist. The target tpoint is also rotated to compensate for camera rotation so the target point should be defined with a north compass angle.

{*******************************************************************************
function TPAWalk(ColorInfo: TExtendedArray; Target: TPoint; Dist: Integer): Boolean;
By: Kanah
Description: Finds color based on colorinfo ( [color,Tolerance] or [color,Tolerance,HueMod,SatMod]
then finds the closest point to Target; if the distance between target and closest point
is less than dist then it walks there. All this is done on the minimap
The target point is also rotated to compensate for any deviation in compass
angle from north so Target should be defined for a north compass angle.

ColorInfo - [Color,Tolerance] or [color,Tolerance,HueMod,SatMod]
Target - The approximate place to click
Dist - the max distance from Target that would constitute a click there
*******************************************************************************}
function TPAWalk(ColorInfo: TExtendedArray; Target: TPoint; Dist: Integer): Boolean;
var
len,tmpCTS: integer;
ColorTPA: TPointArray;
Angle: Extended;
begin
CountItems
len := length(ColorInfo);
Result := false;
Angle := -1*rs_GetCompassAngleRadians;
Target := RotatePoint(Target,Angle,MMCX,MMCY);

//Decide which option we're using
if (len = 4) then
begin
//Set up the HueMod and SatMod
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(ColorInfo[2], ColorInfo[3]);
end else if (len <> 2) then
begin
writeln('Wrong length for ColorInfo');
exit;
end;

//Perform the color finding
if (FindColorsTolerance(ColorTPA,Round(ColorInfo[0]),MMX1,MMY1,MMX2,MMY2,Round(ColorInfo[1]))) then
begin
//Sort from the Target
//SMART_DrawDots(ColorTPA);
SortTPAFrom(ColorTPA,Target);

//Check the distance
if (Distance(ColorTPA[0].x,ColorTPA[0].y,Target.x,Target.y)<dist) then
begin
//Now lets walk there
Mouse(ColorTPA[0].x,ColorTPA[0].y,2,2,true);
FFlag(5);
wait(random(300));
Result := true;
end else
writeln('Color not found in correct location on Minimap');
end else
writeln('Failed to find color on minimap');

if (len = 4) then
begin
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
end;
end;

Sir R. M8gic1an

2011-12-23 07:48:28

Just to point out this has been used with a fair amount of success (the method not this particular function)

-RM

kanah

2011-12-23 07:56:38

From: Sir R. M8gic1an
Just to point out this has been used with a fair amount of success (the method not this particular function)

-RM


cool

Interesting that no one has tried added this to the SRL library before.

Flight

2011-12-23 07:58:51

Kinda the same concept as Camero's walking method, but this has the ability to use CTS2, yes?

kanah

2011-12-23 08:01:36

This has the option of using the CTS2 or CTS1

And yes this is the same concept as camero's walking method.

DeSnob

2011-12-23 08:14:58

A scripter can add this to their own scripts, but I feel that SRL needs a function like this. It works like RadialWalk, but is far more accurate to where it clicks.

Dynamite

2011-12-23 08:30:10

This is just like simple TPA walking, I don't think it should be added to the repos because it is one less thing that doesn't show skill or real knowledge.

-Boom

kanah

2011-12-23 08:34:44

From: Dynamite
This is just like simple TPA walking, I don't think it should be added to the repos because it is one less thing that doesn't show skill or real knowledge.

-Boom


The point of adding something to the SRL library is not to demonstrate skill or anything, it is to provide functions that are used in every script. It makes no sense for everyone to just recreate this function in each of their scripts. The include is so that basic functions like this dont have to be copy-pasted every time they are needed but are by default already in the repo ready for you.

Coh3n

2011-12-30 22:34:48

I actually wouldn't mind this being added. Would definitely be very convenient. I don't think it's any different from radial walking (whether it should in in the include or not).

NCDS

2011-12-30 22:56:11

From: Coh3n
I don't think it's any different from radial walking (whether it should in in the include or not).


Which is exactly why I don't think it needs to be added. SRL already provides a walking method that works perfectly fine. Plus the FindObj* functions in Object.simba can be used the same way as this if specified to search the MM. Nice to see you back Coh3n. :)

Not that there is anything wrong with the function, kanah. :)

Coh3n

2012-01-04 15:10:30

From: NCDS
Which is exactly why I don't think it needs to be added. SRL already provides a walking method that works perfectly fine. Plus the FindObj* functions in Object.simba can be used the same way as this if specified to search the MM. Nice to see you back Coh3n. :)

Not that there is anything wrong with the function, kanah. :)
In my experience, this method works better than radial walking (assuming it's the same as Camaro's). Perhaps this is better in the snippets section.

I don't mind either way.

E: I think it should be added, but I'll wait. I suggest adding "offset" parameters so that if you want to find a rock on the MM, but want to click a little north of it, you can.

Coh3n

2012-01-08 21:22:10

Added a simpler function in the latest version. If scripters want to use CTS2 they can set it before calling TPAWalk (added to mapwalk.simba).

http://villavu.com/forum/showthread.php?p=886690#post886690