SRL Archive - Discussions and Debates

An Idea...


realrune

2006-06-29 17:37:24

Here's an alternate idea about how to deal with randoms in a script…

The idea is too have 2 diff. scars running at the same time, to have one script as the 'main' script, and another one taking care of char switching and randoms. Kinda like this…


program MinerMain;

{.include srl/srl.scar}

const OreColor = 0; // The Color of the Rock You're Mining.
const SecsToWait = 5; // Time to Wait While Mining.

procedure Communicate(s : string);
begin
SendInterSCARMessage('Control', S);
end;

function Received : string;
begin
result := ReadInterSCARMessage('Randoms');
end;

procedure Mine;
begin
if(FindObjMultiText(x, y, 'Min', 'ine', 'Rock', OreColor, 5))then
begin
Communicate('Mining Randoms');
if(Random(20) = 1)then
begin
Mouse(x, y, 3, 3, false);
ChooseOption(x, y, 'Mine');
end
Else
Mouse(x, y, 3, 3, true);
if FlagPresent then FFlag(10);
MarkTime(Mark);
repeat
wait(1);
until(IsChatMessage('You s')) or (TimeFromMark(Mark) >= 500);
MarkTime(Mark);
repeat
wait(1);
until(IsChatMessage('You m')) or (TimeFromMark(Mark) >= SecsToWait * 1000) or (LoggedIn = false);
end;
Communicate('Normal Randoms');
end;

procedure SetupScript;
begin
SetupSRL;
DeclarePlayers;
repeat
wait(100);
until(Received = 'Started');
Communicate('Started');
LoginPlayer;
Communicate('All Clear');
end;

begin
SetupScript;
repeat
Mine;
until(False);
end.


program RandomsHandler;

{.include srl/srl.scar}
{.include srl/srl/skill/mining.scar}

Const RunDirec = 'N' ; // Direction To Run When A Fight Is Found.

Var
S : string;

procedure Communicate(s : string);
begin
SendInterSCARMessage('Randoms', S);
end;

function Received : string;
begin
result := ReadInterSCARMessage('Control');
end;

procedure AntiRandoms;
begin
FindNormalRandoms;
if(FindFight)then
RunTo(RunDirec, true);
end;

procedure AntiMiningRandoms;
begin
AntiRandoms;
FindPick;
end;

procedure SetupScript;
begin
SetupSRL;
SetupSRLMining;
LampSkill := 'Mining';
Communicate('Started');
repeat
wait(100);
until(Received = 'Started');
Communicate('All Clear');
end;

begin
SetupScript;
repeat
S := Received;
Case S Of
'Normal Randoms' : AntiRandoms;
'Mining Randoms' : AntiMiningRandoms;
end;
wait(100);
if(NoPick)then
begin
NoPick := False;
Communicate('No Pick');
repeat
wait(1);
until(Received = 'New Pick');
Communicate('All Clear');
FindPickHeadColor;
end;
until(False);
end.

Dark_Sniper

2006-06-29 21:13:14

not a bad idea.. i thought about that a long time ago but i didnt know how to get scar to communicate with another scar

masquerader

2006-06-30 00:17:26

i actually like this idea, because then instead of rewriting random handlers for every script you could run a universal random script

the hard parts would be knowing which randoms to check, and to make the other script stop while a random is being solved

you would also have to send the player nick to the random script so it could find the talking randoms

but overall, i think you could make this work, let me ponder

realrune

2006-06-30 02:40:01

Example Script:

program ExampleScript;

{.include srl/srl.scar}

Const StartPlayer = 0; // Player to start at.

procedure DeclarePlayers;
Var I : Integer;
begin
CurrentPlayer := StartPlayer;
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);

Players[0].Name := '';
Players[0].Pass := '';
Players[0].Nick := 'nick';

For I := 0 To HowManyPlayers - 1 Do
Players[I].Active := True;
end;

procedure Communicate(s : string);
begin
SendInterSCARMessage('Control', S);
end;

function Received : string;
begin
result := ReadInterSCARMessage('Randoms');
end;

procedure SetNickNameBMP;
begin
Communicate('NickName');
repeat
wait(1);
until(Received = 'Waiting for NickName');
Communicate(Players[CurrentPlayer].Nick);
repeat
wait(1);
until(Received = 'All Clear');
Communicate('All Clear');
end;

procedure WaitForRandoms;
begin
if(Received = 'Solving Random')then
begin
repeat
wait(100);
Case Received of
'Solved Random' : exit;
'Failed Random' : begin if LoggedIn then Logout; Exit; end;
end;
until(false);
end;
end;

procedure SetupScript;
begin
SetupSRL;
DeclarePlayers;
repeat
wait(100);
until(Received = 'Started');
Communicate('Started');
repeat
wait(100);
until(Received = 'Setting NickName');
SetNickNameBmp;
end;

begin
SetupScript;

//Main Loop Here...

end.

Random Handler :

program RandomsHandler;

{.include srl/srl.scar}

Const RunDirec = 'N'; // Direction To Run When A Fight Is Found.
Const LSkill = 'Hitpoints'; // Lamp Skill.

procedure Communicate(s : string);
begin
SendInterSCARMessage('Randoms', S);
end;

function Received : string;
begin
result := ReadInterSCARMessage('Control');
end;

procedure AntiRandoms;
begin
FindNormalRandoms;
if(FindFight)then
RunTo(RunDirec, true);
end;

procedure SetNickNameBmp;
begin
Communicate('Waiting for NickName');
repeat
wait(100);
until(Length(Received) < 8);
NickNameBMP := CreateBitmapMaskFromText(Received, UpChars);
Communicate('All Clear');
end;

