SRL Archive - Help and Support

Bored? Want a challange? Wanna be officaly leet? Enter.


Naike

2008-08-16 21:07:49

Be ready to face the pain


program New;
{.include SRL/SRL/Misc/SMART.scar}
{.include SRL/SRL.scar}
{.include SRL/SRL/Reflection/Reflection.scar}

var i, Hp, HpEx, time, CrabsKill, ExpGain, HowManyResponds : integer;
NPCs, NPCs2 : array of TNPC;
C0l : String;
TheQuestion, TheRespond: array of array of String;

{--------------------------------- Setup Start ---------------------------------}

Const
SmartWorld = 'World157';
YourSRLID = ''; // Leave blank if you dont know what this is!
YourSRLPassword = ''; // Leave blank if you dont know what this is!

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

Players[0].Name := '';
Players[0].Pass := '';
Players[0].Nick := '';
Players[0].Booleans[0] := True; // Use Special attack?
Players[0].Booleans[1] := False; // DrinkPotions?
Players[0].Integers[1] := 15;
// Chance everytime it runs mainloop that it drinks a potion...
// Note Mainloop runs once per crab kill..
Players[0].Active := true;

end;

{All credit to MasterKill for letting me use his responder!}
Procedure SetupResponds; // ADD RESPONDS FOR BETTER ANTI BAN !
begin
HowManyResponds := 3; {<-- SETUP CORRECT !!}
SetArrayLength(TheQuestion, HowManyResponds); SetArrayLength(TheRespond, HowManyResponds);
TheQuestion[0] := ['level', 'lvl']; // MasterKill owns
TheRespond[0] := ['Leave me alone', 'idk bye'];

TheQuestion[1] := ['respond', 'autoer']; // MasterKill owns
TheRespond[1] := ['what to say?', 'i dont have anything to say', 'no im busy'];

TheQuestion[2] := [Players[CurrentPlayer].nick]; // Thats your nickname, Dont change it.
TheRespond[2] := ['no', 'get lost', 'im busy', 'go away', 'let me kill my crabs thank you'];
end;

{--------------------------------- Setup end ---------------------------------}

{All credit to MasterKill for letting me use his responder!}
Function TheResponder: boolean;
var
I, II, Rand: Integer;
Text, Name: String;
begin
If Not GetLastChatText(Text) Then Exit;
For I := 0 To HowManyResponds - 1 Do
begin
For II := 0 To High(TheQuestion[I]) Do
begin
If (Pos(TheQuestion[I][II], Text) <> 0) then
begin
Status('$Making Respond');
Name := GetBlackChatMessage;
If (Pos(Players[CurrentPlayer].nick, Name) <> 0) then break;
WriteLn('Respond:');
WriteLn('/ ' + Name + ' ' + Text);
Rand := Random(High(TheRespond[I]));
TypeSend(TheRespond[I][Rand]);
WriteLn('/ ' + Players[CurrentPlayer].Name + ': ' + TheRespond[I][Rand]);
Result := True;
exit;
end;
end;
end;
end;

Function WalkToMainPoint:Boolean;
Var
T1l: Tpoint;
Begin
T1l.X := 2708 + RandomRange(0, 3) - RandomRange(0, 3);
T1l.Y := 3717 + RandomRange(0, 3) - RandomRange(0, 3);
If Not WalkToTile(T1l, 0, 0) then Exit else Result := True;
end;

Function CheckEat: Boolean;Forward;

Function DoSpec: Boolean;
var lox, loy : integer;
Begin
If Players[CurrentPlayer].Booleans[0] then
begin
GameTab(1);
If FindColorTolerance(lox, loy, 4360769, 702, 419, 713, 428, 6)then
begin
MouseBox(570, 413, 714, 431, 1);
Writeln('Toggled special attack');
Result := True;
end;
end;
end;

Procedure MightRun;
Begin
If GetMMLevels('run', C0l) > RandomRange(40, 100)Then SetRun(True);
end;

