TRiLeZ
2010-02-02 00:28:42
//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- ยป GameTab Routines I --//
//-----------------------------------------------------------------//
// * function GetCurrentTab: Integer; // * by ZephyrsFury
// * function TabExists(Tab: Integer): Boolean; // * by ZephyrsFury
// * function GameTab(Tab: Integer): Boolean; // * by ZephyrsFury
// * function SetFightMode(oFightMode: Integer): Boolean; // * by Nielsie95 & Nava2, fixed by Quickmarch
// * 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 NaumanAkhlaQ
// * function SkillToCoords(ScrollDownIfNeeded: Boolean; 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 IsResting: Boolean; // * by Sabzi
// * function GetMMLevels: integer; // * by Raymond / Wizzup? / Sabzi
// * 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 EquipmentCoords(EquipSlot: Integer): TPoint; // * by RsN modded by WT-Fakawi and Nielsie95
// * 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
// * procedure TakeOffAllExcept(ExceptionSlots: TIntegerArray); // * by EvilChicken!
// * procedure TakeOffAllItems; // * by EvilChicken!
// * function CountEquippedItems: Byte; // * by EvilChicken!
// * function CurrentWorld: Integer; // * by Cheesehunk, edited by Ron and fixed by ZephyrsFury
// * 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 NaumanAkhlaQ
//*****************************************************************//
type
TSMSetting = (Stereo, Mono, NoChange);
{ const GameTab Constants;
Description: Constants representing gametab numbers. }
const
tab_Combat = 21;
tab_Stats = 22;
tab_Quest = 23;
tab_Diary = 24;
tab_Inv = 25;
tab_Equip = 26;
tab_Prayer = 27;
tab_Magic = 28;
tab_Objectives = 29;
tab_Friends = 30;
tab_Ignore = 31;
tab_Clan = 32;
tab_Options = 33;
tab_Emotes = 34;
tab_Music = 35;
tab_Notes = 36;
tab_LogOut = 37;
{*******************************************************************************
function GetCurrentTab: Integer;
By: ZephyrsFury
Description: Returns current tab.
*******************************************************************************}
function GetCurrentTab: Integer;
var
tP: TPoint;
begin
if (not LoggedIn) then exit;
for Result := 1 to 16 do
begin
tP.X := 535 + (Result - 1) mod 8 * 30;
tP.Y := 169 + (Result - 1) div 8 * 298;
if (GetColor(tP.X, tP.Y) = 3775974) then
Break;
end;
result := result + 20; //SO IT ACTUALLY WORKS WITH THE TABS KTHX
end;
{*******************************************************************************
function TabExists(Tab: Integer): Boolean;
By: ZephyrsFury
Description: Returns True if the Tab exists.
*******************************************************************************}
function TabExists(Tab: Integer): Boolean;
var
tP: TPoint;
begin
if (tab < 20) then
begin
SRL_Warn('TabExists', 'Tab ' + IntToStr(Tab) + ' is not using the new constants! Please upgrade your script.', warn_AllVersions);
Exit;
end;
if (not(InRange(Tab, Tab_Combat, Tab_LogOut))) then
begin
SRL_Warn('TabExists', 'Tab ' + IntToStr(Tab) + ' is not a valid tab number.', warn_AllVersions);
Exit;
end;
if (Tab = tab_LogOut) then
begin
Result := (GetColor(753, 6) = 6327197);
Exit;
end;
tP := Point(536 + (Tab - 21) mod 8 * 30, 187 + (Tab - 21) div 8 * 298);
Result := (GetColor(tP.X, tP.y) <> 4478564);
end;
{*******************************************************************************
function GameTab(Tab: Integer): Boolean;
By: ZephyrsFury
Description: Switches to a specific game tab.
*******************************************************************************}
function GameTab(Tab: Integer): Boolean;
var
tP: TPoint;
T, Tries: Integer;
begin
if (not(InRange(Tab, Tab_Combat, Tab_LogOut))) then
begin
SRL_Warn('GameTab', 'Tab ' + IntToStr(Tab) + ' is not a valid tab number.', warn_AllVersions);
Exit;
end;
if (tab < 20) then
begin
SRL_Warn('GameTab', 'Tab ' + IntToStr(Tab) + ' is not using the new constants! Please update your script.', warn_AllVersions);
Exit;
end;
Result := (GetCurrentTab = Tab);
if (Result) then exit;
if (TabExists(Tab)) then
begin
tP := Point((Tab - 21) mod 8 * 30 + RandomRange(527, 545), (Tab - 21) div 8 * 298 + RandomRange(177, 197));
if (Tab = tab_LogOut) then
tP := Point(RandomRange(747, 760), RandomRange(3, 18));
Tries := 0;
while (Tries < 3) do
begin
Mouse(tP.X, tP.Y, 0, 0, True);
T := GetSystemTime;
while (not Result) and (GetSystemTime - T < 2000) do
begin
Result := (GetCurrentTab = Tab);
Wait(100 + Random(100));
end;
Inc(Tries);
end;
end else
SRL_Warn('GameTab', 'GameTab ' + IntToStr(Tab) + ' is not a valid tab number.', warn_Notice);
end;
//****************************************************************************//
// * GameTab 1 Related Functions.
//****************************************************************************//
{*******************************************************************************
function SetFightMode(oFightMode: Integer): Boolean;
By: Nielsie95 & Nava2, fixed by Quickmarch
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: TBoxArray;
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(GetColor(670, 329) = srl_outline_black)) 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: TIntegerArray;
TB: TBox;
TP: TPointArray;
begin
Result := False;
if (not LoggedIn) then exit;
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);
GetClientDimensions(TB.X2, TB.Y2);
TB := IntToBox(0, 0, TB.X2, TB.Y2);
FindColors(TP, 10551295, TB.X1, TB.Y1, TB.X2, TB.Y2);
if (Length(TP) = 0) then exit;
TB := GetTPABounds(TP);
Inc(TB.Y1);
for ii := 0 to 3 do
begin
if (Pos(Lowercase(Kind), LowerCase(GetTextAtEx(TB.X1 + 1, TB.Y1, 0, SmallChars,
False, True, 0, 1, - 1, 30, False, tr_AlphaNumericChars))) <> 0) then
begin
Result := SetFightMode(I + 1);
Exit;
end;
IncEx(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
if (GetCurrentTab <> tab_Combat) then
begin
GameTab(tab_Combat);
Wait(500 + Random(500));
end;
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. }
{ consts in Players.scar ; Here is the list for easier access
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: NaumanAkhlaQ
Description: Returns Coords of Skill's Row and Column (Used for GetSkill functions)
*******************************************************************************}
function SkillCoords(Row, Column : ShortInt): TPoint;
begin
Result := Point(577 + (55 * (Column - 1)), 233 + (32 * (Row - 1)));
if (Row = 8) then Result.Y := 424;
end;
{*******************************************************************************
function SkillToCoords(ScrollDownIfNeeded: Boolean; Skill: Variant): TPoint;
By: Masquerader, Cheesehunk, Raymond, Wizzup?, ZephyrsFury & Timer
Description: Turns skill string into tpoint.
If Scroll returns true then you must scroll down.
*******************************************************************************}
function SkillToCoords(ScrollDownIfNeeded: Boolean; Skill: Variant): TPoint;
var
SkillArr: TStringArray;
CX, CY, Col, skNo: Integer;
ScrollP: TPoint;
SkillS: string;
Scroll: Boolean;
begin
if (not LoggedIn) then exit;
if (VarType(Skill) = VarType(0)) 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), 0), 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, 22, 24));
ScrollP := Point(724, 245 + 192 * 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, 244) = 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)
if (not(Amount)) then
TP := Point(TP.x + 7,TP.y + 15);
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(0);
FindColors(TPA, 65535, TP.x - 2, TP.y - 2, TP.x + 15, TP.y + 15);
Box := GetTPABounds(TPA);
Result := StrToIntDef(GetNumbers(GetTextAtEx(Box.x1 - 2, Box.y1 -1, 100,
StatChars, False, True, 0, 3,65535, 3, 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 IsResting: Boolean;
By: Sabzi
Last Edit: 19 Sep 2009
Description: Returns True if you are currently resting.
*******************************************************************************}
function IsResting: Boolean;
begin
Result := (GetColor(728, 114) = 1919769);
end;
{*******************************************************************************
Function GetMMLevels(LevelType : String;var ColorSign : String): integer;
By: Raymond / Wizzup / Sabzi
Last Edit: 19 Sep 2009
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
Colors : TIntegerArray;
Signs: TStringArray;
P: TPointArray;
TP: TPoint;
I: Integer;
B: TBox;
T, x, y: Integer;
Run: Boolean;
begin;
Result := -1;
ColorSign := '';
case LowerCase(Leveltype) of
'health', 'hp', 'hitpoints': TP := Point(729,29);
'prayer', 'pray' : TP := Point(746,68);
'run','energy' :
begin
TP := Point(740,107);
Run := True;
end;
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
if Run then
begin
MarkTime(T);
repeat
begin
if not IsResting then Break;
if not FindColorComp(x, y, clYellow, ccBlue, 737, 107, 742, 108, 130) then Break;
end;
until (TimeFromMark(T) >= 5000);
end;
FindColorsTolerance(P, Colors[i], TP.X - 5, TP.Y - 5, TP.X + 40, TP.Y + 20, 30);
if (Length(P) < 1) then continue;
B := GetTPABounds(P);
Result := StrToIntDef(GetNumbers(GetTextAtEx(B.X1 - 1 , B.Y1 - 1, 30, statChars,
False, False, 0, 0, Colors[i], 20, False, tr_Digits)), -1);
if (Result > 0) then
begin
ColorSign := Signs[i];
Exit;
end;
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;
begin
Result := -1;
if (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);
if (not WaitFindColor(x, y, 10551295, MIX1, MIY1, MIX2, MIY2, 0, 4000)) then exit;
Wait(200 + Random(150));
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 until you level up in a skill.
Returns -1 if failed.
*******************************************************************************}
function XPTillNextLevel(Skill: Variant): Integer;
var
P: TPoint;
X, Y, tx, ty: Integer;
begin
Result := -1;
if (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);
if (not WaitFindColor(x, y, 10551295, MIX1, MIY1, MIX2, MIY2, 0, 4000)) then exit;
Wait(200 + Random(150));
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.
Does not switch tabs if Players[CurrentPlayer].Level[8] (HP level) is set.
Returns -1 if failed.
*******************************************************************************}
function HPPercent: Integer;
var
ColorString: string;
begin
if (Players[CurrentPlayer].Level[8] < 1) then
Players[CurrentPlayer].Level[8] := Max(1, GetSkillInfo('hitpoints', False));
if (Players[CurrentPlayer].Level[8] > 1) then
Result := Round(GetMMLevels('hp', ColorString) * 100 / Players[CurrentPlayer].Level[8])
else
Result := -1;
end;
{****************************************************************************//
procedure GetAllLevels;
Bsy: WT-Fakawi & ZephyrsFury
Description: Sets all 24 skilllevels to Players.Level[1..24]
* 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;
//****************************************************************************//
// * GameTab 4 Related Functions. SEE ALSO INVENTORY.SCAR
//****************************************************************************//
//****************************************************************************//
// * GameTab 5 Related Functions.
//****************************************************************************//
{*******************************************************************************
function EquipmentCoords(EquipSlot: 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(EquipSlot: Integer): TPoint;
begin
case EquipSlot of
1: Result := Point(640, 225);
2: Result := Point(600, 266);
3: Result := Point(640, 266);
4: Result := Point(684, 266);
5: Result := Point(588, 304);
6: Result := Point(644, 304);
7: Result := Point(700, 304);
8: Result := Point(642, 343);
9: Result := Point(588, 384);
10: Result := Point(643, 384);
11: Result := Point(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', 'shield' :
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; ClickType: 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, ClickType);
end;
{*******************************************************************************
function WearingItem(i: Integer): Boolean;
By: RsN
Description: Results True if an item is equipped at equpiment slot defined by I.
*******************************************************************************}
function WearingItem(I: Integer): Boolean;
var
X, Y: Integer;
TP: TPoint;
begin
if (not InRange(I, 1, 11)) then
begin
srl_Warn('WearingItem', 'Equipment slot #' + IntToStr(I) + ' is not a valid equipment slot', warn_Warning);
Exit;
end;
if (GetCurrentTab <> tab_Equip) then
begin
GameTab(tab_Equip);
if GetCurrentTab <> tab_Equip then exit;
Wait(750 + Random(500));
end;
TP := EquipmentCoords(I);
Result := FindColor(X, Y, srl_outline_black, TP.x - 8, TP.y - 8, TP.x + 8, TP.y + 8);
end;
{*******************************************************************************
procedure TakeOff(I: Integer);
By: RsN
Description: UnEquips Item specified in i.
*******************************************************************************}
procedure TakeOff(I: Integer);
var
TP: TPoint;
begin
TP := EquipmentCoords(I);
if (WearingItem(I)) then
begin
Mouse(TP.x, TP.y, 5, 5, True);
Wait(200 + Random(350));
end;
end;
{*******************************************************************************
procedure TakeOffAllExcept(ExceptionSlots: TIntegerArray);
By: EvilChicken!
Description: Takes off equpped items defined by StripSlots.
*******************************************************************************}
procedure TakeOffAllExcept(ExceptionSlots: TIntegerArray);
var
I: Integer;
begin
for I := 1 to 11 do
if (not InIntArray(ExceptionSlots, I)) then
TakeOff(I);
end;
{*******************************************************************************
procedure TakeOffAllItems;
By: EvilChicken!
Description: Takes off all equipped items.
*******************************************************************************}
procedure TakeOffAllItems;
begin
TakeOffAllExcept([]);
end;
{*******************************************************************************
function CountEquippedItems: Byte;
By: EvilChicken!
Description: Counts the amount of equpped items.
*******************************************************************************}
function CountEquippedItems: Byte;
var
I: Integer;
begin
Result := 0;
for I := 1 to 11 do
if WearingItem(I) then
Inc(Result);
end;
//****************************************************************************//
// * GameTab 6 Related Functions.
//****************************************************************************//
//****************************************************************************//
// * GameTab 7 Related Functions.
//****************************************************************************//
//****************************************************************************//
// * GameTab 8 Related Functions.
//****************************************************************************//
{*******************************************************************************
function CurrentWorld: Integer;
By: Cheesehunk and Ron, fixed by ZephyrsFury
Description: Returns the current world you are on.
*******************************************************************************}
function CurrentWorld: Integer;
var
TextX, TextY: Integer;
begin
Result := -1;
if (GetCurrentTab <> tab_Friends) then
begin
GameTab(tab_Friends);
Wait(250 + Random(500));
end;
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 Player''s 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
Last Edit: 19 Sep 2009
Description: Turns Rest on. Result True if successful.
*******************************************************************************}
function SetRest: Boolean;
var
T: Integer;
begin
Result := False;
if (not(IsResting)) then
begin
Mouse(715, 95, 10, 10, False);
if (WaitOption('Rest', 300)) then
begin
T := GetSystemTime;
while (not(Result)) and (GetSystemTime - T < 5000) do
begin
Result := IsResting;
Wait(100);
end;
end;
end;
end;
{*******************************************************************************
function RestUntil(Energy: Integer): Boolean;
By: ZephyrsFury
Last Edit: 19 Sep 2009
Description: Rests until your Run energy is above Energy. Results True if
successful.
*******************************************************************************}
function RestUntil(Energy: Integer): Boolean;
var
S: string;
begin
Result := (GetMMLevels('run', S) >= Energy);
if (Result) then exit;
SetRest;
while (GetMMLevels('run', S) < Energy) do
begin
Result := IsResting;
if (not(Result)) then exit;
if (SRL_Procs[srl_AntiBan] <> nil) then
SRL_Procs[srl_AntiBan]();
Wait(100 + Random(50));
end;
end;
const
SD_Color = 3655748;
Fixed_Color = 8388607;
ScreenSize_Color = 2070783;
ScreenSize_Count = 142;
//ScreenSize_Box = IntToBox(403, 163, 459, 176);
ScreenSize_Box_x1 = 403;
ScreenSize_Box_y1 = 163;
ScreenSize_Box_x2 = 459;
ScreenSize_Box_y2 = 176;
Bright_Color = 15736607;
WhiteText_Color = 16777215;
YellowText_Color = 2070783;
MenuYellow_Color = 8388607;
MenuBrown_Color = 468031;
{*******************************************************************************
Procedure FixGraphics;
By: Rasta Magician fixed by TRiLeZ
Rev: 224
Date: 02 Sep 09
Description: Fixes the Graphic Options if LoggedIn
*******************************************************************************}
Procedure FixGraphics;
var
TPA: TPointArray;
TB: TBox;
TP, TP2: TPoint;
i, x, y: integer;
begin
//This procedure is not versatile, just gets the needed job done
if (not LoggedIn) then exit;
CloseWindow;
if (not FindColor(x, y, 0, 7, 460, 69, 474)) then
if (not ClickContinue(True, True)) then
Mouse(MMCX, MMCY, 2, 2, True);
i := 0;
while (not FindTextTPA(2071039, 0, MSX1, MSY1, MSX2, MSY2, 'Graphics Settings', UpChars, Nothing)) and (LoggedIn) do
begin
GameTab(tab_Options);
MouseBox(605, 258, 623, 277, 1);
Wait(1000 + Random(500));
Inc(i);
if (i > 3) then
begin
srl_Warn('SetGraphics', 'Could not open Graphics Options screen', warn_Warning);
CloseWindow;
Exit;
end;
end;
if not (GetColor(220, 82) = SD_Color) then
begin
//Checks for the green arrow, clicks middle of box
Mouse(219, 85, 5, 5, True);
if not WaitColor(219, 85, SD_Color, 0, 2000) then
FixGraphics;
end;
if not (GetColor(157, 156) = Fixed_Color) then
begin
//checks for the yellow color in Fixed Screen sizing
//clicks middle of box
Mouse(168, 138, 5, 5, True);
if not WaitColor(157, 174, Fixed_Color, 0, 2000) then
FixGraphics;
end;
{FindColors(TPA, ScreenSize_Color, ScreenSize_Box_x1,
ScreenSize_Box_y1, ScreenSize_Box_x2,
ScreenSize_Box_y2);
if not (Length(TPA) = ScreenSize_Count) then
begin
//clicks middle of box
Mouse(433, 170, 7, 2, True);
//waits for menu
if WaitColor(475, 162, 8388607, 0, 500) then
Mouse(431, 185, 7, 2, True); //clicks 800x600
end;}
if not (GetColor(235, 199) = Bright_Color) then
begin
//checks for blue ball, clicks Max Brightness
Mouse(235, 199, 3, 3, True);
if not WaitColor(235, 199, Bright_Color, 0, 3000) then
FixGraphics;
end;
//now onto the advanced options
//each box is 15px vertically
//counting from the first layer of brown on top
//and first layer of brown on bottom
for i:= 0 to 5 do //6 options on left column
begin
if FindColor(x, y, WhiteText_Color, 188, 224+16*i, 219, 239+16*i) then
begin
Mouse(188, 224+15*i+7, 40, 3, True); //click middle of box
if WaitColor(188, 224+(16*i), MenuYellow_Color, 0, 1000) then
begin
FindColors(TPA, MenuYellow_Color, 172, 224+16*i, 248, 224+16*i+16*2);
//x - 172 = start of menu ; x - 248 = end of menu
//224+15*i+15*2 = start of menu + 2 options
TB := GetTPABounds(TPA); //--> scar fuck up
if not FindColors(TPA, YellowText_Color, TB.x1, TB.y1, TB.x2, TB.y2) then
writeln(inttostr(Length(TPA)));
TP := MiddleTPA(TPA);
Mouse(TP.x, TP.y, 3, 3, True);
if not WaitColor(188, 224+16*i, MenuBrown_Color, 0, 500+Integer(i=4)*3000) then
FixGraphics;
end else
FixGraphics;
end;
wait(random(500));
end;
for i := 0 to 5 do //6 options on right column
begin
if FindColor(x, y, WhiteText_Color, 437, 208+16*i, 460, 223+16*i) then
begin
Mouse(437, 208+16*i+7, 40, 3, True); //click middle of box
if WaitColor(437, 208+16*i, MenuYellow_Color, 0, 500) then
begin
FindColors(TPA, MenuYellow_Color, 418, 208+16*i, 494, 208+16*i+16*3)
//x - 418 = start of menu ; x - 494 = end of menu
//208+15*i+15*3 = start of menu + 3 options
TB := GetTPABounds(TPA); // --> Scar fuck up.
//TB := IntToBox(418, 208+15*i, 494, 208+15*i+15*2);
FindColors(TPA, YellowText_Color, TB.x1, TB.y1, TB.x2, TB.y2);
TP := Point(418, 208+16*i);
SortTPAFrom(TPA, TP); //all this TPA manipulation is needed because
TP := TPA[0]; //animations have 3 options, while the others have 2
TP2 := MiddleTPA(TPA);
Mouse(TP2.x, TP.y+3, 3, 3, True);
if not WaitColor(188, 224+15*i, MenuBrown_Color, 0, 5000) then
FixGraphics;
end else FixGraphics;
wait(random(500));
end;
end;
Mouse(491, 22, 2, 2, True); //CloseWindow;
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');
OutDated since 02 Sep 09
*******************************************************************************}
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 (not FindTextTPA(2070753, 0, MSX1, MSY1, MSX2, MSY2, 'Graphics Options', UpChars, Nothing)) and (LoggedIn) do
begin
GameTab(tab_Options);
MouseBox(605, 258, 623, 277, 1);
Wait(500 + Random(200));
Inc(II);
if (II > 3) then
begin
srl_Warn('SetGraphics', 'Could not open Graphics Options screen', warn_Warning);
CloseWindow;
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) = srl_outline_black) 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 + Random(100));
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 + Random(100));
while (CountColor(16777215, 5, 5, 161, 35) > 100) do Wait(100 + Random(50));
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 (not FindTextTPA(2070753, 0, MSX1, MSY1, MSX2, MSY2, 'Audio Options', UpChars, Nothing)) and (LoggedIn) do
begin
GameTab(tab_Options);
MouseBox(654, 252, 677, 278, 1);
Wait(500 + Random(200));
Inc(C);
if (C > 3) then
begin
srl_Warn('SetAudio', 'Could not open Audio Options screen', warn_Warning);
CloseWindow;
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 + Random(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: NaumanAkhlaQ
Description: Clicks on an emote specified by EmoteNumber (1 to 37)
*******************************************************************************}
procedure DoEmote(EmoteNumber: Integer);
var
I, X, Y, Row, Col: Integer;
begin
if (not InRange(EmoteNumber, 1, 47)) then
begin
srl_Warn('DoEmote', 'Invalid EmoteNumber: ' + IntToStr(EmoteNumber) + ', Valid Emotes: 1..46', warn_AllVersions);
Exit;
end;
if (GetCurrentTab <> tab_Emotes) then
begin
if (not GameTab(tab_Emotes)) then exit;
Wait(500 + Random(750));
end;
case EmoteNumber of
01..20: if (GetColor(723, 226) = 2106924) then
Mouse(723, 226, 8, 4, True);
21..40: if (GetColor(727, 364) = 1975337) then
Mouse(727, 364, 4, 1, True);
41..46: if (GetColor(725, 438) = 1975337) then
Mouse(725, 438, 5, 5, True);
end;
Wait(300 + Random(200));
if InRange(EmoteNumber, 21, 40) then
I := 20
else
if InRange(EmoteNumber, 41, 46) then I := 28;
DecEx(EmoteNumber, I);
Row := Trunc(EmoteNumber / 4) + 1;
if ((EmoteNumber mod 4) = 0) then Dec(Row);
Col := (EmoteNumber mod 4);
if (Col = 0) then Col := 4;
X := 550 + (44 * (Col - 1));
Y := 219 + (49 * (Row - 1));
Mouse(X, Y, 26, 39, True);
end;
Fixed the constant colors for FixGraphics… Jagex changed em on me! :p