SRL Archive - General

*simple* color + reflection (soon) walking


nickrules

2011-01-04 17:39:02

Dont worry, not as long as it looks ;)
Basically, I've been thinking about doing something like this for a long time, and wondered why it had never come up (or i never saw it).

Its TPA walking, with reflection walking soon to be added. Its really short, and really simple imho. Only flaw i see with it, (other than inaccuracy or mm symbols?) is that walking point would most likely need to be declared differently than i have in the example below.

Code breakdown in second post for those who want/need it

TWalkPoint: A simple little type to fill out. Perhaps declared in the TScript? Haven't thought about declaring it a whole lot

type
TWalkPoint = record
Name : string;
X : integer;
Y : Integer;
CoordTol : Integer;
Color : integer;
tol : integer;
end;
Its fairly self explanatory, with perhaps the exception of CoordTol. Basically, its the X and Y coordinate Search area +/- the value of CoordTol. EG, if your point is at 50,50, with a coordTol of 10, the search would be in 40,40 to 60,60

The Goodies

Function MSI_WalkToPoint(WalkPoint:TWalkPoint):boolean;
var CPoints:TPointArray;
begin
FindColorsTolerance(CPoints,WalkPoint.Color,(WalkPoint.X - WalkPoint.CoordTol),(WalkPoint.Y - WalkPoint.CoordTol),(WalkPoint.X + WalkPoint.CoordTol),(WalkPoint.Y + WalkPoint.CoordTol),WalkPoint.Tol)
If not Length(CPoints) >= 1 then //is this how you return the length? :S
begin
Writeln('Colors for ' + WalkPoint.Name + ' not found :(');
end else
begin
SortTPAFrom(CPoints,Point(WalkPoint.X,WalkPoint.Y))
Mouse(CPoints[0].X,CPoints[0].Y, 5, 5, true);
FFlag(10)
Writeln('Walked to ' + WalkPoint.Name + ' Successfully :)');
Result := true;
end;
end;

As you can see, its pretty short (for now. or mehbeh forever, depending on if it needs to be made super-complex). It will be longer when i finish it (failsafes + reflection), but will still [most likely] be pretty short.

Simple example of declaring + use in the mainloop or w/e
Var LolPoint, CaseExample: TWalkPoint; //var for example

Procedure DeclareWalkPoints;
begin

LolPoint.Name := 'VEM to VEB Point 1';
LolPoint.X := 555;
LolPoint.Y := 444;
LolPoint.CoordTol := 10;
LolPoint.Color := 6132864;
LolPoint.Tol := 7;
//can also be declared using with
with CaseExample do
begin
Name := 'VEM to VEB Point 2';
X := 556;
Y := 445;
CoordTol := 11;
Color := 23124534;
Tol := 8;
end;
//But i didn't need to tell you that ;)
end;

begin
setupsrl;
DeclareWalkPoints;
//blahblahblah
MSI_WalkToPoint(LolPoint);
end.


Actually, i just thought of a way of declaring the TWalkPoints. We could have 20 (or however many) global variables. Then in the TScript, we would declare them like this:

with WalkToPoint1 do
begin
//blahh

Unused ones wont matter, and we wont have 9001 variables being unused.


Pros:
  • Simple, fast(?)
  • Easy to declare in scripts
  • Its TPA walking. Need I say more?
  • With reflection (soon) to back it up? Even better.
Cons:
  • Would be unused variables either method of declaring.
  • Im honestly not sure if it would go as fast as we would like, but I highly doubt it would be noticeable.
  • Any more?

I've used TPA walking in many scripts. Its fast, safe, and pretty accurate if I say so myself. I've intentionally tried to screw up the TPA walking in my scripts, and it didn't exactly happen :p

Discuss.




The full script/file.

Program Lol;
{$i srl/srl.scar} {
type
TWalkPoint = record;
Name : string; //Text displayed for output/debug
X : integer; //aproximate X coordinate - assume compas is north
Y : integer; //aproximate Y coordinate - assume compas is north
CoordTol : integer; //Your coord + and - this value is search area
Color : integer; //Color at this point. Use ACA or getcolor or something like that
Tol : integer; //Tollerance
end; }

type
TWalkPoint = record
Name : string;
X : integer;
Y : Integer;
CoordTol : Integer;
Color : integer;
tol : integer;
end;

Var LolPoint, CaseExample: TWalkPoint; //var for example

Procedure DeclareWalkPoints;
begin

LolPoint.Name := 'VEM to VEB Point 1';
LolPoint.X := 555;
LolPoint.Y := 444;
LolPoint.CoordTol := 10;
LolPoint.Color := 6132864;
LolPoint.Tol := 7;
//can also be declared using with
with CaseExample do
begin
Name := 'VEM to VEB Point 2';
X := 556;
Y := 445;
CoordTol := 11;
Color := 23124534;
Tol := 8;
end;
//But i didn't need to tell you that ;)
end;


Function MSI_WalkToPoint(WalkPoint:TWalkPoint):boolean;
var CPoints:TPointArray;
begin
FindColorsTolerance(CPoints,WalkPoint.Color,(WalkPoint.X - WalkPoint.CoordTol),(WalkPoint.Y - WalkPoint.CoordTol),(WalkPoint.X + WalkPoint.CoordTol),(WalkPoint.Y + WalkPoint.CoordTol),WalkPoint.Tol)
If not Length(CPoints) >= 1 then //Cant remember how to return array length :S
begin
Writeln('Colors for ' + WalkPoint.Name + ' not found :(');
end else
begin
SortTPAFrom(CPoints,Point(WalkPoint.X,WalkPoint.Y))
Mouse(CPoints[0].X,CPoints[0].Y, 5, 5, true);
FFlag(10)
Writeln('Walked to ' + WalkPoint.Name + ' Successfully :)');
Result := true;
end;
end;


begin
setupsrl;
//blahblahblah
DeclareWalkPoints;
MSI_WalkToPoint(LolPoint);
end.

nickrules

2011-01-04 17:40:03

BreakDown:
  FindColorsTolerance(CPoints,WalkPoint.Color,(WalkPoint.X - WalkPoint.CoordTol),(WalkPoint.Y - WalkPoint.CoordTol),(WalkPoint.X + WalkPoint.CoordTol),(WalkPoint.Y + WalkPoint.CoordTol),WalkPoint.Tol)
This finds the color, with CoordTol to determine the xs/ys etc.

  If not Length(CPoints) >= 1 then  //Cant remember how to return array length :S
begin
Writeln('Colors for ' + WalkPoint.Name + ' not found :(');
end else
Simple failsafe. In the future, perhaps, add a reflection tile to the record, then check if the point is on the MM.

begin
SortTPAFrom(CPoints,Point(WalkPoint.X,WalkPoint.Y))
Mouse(CPoints[0].X,CPoints[0].Y, 5, 5, true);
FFlag(10)
Writeln('Walked to ' + WalkPoint.Name + ' Successfully :)');
Result := true;
end;
Sort the TPA and click it.
Another chance for a failsafe (right before doing the click)?
We could either:
Get rid of all points out of a certain radius
OR
Preform a reflection check to make sure the point we found is near the tile.
OR
Both? ;)

3Garrett3

2011-01-04 23:51:00

Pros/cons vs the WalkTPA we have now? I don't wanna sound douchy about the one I made, but it's the same concept, they could be merged together. You simply said it was a new idea, but we have WalkTPA already, so it's not much different unless I'm missing something? Either way, I like yours, it makes me think about changing mine around a little :)

nickrules

2011-01-05 06:34:06

From: 3Garrett3
Pros/cons vs the WalkTPA we have now? I don't wanna sound douchy about the one I made, but it's the same concept, they could be merged together. You simply said it was a new idea, but we have WalkTPA already, so it's not much different unless I'm missing something? Either way, I like yours, it makes me think about changing mine around a little :)


Not douchey at all. :)

As usual, i sorta went ahead and did it before looking at a whole lot of code that already exists. :p

