SRL Archive - SRL Suggestions

Function GetTargetHPPercent() : integer;


mr. pali

2012-12-28 04:56:31

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:


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;

riwu

2012-12-28 05:37:11

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

EDIT:

(*
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.

mr. pali

2012-12-28 06:34:43

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

EDIT:

(*
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 :)

Kongenn

2013-05-02 09:42:33

yeah yeh

Kongenn

2013-05-02 09:43:46

Is all g000d