SRL Archive - SRL Archives

Make_RaidialWalk Function


Special Ed

2007-03-28 08:28:29

Yea I'm working on a script that will have a bunch of functions such as this one that will make scripting a lot easier in some cases.

So far I think my Make_RadialWalk function is the most impressive, but I'm going to keep working on it, and if anyone has any input or some ideas of something I could make, that would be most helpful.

Here is my Make_RadialWalk and Make_Wait function… and the procedures / functions that go with it. Just Run the script and wait a few seconds for it to set up and then click your mouse either on the minimap or on the ground *just so a flag appears* and wait until you get to the flag and it should writeln something like… RadialWalk(12345,90,180,50,3,3);

*The Make_Wait Function just keeps it from freezing / crashing but still is useful.

EDIT: Updated March 31,2007
"Fixed a few bugs, doesn't miss the flag as often and gives you the correct distance."

program RadialWalker;
{.include SRL/SRL.scar}

procedure Make_Wait;
var SS:integer;
begin
if(not(IsMouseButtonDown(true)) or (not(IsMouseButtonDown(false)) or (not(FlagPresent))))then
begin
MarkTime(ST);
repeat
Wait(100);
until(IsMouseButtonDown(true) or IsMouseButtonDown(false));
SS:= ((TimeFromMark(ST) / 100) * 100);
Writeln('Wait(' + inttostr(SS) + ' + Random(' + inttostr((Random(5) * 50) + 50) + '));');
end;
if(IsMouseButtonDown(true) or IsMouseButtonDown(false) or FlagPresent)then
begin
Exit;
end;
end;

//Modded from SRL/SRL/core/math.scar "ArcTan2"
function SpecialArcTan(y,x:Extended):Extended;
begin
if(y = MMCY) and (x < MMCX) then Result := Radians(180.0);
if(y = MMCY) and (x > MMCX) then Result := Radians(0.0);
if(x = MMCX) and (y < MMCY) then Result := Radians(270.0);
if(x = MMCX) and (y > MMCY) then Result := Radians(90.0);
if(Result = 0.0) and (x <> MMCX) then
if(x = 0) then
begin
x:= 1;
end;
if(Abs(y) / Abs(x) = 1.0) then
begin
if(y > MMCY) and (x > MMCX) then Result := Radians(45.0);
if(y > MMCY) and (x < MMCX) then Result := Radians(135.0);
if(y < MMCY) and (x < MMCX) then Result := Radians(225.0);
if(y < MMCY) and (x > MMCX) then Result := Radians(315.0);
end;
if Result = 0 then
begin
Result := ArcTan(Abs(-y) div Abs(x));
if(y > MMCY) and (x < MMCX) then Result := Result + Radians(90.0);
if(y < MMCY) and (x < MMCX) then Result := Result + Radians(180.0);
if(y < MMCY) and (x > MMCX) then Result := Result + Radians(270.0);
end;
end;

function FlagIn_Quadrant:integer;
var MPX,MPY:integer;
begin
FindColor(MPX,MPY,255,MMX1,MMY1,MMX2,MMY2);
begin
if(((648 < MPX)and(MPX < 735))and((5 < MPY) and(MPY < 86))) then Result:= 1; // 1 - 89 Degrees
if(((570 < MPX)and(MPX < 648))and((5 < MPY) and(MPY < 86))) then Result:= 2; // 91 - 179 Degrees
if(((570 < MPX)and(MPX < 648))and((86 < MPY)and(MPY < 166))) then Result:= 3; // 181 - 269 Degrees
if(((648 < MPX)and(MPX < 735))and((86 < MPY)and(MPY < 166))) then Result:= 4; // 271 - 359 Degrees
if((MPX = 648)and(5 < MPY) and(MPY < 86)) then Result:= 5; // 0 & 360 Degrees
if((MPY = 86) and(570 < MPX)and(MPX < 648)) then Result:= 6; // 270 Degrees
if((MPY = 86) and(648 < MPX)and(MPX < 735)) then Result:= 7; // 90 Degrees
if((MPX = 648)and(86 < MPY) and(MPY < 166)) then Result:= 8; // 180 Degrees
end;
end;

