SRL Archive - SRL Archives

Fixing the Gametab problem, in the long run...


Naike

2009-07-09 06:03:42

Before I start, I'm aware of that R1ch already fixed it..

Gametab.scar got outdated today, and so did a lot of scripts followed by them
moving/deleting and adding new ones. However, Instead of updating whole SRL
all the time, changing GameTab(4) into GameTab(5) we could use the already
pre-set Consts which already is in GameTab.scar?

Well, that's what I've been doing..
I've changed around in gametab.scar, with the latest dev rev(thanks Zeph),
and made it work with old scripts and still manageable to script new ones.

The key is the preset consts which was there before, but never got used?


const
tab_Combat = 1;
tab_Stats = 2;
tab_Quest = 3;
tab_Inv = 4;
tab_Equip = 5;
tab_Prayer = 6;
tab_Magic = 7;
tab_Friends = 8;
tab_Ignore = 9;
tab_Clan = 10;
tab_Options = 11;
tab_Emotes = 12;
tab_Music = 13;
tab_Logout = 14;
tab_Diary = 15;
tab_Notes = 16;

Now, you see that it's well out of order.. but for a reason.
With ^ setup, and some commitment and support from the scripters,
we can make all the scripts stay updated, and still script on.

Only catch is, that you have to do
GameTab(tab_inv); instead of GameTab(4);
But if we can make this a habit, then it will be our profit in the long run.

Now, Why do this? GameTab(4) is a lot smoother?
Sure is smoother, but doing it the long way will make you're script updated
even if they remove/combine/delete or even eat up a gametab.
As when SRL updates the devs would only had to change the numbers
and the actual coords and such then it be up running again, without
about every single script on SRL.
So, conclusion: It profits you in the long run.

I'm not going to write EVERYTHING I changed in all the files, I just made
GameTab(4) -> GameTab(tab_Inv) with all the tabs.

AND, just to keep the complains out, I will paste GameTab.scar in
 tags
while the rest will be attached(Just live with it).

[I]Note: Might missed some Gametab function in the randoms folder..[/I]

Won't post a diff as I still have problems, and it's in the middle of the night :o
New Gametab.scar:
[scar]
//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- ยป GameTab Routines I --//
//-----------------------------------------------------------------//
// * function GetCurrentTab: Integer; // * by Wizzup?
// * function TabExists(TabNumber: Integer): Boolean; // * by Flyboy
// * function GameTab(tabnumber: Integer): Boolean; // * by Starblaster100 & Nava2
// * function SetFightMode(oFightMode: Integer): Boolean; // * by Nielsie95
// * function SetCombatType(Kind: String): Boolean; // * by Narcle & Nava2
// * function GetCombatLevel: Integer; // * by Nielsie95
// * procedure Retaliate(AutoRet:Boolean); // * By WT-Fakawi & n3ss3s
// * function SkillCoords(row, column: Integer): TPoint; // * by RsN
// * function SkillToCoords(Skill: Variant): TPoint; // * by Masquerader, Cheesehunk, Raymond, Wizzup? & ZephyrsFury
// * function GetSkillInfo(Skill: Variant; Amount: Boolean): Integer; // * by Raymond
// * function GetSkillLevel(Skill: Variant): Integer; // * by Raymond
// * function GetMMLevels: integer; // * by Raymond
// * function GetXP(Skill: Variant): Integer; // * by Nielsie95
// * function XpTillNextLevel(Skill: Variant): Integer; // * by Nielsie95
// * function HpPercent: Integer; // * by Wizzup?
// * procedure GetAllLevels; // * by WT-Fakawi
// * function CurrentWorld: Integer; // * by Cheesehunk and modified by Ron
// * function EquipmentCoords(i : Integer) : TPoint; // * by RsN
// * function GetEquippedItemBounds(Which: String): TBox; // * by Nava2
// * procedure MouseEquippedItem(Which : String; Left : Integer); // * by Nava2
// * function WearingItem(i: Integer): Boolean; // * by RsN
// * procedure TakeOff(i: Integer); // * by RsN
// * function CheckEquipItems(number: Integer): Boolean; // * by SDcit
// * function SetRun(run: Boolean: Boolean; // * by Wizzup? and EvilChicken!
// * function RunEnergy(Min: Integer): Boolean; // * by lordsaturn
// * function SetRest: Boolean; // * by ZephyrsFury
// * function RestUntil(Energy: Integer): Boolean; // * by ZephyrsFury
// * procedure SetGraphics(Brightness: Integer; vl, rr, gd, td, id, fl, gt, cs: string); // * by ZephyrsFury
// * procedure SetAudio(Volume, SFX, Area: Integer; SMSetting: (Stereo, Mono, NoChange) ); // * by ZephyrsFury
// * procedure SetBar(Brightness, Volume, SFX, Area: Integer); // * by ZephyrsFury
// * procedure DoEmote(EmoteNumber: Integer); // * by Sumilion

//****************************************************************************//

type
TSMSetting = (Stereo, Mono, NoChange);

Function InStrArrEx(S: String; StrArr: TStringArray; Var Where: Integer): Boolean; forward;
function CloseWindow: Boolean; forward;
function ClickContinue(Click, Wait: Boolean): Boolean; forward;
function ChooseOption(Txt: string): Boolean; forward;
{ const GameTab Constants;
Description: Constants representing gametab numbers. }

const
tab_Combat = 1;
tab_Stats = 2;
tab_Quest = 3;
tab_Inv = 4;
tab_Equip = 5;
tab_Prayer = 6;
tab_Magic = 7;
tab_Friends = 8;
tab_Ignore = 9;
tab_Clan = 10;
tab_Options = 11;
tab_Emotes = 12;
tab_Music = 13;
tab_Logout = 14;
tab_Diary = 15;
tab_Notes = 16;

{*******************************************************************************
function GetCurrentTab: Integer;
By: Wizzup?
Description: Returns current tab
*******************************************************************************}
function GetCurrentTab: Integer;
var
b: Boolean;
begin
b := False;
for Result := 1 to 15 do
begin
case Result of
tab_Combat: b := (GetColor(539, 169) = 3841510);
tab_Stats: b := (GetColor(566, 169) = 3841510);
tab_Quest: b := (GetColor(597, 169) = 3841510);
tab_Inv: b := (GetColor(656, 169) = 3841510);
tab_Equip: b := (GetColor(688, 169) = 3841510);
tab_Prayer: b := (GetColor(718, 169) = 3841510);
tab_Magic: b := (GetColor(747, 169) = 3841510);
tab_Friends: b := (GetColor(567, 467) = 3841510);
tab_Ignore: b := (GetColor(597, 467) = 3841510);
tab_Clan: b := (GetColor(627, 467) = 3841510);
tab_Options: b := (GetColor(659, 467) = 3841510);
tab_Emotes: b := (GetColor(686, 467) = 3841510);
tab_Music: b := (GetColor(718, 467) = 3841510);
tab_Diary: b := (GetColor(718, 467) = 3841510);
tab_Notes: b := (GetColor(533, 475) = 1581150);
tab_Logout: b := (GetColor(556, 276) = 0);
end;
if b then
Exit;
end;
Result := 0;
end;

{*******************************************************************************
function TabExists(TabNumber: Integer): Boolean;
By: Flyboy
Description: Returns true if tab exists.
Very useful for tutorial Is. as well as a simple double check to make sure
your fully logged in.
*******************************************************************************}

function TabExists(TabNumber: Integer): Boolean;
begin
case TabNumber of
tab_Combat: Result := (GetColor(536, 183) = 65536);
tab_Stats: Result := (GetColor(561, 196) = 65536);
tab_Quest: Result := (GetColor(596, 186) = 14676723);
tab_Inv: Result := (GetColor(658, 177) = 66307);
tab_Equip: Result := (GetColor(680, 179) = 65536);
tab_Prayer: Result := (GetColor(718, 179) = 65536);
tab_Magic: Result := (GetColor(740, 183) = 65536);
tab_Friends: Result := (GetColor(567, 475) = 332036);
tab_Ignore: Result := (GetColor(601, 479) = 65536);
tab_Clan: Result := (GetColor(619, 480) = 65536);
tab_Options: Result := (GetColor(649, 477) = 65536);
tab_Emotes: Result := (GetColor(678, 479) = 65536);
tab_Music: Result := (GetColor(712, 475) = 65536);
tab_Logout: Result := (GetColor(743, 1) = 65536);
tab_Diary: Result := (GetColor(626, 186) = 14676723);
tab_Notes: Result := (GetColor(747, 487) = 65536);
end;
end;


{*******************************************************************************
function GameTab(tabnumber: Integer): Boolean;
By: Starblaster100 & Nava2
Description: Switches between tabs.
*******************************************************************************}
function GameTab(tabnumber: Integer): Boolean;
var
c: Integer;
Coords: TPoint;
begin
if not InRange(TabNumber, 1, 16) then
begin
srl_Warn('GameTab', IntToStr(tabnumber) + ' is not a valid GameTab', warn_AllVersions);
Result := False;
Exit;
end;
if not TabExists(tabnumber) then
begin
srl_Warn('GameTab', IntToStr(tabnumber) + ' does not exist', warn_Notice);
Result := False;
Exit;
end;
case TabNumber of
tab_Combat: Coords := Point(534, 188);
tab_Stats: Coords := Point(566, 188);
tab_Quest: Coords := Point(596, 188);
tab_Inv: Coords := Point(659, 188);
tab_Equip: Coords := Point(685, 188);
tab_Prayer: Coords := Point(716, 188);
tab_Magic: Coords := Point(747, 188);
tab_Friends: Coords := Point(568, 485);
tab_Ignore: Coords := Point(596, 485);
tab_Clan: Coords := Point(621, 477);
tab_Options: Coords := Point(651, 485);
tab_Emotes: Coords := Point(688, 485);
tab_Music: Coords := Point(714, 485);
tab_Logout: Coords := Point(752, 12);
tab_Diary: Coords := Point(624, 184);
tab_Notes: Coords := Point(745, 483);
end;
Result := (GetCurrentTab = TabNumber);
if not Result then
begin
Mouse(Coords.x, Coords.y, 8, 8, True);
while not Result and (c < 4) do
Begin
Wait(RandomRange(100, 200));
Result := (GetCurrentTab = tabnumber);
Inc(c);
end;
end;
end;

//****************************************************************************//
// * GameTab 1 Related Functions.
//****************************************************************************//
{*******************************************************************************
function SetFightMode(oFightMode: Integer): Boolean;
By: Nielsie95, Nava2
Description: Sets fight mode. Returns false if failed to set desired mode.
*******************************************************************************}

function SetFightMode(oFightMode: Integer): Boolean;
var
i, x, y: Integer;
b: TBox;
cmbBoxes: array of TBox;
begin
Result := False;
if not(Loggedin)then Exit;
GameTab(tab_Combat);
Wait(200 + Random(100));

cmbBoxes := [IntToBox(575, 255, 630, 290), IntToBox(660, 255, 710, 290),
IntToBox(575, 310, 630, 345), IntToBox(660, 310, 710, 345)];
b := cmbBoxes[oFightMode - 1];
if (not FindColorTolerance(x, y, 5527896, b.x1, b.y1, b.x2, b.y2, 2)) and (oFightMode = 4) then
b := cmbBoxes[2];
i := 0;
while (i < 4) do
begin
Result := FindColorTolerance(x, y, 1777020, b.x1, b.y1, b.x2, b.y2, 2);
if (Result) then Exit;
Mouse(RandomRange(b.x1, b.x2), RandomRange(b.y1, b.y2), 0, 0, True);
Wait(500 + Random(300));
Inc(i);
end;
end;

