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."
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.