SRL Archive - SRL Archives

Fixed Gametab.scar


Rich

2009-07-08 19:30:52

//-----------------------------------------------------------------//
//-- 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

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

// * GameTab 1 = Fightmode
// * GameTab 2 = Statistic
// * GameTab 3 = Quest
// * GameTab 4 = Achievements
// * GameTab 5 = Inventory (see Inventory.scar)
// * GameTab 6 = Wield
// * GameTab 7 = Prayer
// * GameTab 8 = Mage
// * GameTab 9 = Summoning
// * GameTab 10 = Friends
// * GameTab 11 = Ignore
// * GameTab 12 = Clan
// * GameTab 13 = Tools
// * GameTab 14 = Emotes
// * GameTab 15 = Music
// * GameTab 16 = Notes

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

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_Achieve = 4;
tab_Inv = 5;
tab_Equip = 6;
tab_Prayer = 7;
tab_Magic = 8;
tab_Summoning = 9;
tab_Friensd = 10;
tab_Ignore = 11;
tab_Clan = 12;
tab_Tools = 13;
tab_Emotes = 14;
tab_Music = 15;
tab_Notes = 16;

{*******************************************************************************
function GetCurrentTab: Integer;
By: Wizzup? and fixed by R1ch
Description: Returns current tab
*******************************************************************************}
function GetCurrentTab: Integer;
var
b: Boolean;
begin
b := False;
for Result := 1 to 16 do
begin
case Result of
1: b := (GetColor(525, 198) = 3243659);
2: b := (GetColor(555, 198) = 3243659);
3: b := (GetColor(585, 198) = 3243659);
4: b := (GetColor(615, 198) = 3243659);
5: b := (GetColor(645, 198) = 3243659);
6: b := (GetColor(675, 198) = 3243659);
7: b := (GetColor(705, 198) = 3243659);
8: b := (GetColor(735, 198) = 3243659);
9: b := (GetColor(525, 496) = 3243659);
10: b := (GetColor(555, 496) = 3243659);
11: b := (GetColor(585, 496) = 3243659);
12: b := (GetColor(615, 496) = 3243659);
13: b := (GetColor(645, 496) = 3243659);
14: b := (GetColor(675, 496) = 3243659);
15: b := (GetColor(705, 496) = 3243659);
16: b := (GetColor(735, 496) = 3243659);
end;
if b then
Exit;
end;
Result := 0;
end;

{*******************************************************************************
function TabExists(TabNumber: Integer): Boolean;
By: Flyboy and fixed by R1ch
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
1: Result := (GetColor(537, 186) = 11316900);
2: Result := (GetColor(567, 187) = 6197842);
3: Result := (GetColor(595, 186) = 16677477);
4: Result := (GetColor(622, 186) = 4432487);
5: Result := (GetColor(657, 188) = 1057862);
6: Result := (GetColor(683, 189) = 9739920);
7: Result := (GetColor(716, 187) = 16514296);
8: Result := (GetColor(749, 183) = 2519980);
{9: Result := (GetColor(605, 474) = 65536); Need colour}
10: Result := (GetColor(569, 490) = 6663557);
11: Result := (GetColor(593, 490) = 2378388);
12: Result := (GetColor(627, 491) = 7139839);
13: Result := (GetColor(689, 485) = 6315604);
14: Result := (GetColor(743, 1) = 10062725);
15: Result := (GetColor(716, 480) = 1581349);
16: Result := (GetColor(748, 486) = 8760771);
end;
end;


{*******************************************************************************
function GameTab(tabnumber: Integer): Boolean;
By: Starblaster100 & Nava2 and fixed by R1ch
Description: Switches between tabs.
*******************************************************************************}
function GameTab(tab: integer): boolean;
var
x, y, fx, fy: integer;
begin
result := true;
if not InRange(Tab, 1, 16) then
begin
srl_Warn('GameTab', IntToStr(tab) + ' is not a valid GameTab', warn_AllVersions);
Result := False;
Exit;
end;
if not TabExists(tab) then
begin
srl_Warn('GameTab', IntToStr(tab) + ' does not exist', warn_Notice);
Result := False;
Exit;
end;
if (GetCurrentTab = tab) then exit;
y := 186 + Integer(tab >= 9)*296;
x := 535 + (tab - 1 - (Integer(tab >= 9)*8))*30;
Mouse(x, y, 5, 5, true);
wait(100+random(100));
result := GetCurrentTab = tab;
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(1);
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(1);
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(1);
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(1);
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(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 GetSkillInfo(skill: Variant; Amount : Boolean): Integer;
var
TP: TPoint;
Box : TBox;
TPA : TPointArray;
Cts : Integer;
begin
GameTab(2);
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(2)) then Exit;
GameTab(2);
if (GetCurrentTab <> 2) 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(2)) then Exit;
GameTab(2);
if (GetCurrentTab <> 2) 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(5);
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(5);
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(5);
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(8);
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(11);
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(11);
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(12);
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;