Procedure DrinkPotion;
var
Vial, xxx, yyy : Integer;
Begin
If Players[0].Booleans[1] = False Then Exit;
GameTab(4);
Vial := DTMFromString('78DA63CC616260E06664400629A9190CFF813' +
'448F43F1030A603D5B0A3AA81C8C248209D0C54C34F404D12508D' +
'10013520BBC408A8C907AA1127A0A614A84680809A62A01A1E22C' +
'C11C6AF06002DE30ABC');
If FindDTM(Vial, xxx, yyy, MIX1, MIY1, MIX2, MIY2)Then
begin
FreeDTM(Vial);
MMouse(xxx, yyy, 2, 2);
If IsUpText('Vial')Then
begin
GetMousePos(xxx, yyy);
Mouse(xxx, yyy, 0, 0, False);
If Not ChooseOption('Drop')Then Exit;
DrinkPotion;
end;
If IsUpText('Drink')Then
Begin
GetMousePos(xxx, yyy);
Mouse(xxx, yyy, 0, 0, True);
end;
end;
end;

Procedure AntiBan;
Begin
Case Random(200) of
1: HoverSkill('random', False);
2: BoredHuman;
3: MouseBox(59, 31, 647, 264, 3);
4: MouseSpeed := MouseSpeed + Random(2) - Random(2);
5, 6: CheckEat;
7,8,9,10,11 : Dospec;
12,13 : MightRun;
16,17,18,19: GameTab(RandomRange(1, 13));
20, 21 : DrinkPotion;
end;
end;

Procedure GetExp;
var
Me2: TMe;
Ci : Integer;
begin
If Players[CurrentPlayer].Integers[4] = 0 then
begin
Me2 := GetMe;
Me2.Experience[3] := Players[CurrentPlayer].Integers[4]; //Hp
Me2.Experience[0] := Players[CurrentPlayer].Integers[5]; //attack
Me2.Experience[2] := Players[CurrentPlayer].Integers[6]; // Strength
Me2.Experience[1] := Players[CurrentPlayer].Integers[7]; // Defence
Me2.Experience[4] := Players[CurrentPlayer].Integers[8]; // Range
Me2.Experience[6] := Players[CurrentPlayer].Integers[9]; // mage
Exit;
end;
Players[CurrentPlayer].Integers[3] := 0;
Me2 := GetMe;
Me2.Experience[3] := Players[CurrentPlayer].Integers[10]; //Hp
Me2.Experience[0] := Players[CurrentPlayer].Integers[11]; //attack
Me2.Experience[2] := Players[CurrentPlayer].Integers[12]; // Strength
Me2.Experience[1] := Players[CurrentPlayer].Integers[13]; // Defence
Me2.Experience[4] := Players[CurrentPlayer].Integers[14]; // Range
Me2.Experience[6] := Players[CurrentPlayer].Integers[15]; // mage
For ci:= 10 to 15 do
begin
Players[CurrentPlayer].Integers[ci] := Players[CurrentPlayer].Integers[ci] - Players[CurrentPlayer].Integers[ci - 6];
Players[CurrentPlayer].Integers[3] := Players[CurrentPlayer].Integers[3] + Players[CurrentPlayer].Integers[ci];
end;
end;

Function GetTotalHp: Integer;
begin
Result := GetSkillLevel('hp');
end;

Function CheckEat: Boolean;
Begin
i := GetMMLevels('hp', C0l);
If Hp = 0 Then Hp := GetTotalHp;
Hpex := Round(hp / 100 * RandomRange(45, 65));
If I < Hpex then
begin
Writeln('Low hp eating');
For i := 1 to 28 do
begin
If ExistsItem(i)then
begin
MMouseItem(i);
If IsUpText('Eat')then
begin
MouseItem(i, True);
Result := True;
Exit;
end else
If i = 28 then
begin
RunAway('s', True, 2, 0);
LogOut;
Exit;
end;
end;
end;
end;
end;

Function FindCrabs: Boolean;
Begin
NPCs := SortNPCs(GetNPCsByName('Rocks'));
if GetArrayLength(NPCs)=0 then NPCs := SortNPCs(GetNPCsByName('Rock Crab'));
If GetArrayLength(NPCs)=0 then Exit;
If NPCs[0].MS.X and NPCs[0].MS.Y = 0 then
Begin
If NPCs[0].Tile.X < 2693 then
begin
WalkToMainPoint;
FindCrabs;
exit;
end;
If Not WalkToTile(NPCs[0].Tile, 0, 0) Then Exit else
begin
FFlag(0);
Result := True;
Exit;
end;
end;
If NPCs[0].Name = 'Rocks' then Mouse(NPCs[0].MS.X, NPCs[0].MS.Y, 40, 40, True) else
Mouse(NPCs[0].MS.X, NPCs[0].MS.Y, 7, 7, True);
Result := True;
FFlag(0);
end;

