SCAR Code:
{.Script Info:
# ScriptName = Sandstorm's Auto Dueler
# Author = Sandstorm
# Description = Auto accepts and waits until duel is over
# Version = 1.6
# Date = Dec, 17th, 2007 (initial release, remake: November 29, 2008)
# Comments = Err... None.
/Script Info
Credits:
Camo Kyle for doing just about everything that we could think
of to help. He's spent much of his free time in the past few weeks
helping me, and I don't think I could have made this script function as
well as it does without him helping me and commenting on what I could do
to make it better.
N1ke! for his UseSpecial function.
Narcle for his SpecialPercent function.
Thanks to Floor66 for his UpdateScript function}
Program DuelTrainer;
{.include SRL/SRL.scar}
Const
AllowArmorOff = False; //Allow other people to turn armor off?
AllowRuleChange = False; //Allow other people to turn on/off rules?
Multiplayer = False; //Use more then one player? IMPORTANT TO FILL OUT.
Lag = False; //Do you lag? Increases waittimes if so.
AddToWaits = 1500; //How much to add to the waits, if Lag = true.
SRLStatsID = ''; // Your stats id
SRLStatsPass = ''; // Your stats password
CurrentVersion = '1.6'; // DO NOT TOUCH THIS!
Var
x, y, wins, lost, duels, marking, lagwait, denied, Duelscreendtm, dtm, duels2, CurrentDuels, CurrentWins, CurrentLosses, Currentdenied: Integer;
First : Boolean;
procedure DeclarePlayers;
begin
HowManyPlayers :=1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
Players[0].Name := ''; //username
Players[0].Pass := ''; //password
Players[0].Nick := ''; //3-4 letters from your username
Players[0].Active := True; //Use this character or not?
Players[0].integers[0]:=10; //Duels before switching
Players[0].integers[1]:=20; //How much your special attack takes
Players[0].booleans[0]:=True; //Use special attack?
End;
Procedure ScriptTerminate;
Begin
Disguise('Won: ' + IntToStr(wins) + ' Lost: ' + IntToStr(lost));
End;
Function ArmorOff : Boolean;
Begin
Result := FindColorTolerance(x, y, 114, 71, 55, 251, 259, 5);
End;
Function Challenge : Boolean;
Begin
DTM := DTMFromString('78DA637CCCC0C0709C0105FC9F210FA619A17' +
'CC6B7986A6000AEE635903843C09C4740E22CAA1A4F071354358A' +
'40D64954351E76C6286A0038C70C9C');
Result := FindDtm(DTM, x, y, MSX1, MSY1, MSX2, MSY2);
FreeDtm(dtm);
End;
Function FindTextSand(Text: string; Chars, x1, y1, x2, y2: Integer): Boolean; Forward;
Function Duel : Boolean;
Begin
Result := FindTextSand('duel with you (f', SmallChars, MSX1, MSY1, MSX2, MSY2);
End;
Function DuelScreen(Second : Boolean) : Boolean;
Var
X, Y : Integer;
Begin
Case Second Of
True : Result := FindDtm(DuelScreenDtm, x, y, 162, 288, MSX2, MSY2);
False : Result := FindDtm(DuelScreenDtm, x, y, MSX1, MSY1, 228, 297);
End;
End;
Function Accept : Boolean;
Begin
Result := FindText(x, y, 'aiting for other', SmallChars, MSX1, MSY1, MSX2, MSY2);
End;
Function Accept2 : Boolean;
Begin
Result := FindText(x, y, 'aiting for other', SmallChars, MSX1, MSY1, MSX2, MSY2);
End;
Function Fighting : Boolean;
Var
I : Integer;
ColorsToUse : Array of Integer;
Begin
wait(100 + random(500));
ColorsToUse := [8946705, 6382604, 9205778, 9405202, 8482576, 8944913, 6840077, 8422416, 8882961, 9339410, 9142033];
For I:=0 To GetArrayLength(ColorsToUse)-1 Do
Begin
wait(100 + random(500));
Result := Not FindColorTolerance(x, y, ColorsToUse[i], MMX1, MMY1, MMX2, MMY2, 3) And Not FindColorTolerance(x, y, 244, MMX1, MMY1, MMX2, MMY2, 15) And Not FindSymbol(x, y, 'altar') and Not FindSymbol(x, y, 'minigame') and not FindSymbol(x, y, 'bank') and not FindSymbol(x, y, 'minigame');
wait(100 + random(500));
If Not Result Then
Break;
End;
End;
Function Changes : Boolean;
Begin
Result := FindColorTolerance(x, y, 665, 269, 54, 314, 247, 5);
End;
Function Won : Boolean;
Begin
DTM := DTMFromString('78DA636C62646090056264D000A160A28C738' +
'02C3922D4281350D30C6429E15703007FC604CE');
Result := FindDtm(DTM, x, y, MSX1, MSY1, MSX2, MSY2);
FreeDtm(dtm);
End;
Procedure SandWait(Time : Integer; Condition : Boolean);
Var
TimeMark : Integer;
Begin
MarkTime(TimeMark);
Repeat
Begin
If Condition Then
Exit
Else
Wait(1);
End;
Until(TimeFromMark(TimeMark) >= Time)
End;
Procedure Part2; Forward;
Procedure Part4; Forward;
Procedure FunDuel;
Var
DuelMsg : String;
Begin
If Duelscreen(false) Then
Part2;
If Fighting Then
Part4;
Case random(6) Of
0 : DuelMsg:= ('funning all');
1 : DuelMsg:= ('fun dueling');
2 : DuelMsg:= ('funning everyone');
3 : DuelMsg:= ('dueling for fun');
4 : DuelMsg:= ('funning');
5 : DuelMsg:= ('funning anyone');
End;
TypeSend(AddMistakes(DuelMsg, 30));
wait(100 + random(500))
End;
function SpecialPercent: integer;
var
z: Integer;
TPA: TPointArray;
begin
GameTab(1);
z := GetColorToleranceSpeed;
ColorToleranceSpeed(1);
FindColorsTolerance(TPA, 2985515, 572, 427, 712, 428, 80);
ColorToleranceSpeed(z);
result := Round(GetArrayLength(TPA) / 283.0 * 100.0);
end;
Function SpecialActive : Boolean;
Begin
Result := FindColor(x, y, 65535, 571, 413, 716, 429);
End;
Function CheckVers : Boolean;
Begin
Result := Between('<p>', '</p>', GetPage('http://lalalacheckvers.110mb.com/CheckVersion.txt')) = CurrentVersion;
End;
Procedure ProgressReporting;
Begin
ClearDebug;
Duels := Wins + Lost;
CurrentWins := Wins - CurrentWins;
ReportVars[0] := CurrentWins;
CurrentLosses := Lost - CurrentLosses;
ReportVars[1] := CurrentLosses;
CurrentDuels := Duels - CurrentDuels;
ReportVars[2] := CurrentDuels;
Currentdenied := Denied - CurrentDenied;
ReportVars[3] := CurrentDenied;
WriteLn('You won: ' + IntToStr(Wins) + ' duels.');
WriteLn('You lost: ' + IntToStr(Lost) + ' duels.');
WriteLn('You have dueled: ' + IntToStr(Duels) + ' times.');
WriteLn('You have denied ' + IntToStr(Denied) + ' duels');
WriteLn('The script has been running for: ' + TimeRunning);
WriteLn('Thanks for using the Duel Arena Trainer by Sandstorm!');
SRLRandomsReport;
Marktime(Marking);
If First Then
First := False;
SetTimeOut(300000, 'ProgressReporting');
End;
Function UseSpecial(PowerNeed: Integer):Boolean;
begin
Gametab(1);
If not SpecialActive Then
If SpecialPercent >= PowerNeed then
begin
MouseBox(574, 417, 710, 426, 1);
Result := True;
end;
end;
function FindTextSand(Text: string; Chars, x1, y1, x2, y2: Integer): Boolean;
var
Mask, w, h, tx, ty: Integer;
begin
try
Mask:= CreateBitmapMaskFromText(Text, Chars);
wait(100 + random(500));
except
srl_Warn('ClickText', 'Invalid Character Names', warn_AllVersions);
Exit;
end;
Result:= FindBitmapMaskTolerance(Mask, tx, ty, x1, y1, x2, 502, 10, 10);
wait(100 + random(500));
GetBitmapSize(Mask, W, H);
wait(00 + random(500));
FreeBitmap(Mask);
wait(100 + random(500));
end;
Procedure Part4;
Begin
While Accept2 or Duelscreen(true) Do
Begin
Wait(1000);
If Fighting Then
Break;
If Not Accept2 and Duelscreen(true) Then
MouseBox(181, 302, 235, 317, 1);
SandWait(lagwait + 1000 + random(500), Fighting);
End;
Disguise('Fighting!');
While Fighting Do
Begin
If Players[currentplayer].booleans[0] Then
UseSpecial(Players[currentplayer].integers[1]);
wait(1000 + random(500));
End;
Disguise('Out of fight.');
If Won and not Fighting Then
Begin
Disguise('We won!');
MouseBox(359, 278, 437, 294, 1);
Inc(Wins);
Inc(Duels2);
If First Then
If TimeFromMark(Marking) >= 300000 Then
ProgressReporting;
End else
Begin
Disguise('We lost!');
Inc(Lost);
Inc(Duels2);
If TimeFromMark(Marking) >= 300000 Then
ProgressReporting;
End;
End;
Procedure Part1; Forward;
Procedure HandleRulesAndChanges;
Begin
If Changes and Not Accept and Not AllowRuleChange or ArmorOff and Not AllowArmorOff Then
Begin
MouseBox(313, 273, 379, 286, 1);
Denied := Denied + 1;
wait(lagwait + 1000 + random(500));
Part1;
End else
Begin
While Not Accept and Duelscreen(false) Do
Begin
MouseBox(147, 277, 208, 284, 1);
wait(lagwait + 1000 + random(500));
If Not Duelscreen(false) and not Duelscreen(true) Then
Part1;
End;
End;
End;
Procedure Part3;
Begin
SandWait(lagwait + 1000 + random(500), Duelscreen(true));
If Duelscreen(true) Then
Begin
Disguise('At part three!');
MouseBox(181, 302, 235, 317, 1);
wait(lagwait + 1000 + random(500));
Part4;
End;
End;
Procedure Part2;
Begin
While Duelscreen(false) Do
Begin
If Not Duelscreen(false) Then
Part1;
Disguise('At part two!');
If not Changes and not AllowRuleChange or not ArmorOff or not AllowArmorOff Then
Begin
If Duelscreen(true) Then
Part3;
HandleRulesAndChanges;
If Duelscreen(false) Then
MouseBox(147, 277, 208, 284, 1);
End Else
HandleRulesAndChanges;
SandWait(lagwait + 1000 + random(500), Duelscreen(true));
End;
Part3;
End;
Procedure HandleDuel;
Var
A : Integer;
Begin
If Duelscreen(false) Then
Exit;
Mousebox(293, 484, 335, 499, 1);
While Not Duelscreen(false) And Not Accept Do
Begin
If A >= 3 Then
Part1;
If Challenge Then
Begin
MouseBox(199, 192, 312, 209, 1);
wait(1000 + random(500));
Mousebox(8, 482, 53, 500, 1);
wait(1000 + random(500));
Part1;
End;
Mousebox(15, 443, 238, 452, 1);
A := A + 1;
SandWait(lagwait + 1000 + random(500), Duelscreen(false) or Fighting);
End;
Mousebox(8, 482, 53, 500, 1);
End;
Procedure Part1;
Begin
Disguise('Searching for a dueler!');
While not Duelscreen(false) or not Challenge Do
Begin
If Duel or Duelscreen(false) Then
Begin
If Duel Then
HandleDuel;
SandWait(1000 + random(500), Duelscreen(false));
If Duelscreen(false) Then
Begin
Part2;
End else
Part1;
End;
wait(1000 + random(500))
If Fighting Then
Part4;
wait(100 + random(500));
If Won Then
Begin
Inc(Wins);
Inc(Duels2);
MouseBox(359, 278, 437, 294, 1);
End;
If Duel or Duelscreen(false) Then
Begin
If Duel Then
HandleDuel;
SandWait(1000 + random(500), Duelscreen(false));
If Duelscreen(false) Then
Begin
Part2;
End else
Part1;
End;
wait(100 + random(500));
If Challenge Then
MouseBox(199, 192, 312, 209, 1);
wait(100 + random(500));
If not Duel Then
FunDuel
Else
HandleDuel;
End;
wait(2000 + random(500));
Part2;
End;
{*******************************************************************************
Function UpdateScript(Name, UpdateWebsite, Version: String): Boolean;
by: Floor66
Description: Auto-updates (any) script.
You _need_ to make a const like:
Const
Version = '1.00'; // MUST BE A STRING!
*******************************************************************************}
Function UpdateScript(Name, UpdateWebsite, Version: String): Boolean;
Var
Script, NewVersion : String;
NewS : Integer;
Begin
Script := GetPage(UpdateWebsite);
If Script <> '' Then
Begin
NewVersion := Between('Version = ', ' ', Script);
WriteLn('Script version: '+ Version);
WriteLn('Latest version: '+ NewVersion);
If Not (Version = NewVersion) Then
Begin
WriteLn('Getting the latest script...');
NewS := RewriteFile(AppPath + 'Scripts\'+ Name +'.scar', False);
If WriteFileString(NewS, Script) Then
Begin
WriteLn('Successfully updated script to v'+ NewVersion +'!');
Result := True;
Exit;
End;
End;
End Else
Begin
WriteLn('Failed to get script.');
Result := False;
Exit;
End;
End;
Begin
SetupSRL;
If CheckVers Then
Disguise('Your up to date, continuing!')
Else
Begin
UpdateScript('SSDuelArena', 'http://lalalacheckvers.110mb.com/SSDuelArena.scar', CurrentVersion);
WriteLn('Please reload this script; it has been updated!');
TerminateScript;
End;
If SRLStatsId = '' Then
SRLId := SRLStatsId
Else
SRLID := '6348';
If SRLStatsPass = '' Then
SRLPassword:= SRLStatsPass
Else
SRLID := 'heyhey';
Scriptid := '1101';
DuelScreenDtm := DTMFromString('78DA63BCC7C8C0E005C4C8E00C84828932BE0' +
'5B23C08A8390B6479A2A9614055030065680518');
MarkTime(Marking);
Declareplayers;
If Not Loggedin Then
LoginPlayer;
Case Lag Of
True : Lagwait := AddToWaits;
False : Lagwait := 0;
End;
Case Multiplayer Of
False : Repeat
Part1;
If Not LoggedIn Then
Break;
Until(AllPlayersInactive);
True : Repeat
Duels2 := 0;
Repeat
Part1;
If Not LoggedIn Then Break;
Until(Players[currentplayer].integers[0] = duels2)
If LoggedIn Then
NextPlayer(True)
Else
NextPlayer(False);
Until(AllPlayersInactive)
End;
End.