SRL Archive - OSR Help

How to get number of times Ivy has been chopped


slayr288

2013-10-12 14:07:19

Hello,

I'm making an ivy cutting script, and I've tried everything to count how many times that the bot cut ivy, or even how much xp was gained. SRL-6 doesn't seem to have any functions regarding XP. Any help would be appreciated.

rj

2013-10-12 14:17:45

You could get a TPA of the XP bar text, and store the length of it somewere, and when the length changes, that means the XP changed thus 1 ivy being cut

Rubix

2013-10-14 16:44:57

From: Officer Barbrady
You could get a TPA of the XP bar text, and store the length of it somewere, and when the length changes, that means the XP changed thus 1 ivy being cut


Been awhile since I've SRL'd. But there used to be a function to get XP built into SRL. If so, like he said, call that up, figure out how much exp you get for chopping ivy, and see if the amount is different from the original. etc.

slayr288

2013-10-14 16:56:54

From: Officer Barbrady
You could get a TPA of the XP bar text, and store the length of it somewere, and when the length changes, that means the XP changed thus 1 ivy being cut


That sounds like it would work, do you have a link to an example in the docs or could you create an example for me?

From: Rubix
Been awhile since I've SRL'd. But there used to be a function to get XP built into SRL. If so, like he said, call that up, figure out how much exp you get for chopping ivy, and see if the amount is different from the original. etc.


SRL-6 no longer has that function :/

Wanted Returns

2013-10-14 17:28:12

From: slayr288
SRL-6 no longer has that function :/


Have some sauce ;)


{=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
function HoverSkill(Skill: Integer; CheckST: Boolean): Boolean;
Contributors: Wanted
Description: Hovers a skill. Put a triple digit number for a random skill.
Date Created: November 3rd, 2011. By Wanted. RS2 Build 674.
Last Modified: March 20th, 2013. By Wanted. RS07 Build ???.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=}

function HoverSkill(Skill: Integer; CheckST: Boolean): Boolean;
begin
Result := False;
if (CheckST) then
if (not (SetGameTab(Tab_Stats))) then
Exit;
MouseBoxB(GetSkillBounds(Skill), MoveTo);
Result := True;
WaitRR(1500, 2000);
end;

{=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
function GetSkillXPEx(Skill: Integer; var CurrentXP, XPTilNextLevel: LongInt; CheckCurrent, CheckNext, CheckST: Boolean): Boolean;
Contributors: Wanted
Description: Returns the information by hovering the skill.
Date Created: November 3rd, 2011. By Wanted. RS2 Build 674.
Last Modified: March 22nd, 2013. By Wanted. RS07 Build ???.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=}

function GetSkillXPEx(Skill: Integer; var CurrentXP, XPTilNextLevel: LongInt; CheckCurrent, CheckNext, CheckST: Boolean): Boolean;
var
bmpSkillInfoBox: TSCARBitmap;
Client: TSCARClient;
TPA: TPointArray;
B: TBox;
begin
Result := False;
CurrentXP := -1;
XPTilNextLevel := -1;
if (not (HoverSkill(Skill, CheckST))) then
Exit;
if (not (WaitFindColorEx(TPA, clSkillInfoBox, MIB, 50, True, 100, 200, 1500, 2500))) then
Exit;
Result := True;
B := TPABounds(TPA);
try
bmpSkillInfoBox := GetClient.CaptureEx(B.X1, B.Y1, B.X2, B.Y2);
Client := SetClient(TSCARBitmapClient.Create(bmpSkillInfoBox));
B := Box(0, 0, bmpSkillInfoBox.Width - 1, bmpSkillInfoBox.Height - 1);
if (CheckCurrent) then
CurrentXP := StrToIntDef(GetNumbers(GetTextAtEx(B.X1, B.Y1 + 2, 0, SmallChars, False, False, 0, 2, clBlack, 30, False, tr_AllChars)), -1);
if (CheckNext) then
XPTilNextLevel := StrToIntDef(GetNumbers(GetTextAtEx(B.X1, B.Y1 + 15, 0, SmallChars, False, False, 0, 2, clBlack, 30, False, tr_AllChars)), -1);
finally
SetClient(Client).Free;
bmpSkillInfoBox.Free;
end;
end;

{=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
function GetXP(Skill: Integer; CheckST: Boolean): Integer;
Contributors: Wanted
Description: Returns the information by hovering the skill.
Date Created: November 3rd, 2011. By Wanted. RS2 Build 674.
Last Modified: March 20th, 2013. By Wanted. RS07 Build ???.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=}

function GetXP(Skill: Integer; CheckST: Boolean): Integer;
var
I: Integer;
begin
GetSkillXPEx(Skill, Result, I, True, False, CheckST);
end;

rj

2013-10-14 17:28:24

From: slayr288
That sounds like it would work, do you have a link to an example in the docs or could you create an example for me?



SRL-6 no longer has that function :/

It would be simple as

procedure MarkTime(var a:Integer);
begin
a := GetSystemTime;
end;

