SCAR Code:
//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- ยป GameTab Routines I --//
//-----------------------------------------------------------------//
// * GameTab 1 = Fightmode
// * GameTab 2 = Statistic
// * GameTab 3 = Quest
// * GameTab 4 = Inventory (see Inventory.scar)
// * GameTab 5 = Wield
// * GameTab 6 = Prayer
// * GameTab 7 = Mage
// * GameTab 8 = Add Friend
// * GameTab 9 = Del Friend
// * GameTab 10 = ClanChat
// * GameTab 11 = Run/Tools
// * GameTab 12 = Emotes
// * GameTab 13 = Music
// * GameTab 14 = LogOut
// * GameTab 15 = Summoning
//****************************************************************************//
// * function GetCurrentTab: Integer; // * by Wizzup?
// * function TabExists(TabNumber: Integer): Boolean; // * by Flyboy
// * function GameTab(tabnumber: Integer): Boolean; // * by Starblaster100
// * function SetFightMode(oFightMode: Integer): Boolean; // * Nielsie95
// * function GetCombatLevel: Integer; // * by Nielsie95
// * procedure Retaliate(AutoRet:Boolean); // * By WT-Fakawi & n3ss3s
// * function SkillCoords(row, column: Integer): TPoint; // * by RsN
// * function SkillToCoords(skill: String): TPoint; // * by Masquerader extended by Cheesehunk
// * function GetSkillInfo: Integer; // * by: Raymond
// * function GetMMLevels: integer; // * by Raymond
// * function GetXP(Skill: String): Integer; // * by Nielsie95
// * function XpTillNextLevel(Skill: String): 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 WearingItem(i: Integer): Boolean; // * by RsN
// * procedure TakeOff(i: Integer); // * by RsN
// * function CheckEquipItems(number: Integer): Boolean; // * by SDcit
// * procedure SetRun(run: Boolean); // * by Wizzup?
// * procedure RunControl(Run: Boolean); // * by Wizzup?
// * procedure SetGraphics(Brightness: Integer; vl, rr, gd, td, id, fl, gt, cs: string); // * by ZephyrsFury
// * procedure SetAudio(Volume, SFX, Area: Integer; SMSetting: (Stereo, Mono, NoChange) ); // * by ZephyrsFury
// * procedure SetBar(Brightness, Volume, SFX, Area: Integer); // * by ZephyrsFury
// * procedure DoEmote(EmoteNumber: Integer); // * by Sumilion
type
TSMSetting = (Stereo, Mono, NoChange);
Function InStrArrEx(S: String; StrArr: TStringArray; Var Where: Integer): Boolean; forward;
function CloseWindow: Boolean; forward;
{*******************************************************************************
function GetCurrentTab: Integer;
By: Wizzup?
Description: Returns current tab
*******************************************************************************}
function GetCurrentTab: Integer;
var
i: Integer;
b: Boolean;
begin
b := False;
Result := 0;
for i := 1 to 15 do
begin
case i of
1: b := (GetColor(543, 178) = 1580634);
2: b := (GetColor(570, 179) = 1778795);
3: b := (GetColor(604, 174) = 1910385);
4: b := (GetColor(632, 172) = 1910385);
5: b := (GetColor(666, 182) = 1647204);
6: b := (GetColor(699, 177) = 1910385);
7: b := (GetColor(735, 177) = 1778795);
8: b := (GetColor(569, 471) = 1910385);
9: b := (GetColor(598, 471) = 1910385);
10: b := (GetColor(633, 478) = 1778795);
11: b := (GetColor(668, 476) = 1778795);
12: b := (GetColor(703, 481) = 1580634);
13: b := (GetColor(740, 471) = 1778795);
14: b := (GetColor(555, 275) = 2070783);
15: b := (GetColor(533, 475) = 1581150);
end;
if b then
begin
Result := i;
Exit;
end;
end;
end;
{*******************************************************************************
function TabExists(TabNumber: Integer): Boolean;
By: Flyboy
Description: Returns true if tab exists.
Very useful for tutorial Is. as well as a simple double check to make sure
your fully logged in.
*******************************************************************************}
function TabExists(TabNumber: Integer): Boolean;
begin
case TabNumber of
1: Result := (GetColor(533, 177) = 65536);
2: Result := (GetColor(565, 175) = 65536);
3: Result := (GetColor(609, 175) = 1052432);
4: Result := (GetColor(638, 174) = 65536);
5: Result := (GetColor(670, 176) = 65536);
6: Result := (GetColor(708, 171) = 65536);
7: Result := (GetColor(740, 175) = 65536);
8: Result := (GetColor(575, 474) = 65536);
9: Result := (GetColor(605, 474) = 65536);
10: Result := (GetColor(640, 472) = 65536);
11: Result := (GetColor(680, 472) = 65536);
12: Result := (GetColor(710, 470) = 65536);
13: Result := (GetColor(735, 473) = 65536);
14: Result := (GetColor(743, 1) = 65536);
15: Result := (GetColor(537, 477) = 65536);
end;
end;
{*******************************************************************************
function GameTab(tabnumber: Integer): Boolean;
By: Starblaster100
Description: Switches between tabs.
*******************************************************************************}
function GameTab(tabnumber: Integer): Boolean;
var
c: Integer;
Coords: TPoint;
begin
if ((Tabnumber < 1) or (TabNumber > 15)) then
begin
srl_Warn('GameTab', IntToStr(tabnumber) + ' is no 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;
if (tabnumber = 14) then
Coords := Point(752, 12)
else if (tabnumber = 15) then
Coords := Point(538, 485)
else if (tabnumber <= 7) then
Coords := Point(540 + ((tabnumber -1) * 33), 185)
else
Coords := Point(540 + ((tabnumber mod 7) * 33), 485);
while not(GetCurrentTab = tabnumber) and (c < 4) do
Begin
Mouse(Coords.x, Coords.y, 8, 8, true);
Inc(c);
end;
Result := (GetCurrentTab = tabnumber);
end;
//****************************************************************************//
// * GameTab 1 Related Functions.
//****************************************************************************//
{*******************************************************************************
function SetFightMode(oFightMode: Integer): Boolean;
By: Nielsie95 tweaked by Timer
Description: Sets fight mode. Returns false if failed to set desired mode.
*******************************************************************************}
function SetFightMode(oFightMode: Integer): Boolean;
var
i, x, y: Integer;
b: TBox;
Begin
if not(Loggedin)then Exit;
if (GetCurrentTab <> 1) then
begin
GameTab(1);
Wait(200 + Random(777));
end;
case oFightMode of
1: b := IntToBox(575, 255, 630, 290);
2: b := IntToBox(660, 255, 710, 290);
3: b := IntToBox(575, 310, 630, 345);
4: b := IntToBox(660, 310, 710, 345);
else Exit;
end;
while (i < 4) and (not FindColorTolerance(x, y, 1777020, b.x1, b.y1, b.x2, b.y2, 2)) do
begin
Mouse(RandomRange(b.x1, b.x2), RandomRange(b.y1, b.y2), 0, 0, True);
Wait(200 + Random(300));
Inc(i);
end;
Result := FindColorTolerance(x, y, 1777020, b.x1, b.y1, b.x2, b.y2, 2);
if (not Result) and (oFightMode = 4) then
SetFightMode(3);
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
try
Result := StrToInt(Trim(GetTextAtEx(x, y, 0, StatChars, False, False, 0,
2, 2070783, 20, True, tr_Digits)));
except
srl_Warn('GetCombatLevel', 'Exception, could not get combat level', warn_AllVersions);
end
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.
//****************************************************************************//
{*******************************************************************************
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(skill: string; var Scroll : Boolean): TPoint;
By: Masquerader, Cheesehunk, Raymond and Wizzup?
Description: Turns skill string into tpoint.
If Scroll returns true then you must scroll down.
*******************************************************************************}
function SkillToCoords(ScrollDownIfNeeded : Boolean; skill: string): TPoint;
var
Scroll : Variant;
Timer : Integer;
ScrollTP : TPoint;
begin
case LowerCase(skill) of
'attack': Result := SkillCoords(1, 1);
'hitpoints','hp': Result := SkillCoords(1, 2);
'mining': Result := SkillCoords(1, 3);
'strength': Result := SkillCoords(2, 1);
'agility': Result := SkillCoords(2, 2);
'smithing': Result := SkillCoords(2, 3);
'defence': Result := SkillCoords(3, 1);
'herblore': Result := SkillCoords(3, 2);
'fishing': Result := SkillCoords(3, 3);
'range','ranged': Result := SkillCoords(4, 1);
'thieving': Result := SkillCoords(4, 2);
'cooking': Result := SkillCoords(4, 3);
'prayer': Result := SkillCoords(5, 1);
'crafting': Result := SkillCoords(5, 2);
'firemaking': Result := SkillCoords(5, 3);
'magic': Result := SkillCoords(6, 1);
'fletching': Result := SkillCoords(6, 2);
'woodcutting': Result := SkillCoords(6, 3);
'runecrafting': Result := SkillCoords(7, 1);
'slayer': Result := SkillCoords(7, 2);
'farming': Result := SkillCoords(7, 3);
'construction': Result := SkillCoords(8, 1);
'hunting', 'hunter': Result := SkillCoords(8, 2);
'summoning': Result := SkillCoords(8, 3);
else
begin;
//writeln('invalid skill: ' + skill);
srl_Warn('SkillToCoords', skill + ' is not a valid skill', warn_AllVersions);
Result := Point(0,0);
exit;
end;
end;
Scroll := False;
case LowerCase(skill) of
'construction','hunting', 'hunter','summoning': Scroll := True;
end;
ScrollTP := Point(724, Variant(250 + 173 * (not (scroll) + 1)));
GameTab(2);
if FindColorSpiralTolerance(ScrollTP.x,ScrollTP.y,1646629,719, 245 + Variant(169 * (not (scroll) + 1)),
728, 255 - Variant(169 * ((scroll) + 1)) ,10) then
begin
ScrollTP := Point(724, 423);
if FindColorSpiralTolerance(ScrollTP.x,ScrollTP.y,1646629,719, 245 + Variant(169 * (not (scroll) + 1)),
728, 255 - Variant(169 * ((scroll) + 1)) ,10) then
begin
Mouse(ScrollTP.x,ScrollTP.y,2,2,True);
Timer := GetSystemTime;
Repeat
Wait(100 + Random(50));
until ((GetSystemTime - Timer) > 10000) or (not FindColorSpiralTolerance(ScrollTP.x,ScrollTP.y,1646629,719, 245 + Variant(169 * (not (scroll) + 1)),
728, 255 - Variant(169 * ((scroll) + 1)) ,10))
end;
end;
end;
{*******************************************************************************
function GetSkillInfo(skill: string; 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: string; 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: string): 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: String): Integer;
By: Nielsie95
Description: Returns current xp for a skill. Returns -1 if failed.
*******************************************************************************}
function GetXp(skill: string): Integer;
var
p: TPoint;
i, tx, ty, x, y: Integer;
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);
while (not FindColor(x, y, 10551295, MIX1, MIY1, MIX2, MIY2)) and (i < 50) do
begin
Wait(100);
Inc(i);
end;
Wait(200 + Random(150));
if (not FindColor(x, y, 10551295, MIX1, MIY1, MIX2, MIY2)) 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: String): Integer;
By: Nielsie95
Description: Returns current xp til you level up in a skill.
Returns -1 if failed.
*******************************************************************************}
function XpTillNextLevel(Skill: string): Integer;
var
p: TPoint;
i, tx, ty, x, y: Integer;
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);
while (not FindColor(x, y, 10551295, MIX1, MIY1, MIX2, MIY2)) and (i < 50) do
begin
Wait(100);
Inc(i);
end;
Wait(200 + Random(150));
if (not FindColor(x, y, 10551295, MIX1, MIY1, MIX2, MIY2)) 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
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;
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] := GetSkillLevel('construction');
// Players[CurrentPlayer].level[23] := GetSkillLevel('hunting');
// Players[CurrentPlayer].level[24] := GetSkillLevel('summoning');
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 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;
// Sees if there are number items.
var
CheckCoords: Integer;
x: integer;
begin
x := 0;
begin
for CheckCoords := 1 to 11 do
begin
if WearingItem(CheckCoords) then
x := x + 1;
end;
if (x > number) then
begin
WriteLn('ERROR : You have more than ' + IntToStr(number) +
' items equiped.');
WriteLn(' You have : ' + IntToStr(x) + ' Items equiped');
Result := False;
end else
Result := True;
end;
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;
if (GetCurrentTab <> 8) then
begin
GameTab(8);
Wait(50 + Random(50));
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
WriteLn('Could not get Current World.');
end;
//****************************************************************************//
// * GameTab 9 Related Functions.
//****************************************************************************//
//****************************************************************************//
// * GameTab 10 Related Functions.
//****************************************************************************//
//****************************************************************************//
// * GameTab 11 Related Functions.
//****************************************************************************//
{*******************************************************************************
procedure SetRun(run: Boolean);
By: Wizzup? & EvilChicken!
Description: Sets Run on or off.
*******************************************************************************}
Procedure SetRun(Run: Boolean);
Var
TPA: TPointArray;
Begin
FindColorsTolerance(TPA, 5753055, 715, 105, 731, 110, 30);
If (Length(TPA) > 10) Xor Run Then
Mouse(715, 95, 10, 10, True);
End;
{*******************************************************************************
procedure RunControl(Run: Boolean);
By: Wizzup?
Description: Sets Run on or off, using control, DOES NOT stack with SetRun(),
Use them seperately.
*******************************************************************************}
procedure RunControl(Run: Boolean);
begin
Wait(10 + Random(20));
if Run then
KeyDown(17)
else
KeyUp(17);
Wait(10 + Random(20));
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;
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) = 522) do Wait(100);
end else
Mouse(TB.x1 + 10, TB.y1 + 3, 10, 5, True);
end;
MouseBox(490, 30, 499, 42, 1);
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: Integer;
P: TPoint;
begin
if (not(LoggedIn)) then Exit;
Settings := [Volume, SFX, Area];
OptionName := ['Volume', 'SFX', 'Area'];
C := 0;
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);
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
if (II = 0) then K := 4
else K := 5;
if (not(InRange(Settings[II], 0, K))) then
srl_Warn('SetBar', 'Setting: ' + IntToStr(Settings[II]) + ' is not valid for Bar: ' + Names[II] + '.', warn_AllVersions);
end;
SetGraphics(Brightness, '', '', '', '', '', '', '', '');
Wait(100 + Random(500));
SetAudio(Volume, SFX, Area, 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;
SCAR Code:
//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- ยป Login Routines --//
//-----------------------------------------------------------------//
// * function RSReady: Boolean; // * by ZephyrsFury
// * Procedure LoginScreenMusic(State: Variant); // * by Wizzup?
// * procedure Login_SetAudio(Volume, SFX, Area: Integer; SMSetting: (Stereo, Mono, NoChange) ); // * by ZephyrsFury
// * procedure Login_SetGraphics(Brightness: Integer; vl, rr, gd, td, ia, fl, gt, cs: string); // * by ZephyrsFury
// * procedure SetAutoingDefaults; // * by ZephyrsFury
// * procedure Logout; // * by Starblaster100 and Raymond
// * procedure LoginPlayer; // * by SRL Developers
// * procedure RandomNextPlayer(Active: Boolean); // * by Dankness, Ron and Raymond
// * procedure NextPlayer(Active: Boolean); // * by Dankness, Ron and Raymond
// * procedure CheckUserNicks; // * by Sumilion and Raymond
{ var SRL_Logs: Integer;
Description: Variables needed for some login functions. }
{ var RandomPlayer, GraphicsSet: Boolean;
Description: Variables needed for some login functions. }
var
SRL_Logs: Integer;
RandomPlayer, GraphicsSet: Boolean;
procedure NextPlayer(Active: Boolean); forward;
procedure RandomNextPlayer(Active: Boolean); forward;
{*******************************************************************************
function RSReady: Boolean;
By: ZephyrsFury
Description: Returns true if we are ready to auto (on loginscreen or logged in).
Useful for waiting until RS has fully loaded.
*******************************************************************************}
function RSReady: Boolean;
begin
Result := (LoggedIn) or (GetColor(520, 146) = 4038981);
end;
{*******************************************************************************
Procedure LoginScreenMusic(State: Variant);
By: Wizzup?
Description: Takes Boolean(True, False) or Integer(1..5) as arguments.
1 or True = Off, 5 or False = Max.
1 2 3 4 5
<-o---o---o---o---o->
*******************************************************************************}
Procedure LoginScreenMusic(State: Variant);
Var
RealState: Variant;
x: Extended;
Begin
if (LoggedIn) then Exit;
if (CountColor(7750, 346, 356, 416, 369) <> 119) and (GetColor(520, 135) = 4038981) then
begin
TypeByte(vk_Escape);
Wait(100);
end;
if (CountColor(7750, 346, 356, 416, 369) <> 119) then Exit;
Case VarType(State) Of
11: RealState := (State + 1) * 4;
3: If InRange(State, 1, 5) Then
RealState := State - 1;
Else
RealState := 0;
End;
x := (425.0 - 337.0) * RealState / 4.0 + 339.0;
If CountColorTolerance(1647966, Round(x) - 5, 375, Round(x) + 5, 385, 20) < 5 Then
If CountColorTolerance(991349, Round(x) - 5, 375, Round(x) + 5, 385, 20) < 5 Then
Mouse(Round(x), RandomRange(375, 385), 0, 0, True);
End;
{*******************************************************************************
procedure Login_SetAudio(Volume, SFX, Area: Integer; SMSetting: (Stereo, Mono, NoChange) );
By: ZephyrsFury
Description: Sets audio options through the login screen.
Use: Enter the desired Setting for the desired Option. Make option 0 for no change.
EG. Login_SetAudio(1, 5, 2, NoChange);
1 2 3 4 5
Volume, SFX, Area: <-o---o---o---o---o->
*******************************************************************************}
procedure Login_SetAudio(Volume, SFX, Area: Integer; SMSetting: TSMSetting);
var
II, Tx, Ty, T: Integer;
Pts: TIntegerArray;
begin
if (LoggedIn) then Exit;
TypeByte(vk_Escape);
T := GetSystemTime;
while (CountColor(7750, 346, 373, 416, 386) <> 119) and (GetSystemTime - T < 5000) do
Wait(100);
if (CountColor(7750, 346, 373, 416, 386) = 119) then
MouseBox(334, 362, 426, 371, 1)
else
Exit;
Wait(100);
Pts := [Volume, SFX, Area];
for II := 0 to 2 do
begin
if (Pts[II] = 0) then Continue;
if (not(InRange(Pts[II], 0, 5))) then
begin
srl_Warn('Login_SetAudio', 'Points must be between 0 and 5', warn_AllVersions);
Continue;
end;
Tx := 337 + Round((425 - 337) * (Pts[II] - 1) / 4);
Ty := Round(3.5 * II * II + 46.5 * II + 245);
if (GetColor(Tx, Ty) <> 1121100) then
Mouse(Tx + 2, Ty - 14, 0, 0, True);
Wait(50);
end;
if (GetColor(337, 389) = 181) and (SMSetting = Stereo) then
Mouse(421, 385, 10, 10, True)
else
if (GetColor(426, 389) = 181) and (SMSetting = Mono) then
Mouse(332, 385, 10, 10, True);
Wait(100);
TypeByte(vk_Escape);
end;
{*******************************************************************************
procedure Login_SetGraphics(Brightness: Integer; vl, rr, gd, td, ia, fe, gt, cs: string);
By: ZephyrsFury
Description: Sets graphic options in the login screen.
Use: Enter the desired Setting for the desired Option.
Leave as 0 for no change of brightness and '' for no change in anything else.
Parameter Option Setting
Brightness Brightness 1 - 4 (0 for no change)
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 Chracter Shadows Off / On
1 2 3 4
Brightness: <---o---o---o---o--->
EG. Login_SetGraphics(2, 'current', '', 'off', 'low', 'few', '', 'few', 'off');
For Autoing:
Login_SetGraphics(4, 'current', 'always', 'off', 'low', 'few', 'off', 'few', 'off');
*******************************************************************************}
procedure Login_SetGraphics(Brightness: Integer; vl, rr, gd, td, ia, fe, gt, cs: string);
var
Settings, PosSettings, OptionName: TStringArray;
II, T, W, tCol, x, y, mSpeed: Integer;
TB: TBox;
P: TPoint;
begin
if (LoggedIn) then Exit;
Settings := [vl, rr, gd, td, ia, fe, gt, cs];
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'];
TypeByte(vk_Escape);
T := GetSystemTime;
while (CountColor(7750, 346, 373, 416, 386) <> 119) and (GetSystemTime - T < 5000) do
Wait(100);
if (CountColor(7750, 346, 373, 416, 386) = 119) then
MouseBox(321, 338, 443, 346, 1)
else
Exit;
mSpeed := MouseSpeed;
MouseSpeed := 25;
Wait(100);
if (Brightness > 4) then
srl_Warn('Login_SetGraphics', 'Brightness must be between 0 and 4', warn_AllVersions)
else
if (Brightness <> 0) then
begin
P := Point(89 + (Brightness - 1) * 21, 266);
if (GetColor(P.x, P.y) <> 1121100) then
Mouse(P.x - 3, P.y - 17, 6, 6, True);
end;
for II := 0 to 7 do
begin
TB.x1 := 67 + 130 * ((II + 1) mod 5);
TB.y1 := 245 + 60 * ((II + 1) div 5);
TB.x2 := TB.x1 + 109;
TB.y2 := TB.y1 + 15;
if (not(InStrArrEx(Capitalize(Settings[II]), [PosSettings[II * 2], PosSettings[II * 2 + 1]], W))) then
begin
srl_Warn('Login_SetGraphics', 'Invalid Setting: ' + Settings[II] + ' for Option: ' + OptionName[II] + '.', warn_AllVersions);
Continue;
end;
tCol := (W mod 2) * 16777088 + 127;
if (not(FindColor(x, y, tCol, TB.x1, TB.y1, TB.x2, TB.y2))) then
begin
Mouse(TB.x1 + 10, TB.y1 + 3, 10, 7, True);
if (FindColor(x, y, tCol, TB.x1, TB.y2 + 1, TB.x2, TB.y2 + 1 + 51)) then
Mouse(x, y, 10, 7, True)
else
MouseBox(TB.x1 + 10, TB.y1 + 3, TB.x2 - 40, TB.y2 - 3, 1);
end;
end;
Wait(100);
TypeByte(vk_Escape);
MouseSpeed := mSpeed;
end;
{*******************************************************************************
procedure SetAudioOff;
By: ZephyrsFury
Description: Sets the Audio to off (1 for each bar). Works logged in and out.
*******************************************************************************}
procedure SetAudioOff;
begin
if (LoggedIn) then
SetAudio(1, 1, 1, NoChange)
else
Login_SetAudio(1, 1, 1, NoChange);
end;
{*******************************************************************************
procedure SetAutoingDefaults;
By: ZephyrsFury
Description: Sets the graphic options for best SRL compatibility. Works both logged in and out.
*******************************************************************************}
procedure SetAutoingDefaults;
begin
if (LoggedIn) then
SetGraphics(4, 'current', 'always', 'off', 'low', 'few', 'off', 'few', 'off')
else
Login_SetGraphics(4, 'current', 'always', 'off', 'low', 'few', 'off', 'few', 'off');
end;
{*******************************************************************************
procedure Logout;
By: Starblaster100 / Raymond
Description: Logs you out.
*******************************************************************************}
function Logout: Boolean;
var
c, i: Integer;
begin
Result := (not (LoggedIn));
if Result = True then
Exit;
if GameTab(14) = False then
Exit;
Wait(200 + Random(100));
while (LoggedIn) and (c < 10) do
begin
Inc(c);
if(ClickText('here', UpChars, MIX1, MIY1, MIX2, MIY2, True))then
for i := 0 to 10 do
begin
Wait(1000);
if not(LoggedIn)then
begin
Result := True;
Exit;
end;
end;
end;
end;
{*******************************************************************************
procedure LoginPlayer;
By: SRL Developers
Description: Logs in the Player[CurrentPlayer]. Detects most Client Login Errors
*******************************************************************************}
procedure LoginPlayer;
var
Mark, Attempts: Integer;
Actions: TVariantArray;
RetryLogin: Boolean;
label
ProcStart;
begin
ActivateClient;
Wait(100);
if (GetColor(212, 327) = 238301) then //At Click To Play screen
begin
Wait(1000 + Random(3000));
MouseBox(227, 337, 555, 364, 1);
MarkTime(Mark);
while (TimeFromMark(Mark) < 30000) and (not(LoggedIn)) do
Wait(1000 + Random(1000));
end;
if (not(RSReady)) then
begin
MarkTime(Mark);
while (not(RSReady)) do
begin
Wait(100);
if (TimeFromMark(Mark) > 120000) then
begin
WriteLn('It has been 2 minutes and Runescape is not yet ready... Terminating.');
TerminateScript;
end;
end;
WriteLn('Welcome to Runescape.');
end;
LoginScreenMusic(True);
if (not(GraphicsSet)) then
begin
SetAutoingDefaults;
GraphicsSet := True;
end;
ProcStart:
if (not(LoggedIn)) then
begin
if (not(Players[CurrentPlayer].Active)) then
begin
WriteLn('Player is not Active...');
NextPlayer(False);
Exit;
end;
Wait(900 + random(60));
//Click 'Log In' on main menu
while (GetColor(343, 174) <> 7750) do
begin
MouseBox(360, 180, 400, 185, 1);
Wait(100 + Random(100));
end;
//Type Username
Mouse(315, 272, 10, 5, True);
while (CountColor(7750, 311, 269, 452, 284) > 13) do
begin
KeyDown(vk_Back);
Wait(10 + Random(10));
KeyUp(vk_Back);
Wait(50 + Random(50));
end;
for Mark := 0 to 3 do
begin
KeyDown(vk_Back);
Wait(10 + Random(10));
KeyUp(vk_Back);
Wait(50 + Random(50));
end;
Wait(100 + Random(200));
WriteLn(Capitalize(Players[CurrentPlayer].Name));
TypeSend(Players[CurrentPlayer].Name);
Wait(100+random(50));
//Type Password
Mouse(315, 334, 10, 5, True);
while (CountColor(7750, 311, 337, 452, 352) > 13) do
begin
KeyDown(vk_Back);
Wait(10 + Random(10));
KeyUp(vk_Back);
Wait(50 + Random(50));
end;
for Mark := 0 to 3 do
begin
KeyDown(vk_Back);
Wait(10 + Random(10));
KeyUp(vk_Back);
Wait(50 + Random(50));
end;
Wait(100 + Random(200));
TypeSend(Players[CurrentPlayer].Pass);
Wait(500 + Random(300));
if (not(FindTextTPA(12509695, 0, 288, 205, 475, 247, 'login', StatChars, Nothing))) then //If 'enter' from typesend didn't log us in
begin
MouseBox(355, 359, 403, 372, 1); //Click 'login' login screen
Wait(250 + random(100));
end;
MarkTime(Mark);
repeat
SetLength(Actions, 0);
if (TimeFromMark(Mark) > 60000) then
Actions := ['One minute has passed...', 0, 2, 'NextPlayer', 'Login Failed']
else
case (CountColor(12509695, 288, 205, 475, 247)) of //Number of text colour points
// Actions := ['WriteLn Text', TimeToWait, NumberOfRetries, 'FinalAction', 'PlayerStatus'];
760: Actions := ['Too many incorrect logins.', 5 * 60000, 2, 'NextPlayer', ''];
536: Actions := ['Login limit exceeded. Please wait 1 minute and try again.', 60000, 2, 'NextPlayer', ''];
711: Actions := ['Your account has been disabled', 0, 0, 'NextPlayer', 'Acc Disabled'];
598: Actions := ['Invalid Username \ Password', 0, 2, 'NextPlayer', 'Wrong User/Pass'];
787: Actions := ['You need a members account for this world.', 0, 0, 'NextPlayer', 'Non-member'];
408: Actions := ['World is full.', 5000, -1, 'Terminate', ''];
623: Actions := ['Your account is already logged in', 5000, 0, 'RandomNextPlayer', ''];
555: Actions := ['The Server is being updated.', 60000, 4, 'Terminate', 'Server Updating'];
218: Actions := ['Error Connecting.', 20000, 9, 'Terminate', 'Error Connecting'];
335: Actions := ['Unable to connect Login Server offline.',(20000) + Random(6000), 4, 'Terminate', 'Login Server Offline'];
512: Actions := ['RuneScape has been updated. Script Terminated.', 0, 0, 'Terminate', 'RS Updated'];
489: Actions := ['Connection timed out.', 0, 4, 'Terminate', 'Connection Timed Out'];
737: Actions := ['You are standing in a members-only area.', 0, 0, 'NextPlayer', 'In Mems-Only Area'];
//10: Actions := ['Error loading your profile.', 5000, 10, 'NextPlayer', 'Profile Loading Failed']; // Error loading your profile. Will attempt to re-login 5 more times.)
//11: Actions := ['Login server rejected session.', 1000, 10, 'NextPlayer', 'Login Serv. Rejected']; // Login server rejected session.
end;
if (Length(Actions) > 0) then
begin
WriteLn(Actions[0]);
Wait(Actions[1] + Random(100));
if (Actions[2] <> 0) then
if (Attempts < Actions[2]) or (Actions[2] = -1) then
begin
RetryLogin := True;
Break;
end;
if (Actions[4] <> '') then
Players[CurrentPlayer].Loc := Actions[4];
case Actions[3] of
'NextPlayer': NextPlayer(False);
'RandomNextPlayer': RandomNextPlayer(True);
'Terminate': TerminateScript;
end;
Exit;
end;
Wait(100);
until(GetColor(212, 327) = 238301);
if (RetryLogin) then
begin
RetryLogin := False;
Inc(Attempts);
goto ProcStart;
end;
if (GetColor(212, 327) = 238301) then
begin
Wait(1000 + Random(2000));
MouseBox(227, 337, 555, 364, 1);
end;
MarkTime(Mark);
while (TimeFromMark(Mark) < 30000) and (not(LoggedIn)) do
Wait(1000 + Random(1000));
end;
if (LoggedIn) then
begin
PlayerStartTime := (GetSystemTime div 1000); // PlayerStartTime
if Length(Players[CurrentPlayer].NickTPA) < 2 then
begin;
Writeln('Creating the NickTPA.');
if Players[CurrentPlayer].Nick <> '' then
Players[CurrentPlayer].NickTPA := CreateTPAFromText(Players[CurrentPlayer].Nick, UpChars)
else
begin;
Writeln('Nickname isn''t set, taking the username instead..');
Players[CurrentPlayer].NickTPA := CreateTPAFromText(Players[CurrentPlayer].Name, UpChars);
end;
end;
AddToSRLLog('Current player: ' + Capitalize(Players[CurrentPlayer].Name));
end;
end;
{*******************************************************************************
procedure RandomNextPlayer(Active: Boolean);
By: Dankness based on WT-Fawki's NextPlayer and modified by Ron and by Raymond
Description: Picks Random Player that is Active and Logs in
*******************************************************************************}
procedure RandomNextPlayer(Active: Boolean);
var
LastPlayer: Integer;
begin
WriteLn('NextPlayer');
LastPlayer := CurrentPlayer;
Players[CurrentPlayer].Active := Active;
Logout;
PlayerCurTime := (GetSystemTime div 1000);
Players[CurrentPlayer].Worked := Players[CurrentPlayer].Worked +
((PlayerCurTime - PlayerStartTime) / 60);
repeat
if (AllPlayersInactive) then Wait(60000);
if (PlayersActive = 1) then Break;
CurrentPlayer := Random(HowManyPlayers);
Wait(100);
until (Players[CurrentPlayer].Active) and (LastPlayer <> CurrentPlayer);
SRL_Logs := SRL_Logs + 1;
LoginPlayer;
end;
{*******************************************************************************
procedure NextPlayer(Active: Boolean);
By: Dankness and modified by Ron and by Raymond
Description: Logs in the next player.
Boolean: True - Current player is ok. False - Current player is false.
*******************************************************************************}
procedure NextPlayer(Active: Boolean);
begin
if RandomPlayer then
RandomNextPlayer(Active)
else
begin
WriteLn('NextPlayer(Active: ' + BoolToStr(Active)+ ');');
Players[CurrentPlayer].Active := Active;
Logout;
PlayerCurTime := (GetSystemTime div 1000);
Players[CurrentPlayer].Worked := Players[CurrentPlayer].Worked +
((PlayerCurTime - PlayerStartTime) / 60);
CurrentPlayer := (CurrentPlayer + 1) mod Length(Players);
while Players[CurrentPlayer].Active = False do
begin
CurrentPlayer := (CurrentPlayer + 1) mod Length(Players);
if (AllPlayersInactive) then Wait(60000); // Everybody False. Endless Loop.
end;
SRL_Logs := SRL_Logs + 1;
LoginPlayer;
end;
end;
{*******************************************************************************
procedure CheckUserNicks;
By: Sumilion / Raymond
Description: Checks if all nicks are set correct.
*******************************************************************************}
procedure CheckUserNicks;
var
CorrectString: string;
i: Integer;
Wrong : Boolean;
Str : String;
begin
for i := 0 to HowManyPlayers - 1 do
begin
if (not(Players[CurrentPlayer].Active)) then Continue;
Wrong := False;
if (Players[i].Nick = '') then
begin
Wrong := True;
Str := 'WARNING : Please fill in your nickname.';
end;
if (Players[i].Nick <> LowerCase(Players[i].Nick)) then
begin
Wrong := True;
Str := 'WARNING : Please Uncapitalise your nickname.';
end;
if (pos(Players[i].Nick, LowerCase(Players[i].Name)) = 1) then
begin
Wrong := True;
Str := 'WARNING : Dont use the first letter in your nick.';
end;
if (pos(' ', Players[i].Nick) > 0) then
begin
Wrong := True;
Str := 'WARNING : Dont use spaces in your Nick.';
end;
CorrectString := Capitalize(Players[i].Name);
if not (Pos(LowerCase(Players[i].Nick), CorrectString) > 0) then
begin
Wrong := true;
Str := 'WARNING : Nick does NOT match the name.';
end;
if Wrong then
begin;
Writeln('--');
Writeln(Str);
if (Length(Players[i].Name) > 0) then
Writeln('Warning occured with player : ' + Players[i].Name);
Writeln('For more information, visit http://www.villavu.com/forum/showthread.php?t=5410');
end;
end;
end;