PDA

View Full Version : First Script... Ever...



Kave
08-27-2007, 02:41 AM
All it does is pick up body runes from the second floor of the scimmy shop in al kharid.... I needed 90 body runes and I didnt want to pick them up.... It has Fakawi's randoms and you could use multiple players if you wanted...

**EDIT**

I updated the script a bit... it checks for randoms more and if it finds a fight it will go up the stairs for a bit then come back and added some checks for not logged in. any advice / criticism is welcome.

***EDIT***

I updated script again, you will see some thing i plan on doing at the top of the script, i fixed a problem that made it auto-logout every 20 mins, its detectable im sure :P BUT, i believe you could run it all day :P (dont quote me on that please lol)

****EDIT****

No more adding your own colors and it will walk from bank, check the curtains, and go up the ladder. I took alot of the walking from XcanadamanX's autosmelter lol (love his autosmelter).

*****EDIT*****

Updated again, cant seem to find an issue with my tries, if anyone can look and see if they can find what wrong i'll be much obliged....

// KAVES RUNE SNATCHER! v0.8
//used snippets from XcanadamanX, neG, and WT-Fakawi
//everything else(all the crappy parts lol) are my own
// ~~~~POSSIBLE ADDITIONS FOR LEARNING PURPOSES~~~~
//try to add banking and walk from bank to rune and back again
//Maybe add SRLstats?(for learning... lol)
//Al Kharid(Water,Fire,Body) BODY WORKS (no banking)
//Varrock(Body) WORKS (no banking)
//Lumbridge(Mind) WORKS

program Kaves_Rune_Snatcher;
{.include SRL\SRL.scar}
var
x,y,Multiplier,NumPickedUp,PickUp,Rest,TilRest,Cac tusColor,RuneColor1,RuneColor2:Integer;
location,runename,Rune1,Rune2:string;

procedure DeclarePlayers;
begin
HowManyPlayers := 2;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 1;

Players[0].Name := '1234';
Players[0].Pass := '1234';
Players[0].Nick := '234'; // 3-4 letters of username
Players[0].Loc := 'VA'; //'AK'(Al Kharid),'VA'(Varrock),'LU'(Lumbridge)
//LU only has mind, AK has body fire and water, VA only has body
//Players[0].Pin := ; //Integer not string
Players[0].Integers[0] := 200; //Number to pick up
Players[0].Integers[1] := 10;//How many runes to pick up before resting
//Integers[2] = Keeps how many you already got
//Integers[3] = How many times you've logged out
//Integers[3] = How many (total) til next rest
Players[0].Strings[0] := 'Body'; //'Body', 'Mind', 'Water', 'Fire'
Players[0].Active := True;

Players[1].Name := '5678';
Players[1].Pass := '5678';
Players[1].Nick := '678';
Players[1].Loc := 'LU';
//Players[1].Pin := ;
Players[1].Integers[0] := 100;
Players[1].Integers[1] := 10;
Players[1].Strings[0] := 'Mind';
Players[1].Active := True;
end;

//By: WT-Fakawi & Wizzup? (idea from XcanadamanX...)
function myRadialWalk(TheColor: Integer; StartRadial, EndRadial: Integer; Radius:
Integer; Xmod, Ymod: Integer): Boolean;
var
mx, my: Integer;
begin
if (StartRadial = EndRadial) then
begin
WriteLn('WARNING: Using LinearWalk, StartRadial, and EndRadial are the same');
if LinearRoadWalk(TheColor, StartRadial, Radius, XMod, YMod) then
Result := True;
end else
if (radialwalkex(mx, my, 648, 83, thecolor, 0, startradial, endradial, radius)) then
begin
MouseFindNoFlag(mx, my, Xmod, Ymod);
Result := True;
end;
end;

//XcanadamanX
function FindCactusColor: Integer;
var
GenericColor, a, b, TestColor, Red, Green, Blue : integer;
begin
GenericColor := 3698770;
Flag;
a := MMX1;
b := MMY1;
repeat
b := b + 1;
repeat;
a := a + 1;
if FindColorTolerance(x, y, GenericColor, a, b, MMX2, MMY2, 50) then
begin
if a = MMX1 + 1 then b := y;
a := x;
TestColor := GetColor(x, y);
red := (TestColor mod 256);
green := ((TestColor / 256) mod 256);
blue := ((TestColor / 256) / 256);
if Green - Red >= 24 then if Green - Red <= 60 then
if Red - Blue >= 1 then if Red - Blue <= 33 then
if Green - Blue >= 40 then if Green - Blue <= 78 then
begin
Result := TestColor;
CactusColor := TestColor;
WriteLn('Cactus Color = ' +
IntToStr(TestColor));
Exit;
end;
end else a := MMX2;
until a >= MMX2;
a := MMX1;
until b >= MMY2;
WriteLn('Could not find Cactus Color!');
Result := 0;
end;

