SRL Archive - SRL Archives

XP Total


Narcle

2010-06-17 20:02:42

I thought I'd just put this here to get peoples opinions on it first. This is the Font and really the only 3 functions you'll need to use this.

This will allow you to read and reset the "XP Total" counter that is now in Runescape.

Extract XPChars folder from the zip file attached to the font folder in Simba.

Function SetXPTotal(Open: boolean): boolean;
begin
if (GetColor(512, 63) = 4160940) xor Open then
Mouse(519, 48, 29, 29, true);
end;

Function GetXPTotal: Integer;
begin
SetTotalXP(true);
While not (GetColor(512, 63) = 4160940) and LoggedIn do
Wait(10);
Result := StrToInt(ExtractFromStr(GetTextAtExWrap(452, 55, 512, 69, 0, 5, 4, clWhite, 0, 'XPChars'), numbers));
end;

Function ResetXPTotal: boolean;
begin
Mouse(519, 48, 29, 29, false);
result := WaitOption('eset', 1000);
end;

Frement

2010-06-17 20:11:24

{*******************************************************************************
function XPBarOpen: Boolean;
By: Frement
Description: Returns true if XP bar is open.
*******************************************************************************}
function XPBarOpen: Boolean;
begin
Result := False;
if (CountColorTolerance(16777215, 430, 55, 515, 70, 3) >= 50) then
Result := True;
end;

{*******************************************************************************
function OpenXPBar: Boolean;
By: Frement
Description: Opens the XP bar if it already is not open.
*******************************************************************************}
function OpenXPBar: Boolean;
var x, y: Integer;
begin
Result := False;
if not (XPBarOpen) then
if (FindColorTolerance(x, y, 12317946, 520, 50, 540, 70, 5)) then begin
Mouse(x, y, 5, 5, True);
Result := True;
end;
end;

{*******************************************************************************
function CloseXPBar: Boolean;
By: Frement
Description: Closes the XP bar if it already is not closed.
*******************************************************************************}
function CloseXPBar: Boolean;
var x, y: Integer;
begin
Result := False;
if (XPBarOpen) then
if (FindColorTolerance(x, y, 12317946, 520, 50, 540, 70, 5)) then begin
Mouse(x, y, 5, 5, True);
Result := True;
end;
end;

{*******************************************************************************
function ResetXPBar: Boolean;
By: Frement
Description: Resets the XP bar, opens it if its closed and then closes it.
*******************************************************************************}
function ResetXPBar: Boolean;
begin
Result := False;
if (XPBarOpen) then begin
Mouse(RandomRange(450, 490), 65, 5, 5, True);
Result := True;
end else begin
OpenXPBar;
Mouse(RandomRange(450, 490), 65, 5, 5, True);
Result := True;
CloseXPBar;
end;
end;

I think reset function is outdated. As it needs to click on the icon rather then the bar.

Narcle

2010-06-17 20:14:08

I think its easier to just have one function to open/close it. Oh but I do prefer your name for it "XPBar" although Jagex calls it "XP Total."

Frement

2010-06-17 20:14:52

From: Narcle
I think its easier to just have one function to open/close it. Oh but I do prefer your name for it "XPBar" although Jagex calls it "XP Total."


Well those are just some functions I made when it first came.

Narcle

2010-06-17 20:23:50

Change the names around. Using "XPTotal" while its not as short it conveys what it is better.

Craig`

2010-06-17 20:33:34

[PHP]
function XPBarOpen: Boolean;
begin
Result := False;
if (CountColorTolerance(16777215, 430, 55, 515, 70, 3) >= 50) then
Result := True;
end;

// improved.

function XPBarOpen: Boolean;
begin
Result := CountColorTolerance(16777215, 430, 55, 515, 70, 3) >= 50;
end;
[/PHP]

craiggles.

masterBB

2010-06-18 05:24:49

{*******************************************************************************
function CloseXPBar: Boolean;
By: Frement
Description: Closes the XP bar if it already is not closed.
*******************************************************************************}
function CloseXPBar: Boolean;
var x, y: Integer;
begin
Result := False;
if ((XPBarOpen) and (FindColorTolerance(x, y, 12317946, 520, 50, 540, 70, 5))) then begin
Mouse(x, y, 5, 5, True);
Result := True;
end;
end;

{*******************************************************************************
function ResetXPBar: Boolean;
By: Frement
Description: Resets the XP bar, opens it if its closed and then closes it.
*******************************************************************************}
procedure ResetXPBar;
begin
if (XPBarOpen) then begin
Mouse(RandomRange(450, 490), 65, 5, 5, True);
end else begin
OpenXPBar;
Mouse(RandomRange(450, 490), 65, 5, 5, True);
CloseXPBar;
end;
end;

I we're optimizing anyway… And there are no waits in ResetXPBar

masterBB

2010-06-18 05:28:13

double post…

Craig`

2010-06-18 05:30:21

[PHP]
function CloseXPBar: Boolean;
var x, y: Integer;
begin
Result := False;
if ((XPBarOpen) and (FindColorTolerance(x, y, 12317946, 520, 50, 540, 70, 5))) then begin
Mouse(x, y, 5, 5, True);
Result := True;
end;
end;