I think the main idea of what I've done here is that it seems like it would be a whole lot cleaner to make scripts for.
The scripts would have to be longer, but if the reflection path were added the the Type, it might make people to make more willing to make a color path - after all, its not that hard with this method. Because, Not gonna lie - your method of walking confuses the balls off of me :S

I think if we had like 10 or 15 globally declared, generic TWalkPoint available for scripters to use, that would be overwritten for each new account/player, that would be best.

I have to go, If I left anything out I'll put in another post.

Coh3n

2011-01-05 15:11:53

I guess it's safe to say that you haven't seen this?

I was planning on finishing that up sometime soon. It's the TPA walking that Camaro got the masters cup for. It's used for 3 or 4 scripts in MSI and I've never seen color walking work so well before. :o

nickrules

2011-01-05 18:01:22

>_>
Not gonna lie (and i really, really don't mean to be an ass when i say this, but) I don't feel that really deserves a masters cup. TPA walking isn't exactly rocket science. Its basically simple object finding on a minimap. IMHO, its easier than radial walking. But enough of me complaining.

The main reason for making this is its 'modularity' (is that even the right word?) and ease of use. Think about it - 20 to 30 globally declared variables, which are set IN the script. They can be over written (herp derp they're variables) and take slightly more effort to code a 'TWalkPoint' than reflection. Hell, once I add reflection (or if I add reflection - no point if its just going to be set aside over camaro''s method) It would be one of those "I'm already here, why the hell not?" sorta deals.

Coh3n

2011-01-05 18:28:12

From: nickrules
The main reason for making this is its 'modularity' (is that even the right word?) and ease of use. Think about it - 20 to 30 globally declared variables, which are set IN the script. They can be over written (herp derp they're variables) and take slightly more effort to code a 'TWalkPoint' than reflection. Hell, once I add reflection (or if I add reflection - no point if its just going to be set aside over camaro''s method) It would be one of those "I'm already here, why the hell not?" sorta deals.

I think you're missing the fact that yours and Camaro's method are exactly the same - a type that is used for one TPA walking function.

Camaro made the function (the one he got the cup for), and I suggested a rewrite of Walking_Color.simba to a structure the same as the rest of our records (Items, Obejcts, etc.).

const
WALK_PS_WILLOWS_1 = 10;
WALK_PS_WILLOWS_2 = 11;

WALK_ARRAY_LENGTH = 11;

type
TWalkPoint = record
Name : string;
Color : Integer;
Tolerance : Integer;
SortFrom : TPoint;
OnMMOffset : TPoint;
ResOffset : TPoint;
Failsafe : array of function(Color, sRadial, eRadial, r, modX, modY, Tol: Integer): Boolean;
end;

TWalkPointArray = array of TWalkInfo;

var
MSI_WalkPoints: array[0..WALK_ARRAY_LENGTH] of TWalkInfo;

procedure MSI_LoadWalkPoint(Index: Integer);
begin
case Index of
WALK_PS_WILLOW_1:
with MSI_WalkPoints[Index] do
begin
end;

WALK_PS_WILLOW_1:
with MSI_WalkPoints[Index] do
begin
end;
end;
end;

procedure MSI_LoadAllWalkPoints();
var
i: Integer;
begin
for i := 0 to High(MSI_WalkPoints) do
MSI_LoadWalkPoint(i);
end;

function MSI_GetMMPoint(WalkPoint: Integer): TPoint;
begin
// Here would be the TPA function returning the TPoint on the minimap
// To use the type, just call MSI_WalkPoints[WalkPoint].Tolerance, etc.
end;

function MSI_WalkToPoint(WalkPoint: Integer): Boolean;
begin
// Already exists as MSI_WalkToColorIndex, so it would be the same
// except this one would call the failsafe functions also
end;

// MSI_LoadColorPath and MSI_ColorWalk would remain the same; slight edits may be necessary
That is was the structure will be. Camaro attempted to do that (and did okay for the most part in the other thread I linked you). I just need to get the time to properly clean it up and make it work.