//XcanadamanX (OpenDoor function >.>)
function OpenCurtain: Boolean;
begin
if FindObjCustom(x, y, ['urt','tai','ain'],[68928,74035,5410],10) then
begin
If IsUpTextMulti('C','los','ose') then
writeln('curtain is open')
else
begin
if IsUpTextMulti('O','pen','Open') then
begin
Mouse(x,y,0,0,true)
end;
end;
end;
end;

procedure NotFight;
begin
location := Players[CurrentPlayer].Loc;
runename := Players[CurrentPlayer].Strings[0];
Case Lowercase(location) of
'ak':
begin
if(Lowercase(runename) = 'body') then
begin
if(FindObjCustom(x, y, ['add','der'],[928581,141377],10)) then
begin
Mouse(x, y, 0, 0, false);
ChooseOption('Climb-up');
FFlag(0);
end;
Wait(10000 + random(2000));
if(FindObjCustom(x, y, ['add','der'],[928581,141377],10)) then
begin
Mouse(x, y, 0, 0, false);
ChooseOption('Climb-down');
FFlag(0);
end;
end else
begin
RunAwayDirection('S');
Wait(10000 + random(2000));
RunBack;
end;
end;
'va':
begin
RunAwayDirection('S');
Wait(10000 + random(2000));
RunBack;
end;
'lu':
begin
if(FindObjCustom(x, y, ['tai','irc','cas'],[603212,1250582,6694],10)) then
begin
Mouse(x, y, 0, 0, false);
ChooseOption('Climb-up');
FFlag(0);
end;
Wait(10000 + random(2000));
if(FindObjCustom(x, y, ['tai','irc','cas'],[603212,1250582,6694],10)) then
begin
Mouse(x, y, 0, 0, false);
ChooseOption('Climb-down');
FFlag(0);
end;
end;
end;
end;

//WT-Fakawi (modified a bit for my uses)
function FindFastRandoms: Boolean;
var
i: Integer;
begin
for i := 1 to 8 do
begin
case i of
1: if FindDead then
Result := True;
2: if FindMod then
Result := True;
3: if FindMime then
Result := True;
4: if FindMaze then
Result := True;
5: if FindQuiz then
Result := True;
6: if FindDemon then
Result := True;
7: if FindLamp(LampSkill) then
Result := True;
8: if FindBox then
begin
Result := True;
if not(SolveBox) then GambleBox;
end;
end;
wait(1);
end;
end;

procedure TalkingRandoms;
begin
FindTalk;
wait(10)
FindFastRandoms;
wait(10);
if (FindFight = true) then NotFight;
FindTalk;
end;


procedure RandomLoop;
var
i: Integer;
begin
WriteLN('Checking Randoms...');
repeat
begin
wait(300 + random(200));
TalkingRandoms;
i := i + 1;
end;
until(i = 57);
i := 0;
WriteLn('Done Checking Randoms');
end;

procedure OffRune;
begin
Case Lowercase(location) of
'ak':
begin
if(Lowercase(runename) = 'body') then
begin
if(FindObjCustom(x, y, ['add','der'],[928581,141377],10)) then
begin
Mouse(x+40,y-120,0,0,true)
end;
end;
{ end else //for fire and water walk to a rock?
begin
end;}
end;
'va':
begin
Mouse(x+40,y-40,0,0,true);
end;
'lu': //check this one...
begin
if(FindObjCustom(x, y, ['tai','irc','cas'],[603212,1250582,6694],10)) then
begin
Mouse(x+40,y-40,0,0,true)
end;
end;
end;

end;

procedure WhatToGet;
begin
Rune2 :='une';
Case Lowercase(runename) of
'body':
begin
Rune1 := 'ody';
RuneColor1 := 12323591;
RuneColor2 := 12323591;
if(Lowercase(location) = 'ak') then
Multiplier := 1
else
Multiplier := 3;
end;
'mind':
begin
Rune1 := 'ind';
RuneColor1 := 607816;
RuneColor2 := 1738976;
Multiplier := 1;
end;
'fire':
begin
Rune1 := 'ire';
RuneColor1 := 0; // missing colors...
RuneColor2 := 0; // missing colors...
Multiplier := 0; // missing value...
end;
'water':
begin
Rune1 := 'ate';
RuneColor1 := 0; // missing colors...
RuneColor2 := 0; // missing colors...
Multiplier := 0; // missing value...
end;
end;
end;

