Results 1 to 23 of 23

Thread: FindObjOre rewamp...

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

    Default FindObjOre rewamp...

    Well actually Im not sure can this be called FindObjOre anymore

    But anyways, the reason I didn't post this in my thread in members section was
    that I haven't given any 'big' functions to the Junior section (well this is 100 lines ) and if there are any a bit more advanced Junior Members that wanna learn about TPAs they can try and learn from this...

    Also if someone feels like, is completely free to use this
    as long as I get credit from these

    Tested in Varrock East Mine
    Tin rock
    ColorToleranceSpeed(2)

    Found the rock in 282ms, no world record but I didn't concentrate on the speed so much on this one.

    Also the TPAFromBox takes 100ms, Wizzy should stuff something like that in his plugin.

    Here you go -

    SCAR Code:
    program New;
    {.include SRL/SRL.scar}
    Var
      Myx, Myy, MyOreColor, MyDirtColor: Integer;

    Function CheckRockDirt(Var RefColor: Integer; Var rTPA: TPointArray; X, Y, Tol, HowMany, TheCTS, Dbg: Integer): Boolean;
    Var
      CTS, F, I, C, SmallTol: Integer;
      TPA: TPointArray;
    Begin
      CTS := GetColorToleranceSpeed;
      If Not CTS = TheCTS Then ColorToleranceSpeed(TheCTS);
      FindColorsSpiralTolerance(X, Y, TPA, RefColor, X - 12, Y - 12, X + 12, Y + 12, Tol);
      SmallTol := Tol;
      For I := 0 To High(TPA) Do
      Begin
        C := GetColor(TPA[i].x, TPA[i].y);
        If SimilarColors(C, RefColor, Tol) Then
        Begin
          F := F + 1;
          If Round(Abs(C - RefColor)) < SmallTol Then
          Begin
            RefColor := C;
            If Dbg = 1 Then Writeln('Found new RefColor!');
          End;
          SetArrayLength(rTPA, GetArrayLength(rTPA) + 1);
          rTPA[High(rTPA)] := TPA[i];
        End;
      End;
      If F >= HowMany Then
        Result := True;
      ColorToleranceSpeed(CTS);
    End;

    Procedure TPAFromBox(Var TPA: TPointArray; x1, y1, x2, y2: Integer);
    Var
      W, H, I, L, WD, HD: Integer;
    Begin
      WD := x2 - x1;
      HD := y2 - y1;
      L := (WD + 1) * (HD + 1);
      SetArrayLength(TPA, L);
      For W := x1 To x2 Do
        For H := y1 To y2 Do
        Begin
          TPA[i] := IntToPoint(W, H);
          I := I + 1;
        End;
    End;

    Function OreColorsTPA(Var OreColor: Integer; Tol, TheCTS: Integer; TPA: TPointArray): Integer;
    Var
      I, CTS, C, X, Y: Integer;
      colPoints: TPointArray;
      Colors: TIntegerArray;
    Begin
      CTS := GetColorToleranceSpeed;
      If Not CTS = TheCTS Then ColorToleranceSpeed(TheCTS);
      MiddleTPAEx(TPA, X, Y);
      TPAFromBox(colPoints, X - 12, Y - 12, X + 12, Y + 12);
      Colors := GetColors(colPoints);
      For I := 0 To High(colPoints) Do
        If SimilarColors(Colors[i], OreColor, Tol) Then
          Result := Result + 1;
      ColorToleranceSpeed(CTS);
    End;

    Function FindObjNewOre(Var OreX, OreY: Integer; Var Color, DirtColor: Integer; Tol, DirtTol, Count, CTS: Integer): Boolean;
    Var
      Veins: Array of TPointArray;
      rTPA, rPts: TPointArray;
      TheCTS, C: Integer;
      TP: TPoint;
    Begin
      TheCTS := GetColorToleranceSpeed;
      If Not TheCTS = CTS Then ColorToleranceSpeed(CTS);
      MA := GetSystemTime;
      FindColorsSpiralTolerance(MSCX, MSCY, rTPA, Color, MSX1, MSY1, MSX2, MSY2, Tol);
      Veins := SplitTPAEx(rTPA, 2, 2);
      SetArrayLength(rTPA, GetArrayLength(Veins));
      For C := 0 To High(rTPA) Do
      Begin
        rTPA[c] := MiddleTPA(Veins[c]);
        If CheckRockDirt(DirtColor, rPts, rTPA[c].x, rTPA[c].y, DirtTol, 30, CTS, 2) Then
        Begin
          If OreColorsTPA(Color, Tol, Cts, rPts) >= Count Then
          Begin
            TP := MiddleTPA(rPTs);
            MMouse(TP.x, TP.y, 2, 2);
            If IsUpTextMulti('ine', 'Mine', 'ocks') Then
            Begin
              Result := True;
              GetMousePos(OreX, OreY);
              Break;
            End;
          End;
        End;
      End;
      ColorToleranceSpeed(TheCTS);
    End;
     
    begin
      SetupSRL;
      MyOreColor := 7698047;
      MyDirtColor := 1592925;
      If FindObjNewOre(MyX, MyY, MyOreColor, MyDirtColor, 12, 12, 5, 2) Then
        MMouse(MyX, MyY, 2, 2);
    end.

    EDIT: Worked for me without problem without using the uptext
    (well it moved to a real rock on the first attempt so...)
    but I put it there so people feel safer...

    EDIT EDIT: I should use this in my VEM lol...

    EDIT EDIT EDIT: I took out the re-coloring in OreColorsTPA, but anyone who can make a HelloWorld can put it back...

  2. #2
    Join Date
    Nov 2006
    Location
    NSW, Australia
    Posts
    3,487
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Genius! All I can say.
    [CENTER][img]http://signatures.mylivesignature.com/54486/113/4539C8FAAF3EAB109A3CC1811EF0941B.png[/img][/CENTER]
    [CENTER][BANANA]TSN ~ Vacation! ~ says :I Love Santy[/BANANA][/CENTER]

    [CENTER][BANANA]Raymond - Oh rilie? says :Your smart[/BANANA][/CENTER]

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

    Default

    lol thanks

    I want some comment from devs or something, I always see them or Boreas view my threads for about 5 minutes, and not post

    (darn leechers! jks)

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

    Default

    im so jeaulous
    ~Hermen

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

    Default

    So you made one last spam?

  6. #6
    Join Date
    Jun 2007
    Posts
    785
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by n3ss3s View Post
    So you made one last spam?
    nice 11 posts for 3k post =P

    Awsome ;o you are the SeCks at Scripting :|

    [22:20] <[-jesus-]> freddy, go uninstall yourself

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

    Default

    Haha thanks

    And yeah, I'll get my 3rd millenium today

    @Nielsie: Post?

    Peek to Nielsie's lab

    ___

    | |
    ___

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

    Default

    Quote Originally Posted by n3ss3s View Post
    lol thanks

    I want some comment from devs or something, I always see them or Boreas view my threads for about 5 minutes, and not post

    (darn leechers! jks)
    i see nielsie vieuwing ^^
    ~Hermen

  9. #9
    Join Date
    Sep 2006
    Posts
    6,089
    Mentioned
    77 Post(s)
    Quoted
    43 Post(s)

    Default

    OreColorsTPA is a CountColorTolerance?

    How does it work on old rocks?
    Hup Holland Hup!

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

    Default

    Its made for new rocks, and nah, no it isnt

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

    Default

    Quote Originally Posted by nielsie95 View Post
    OreColorsTPA is a CountColorTolerance?

    How does it work on old rocks?
    Quote Originally Posted by n3ss3s View Post
    Its made for new rocks, and nah, no it isnt
    teach it him n3ss3s btw, forgot to say nice function
    ~Hermen

  12. #12
    Join Date
    Apr 2007
    Location
    Australia
    Posts
    4,163
    Mentioned
    9 Post(s)
    Quoted
    19 Post(s)

    Default

    It looks like one to me

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

    Default

    Quote Originally Posted by The Claw View Post
    It looks like one to me

    man you avy its so burning my eyes
    ~Hermen

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

    Default

    It looks like one to me
    A nice function?

    Yay thanks!

    And thanks hermpie.

    Btw, I made a decision, I am not going to finish CM4D.

    I abandoned it a long time ago, but I'll post it in the members section so somebody can finish it, though mentioning me in the credits would be nice.
    Its over 2k code =S

    Now, I am making a VEM... Hopefully it'll end up released

  15. #15
    Join Date
    Sep 2006
    Posts
    6,089
    Mentioned
    77 Post(s)
    Quoted
    43 Post(s)

    Default

    EDIT: Wow, this thread is going fast..

    @N3ss3s: "no it isnt"

    Oh really?

    Well, you can speed it up by using a CountColorTolerance.
    And you could use GetColors in CheckRockDirt + you could do this:

    SCAR Code:
    SetArrayLength(rTPA, GetArrayLength(Veins));
      For I := 0 To High(Veins) Do
        rTPA[i] := MiddleTPA(Veins[i]);

    in the loop
    Hup Holland Hup!

  16. #16
    Join Date
    Apr 2007
    Location
    Australia
    Posts
    4,163
    Mentioned
    9 Post(s)
    Quoted
    19 Post(s)

    Default

    Quote Originally Posted by n3ss3s View Post
    A nice function?

    Yay thanks!
    lolwut? I meant it looks like a CountColorsTolerance, lol.

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

    Default

    Go home claw Jks

    Nielsie, why do I need it in the loop, it needs to be done only once..

    I actually didn't see the CountColorTolerance, should update if I wasnt too lazy

    EDIT: 6 posts till 3k

  18. #18
    Join Date
    Sep 2006
    Posts
    6,089
    Mentioned
    77 Post(s)
    Quoted
    43 Post(s)

    Default

    Because it would be faster..
    You first get all the middles, and when one of them is a rock you break out of the loop so you don't need the other ones
    You can better do one MiddleTPA a time so it doen't do unneeded work?
    Hup Holland Hup!

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

    Default

    Hey that makes sence, thanks!

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

    Default

    i posted on your thread n3ss3s (no not this one )
    ~Hermen

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

    Default

    Rofl, hermpie is banned, propably for spam.

    Anyone knows??

    Gotta go see the General News!
    EDIT: 0mg 3millenium1!!!!

    EDIT EDIT: Oh, for request...

  22. #22
    Join Date
    Apr 2007
    Location
    UK
    Posts
    2,295
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by n3ss3s View Post
    Rofl, hermpie is banned, propably for spam.

    Anyone knows??

    Gotta go see the General News!
    EDIT: 0mg 3millenium1!!!!

    EDIT EDIT: Oh, for request...
    Nice revamp . Gonna try it later if i get a chance

    //oftopic He left and wanted to be banned.

    Rogeruk's Al-Kharid Tanner V1.1 [Released]
    Rogeruk's Barbarian Crafter [Coming Soon]
    Rogeruk's Guild Fisher [Coming Soon]
    !! - Taking Requests - !!

  23. #23
    Join Date
    Jun 2007
    Posts
    785
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by rogeruk View Post
    Nice revamp . Gonna try it later if i get a chance

    //oftopic He left and wanted to be banned.
    temp ban :P for like 1 month...

    I hope hermpie won't suicide because he can't spam ;o

    [22:20] <[-jesus-]> freddy, go uninstall yourself

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
  •