SRL Archive - First Scripts

My first poor script :) Advice more than welcome.


Sjoe

2013-01-05 16:28:53

Ok I'm probably one of the few SRL members here that didn't know how to script ;) Don't judge me hehe.

It's a Sapphire Necklace Maker in Al Kharid
Just posting it for getting advice


const
SpeedOfMouse = 20;
Loads = 50;

var
LoadsDone, AttemptsOnBank: Integer;
BlueSaph, GoldBar, GreenVial, SaphNeckInv: Integer;


Procedure AntiBan;

begin
case Random(150) of
1: begin HoverSkill('random', False) GameTab(25) end;
2-6: begin HoverSkill('crafting', False) GameTab(25) end;
6-8: BoredHuman;
9: PickUpMouse;
10: RandomMovement;
11: RandomRclick;
12: CompassMovement(10, 70, True);
end;

end;

//---------------------AutoColors--------------------\\


function NPCBANKColor: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
R, G, B: Integer;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.16, 1.90);

if not (FindColorsTolerance(arP, 2386031, MSX1, MSY1, MSX2, MSY2, 10)) then
begin
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);

for i := 0 to arL do
begin
ColorToRGB(arC[i], R, G, B);

if (R >= 67) and (R <= 137) and (G >= 63) and (G <= 129) and (B >= 14) and (B <= 66) then
begin
ColorToXYZ(arC[i], X, Y, Z);

if (X >= 4.49) and (X <= 17.80) and (Y >= 4.99) and (Y <= 20.51) and (Z >= 1.69) and (Z <= 8.04) then
begin
Result := arC[i];
Break;
end;
end;
end;

ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);

if (i = arL + 1) then
Writeln('AutoColor failed in finding the color.');
end;


function FurnaceColor: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
R, G, B: Integer;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.06, 2.74);

FindColorsSpiralTolerance(MSCX, MSCY, arP, 11192803, MSX1, MSY1, MSX2, MSY2, 5);
if (Length(arP) = 0) then
begin
Writeln('Failed to find the color, no result.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);

for i := 0 to arL do
begin
ColorToRGB(arC[i], R, G, B);

if (R >= 211) and (R <= 240) and (G >= 188) and (G <= 214) and (B >= 161) and (B <= 183) then
begin
ColorToXYZ(arC[i], X, Y, Z);

if (X >= 51.85) and (X <= 67.85) and (Y >= 52.98) and (Y <= 69.34) and (Z >= 41.65) and (Z <= 54.07) then
begin
Result := arC[i];
Writeln('AutoColor = ' + IntToStr(arC[i]));
Break;
end;
end;
end;

ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);

if (i = arL + 1) then
Writeln('AutoColor failed in finding the color.');
end;




//--------------------------------------------------------\\


//------------------Walking Procedures---------------------\\
procedure WalkToFurnace;

var
Furny: TPointArray;

begin
Case Random(15) of
1: begin HoverSkill('crafting', False) GameTab(25) end;
end;
FindNormalRandoms;
RunEnergy(30);

Furny := [Point(89, 164), Point(89, 165), Point(110, 150), Point(112, 126), Point(116, 110), Point(126, 95), Point(129, 78), Point(111, 79)]
SPS_WalkPath(Furny);
Wait(150+ Random (50));

end;

procedure WalkToBank;

var
Banky: TPointArray;

begin
FindNormalRandoms;
RunEnergy(30);

Banky := [Point(112, 73), Point(112, 72), Point(130, 77), Point(126, 94), Point(116, 105), Point(113, 122), Point(110, 136), Point(112, 153), Point(108, 166), Point(91, 167)]
SPS_WalkPath(Banky);
Wait(1250+ Random(250));

end;


//--------------------------------------------------------\\


//------------------------Banking----------------------------\\

procedure FindBankers;

var
x,y: Integer;

begin
repeat
if (BankScreen = False) then
begin
if FindObj(x, y, ('Bank'), NPCBANKColor, 5) then
MMouse(x, y, 3, 3);
Clickmouse2(mouse_right);
ChooseOptionEx('nk B', 'k Ba')
Wait(2250+ random(500))
end;
inc(AttemptsOnBank)
until((BankScreen = True) or (AttemptsOnBank=5))
if(BankScreen = True) then Writeln('opened')

end;


procedure BankingTheStuff;

var
BankAttempts, x, y: Integer;

