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
The Goodies
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
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:
Unused ones wont matter, and we wont have 9001 variables being unused.
Pros:
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.
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,60The 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.
- 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.