Results 1 to 12 of 12

Thread: Some functions...

  1. #1
    Join Date
    Jul 2007
    Posts
    1,431
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Some functions...

    Some functions by me, have fun...

    Finds gas near x & y
    SCAR Code:
    function GasIn(X, Y : integer) : Boolean;
    var
      CTS, i, a : integer;
      PCount : TIntegerArray;
    begin
      SetLength(PCount, 2);
      CTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorspeed2Modifiers(0.08, 0.25);
      if FindColorTolerance(a, a, 7835543, X - 25, Y - 25, X + 25, Y + 25, 15) then
      begin
        for i:=0 to 1 do
        begin
          PCount[i]:= CountColorTolerance(7835543, X - 25, Y - 25, X + 25, Y + 25, 15);
          if i = 0 then wait(250);
        end;
        if PCount[0] <> PCount[1] then
        begin
          Result := True;
          Writeln('Gas found, Pixelcount change: '+FloatToStr((Abs(PCount[0] - PCount[1]) * PCount[0]) / 100)+'%');
        end;
      end;
      SetColorspeed2Modifiers(0.2, 0.2);
      ColorToleranceSpeed(CTS);
    end;


    Makes <Array of Array of Integer> to <Array of integer>
    SCAR Code:
    Function TIAAtoTIA(dd :Array of TIntegerArray) : TIntegerArray;
    var
      New : TIntegerArray;
      L, K, i, j, g, d, add, ddl : integer;
    begin
      g := length(dd);
      d := high(dd)
      for g := 0 to d do
      ddl := ddl + Length(dd[g]);
      SetLength(New, ddl)
      L := High(dd);
      For i := 0 to L do
      begin
        K := High(dd[i])
        For j := 0 to K do
        begin
          New[add] := dd[i][j];
          Inc(Add);
        end;
      end;
      Result := New;
    end;

    Finds a dummy!
    SCAR Code:
    function FindDummy(var a, b : integer) : Boolean;
    var
      TPA : TPointArray;
      ATPA : TPointArrayArray;
      I, CTS, L : integer;
    begin
      CTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorspeed2Modifiers(0.2, 0.8);
      FindColorsTolerance(TPA, 8429238, MSX1, MSY1, MSX2, MSY2, 12);
      SetColorspeed2Modifiers(0.2, 0.2);
      ColorToleranceSpeed(CTS);
      ATPA := SplitTPAEx(TPA, 10, 10);
      SortATPAFrom(ATPA, IntToPoint(MSCX, MSCY));
      L := High(ATPA)
      For i := 0 to L do
      if Length(ATPA[i]) >= 100 then
      begin
        MiddleTPAEx(ATPA[i], a, b);
        MMouse(a - 5, b - 8, 3, 17);
        Wait(50 + random(50));
        if (pos('mmo', rs_GetUpText) > 0) then
        begin
          Getmousepos(a, b);
          Result := True;
          status('Dummy found!');
          Exit;
        end;
      end;
    end;

    Find all items execpt colors given, and does what uptext says
    SCAR Code:
    procedure DoItemsExceptColors(colorz : TIntegerArray; todo : string);
    var
      IC : TPoint;
      I, J, x, y : integer;
    begin
      if (GetCurrentTab <> 4) then
      begin
        Gametab(4);
        Wait(1000 + random(1000));
      end;
      for i := 1 to 28 do
      begin
        if ExistsItem(i) then
        begin
          Wait(1000);
          if not ExistsItem(i) then Continue;
          IC := ItemCoords(i)
          For j := 0 to High(Colorz) do
          begin
            if FindColorSpiralTolerance(x, y, colorz[j],ic.x - 20, ic.y - 20, ic.x + 20, ic.y + 20, 5) then Continue;
            if j = High(Colorz) then
            begin
              MMouseItem(i);
              Getmousepos(x, y);
              if pos(todo, Rs_GetUpText) > 0 then
                Mouse(x, y, 0, 0, true)
              else
              begin
                Mouse(x, y, 0, 0, false)
                ChooseOption(ToDo);
              end;
            end;
          end;
        end;
      end;
    end;

    Finds an object, Mincount is integer, that how much pixels should that object have
    SCAR Code:
    function FindObjTPA(var x, y, Color, MinPoints : integer; Text : String) : Boolean;
    var
      TPA : TPointArray;
      ATPA : TPointArrayArray;
      I, L : integer;
    begin
      FindColorsTolerance(TPA, Color, MSX1, MSY1, MSX2, MSY2, 12);
      ATPA := SplitTPAEx(TPA, 10, 10);
      SortATPAFrom(ATPA, IntToPoint(MSCX, MSCY));
      L := High(ATPA)
      For i := 0 to L do
      if Length(ATPA[i]) >= MinPoints then
      begin
        MiddleTPAEx(ATPA[i], a, b);
        MMouse(x - 5, y - 5, 11, 11);
        Wait(50 + random(50));
        if (pos(text, rs_GetUpText) > 0) then
        begin
          Getmousepos(x, y);
          Result := True;
          status('Object found!');
          Exit;
        end;
      end;
    end;
    [CENTER][SIZE="4"]Inactive[/SIZE]I forgot my password[/CENTER]

  2. #2
    Join Date
    Jul 2007
    Location
    N O R
    Posts
    208
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    oh nice, i'll be sure to use these, thanks !

  3. #3
    Join Date
    Mar 2007
    Posts
    3,116
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    SCAR Code:
    Function TIAAtoTIA(dd :Array of TIntegerArray) : TIntegerArray;
    var
      New : TIntegerArray;
      L, K, i, j, g, d, add, ddl : integer;
    begin
      g := length(dd);
      d := high(dd)
      for g := 0 to d do
      ddl := ddl + Length(dd[g]);
      SetLength(New, ddl)
      L := High(dd);
      For i := 0 to L do
      begin
        K := High(dd[i])
        For j := 0 to K do
        begin
          New[add] := dd[i][j];
          Inc(Add);
        end;
      end;
      Result := New;
    end;
    This Could be shorter
    SCAR Code:
    Function TIAAtoTIA(dd :Array of TIntegerArray) : TIntegerArray;
    var
      I:integer;
    begin
      For I:=0 to GetArrayLength(dd)-1 do
        Result:=CombineIntArray(Result, dd[I])
    end;

  4. #4
    Join Date
    May 2007
    Location
    Ohio
    Posts
    2,296
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Nice, Maybe I Could Make Some Of These

  5. #5
    Join Date
    Jul 2007
    Posts
    1,431
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    @Myles, yours doesnt work...

    Edit: if <Array of array> has total like 10 components then yours makes <array of> to have 10000 components
    [CENTER][SIZE="4"]Inactive[/SIZE]I forgot my password[/CENTER]

  6. #6
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,553
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    meh, he couldn't even fix my script he sucks...

    xD
    ~Hermen

  7. #7
    Join Date
    Dec 2006
    Location
    Copy pastin to my C#
    Posts
    3,788
    Mentioned
    8 Post(s)
    Quoted
    29 Post(s)

    Default

    Hermpie, couldn't you just stop the spamming?


    Edit: if <Array of array> has total like 10 components then yours makes <array of> to have 10000 components
    Overruled, run the script below.


    SCAR Code:
    Program New;

    Function TIAAToTIA(TIAA: Array of TIntegerArray): TIntegerArray;
    Var
      I: Integer;
    Begin
      For I := 0 To High(TIAA) Do
        Result := CombineIntArray(Result, TIAA[i]);
    End;

    Var
      Arr: Array of TIntegerArray;
      Ar: TIntegerArray;
      I: Integer;

    Begin
      SetArrayLength(Arr, 3);
      Arr[0] := [1, 2, 3];
      Arr[1] := [4, 5, 6];
      Arr[2] := [7, 8, 9];
      Ar := TIAAToTIA(Arr);
      For I := 0 To High(Ar) Do
        Writeln(IntToStr(Ar[i]));
    End.

  8. #8
    Join Date
    Jul 2007
    Posts
    1,431
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by hermpie View Post
    meh, he couldn't even fix my script he sucks...

    xD
    First, learn some standards, second, I fixed the banking, third, you will not say do I suck or not...next time don't request help if you assist someone to fix your procedure(not remake like I did, when you said "omg you wasted a hour in my life!") so you don't have to give credits.

    He had
    SCAR Code:
    Procedure Bank;
    Begin
      If Not (LoggedIn) Then Exit;
      LoadDTMs;
      If DTMRotated(OpenFWBank, X, Y, MSX1, MSY1, MSX2, MSY2) Then
      Begin
        Mouse(X,Y,3,3,False);
        Wait(50 + Random (25));
        If ChooseOption('quickly') Then if WaitUntil(2000,PinScreen) then if Inpin(IntToStr(Players[CurrentPlayer].Integers[1])) then if WaitUntil(2000,BankScreen) then
        begin
          If Players[CurrentPlayer].Booleans[2] Then
          Begin
            If FindDTM(BigBone, X, Y, MSX1, MSY1, MSX2, MSY2) then
            Begin
              WaitUntil(5000,ChooseOption('ll'));
              CloseBank;
              GameTab(4);
            End Else
              If FindDTM(Bone, X, Y, MSX1, MSY1, MSX2, MSY2) Then
              WaitUntil(5000,ChooseOption('ll'));
              CloseBank;
              GameTab(4);
          End Else
            If FindDTM(Bone, X, Y, MSX1, MSY1, MSX2, MSY2) then
            WaitUntil(5000,ChooseOption('ll'));
            CloseBank;
            GameTab(4);
        End Else
          Begin
            CloseBank;
            logout;
          End;
      End Else
      OpenBankQuiet('FWB');
    End;

    I made it to:
    SCAR Code:
    Procedure Bank;
    var
      t : longint;
    Begin
      If Not (LoggedIn) or bankscreen Then Exit;
      If DTMRotated(OpenFWBank, X, Y, MSX1, MSY1, MSX2, MSY2) Then
      Begin
        Mouse(X,Y,3,3,False);
        Wait(50 + Random (25));
        If ChooseOption('quickly') Then
        begin
          marktime(t);
          repeat
            wait(100);
            if pinscreen then
              Inpin(IntToStr(Players[CurrentPlayer].Integers[1]));
            if timefrommark(t) > 30000 then exit;
          until bankscreen;
        end;
      end else
      if not Findbank('fwb') then
      begin
        logout;
        exit;
      end;
      Wait(1500 + random(500));
      fixbank;
      writeln('Bank opened');
     
      writeln(booltostr(Players[CurrentPlayer].Booleans[2]));
      If Players[CurrentPlayer].Booleans[2] Then
      Begin
        If FindDTM(BigBone, X, Y, MSX1, MSY1, MSX2, MSY2) then
          Mouse(x,y,5,5,false)
        Else
        If FindDTM(Bone, X, Y, MSX1, MSY1, MSX2, MSY2) Then
          Mouse(x,y,5,5,false);
      end Else
      If FindDTM(Bone, X, Y, MSX1, MSY1, MSX2, MSY2) then
        Mouse(x,y,5,5,false);

      WaitUntil(5000,ChooseOption('ll'));
      CloseBank;
      GameTab(4);
    end;

    And he pointed out that I ruined hes procedure, though i fixed it...he wanted that waituntil will stay, since I removed, and sayd him to repeat standards learning, he started to swear on me in msn, etc, so block, and have fun

    Edit:
    have to say it back,
    Fuck you too hermpie!

    Edit:
    Too bad I don't got conv records, deleted him on msn and blocked.

    Edit:
    http://www.srl-forums.com/forum/omgz...tml#post345680
    Thread about WaitUntil what I kinda removed and he wanted so much that it will stay! oh noes!

    edit:
    Back on topic
    Run this and see...no idea
    SCAR Code:
    program New;

    Function TIAAtoTIA(dd :Array of TIntegerArray) : TIntegerArray;
    var
      New : TIntegerArray;
      L, K, i, j, g, d, add, ddl : integer;
    begin
      g := length(dd);
      d := high(dd)
      for g := 0 to d do
      ddl := ddl + Length(dd[g]);
      SetLength(New, ddl)
      L := High(dd);
      For i := 0 to L do
      begin
        K := High(dd[i])
        For j := 0 to K do
        begin
          New[add] := dd[i][j];
          Inc(Add);
        end;
      end;
      Result := New;
    end;

    Function TIAAtoTIAMyles(dd :Array of TIntegerArray) : TIntegerArray;
    var
      I:integer;
    begin
      For I:=0 to GetArrayLength(dd)-1 do
        Result:=CombineIntArray(Result, dd[i]);
    end;

    var
     tiaa : array of tintegerarray;
     tia : tintegerarray;
     t, i, L : longint;

    begin
      setarraylength(tiaa, 10);
      for i := 0 to  9 do
      setarraylength(tiaa[i], 1);
      TIAA[0][0] := 1111;
      TIAA[1][0] := 2222;
      TIAA[2][0] := 3333;
      TIAA[3][0] := 4444;
      TIAA[4][0] := 5555;
      TIAA[5][0] := 6666;
      TIAA[6][0] := 7777;
      TIAA[7][0] := 8888;
      TIAA[8][0] := 9999;
      TIAA[9][0] := 0;
     
      t := getsystemtime;
      for i := 0 to 999 do
      tia := TIAAtoTIAMyles(tiaa);
      writeln('Myles took '+inttostr(getsystemtime -t));

      writeln(inttostr(length(tia)));
      L := high(tia);
      for i := 0 to  L do
      writeln(inttostr(tia[i]));
      writeln('');
     
      t := getsystemtime;
      for i := 0 to 999 do
      tia := TIAAtoTIA(tiaa);
      writeln('Mine took '+inttostr(getsystemtime -t));

      L := high(tia);
      for i := 0 to  L do
      writeln(inttostr(tia[i]));
      writeln('');

    end.

    No idea.
    [CENTER][SIZE="4"]Inactive[/SIZE]I forgot my password[/CENTER]

  9. #9
    Join Date
    Dec 2006
    Location
    Copy pastin to my C#
    Posts
    3,788
    Mentioned
    8 Post(s)
    Quoted
    29 Post(s)

    Default

    SCAR Code:
    program New;

    Function TIAAtoTIA(dd :Array of TIntegerArray) : TIntegerArray;
    var
      New : TIntegerArray;
      L, K, i, j, g, d, add, ddl : integer;
    begin
      g := length(dd);
      d := high(dd)
      for g := 0 to d do
      ddl := ddl + Length(dd[g]);
      SetLength(New, ddl)
      L := High(dd);
      For i := 0 to L do
      begin
        K := High(dd[i])
        For j := 0 to K do
        begin
          New[add] := dd[i][j];
          Inc(Add);
        end;
      end;
      Result := New;
    end;

    Function TIAAtoTIAMyles(dd :Array of TIntegerArray) : TIntegerArray;
    var
      I:integer;
    begin
      For I:=0 to High(dd) do
        Result:=CombineIntArray(Result, dd[i]);
    end;

    var
     tiaa : array of tintegerarray;
     tia : tintegerarray;
     t, i, L : longint;

    begin
      setarraylength(tiaa, 10);
      for i := 0 to  9 do
      setarraylength(tiaa[i], 1);
      TIAA[0][0] := 1111;
      TIAA[1][0] := 2222;
      TIAA[2][0] := 3333;
      TIAA[3][0] := 4444;
      TIAA[4][0] := 5555;
      TIAA[5][0] := 6666;
      TIAA[6][0] := 7777;
      TIAA[7][0] := 8888;
      TIAA[8][0] := 9999;
      TIAA[9][0] := 0;

      t := getsystemtime;
      for i := 0 to 999 do
      Begin
        SetArrayLength(Tia, 0);
        tia := TIAAtoTIAMyles(tiaa);
      End;
      writeln('Myles took '+inttostr(getsystemtime -t));

      writeln(inttostr(length(tia)));
      L := high(tia);
      for i := 0 to  L do
      writeln(inttostr(tia[i]));
      writeln('');

      t := getsystemtime;
      for i := 0 to 999 do
      Begin
        SetArrayLength(Tia, 0);
        tia := TIAAtoTIA(tiaa);
      End;
      writeln('Mine took '+inttostr(getsystemtime -t));

      L := high(tia);
      for i := 0 to  L do
      writeln(inttostr(tia[i]));
      writeln('');

    end.

    -.- you yourself made them 1000 indexes big...

    run that, works.

  10. #10
    Join Date
    Jul 2007
    Posts
    1,431
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Ow...my bad...so I have always to set length to 0?

    Embarrising?

    dow!

    Edit: sorry Myles

    Edit: Myles made is still faster
    [CENTER][SIZE="4"]Inactive[/SIZE]I forgot my password[/CENTER]

  11. #11
    Join Date
    Dec 2006
    Location
    Copy pastin to my C#
    Posts
    3,788
    Mentioned
    8 Post(s)
    Quoted
    29 Post(s)

    Default

    The TIAAToTIA that uses CombineIntArray, combines the TIAA to the result, so you did that 1000 times

  12. #12
    Join Date
    Jul 2007
    Posts
    1,431
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by n3ss3s View Post
    The TIAAToTIA that uses CombineIntArray, combines the TIAA to the result, so you did that 1000 times
    Now i got it

    In combinearray it just add and adds...but mine repeat adding values to same spot -.-
    [CENTER][SIZE="4"]Inactive[/SIZE]I forgot my password[/CENTER]

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Functions
    By lordsaturn in forum OSR Help
    Replies: 1
    Last Post: 08-13-2007, 10:12 PM
  2. Help with some functions
    By Pinqvin in forum OSR Help
    Replies: 6
    Last Post: 03-06-2007, 01:34 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
  •