Results 1 to 18 of 18

Thread: FindCoins

  1. #1
    Join Date
    Sep 2006
    Posts
    5,219
    Mentioned
    4 Post(s)
    Quoted
    1 Post(s)

    Default FindCoins

    Here's a little preview of B4. Since coins use more than one picture, I had to write something special for it, so that a higherlevel function can decide whether to call this or do it the normal way with item profiles.

    You need SRL 3.81 so that the multiple text colors works, and you need to go to line 92 in amount.scar and change

    itemx + 1, itemy + 3
    to
    itemx , itemy + 4
    Finds coins in bank, inventory, left trade, or right trade.
    Just have coins in one or more of those places and run



    SCAR Code:
    program FindCoins;
    {.include srl/srl.scar}
    {.include srl/srl/misc/amount.scar}

    type

      BlackList = array of integer;

    type
      BlackListNet = array of Tpoint;

    var MyList:BlackListNet;





    function BankSlot(WhichSlot:integer):integer;
    begin
      result:=Whichslot;
    end;

    function InvSlot(WhichSlot:integer):integer;
    begin
      result:=Whichslot+48;
    end;

    function ShopSlot(WhichSlot:integer):integer;
    begin
      result:=Whichslot+48+28;
    end;

    function LeftTradeSlot(WhichSlot:integer):integer;
    begin
      result:=Whichslot+48+28+40;
    end;

    function RightTradeSlot(WhichSlot:integer):integer;
    begin
      result:=Whichslot+48+28+40+28;
    end;







    {*******************************************************************************
    function CreateCustomNet(Num:integer):TPointArray;
    By: Boreas
    Note: Purely an internal function, used in setup.
    Description: Returns a TPointArray containing the relative (to x1,y1 of a BSlot)
    for a custom amount of points. Only needs to be done once, to create
    the list of points to check for 65536. Only takes like 15ms, and I didn't
    feel like typing them all out.
    Num=1 will check every point
    Num=2 will make a net with 1x1 holes
    Num=4 will make a net with 3x3 holes
    *******************************************************************************}

    function CreateCustomNet(Num:integer):BlackListNet;
    var Counter,hx,hy,tAL:integer;
      var TPointsToCheck:array of TPoint;
    begin
      repeat
        hy:=15;
        hx:=hx+1;
        repeat
          hy:=hy+1;
          if (((hx mod Num)=0) or ((hy mod Num)=0)) then
          begin
            tAL:=tAL+1;
            setarraylength(TPointsToCheck,tAL);
            TPointsToCheck[Counter].x:=hx;
            TPointsToCheck[Counter].y:=hy;
            Counter:=Counter+1;
          end;
        until hy=31;
      until hx=31;
      result:=TPointsToCheck;
    end;

    {*******************************************************************************
    function CreateItemBlackList(WhichBankSlot:integer;WhichList:TPointArray):array of integer;
    By: Boreas
    Description: Looks at the points in the list for an item, and returns an array
    contatining the indexes of the points that are black.
    Usage: WhichBankSlot-just what it sounds like. WhichList-the TPointArray
    containing positions relative to the x1,y1 of a bankslot which you want to check
    *******************************************************************************}


    function CreateItemBlackList(WhichBankSlot:integer;WhichList:TPointArray):array of integer;
    var Counter,Counter2,Tmpx1,Tmpy1,ListLength:integer;
    var TmpArray:array of integer;
    begin
      Tmpx1:=79+((((WhichBankSlot+7)mod 8))*47);
      Tmpy1:=62+((((WhichBankSlot-1)/8))*38);
      if WhichBankSlot > 48 then   //inv
      begin
        Tmpx1:=569+(((((WhichBankSlot-48)+3)mod 4))*42);
        Tmpy1:=213+(((((WhichBankSlot-48)-1)/4))*36);
      end;
      if WhichBankSlot>(48+28) then //shop
      begin
        Tmpx1:=80+(((((WhichBankSlot-(48+28))+7)mod 8))*47);
        Tmpy1:=69+(((((WhichBankSlot-(48+28))-1)/8))*47);
      end;
      if WhichBankSlot>(48+28+40) then //left trade
      begin
        Tmpx1:=36+(((((WhichBankSlot-(48+28+40))+3)mod 4))*42);
        Tmpy1:=75+(((((WhichBankSlot-(48+28+40))-1)/4))*33);
      end;
      if WhichBankSlot>(48+28+40+28) then //right trade
      begin
        Tmpx1:=325+(((((WhichBankSlot-(48+28+40+28))+3)mod 4))*42);
        Tmpy1:=73+(((((WhichBankSlot-(48+28+40+28))-1)/4))*33);
      end;

      ListLength:=getarraylength(WhichList)-1;
      setarraylength(tmparray,1);
      for Counter:= 0 to ListLength do
      begin

        if GetColor(Tmpx1+WhichList[Counter].x,Tmpy1+WhichList[Counter].y)=65536 then
        begin
          TmpArray[Counter2]:=Counter;
          Counter2:=Counter2+1;
          setarraylength(TmpArray,Counter2+1);

        end;
      end;
      setarraylength(TmpArray,Counter2-1);
      result:=TmpArray;
    end;

    {*******************************************************************************
    function CheckItemBlackList(WhichBankSlot:integer;WhichBlackList:array of integer;WhichList:TPointArray):boolean;
    By: Boreas
    Description: Returns true if an items blacklist matches the one in the parameters
    *******************************************************************************}

    function CheckItemBlackList(WhichBankSlot:integer;WhichBlackList:array of integer;WhichList:TPointArray):boolean;
    var Counter,Tmpx1,Tmpy1,ListLength:integer;
    var TheBoolean:boolean;
    begin
      Tmpx1:=79+((((WhichBankSlot+7)mod 8))*47);
      Tmpy1:=62+((((WhichBankSlot-1)/8))*38);
      ListLength:=getarraylength(WhichBlackList)-1;
      TheBoolean:=true;
      repeat
        if not(getcolor(Tmpx1+Whichlist[WhichBlacklist[Counter]].x,
           Tmpy1+Whichlist[WhichBlacklist[Counter]].y)=65536) then
           TheBoolean:=false;
        Counter:=Counter+1;
      until ((not(TheBoolean)) or  (Counter=(ListLength+1)));
      result:=TheBoolean;
    end;

    {*******************************************************************************
    function CompareIntArrays(FirstIntArray,SecondIntArray:array of integer):boolean;
    By: Boreas
    Description: Returns true both arrays are the same
    ******************************************************************************}

    function CompareIntArrays(FirstIntArray,SecondIntArray:array of integer):boolean;
    var Counter:integer;
    begin
      if not(getarraylength(FirstIntArray)=getarraylength(SecondIntArray)) then
        result:=false;


      if (getarraylength(FirstIntArray)=getarraylength(SecondIntArray)) then
      begin
        result:=true;
        repeat
          if not(FirstIntArray[Counter]=SecondIntArray[Counter]) then
            result:=false;
          Counter:=Counter+1;
        until ((Counter=getarraylength(FirstIntArray)) or (result=false));
      end;
    end;

    {*******************************************************************************
    function LoadBlackListFromString(BlackListString: string): BlackList;
    By: Boreas/moparisthebest
    Description: Loads a BlackList from a string given by WriteBlackList. Basically
    string -> array or integer
    *******************************************************************************}

    function LoadBlackListFromString(BlackListString: string): BlackList;
    var
      i, spacePos: Integer;
    begin
      repeat
        SetArrayLength(Result, i + 1);
        spacePos := Pos(' ', BlackListString);
        if (not (spacePos = 0)) then
        begin
          Result[i] := StrToInt(Copy(BlackListString, 1, spacePos - 1));
        end
        else
        begin
          Result[i] := StrToInt(Copy(BlackListString, 1, Length(BlackListString)));
          break;
        end;
        Delete(BlackListString, 1, spacePos);
        i := i + 1;
      until (False)
    end;

    function FindCoins(Where:string):tpoint;
    var
    //BL_Coins1, BL_Coins2, BL_Coins3, BL_Coins4, BL_Coins5,
    //BL_Coins25, BL_Coins100, BL_Coins250, BL_Coins1000, BL_Coins10000,
    tmplist:Blacklist;
    CoinBLs:array of Blacklist;
    i,i2:integer;
    done:boolean;
    begin
      SetArrayLength(CoinBLs,10);
      CoinBLs[0] := LoadBlackListFromString('9 10 11 12 24 32 3' +
           '8 48 51 62 75 86 99 110 128 129 133 145');

      CoinBLs[1] := LoadBlackListFromString('9 10 11 12 24 32 3' +
           '8 48 51 62 75 86 99 110 128 129 133 134 135 145 148 1' +
           '54 160 169 172 177 184 193 196 202 208 217 226 231 242');

      CoinBLs[2] := LoadBlackListFromString('9 10 11 12 24 32 3' +
           '8 48 51 62 75 86 99 110 128 129 133 134 135 145 148 1' +
           '54 160 169 172 177 184 193 196 200 201 202 208 231 24' +
           '3 253 277 300 320 321');

      CoinBLs[3] := LoadBlackListFromString('9 10 11 12 24 32 3' +
           '8 48 51 62 75 86 99 110 133 134 135 145 148 154 160 1' +
           '69 172 184 193 196 201 202 208 231 243 253 277 300 320 321');

      CoinBLs[4] := LoadBlackListFromString('10 11 12 13 27 32 ' +
           '39 48 63 87 96 104 105 111 123 134 135 136 146 162 17' +
           '3 186 197 203 209 233 243 244 253 277 301 320 321 322 323');

      CoinBLs[5] := LoadBlackListFromString('11 12 13 14 25 33 ' +
           '40 52 56 64 72 76 80 88 100 104 105 112 135 136 146 1' +
           '62 173 186 197 203 210 233 243 244 254 267 278 291 29' +
           '6 302 312 321 322 323');

      CoinBLs[6] := LoadBlackListFromString('8 9 11 12 13 14 25' +
           ' 40 52 64 76 88 100 105 112 135 136 146 162 173 186 1' +
           '97 210 233 243 244 254 267 278 291 302 312 315 322 323 324');

      CoinBLs[7] := LoadBlackListFromString('1 2 17 29 42 53 66' +
           ' 77 90 101 110 111 112 113 114 115 123 126 140 165 18' +
           '9 213 221 222 232 257 281 305 315 316 320 325 336 345 346 347');

      CoinBLs[8] := LoadBlackListFromString('2 3 4 16 28 40 52 ' +
           '64 65 66 72 73 74 80 81 82 83 91 115 138 147 148 157 ' +
           '161 185 186 187 198 209 213 216 217 220 227 228 229 2' +
           '30 232 237 240 244 250 251 252 253 254 255 256 257 25' +
           '8 259 260 269 283 307 320 331 337 338 339 340');

      CoinBLs[9] := LoadBlackListFromString('1 5 11 12 13 14 18' +
           ' 29 42 53 65 66 67 72 78 80 81 82 92 102 116 126 139 ' +
           '147 148 149 158 162 173 174 186 187 189 197 199 210 2' +
           '14 220 221 223 224 225 231 234 238 241 242 243 245 24' +
           '8 249 250 251 252 253 254 255 256 257 258 259 260 270' +
           ' 285 309 333 336 337 338 339 340 341');
      MyList:=CreateCustomNet(2);
      if Where='bank' then
      begin
        for i:=1 to 48 do
        begin
          tmplist:=CreateItemBlackList(i,MyList);
          for i2:=0 to 9 do
          begin
            if CompareIntArrays(tmplist,CoinBLs[i2])then
            begin
              result.x:=i;
              done:=true;
              break;
            end;
          end;
          if done then break;
        end;
        result.y:=Amount(Where,result.x);
      end;

      if Where='inv' then
      begin
        for i:=1 to 28 do
        begin
          tmplist:=CreateItemBlackList(InvSlot(i),MyList);
          for i2:=0 to 9 do
          begin
            if CompareIntArrays(tmplist,CoinBLs[i2])then
            begin
              result.x:=i;
              done:=true;
              break;
            end;
          end;
          if done then break;
        end;
        result.y:=Amount(Where,result.x);
      end;
     
      if Where='lefttrade' then
      begin
        for i:=1 to 28 do
        begin
          tmplist:=CreateItemBlackList(LeftTradeSlot(i),MyList);
          for i2:=0 to 9 do
          begin
            if CompareIntArrays(tmplist,CoinBLs[i2])then
            begin
              result.x:=i;
              done:=true;
              break;
            end;
          end;
          if done then break;
        end;
        result.y:=Amount('your trade',result.x);
      end;
     
      if Where='righttrade' then
      begin
        for i:=1 to 28 do
        begin
          tmplist:=CreateItemBlackList(RightTradeSlot(i),MyList);
          for i2:=0 to 9 do
          begin
            if CompareIntArrays(tmplist,CoinBLs[i2])then
            begin
              result.x:=i;
              done:=true;
              break;
            end;
          end;
          if done then break;
        end;
        result.y:=Amount('trade',result.x);
      end;

     
      if not(done) then
      begin
        writeln('no coins in '+where);
        result.x:=0;
        result.y:=0;
      end;
    end;


    {*******************************************************************************
    function GetNameOfItemInBank: string;
    By: Boreas, bases off of Ron's Replace
    Description: Takes item name from uptext in bankscreen, and changes spaces
    to underscores
    *******************************************************************************}

    function GetNameOfItemInBank: string;
    var
      a : LongInt;
      TheString:string;
    begin
      TheString:=GetUptext;
      a := Pos('Withdraw 1 ', TheString);
      if(a = 0)then
      begin
        // Do nothing..
      end else
      begin
        Delete(TheString, a, Length('Withdraw 1 '));
        Insert('', TheString, a);
        a := Pos(' /', TheString);
        delete(thestring,a,Length(TheString));
        repeat
          a := Pos(' ', TheString);
          if a<>0 then
          begin
            Delete(TheString, a, 1);
            Insert('_', TheString, a);
          end;
        until a=0;
        repeat
          a := Pos(chr(39), TheString);
          if a<>0 then
          begin
            Delete(TheString, a, 1);
          end;
        until a=0;

        Result := TheString;
      end;
    end;

    {*******************************************************************************
    function LongTextBreakDown(TheString):string;
    By: Ron and Boreas
    Description: Formats a long string so that it looks like the result of
    DTM to text. Pretty much only useful for BlackList to Text
    *******************************************************************************}


    function LongTextBreakDown(TheString:string):array of string;
    var iter:integer;
    tmpstring:string;
    begin
      tmpstring:=TheString;
      if length(tmpstring) > 62 then
      begin
        setarraylength(result,iter+1);
        result[iter]:=copy(tmpstring, 1, 61)+chr(39)+' +';
        delete(tmpstring, 1, 61);
        while length(tmpstring) > 69 do
        begin
          iter:=iter+1;
          setarraylength(result,iter+1);
          result[iter]:='       '+chr(39)+copy(tmpstring, 1, 53)+chr(39)+' +';
          delete(tmpstring, 1, 53);
        end;
        iter:=iter+1;
        setarraylength(result,iter+1);
        result[iter]:='       '+chr(39)+tmpstring;
      end else
      begin
        setarraylength(result,1);
        result[0]:=tmpstring;
      end;
    end;
    {*******************************************************************************
    procedure WriteBlackList(TheBlackList: BlackList);
    By: Boreas/moparisthebest
    Description: Displays a BlackList as a string in debug box. Basically
    array of integer -> string and DTM editor's DTM to Text put together
    *******************************************************************************}

    procedure WriteBlackList(TheBlackList: BlackList);
    var
      i, arrayLength: Integer;
      mystr,tmpresult:string;
      aos:array of string;
    begin
      arrayLength := GetArrayLength(TheBlackList);
      repeat
        tmpresult := tmpresult + IntToStr(TheBlackList[i]);
        if (not (i = (arrayLength - 1))) then
          tmpresult := tmpresult + ' ';
        i := i + 1;
      until (i = arrayLength)
      mystr:=GetNameOfItemInBank;
      if mystr='' then mystr:='BlackList';
      tmpresult:='  BL_'+mystr+' := LoadBlackListFromString('+chr(39)+tmpresult+chr(39)+');';
      aos:=LongTextBreakDown(tmpresult);
      for i:=0 to getarraylength(aos)-1 do
        writeln(aos[i]);
    end;

    var coins:tpoint;
    t:integer;

    begin
      setupsrl;

      t:=getsystemtime;
      coins:=findcoins('bank');
      writeln('Found '+inttostr(coins.y)+' coins at bank slot '+
      inttostr(coins.x)+' in '+inttostr(getsystemtime-t)+'ms');

      t:=getsystemtime;
      coins:=findcoins('inv');
      writeln('Found '+inttostr(coins.y)+' coins at inv slot '+
      inttostr(coins.x)+' in '+inttostr(getsystemtime-t)+'ms');
               
       t:=getsystemtime;
      coins:=findcoins('lefttrade');
      writeln('Found '+inttostr(coins.y)+' coins at lefttrade slot '+
      inttostr(coins.x)+' in '+inttostr(getsystemtime-t)+'ms');

      t:=getsystemtime;
      coins:=findcoins('righttrade');
      writeln('Found '+inttostr(coins.y)+' coins at righttrade slot '+
      inttostr(coins.x)+' in '+inttostr(getsystemtime-t)+'ms');
         
               

    end.

  2. #2
    Join Date
    Dec 2006
    Location
    Sweden
    Posts
    10,812
    Mentioned
    3 Post(s)
    Quoted
    16 Post(s)

    Default

    Woot first post! I don't get what this does..


    Send SMS messages using Simba
    Please do not send me a PM asking for help; I will not be able to help you! Post in a relevant thread or make your own! And always remember to search first!

  3. #3
    Join Date
    Jun 2006
    Location
    USA
    Posts
    1,828
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Again some crazy stuff made by Boreas! Haha!
    Very nice.

  4. #4
    Join Date
    Sep 2006
    Posts
    5,219
    Mentioned
    4 Post(s)
    Quoted
    1 Post(s)

    Default

    Thanks to Pentti for helping me get the trade coords

    hy it finds out how much gp you have in your inventory (or bank or tradescreen)
    SCAR Code:
    var Coins:tpoint;
    begin
      setupsrl;
      Coins:=FindCoins('inv'); //Looks for coins in inventory
      writeln(inttostr(Coins.x)); //which slot the coins are in
      writeln(inttostr(Coins.y)); // how many coins are in that slot
    end.

  5. #5
    Join Date
    Jun 2007
    Posts
    69
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

  6. #6
    Join Date
    Sep 2006
    Location
    New Jersey, USA
    Posts
    5,347
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    Amazing

    If only we could use that in the scripting competition
    Interested in C# and Electrical Engineering? This might interest you.

  7. #7
    Join Date
    Oct 2006
    Posts
    585
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    i see future amazing merchanting scripts

    Quote Originally Posted by YoHoJo View Post
    I like hentai.

  8. #8
    Join Date
    May 2007
    Location
    Seattle
    Posts
    1,069
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Wha?

    What does it do?
    FORMERLY BORN2CODE | Play Internet Games
    http://img147.imageshack.us/img147/2084/sigg.png

  9. #9
    Join Date
    Sep 2006
    Posts
    5,219
    Mentioned
    4 Post(s)
    Quoted
    1 Post(s)

    Default

    See posts 1 and 4.

  10. #10
    Join Date
    Dec 2006
    Location
    Sweden
    Posts
    10,812
    Mentioned
    3 Post(s)
    Quoted
    16 Post(s)

    Default

    Ah, i get it! Nice job!


    Send SMS messages using Simba
    Please do not send me a PM asking for help; I will not be able to help you! Post in a relevant thread or make your own! And always remember to search first!

  11. #11
    Join Date
    Sep 2006
    Location
    West U.S.
    Posts
    2,172
    Mentioned
    0 Post(s)
    Quoted
    6 Post(s)

    Default

    this is great!
    merchant scripts are definitely going to be needing this!

    They are sisters...
    Runescape Classic

  12. #12
    Join Date
    May 2007
    Posts
    468
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    boreas, do u create scriptS? cuz i smell a merchanter
    Originally Posted by YoHoJo
    I like hentai.

  13. #13
    Join Date
    Sep 2006
    Posts
    5,219
    Mentioned
    4 Post(s)
    Quoted
    1 Post(s)

    Default

    This is part of B4, which will handle all bank/trade/inv/shop items. It isn't for any script I plan on doing. I suppose it could be used for shop buyers, merchanters, and world 16 air runners.

    Now I'm working on something that gets everything on the second trade screen. It will also be a part of B4, but I will be using it in a law runner script which I will release either to members or publicly.

  14. #14
    Join Date
    Apr 2007
    Location
    Michigan -.-
    Posts
    1,357
    Mentioned
    2 Post(s)
    Quoted
    4 Post(s)

    Default

    very nice timing =)

    i just happen to be working on a merchanting script w00t

    do i need all those functions for findcoins to work or just a few? Would it be easier for me to just paste all that into SRL and include it? Not sure it looks pretty complex, im gonna try to implement it for sure tho!

    THANKS!
    METAL HEAD FOR LIFE!!!

  15. #15
    Join Date
    Sep 2006
    Posts
    5,219
    Mentioned
    4 Post(s)
    Quoted
    1 Post(s)

    Default

    You need most of em, including the types at the top. Put them in a file called B4.scar and put in SRL/SRL/misc, add to your script
    {.include srl/srl/misc/b4.scar}

  16. #16
    Join Date
    Jun 2006
    Posts
    1,492
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Another great post by Boreas... amazing.

    And you know, I can't wait for the day when all those scripts you said you have been "working on" finally are released lol. It will be like a second christmas

  17. #17
    Join Date
    Sep 2006
    Posts
    5,219
    Mentioned
    4 Post(s)
    Quoted
    1 Post(s)

    Default

    Don't hold your breath

    As I see it now I will be releasing:
    Current: B4
    Next: WebWalker (depending on another tool) or Law runner
    After that: MouseHelper (depending on another tool) or Lumbridge multi skill

  18. #18
    Join Date
    Apr 2007
    Location
    Michigan -.-
    Posts
    1,357
    Mentioned
    2 Post(s)
    Quoted
    4 Post(s)

    Default

    Quote Originally Posted by Boreas View Post
    You need most of em, including the types at the top. Put them in a file called B4.scar and put in SRL/SRL/misc, add to your script
    {.include srl/srl/misc/b4.scar}
    THANKS =D!!!

    EDIT:

    hey quick question,

    would i be able to find the location of the coins and use the tpoint var in order to move the mouse to its slot and click it....

    like:
    SCAR Code:
    coins:=findcoins('lefttrade');
    if(FindCoins('lefttrade'))then
    begin
      Mouse(coins.x,3,3,False);
    end;
    METAL HEAD FOR LIFE!!!

Thread Information

Users Browsing this Thread

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

Posting Permissions

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