Results 1 to 4 of 4

Thread: beginner scripter: need examples of code

  1. #1
    Join Date
    Oct 2007
    Posts
    100
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default beginner scripter: need examples of code

    i'm a pretty good programmer in general, but i am new to scripting in scar. i have looked around the manual many times, and now i think its time for me to start making my own scripts from scratch

    what i'm asking of someone is if they could let me see one of their scripts, that are easy to read/understand and have quite a few program comments. i'm looking for a script that has some sort of walking involved (i.e. banking ores). i have taken a look at most of the 5 star junior member scripts, and a lot of them do not have too many program comments with the exception of the player setup.

    any help is greatly appreciated

  2. #2
    Join Date
    Mar 2007
    Location
    Netherlands->Amersfoort.
    Posts
    1,615
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    {=========================================================================]
    [                      Rikjess Swamp Miner V0.7 (Only coal atm)           ]
    [                                                                         ]
    [           Name          : Swamp Miner V0.7                              ]
    [           WRITER        : Rikjess                                       ]
    [           CATEGORY      : Miner                                         ]
    [           USAGE         : Mines coal in Lumby swamp. and bank in Draynor]
    [           AUTOCOLOR     : Yes.                                          ]
    [           NOTES         : Beta.                                         ]
    [           Needs         : Scar DIVI 3.11. Srl 4+                        ]
    [                                                                         ]
    [=========================================================================]
    [   This Script Mines Coal in the lumby Swamp west mines.                 ]
    [   When full he will bank in Draynor bank.                               ]
    [   Gas detection and pick repear funtion.                                ]
    [   It will mine like 100 ores a hour.                                    ]
    [                                                                         ]
    [=========================================================================]
    [                           Instructions.                                 ]
    [=========================================================================]
    [                                                                         ]
    [                                                                         ]
    [ 1. USE Runescape with Low Detail, Very Bright, AND SCSS!.               ]
    [ 2. Set your Screen to 32 bit TRUE color.                                ]
    [ 3. Set Playernames and Passwords in DeclarePlayers!                     ]
    [ 5. Put your SRL Stats ID and Pass on line:  65 & 66  Please (A)         ]
    [ 6. Set NumberOfPlayers!!!                                               ]
    [ 7. Position your chars at Draynor Bank                                  ]
    [ 8. Watch it the first time to see if the OreTol is oke.                 ]
    [ 9. Post your proggy and the bugs you found!                             ]
    [=========================================================================]
    [                           Special Thanks:                               ]
    [                                                                         ]
    [ ILoveIt8, Pentti: Allways helping me with qeustions.                    ]
    [ Nielsie95       : A lot of great tut. Learned a lot from those! thx.    ]
    [ Yohojo          : your tut made me understand DDTM. ty.                 ]
    [ Srl-forum       : For having fun. And for making srl. Thx to every one! ]
    [=========================================================================}



    program SwampMiner;
    {.include srl/srl.scar}
    {.include srl/srl/skill/Mining.scar}
    {.include srl/srl/skill/Fighting.scar}
    {.include SRL/SRL/Misc/Trade.scar}

    var
      LoadsDone, MineRock, I, NormalOre, MithrilOre, AdamantiteOre, CoalOre, Banked, GemMask, x, y, TempColor, R: integer;
      PickAxeDTM, TotalOres, CoalOres, MithrilOres, AdamantiteOres, TheRoadColor, AtMines, WaitMS, Xy, Xx, Ax, Ay : integer;
      Active : string;
      OreColors: array[1..3] of Integer;
      ToWaitMS: array[1..3] of Integer;

    const
    //------------------//
      LoadsToDo=3;     //How many loads each player before switching.  1 = like 15mins.
      OreToll=5;      //The ore Toll  4-6 (try with one for you work. watch it the first time to see if its oke.)
      CoalTime=8000; //Millisecons it will mine on a coal rock before next click.
    //--------------//

    procedure DeclarePlayers;

    Begin
      NumberOfPlayers(9);
      CurrentPlayer := 6;
      SRLID          := '';
      SRLPassword    := '';

      Players[0].Name    :='';
      Players[0].Pass    :='';
      Players[0].Nick    :='';
      Players[0].Active  :=True;
      Players[0].Loc     := 'Bank';
      Players[0].strings[1]:='1';  //NO need to this...(no commant on this string lol)

      Players[1].Name    :='';
      Players[1].Pass    :='';
      Players[1].Nick    :='';
      Players[1].Active  :=True;
      Players[1].Loc     := 'Bank';
      Players[1].strings[1]:='1';

      Players[2].Name    :='';
      Players[2].Pass    :='';
      Players[2].Nick    :='';
      Players[2].Active  :=True;
      Players[2].Loc := 'Bank';
      Players[2].strings[1]:='1';

      Players[3].Name    :='';
      Players[3].Pass    :='';
      Players[3].Nick    :='';
      Players[3].Active  :=True;
      Players[3].Loc     := 'Bank';
      Players[3].strings[1]:='1';

      Players[4].Name    :='';
      Players[4].Pass    :='';
      Players[4].Nick    :='';
      Players[4].Active  :=True;
      Players[4].Loc     := 'Bank';
      Players[4].strings[1]:='1';

      Players[5].Name    :='';
      Players[5].Pass    :='';
      Players[5].Nick    :='';
      Players[5].Active  :=True;
      Players[5].Loc     := 'Bank';
      Players[5].strings[1]:='1';

      Players[6].Name    :='';
      Players[6].Pass    :='';
      Players[6].Nick    :='';
      Players[6].Active  :=True;
      Players[6].Loc     := 'Bank';
      Players[6].strings[1]:='1';

      Players[7].Name    :='';
      Players[7].Pass    :='';
      Players[7].Nick    :='';
      Players[7].Active  :=True;
      Players[7].Loc     := 'Bank';
      Players[7].strings[1]:='1';

      Players[8].Name    :='';
      Players[8].Pass    :='';
      Players[8].Nick    :='';
      Players[8].Active  :=True;
      Players[8].Loc     := 'Bank';
      Players[8].strings[1]:='1';

      NickNameBMP := CreateBitmapMaskFromText(Players[CurrentPlayer].Nick, UpChars);
    end;

    function FindFastRandoms: Boolean; //By WT-Fakawi.
    var
      i : Integer;
    begin

      for i := 1 to 9 do
      begin
        case I of
          1: if FindDead then
              Result := True;
          2: if FindMod then
              Result := True;
          3: if FindMime then
              Result := True;
          4: if FindMaze then
              Result := True;
          5: if FindQuiz then
              Result := True;
          6: if FindDemon then
              Result := True;
          7: begin
              if NoGameTab then
              begin
                //Result := True;
                Players[CurrentPlayer].loc := 'No GameTab';
                //Logout;
                WriteLN('Not found game tabs...' );
                Exit;
              end;
            end;
          7: begin
              if InBlack then
              begin
                Result := True;
                Players[CurrentPlayer].loc := 'InBlack';
                Logout;
                Exit;
              end;
            end;
          8: RC;
         
          9: begin;
               if (not(InFight)) then Exit;
               if(GetHp<GetSkillLevel('hitpoints'))then
               begin;
                 Setrun(true);
                 MakeCompass('N');
                 RunAwayDirection('N');
                 Wait(2000);
                 RunBack;
                 if(FindSymbol(x, y,'mining site'))then
                 Mouse(x,y,2,2,true);
               end;
             end;
          end;
        wait(1);
      end;
    end;

    function LookForGas:boolean; forward;
    procedure Tobank; forward;
    Procedure DoMine; Forward;
    procedure StartPlayer; forward;


    { a verry custom welcom procedure :p }
    procedure Welcome;
    begin
      WriteLn('  ||   ||    []                                                                     ');
      WriteLn('  ||   ||                                                                           ');
      WriteLn('  ||---||    ||       Enjoy it!                                                     ');
      WriteLn('  ||---||    ||             Script Name: Lumby Swamp miner!                         ');
      WriteLn('  ||   ||    || //             Made By: Rikjess                                     ');
    end;


    { ...i know. its not prober scripting }
    procedure FindRandoms;
    begin
      if (not(loggedIn)) then Exit;
      FindNormalRandoms;
      FindFastRandoms;
    end;

    { Gives a sexy proggy :p. no rly! }
    procedure Proggy;
    begin
      Writeln('[]-------------------------------------------[]');
      WriteLn('[]======Rikjes, Lumby Swamp Miner V0.7=======[]');
      Writeln('Worked For : ' + TimeRunning);
      WriteLn('Total Banks done:  ' +IntToStr(Banked));
      Writeln('Total ores minned: ' +IntToStr(TotalOres));
      WriteLn('Total Coal Minned: ' +IntToStr(CoalOres));
      WriteLn('Total Mith Minned: ' +IntToStr(MithrilOres));
      WriteLn('Total Addy Minned: ' +IntToStr(AdamantiteOres));
      WriteLn('Please post the proggy and the bugs you found ^^');
      Writeln('[]--------------------------------------------[]');
      WriteLn('[]============================================[]');
      begin
        for I := 0 To HowManyPlayers - 1 do
        begin
          if Players[i].Active = True then
            Active := 'True'
          else
          Active := 'False';
          WriteLn((IntToStr(I)) + ' : ' + Players[I].Name + ' = ' +
          Active +' | Worked: ' + IntToStr(Players[I].Worked) + ' Minutes |Loc: ' + Players[I].Loc + ' |');
        end;
      end;
      WriteLn('[]--------------------------------------------[]');
      WriteLn('[]============================================[]');
      SRLRandomsReport;
    end;

    { Loadds the needed BitMaps and DTMs }
    procedure LoadOreStrings;
    begin

      NormalOre := BitmapFromString(11, 11, 'z78DA73730301033070436' +
                   '2238B60024C35B84CC0A5923C13F0BB937813F0EB22DE04CC5022' +
                   'CF04CADD404CC890EA0BFCE2F85D4E4C6A212FF470998FCC0600F' +
                   'B599CC1');
                   
      MithrilOre := BitmapFromString2(False, 'aC5D5B78DA6D8F5192C' +
           '3200C43AFE45896219F40C3FD8F548CDB4D66B67CBCD1085B0211' +
           '39D4659D2B6808B25F8BCEBA755C3AC69FCF2B7CA3DE7E8D2DAD1' +
           '69ADB99E1788C088F57E8792E961E33BE13CAA9B7AF7B0BF3F63B' +
           '171110E98DDD1AE06A1325354F2BD80572405452AEDF5089828A4' +
           'A4BE73F73FE494E1BA093BAF6B6CE961FF9450B1A3A5EFCF2D1F5' +
           'CCB48A0BB46E8A962FF74147FFFC62B7FCC81F3AECC864131397E' +
           '4EA6CF49CF9249F26DFFC37F80');

      AdamantiteOre := BitmapFromString(6, 6, 'z78DA558E410E00210803BFA' + //Not Working i Think...
        '4D2E27A54A3FF7FD212F0A024E53243434A36B94CA9968166110A' +
        '04A002C9696C29B22CE13845E5877A9B7626A24F4FE344C7E0C23' +
        '88ED3A76769C68A1D0E12B62568343865D1CA729CFB07EFC75630' +
        '93DAC91F0EBE2D59');
       
      CoalOre := BitmapFromString2(False, 'a64B7178DA8D8D510A0421' +
           '0C43AF5493D6EAA7237AFF236DEBECC7C0C0B2080F79265144647' +
           '9404609708C602D089AAEE46A41B53495334DAB4134CDBB1DB3D3' +
           'D48C883A836E3B8DE7A6E36498C6FBD9B92C17CE2FB29B5D3A982' +
           'D9142811C1DF732E31013B3AC2F3B7AE9CFA46D9DB4DF5D8280DC' +
           '7C2E54E8A6BFBB11643CBEBA741AECF6D50C6C7F754FEBC90FFC2' +
           '');
       
      PickAxeDTM := DTMFromString('78DA8DCA3B0A80301444D197EC49108C85602' +
           '9EAF243F02F6EC015784BB17032C59DE6B8D69B2DF6997B95EF30' +
           '7386D984A93193300113852931B73015E612A6C19CC21498244C8' +
           'F59851931BB3003E6F8370F71800DED');
           
      GemMask := BitmapFromString2(False, 'aC5B4378DAED98C10EC320' +
           '0C437F299490F40A2DFCFF2735EE61B74D93A6551DF33B58915A6' +
           '28C90108888740F919A42725F42CB6AD001D57CD6DA434D2BEA1D' +
           'BAAC8ABA6C8F3F0D43451BBA592BA19E777C4D5073F4F79AA1A94' +
           '11D1D7C93410821B7444E7E659EEFF36CD4AC2BFF7A1DE6DB4BF4' +
           'A217BDE670642EE6FACF5CD7F832177723733117BD78B2CCF47AF' +
           '08DDBEE3DDF43E4630621845CCE011A9');
      begin;
        OreColors[1]:= 6717286; //Adamantite;
        OreColors[2]:= 5782331; //Mithril;
        OreColors[3]:= 2175024; //Coal;
        ToWaitMS[1]:=20000;
        ToWaitMS[2]:=CoalTime;
        ToWaitMs[3]:=CoalTime;
      end;
       
    end;

    { Change the currently playing music }
    procedure ChangeMusic;
    var
      Tx, Ty : integer;
    begin
      GameTab(13);
      if (FindColorSpiral(Tx, Ty, 65280, 555, 296, 711, 447)) then
        Mouse(Tx, Ty, 1, 1, True);
    end;

    { LogOut wait 5sec + random 3 and log back }
    procedure LogOutFake;
    begin
      if Random(3) = 1 then
      begin;
        WriteLn('A fake LogOut');
        Case Random(4) of
          0: TypeSend('Brb');
          1: TypeSend('arg');
          2: TypeSend('gtg');
          3: TypeSend('Bye');
        end;
        Wait(1000);
        LogOut;
        SleepAndMoveMouse(5000+Random(5000));
        LogInPlayer;
        Wait(1000);
        WriteLn('ContinueMining');
        SetRun(True);
      end;
    end;

    { Some simple anit-ban }
    procedure AntiBansz;
    begin
      case Random(13) of

        0: LogOutFake;

        1: begin
             if FindObjOre(x, y, 'Rock', 2834753, 5, 1) then;
             begin
               Mouse(x, y, 2, 2, False);
               ClickOption('rospect',1);
             end;
           end;
             
        2: RandomRClick;

        3: begin
             HoverSkill('magic', false);
             wait(1000+random(2000));
             GameTab(4);
           end;

        4: RandomRClick;

        5: GameTab(1+random(10));

        6: AlmostLogout;

        7: GameTab(1 + Random(10));

        8: begin
             HoverSkill('mining', false);
             wait(1000+random(500));
             GameTab(4);
           end;


        9: begin
              HoverSkill('smithing', False);
              wait(500+random(500));
              GameTab(4);
            end;


        10: HoverSkill('attack', False);

        11: RandomRClick;
       
        12: ChangeMusic;
       
      end;
      //
    end;

    {Make A random Talk }
    procedure RandomTalk;
    begin
      If (Random(50) = 1) then
      begin
        case Random(26) of
     
          0: TypeSend('Mining can be sooooo boring..');
          1: TypeSend('i like this mine, yeaj!');
          2: TypeSend('Mining rulezz');
          3: TypeSend('I need money,, mining is a good way isnt?');
          4: TypeSend('=p');
          5: TypeSend(':o');
          6: TypeSEnd('=]');
          7: TypeSend(':c');
          8: TypeSend('I like mining. and you?');
          9: TypeSend('yeaj, i got a ore');
          10:TypeSend('Metal rulezz :p');
          11:TypeSend('Disturbed is a good band, what kind of music you guys like?');
          12:TypeSend('Tralalla');
          13:TypeSend('I have a Dream! =p');
          14:TypeSend('yesterday my pickaxe broke :(');
          15:TypeSend('At the drawven mines you can buy pick hé?');
          16:TypeSend('Avatar the last airbender rulezz!');
          17:TypeSEnd('hi');
          18:TypeSend('yo');
          19:TypeSend('bots ar killing this game. =['); // says the bot :p
          20:TypeSend('school is boring');
          21:TypeSend('Get up, come on get down with the sickness');
          22:TypeSend('Jump! =p');
          23:TypeSend('w00tage! i have ores ^^');
          24:TypeSend('*cough* Mining is so boring *cough*');
          25:TypeSend('i like those uncuts =]');
        end;
      end;
    end;

    { atm a small auto respowner }
    procedure TalkBack;
    begin
      if IsChatBlackTextAnyLine(+Players[currentplayer].Nick) then
        Exit;

      if FindChatText('ing lvl') or FindChatText('g lvl') then
      begin
        case Random(3) of
          0: TypeSend(IntToStr(Players[CurrentPlayer].level[15]));
          1: TypeSend('Mining'+IntToStr(Players[CurrentPlayer].level[15])+' here ')
          2: TypeSend(IntToStr(Players[CurrentPlayer].level[15])+'here');
        end;
      end;
     
      if FindChatText('hello') then
      begin
        case Random(3) of
          0: TypeSend('eey');
          1: TypeSend('hello');
          2: TypeSend('hi');
        end;
      end;
     
      if FindChatText('you just advanced') then
      begin
        case Random(3) of
          0: TypeSend('Yea new lvl!');
          1: TypeSend('w00t lvl up ');
          2: TypeSend('lvl up! =]');
        end;
      end;
      RandomTalk;
    end;

    { Looks if there is a pick axe.. }
    function AxeWithMe(InInvent : string):Boolean;
    Var
      Bx, By : integer;
    begin
      FindRandoms;
      if Players[currentplayer].Loc = 'No GameTab' then
        exit;
      case InInvent of
        '1': GameTab(4);
        '2': GameTAb(5);
      end;
      FindPick;
      if FindDTM(PickAxeDTM, Bx, By, MIX1, MIY1, MIX2, MIY2) then
        Result := True;
    end;

    { Looks witch ore your char can mine }
    procedure WhatOreCanIMine;
    begin
      if (not(loggedin)) then
        Exit;
      if (Players[CurrentPlayer].level[15]) > 54 then
        Players[currentplayer].Booleans[2] := True;
      if (Players[CurrentPlayer].level[15]) > 69 then
          Players[Currentplayer].Booleans[1]:= True;
       Players[currentplayer].Booleans[3]:= True;
    end;

    { Repear the pickaxe when broke loop }
    procedure RepearPick;
    begin
      if FindFastRandoms then Exit;
      if FindNormalRandoms then Exit;
      if (AxeWithMe(Players[CurrentPlayer].strings[1])) then
        Exit;
      FindPick;
      if (not(FindPick)) then ToBank;
    end;

    { Clicks on a rock }
    function AtackOre:boolean;
    begin
      if (not(loggedin)) then
        Exit;
      if InvFull then
      begin
        Result:= True;
        Exit;
      end;
      for R := 1 to 3 do
      begin
        if Players[CurrentPlayer].Booleans[R] then
        begin
          FindRandoms;
          if FindObjCustom(Xx, Xy, ['ine Rock', 'ine'], [OreColors[R]], OreToll) then
          begin
            WaitMs:= ToWaitMS[R]
            TempColor:= GetColor(Xx, Xy);
            LookforGas;
            If Random(10)=1 then
            begin
              Mouse(Xx, Xy, 2, 2, False);
              ClickOption('ine',1);
            end else
            Mouse(Xx, Xy, 3, 3, True);
            Result:=True;
            Exit;
          end;
        end;
      end;
    end;

    { Looks if you mined the ore by using the black message in the chat box }
    function Oremined: boolean;
    begin
      if InvFull then
        Result:= True;
      if FindBlackChatMessage('anage') or FindBlackChatMessage('vailable') then
        result:= True;
      if not TempColor = GetColor(Xx, Xy) then
        Result:= True;
    end;

    { A Rotate Compass procedure }
    procedure ChangeCompass;
    begin
      if (not(loggedin)) then
        Exit;
      FindRandoms;
      case Random(4) of

        0: MakeCompass('N');
        1: MakeCompass('E');
        2: MakeCompass('W');
        3: MakeCompass('S');
      end;
    end;

    { Gas detection (i hope..) }
    function LookforGas:Boolean;
    var
      Agas: integer;
    begin
      if (not(loggedin)) then
        Exit;
      if FindGas(Xx, Xy) then
      begin
        MarkTime(Agas);
        Result:=True;
        //MouseSpeed:= 1;
        MouseFindNoFlag(MMCX, MMCY + 5, 2, 2);
        repeat
          FindFastRandoms;
          FindNormalRandoms;
          SleepAndMoveMouse(3000);
        until(timefrommark(Agas)>20000)
        //MouseSpeed:= 12;
      end;
    end;

    {procedure FollowRock;
    var
      S :  Integer;
    begin
      repeat;
        If FindcolorspiralTolerance(Xx, Xy, OreColors[R], MSX1, MSY1, MSX2, MSY2, OreToll) then
          TempColor:= GetColor(Xx, Xy);
      until(not Flagpresent);
      //FollowRock2;
      MMouse(Xx, Xy, 0,0);
    end;}


    { ---------------------------------------------------------------------------- ]
    [  >>  Function UpdateCoords(Var ax, ay: Integer; TheColor: Integer): Boolean; ]
    [  >>  Updates Color Coords When you are Moving after a Click                  ]
    [  >>  Huge Thanks to Sumillion and Lorax for the Function - modified by Star  ]
    [ ---------------------------------------------------------------------------- }


    Function UpdateCoords(Var cx, cy: Integer; ax, ay, TheColor, Tol: Integer): Boolean;
    var
      //ax, ay,
      Counter: Integer;
    Begin
      //GetMousePos(ax, ay);
      If (ax < 20) then ax := 20; If (ay < 20) then ay := 20;
      While (FlagPresent) and (FindColorSpiralTolerance(cx, cy, TheColor, ax-20, ay-20, ax+20, ay+20, Tol)) do
      begin
        ax := cx; ay := cy;
        Wait(10);
      end;
      If (ax < 10) then ax := 10; If (ay < 10) then ay := 10;
      While (FindColorSpiralTolerance(cx, cy, TheColor, ax-10, ay-10, ax+10, ay+10, Tol)) and (Counter < 100) do
      begin
        ax := cx; ay := cy;
        Counter := Counter + 1;
        Wait(10);
      end;
      Result := FindColorSpiralTolerance(cx, cy, TheColor, ax-10, ay-10, ax+10, ay+10, Tol);
    end;


    { The Mine Procedure }
    procedure DoMine;
    var
      NotFoundRock : integer;
    begin
      if InvFull then //somethimes the others mess up the script. will mine 2 ore when invent is full...
      begin
        Players[CurrentPlayer].Loc := 'To Bank';
        FindRandoms;
        Exit;
      end;
      //GameTab(4);
      if (not(loggedIn)) then Exit;
      FindRandoms;
      if Random(5) = 1 then ChangeCompass;
      if (not(AtackOre)) then
      begin
        if InvFull then
        begin;
          Players[CurrentPlayer].Loc := 'To Bank';
          FindRandoms;
          Exit; Exit;
        end;
        ChangeCompass;
        NotFoundRock:= NotFoundRock + 1;
        if (NotFoundRock = 15) then
        begin
          WriteLn('Not found the rocks anymore..');
          LogOut;
          if (not(loggedin)) then Exit;
        end;
        Exit;
      end;
      Wait(500);
      if FlagPresent then
      begin
        Wait(2000+Random(500));
        DoMine;
      end;
      //UpdateCoords(Xx, Xy, Xx, Xy, OreColors[R], OreToll);
      //MMouse(Xx, Xy, 0, 0);
      LookforGas;
      Flag;
      MarkTime(MineRock);
      TalkBack;
      //RandomTalk;
      FindRandoms;
      NotFoundRock := 0;

      repeat
        if InvFull then
        begin;
          Players[CurrentPlayer].Loc := 'To Bank';
          FindRandoms;
          Break;
        end;
        FindRandoms;
        if (not(FindPick)) then RepearPick;
        if LookforGas then Exit;
        if Random(30)=1 then AntiBansz;
        if Oremined then Exit;
        if(timefrommark(MineRock)>WaitMS+Random(1000))then Exit;
        SleepAndMoveMouse(1000);
        if (not(loggedin)) then Exit;
      until(InvFull);
    end;

    { The Mine Loop }
    procedure MineLoop;
    begin
      WhatOreCanIMine;
      repeat;
        DoMine;
        If (not(loggedIn)) then Exit;
      Until(InvFull)
      Players[CurrentPlayer].Loc := 'To Bank';
    end;

    { Find Road color, there some problems with the FindRoadColor;, with some java's.
    it was finding the wrong color. so i needed to make my owne.

                 By nieslies aca.}

    function FindMyRoadColor : Integer;
    var
      X, Y, Z: Extended;
      Points: TPointArray;
      Colors, UniqueColors: TIntegerArray;
      i, a: Integer;
      NewColor: Boolean;
    begin
      if not LoggedIn then Exit;
      ColorToleranceSpeed(0);
      FindColorsSpiralTolerance(MMCX, MMCY, Points, 6710894, MMX1, MMY1, MMX2, MMY2, 20);
      if Length(Points) < 1 then
      begin
        ColorToleranceSpeed(1)
        Exit;
      end;
      Colors := GetColors(Points);

      for i := 0 to Length(Colors) -1 do
      begin
        NewColor := True;
        for a := 0 to GetArrayLength(UniqueColors) - 1 do
        begin
          if(UniqueColors[a] = Colors[i])then
          begin
            NewColor := False;
            Break;
          end;
        end;
        if(NewColor)then
        begin
          SetArrayLength(UniqueColors, GetArrayLength(UniqueColors) + 1);
          UniqueColors[GetArrayLength(UniqueColors) - 1] := Colors[i];
        end;
      end;
      for i := 0 to Length(UniqueColors) -1 do
      if UniqueColors[i] <> 0 then
      begin
        ColorToXYZ(UniqueColors[i], X, Y, Z);
        if (X < 20) and (X > 8) then
          if (Y < 21) and (Y > 9) then
            if (Z < 20) and (Z > 8) then
              if CountColor(UniqueColors[i], MMX1, MMY1, MMX2, MMY2) > 50 then
              begin
                WriteLn('My RoadColor: '+IntTostr(UniqueColors[i]))
                Result := UniqueColors[i];
                Break;
              end;
      end;

      ColorToleranceSpeed(1);
    end;




    { Sets the vars Ax and Xy for the walk to the mines }
    procedure SetSearchTo;
    begin
      if (I = 1) then
      begin
        Ax:=686;
        Ay:=68;
        exit;
      end;
      if (I = 2) or (I = 3) then
      begin
        Ax:=715;
        Ay:=80;
        Exit;
      end;
        Ax:=682;
        Ay:=155;
    end;

    { Walks To lumby swamp west mines. }
    procedure WalkToSW;
    var
      TheWater : integer;
    begin
      if (not(loggedin)) then Exit;
      Players[CurrentPlayer].Loc := 'To Mines.';
      MakeCompass('N');
      I:= 0;
      TheRoadColor:= 0;
      TheRoadColor:= FindMyRoadColor;
      if TheRoadColor = 0 then LogOut;
      Wait(500);
      RadialRoadWalk(TheRoadColor, 132, 90, 64, 0, 0);
      Wait(3000);
      if FlagPresent then
        Flag;
      RadialRoadWalk(TheRoadColor, 175, 143, 60, 0, 0);
      RadialRoadWalk(TheRoadColor, 180, 120, 48, 0, 0);
      FindRandoms;
      RadialRoadWalk(TheRoadColor, 170, 120, 50, 0, 0);
      begin
        TheWater:= 0;
        TheWater:= FindWaterColor;
        if TheWater = 0 then
          LogOut;
        repeat
          I:= I+ 1;
          SetSearchTo;
          X:= Ax;
          Y:= Ay;
          if(FindColorSpiral(x, y, TheWater, MMX1, MMY1, MMX2, MMY2))then
          begin
            Mouse(x+(6), y-(5), 3, 3, true);
            FindRandoms;
            FFlag(10);
          end;
          If (I = 30) then
            LogOut;
        Until(FindSymbol(x,y,'mining site')) or (I > 30);
      end;
      if(not(FindSymbol(x,y,'mining site')))then
      begin
        Players[CurrentPlayer].Loc := 'No Mines';
        WriteLn('Not found mines');
        LogOut;
        Exit;
      end;
      Mouse(x,y,2,2,true);
      FFlag(1);
      Players[CurrentPlayer].Loc := 'Mines';
      WriteLn('Found the Mine');
    end;

    { Looks for the bank by using a DDtm }
    { @jagex: it was pritty hard to make him. but thx for that girl on a chair. she gave me the helping hand ^^ }
    function FindBankDDtm:Boolean;
    var
      DraynorBank,D,DTMTol,DTMArea, RoadColorDtm:Integer;
      DraynorBankMP: TDTMPointDef;
      DraynorBankSP: array[0..3] of TDTMPointDef;
      DraynorBankDTMSkel: TDTM;
    begin
      MMouse(470, 74, 4, 4);
      RoadColorDtm:= FindRoadColor;
      DTMArea:=0;
      DTMTol:=0;
      Begin
        DraynorBankMP.x:=593;
        DraynorBankMP.y:=63;
        DraynorBankMP.areasize:=1;
        DraynorBankMP.areashape:=0;
        DraynorBankMP.color:=0;
        DraynorBankMP.tolerance:=255;

        DraynorBankSP[0].x:=643;
        DraynorBankSP[0].y:=42;
        DraynorBankSP[0].areasize:=DTMArea;
        DraynorBankSP[0].areashape:=0;
        DraynorBankSP[0].color:=RoadColorDTm;
        DraynorBankSP[0].tolerance:=DTMTol;

        DraynorBankSP[1].x:=609;
        DraynorBankSP[1].y:=40;
        DraynorBankSP[1].areasize:=DTMArea;
        DraynorBankSP[1].areashape:=0;
        DraynorBankSP[1].color:=RoadColorDtm;
        DraynorBankSP[1].tolerance:=DTMTol;

        DraynorBankSP[2].x:=648;
        DraynorBankSP[2].y:=69;
        DraynorBankSP[2].areasize:=DTMArea;
        DraynorBankSP[2].areashape:=0;
        DraynorBankSP[2].color:=RoadColorDtm;
        DraynorBankSP[2].tolerance:=DTMTol;

        DraynorBankSP[3].x:=603;
        DraynorBankSP[3].y:=26;
        DraynorBankSP[3].areasize:=7+DTMArea;
        DraynorBankSP[3].areashape:=0;
        DraynorBankSP[3].color:=195836;
        DraynorBankSP[3].tolerance:=5+DTMTol;

        DraynorBankDTMSkel.MainPoint:=DraynorBankMP;
        DraynorBankDTMSkel.SubPoints:=DraynorBankSP;
        DraynorBank:=AddDTM(DraynorBankDTMSkel);
      End;
     
      begin
        for D:=1 To 5 Do
        begin
          DTMTol:=DTMTol+5;
          DTMArea:=DTMArea+1
          if (FindDTM(DraynorBank,x, y,MMX1,MMY1,MMX2,MMY2)) Then
          begin
            Mouse(x,y,1,1,True);
            Result:=True;
            WriteLn('Found Bank by using DDTM');
            FreeDTM(DraynorBank);
            Exit;
          end;
        end;
      end;
      FreeDTM(DraynorBank);
      PerfectNorth;
    end;

    { Walks to the bank }
    procedure ToBank;
    var
      TheWater, D : integer;
    begin
      if (not(loggedin)) then
        Exit;
      Makecompass('N');
      WriteLn('Walk To Bank');
      Setrun(False);
      FindRandoms;
      D:= 0;
      begin
        TheWater:= FindWaterColor;
        if TheWater = 0 then
          LogOut;
        repeat
          if (not(loggedin)) then Exit;
          D:= D+ 1;
          X:= 649;
          Y:= 11;
          if(FindColorSpiral( x, y, TheWater, MMX1, MMY1, MMX2, MMY2))then
          begin
            Mouse(x+(4), y, 3, 3, true);
            Wait(500);
            FFlag(10);
          end else
          begin
            TheWater:= FindWaterColor;
          end;

        If (D > 4) then
          TheRoadColor:=  FindRoadColor;
        FindRandoms;
        If (D = 20) then
           LogOut;
        Until(D > 20) or (RadialWalk(TheRoadColor, 264, 315, 60, 0, 0));
        end;
        if (not(loggedIn)) then Exit;
        Flag;
        RadialRoadWalk(TheRoadColor, 70, 10, 60, 0, 0);
        Wait(20);
        SetRun(True);
        Wait(20);
        RadialRoadWalk(TheRoadColor, 359, 275, 50, 0, 0);
        RadialRoadWalk(TheRoadColor, 300, 354, 40, 0, 0);
        RadialRoadWalk(TheRoadColor, 359, 275, 47, 0, 0);
        //if (not (RadialRoadWalk(TheRoadColor, 280, 300, 54, 0, 0))) then
        TheRoadColor:= FindRoadColor;
        FindRandoms;
        repeat
          D:= D + 1;
          if FindBankDDtm then Exit;
          if (not(RadialRoadWalk(TheRoadColor, 359, 290, 50, 0, 0))) then
             RadialRoadWalk(TheRoadColor, 298, 334, 40, 0, 0);
          if (not(loggedin)) then Exit;
        until(Not(loggedIn)) or (D = 5);
      Flag;
    end;

    { A smiple bank procedure }
    procedure Bank;
    begin
      if (not(loggedIn)) then exit;
      Flag;
      FindRandoms;
      OpenBankQuiet('db');
      Wait(1000);
      if (not(Bankscreen)) then
      if (FindSymbol(x,y,'bank')) then
      begin
        Mouse(x, y, 1, 1, true);
        OpenBankQuiet('db');
        If (not(BAnkScreen)) then
          if FindBankDDtm then
            OpenBankFast('db');
      end;

      if (not(Bankscreen)) then
      begin
        Players[CurrentPlayer].Loc := 'No Bank';
        WriteLn('Could not found bank..');
        LogOut;
      end else
      begin
        Players[CurrentPlayer].Loc := 'Bank';
        WriteLn('Where at the bank');
      end;
     
        TotalOres        := TotalOres  + CountItemBmpMaskTol(NormalOre, 5, 15);
        CoalOres         := CoalOres    + CountItemBmpTol(CoalOre, 10);
        MithrilOres      := MithrilOres + CountItemBmpTol(MithrilOre, 10);
        AdamantiteOres   := AdamantiteOres   + CountItemBmpTol(AdamantiteOre, 10);
        Banked           := Banked + 1;

        ReportVars[0] := CountItemBmpTol(CoalOre, 10);
        ReportVars[1] := CountItemBmpTol(MithrilOre, 10);
        ReportVars[2] := CountItemBmpTol(AdamantiteOre, 10);
        ReportVars[3] := CountItemBmpMaskTol(NormalOre, 5, 15);
        ReportVars[4] := CountItemBmpMaskTol(GemMask, 5, 15);
        Banks := Banks + 1;

      case Players[currentplayer].strings[1] of
        '1': DePosit(2,28,2);
        '2': DePositAll;
      end;
      Wait(1000);
      CloseBank;
      CloseBank;
      Wait(2000);
      FindRandoms;
    end;

    { Looks if the pick is equiped of if he is weared }
    procedure WherePickAxe;
    begin
      GameTab(4);
      FindRandoms;
      if FindDTM(PickAxeDTM, x, y, MIX1, MIY1, MIX2, MIY2) then
      begin
        Players[CurrentPlayer].strings[1]:='1';
        EquipPick := False;
        FindPickHeadColor;
        Exit;
      end;
      Wait(1000);
      FindRandoms;
      GameTAb(5);
      if FindDTM(PickAxeDTM, x, y, MIX1, MIY1, MIX2, MIY2) then
        Players[CurrentPlayer].strings[1]:='2';
      EquipPick := True;
      FindPickHeadColor;
    end;

    { LogNext }
    procedure LogNext;
    begin
      SetChat('Off',1);
      repeat
        Wait(1000);
        FindRandoms;
      until(not(LoggedIn));
      LoadsDone:= 0;
      NextPlayer(true);
      Proggy;
    end;

    { Gets the player ready to mine }
    procedure StartPlayer;
    begin
      WherePickAxe;
      FindRandoms
      if (not(AxeWithMe(Players[CurrentPlayer].strings[1]))) then
      begin
        WriteLn('Not found axe... player turned to false.');
        Players[CurrentPlayer].Loc := 'No PickAxe Found.';
        Nextplayer(false);
        StartPlayer;
      end;
      GetAllLevels;
      if (Players[CurrentPlayer].level[15]) < 30 then
      begin
        WriteLn('Not high anouhg mining lvl to run this script...');
        Players[CurrentPlayer].Loc :='To Low Mining lvl';
        NextPlayer(false);
        StartPlayer;
      end;
      WriteLn('[------------------------------]');
      WriteLn(Players[CurrentPlayer].Name + ' mines:');
      WriteLn('Coal');
      if (Players[CurrentPlayer].level[15]) > 54 then
        WriteLn('   Mithril');
      if (Players[CurrentPlayer].level[15]) > 69 then
        WriteLn('      Adamantite');
      WriteLn('[------------------------------]');
      LoadsDone:= LoadsDone+1;
      MakeCompass('N');
      HighestAngle;
      FindRAndoms
      SetChat('On', 1);
      SetChat('Friends', 2);
      SetChat('Off', 3);
    end;

    procedure StartScript;
    begin
      ClearDeBug;
      SetupSRL;
      SetupMining;
      ScriptID:='246';
      Welcome;
      Wait(500);
      DeclarePlayers;
      Proggy;
      Wait(1000);
      LoadOreStrings;
      Activateclient;
      //MouseSpeed:= 12;
      LoginPlayer;
      FindRandoms
    end;

    { Main loop }
    begin
      StartScript;
      repeat
        StartPlayer;

        If Players[CurrentPlayer].Loc = 'Bank' then
        begin
          WalkToSW;
          SetRun(True);
          MarkTime(AtMines);
          MineLoop;
        end;
       
        if Players[CurrentPlayer].Loc = 'To Bank' then
        begin
          ToBank;
          Bank;
        end;

        FindRandoms
        Proggy;
        MakeCompass('E');
        PerfectNorth;
        if (not(loggedin)) then
        begin
          nextplayer(false);
          LoadsDone:=0;
        end;
        if LoadsDone = LoadsToDo then LogNext;
      Until(false);
    end.

    its not that great, but i hope it helps

  3. #3
    Join Date
    May 2006
    Location
    Helsinki, Finland (capital)
    Posts
    269
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    The whole srl libary is opensource as far as you credit the makers properly, there is alot of cool tricks and flawless procedures.

  4. #4
    Join Date
    Oct 2007
    Posts
    100
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    thanks jess, it looks good i'm loving the prog comments btw, very helpful

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Tutorial for the "Beginner Scripter". With video aid.
    By Wanted in forum Outdated Tutorials
    Replies: 63
    Last Post: 07-26-2010, 04:59 PM
  2. How to design Autocolor Functions (Along with examples and tools!)
    By Pure1993 in forum OSR Advanced Scripting Tutorials
    Replies: 63
    Last Post: 04-20-2009, 07:39 PM
  3. C++ Beginner Tut
    By Macrosoft in forum C/C++ Help and Tutorials
    Replies: 31
    Last Post: 10-28-2007, 11:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •