Current projects:
[ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]
"I won't fall in your gravity. Open your eyes,
you're the Earth and I'm the sky..."
hmm
just made a path. In towns it seems to missclick west like 10-5 pixels, this happens with more than half of the clicks it makes on MM. It gets lost too pretty easily...
just made a path. In towns it seems to missclick west like 10-5 pixels, this happens with more than half of the clicks it makes on MM. It gets lost too pretty easily...
E: when there are more than 5 ppl on the map, it wont start moving at all.
Ok, so through further progressing I advanced the function to use a much more practical method. I hope you'll like what I did here as I'm quite pleased with the ingenuity.
Before we had two static DTMs; one of a vertical wall and one of a horizontal wall, both about 12 in length. Like I said this was a sloppy way of doing it.
So, what I've done is created two new functions to aid the 'ForceMapNorth' function. The first of which will find the longest wall on your minimap, no matter what angle you're at. It search both horizontal and vertical. The second function generates an absolute DTM of a straight-line wall. You feed this function what wall type you want (1 for vertical, 2 for horizontal) and the length of the wall and it will generate a perfect wall DTM for you. Later these two function work together to auto-generate a perfect DTM of the longest wall (both vertical and horizontal) on your MM and these two DTMs are fed into the ForceMapNorth function. Now, in this new version of the function I chose to generate DTMs of only 70% of the longest wall but of course this could be changed back to 100% of the longest wall, if one chooses.
Also, in this new version of ForceMapNorth there's a more accurate way of rotating the map and it will not rotate as far as before. Also if the DTM is not found in the first direction it rotates it should try again in the opposite direction, starting from North. If the DTM is not found in either direction it will revert your compass back to the default North position.
Simba Code:{*******************************************************************************
Function GenerateWallDTM(WallType, WallLength: Integer): Integer;
By: Flight
Description: Creates a DTM of a perfectly straight wall.
-WallType : 1 for vertical, 2 for horizontal
-WallLength: Length of the DTM to be generated
*******************************************************************************}
function GenerateWallDTM(WallType, WallLength: Integer): Integer;
var
i: Integer;
TempTDTM: TDTM;
mPnt: TDTMPointDef;
sPnts: array of TDTMPointDef;
begin
SetArrayLength(sPnts, (WallLength-1));
mPnt.x := 0;
mPnt.y := 0;
mPnt.AreaSize := 0;
mPnt.AreaShape := 0;
mPnt.Color := 16119287;
mPnt.Tolerance := 40;
for i:=0 to High(sPnts) do
begin
case WallType of
1:
begin
sPnts[i].x := 0;
sPnts[i].y := i+1;
end;
2:
begin
sPnts[i].x := i+1;
sPnts[i].y := 0;
end;
end;
sPnts[i].AreaSize := 0;
sPnts[i].AreaShape := 0;
sPnts[i].Color := 16119287;
sPnts[i].Tolerance := 40;
end;
TempTDTM.MainPoint := mPnt;
TempTDTM.SubPoints := sPnts;
Result := AddDTM(TempTDTM);
end;
{*******************************************************************************
Function GetLongestWallLength(WallType: Integer): Integer;
By: Flight
Description: Determines the longest wall on your MM at any compass angle.
-WallType: 1 for vertical walls, 2 for horizontal walls
*******************************************************************************}
function GetLongestWallLength(WallType: Integer): Integer;
var
B: TBox;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
ColorToleranceSpeed(1);
FindColorsSpiralTolerance(MMCX, MMCY, TPA, 16119287, MMX1, MMY1, MMX2, MMY2, 40);
if (Length(TPA)<1) then
Exit;
if (WallType = 1) then
SplitTPAExWrap(TPA, 2, 5, ATPA)
else
SplitTPAExWrap(TPA, 5, 2, ATPA);
SortATPASize(ATPA, True);
B := GetTPABounds(ATPA[0]);
if (WallType = 1) then
Result := (B.Y2-B.Y1)
else
Result := (B.X2-B.X1);
end;
{*******************************************************************************
Function ForceMapNorth: Boolean;
By: Flight
Description: Using auto-generated wall DTMs, this function will attempt to
rotate the compass to near-perfect north. Should it fail it will revert
back to default north.
*******************************************************************************}
Function ForceMapNorth: Boolean;
var
Left: Boolean;
StartAngle: Extended;
X,Y,DTM_VertWall,
DTM_HorWall,T,F,L1,L2: Integer;
label
Start,FuncEnd;
begin
Result := False;
L1 := GetLongestWallLength(1);
L2 := GetLongestWallLength(2);
if (L1 > 50) then
L1 := 50;
if (L2 > 50) then
L2 := 50;
DTM_VertWall := GenerateWallDTM(1, Round(L1*0.85)); //Create a DTM 85% of the length of the longest vertical wall
DTM_HorWall := GenerateWallDTM(2, Round(L2*0.85)); //Create a DTM 85% of the length of the longest horizontal wall
if (FindDTM(DTM_VertWall, X, Y, MMx1, MMy1, MMx2, MMy2) or
FindDTM(DTM_HorWall, X, Y, MMx1, MMy1, MMx2, MMy2)) then
begin
Result := True;
GoTo FuncEnd;
end;
StartAngle := (rs_GetCompassAngleDegrees);
Left := (Round((360 - StartAngle)) mod 360 <= Round((StartAngle + 360)) mod 360);
Start:
if (F > 0) then
MakeCompass('N');
MarkTime(T);
Repeat
TypeByte((Ord(not Left) * 2) + 37); //No holding down, actually press the arrow key
if (FindDTM(DTM_VertWall, X, Y, MMx1, MMy1, MMx2, MMy2) or
FindDTM(DTM_HorWall, X, Y, MMx1, MMy1, MMx2, MMy2)) then
break;
Until(TimeFromMark(T) >= 1000)
FuncEnd:
if ((not FindDTM(DTM_VertWall, X, Y, MMx1, MMy1, MMx2, MMy2)) and
(not FindDTM(DTM_HorWall, X, Y, MMx1, MMy1, MMx2, MMy2))) then
begin
Inc(F);
StartAngle := (rs_GetCompassAngleDegrees);
Left := (Round((360 - StartAngle)) mod 360 <= Round((StartAngle + 360)) mod 360);
if (F < 2) then
GoTo Start;
end else if ((X > 1) and (Y > 1)) then
Result := True;
if not Result then
MakeCompass('N');
FreeDTM(DTM_VertWall);
FreeDTM(DTM_HorWall);
end;
Last edited by Flight; 05-06-2013 at 04:36 AM.
Current projects:
[ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]
"I won't fall in your gravity. Open your eyes,
you're the Earth and I'm the sky..."
Yeah here's an example script that should walk you from the AlKharid bank to the fire altar, then back to the bank. Unfortunately my current SMART client has radical MM colors and SPS cannot determine my location so I couldn't test this.
Simba Code:{$DEFINE SMART8}
{$i SRL-OSR/SRL.Simba}
{$i SPS/SPS-OSR.simba}
Procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
with Players[0] do
begin
Name := '';
Pass := '';
Nick := '';
Pin := '';
LampSkill := Skill_Herblore;
WorldInfo := [];
Member := True;
Active := True;
end;
end;
Function InvertPath(Points: TPointArray): TPointArray;
Var
i, j: integer;
begin
SetLength(Result, Length(Points));
j := 0;
for i := High(Points) downto 0 do
begin
Result[j] := Points[i];
Inc(j);
end;
end;
Function IsMoving_F: Boolean;
begin
Result := PixelShift(IntToBox(MMCX-30, MMCY-30, MMCX+30, MMCY+30), 200) > 200;
end;
{*******************************************************************************
Function GenerateWallDTM(WallType, WallLength: Integer): Integer;
By: Flight
Description: Creates a DTM of a perfectly straight wall.
-WallType : 1 for vertical, 2 for horizontal
-WallLength: Length of the DTM to be generated
*******************************************************************************}
function GenerateWallDTM(WallType, WallLength: Integer): Integer;
var
i: Integer;
TempTDTM: TDTM;
mPnt: TDTMPointDef;
sPnts: array of TDTMPointDef;
begin
SetArrayLength(sPnts, (WallLength-1));
mPnt.x := 0;
mPnt.y := 0;
mPnt.AreaSize := 0;
mPnt.AreaShape := 0;
mPnt.Color := 16119287;
mPnt.Tolerance := 40;
for i:=0 to High(sPnts) do
begin
case WallType of
1:
begin
sPnts[i].x := 0;
sPnts[i].y := i+1;
end;
2:
begin
sPnts[i].x := i+1;
sPnts[i].y := 0;
end;
end;
sPnts[i].AreaSize := 0;
sPnts[i].AreaShape := 0;
sPnts[i].Color := 16119287;
sPnts[i].Tolerance := 40;
end;
TempTDTM.MainPoint := mPnt;
TempTDTM.SubPoints := sPnts;
Result := AddDTM(TempTDTM);
end;
{*******************************************************************************
Function GetLongestWallLength(WallType: Integer): Integer;
By: Flight
Description: Determines the longest wall on your MM at any compass angle.
-WallType: 1 for vertical walls, 2 for horizontal walls
*******************************************************************************}
function GetLongestWallLength(WallType: Integer): Integer;
var
B: TBox;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
ColorToleranceSpeed(1);
FindColorsSpiralTolerance(MMCX, MMCY, TPA, 16119287, MMX1, MMY1, MMX2, MMY2, 40);
if (Length(TPA)<1) then
Exit;
if (WallType = 1) then
SplitTPAExWrap(TPA, 2, 5, ATPA)
else
SplitTPAExWrap(TPA, 5, 2, ATPA);
SortATPASize(ATPA, True);
B := GetTPABounds(ATPA[0]);
if (WallType = 1) then
Result := (B.Y2-B.Y1)
else
Result := (B.X2-B.X1);
end;
{*******************************************************************************
Function ForceMapNorth: Boolean;
By: Flight
Description: Using auto-generated wall DTMs, this function will attempt to
rotate the compass to near-perfect north. Should it fail it will revert
back to default north.
*******************************************************************************}
Function ForceMapNorth: Boolean;
var
Left: Boolean;
StartAngle: Extended;
X,Y,DTM_VertWall,
DTM_HorWall,T,F,L1,L2: Integer;
label
Start,FuncEnd;
begin
Result := False;
L1 := GetLongestWallLength(1);
L2 := GetLongestWallLength(2);
if (L1 > 50) then
L1 := 50;
if (L2 > 50) then
L2 := 50;
DTM_VertWall := GenerateWallDTM(1, Round(L1*0.85)); //Create a DTM 85% of the length of the longest vertical wall
DTM_HorWall := GenerateWallDTM(2, Round(L2*0.85)); //Create a DTM 85% of the length of the longest horizontal wall
if (FindDTM(DTM_VertWall, X, Y, MMx1, MMy1, MMx2, MMy2) or
FindDTM(DTM_HorWall, X, Y, MMx1, MMy1, MMx2, MMy2)) then
begin
Result := True;
GoTo FuncEnd;
end;
StartAngle := (rs_GetCompassAngleDegrees);
Left := (Round((360 - StartAngle)) mod 360 <= Round((StartAngle + 360)) mod 360);
Start:
if (F > 0) then
MakeCompass('N');
MarkTime(T);
Repeat
TypeByte((Ord(not Left) * 2) + 37); //No holding down, actually press the arrow key
if (FindDTM(DTM_VertWall, X, Y, MMx1, MMy1, MMx2, MMy2) or
FindDTM(DTM_HorWall, X, Y, MMx1, MMy1, MMx2, MMy2)) then
break;
Until(TimeFromMark(T) >= 1000)
FuncEnd:
if ((not FindDTM(DTM_VertWall, X, Y, MMx1, MMy1, MMx2, MMy2)) and
(not FindDTM(DTM_HorWall, X, Y, MMx1, MMy1, MMx2, MMy2))) then
begin
Inc(F);
StartAngle := (rs_GetCompassAngleDegrees);
Left := (Round((360 - StartAngle)) mod 360 <= Round((StartAngle + 360)) mod 360);
if (F < 2) then
GoTo Start;
end else if ((X > 1) and (Y > 1)) then
Result := True;
if not Result then
MakeCompass('N');
FreeDTM(DTM_VertWall);
FreeDTM(DTM_HorWall);
end;
function WalkPath_F(Path: TPointArray): boolean;
var
I, H, T, D, Fails: integer;
P, MM, MMF: TPoint;
begin
ColorToleranceSpeed(1);
H := High(Path);
T := GetSystemTime + 11000 + Random(2000);
Fails := 0;
ForceMapNorth;
RunEnergy(70);
while (not Result) and (GetSystemTime < T) and (Fails < 5) do
begin
FindNormalRandoms;
if (not LoggedIn()) then
Exit;
P := SPS_GetMyPos();
for I := H downto 0 do
begin
MM := RotatePoint(Point(MMCX + Path[I].X - P.X, MMCY + Path[I].Y - P.Y), 0-(Radians((Round(rs_GetCompassAngleDegrees + DF) mod 360))), MMCX, MMCY);
if MM = MMF then
Inc(Fails);
D := Distance(MM.X, MM.Y, MMCX, MMCY);
if (D < 10) then
break
else
if (D < 70) then
begin
Mouse(MM.X, MM.Y, 0, 0, mouse_left);
WaitFunc(@IsMoving_F, 10, 2500);
MMF := MM;
FFlag(30);
T := getSystemTime + 11000 + Random(2000);
Break;
end;
end;
if (I = H) then
While IsMoving_F do
Wait(1);
Result := (I = H);
end;
end;
Var
Path_BankToAltar: TPointArray;
begin
DeclarePlayers;
SetupSRL;
SRL_CombatRandoms := False;
SPS_Setup(runescape_surface, ['alkharidpath']);
//SPS_AnyAngle := True; //No need
Path_BankToAltar := [Point(75,414), Point(93,408), Point(111,378), Point(120,348),
Point(126,312), Point(130,264), Point(159,228), Point(183,195),
Point(201,162), Point(208,126), Point(225,93), Point(240,72)];
WalkPath_F(Path_BankToAltar);
WalkPath_F(InvertPath(Path_BankToAltar));
end.
And here's the SPS image (you'll need to stick this in with the other 07 SPS maps):
Oh and by the way, I made a slight modification to both 'GetLongestWallLength' as well as ForceMapNorth. Now, we grab the longest wall lengths separately for each wall type rather than the longest wall is made into both a vertical and horizontal wall, instead now the two DTMs will be relevant to their own length. Also in the ForceMapNorth function it no long holds down the arrow key but instead presses it. This is less human-like, yes, but it should give us more accuracy in finding the wall DTMs. I've updated the post above with these two modified functions.
Current projects:
[ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]
"I won't fall in your gravity. Open your eyes,
you're the Earth and I'm the sky..."
How do I download the SPS Simba file as a ZIP so I can put it in the folder.......?
i always get: SPS returns -1, -1
any tips?
Ok you guys, replace your 'GetLongestWallLength' with this one:
Simba Code:{*******************************************************************************
Function GetLongestWallLength(WallType: Integer): Integer;
By: Flight
Description: Determines the longest wall on your MM at any compass angle.
-WallType: 1 for vertical walls, 2 for horizontal walls
*******************************************************************************}
function GetLongestWallLength(WallType: Integer): Integer;
var
B: TBox;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
ColorToleranceSpeed(1);
FindColorsSpiralTolerance(MMCX, MMCY, TPA, 16119287, MMX1, MMY1, MMX2, MMY2, 40);
if (Length(TPA)<1) then
Exit;
RAaSTPA(TPA, 1);
if (WallType = 1) then
SplitTPAExWrap(TPA, 2, 3, ATPA)
else
SplitTPAExWrap(TPA, 3, 2, ATPA);
SortATPASize(ATPA, True);
B := GetTPABounds(ATPA[0]);
if (WallType = 1) then
Result := (B.Y2-B.Y1)
else
Result := (B.X2-B.X1);
end;
Yeah, you're better off making custom SPS maps. The '07 maps that come with that unofficial OSR-SPS are really low quality compared to the real RS minimap. If you're really determined to use SPS then I'd suggest you take a look at this RSPS map-editor. It's a cache version of the RS map from sometime in 2006 so it contains most of the current 07 map. You'll have to load areas region by region and take snapshots of the minimap printed then peice them together but it's faster than using the minimap in OSR and it's very high quality compared to the SPS maps.
Last edited by Flight; 05-12-2013 at 12:33 PM.
Current projects:
[ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]
"I won't fall in your gravity. Open your eyes,
you're the Earth and I'm the sky..."
In OSR it's very difficult to walk, mainly due to the violent color changes after every region change. But actually there's 3 weapons used against color bots for the minimap alone. First is the angle will change degrees at random times, whether your map region changes or not. The second is, as I stated before, the extreme changes in MM colors. And the last anti-bot measure for the MM is the zoom; you'll notice that the MM will actually zoom in/out a small amount at random times as well.
Between these 3 it's an absolute pain to make a minimap-walker both accurate and stable. There's a few ways to walk in OSR but none really classify as both accurate and stable. You can use (D)DTMs, RadialWalking (this in combination with AutoColoring I heard works well), ObjectDTMs (made for the current RS but you can modify them to work for OSR; still not 100% stable though) and SPS (highly suggest using custom maps). It's frustrating I know; I couldn't get my Naturez script to run for more than 30 minutes before SPS start walking to odd places, and that's using 2 separate high-quality area maps.
It's a reason why I've been spending time trying to understand reflection & getting it to work in SMART.
Current projects:
[ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]
"I won't fall in your gravity. Open your eyes,
you're the Earth and I'm the sky..."
Mmmh i see.. But if you get reflection to work in smart that would be amazing! It doesnt need all the features like other bots but only walking and maybe random events.
Thanks for the fast responses and good luck on figuring out how reflection works and how to get it working with the smart client!
i have problem i dont got the binaryl file to get it work where i can find thing like that keep getting Exception in Script: Plugin(sps32) has not been found my simba + srl osr working fine but where to find binary to make sps osr work!
SPS Still does not work as it supposed to! It runs and clicks non Stop even though it hasn't reached the coords!
Oh it found the flag it just kept clicking none stop until all the cords are done! It doesnt wait until it reaches the flag is what im trying to say!
I haven't been active here for a couple months, if anyone would like to add this to a new github page to continue development, I'll update the OP.
Also, @Flight, I was actually thinking about making a procedure that attempted to do perfect north based on walls. Depending on how it is used, would definitely increase stability.
.---. ``````````` .---. .
\___ `,-. ,-. ,-. \___ ยท|- ,-. ,-
``` \ |-'`,-| | | ``` \ | `,-| |
`---' `-' `-^ ' ' `---' `' `-^ '
Would Love to see what you have come up with Star!! and not only make attempt to do a perfect north based wall but make sure it waits long enough until it reaches the FFlag before it clicks the other point!
@Flight, It would work so much better if the FFlag(30), would work! It doesnt wait long enough and causes the script to click random points no matter where its at!
Exception in Script: Unable to find file 'SPS/sps-osr.simba' used from 'C:\Simba\Scripts\ineedbot's AIO Chopper[2.1].simba'
I keep getting this error but the SPS file is where the script file is. I've installed everything correctly and I still can't make it work.
There are currently 1 users browsing this thread. (0 members and 1 guests)