PDA

View Full Version : My health bar percent functions



ShapeShifter
07-15-2007, 11:39 AM
Well, i thought of making my own health bar functions to find the percent of hp that you have got left. It finds the closest healthbar to your head then works out the percent. Script takes an average of 10ms.

To test it minimize it and click on a monster in runescape then press 'alt + tab' and you'll see the info in the debug every 500 ms, make sure the scar window is not in the middle where your health bar is, or else it will block the healthbar and the script won't work.
program HealthBar;//By ShapeShifter.

{.include SRL\SRL.SCAR}

var HBar:extended;

{FindStartHealthBar - Finds the green starting point of health bar}
function FindStartHealthBar(var x1,y1:integer):Boolean;
var xx,yy,XC:integer;
begin
if FindColorSpiral(xx,yy,65280,MSCx-10,MSCy-37,MSCx+10,MSCy+25) then
begin
for XC:=1 to 30 do
begin
xx:=xx-1;
if GetColor(xx,yy)<>65280 then
begin
x1:=xx+1;
y1:=yy;
Result:=True;
WriteLn('Found health bar at '+IntToStr(xx+1)+','+IntToStr(yy));
exit;
end;
end;
end;
end;

{MyGreenHealthBarPercent - Checks how much percent of hp you got left.
ONLY WORKS AT HIGHEST ANGLE}
function MyGreenHealthBarPercent(MyGHBP:extended):Boolean;
var HBx1,HBy,HBx2,HB,StartTime:integer;
WentPastEnd:boolean;
begin
MarkTime(StartTime);
if FindStartHealthBar(HBx1,HBy) then
begin
HBx2:=HBx1;
for HB:=1 to 6 do
begin
HBx2:=HBx2+5;
if GetColor(HBx2,HBy)<>65280 then
begin
WentPastEnd:=True;
break;
end;
end;
end
else
begin
WriteLn('Couldn''t find start of health bar');
exit;
end;
if WentPastEnd then
begin
for HB:=1 to 5 do
begin
HBx2:=HBx2-1;
if GetColor(HBx2,HBy)=65280 then
begin
MyGHBP:=((HBx2-(HBx1-1))/30)*100;
Result:=True;
WriteLn('Took '+IntToStr(GetSystemTime-StartTime)+' msecs');
WriteLn('Width of green pixels '+IntToStr(HBx2-(HBx1-1))+','+
FloatToStr(((HBx2-(HBx1-1))/30)*100)+' percent full');
exit;
end;
end;
WriteLn('Couldn''t find end of healthbar');
end
else
begin
WriteLn('Didn''t go past the end of the healthbar');
end;
end;

begin
SetUpSRL;
repeat
MyGreenHealthBarPercent(HBar);
wait(500);
ClearDebug;
until(false);
end.

Here
07-15-2007, 06:14 PM
A full program for just one thing? Why don't you follow YoHoJo and just make it a function of a procedure. I'm sure NOBODY likes having to run a whole script just to find their HP percent.

nielsie95
07-15-2007, 06:29 PM
It is a function :p
But why are 3 persons making the same function? :)

Here
07-15-2007, 06:45 PM
Oh, so it is. Sorry. I just saw "program" at the start, and was being stupid.

YoHoJo
07-15-2007, 06:52 PM
Yea, i made mine first, wtf is going on!
=)

ShapeShifter
07-15-2007, 07:16 PM
You know that thread that was talking about getting your hp without clicking on gametab(2)Yohojo, the one you made your healthbar script for, i thought of making my own from that thread, i didn't know you already made one though soz.

YoHoJo
07-15-2007, 07:30 PM
Rofl, np np. Its good that your making you own stuff =)
Now try making a script using that =)!

Spky
07-15-2007, 07:30 PM
Mine p00ns j00rs:



begin
for I:= 1 to 100 does
ifs Readln('Your HP is ' + IntToStr(I) + '..?') = 'YES' then
begin
Writeln('Your HP is ' + IntToStr(I) + '!!!1111!!1!1!!!');;
BREAK
end
end;

ShapeShifter
07-15-2007, 07:35 PM
Spky what are you on bout?

Yohojo, I was going to add healthbar fuction to my chicken killer but you never really die so there's no point=]