function TimeFromMark(a:Integer):Integer;
begin
result := (GetSystemTime - a);
end;

function findText:Integer;
var
textTPA:TPointArray;
begin
findColorsTolerance(textTPA, color, x1, y1, x2, y2, tol);
result := length(textTPA);
end;

function choppedIvy:Boolean;
var
originalCount:Integer;
begin
originalCount := findText;
repeat
wait(25);
result := (findText <> originalCount);
until (result) or (TimeFromMark(t) > 4000);
end;

Wanted Returns

2013-10-14 17:38:25

From: Officer Barbrady
It would be simple as

procedure MarkTime(var a:Integer);
begin
a := GetSystemTime;
end;

function TimeFromMark(a:Integer):Integer;
begin
result := (GetSystemTime - a);
end;

function findText:Integer;
var
textTPA:TPointArray;
begin
findColorsTolerance(textTPA, color, x1, y1, x2, y2, tol);
result := length(textTPA);
end;

function choppedIvy:Boolean;
var
originalCount:Integer;
begin
originalCount := findText;
repeat
wait(25);
result := (findText <> originalCount);
until (result) or (TimeFromMark(t) > 4000);
end;


For one application… think of SRL 6 as a whole ;)


Wait derp….


Lol ;)

Ah you meant XP Bar..

More sauce!!

{=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
function IsXPBarOpen: Boolean;
Contributors: Wanted
Description: Returns true if the XP counter bar is open.
Date Created: August 7th, 2011. By Wanted. RS2 Build 660.
Last Modified: February 19th 2012. By Wanted. RS2 Build 701.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=}

function IsXPBarOpen: Boolean;
begin
Result := CountColor(14474460, 410, MSY1, MSX2, 27) > 6;
end;

{=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
function ToggleXPBar(Open: Boolean): Boolean;
Contributors: Wanted
Description: Opens or closes the XP Bar, true if had to toggle.
Date Created: August 7th, 2011. By Wanted. RS2 Build 660.
Last Modified: October 28th, 2011. By Wanted. RS2 Build 671.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=}

function ToggleXPBar(Open: Boolean): Boolean;
begin
Result := IsXPBarOpen <> Open;
if (not (Result)) then
Exit;
MouseCircle(12, 534, 63, ClickLeft);
end;

{=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
function GetXPBarTotal: LongInt;
Contributors: Wanted, Freddy
Description: Returns the number from your XP Bar.
Date Created: August 7th, 2011. By Wanted. RS2 Build 660.
Last Modified: July 20th, 2012. By Freddy. RS2 Build 725.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=}

function GetXPBarTotal: LongInt;
var
Previous: Boolean;
TPA: TPointArray;
XP: string;
B: TBox;
begin
Result := -1;
Previous := ToggleXPBar(True);
if (Previous) then
if (not (WaitFunc(@IsXPBarOpen, True, 10, 15, 1500, 1750))) then
Exit;
FindColorEx(TPA, 14474460, 350, MSY1, MSX2, 27)
B := TPABounds(TPA);
XP := GetTextAtEx(B.X1 - 1, B.Y1 - 3, 0, XPChars, False, False, 0, 2, 14474460, 20, False, tr_AllChars);
XP := XP + '#';
if (Pos('xp', XP) > 0) then
Result := StrToIntDef(GetNumbers(Between(' ', '#', XP)), -1)
else
Result := StrToIntDef(GetNumbers(XP), -1);
if (not (Previous)) then
Exit;
WaitRR(500, 1500);
ToggleXPBar(False);
end;

;)

#WantedReturns

slayr288

2013-10-14 18:08:08

From: Wanted Returns
For one application… think of SRL 6 as a whole ;)


Wait derp….


Lol ;)

Ah you meant XP Bar..

More sauce!!

{=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
function IsXPBarOpen: Boolean;
Contributors: Wanted
Description: Returns true if the XP counter bar is open.
Date Created: August 7th, 2011. By Wanted. RS2 Build 660.
Last Modified: February 19th 2012. By Wanted. RS2 Build 701.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=}

function IsXPBarOpen: Boolean;
begin
Result := CountColor(14474460, 410, MSY1, MSX2, 27) > 6;
end;

{=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
function ToggleXPBar(Open: Boolean): Boolean;
Contributors: Wanted
Description: Opens or closes the XP Bar, true if had to toggle.
Date Created: August 7th, 2011. By Wanted. RS2 Build 660.
Last Modified: October 28th, 2011. By Wanted. RS2 Build 671.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=}

function ToggleXPBar(Open: Boolean): Boolean;
begin
Result := IsXPBarOpen <> Open;
if (not (Result)) then
Exit;
MouseCircle(12, 534, 63, ClickLeft);
end;

{=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
function GetXPBarTotal: LongInt;
Contributors: Wanted, Freddy
Description: Returns the number from your XP Bar.
Date Created: August 7th, 2011. By Wanted. RS2 Build 660.
Last Modified: July 20th, 2012. By Freddy. RS2 Build 725.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=}