{*******************************************************************************
function SetCombatType(Kind : string): Boolean;
By: Narcle & Nava2
Description: Sets Combat mode inputted into Kind, treat like UpText.
*******************************************************************************}
function SetCombatType(Kind : string): Boolean;
var
x, y, i, ii: integer;
Xarr, Yarr: array of integer;
TB: TBox;
TP: TPointArray;
begin
Xarr := [595, 680, 595, 680];
Yarr := [270, 270, 325, 325];
GameTab(tab_Combat);
for i := 0 to 3 do
begin
MMouse(Xarr[i], Yarr[i], 12, 12);
Result := WaitFindColor(x, y, 10551295, 540, 205, 750, 465, 0, 3000);
wait(Random(200));
GetClientDimensions(TB.X2, TB.Y2);
TB := IntToBox(0, 0, TB.X2, TB.Y2);
FindColorsTolerance(TP, 10551295, TB.X1, TB.Y1, TB.X2, TB.Y2, 0);
if Length(TP) = 0 then
Exit;
TB := GetTPABounds(TP);
TB.Y1 := TB.Y1 + 1;
for ii := 0 to 3 do
begin
Result := Pos(Kind, LowerCase(GetTextAtEx(TB.X1 + 1, TB.Y1, 0, SmallChars, False, True, 0, 1, - 1, 30, False, tr_AlphaNumericChars))) <> 0;
if Result then
begin
Result := SetFightMode(I + 1);
Exit;
end;
TB.Y1 := TB.Y1 + 13;
end;
end;
end;

{*******************************************************************************
function GetCombatLevel: Integer;
By: Nielsie95
Description: Returns the players combat level.
*******************************************************************************}
function GetCombatLevel: Integer;
var
x, y: Integer;
begin
Gametab(tab_Combat);
Wait(100 + Random(100));
if IsTextInAreaEx(590, 225, 690, 245, x, y, 'Combat', 0, StatChars, False, False, 0, 2, 2070783) then
Result := StrToIntDef(Trim(GetTextAtEx(x, y, 0, StatChars, False, False, 0, 2, 2070783, 20, True, tr_Digits)), -1);
end;

{*******************************************************************************
procedure Retaliate(RetTrue: Boolean);
By: WT-Fakawi & n3ss3s, slight mod by EvilChicken!
Description: Set's Auto Retaliate ON of OFF.
*******************************************************************************}

procedure Retaliate(RetTrue: Boolean);
Var
X, Y: Integer;
Begin
GameTab(tab_Combat);
If RetTrue Xor FindColor(X, Y, 1777020, 624, 385, 719, 396) Then
MouseBox(624, 385, 719, 396, 1);
End;

//****************************************************************************//
// * GameTab 2 Related Functions.
//****************************************************************************//

{ const Skill Constants;
Description: Constants representing player skills. }
const
skill_Attack = 1;
skill_Strength = 2;
skill_Defence = 3;
skill_Range = 4;
skill_Prayer = 5;
skill_Magic = 6;
skill_Runecrafting = 7;
skill_Hitpoints = 8;
skill_Agility = 9;
skill_Herblore = 10;
skill_Thieving = 11;
skill_Crafting = 12;
skill_Fletching = 13;
skill_Slayer = 14;
skill_Mining = 15;
skill_Smithing = 16;
skill_Fishing = 17;
skill_Cooking = 18;
skill_Firemaking = 19;
skill_Woodcutting = 20;
skill_Farming = 21;
skill_Construction = 22;
skill_Hunting = 23;
skill_Summoning = 24;

{*******************************************************************************
function SkillCoords(row, column: Integer): TPoint;
By: RsN fixed by dark sniper and fixed by Raymond
Description: Returns Coords of Skill's Row and Column (Used for GetSkill functions)
*******************************************************************************}

function SkillCoords(row, column: Integer): TPoint;
begin
case Column of
1: Result.x := 577;
2: Result.x := 631;
3: Result.x := 687;
end;
case row of
1: Result.y := 228;
2: Result.y := 260;
3: Result.y := 293;
4: Result.y := 324;
5: Result.y := 356;
6: Result.y := 388;
7: Result.y := 420;
8: Result.y := 419;
end;
end;

{*******************************************************************************
function SkillToCoords(ScrollDownIfNeeded : Boolean; skill: string): TPoint;
By: Masquerader, Cheesehunk, Raymond, Wizzup? & ZephyrsFury
Description: Turns skill string into tpoint.
If Scroll returns true then you must scroll down.
*******************************************************************************}

