Brandon
06-05-2012, 03:13 AM
Due to SRL's awful style of file comments the line error is probably at an offset and has been happening to me to for various files when an exception occurs. Usually removing the comments helps pinpoint it. I can't be the only one who hates the look of the documentation..
Anyway try this and when you get the error, post which line you got it on then we can see.. If it's on the same line of code then try installing: http://nala.villavu.com/downloads/master/2660cd951f0ebdebc969fadfa052e2d1ff482854/
type
TSMSetting = (Stereo, Mono, NoChange);
{ const LobbyTab Constants;
Description: Constants representing lobbytab numbers. }
const
L_PlayerInfo = 1;
L_WorldSelect = 2;
L_FriendsList = 3;
L_FriendsChat = 4;
L_ClanChat = 5;
L_Options = 6;
function GetCurrentTab: Integer;
var
tP: TPoint;
begin
Result := -1;
if (not LoggedIn) then exit;
for Result := 0 to (tab_LogOut - tab_Combat)-1 do
begin
tP.X := 535 + Result mod 8 * 30;
tP.Y := 169 + Result div 8 * 298;
if (GetColor(tP.X, tP.Y) = 3775974) then
Break;
end;
Result := Result + tab_Combat;
if BankScreen then
Result := tab_Inv;
end;
function TabExists(tab: integer): boolean;
var
b: TBox;
tmpCTS: integer;
begin
result := false;
if (not loggedIn) then
exit;
if (not inRange(tab, TAB_COMBAT, TAB_LOGOUT)) then
begin
SRL_Warn('TabExists', 'Tab ' + toStr(Tab) + ' is not a valid tab number.', warn_AllVersions);
exit;
end;
// requires CTS 1, may result in false negatives if CTS 2
tmpCTS := getColorToleranceSpeed;
colorToleranceSpeed(1);
if (tab = TAB_INV) then
if (bankScreen) then
begin
colorToleranceSpeed(tmpCTS);
result := true;
exit;
end;
if (tab = TAB_LOGOUT) then
begin
result := (getColor(746, 0) = 65536);
colorToleranceSpeed(tmpCTS);
exit;
end;
// small boxes inside the tabs (hardly any of the background showing)
b := gridBox(tab - 20, 8, 2, 13, 18, 30, 300, point(536, 186));
// the color of the tab background
result := (countColorTolerance(5005422, b.x1, b.y1, b.x2, b.y2, 55) < 250); // actual count should be 266
colorToleranceSpeed(tmpCTS);
end;
function GameTab(Tab: Integer): Boolean;
var
tP: TPoint;
T, Tries: Integer;
begin
if (not LoggedIn) then
Exit;
Result := false;
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;
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) and (not Result)) do
begin
Mouse(tP.X, tP.Y, 0, 0, mouse_left);
T := GetSystemTime;
while (not Result) and (GetSystemTime - T < 2000) do
begin
Result := (GetCurrentTab = Tab);
Wait(100 + Random(100));
end;
Inc(Tries);
end;
if (Result) then
Wait(250 + Random(300));
end else
SRL_Warn('GameTab', 'GameTab ' + IntToStr(Tab) + ' is not a valid tab number.', warn_Notice);
end;
function FTab(Tab: integer): boolean;
var
T, F: integer;
begin
if (GetCurrentTab = Tab) then
begin
result := true;
Exit;
end;
Case Tab of
tab_Inv: F := 1;
tab_Equip: F := 2;
tab_Prayer: F := 3;
tab_Magic: F := 4;
tab_Combat: F := 5;
else
writeln('Tab '+inttostr(tab)+' isn''t a valid option.');
end;
T := GetSystemTime + 2000;
Repeat
TypeByte(111+F);
Wait(150+random(100));
Result := GetCurrentTab = Tab;
until Result or (GetSystemTime > T);
end;
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 (oFightMode = 4) and (not FindColor(x, y, 2070783, 660, 310, 710, 345)) then
b := cmbBoxes[2];
i := 0;
while (i < 4) do
begin
Result := FindColorTolerance(x, y, 1323362, b.x1, b.y1, b.x2, b.y2, 2);
if (Result) then Exit;
MouseBox(b.x1, b.y1, b.x2, b.y2, mouse_left);
Wait(500 + Random(300));
Inc(i);
end;
end;
Function GetWeaponName: String;
begin
if GameTab(tab_Combat) then
Result := GetTextAtExWrap(584, 208, 734, 226, 0, 3, 4, 3907053, 0, UpChars);
end;
function GetWeaponData(var WArr: array of TStringArray): Boolean;
var
x, y, i, ii, H, L: integer;
TB: TBox;
TP: TPointArray;
T: TPoint;
begin
Result := False;
if (not LoggedIn) then
Exit;
if not GameTab(tab_Combat) then
Exit;
for i := 0 to 3 do
begin
T := Point(680-(i+1) mod 2*85, 270+2 mod (i+1)*28);
if CountColor(2070783, T.x - 27, T.y-18, T.x + 40, T.y + 22) > 10 then
Inc(L);
end;
SetArrayLength(WArr, L);
for I := 0 to L-1 do
begin
MMouse(680-(i+1) mod 2*85, 270+2 mod (i+1)*28, 12, 12);
wait(100+random(50));
WaitFindColor(X, Y, 15133931, MIX1-10, MIY1-10, MIX2+10, MIY2+10, 0, 3000);
GetClientDimensions(TB.X2, TB.Y2);
TB := IntToBox(0, 0, TB.X2, TB.Y2);
FindColors(TP, 15133931, TB.X1, TB.Y1, TB.X2 - 1, TB.Y2 - 1);
if (Length(TP) < 1) then
Continue;
TB := GetTPABounds(TP);
H := ((TB.y2-TB.y1)/17)-1;
SetArrayLength(WArr[i], H+1);
for ii := 0 to H do
begin
WArr[i][ii] := GetTextAtExWrap(TB.x1+1, TB.y1+2, TB.x2, TB.y1+18, 0, 3, 4, 4305653, 0, smallChars);
Debugln(WArr[i][ii]);
Result := (WArr[i][ii] <> '');
IncEx(TB.Y1, 16);
end;
end;
end;
Function SetWeaponMode(Skill: string; WeaponData: array of TStringArray; SetIt: boolean): boolean;
var
i, ii: integer;
begin
for i := 0 to High(WeaponData) do
for ii := 0 to High(WeaponData[i]) do
if (Pos(Lowercase(skill), Lowercase(WeaponData[i][ii])) <> 0) then
begin
if SetIt then
Result := SetFightMode(i + 1)
else
Result := True;
Exit;
end;
end;
function SetCombatType(Skill: string): Boolean;
var
WeapArr: array of TStringArray;
begin
if GetWeaponData(WeapArr) then
Result := SetWeaponMode(Skill, WeapArr, true)
else
Result := False;
end;
function GetCombatLevel: Integer;
begin
Result := -1;
if not Gametab(tab_Combat) then
exit;
Wait(100 + Random(100));
Result := StrToIntDef(ExtractFromStr(GetTextAtExWrap(680, 229, 718, 245, 0,
3, 4, 3907053, 20, UpChars), Numbers), -1);
end;
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 FindColorTolerance(X, Y, 1125209, 624, 385, 719, 396, 2) then
MouseBox(624, 385, 719, 396, mouse_left);
End;
function SkillCoords(Row, Column : ShortInt): TPoint;
begin
Result := Point(576 + (62 * (Column - 1)), 213 + (28 * (Row - 1)));
end;
function SkillToCoords(Skill: Variant): TPoint;
var
SkillArr: TStringArray;
skNo: Integer;
SkillS: string;
SkillPT : TPoint; //Row/Column
begin
if (not LoggedIn) then exit;
if ((VarType(Skill) = varInteger) or (VarType(Skill) = varByte)) then
skNo := Skill
else
begin;
SkillS := Lowercase(Skill);
case Lowercase(SkillS) of
'hp', 'constitution': SkillS := 'hitpoints';
'ranged': SkillS := 'range';
'hunter': SkillS := 'hunting';
'dung' : skillS := 'dungeoneering';
end;
SkillArr := ['attack', 'defence', 'strength', 'hitpoints', 'range',
'prayer', 'magic', 'cooking', 'woodcutting', 'fletching',
'fishing', 'firemaking', 'crafting', 'smithing', 'mining',
'herblore', 'agility', 'thieving', 'slayer', 'farming',
'runecrafting', 'hunting', 'construction', 'summoning',
'dungeoneering'];
if (not InStrArrEx(SkillS, SkillArr, skNo)) then
begin
srl_Warn('SkillToCoords',
'Invalid Skill Name/Number: ''' + string(Skill) + '''',
warn_AllVersions);
Exit;
end;
end;
case skNo of
Skill_Attack : SkillPT := Point(1,1);
Skill_Strength : SkillPT := Point(1,2);
Skill_Defence : SkillPT := Point(1,3);
Skill_Range : SkillPT := Point(1,4);
Skill_Prayer : SkillPT := Point(1,5);
Skill_Magic : SkillPT := Point(1,6);
Skill_RuneCrafting : SkillPT := Point(1,7);
Skill_Construction : SkillPT := Point(1,8);
Skill_Dungeoneering : SkillPT := Point(1,9);
Skill_Hitpoints : SkillPT := Point(2,1);
Skill_Agility : SkillPT := Point(2,2);
Skill_Herblore : SkillPT := Point(2,3);
Skill_Thieving : SkillPT := Point(2,4);
Skill_Crafting : SkillPT := Point(2,5);
Skill_Fletching : SkillPT := Point(2,6);
Skill_Slayer : SkillPT := Point(2,7);
Skill_Hunter : SkillPT := Point(2,8);
Skill_Mining : SkillPT := Point(3,1);
Skill_Smithing : SkillPT := Point(3,2);
Skill_Fishing : SkillPT := Point(3,3);
Skill_Cooking : SkillPT := Point(3,4);
Skill_FireMaking : SkillPT := Point(3,5);
Skill_WoodCutting : SkillPT := Point(3,6);
Skill_Farming : SkillPT := Point(3,7);
Skill_Summoning : SkillPT := Point(3,8);
else
begin
srl_Warn('SkillToCoords', 'Invalid Skill Number: ''' + inttostr(skNo) + '''', warn_AllVersions);
exit;
end;
end;
Result := SkillCoords(SkillPT.y,SkillPT.x);
end;
function GetSkillInfo(Skill: Variant; Amount : Boolean): Integer;
var
TP: TPoint;
Box : TBox;
TPA : TPointArray;
Cts : Integer;
begin
Result := -1;
GameTab(tab_Stats);
TP := SkillToCoords(Skill);
if (not(Amount)) then
TP := Point(TP.x + 15,TP.y + 12);
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(0);
if not FindColors(TPA, 36095, TP.x - 2, TP.y - 2, TP.x + 15, TP.y + 15) then
begin
ColorToleranceSpeed(CTS);
exit;
end;
Box := GetTPABounds(TPA);
Result := StrToIntDef(GetNumbers(GetTextAtEx(Box.x1 - 2, Box.y1 -1, 100,
StatChars, False, True, 0, 3, 36095, 3, True, tr_Digits)), -1);
ColorToleranceSpeed(CTS);
end;
function GetSkillLevel(Skill: Variant): Integer;
begin
Result := GetSkillInfo(Skill, False);
end;
function IsResting: Boolean;
begin
result := (CountColorTolerance(3712343,707, 95,732, 122,10)>10);
end;
function GetMMLevels(LevelType: string; var ColorSign: string): Integer;
var
Colors : TIntegerArray;
Signs: TStringArray;
P: TPointArray;
I: Integer;
B: TBox;
begin;
Result := -1;
ColorSign := '';
case LowerCase(Leveltype) of
'health', 'hp', 'hitpoints', 'constitution': B := IntToBox(719,27,745,43);
'prayer', 'pray' : B := IntToBox(735,66,762,82);
'run','energy' : B := IntToBox(735,103,762,122);
'summon', 'summoning' : B := IntToBox(719,119,745,156);
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
With B do
FindColorsTolerance(P, Colors[i], x1, y1, x2, y2, 30);
if Length(P) < 1 then
Continue;
Result := StrToIntDef(GetNumbers(GetTextAtExWrap(B.X1, B.Y1, B.X2, B.Y2, 0, 4, 4, Colors[i], 20, statChars)), -1);
if (Result > -1) then
begin
ColorSign := Signs[i];
Exit;
end;
end;
end;
function GetXP(skill: variant): integer;
var
b: TBox;
p: TPoint;
tpa: TPointArray;
begin
result := -1;
if (not gameTab(TAB_STATS)) then
exit;
p := skillToCoords(skill);
if (p.x < 1) then
exit;
mmouse(p.x, p.y + 5, 12, 4);
wait(400 + random(200));
if (WaitFindColors(tpa, 15133931, MIX1, MIY1, MIX2, MIY2, 0, 3000)) then
begin
b := getTPABounds(tpa);
wait(400 + random(150));
result := strToIntDef(getNumbers(getTextAt(b.x1 + 15, b.y1 + 15, 0, 1, 4, 4305653, 0, 75, smallChars)), -1);
end;
end;
function XPTillNextLevel(Skill: Variant): Integer;
var
TPA: TPointArray;
P: TPoint;
B: TBox;
begin
Result := -1;
if (not TabExists(tab_Stats)) then exit;
GameTab(tab_Stats);
if (GetCurrentTab <> tab_Stats) then exit;
P := SkillToCoords(Skill);
if (P.x < 1) then exit;
MMouse(P.x, P.y + 5, 12, 4);
wait(400 + random(200));
if (not WaitFindColors(TPA, 15133931, MIX1, MIY1, MIX2, MIY2, 0, 4000)) then exit;
B := GetTPABounds(TPA);
Wait(200 + Random(150));
Result := StrToIntDef(GetNumbers(GetTextAt(B.X1 + 15, B.Y1 + 45, 0, 1, 4, 4305653, 0, 75, SmallChars)), -1);
end;
function HPPercent: Integer;
var
ColorString: string;
begin
if (Players[CurrentPlayer].Level[SKILL_HITPOINTS] < 1) then
Players[CurrentPlayer].Level[SKILL_HITPOINTS] := Max(1, GetSkillInfo('hitpoints', False));
if (Players[CurrentPlayer].Level[SKILL_HITPOINTS] > 1) then
Result := Round(GetMMLevels('hp', ColorString) * 10 / Players[CurrentPlayer].Level[SKILL_HITPOINTS])
else
Result := -1;
end;
procedure GetAllLevels;
var
II: Integer;
begin
try
for II := 0 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;
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);
else
begin
result := Point(-1,-1);
srl_warn('EquipmentCoords','Invalid EquipSlot('+inttostr(EquipSlot)+') passed',warn_AllVersions);
end;
end;
end;
function GetEquippedItemBounds(Which: Variant): TBox;
var
P: TPoint;
I: Integer;
begin
Result := IntToBox(0, 0, 0, 0);
I := -1;
case VarType(Which) of
varInteger: if (InRange(Which, 1, 11)) then
I := Which;
varString: case Which of
'helm', 'helmet' :
I := 1;
'cape' :
I := 2;
'amulet', 'neck', 'necklace' :
I := 3;
'arrows', 'bolts' :
I := 4;
'right hand', 'weapon' :
I := 5;
'plate', 'chest', 'platebody' :
I := 6;
'left hand', 'sheild', 'shield' :
I := 7;
'legs', 'platelegs', 'skirt', 'plateskirt' :
I := 8;
'gloves', 'gauntlets' :
I := 9;
'boots':
I := 10;
'ring' :
I := 11;
end;
end;
if (I = -1) then
begin
SRL_Warn('GetEquiptItemBounds', 'Invalid entry (' + ToStr(Which) + ')', Warn_AllVersions);
Exit;
end;
P := EquipmentCoords(I);
Result := IntToBox(P.x - 11, P.y - 11, P.x + 11, P.y + 11);
end;
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;
var
X, Y: Integer;
TP: TPoint;
begin
Result := false;
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 (not Gametab(tab_Equip)) then exit;
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);
var
TP: TPoint;
begin
TP := EquipmentCoords(I);
if (WearingItem(I)) then
begin
Mouse(TP.x, TP.y, 5, 5, mouse_left);
Wait(200 + Random(350));
end;
end;
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;
begin
TakeOffAllExcept([]);
end;
function CountEquippedItems: Integer;
var
I: Integer;
begin
Result := Integer(GameTab(tab_Equip)) - 2;
if (Result = -1) then exit;
for I := 1 to 11 do
if WearingItem(I) then
Inc(Result);
end;
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', 5,
SmallChars, False, False, 0, 0, 3381759)) then
Result := StrToIntDef(Trim(GetTextAtEx(TextX + 65, TextY, 5,
SmallChars, True, False, 0, 0, 3381759, 3, False, tr_AllChars)), -1);
if (Result = -1) then
srl_Warn('CurrentWorld', 'Could not get Player''s current world', Warn_AllVersions);
end;
function ObjectivePercent: Integer;
begin
Result := -1;
if (not GameTab(tab_Objectives)) then exit;
Result := Round(CountColor(42516, 596, 390, 690, 400) / 9.73);
end;
function ObjectiveCoords(ObjectiveSlot: Byte): TPoint;
begin
if (not InRange(ObjectiveSlot, 1, 6)) then
begin
srl_Warn('ObjectiveCoords', 'Invalid Slot', Warn_AllVersions);
Exit;
end;
Result.y := Trunc(ObjectiveSlot / 2) + 1;
if (Result.y mod 2 = 0) then
Dec(Result.y);
Result.x := ObjectiveSlot mod 3;
if (Result.x = 0) then
Result.x := 3;
Result := Point(RandomRange(20 + 165 * (Result.x - 1), 160 + 165 * (Result.x - 1)),
RandomRange(50 + 65 * (Result.y - 1), 160 + 65 * (Result.y - 1)));
end;
function HasObjective: Boolean;
begin
Result := False;
if (GameTab(tab_Objectives)) then
Result := (GetColor(582, 267) <> 3029570)
else
srl_Warn('HasObjective', 'Failed to open GameTab #' +
IntToStr(tab_Objectives), Warn_AllVersions);
end;
function ClearObjective: Boolean;
begin
Result := HasObjective;
if (Result) then
MouseBox(559, 447, 724, 456, mouse_left)
else
srl_Warn('ClearObjective', 'No Objective to Clear', Warn_AllVersions);
end;
function SetObjective(Skill: string; Level: Integer): Boolean;
var
TP: TPoint;
begin
Result := False;
if (not InRange(Level, 1, 99)) then
begin
srl_Warn('SetObjective', IntToStr(Level) + ' is not a valid level', Warn_AllVersions);
Exit;
end;
if (not GameTab(tab_Stats)) then exit;
TP := SkillToCoords(Skill);
Mouse(TP.x, TP.y + 3, 2, 2, mouse_right);
WaitOption('bjec', 300 + Random(500));
Wait(1000 + Random(250));
if (FindTextTpa(clBlack, 0, 100, 390, 235, 410, 'Enter the skill', UpCharsEx, Nothing)) then
begin
Wait(1000 + Random(250));
TypeSend(IntToStr(Level));
Result := True;
end;
end;
function SetRandomObjective(ObjectiveSlot: Integer; KeepOld: Boolean): Boolean;
var
ObjP: TPoint;
begin
Result := False;
if not InRange(ObjectiveSlot, 1, 6) then
begin
srl_Warn('SetRandomObjective', 'Invalid Objective Slot', Warn_AllVersions);
Exit;
end;
if (not GameTab(tab_Objectives)) then exit;
if (HasObjective) and (KeepOld) then exit;
MouseBox(556, 422, 725, 432, mouse_left);
Wait(400 + Random(350));
ObjP := ObjectiveCoords(ObjectiveSlot);
Mouse(ObjP.x, ObjP.y, 0, 0, mouse_left);
Result := HasObjective;
end;
function SetRun(Run: Boolean): Boolean;
begin
Result := false;
if (((CountColorTolerance(3467501, 720, 117, 723, 119, 80) > 1) or (SimilarColors(GetColor(725, 111), 6608616, 10))) xor (Run)) then
begin
Mouse(715, 95, 10, 10, mouse_left);
Result := True;
end;
end;
function RunEnergy(Min: Integer): Boolean;
var
T, R: Integer;
s: String;
begin
T := GetSystemTime + 5000;
repeat
R := GetMMLevels('run', s);
Result := (R >= Min);
if (Result) then
begin
SetRun(True);
Exit;
end;
if (R > 0) then
Exit;
until (T > GetSystemTime);
end;
function SetRest: Boolean;
begin
Result := False;
if (not(IsResting)) then
begin
Mouse(715, 95, 10, 10, mouse_right);
if (WaitOption('Rest', 300)) then
Result := WaitFunc(@IsResting, 100, 5000);
end;
end;
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;
function RestUntilHP(HPPerc: Integer): Boolean;
begin
Result := (HPPercent >= HPPerc);
if (Result) then exit;
SetRest;
while (HPPercent < HPPerc) 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
BrightnessColor = 9605778;
ScrollColor = 2106924;
ArrowOptions = 16645886;
BlueText = 14790912;
procedure FixGraphics;
var
I, X, Y : Integer;
TPA : TPointArray;
ATPA : T2DPointArray;
TP : TPoint;
TB : TBox;
begin
if (not LoggedIn) then exit;
CloseWindow;
if (not FindColor(x, y, ClBlack, 7, 460, 69, 474)) then {if you're in chat}
if (not ClickContinue(True, True)) then
begin
Mouse(MMCX, MMCY, 2, 2, mouse_left);
Wait(RandomRange(3000, 4000));
end;
i := 0; //failsafe opening clause
while (not FindTextTPA(ClWhite, 0, MSX1, MSY1, MSX2, MSY2, 'aphics', UpCharsEx, Nothing)) and (LoggedIn) do
begin
GameTab(tab_Options);
MouseBox(605, 258, 623, 277, mouse_left);
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 FindTextTPA(ClWhite, 0, MSX1, MSY1, MSX2, MSY2, 'aphics', UpCharsEx, Nothing) Then
Mouse(386, 172, 30, 10, mouse_left);
if GetColor(255, 178) = BrightnessColor then
Mouse(255, 178, 2, 2, mouse_left); //Sets brightness
Wait(1000 + Random(400)); //waits for it
FindColors(TPA, ArrowOptions, MSX1, MSY1, MSX2, MSY2); //finds drop down arrows
ATPA := SplitTPA(TPA, 5); //gets individual arrows
SortATPAFromFirstPoint(ATPA, Point(197, 89)); //sorts them
for I := 0 to High(ATPA) do
begin
TP := MiddleTPA(ATPA[I]);
TB := IntToBox(TP.X - 60, TP.Y - 5, TP.X + 2, TP.Y + 5);
if (CountColor(BlueText, TB.X1, TB.Y1, TB.X2, TB.Y2) > 5) then //if its not optimum
begin
Mouse(TP.X, TP.Y, 3, 3, mouse_left);
GetMousePos(X, Y);
If IntInBox(X, Y, IntToBox(236, 308, 462, 587)) Then
if (CountColor(ClWhite, 201, 295, 226, 308) > 5) then //clicks the correct one
begin
MouseBox(201, 295, 226, 308, mouse_left);
Wait(900 + Random(100));
end;
If Not IntInBox(X, Y, IntToBox(236, 308, 462, 587)) Then
if (CountColor(ClWhite, TB.X1, TB.Y1 + 20, TB.X2, TB.Y2 + 15) > 5) then //clicks the correct one
begin
MouseBox(TB.X1, TB.Y1 + 20, TB.X2 - 15, TB.Y2 + 15, mouse_left);
Wait(900 + Random(100));
end;
end;
end;
CloseWindow;
CloseWindow;
end;
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, mouse_left);
II := 0;
while (not FindTextTPA(2070753, 0, MSX1, MSY1, MSX2, MSY2, 'Graphics Options', UpCharsEx, Nothing)) and (LoggedIn) do
begin
GameTab(tab_Options);
MouseBox(605, 258, 623, 277, mouse_left);
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, mouse_left);
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, mouse_left);
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, mouse_left);
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, mouse_left);
end;
Wait(500 + Random(500));
CloseWindow;
end;
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, mouse_left);
while (not FindTextTPA(2070753, 0, MSX1, MSY1, MSX2, MSY2, 'Audio Options', UpCharsEx, Nothing)) and (LoggedIn) do
begin
GameTab(tab_Options);
MouseBox(654, 252, 677, 278, mouse_left);
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, mouse_left);
Wait(10 + Random(10));
end;
if (GetColor(238, 268) = 181) and (SMSetting = Stereo) then
Mouse(302, 265, 7, 7, mouse_left)
else
if (GetColor(305, 268) = 181) and (SMSetting = Mono) then
Mouse(235, 265, 7, 7, mouse_left);
Wait(500 + Random(500));
CloseWindow;
end;
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;
procedure DoEmote(EmoteNumber: Integer);
var
I, X, Y, Row, Col: Integer;
begin
if (not InRange(EmoteNumber, 1, 51)) 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) = 2041131) then
Mouse(723, 226, 8, 4, mouse_left);
21..40: if (GetColor(727, 364) = 1909544) then
Mouse(727, 354, 4, 1, mouse_left);
41..51: if (GetColor(725, 438) = 1909544) then
Mouse(725, 438, 5, 5, mouse_left);
end;
Wait(300 + Random(200));
if InRange(EmoteNumber, 21, 40) then
I := 20
else
if InRange(EmoteNumber, 41, 51) 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, mouse_left);
end;
function GetLobbyTab: Integer;
begin
for result := 1 to 6 do
if GetColor(63 + (result-1)*102, 32) = 11516354 then
Exit;
Result := -1;
end;
function LobbyTab(Tab: Integer): Boolean;
begin
Result := false;
if not InRange(Tab, L_PlayerInfo, L_Options) then
begin
Srl_Warn('LobbyTab', 'Tab ' + IntToStr(Tab) + ' is not valid.', warn_AllVersions);
Exit;
end;
result := GetLobbyTab = Tab;
if result then
Exit;
if GetColor(63 + (Tab-1)*102, 32) = 8029324 then
begin
Mouse(63 + (Tab-1)*102, 32, 10, 6, mouse_left);
result := true;
end;
end;
Function ToggleXPPopUp(Disabled: Boolean): Boolean;
var
i: Integer;
TPA: TPointArray;
P: TPoint;
S: String;
begin
for i := 0 to 1 do
begin
TPA := TPAFromBox(IntToBox(521, 51, 546, 75));
FilterPointsPie(TPA, 0, 360, 0, 12, 534, 63);
P := TPA[Random(Length(TPA))];
Mouse(P.X, P.Y, 0, 0, mouse_right);
if WaitOptionMulti(['Pop', 'op', '-up'], 1000) then
begin
Wait(1500+Random(500))
S := GetBlackChatMessage;
if Pos('disabled', S) > 0 then
Result := Disabled;
if Pos('enabled', S) > 0 then
Result := not Disabled;
if Result then
Break;
end;
end;
Writeln(S);
end;
function IsXPBarOpenEx(CounterNum: integer): Boolean;
begin
Result := CountColor(14474460, 481, 10+(CounterNum-1)*22, 489, 22+(CounterNum-1)*22) > 6;
end;
function IsXPBarOpen: Boolean;
begin
Result := IsXPBarOpenEx(1);
end;
function ToggleXPBarEx(Open: Boolean; CounterNum: integer): Boolean;
var
TPA: TPointArray;
P: TPoint;
T: Integer;
begin
if Open xor IsXPBarOpenEx(CounterNum) then
begin
TPA := TPAFromBox(IntToBox(521, 51, 546, 75));
FilterPointsPie(TPA, 0, 360, 0, 12, 534, 63);
P := TPA[Random(Length(TPA))];
Mouse(P.X, P.Y, 0, 0, mouse_left);
T := GetSystemTime + 300;
repeat
wait(1);
Result := Open = IsXPBarOpenEx(CounterNum);
until Result or (GetSystemTime > t);
end else
Result := true;
end;
function ToggleXPBar(Open: Boolean): Boolean;
begin
Result := ToggleXPBarEx(Open, 1);
end;
Function GetXPBar(CounterNum: integer): LongInt;
var
TPA: TPointArray;
B: TBox;
S: String;
P: integer;
begin
if ToggleXPBarEx(true, CounterNum) then
begin
FindColorsTolerance(TPA, 14474460, 407, 10+(CounterNum-1)*22, 489, 24+(CounterNum-1)*22, 0);
B := GetTPABounds(TPA);
S := Replace(GetTextAtExWrap(B.x1, B.y1, B.x2, B.y2, 0, 1, 4, 14474460, 0, UpChars), ' ', '');
P := Pos('x', S);
if P > 0 then
Result := StrToIntDef(ExtractFromStr(Copy(s, P, Length(S)), Numbers), 0)
else
Result := StrToIntDef(ExtractFromStr(S, Numbers), 0);
end;
end;
function GetXPBarTotal: LongInt;
begin
Result := GetXPBar(1);
end;
function ResetXPTotal: Boolean;
var
TPA: TPointArray;
P: TPoint;
begin
TPA := TPAFromBox(IntToBox(521, 51, 546, 75));
FilterPointsPie(TPA, 0, 360, 0, 12, 534, 63);
P := TPA[Random(Length(TPA))];
Mouse(P.X, P.Y, 0, 0, mouse_right);
Result := WaitOptionMulti(['Res', 'ese', 'set'], 1000);
end;
function IsMoneyPouchOpen: Boolean;
var
Cols :TIntegerArray;
I :Integer;
begin
Cols := [65535, 16777215, 8453888];
for I := 0 to 2 do
If CountColor(Cols[I],450, 90, 510, 109) > 10 then
Result := CountColor(Cols[I],450, 90, 510, 109) > 10;
end;
function ToggleMoneyPouch(Open: Boolean): Boolean;
begin
Result := IsMoneyPouchOpen <> Open;
if (not (Result)) then
Exit;
MouseBox(528, 94, 533, 107, mouse_Left);
end;
function GetMoneyPouchAmount: Integer;
var
Previous: Boolean;
TPA: TPointArray;
B: TBox;
I :Integer;
Col :TIntegerArray;
Money :String;
begin
Previous := IsMoneyPouchOpen;
if (ToggleMoneyPouch(True)) then
WaitFunc(@IsMoneyPouchOpen, 10, 2750);
Col := [65535, 65278, 16777215, 8453888];
for I := 0 to 3 do
if (FindColors(TPA, Col[I], 450, 90, 510, 109)) then
begin
B := GetTPABounds(TPA);
B := IntToBox(B.X1 - 2, B.Y1 - 2, B.X2 + 2, B.Y2 + 2);
Money := (GetTextAtEx(B.X1 - 1, B.Y1 - 1, 0, StatChars, False, False, 0, 2, Col[I], 5, False, tr_AllChars));
Result := StrToIntDef(GetNumbers(Money), -1);
If Pos('K', Money) > 0 then
Result := Result * 1000;
If Pos('M', Money) > 0 then
Result := Result * 1000000;
break;
end;
if (not(Previous)) then
begin
Wait(RandomRange(500, 1500));
ToggleMoneyPouch(Previous);
end;
end;
function DepositToPouch :Boolean;
var
MoneyPoint :TPoint;
begin
Result := False;
If FindCoins(MoneyPoint.X, MoneyPoint.Y, 'Inv') then
begin
MMouse(MoneyPoint.X, MoneyPoint.Y, 3, 3);
If WaitUpText('Coins', 500) then
begin
Mouse(MoneyPoint.X, MoneyPoint.Y, 0, 0, False);
Result := WaitOption('Add', 500);
end;
end;
end;
function ToolBeltScreen() : Boolean;
begin
Result := (CountColorTolerance(1158880, 192, 18, 264, 33, 9) > 120);
end;
function ItemSlotFilled() : Boolean;
var
TPA : TPointArray;
tmpCTS : Integer;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(1.86, 0.06);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, 5855064, 211, 199, 298, 273, 9);
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Result := Length(TPA) > 0;
end;
procedure OpenToolBelt();
begin
GameTab(tab_Equip);
MouseBox(670, 416, 704, 450, mouse_Left);
Wait(RandomRange(250, 750));
end;
procedure SetCategory(Category : string);
var
catBox : TBox;
TPA : TPointArray;
tmpCTS : Integer;
begin
case(LowerCase(Category))of
'general' : catBox := IntToBox(161, 86, 188, 107);
'fishing' : catBox := IntToBox(219, 86, 246, 104);
'crafting' : catBox := IntToBox(275, 87, 305, 104);
'farming' : catBox := IntToBox(332, 88, 359, 105);
end;
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.34, 0.80);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, 1810641, catBox.X1, catBox.Y1, catBox.X2, catBox.Y2, 9);
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
if(not(Length(TPA) > 0))then
MouseBox(catBox.X1, catBox.Y1, catBox.X2, catBox.Y2, 1);
end;
function CheckToolBeltFor(Category, Tool : string) : Boolean;
var
I, catCount : Integer;
begin
if(not(toolBeltScreen()))then
openToolBelt();
setCategory(Category);
case(LowerCase(Category))of
'general', 'crafting' : catCount := 13;
'fishing' : catCount := 8;
'farming' : catCount := 5;
end;
for I := 1 to catCount do
begin
if(not(FindTextTpa(1158880, 9, 167, 146, 352, 161, Tool, SmallChars, Nothing)))then
begin
Mouse((375 + 397) / 2, (147 + 163) / 2, 1, 1, True);
Wait(RandomRange(250, 750))
end else
Break;
end;
Result := itemSlotFilled;
Wait(RandomRange(250, 750));
MouseBox(479, 20, 491, 29, mouse_Left);
end;
function GetMusic: string;
var
Pts: TPointArray;
B: TBox;
begin
if (GetCurrentTab <> tab_Music) then
begin
GameTab(tab_Music);
Wait(500 + Random(500));
end;
if (FindColorsTolerance(Pts, 39401, 553, 242, 729, 264, 0)) then
begin
B := GetTPABounds(Pts);
Result := Trim(GetTextAtEx(B.X1 - 1, 245, 0, UpCharsEx, False, False, 0, 1, 39401, 50, False, tr_AllChars));
end;
end;
function PinScreen: boolean; forward;
function CloseAllScreens: boolean;
var
I: Integer;
begin
for I := 0 to 4 do
begin
case I of
0: Result := BankScreen;
1: Result := DepositScreen;
2: Result := ShopScreen;
3: Result := ToolBeltScreen;
4: Result := PinScreen;
end;
if Result then
if CloseWindow then
begin
Result := true;
Exit;
end else
Result := false;
end;
end;
Powered by vBulletin® Version 4.2.1 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.