function GetXPBarTotal: LongInt;
var
Previous: Boolean;
TPA: TPointArray;
XP: string;
B: TBox;
begin
Result := -1;
Previous := ToggleXPBar(True);
if (Previous) then
if (not (WaitFunc(@IsXPBarOpen, True, 10, 15, 1500, 1750))) then
Exit;
FindColorEx(TPA, 14474460, 350, MSY1, MSX2, 27)
B := TPABounds(TPA);
XP := GetTextAtEx(B.X1 - 1, B.Y1 - 3, 0, XPChars, False, False, 0, 2, 14474460, 20, False, tr_AllChars);
XP := XP + '#';
if (Pos('xp', XP) > 0) then
Result := StrToIntDef(GetNumbers(Between(' ', '#', XP)), -1)
else
Result := StrToIntDef(GetNumbers(XP), -1);
if (not (Previous)) then
Exit;
WaitRR(500, 1500);
ToggleXPBar(False);
end;

;)

#WantedReturns


From: Officer Barbrady
It would be simple as

procedure MarkTime(var a:Integer);
begin
a := GetSystemTime;
end;

function TimeFromMark(a:Integer):Integer;
begin
result := (GetSystemTime - a);
end;

function findText:Integer;
var
textTPA:TPointArray;
begin
findColorsTolerance(textTPA, color, x1, y1, x2, y2, tol);
result := length(textTPA);
end;

function choppedIvy:Boolean;
var
originalCount:Integer;
begin
originalCount := findText;
repeat
wait(25);
result := (findText <> originalCount);
until (result) or (TimeFromMark(t) > 4000);
end;


From: Wanted Returns
Have some sauce ;)


{=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
function HoverSkill(Skill: Integer; CheckST: Boolean): Boolean;
Contributors: Wanted
Description: Hovers a skill. Put a triple digit number for a random skill.
Date Created: November 3rd, 2011. By Wanted. RS2 Build 674.
Last Modified: March 20th, 2013. By Wanted. RS07 Build ???.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=}

function HoverSkill(Skill: Integer; CheckST: Boolean): Boolean;
begin
Result := False;
if (CheckST) then
if (not (SetGameTab(Tab_Stats))) then
Exit;
MouseBoxB(GetSkillBounds(Skill), MoveTo);
Result := True;
WaitRR(1500, 2000);
end;

{=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
function GetSkillXPEx(Skill: Integer; var CurrentXP, XPTilNextLevel: LongInt; CheckCurrent, CheckNext, CheckST: Boolean): Boolean;
Contributors: Wanted
Description: Returns the information by hovering the skill.
Date Created: November 3rd, 2011. By Wanted. RS2 Build 674.
Last Modified: March 22nd, 2013. By Wanted. RS07 Build ???.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=}

function GetSkillXPEx(Skill: Integer; var CurrentXP, XPTilNextLevel: LongInt; CheckCurrent, CheckNext, CheckST: Boolean): Boolean;
var
bmpSkillInfoBox: TSCARBitmap;
Client: TSCARClient;
TPA: TPointArray;
B: TBox;
begin
Result := False;
CurrentXP := -1;
XPTilNextLevel := -1;
if (not (HoverSkill(Skill, CheckST))) then
Exit;
if (not (WaitFindColorEx(TPA, clSkillInfoBox, MIB, 50, True, 100, 200, 1500, 2500))) then
Exit;
Result := True;
B := TPABounds(TPA);
try
bmpSkillInfoBox := GetClient.CaptureEx(B.X1, B.Y1, B.X2, B.Y2);
Client := SetClient(TSCARBitmapClient.Create(bmpSkillInfoBox));
B := Box(0, 0, bmpSkillInfoBox.Width - 1, bmpSkillInfoBox.Height - 1);
if (CheckCurrent) then
CurrentXP := StrToIntDef(GetNumbers(GetTextAtEx(B.X1, B.Y1 + 2, 0, SmallChars, False, False, 0, 2, clBlack, 30, False, tr_AllChars)), -1);
if (CheckNext) then
XPTilNextLevel := StrToIntDef(GetNumbers(GetTextAtEx(B.X1, B.Y1 + 15, 0, SmallChars, False, False, 0, 2, clBlack, 30, False, tr_AllChars)), -1);
finally
SetClient(Client).Free;
bmpSkillInfoBox.Free;
end;
end;

{=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
function GetXP(Skill: Integer; CheckST: Boolean): Integer;
Contributors: Wanted
Description: Returns the information by hovering the skill.
Date Created: November 3rd, 2011. By Wanted. RS2 Build 674.
Last Modified: March 20th, 2013. By Wanted. RS07 Build ???.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=}

function GetXP(Skill: Integer; CheckST: Boolean): Integer;
var
I: Integer;
begin
GetSkillXPEx(Skill, Result, I, True, False, CheckST);
end;


Thanks guys, this will help me greatly.

Wanted Returns

2013-10-14 18:11:20

Glad I could help ;)