Function NPlayersActive: Integer;
var
x, a : integer;
Begin
For x:= 0 to HowManyPlayers - 1 do
If Players[x].Active then a := a + 1;
Result := a;
end;

Procedure MaybeSleep;
var
v, h, Time: integer;
begin
Case Random(20) of

1:begin

If NPlayersActive = 1 then
begin
v := RandomRange(4, 13);
h := v;
Status('Sleeping');
MarkTime(Time);
Repeat
Writeln('Sleeping for ' + IntToStr(v) + ' minutes');
Wait(1000*60*1);
v := v - 1;
Until(TimeFromMark(Time) > 1000*60*h);
end;
end;
end;
end;

Function NChangePlayer: Boolean;
begin
If NPlayersActive > 2 then
begin
NextPlayer(True);
SetupResponds;
SetAllChats('on', 'off', '', 'off', 'off');
Retaliate(True);
Writeln('Changed player');
MightRun;
Result := True;
end;
end;

Function UnAggresiv: Boolean;
var
G : Tpoint;
Begin
If(Not(LoggedIn))Then Exit;
For i:=0 to 2 do
begin
G := GetMyPos;
G.X := G.X + RandomRange(0, 3) - RandomRange(0, 3);
G.Y := G.Y - RandomRange(10, 18);
If Not WalkToTile(G, 0, 0) Then Exit;
end;
GetExp;
LogOut;
MaybeSleep;
If NChangePlayer Then GetExp;
LogInPlayer;
SetupResponds;
SetAllChats('on', 'off', '', 'off', 'off');
MightRun;
For i:=0 to 2 do
begin
G := GetMyPos;
G.Y := G.Y + RandomRange(10, 18);
If Not WalkToTile(G, 3, 0) Then Exit;
end;
Result := True;
end;

Function IsFightRock: Boolean;
var
p: TPoint;
Me: TMe;
begin
Me := GetMe;
If Me.InFight Then
begin
NPCs2 := SortNPCs(GetNPCsByName('Rock Crab'));
p := GetMyPos
For i := 0 to High(NPCs2) do
if IntInBox(NPCs2[i].Tile.X, NPCs2[i].Tile.Y, IntToBox(p.x-1,p.y-1,p.x+1,p.y+1))then Result := True;
FTwait(2);
end;
end;

Function Fighting: Boolean;Forward;

Procedure FightWait;
Begin
FTwait(RandomRange(3, 6));
Repeat
CheckEat;
TheResponder;
FTWait(RandomRange(1, 3));
FindNormalRandoms;
AntiBan;
Until(Not(IsFightRock))
end;

Function Fighting: Boolean;
var CountMissed : Integer;
begin
If(Not(LoggedIn))Then Exit;
If FindCrabs then
Begin
MarkTime(Time);
FightWait;
If TimeFromMark(Time) < 3000 then
begin
CountMissed := CountMissed + 1;
If CountMissed > 3 then
begin
UnAggresiv;
Result := True;
Exit;
end else Exit;
end;
Result := True;
CountMissed := 0;
Players[CurrentPlayer].Integers[0] := Players[CurrentPlayer].Integers[0] + 1;
CrabsKill := CrabsKill + 1;
ReportVars[0] := ReportVars[0] + 1;
end;
end;

Function Convert(i : Integer): String;
begin
Case i of
10 : Result := ' Hitpoints';
11 : Result := ' Attack';
12 : Result := ' Strength';
13 : Result := ' Defence';
14 : Result := ' Range';
15 : Result := ' Mage';
end;
end;

Procedure ProgressReport;
var
t, b : integer;
begin
ExpGain := 0;
For t:=0 to HowManyPlayers - 1 do
ExpGain := ExpGain + Players[t].Integers[3];
ReportVars[1] := ExpGain;
SrlRandomsReport;
ClearDebug;
Writeln('[#][#][#][#][-] AntiCrabs [-][#][#][#][#]');
Writeln('[#]');
Writeln('[#] Worked for ' + TimeRunning);
Writeln('[#] with ' + IntToStr(HowManyPlayers) + ' players');
Writeln('[#] Killed about total ' + IntToStr(CrabsKill) + ' crabs!');
Writeln('[#] Making ' + IntToStr(ExpGain) + ' total exp!');
Writeln('[#] ' + IntToStr(NPlayersActive) + '/' + IntToStr(HowManyPlayers) + ' Players is still active!');
Writeln('[#]');
Writeln('[#][#][#][] More detailed report [][#][#][#]');
Writeln('[#]');
Writeln('[#] Player - Crabs killed - Exp Gained ');
For t:=0 to HowManyPlayers - 1 do
begin
Writeln('[#] #' + IntToStr(t) + ' - ' + IntToStr(Players[t].Integers[0]) + ' - ' + IntToStr(Players[t].Integers[3]));
For b:=10 to 15 do
If Players[CurrentPlayer].Integers[b] > 1 then Writeln('[#] Got ' + IntToStr(Players[CurrentPlayer].Integers[b]) + Convert(b) + ' Exp!');
end;
end;