begin
SaphNeckInv := DTMFromString('mggAAAHicY2NgYEhjYmAoBuIkIE4F4lwgrgRiOUYGBk4glgZiZSBWAGJhEBbrAupixMBGQJIfC8ZUCcEQAACzoQRy');
BlueSaph := DTMFromString('mggAAAHicY2NgYGADYg4g5gZifiBmZIAATigtCFUjAsSsQNzRMReqChXzM2AHmCoRdjAwAACwmAIw');
GoldBar := DTMFromString('mrAAAAHic42BgYOAFYmEglgViSSAWAGJOBgjgAmI2KJsFiHmAWBSqng+ImYB4SbM4kGTEiY2AJD8ejFsnBMMAAB10Arg=');

begin
begin
if FindDTM(SaphNeckInv, x, y, MIX1, MIY1, MIX2, MIY2) then
repeat
FindBankers;
QuickDeposit(SRL_DEPOSIT_ALL);
Wait(150 + Random(150))
MouseBox(396, 146, 413, 154, mouse_right)
Wait(150 + Random(150))
ChooseOption('-14')
Wait(150 + Random(150))
MouseBox(444, 145, 454, 154, mouse_Right)
Wait(150 + Random(150))
ChooseOption('-14')
Wait(800 + Random(150))

Inc(BankAttempts);
until (FindDTM(BlueSaph, x, y, MIX1, MIY1, MIX2, MIY2)
or (BankAttempts = 5))
end;
end;

FreeDTM(SaphNeckInv);
FreeDTM(BlueSaph);
FreeDTM(GoldBar);

end;



//----------------------------------------------------------\\

function CraftingScreen: Boolean;
var
x, y: Integer;

begin
Result := False;

GreenVial := DTMFromString('mggAAAHicY2NgYDBlgmAjILYEYisg1gPiZEYGhlAgTofiWCBOAGKGpfoMLYv3MKibezBImngxGBibMUhJSTH8B0rxY8GMODAEAAD/KgnE');

if FindDTM(GreenVial, x, y, MSX1, MSY1, MSX2, MSY2) then
begin
Writeln('Opened Crafting Screen')
Result := True
end;

FreeDTM(GreenVial);
end;

procedure FindFurnace;

var
FurnaceFinding, x, y: Integer;

begin
Marktime(FurnaceFinding)

FindNormalRandoms;

if ((IsMoving = False) or FFlag(0)) then
begin
repeat
if FindObj(x, y, ('Smelt'), FurnaceColor, 5) then
begin
MMouse(x, y, 3, 3);
Clickmouse2(mouse_left);
Wait(1500 + Random(500));
end;
until((CraftingScreen) or (TimeFromMark(FurnaceFinding) > (30000)))
end;
end;

procedure CraftingRings;

var
WaitingTime, CraftingTheRings: Integer;
SaphNeckCraftScr: Integer;
x, y: Integer;

begin

SaphNeckCraftScr := DTMFromString('mbQAAAHicY2VgYAgF4mAgjgDiVCCOBuLDQHwKirdCsaBIGwM6MAJifjTMiAWDAQAJYwal');

WaitingTime := (23500 + Random(1250))

if CraftingScreen then
begin
if FindDTM(SaphNeckCraftScr, x, y, 220, 10, MSX2, MSY2) then
begin
MouseBox(265, 314, 480, 324, mouse_left)
Writeln('Crafting Necklaces')
Wait(2000)
end else
if FindDTM(SaphNeckCraftScr, x, y, MSX1, MSY1, 167, 227) then
begin
MouseBox(78, 134, 110, 167, mouse_left);
Wait(350 + Random(250));
MouseBox(265, 314, 480, 324, mouse_left)
Writeln('Crafting Necklaces')
Wait(2000)
end else
begin
Dragmouse(229, 205, 1, 1, 227, 89, 2, 2);
Wait(350 + Random(350))
MouseBox(78, 134, 110, 167, mouse_left);
Wait(550 + Random(150));
MouseBox(265, 314, 480, 324, mouse_left);
Writeln('Crafting Necklaces');
Wait(2000)
end;
end;

FreeDTM(SaphNeckCraftScr);

Marktime(CraftingTheRings);

repeat
AntiBan;
Wait(1250 + Random (750))
until (TimeFromMark(CraftingTheRings) > WaitingTime)

end;

begin
SetupSRL;
MouseSpeed := (SpeedOfMouse);
SPS_Setup(Runescape_Other, ['Al_Kharid']);
ClickNorth(SRL_Angle_High);

repeat
BankingTheStuff;
WalkToFurnace;
FindFurnace;
CraftingRings;
WalkToBank;
inc(LoadsDone);
until(LoadsDone = Loads)
end.


Would like more advice on smarter scripting, and failsafes

Cheers guys

rj

