Results 1 to 16 of 16

Thread: Ambiguous Colors

  1. #1
    Join Date
    May 2012
    Posts
    18
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Ambiguous Colors

    Hello,
    I tried creating my first script after finding this forum yesterday. I've never used Pascal or Simba before but I have some experience in C, Java, Racket, Clips and Prolog.
    I wanted to make a simple script for collecting and burying bones at the Chaos Temple in the wilderness, but I run into a rather nasty problem: the bone and the enviorment have pretty much the same color and it's almost impossible to make the difference. The basic find color with tolerance was just clicking around the place randomly, SmartColors was just clicking around the bones for a while then stopping, ACA v2 was unable to distinguish between just the bone and the ground, although it did collect some bones at first it would just run like crazy somewhere else in the wild after some time. I could make a condition to not go too far away from the starting point, but the efficiency would still be terrible. I didn't try DTMs because i thought they would be useless for the main screen. The burying part works well btw. I do not yet know many functions in Simba, so this is why I am asking for help: is there anything that could be used for color recognition in this case or should I just click on coordinates with some random waiting in between?

  2. #2
    Join Date
    Sep 2007
    Location
    Michigan
    Posts
    3,862
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default

    If the bones show up on MiniMap you can narrow your search area down using MMtoMS.
    (Scripts outdated until I update for new SRL changes)
    AK Smelter & Crafter [SRL-Stats] - Fast Fighter [TUT] [SRL-Stats]
    If you PM me with a stupid question or one listed in FAQ I will NOT respond. -Narcle
    Summer = me busy, won't be around much.

  3. #3
    Join Date
    Feb 2012
    Location
    Somewhere, over the rainbow...
    Posts
    2,272
    Mentioned
    3 Post(s)
    Quoted
    45 Post(s)

    Default

    Quote Originally Posted by elpreda View Post
    I didn't try DTMs because i thought they would be useless for the main screen.
    Who told you that? I've never had problems using DTM's to recognise items/objects on the main screen.

  4. #4
    Join Date
    Feb 2007
    Location
    PA, USA
    Posts
    5,240
    Mentioned
    36 Post(s)
    Quoted
    496 Post(s)

    Default

    is TPA's, possible multiple TPA's with different colors and ensure they're within x pixels of each other.

  5. #5
    Join Date
    May 2012
    Posts
    18
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks for the quick replies.
    I tried to narrow the search area using the minimap. I searched for red spot on the minimap, translated them with MMtoMS, used ACA on bones and searched with FindObjectEx in an 40 pixel radius of the point returned by MMtoMS. The problem however is that MMtoMS always returns (-1,-1). I checked the coordinates transmited and they were valid. I looked at GridCoords16Ex but I don't know the way how the map is built so I couldn't really make anythinig of it.

  6. #6
    Join Date
    Feb 2007
    Location
    PA, USA
    Posts
    5,240
    Mentioned
    36 Post(s)
    Quoted
    496 Post(s)

    Default

    Quote Originally Posted by elpreda View Post
    Thanks for the quick replies.
    I tried to narrow the search area using the minimap. I searched for red spot on the minimap, translated them with MMtoMS, used ACA on bones and searched with FindObjectEx in an 40 pixel radius of the point returned by MMtoMS. The problem however is that MMtoMS always returns (-1,-1). I checked the coordinates transmited and they were valid. I looked at GridCoords16Ex but I don't know the way how the map is built so I couldn't really make anythinig of it.
    mind posting the code you're using? I'm sure we can all help you much better if we can see into your mind(code).

  7. #7
    Join Date
    May 2012
    Posts
    18
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Code:
     procedure main;
    var x,y,auto,ox,oy: Integer;
        first :boolean;
        spoint :Tpoint;
    begin
        while (true) do
        begin
            Antiban;
            AntiRandoms;
            if FindColorSpiralTolerance(x, y, 12369349, MIX1, MIY1, MIX2, MIY2, 10)  then
            begin
            Mouse(x, y, 4, 4, True);
            Wait(700);
            end;
    
            auto := ColorBone;
            if FindColorSpiralTolerance(x, y, 1840372, MMX1, MMY1, MMX2, MMY2, 70)  then
            begin
                spoint:=MMtoMS(Point(x,y));
                writeln(IntToStr(spoint.x)+'  '+IntToStr(spoint.y));
                writeln(IntToStr(max(spoint.x - 40,0))+'  '+IntToStr(max(0,spoint.y - 40))+'  '+IntToStr(max(0,spoint.x + 40))+'  '+IntToStr(max(0,spoint.y + 40)));
                FindObjEx(ox,oy,['on','es'],[auto],10,50,max(spoint.x - 40,0),max(0,spoint.y - 40),max(0,spoint.x + 40) ,max(0,spoint.y + 40));
                writeln(IntToStr(ox)+'  '+ IntToStr(oy));
                Mouse(ox, oy, 4, 4, True);
                Wait(6000);
            end;
        end;
    end;

  8. #8
    Join Date
    Feb 2007
    Location
    PA, USA
    Posts
    5,240
    Mentioned
    36 Post(s)
    Quoted
    496 Post(s)

    Default

    Simba Code:
    function FindEleBal(var x, y: integer): boolean;
    var
      YelDots: TPointArray;
      MSdot: TPoint;
    begin
      YelDots := GetMiniMapDots('y');
      if Length(YelDots) < 1 then EXIT;

      SortTPAFrom(YelDots, Point(MMCX, MMCY));

      MSdot := MMtoMS(YelDots[0]);
      result := FindColorTolerance(x, y, 11580598, MSdot.x-45, MSdot.y-45, MSdot.x+45, MSdot.y+45, 27);

    end;

    That is how I find the elemental balance in a POH by searching first for the yellow dot on the MM and converting that point into a main screen point.

    Try using something similar except obviously red dots as opposed to yellow. If you need info on what params getMinimapDots accepts look in the include

  9. #9
    Join Date
    May 2012
    Posts
    18
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I used the GetMiniMapDots function and it seems to work, though it still finds and clicks spots far away from any red dots on the minimap. Still, it does collect bones this way.
    However there seems to be a new problem, i am getting an error about DTM's. I haven't used any DTMs in this script so I asume it's some function.
    I am getting the error on this line:
    Code:
    spoint:=MMtoMS(reds[i]);
    the error message is:

    Code:
    Error: Out Of Range at line 115
    The following DTMs were not freed: [SRL - Lamp bitmap, 1]
    The following bitmaps were not freed: [SRL - Mod bitmap, SRL - Admin bitmap, SRL - Flag bitmap]

  10. #10
    Join Date
    Feb 2007
    Location
    PA, USA
    Posts
    5,240
    Mentioned
    36 Post(s)
    Quoted
    496 Post(s)

    Default

    Quote Originally Posted by elpreda View Post
    I used the GetMiniMapDots function and it seems to work, though it still finds and clicks spots far away from any red dots on the minimap. Still, it does collect bones this way.
    However there seems to be a new problem, i am getting an error about DTM's. I haven't used any DTMs in this script so I asume it's some function. I am getting the error on this line:
    Code:
    spoint:=MMtoMS(reds[i]);
    the error message is:

    Code:
    Error: Out Of Range at line 115
    The following DTMs were not freed: [SRL - Lamp bitmap, 1]
    The following bitmaps were not freed: [SRL - Mod bitmap, SRL - Admin bitmap, SRL - Flag bitmap]
    the dtm thing isn't an error, it's just letting you know that the script crashed and those dtms were not freed so it freed them for you.

    Your error is an out of range error, you're trying to access something in the array that isn't there.
    If you post your code i can point it out.

  11. #11
    Join Date
    May 2012
    Posts
    18
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I see, so it's basically a segmentation fault. I checked the code and found the problem, fixed it and it seems to be running well. Thank you for your help.
    Now I need to figure out how to check when the inventory is full so I don't have to bury every bone when I find it, make a progress report and tidy up the code a bit.

  12. #12
    Join Date
    Feb 2007
    Location
    PA, USA
    Posts
    5,240
    Mentioned
    36 Post(s)
    Quoted
    496 Post(s)

    Default

    Quote Originally Posted by elpreda View Post
    I see, so it's basically a segmentation fault. I checked the code and found the problem, fixed it and it seems to be running well. Thank you for your help.
    Now I need to figure out how to check when the inventory is full so I don't have to bury every bone when I find it, make a progress report and tidy up the code a bit.
    there is a function in the include for to see if your inventory is full.
    Actually. the function is simply: InvFull

    so you could is it like so:

    Simba Code:
    if InvFull then BuryBones;
    where BuryBones is your procedure to bury bones.

  13. #13
    Join Date
    Feb 2006
    Location
    Canada
    Posts
    2,254
    Mentioned
    21 Post(s)
    Quoted
    238 Post(s)

    Default

    I find InvFull to not always be accurate, I'd suggest

    If finddtm(bonedtm, etc...) then Bury

    And just have it search for the bonedtm in the last inv spot.
    Or, just have it search the whole inv and bury every time you pick one up, both ways are probably as efficient.

  14. #14
    Join Date
    Feb 2007
    Location
    PA, USA
    Posts
    5,240
    Mentioned
    36 Post(s)
    Quoted
    496 Post(s)

    Default

    Quote Originally Posted by cause View Post
    I find InvFull to not always be accurate, I'd suggest

    If finddtm(bonedtm, etc...) then Bury

    And just have it search for the bonedtm in the last inv spot.
    Or, just have it search the whole inv and bury every time you pick one up, both ways are probably as efficient.
    invfull just loops through each inv slot and runs an itemexists on it.
    I don't see how it could possibly fail... and if it EVER does we have a huge issue meaning itemexists isn't working...

    invfull has never failed me.

  15. #15
    Join Date
    May 2012
    Posts
    18
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Ok, I finished the bury function, I made some failsafes in case it wanders away from the Chaos Temple making it return if it's not too far away and I made the report progress too. I'm going to let it run for the night and tomorrow, if everything goes alright, i am going to post it.

  16. #16
    Join Date
    Feb 2007
    Location
    PA, USA
    Posts
    5,240
    Mentioned
    36 Post(s)
    Quoted
    496 Post(s)

    Default

    Quote Originally Posted by elpreda View Post
    Ok, I finished the bury function, I made some failsafes in case it wanders away from the Chaos Temple making it return if it's not too far away and I made the report progress too. I'm going to let it run for the night and tomorrow, if everything goes alright, i am going to post it.
    awesome man!
    make sure to post a link here I wanna see/critique

Thread Information

Users Browsing this Thread

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

Tags for this Thread

Posting Permissions

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