// boolean returning functions with no explicit result assignment return false

function CloseXPBar: Boolean;
var x, y: Integer;
begin
if (XPBarOpen) and (FindColorTolerance(x, y, 12317946, 520, 50, 540, 70, 5)) then
begin
Mouse(x, y, 5, 5, True);
Result := True;
end;
end;
[/PHP]

Wanted

2010-12-03 17:34:50

I find this to be useful, commit pl0x?

Narcle

2010-12-03 20:11:40

From: IceFire908
I find this to be useful, commit pl0x?


Only reason I didn't commit is because the font needs to be added to Simba.

Gu3st...

2010-12-03 20:26:54

This is the font used

EDIT: Oh, wait.. It's in the first post

Wanted

2010-12-03 21:35:57

From: Narcle
Only reason I didn't commit is because the font needs to be added to Simba.


Should be a pretty easy for who ever can.

Wizzup?

2010-12-04 05:22:20

Added to Simba repos & online snapshot for Simba. Should autoupdate as soon as you start Simba.

Loaded fonts: UpChars, SmallChars, CharsTrade, LoginChars, XPChars, FriendChars, StatChars, BigChars, CharsNPC

Wanted

2010-12-04 16:59:17

I think you messed up or something because you put a new folder names Fonts inside of Fonts that has the right chars but it won't work like this.

Gu3st...

2010-12-04 17:52:15

From: IceFire908
I think you messed up or something because you put a new folder names Fonts inside of Fonts that has the right chars but it won't work like this.
I saw that too, but I though it was a problem with my Simba! :cartman: apparently not.. :o

Wanted

2010-12-04 19:08:34

Also, Wizzup. I noticed that since this thread is old the XPChars have since changed, if you could please reupload these news ones from http://rs2fonts.googlecode.com/svn/trunk/ it would be much appreciated.

Edit:

Well I'm done for the day, and I'm absolutely stumped with both SCAR and simba on this one. Simba is mixing up 3s and putting 5s in there. If anyone can debunk this that would be great, just remember to get the new fonts from googlecode when testing.

{*******************************************************************************
function IsXPBarOpen: Boolean;
By: Narcle & IceFire908
Description: Results True if the XP Bar is showing.
*******************************************************************************}

function IsXPBarOpen: Boolean;
begin
Result := GetColor(459, 55) = 4095148;
end;

{*******************************************************************************
function ToggleXPBar(Open: Boolean): Boolean;
By: Narcle & IceFire908
Description: Opens or closes the XP Bar, true if had to toggle.
*******************************************************************************}

function ToggleXPBar(Open: Boolean): Boolean;
var
TPA: TPointArray;
P: TPoint;
begin
Result := IsXPBarOpen <> Open;
if (not (Result)) then
Exit;
TPA := TPAFromBox(IntToBox(521, 51, 546, 75));
FilterPointsPie(TPA, 0, 360, 0, 12, 534, 63);
P := TPA[Random(Length(TPA))];
Mouse(P.X, P.Y, 0, 0, True);
end;

{*******************************************************************************
function GetXPBarTotal: LongInt;
By: Narcle & IceFire908
Description: Returns the number from your XP Bar.
*******************************************************************************}

function GetXPBarTotal: string;
var
Previous: Boolean;
TPA: TPointArray;
P: TPoint;
B: TBox;
begin
Previous := IsXPBarOpen;
if (ToggleXPBar(True)) then
WaitFunc(@IsXPBarOpen, 10, 1500);
FindColorsTolerance(TPA, clWhite, 372, 50, 515, 76, 1);
B := GetTPABounds(TPA);
{$IFDEF Simba}
B := IntToBox(b.x1-2, b.y1-2, b.x2+2, b.y2+2);
Result := {StrToInt(ExtractFromStr(}GetTextAtExWrap(B.X1, B.Y1, B.X2, B.Y2, 0, 5, 4, clWhite, 0, 'XPChars'){, Numbers));}
{$ELSE}
WriteLn(IsTextInAreaEx(433, 55, 454, 70, P.X, P.Y, 'XP', 0, XPChars, False, False, 0, 2, clWhite));
Result := StrToIntDef(GetNumbers(GetTextAtEx(B.X1 - 1, B.Y1 - 1, 0, XPChars, False, False, -1, 1, 0, 60, True, tr_AllChars)), 0);
{$ENDIF}
if (not (Previous)) then
Wait(RandomRange(500, 1500));
ToggleXPBar(Previous);
end;

{*******************************************************************************
function ResetXPTotal: Boolean;
By: Narcle & IceFire908
Description: Resets the XP Bar.
*******************************************************************************}

function ResetXPTotal: Boolean;
var
TPA: TPointArray;
P: TPoint;
begin
TPA := TPAFromBox(IntToBox(521, 51, 546, 75));
FilterPointsPie(TPA, 0, 360, 0, 12, 534, 63);
P := TPA[Random(Length(TPA))];
Mouse(P.X, P.Y, 0, 0, False);
Result := WaitOptionMulti(['Res', 'ese', 'set'], 1000);
end;

