Advertisement
Guest User

Untitled

a guest
Jul 10th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.45 KB | None | 0 0
  1. program UniversalFighter;
  2. {$DEFINE SMART}
  3. {$i SRL\SRL.scar}
  4. {$i Reflection\Reflection.Simba}
  5.  
  6.  
  7. const
  8. sSigned = True;
  9. sMems = True;
  10. sHD = False;
  11. sWorld = 30;
  12.  
  13. type
  14. {offs = array[0..1] of Extended;}
  15. TUFUser = record //Type Universal Fighter User
  16. Name: string;
  17. Pass: string;
  18. Active: Boolean;
  19. AtBank: Boolean;
  20. Nick: string;
  21. Pin: string;
  22. Monster: string;
  23. MultiCombat: Boolean;
  24. BankLocation: string;
  25. Path: TPointArray; //Tile path to walk to bank
  26. ObstArray: TPointArray; //array of tiles that any obstacles are on (doors, stairs, ladders, etc.)
  27. {OffsArray: array of offs;}
  28. MaxFightTime: Integer;
  29. end;
  30.  
  31.  
  32. var
  33. UF_Players: array of TUFUser;
  34.  
  35.  
  36. procedure DeclarePlayers;
  37. var
  38. i: Integer;
  39. begin
  40. HowManyPlayers := 1;
  41. NumberOfPlayers(HowManyPlayers);
  42. CurrentPlayer := 0;
  43. SetLength(UF_Players, HowManyPlayers);
  44.  
  45. with UF_Players[0] do //info here is for al-kharid warriors
  46. begin
  47. Name := ''; //sign in name (or email)
  48. Pass := ''; //password
  49. Active := True; //use this player?
  50. AtBank := True; //Is this player starting in the bank?
  51. Nick := ''; //nickname [for progress report, set to whatever you'd like]
  52. Pin := ''; //bank pin
  53. MaxFightTime := 8000; //maximum time to wait while fighting (in ms)
  54. Monster := 'Al-Kharid warrior'; //Monster to attack; exact name, perfect capitilization, exact spacing
  55. BankLocation := 'akb'; //bank location (See R_OpenBankBooth for valid settings)
  56. MultiCombat := True;
  57. Path := [Point(3269, 3168), Point(3280, 3182), Point(3286, 3172)]; //tile path from bank to location of monsters.
  58. //make sure the first point is in the bank and
  59. //the last point is at the monsters
  60. ObstArray := [NULL_TILE, NULL_TILE, NULL_TILE];
  61. end;
  62.  
  63. for i := 0 to (HowManyPlayers - 1) do
  64. begin
  65. with Players[i] do
  66. begin
  67. Name := UF_Players[i].Name;
  68. Nick := UF_Players[i].Nick;
  69. Active := UF_Players[i].Active;
  70. Pass := UF_Players[i].Pass;
  71. Pin := UF_Players[i].Pin;
  72. end;
  73. end;
  74. end;
  75.  
  76.  
  77. function InvertT2DExtendedArray(arr: T2DExtendedArray): T2DExtendedArray;
  78. var
  79. i, j: Integer;
  80. begin
  81. SetLength(Result, Length(arr));
  82. for i := High(arr) downto 0 do
  83. for j := 0 to High(Result) do
  84. Result[j] := arr[i];
  85. end;
  86.  
  87.  
  88. function WalkAndHandle(ToOrFro: Boolean): Boolean; //Walks a tile path and handles objects using given x/y offsets
  89. var
  90. TileArr, ObstArr: TPointArray;
  91. {OffsArr: array of array[0..1] of Extended; }
  92. i: Integer;
  93. Pt: TPoint;
  94. begin
  95. if not(LoggedIn) then
  96. Exit;
  97. TileArr := UF_Players[CurrentPlayer].Path;
  98. ObstArr := UF_Players[CurrentPlayer].ObstArray;
  99. {OffsArr := UF_Players[CurrentPlayer].OffsArray;}
  100. if not(ToOrFro) then
  101. begin
  102. InvertTPA(TileArr);
  103. InvertTPA(ObstArr);
  104. {OffsArr := InvertT2DExtendedArray(OffsArr);}
  105. end;
  106. for i := 0 to High(TileArr) do
  107. begin
  108. R_FindRandoms;
  109. if TileOnMM(TileArr[i]) then
  110. begin
  111. Pt := TileToMM(TileArr[i]);
  112. Mouse(Pt.x - 1, Pt.y - 1, 2, 2, True);
  113. FFlag(0);
  114. if (UF_Players[CurrentPlayer].ObstArray[i] <> NULL_TILE) then
  115. begin
  116. if TileOnMS(ObstArr[i], 0) then
  117. begin
  118. Pt := TileToMS{Ex}(ObstArr[i], {OffsArr[i][0], OffsArr[i][1],} 0);
  119. Mouse(Pt.x, Pt.y, 0, 0, True);
  120. FFlag(0);
  121. end else
  122. begin
  123. Writeln('failed to handle obstacle ' + IntToStr(i) + ' in player ' + IntToStr(CurrentPlayer) + '''s obstacle array because it was not on the main screen after we walked to tile ' + IntToStr(i));
  124. Logout;
  125. Players[CurrentPlayer].Active := False;
  126. UF_Players[CurrentPlayer].Active := False;
  127. Exit;
  128. end;
  129. end;
  130. end else
  131. begin
  132. Writeln('failed to walk to tile ' + IntToStr(i) + ' in player ' + IntToStr(CurrentPlayer) + '''s tile path because it was not found on the minimap');
  133. Logout;
  134. Players[CurrentPlayer].Active := False;
  135. UF_Players[CurrentPlayer].Active := False;
  136. Exit;
  137. end;
  138. end;
  139. Result := True; //If it gets to this point, then it never exit'd because none of the checks returned false
  140. end;
  141.  
  142.  
  143. function AttackMonster: Boolean;
  144. var
  145. NPCs: TNPCArray;
  146. Target: TNPC;
  147. i, j: Integer;
  148. Pt: TPoint;
  149. begin
  150. if not(LoggedIn) then
  151. Exit;
  152. Target := NULL_NPC;
  153. NPCs := SortNPCs(GetNPCsBy(UF_Players[CurrentPlayer].Monster));
  154. if (Length(NPCs) < 1) then
  155. Exit;
  156. for i := 0 to High(NPCs) do
  157. if (NPCs[i].Name = UF_Players[CurrentPlayer].Monster) then
  158. begin
  159. if (UF_Players[CurrentPlayer].MultiCombat = False) then
  160. begin
  161. if (NPCs[i].Fighting = False) then
  162. for j := 0 to High(NPCs[i].Actions) do
  163. begin
  164. if (NPCs[i].Actions[j] = 'Attack') then
  165. begin
  166. Target := NPCs[i];
  167. Break;
  168. end;
  169. end;
  170. end else
  171. begin
  172. for j := 0 to High(NPCs[i].Actions) do
  173. begin
  174. if (NPCs[i].Actions[j] = 'Attack') then
  175. begin
  176. Target := NPCs[i];
  177. Break;
  178. end;
  179. end;
  180. end;
  181. end;
  182. if (Target = NULL_NPC) then
  183. Exit;
  184. if not(TileOnMS(Target.Tile, 0)) then
  185. if not(WalkToTile(Target.Tile, 0, 0)) then
  186. Exit;
  187. Pt := TileToMS(Target.Tile, (RandomRange(1/3, 2/3) * Target.Height));
  188. MMouse(Pt.x - 4, Pt.y - 4, 8, 8);
  189. if R_WaitUptext(UF_Players[CurrentPlayer].Monster, Length(UF_Players[CurrentPlayer].Monster) * 600) then
  190. begin
  191. ClickMouse2(False);
  192. Result := R_WaitOption('tack', 2400);
  193. end else
  194. Exit;
  195. if Result then(FFlag(0));
  196. end;
  197.  
  198.  
  199. function Bank: Boolean;
  200. var
  201. FoodTexts: TStringArray;
  202. begin
  203. if not(LoggedIn) then
  204. Exit;
  205. R_FindRandoms;
  206. if not R_OpenBankBooth(UF_Players[CurrentPlayer].BankLocation) then
  207. Exit;
  208. FoodTexts := ['Meat', 'Shrimp', 'Crayfish', 'Chicken', 'Rabbit', 'Anchovies', 'Sardine',
  209. 'Karambwanji', 'Karambwan', 'Ugthanki kebab', 'Herring', 'Mackerel',
  210. 'Roasted bird meat', 'Thin snail', 'Trout', 'Spider', 'Roasted rabbit',
  211. 'Lean snail', 'Cod', 'Pike', 'Roasted beast meat', 'Giant crab meat',
  212. 'Fat snail', 'Salmon', 'Slimy eel', 'Tuna', 'Roasted chompy', 'Fishcake',
  213. 'Rainbow fish', 'Cave eel', 'Lobster', 'Jubbly', 'Bass', 'Swordfish',
  214. 'Oomlie wrap', 'Lava eel', 'Monkfish', 'Shark', 'Sea turtle', 'Cavefish',
  215. 'Manta ray', 'Rocktail']
  216. Result := WithdrawEx(1, 1, 28, FoodTexts);
  217. end;
  218.  
  219.  
  220. function Eat: Boolean;
  221. var
  222. i: Integer;
  223. begin
  224. if ((not(LoggedIn)) or (not(HPPercent < 70))) then
  225. Exit;
  226. R_FindRandoms;
  227. for i := 1 to 28 do
  228. if ExistsItem(i) then
  229. begin
  230. MouseItem(i, false);
  231. if WaitUptext('Eat', 1200) then
  232. begin
  233. ClickMouse2(True);
  234. Result := True;
  235. Break;
  236. end;
  237. end;
  238. end;
  239.  
  240.  
  241. procedure MainLoop;
  242. var
  243. a, T: Integer; //a for attempts; T for Time
  244. begin
  245. Smart_Server := sWorld;
  246. Smart_Members := sMems;
  247. Smart_Signed := sSigned;
  248. Smart_SuperDetail := sHD;
  249. SetupSRL;
  250. SetupReflectionEx(True);
  251. DeclarePlayers;
  252. repeat
  253. LogInPlayer;
  254. SetAngle(True);
  255. repeat
  256. if UF_Players[CurrentPlayer].AtBank then
  257. if WalkAndHandle(True) then
  258. UF_Players[CurrentPlayer].AtBank := False;
  259. repeat
  260. repeat
  261. AttackMonster;
  262. inc(a);
  263. until((a > 4) or srl_InFight);
  264. if ((a > 4) and not(srl_InFight)) then
  265. begin
  266. Writeln('we failed to attack a monster more than 4 times. Exiting.');
  267. UF_Players[CurrentPlayer].Active := False;
  268. Players[CurrentPlayer].Active := False;
  269. Logout;
  270. end;
  271. T := GetSystemTime + UF_Players[CurrentPlayer].MaxFightTime;
  272. repeat
  273. R_FindRandoms;
  274. Wait(600 + Random(60));
  275. Eat;
  276. until(not(srl_InFight) or (GetSystemTime > T));
  277. until(InvEmpty or not(LoggedIn));
  278. if WalkAndHandle(False) then
  279. UF_Players[CurrentPlayer].AtBank := True;
  280. if not(Bank) then
  281. begin
  282. Writeln('banking failed. logging out.');
  283. Logout;
  284. UF_Players[CurrentPlayer].Active := False;
  285. Players[CurrentPlayer].Active := False;
  286. end;
  287. until(not(LoggedIn));
  288. until(AllPlayersInactive);
  289. end;
  290.  
  291.  
  292. begin
  293. MainLoop;
  294. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement