Scar color

Discussion in 'Code Snippets and Tutorials' started by Billy, Mar 20, 2007.

  1. zav75

    zav75 Level I

    Joined:
    Feb 28, 2007
    Messages:
    76
    Likes Received:
    6
    Location:
    Canada, Province of Québec
    I tried to anwser all your questions at once in this code example
    since most of people gave you anwsers with syntaxe/logic errors in (exept for chelsa)

    You can compile it without problem

    Code (Text):
    1. program Example;
    2.  
    3.  
    4. var
    5. x,y,red,cpt,bitmap :integer  ;
    6. ColorFound : Boolean ;
    7.  
    8.  
    9. procedure findColorExample; // find a color in a specified area
    10. begin
    11. red:= 255;
    12.  
    13. //search for the color in the square
    14. //(0,0)-(0,500)-(500,0)-(500,500)
    15. //no other way to use findcolor, must use
    16. //xs,ys,xe,ye
    17. //but you maybe search in a square of 1 pixel
    18.  
    19. ColorFound := FindColor(x,y,red,0,0,500,500) ;
    20.  
    21. if(ColorFound) then
    22. begin
    23.   KeyDown(65); //press key "A"
    24.   wait(15);
    25.   Keyup(65);
    26. end;
    27. end; //end of procedure
    28.  
    29. procedure  getColorExample;
    30. begin
    31. if( getcolor(500,500) = 255 ) then
    32.   begin
    33.   for cpt:= 0 to 1 do
    34.   begin
    35.   Writeln('looping');
    36.   end;
    37.  
    38. end else      //if else example
    39. begin
    40.   KeyDown(65); //press key "A"
    41.   wait(15);
    42.   Keyup(65);
    43. end;
    44.  
    45. end;  //end of procedure
    46.  
    47. procedure FindBitmapExample;
    48. begin
    49. Bitmap :=  BitmapFromString(7, 6, 'z78DA7DCA3912C0200800' +
    50.        'C02FA1A0600911FFFFA41CA670C29866AB157226D532982D49A32' +
    51.        '40E7D3846D9EE39FDFF8CDD29AFEE7EB55E2947018A027C27B6D5' +
    52.        '78DE89875FE77177A627E9E23A72'); //green arrow of scar
    53.        
    54. if( FindBitmap(bitmap,x,y) ) then
    55. begin
    56. Writeln('Bitmap found !');
    57. end;
    58.  
    59. //OR, you can search in a spcified area
    60.  
    61.  
    62. if( FindBitmapIn(bitmap,x,y,0,0,500,500) ) then
    63. begin
    64. Writeln('Bitmap found in the square specified');
    65. end;
    66.  
    67. end;//end of procedure
    68.  
    69. begin //main program
    70. end. //end of main program
    pm me to have my msn email (if you want live conversation)
     
  2. Billy

    Billy Level IV

    Joined:
    Feb 21, 2007
    Messages:
    1,856
    Likes Received:
    39
    ok, wow thank you so much for all of that information. i still have two more questions for this
    Code (Text):
    1. procedure FindBitmapExample;
    2. begin
    3. Bitmap :=  BitmapFromString(7, 6, 'z78DA7DCA3912C0200800' +
    4.        'C02FA1A0600911FFFFA41CA670C29866AB157226D532982D49A32' +
    5.        '40E7D3846D9EE39FDFF8CDD29AFEE7EB55E2947018A027C27B6D5' +
    6.        '78DE89875FE77177A627E9E23A72'); //green arrow of scar
    7.        
    8. if( FindBitmap(bitmap,x,y) ) then
    9. begin
    10. Writeln('Bitmap found !');
    11. end;
    12.  
    do i just put x,y after find bitmap. if not what do i put there (that is for finding a bitmap anywhere on the screen right?). also, for the find color, how do i get it to find similar colors. ill give you an example
    Code (Text):
    1. program New;
    2. begin
    3. case getcolor(x,y) of
    4. 122344// or simalar. how do i say that?// :keydown(74)
    5. 24324321//or similar// :keydown(73)
    6. end.
    how would i say that with the similar? i am pretty sure that it is possible but i am not sure how to do it.
     
  3. chelsea1

    chelsea1 Level IV

    Joined:
    Nov 26, 2006
    Messages:
    2,538
    Likes Received:
    31
    Location:
    London
    nah you don't need to put anything else apart from x and y (or whatever the bitmap's variables are
    if you want it to click the bitmap (as i think you do) just put the code
    Code (Text):
    1. clickmouse(x,y,true)
    after
    Code (Text):
    1. then
    i have no idea whatsoever sorry to that one
     
  4. Billy

    Billy Level IV

    Joined:
    Feb 21, 2007
    Messages:
    1,856
    Likes Received:
    39
    so if i did this
    Code (Text):
    1. procedure FindBitmapExample;
    2. begin
    3. Bitmap :=  BitmapFromString(7, 6, 'z78DA7DCA3912C0200800' +
    4.        'C02FA1A0600911FFFFA41CA670C29866AB157226D532982D49A32' +
    5.        '40E7D3846D9EE39FDFF8CDD29AFEE7EB55E2947018A027C27B6D5' +
    6.        '78DE89875FE77177A627E9E23A72'); //green arrow of scar
    7.        
    8. if( FindBitmap(bitmap,x,y) ) then
    9. begin
    10. clickmouse(x,y);
    11. end;
    then it will click on the bitmap. also, i am sorry if i am asking way too many questions, but dont worry, i am a fast learner.
     
  5. chelsea1

    chelsea1 Level IV

    Joined:
    Nov 26, 2006
    Messages:
    2,538
    Likes Received:
    31
    Location:
    London
    do this instead (just one tiny change
    Code (Text):
    1. FindBitmapExample;
    2. begin
    3. Bitmap :=  BitmapFromString(7, 6, 'z78DA7DCA3912C0200800' +
    4.        'C02FA1A0600911FFFFA41CA670C29866AB157226D532982D49A32' +
    5.        '40E7D3846D9EE39FDFF8CDD29AFEE7EB55E2947018A027C27B6D5' +
    6.        '78DE89875FE77177A627E9E23A72'); //green arrow of scar
    7.        
    8. if( FindBitmap(bitmap,x,y) ) then
    9. clickmouse(x,y);
    10. end;
     
  6. Billy

    Billy Level IV

    Joined:
    Feb 21, 2007
    Messages:
    1,856
    Likes Received:
    39
    aobut the similar color command, i did a little research and it is
    Code (Text):
    1. FindColorTolerance(var x,y: Integer; color, xs, ys, xe, ye: Integer; Tolerance: Integer): Boolean
    but you see, i have no clue how to use it, can you help me?
     
  7. zav75

    zav75 Level I

    Joined:
    Feb 28, 2007
    Messages:
    76
    Likes Received:
    6
    Location:
    Canada, Province of Québec
    Sure this si pretty simple,

    Code (Text):
    1. procedure findColorExample; // find a color in a specified area
    2. begin
    3. red:= 255;
    4.  
    5. //search for the color in the square
    6. //(0,0)-(0,500)-(500,0)-(500,500)
    7. //no other way to use findcolor, must use
    8. //xs,ys,xe,ye
    9. //but you maybe search in a square of 1 pixel
    10.  
    11. ColorFound := FindColorTolerance(x,y,red,0,0,500,500,20) ;//this will search for a color between 235 and 275 because the tolerance is 20
    12.  
    13. if(ColorFound) then
    14. begin
    15.   KeyDown(65); //press key "A"
    16.   wait(15);
    17.   Keyup(65);
    18. end;
    19. end; //end of procedure
     
  8. Billy

    Billy Level IV

    Joined:
    Feb 21, 2007
    Messages:
    1,856
    Likes Received:
    39
    you should become a programmer. also, what about the first set of zeros in the coordinates, why dont you enter anything there. i am guessing that 0,500 is one corner and 500,500 is another corner but i dont understand. please explain xs,ys,xe,ye to me. would deformed bitmap work in a similar way? also, do i enter coordinates where it says x,y?
     
  9. chelsea1

    chelsea1 Level IV

    Joined:
    Nov 26, 2006
    Messages:
    2,538
    Likes Received:
    31
    Location:
    London
    ok so the 0,0,500,500 are the co-ordinates of the box
    the first zero is for the x axis start point and the second zero is for the y value at that point
    the two 500s are the x and y values at the other point
    now with those two points, scar draws lines at right angles to make a box in which scar looks for the color
    does that help?
     
  10. Billy

    Billy Level IV

    Joined:
    Feb 21, 2007
    Messages:
    1,856
    Likes Received:
    39
    yes, but two, well, three, more yhings. first, what do i put in the x,y values, or do i use a variable called x,y there. ok, i just solved my second question, but ill ask it anyways so that box would start in the corner of the screen and go up to a square box of 500 x 500 pixels. i am just making sure that i understand. lastly, does finddeformedbitmap (or something like that) detect color changes too?
     
  11. chelsea1

    chelsea1 Level IV

    Joined:
    Nov 26, 2006
    Messages:
    2,538
    Likes Received:
    31
    Location:
    London
    to your second question, 0,0,500,500 means a box with points at 0,0 0,500 500,0 and 500,500
    to your third question i don't know but look in the list of bitmap functions i posted and it should tell you there
     
  12. Billy

    Billy Level IV

    Joined:
    Feb 21, 2007
    Messages:
    1,856
    Likes Received:
    39
    Code (Text):
    1. function FindDeformedBitmapToleranceIn(bitmap: Integer; var x, y: Integer; x1, y1, x2, y2: Integer; tolerance: Integer; Range: Integer; AllowPartialAccuracy: Boolean; var accuracy: Extended): Boolean; - Works similar to FindBitmapToleranceIn but allows searching for partially covered or transformed bitmaps. If range is 0, it checks pixels at positions that match bitmap we are looking for; if Range ir 1, it checks neighbor pixels as well, if range is bigger, it checks further. AllowPartialAccuracy allows accuracy that is not 100% match. accuracy returns accuracy of found bitmap to bitmap we are looking for. accuracy = 1.0 means it was 100% perfect match.
    2. Example: we are searching for .
    3. 1. Target bitmap:
    4. FindDeformedBitmapToleranceIn(b, x, y, 0, 0, 100, 100, 70, 0, True, acc);
    5. Results: acc = 0.825745682889
    6. FindDeformedBitmapToleranceIn(b, x, y, 0, 0, 100, 100, 70, 1, True, acc);
    7. Results: acc = 1.000000000000
    8. 2. Target bitmap:
    9. FindDeformedBitmapToleranceIn(b, x, y, 0, 0, 100, 100, 70, 0, True, acc);
    10. acc = 0.585557299843
    11. FindDeformedBitmapToleranceIn(b, x, y, 0, 0, 100, 100, 70, 1, True, acc);
    12. acc = 0.751962323391
    this is what it says in the instructions but now i am even more confused
     
  13. chelsea1

    chelsea1 Level IV

    Joined:
    Nov 26, 2006
    Messages:
    2,538
    Likes Received:
    31
    Location:
    London
    lol
    well this is the bit you need to focus on i think
     
  14. zav75

    zav75 Level I

    Joined:
    Feb 28, 2007
    Messages:
    76
    Likes Received:
    6
    Location:
    Canada, Province of Québec
    -yes deformed bitmaps work the same
    -yes its corners

    -with xs,ys,xe,ye a box is created in witch scar operate, the box is built this way

    [​IMG]


    If you noticed well, the x and y axis are not the same as we see often in math, the origine is at the top left of your screen.
     
  15. Billy

    Billy Level IV

    Joined:
    Feb 21, 2007
    Messages:
    1,856
    Likes Received:
    39
    so this would be a good example
    Code (Text):
    1. if FindDeformedBitmapToleranceIn(bitmap1, x, y, 100, 100, 200, 200, 85, 1, true, acc) then
    2. keydown(72);
    what should i put for x,y? a variable named x,y or coordinates?
     
  16. chelsea1

    chelsea1 Level IV

    Joined:
    Nov 26, 2006
    Messages:
    2,538
    Likes Received:
    31
    Location:
    London
    you are trying to find a bitmap so 2 variables
     
  17. Billy

    Billy Level IV

    Joined:
    Feb 21, 2007
    Messages:
    1,856
    Likes Received:
    39
    so this would work
    Code (Text):
    1. program New;
    2. var x: integer;
    3. var y: integer;
    4. var bitmap1: string;
    5. begin
    6. bitmap1 :='213234455412345678901348890134'
    7. if FindDeformedBitmapToleranceIn(bitmap1, x, y, 100, 100, 200, 200, 85, 1, true, acc) then
    8. keydown(72);
    9. end.
    ok, i will tell you what i am (attempting to) making a script for, only if you dont make it your self. i am trying to make one for trouble at national neopean, would i only need to get a bitmap of one of each of the guys and use deformed bitmaps or do i need like 50 bitmaps of each variation of a character?
     
  18. chelsea1

    chelsea1 Level IV

    Joined:
    Nov 26, 2006
    Messages:
    2,538
    Likes Received:
    31
    Location:
    London
    that is a very hard game to make it for and all of the scripts i have tried for it have failed
    i don't know whether or not you need a deformed bitmap or 50 ordinary bitmaps but i would say that you don't need the latter
     
  19. Billy

    Billy Level IV

    Joined:
    Feb 21, 2007
    Messages:
    1,856
    Likes Received:
    39
    what are some games that are possible to make a script for that dont already have a script?
     
  20. zav75

    zav75 Level I

    Joined:
    Feb 28, 2007
    Messages:
    76
    Likes Received:
    6
    Location:
    Canada, Province of Québec
    Mine works with constant colors (there are some on each caracter), but it's not finished yet(do 8-9 level), scar programing is only useful if you want trophies. Else if you want to do a good amount of neopoints you need to work on a badass aber :p or sponsors doer (mine does only 20k).