The gametab functions now work. I just need a colour for Summoning, for TabExists, as I am F2P. Also StatChars needs updating as Jagex has discovered a new font. If there are any more problems, let me know.

Crazydictator

2009-07-08 19:40:55

If it will help you can use one of my accounts which is P2P.

Rich

2009-07-08 19:43:52

That would be much appreciated Crazydictator. Would you PM me the user and password, and I'll be on the account for 1 minute max.

Richard

Crazydictator

2009-07-08 19:45:50

Pmed you it =D

Crazydictator

2009-07-08 21:21:49

Here isa screenshot of my noob screen, you can get the color from there?

Rich

2009-07-08 21:23:25

No, I can't. I think you have to have an animal on you, and that the tab is meant to be in between Magic and Friends, where the gap is.

Thanks for the help,
Richard

Crazydictator

2009-07-08 21:25:59

No idea why it doesn't appear….

Torrent of Flame

2009-07-08 21:34:31

From: Crazydictator
No idea why it doesn't appear….


You need a creature summoned.

Feroc1ty

2009-07-08 21:36:44

I'm getting a bunch of compile errors, such as WaitFindColor identifier error..

Rich

2009-07-08 21:39:05

From: Feroc1ty
I'm getting a bunch of compile errors, such as WaitFindColor identifier error..


Get the latest Dev Rev, and this is the completely wrong thread to post it in.

Feroc1ty

2009-07-08 23:07:59

From: R1ch
Get the latest Dev Rev, and this is the completely wrong thread to post it in.


It's completely wrong to post a compile error of a script on the thread that the script was originally posted at?

Rich

2009-07-08 23:11:53

Well, ok then, but you still need the Dev Rev.

EDIT: You tried to run the code above on its own?

Dynamite

2009-07-08 23:46:38

:'( I made this but Zephy told me he already done, so I didnt post.

T~M

Rich

2009-07-09 00:14:23

I think Zephy has made a temporary one, because he said that the inventory is still 4.

Feroc1ty

2009-07-09 01:06:26

From: R1ch
Well, ok then, but you still need the Dev Rev.

EDIT: You tried to run the code above on its own?


I have SRL#35, I don't really understand what you mean Dev Rev, because I'm pretty new to SCAR scripting scene, and no I'm not dumb enough to run the code on it's own.

[JS]

2009-07-09 01:32:19

From: Feroc1ty
I have SRL#35, I don't really understand what you mean Dev Rev, because I'm pretty new to SCAR scripting scene, and no I'm not dumb enough to run the code on it's own.


In you Includes>SRL>SRL>Core folder there should be a file saying Gametab.scar Replace the code with the one given above and that is the fix.

Feroc1ty

2009-07-09 01:40:57

From: [JS]
In you Includes>SRL>SRL>Core folder there should be a file saying Gametab.scar Replace the code with the one given above and that is the fix.


If you knew how to read you'd realize that that's what I did, but I get compile error.

[JS]

2009-07-09 01:45:17

From: Feroc1ty
If you knew how to read you'd realize that that's what I did, but I get compile error.


If i knew how to read? clearly you put "I have SRL#35, I don't really understand what you mean Dev Rev"

Coh3n

2009-07-09 02:21:09

Are you sure the GameTab(9) is for summoning? In the update, they said all you have to do is right click on the Summoning icon near the minimap to get the Summoning interface. They also said that they had plans for the blank "tab".

Feroc1ty

2009-07-09 04:48:23

From: [JS]
If i knew how to read? clearly you put "I have SRL#35, I don't really understand what you mean Dev Rev"


No comment, just a /me facepalm.


Anyways, I have the latest dev rev in my includes folder, yet I'm getting the error, do I have to include it in the script somehow?

Blender

2009-07-09 05:43:40

I'm a member.

Anyone need pictures of tabs, etc?

Awkwardsaw

2009-07-09 06:00:24

they moved the summoning tab. it is now at the litle icon near the minimap, although you still need a familier to get to it, and a right click. im not sure if this has been posted yet but i havnt seen any so far :P

and if you still need an account i can lend you mine r1ch

Rich

2009-07-09 10:32:14

Nah, don't worry Awkwardsaw, I'll fix it later on.

marpis

2009-07-09 11:54:15

btw here's GameTab() the shorter way:

function GameTab(tab: integer): boolean;
var
x, y, fx, fy: integer;
begin
result := true;
if not InRange(Tab, 1, 16) then
begin
srl_Warn('GameTab', IntToStr(tab) + ' is not a valid GameTab', warn_AllVersions);
Result := False;
Exit;
end;
if not TabExists(tab) then
begin
srl_Warn('GameTab', IntToStr(tab) + ' does not exist', warn_Notice);
Result := False;
Exit;
end;
if (GetCurrentTab = tab) then exit;
y := 186 + Integer(tab >= 9)*296;
x := 535 + (tab - 1 - (Integer(tab >= 9)*8))*30;
Mouse(x, y, 5, 5, true);
wait(100+random(100));
result := GetCurrentTab = tab;
end;

edit: added here the warning things and it actually isn't that much shorter :p