Hi all. It took me sps switch between custom maps in real time, and this is what came of it:
Simba Code:
//function for dinamically map switching in script
function SPS_SwitchMap(surface: integer; areas: TStringArray):boolean;
var
t: integer;
tmp: TMufasaBitmap;
begin
SetLength(SPS_Areas,0);
SetLength(SPS_AreaMaps,0);
t:=getSystemTime;
SPS_MultiMouse := true;
SPS_Accuracy := 4;
if (length(areas) > 0) then
begin
SetLength(areas,1);
if (surface = RUNESCAPE_OTHER) or (surface = RUNESCAPE_SURFACE) then
if (length(areas) = 1) then
tmp := SPS_GetArea(areas[0], surface)
else begin
writeln('SPS_SwitchMap(): Invalid custom map. You can only select one!');
exit;
end;
result := true;
{$IFDEF SIMBAMAJOR990}
SPS_BitmapToMap(tmp, SPS_Accuracy, SPS_AreaMaps);
{$ELSE}
SPS_AreaMaps := SPS_BitmapToMap(tmp, SPS_Accuracy);
{$ENDIF}
if (surface = RUNESCAPE_OTHER) then
SPS_Areas := areas;
tmp.free();
end else
writeln('SPS_SwitchMap(): ERROR: SPS areas are not set!');
t := (getSystemTime - t);
if (SPS_Debug) and (result) then
writeln('[SPS] SPS_SwitchMap() took '+toStr(t)+' ms. Areas: '+toStr(SPS_Areas));
end;
How to use:
Simba Code:
//***WALKING ROUTINE***
// 2 map sps setup
procedure InitMap;
begin
if mode then
begin
ClickNorth(SRL_ANGLE_HIGH);
SPS_SwitchMap(RUNESCAPE_OTHER,['mg_highlevel']);
end
else
begin
ClickNorth(SRL_ANGLE_HIGH);
SPS_SwitchMap(RUNESCAPE_OTHER,['mg_lowlevel']);
end;
end;
procedure ToMine;
var
ToMinePath: TPointArray;
begin
ToMinePath:=[Point(139,276),Point(159,279),Point(180,282),Point(208,283)];
if SPS_WalkPath(ToMinePath) then
Status := 'ToMine'
else begin
Status :='Failed ToMine';
WriteLn(status + '#Time Running:' +TimeRunning);
Logout;
TerminateScript;
end;
WriteLn(status + '#Time Running:' +TimeRunning);
WriteLn(toStr(SPS_GetMyPos));
end;
procedure ToGuild;
var
ToGuildPath: TPointArray;
begin
ToGuildPath:=[Point(242,205),Point(247,187),Point(262,186),Point(283,189),Point(293,202),Point(292,223),Point(312,238),Point(317,256),Point(319,280),Point(313,294),Point(274,280)];
if SPS_WalkPath(ToGuildPath) then
Status := 'ToGuild'
else begin
Status :='Failed ToGuild';
WriteLn(status + '#Time Running:' +TimeRunning);
Logout;
TerminateScript;
end;
WriteLn(status + '#Time Running:' +TimeRunning);
WriteLn('Im in point: '+toStr(SPS_GetMyPos));
mode:= false;
wait(5000);
//here insert your ladder down routine.
InitMap;
wait(1000);
ToMine;
end;
Test output:
Simba Code:
ToGuild#Time Running:36 Seconds
Im in point: (275, 287)
ToMine#Time Running:52 Seconds
(155, 275)
Successfully executed.
Simba Code:
procedure InitMap;
begin
if mode then
begin
ClickNorth(SRL_ANGLE_HIGH);
SPS_SwitchMap(RUNESCAPE_OTHER,['mg_highlevel']);
WriteLn(toStr(SPS_Areas));
end
else
begin
ClickNorth(SRL_ANGLE_HIGH);
SPS_SwitchMap(RUNESCAPE_OTHER,['mg_lowlevel']);
WriteLn(toStr(SPS_Areas));
end;
end;
//*******TEST OUTPUT
['mg_highlevel']
ToGuild#Time Running:22 Seconds
Im in point: (279, 287)
['mg_lowlevel']
ToMine#Time Running:40 Seconds
(143, 311)
Successfully executed.
Maps for testing in attachment:
Thanks for you advance, Cynic.