YoHoJo
2009-12-21 01:44:30
Const FullDebug = True; //Debug it all?
M_DefaultHeight = 62; //Molly's Height (Used in M_FindMS)
M_CrossColor = 2438909; //The crosshair color, should be fine..
Var
MollyColors : TIntegerArray; //Variables
M_TileWidth : Extended;
M_CrossPoint : TPoint;
Type
TMollyControl = Record //Molly record.
Direction : (Up, Down, _Right, _Left);
Times : Byte;
End;
{*******************************************************************************
Function Molly_CrosshairPos(Var Cross : TPoint; Inn : TBox) : Boolean
by: ***
Description: Finds the position of the crosshair.
*******************************************************************************}
Function Molly_CrosshairPos(Var Cross : TPoint; Inn : TBox) : Boolean;
Var TPA : TPointArray;
Begin //Finds cross colors
FindColorsTolerance(TPA, M_CrossColor, Inn.x1, Inn.y1, Inn.x2, Inn.y2, 5)
If FullDebug Then
WriteLn('Length of Cross Count = '+IntToStr(Length(TPA)));
If Length(TPA) > 0 Then
Begin
Cross := MiddleTPA(TPA);
If FullDebug Then
WriteLn('Cross found at '+IntToStr(Cross.X)+', '+IntToStr(Cross.Y));
Result := True;
Exit;
End Else
If FullDebug Then
WriteLn('Cross not found');
End;
{*******************************************************************************
Procedure Molly_FindMS(Var Molly : TPoint);
by: ***
Description: Finds the position of molly on the main screen
*******************************************************************************}
Procedure Molly_FindMS(Var Molly : TPoint);
Label Begining;
Var //
ATPA : T2DPointArray;
TPA : TPointArray;
I, II : Integer;
P : TPoint;
NotFound : Boolean;
AddOn : Integer;
Begin
Begining : I := 0;
SetLength(ATPA, Length(MollyColors)); //sets length the same as colors
For I := 0 To High(MollyColors) Do
FindColors(ATPA[I], MollyColors[I], MSX1, MSY1, MSX2, MSY2); //finds colors
TPA := MergeATPA(ATPA); //Merges all the seperate TPA's into one
ATPA := TPAToATPA(TPA, 20); //20 radius circles
For I := 0 To High(ATPA) Do
Begin
If FullDebug Then WriteLn('Found '+IntToStr(Length(ATPA))+' Similars.');
If Not InAbstractBox(400, 8, 503, 0, 514, 96, 500, 130, ATPA[I][0].X, ATPA[I][0].Y) Then //Removes problem points for l-brown
If GetArraylength(ATPA[I]) >= 3 Then //length check
Begin
P := MiddleTPA(ATPA[I]);
Begin
If FullDebug Then
WriteLn('Molly found at index '+IntToStr(I));
// \/ Mollys height
For II := 0 To 3 Do
If PointInBox(P, IntToBox(0, II * 30, 520, ((II + 1) * 30) + (Integer(II = 3)*10) )) Then
AddOn := M_DefaultHeight + ((II - 1) * (10 - II));
If AddOn = 52 Then
DecEx(AddOn, 8);
Molly := Point(P.x, P.y + AddOn);
If FullDebug Then
WriteLn('Molly found at '+IntToStr(Molly.X)+', '+IntToStr(Molly.Y));
DebugATPA(ATPA, '');
If FullDebug Then
WriteLn('Mollys Height is : '+IntToStr(AddOn));
Exit;
End;
NotFound := (I >= 3);
If NotFound Then Break;
End;
End;
If NotFound Then
GoTo Begining;
End;
{*******************************************************************************
Function IsMollyOnDot(CP : TPoint) : Boolean;
by: ***
Description: Results true if molly is standing on dot.
*******************************************************************************}
Function IsMollyOnDot(CP : TPoint) : Boolean;
Var MollysPosition : TPoint;
Begin
Molly_FindMS(MollysPosition); //If some of the points are inrange of mollys feet
Result := (PointInBox(MollysPosition, IntToBox(Cp.x - 6, Cp.y - 6, Cp.x + 6, Cp.y + 6)))
Or (InRange(iAbs(CP.X - MollysPosition.X), 0, 7) And InRange(iAbs(CP.Y - MollysPosition.Y), 0, 7));
End;
{*******************************************************************************
Function Molly_PtsToCtrl(Point1, Point2 : TPoint; Vertical : Boolean) : TMollyControl;
by: ***
Description: Turns the two points (crosshair and molly) into directions.
*******************************************************************************}
Function Molly_PtsToCtrl(Point1, Point2 : TPoint; Vertical : Boolean) : TMollyControl;
Begin
Case Vertical Of //determines direction
True : If (Point1.y - Point2.y) < 0 Then
Result.Direction := Up
Else
Result.Direction := Down;
//determines direction
False : If (Point1.x - Point2.x) > 0 Then
Result.Direction := _Left
Else
Result.Direction := _Right;
End;
M_TileWidth := 33.8; //default for sideways
If Result.Direction = Down Then M_TileWidth := 24.3; //greater width
If Result.Direction = Up Then M_TileWidth := 17.9;
If FullDebug Then
WriteLn('Tile Width (perspective) is: '+FloatToStr(M_TileWidth));
Result.Times := Round(Distance(Point1.x, Point1.y, Point2.x, Point2.y) / M_TileWidth); //number of times to move
If FullDebug Then
If Vertical Then
WriteLn('This means that the crosshair must be moved '+IntToStr(Result.Times)+' Up/Down ')
Else
WriteLn('This means that the crosshair must be moved '+IntToStr(Result.Times)+' Left/Right ')
End;
{*******************************************************************************
Procedure Molly_Operate(Information : TMollyControl);
by: *** and Wizzup
Description: Clicks a direction based on the input
*******************************************************************************}
Procedure Molly_Operate(Information : TMollyControl);
Var I : Byte;
Mark : Integer;
Begin
I := 0; //operating proc
Mark := GetSystemTime + 2800; //timeout to avoid spasms
Repeat
If FindBlackChatMessage('win') Or FindBlackChatMessage('Evil') Or ClickContinue(False, False) Then
Exit;
If Information.Times = 0 Then
Exit;
If IsMollyOnDot(M_CrossPoint) Or (M_CrossPoint.X = 0) Then
Exit;
Case Information.Direction Of //co-ords taken from wizzups
Up : Mouse(RandomRange(630, 650), RandomRange(260, 275), 0, 0, True); // Up
Down : Mouse(RandomRange(627, 655), RandomRange(383, 411), 0, 0, True); // Down
_Right : Mouse(RandomRange(705, 720), RandomRange(315, 340), 0, 0, True); // Right
_Left : Mouse(RandomRange(563, 583), RandomRange(323, 341), 0, 0, True); // Left
End;
Inc(I);
Until(I >= Information.Times) Or (Mark < GetSystemTime);
End;
{*******************************************************************************
Procedure Molly_MoveCrossTo;
by: ***
Description: Moves the crosshair to molly
*******************************************************************************}
Procedure Molly_MoveCrossTo;
Var MollyP: TPoint;
Point3 : TPoint;
Begin // gets pos of crosshair
Molly_CrosshairPos(M_CrossPoint, IntToBox(MSX1, MSY1, 515, 200));
If Not IsMollyOnDot(M_CrossPoint) Then
Begin
Molly_FindMS(MollyP); //finds molly
Point3 := Point(MollyP.x, M_CrossPoint.y); //completes the r-a triangle
Molly_Operate(Molly_PtsToCtrl(M_CrossPoint, Point3, False)); //proc
Molly_Operate(Molly_PtsToCtrl(MollyP, Point3, True)); //proc
Wait(250 + Random(30));
End;
End;
{*******************************************************************************
Function SolveMolly : Boolean;
by: Wizzup and ***
Description: Solves the Molly Random
*******************************************************************************}
Function SolveMolly : Boolean;
Label IfNot_CivilianCaught;
Var P : TPoint;
T, Tries, MolMark, I, TX, TY : Integer;
MCaught : Boolean;
CTS : Byte;
Begin
SetAngle(True);
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
Players[CurrentPlayer].Rand := 'Molly';
MarkTime(MolMark);
If InConvo Then
MollyColors := GetColorsBox(41, 374, 84, 382, True); //GetColorsBox(42, 372, 60, 385, True); light brown
For I := 0 To Random(7) Do
ClickContinue(True, True);
SetRun(False);
If FindMollyDoor(P) Then
Mouse(P.X, P.Y, 0, 0, True)
Else
Begin
WriteLn('Molly : Could NOT Open Door');
ColorToleranceSpeed(CTS);
Result := False;
Exit;
End;
Begin
I := 0;
Repeat
Wait(740 + Random(100));
Inc(I);
FindNPCChatText('now', ClickLeft);
ClickContinue(True, True);
Until(I >= 8 + Random(2));
End;
Wait(1);
Begin
If FindObjTPAMulti(P.x, P.y, [2379300, 4015557, 3697078, 5140596], 15, -1, 20,
20, 10, ['ontr', 'anel', 'se']) Then
Mouse(P.X, P.Y, 0, 0, True)
Else
Begin
WriteLn('Molly : Could NOT Find Machine');
ColorToleranceSpeed(CTS);
Result := False;
Exit;
End;
End;
I := 0;
While (I < 10) Do
Begin
Wait(1000 + Random(200));
Inc(I);
If GetColor(561, 221) = 6918288 Then
Break;
End;
If GetColor(561, 221) = 6918288 Then
Begin
If FindText(TX, TY, 'Tries', SmallChars, 555, 216, 600, 240) Then
Tries := StrToInt(GetNumbers(GetTextAtEx(TX, TY, 0, SmallChars,
False, False, 0, 1, 6918288, 50, False, tr_AllChars)));
If Tries = 0 Then
Tries := 2;
T := GetSystemTime + 120000; //2 minutes timeout.
IfNot_CivilianCaught :
While Not (MCaught) And (T > GetSystemTime) Do
Begin
Molly_MoveCrossTo;
Molly_CrosshairPos(P, IntToBox(MSX1, MSY1, 515, 200));
If IsMollyOnDot(P) Then
Begin
Mouse(700, 423, 10, 10, True);
Wait(1000 + Random(1000));
End;
If Tries = 0 Then
Begin
WriteLn('Tries are finished, we were not able to get the twin');
Exit;
End;
If FindBlackChatMessage('win') Or FindBlackChatMessage('Evil') Or ClickContinue(False, False) Then
Begin
WriteLn('We got the Twin.');
MCaught := True;
Break;
End;
If FindBlackChatMessage('cent') Or FindBlackChatMessage('illian') Then
Begin
WriteLn('We Caught a Civilian.');
Dec(Tries);
MCaught := False;
Break;
End;
If FindBlackChatMessage('target!') Or FindBlackChatMessage('upposed') Then
Begin
MCaught := False;
Break;
End;
Result := (GetSystemTime > T);
End;
If Not MCaught Then GoTo IfNot_CivilianCaught;
If GetSystemTime > T Then
Begin
Result := False;
WriteLn('Could NOT find Molly!');
ColorToleranceSpeed(CTS);
Players[CurrentPlayer].Loc := 'NoMolly';
Exit;
End;
If MCaught Then
Begin
WriteLn('Found Molly in ' +IntToStr(TimeFromMark(MolMark))+' msec!');
Wait(20000);
T := GetSystemTime;
While (GetSystemTime - T < 15000) Do
Begin
If Not ClickContinue(True, True) Then
Break;
Wait(1000);
End;
If Not FindMollyDoor(P) Then
Begin
ColorToleranceSpeed(CTS);
Exit;
End;
Mouse(P.X, P.Y, 0, 0, True);
Wait(10000);
If FindObjTPAMulti(P.X, P.Y, MollyColors, 5, -1, 6, 8, 4,
['alk', 'olly']) Then
Mouse(P.X, P.Y, 0, 0, True);
Wait(5000);
T := GetSystemTime;
While (GetSystemTime - T < 15000) Do
Begin
If Not ClickContinue(True, True) Then
Break;
Wait(1000);
End;
Result := True;
If Result Then
Begin
WriteLn('Solved Molly Random Event.');
Wait(10000);
ColorToleranceSpeed(CTS);
End;
End;
End;
End;Point System:
* Individuality (75)
* Presentation (75)
* Technique & Creativity (100)
* Reliability (125)
* Efficiency & Simplicity (150)