procedure WhereAmI;
begin
location := Players[CurrentPlayer].Loc;
runename := Players[CurrentPlayer].Strings[0];
PickUp := Players[CurrentPlayer].Integers[0];
NumPickedUp := Players[CurrentPlayer].Integers[2];
Rest := Players[CurrentPlayer].Integers[3];
TilRest := Players[CurrentPlayer].Integers[4];
Case Lowercase(location) of
'ak':
begin
Writeln('We are in Al Kharid! Collecting ' + runename + 'runes!');
//FindCactusColor;
//ToBodyRuneAK;
end;
'va':
begin
Writeln('We are in Varrock! Collecting ' + runename + 'runes!');
end;
'lu':
begin
Writeln('We are in Lumbridge! Collecting ' + runename + 'runes!');
end;
end;
end;

procedure ToBodyRuneAK;
begin
if myRadialWalk(CactusColor, 400, 420, 45, 1, -2) then writeln('walking to cactus')
wait(10)
FFlag(0);
if myRadialWalk(CactusColor, 50, 10, 60, 0, 0) then writeln('walking to scimmy shop')
wait(10)
FFlag(0);
OpenCurtain;
if myRadialWalk(6984, 350, 400, 60, 0, 0) then writeln('walking to ladder')
wait(10)
FFlag(0);
if(FindObjCustom(x, y, ['add','der'],[928581,141377],10)) then
begin
Mouse(x, y, 0, 0, false);
ChooseOption('Climb-up');
FFlag(0);
writeln('arrived!');
end;
end;

procedure ToBankAK;
begin
//learn radialwalk and how to use bitmaps.
end;

procedure Report;
begin
ClearDebug;
SRLRandomsReport;
WriteLn('>--------------------<>--------------------<')
WriteLn('> Kaves Rune Snatcher ')
WriteLn('> ')
WriteLn('> Running Time: ' + (TimeRunning) + ' ')
WriteLn('> '+runename+ ' Runes Picked Up: ' + IntToStr(NumPickedUp) + '')
WriteLn('> Rested '+IntToStr(Rest)+ ' times. ')
WriteLn('> ')
WriteLn('>--------------------<>--------------------<')
end;


procedure GetRune;
var
Tries, GiveUp:Integer;
begin
if(not(LoggedIn)) then exit;
if(not(NumPickedUp = PickUp)) then
begin
if(not(NumPickedUp = TilRest)) then
begin
if(GiveUp < 5) then
begin
if(Tries < 10) then
begin
wait(500 + random(500));
if(FindObjCustom(x, y, [Rune1,Rune2], [RuneColor1,RuneColor2],1)) then
begin
WriteLn('Found Rune! Picking up...');
Mouse(x, y, 0, 0, true);
FFlag(0);
WriteLn('Picked up the Rune!');
NumPickedUp := NumPickedUp + Multiplier;
Tries := 0;
GiveUp := 0;
wait(1000);
OffRune;
Report;
RandomLoop;
end
else
begin
Tries := Tries + 1;
WriteLn('Try number: ' +IntToStr(Tries)+ '');
end;
end else
begin
wait(100);
OffRune;
FFlag(0);
FindFastRandoms;
ClearDebug;
Tries := 0;
GiveUP := GiveUp + 1;
end;
end else
begin
Writeln('Cant find the rune... Logging out...');
Players[CurrentPlayer].Loc := 'Lost';
Players[CurrentPlayer].Active := False;
LogOut;
wait(1000)
NextPlayer(True);
NumPickedUp := 0;
HighestAngle;
end;
end;
end;

if(NumPickedUp = PickUp) then
begin
Report;
WriteLn('Found all' +IntToStr(PickUp)+ ' ' +runename+ ' runes!');
Players[CurrentPlayer].Loc := 'Done';
Players[CurrentPlayer].Active := False;
end;

if(NumPickedUp = TilRest) then
begin
Report;
WriteLn('Found ' +IntToStr(NumPickedUp)+ ' ' +runename+ ' runes!');
WriteLn('Time to Rest!');
Players[CurrentPlayer].Integers[4] := TilRest + Players[CurrentPlayer].Integers[1];
Players[CurrentPlayer].Integers[2] := NumPickedUp;
Players[CurrentPlayer].Integers[3] := Rest + 1;
end;
end;
//Essentially neG's lol
begin
SetupSRL;
FindWindowBySize(766, 504);
ActivateClient;
DeclarePlayers;
begin
if (not (LoggedIn)) then
begin
Loginplayer;
HighestAngle;
Players[CurrentPlayer].Integers[2] := 0;
Players[CurrentPlayer].Integers[3] := 0;
end;
end;

repeat
NickNameBMP := CreateBitmapMaskFromText(Players[CurrentPlayer].Nick, UpChars);
if(Players[CurrentPlayer].Integers[4] < 0) then
Players[CurrentPlayer].Integers[4] := Players[CurrentPlayer].Integers[1];
WhereAmI;
WhatToGet;
repeat
if(not(LoggedIn)) then exit;
GetRune;
until(NumPickedUp = TilRest);
if (NumPickedUp = TilRest) then
begin
LogOut;
wait(1000)
NextPlayer(True);
HighestAngle;
end;
until (false);
end.