procedure SetupScript;
begin
SetupSRL;
LampSkill := LSkill;
Communicate('Started');
repeat
wait(100);
until(Received = 'Started');
Communicate('Setting NickName');
repeat
wait(100);
until(Received = 'NickName');
SetNickNameBMP;
end;

begin
SetupScript;
repeat
Case Received Of
'Normal Randoms' : FindNormalRandoms;
'All Randoms' : AntiRandoms;
'NickName' : SetNickNameBMP;
end;
wait(100);
until(False);
end.

Script sends nickname from examplescript to randoms handler.

Randoms need to be tweaked so that the random handler will tell the main script to wait while solving randoms, but other then that I think i've got it figured out.

Dark_Sniper

2006-06-30 13:47:33

nice now i really like the idea:rolleyes:

masquerader

2006-06-30 15:04:26

which script would log in if it got logged out?

Dankness

2006-06-30 16:42:03

there was already a antirandom include like this from wayback, WA-AMP or somethingl ike that…

realrune

2006-06-30 16:54:49

From: masquerader
which script would log in if it got logged out?


The main script. When switching players you'd have to do this though.

NextPlayer(Active : Boolean);
SetNickNameBmp;

From: Dankness
there was already a antirandom include like this from wayback, WA-AMP or somethingl ike that…


Yeah, I've seen it. I don't think it really does anything usefull though.

Avaphi

2006-07-02 05:53:55

This is genious ! one can be running all the srl plugins, randoms, charswitching needs :eek: I love the idea RR, I think Solemn could do it really well, he has already experimented with this sort of thing

Jagex_Fagex

2006-07-02 06:31:47

aye.. i have also been thinking of something like this for a few years, i have been experimenting but never really found the time to do anything major with it, thanks RR you take it off my mind.. :) great idea

From: mastaraymond
I like the idea. But isn't it a bit too much work?


we are the SRL community.. we can make it very user friendly XD

masquerader

2006-07-02 16:28:25

i was thinking that you wouldnt really want the anti randoms script to load the entire srl, it should just load what it needs to make antirandoms.scar to work (mouse, etc)

moparisthebest

2006-07-03 07:53:34

From: Dankness
there was already a antirandom include like this from wayback, WA-AMP or somethingl ike that…


yup, chriz's autominer could use it, and it was called WAAMP, and it was coded by genodemon, even the comments say it is the only clean code genodemon ever wrote, you can only lol at that :P

anyways I dug it up and here it is:

procedure CheckCommunication;
var
cont:boolean;
begin
cont:=true;
if (ReadInterSCARMessage('WAAMP')=('SCRIPT:PAUSE')) then
begin
wait(10)
SendInterScarMessage('WAAMP','SCRIPT:PAUSE:OK');
repeat
wait(50)
if (cont) then writeln('Paused By WAAMP. Waiting for WAAMP to continue...');
if (ReadInterSCARMessage('WAAMP')=('SCRIPT:RUN')) then cont:=true else cont:=false;
until (cont);
end;
end;

procedure PauseWAAMPScript;
var
cont:boolean;
begin
writeln('Pausing WAAMP script...');
SendInterScarMessage('WAAMP','WAAMP:PAUSE');
sleep(50)
repeat
if (ReadInterSCARMessage('WAAMP')=('WAAMP:PAUSE:OK')) then cont:=true else cont:=false;
sleep(100)
until (cont)
writeln('WAAMP has been paused, main script will now continue...');
end;


procedure UnPauseWAAMPScript;
begin
writeln('un-pausing WAAMP script');
SendInterScarMessage('WAAMP','WAAMP:RUN');
sleep(50)
end;


procedure Send(UserName,Password,str1,str2,str3,str4,str5,str6,str7,str8,str9,str10:string);
var
count:integer;
cont:boolean;
massage:string;
begin
writeln('WaG scripting Sending and Reciveing');
writeln(' Concept by: Wallfire');
writeln(' Uber l33t Coding bY:');
writeln(' GenoDemoN');
writeln(' Made in a mear 47 minutes!');
SendInterSCARMessage('COMM2WAAMP', 'CLEAR');
SendInterSCARMessage('SHARE', 'CLEAR');
SendInterSCARMessage('COMM2MAIN', 'CLEAR');
wait(500);
repeat (* Only Clean Code GenoDemoN ever MADE!*)
sleep(10)
status('synching up...');
sleep(50)
cont:=false;
if ( ReadInterSCARMessage('COMM2MAIN')='READY' ) then
begin
writeln('ready')
SendInterSCARMessage('COMM2WAAMP','OK')
cont:=true
end;
until (cont)
sleep(2000)
count:=0;
repeat
count:=count+1;
IF (count>strtoint(ReadInterSCARMessage('Recivedd'))+1) and (count>1) then
count:=strtoint(ReadInterSCARMessage('Recivedd'))+1;
IF (count>12) then count:=1;
case count of
1:massage:=UserName;
2:massage:=Password;
3:massage:=str1;
4:massage:=str2; (* Only Clean Code GenoDemoN ever MADE!*)
5:massage:=str3;
6:massage:=str4;
7:massage:=str5;
8:massage:=str6;
9:massage:=str7;
10:massage:=str8;
11:massage:=str9;
12:massage:=str10;
end;
writeln('Sending packet #'+inttostr(count)+' Consists of:'+massage);
SendInterSCARMessage('COMM2WAAMP',inttostr(count));
SendInterSCARMessage('SHARE',massage);
wait(1000);
repeat (* Only Clean Code GenoDemoN ever MADE!*)
wait(150);
until(ReadInterSCARMessage('Recived')='Yes')
until (ReadInterSCARMessage('COMM2MAIN')='DONE')
SendInterSCARMessage('SHARE','OK')
end;

if you want the script that used it i can find that too, it wont work today obviously though ;)