SRL Archive - OSR Utility Scripts

Health Checker Utility


Eduard

2013-03-01 17:32:38

Hi guys,

A little contribution (it's not perfect..)

program HealthTest;
{$Define SMART8}
{$include SRL/SRL.simba}
{$include SPS/SPS.simba}
{$include SRL/SRL/Misc/SmartGraphics.simba}

var
DebugBitmap: integer;

const
debug = true;

function FindGreenHealth: integer;
var
HealthBarTPA: TPointArray;
HealthBarATPA: T2DPointArray;
begin
if (Findcolors(HealthBarTPA, 65280, MSX1, MSY1, MSX2, MSY2)) then
begin
SplitTPAWrap(HealthBarTPA, 10, HealthBarATPA);
SortATPAFromMidPoint(HealthBarATPA, Point(251, 171));
if (debug) then
Smart_DrawDotsEx(true, HealthBarTPA, clBlue);
result := High(HealthBarATPA[0]);
end;
end;

function CalculateHealth: integer;
var
Conversion, Red, Green: extended;
Calculation: integer;
begin
Green := FindGreenHealth;
Conversion := (green / 149) * 100;
Calculation := Round(Conversion);
if (Calculation < 1) then
begin
result := - 1;
end
else
result := Calculation;
end;

begin
SetupSRL;
Smart_SetupDebug;
repeat
Cleardebug;
writeln(CalculateHealth);
Wait(3000);
until (false)
end.

What it does:


Green is a constant color in old rs, so it checks for that color on the screen using FindColors().
It then splits all the TPA's into ATPA's and check for the first ATPA in the middle (characters health bar)
It then (if debug = true -> debugs on smart) calculates the health in % using very simple math.

sprunt

2013-03-01 18:55:31

what does it do?

Tombraider

2013-03-01 19:02:24

Thx for adding this utility! However it still checks A green bar not your OWN healthbar :P

sprunt

2013-03-01 19:16:29

doesnt compile either

Eduard

2013-03-02 09:42:27

From: Tombraider
Thx for adding this utility! However it still checks A green bar not your OWN healthbar :P


Since it sorts the tpa from the center of the screen (MMX1 + MMX2 / 2) etc. it most likely finds the own healthbar.

kiwiownage

2013-03-04 02:25:49

Thanks for this:spot: