enoyhs
2011-04-07 03:26:17
How Long have You Played Runescape?
8 Year(s)
Are you affilated in anyway with Jagex LTD?
No
Were you Referred to SRL?
What is your general programming knowledge?
I'm not sure I can remember all of them..
I'm fluent in C, C++, PHP, HTML, JavaScript, CSS.
I'm sort of good in PASCAL, ASP.NET, BASH.
I've tried my hand in countless other languages, like, python, java, actionscript, ruby and many more..
Are you a member of any other communities?
Not that I know of..
Tell us about yourself…
Please show us one (or multiple) of your scripts.
EDIT:
Just for the show, I have added full color version of this script (without breaks and player switching, though :(. But that is included in original version and this is just for show..).
8 Year(s)
Are you affilated in anyway with Jagex LTD?
No
Were you Referred to SRL?
What is your general programming knowledge?
I'm not sure I can remember all of them..
I'm fluent in C, C++, PHP, HTML, JavaScript, CSS.
I'm sort of good in PASCAL, ASP.NET, BASH.
I've tried my hand in countless other languages, like, python, java, actionscript, ruby and many more..
Are you a member of any other communities?
Not that I know of..
Tell us about yourself…
From: enoyhs
I've been programming since I was 15 (For six years now). I have done more things than I can remember and tried to learn more languages than I can count.
Most of what I've learnt, if not all, is self taught through various sources, I never really had a real human teacher.
I've been participating in various programming contests on-line and on-site, as well as teaching new students about algorithmic programming, so I would like to believe I have some knowledge..
I don't remember how I found SCAR and SRL, but I've been doing a lot of stuff with SCAR (now SIMBA) and SRL and many things not even related to RS.
I love to write scripts not because they can bring in GP or stuff, but because they are nice challenge and I love to think how to do things differently.
I've noticed that when I play games I think of how they are made and how could I cheat in them by writing some sort of script or something..
Please show us one (or multiple) of your scripts.
program OakChopNBank;
{$DEFINE SMART}
{$i SRL/SRL.scar}
{$i Reflection/Reflection.simba}
{$i SRL/SRL/misc/reports.scar}
{
Hello! This my SRL Members application script.
So what this script does is chop oaks at draynor near jail and banks them using deposit box.
It also picks up other people dropped logs and bird's nests, if you want to.
I used reflection with some touches of color.
There is also death walk included (color walking from lumby), but I realised I could use r_WebWalk to almost same effect.
I left DeathWalk in anyways just so you can have a look at how I would do it.
}
const
BREAK_EVERY = 45; // Break every x +/- 10 minutes
BREAK_FOR = 5; // Break for x +/- 5 minutes
const
VERSION = '0.0';
var
OakTiles: TTileArray;
DepositBox: TTile;
TPA: TPointArray;
ATPA: T2DPointArray;
MS, P: TPoint;
LastReport: Integer;
procedure InitScript;
begin
NumberOfPlayers(1);
with Players[0] do
begin
Name := '';
Pass := '';
Nick := ''
Booleans[0] := True; // Should we pick up dropped logs and bird nests?
Booleans[1] := True; // Is hatchet equiped?
Strings := ['logs', 'ird']; // Array of strings for items we should pick up
Active := True;
end;
OakTiles := [Tile(3117, 3252), Tile(3120, 3258),
Tile(3125, 3256)];
DepositBox := Tile(3094, 3240);
end;
{
By: Iamadam
From: [url]http://villavu.com/forum/showthread.php?t=63505[/url]
}
function walkPathEx(path: TTileArray; acceptableDistance, tileRandomness, waitTime: Integer) : boolean;
var index, lastClick, lastClickTime: Integer;
clickPoint : TPoint;
clickTile : TTile;
begin
if(not loggedIn) then
begin
result:= false;
exit;
end;
lastClickTime := getSystemTime;
while (distanceFrom(path[high(path)]) > acceptableDistance) do
begin
for index := high(path) downto 0 do
begin
if(tileOnMM(path[index])) then
break;
end;
//click the point
if(lastClick <> index) then //make sure we havn't already clicked there...
begin
if (index < 0) or ((index = 0) and (not tileOnMM(path[0]))) then //none of the tiles are on the minimap, return false
begin
result := false;
exit;
end;
lastClick := index;
clickTile := randomizeTile(path[index], tileRandomness, tileRandomness);
while (not tileOnMM(clickTile)) do
clickTile := randomizeTile(path[index], tileRandomness, tileRandomness); //Make sure the random tile is on the mmap.
clickPoint := tileToMM(clickTile);
Mouse(clickPoint.x, clickPoint.y, 1, 1, true);
lastClickTime := GetSystemTime;
wait(waitTime + random(500) + random(random(500)));
end else
begin
if(GetSystemTime - lastClickTime > 1000 * 20) then //its been 20 seconds since the last click... walking has failed.
begin
writeln('Please check your path. The tile at index ' + toStr(index) + ' is too far from the next tile');
result := false;
exit;
end
else
wait(random(500) + random(random(500))); //so, we already clicked the best tile, now we wait a little bit.
end;
end;
if(not loggedIn) then
result := false
else
result := true;
end;
function e_Walk(Tiles: TTileArray): boolean;
begin
Result := walkPathEx(Tiles, 5, 1, 1000);
end;
function SortByDistance(var Tiles: TTileArray): Boolean;
var i, n: Integer;
swapped: Boolean;
begin
n := High(Tiles);
repeat
swapped := False;
for i := 1 to n do
begin
if (DistanceFrom(Tiles[i - 1]) > DistanceFrom(Tiles[i])) then
begin
swap(Tiles[i - 1], Tiles[i]);
swapped := True;
end;
end;
Result := Result or swapped;
until (not swapped);
end;
function PickUpItems(Names: TStringArray): Boolean;
var items: TGroundItemArray;
i: Integer;
f: Boolean;
begin
items := GetItemsNear(2);
if (Length(items) = 0) then
Exit;
writeln('Oh my! There are items lying around, we better pick them up!');
P := TileToMS(items[0].Tile, 0);
Mouse(P.x, P.y, 2, 2, False);
Result := R_WaitOptionMulti(Names, 200);
if (not Result) then
Exit;
R_Flag;
Wait(RandomRange(100, 300));
P := TileToMS(GetMyPos, 0);
repeat
f := False;
Wait(RandomRange(100, 200));
MMouse(P.x, P.y, 1, 1);
if (r_WaitUpTextMulti(Names, 200)) then
begin
Mouse(P.x, P.y, 1, 1, True);
f := True;
end else
begin
Mouse(P.x, P.y, 1, 1, False);
f := r_WaitOptionMulti(Names, 200);
end;
until (f = False) or (InvFull);
end;
function NextOak: Integer;
var
i: Integer;
begin
Result := -1;
SortByDistance(OakTiles);
Wait(RandomRange(100, 200));
for i := 0 to High(OakTiles) do begin
if (not TileOnMS(OakTiles[i], 0)) then
Continue;
MS := TileToMS(OakTiles[i], 0);
MMouse(MS.X, MS.Y, 5, 5);
if WaitUpTextMulti(['Oak'], 200) then begin
Result := i;
Exit;
end;
end;
end;
{
Color method of finding Oaks. Not used currently, but here for color sake and to satisfy anyone who is looking for more color in this script.
}
function FindOak: TPoint;
var i, j: Integer;
begin
Result := Point(-1, -1); // No tree
FindColorsSpiralTolerance(MSCX, MSCY, TPA, 2445895, MSX1, MSY1, MSX2, MSY2, 5);
ATPA := TPAtoATPA(TPA, 100);
for i := 0 to High(ATPA) do
begin
P := MiddleTPA(ATPA[i]);
MMouse(P.x, P.y, 5, 5);
if (WaitUptext('oak', RandomRange(800, 1000))) then
begin
GetMousePos(Result.x, Result.y);
Exit;
end;
end;
end;
function ChopOak: Boolean;
var
CurrentOak: Integer;
begin
Result := False;
if (CharacterAnimating) or (FlagPresent) or (CharacterMoving) then begin
case Random(10000) of
0..10: WriteLn('I love choppin here and choppin there!');
11..20: HoverSkill('woodcutting', False);
21..30: RandomRClick;
31..40: BoredHuman;
41..50: RandomMovement;
end;
Wait(RandomRange(100, 200));
Exit;
end;
if (PickUpItems(Players[CurrentPlayer].Strings)) then
Exit;
CurrentOak := NextOak;
if (CurrentOak = -1) then begin
WriteLn('Save the Oaks! Save the Oaks! [No oaks visible]');
ClickNorth(True);
e_Walk([Tile(3120, 3255)]);
Wait(RandomRange(500, 1000));
Exit;
end;
MS := TileToMS(OakTiles[CurrentOak], 0);
if (Random(100) > 30) then
Mouse(MS.x, MS.y, 3, 3, True)
else
begin
Mouse(MS.x, MS.y, 3, 3, False);
WaitOptionMulti(['wn O'], 1000);
R_ChooseOptionMulti(['wn O']);
end;
Result := DidRedClick;
end;
function BankOaks: Boolean;
var T: Integer;
begin
// Opening Deposit Box
if (not TileOnMS(DepositBox, 0)) then
e_Walk([DepositBox]);
MS := TileToMS(DepositBox, 10);
if FindObjEx(MS.x, MS.y, ['osit'], [739167], 10, 50, MS.x - 50, MS.y - 50, MS.x + 50, MS.y + 50) then
begin
GetMousePos(MS.x, MS.y);
Mouse(MS.x, MS.y, 0, 0, True);
if (not WaitFunc(@DepositScreen, 100, 5000)) then
begin
Writeln('Could not open the deposit box');
Exit;
end;
end else
begin
Writeln('Could not find the deposit box');
Exit;
end;
// Banking Oaks
if (Players[CurrentPlayer].Booleans[1]) then
begin
DepositAll;
T := 0;
repeat
Inc(T);
Wait(100);
until (InvCount = 0) or (T >= 30);
Result := (T < 30);
end else
begin
Deposit(2, 28, True);
T := 0;
repeat
Inc(T);
Wait(100);
until (InvCount = 1) or (T >= 30);
Result := (T < 30);
end;
if (Result) then
begin
Inc(Players[CurrentPlayer].Banked);
Players[CurrentPlayer].Integers[3] := Players[CurrentPlayer].Integers[3] + 28 - InvCount;
end;
end;
function DoBreak: Boolean;
var next: Integer;
begin
if (AllPlayersInactive) then
TerminateScript;
if (not LoggedIn) or (LobbyScreen) or (GetSystemTime < Players[CurrentPlayer].Integers[1]) then
begin
Wait(RandomRange(1000, 2000));
// Finding next available player
next := (CurrentPlayer + 1) mod Length(Players);
while (next <> CurrentPlayer) do
begin
if (Players[next].Active = True) and (GetSystemTime > Players[next].Integers[1]) then
Break;
next := (next + 1) mod Length(Players);
end;
if (GetSystemTime < Players[next].Integers[1]) then
Exit;
CurrentPlayer := next;
// This character will break at Players[CurrentPlayer].Integers[0]
Players[CurrentPlayer].Integers[0] := GetSystemTime + Max(0, RandomRange(BREAK_EVERY * 60000 - 600000, BREAK_EVERY * 60000 + 600000));
LogInPlayer;
Wait(RandomRange(1000, 2000));
ClickNorth(True);
// Get's start XP and stores in Players[CurrentPlayer].Integers[2]
if (Players[CurrentPlayer].Integers[2] = 0) then
Players[CurrentPlayer].Integers[2] := R_GetSkillExperience(SKILL_WOODCUTTING);
end;
if (GetSystemTime > Players[CurrentPlayer].Integers[0]) and (LoggedIn) then
begin
// This character will be available at Players[CurrentPlayer].Integers[1]
Players[CurrentPlayer].Integers[1] := GetSystemTime + Max(0, RandomRange(BREAK_FOR * 60000 - 300000, BREAK_FOR * 60000 + 300000));
// Logging out current player
if (PlayersActive = 1) then
ExitToLobby
else
Logout;
end;
end;
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_WOODCUTTING] - Players[CurrentPlayer].Integers[2];
PrintOnSmart(['Oak Chop and Bank ' + VERSION + ' ~ By enoyhs'], Point(20, 25), 16777215, 8388736);
PrintOnSmart(['Running for: ' + TimeRunning,
'Next break in: ' + MsToTime(Players[CurrentPlayer].Integers[0] - GetSystemTime, Time_Formal),
'Oaks: ' + GroupDigits(Players[CurrentPlayer].Integers[3], ','),
'Experience: ' + GroupDigits(Exp, ',')
], Point(20,55), 16777215, 8388736);
end;
function DeathWalk: Boolean;
var T: Integer;
r: Boolean;
begin
MakeCompass('n');
// Walk out of Castle
RoadColor := 8226962;
RadialRoadWalk(RoadColor, 70, 90, 70, -1, -1);
repeat
r := RadialRoadWalk(RoadColor, 310, 390, 70, -1, -1);
Inc(T);
until (FindSymbolIn(P.x, P.y, 'quest', MMCX, MMCY, MMX2, MMY2)) or (T >= 30);
// Walk to Draynor crossroads
RoadColor := 8031122
T := 0;
repeat
r := RadialRoadWalk(RoadColor, 270, 360, 70, 0, 0);
Inc(T);
until (T >= 30);
// Walk to Draynor Bank
RoadColor := 7172469;
T := 0;
repeat
r := RadialRoadWalk(RoadColor, 180, 280, 70, 0, 0);
Inc(T);
until (FindSymbol(P.x, P.y, 'bank')) or (T >= 30);
end;
procedure ProgressReport;
begin
SRLPlayerReport(ResultDebugBox, SKILL_WOODCUTTING, False,
[True, True, False, True, False, False],
[],
[], [], [], []);
end;
var LostTries: Integer;
begin
Smart_Signed := True;
Smart_Members := False;
Smart_Server := 33;
SetupSRL;
InitScript;
// DeathWalk;
//WriteLn('Tile(' + IntToStr(GetMyPos.X) + ', ' + IntToStr(GetMyPos.Y) + ')');
AddOnTerminate('ProgressReport');
if (LoggedIn) then
Logout;
while (PlayersActive > 0) do
begin
if (LoggedIn) then
begin
if (not InvFull) and (not TileOnMS(Tile(3120, 3255), 0)) then
begin
if (e_Walk([Tile(3093, 3248), Tile(3104, 3250), Tile(3113, 3255), Tile(3120, 3255)])) then
begin
Players[CurrentPlayer].Loc := 'Walking to Oaks';
LostTries := 0;
end;
end;
if (not InvFull) and (TileOnMS(Tile(3120, 3255), 0)) then
begin
ChopOak;
Players[CurrentPlayer].Loc := 'Chopping Oaks';
LostTries := 0;
end;
if (InvFull) and (not TileOnMS(DepositBox, 0)) then
begin
if (e_Walk([Tile(3115, 3255), Tile(3110, 3255), Tile(3102, 3249), Tile(3093, 3249), Tile(3094, 3243)])) then
begin
Players[CurrentPlayer].Loc := 'Walking to Bank';
LostTries := 0;
end;
end;
if (InvFull) and (TileOnMS(DepositBox, 0)) then
begin
if (not BankOaks) then
WalkToTile(DepositBox, 1, 0);
Players[CurrentPlayer].Loc := 'Banking Oaks';
LostTries := 0;
end;
Inc(LostTries);
R_FindRandoms;
if (LostTries mod 5 = 0) then
begin
WriteLn('Where am I? I think I better close my eyes and walk..');
r_WebWalk(DepositBox);
end;
end;
if (GetSystemTime - LastReport > 10000) then
begin
PaintReport;
LastReport := GetSystemTime;
end;
DoBreak;
end;
end.EDIT:
Just for the show, I have added full color version of this script (without breaks and player switching, though :(. But that is included in original version and this is just for show..).
program OakChopNBank;
{$DEFINE SMART}
{$i SRL/SRL.scar}
{$i SRL/SRL/misc/reports.scar}
{$i SRL/SRL/skill/magic.scar}
var
TPA: TPointArray;
ATPA: T2DPointArray;
P: TPoint;
OakSpotDTM: Integer;
Fails: Integer;
procedure InitScript;
begin
// Oak chopping spot
OakSpotDTM := DTMFromString('mQwAAAHicY2ZgYKhkYmAoBOIqII4B8n2B2AWIM+z4GAyTRcGYC8iHYUYkDAQAyLAEgg==');
end;
procedure e_Debug(s: Variant);
begin
WriteLn(s);
end;
function WalkToOaks: Boolean;
var aFound: Extended;
T: Integer;
begin
Result := False;
MakeCompass('n');
// Walks out of the bank to the road
FindColorsPie(TPA, 7432822, 10, 45, 135, 10, 70, MMX1, MMY1, MMX2, MMY2, MMCX, MMCY);
if (Length(TPA) < 1) then
begin
e_Debug('[WalkToOaks] Could not find Road Color.');
Exit;
end;
P := TPA[0];
Mouse(P.x - 1, P.y - 1, 1, 1, True);
T := 0;
while (FlagDistance > 5) and (T < 30) do
begin
Inc(T);
Wait(RandomRange(150, 200));
end;
if (not FindSymbol(P.x, P.y, 'rest')) then
begin
e_Debug('[WalkToOaks] Could not find Musician.');
Exit;
end;
Mouse(P.x - 1, P.y - 1, 1, 1, True);
Flag;
// Walks to oak chopping spot
if (not FindDTMRotated(OakSpotDTM, P.x, P.y, MMX1, MMY1, MMX2, MMY2, 6.1, 8.1, 0.01, aFound)) then
begin
e_Debug('[WalkToOaks] Could not find Oak Spot DTM.');
Exit;
end;
Mouse(P.x - 1, P.y - 1, 1, 1, True);
Flag;
Result := True;
end;
function WalkToBank: Boolean;
var aFound: Extended;
T: Integer;
begin
Result := False;
MakeCompass('n');
// Walks to the bank
FindColorsPie(TPA, 7432822, 10, 225, 270, 10, 70, MMX1, MMY1, MMX2, MMY2, MMCX, MMCY);
if (Length(TPA) < 1) then
begin
e_Debug('[WalkToBank] Could not find Road Color.');
Exit;
end;
P := MiddleTPA(TPA);
Mouse(P.x - 1, P.y - 1, 1, 1, True);
T := 0;
while (FlagDistance > 2) and (T < 30) do
begin
Inc(T);
Wait(RandomRange(150, 200));
end;
if (not FindSymbol(P.x, P.y, 'bank')) then
begin
e_Debug('[WalkToBank] Could not find Bank.');
Exit;
end;
Mouse(P.x - 1, P.y - 1, 1, 1, True);
Flag;
Result := True;
end;
function BankAll: Boolean;
begin
Result := False;
if (not OpenBank('db', True, True)) then
begin
e_Debug('[BankAll] Could not open bank.');
Exit;
end;
Wait(RandomRange(150, 300));
Result := DepositAll;
Wait(RandomRange(150, 300));
end;
function FindTree(UpText: TStringArray): TPoint;
var i: Integer;
begin
Result := Point(-1, -1);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, 3235924, MSX1, MSY1, MSX2, MSY2, 5);
ATPA := TPAtoATPAEx(TPA, 80, 100);
if (Length(ATPA) = 0) then
begin
e_Debug('[FindOak] Could not find any Tree.');
Exit;
end;
for i := 0 to High(ATPA) do
begin
P := MiddleTPA(ATPA[i]);
MMouse(P.x - 1, P.y - 1, 1, 1);
if (WaitUpTextMulti(UpText, RandomRange(400, 500))) then
begin
GetMousePos(Result.x, Result.y);
Break;
end;
end;
if (Result = Point(-1, -1)) then
begin
e_Debug('[FindOak] Could not find any tree with provided uptext.');
Exit;
end;
end;
function ChopTree: Boolean;
begin
Result := False;
// Let's find next Oak to chop
P := FindTree(['Oak']);
if (P = Point(-1, -1)) then
Exit;
// Let's chop it
Mouse(P.x - 1, P.y - 1, 1, 1, True);
Result := DidRedClick;
end;
function CharacterAnimating: Boolean;
begin
// Pixel shift while chopping is around 700, and when idle it is around 200.
Result := (AveragePixelShift(IntToBox(235, 135, 275, 185), 100, 300) > 500);
end;
function DeathWalk: Boolean;
var T: Integer;
r: Boolean;
begin
GameTab(tab_Magic);
Wait(RandomRange(150, 300));
Cast('lumbridge home teleport', False);
Wait(RandomRange(800, 1000));
// Waits for teleport to finish
Wait(60 * 1000);
MakeCompass('n');
// Walk out of Castle
RoadColor := 8226962;
RadialRoadWalk(RoadColor, 70, 90, 70, -1, -1);
repeat
r := RadialRoadWalk(RoadColor, 325, 390, 70, -1, -1);
Inc(T);
until (FindSymbolIn(P.x, P.y, 'quest', MMCX, MMCY, MMX2, MMY2)) or (T >= 30);
// Walk to Draynor crossroads
RoadColor := 8031122
T := 0;
repeat
r := RadialRoadWalk(RoadColor, 270, 360, 70, 0, 0);
Inc(T);
until (T >= 30);
// Walk to Draynor Bank
RoadColor := 6974575;
T := 0;
repeat
r := RadialRoadWalk(RoadColor, 180, 280, 70, 0, 0);
Inc(T);
until (FindSymbol(P.x, P.y, 'bank')) or (T >= 30);
end;
begin
Smart_Signed := True;
Smart_Members := False;
Smart_Server := 33;
SetupSRL;
InitScript;
ClearDebug;
while (True) do
begin
Fails := 0;
while (not WalkToOaks) and (Fails < 10) do
begin
Inc(Fails);
Wait(RandomRange(150, 300));
end;
ClickNorth(True);
while (not InvFull) do
begin
ChopTree;
while (IsMoving) or (CharacterAnimating) do
Wait(RandomRange(100, 200));
end;
Fails := 0;
while (not WalkToBank) and (Fails < 10) do
begin
Inc(Fails);
Wait(RandomRange(150, 300));
end;
if (Fails < 10) then
begin
while (not BankAll) and (Fails < 10) do
begin
Inc(Fails);
Wait(RandomRange(150, 300));
end;
end;
if (Fails >= 10) then
DeathWalk;
end;
FreeDTM(OakSpotDTM);
end.