Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program UniversalFighter;
- {$DEFINE SMART}
- {$i SRL\SRL.scar}
- {$i Reflection\Reflection.Simba}
- const
- sSigned = True;
- sMems = True;
- sHD = False;
- sWorld = 30;
- type
- {offs = array[0..1] of Extended;}
- TUFUser = record //Type Universal Fighter User
- Name: string;
- Pass: string;
- Active: Boolean;
- AtBank: Boolean;
- Nick: string;
- Pin: string;
- Monster: string;
- MultiCombat: Boolean;
- BankLocation: string;
- Path: TPointArray; //Tile path to walk to bank
- ObstArray: TPointArray; //array of tiles that any obstacles are on (doors, stairs, ladders, etc.)
- {OffsArray: array of offs;}
- MaxFightTime: Integer;
- end;
- var
- UF_Players: array of TUFUser;
- procedure DeclarePlayers;
- var
- i: Integer;
- begin
- HowManyPlayers := 1;
- NumberOfPlayers(HowManyPlayers);
- CurrentPlayer := 0;
- SetLength(UF_Players, HowManyPlayers);
- with UF_Players[0] do //info here is for al-kharid warriors
- begin
- Name := ''; //sign in name (or email)
- Pass := ''; //password
- Active := True; //use this player?
- AtBank := True; //Is this player starting in the bank?
- Nick := ''; //nickname [for progress report, set to whatever you'd like]
- Pin := ''; //bank pin
- MaxFightTime := 8000; //maximum time to wait while fighting (in ms)
- Monster := 'Al-Kharid warrior'; //Monster to attack; exact name, perfect capitilization, exact spacing
- BankLocation := 'akb'; //bank location (See R_OpenBankBooth for valid settings)
- MultiCombat := True;
- Path := [Point(3269, 3168), Point(3280, 3182), Point(3286, 3172)]; //tile path from bank to location of monsters.
- //make sure the first point is in the bank and
- //the last point is at the monsters
- ObstArray := [NULL_TILE, NULL_TILE, NULL_TILE];
- end;
- for i := 0 to (HowManyPlayers - 1) do
- begin
- with Players[i] do
- begin
- Name := UF_Players[i].Name;
- Nick := UF_Players[i].Nick;
- Active := UF_Players[i].Active;
- Pass := UF_Players[i].Pass;
- Pin := UF_Players[i].Pin;
- end;
- end;
- end;
- function InvertT2DExtendedArray(arr: T2DExtendedArray): T2DExtendedArray;
- var
- i, j: Integer;
- begin
- SetLength(Result, Length(arr));
- for i := High(arr) downto 0 do
- for j := 0 to High(Result) do
- Result[j] := arr[i];
- end;
- function WalkAndHandle(ToOrFro: Boolean): Boolean; //Walks a tile path and handles objects using given x/y offsets
- var
- TileArr, ObstArr: TPointArray;
- {OffsArr: array of array[0..1] of Extended; }
- i: Integer;
- Pt: TPoint;
- begin
- if not(LoggedIn) then
- Exit;
- TileArr := UF_Players[CurrentPlayer].Path;
- ObstArr := UF_Players[CurrentPlayer].ObstArray;
- {OffsArr := UF_Players[CurrentPlayer].OffsArray;}
- if not(ToOrFro) then
- begin
- InvertTPA(TileArr);
- InvertTPA(ObstArr);
- {OffsArr := InvertT2DExtendedArray(OffsArr);}
- end;
- for i := 0 to High(TileArr) do
- begin
- R_FindRandoms;
- if TileOnMM(TileArr[i]) then
- begin
- Pt := TileToMM(TileArr[i]);
- Mouse(Pt.x - 1, Pt.y - 1, 2, 2, True);
- FFlag(0);
- if (UF_Players[CurrentPlayer].ObstArray[i] <> NULL_TILE) then
- begin
- if TileOnMS(ObstArr[i], 0) then
- begin
- Pt := TileToMS{Ex}(ObstArr[i], {OffsArr[i][0], OffsArr[i][1],} 0);
- Mouse(Pt.x, Pt.y, 0, 0, True);
- FFlag(0);
- end else
- begin
- 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));
- Logout;
- Players[CurrentPlayer].Active := False;
- UF_Players[CurrentPlayer].Active := False;
- Exit;
- end;
- end;
- end else
- begin
- Writeln('failed to walk to tile ' + IntToStr(i) + ' in player ' + IntToStr(CurrentPlayer) + '''s tile path because it was not found on the minimap');
- Logout;
- Players[CurrentPlayer].Active := False;
- UF_Players[CurrentPlayer].Active := False;
- Exit;
- end;
- end;
- Result := True; //If it gets to this point, then it never exit'd because none of the checks returned false
- end;
- function AttackMonster: Boolean;
- var
- NPCs: TNPCArray;
- Target: TNPC;
- i, j: Integer;
- Pt: TPoint;
- begin
- if not(LoggedIn) then
- Exit;
- Target := NULL_NPC;
- NPCs := SortNPCs(GetNPCsBy(UF_Players[CurrentPlayer].Monster));
- if (Length(NPCs) < 1) then
- Exit;
- for i := 0 to High(NPCs) do
- if (NPCs[i].Name = UF_Players[CurrentPlayer].Monster) then
- begin
- if (UF_Players[CurrentPlayer].MultiCombat = False) then
- begin
- if (NPCs[i].Fighting = False) then
- for j := 0 to High(NPCs[i].Actions) do
- begin
- if (NPCs[i].Actions[j] = 'Attack') then
- begin
- Target := NPCs[i];
- Break;
- end;
- end;
- end else
- begin
- for j := 0 to High(NPCs[i].Actions) do
- begin
- if (NPCs[i].Actions[j] = 'Attack') then
- begin
- Target := NPCs[i];
- Break;
- end;
- end;
- end;
- end;
- if (Target = NULL_NPC) then
- Exit;
- if not(TileOnMS(Target.Tile, 0)) then
- if not(WalkToTile(Target.Tile, 0, 0)) then
- Exit;
- Pt := TileToMS(Target.Tile, (RandomRange(1/3, 2/3) * Target.Height));
- MMouse(Pt.x - 4, Pt.y - 4, 8, 8);
- if R_WaitUptext(UF_Players[CurrentPlayer].Monster, Length(UF_Players[CurrentPlayer].Monster) * 600) then
- begin
- ClickMouse2(False);
- Result := R_WaitOption('tack', 2400);
- end else
- Exit;
- if Result then(FFlag(0));
- end;
- function Bank: Boolean;
- var
- FoodTexts: TStringArray;
- begin
- if not(LoggedIn) then
- Exit;
- R_FindRandoms;
- if not R_OpenBankBooth(UF_Players[CurrentPlayer].BankLocation) then
- Exit;
- FoodTexts := ['Meat', 'Shrimp', 'Crayfish', 'Chicken', 'Rabbit', 'Anchovies', 'Sardine',
- 'Karambwanji', 'Karambwan', 'Ugthanki kebab', 'Herring', 'Mackerel',
- 'Roasted bird meat', 'Thin snail', 'Trout', 'Spider', 'Roasted rabbit',
- 'Lean snail', 'Cod', 'Pike', 'Roasted beast meat', 'Giant crab meat',
- 'Fat snail', 'Salmon', 'Slimy eel', 'Tuna', 'Roasted chompy', 'Fishcake',
- 'Rainbow fish', 'Cave eel', 'Lobster', 'Jubbly', 'Bass', 'Swordfish',
- 'Oomlie wrap', 'Lava eel', 'Monkfish', 'Shark', 'Sea turtle', 'Cavefish',
- 'Manta ray', 'Rocktail']
- Result := WithdrawEx(1, 1, 28, FoodTexts);
- end;
- function Eat: Boolean;
- var
- i: Integer;
- begin
- if ((not(LoggedIn)) or (not(HPPercent < 70))) then
- Exit;
- R_FindRandoms;
- for i := 1 to 28 do
- if ExistsItem(i) then
- begin
- MouseItem(i, false);
- if WaitUptext('Eat', 1200) then
- begin
- ClickMouse2(True);
- Result := True;
- Break;
- end;
- end;
- end;
- procedure MainLoop;
- var
- a, T: Integer; //a for attempts; T for Time
- begin
- Smart_Server := sWorld;
- Smart_Members := sMems;
- Smart_Signed := sSigned;
- Smart_SuperDetail := sHD;
- SetupSRL;
- SetupReflectionEx(True);
- DeclarePlayers;
- repeat
- LogInPlayer;
- SetAngle(True);
- repeat
- if UF_Players[CurrentPlayer].AtBank then
- if WalkAndHandle(True) then
- UF_Players[CurrentPlayer].AtBank := False;
- repeat
- repeat
- AttackMonster;
- inc(a);
- until((a > 4) or srl_InFight);
- if ((a > 4) and not(srl_InFight)) then
- begin
- Writeln('we failed to attack a monster more than 4 times. Exiting.');
- UF_Players[CurrentPlayer].Active := False;
- Players[CurrentPlayer].Active := False;
- Logout;
- end;
- T := GetSystemTime + UF_Players[CurrentPlayer].MaxFightTime;
- repeat
- R_FindRandoms;
- Wait(600 + Random(60));
- Eat;
- until(not(srl_InFight) or (GetSystemTime > T));
- until(InvEmpty or not(LoggedIn));
- if WalkAndHandle(False) then
- UF_Players[CurrentPlayer].AtBank := True;
- if not(Bank) then
- begin
- Writeln('banking failed. logging out.');
- Logout;
- UF_Players[CurrentPlayer].Active := False;
- Players[CurrentPlayer].Active := False;
- end;
- until(not(LoggedIn));
- until(AllPlayersInactive);
- end;
- begin
- MainLoop;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement