SCAR Code:
//-----------------------------------------------------------------//
//-- 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
// * function MaxNotes : Boolean; // * by R1ch
// * function NotesPresent : Boolean; // * by R1ch
// * function MakeNewNote(Note : string; IfMaxDelete : Boolean; Amount : Integer) : Boolean; // * by R1ch
// * function DeleteNotes(Amount : Integer); : Boolean; // * by R1ch
//****************************************************************************//
// * 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(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
1..8: Coords := Point(525 + ((tabnumber -1) * 30), 187);
9..16: Coords := Point(525 + ((tabnumber -1) * 30), 486);
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;
{*******************************************************************************
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;
//****************************************************************************//
// * GameTab 16 Related Functions.
//****************************************************************************//
{*******************************************************************************
function MaxNotes : Boolean;
By: R1ch
Description: Returns true if you can not write any more notes.
*******************************************************************************}
{*******************************************************************************
function MaxNotes : Boolean;
By: R1ch
Description: Returns true if you can not write any more notes.
*******************************************************************************}
function MaxNotes : Boolean;
begin
Result:= GetChatBoxText(clMessage, 8) = 'You can only store 30 notes';
end;
{*******************************************************************************
function NotesPresent : Boolean;
By: R1ch
Description: Checks if there are notes already written.
*******************************************************************************}
function NotesPresent : Boolean;
var
X, Y : Integer;
begin
GameTab(16);
Result:= FindColor(X, Y, 0, MIX1, MIY1, MIX2, MIY2);
end;
{*******************************************************************************
function MakeNewNote(Note : string; IfMaxDelete : Boolean; Amount : Integer) : Boolean;
By: R1ch
Description: Makes a new note. If you can make no more notes, it will delete
Amount notes depending on IfMaxDelete.
*******************************************************************************}
function MakeNewNote(Note : string; IfMaxDelete : Boolean; Amount : Integer) : Boolean;
begin
GameTab(16);
Wait(500 + Random(1000));
Mouse(565, 217, 6, 6, True);
Wait(750 + Random(750));
if ((MaxNotes) and (IfMaxDelete)) then
DeleteNotes(Amount);
TypeSend(Note);
Result:= True;
end;
{*******************************************************************************
function DeleteNotes(Amount : Integer); : Boolean;
By: R1ch
Description: Deletes Amount notes.
*******************************************************************************}
function DeleteNotes(Amount : Integer) : Boolean;
var
I, X, Y : Integer;
begin
GameTab(16);
for I:= 1 to Amount do
begin
if NotesPresent then
begin
Mouse(X, Y, 25, 3, True);
Wait(1000 + Random(750));
Mouse(640, 450, 88, 6, True);
end;
end;
end;