function StartRadialDegrees:extended;
var RadX,RadY,AngleInRadians,AngleInDegrees:Extended;
MPX,MPY:integer;
begin
if(not(FlagPresent))then Exit;
if(FlagPresent)then
begin
GetMousePos(MPX,MPY);
RadX:= (MMCX - MPX);
RadY:= (MMCY - MPY);
AngleInRadians:= (Abs((SpecialArcTan(MMCY + 72,MMCX) - SpecialArcTan(RadY,RadX))));
AngleInDegrees:= ((AngleInRadians * 180) / Pi);
if(FlagIn_Quadrant = 1)then result:= (180 - AngleInDegrees);
if(FlagIn_Quadrant = 2)then result:= (180 + AngleInDegrees);
if(FlagIn_Quadrant = 3)then result:= ((180 - AngleInDegrees) + 180);
if(FlagIn_Quadrant = 4)then result:= (AngleInDegrees);
if(FlagIn_Quadrant = 5)then result:= 0;
if(FlagIn_Quadrant = 6)then result:= 270;
if(FlagIn_Quadrant = 7)then result:= 90;
if(FlagIn_Quadrant = 8)then result:= 180;
end;
end;

function EndRadialDegrees:extended;
var RadX,RadY,AngleInRadians,AngleInDegrees:Extended;
MPX,MPY,FIQ:integer;
begin
if(not(FlagPresent))then Exit;
begin
repeat
if(FlagIn_Quadrant = 1)then FIQ:= 1;
if(FlagIn_Quadrant = 2)then FIQ:= 2;
if(FlagIn_Quadrant = 3)then FIQ:= 3;
if(FlagIn_Quadrant = 4)then FIQ:= 4;
if(FlagIn_Quadrant = 5)then FIQ:= 5;
if(FlagIn_Quadrant = 6)then FIQ:= 6;
if(FlagIn_Quadrant = 7)then FIQ:= 7;
if(FlagIn_Quadrant = 8)then FIQ:= 8;
Wait(100);
until(not(FlagPresent));
end;
RadX:= (MMCX - MPX);
RadY:= (MMCY - MPY);
AngleInRadians:= (Abs((SpecialArcTan(MMCY + 72,MMCX) - SpecialArcTan(RadY,RadX))));
AngleInDegrees:= ((AngleInRadians * 180) / Pi);
if(FIQ = 1)then result:= (180 - AngleInDegrees);
if(FIQ = 2)then result:= (180 + AngleInDegrees);
if(FIQ = 3)then result:= ((180 - AngleInDegrees) + 180);
if(FIQ = 4)then result:= (AngleInDegrees);
if(FIQ = 5)then result:= 0;
if(FIQ = 6)then result:= 270;
if(FIQ = 7)then result:= 90;
if(FIQ = 8)then result:= 180;
end;

procedure Make_RadialWalk;
var CX,CY,Color,MouseRand,Dist,SR,ER:integer;
begin
if((not(FlagPresent)))then Exit;
if(FlagPresent)then
begin
FindColor(CX,CY,255,MMX1,MMY1,MMX2,MMY2);
Color:= GetColor(CX + 2,CY);
SR:= Trunc(StartRadialDegrees);
ER:= Trunc(EndRadialDegrees);
Dist:= Distance(MMCX,MMCY,CX,CY);
MouseRand:= (Random(3) + 1);
Writeln('RadialWalk(' + inttostr(Color) + ',' + inttostr(SR) + ',' + inttostr(ER) + ',' + inttostr(Dist) + ',' + inttostr(MouseRand) + ',' + inttostr(MouseRand) + ');');
end;
end;

begin
SetupSRL;
Wait(500);
ClearDebug;
repeat
Make_Wait;
Make_RadialWalk;
until(false);
end.

JuKKa

2007-03-28 08:47:57

