Results 1 to 9 of 9

Thread: Finding HP Bars

  1. #1
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default Finding HP Bars

    Anyone have a premade function(boolean) that results true if any HP bars are found on the screen?

    The one in SRL doesn't work for right before the enemy dies and the HP bar is all red, I need one that accounts for that.

  2. #2
    Join Date
    Mar 2008
    Location
    Look behind you.
    Posts
    795
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    I'm gonna make a simple bitmap searching function for my own script in a sec, I'll share with ya when I'm done.

  3. #3
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Fix the SRL one so it takes it into account?

  4. #4
    Join Date
    Mar 2008
    Location
    Look behind you.
    Posts
    795
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Here:
    Simba Code:
    Function HPExists: Boolean;
    var
      HP: integer;
    begin
      HP := BitmapFromString(56, 1, 'meJxjYrdmYMhhYGgCIkaGLgw0iZl' +
       'hFjJiYVgIR6wMq+CIg2EjDO3EhTgZDgARhIFHGQZazcRuDQB2WiWA');
      Result := FindBitmap(HP, x, y);
    end;

  5. #5
    Join Date
    Sep 2008
    Location
    Not here.
    Posts
    5,422
    Mentioned
    13 Post(s)
    Quoted
    242 Post(s)

    Default

    The green outline and red outline are both constant colors. Just do a tpa search.

    I use this to find if they are dead(TPoint of the middle of the tracked npc).
    Simba Code:
    function FindDeath(P: TPoint): Boolean;
    var
      TPA: TPointArray;
      ATPA: T2DPointArray;
      B, tB: TBox;
      Len, i, Dist: Integer;
    begin
      Result := False;
      if not LoggedIn then Exit;
      B := IntToBox(P.x - 45, P.y - 55, P.x + 45, P.y + 20);
      if (B.X1 < MSX1) then B.X1 := MSX1;
      if (B.Y1 < MSY1) then B.Y1 := MSY1;
      if (B.X2 > MSX2) then B.X2 := MSX2;
      if (B.Y2 > MSY2) then B.Y2 := MSY2;
      if FindColorsSpiralTolerance(MSCX, MSCY, TPA, 132923, B.X1, B.Y1, B.X2, B.Y2, 0) then
      begin
        ATPA := SplitTPA(TPA, 10);
        SortATPASize(ATPA, True);
        if not (Length(ATPA) > 0) then Exit;

        for i := 0 to High(ATPA) do
        begin
          Len := Length(ATPA[i]);
          if (Len > 0) then
          begin
            tB := GetTPABounds(ATPA[i]);
            Dist := Distance(tB.X1, tB.Y1, tB.X2, tB.Y2);
            m_Debug('HP bar dist: ' + ToStr(Dist), False);
            Result := (Dist > 54);
            if Result then
            begin
              if Debug then
              begin
                SMART_DrawBoxEx(False, B, clBlue);
                SMART_DrawBoxEx(False, GetTPABounds(ATPA[i]), clWhite);
              end;
              Exit;
            end;
          end;
        end;
      end;
    end;

  6. #6
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    @Marpis, thanks.

    @Cohen yeah I would, now that I know that green/red of HP are constant I'll maybe make one. I don't feel like I'd make it as 'perfect' as a more able scripter even though it's easy to do.

  7. #7
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    Simba Code:
    Function YoHoIsFightAt: Boolean;
      var
      arP: TPointArray;
      tmpCTS: Integer;
    begin
      tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(5.33, 1.31);

      FindColorsSpiralTolerance(MMCX, MMCY, arP, 78384, MSX1, MSY1, MSX2, MSY2, 3);

      WriteLn(Length(Arp));
      If Length(arP) > 30 Then
      Result:=True;
      ColorToleranceSpeed(tmpCTS);
      SetColorSpeed2Modifiers(0.2, 0.2);

    End;

    That works. Just find ANY HP bars on the mainscreen.

    Simba Code:
    SetColorSpeed2Modifiers(5.33, 1.31);

      FindColorsSpiralTolerance(MMCX, MMCY, arP, 78384, MSX1, MSY1, MSX2, MSY2, 3);

    Is the main part that just fins the HP bar colors. Edit/use it however you wish.

  8. #8
    Join Date
    Sep 2008
    Location
    Not here.
    Posts
    5,422
    Mentioned
    13 Post(s)
    Quoted
    242 Post(s)

    Default

    You really really really don't need to do that. I'm going to revamp my procedure tomorrow to find HPPercent instead of just checking for the length(this will include finding the green outline as well, plus a better splitting of the tpa). I'll post it here when i'm done.

  9. #9
    Join Date
    Sep 2007
    Location
    British Columbia, Canada
    Posts
    4,047
    Mentioned
    1 Post(s)
    Quoted
    2 Post(s)

    Default

    Am not sure what you need it for, but I had a function that will check if an player/monster that is in fight by checking if an hp bar is within certain range (varies depends on its location on rs screen as well!).
    Oh Hai Dar

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
  •