Naike
2009-06-20 15:53:25
A bit bigger one here, got the advice not to touch these…
But stubborn as I am…
What I did in FlagChat.scar
FlagEx makes it all in one function, and don't worry Nava2 - It got RoadColorChecker aswell.
What I did in MapWalk.scar
Note: Flag functions should be moved to MapWalk..
MapWalk.scar
FlagChat.scar
But stubborn as I am…
What I did in FlagChat.scar
- Added FlagEx
- Pointed all the Flag functions to use FlagEx
FlagEx makes it all in one function, and don't worry Nava2 - It got RoadColorChecker aswell.
What I did in MapWalk.scar
- RadialWalkRoad/LinearRoadWalk now uses RadialWalk(With RoadColorChecker ofc).
- Added a Global boolean. (Sorry, had to).
- CountFlag now uses FlagEx
Note: Flag functions should be moved to MapWalk..
MapWalk.scar
//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- » MapWalking Routines --//
//-----------------------------------------------------------------//
// * function MakeCompass(Direction: string): Boolean; // * by nielsie95
// * Function GetWallAngle(Ps: TPointArray): Extended; // * by Wizzup?
// * procedure RunTo(dir: String; runfar: Boolean); // * by Mutant Squirrle and nielsie95
// * procedure RunAway(dir: string; RunFar: Boolean; Action, WaitTime: Integer); // * by nielsie95 modified by ZephyrsFury
// * procedure StoreToRoadColorArray; // * by Wizzup? / WT-Fakawi.
// * function GetOldRoadColors: Boolean; // * by Wizzup? / WT-Fakawi.
// * function GetNewRoadColor(xs, ys, xe, ye, tol: Integer): Boolean; // * by Wizzup? / WT-Fakawi and modified by Ron
// * function RoadColorChecker: Boolean; // * by Wizzup? / WT-Fakawi and modified by Ron
// * function CountFlag(Dist: Integer): Boolean; // * by Wizzup? / WT-Fakawi.
// * function LinearWalkEx(var tpa: TPointArray; cx, cy, TheColor, tol: Integer; Direction: Integer; Radius: Integer): Boolean; // * by nielsie95
// * function RadialWalkEx(var tpa: TPointArray; cx, cy, TheColor, tol: Integer; StartRadial, EndRadial: Integer; Radius: Integer): Boolean; // * by nielsie95
// * function RadialWalk(TheColor: Integer; StartRadial, EndRadial: Integer; Radius: Integer; Xmod, Ymod: Integer): Boolean; // * by nielsie95
// * function LinearWalk(TheColor: Integer; Direction: Integer; Radius: Integer; Xmod, Ymod: Integer): Boolean; // * by nielsie95
// * function RadialRoadWalk(TheColor: Integer; StartRadial, EndRadial: Integer; Radius: Integer; Xmod, Ymod: Integer): Boolean; // * by nielsie95
// * function LinearRoadWalk(TheColor: Integer; Direction: Integer; Radius: Integer; Xmod, Ymod: Integer): Boolean; // * by nielsie95
// * function WaterWalk(StartRadial, EndRadial: Integer; Radius, FFlagBreakOut: Integer; Xoff, Yoff, Xmod, Ymod: Integer): Boolean; // * by nielsie95
// * procedure SetAngle(highest : Boolen); // * by Raymond
// * function GetMiniMapDotsIn(WhatDot: String; x1, y1, x2, y2: Integer): TPointArray; // * by footballjds, NaumanAklaQ, Nava2 & Cazax
// * function GetMiniMapDots(WhatDot: String): TPointArray; // * by Nava2
// * function CountMiniMapDots(WhatDot: String): integer; // * by Nava2
// * procedure MouseMM(x, y, randX, randY: Integer); // * by mixster
//-----------------------------------------------------------------//
var
RoadColors: array[1..256] of Integer;
//* Roadwalk
{ var DebugRadialRoad: Boolean;
Description: Shows Debug Info on RRW. }
var
DebugRadialRoad: Boolean;
RoadCheckFlag: Boolean;
{*******************************************************************************
function MakeCompass(Direction: Variant): Boolean;
By: Nielsie95 mod by Nava2
Description: Aligns RS to specified direction
direction: Enter a compass angle ('n', 's', 'e', 'w') or degree (23.3, 25, 205.2)
and it will move the compass to that angle. Also accepts 'random',
and 'rand' to make the compass a random direction.
*******************************************************************************}
function MakeCompass(Direction: Variant): Boolean;
var
StartAngle, Angle, DirectionDeg, i: Extended;
Left: Boolean;
Mark: Integer;
begin
Result := False;
StartAngle := (rs_GetCompassAngleDegrees);
if (StartAngle < 0) or (not LoggedIn) then Exit;
case VarType(Direction) of
3, 5: DirectionDeg := FixD(Direction + 0.0);
256: try
DirectionDeg := FixD(StrToFloat(Direction));
except
case LowerCase(Direction) of
'n': DirectionDeg := 0;
'w': DirectionDeg := 270;
's': DirectionDeg := 180;
'e': DirectionDeg := 90;
'random', 'rand': DirectionDeg := RandomRange(0, 360);
end;
end;
end;
if (MinE(Abs(StartAngle - DirectionDeg), MinE(Abs(StartAngle - (DirectionDeg + 360)), Abs((StartAngle + 360) - DirectionDeg)))) <= 8.0 then
begin
Result := True;
Exit;
end;
Left := (Round((360 - StartAngle) + DirectionDeg) mod 360 <= Round((StartAngle + 360) - DirectionDeg) mod 360);
if Left then
KeyDown(VK_LEFT)
else
KeyDown(VK_RIGHT);
Wait(10);
MarkTime(Mark);
repeat
Wait(1);
Angle:= rs_GetCompassAngleDegrees;
if ((TimeFromMark(Mark) > 6000) and (i < 1.0)) or
((TimeFromMark(Mark) > 10000) and (i < 2.0)) or
((TimeFromMark(Mark) > 14000) and (i < 3.0)) then
begin
i := i + 1.0;
end;
until ((MinE(Abs(Angle - DirectionDeg), MinE(Abs(Angle - (DirectionDeg + 360)), Abs((Angle + 360) - DirectionDeg)))) <= (7.0 + i))
or (TimeFromMark(Mark) > 14000)
or (Angle < 0);
if Left then
KeyUp(VK_Left)
else
KeyUp(VK_Right);
Wait(10);
Result := ((MinE(Abs(Angle - DirectionDeg), MinE(Abs(Angle - (DirectionDeg + 360)), Abs((Angle + 360) - DirectionDeg)))) <= (7.0 + i));
end;
{$DEFINE WALL_ANGLELEFT}
{*******************************************************************************
Function GetWallAngle(Ps: TPointArray): Extended;
by: Wizzup?
Description: Get's the Minimap angle using Walls. Returns Angle in Radians.
Used in Maze.scar, but feel free to use for Perfect map aligning projects.
*******************************************************************************}
Function GetWallAngle(Ps: TPointArray): Extended;
Var
L, I, C: Integer;
ATPA, gATPA: T2DPointArray;
P, P2: TPoint;
B: TBox;
Begin
Result := -1.0;
If High(Ps) = -1 Then
Exit;
SortTPAFrom(Ps, Point((550 + 703) / 2, 0)); // Sort it from the center.
{$IFDEF WALL_ANGLELEFT}
ATPA := SplitTPAEx(Ps, 0, 1); // This turns a PointArray into
// vertical lines
{$ELSE}
ATPA := SplitTPAEx(Ps, 1, 0); //horizontal lines
{$ENDIF}
SortATPASize(ATPA, True); // longest 'line'.
L := High(aTPA);
If L = -1 Then
Exit;
SetLength(gATPA, L + 1);
C := 1;
gATPA[0] := aTPA[0];
P := MiddleTPA(aTPA[0]); // get middle of the line.
For I := 1 To L Do
Begin // this loops adds any points that are in a dist of 10 pixels.
// if vert, then x, hori then y (A wall isn't straight.)
If Length(aTPA[I]) < 4 Then
Continue;
P2 := MiddleTPA(aTPA[I]);
{$IFDEF WALL_ANGLELEFT} If Abs(P.X - P2.X) < 10 Then
{$ELSE} If Abs(P.Y - P2.Y) < 10 Then {$ENDIF}
Begin
gATPA[C] := aTPA[I];
C := C + 1;
End;
End;
SetLength(gATPA, C);
SetLength(Ps, 0);
Ps := MergeATPA(gATPA); //Combine all the points. within 10pix
B := GetTPABounds(Ps);
SortTPAFrom(Ps, Point((B.X1 + B.X2) / 2, 0)); // sort from center
SetLength(ATPA, 0);
ATPA := SplitTPA(Ps, 3); // split dist three, the left over walls
// were all in Ps, and now we split them again.
SetLength(Ps, 0);
SortATPASize(ATPA, True); // longest wall.
Ps := ATPA[0];
L := High(Ps); //angle getting
Result := ArcTan2(Ps[L].Y -Ps[0].Y, Ps[L].X - Ps[0].X) - (Pi * 0.5);
{$IFDEF WALL_ANGLELEFT} {$ELSE} Result := Result + 0.5 * Pi {$ENDIF}
End;
{*******************************************************************************
procedure RunAway(dir: string; RunFar: Boolean; Action, WaitTime: Integer);
By: nielsie95 modified by ZephyrsFury
Description: Runs away in minimap related direction, based on north.
Dir can be 'N', 'E', 'S', 'W' or an angle in degrees (145, 93, 180, etc).
RunFar will run further than normal.
Action can be either 1, 2 or 3.
1: RunAway + Wait(WaitTime) + RunBack
2: RunAway + Wait(WaitTime)
3: RunBack
Note: WaitTime is in milliseconds!
*******************************************************************************}
procedure RunAway(dir: string; RunFar: Boolean; Action, WaitTime: Integer);
var
Rad, Deg, Tab, t: Integer;
begin
if not LoggedIn then exit;
Tab := GetCurrentTab;
if RunFar then
Rad := 63
else
Rad := 30;
case UpperCase(dir) of
'N': Deg := 0;
'E': Deg := 90;
'S': Deg := 180;
'W': Deg := 270;
else Deg := StrToIntDef(Dir, -1);
end;
if (Deg = -1) then
begin
srl_Warn('RunAway', '' + Dir + ' is not a valid direction.', warn_AllVersions);
Exit;
end;
if (Action < 3) then
begin
SetRun(True);
MFNF(Trunc(Rad * Sin(Radians(FixD(Rs_GetCompassAngleDegrees + Deg))) + MMCX + Random(5)),
Trunc(-Rad * Cos(Radians(FixD(Rs_GetCompassAngleDegrees + Deg))) + MMCY + Random(5)),
1, 1);
FFlag(0);
Wait(700);
t := GetSystemTime;
while ((GetSystemTime - t) < WaitTime) and LoggedIn do
if (Random(5) = 0) then
IdleTime(2000, 500, 1.0)
else
Wait((WaitTime - (GetSystemTime - t)) / 5);
end;
if (Action = 1) or (Action = 3) then
begin
MFNF(Trunc(Rad * Sin(Radians(FixD(Rs_GetCompassAngleDegrees + (Deg + 180)))) + MMCX - Random(5)),
Trunc(-Rad * Cos(Radians(FixD(Rs_GetCompassAngleDegrees + (Deg + 180)))) + MMCY - Random(5)),
1, 1);
FFlag(0);
Wait(700);
end;
SetRun(False);
GameTab(Tab);
end;
{*******************************************************************************
procedure RunTo(Dir: String; RunFar: Boolean);
By: EvilChicken!
Description: Runs to direction
*******************************************************************************}
procedure RunTo(Dir: string; RunFar: Boolean);
begin
RunAway(dir, RunFar, 2, 0);
end;
{*******************************************************************************
procedure StoreToRoadColorArray;
By: Wizzup? / WT-Fakawi.
Description: Stores RoadColor to Array. Debugging and logging purposes.
*******************************************************************************}
procedure StoreToRoadColorArray;
var
I: Integer;
begin
for I := 1 to 256 do
if RoadColor = RoadColors[i] then
Exit
else
if RoadColors[i] = 0 then
begin
RoadColors[i] := RoadColor;
Exit;
end;
end;
{*******************************************************************************
function GetOldRoadColors: Boolean;
By: Wizzup? / WT-Fakawi.
Description: Tries to find the stored Roadcolor on the minimap and sets RoadColor.
*******************************************************************************}
function GetOldRoadColors: Boolean;
var
EC, FX, FY: Integer;
begin
Result := False;
for EC := 1 to 256 do
if RoadColors[EC] <> 0 then
if FindColorTolerance(FX, FY, RoadColors[EC], MMX1, MMY1, MMX2, MMY2, 10) then
begin
RoadColor := RoadColors[EC];
Result := True;
Exit;
end;
end;
{*******************************************************************************
function GetNewRoadColor(xs, ys, xe, ye, tol: Integer): Boolean;
By: Wizzup? / WT-Fakawi and modified by Ron
Description: Copies and compares a Bitmap of 20* 20 around Flag with known RoadColor.
Results the new global RoadColor.
*******************************************************************************}
function GetNewRoadColor(xs, ys, xe, ye, tol: Integer): Boolean;
var
DebugCanvas, ClientCanvas, MMCanvas: TCanvas;
fpx, fpy, bmp, w, h: Integer;
TC: TColor;
bmp1: Integer;
begin
if (DebugRadialRoad) then
begin
if (XS > XE) then
WriteLn('Error with RadialRoadWalk XS : ' + IntToStr(XS) + ' XE : ' +
IntToStr(XE));
if (YS > YE) then
WriteLn('Error with RadialRoadWalk YS : ' + IntToStr(YS) + ' YE : ' +
IntToStr(YE));
end;
w := xe - xs;
h := ye - ys;
ActivateClient;
if (not (LoggedIn)) then Exit;
if (DebugRadialRoad) then
begin
DisplayDebugImgWindow(w, h);
DebugCanvas := GetDebugCanvas;
ClientCanvas := GetClientCanvas;
SafeCopyCanvas(ClientCanvas, DebugCanvas, xs, ys, xe, ye, 0, 0, w, h);
end;
bmp1 := BitmapFromString(w, h, '');
Wait(1);
MMCanvas := GetBitmapCanvas(bmp1);
Wait(1);
try
bmp := BitmapFromString(w, h, '');
Wait(1);
SafeCopyCanvas(getclientcanvas, GetBitmapCanvas(bmp), xs, ys, xe, ye, 0, 0,
w, h)
except
WriteLn('Error with RadialRoadWalk');
WriteLn('Should be fixed though, so lets debug.');
WriteLn('xs = ' + IntToStr(xs) + ' ys = ' + IntToStr(ys) + ' xe = ' +
IntToStr(xe) + ' ye = ' + IntToStr(ye));
GetClientDimensions(w, h);
WriteLn('and client area is 0, 0, ' + IntToStr(w) + ', ' + IntToStr(h));
SaveBitmap(bmp, 'RoadWalkBMP');
SaveBitmap(bmp1, 'RoadWalkBMP1');
repeat
Wait(1000);
until (not (LoggedIn));
FreeBitmap(bmp);
FreeBitmap(bmp1);
Exit;
end;
Wait(1);
for fpy := 1 to h do
for fpx := 1 to w do
begin
TC := FastGetPixel(bmp, fpx, fpy);
if SimilarColors(TC, RoadColor, tol) then
begin
RoadColor := TC;
StoreToRoadColorArray;
Result := True;
Exit;
end
end;
FreeBitmap(bmp1);
end;
{*******************************************************************************
function RoadColorChecker: Boolean;
By: Wizzup? / WT-Fakawi and modified by Ron
Description: Checks for presence of RoadColor. If not found will call GetNewRoadColor
*******************************************************************************}
function RoadColorChecker: Boolean;
var
Tx, Ty, Flag4, x, y: Integer;
begin
if (not (LoggedIn)) then Exit;
Flag4 := BitmapFromString(3, 3, 'beNpjYvqjwAxEt5kwGAB7PAlY');
if (not (FindColor(x, y, RoadColor, MMX1 + 20, MMY1 + 20, MMX2 - 20, MMY2 -
20))) then // is there RoadColor ?
begin
if (FindTransparentBitmap(Flag4, TX, TY, clBlack, MMX1, MMY1, MMX2, MMY2)) then
// is there flag ?
begin
if GetNewRoadColor(TX - 14, TY - 14, TX + 26, TY + 26, 10) then
// then Copycount Bitmap...
begin
Result := True;
if (DebugRadialRoad) then
WriteLn('THROUGH FLAG!!!!!!!! ---> ' + IntToStr(RoadColor));
end
else
begin
if (GetOldRoadColors) then
if (DebugRadialRoad) then
WriteLn('THROUGH GetOldRoadColors = ---> ' + IntToStr(RoadColor))
else
begin
if (DebugRadialRoad) then
WriteLn('Couldnt Find RoadColor while Flag');
Players[CurrentPlayer].loc := 'no RoadColor';
FreeBitmap(Flag4);
Exit;
end;
end;
end
else
begin
if (GetNewRoadColor(MMCX - 20, MMCY - 20, MMCX + 20, MMCY + 20, 10)) then
// just grab from centre when no flag
begin
Result := True;
if (DebugRadialRoad) then
WriteLn('THROUGH MINIMAP!!!!!!!!---> ' + IntToStr(RoadColor));
end
else
begin
if (GetOldRoadColors) then
if (DebugRadialRoad) then
WriteLn('THROUGH GetOldRoadColors = ---> ' + IntToStr(RoadColor))
else
begin
if (DebugRadialRoad) then
WriteLn('Couldnt Find RoadColor while NO Flag');
Players[CurrentPlayer].loc := 'no RoadColor';
FreeBitmap(Flag4);
Exit;
end;
end;
end;
end;
FreeBitmap(Flag4);
end;
{*******************************************************************************
function CountFlag(Dist: Integer): Boolean;
By: Wizzup? / WT-Fakawi
Description: Waits until Flag is within "Distance" distance and check for RoadColor
changes.
*******************************************************************************}
Function CountFlag(Dist: Integer): Boolean;
begin
Result := FlagEx(Dist, True);
end;
{*******************************************************************************
function LinearWalkEx(var tpa: TPointArray; cx, cy, TheColor, tol: Integer; Direction: Integer; Radius: Integer): Boolean;
By: Nielsie95
Description: Finds TheColor from Radial (scanning outwards) for Radius Distance.
Valid Arguments:
tpa: Result points.
Direction: Any number between 0-720. 0=N,90=E,180=S,270=W.
Radius: Distance from the centre of minimap, i.e. how far away the mouse clicks. Use numbers 20-72
*******************************************************************************}
function LinearWalkEx(var tpa: TPointArray; cx, cy, TheColor, tol: Integer; Direction: Integer; Radius: Integer): Boolean;
var
i, SD, ED: Integer;
begin
Result := False;
if (not LoggedIn) then Exit;
i := GetSystemTime;
Direction := Direction mod 360;
if (Direction < 50) then
SD := ((Direction + 360) - 50)
else
SD := (Direction - 50);
ED := (Direction + 50);
while (SD > 360) do
SD := SD - 360;
while (ED > 360) do
ED := ED - 360;
try
FindColorsTolerance(tpa, TheColor, MMX1, MMY1, MMX2, MMY2, tol);
FilterPointsPie(tpa, SD, ED, 10, Radius, cx, cy);
LinearSort(tpa, cx, cy, Direction, False);
Result := (Length(tpa) > 0);
except srl_Warn('LinearWalkEx', 'LWex error!', warn_AllVersions); Exit; end;
// Uncomment this for debug
// WriteLn('LWex time: '+IntToStr(GetSystemTime - i)+'ms. Found points: '+IntToStr(Length(tpa)));
end;
{*******************************************************************************
function RadialWalkEx(var tpa: TPointArray; cx, cy, TheColor, tol: Integer; StartRadial, EndRadial: Integer; Radius: Integer): Boolean;
By: Nielsie95
Description: Finds TheColor from StartRadial to EndRadial for Radius Distance.
Valid Arguments:
tpa: Result points.
StartRadial/EndRadial: Any number between 0-720. 0=N,90=E,180=S,270=W.
Radius: Distance from the centre of minimap, i.e. how far away the mouse clicks. Use numbers 20-72
*******************************************************************************}
function RadialWalkEx(var tpa: TPointArray; cx, cy, TheColor, tol: Integer; StartRadial, EndRadial: Integer; Radius: Integer): Boolean;
var
i, SD, ED: Integer;
begin
Result := False;
SD := StartRadial;
ED := EndRadial;
if (SD = ED) then
begin
WriteLn('Using LinearWalkEx, equal values.');
Result := LinearWalkEx(tpa, cx, cy, TheColor, tol, StartRadial, Radius);
end;
if (SD > ED) then
Swap(SD, ED);
while (SD > 360) do
SD := SD - 360;
while (ED > 360) do
ED := ED - 360;
if (not LoggedIn) then Exit;
i := GetSystemTime;
try
FindColorsTolerance(tpa, TheColor, MMX1, MMY1, MMX2, MMY2, tol);
FilterPointsPie(tpa, SD, ED, 10, Radius, cx, cy);
SortCircleWise(tpa, cx, cy, StartRadial, False, StartRadial > EndRadial);
Result := (Length(tpa) > 0);
except srl_Warn('RadialWalkEx', 'An exception has occured', warn_AllVersions); Exit; end;
// Uncomment this for debug
// WriteLn('RWex time: '+IntToStr(GetSystemTime - i)+'ms. Found points: '+IntToStr(Length(tpa)));
end;
{*******************************************************************************
function RadialWalk(TheColor: Integer; StartRadial, EndRadial: Integer; Radius: Integer; Xmod, Ymod: Integer): Boolean;
By: Nielsie95
Description: Walks TheColor from StartRadial to EndRadial for Radius Distance
Valid Arguments:
TheColor: Any Color, but Road- or WaterColor will do fine :)
StartRadial/EndRadial: Any number between 0-720. 0=N,90=E,180=S,270=W.
Radius: Distance from the centre of minimap, i.e. how far away the mouse clicks. Use numbers 20-72
XMod, YMod: deviation from MouseFindFlag. -2 to 2.
*******************************************************************************}
function RadialWalk(TheColor: Integer; StartRadial, EndRadial: Integer; Radius: Integer; Xmod, Ymod: Integer): Boolean;
var
tpa: TPointArray;
i: Integer;
begin
Result := False;
if RadialWalkEx(tpa, MMCX, MMCY, TheColor, 0, StartRadial, EndRadial, Radius) then
for i := 0 to High(tpa) do
if MFNF(tpa[i].x, tpa[i].y, Xmod, Ymod) then
begin
FlagEx(10, RoadCheckFlag);
Result := True;
Break;
end;
end;
{*******************************************************************************
function LinearWalk(TheColor: Integer; Direction: Integer; Radius: Integer; Xmod, Ymod: Integer): Boolean;
By: Nielsie95
Description: Walks TheColor from Direction MIDDLE OUT!by performing windscreenlike scanning movements for Radius Distance
Valid Arguments:
TheColor: Any Color, but Road- or WaterColor will do fine :)
Direction: Any number between 0-720. 0=N,90=E,180=S,270=W.
Radius: Distance from the centre of minimap, i.e. how far away the mouse clicks. Use numbers 20-72
XMod, YMod: deviation from MouseFindFlag. -2 to 2.
*******************************************************************************}
function LinearWalk(TheColor: Integer; Direction: Integer; Radius: Integer; Xmod, Ymod: Integer): Boolean;
var
tpa: TPointArray;
i: Integer;
begin
Result := False;
if LinearWalkEx(tpa, MMCX, MMCY, TheColor, 0, Direction, Radius) then
for i := 0 to High(tpa) do
if MFNF(tpa[i].x, tpa[i].y, Xmod, Ymod) then
begin
FlagEx(10, RoadCheckFlag);
Result := True;
Break;
end;
end;
{*******************************************************************************
function RadialRoadWalk(TheColor: Integer; StartRadial, EndRadial: Integer; Radius: Integer; Xmod, Ymod: Integer): Boolean;
By: Nielsie95
Description: Walks TheColor from StartRadial to EndRadial for Radius Distance
Valid Arguments:
TheColor: RoadColor. RoadColor will be dynamically updated.
StartRadial/EndRadial: Any number between 0-720. 0=N,90=E,180=S,270=W.
Radius: Distance from the centre of minimap, i.e. how far away the mouse clicks. Use numbers 20-72
XMod, YMod: deviation from MouseFindFlag. -2 to 2.
*******************************************************************************}
function RadialRoadWalk(TheColor: Integer; StartRadial, EndRadial: Integer; Radius: Integer; Xmod, Ymod: Integer): Boolean;
begin
Result := False;
if(not LoggedIn)then Exit;
if (RoadColorChecker)and(DebugRadialRoad) then
WriteLn(' THROUGH RADIALROADWALK= ---> ' + IntToStr(RoadColor));
RoadCheckFlag := True;
Result := RadialWalk(TheColor, StartRadial, EndRadial, Radius, Xmod, Ymod);
RoadCheckFlag := False;
end;
{*******************************************************************************
function LinearRoadWalk(TheColor: Integer; Direction: Integer; Radius: Integer; Xmod, Ymod: Integer): Boolean;
By: Nielsie95
Description: Walks TheColor from Direction MIDDLE OUT!by performing windscreenlike scanning movements for Radius Distance
Valid Arguments:
TheColor: Any Color, but Road- or WaterColor will do fine :)
Direction: Any number between 0-720. 0=N,90=E,180=S,270=W.
Radius: Distance from the centre of minimap, i.e. how far away the mouse clicks. Use numbers 20-72
XMod, YMod: deviation from MouseFindFlag. -2 to 2.
*******************************************************************************}
function LinearRoadWalk(TheColor: Integer; Direction: Integer; Radius: Integer; Xmod, Ymod: Integer): Boolean;
begin
Result := False;
if(not LoggedIn)then Exit;
if (RoadColorChecker)and(DebugRadialRoad) then
WriteLn(' THROUGH RADIALROADWALK= ---> ' + IntToStr(RoadColor));
RoadCheckFlag := True;
Result := LinearWalk(TheColor, Direction, Radius, Xmod, Ymod);
RoadCheckFlag := False;
end;
{*******************************************************************************
function WaterWalk(StartRadial, EndRadial: Integer; Radius, FFlagBreakOut: Integer; Xoff, Yoff, Xmod, Ymod: Integer): Boolean;
By: Nielsie95
Description: Walks alongside Water.
StartRadial/EndRadial := Any number between 0-720. 0=N,90=E,180=S,270=W.
Radius: Distance from the centre of minimap, i.e. how far away the mouse clicks. Use numbers 20-72
FFlagBreakOut: Distance to flag where it will break out. 15 - 10 is good.
Xoff, Yoff: Added to found point.
XMod, YMod: deviation from MouseFindFlag. -2 to 2.
*******************************************************************************}
function WaterWalk(StartRadial, EndRadial: Integer; Radius, FFlagBreakOut: Integer; Xoff, Yoff, Xmod, Ymod: Integer): Boolean;
var
tpa: TPointArray;
i: Integer;
begin
Result := False;
if RadialWalkEx(tpa, MMCX, MMCY, WaterColor, 0, StartRadial, EndRadial, Radius) then
for i := 0 to High(tpa) do
if MFNF(tpa[i].x + Xoff, tpa[i].y + Yoff, Xmod, Ymod) then
begin
FFLag(FFlagBreakOut);
Result := True;
Break;
end;
end;
{*******************************************************************************
procedure SetAngle(Highest : Boolean);
By: Raymond
Description: Sets the mainscreen at highest\lowest angle (Depends on the boolean)
*******************************************************************************}
procedure SetAngle(Highest : Boolean);
var
Key : Byte;
begin;
if Highest then
Key := 38
else
Key := 40;
if (LoggedIn) then
begin
KeyDown(Key);
Sleep(1000 + Random(100) + Random(200));
KeyUp(Key);
Wait(500 + Random(100));
end;
end;
{*******************************************************************************
function GetMiniMapDotsIn(WhatDot: String; x1, y1, x2, y2: Integer): TPointArray;
By: footballjds, NaumanAkhlaQ, Nava2 & Cazax
Description: Results the dots specified by WhatDot in x1, y1, x2, y2.
Usage : 'npc', 'yellow' : Yellow Dot;
'cape', 'blue' : Blue Dot;
'item', 'red' : Red Dot;
'player', 'white' : White Dot;
'friend', 'green' : Green Dot;
*******************************************************************************}
function GetMiniMapDotsIn(WhatDot: String; x1, y1, x2, y2: Integer): TPointArray;
var
Color: Integer;
begin
WhatDot := LowerCase(WhatDot);
case WhatDot Of
'npc', 'yellow' : Color := 60909;
'cape', 'blue' : Color := 12742980;
'item', 'red' : Color := 789758;
'player', 'white' : Color := 16711422;
'friend', 'green' : Color := 61440;
end;
FindColorsSpiralTolerance(MMCX, MMCY, Result, Color, x1, y1, x2, y2, 0);
RAaSTPA(Result, 4);
if (WhatDot = 'player') or (WhatDot = 'white') then
begin
InvertTPA(Result);
SetLength(Result, Length(Result) - 1);
InvertTPA(Result);
end;
end;
{*******************************************************************************
function GetMiniMapDotsIn(WhatDot: String): TPointArray;
By: Nava2
Description: Results the dots specified by WhatDot on the Minimap. See GetMiniMapDots
in for more information.
*******************************************************************************}
function GetMiniMapDots(WhatDot: String): TPointArray;
begin
Result := GetMinimapDotsIn(WhatDot, MMX1, MMY1, MMX2, MMY2);
end;
{*******************************************************************************
function CountDots(WhatDot: String): integer;
By: Nava2
Description: Counts the occurance of WhatDot on the MiniMap. See GetMiniMapDots
in for more information.
*******************************************************************************}
function CountDots(WhatDot: String): integer;
begin
Result := Length(GetMinimapDots(WhatDot));
end;
{*******************************************************************************
procedure MouseMM(x, y, randX, randY: Integer);
By: mixster
Description: Clicks (x, y) on the MM, taking Map Angle into Account.
Be sure to choose the coords when Map Angle = 0 !
*******************************************************************************}
procedure MouseMM(x, y, randX, randY: Integer);
var
p: TPoint;
begin
if not rs_OnMinimap(x, y) then
exit;
p := RotatePoint(Point(x, y), rs_GetCompassAngleRadians, MMCX, MMCY);
Mouse(p.x, p.y, randX, randY, True);
end;FlagChat.scar
//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- » Mouse Flag & Chat Routines --//
//-----------------------------------------------------------------//
// * function IsMoving(WaitTime: Integer): Boolean; // * by Bullzeye95 & Nava2
// * function FlagPresent: Boolean; // * by Mutant Squirrle
// * function FlagDistance: Integer; // * by PPLSUQBAWLZ/Odie533
// * Function MFF(ax, ay, xmod, ymod: Integer):Boolean; // * by WT-Fakawi
// * Function MFNF(ax, ay, xmod, ymod: Integer):Boolean; // * by WT-Fakawi
// * function FFlag(Dist: Integer): Boolean; // * by Wizzup? / WT-Fakawi / ZephyrsFury
// * function Flag: Boolean; // * by Nava2
// * procedure MouseFlag(cx, cy, rx, ry, FlagDist: Integer); // * by RsN edit by EvilChicken!
// * procedure SetChat(state: String; chat: Integer); // * by Wizzup?, WT-Fakawi, Starblaster100 & N1ke!
// * procedure SetAllChats(Pub, Priv, Clan, Trade, Assist: string); // * by ZephyrsFury
// * procedure ChatsOff; // * by Starblaster100
{*******************************************************************************
function IsMoving(WaitTime: Integer): Boolean;
By: Bullzeye95; Edits by Nava2
Description: Checks if the currently loaded player is moving. Uses Minimap,
ignoring all dots which can move without the player moving.
Nava2 edit: Added try..finally, also changed to work with SMART,
as well added WaitTime Parameter.
*******************************************************************************}
function IsMoving(WaitTime: Integer): Boolean;
var
BMP, BMP2, I, H, x, y: Integer;
ReplaceCols: TIntegerArray;
P: TPointArray;
DC: HDC;
begin
WaitTime := Max(50, WaitTime);
try
DC := GetTargetDC;
ReplaceCols:= [65536, 16711422, 12961221, 14869218, 16777215, 15527148, 195836, 56797, 60909, 52428,
13816530, 982782, 1310462, 62965, 2105598, 395004, 789758, 3553023, 217, 188, 241,
206, 233, 64768, 58880, 51456, 49152, 44800, 61440, 16215571, 9716750, 13129742];
BMP:= BitmapFromString(100, 100, '');
BMP2:= BitmapFromString(100, 100, '');
SafeCopyCanvas(GetClientCanvas, GetBitmapCanvas(BMP), MMCX - 50, MMCY - 50, MMCX + 50, MMCY + 50, 0, 0, 100, 100);
H := High(ReplaceCols);
for I:= 0 to H do
FastReplaceColor(BMP, ReplaceCols[i], 0);
wait(WaitTime);
SafeCopyCanvas(GetClientCanvas, GetBitmapCanvas(BMP2), MMCX - 50, MMCY - 50, MMCX + 50, MMCY + 50, 0, 0, 100, 100);
SetTargetDC(GetBitmapDC(BMP2));
for I:= 0 to H do
begin
FindColorsTolerance(P, ReplaceCols[i], 0, 0, 99, 99, 0);
y:= High(P);
for x:= 0 to y do
FastSetPixel(BMP2, P[x].x, P[x].y, FastGetPixel(BMP, P[x].x, P[x].y));
end;
Result:= not FindBitmapIn(BMP, x, y, 0, 0, 99, 99);
finally
SetTargetDC(DC);
FreeBitmap(BMP);
FreeBitmap(BMP2);
end;
end;
{*******************************************************************************
function FlagPresent: Boolean;
By: Mutant Squirrle
Description: T/F depending on flag exist.
*******************************************************************************}
function FlagPresent: Boolean;
var
x, y: integer;
begin
Result := FindColor(x, y, 3026478, MMX1, MMY1, MMX2, MMY2);
end;
{*******************************************************************************
function FlagDistance: Integer;
By: PPLSUQBAWLZ/Odie533
Description: Returns distance in pixels your char dot is from flag on mini-map
*******************************************************************************}
function FlagDistance: Integer;
var
x, y: Integer;
begin
if (FindColor(x, y, 3026478, MMX1, MMY1, MMX2, MMY2)) then
Result := Distance(MMCX, MMCY, x + 1, y + 14);
end;
{*******************************************************************************
Function MFF(ax, ay, xmod, ymod: Integer):Boolean;
By: WT-Fakawi
Description: If the flag is not present it will click at (ax, ay) increasing by
(xmod, ymod) 5 times or until the flag appears.
*******************************************************************************}
Function MFF(ax, ay, xmod, ymod: Integer):Boolean;
var
TT, i, xx, yy, x, y, BreakOutTime: Integer;
begin
if (not LoggedIn) then Exit;
if (not (FlagPresent)) then
begin
xx := ax - xmod;
yy := ay - ymod;
MarkTime(BreakOutTime);
for i := 0 to 4 do
begin
xx := xx + xmod;
yy := yy + ymod;
if rs_OnMiniMap(xx, yy) then
Mouse(xx, yy, 2, 2, True)
else
Continue;
Wait(50);
MarkTime(TT);
repeat
Wait(10);
if FindColor(x, y, 3026478, MMx1, MMy1, MMx2, MMy2) then
begin
Result := True
Exit;
end;
Wait(Random(100));
until TimeFromMark(TT) > 3000;
end;
Result := False;
end;
end;
{*******************************************************************************
Function MFNF(ax, ay, xmod, ymod: Integer):Boolean;
By: WT-Fakawi
Description: Like MFF except it will click even if the flag is present when the
function is called.
*******************************************************************************}
Function MFNF(ax, ay, xmod, ymod: Integer):Boolean;
var
TT, i, xx, yy, x, y: Integer;
begin
Result := False;
if (not LoggedIn) then Exit;
xx := ax - xmod;
yy := ay - ymod;
for i := 0 to 4 do
begin
xx := xx + xmod;
yy := yy + ymod;
if rs_OnMiniMap(xx, yy) then
Mouse(xx, yy, 2, 2, True)
else
Continue;
Wait(50);
MarkTime(TT);
repeat
Wait(100);
if FindColor(x, y, 3026478, MMx1, MMy1, MMx2, MMy2) then
begin
Result := True;
Exit;
end;
Wait(Random(100));
until TimeFromMark(TT) > 3000;
end;
end;
function RoadColorChecker: Boolean;Forward;
{*******************************************************************************
function FlagEx(Dist: Integer; RoadColorCheck: Boolean): Boolean;
By: Wizzup? / WT-Fakawi / ZephyrsFury modified by N1ke!
Description: Waits until Flag is within "Distance" distance.
*******************************************************************************}
function FlagEx(Dist: Integer; RoadColorCheck: Boolean): Boolean;
var
Tx, Ty, M, D1, D2: Integer;
begin
Result := False;
M := GetSystemTime;
while (FindColor(Tx, Ty, 3026478, MMX1, MMY1, MMX2, MMY2)) do
begin
D1 := Distance(Tx, Ty + 14, MMCX, MMCY);
if (D1 <= Dist) then
begin
Result := True;
Exit;
end;
If RoadColorCheck then
RoadColorChecker;
Wait(100);
if (GetColor(6, 6) <> clWhite) then
if (GetSystemTime - M > 5000) then
begin
if (D1 = D2) then Exit;
D2 := D1;
M := GetSystemTime;
end;
if (Random(20) = 0) then IdleTime(500, 1000, 0.01);
if SRL_Procs[SRL_AntiBan] <> nil then
SRL_Procs[SRL_AntiBan]();
end;
Wait(RandomRange(200, 400));
end;
{*******************************************************************************
function FFlag(Dist: Integer): Boolean;
By: Wizzup? / WT-Fakawi / ZephyrsFury
Description: Waits until Flag is within "Distance" distance.
*******************************************************************************}
function FFlag(Dist: Integer): Boolean;
begin
Result := FlagEx(Dist, False);
end;
{*******************************************************************************
function Flag: Boolean;
By: Nava2
Description: Waits while flag exists.
*******************************************************************************}
function Flag: Boolean;
begin
Result := FlagEx(0, False);
end;
{*******************************************************************************
procedure MouseFlag(cx, cy, rx, ry, FlagDist: Integer);
By: RsN edit by EvilChicken!
Description: Mouse and Flag combined into one easy procedure.
*******************************************************************************}
procedure MouseFlag(cx, cy, rx, ry, FlagDist: Integer);
var
i: Integer;
begin
if (not LoggedIn) then Exit;
Mouse(cx, cy, rx, ry, True);
while (not FlagPresent) and (i < 10) do
begin
Wait(100);
Inc(i);
end;
FFlag(FlagDist);
Wait(300 + Random(200));
end;
{*******************************************************************************
procedure SetChat(state: String; chat: Integer);
By: Wizzup?, WT-Fakawi, Starblaster100 & N1ke!
Description: Sets Chat to desired state
Chat: Game Public Private Clan Trade Assist
0 1 2 3 4 5
*******************************************************************************}
procedure SetChat(state: string; chat: Integer);
var
x, y, mx, Color: Integer;
begin
case chat of
0: mx := 90;
1: mx := 145;
2: mx := 200;
3: mx := 260;
4: mx := 320;
5: mx := 373;
else
begin
srl_Warn('SetChat', 'chat(' + IntToStr(chat) + ') does not exist.', warn_AllVersions);
Exit;
end;
end;
State := LowerCase(State);
case State of
'on', 'all': Color := 65280;
'off': Color := 255;
'hide': Color := 16776960;
'friends', 'filter': Color := 65535;
else srl_Warn('SetChat', state + ' does not exist.', warn_AllVersions);
end;
State := Capitalize(State);
if not FindColor(x, y, Color, mx - 10, 486, mx + 10, 506) then
begin
Mouse(mx, 496, 8, 8, False);
Wait(450 + Random(175));
ChooseOption(State);
end;
end;
{*******************************************************************************
procedure SetAllChats(Game, Pub, Priv, Clan, Trade, Assist: string);
By: ZephyrsFury
Description: Sets all the chats to a particular state in one simple procedure.
Leave the parameter as '' if you wish to leave the chat as it is.
Example: SetAlChats('all', 'Hide', '', 'Off', '', 'Friend');
*******************************************************************************}
procedure SetAllChats(Game, Pub, Priv, Clan, Trade, Assist: string);
var
States: TStringArray;
II: Integer;
begin
if (not(LoggedIn)) then Exit;
States := [Game, Pub, Priv, Clan, Trade, Assist];
for II := 0 to 5 do
begin
if (States[II] = '') then Continue;
SetChat(States[II], II);
end
end;
{*******************************************************************************
procedure ChatsOff;
By: Starblaster100
Description: Sets all Chats to off.
*******************************************************************************}
Procedure ChatsOff;
var
i: Integer;
begin
for i := 1 to 5 do
SetChat('off', i);
end;