program CosmicCrafter;
{$DEFINE SMART}
{$I SRL-6/SRL.simba}
{$I SPS/lib/SPS-RS3.Simba}
var //Global Variables
bankTrips : Integer;
procedure declarePlayers();
begin
setLength(players, 1);
with players[0] do
begin
loginName := ''; //Spacing slightly changed
password := '';
isActive := true;
world := 2;
isMember := true;
end
currentPlayer := 0;
end;
{If you plan to release a script, documenting your method helps, but is not required}
procedure walkToBank();
var
bankPath : TPointArray;
begin
bankPath := [Point(150, 357), Point(150, 346), Point(200, 354), Point(226, 332), Point(230, 290), Point(226, 244), Point(190, 202), Point(138, 183), Point(112, 162), Point(104, 145), Point(84, 144)];
minimap.setAngle(MM_DIRECTION_NORTH);
mainScreen.setAngle(MS_ANGLE_HIGH);
if (SPS.walkPath(bankPath)) then
minimap.waitPlayerMoving()
end;
procedure walkToAgility();
var
agilityPath, p : TPointArray;
begin
agilityPath := [Point(89, 143), Point(109, 143), Point(133, 173), Point(163, 190), Point(191, 202), Point(223, 235), Point(230, 279), Point(231, 305), Point(225, 331), Point(203, 352), Point(181, 356), Point(157, 355), Point(151, 356)];
minimap.setAngle(MM_DIRECTION_NORTH);
mainScreen.setAngle(MS_ANGLE_HIGH);
if (SPS.walkPath(agilityPath)) then
minimap.waitPlayerMoving()
end;
procedure walkBackToAgility();
var
agilityPathBack : TPointArray;
begin
agilityPathBack := [Point(178, 464), Point(171, 444), Point(171, 431), Point(168, 417), Point(159, 411), Point(127, 403), Point(122, 398), Point(126, 390), Point(136, 383), Point(149, 375)];
minimap.setAngle(MM_DIRECTION_NORTH);
mainScreen.setAngle(MS_ANGLE_HIGH);
if (SPS.walkPath(agilityPathBack)) then
minimap.waitPlayerMoving()
end;
procedure findAgilityShortcut();
var
x, y : Integer;
z : boolean
begin
minimap.setAngle(MM_DIRECTION_SOUTH);
mainscreen.findObject(x, y, 7577777, 20, colorSetting(2, 0.04, 0.77), mainscreen.playerPoint, 30, 50, 50, ['utting', 'all'], MOUSE_LEFT);
wait(5000); //add randomRange instead
end;
procedure runToAltar();
var
altarPath : TPointArray;
begin
altarPath := [Point(149, 368), Point(148, 377), Point(139, 380), Point(127, 391), Point(123, 397), Point(137, 404), Point(152, 406), Point(166, 418), Point(174, 435), Point(180, 451), Point(183, 467)];
if(SPS.walkPath(altarPath)) then
minimap.waitPlayerMoving()
end;
procedure teleToCosmic();
begin
wait(randomRange(1000,2000));
mainscreen.findObject(x, y, 11561625, 9, colorSetting(2, 0.06, 0.98), mainScreen.playerPoint, 30, 50, 50, ['ysterious', 'uins'], MOUSE_LEFT);
end;
procedure craftRunes();
var
runePath, TPA : TPointArray;
q : TPoint;
returnDTM, i, ii, xx, yy : Integer;
ATPA : T2DPointArray;
begin
returnDTM := DTMFromString('mWAAAAHicY2FgYDjIy8BwCIj3QfFGJgaGlUC8DkoXduxh6I+VZ2iaeZphWpQagwhQDzJmRMMgAACyJgwB');
wait(randomRange(2000,4000));
minimap.tpaWalk(3947842, 2, Point(minimap.x2, minimap.y1), 10);
wait(randomRange(6000, 8000));
mainscreen.findObject(x, y, 6119255 ,10,colorSetting(2, 3.04, 0.09), mainScreen.playerPoint, 20, 50, 50, ['ltar'], MOUSE_LEFT);
wait(randomRange(3000, 5000));
minimap.findDTM(returnDTM, x, y);
mouse(Point(x, y), MOUSE_LEFT);
wait(randomRange(7000,9000));
repeat
begin
findColorsSpiralTolerance(xx, yy, TPA, 9542562, mainScreen.getBounds(), 13, colorSetting(2, 0.40, 0.41));
ATPA := TPA.toATPA(30, 30);
ATPA.sortFromMidPoint(mainscreen.playerPoint);
for ii := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[ii]), MOUSE_MOVE);
if isMouseOverText(['ortal'], 1000) then
begin
fastClick(MOUSE_LEFT);
exit;
end;
end;
inc(i);
end;
until(i > 10);
freeDTM(returnDTM); //Always free your DTMs
end;
var
bmp: integer; //Not sure why this is here
begin
clearDebug();
smartEnableDrawing := true;
smartPlugins := ['openGL32.dll', 'd3d9.dll'];
bmp := bitmapFromClient(0, 0, getClientBounds().x2 -1, getClientBounds().y2 -1); //Not sure what these two lines of code are for
freeBitmap(bmp);
setupSRL();
declarePlayers();
bankTrips := 0;
if not isLoggedIn() then
begin
players[currentPlayer].login();
exitSquealOfFortune();
minimap.setAngle(MM_DIRECTION_NORTH);
mainScreen.setAngle(MS_ANGLE_HIGH);
end;
SPS.setup('Zanaris', RUNESCAPE_OTHER, 4, 900, 0.40);
walkToAgility();
findAgilityShortcut();
runToAltar();
teleToCosmic();
craftRunes();
walkBackToAgility();
findAgilityShortcut();
walkToBank();
end.
I don't have time tonight to really look through the code or even test it, but I've fixed a lot of small coding conventions that we do here at SIMBA. I left a quick edit of your code above, and added a few comments on what I changed. I changed the spacing to my liking, but that's usually left up to you. Variable declarations however, should pretty much always be declared after procedure such as:
procedure MyProcedure();
var
x, y : integer;
begin
//code
end;
For runecrafting, I've always found it helpful to use waitForloading methods as defined here, but its ok if you don't want to implement them yet:
https://villavu.com/forum/showthread.php?t=111436You should also consider adding more failsafes, and making use of the return values of some of your functions. For example mainScreen.findObject returns a boolean on whether or not it was successful. I can explain more tomorrow maybe.