Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function TReflectionLogin.SortWorlds(Members: Boolean; PVP: Boolean = False): TIntegerArray;
- var
- PVPW, FreeW, MembW, DeadW: TIntegerArray;
- begin
- PVPW := [325, 337];
- DeadW := [321, 345];
- FreeW := [301, 308, 316, 326, 335, 381, 382, 383, 384, 385, 393, 394];
- MembW := [302, 303, 304, 305, 306, 307, 309, 310, 311, 312, 313, 314, 315, 317,
- 318, 319, 320, 322, 323, 324, 327, 328, 329, 330, 331, 332, 333, 334, 336,
- 338, 339, 340, 341, 342, 343, 344, 346, 347, 348, 349, 350, 351, 352, 353,
- 354, 355, 356, 357, 358, 359, 360, 361, 362, 365, 366, 367, 368, 369,
- 370, 373, 374, 375, 376, 377, 378, 386];
- If Members then
- Result := MembW
- else
- Result := FreeW;
- If (Members) and (PVP) then
- Result := CombineIntArray(PVPW, MembW);
- end;
- function TReflectionLogin.RandomWorld(Members: Boolean; PVP: Boolean = False): Integer;
- var
- Worlds: TIntegerArray;
- begin
- Worlds := Reflect.Login.SortWorlds(Members, PVP);
- Result := Worlds[Random(Length(Worlds))];
- end;
- function TReflectionLogin.GetClientState: Integer;
- begin
- Result := (Reflect.Smart.GetFieldInt(0, Client_LoginState));
- end;
- function TReflectionLogin.AtLogin: Boolean;
- begin
- Result := Reflect.Login.GetClientState = 10;
- end;
- function TReflectionLogin.AtWorldScreen: Boolean;
- begin
- Result := CountColor(0, 2, 30, 100, 400) > 10000;
- end;
- function TReflectionLogin.AtLobby: Boolean;
- var
- W: TReflectWidget;
- begin
- Result := W.IsValid(Interface_Lobby, Widget_Lobby_Close_Child);
- W.Free;
- end;
- function TReflectionLogin.OpenWorldSelector: Boolean;
- const
- ClickSwitchButton: TBox = [5, 465, 105, 495];
- var
- T: TReflectTimer;
- Tries: Integer;
- begin
- if Reflect.Login.AtWorldScreen then
- Exit(True);
- repeat
- If not Reflect.Login.AtLogin then
- Exit(False);
- Inc(Tries);
- Reflect.Mouse.Move(ClickSwitchButton, Mouse_Left);
- T.Start;
- while (not Result) and (T.ElapsedTime < 5000) do
- Result := Reflect.Login.AtWorldScreen;
- until(Result)or(Tries > 4);
- end;
- function TReflectionLogin.ExitWorldSelector: Boolean;
- const
- ClickCancelButton: TBox = [709, 4, 753, 16];
- var
- T: TReflectTimer;
- Tries: Integer;
- begin
- if not Reflect.Login.AtWorldScreen then
- Exit(True);
- repeat
- if not Reflect.Login.AtWorldScreen then
- Exit(True);
- Inc(Tries);
- Reflect.Mouse.Move(ClickCancelButton, Mouse_Left);
- T.Start;
- while (not Result) and (T.ElapsedTime < 5000) do
- Result := (not Reflect.Login.AtWorldScreen);
- until(Result)or(Tries > 4);
- end;
- function TReflectionLogin.SelectWorld(World: Integer): Boolean;
- const
- Worlds: TIntegerArray = [301, 318, 335, 352, 373,
- 302, 319, 336, 353, 374,
- 303, 320, 337, 354, 375,
- 304, 321, 338, 355, 376,
- 305, 322, 339, 356, 377,
- 306, 323, 340, 357, 378,
- 307, 324, 341, 358, 381,
- 308, 325, 342, 359, 382,
- 309, 326, 343, 360, 383,
- 310, 327, 344, 361, 384,
- 311, 328, 345, 362, 385,
- 312, 329, 346, 365, 386,
- 313, 330, 347, 366, 393,
- 314, 331, 348, 367, 394,
- 315, 332, 349, 368, -1,
- 316, 333, 350, 369, -1,
- 317, 334, 351, 370, -1];
- var
- I: Integer;
- T: TReflectTimer;
- begin
- if (not InIntArrayEx(Worlds, I, World)) or (Not Reflect.Login.AtWorldScreen) then
- Exit(False);
- Wait(RandomRange(250, 500));
- Reflect.Mouse.Move(Reflect.Math.GridBox(I + 1, 5, 17, 87, 17, 93, 24, Point(195, 70)),
- Mouse_Left);
- T.Start;
- while (Reflect.Login.AtWorldScreen) and (T.ElapsedTime < 5000) do
- Wait(RandomRange(100, 200));
- Result := (not Reflect.Login.AtWorldScreen);
- end;
- function TReflectionLogin.GetLoginState: Integer;
- var
- ColorCount: Integer;
- begin
- Result := -1;
- case Reflect.Login.GetClientState of
- 10:
- begin
- ColorCount := CountColor(Login_Text_Yellow, 304, 237, 460, 256);
- If (ColorCount = 479) then
- Exit(Login_ExistingUser);
- ColorCount := CountColor(Login_Text_Yellow, 204, 165, 570, 253);
- case ColorCount of
- 799, 863: Result := Login_EnterUser;
- 1439, 774, 1437, 738, 1539, 1073, 492, 1721, 906, 1227,
- 1231, 1136, 777, 1700, 1666, 1783, 439, 210,
- 1017, 1037, 1053, 1022: Result := Login_Problems;
- end;
- end;
- 20: Result := Login_Connecting;
- 30:
- If Reflect.Login.AtLobby then
- Result := Login_ClickToPlay;
- end;
- end;
- function TReflectionLogin.GetCursor: Byte;
- var
- TimeOut: UInt64;
- begin
- TimeOut := GetTickCount64 + Random(3000, 4000);
- repeat
- if (CountColor(Login_Text_Yellow, Login_LoginBox.X1, Login_LoginBox.Y1,
- Login_LoginBox.X2, Login_LoginBox.Y2) > 10) then
- Exit(Login_LoginBox_Byte);
- if (CountColor(Login_Text_Yellow, Login_PasswordBox.X1,
- Login_PasswordBox.Y1, Login_PasswordBox.X2,
- Login_PasswordBox.Y2) > 10) then
- Exit(Login_PasswordBox_Byte);
- Wait(Random(25, 50));
- until (GetTickCount64 > TimeOut);
- end;
- procedure TReflectionLogin.SetCursor(const New: Integer);
- var
- T: TReflectTimer;
- begin
- if (Reflect.Login.GetCursor = New) then
- Exit;
- T.Start;
- while (Reflect.Login.GetCursor <> New) and
- (Reflect.Login.GetLoginState = Login_EnterUser) and
- (T.ElapsedTime < 8000) do
- begin
- Reflect.Keyboard.Send('{tab}');
- Wait(Random(350, 650));
- end;
- end;
- function TReflectionLogin.LoginProblems: Boolean;
- var
- ColorCount: Integer;
- begin
- ColorCount := CountColor(Login_Text_Yellow, 204, 165, 570, 253);
- case ColorCount of
- 738, 1539, 1136: Reflect.Logger.Fatal(
- 'We''ve been forced to terminate due to failing logging into your account.');
- 1073, 777, 1227: {Retry}
- begin
- Reflect.Logger.Warn('Already logged in, retry');
- Wait(15000+Random(10000));
- Reflect.Mouse.Move(238, 309, 364, 334, Mouse_Left);
- end;
- 1439: { Too many login attempts }
- begin
- Reflect.Logger.Warn('Too many login attempts, waiting 5-10 seconds...');
- Wait(5000+Random(10000));
- Reflect.Mouse.Move(238, 309, 364, 334, Mouse_Left);
- end;
- 1721: {Too many incorrect logins}
- begin
- Reflect.Logger.Warn('Too many incorrect logins, waiting for 5 minutes');
- Wait(RandomRange(1000*60*5, 1000*60*6));
- Reflect.Mouse.Move(238, 309, 364, 334, Mouse_Left);
- end;
- 906: {World is full}
- begin
- Reflect.Logger.Warn('World is full, re-trying');
- Reflect.Mouse.Move(238, 309, 364, 334, Mouse_Left);
- Wait(RandomRange(1000, 2000));
- end;
- 492, 1231, 1666, 1017, 1037, 1053, 1022: {World change}
- begin
- Reflect.Logger.Warn('Changing world.');
- Reflect.Mouse.Move(IntToBox(5, 465, 105, 495), Mouse_Left);
- Wait(RandomRange(500, 700));
- if Reflect.Login.SelectWorld(RandomWorld(True)) then
- Wait(RandomRange(550, 650));
- Reflect.Mouse.Move(238, 309, 364, 334, Mouse_Left);
- end;
- 1700, 1783: {F2p world needed}
- begin
- Reflect.Logger.Warn('Changing world.');
- Reflect.Mouse.Move(IntToBox(5, 465, 105, 495), Mouse_Left);
- Wait(RandomRange(500, 700));
- if Reflect.Login.SelectWorld(RandomWorld(False)) then
- Wait(RandomRange(550, 650));
- Reflect.Mouse.Move(238, 309, 364, 334, Mouse_Left);
- end;
- 439, 210: {PVP world -> Exit}
- begin
- Reflect.Mouse.Move(IntToBox(408, 310, 517, 333), Mouse_Left);
- Reflect.Logger.Warn('Changing world.');
- Reflect.Mouse.Move(IntToBox(5, 465, 105, 495), Mouse_Left);
- Wait(RandomRange(500, 700));
- if Reflect.Login.SelectWorld(RandomWorld(True)) then
- Wait(RandomRange(550, 650));
- end;
- end;
- end;
- Procedure TReflectionLogin.EnterDetails(Username, Password: String);
- var
- Clear: array [0..1] of Boolean;
- Timeout: UInt64 := GetTickCount64 + Random(7500, 8000);
- begin
- Clear[Login_LoginBox_Byte] := CountColor(Login_Text_White, Login_LoginBox.X1,
- Login_LoginBox.Y1, Login_LoginBox.X2,
- Login_LoginBox.Y2);
- Clear[Login_PasswordBox_Byte] := CountColor(Login_Text_White,
- Login_PasswordBox.X1,
- Login_PasswordBox.Y1,
- Login_PasswordBox.X2,
- Login_PasswordBox.Y2);
- if (Reflect.Login.GetCursor <> Login_LoginBox_Byte) then
- Reflect.Login.SetCursor(Login_LoginBox_Byte);
- if (Clear[Login_LoginBox_Byte]) then
- while (CountColor(Login_Text_White, Login_LoginBox.X1, Login_LoginBox.Y1, Login_LoginBox.X2, Login_LoginBox.Y2) > 5) and (Timeout > GetTickCount64) do
- begin
- Reflect.Keyboard.Send('{backspace}');
- Wait(Random(30, 120));
- end;
- Reflect.Keyboard.Send(Username);
- if (Reflect.Login.GetCursor <> Login_PasswordBox_Byte) then
- Reflect.Login.SetCursor(Login_PasswordBox_Byte);
- if (Clear[Login_PasswordBox_Byte]) then
- while (CountColor(Login_Text_White, Login_PasswordBox.X1,
- Login_PasswordBox.Y1, Login_PasswordBox.X2,
- Login_PasswordBox.Y2) > 5) and (Timeout > GetTickCount64) do
- begin
- Reflect.Keyboard.Send('{backspace}');
- Wait(Random(30, 120));
- end;
- Reflect.Keyboard.Send(Password+'{enter}');
- Wait(1000+Random(500));
- end;
- function TReflectionLogin.LoginPlayer(Username, Password: string): Boolean;
- var
- CurState, Tries: Integer;
- T, TLogged: TReflectTimer;
- begin
- If (Reflect.Login.GetClientState = 30) and (Not Reflect.Login.AtLobby) then
- Exit(True);
- If Self.ExitWorldSelector then
- Wait(500+Random(700));
- repeat
- CurState := Reflect.Login.GetLoginState;
- If CurState = -1 then
- Inc(Tries);
- T.Start;
- case CurState of
- LOGIN_ExistingUser: Reflect.Mouse.Move(Login_ExistingUserBox, Mouse_Left);
- LOGIN_EnterUser: Reflect.Login.EnterDetails(Username, Password);
- LOGIN_Problems: Reflect.Login.LoginProblems;
- LOGIN_Connecting: Wait(RandomRange(500, 1000));
- LOGIN_ClickToPlay:
- begin
- Wait(RandomRange(300, 600));
- Reflect.Mouse.Move(330, 315, 483, 360, Mouse_Left);
- TLogged.Start;
- repeat
- Wait(RandomRange(100, 200));
- until(TLogged.ElapsedTime > 3000)or((Reflect.Login.GetClientState = 30) and (Not Reflect.Login.AtLobby));
- end;
- else
- Wait(RandomRange(100, 200));
- end;
- If Not (InIntArray([Login_Connecting, Login_ClickToPlay], CurState))then
- While(not CurState = Reflect.Login.GetLoginState + 1) and
- (T.ElapsedTime < 5000) do
- Wait(RandomRange(100, 200));
- until(Tries > 30)or((Reflect.Login.GetClientState = 30) and (Not Reflect.Login.AtLobby));
- Result := ((Reflect.Login.GetClientState = 30) and (Not Reflect.Login.AtLobby));
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement