CephaXz
2012-06-25 20:17:56
I know there's already some wilderness agi course scripts out there. But I wanted a better and faster version. And also learning some of the functions to improve my scripting skills. I basically done with everything that needs to be done in the course, except eating, deathwalk, banking and some others.
But I find this script is a big failure. I didn't notice how much SPS_GetMyPos is using the resources. I'm using the function to check on my position every second, until my position is at the desired position. And whenever the checking starts, my ram goes up mad.
I'm going to rework on it. Kinda disappointed honestly. Maybe using exp gain to check or some other functions. Please give any suggestions or critiques. Thank you.
Update 1:
Changed using XP gained and HPPercent and PercentMMBlack to check current location. Added lobster for food since I'm only using that. Will add more upon request later when released. Improved the procedures. And still, suggestions and critiques are welcomed.
But I find this script is a big failure. I didn't notice how much SPS_GetMyPos is using the resources. I'm using the function to check on my position every second, until my position is at the desired position. And whenever the checking starts, my ram goes up mad.
I'm going to rework on it. Kinda disappointed honestly. Maybe using exp gain to check or some other functions. Please give any suggestions or critiques. Thank you.
Previous version removed
Update 1:
Changed using XP gained and HPPercent and PercentMMBlack to check current location. Added lobster for food since I'm only using that. Will add more upon request later when released. Improved the procedures. And still, suggestions and critiques are welcomed.
program WildyAgi;
{$i srl/srl/misc/smart.simba}
{$i srl/srl.simba}
{$i sps/sps.simba}
{$i srl/srl/misc/paintsmart.simba}
const
UserName = 'CephaXz';
Password = 'QWERTY';
Pin = '1234';
HPLEVEL = 99;
Food = 'lobster';
var
Sst, x, y, CurrentXP, CurrentHP, Trips, StartXP, FoodDTM: Integer;
procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
Players[0].Name := UserName;
Players[0].Pass := Password;
Players[0].Active := True;
Players[0].Member := True;
Players[0].Level[SKILL_HITPOINTS] := HPLEVEL;
Players[0].Pin := Pin;
Players[0].BoxRewards := ['Xp', 'mote', 'ostume', 'oins', 'aphire', 'ssence'];
end;// declare players
procedure SetupSRL2;
var
t: Integer;
begin
{$IFNDEF SMART}
{$IFDEF SIMBA}
if (not IsTargetValid) then
srl_Warn('SetUpSRL', 'Target client is not valid! ' +
'Drag the crosshairs over the target client.', warn_Terminate);
{$ENDIF}
{$ENDIF}
SetupBoxes; //Sets up box variables in globals.simba
t := GetTimeRunning;
MouseSpeed := 15;
{$IFDEF UseLaptopMouse}LMouse_MissChance := 75;{$ENDIF}
CheckHPFirst := True;
Reincarnate := False;
TalkAfterRandoms := False;
RoadColor := 0;
WaterColor := 0;
BankColor := 0;
// these need to be removed eventually (no longer used)
SRL_OnFindRandomCall := nil;
LampSkill := 'mining';
//SetUpSRLReport;
LoadCosineArrays;
SymbolAccuracy:= 0.8;
LoadSRLBitMaps;
LoadSRLFonts;
{$IFNDEF SRL_RANDOMS_TEST}
_SetRandoms();
{$ENDIF}
SetupSRLAutoResponder;
SRL_RandomScreenShot := False;
UseFindMod := True;
LogoutOnMod := True;
UseFindTrade := True;
UseAutoResponder := True;
GraphicsSet := False;
AllowPVP := False;
SRL_DisableIPLog := false;
SRL_SavePath := includePath + 'SRL/logs/';
SRL_StartTime := theDate(DATE_MONTH)+' at '+theTime;
WarnSensitivity := -2;
SetupAutoColors;
{$IFDEF LoadExtraFonts}
srl_UpdateFonts(srl_FontsUp2date);
{$ENDIF}
AddOnTerminate('FreeSRL');
SetSupressExceptions(true);
Writeln ('SRL Compiled in '+ IntToStr(GetTimeRunning - t) + ' msec');
{$IFDEF SRL_SMART}
if (Smart_Server = 0) then
begin
Smart_Server := 10;
Smart_Members := True;
Smart_Signed := True;
Smart_SuperDetail := False;
end;
Writeln('SMART Initialized.' + #10 + 'Loaded: Server ' + IntToStr(Smart_Server) + ', Members: ' + BoolToStr(Smart_Members)
+ ', Signed: ' + BoolToStr(Smart_Signed) + ', Super Detail: ' + BoolToStr(Smart_SuperDetail) + '.');
SmartSetupEx(Smart_Server, Smart_Members, Smart_Signed, Smart_SuperDetail);
SetTargetArray(SmartImageArray, 765,503);
repeat
Wait(100);
SmartSetRefresh(100);
until(RSReady);
SmartSetRefresh(40);
{$ELSE}
Smart_Server := 0;
Smart_Members := false;
Smart_Signed := True;
Smart_SuperDetail := false;
{$ENDIF}
SetupGauss();
end;
procedure SetupLogin;
begin
ClearDebug;
Smart_Server := 10;
Smart_Members := True;
Smart_Signed := True;
Smart_SuperDetail := False;
SetupSRL2;
DeclarePlayers;
LoginPlayer;
repeat
wait(500);
until LoggedIn;
if LoggedIn then
begin
ClickNorth(SRL_ANGLE_HIGH);
ExitSquealOfFortune();
if not IsXPBarOpen then
GetXPBar(1);
end;
StartXP := GetXPBarTotal;
end;
Procedure LoadFoodDtm;
begin
case Food of
'lobster':
FoodDTM := DTMFromString('mrAAAAHic42BgYJjBxMAwAYinAvE8KJ4LxNOAeDIQazEyMKhDsQIQawCxKRBbA7EREC8LlmDg4+UFmsSEFfMz4AeMBDAMAAAcTgee');
end;
end;
Procedure FreeAllDTM;
begin
FreeDTM(FoodDTM);
end;
Procedure EatFood;
begin
if HPPercent < RandomRange(40, 50) then
begin
writeln('Eating');
if FindDTM(FoodDTM, x, y, MIX1, MIY1, MIX2, MIY2) then
begin
Mouse(x, y, 3, 3, mouse_Left);
wait(RandomRange(1500, 2000));
end else
begin
writeln('No more food');
TypeSendEx(':(((((((((((', true);
TerminateScript;
end;
end;
end;
function SPS_WalkPath2(Path: TPointArray): boolean;
var
I, H, T, D: integer;
P, MM: TPoint;
begin
H := High(Path);
T := GetSystemTime + 20000 + Random(5000);
while (not Result) and (GetSystemTime < T) do
begin
RunEnergy(20);
P := SPS_GetMyPos;
for I := H downto 0 do
begin
MM.X := MMCX + Path[I].X - P.X;
MM.Y := MMCY + Path[I].Y - P.Y;
D := Distance(MM.X, MM.Y, MMCX, MMCY);
if (D < 1) then
break
else
if (D < 70) then
begin
if (SPS_MultiMouse) then
MultiMouse(MM.X, MM.Y, 25, 3, false)
else
Mouse(MM.X, MM.Y, 5, 5, mouse_Left);
FFlag(40);
T := getSystemTime + 20000 + Random(1000);
Break;
end;
end;
Result := (I = H);
end;
end;
Function FindIt(x, y, rx, ry, Color, Tolerance: Integer; Hue, Sat: Extended; Uptext: String; SortFrom: TPoint; Size: Boolean): Boolean;
var
a, Tries: Integer;
TPA : TPointArray;
ATPA : T2DPointArray;
MP : TPoint;
tmpCTS : Integer;
begin
if(not(LoggedIn))then Exit;
FindNormalRandoms;
if not FindNormalRandoms then
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(Hue, Sat);
if not FindColorsTolerance(TPA, Color, MSX1, MSY1, MSX2, MSY2, Tolerance) then
begin
writeln('Cant find it');
repeat
wait(1000);
Inc(Tries);
until (FindColorsTolerance(TPA, Color, MSX1, MSY1, MSX2, MSY2, Tolerance)) or (Tries = 3);
end;
If (Tries = 3) then
begin
writeln('Cant find after 3 times');
TerminateScript;
end;
SortTPAFrom(TPA, SortFrom);
ATPA := TPAtoATPAEx(TPA, 20, 20);
if Size = True then
SortATPASize(ATPA, true);
//SortATPAFromSize(ATPA, 10, true);
if length(ATPA) = 0 then
Exit;
for a := 0 to 1 do
begin
MP := MiddleTPA(ATPA[a]);
{$IFDEF SMART}
SMART_DrawCircle(true, MP, 20, false, clRed);
{$ENDIF}
x := MP.x;
y := MP.y;
MMouse(x, y, rx, ry);
if WaitUptext(Uptext, 500) then
begin
Result := True;
Break;
end;
end;
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
end;
Procedure WalktoLad;
var
myPath:TPointArray;
begin
FindNormalRandoms;
if not FindNormalRandoms then
writeln('Walking to ladder');
SPS_Setup(1, ['wilderness_dungeons']);
myPath := [Point(135, 228), Point(142, 217), Point(154, 210), Point(159, 201), Point(168, 186), Point(169, 171), Point(171, 149), Point(167, 145)];
SPS_WalkPath2(myPath);
repeat
wait(100);
until not FlagPresent;
wait(RandomRange(1000, 1300));
end;
Procedure ClickLadder;
var
Lad, MP: TPoint;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
FindMMColorsSpiralTolerance(TPA, 799581, 10);
ATPA := TPAtoATPAEx(TPA, 10, 10);
MP := MiddleTPA(ATPA[0]);
Lad := MMtoMS(Point(MP.x, MP.y));
Mouse(Lad.x, Lad.y, 2, 2, mouse_Right);
if WaitOption('lim', 2000) then
begin
writeln('Climbing');
end else
begin
writeln('Cant find ladder');
if FindIt(x, y, 3, 3, 3292481, 9, 1.13, 1.08, 'lim', Point(MSCX, MSCY), True) then
begin
ClickMouse2(mouse_Right);
if WaitOption('lim', 2000) then
begin
writeln('Failsafe climb ladder');
end else
begin
writeln('Dafuq ladder');
TerminateScript;
end;
end;
end;
end;
procedure WalkToWeb;
var
myPath:TPointArray;
begin
FindNormalRandoms;
if not FindNormalRandoms then
writeln('Walking to Web');
SPS_Setup(RUNESCAPE_SURFACE, ['11_2','10_2','11_1','12_2']);
myPath := [Point(4457, 935), Point(4454, 917), Point(4457, 904), Point(4461, 892), Point(4463, 879), Point(4469, 863), Point(4470, 847), Point(4470, 835), Point(4469, 826)];
SPS_WalkPath2(myPath);
repeat
wait(300);
until not IsMoving;
end;
function FindTPointCluster(Colors: TIntegerArray; Tol: Integer; SortFrom: TPoint; Filter, Trim, MaxDist: Integer; x1, y1, x2, y2: Integer): TPointArray;
var
TPA: TPointArray;
aPoints: array of TPointArray;
hPoints, hColors: Integer;
cError, Len, Match: Integer;
t, r, i, ii: Integer;
begin
MarkTime(t);
SetLength(aPoints, Length(Colors));
hColors := High(Colors);
cError := 0;
r := 0;
for i := 0 to hColors do
begin
if (FindColorsTolerance(TPA, Colors[i], x1, y1, x2, y2, Tol)) then
begin
SortTPAFrom(TPA, SortFrom);
if (Filter <> -1) then
FilterPointsDist(TPA, 0, Filter, SortFrom.x, SortFrom.y);
if (Trim <> -1) and (Length(TPA) > Trim) then
SetLength(TPA, Trim);
aPoints[i - cError] := TPA;
end else
begin
Len := Length(aPoints) - 1;
SetLength(aPoints, Len);
Inc(cError);
end;
if (cError >= 1{hColors}) then
begin
//Currently('ERROR: Not enough colors found!');
Exit;
end;
end;
hPoints := High(aPoints);
for i := 0 to High(aPoints[0]) do
begin
Match := 0;
for ii := 1 to hPoints do
begin
if NearbyPointInArray(aPoints[0][i], MaxDist, aPoints[ii]) then
begin
Inc(Match);
if (Match >= hPoints) then
begin
SetLength(Result, r + 1);
Result[r] := aPoints[0][i];
Inc(r);
end;
end else
Break;
end;
end;
SortTPAFrom(Result, SortFrom);
//Currently('Took: '+IntToStr(TimeFromMark(t))+' ms, found '+IntToStr(Length(Result))+' point(s)');
end;
Function MyPos(Position: TPoint): Boolean;
begin
SPS_Setup(RUNESCAPE_SURFACE, ['9_2','9_1']);
if SPS_GetMyPos = Position then
Result := True;
end;
Function InsideArea(Map: Integer; Area: TStringArray; x1, y1, x2, y2: Integer): Boolean;
var
P: TPoint;
Box: TBox;
begin
SPS_Setup(Map, Area);
P := SPS_GetMyPos;
Box := IntToBox(x1, y1, x2, y2);
if PointInBox(P, Box) then
begin
Result := True;
end;
end;
Procedure WalkClimb;
var
i: Integer;
MP: TPoint;
TheThing: TPointArray;
ATPA: T2DPointArray;
begin
CurrentXP := GetXPBarTotal;
TheThing := FindTPointCluster([2302756,1918041,5723991,10789533,3289396], 10, Point(629, 118), 90, 50, 70, MMX1, MMY1, MMX2, MMY2);
ATPA := TPAtoATPAEx(TheThing, 20, 20);
for i := 0 to high(ATPA) do
begin
MP := MiddleTPA(ATPA[i]);
SMART_DrawCircle(true, MP, 15, false, clRed);
Mouse(MP.x, MP.y, 3, 3, mouse_Left);
while not IsMoving do wait(10);
repeat
wait(10);
until not FlagPresent;
wait(RandomRange(800, 1000));
Break;
end;
end;
Procedure ClimbIt;
var
i, t: Integer;
MP, ThePoint: TPoint;
TheThing: TPointArray;
ATPA: T2DPointArray;
begin
CurrentXP := GetXPBarTotal;
TheThing := FindTPointCluster([2302756,1918041,5723991,10789533,3289396], 10, Point(MMCX, MMCY+20), 90, 50, 70, MMX1, MMY1, MMX2, MMY2);
ATPA := TPAtoATPAEx(TheThing, 20, 20);
for i := 0 to high(ATPA) do
begin
MP := MiddleTPA(ATPA[i]);
SMART_DrawCircle(true, MP, 15, false, clRed);
ThePoint := MMtoMS(MP);
Mouse(ThePoint.x, ThePoint.y, 3, 3, mouse_Right);
if WaitOption('lim', 2000) then
begin
writeln('Climbing');
MarkTime(t);
repeat
wait(10);
if TimeFromMark(t) > 10000 then
ClimbIt;
until GetXPBarTotal > CurrentXP;
Break;
end else
begin
writeln('Fail climbing');
TerminateScript;
end;
end;
end;
Procedure WalkInsideCourse(Path: TPointArray);
var
myPath:TPointArray;
begin
SPS_Setup(RUNESCAPE_SURFACE, ['9_2','9_1']);
myPath := Path;
SPS_WalkPath2(myPath);
repeat
wait(10);
until not FlagPresent;
wait(RandomRange(1000, 1300));
end;
procedure getmyposition;
var
P: TPoint;
begin
SPS_Setup(RUNESCAPE_SURFACE, ['9_2','9_1']);
P := SPS_GetMyPos;
writeln('Point'+ToStr(P));
end;
Procedure WalkToLog;
var
MP: TPoint;
TheThing: TPointArray;
ATPA: T2DPointArray;
begin
TheThing := FindTPointCluster([1721945,1258561,1026,1580059], 15, Point(647, 147), -1, -1, 10, MMX1, MMY1, MMX2, MMY2);
ATPA := TPAtoATPAEx(TheThing, 3,3);
writeln('Walking to log');
Writeln('Length: ' + intToStr(length(ATPA)));
MP := MiddleTPA(ATPA[0]);
SMART_DrawCircle(true, MP, 15, false, clRed);
Mouse(MP.x, MP.y, 5, 5, mouse_Left);
repeat
wait(10);
until not FlagPresent;
while IsMoving do wait(10);
//Point(3843, 839) Point(3847, 847)
end;
Function WalkOnLog: Boolean;
var
MP, ThePoint: TPoint;
TheThing: TPointArray;
ATPA: T2DPointArray;
begin
EatFood;
CurrentXP := GetXPBarTotal;
TheThing := FindTPointCluster([1721945,1258561,1026,1580059], 15, Point(MMCX, MMCY), -1, -1, 10, MMX1, MMY1, MMX2, MMY2);
ATPA := TPAtoATPAEx(TheThing, 3,3);
writeln('Loging');
Writeln('Length: ' + intToStr(length(ATPA)));
MP := MiddleTPA(ATPA[0]);
SMART_DrawCircle(true, MP, 15, false, clRed);
ThePoint := MMtoMS(MP);
Mouse(ThePoint.x+30, ThePoint.y+10, 3, 3, mouse_Right);
if WaitOption('ross', 2000) then
begin
repeat
wait(100);
until (GetXPBarTotal > CurrentXP) or (PercentBlackMM > 40);
if PercentBlackMM > 40 then
begin
WalktoLad;
ClickLadder;
WalkInsideCourse([Point(3850, 781), Point(3843, 773), Point(3828, 770), Point(3817, 774), Point(3817, 788), Point(3826, 800), Point(3831, 809), Point(3837, 820), Point(3844, 833), Point(3843, 844)]);
while IsMoving do wait(100);
WalkOnLog;
end;
Result := True;
end;
end;
Procedure Pipe;
var
x, y: Integer;
begin
EatFood;
CurrentXP := GetXPBarTotal;
repeat
FindIt(x, y, 5, 5, 6710369, 14, 1.00, 1.04, 'eeze', Point(MSCX, MSCY), true);
until WaitUptext('eeze', 500);
if WaitUptext('eeze', 500) then
begin
writeln('Clicking pipe');
ClickMouse2(mouse_Left);
end else
begin
writeln('Cant find pipe');
TerminateScript;
end;
repeat
wait(100);
//Point(3851, 823) Point(3863, 827)
until GetXPBarTotal > CurrentXP;
wait(RandomRange(300, 500));
end;
Procedure Swing;
var
t: Integer;
begin
EatFood;
CurrentXP := GetXPBarTotal;
//repeat
// FindIt(x, y, 0, 3, 729382, 4, 1.11, 1.73, 'wing', Point(MSCX, MSCY), True);
//until FindIt(x, y, 0, 3, 729382, 4, 1.11, 1.73, 'wing', Point(MSCX, MSCY), True);
repeat
FindIt(x, y, 0, 3, 729382, 4, 1.11, 1.73, 'wing', Point(MSCX, MSCY), True);
wait(100);
until FindIt(x, y, 0, 3, 729382, 4, 1.11, 1.73, 'wing', Point(MSCX, MSCY), True);
writeln('Swinging');
ClickMouse2(mouse_Right);
if WaitOption('wing', 2000) then
writeln('Found swing')
else
Swing;
MarkTime(t);
repeat
wait(100);
//Point(3851, 823) Point(3859, 827)
until (GetXPBarTotal > CurrentXP) or (PercentBlackMM > 40) or (TimeFromMark(t) > 10000);
if GetXPBarTotal > CurrentXP then
wait(RandomRange(1000, 1500));
if TimeFromMark(t) > 10000 then
begin
Swing;
end;
if PercentBlackMM > 40 then
begin
WalktoLad;
ClickLadder;
WalkInsideCourse([Point(3853, 783), Point(3857, 788), Point(3864, 798), Point(3866, 808), Point(3858, 817)]);
while IsMoving do wait(100);
Swing;
end;
end;
Procedure LavaFailsafe;
begin
EatFood;
CurrentXP := GetXPBarTotal;
CurrentHP := HPPercent;
wait(RandomRange(1000, 1500));
repeat
FindIt(x, y, 5, 5, 2567773, 5, 1.23, 2.54, 'ross', Point(222, 300), False);
wait(100);
until FindIt(x, y, 5, 5, 2567773, 5, 1.23, 2.54, 'ross', Point(222, 300), False);
ClickMouse2(mouse_Right);
if WaitOption('ross', 2000) then
begin
writeln('Lavaing');
wait(RandomRange(3000, 4000));
end else
begin
writeln('Cant find lava');
TerminateScript;
end;
repeat
wait(100);
//Point(3843, 771) Point(3851, 779)
until (GetXPBarTotal > CurrentXP) or (HPPercent < CurrentHP);
if HPPercent < CurrentHP then
LavaFailsafe;
end;
Procedure Lava;
begin
EatFood;
CurrentXP := GetXPBarTotal;
CurrentHP := HPPercent;
{if InsideArea(0, ['9_1','9_2'], 3843, 771, 3851, 779) then
FindIt(x, y, 5, 5, 2567773, 5, 1.23, 2.54, 'ross', Point(222, 300), False)
else }
repeat
FindIt(x, y, 5, 5, 2567773, 5, 1.23, 2.54, 'ross', Point(124, 120), False);
wait(100);
until FindIt(x, y, 5, 5, 2567773, 5, 1.23, 2.54, 'ross', Point(124, 120), False);
ClickMouse2(mouse_Right);
if WaitOption('ross', 2000) then
begin
writeln('Lavaing');
wait(RandomRange(3000, 4000));
end else
begin
writeln('Cant find lava');
TerminateScript;
end;
repeat
wait(100);
//Point(3843, 771) Point(3851, 779)
until (GetXPBarTotal > CurrentXP) or (HPPercent < CurrentHP);
if (HPPercent < CurrentHP) then
LavaFailsafe;
end;
procedure Proggy;
var
Wet, Wst, Cst, Srt, Tih, Tim, Tis, Awt, Sec, XPTotal: Integer;
begin
Cst := GetSystemTime;
Srt := (cst - sst) / 1000;
Tih := srt / 3600;
tim := (srt / 60) - tih * 60;
Tis := srt - tim * 60 - tih * 3600;
Awt := wet - wst
Sec := GetTimeRunning div 1000;
XPTotal := GetXPBarTotal - StartXP;
Writeln('+++++++++++++++++++++++++++++++++++++++++++++++++++++++');
Writeln(' CephaXz Wildy Agi Course ');
Writeln('+++++++++++++++++++++++++++++++++++++++++++++++++++++++');
Writeln('Trips Done : ' + IntToStr(Trips));
Writeln('Trips / Hour : ' + IntToStr(Round(3600 * Trips / Sec)));
Writeln('Total XP : ' + IntToStr(XPTotal));
Writeln('XP / Hour : ' + IntToStr(Round(3600 * XPTotal / Sec)));
Writeln('Time Ran : ' + TimeRunning);
Writeln('-------------------------------------------------------');
end;
Procedure MainLoop;
begin
WalkInsideCourse([Point(3855, 883)]);
Pipe;
Swing;
Lava;
//WalkInsideCourse([Point(3843, 843)]) //Backup Lavatolog walk
WalkToLog;
WalkOnLog;
WalkClimb;
ClimbIt;
Trips := Trips + 1;
Proggy;
end;
Begin
SetupLogin;
LoadFoodDtm;
AddOnTerminate('FreeAllDTM');
//SPS_Debug:= true;
repeat
MainLoop;
until not LoggedIn;
End.