SRL Archive - SRL Archives

GameTab.Scar Additions


Naum

2009-07-23 20:36:14

SkillCoords:
In SRL/SRL/Core/GameTab.scar


Function SkillCoords(Row, Column : ShortInt): TPoint;
Begin
Result := Point(577 + (53 * (Column-1)), 228 + (32 * (Row-1)));
If Row = 8 Then Result.y := 419;
End;
^ This is basically a shorter SkillCords, and it does work! ^


Tab_Music Functions
All of these In SRL/SRL/Core/GameTab.scar


Procedure Loop(State : (TurnOn, TurnOff));
Begin
GameTab(tab_Music);
If GetCurrentTab <> tab_Music Then Exit;
If (GetColor(643, 226) = 716552) xOr (State = TurnOn) Then
Mouse(633, 212, 20, 20, True);
End;



Function NumberOfUnlockedSongs: Integer;
Var TmpStr : String;
x, y : Integer;
Begin
GameTab(tab_Music);
If GetCurrentTab <> tab_Music Then Exit;

If FindColor(x, y, 39423, 671, 220, 673, 223) Then
TmpStr := GetTextAtEx(x - 2, y - 2, 0, StatChars, False, False, 0, 1, 39423, 30, False, tr_AllChars);
If Pos(' ', TmpStr) > 0 Then Delete(TmpStr, Pos(' ', TmpStr), Length(TmpStr));
Result := StrToIntDef(Trim(TmpStr), -1);
End;



Function SelectMusic(Name : String) : Boolean;
Var I, x, y, xx, yy, Time : Integer;
Arr : TStringArray;
CordY : Extended;
Result2 : Boolean;

Begin
Result := (Capitalize(Trim(LowerCase(Name))) = GetMusic);
If Result Then
Begin
WriteLn('We are already playing the song');
Exit;
End;
If NumberOfUnlockedSongs <= 30 Then
Begin
WriteLn('Too few songs unlocked');
Exit
End;
GameTab(tab_Music);
If GetCurrentTab <> tab_Music Then Exit;

Arr := ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
If Pos('the ', Trim(LowerCase(Name))) > 0 Then Delete(Name, 1, 4);

For I := 0 to High(Arr) Do
If LowerCase(Name) = 'random' Then
Begin
I := Random(23);
Name := Capitalize(Arr[i]);
Break;
End Else
If LowerCase(Trim(Left(Name, 1))) = Arr[i] Then
Break;

CordY := ((5.158 * I) + I Mod 3);

If StartsWith('s', Trim(Name)) Then CordY := CordY - 2.03;
If GetNumbers(Left(LowerCase(Trim(Name)), 1)) = '7' Then
CordY := CordY - (CordY - 0.5);

Mouse(719, 287 + Round(CordY), 6, 1, True);
Wait(200 + Random(200));
Time := GetSystemTime + 9600;

MMouse(718, 440, 7, 7);
GetMousePos(x, y);
HoldMouse(x, y, True);
Repeat
Result := FindTextTpaEx(ClGreen, 0, MIX1, MIY1, MIX2, MIY2, xx, yy, Capitalize(Name), StatChars, Nothing);
Result2 := FindTextTpaEx(ClRed, 0, MIX1, MIY1, MIX2, MIY2, xx, yy, Capitalize(Name), StatChars, Nothing);
Until((Result) Or (Result2) Or (GetSystemTime >= Time));
Wait((Round(CordY)/5) + Random(30));
ReleaseMouse(x, y, True);
Wait(100 + Random(200));

If Result Then
ClickText(Capitalize(Name), StatChars, MIX1, MIY1, MIX2, MIY2, True);
If Result2 Then
If Random(5) = 0 Then
ClickText(Capitalize(Name), StatChars, MIX1, MIY1, MIX2, MIY2, True);

If Result Then WriteLn('Found The Song (Unlocked)');
If Result2 Then WriteLn('Found The Song (Locked)');
If (Not (Result)) And (Not (Result2)) Then WriteLn('Could NOT Find The Song :(');
End;


Loop(State : (TurnOn, TurnOff));
Loop(TurnOff);
Will turn off the Loop if it is on and will not do anything if it is off.

Loop(TurnOn);
Will turn on the Loop if it is off and will not do anything if it is on.


NumberOfUnlockedSongs : Integer
Gets the amount of Unlocked Songs out of 604, will return '-1' if failed


SelectMusic(Music : String);
If the selected music is playing then it will abort.
Otherwise, it will select the given music if it is unlocked, otherwise there is a 1/5 chance of it clicking the locked tune.
It uses some basic math to calculate where the song titles (of that respective suffix) begins. Useful for Anti-Ban :).

Naike

2009-07-23 20:54:54

Lookin' good, tho I'm still not certain that It would change sound if you get a random…
However, you forgot to use GameTab(Tab_Music) in the first two music functions.

Naum

2009-07-23 21:47:43

From: N1ke!
Lookin' good, tho I'm still not certain that It would change sound if you get a random…
However, you forgot to use GameTab(Tab_Music) in the first two music functions.


Thanks, added :)

Nava2

2009-07-23 22:09:22

No to the music changer. Randoms rely on it too much.

Sorry bud.

Naum

2009-07-23 23:01:45

Okay, I accept that. Could you give the SkillCoords shorten a once-over please?

ZephyrsFury

2009-07-24 11:07:09

