Advertisement
Guest User

Untitled

a guest
Feb 18th, 2017
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.77 KB | None | 0 0
  1. function TReflectionLogin.SortWorlds(Members: Boolean; PVP: Boolean = False): TIntegerArray;
  2. var
  3. PVPW, FreeW, MembW, DeadW: TIntegerArray;
  4. begin
  5. PVPW := [325, 337];
  6. DeadW := [321, 345];
  7. FreeW := [301, 308, 316, 326, 335, 381, 382, 383, 384, 385, 393, 394];
  8. MembW := [302, 303, 304, 305, 306, 307, 309, 310, 311, 312, 313, 314, 315, 317,
  9. 318, 319, 320, 322, 323, 324, 327, 328, 329, 330, 331, 332, 333, 334, 336,
  10. 338, 339, 340, 341, 342, 343, 344, 346, 347, 348, 349, 350, 351, 352, 353,
  11. 354, 355, 356, 357, 358, 359, 360, 361, 362, 365, 366, 367, 368, 369,
  12. 370, 373, 374, 375, 376, 377, 378, 386];
  13. If Members then
  14. Result := MembW
  15. else
  16. Result := FreeW;
  17. If (Members) and (PVP) then
  18. Result := CombineIntArray(PVPW, MembW);
  19. end;
  20.  
  21. function TReflectionLogin.RandomWorld(Members: Boolean; PVP: Boolean = False): Integer;
  22. var
  23. Worlds: TIntegerArray;
  24. begin
  25. Worlds := Reflect.Login.SortWorlds(Members, PVP);
  26. Result := Worlds[Random(Length(Worlds))];
  27. end;
  28.  
  29. function TReflectionLogin.GetClientState: Integer;
  30. begin
  31. Result := (Reflect.Smart.GetFieldInt(0, Client_LoginState));
  32. end;
  33.  
  34. function TReflectionLogin.AtLogin: Boolean;
  35. begin
  36. Result := Reflect.Login.GetClientState = 10;
  37. end;
  38.  
  39. function TReflectionLogin.AtWorldScreen: Boolean;
  40. begin
  41. Result := CountColor(0, 2, 30, 100, 400) > 10000;
  42. end;
  43.  
  44. function TReflectionLogin.AtLobby: Boolean;
  45. var
  46. W: TReflectWidget;
  47. begin
  48. Result := W.IsValid(Interface_Lobby, Widget_Lobby_Close_Child);
  49. W.Free;
  50. end;
  51.  
  52. function TReflectionLogin.OpenWorldSelector: Boolean;
  53. const
  54. ClickSwitchButton: TBox = [5, 465, 105, 495];
  55. var
  56. T: TReflectTimer;
  57. Tries: Integer;
  58. begin
  59. if Reflect.Login.AtWorldScreen then
  60. Exit(True);
  61. repeat
  62. If not Reflect.Login.AtLogin then
  63. Exit(False);
  64. Inc(Tries);
  65. Reflect.Mouse.Move(ClickSwitchButton, Mouse_Left);
  66. T.Start;
  67. while (not Result) and (T.ElapsedTime < 5000) do
  68. Result := Reflect.Login.AtWorldScreen;
  69. until(Result)or(Tries > 4);
  70. end;
  71.  
  72. function TReflectionLogin.ExitWorldSelector: Boolean;
  73. const
  74. ClickCancelButton: TBox = [709, 4, 753, 16];
  75. var
  76. T: TReflectTimer;
  77. Tries: Integer;
  78. begin
  79. if not Reflect.Login.AtWorldScreen then
  80. Exit(True);
  81. repeat
  82. if not Reflect.Login.AtWorldScreen then
  83. Exit(True);
  84. Inc(Tries);
  85. Reflect.Mouse.Move(ClickCancelButton, Mouse_Left);
  86. T.Start;
  87. while (not Result) and (T.ElapsedTime < 5000) do
  88. Result := (not Reflect.Login.AtWorldScreen);
  89. until(Result)or(Tries > 4);
  90. end;
  91.  
  92. function TReflectionLogin.SelectWorld(World: Integer): Boolean;
  93. const
  94. Worlds: TIntegerArray = [301, 318, 335, 352, 373,
  95. 302, 319, 336, 353, 374,
  96. 303, 320, 337, 354, 375,
  97. 304, 321, 338, 355, 376,
  98. 305, 322, 339, 356, 377,
  99. 306, 323, 340, 357, 378,
  100. 307, 324, 341, 358, 381,
  101. 308, 325, 342, 359, 382,
  102. 309, 326, 343, 360, 383,
  103. 310, 327, 344, 361, 384,
  104. 311, 328, 345, 362, 385,
  105. 312, 329, 346, 365, 386,
  106. 313, 330, 347, 366, 393,
  107. 314, 331, 348, 367, 394,
  108. 315, 332, 349, 368, -1,
  109. 316, 333, 350, 369, -1,
  110. 317, 334, 351, 370, -1];
  111. var
  112. I: Integer;
  113. T: TReflectTimer;
  114. begin
  115. if (not InIntArrayEx(Worlds, I, World)) or (Not Reflect.Login.AtWorldScreen) then
  116. Exit(False);
  117. Wait(RandomRange(250, 500));
  118. Reflect.Mouse.Move(Reflect.Math.GridBox(I + 1, 5, 17, 87, 17, 93, 24, Point(195, 70)),
  119. Mouse_Left);
  120. T.Start;
  121. while (Reflect.Login.AtWorldScreen) and (T.ElapsedTime < 5000) do
  122. Wait(RandomRange(100, 200));
  123. Result := (not Reflect.Login.AtWorldScreen);
  124. end;
  125.  
  126. function TReflectionLogin.GetLoginState: Integer;
  127. var
  128. ColorCount: Integer;
  129. begin
  130. Result := -1;
  131. case Reflect.Login.GetClientState of
  132. 10:
  133. begin
  134. ColorCount := CountColor(Login_Text_Yellow, 304, 237, 460, 256);
  135. If (ColorCount = 479) then
  136. Exit(Login_ExistingUser);
  137. ColorCount := CountColor(Login_Text_Yellow, 204, 165, 570, 253);
  138. case ColorCount of
  139. 799, 863: Result := Login_EnterUser;
  140. 1439, 774, 1437, 738, 1539, 1073, 492, 1721, 906, 1227,
  141. 1231, 1136, 777, 1700, 1666, 1783, 439, 210,
  142. 1017, 1037, 1053, 1022: Result := Login_Problems;
  143. end;
  144. end;
  145. 20: Result := Login_Connecting;
  146. 30:
  147. If Reflect.Login.AtLobby then
  148. Result := Login_ClickToPlay;
  149. end;
  150. end;
  151.  
  152. function TReflectionLogin.GetCursor: Byte;
  153. var
  154. TimeOut: UInt64;
  155. begin
  156. TimeOut := GetTickCount64 + Random(3000, 4000);
  157. repeat
  158. if (CountColor(Login_Text_Yellow, Login_LoginBox.X1, Login_LoginBox.Y1,
  159. Login_LoginBox.X2, Login_LoginBox.Y2) > 10) then
  160. Exit(Login_LoginBox_Byte);
  161. if (CountColor(Login_Text_Yellow, Login_PasswordBox.X1,
  162. Login_PasswordBox.Y1, Login_PasswordBox.X2,
  163. Login_PasswordBox.Y2) > 10) then
  164. Exit(Login_PasswordBox_Byte);
  165. Wait(Random(25, 50));
  166. until (GetTickCount64 > TimeOut);
  167. end;
  168.  
  169. procedure TReflectionLogin.SetCursor(const New: Integer);
  170. var
  171. T: TReflectTimer;
  172. begin
  173. if (Reflect.Login.GetCursor = New) then
  174. Exit;
  175. T.Start;
  176. while (Reflect.Login.GetCursor <> New) and
  177. (Reflect.Login.GetLoginState = Login_EnterUser) and
  178. (T.ElapsedTime < 8000) do
  179. begin
  180. Reflect.Keyboard.Send('{tab}');
  181. Wait(Random(350, 650));
  182. end;
  183. end;
  184.  
  185. function TReflectionLogin.LoginProblems: Boolean;
  186. var
  187. ColorCount: Integer;
  188. begin
  189. ColorCount := CountColor(Login_Text_Yellow, 204, 165, 570, 253);
  190. case ColorCount of
  191. 738, 1539, 1136: Reflect.Logger.Fatal(
  192. 'We''ve been forced to terminate due to failing logging into your account.');
  193.  
  194. 1073, 777, 1227: {Retry}
  195. begin
  196. Reflect.Logger.Warn('Already logged in, retry');
  197. Wait(15000+Random(10000));
  198. Reflect.Mouse.Move(238, 309, 364, 334, Mouse_Left);
  199. end;
  200.  
  201. 1439: { Too many login attempts }
  202. begin
  203. Reflect.Logger.Warn('Too many login attempts, waiting 5-10 seconds...');
  204. Wait(5000+Random(10000));
  205. Reflect.Mouse.Move(238, 309, 364, 334, Mouse_Left);
  206. end;
  207.  
  208. 1721: {Too many incorrect logins}
  209. begin
  210. Reflect.Logger.Warn('Too many incorrect logins, waiting for 5 minutes');
  211. Wait(RandomRange(1000*60*5, 1000*60*6));
  212. Reflect.Mouse.Move(238, 309, 364, 334, Mouse_Left);
  213. end;
  214. 906: {World is full}
  215. begin
  216. Reflect.Logger.Warn('World is full, re-trying');
  217. Reflect.Mouse.Move(238, 309, 364, 334, Mouse_Left);
  218. Wait(RandomRange(1000, 2000));
  219. end;
  220. 492, 1231, 1666, 1017, 1037, 1053, 1022: {World change}
  221. begin
  222. Reflect.Logger.Warn('Changing world.');
  223. Reflect.Mouse.Move(IntToBox(5, 465, 105, 495), Mouse_Left);
  224. Wait(RandomRange(500, 700));
  225. if Reflect.Login.SelectWorld(RandomWorld(True)) then
  226. Wait(RandomRange(550, 650));
  227. Reflect.Mouse.Move(238, 309, 364, 334, Mouse_Left);
  228. end;
  229. 1700, 1783: {F2p world needed}
  230. begin
  231. Reflect.Logger.Warn('Changing world.');
  232. Reflect.Mouse.Move(IntToBox(5, 465, 105, 495), Mouse_Left);
  233. Wait(RandomRange(500, 700));
  234. if Reflect.Login.SelectWorld(RandomWorld(False)) then
  235. Wait(RandomRange(550, 650));
  236. Reflect.Mouse.Move(238, 309, 364, 334, Mouse_Left);
  237. end;
  238. 439, 210: {PVP world -> Exit}
  239. begin
  240. Reflect.Mouse.Move(IntToBox(408, 310, 517, 333), Mouse_Left);
  241. Reflect.Logger.Warn('Changing world.');
  242. Reflect.Mouse.Move(IntToBox(5, 465, 105, 495), Mouse_Left);
  243. Wait(RandomRange(500, 700));
  244. if Reflect.Login.SelectWorld(RandomWorld(True)) then
  245. Wait(RandomRange(550, 650));
  246. end;
  247. end;
  248. end;
  249.  
  250. Procedure TReflectionLogin.EnterDetails(Username, Password: String);
  251. var
  252. Clear: array [0..1] of Boolean;
  253. Timeout: UInt64 := GetTickCount64 + Random(7500, 8000);
  254. begin
  255. Clear[Login_LoginBox_Byte] := CountColor(Login_Text_White, Login_LoginBox.X1,
  256. Login_LoginBox.Y1, Login_LoginBox.X2,
  257. Login_LoginBox.Y2);
  258.  
  259. Clear[Login_PasswordBox_Byte] := CountColor(Login_Text_White,
  260. Login_PasswordBox.X1,
  261. Login_PasswordBox.Y1,
  262. Login_PasswordBox.X2,
  263. Login_PasswordBox.Y2);
  264.  
  265. if (Reflect.Login.GetCursor <> Login_LoginBox_Byte) then
  266. Reflect.Login.SetCursor(Login_LoginBox_Byte);
  267. if (Clear[Login_LoginBox_Byte]) then
  268. while (CountColor(Login_Text_White, Login_LoginBox.X1, Login_LoginBox.Y1, Login_LoginBox.X2, Login_LoginBox.Y2) > 5) and (Timeout > GetTickCount64) do
  269. begin
  270. Reflect.Keyboard.Send('{backspace}');
  271. Wait(Random(30, 120));
  272. end;
  273. Reflect.Keyboard.Send(Username);
  274. if (Reflect.Login.GetCursor <> Login_PasswordBox_Byte) then
  275. Reflect.Login.SetCursor(Login_PasswordBox_Byte);
  276. if (Clear[Login_PasswordBox_Byte]) then
  277. while (CountColor(Login_Text_White, Login_PasswordBox.X1,
  278. Login_PasswordBox.Y1, Login_PasswordBox.X2,
  279. Login_PasswordBox.Y2) > 5) and (Timeout > GetTickCount64) do
  280.  
  281. begin
  282. Reflect.Keyboard.Send('{backspace}');
  283. Wait(Random(30, 120));
  284. end;
  285. Reflect.Keyboard.Send(Password+'{enter}');
  286. Wait(1000+Random(500));
  287. end;
  288.  
  289. function TReflectionLogin.LoginPlayer(Username, Password: string): Boolean;
  290. var
  291. CurState, Tries: Integer;
  292. T, TLogged: TReflectTimer;
  293. begin
  294. If (Reflect.Login.GetClientState = 30) and (Not Reflect.Login.AtLobby) then
  295. Exit(True);
  296. If Self.ExitWorldSelector then
  297. Wait(500+Random(700));
  298. repeat
  299. CurState := Reflect.Login.GetLoginState;
  300. If CurState = -1 then
  301. Inc(Tries);
  302. T.Start;
  303. case CurState of
  304. LOGIN_ExistingUser: Reflect.Mouse.Move(Login_ExistingUserBox, Mouse_Left);
  305. LOGIN_EnterUser: Reflect.Login.EnterDetails(Username, Password);
  306. LOGIN_Problems: Reflect.Login.LoginProblems;
  307. LOGIN_Connecting: Wait(RandomRange(500, 1000));
  308. LOGIN_ClickToPlay:
  309. begin
  310. Wait(RandomRange(300, 600));
  311. Reflect.Mouse.Move(330, 315, 483, 360, Mouse_Left);
  312. TLogged.Start;
  313. repeat
  314. Wait(RandomRange(100, 200));
  315. until(TLogged.ElapsedTime > 3000)or((Reflect.Login.GetClientState = 30) and (Not Reflect.Login.AtLobby));
  316. end;
  317. else
  318. Wait(RandomRange(100, 200));
  319. end;
  320. If Not (InIntArray([Login_Connecting, Login_ClickToPlay], CurState))then
  321. While(not CurState = Reflect.Login.GetLoginState + 1) and
  322. (T.ElapsedTime < 5000) do
  323. Wait(RandomRange(100, 200));
  324. until(Tries > 30)or((Reflect.Login.GetClientState = 30) and (Not Reflect.Login.AtLobby));
  325. Result := ((Reflect.Login.GetClientState = 30) and (Not Reflect.Login.AtLobby));
  326. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement