Results 1 to 15 of 15

Thread: FindFire(var FX, FY:Integer):Boolean;

  1. #1
    Join Date
    Oct 2006
    Location
    C:\Program Files\SCAR 2.03
    Posts
    1,194
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default FindFire(var FX, FY:Integer):Boolean;

    Well... after a lot of FindFire functions failing, working, sometimes working, finding other things, and not working in the least bit I think I've found a very solid FindFire function. Me and Sky Scripter have been kind of "battling" to see who can make the best Findfire function. Because mine works for me and his works for him, but they both don't work good for each other, so we ended up remaking them over.. and over.. so I think I've finally got it.

    It doesn't work at all angles because I was just testing it at square angles. N,S,E,W. But to make it work at all angles I think I'd just have to use FindDTMRotated oh well... Also remember to tell me how it worked, or any ideas you have on improving it.

    Here it is!
    *Also I think I am the first person to use "Array of Boolean" Lol .*

    SCAR Code:
    function FindFire(var FX, FY:Integer):Boolean;
    var ZX, ZY, Fx1, Fx2, Fy1, Fy2, i:Integer;
    var Slope:Extended;
    var FireDTM:Array[0..3] of Integer;
    var FireResult:Array[0..3] of Boolean;
    var Coords:Array[0..3] of TPoint;
    var Fire:TPoint;
    begin
      FireDTM[0]:= DTMFromString('78DA6374606460D8C98002ACF41818B880345' +
           '086E13F10309A01599B70AB0101460F206B337E350032480838');
      FireDTM[1]:= DTMFromString('78DA6334636460D8C48002ACF41818B880342' +
           '394CFE801646D26A0C613C85A855B0D08030006B50437');
      FireDTM[2]:= DTMFromString('78DA6334636460D8C48002ACF41818B880342' +
           '394CFE801646D26A0C602C85A8D5F0D00047D0426');
      FireDTM[3]:= DTMFromString('78DA63B467646058CC8002ACF41818B880345' +
           '086E13F10309A0359AB71AB0101464F206B157E350026810813');
      Fx1:= MSX1;
      Fy1:= MSY1;
      Fx2:= MSX2;
      Fy2:= MSY2;
        for i:= 0 to 3 do
          begin
            if(FindDTM(FireDTM[i], Fx, Fy, Fx1, Fy1, Fx2, Fy2))then
              begin
                Coords[i].x:= Fx;
                Coords[i].y:= Fy;
                ZX:= Fx;
                ZY:= Fy;
                Fx1:= (Fx - 30);
                Fy1:= (Fy - 30);
                Fx2:= (Fx + 30);
                Fy2:= (Fy + 30);
                FireResult[i]:= True;
                Writeln('Fire[' + inttostr(i) + '] = True');
              end else
                begin
                if(i = 0)then
                  begin
                    Coords[0].x:= 0;
                    Coords[0].y:= 0;
                  end else
                    begin
                      Coords[i].x:= Coords[(i - 1)].x;
                      Coords[i].y:= Coords[(i - 1)].y;
                      FireResult[i]:= False;
                      Writeln('Fire[' + inttostr(i) + '] = False');
                    end;
                end;
          end;
      if(FireResult[0] or FireResult[1] or FireResult[2] or FireResult[3])then Result:= True else
      Result:= False;
      Fire:= MdPtOfArray(Slope,Coords);
      Writeln('Fire[0].x:= ' + inttostr(Coords[0].x));
      Writeln('Fire[0].y:= ' + inttostr(Coords[0].y));
      Writeln('Fire[1].x:= ' + inttostr(Coords[1].x));
      Writeln('Fire[1].y:= ' + inttostr(Coords[1].y));
      Writeln('Fire[2].x:= ' + inttostr(Coords[2].x));
      Writeln('Fire[2].y:= ' + inttostr(Coords[2].y));
      Writeln('Fire[3].x:= ' + inttostr(Coords[3].x));
      Writeln('Fire[3].y:= ' + inttostr(Coords[3].y));
      FX:= Fire.x;
      FY:= Fire.y;
      FreeDTM(FireDTM[0]);
      FreeDTM(FireDTM[1]);
      FreeDTM(FireDTM[2]);
      FreeDTM(FireDTM[3]);
    end;

    If all of the DTM's turn up False please let me know, I don't think I set the tolerance high enough...

    EDIT: Apparently it does work at all angles, a few people that have tested it have gotten it to work at all angles and it does seems to work for me too XD. What a bonus!
    [FONT="Garamond"][SIZE="3"]
    Yes, I am a criminal. My crime is that of curiosity. My crime is that of judging people by what they say and think, not what they look like. My crime is that of outsmarting you, something that you will never forgive me for.
    [/SIZE][/FONT][URL="http://www.villavu.com/forum/forumdisplay.php?f=125"][IMG]http://i40.tinypic.com/r1lzdv.jpg[/IMG][/URL]

  2. #2
    Join Date
    Jan 2007
    Location
    Kansas
    Posts
    3,760
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    Was this half for MSI?


  3. #3
    Join Date
    Oct 2006
    Location
    C:\Program Files\SCAR 2.03
    Posts
    1,194
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Yes it's for MSI I just need some testers, before I commit.
    [FONT="Garamond"][SIZE="3"]
    Yes, I am a criminal. My crime is that of curiosity. My crime is that of judging people by what they say and think, not what they look like. My crime is that of outsmarting you, something that you will never forgive me for.
    [/SIZE][/FONT][URL="http://www.villavu.com/forum/forumdisplay.php?f=125"][IMG]http://i40.tinypic.com/r1lzdv.jpg[/IMG][/URL]

  4. #4
    Join Date
    Dec 2006
    Location
    utah
    Posts
    1,427
    Mentioned
    2 Post(s)
    Quoted
    7 Post(s)

    Default

    i still think mine works better...

    mine works for all bright settings.. not just very bright...
    and your has miss clicked several times before.... mine is dead on the fire...
    Also mine works all Angles.....

    actually try them Special Ed.. dont just say your is better i have spent.. alot of time on yours and mine, trying to finds bugs... and i will ammit i have found one bug in mine... Very RARLY.. it will not find the fire.. but it has never click anything else but the flame of the fire...

    You find this a game...? Please.. Test Them Both!!!!

    Thanks.

    Oh Yeah Heres Mine...

    SCAR Code:
    Function FindFire(Var x, y : Integer) : Boolean;
    Var
      DTM : TDTM;
      NewDTM, i : Integer;
      Angle : Extended;

    begin
    ColorToleranceSpeed(2);

    DTM.MainPoint.Color := 4505332;
    DTM.MainPoint.Tolerance := 20;
    DTM.MainPoint.x := 225;
    DTM.MainPoint.y := 166;

    SetArrayLength(DTM.SubPoints, 3);

    DTM.SubPoints[0].Color := 12348;
    DTM.SubPoints[0].Tolerance := 20;
    DTM.SubPoints[0].x := 223;
    DTM.SubPoints[0].y := 174;

    DTM.SubPoints[1].Color := 12348;
    DTM.SubPoints[1].Tolerance := 20;
    DTM.SubPoints[1].x := 234;
    DTM.SubPoints[1].y := 162;

    DTM.SubPoints[2].Color := 12348;
    DTM.SubPoints[2].Tolerance := 20;
    DTM.SubPoints[2].x := 217;
    DTM.SubPoints[2].y := 160;

    NewDTM := AddDTM(DTM);
     For i := 1 to 2 do
     begin
      Result := (FindDTMRotated(NewDTM, x, y, 5, 5, 510, 320, 0.0, 6.28, 0.1, Angle));
         If Result Then Break;
         Wait(500);
     end;
    ColorToleranceSpeed(1);
    FreeDTM(NewDTM);
    end;

  5. #5
    Join Date
    Jun 2006
    Posts
    3,861
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Whoa SKy, don't get all mad... yours never worked properly for me either. Special's has never misclicked for me. Yours would sometimes find daises, if I'm not mistaken.

  6. #6
    Join Date
    Oct 2006
    Location
    C:\Program Files\SCAR 2.03
    Posts
    1,194
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I didn't say it was better I said that I think I've gotten a good formula down, and I could make it work at all angles and all brightness levels I'm just testing it on this one to make sure it works. I've update it to work with all later, I've only seen mine misclick once, and that was because there was only half a fire. I'm not trying to say mines better than yours I was just asking for people to test it for me.

    PS - Yes this is a game to me XP.
    [FONT="Garamond"][SIZE="3"]
    Yes, I am a criminal. My crime is that of curiosity. My crime is that of judging people by what they say and think, not what they look like. My crime is that of outsmarting you, something that you will never forgive me for.
    [/SIZE][/FONT][URL="http://www.villavu.com/forum/forumdisplay.php?f=125"][IMG]http://i40.tinypic.com/r1lzdv.jpg[/IMG][/URL]

  7. #7
    Join Date
    Dec 2006
    Location
    utah
    Posts
    1,427
    Mentioned
    2 Post(s)
    Quoted
    7 Post(s)

    Default

    Whoa SKy, don't get all mad... yours never worked properly for me either. Special's has never misclicked for me. Yours would sometimes find daises, if I'm not mistaken.
    Ok, Lol But i dont believe the daisy part....

    I didn't say it was better I said that I think I've gotten a good formula down, and I could make it work at all angles and all brightness levels I'm just testing it on this one to make sure it works. I've update it to work with all later, I've only seen mine misclick once, and that was because there was only half a fire. I'm not trying to say mines better than yours I was just asking for people to test it for me.

    PS - Yes this is a game to me XP.
    Sorry, i took it well that you were saying yours was better... Once Again im sorry.. i just dont feel you spent enough time testing them... but Good Job

  8. #8
    Join Date
    Jun 2006
    Posts
    3,861
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Dunno, it was somebody's that found daises...

  9. #9
    Join Date
    Oct 2006
    Location
    C:\Program Files\SCAR 2.03
    Posts
    1,194
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Hey it not like we're against each other or anything Sky, I'm try trying to find the best way possible to do this. I've tried your a few time but for some reason it didn't work for me, probably something on my part but I'd just assume doing it myself. Also I wanted to experiment with arrays and Tpoints so it looked like a good way to do that.

    Oh for anyone who wants to test, I got a newer version, works better, doesn't miss... *I don't think* but again let me know if it can't find any of the DTM due to color tolerance, ect. But even if it cant find 1 or 2 it should still work fine.

    SCAR Code:
    program New;
    {.include SRL/SRL.scar}

    function MidPoint(X1, Y1, X2, Y2: Integer): TPoint;
    var
      MidX, MidY: Integer;
      IntStr: String;
    begin
      MidX:= (X1 + X2) div 2;
      IntStr:= IntToStr(MidX);
      Delete(IntStr, Pos('-', IntStr), 1);
      MidX:= StrToInt(IntStr);
      MidY:= (Y1 + Y2) div 2;
      IntStr:= IntToStr(MidY);
      Delete(IntStr, Pos('-', IntStr), 1);
      MidY:= StrToInt(IntStr);
      Result.X:= MidX;
      Result.Y:= MidY;
    end;

    function FindFire(var FX, FY:Integer):Boolean;
    var ZX, ZY, Fx1, Fx2, Fy1, Fy2, i:Integer;
    var FireDTM:Array[0..3] of Integer;
    var FireResult:Array[0..3] of Boolean;
    var Coords:Array[0..3] of TPoint;
    var FireMidPoint:Array[0..2] of TPoint;
    begin
      FireDTM[0]:= DTMFromString('78DA6394606460D8C28002ACF51918B880345' +
           '086E13F1030F20159BB70AB01014605206B377E3500134207D1');
      FireDTM[1]:= DTMFromString('78DA631463646038CD8002ACF51918B880345' +
           '086E13F1030F202594770AB0101460520EB287E35001F3A07F9');
      FireDTM[2]:= DTMFromString('78DA63E465646038C28002ACF51918B880345' +
           '086E13F10302A00594771AB0101B09A3DF8D500001D1707F4');
      FireDTM[3]:= DTMFromString('78DA6354606460D8C38002ACF51918B880345' +
           '086E13F103082D41CC1AD060418F980AC5DF8D500001ED907EA');
      Fx1:= MSX1;
      Fy1:= MSY1;
      Fx2:= MSX2;
      Fy2:= MSY2;
        for i:= 0 to 3 do
          begin
            if(FindDTM(FireDTM[i], Fx, Fy, Fx1, Fy1, Fx2, Fy2))then
              begin
                Coords[i].x:= Fx;
                Coords[i].y:= Fy;
                ZX:= Fx;
                ZY:= Fy;
                Fx1:= (Fx - 30);
                Fy1:= (Fy - 30);
                Fx2:= (Fx + 30);
                Fy2:= (Fy + 30);
                FireResult[i]:= True;
                Writeln('Fire[' + inttostr(i) + '] = True');
              end else
                begin
                if(i = 0)then
                  begin
                    Coords[0].x:= 0;
                    Coords[0].y:= 0;
                    Writeln('Fire[' + inttostr(i) + '] = 0');
                  end else
                    begin
                      Coords[i].x:= Coords[(i - 1)].x;
                      Coords[i].y:= Coords[(i - 1)].y;
                      FireResult[i]:= False;
                      Writeln('Fire[' + inttostr(i) + '] = False');
                    end;
                end;
          end;
      if(FireResult[0] or FireResult[1] or FireResult[2] or FireResult[3])then Result:= True else
      Result:= False;
      Writeln('Fire[0].x:= ' + inttostr(Coords[0].x));
      Writeln('Fire[0].y:= ' + inttostr(Coords[0].y));
      Writeln('Fire[1].x:= ' + inttostr(Coords[1].x));
      Writeln('Fire[1].y:= ' + inttostr(Coords[1].y));
      Writeln('Fire[2].x:= ' + inttostr(Coords[2].x));
      Writeln('Fire[2].y:= ' + inttostr(Coords[2].y));
      Writeln('Fire[3].x:= ' + inttostr(Coords[3].x));
      Writeln('Fire[3].y:= ' + inttostr(Coords[3].y));
      FireMidPoint[0]:= MidPoint(Coords[0].x, Coords[0].y, Coords[1].x, Coords[1].y);
      FireMidPoint[1]:= MidPoint(Coords[2].x, Coords[2].y, Coords[3].x, Coords[3].y);
      FireMidPoint[2]:= MidPoint(FireMidPoint[0].x, FireMidPoint[0].y, FireMidPoint[1].x, FireMidPoint[1].y);
      FX:= FireMidPoint[2].x;
      FY:= FireMidPoint[2].y;
      FreeDTM(FireDTM[0]);
      FreeDTM(FireDTM[1]);
      FreeDTM(FireDTM[2]);
      FreeDTM(FireDTM[3]);
    end;

    begin
    SetupSRL;
    FindFire(x, y);
    MMouse(x, y, 0, 0);
    end.

    @ Sky: Hey I did some more testing with yours and mine, yours works phenomenally well.. good job but one problem I noticed is that it can only find it if the fire is 100% in view, mostly unobstructed. It works good if your not around a lot of people but for this situation it might miss the fire if someone is standing on it or leaning over it "cooking". Thats kind of an answer to your question / statement about me using the 4 DTM's I made them small so that they don't lag and I made them in different spot so that if someone is standing on the fire or cooking it still can be found. Sorry if it sounds like I'm bashing you but it's just me trying to get my point across...

    PS: Has anyone tested this YET!!!!
    [FONT="Garamond"][SIZE="3"]
    Yes, I am a criminal. My crime is that of curiosity. My crime is that of judging people by what they say and think, not what they look like. My crime is that of outsmarting you, something that you will never forgive me for.
    [/SIZE][/FONT][URL="http://www.villavu.com/forum/forumdisplay.php?f=125"][IMG]http://i40.tinypic.com/r1lzdv.jpg[/IMG][/URL]

  10. #10
    Join Date
    Dec 2006
    Location
    utah
    Posts
    1,427
    Mentioned
    2 Post(s)
    Quoted
    7 Post(s)

    Default

    Lol, Thanks Dude i Feel Better i dont care Whos FindFire is on now just as long as it works, lol... Nice Job

    Sorry Again... Please dont find me as a enemy...

  11. #11
    Join Date
    Oct 2006
    Location
    C:\Program Files\SCAR 2.03
    Posts
    1,194
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by SKy Scripter View Post
    Lol, Thanks Dude i Feel Better i dont care Whos FindFire is on now just as long as it works, lol... Nice Job

    Sorry Again... Please dont find me as a enemy...
    Hey man its cool, but I was thinking, maybe we could combine the functions, first it would search for yours then if it couldn't find it it would use mine, or do you think that would just create a lot of lag?
    [FONT="Garamond"][SIZE="3"]
    Yes, I am a criminal. My crime is that of curiosity. My crime is that of judging people by what they say and think, not what they look like. My crime is that of outsmarting you, something that you will never forgive me for.
    [/SIZE][/FONT][URL="http://www.villavu.com/forum/forumdisplay.php?f=125"][IMG]http://i40.tinypic.com/r1lzdv.jpg[/IMG][/URL]

  12. #12
    Join Date
    Jun 2006
    Posts
    3,861
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    I think that would work good. Lag maybe, but safer.

  13. #13
    Join Date
    Dec 2006
    Location
    utah
    Posts
    1,427
    Mentioned
    2 Post(s)
    Quoted
    7 Post(s)

    Default

    Hey man its cool, but I was thinking, maybe we could combine the functions, first it would search for yours then if it couldn't find it it would use mine, or do you think that would just create a lot of lag?
    Yeah... considering mine is a strict FindFire
    you would just have to change mine to this for less lagg....

    SCAR Code:
    Function FindFire(Var x, y : Integer) : Boolean;
    Var
      DTM : TDTM;
      NewDTM : Integer;
      Angle : Extended;
     
    begin
    ColorToleranceSpeed(2);
     
    DTM.MainPoint.Color := 4505332;
    DTM.MainPoint.Tolerance := 20;
    DTM.MainPoint.x := 225;
    DTM.MainPoint.y := 166;
     
    SetArrayLength(DTM.SubPoints, 3);
     
    DTM.SubPoints[0].Color := 12348;
    DTM.SubPoints[0].Tolerance := 20;
    DTM.SubPoints[0].x := 223;
    DTM.SubPoints[0].y := 174;
     
    DTM.SubPoints[1].Color := 12348;
    DTM.SubPoints[1].Tolerance := 20;
    DTM.SubPoints[1].x := 234;
    DTM.SubPoints[1].y := 162;
     
    DTM.SubPoints[2].Color := 12348;
    DTM.SubPoints[2].Tolerance := 20;
    DTM.SubPoints[2].x := 217;
    DTM.SubPoints[2].y := 160;
    NewDTM := AddDTM(DTM);
      Result := (FindDTMRotated(NewDTM, x, y, 5, 5, 510, 320, 0.0, 6.28, 0.1, Angle));
    ColorToleranceSpeed(1);
    FreeDTM(NewDTM);
    end;

  14. #14
    Join Date
    Oct 2006
    Location
    C:\Program Files\SCAR 2.03
    Posts
    1,194
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Hey any idea oh how to make it search from the center of the mainscreen out? Effectively of course...
    [FONT="Garamond"][SIZE="3"]
    Yes, I am a criminal. My crime is that of curiosity. My crime is that of judging people by what they say and think, not what they look like. My crime is that of outsmarting you, something that you will never forgive me for.
    [/SIZE][/FONT][URL="http://www.villavu.com/forum/forumdisplay.php?f=125"][IMG]http://i40.tinypic.com/r1lzdv.jpg[/IMG][/URL]

  15. #15
    Join Date
    Dec 2006
    Location
    utah
    Posts
    1,427
    Mentioned
    2 Post(s)
    Quoted
    7 Post(s)

    Default

    Hey any idea oh how to make it search from the center of the mainscreen out? Effectively of course...
    Somthing Like This

    SCAR Code:
    program New;
    {.include srl/srl.scar}



    function ObjPoints(Var P : TPointArray;  color, tol: Integer): Boolean;
    var
      x, y, a, c, i, x1, y1, x2, y2: Integer;
    begin
    If (Not(FindColorTolerance(x, y, color, 5, 5, 510, 330, tol))) then exit;
        Result := True;
        SetArrayLength(P, 0);
        x1 := 245;
        y1 := 165;
        x2 := 277;
        y2 := 185;
        repeat
            if (not (Loggedin)) then
            Break;
          a := a + 1;
          if (a = 1) or (a = 3) then
            c := c + 1;
          for i := 1 to c do
          begin
            if (a = 1) then
            begin
              x1 := x1 + 30;
              x2 := x2 + 30;
            end else
            if (a = 2) then
            begin
              y1 := y1 - 20;
              y2 := y2 - 20;
            end else
            if (a = 3) then
            begin
              x1 := x1 - 30;
              x2 := x2 - 30;
            end else
            if (a = 4) then
            begin
              y1 := y1 + 20;
              y2 := y2 + 20;
            end;
            if (x1 = 485) and (x2 = 517) then
              x2 := x2 - 2;
            if (y1 = 325) and (y2 = 345) then
              y2 := y2 - 7;
            if (x2 > 515) then
              Break;
            if (FindColorTolerance(x, y, color, x1, y1, x2, y2, tol)) then
            begin
               SetArrayLength(P, GetArrayLength(P)+1);
               P[GetArrayLength(p)-1].x := x;
               P[GetArrayLength(p)-1].y := y;
            end;
          end;
          if (a = 4) then a := 0;
        until (x2 > 515);
    end;


    Function FindFire(Var x, y : Integer) : Boolean;
    Var
      P : TPointArray;
      DTM : TDTM;
      NewDTM, i : Integer;
      Angle : Extended;

    begin
    ColorToleranceSpeed(2);
    If (Not(ObjPoints(P, 4505332, 20))) then
    begin
      ColorToleranceSpeed(1);
      Exit;
    end;

    DTM.MainPoint.Color := 4505332;
    DTM.MainPoint.Tolerance := 20;
    DTM.MainPoint.x := 225;
    DTM.MainPoint.y := 166;

    SetArrayLength(DTM.SubPoints, 3);

    DTM.SubPoints[0].Color := 12348;
    DTM.SubPoints[0].Tolerance := 20;
    DTM.SubPoints[0].x := 223;
    DTM.SubPoints[0].y := 174;

    DTM.SubPoints[1].Color := 12348;
    DTM.SubPoints[1].Tolerance := 20;
    DTM.SubPoints[1].x := 234;
    DTM.SubPoints[1].y := 162;

    DTM.SubPoints[2].Color := 12348;
    DTM.SubPoints[2].Tolerance := 20;
    DTM.SubPoints[2].x := 217;
    DTM.SubPoints[2].y := 160;
    NewDTM := AddDTM(DTM);
    For i := 0 To GetArrayLength(P)-1 do
    begin
      Result := (FindDTMRotated(NewDTM, x, y, P[i].x -30, P[i].y -30, P[i].x +30, P[i].y +30, 0.0, Radians(360), 0.1, Angle));
      If (Result) then Break;
    end;
    ColorToleranceSpeed(1);
    FreeDTM(NewDTM);
    end;




    begin
    SetupSRL;
    FindRS;
    ActivateClient;
    Wait(500);
    if (FindFire(x, y)) then
    MMouse(x, y, 0, 0);
    end.

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
  •