You sure your SkillCoords work 100%. Cos when we tested it a couple weeks back, the coords weren't exactly the same, remember?

Naum

2009-07-24 11:20:31

From: ZephyrsFury
You sure your SkillCoords work 100%. Cos when we tested it a couple weeks back, the coords weren't exactly the same, remember?


I remember, but I fixed it, try it with this script:

program New;
{.Include SRL/SRL.Scar}

Var x, y : Integer;
tp : tpoint;

Function SkillCoords1(Row, Column : ShortInt): TPoint;
Begin
Result := Point(577 + (54 * (Column-1)), 228 + (32 * (Row-1)));
If Row = 8 Then Result.y := 419;
End;

function SkillToCoords1(ScrollDownIfNeeded : Boolean; skill: Variant): TPoint;
var
Scroll: Boolean;
CX, CY, Col, skNo: Integer;
ScrollP : TPoint;
SkillS: string;
SkillArr: TStringArray;
begin
if (not(LoggedIn)) then Exit;

if (VarType(Skill) = 11) then
SkillS := IntToStr(Skill)
else
SkillS := Lowercase(Skill);

case Lowercase(SkillS) of
'hp': SkillS := 'hitpoints';
'ranged': SkillS := 'range';
'hunter': SkillS := 'hunting';
end;

SkillArr := ['attack', 'strength', 'defence', 'range', 'prayer', 'magic', 'runecrafting',
'hitpoints', 'agility', 'herblore', 'thieving', 'crafting', 'fletching',
'slayer', 'mining', 'smithing', 'fishing', 'cooking', 'firemaking',
'woodcutting', 'farming', 'construction', 'hunting', 'summoning'];
if (GetNumbers(SkillS) = SkillS) and (InRange(StrToIntDef(GetNumbers(SkillS), -1), 1, Length(SkillArr))) then
skNo := StrToInt(SkillS) - 1
else
if (not(InStrArrEx(SkillS, SkillArr, skNo))) then
begin
srl_Warn('SkillToCoords', 'Invalid Skill Name/Number: ''' + Skill + '''', warn_AllVersions);
Exit;
end;

if (InRange(skNo + 1, 1, 21)) then
begin
CX := skNo div 7 + 1;
CY := skNo mod 7 + 1;
end else
begin
CX := skNo mod 3 + 1;
CY := skNo div 3 + 1;
end;

Result := skillcoords1(CY, CX);

Scroll := (ScrollDownIfNeeded) and (InRange(skNo + 1, 21, 24));
ScrollP := Point(724, 240 + 194 * Integer(Scroll));
Col := 1316634 - 658704 * Integer(Scroll);
//GameTab(2);

if (GetColor(ScrollP.X, ScrollP.Y) <> Col) then
begin
MMouse(ScrollP.X, ScrollP.Y + 10 * (2 * Integer(Scroll) - 1), 5, 5);
GetMousePos(CX, CY);
HoldMouse(CX, CY, True);
while (GetColor(ScrollP.X, ScrollP.Y) <> Col) and (GetColor(724, 239) = 657930) do
Wait(500 + Random(500));
ReleaseMouse(CX, CY, True);
end;
end;

{*******************************************************************************
function GetSkillInfo(skill: Variant; Amount : Boolean): Integer;
By: Raymond
Description: Gets the amount / level of a skill.
E.G.
0/15
Amount = True will return 0.
Amount = False will return 15 (The actual level).
*******************************************************************************}

function GetSkillInfo1(skill: Variant; Amount : Boolean): Integer;
var
TP: TPoint;
Box : TBox;
TPA : TPointArray;
Cts : Integer;
begin
GameTab(2);
TP := SkillToCoords1(True,skill);
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(0);
if not Amount then
TP := Point(TP.x + 7,TP.y + 13);
FindColorsTolerance(TPA,65535,TP.x - 2,TP.y - 2, TP.x + 15,TP.y + 15,0);
Box := GetTPABounds(TPA);
Result := StrToIntDef(GetNumbers(GetTextAtEx(Box.x1-2, Box.y1 -1, 100,
StatChars, False, True, 0, 5,65535, 2, True, tr_Digits)),0);
ColorToleranceSpeed(CTS);
end;

{*******************************************************************************
Function GetSkillLevel(skill: Variant): Integer;
By: Raymond
Description: Gets the max level for a particular skill.
*******************************************************************************}

Function GetSkillLevel1(skill: Variant): Integer;
Begin
Result := GetSkillInfo1(skill, False);
End;

begin
SetupSRL;
For x := 1 to 24 Do
Writeln(GetSkillLevel1(x));
end.

Open your skills table and confirm that it matches.

Edit: I get this as the SCAR output:

Successfully compiled (2257 ms)
Line 4: [Hint] (19801:5): Variable 'Y' never used in script
Line 5: [Hint] (19802:1): Variable 'TP' never used in script
SRL Compiled in 31 msec
49
51
48
3
28
37
6
49
1
1
1
3
1
1
38
31
0
31
33
73
1
1
1
1
Successfully executed

My Stats are this:


ian.

2009-07-24 12:04:02

Doesn't work if the skill is 10-19?

Naum

2009-07-24 14:19:45

From: 99_ aka ian.
Doesn't work if the skill is 10-19?


The current one is SRL does not do the '1's either according to my SCAR?

ian.

2009-07-24 14:43:14

It does the skills that are 1 or end in a 1, but if it's 10-19, it doesn't get the one, only x in 1x.