Results 1 to 5 of 5

Thread: Function GetTargetHPPercent() : integer;

  1. #1
    Join Date
    Mar 2006
    Location
    NW US
    Posts
    210
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default Function GetTargetHPPercent() : integer;

    Hey so the new GetAdrenalinePercent function in the SRL gametab include written by @Slushpuppy is really great. I was wondering, perhaps the code could be modified slightly to read the green HP bar of your target in the combat tab? Maybe this function could be added to the SRL include as well?

    here's the function for anyone wondering:

    Simba Code:
    function GetAdrenalinePercent(): Integer;
    var
      BarX1,BarX2,BarY1,BarY2 : Integer;
      tpa : TPointArray;
      box : TBox;
    begin
      Result := -1;
      if isActionBarOpen then
      begin
        Result := 100;
        BarY1 := 334 - SRL_NAVBAR_INGAME_Y;
        BarY2 := 337- SRL_NAVBAR_INGAME_Y;
        BarX1 := 49 - SRL_NAVBAR_INGAME_X;
        BarX2 := 469 - SRL_NAVBAR_INGAME_X;
        if FindColorsTolerance(tpa,1776411,BarX1,BarY1,BarX2,BarY2,15) then
        begin
          box := GetTPABounds(tpa);
          Result := Floor(100 - ((BarX2 - box.X1)*1.0 / (BarX2-BarX1) * 1.0) * 100);
        end;
       end;
    end;

  2. #2
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    Isn't that already in the include? I'll make one for getting target hp then, give me a moment.

    EDIT:
    Simba Code:
    (*
    TargetHpPercent
    ~~~~~~~~~~~~~~~

    .. code-block:: pascal

        function TargetHpPercent: Integer;

        Returns the Hp Percent of the target.

    .. note::

        by riwu

    Example:

    .. code-block:: pascal

    *)

    function TargetHpPercent: Integer;
    var
      hpBar: TPointArray;
      box: TBox;
    begin
      if not FTab(tab_Combat) then
      begin
        srl_Warn('TargetHpPercent', 'Could not open combat tab', warn_AllVersions);
        Result:= -1;
        Exit;
      end;

      Result:= 0;
      if not HasTarget then
        Exit;

      if FindColorsTolerance(hpBar, 2329176, 600, 237, 685, 242, 50) then
      begin
        box:= GetTPABounds(hpBar);
        Result:= Round(Max(1, (box.X2 - box.X1)) / 0.85);
      end;
    end;
    I'll add this to the include soon, so expect a duplicate identifier soon.
    Last edited by riwu; 12-28-2012 at 11:06 AM.

  3. #3
    Join Date
    Mar 2006
    Location
    NW US
    Posts
    210
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    Quote Originally Posted by riwu View Post
    Isn't that already in the include? I'll make one for getting target hp then, give me a moment.

    EDIT:
    Simba Code:
    (*
    TargetHpPercent
    ~~~~~~~~~~~~~~~

    .. code-block:: pascal

        function TargetHpPercent: Integer;

        Returns the Hp Percent of the target.

    .. note::

        by riwu

    Example:

    .. code-block:: pascal

    *)

    function TargetHpPercent: Integer;
    var
      hpBar: TPointArray;
      box: TBox;
    begin
      if not FTab(tab_Combat) then
      begin
        srl_Warn('TargetHpPercent', 'Could not open combat tab', warn_AllVersions);
        Result:= -1;
        Exit;
      end;

      Result:= 0;
      if not HasTarget then
        Exit;

      if FindColorsTolerance(hpBar, 2329176, 600, 237, 685, 242, 50) then
      begin
        box:= GetTPABounds(hpBar);
        Result:= Round(Max(1, (box.X2 - box.X1)) / 0.85);
      end;
    end;
    I'll add this to the include soon, so expect a duplicate identifier soon.
    thank you. the community appreciates your efforts

  4. #4
    Join Date
    Apr 2013
    Posts
    12
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    yeah yeh

  5. #5
    Join Date
    Apr 2013
    Posts
    12
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    Is all g000d

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
  •