SRL Archive - OSR Help

Checking HP level.


seany

2010-09-15 23:02:16

Im creating a script for a p server and i was wondering how i could go about checking the HP?

i thought it could be possible to go to skills and check the hp that way by looking at the numbers but i dont know??

please help if you can.


EDIT - when i mean level i mean the level of HP left till i die. not the skill level.

Frement

2010-09-16 00:37:28

You can try creating a font, or a DTM for each level (99 DTM's), but the font is easier.

I also used CountColorTolerance, and if the HP was not the same as the 99's CCT, the script ate a shark. This is quite sufficient way because I checked it after 5 pickpockets, the Paladins don't do more then 10 damage at a time, so max 50 lost.

So, my suggestion is that try to create the font. Simba seemed to fail at retrieving the text, althought Simbas OCR is amazing.

Hope this helps ;)

Coh3n

2010-09-16 00:54:40

If you're just going to make a thread anyway, please don't PM me. If you make a thread, I'll see it. It's just I get a lot of PMs and if you aren't going to wait for a response anyway, don't bother. I don't mean to be rude, I'm sure you'll understand. :)

Thanks.

Wanted

2010-09-16 01:15:51

If you're making a script where the HP level can potentially rise then it's a good idea to often check your actual HP level (the bottom number) via the stats tab.

Players[CurrentPlayer].Level[Skill_HP] := GetSkillLevel(Skill_HP);
//or
GetAllLevels;

then to check the minimap's (current Health)

function CurrentHealth: Integer;
var
S: string;
begin
Result := GetMMLevels('health', S);
end;

Then you can compare it with Players[CurrentPlayer].Level[Skill_HP] using math or whatever.

Edit: Ah? Private server

In that case you will need to make your own font (or find the correct one) that matches those small chars. Then you can do your source similar to this

{*******************************************************************************
Function GetMMLevels(LevelType : String;var ColorSign : String): integer;
By: Raymond / Wizzup / Sabzi
Last Edit: 29 June 2010
Description: Returns the level shown next to the minimap.
Colorsign returns the color of the text (Green,Yellow,Orange,Red).
Returns -1 if failed.
*******************************************************************************}
function GetMMLevels(LevelType: string; var ColorSign: string): Integer;
var
Colors : TIntegerArray;
Signs: TStringArray;
P: TPointArray;
TP: TPoint;
I,cl: Integer;
B: TBox;
{$ifdef Scar}
x,y : integer;
{$endif}
W,H, T: integer;
SearchBox : TBox;
Run: Boolean;
begin;
Result := -1;
ColorSign := '';
case LowerCase(Leveltype) of
'health', 'hp', 'hitpoints', 'constitution': TP := Point(715,27);
'prayer', 'pray' : TP := Point(730,66);
'summon', 'summoning' : TP := Point(715,140);
'run','energy' :
begin
TP := Point(730,105);
Run := True;
end;
else
begin;
srl_Warn('GetMMLevels', 'Invalid LevelType: ''' + LevelType + '', warn_AllVersions);
Exit;
end;
end;
Colors := [65280, 65535, 2070783, 255];
Signs := ['Green', 'Yellow', 'Orange', 'Red'];
GetClientDimensions(w,h); //We donnot want to search out of the clients area!
SearchBox := IntToBox(TP.X, TP.Y, Min(w-1,TP.X + 30), min(h-1,TP.Y + 15));
for I := 0 to 3 do
begin
if Run then
begin
MarkTime(T);
cl := GetColor(749, 118);
repeat
if not IsResting then Break;
{$ifdef Simba}
if CountColorTolerance(cl, 730, 105, 760, 120, 20) = 215 then Break;
{$else}
if not FindColorComp(x, y, clYellow, ccBlue, 730, 107, 742, 108, 130) then Break;
{$endif}
until (TimeFromMark(T) >= 5000);
end; //Do not search outside the client
With SearchBox do
FindColorsTolerance(P, Colors[i], x1, y1, x2, y2, 30);
if Length(P) < 1 then
Continue;
B := GetTPABounds(P);//GetTextAtEx works better for Simba for Run
Result := StrToIntDef(GetNumbers(GetTextAtEx(B.X1 - 1 , B.Y1 - 1, 30, statChars,
False, False, 0, 0, Colors[i], 20, False, tr_Digits)), -1);
if (Result > 0) then
begin
ColorSign := Signs[i];
Exit;
end;
end;
end;

of course you will need to edit the coordinates and such.

If the private server is old to the point where there's no MM levels then use something like the source code in SRL's core/gametab.

seany

2010-09-16 16:51:46

there is no level/stats around the mm.


im finding it very difficult on how to use the SRL'c core/gametab.

im guessing it would be using the GetSkillInfo function… but i currently im finding it difficuly incorporating it.

Coh3n

2010-09-16 17:56:32


function GetHPLevel: integer;
begin
result := GetSkillLevel(SKILL_HITPOINTS);
end;

Frement

2010-09-16 17:56:55

From: Coh3n

function GetHPLevel: integer;
begin
result := GetSkillLevel(SKILL_HITPOINTS);
end;


The fonts wont work.

Coh3n

2010-09-16 17:59:00

From: Frement
The fonts wont work.

Then he needs his own fonts. He's not going to be able to use most of the include if he doesn't have the right fonts.