PDA

View Full Version : GetHPPercentageMM



Markus
02-11-2008, 03:01 PM
My newest creation, this will get the percentage HP you have left without ANY tabswitching :D
It uses the circle next to the MM to determine the percentage left. Due to the size of the circle, this is only like 8% accurate.

{************************************************* ******************************
function GetHPPercentageMM : integer;
by: Markus
Description: Gets the HP percentage from the circle next to the MM. Up to 8% accurate
************************************************** *****************************}
function GetHPPercentageMM : integer;
var
i, x, y : integer;
begin
for i := 180 downto 0 do
begin
x :=round( 13 * Sin(i/180*pi) + 706);
y :=round( -13*cos(i/180*pi)+27);
if not(similarcolors(getcolor(x, y), 132231, 70)) then
begin
result := (100-round(i div 180.0 * 100));
break;
end;
end;
end;

Please tell me how it works :)

Markus

JuKKa
02-11-2008, 03:08 PM
thats some nice math.. But i think getting the text is just easier :P

Markus
02-11-2008, 03:20 PM
With the text you can't calculate a percentage without gametab switching ;)

gerauchert
02-11-2008, 03:24 PM
With the text you can't calculate a percentage without gametab switching ;)

Requires only 1 switch per login...i have it search for the total HP and then it will be constant the entire login, and it can check the minimap the rest of the time ;)

Good function anyway though, i will test it out when i get outa school :D

n3ss3s
02-11-2008, 04:00 PM
Markus, why did you revert sine and cosine?

Cosine gives the "x amount" to go to get to the arc of the unit circle

Sine is the y thing of the above.

So,
X := Round(13 * Cos(i / 180 * Pi)) + 706;
Y := Round(13 * Sin(i / 180 * Pi)) + 27;

also, I hope you know that unit circle 0 is the 90 of the general understanding :)

So, if you want to go from 180 DownTo 0 from South to North, you need to do

"(i - 90) / 180 * Pi" ;)

Markus
02-11-2008, 04:08 PM
For your interest, scar doesn't work in all functions with the 0 = 90 scale, but with the 0 = 0 (north) scale for sin and cos. Arctan does return in the mathematical scale.
And as scar's Sin and Cos use the normal scale, I am allowed to reverse the Sine and Cosine ;)

n3ss3s
02-11-2008, 04:31 PM
For your knowledge mister, if you do the trick with Cos(90) and Sin(90), it'll go to "180" :p

And yes, you are allowed to, but, you can also save time by not typing the "-" ;)

Markus
02-11-2008, 04:37 PM
And yes, you are allowed to, but, you can also save time by not typing the "-" ;)

In maths, higher Y is going up. In computers it is the opposite, that is were the - comes from :)