SRL Archive - Research & Development Lounge

(Usable) WorldSwitcher.scar !


Floor66

2008-12-06 15:22:33

I was bored so I decided to make myself a WorldSwitcher.scar
I've removed most of the old functions, but I've tested this and it works!

FindWorld will scroll down and flawlessfly find it (probably :p)!
It'll most likely see it before you do =]

//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- ยป WorldSwitch routines --//
//-----------------------------------------------------------------//
//
// * Function WorldScreen: Boolean; // by Floor66 (Originally by Narcle)
// * Function OpenWorldScreen: Boolean; // by Floor66 (Originally by ZephyrsFury & Narcle)
// * Function CloseWorldScreen: Boolean; // by Floor66
// * Function FindWorld(var cx, cy : Integer; W : Integer): Boolean; // by Floor66 (Originally by Narcle)
// * Procedure SortWorlds(WType : String; UpDown : Boolean); // by Floor66
// * Function JoinWorld(W: Integer): Boolean; // by Floor66

{*******************************************************************************
function WorldScreen: Boolean;
by: Floor66 (Originally by Narcle)
Description: Returns true if the World screen is open.
*******************************************************************************}

Function WorldScreen: Boolean;
Begin
Result := (GetColor(64, 182) = 1266697);
End;

{*******************************************************************************
Function OpenWorldScreen: Boolean;
by: Floor66 (Originally by ZephyrsFury & Narcle)
Description: Opens the world screen. Returns true if world screen is opened.
*******************************************************************************}

Function OpenWorldScreen: Boolean;
Var
T: Integer;
Begin
If (WorldScreen) Then
Begin
Result := True;
Exit;
End;
Mouse(380, 240, 8, 8, True);
While Not WorldScreen Do
Begin
MarkTime(T);
Repeat
Wait(100);
If TimeFromMark(T) > 60000 Then Exit;
If WorldScreen Then Result := True;
Until(WorldScreen);
End;
End;

{*******************************************************************************
Function CloseWorldScreen: Boolean;
by: Floor66
Description: Closes the world screen.
*******************************************************************************}

Function CloseWorldScreen: Boolean;
Begin
Mouse(695, 70, 7, 7, True);
Wait(100+Random(150));
Result := WorldScreen;
End;

{*******************************************************************************
Function FindWorld(var cx, cy: Integer; W: Integer): Boolean;
by: Floor66 (Originally by Narcle)
Description: Looks for specified world in the World list and returns the coords
of it.
*******************************************************************************}

Function FindWorld(var cx, cy: Integer; W: Integer): Boolean;
Var
I : Integer;
Begin
If Not WorldScreen Then OpenWorldScreen;
Result := FindTextTpaEx(16777215, 0, 57, 130, 162, 458, cx, cy, 'orld '+inttostr(W)+' ', SmallChars, Nothing);
I := 200;
If Not Result Then Mouse(700, 150, 6, 6, True);
Result := FindTextTpaEx(16777215, 0, 57, 130, 162, 458, cx, cy, 'orld '+inttostr(W)+' ', SmallChars, Nothing);
While Not Result Do
Begin
Mouse(700, i, 6, 6, true);
Wait(500+random(500));
Result := FindTextTpaEx(16777215, 0, 57, 130, 162, 458, cx, cy, 'orld '+inttostr(W)+' ', SmallChars, Nothing);
IncEx(I, 30);
End;
End;

{*******************************************************************************
Function JoinWorld(W: Integer): Boolean;
by: Floor66
Description: Joins the specified world
*******************************************************************************}

Procedure JoinWorld(W: Integer);
Var
cx, cy : Integer;
Begin
If Not WorldScreen Then OpenWorldScreen;
If FindWorld(cx, cy, W) Then Mouse(cx, cy, 3, 3, True);
End;

{*******************************************************************************
Procedure SortWorlds(WType : String; UpDown : Boolean);
by: Floor66
Description: Sorts the worlds up or down in World list by:
'world', 'players', 'loc', 'activity',
'ls', 'qc', 'pvp', 'member'.
*******************************************************************************}

Procedure SortWorlds(WType : String; UpDown : Boolean);
Var
Coords : TPoint;
Begin
While Not WorldScreen Do OpenWorldScreen;
Case WType Of
'world': Begin
If UpDown Then
Begin
Coords := Point(104, 125);
End Else Coords := Point(125, 125);
End;
'players': Begin
If UpDown Then
Begin
Coords := Point(177, 125);
End Else Coords := Point(198, 125);
End;
'loc': Begin
If UpDown Then
Begin
Coords := Point(274, 125);
End Else Coords := Point(295, 125);
End;
'activity': Begin
If UpDown Then
Begin
Coords := Point(415, 125);
End Else Coords := Point(436, 125);
End;
'ls': Begin
If UpDown Then
Begin
Coords := Point(512, 125);
End Else Coords := Point(527, 125);
End;
'qc': Begin
If UpDown Then
Begin
Coords := Point(549, 125);
End Else Coords := Point(564, 125);
End;
'pvp': Begin
If UpDown Then
Begin
Coords := Point(582, 125);
End Else Coords := Point(597, 125);
End;
'members': Begin
If UpDown Then
Begin
Coords := Point(649, 125);
End Else Coords := Point(660, 125);
End;
End;
Mouse(Coords.x, Coords.y, 3, 3, True);
Wait(1500+Random(500));
End;

Test it out!
program New;
{.include SRL\SRL.scar}
{.include SRL\SRL\Misc\WorldSwitcher.scar}

Var
x, y : Integer;

Begin
SetupSRL;
SortWorlds('members', True);
JoinWorld(99);
End.

Known bug: SortWorlds fails if you start with World list open. Added a temporary solution for that.

ZephyrsFury

2008-12-06 22:31:56

What was wrong with the old one? It was only updated last revision. :p

EDIT: Remember you need an updated Worlds.ini (not the one from SRL) for it to work.

Floor66

2008-12-07 01:21:31

It didn't seem to work with the script I used :s
Well this one is usable too anyway xD

EDIT:
And purely looking at the script, how bad have I done? ;p

Narcle

2008-12-07 02:39:49

You need a worlds.ini from mixster's parser… which is on the site somewhere.

Markus forgot to put worlds.ini in last revision. (yes I will never let it go)

Floor66

2008-12-07 03:32:41

While making this my mind still thought it was broken ;S
Well mine works too, but I guess that SRL's functions beat me =\

ZephyrsFury

2008-12-07 21:12:24

Well I wouldn't say it beats yours but the SRL one uses Worlds.ini which allows users to switch to only specific worlds (free, member, pvp, quickchat, etc).

Anyway thanks for trying. Keep up the good work. :D