Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program ApeAtollCourse;
- {$DEFINE SMART}
- {$i SRL/SRL.scar}
- {$i SRL/SRL/misc/stats.simba}
- {$i Reflection/Reflection.simba}
- {==============================================================================]
- ADVANCED GNOME AGILITY
- by enoyhs
- 24th April 2011
- {==============================================================================}
- {==============================================================================]
- x Set up lines from 20 to 27.
- {==============================================================================}
- const
- USERNAME = '';
- PASSWORD = '';
- SRLStats_Username = '';
- SRLStats_Password = '';
- MINUTES_TO_RUN = 24 * 60;
- BREAK_EVERY = 45; // Break every x +/- Random(10) for ~5mins
- const
- VERSION = '0.4';
- OBSTACLE_COUNT = 7;
- LOG_BALANCE = 0;
- OBSTACLE_NET = 1;
- TREE_BRANCH = 2;
- TREE = 3;
- SIGNPOST = 4;
- POLE = 5;
- BARRIER = 6;
- OBSTACLE_TIMEOUT = 15;
- type
- TObstacle = record
- Name: string;
- ClickTile: TTile;
- Plane: Integer;
- Colors: TIntegerArray;
- CompassDir: Double;
- UpText: TStringArray;
- end;
- var
- Obstacles: Array [0..OBSTACLE_COUNT] of TObstacle;
- StartTile: TTile;
- StartXP, LastXP: Integer;
- FailTimer, NextBreak: Integer;
- FailCounter, CurrentObstacle: Integer;
- DTM: Integer;
- TotalBreaks: Integer;
- procedure InitScript;
- begin
- LampSkill := 'agility';
- with Obstacles[LOG_BALANCE] do
- begin
- Name := 'Log balance';
- ClickTile := Tile(2474, 3435);
- Plane := 0;
- Colors := [932711, 532794];
- CompassDir := 230;
- UpText := ['k-a'];
- end;
- with Obstacles[OBSTACLE_NET] do
- begin
- Name := 'Obstacle net';
- ClickTile := Tile(2472, 3423);
- Plane := 0;
- Colors := [465969, 400175, 2570310, 790806];
- CompassDir := 230;
- UpText := ['b-o'];
- end;
- with Obstacles[TREE_BRANCH] do
- begin
- Name := 'Tree branch';
- ClickTile := Tile(2473, 3422);
- Plane := 1;
- Colors := [1052945, 1654868, 2051687];
- CompassDir := 90;
- UpText := ['mb T', 'e b'];
- end;
- with Obstacles[TREE] do
- begin
- Name := 'Tree';
- ClickTile := Tile(2473, 3419);
- Plane := 2;
- Colors := [2184045, 1059383];
- CompassDir := 90;
- UpText := ['b-u'];
- end;
- with Obstacles[SIGNPOST] do
- begin
- Name := 'Signpost';
- ClickTile := Tile(2478, 3418);
- Plane := 3;
- Colors := [4290710, 4554655, 6137807];
- CompassDir := 90;
- UpText := ['n-a'];
- end;
- with Obstacles[POLE] do
- begin
- Name := 'Pole';
- ClickTile := Tile(2485, 3427);
- Plane := 3;
- Colors := [4475727, 4344141, 1052945];
- CompassDir := 0;
- UpText := ['g-t'];
- end;
- with Obstacles[BARRIER] do
- begin
- Name := 'Barrier';
- ClickTile := Tile(2486, 3434);
- Plane := 3;
- Colors := [11066877, 1521230];
- CompassDir := 0;
- UpText := ['p-o'];
- end;
- end;
- procedure AntiBan;
- begin
- case random(10000) of
- 0..5: HoverSkill('agility',false);
- 6..8: RandomRClick;
- 9..10: PickupMouse;
- 11..30: RandomMovement;
- end;
- end;
- procedure CheckRandoms;
- begin
- R_FindRandoms;
- FindNormalRandoms;
- end;
- function WaitToComplete(Obstacle: TObstacle): boolean;
- var
- MyPos: TTile;
- begin
- Result := False;
- FailTimer := GetSystemTime;
- Wait(RandomRange(1000, 1500));
- if (IsIdle) or ((GetMyPos = StartTile) and (not FlagPresent)) then
- begin
- if not (((CurrentObstacle = TREE_BRANCH) or (CurrentObstacle = TREE)) and (not IsIdle)) then
- begin
- WriteLn('Did not even try to do anything for a second.. Maybe just failed, or just a lag..');
- Exit;
- end;
- end;
- if (CurrentObstacle = LOG_BALANCE) and (not WaitToMove(RandomRange(500, 800))) then
- begin
- WriteLn('Did not even try to do anything for a second.. Maybe just failed, or just a lag..');
- Exit;
- end;
- MakeCompass(Obstacles[(CurrentObstacle + 1) mod OBSTACLE_COUNT].CompassDir + Random(100) * 0.1);
- repeat
- wait(RandomRange(50, 100));
- AntiBan;
- if (ClickToContinue) then
- begin
- Writeln('Oops! Clicked on NPC!');
- Exit;
- end;
- MyPos := GetMyPos;
- case Obstacle.Name of
- 'Log balance': Result := (MyPos = Tile(2474, 3429)) and (GetPlaneIndex = 0);
- 'Obstacle net': Result := (GetPlaneIndex = 1);
- 'Tree branch': Result := (GetPlaneIndex = 2);
- 'Tree': Result := (MeInBox(IntToBox(2472, 3420, 2477, 3418))) and (GetPlaneIndex = 3);
- 'Signpost': Result := (MyPos = Tile(2484, 3418)) and (GetPlaneIndex = 3) and (not CharacterAnimating);
- 'Pole': Result := (MeInBox(IntToBox(2482, 3435, 2488, 3432))) and (GetPlaneIndex = 3);
- 'Barrier': Result := (MyPos = Tile(2485, 3436)) and (GetPlaneIndex = 0) and (not CharacterAnimating);
- else Exit;
- end;
- until (Result) or (GetSystemTime > FailTimer + OBSTACLE_TIMEOUT * 1000);
- if ((GetSystemTime > FailTimer + OBSTACLE_TIMEOUT * 1000)) then
- writeln('Could not finish obstacle in ' + IntToStr(OBSTACLE_TIMEOUT) + ' seconds:' + Obstacle.Name);
- end;
- function FindNextObstacle: Integer;
- var MyPos: TTile;
- begin
- MyPos := GetMyPos;
- Result := LOG_BALANCE;
- if (MeInBox(IntToBox(2470, 3429, 2477, 3426))) and (GetPlaneIndex = 0) then
- Result := OBSTACLE_NET
- else if (MeInBox(IntToBox(2471, 3424, 2476, 3422))) and (GetPlaneIndex = 1) then
- Result := TREE_BRANCH
- else if (MeInBox(IntToBox(2472, 3421, 2477, 3418))) and (GetPlaneIndex = 2) then
- Result := TREE
- else if (MeInBox(IntToBox(2472, 3420, 2477, 3418))) and (GetPlaneIndex = 3) then
- Result := SIGNPOST
- else if (MeInBox(IntToBox(2484, 3421, 2487, 3418))) and (GetPlaneIndex = 3) then
- Result := POLE
- else if (MeInBox(IntToBox(2482, 3435, 2488, 3432))) and (GetPlaneIndex = 3) then
- Result := BARRIER
- end;
- function ClickObstacle(Obstacle: TObstacle): boolean;
- var
- MS: TPoint;
- TPA, tTPA: TPointArray;
- ATPA: T2DPointArray;
- ObstacleClicked, ColorFound: Boolean;
- i, j, adj, n: Integer;
- begin
- Result := False;
- if not LoggedIn then
- begin
- WriteLn('Not logged in!');
- Exit;
- end;
- ObstacleClicked := False;
- ColorFound := False;
- CheckRandoms;
- MakeCompass(Obstacle.CompassDir + Random(100) * 0.1);
- if (Obstacle.Name = 'Pole') and (GetMyPos <> Tile(2486, 3418)) then
- begin
- MS := TileToMS(Tile(2486, 3418), 0);
- Mouse(MS.X - 2, MS.Y - 2, 2, 2, True);
- end;
- if (not TileOnMS(Obstacle.ClickTile, 0)) then
- begin
- WalkToTile(Obstacle.ClickTile, 1, 1);
- WaitToMove(300 + Random(50));
- while CharacterMoving do
- Wait(100);
- end;
- StartTile := GetMyPos;
- adj := 75;
- MS := TileToMS(Obstacle.ClickTile, 0);
- MMouse(MS.X, MS.Y, 0, 0);
- if TileOnMS(Obstacle.ClickTile, 0) then
- begin
- for i := 0 to High(Obstacle.Colors) do
- begin
- FindColorsSpiralTolerance(MS.X, MS.Y, tTPA, Obstacle.Colors[i],
- Max(0, MS.X - adj), Max(0, MS.Y - adj), Min(MS.X + adj, MSX2), Min(MS.Y + adj, MSY2), 2);
- TPA := CombineTPA(TPA, tTPA);
- end;
- ATPA := SplitTPA(TPA, Max(5 - (FailCounter div 3), 0));
- if (Length(ATPA) > 0) then
- begin
- SortATPAFrom(ATPA, Point(MS.X, MS.Y));
- n := High(ATPA);
- for j := 0 to n do begin
- if (CurrentObstacle <> FindNextObstacle) then
- begin
- WriteLn('Already finished: ' + Obstacle.Name);
- Exit;
- end;
- MS := MiddleTPA(ATPA[j]);
- MMouse(MS.X, MS.Y, Random(3), Random(3));
- if r_WaitUpTextMulti(Obstacle.UpText, 100 + random(50)) then
- begin
- GetMousePos(MS.X, MS.Y);
- Mouse(MS.X, MS.Y, 0, 0, True);
- ObstacleClicked := DidRedClick;
- Break;
- end;
- end;
- end else
- begin
- Writeln('Color not found: ' + Obstacle.Name);
- Exit;
- end;
- end else
- begin
- WriteLn('Not visible: ' + Obstacle.Name);
- Exit;
- end;
- if not ObstacleClicked then
- begin
- Writeln('Uptext not found: ' + Obstacle.Name);
- Exit;
- end;
- Result := WaitToComplete(Obstacle);
- end;
- function SolveObstacle: boolean;
- begin
- Result := False;
- if not LoggedIn then
- begin
- WriteLn('Not logged in!');
- Exit;
- end;
- CheckRandoms;
- WriteLn('Next obstacle: ' + Obstacles[CurrentObstacle].Name);
- Result := ClickObstacle(Obstacles[CurrentObstacle]);
- if Result = True then
- begin
- FailCounter := 0;
- CurrentObstacle := (CurrentObstacle + 1) mod OBSTACLE_COUNT;
- end else
- begin
- FailCounter := FailCounter + 1;
- CurrentObstacle := FindNextObstacle;
- end;
- end;
- procedure ProgressReport;
- var
- Me: TMe;
- begin
- ClearDebug;
- Me := GetMe;
- WriteLn('=== ADVANCED GNOME AGILITY COURSE ' + VERSION + ' ~ By enoyhs =======');
- WriteLn(' Experience gained: ' + GroupDigits(Me.Experience[SKILL_AGILITY] - StartXP, ','));
- WriteLn(' XP/H : ' + GroupDigits(
- Round((Me.Experience[SKILL_AGILITY] - StartXP) / (GetTimeRunning/3600000.0)), ',') );
- WriteLn(' Time running : ' + TimeRunning);
- WriteLn('====================================');
- WriteLn('');
- stats_Commit;
- end;
- // Credits to HobboBobbo for this procedure, thanks!
- procedure PrintOnSmart(TP: TStringArray; Placement: TPoint; Colour, Shadow: integer);
- var
- mx, my, Pic, I, B, H, TPH, Numb: Integer;
- TTP: TPointArray;
- Canvas: TCanvas;
- begin
- SmartSetDebug(True);
- GetClientDimensions(mx,my);
- Pic := BitmapFromString(mx,my,'');
- TPH := High(TP);
- for I := 0 to TPH do
- begin
- TTP := LoadTextTPA(TP[i], UpChars, H);
- for B := 0 to High(TTP) do
- begin
- try
- Numb := ((I + 1) * 13);
- FastSetPixel(Pic, TTP[b].x + 1, TTP[b].y + Numb + 1, Shadow);
- FastSetPixel(Pic, TTP[b].x, TTP[b].y + Numb, Colour);
- except
- end;
- end;
- end;
- Canvas := TCANVAS.Create;
- Canvas.Handle := SmartGetDebugDC;
- DrawBitmap(Pic, Canvas, Placement.x, Placement.y);
- FreeBitmap(Pic);
- end;
- procedure PaintReport;
- var Exp: integer;
- Me: TMe;
- begin
- Me := GetMe;
- Exp := Me.Experience[SKILL_AGILITY] - StartXP;
- PrintOnSmart(['Advanced Gnomes ' + VERSION + ' ~ By enoyhs'],Point(20, 25), 16777215, 8388736);
- PrintOnSmart(['Running for: ' + TimeRunning,
- 'Next break in: ' + MsToTime(NextBreak - GetTimeRunning, Time_Formal),
- 'Experience: ' + GroupDigits(Exp, ','),
- 'Exp/hour: ' + GroupDigits(Round(Exp / (GetTimeRunning / 3600000.0)), ',')
- ], Point(20,55), 16777215, 8388736);
- end;
- procedure DoBreak;
- var Timer: Integer;
- begin
- Logout;
- Timer := GetSystemTime + 6000 + Random(4 * 60 * 1000);
- while (GetSystemTime < Timer) do
- begin
- writeln('Time left till we continue: ' + MsToTime(Timer - GetSystemTime, Time_Short));
- Wait(10000);
- if (LoggedIn) then
- Break;
- end;
- LogInPlayer;
- R_FindRandoms;
- Wait(RandomRange(3000,4000)); //Give time to load before continuing script
- Inc(TotalBreaks);
- end;
- procedure EndScript;
- begin
- stats_SetVariable('Agility EXP (Gained)', R_GetSkillExperience(SKILL_AGILITY) - StartXP);
- ProgressReport;
- LogOut;
- end;
- begin
- AddOnTerminate('EndScript');
- Smart_Signed := true;
- Smart_Members := true;
- Smart_Server := 96;
- SetupSRL;
- NumberOfPlayers(1);
- CurrentPlayer := 0;
- Players[0].Name := USERNAME;
- Players[0].Pass := PASSWORD;
- Players[0].Active:= True;
- if (SRLStats_Username = '') and (SRLStats_Password = '') then
- SetupSRLStats(45, 'enoyhsDefault', 'enoyhs')
- else
- SetupSRLStats(45, SRLStats_Username, SRLStats_Password);
- LogInPlayer;
- ClearDebug;
- InitScript;
- SetAngle(False);
- StartXP := R_GetSkillExperience(SKILL_AGILITY);
- LastXP := StartXP;
- CurrentObstacle := FindNextObstacle;
- NextBreak := GetTimeRunning + (BREAK_EVERY * 60 * 1000) + (Random(10) * 60 * 1000) + Random(60 * 1000);
- while GetTimeRunning < MINUTES_TO_RUN * 60 * 1000 do begin
- if (CurrentObstacle = LOG_BALANCE) then PaintReport;
- CheckRandoms;
- if (GetTimeRunning > NextBreak) or (not LoggedIn) or (LobbyScreen) then
- begin
- DoBreak;
- Wait(1000);
- NextBreak := GetTimeRunning + (BREAK_EVERY * 60 * 1000) + (Random(10) * 60 * 1000) + Random(60 * 1000);
- end;
- if (FailCounter > 20) then
- TerminateScript;
- if (FailCounter > 0) and (FailCounter mod 5 = 0) then
- begin
- WalkToTile(GetMyPos, 3, 0);
- SetAngle(False);
- end;
- if (SolveObstacle) then
- ProgressReport;
- Wait(100 + Random(100));
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement