SRL Archive - Research & Development Lounge

Some new HP getting stuff!!! Muhahaa! :D


Pentti

2007-07-14 06:12:59

Just made these today, and worked pretty good for me, takes about 100milliseconds to find hp bar + calcute the hp left. (No lag, no game tab) :D
Function HPBoxCanvas:TCanvas;
Function GetTopLeft(Canvas:TCanvas):TPoint;
Function GetBottomRight(Canvas:TCanvas):TPoint;
Function GetHPBarPoints:TBox;
Function HPLeft:Extended;




Please post comments!


Const ShowdaGoddamnDecimalsYesOrNoYouDecide=True;
Function HPBoxCanvas:TCanvas;
var
TempBmp:Integer;
begin
TempBmp:=BitMapFromString(0,0,'');
CopyClientToBitmap(TempBmp,240,145,285,173)
Result:=GetBitMapCanvas(TempBmp);
end;

Function GetTopLeft(Canvas:TCanvas):TPoint;
var
xx,yy:Integer;
begin
For xx:=0 to 45 do
For yy:=0 to 28 do
If(Canvas.Pixels[xx,yy]=65280)Then
begin
Result.X:=xx;
Result.Y:=yy;
Exit;
end;
end;

Function GetBottomRight(Canvas:TCanvas):TPoint;
var
xx,yy:Integer;
begin
For yy:=45 downto 0 do
For xx:=28 downto 0 do
If(Canvas.Pixels[xx,yy]=65280)or(Canvas.Pixels[xx,yy]=255)Then
begin
Result.X:=xx;
Result.Y:=yy;
Exit;
end;
end;

var
x,y:integer;
Function GetHPBarPoints:TBox;
var
TempBR,TempTL:TPoint;
DaBmpCanva:TCanvas;
begin
if(Not(FindColor(x,y,255,240,145,285,173)))then
Exit;
DaBmpCanva:=HPBoxCanvas;
TempTL:=GetTopLeft(DaBmpCanva);
TempBR:=GetBottomRight(DaBmpCanva);
if(TempTL.X+2<TempBR.X)then
begin
Result.X1:=TempTL.X;
Result.Y1:=TempTL.Y;
Result.X2:=TempBR.X;
Result.Y2:=TempBR.Y;
Writeln('X: ('+Inttostr(TempTL.X+240)+','+inttostr(TempBR.X+285)+')')
Writeln('Y: ('+Inttostr(TempTL.Y+145)+','+inttostr(TempBR.Y+173)+')')
Writeln('HP bar size (X*Y)='+inttostr( (TempBR.Y-TempTL.Y)*(TempBR.X-TempTL.X) )+' X('+inttostr(TempTL.X)+','+inttostr(TempBR.X)+') Y('+inttostr(TempTL.Y)+','+inttostr(TempBR.Y)+')')
end;
end;

Function HPLeft:Extended;
var
TempBR,TempTL:TPoint;
DaBmpCanva:TCanvas;
xx,yy:Integer;
HPBarLength:Integer;
begin
if(Not(FindColor(x,y,255,240,145,285,173)))then
Exit;
DaBmpCanva:=HPBoxCanvas;
TempTL:=GetTopLeft(DaBmpCanva);
TempBR:=GetBottomRight(DaBmpCanva);
HPBarLength:=TempBR.X - TempTL.X
yy:=TempTL.Y+3;
For xx:=TempBR.X downto TempTL.X do
If(DaBmpCanva.Pixels[xx,yy]=65280)Then
begin
Result:=((xx-TempTL.X) / HPBarLength)*100;
Exit;
end;
end;

var
Timer:integer;

begin
Repeat
ClearDebug;
Timer:=GetsystemTime;
GetHPBarPoints;
Writeln('HP bar points took: '+inttostr(GetsystemTime-Timer)+'ms')
wait(500)
Timer:=GetsystemTime;
if ShowdaGoddamnDecimalsYesOrNoYouDecide then
Writeln(FloatToStr(HPLeft)+'% HP left') else
Writeln(IntToStr(Round(HPLeft))+'% HP left')

Writeln('Hp left + points took: '+inttostr(GetsystemTime-Timer)+'ms')
wait(1000)
until(False)
end.

MasterKill

2007-07-14 06:27:28

how that look rly nice, and its fast. thats cool man :D

frist post ;)

Pentti

2007-07-14 06:33:06

From: MasterKill
how that look rly nice, and its fast. thats cool man :D

frist post ;)

Haha! Thanks dude. :D

Ilm1

2007-07-14 06:50:25

oo cool :D

Pentti

2007-07-14 06:51:52

From: Ilm1
oo cool :D

Hehe Kiitti. :D Ko tuo scripti on auki on kivempi taistella runes iha normaalistiki. :D

yanix

2007-07-14 06:52:15

yeah nice

Pentti

2007-07-14 06:53:05

From: yanix
yeah nice

thanks dude! :D

BobboHobbo

2007-07-14 07:36:05

Looks awesome and complicated.

Probly works good as i can see from other people.

Pentti

2007-07-14 08:28:46

From: bobbohobbo
Looks awesome and complicated.

Probly works good as i can see from other people.

Thanks!
Well, it has now always worked for me when have I tested it, hasnt failed yet. :D

n3ss3s

2007-07-14 08:41:56

Ja sitte ei ku pk :D

Pentti

2007-07-14 08:42:54

From: n3ss3s
Ja sitte ei ku pk :D

Hehe. :D

teuneboon

2007-07-14 09:36:09

gs!(good script :P)

Pentti

2007-07-14 09:37:20

From: teuneboon
gs!(good script :P)

TItisnsf! (Thanks, I think it still needs some fixing!). :D

Santa_Clause

2007-07-14 09:42:01

Competing with Yoho eh? Seems good.

Pentti

2007-07-14 09:44:22

From: SantaClause
Competing with Yoho eh? Seems good.

Thanks and nah, not actually competing with him, I just wanted to make these and see how this would work. :D
I had the idea ready how to do this when I saw the topic where someone asked for function like this, so I had to try. :D

Santa_Clause

2007-07-14 09:49:31

Well I guess I'm not the only one. I was about to make it for my fighter when I found that you two did…no point trying now.

itSchRis917

2007-07-14 15:29:04

I like your constant name Pentti :D

ShowdaGoddamnDecimalsYesOrNoYouDecide;

WhiteShadow

2007-07-14 19:17:41

I was just about to make one using canvases.

Oh well, looks nice, but please, learn standards foo. :p :)

Pentti

2007-07-15 04:17:31

From: itschris917
I like your constant name Pentti :D

ShowdaGoddamnDecimalsYesOrNoYouDecide;

Hehe. Well I had to name it as something. :D
From: WhiteShadow
I was just about to make one using canvases.

Oh well, looks nice, but please, learn standards foo. :p :)

Thanks!
Ye ye, sure you was. :D
Guess how many times people have been coming to tell me "Pentti your standards are all fucked up man"
And dude, I dont give a fuck about standards. :D
Hehe, I hate them. I do it my own way.