Bad Boy JH

2010-12-05 20:09:37

/me wonders if its possible with reflection. Will check that today.

Wizzup?

2010-12-06 17:32:46

From: IceFire908
Also, Wizzup. I noticed that since this thread is old the XPChars have since changed, if you could please reupload these news ones from http://rs2fonts.googlecode.com/svn/trunk/ it would be much appreciated.


I noticed this too. But once I updated again it was named XPChars. I committed with the right name, perhaps I messed up the zipping. Or there is a bug in Simba.

I've updated it to use the latest XPChars.

Wanted

2010-12-06 19:51:50

From: Zyt3x
I saw that too, but I though it was a problem with my Simba! :cartman: apparently not.. :o


Is there an easy way that you could give us bitmaps of every char of any font set?

Wizzup, sorry last time. Turns out the '3' was one pixel off, its on the same SVN.

Edit: Committed working versions of the following functions to latest SRL open dev. Simba users update your SR (and manually update your fonts until Wizzup uploads the new '3'), SCAR users update your SRL + Fonts folder.

// * function IsXPBarOpen: Boolean;                                // by Narcle & IceFire908
// * function ToggleXPBar(Open: Boolean): Boolean; // by Narcle & IceFire908
// * function GetXPBarTotal: LongInt; // by Narcle & IceFire908
// * function ResetXPTotal: Boolean; // by Narcle & IceFire908
//*****************************************************************//

{*******************************************************************************
function IsXPBarOpen: Boolean;
By: Narcle & IceFire908
Description: Results True if the XP Bar is showing.
*******************************************************************************}

function IsXPBarOpen: Boolean;
begin
Result := CountColor(clWhite, 342, 55, 510, 69) > 40;
end;

{*******************************************************************************
function ToggleXPBar(Open: Boolean): Boolean;
By: Narcle & IceFire908
Description: Opens or closes the XP Bar, true if had to toggle.
*******************************************************************************}

function ToggleXPBar(Open: Boolean): Boolean;
var
TPA: TPointArray;
P: TPoint;
begin
Result := IsXPBarOpen <> Open;
if (not (Result)) then
Exit;
TPA := TPAFromBox(IntToBox(521, 51, 546, 75));
FilterPointsPie(TPA, 0, 360, 0, 12, 534, 63);
P := TPA[Random(Length(TPA))];
Mouse(P.X, P.Y, 0, 0, True);
end;

{*******************************************************************************
function GetXPBarTotal: LongInt;
By: Narcle & IceFire908
Description: Returns the number from your XP Bar.
*******************************************************************************}

function GetXPBarTotal: LongInt;
var
Previous: Boolean;
TPA: TPointArray;
P: TPoint;
B: TBox;
begin
Previous := IsXPBarOpen;
if (ToggleXPBar(True)) then
WaitFunc(@IsXPBarOpen, 10, 1500);
FindColorsTolerance(TPA, clWhite, 342, 55, 510, 69, 1);
B := GetTPABounds(TPA);
B := IntToBox(B.X1 - 2, B.Y1 - 2, B.X2 + 2, B.Y2 + 2);
{$IFDEF Simba}
Result := StrToInt(ExtractFromStr(GetTextAtExWrap(B.X1, B.Y1, B.X2, B.Y2, 0, 5, 4, clWhite, 0, 'XPChars'), Numbers));
{$ELSE}
IsTextInAreaEx(B.X1, B.Y1, B.X2, B.Y2, P.X, P.Y, 'XP', 0, XPChars, False, False, 0, 1, clWhite);
Result := StrToIntDef(GetNumbers(GetTextAtEx(P.X, P.Y, 1, XPChars, False, False, 0, 2, clWhite, 60, False, tr_AllChars)), 0);
{$ENDIF}
if (not (Previous)) then
Wait(RandomRange(500, 1500));
ToggleXPBar(Previous);
end;

{*******************************************************************************
function ResetXPTotal: Boolean;
By: Narcle & IceFire908
Description: Resets the XP Bar.
*******************************************************************************}

function ResetXPTotal: Boolean;
var
TPA: TPointArray;
P: TPoint;
begin
TPA := TPAFromBox(IntToBox(521, 51, 546, 75));
FilterPointsPie(TPA, 0, 360, 0, 12, 534, 63);
P := TPA[Random(Length(TPA))];
Mouse(P.X, P.Y, 0, 0, False);
Result := WaitOptionMulti(['Res', 'ese', 'set'], 1000);
end;

Wizzup?

2010-12-07 05:08:42

Updated to latest.

Gu3st...

2010-12-07 13:47:44

From: IceFire908
Is there an easy way that you could give us bitmaps of every char of any font set?
I have tried to create an auto-updater, but the spacing for each charset is different (and the size too.. some is 400x400 others are 200x200 and so on) and some of the characters have no spacing at all (not in this charset though)

I guess if you made some constants for the spacing of each charset and where the characters starts then it could be done…. I'll try making one again… :)

EDIT: For UpText, the spacing between each row (EDIT2: And column!) is 16.. I am starting to think I did something extremely wrong last time I tried! This might be very do-able!