JuKKa
08-27-2007, 04:07 AM
you should still add: If(Not Loggedin)Then Break;
To ur loops

Kave
08-27-2007, 04:54 AM
so like this?
if(not(LoggedIn)) then exit;
if(NumPickedUp < PickUp) then
begin
if(FindObjCustom(x, y, ['ody','une'], [Color1,Color2,Color3],1)) then
begin
MMouse(x, y, 0, 0);
Mouse(x, y, 0, 0, true);
wait(2000);
NumPickedUp := NumPickedUp + 1;
Mouse(x-60, y, 0, 0, true);
Report;
wait(30000);
end;
end else
exit;
end;

Kave
08-27-2007, 02:52 PM
I updated the script a bit... it checks for randoms more and if it finds a fight it will go up the stairs for a bit then come back and added some checks for not logged in. any advice / criticism is welcome.

BobboHobbo
08-28-2007, 04:00 AM
Preety good for a first script.

Kave
08-28-2007, 04:20 AM
Preety good for a first script.

thank you very much :) i updated again lol im trying to make it walk from the bank to the 2nd floor of the scimmy shop, then bank the runes when it finishes lol, not having much success though >.< im trying to modify Xcan's walk to furnace function though >.>

HyperSecret
08-28-2007, 04:37 AM
yea pretty good for a first...but why not just use an already made random and give credits...good for making own, but the other prolly would work better

gerauchert
08-28-2007, 04:51 AM
i agree, good first script ;)

keep at it and im happy you are learning to script :D

Kave
08-28-2007, 05:29 AM
yea pretty good for a first...but why not just use an already made random and give credits...good for making own, but the other prolly would work better

i used WT-Fakawi's FastFindRandom, i just got rid of some useless ones lol.

i can barely make a simple script to pick up body runes >.> im not making my own find randoms lol

Pwnt by Pwnt
08-28-2007, 05:39 AM
yeah.. not bad.. but you could maybe try DTMs for next version, but yeah, good for a first :)

dvdcrayola
08-28-2007, 05:56 AM
Check out this:
http://www.villavu.com/forum/showthread.php?t=12858?t=14246

And this:
http://www.srl-forums.com/forum/showthread.php?t=17157

Maybe the second one first... it will show you how to add multiplayer to your script.. this will be a HUGE add, makes it much better as far as getting banned.

looks good though. If you need any help with the Multiplayer PM me about it, or post here, ill check back ;)

Kave
08-28-2007, 07:12 AM
Check out this:
http://www.villavu.com/forum/showthread.php?t=12858?t=14246

And this:
http://www.srl-forums.com/forum/showthread.php?t=17157

Maybe the second one first... it will show you how to add multiplayer to your script.. this will be a HUGE add, makes it much better as far as getting banned.

looks good though. If you need any help with the Multiplayer PM me about it, or post here, ill check back ;)

It has multiplayer, you just need to change the HowManyPlayers and add more of the Player[i].

dvdcrayola
08-28-2007, 02:37 PM
oh lol.. my bad, i skipped over it at the begining...

you need to add more "if(not(LoggedIn)) then exit;" as failsafes, also another good step would be to have some antiban, search it if you dont know how. and then eventually more and more failsafes

good job, and sorry about my mistake. :p

Kave
08-28-2007, 11:06 PM
well i ran it while at school and thought you might want to see how it did...

>--------------------<>--------------------<
> Kaves Body Rune Snatcher
>
> Running Time: 3 Hours, 23 Minutes and 32 Seconds
> Runes Picked Up: 297
>--------------------<>--------------------<

/~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\
| SRL 4 Randoms Report |
| www.srl-forums.com |
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
| Fights : 2 |
| Talks : 6 |
| Ricks : 1 |
| Old Men : 2 |
| No Sandwiches : 1 |
| Lamps Missed : 1 |
| Capn Hand[s] : 1 |
\~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/

Pwnt by Pwnt
08-30-2007, 01:34 AM
:o wow... thats amazing that you got so many randoms in just 23 mins and 32 seconds O_o oh wait.. just noticed it said 3 hrs :P but yeah, seems like it ran good :p nice work :D

Kave
08-31-2007, 03:36 AM
Well ive updated it again, i added some more runes you can pick up. still working on the banking and suck though...

dvdcrayola
08-31-2007, 06:28 AM
wow, good adition with adding other runes!

I B X R
08-31-2007, 05:53 PM
Wow, nice

dark4mdawn
09-01-2007, 03:57 AM
yea priity good