2013-01-05 19:24:41

Don't you have to apply wi a script to get srl members?

This actually looks good for a first script

Pod

2013-01-05 19:34:27

From: rjj95
Don't you have to apply wi a script to get srl members?

This actually looks good for a first script


Scripting was different a few years back. :p

Silentcore

2013-01-05 19:35:22

^^Yeah, how did he become a SRL member? Did you like make one before but didnt make one after you got the Membership. lol.

masterBB

2013-01-05 19:48:25

member.php?u=172

He is from before the forum started. Everyone was a member back then ^^

x[Warrior]x3500

2013-01-05 19:57:24

From: Sjoekeloe
Ok I'm probably one of the few SRL members here that didn't know how to script ;) Don't judge me hehe.


and prolly the only one that got a srl scripter cup w/o knowing now to script :D

Sjoe

2013-01-05 20:25:29

I'm an Old Timer I guess.
Anyone have some advice please? :)

DannyRS

2013-01-05 21:19:04

From: Sjoekeloe
I'm an Old Timer I guess.
Anyone have some advice please? :)


looks good but, global variable the DTMs set once and free at end is a better way

http://villavu.com/forum/showthread.php?t=78418

And your SPS Paths are a tad short maybe add more with closer points

BraK

2013-01-05 21:21:10

From: Silentcore
^^Yeah, how did he become a SRL member? Did you like make one before but didnt make one after you got the Membership. lol.


The Member's application hasn't been around the entire forum life. Originally all members were selected by the staff.

Sjoe

2013-01-05 22:06:39

From: DannyRS
looks good but, global variable the DTMs set once and free at end is a better way

http://villavu.com/forum/showthread.php?t=78418

And your SPS Paths are a tad short maybe add more with closer points


Alright thanks, luckily the SPS path is working atm.

DannyRS

2013-01-05 22:11:11

From: Sjoekeloe
Alright thanks, luckily the SPS path is working atm.


Yea just a suggestion coz if it gets really crowded two points might get blocked :p

Sjoe

2013-01-06 01:01:24

From: DannyRS
Yea just a suggestion coz if it gets really crowded two points might get blocked :p


Yeah good point, didn't even think about that lol

Mr[S]

2013-01-06 04:40:50

Who actually started up this community?

John

2013-01-06 04:53:54

Wizzup and WT-Fakawi I'm pretty sure.

Sjoe

2013-01-06 04:57:18

From: John
Wizzup and WT-Fakawi I'm pretty sure.


Yeps

And could u people offtopic somewhere else :(
I'm trying to learn here!

John

2013-01-06 05:03:47

Oh soz bro, One thing I recommend is that you read through other peoples scripts, It helps A LOT and you can find some nifty functions for private use ;)

Sjoe

2013-01-06 05:44:28

From: John
Oh soz bro, One thing I recommend is that you read through other peoples scripts, It helps A LOT and you can find some nifty functions for private use ;)


I try to do that, but most of the time, I just don't understand a line of it lol
Don't understand TPA/ATPA and advanced colorsearching on MS.
Hopefully someday

DannyRS

2013-01-06 06:00:54

From: Sjoekeloe
I try to do that, but most of the time, I just don't understand a line of it lol
Don't understand TPA/ATPA and advanced colorsearching on MS.
Hopefully someday


TPA is basically finding all of a certain color on the MS, much more accurately than normal when combined with CTS2 hue/sat Mod from ACA,

ATPA is a way to Sort the loads of tiny TPA single pixel results and store them (Join all color pixels within 20 pixels of each other for example),

Read all these that use either of them and you should understand better:
http://villavu.com/forum/showthread.php?t=49067

xtrapsp

2013-01-06 08:09:16

From: Sjoekeloe
I try to do that, but most of the time, I just don't understand a line of it lol
Don't understand TPA/ATPA and advanced colorsearching on MS.
Hopefully someday


Have you watched YohoJos Video Tutorials?

Should give you a basic grasp on reading the scripts ^^

Sjoe

2013-01-06 14:28:29

From: DannyRS
TPA is basically finding all of a certain color on the MS, much more accurately than normal when combined with CTS2 hue/sat Mod from ACA,

ATPA is a way to Sort the loads of tiny TPA single pixel results and store them (Join all color pixels within 20 pixels of each other for example),

Read all these that use either of them and you should understand better:
http://villavu.com/forum/showthread.php?t=49067



Thx mate, always helpful!

From: xtrapsp
Have you watched YohoJos Video Tutorials?

Should give you a basic grasp on reading the scripts ^^


Yeah I watched them, they've been informative.