Results 1 to 12 of 12

Thread: Fighting.scar Addition / Fix

  1. #1
    Join Date
    Nov 2007
    Location
    46696E6C616E64
    Posts
    3,069
    Mentioned
    44 Post(s)
    Quoted
    302 Post(s)

    Default Fighting.scar Addition / Fix

    Ok so i noticed InFight did not work all the times and gave false results when i was not fighting.

    Heres a function i made:
    SCAR Code:
    function InFight: Boolean;
    var GTPA, RTPA: TPointArray;
    begin
      FindColorsTolerance( GTPA, 49499, MSCX - 20, MSCY - 30, MSCX + 20, MSCY - 10, 20 );
      FindColorsTolerance( RTPA, 590010, MSCX - 20, MSCY - 30, MSCX + 20, MSCY - 10, 20 );
      Result := ( ( GetArrayLength( GTPA ) + GetArrayLength( RTPA ) ) >= 20 );
    end;
    Last edited by Frement; 02-08-2010 at 06:46 AM.
    There used to be something meaningful here.

  2. #2
    Join Date
    Apr 2007
    Location
    Melbourne, Aus
    Posts
    202
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    yeh looks good. but the dimensions are too far out.
    maybe this:
    SCAR Code:
    function InFight: Boolean;
    var GTPA, RTPA: TPointArray;
    begin
      FindColorsTolerance(GTPA, 49499,  MSCX-5, MSCY-40, MSCX+5, MSCY-5, 25);
      FindColorsTolerance(RTPA, 590010,  MSCX-5, MSCY-40, MSCX+5, MSCY-5, 25);
      Result := ((GetArrayLength(GTPA) + GetArrayLength(RTPA)) >= 20);
    end;
    Last edited by jimmy_mac; 02-08-2010 at 02:51 AM.

  3. #3
    Join Date
    Nov 2007
    Location
    46696E6C616E64
    Posts
    3,069
    Mentioned
    44 Post(s)
    Quoted
    302 Post(s)

    Default

    Quote Originally Posted by jimmy_mac View Post
    yeh looks good. but the dimensions are too far out.
    maybe this:
    SCAR Code:
    function InFight: Boolean;
    var GTPA, RTPA: TPointArray;
    begin
      FindColorsTolerance(GTPA, 49499,  MSCX-5, MSCY-40, MSCX+5, MSCY-5, 25);
      FindColorsTolerance(RTPA, 590010,  MSCX-5, MSCY-40, MSCX+5, MSCY-5, 25);
      Result := ((GetArrayLength(GTPA) + GetArrayLength(RTPA)) >= 20);
    end;
    The dimensions are good, If the mob your are fighting is north from you and someone else is hitting it too, your hits to it might go over the hp bar. Then it wouldnt find that many colors and it would fail on it.

    Heres an image indicating my search area and yours:
    Last edited by Frement; 02-08-2010 at 06:36 AM.
    There used to be something meaningful here.

  4. #4
    Join Date
    Apr 2007
    Location
    Melbourne, Aus
    Posts
    202
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    ok. those were just rough estimates. which seemed to work. but your original code detects others fighting nearby you which results in a false positive. maybe use dtms. unless you can make it more accurate.

  5. #5
    Join Date
    Nov 2007
    Location
    46696E6C616E64
    Posts
    3,069
    Mentioned
    44 Post(s)
    Quoted
    302 Post(s)

    Default

    I tested it several times and i did not notice that kind of effect, and i cant even see how it could.

    EDIT: Made the box 40x20 and it seems to work nicely now. Still not detecting fights near me.
    SCAR Code:
    function InFight: Boolean;
    var GTPA, RTPA: TPointArray;
    begin
      FindColorsTolerance( GTPA, 49499, MSCX - 20, MSCY - 30, MSCX + 20, MSCY - 10, 20 );
      FindColorsTolerance( RTPA, 590010, MSCX - 20, MSCY - 30, MSCX + 20, MSCY - 10, 20 );
      Result := ( ( GetArrayLength( GTPA ) + GetArrayLength( RTPA ) ) >= 20 );
    end;
    Last edited by Frement; 02-08-2010 at 06:45 AM.
    There used to be something meaningful here.

  6. #6
    Join Date
    Apr 2007
    Location
    Melbourne, Aus
    Posts
    202
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Just tested yours then your y-range is out, it needs to be greater than 30 pixels, i think 46 pixels from the center is the greatest i have found. still checking tho.
    for example with your code, this is a false positive:

  7. #7
    Join Date
    Nov 2007
    Location
    46696E6C616E64
    Posts
    3,069
    Mentioned
    44 Post(s)
    Quoted
    302 Post(s)

    Default

    True, and my mistake was not to check those angles, i only checked on N, E, S, W.

    EDIT: This is what i got so far and it seems to work:
    SCAR Code:
    function InFight: Boolean;
    var GTPA, RTPA: TPointArray;
    begin
      FindColorsTolerance( GTPA, 49499, MSCX - 15, MSCY - 40, MSCX + 15, MSCY, 20 );
      FindColorsTolerance( RTPA, 590010, MSCX - 15, MSCY - 40, MSCX + 15, MSCY, 20 );
      Result := ( ( GetArrayLength( GTPA ) + GetArrayLength( RTPA ) ) >= 20 );
    end;
    EDIT2: Maybe use PixelShift also? If it finds the hp bar it would check pixels that change in MSCX+5, MSCY+5,MSCX-5, MSCY-5?
    Last edited by Frement; 02-08-2010 at 07:11 AM.
    There used to be something meaningful here.

  8. #8
    Join Date
    Apr 2007
    Location
    Melbourne, Aus
    Posts
    202
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    dont the bars stay in the same spot no matter which direction your facing?

  9. #9
    Join Date
    Nov 2007
    Location
    46696E6C616E64
    Posts
    3,069
    Mentioned
    44 Post(s)
    Quoted
    302 Post(s)

    Default

    Nope, you can try rotating the angle when near a fight.
    There used to be something meaningful here.

  10. #10
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,488
    Mentioned
    3 Post(s)
    Quoted
    12 Post(s)

    Default

    I had a look at my cow fighter just now, for which I developed a different InFight. This was before the HP bar update, buth concept can still be used.

    Get a TPA of the green part ofthe HP bar 100 pc around you. (x- 100, x + 100, y - 100, y + 100)

    TPAToATPA
    And the sort the TPAs fro mthe distance to you. Then it's jsut a questin of finding the rght distance.

    The main advantage of this is that it only checks the green part. The HP bar after dead still hangs there for a while, returning a false positive when the NPC is already dead.

    ~RM

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

  11. #11
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    Quote Originally Posted by Rasta Magician View Post
    I had a look at my cow fighter just now, for which I developed a different InFight. This was before the HP bar update, buth concept can still be used.

    Get a TPA of the green part ofthe HP bar 100 pc around you. (x- 100, x + 100, y - 100, y + 100)

    TPAToATPA
    And the sort the TPAs fro mthe distance to you. Then it's jsut a questin of finding the rght distance.

    The main advantage of this is that it only checks the green part. The HP bar after dead still hangs there for a while, returning a false positive when the NPC is already dead.

    ~RM
    Something like this..?
    SCAR Code:
    function N_InFight: Boolean;
    var
      Arr: array of TPoint;
    begin
      FindColorsSpiralTolerance(MSCx, MSCy, Arr, 51837, MSCx - 100, MSCy - 75, MSCx + 100, MSCy + 75, 8);
      if Length(Arr) = 0 then
        Exit;
      RemoveDistTPointArray(MSCx, MSCy, 70, Arr, True);
      Result := (Length(Arr) > 1);
    end;
    It has worked everytime for me so far. The color should be set to a constant in SRL though, IMO at least.

  12. #12
    Join Date
    Jan 2007
    Posts
    834
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by NCDS View Post
    Something like this..?
    SCAR Code:
    function N_InFight: Boolean;
    var
      Arr: array of TPoint;
    begin
      FindColorsSpiralTolerance(MSCx, MSCy, Arr, 51837, MSCx - 100, MSCy - 75, MSCx + 100, MSCy + 75, 8);
      if Length(Arr) = 0 then
        Exit;
      RemoveDistTPointArray(MSCx, MSCy, 70, Arr, True);
      Result := (Length(Arr) > 1);
    end;
    It has worked everytime for me so far. The color should be set to a constant in SRL though, IMO at least.
    Tested it, worked from start to end perfectly. I also posted a thread about this but it fell to the bottom and this one was made. :l

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
  •