Procedure ScriptTerminate;
Begin
ProgressReport;
Writeln('[#]');
Writeln('[#][#] Thank you for using Anti crabs! [#][#]');
end;

Procedure MainLoop;
var
q : integer;
Begin
LogInPlayer;
SetupResponds;
GetExp;
SetAllChats('on', 'off', '', 'off', 'off');
Retaliate(True);
q := 0;
MightRun;
Repeat
TheResponder;
If NPlayersActive = 0 then TerminateScript;
If(Not(LoggedIn))Then
begin
FTwait(8);
If(Not(LoggedIn))Then
NextPlayer(False);
SetupResponds;
end;
SetAngle(True);
If(not(Fighting))Then
Begin
If q > 3 then
begin
LogOut;
NChangePlayer;
MainLoop;
end;
FindNormalRandoms;
FindInventoryRandoms;
q := q + 1;
if(Not(Fighting))Then WalkToMainPoint;
If(Not(Fighting))Then
If(Not(Fighting))then
If Not UnAggresiv then LogOut;
end;
q := 0;
TheResponder;
Case Random(20) of
0,1,3: AntiBan;
2: CheckEat;
4: MightRun;
end;
Case Random(Players[CurrentPlayer].Integers[1]) of
0 : DrinkPotion;
end;
TheResponder;
GetExp;
ProgressReport;
SetupResponds;
Until(False);
end;

begin
SetupSRL;
ScriptID := '953';
DeclarePlayers;
SRLID := YourSRLID;
SRLPassword := YourSRLPassword;

If SRLID = '' then SRLID := '5963';
If SRLPassword = '' then SRLPassword := 'srlpwnsall';

SmartSetup(SmartWorld, True, True, False);
SetTargetDC(SMARTGetDC);
ClearDebug;
MainLoop;
end.


This thing have been struggling with me for 4 days straight :duh:
It changes player at random time, out of nowere it does nothing more then sitting doing nothing loginout. I cant see the problem can you?

Please also point out my stupid mistakes and make fun of me :)

Ultimate leet test can now begin :)

Method

2008-08-16 21:16:38

Have you been mousing between SCAR / SMART and other windows while your script is running? If so, the script may not find the color used to check if you're logged in while your computer loads the graphics and will actually think you're logged out. Try replacing every LoggedIn with R_LoggedIn, and see if you encounter the same problems.

If that's not the problem (as it has been for me), I'm not sure what is.

Naike

2008-08-16 21:21:46

I thought of that, But do you think it would fail 2 times in a row?

Got a wait for 3 secs then checks again…

Method

2008-08-16 21:24:30

I'm really not sure, but it's certainly possible.

n3ss3s

2008-08-17 04:34:02


If(not(Fighting))Then
Begin
If q > 3 then
begin
LogOut;
NChangePlayer;
MainLoop;
end;

Your problem might mean your script works…

Naum

2008-08-17 05:36:17

Need A Main Loop something like this:

Begin
Repeat
Repeat
DoBlah;
WalkBlah;
BankBlah;
Until(Loads >= HowManyToDo Or Not (LoggedIn));
LogOut;
If Loads >= HowManyToDo Then
Nextplayer(True)
else
NextPlayer(False);
Until(AllPlayersInactive);
end.

But In Your case I think that the part

LogOut;
If Loads >= HowManyToDo Then
Nextplayer(True)
else
NextPlayer(False);

You can put your NChangePlayer, instead.

Procedure FightWait;
Begin
FTwait(RandomRange(3, 6));
Repeat
CheckEat;
TheResponder;
FTWait(RandomRange(1, 3));
FindNormalRandoms;
AntiBan;
Until(Not(IsFightRock))
end;

You need a TimeMark there incase your IsFightRock procedure mucks up.

Yeah Looks fine apart from that.