wow COOL i mean really cool, toobad runescape is updating, so i cant test it :(

Secet

2007-03-28 09:02:54

Testing it now, very good and cool job. This will make walking ALOT easier!

Secet

2007-03-28 09:24:54

I get this error when I try my RadialWalking that script gave me:
[Runtime Error] : Exception: Canvas does not allow drawing in line 527 in script D:\SCAR 2.03\includes\srl\srl\core\MapWalk.scar

Any help?

Special Ed

2007-03-28 16:20:27

Oh, lol… since this is part of a bigger script of Script making functions when I took it out I forgot to put the program; and include SRL in there… fixed that though now.

And for your problem secet I don't know what to say… do you have any edited SRL files or something?

Also if anyone wants to check out my other functions and help me test/tweak them just say so and I'll message you them. I'll Post the full thing here when It gets more complete.

TOB

2007-03-28 21:00:30

Secet, make sure you select the client until you get that surrounding box.

Special Ed

2007-03-29 08:19:58

So what do you guys think? Does it work good? Anything you can see wrong with the coding, ect?

oliver1205

2007-03-29 17:46:28

all i got was a bunch of waits with different vaules.

for example

wait(random 100+300)

Special Ed

2007-03-29 22:43:40

Ok… you need to wait a bit so it can compile… that is just my wait function.
Did you select to RS window and follow the instructions in my first post? Sometimes its a little buggy you just need to wait a few seconds.

Secet

2007-03-30 14:03:29

Btw, I was little confused first when I tried it, it only gave me two radialwalks but then I looked trough the script and spotted this:

  if(IsMouseButtonDown(true)

So when you click the button, you need to hold mouse button down until flag doesn't exist anymore, atleast that's how it worked me. Gonna test it now, maybe I won't get that weird SCAR error this time.

Special Ed

2007-03-30 16:20:16

Hmm.. if so how would i fix that i can't think right now… durrrr

mage of begu

2007-03-31 04:18:48

Dam i love this one…but the color thing isnt good…it gives me 0 very offen…but that aint any problem cause eventually i use FindRoadColor…and then some times it doesnt give me radial walk just an Wait…if that will be fixed in next update its flawless…!

EDIT:And it seems to have some problems with radius…it gives me 500+ amount all the time..
this one needs some work :(…but i will be happily waiting next update…

Special Ed

2007-03-31 15:10:06

Hmmm.. I dunno I'm looking I'm looking into it right now..

EDIT: Aha… Well I fixed the distance problem I had it finding the distance between MMCX, MMCX , and CX,CY instead of MMCX, and MMCY. But I don't know about your degrees thing… it works for me, im looking into that now.

EDIT: K, Found it, I needed to remove the IsMousebutton Down from the Make_RadialWalk procedure so it just looks for the flag now, so it doesn't miss the flag and just give you another wait, and for the 0 color thing… I don't know what to tell you, Ill test it some more and see if i can get it to give me 0 as a color..

Also the waits are just my make_wait procedure you can get rid of that and use
repeat
Wait(100);
until(IsMouseButtonDown(true) or FlagPresent)

because without that it will just lag it out

mage of begu

2007-03-31 15:59:26

From: Special Ed
Hmmm.. I dunno I'm looking I'm looking into it right now..

EDIT: Aha… Well I fixed the distance problem I had it finding the distance between MMCX, MMCX , and CX,CY instead of MMCX, and MMCY. But I don't know about your degrees thing… it works for me, im looking into that now.

EDIT: K, Found it, I needed to remove the IsMousebutton Down from the Make_RadialWalk procedure so it just looks for the flag now, so it doesn't miss the flag and just give you another wait, and for the 0 color thing… I don't know what to tell you, Ill test it some more and see if i can get it to give me 0 as a color..

Also the waits are just my make_wait procedure you can get rid of that and use
repeat
Wait(100);
until(IsMouseButtonDown(true) or FlagPresent)

because without that it will just lag it out


Great….just great…i dont actually need those waits…i just put Flag; there anyways :D….now i try this one again and post bugs or errors ;) nice work…!

Edit: Ok, i have tested it now…it seems to not give me radial sometimes…just writes wait…but then in next click it will give me radial….:(

Special Ed

2007-03-31 18:41:19

I dunno how to make it so it always recognized it, maybe there is just something wrong with one of my procedures so it can't continue all the time. Any ideas?

mage of begu

2007-04-01 05:23:18

From: Special Ed
I dunno how to make it so it always recognized it, maybe there is just something wrong with one of my procedures so it can't continue all the time. Any ideas?


I have no idea….

Special Ed

2007-04-01 11:01:26

Lol…. Anyone else care to give me some help?

mage of begu

2007-04-01 13:20:07

From: Special Ed
Lol…. Anyone else care to give me some help?


I can check…but im pretty sure i cant help :(