function SkillToCoords(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 := SkillCoords(CY, CX);

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

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 GetSkillInfo(skill: Variant; Amount : Boolean): Integer;
var
TP: TPoint;
Box : TBox;
TPA : TPointArray;
Cts : Integer;
begin
GameTab(tab_Stats);
TP := SkillToCoords(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 GetSkillLevel(skill: Variant): Integer;
Begin
Result := GetSkillInfo(skill, False);
End;

{*******************************************************************************
Function GetMMLevels(LevelType : String;var ColorSign : String): integer;
By: Raymond / Wizzup
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
TP : TPoint;
I: Integer;
Colors : TIntegerArray;
P: TPointArray;
B: TBox;
Signs : TStringArray;
begin;
Result := -1;
ColorSign := '';
Case LowerCase(Leveltype) of
'health','hp','hitpoints' : TP := Point(729,29);
'prayer','pray' : TP := Point(746,68);
'run','energy' : TP := Point(740,107);
else
begin;
srl_Warn('GetMMLevels', 'Invalid LevelType: ''' + LevelType + '', warn_AllVersions);
Exit;
end;
end;
Colors := [65280, 65535, 2070783, 255];
Signs := ['Green', 'Yellow', 'Orange', 'Red'];
For I := 0 to 3 do
Begin
FindColorsTolerance(P, Colors[i], TP.X - 5, TP.Y - 5, TP.X + 40, TP.Y + 20, 0);
If Length(P) < 1 Then
Continue;
B := GetTPABounds(P);
Result := StrToIntDef(GetNumbers(GetTextAtEx(B.X1 - 1 , B.Y1 - 1, 0, statChars,
False, False, 0, 4, Colors[i], 20, False, tr_Digits)), 1);
ColorSign := Signs[i];
End;
end;

{*******************************************************************************
function GetXP(Skill: Variant): Integer;
By: Nielsie95
Description: Returns current xp for a skill. Returns -1 if failed.
*******************************************************************************}

function GetXp(skill: Variant): Integer;
var
p: TPoint;
tx, ty, x, y: Integer;
b: Boolean;
begin
Result := -1;
if (not LoggedIn) or (not TabExists(tab_Stats)) then Exit;
GameTab(tab_Stats);
if (GetCurrentTab <> tab_Stats) then Exit;
p := SkillToCoords(True,Skill);
if (p.x < 1) then Exit;
MMouse(p.x, p.y +5, 12, 4);
b := WaitFindColor(x, y, 10551295, MIX1, MIY1, MIX2, MIY2, 0, 4000);
Wait(200 + Random(150));
if (not b) then Exit;
if IsTextInAreaEx(x, y, x + 60, y + 60, tx, ty, 'urrent', 0, SmallChars, False, False, 0, 1, 0) then
Result := StrToIntDef(GetNumbers(GetTextAtEx(tx, ty, 0, SmallChars, False, True, 0, 1, 0, 50, False, tr_AllChars)), -1);
end;

{*******************************************************************************
function XpTillNextLevel(Skill: Variant): Integer;
By: Nielsie95
Description: Returns current xp til you level up in a skill.
Returns -1 if failed.
*******************************************************************************}

function XpTillNextLevel(Skill: Variant): Integer;
var
p: TPoint;
tx, ty, x, y: Integer;
b: Boolean;
begin
Result := -1;
if (not LoggedIn) or (not TabExists(tab_Stats)) then Exit;
GameTab(tab_Stats);
if (GetCurrentTab <> tab_Stats) then Exit;
p := SkillToCoords(True,Skill);
if (p.x < 1) then Exit;
MMouse(p.x, p.y +5, 12, 4);
b := WaitFindColor(x, y, 10551295, MIX1, MIY1, MIX2, MIY2, 0, 4000);
Wait(200 + Random(150));
if (not b) then Exit;
if IsTextInAreaEx(x, y, x + 60, y + 60, tx, ty, 'ainder', 0, SmallChars, False, False, 0, 1, 0) then
Result := StrToIntDef(GetNumbers(GetTextAtEx(tx, ty, 0, SmallChars, False, True, 0, 1, 0, 50, False, tr_AllChars)), -1);
end;

{*******************************************************************************
function HpPercent: Integer;
By: Wizzup?
Description: Returns Hp left as a percentage.
If The HP level is set, it does not switch tabs.
*******************************************************************************}

function HPPercent: Integer;

Var
ColorString: String;
Begin
If Players[CurrentPlayer].Level[8] < 1 Then
Players[CurrentPlayer].Level[8] := Max(1, GetSkillInfo('hitpoints', False));

Result := Round(GetMMLevels('hp', ColorString) * 100 / Players[CurrentPlayer].Level[8]);
End;

{****************************************************************************//
procedure GetAllLevels;
By: WT-Fakawi & ZephyrsFury
Description: Sets all 21 skilllevels to Players.Level[21]

* 1 8 15
* 2 9 16
* 3 10 17
* 4 11 18
* 5 12 19
* 6 13 20
* 7 14 21
* 22 23 24

* 1 = attack
* 2 = strength
* 3 = defence
* 4 = range
* 5 = prayer
* 6 = magic
* 7 = runecrafting
* 8 = hitpoints
* 9 = agility
* 10 = herblore
* 11 = thieving
* 12 = crafting
* 13 = fletching
* 14 = slayer
* 15 = mining
* 16 = smithing
* 17 = fishing
* 18 = cooking
* 19 = firemaking
* 20 = woodcutting
* 21 = farming
* 22 = construction
* 23 = hunting
* 24 = summoning
*******************************************************************************}

procedure GetAllLevels;
var
II: Integer;
begin
try
for II := 1 to High(Players[CurrentPlayer].Level) do
Players[CurrentPlayer].Level[II] := GetSkillLevel(II);
except
srl_Warn('GetAllLevels', 'Could not get all skill levels!', warn_AllVersions);
end;
end;

{procedure GetAllLevels;
begin
try
Players[CurrentPlayer].level[1] := GetSkillInfo('attack',False);
Players[CurrentPlayer].level[2] := GetSkillInfo('strength',False);
Players[CurrentPlayer].level[3] := GetSkillInfo('defence',False);
Players[CurrentPlayer].level[4] := GetSkillInfo('range',False);
Players[CurrentPlayer].level[5] := GetSkillInfo('prayer',False);
Players[CurrentPlayer].level[6] := GetSkillInfo('magic',False);
Players[CurrentPlayer].level[7] := GetSkillInfo('runecrafting',False);
Players[CurrentPlayer].level[8] := GetSkillInfo('hitpoints',False);
Players[CurrentPlayer].level[9] := GetSkillInfo('agility',False);
Players[CurrentPlayer].level[10] := GetSkillInfo('herblore',False);
Players[CurrentPlayer].level[11] := GetSkillInfo('thieving',False);
Players[CurrentPlayer].level[12] := GetSkillInfo('crafting',False);
Players[CurrentPlayer].level[13] := GetSkillInfo('fletching',False);
Players[CurrentPlayer].level[14] := GetSkillInfo('slayer',False);
Players[CurrentPlayer].level[15] := GetSkillInfo('mining',False);
Players[CurrentPlayer].level[16] := GetSkillInfo('smithing',False);
Players[CurrentPlayer].level[17] := GetSkillInfo('fishing',False);
Players[CurrentPlayer].level[18] := GetSkillInfo('cooking',False);
Players[CurrentPlayer].level[19] := GetSkillInfo('firemaking',False);
Players[CurrentPlayer].level[20] := GetSkillInfo('woodcutting',False);
Players[CurrentPlayer].level[21] := GetSkillInfo('farming',False);
Players[CurrentPlayer].level[22] := GetSkillInfo('construction', False);
Players[CurrentPlayer].level[23] := GetSkillInfo('hunting', False);
Players[CurrentPlayer].level[24] := GetSkillInfo('summoning', False);
except
WriteLn('Could not get all skill levels');
Exit;
end;
end;

//****************************************************************************//
// * GameTab 4 Related Functions. SEE ALSO INVENTORY.SCAR
//****************************************************************************//

//****************************************************************************//
// * GameTab 5 Related Functions.
//****************************************************************************//

{*******************************************************************************
function EquipmentCoords(i : Integer) : TPoint;
By: RsN modded by WT-Fakawi and Nielsie95
Description: Returns X and Y of the coordinates of the specified equipment item
*******************************************************************************}

function EquipmentCoords(i: Integer): TPoint;
begin
case i of
1: Result := IntToPoint(640, 225);
2: Result := IntToPoint(600, 266);
3: Result := IntToPoint(640, 266);
4: Result := IntToPoint(684, 266);
5: Result := IntToPoint(588, 304);
6: Result := IntToPoint(644, 304);
7: Result := IntToPoint(700, 304);
8: Result := IntToPoint(642, 343);
9: Result := IntToPoint(588, 384);
10: Result := IntToPoint(643, 384);
11: Result := IntToPoint(700, 384);
end;
end;

{*******************************************************************************
function GetEquippedItemBounds(Which: String): TBox;
By: Nava2
Description: Returns TBox of eqquipped item in which.
*******************************************************************************}

function GetEquippedItemBounds(Which: Variant): TBox;
var
P : TPoint;
I : Byte;
begin
Which := LowerCase(Which);
case Which of
1, 'helm', 'helmet' :
I := 1;
2, 'cape' :
I := 2;
3, 'amulet', 'neck', 'necklace' :
I := 3;
4, 'arrows', 'bolts' :
I := 4;
5, 'right hand', 'weapon' :
I := 5;
6, 'plate', 'chest', 'platebody' :
I := 6;
7, 'left hand', 'sheild' :
I := 7;
8, 'legs', 'platelegs', 'skirt', 'plateskirt' :
I := 8;
9, 'gloves', 'gauntlets' :
I := 9;
10, 'ring' :
I := 10;
else
begin
SRL_Warn('GetEquiptItemBounds', 'Invalid entry.', Warn_AllVersions);
Result := IntToBox(0, 0, 0, 0);
Exit;
end;
end;
P := EquipmentCoords(I);
Result := IntToBox(P.x - 11, P.y - 11, P.x + 11, P.y + 11);
end;

{*******************************************************************************
procedure MouseEquippedItem(Which : String; Left : Integer);
By: Nava2
Description: Mouses Equipped item like MouseItem.
*******************************************************************************}
procedure MouseEquippedItem(Which : String; Left : Integer);
var
B : TBox;
begin
B := GetEquippedItemBounds(Which);
if (B.x1 = 0) and (B.x2 = 0) then Exit;
GameTab(tab_Equip);
MouseBox(B.x1, B.y1, B.x2, B.y2, Left);
end;

{*******************************************************************************
function WearingItem(i: Integer): Boolean;
By: RsN
Description: Results True if an item is equiped at i
*******************************************************************************}

function WearingItem(i: Integer): Boolean;
var
x, y:Integer;
T: TPoint;
begin
GameTab(tab_Equip);
T := EquipmentCoords(i);
If FindColor(x, y, 65536, T.x - 8, T.y - 8, T.x + 8, T.y + 8 ) then
Result := True;
end;

{*******************************************************************************
procedure TakeOff(i: Integer);
By: RsN
Description: UnEquips Item specified in i.
*******************************************************************************}

procedure TakeOff(i: Integer);
var
T: TPoint;
begin
GameTab(tab_Equip);
T := EquipmentCoords(i);
if (WearingItem(i)) then
begin
Mouse(T.x, T.y, 5, 5, True);
Wait(200 + Random(100));
end;
end;

{*******************************************************************************
function CheckEquipItems(number: Integer): Boolean;
By: SDcit
Description: Sees if there are number items equiped and returns true if yes.
*******************************************************************************}
function CheckEquipItems(number: Integer): Boolean;
var
CheckCoords: Integer;
x: integer;
begin
x := 0;
for CheckCoords := 1 to 11 do
begin
if WearingItem(CheckCoords) then
Inc(x);
end;
Result := x > number;
if not Result then
SRL_Warn('CheckEquipItems', 'You have more than ' + IntToStr(number) +' items equiped. Currently have '
+ IntToStr(x) + ' equipped.', Warn_AllVersions);
end;

//****************************************************************************//
// * GameTab 6 Related Functions.
//****************************************************************************//

//****************************************************************************//
// * GameTab 7 Related Functions.
//****************************************************************************//

//****************************************************************************//
// * GameTab 8 Related Functions.
//****************************************************************************//

{*******************************************************************************
function CurrentWorld: Integer;
By: Cheesehunk, Ron and fixed by ZephyrsFury
Description: Returns the current world you are on.
*******************************************************************************}
function CurrentWorld: Integer;
var
TextX, TextY: Integer;
begin
Result := -1;
GameTab(tab_Friends);
Wait(RandomRange(50, 100));
if (IsTextInAreaEx(635, 205, 727, 226, TextX, TextY, 'RuneSca', 0, SmallChars, False, False, 0, 0, -1)) then
Result := StrToIntDef(Trim(GetTextAtEx(TextX + 65, TextY, 0, SmallChars, True,
False, 0, 0, -1, 3, False, tr_AllChars)), -1);
if (Result = -1) then
SRL_Warn('CurrentWorld', 'Could not get Current World.', Warn_AllVersions);
end;

//****************************************************************************//
// * GameTab 9 Related Functions.
//****************************************************************************//

//****************************************************************************//
// * GameTab 10 Related Functions.
//****************************************************************************//

//****************************************************************************//
// * GameTab 11 Related Functions.
//****************************************************************************//
{*******************************************************************************
function SetRun(Run: Boolean): Boolean;
By: Wizzup? & EvilChicken!
Description: Sets Run on or off.
*******************************************************************************}

function SetRun(Run: Boolean): Boolean;
Begin
if (CountColorTolerance(5753055, 715, 105, 731, 110, 30) +
CountColorTolerance(514811, 715, 105, 731, 110, 30) > 10) xor (Run) then
begin
Mouse(715, 95, 10, 10, True);
Result := True;
end;
End;

{*******************************************************************************
function RunEnergy(Min: Integer): Boolean;
By: lordsaturn
Description: Toggles run if energy is greater or equal to MinEnergy. Results
true if energy is greater or equal to minimum.
*******************************************************************************}

function RunEnergy(Min: Integer): Boolean;
var
t: String;
begin
Result := (GetMMLevels('run', t) >= Min);
if (Result) then SetRun(True);
end;

{*******************************************************************************
function SetRest: Boolean;
By: ZephyrsFury
Description: Turns Rest on. Result True if successful.
*******************************************************************************}

function SetRest: Boolean;
var
T: Integer;
begin
if (CountColor(3777879, 713, 107, 732, 115) < 10) then
begin
Mouse(715, 95, 10, 10, False);
if (WaitOption('Rest', 300)) then
begin
T := GetSystemTime;
while (CountColor(3777879, 713, 107, 732, 115) < 10) and (GetSystemTime - T < 5000) do
Wait(100);
Result := (CountColor(3777879, 713, 107, 732, 115) > 10);
end;
end;
end;

{*******************************************************************************
function RestUntil(Energy: Integer): Boolean;
By: ZephyrsFury
Description: Rests until your Run energy is above Energy. Results True if
successful.
*******************************************************************************}

function RestUntil(Energy: Integer): Boolean;
var
S: string;
begin
Result := True;
if (GetMMLevels('run', S) >= Energy) then Exit;
SetRest;
while (GetMMLevels('run', S) < Energy) do
begin
Result := (CountColor(3777879, 713, 107, 732, 115) > 10);
if (not(Result)) then Exit;
Wait(1000 + Random(1000));
end;
end;

{*******************************************************************************
procedure SetGraphics(Brightness: Integer; vl, rr, gd, td, id, fe, gt, cs: string);
By: ZephyrsFury
Description: Sets graphic options through the Graphics Screen in GameTab 11.
Use: Enter the desired Setting for the desired Option. Leave as '' for no change

Parameter Option Setting
vl Visible Levels Current / All
rr Remove Roofs Always / Selectively
gd Ground Decoration Off / On
td Texture Detail Low / High
ia Idle Animations Few / Many
fe Flickering Effects Off / On
gt Ground Textures Few / Many
cs Character Shadows Off / On
1 2 3 4
Brightness: <---o---o---o---o--->

EG. SetGraphics(2, 'current', '', 'off', 'low', 'few', '', 'few', 'off');
For Autoing: SetGraphics(4, 'current', 'always', 'off', 'low', 'few', 'off', 'few', 'off');
*******************************************************************************}

procedure SetGraphics(Brightness: Integer; vl, rr, gd, td, ia, fe, gt, cs: string);
var
Settings, PosSettings, OptionName, tArr: TStringArray;
TB: TBox;
II, Tx, Ty, Col, Where: Integer;
P: TPoint;
begin
if (not(LoggedIn)) then Exit;
CloseWindow;
if (not(FindColor(Tx, Ty, 0, 7, 460, 69, 474))) then
if (not(ClickContinue(True, True))) then
Mouse(MMCX, MMCY, 2, 2, True);
II := 0;
while (CountColor(2070753, 201, 28, 317, 46) <> 367) and (LoggedIn) do
begin
GameTab(tab_Options);
MouseBox(605, 258, 623, 277, 1);
Wait(500 + Random(200));
Inc(II);
if (II > 3) then
begin
WriteLn('Could not open Graphics Options screen.');
Exit;
end;
end;
if (not(InRange(Brightness, 0, 4))) then
srl_Warn('Login_SetGraphics', 'Brightness must be between 0 and 4', warn_AllVersions)
else
if (Brightness <> 0) then
begin
P := Point(140 + ((Brightness - 1) * 31), 185);
if (GetColor(P.x, P.y) = 65536) then
Mouse(P.x - 2, P.y - 2, 5, 5, True);
end;
PosSettings := ['Current', 'All', 'Always', 'Selectively', 'Off', 'On', 'Low',
'High', 'Few', 'Many', 'Off', 'On', 'Few', 'Many', 'Off', 'On'];
OptionName := ['Visible Levels', 'Remove Roofs', 'Ground Decoration', 'Texture Detail',
'Idle Animations', 'Flickering Effects', 'Ground Textures', 'Character Shadows'];
Settings := [vl, rr, gd, td, ia, fe, gt, cs];
for II := 0 to High(Settings) do
begin
if (Settings[II] = '') then Continue;
TB.x1 := 149 + ((II + 1) div 7) * 239;
TB.y1 := 173 + ((II + 1) mod 7) * 17;
TB.x2 := TB.x1 + 104;
TB.y2 := TB.y1 + 14;
tArr := [PosSettings[II * 2], PosSettings[II * 2 + 1]];
if (not(InStrArrEx(Capitalize(Settings[II]), tArr, Where))) then
begin
srl_Warn('SetGraphics', 'Setting: ' + Settings[II] + ' is not valid for Option: ' + OptionName[II], warn_AllVersions);
Continue;
end;
Col := Where * 16777008 + 207;
if (FindColor(Tx, Ty, Col, TB.x1, TB.y1, TB.x2, TB.y2)) then
Continue;
Mouse(TB.x1 + 10, TB.y1 + 3, 10, 5, True);
Wait(50);
if (FindColor(Tx, Ty, Col , TB.x1, TB.y2 + 1, TB.x2, TB.y2 + 1 + 51)) then
begin
Mouse(Tx, Ty, 10, 5, True);
Wait(50);
while (CountColor(16777215, 5, 5, 161, 35) > 100) do Wait(100);
end else
Mouse(TB.x1 + 10, TB.y1 + 3, 10, 5, True);
end;
Wait(500 + Random(500));
CloseWindow;
end;

{*******************************************************************************
procedure SetAudio(Volume, SFX, Area: Integer; SMSetting: (Stereo, Mono, NoChange) );
By: ZephyrsFury
Description: Sets audio options through the Audio screen in GameTab 11
Use: Enter the desired Setting AS A POINT for the desired Option. Make option 0
for no change.
1 2 3 4 5
Volume, SFX, Area: <--o---o---o---o---o-->

EG. SetAudio(1, 4, 0, Stereo);
*******************************************************************************}

procedure SetAudio(Volume, SFX, Area: Integer; SMSetting: TSMSetting);
var
Settings: TIntegerArray;
OptionName: TStringArray;
II, C, Tx, Ty: Integer;
P: TPoint;
begin
if (not(LoggedIn)) then Exit;
Settings := [Volume, SFX, Area];
OptionName := ['Volume', 'SFX', 'Area'];
C := 0;
CloseWindow;
if (not(FindColor(Tx, Ty, 0, 7, 460, 69, 474))) then
if (not(ClickContinue(True, True))) then
Mouse(MMCX, MMCY, 2, 2, True);
while (CountColor(2070753, 201, 46, 296, 65) <> 309) and (LoggedIn) do
begin
GameTab(tab_Options);
MouseBox(654, 252, 677, 278, 1);
Wait(500 + Random(200));
Inc(C);
if (C > 3) then
begin
WriteLn('Could not open Graphics Options screen.');
Exit;
end;
end;
for II := 0 to 2 do
begin
if (not(InRange(Settings[II], 0, 5))) then
begin
srl_Warn('SetAudio', IntToStr(Settings[II]) + ' is not a valid setting ' +
'for: ' + OptionName[II] + '. Must be between 0 and 5', warn_AllVersions);
Continue;
end;
if (Settings[II] = 0) then Continue;
P.x := Round(201.0 + 25.5 * (Settings[II] - 1));
P.y := Round(1.5 * II * II + 54.5 * II + 118.0);
if (GetColor(P.x, P.y) <> 16777215) then
Mouse(P.x - 6, P.y, 0, 5, True);
Wait(10);
end;
if (GetColor(238, 268) = 181) and (SMSetting = Stereo) then
Mouse(302, 265, 7, 7, True)
else
if (GetColor(305, 268) = 181) and (SMSetting = Mono) then
Mouse(235, 265, 7, 7, True);
Wait(500 + Random(500));
CloseWindow;
end;

{*******************************************************************************
procedure SetBar(Brightness, Volume, SFX, Area: Integer);
By: ZephyrsFury
Description: Sets each bar to the specific point. 1-4 for Brightness, 1-5 for
others. For no change in the value make the respective parameter 0.
*******************************************************************************}

procedure SetBar(Brightness, Volume, SFX, Area: Integer);
var
Settings: TIntegerArray;
Names: TStringArray;
II, K: Integer;
begin
Settings := [Brightness, Volume, SFX, Area];
Names := ['Brightness', 'Volume', 'SFX', 'Area'];
for II := 0 to 3 do
begin
K := 5 - Integer(II = 0);
if (not(InRange(Settings[II], 0, K))) then
begin
srl_Warn('SetBar', 'Setting: ' + IntToStr(Settings[II]) + ' is not valid for Bar: ' + Names[II] + '.', warn_AllVersions);
Settings[II] := 0;
end;
end;
SetGraphics(Settings[0], '', '', '', '', '', '', '', '');
Wait(100 + Random(500));
SetAudio(Settings[1], Settings[2], Settings[3], NoChange);
end;

//****************************************************************************//
// * GameTab 12 Related Functions.
//****************************************************************************//

{*******************************************************************************
procedure DoEmote(EmoteNumber: Integer);
By: Sumilion
Description: Clicks on an emote specified by EmoteNumber (1 to 37)
*******************************************************************************}

procedure DoEmote(EmoteNumber: Integer);
var
row, X1, Y1, X2, Y2, Others: Integer;
begin
if (not(InRange(EmoteNumber, 1, 37))) then
begin
srl_Warn('DoEmote', 'Invalid EmoteNumber: ' + IntToStr(EmoteNumber) + ', Valid Emotes: 1..37', warn_AllVersions);
Exit;
end;
GameTab(tab_Emotes);
if (EmoteNumber > 20) then
begin
if (GetColor(734, 442) = 1777699) then
Mouse(734, 442, 10, 10, True);
Others := 10;
end else if (GetColor(733, 224) = 1777699) then
Mouse(733, 224, 10, 10, True);
if (EmoteNumber > 4) then
begin
repeat;
row := row + 1;
EmoteNumber := EmoteNumber - 4;
until (EmoteNumber <= 4) or (row = 10)
end;
if (row >= 5) then
row := row - 5;
EmoteNumber := EmoteNumber - 1;
X1 := 554 + (43 * EmoteNumber);
Y1 := 211 + (49 * row) + Others;
X2 := 592 + (43 * EmoteNumber);
Y2 := 257 + (49 * row) + Others;
MouseBox(X1 + 10, Y1 + 10, X2 - 10, Y2 - 10, 1);
end;

Naike

2009-07-09 06:04:42

For the other attachments…

Jethr0x

2009-07-09 06:08:09

i shoulda known u'd be the one to fix… :-p +rep

Rubix

2009-07-09 06:09:01

Rep -, he was suppose to let me post this so i could appear to have contributed to the community.

You must spread some Reputation around before giving it to N1ke! again

Blumblebee

2009-07-09 06:10:38

brilliant. However, the gametabs get changed…oh isnt this like the first time they have been changed? As much as its nice to have that, I'm sure GameTab(5) will become the norm soon.

Naike

2009-07-09 06:16:54

From: Blumblebee
brilliant. However, the gametabs get changed…oh isnt this like the first time they have been changed? As much as its nice to have that, I'm sure GameTab(5) will become the norm soon.


If we do as I said in the first post then every SRL script won't get outdated when Jagex decides to fool around with us. And I seriously doubt that
they won't update the GameTabs anything more, they always find a way.
Even If they move Gametabs around, like switching place.. we'll be screwed.

But not if we use consts :)

Blumblebee

2009-07-09 06:19:08

From: N1ke!
If we do as I said in the first post then every SRL script won't get outdated when Jagex decides to fool around with us. And I seriously doubt that
they won't update the GameTabs anything more, they always find a way.
Even If they move Gametabs around, like switching place.. we'll be screwed.

But not if we use consts :)


im not hacking you down for it, I'm just saying the re-arrangement/addition of gametabs is unlikely to happen again. With that said, it still is a move towards not letting it happen again. However I'm also saying that I think people will become lazy overtime and instead of writing GameTab(tab_inv) they will get lazy and simply write gamteTab(5);

Naike

2009-07-09 06:23:07

From: Blumblebee
im not hacking you down for it, I'm just saying the re-arrangement/addition of gametabs is unlikely to happen again. With that said, it still is a move towards not letting it happen again. However I'm also saying that I think people will become lazy overtime and instead of writing GameTab(tab_inv) they will get lazy and simply write gamteTab(5);


I'm just discussing the usefulness of this, not trying to be rude/harsh or so :p
If we do it this way, people would have to do GameTab(The number that const is on atm); Gametab(5) would send you off to the const being set to gametab 5, which atm is Equip.

Also, Your lazyness would cost you to take extra time updating all your
gametab types if SRL or Runescape got updated…
When other scripts would still be running ;)

ZephyrsFury

2009-07-09 08:40:12

I discussed having contants a for tabs with Nava, we think its a good idea. Jagex said they're adding a new tab soon on their news article so more tab changes ahead. I think we'll start using Tab_Inv or w/e in SRL so if numbers have to change in the future the amount of editing needed is reduced. Of course scripters can still use the number directly but don't expect us to keep them the same.

austin2162

2009-07-09 08:50:45

so i have a question to get to the game tab you type in gametab(tab_inv)?

edit
so if srl or runescape updates it will still work

ZephyrsFury

2009-07-09 11:46:22

From: austin2162
so i have a question to get to the game tab you type in gametab(tab_inv)?

edit
so if srl or runescape updates it will still work


tab_Inv is a constant in SRL with the value of 4 atm. That means GameTab(tab_Inv); is the same as GameTab(4); currently. However if people started using GameTab(tab_Inv) we could change the value of that constant to a different value, say 5. Scripts would then still work but the numbering would have changed.

Summary: we can change the numbers without affecting the script/SRL.

Feroc1ty

2009-07-09 12:00:18

I thought it was quite obvious to use constants instead of numbers, I mean do you think they put them there for fun?

And also, zephyr, the constants will change when the SRL is updated, which means that the scripts which used constants will be usable once again when the SRL is updated (assuming the gametabs was the only issue), yet the scripts which used numbers instead of constants will remain defunct.

ShowerThoughts

2009-07-09 12:18:19

Still a Tab_<TabName> Is genius since sometimes I(we) don't feel like logging in to see what number a specified gametab is.

Nice.

ZephyrsFury

2009-07-09 16:05:23

From: Feroc1ty
And also, zephyr, the constants will change when the SRL is updated, which means that the scripts which used constants will be usable once again when the SRL is updated (assuming the gametabs was the only issue), yet the scripts which used numbers instead of constants will remain defunct.


That was the point I was trying to make.