Cazax
2009-05-26 02:09:49
Functions and procedures for the world map:
//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- ยป World Map Routines --//
//-----------------------------------------------------------------//
// * Procedure OpenWorldMap; // * by Cazax
// * Function IsWorldMapOpened: Boolean; // * by Cazax
// * Procedure CloseWorldMap; // * by Cazax
// * Procedure WaitWorldMap; // * by Cazax
// * Procedure SearchPlace(Place : String); // * by Cazax
// * Procedure Zoom(Percent : Integer); // * by Cazax
// * Procedure GoToPlayer; // * by Cazax
{*******************************************************************************
Procedure OpenWorldMap;
By: Cazax
Description: Opens world map
*******************************************************************************}
Procedure OpenWorldMap;
Begin
If Not LoggedIn Then
Exit;
MouseBox(527, 125, 559, 156, 1);
End;
{*******************************************************************************
Function IsWorldMapOpened: Boolean;
By: Cazax
Description: Returns true if the world map is opened
*******************************************************************************}
Function IsWorldMapOpened: Boolean;
Begin
Result := GetColor(29, 481) = 65536;
End;
{*******************************************************************************
Procedure CloseWorldMap;
By: Cazax
Description: Closes world map
*******************************************************************************}
Procedure CloseWorldMap;
Begin
If Not IsWorldMapOpened Then
Exit;
MouseBox(740, 10, 755, 25, 1);
End;
{*******************************************************************************
Procedure WaitWorldMap;
By: Cazax
Description: Waits for the world map to load
*******************************************************************************}
Procedure WaitWorldMap;
Var
T : Integer;
Begin
T := GetTickCount;
While (GetColor(229, 154) = 0) Do
Begin
Wait(250 + Random(350));
If Random(5) = 0 Then
IdleTime(250 + Random(500), 3, 2);
If TimeFromMark(T) > 15000 Then
Begin
Writeln('World map opening is taking too much time');
CloseWorldMap;
Exit;
End;
End;
End;
{*******************************************************************************
Procedure SearchPlace(Place : String);
By: Cazax
Description: Finds a place using the searcher
*******************************************************************************}
Procedure SearchPlace(Place : String);
Begin
If Not isWorldMapOpened Then
Exit;
TypeSend(Place);
While IsMoving(250) Do
Wait(150 + Random(100));
End;
{*******************************************************************************
Procedure Zoom(Percent : Integer);
By: Cazax
Description: Zooms the world map according to the percent. It can be 37, 50, 75, 100 or 200
*******************************************************************************}
Procedure Zoom(Percent : Integer);
Var
T, I : Integer;
Begin
If Not IsWorldMapOpened Then
Exit;
If Not InIntArray([37, 50, 75, 100, 200], Percent) Then
Begin
Writeln('Incorrect zoom percent');
Exit;
End;
For I := 1 To 4 Do
Begin
MouseBox(742, 480, 757, 495, 1);
Wait(500 + Random(250));
End;
Case Percent Of
37: Exit;
50: T := 1;
75: T := 2;
100: T := 3;
200: T := 4;
End;
For I := 1 To T Do
Begin
MouseBox(742, 464, 755, 477, 1);
Wait(500 + Random(250));
End;
End;
{*******************************************************************************
Procedure GoToPlayer;
By: Cazax
Description: Goes to the player's position using the 'You are here' sign
*******************************************************************************}
Procedure GoToPlayer;
Var
TPA : TPointArray;
X, Y : Integer;
Box : TBox;
Begin
If Not IsWorldMapOpened Then
Exit;
If FindColorsTolerance(TPA, 9100798 , 0, 0, 764, 502, 10) Then
Begin
Box := GetTPABounds(TPA);
MouseBox(Box.X1, Box.Y1, Box.X2, Box.Y2, 1);
While IsMoving(250) Do
Wait(150 + Random(100));
End;
End;