SRL Archive - SRL Snippets

EOC functions


Ashaman88

2012-11-18 19:39:16

Will be putting some functions I'll be using with EOC. I'll edit this post with them as I do them


Gets the players max hp level:
Function HPLevel: Integer;                                    
Var
ColourString: String;
Begin
Result:= GetMMLevels('HP', ColourString);
End;

Function GetMaxHP: Extended;
Var
Text: String;
B, BigBox: TBox;
TPA : TPointArray;
ATPA : T2DPointArray;
I,cts: Integer;
BoxColors: TIntegerArray;
Begin
GameTab(Tab_Combat);
HumanMouseBox(650,394-50,682,401-50);
Wait(RandomRange(500,700));

B := IntToBox(594, 365-50, 694, 394-50);
cts := GetColorToleranceSpeed;
ColorToleranceSpeed(1);
// Black
BoxColors := [1774603];
SetLength(ATPA, Length(BoxColors));
for i := 0 to High(BoxColors) do
FindColorsTolerance(ATPA[i], BoxColors[i], B.X1, B.Y1, B.X2, B.Y2, 0);
TPA := MergeATPA(ATPA);
If Length(TPA) < 10 Then
begin
Writeln('Not enough colors');
ColorToleranceSpeed(cts);
Exit;
end;

ATPA := SplitTPA(TPA, 4);
For i := 0 to High(ATPA) do
begin
B := GetTPABounds(ATPA[i]);
if ((B.x2-B.x1) > 4) and ((B.y2-B.y1) > 4) then
Break
else
B := IntToBox(0, 0, 0, 0);
end;

If (B.x2 = 0) then
begin
ColorToleranceSpeed(cts);
Exit;
end;

BigBox := B;

Text:= GetTextAtExWrap(BigBox.X1, BigBox.Y1, BigBox.X2, BigBox.Y2, 0, 5, 2, 3111603, 10, 'UpChars');
Text:= Copy(Text, 0, High(Text)-1);
If (StrToIntDef(Text, 0)=100) Then
Result:=HPLevel Else
Result:= (HPLevel*100)/(StrToIntDef(Text, 0));
End;

Did this because your max hp no longer set upon your hp level, but also armors and such. So what it does is it goes to the combat tab, moves the mouse over your health icon, then a black box pops up with the % of health you have. It gets that black box and searches for the text in it, converts it to a number. Then it calculates what your total hp should be based on that % and what your current hp lvl is at. Borrowed parts from getchooseoptions

Justin

2012-11-18 20:28:49

Nice work, just a question about line 5, should the ']' be there (At the end)?

Ashaman88

2012-11-18 20:30:52

Hehe no I don't think so had to take out some debug stuff from them and probably left that

Le Jingle

2012-11-18 20:33:28

https://github.com/Brandon-T/SRL-GLHook

Might be useful in a couple days :)

Ashaman88

2012-11-20 00:35:09

Returns true if skill menu is up

Function SkillMenu: Boolean;
Var
CTS: Integer;
Begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);

SetColorSpeed2Modifiers(0.02, 0.36);

If CountColorTolerance(8280838,398,361-50,480,369-50,11) > 500 Then
Result:=True;

ColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(0.2, 0.2);
End;


Returns true if the Done button shows up after completing skilling

Function DoneButton: Boolean;
Var
CTS: Integer;
Begin

CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);

SetColorSpeed2Modifiers(0.02, 0.36);

If CountColorTolerance(8280838,223,217-50,299,233-50,20) > 100 Then
Result:=True;

ColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(0.2, 0.2);
End;

J J

2012-11-20 00:41:09

Nice work, didn't know about the health percentage in the combat tab :) Good that we don't have to ask users to put it in themselves.

Ashaman88

2012-11-20 00:45:03

From: J J
Nice work, didn't know about the health percentage in the combat tab :) Good that we don't have to ask users to put it in themselves.


Never trust the users! lol but yeah there might be an even easier way to get the max hp, but I'm still trying to figure out this whole EOC things