YoHoJo
2009-11-08 02:17:38
23/07/2009: SCAR 3.21 has been released, it has many bugfixes and
some nice new features, be sure to check it out at:
http://freddy1990.com/scar.php
If you downloaded 3.21 on 22-23/07, please redownload it. I modified
it so it sends me some extra data with error reports to help debugging.
(Forums: http://freddy1990.com/forums)
(IRC: irc.dal.net #freddy1990)
(Donate: http://freddy1990.com/donate.php)
Color Picked: 0 at (370, 459)
Color Picked: 0 at (352, 647)
New client targeted
Successfully compiled (4064 ms)
Line 148: [Hint] (3102:1): Variable 'T' never used in script C:\Program Files\SCAR 3.21\includes\SRL\SRL\Core\Chat.scar
SRL Compiled in 15 msec
Successfully executed
Color Picked: 7807248 at (235, 425)
Color Picked: 7807248 at (323, -16966096)
Color Picked: 11040367 at (360, -16966113)
New client targeted
Successfully compiled (4058 ms)
Line 148: [Hint] (3102:1): Variable 'T' never used in script C:\Program Files\SCAR 3.21\includes\SRL\SRL\Core\Chat.scar
SRL Compiled in 16 msec
Trout Fish Small, with a score of 7
Necklace Big, with a score of 7
Ring Small, with a score of 9
Use: Edible, Count: 1
Use: Jewelry, Count: 2
We need to pick Trout Fish Small, and it's use is Edible and located at slot 1
Shears Small, with a score of 7
Tuna Fish Big, with a score of 7
Trout Fish Small, with a score of 7
Use: Tool, Count: 1
Use: Edible, Count: 2
We need to pick Shears Small, and it's use is Tool and located at slot 1
Tuna Fish Small, with a score of 9
Shears Big, with a score of 9
Trout Fish Small, with a score of 7
Use: Edible, Count: 2
Use: Tool, Count: 1
We need to pick Shears Big, and it's use is Tool and located at slot 2
Ring Small, with a score of 9
Necklace Big, with a score of 9
Tuna Fish Small, with a score of 7
Use: Jewelry, Count: 2
Use: Edible, Count: 1
We need to pick Tuna Fish Small, and it's use is Edible and located at slot 3
FREAKING WIN! <3
Also, no credit to me please, I simply just changed 3 colors and it worked again! Incredible! (I might have done a few other changes, so here's just my entire Quiz.Scar)
[Sarcasm I know you work hard]
Also, Devs, SHAME ON YOU YOU LAZY BAST*RDS! Get your asses working on the randoms! Seriously, just had to change 3 colors to get this one working, do you guys even try to see whats wrong with them!?[/Sarcasm I know you work hard]]
//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- ยป Quiz Routines --//
//-----------------------------------------------------------------//
// * function InQuizRandom : Boolean; // * by ZephyrsFury
// * Function QuizItemBox(Index: Integer): TBox; // * by Wizzup?
// * Procedure LoadQuizArray; // * by Wizzup?
// * Function GetQuizObjectInfo(Index: Integer): QuizObj; // * by Wizzup?
// * Function GetQuizObjectInfoAverage(Index, Times: Integer): QuizObj; // * by Wizzup?
// * Function GetQuizItem(Index: Integer): QuizObj; // * by Wizzup?
// * Procedure SolveQuizQuestion; // * by Wizzup?
// * Function SolveQuiz: Boolean; // * by Wizzup? and ZephyrsFury
// * Function FindQuiz: Boolean; // * by Wizzup?
Type
QuizObj = Record
Count, Width, Height, TotalCount: Integer;
CoverPercentage: Extended;
Name, Use: String;
End;
Var
QuizItems: Array Of QuizObj;
QuizAccuracy: Integer;
{*******************************************************************************
function InQuizRandom : Boolean;
by: ZephyrsFury
Description: Returns true if the quiz random is found.
*******************************************************************************}
function InQuizRandom : Boolean;
begin
if (InBlack) then
Result := (PercentBlackMM > 95);
end;
{*******************************************************************************
Function QuizItemBox(Index: Integer): TBox;
by: Wizzup?
Description: Returns a TBox of the Quiz Item Slow defined by Index.
*******************************************************************************}
Function QuizItemBox(Index: Integer): TBox;
Begin
Result.X1 := 46 + 174 * (Index-1);
Result.Y1 := 417;
Result.X2 := 46 + 174 * (Index-1) + 80;
Result.Y2 := 417 + 33;
End;
{*******************************************************************************
Procedure LoadQuizArray;
by: Wizzup?
Description: Loads all the data.
*******************************************************************************}
Procedure LoadQuizArray;
Begin
If Length(QuizItems) <> 0 Then
Exit;
QuizAccuracy := 100;
SetLength(QuizItems, 20);
With QuizItems[0] Do
Begin
Name := 'Trout Fish Big';
Use := 'Edible';
Count := 165;
Width := 23;
Height := 15;
TotalCount := 330;
CoverPercentage := 50.0;
End;
With QuizItems[1] Do
Begin
Name := 'Trout Fish Small';
Use := 'Edible';
Count := 105;
Width := 18;
Height := 11;
TotalCount := 205;
CoverPercentage := 52.0;
End;
With QuizItems[2] Do
Begin
Name := 'Tuna Fish Big';
Use := 'Edible';
Count := 225;
Width := 23;
Height := 15;
TotalCount := 365;
CoverPercentage := 61.0;
End;
With QuizItems[3] Do
Begin
Name := 'Tuna Fish Small';
Use := 'Edible';
Count := 140;
Width := 18;
Height := 12;
TotalCount := 220;
CoverPercentage := 63.0;
End;
With QuizItems[4] Do
Begin
Name := 'Necklace Small';
Use := 'Jewelry';
Count := 80;
Width := 17;
Height := 10;
TotalCount := 170;
CoverPercentage := 47.0;
End;
With QuizItems[5] Do
Begin
Name := 'Necklace Big';
Use := 'Jewelry';
Count := 128;
Width := 21;
Height := 13;
TotalCount := 275;
CoverPercentage := 46.0;
End;
With QuizItems[6] Do
Begin
Name := 'Ring Small';
Use := 'Jewelry';
Count := 90;
Width := 13;
Height := 9;
TotalCount := 125;
CoverPercentage := 72.0;
End;
With QuizItems[7] Do
Begin
Name := 'Ring Big';
Use := 'Jewelry';
Count := 148;
Width := 17;
Height := 12;
TotalCount := 213;
CoverPercentage := 70;
End;
With QuizItems[8] Do
Begin
Name := 'Shield Small';
Use := 'Armour';
Count := 78;
Width := 13;
Height := 8;
TotalCount := 104;
CoverPercentage := 76.0;
End;
With QuizItems[9] Do
Begin
Name := 'Shield Big';
Use := 'Armour';
Count := 123;
Width := 16;
Height := 10;
TotalCount := 172;
CoverPercentage := 71.0;
End;
With QuizItems[10] Do
Begin
Name := 'Spade';
Use := 'Tool';
Count := 95;
Width := 23;
Height := 14;
TotalCount := 304;
CoverPercentage := 31.5;
End;
With QuizItems[11] Do
Begin
Name := 'Sword Small';
Use := 'Weapon';
Count := 36;
Width := 15;
Height := 10;
TotalCount := 142;
CoverPercentage := 25.0;
End;
With QuizItems[12] Do
Begin
Name := 'Sword Big';
Use := 'Weapon';
Count := 55;
Width := 21;
Height := 13;
TotalCount := 239;
CoverPercentage := 23.0;
End;
With QuizItems[13] Do
Begin
Name := 'Shears Small';
Use := 'Tool';
Count := 122;
Width := 20;
Height := 12;
TotalCount := 243;
CoverPercentage := 50.0;
End;
With QuizItems[14] Do
Begin
Name := 'Shears Big';
Use := 'Tool';
Count := 195;
Width := 25;
Height := 16;
TotalCount := 395;
CoverPercentage := 49.0;
End;
With QuizItems[15] Do
Begin
Name := 'BattleAxe Big';
Use := 'Weapon';
Count := 108;
Width := 21;
Height := 13;
TotalCount := 275;
CoverPercentage := 38.0;
End;
With QuizItems[16] Do
Begin
Name := 'BattleAxe Big';
Use := 'Weapon';
Count := 108;
Width := 21;
Height := 13;
TotalCount := 275;
CoverPercentage := 38.0;
End;
With QuizItems[17] Do
Begin
Name := 'BattleAxe Small';
Use := 'Weapon';
Count := 68;
Width := 16;
Height := 10;
TotalCount := 171;
CoverPercentage := 40.0;
End;
With QuizItems[18] Do
Begin
Name := 'Helmet Small';
Use := 'Weapon';
Count := 246;
Width := 16;
Height := 17;
TotalCount := 285;
CoverPercentage := 85.5;
End;
With QuizItems[19] Do
Begin
Name := 'Helmet Big';
Use := 'Weapon';
Count := 388;
Width := 21;
Height := 22;
TotalCount := 465;
CoverPercentage := 83.5;
End;
End;
{*******************************************************************************
Function GetQuizObjectInfo(Index: Integer): QuizObj;
by: Wizzup?
Description: Get's the data of a QuizObj, once.
*******************************************************************************}
Function GetQuizObjectInfo(Index: Integer): QuizObj;
Var
TPA, TPA2, ObjectTPA: TPointArray;
aTPA: T2DPointArray;
SearchB, ObjB: TBox;
cts: Integer;
Begin
Cts := GetColorToleranceSpeed;
ColorToleranceSpeed(1);
SearchB := QuizItemBox(Index);
FindColorsTolerance(TPA, 7807248 , SearchB.X1, SearchB.Y1, SearchB.X2, SearchB.Y2, 35);
FindColorsTolerance(TPA2, 11040367 , SearchB.X1, SearchB.Y1, SearchB.X2, SearchB.Y2, 35);
TPA := CombineTPA(TPA, TPA2);
ObjectTPA := ReturnPointsNotInTPA(TPA, SearchB);
ObjB := GetTPABounds(ObjectTPA);
aTPA := SplitTPA(ObjectTPA, 5);
SortATPASize(aTPA, True);
If Length(aTPA) <> 0 Then
ObjectTPA := aTPA[0]
Else
SetLength(ObjectTPA, 0);
Result.Count := Length(ObjectTPA);
Result.Width := ObjB.X2 - ObjB.X1;
Result.Height := ObjB.Y2 - ObjB.Y1;
Result.TotalCount := (ObjB.X2 - ObjB.X1) * (ObjB.Y2 - ObjB.Y1);
ColorToleranceSpeed(cts);
End;
{*******************************************************************************
Function GetQuizObjectInfoAverage(Index, Times: Integer): QuizObj;
by: Wizzup?
Description: Get's the average data of a QuizObj
*******************************************************************************}
Function GetQuizObjectInfoAverage(Index, Times: Integer): QuizObj;
Var
I: Integer;
TempObjs: Array Of quizObj;
Begin
SetLength(TempObjs, Times);
For I := 0 To Times - 1 Do
Begin
tempObjs[I] := GetQuizObjectInfo(Index);
Wait(50);
End;
For I := 0 To Times - 1 Do
Begin
Result.Count := Result.Count + tempObjs[I].Count;
Result.Width := Result.Width + tempObjs[I].Width;
Result.Height := Result.Height + tempObjs[I].Height;
Result.TotalCount := Result.TotalCount + tempObjs[I].TotalCount;
End;
Result.Count := Result.Count / Times;
Result.Width := Result.Width / Times;
Result.Height := Result.Height / Times;
Result.TotalCount := Result.TotalCount / Times;
Result.CoverPercentage := Result.Count / Result.TotalCount * 100.0;
End;
{$IFDEF DebugQuiz}
{*******************************************************************************
Procedure QuizObjStats(Obj: QuizObj);
by: Wizzup?
Description: WriteLn's a QuizObj's data.
*******************************************************************************}
Procedure QuizObjStats(Obj: QuizObj);
Begin
WriteLn('Count: ' + IntToStr(Obj.Count));
WriteLn('Width: ' + IntToStr(Obj.Width));
WriteLn('Height: ' + IntToStr(Obj.Height));
WriteLn('TotalCount: ' + IntToStr(Obj.TotalCount));
WriteLn('Cover Percent: ' + FloatToStr(Obj.Count / Obj.TotalCount * 100.0));
End;
{$ENDIF}
{*******************************************************************************
Function GetQuizItem(Index: Integer): QuizObj;
by: Wizzup?
Description: Identifies a Quiz Item.
*******************************************************************************}
Function GetQuizItem(Index: Integer): QuizObj;
Var
I, maxScore, maxIndex: Integer;
theObj: QuizObj;
Scores: TIntegerArray;
Begin
theObj := GetQuizObjectInfoAverage(Index, QuizAccuracy);
{$IFDEF DebugQuiz} QuizObjStats(theObj); {$ENDIF}
SetLength(Scores, Length(QuizItems));
For I := 0 To High(QuizItems) Do
Begin
If (QuizItems[I].Width = theObj.Width) And (QuizItems[I].Height = theObj.Height) Then
Begin
Scores[I] := Scores[I] + 5;
{$IFDEF DebugQuiz} WriteLn(QuizItems[I].Name + ' are of the same width and height'); {$ENDIF}
End Else
If InRange(theObj.Width, QuizItems[I].Width - 2, QuizItems[I].Width + 2) And InRange(theObj.Height, QuizItems[I].Height - 2, QuizItems[I].Height + 2) Then
Begin
Scores[I] := Scores[I] + 3;
{$IFDEF DebugQuiz} WriteLn(QuizItems[I].Name + ' are nearly of the same width and height'); {$ENDIF}
End;
If InRange(theObj.Count, QuizItems[I].Count - 8, QuizItems[I].Count + 8) Then
Begin
Scores[I] := Scores[I] + 2;
{$IFDEF DebugQuiz} WriteLn(QuizItems[I].Name + '''s object Count is in range.'); {$ENDIF}
End;
If InRange(theObj.TotalCount, QuizItems[I].TotalCount - 8, QuizItems[I].TotalCount + 8) Then
Begin
Scores[I] := Scores[I] + 2;
{$IFDEF DebugQuiz} WriteLn(QuizItems[I].Name + '''s object TotalCount is in range.'); {$ENDIF}
End;
If (theObj.CoverPercentage > QuizItems[I].CoverPercentage - 3) And (theObj.CoverPercentage < QuizItems[I].CoverPercentage + 3) Then
Begin
Scores[I] := Scores[I] + 2;
{$IFDEF DebugQuiz} WriteLn(QuizItems[I].Name + '''s object TotalCount is in range.'); {$ENDIF}
End;
{$IFDEF DebugQuiz}
if Scores[I] > 0 Then
WriteLn(QuizItems[I].Name + ' has a final score of ' + IntToStr(Scores[I]));
{$ENDIF}
End;
maxScore := -1;
maxIndex := -1;
For I := 0 To High(Scores) Do
Begin
If Scores[I] > maxScore Then
Begin
maxScore := Scores[I];
maxIndex := I;
End;
End;
//WriteLn('The winner: ' + QuizItems[maxIndex].Name + ', with a score of ' + IntToStr(Scores[maxIndex]));
WriteLn(QuizItems[maxIndex].Name + ', with a score of ' + IntToStr(Scores[maxIndex]));
Result.Name := QuizItems[maxIndex].Name;
Result.Use := QuizItems[maxIndex].Use;
End;
{*******************************************************************************
Procedure SolveQuizQuestion;
by: Wizzup?
Description: Solves one question of the quiz.
*******************************************************************************}
Procedure SolveQuizQuestion;
Var
I, II, Count: Integer;
Found: Boolean;
ObjInfo: Array [0..2] Of QuizObj;
theUsesNames: TStringArray;
theUsesCount: TIntegerArray;
itemBox: TBox;
Begin
Try
Found := False;
For I := 0 To 2 Do
ObjInfo[I] := GetQuizItem(I + 1);
For I := 0 To 2 Do
Begin
For II := 0 To High(theUsesNames) Do
If ObjInfo[I].Use = theUsesNames[II] Then
Begin
Found := True;
Break;
End;
If Found Then
theUsesCount[II] := theUsesCount[II] + 1
Else
Begin
SetLength(theUsesNames, Length(theUsesNames) + 1);
SetLength(theUsesCount, Length(theUsesCount) + 1);
theUsesNames[High(theUsesNames)] := ObjInfo[I].Use;
theUsesCount[High(theUsesCount)] := 1;
End;
Found := False;
End;
II := -1;
Count := -1;
For I := 0 To High(theUsesNames) Do
Begin
WriteLn('Use: ' + theUsesNames[I] + ', Count: ' + IntToStr(theUsesCount[I]));
If theUsesCount[I] > Count Then
Begin
Count := theUsesCount[I];
II := I;
End;
End;
For I := 0 To 2 Do
If ObjInfo[I].Use <> theUsesNames[II] Then
Break;
WriteLn('We need to pick ' + ObjInfo[I].Name + ', and it''s use is ' + ObjInfo[I].Use + ' and located at slot ' + IntToStr(I + 1));
itemBox := QuizItemBox(I + 1);
Mouse(itemBox.X1 + 5, ItemBox.Y1 + 5, itemBox.X2 - itemBox.X1 - 5, itemBox.Y2- itemBox.Y1 - 5, True);
Except
End;
End;
{*******************************************************************************
Function SolveQuiz: Boolean;
by: Wizzup? and ZephyrsFury
Description: Solves the quiz random and returns true if solved.
*******************************************************************************}
Function SolveQuiz: Boolean;
Var
TimeMarker: LongInt;
X, Y: Integer;
Begin
Result := False;
LoadQuizArray;
TimeMarker := GetSystemTime;
While GetSystemTime - TimeMarker < 300000 Do
Begin
if (FindColor(X, Y, 65535, MCX1, MCY1, MCX2, MCY2)) then
begin
SolveQuizQuestion;
Wait(2000 + Random (1000));
end;
ClickContinue(True, True);
if (PercentBlackMM < 95) then
begin
Result := True;
Exit;
end;
End;
End;
{*******************************************************************************
Function FindQuiz: Boolean;
by: Wizzup?
Description: Solves the quiz random and returns true if solved.
*******************************************************************************}
Function FindQuiz: Boolean;
Begin
LoadQuizArray;
Players[CurrentPlayer].Rand := 'Quiz';
Wait(10000);
If SolveQuiz Then
Result := True
Else
Begin
Result := False;
Players[CurrentPlayer].Active := False;
Players[CurrentPlayer].Rand := 'NoQuiz';
Repeat
Wait(1000);
Until Not LoggedIn;
End;
End;
