Is this script a little old? Cleaned up standards and commented out the old stats and SMART procedure.
Script After Changes -
program WT_Experiment;
{$DEFINE SMART}
{.include SRL/SRL.scar}
const
TheFood = 'lobster'; // <- one choice for now: 'lobster'
VersionNumber = '0.24';
VeryLowDefence = False; // If set to true will not attack Experiment Level-51
Fawkidebug = False;
LegitLogOutTime = 4; // Timeout in minutes for logout (pauze) for legit
UseCamUpDown = False; // If set, moves cam down for wider range. I have this on by default
{ MySRLID = ' '; //<- Your SRLID. Leave blank if you dont have one.
MySRLPassword = ' '; //<- Your SRL Password here if you want to have yout stats logged}
//----------------------------------------------------------------------------//
procedure DeclarePlayers;
begin
NumberOfPlayers(1);
CurrentPlayer := 0;
with Players[0] do
begin
Name := '';
Pass := '';
Nick := '';
Active := True;
end;
end;
//----------------------------------------------------------------------------//
type
TWall = record
Point: TPoint;
Dist: integer;
end;
var
Food, FoodLeft, FoodHeals, Damage, Start, WallArrayIndex,
LegitTimeOut, LegitLogOut, Dist2Legit, WalkedAwayFromLegits,
WallColor, ExperimentsKilled: integer;
LegitFlag, FirstCheck, ForceEdgeCheck: boolean;
NPCColors: array[1..16] of integer;
CombatLevels: array[1..8] of integer;
WallArray: array of Integer;
Wall: array[0..3] of TWall;
P1, P2: Tpoint;
//----------------------------------------------------------------------------//
procedure Quit(reason: string);
begin
WriteLn('QUIT: ' + reason + ' QUIT');
Logout;
TerminateScript;
end;
//----------------------------------------------------------------------------//
procedure FTWait(time: integer);
var
x: integer;
begin
for x := 0 to time do
begin
Wait(100 + Random(100));
FindNormalRandoms;
end;
if (not (Loggedin)) then
Quit('Logged Out');
end;
//----------------------------------------------------------------------------//
// -- Performs FlagWait and FindTalk....
//----------------------------------------------------------------------------//
function FlagFTWait: boolean;
var
FlagMark: integer;
begin
MarkTime(FlagMark);
if (not (FlagPresent)) then
begin
Result := False;
Exit;
end else
begin
repeat
FTWait(1);
if (not (Loggedin)) then
Break;
until ((not (FlagPresent)) or (TimeFromMark(FlagMark) > 6000)); // waits until flag is gone or 6 seconds.
Result := True;
Wait(250);
end;
end;
//----------------------------------------------------------------------------//
procedure SetFood(WhatFood: string);
begin
case WhatFood of
'lobster': begin
Food := BitmapFromString(10, 13, 'beNpjYMAD/v//j5WNJ' +
'oIpBRGEADwm45HFJUW5LC41BL1DqizWEMAeLABkblmn');
FoodHeals := 12;
end;
'anyotherfood': begin
Food := BitmapFromString(10, 13, 'beNpjYMAD/v//j5WNJ' +
'oIpBRGEADwm45HFJUW5LC41BL1DqizWEMAeLABkblmn');
FoodHeals := 9;
end;
end;
end;
//----------------------------------------------------------------------------//
procedure SetupColors;
begin
NPCColors[1] := 10283742; // sheep
NPCColors[2] := 7642575; // spider
NPCColors[3] := 10217948;
NPCColors[4] := 2901605;
NPCColors[5] := 7251613;
NPCColors[6] := 6983870;
NPCColors[7] := 10086105;
NPCColors[8] := 1854556;
NPCColors[9] := 9888213;
NPCColors[10] := 2967655;
NPCColors[11] := 10283742;
NPCColors[12] := 2571608;
NPCColors[13] := 9492685;
NPCColors[14] := 7906263;
NPCColors[15] := 10547427;
NPCColors[16] := 7379401;
end;
//----------------------------------------------------------------------------//
procedure ProgressReport;
begin
ClearDebug;
WriteLn(' ');
WriteLn('<=== ========== - Progress Report V' + VersionNumber + '===============>');
WriteLn('Worked for ' + TimeRunning + '. ');
WriteLn('Killed ' + IntToStr(ExperimentsKilled) + ' Experiments');
WriteLn('XP Gained = ' + IntToStr(ExperimentsKilled * 400));
WriteLn('Walked away from Legits: ' + IntToStr(WalkedAwayFromLegits) + ' Times');
WriteLn('Logged out for Legits : ' + IntToStr(LegitLogOut) + ' Times');
WriteLn('WallColor = ' + IntToStr(WallColor));
WriteLn(' ');
WriteLn('Start Attack Level = ' + IntToStr(Combatlevels[1]));
WriteLn('Start Strength Level = ' + IntToStr(Combatlevels[2]));
WriteLn('Start Defence Level = ' + IntToStr(Combatlevels[3]));
WriteLn('Start Constitution Level = ' + IntToStr(Combatlevels[4]));
WriteLn('Current Attack Level = ' + IntToStr(Combatlevels[5]));
WriteLn('Current Strength Level = ' + IntToStr(Combatlevels[6]));
WriteLn('Current Defence Level = ' + IntToStr(Combatlevels[7]));
WriteLn('Current Constitution Level = ' + IntToStr(Combatlevels[8]));
WriteLn(' ');
end;
//----------------------------------------------------------------------------//
// Performss Arrow up/down/left/right : Time + Random(Time * 2)
//----------------------------------------------------------------------------//
procedure Arrow(Direction: string; Time: integer);
var
Dir: byte;
begin
if UseCamUpDown then // what a wonderful bypass
begin
case LowerCase(Direction) of
'down', 'd': Dir := VK_DOWN;
'up', 'u': Dir := VK_UP;
'left', 'l': Dir := VK_LEFT;
'right', 'r': Dir := VK_RIGHT;
end;
KeyDown(dir);
Wait(Time + Random(Time * 2));
KeyUp(dir);
end;
end;
//----------------------------------------------------------------------------//
// Search for color by drawing circle roung MM edges. Return last Color found.
//----------------------------------------------------------------------------//
function GetRoadEdge(RFrom, RTo: integer): Tpoint;
var
Mx, My, Cx, Cy, i: integer;
begin
if RFrom > RTo then
begin
for i := RFrom downto RTo do
begin
Cx := Round(76 * Sin(i * Pi / 180)) + 627;
Cy := Round(-76 * Cos(i * Pi / 180)) + 85;
FindColor(Mx, My, WallColor, Cx, Cy, Cx + 16, Cy + 16);
end;
end else
begin
for i := RFrom to RTo do
begin
Cx := Round(76 * Sin(i * Pi / 180)) + 627;
Cy := Round(-76 * Cos(i * Pi / 180)) + 85;
FindColor(Mx, My, WallColor, Cx - 16, Cy - 16 , Cx, Cy);
end;
end;
Result.x := Mx;
Result.y := My;
end;
//----------------------------------------------------------------------------//
// Returns True if the wallopening is on top of the screen.
//----------------------------------------------------------------------------//
function CloseEnough: boolean;
begin
if ForceEdgeCheck then
begin
P1 := GetRoadEdge(0, 180);
P2 := GetRoadEdge(360, 180);
end;
Status('P1 = '+ IntToStr(P1.x) + ' ' + IntToStr(P1.y));
Status('P2 = '+ IntToStr(P2.x) + ' ' + IntToStr(P2.y));
if (P1.y > P2.y - 30) and (P1.y < P2.y + 30) then // 30 pixels apart on the vertical axes
begin
Status('CLoseEnough Returned True');
Result := True;
Exit;
end else
Status('CLoseEnough Returned FALSE');
end;
//----------------------------------------------------------------------------//
// Turns Map until wallopening is on top of the screen.
//----------------------------------------------------------------------------//
function CallToMid: boolean;
var
TimeOut: integer;
begin
TimeOut := GetSystemTime;
while (not (CloseEnough)) do
begin
if (Random(2) = 1) then
Arrow('l', 100)
else
Arrow('r', 100);
FTWait(1);
if ((TimeOut + 1000) < GetSystemTime) then
Exit;
end;
Status('CalToMid Returned True');
Result := True;
end;
//----------------------------------------------------------------------------//
// Returns WallColor! Works always. Hasn't failed me once.
//----------------------------------------------------------------------------//
function GetWallColor: integer;
var
c, x, y, tol, TCCounter, TCColorIndex: integer;
RefWallColors: array[0..3] of integer;
TC: array[0..10] of array[0..1] of integer;
begin
RefWallColors[0] := 15461361;
RefWallColors[1] := 15988988;
RefWallColors[2] := 15332584;
RefWallColors[3] := 15070968;
for tol := 0 to 25 do
begin
for c := 0 to 3 do
begin
if FindColorCircleTolerance(x, y, RefWallColors[c], MMCx, MMCy, 76, tol) then
begin
SetArrayLength(WallArray, WallArrayIndex + 1);
WallArray[WallArrayIndex] := GetColor(x, y);
Inc(WallArrayIndex);
end
end;
end;
BubbleSort(WallArray);
for c := 1 to GetArrayLength(WallArray) - 1 do
begin
if (WallArray[c] = WallArray[c - 1]) then
begin
TC[TCColorIndex][0] := WallArray[c];
TC[TCColorIndex][1] := TCCounter;
Inc(TCCounter);
end else
Inc(TCColorIndex);
end;
for c := 0 to 9 do
begin
if (TC[c][1] > TC[c + 1][1]) then // replace result until highest count.
Result := TC[c][0]; // return highest count color.
end;
Status('WallColor := '+ IntToStr(Result));
end;
//----------------------------------------------------------------------------//
// Returns Distance to the four walls N-E-S-W.
//----------------------------------------------------------------------------//
procedure GetWalls;
var
x, y: integer; // fill clockwise 3[0]-6[1]-9[2]-12[3] hours
begin
for x := MMCx to MMx2 do
if FindColor(Wall[0].Point.x, Wall[0].Point.y, WallColor, x, MMCy - 2, x + 4, MMCy + 2) then
Break;
for y := MMCy to MMy2 do
if FindColor(Wall[1].Point.x, Wall[1].Point.y, WallColor, MMCx - 2, y, MMCx + 2, y + 4) then
Break;
for x := MMCx downto MMx1 do
if FindColor(Wall[2].Point.x, Wall[2].Point.y, WallColor, x, MMCy - 2, x + 4, MMCy + 2) then
Break;
for y := MMCy downto MMy1 do
if FindColor(Wall[3].Point.x, Wall[3].Point.y, WallColor, MMCx - 2, y, MMCx + 2, y + 4) then
Break;
end;
//----------------------------------------------------------------------------//
// Returns True if Wall South is closest i.e. we are with our back the wall and looking in the arena
//----------------------------------------------------------------------------//
function IsWallBehind: boolean;
var
c, SmallDist: integer;
begin
GetWalls;
for c := 0 to 3 do
begin
if ((Wall[c].Point.x <> 0) and (Wall[c].Point.y <> 0)) then
begin
Wall[c].Dist := Distance(MMCx, MMCy, Wall[c].Point.x, Wall[c].Point.y);
Status('ISWALLBEHIND: Wall ' + IntToStr(c + 1) + ' Distance = ' + IntToStr(Wall[c].Dist));
end;
end;
SmallDist := 100;
for c := 0 to 3 do
begin
if Wall[c].Dist <> 0 then
begin
if (SmallDist > Wall[c].Dist) then
SmallDist := Wall[c].Dist;
end;
end;
Status('ISWALLBEHIND: SmallDist = ' + IntToStr(SmallDist));
if (SmallDist = Wall[1].Dist) then // is wall below MMCentre?
begin
Result := True;
Status('SmallDist Returned TRUE');
end;
end;
//----------------------------------------------------------------------------//
// Returns distsance of Wall South.
//----------------------------------------------------------------------------//
function WallDist: integer;
var
c, SmallDist: integer; // fill clockwise 3[0]-6[1]-9[2]-12[3] hours
begin
GetWalls;
for c := 0 to 3 do
begin
if ((Wall[c].Point.x <> 0) and (Wall[c].Point.y <> 0)) then
begin
Wall[c].Dist := Distance(MMCx, MMCy, Wall[c].Point.x, Wall[c].Point.y);
Status('WALDIST: Wall ' + IntToStr(c + 1) + ' Distance = ' + IntToStr(Wall[c].Dist));
end;
end;
SmallDist := 100;
for c := 0 to 3 do
begin
if (Wall[c].Dist <> 0) then
begin
if (SmallDist > Wall[c].Dist) then
SmallDist := Wall[c].Dist;
end;
end;
Status('WALDIST: SmallDist = '+ IntToStr(SmallDist));
if (SmallDist = Wall[1].Dist) then // is wall below MMCentre?
begin
Result := SmallDist;
Status('SmallDist Returned TRUE');
end;
end;
//----------------------------------------------------------------------------//
// Rotates towards the arena
//----------------------------------------------------------------------------//
procedure TurnAwayFromWall;
var
TimeOut, LR: integer;
begin
TimeOut := GetSystemTime;
LR := Random(2);
if (LR = 0) then
KeyDown(VK_LEFT)
else
KeyDown(VK_RIGHT);
repeat
Wait(100);
if ((TimeOut + 5000) < GetSystemTime) then
begin
if (LR = 0) then
KeyUp(VK_LEFT)
else
KeyUp(VK_RIGHT);
Exit;
end;
until IsWallBehind;
if (LR = 0) then
KeyDown(VK_LEFT)
else
KeyDown(VK_RIGHT);
end;
//----------------------------------------------------------------------------//
function HaveFood(var Lx, Ly: integer): boolean;
var
Dx, Dy: integer;
begin
GameTab(Tab_Inv);
FoodLeft := CountItems('bitmap', Food, [20]);
if FindBitmapMaskTolerance(Food, Dx, Dy, MIX1, MIY1, MIX2, MIY2, 20, 20) then
begin
Lx := Dx;
Ly := Dy;
if FawkiDebug then
WriteLn('HaveFood returded True');
Result := True;
end else
begin
if FawkiDebug then
WriteLn('HaveFood returded False');
end;
end;
procedure CheckCBLevels;
begin
if FirstCheck then
begin
CombatLevels[1] := GetSkillLevel('attack');
CombatLevels[2] := GetSkillLevel('strength');
CombatLevels[3] := GetSkillLevel('defence');
CombatLevels[4] := GetSkillLevel('hitpoints');
CombatLevels[5] := CombatLevels[1];
CombatLevels[6] := CombatLevels[2];
CombatLevels[7] := CombatLevels[3];
CombatLevels[8] := CombatLevels[4];
FirstCheck := False
end else
begin
CombatLevels[5] := GetSkillLevel('attack');
CombatLevels[6] := GetSkillLevel('strength');
CombatLevels[7] := GetSkillLevel('defence');
CombatLevels[8] := GetSkillLevel('hitpoints');
end;
end;
//----------------------------------------------------------------------------//
function CheckAndRestoreHealth: boolean;
var
Lx, Ly, HPAmount: integer;
HPColor: string;
begin
HPAmount := GetMMlevels('hp', hpcolor);
Damage := (((Combatlevels[8] * 10) - HPAmount) / 10);
if FawkiDebug then
Writeln('Damage = ' + IntToStr(Damage));
Result := True;
if (Damage > 40) then
begin
if FawkiDebug then
Writeln('skipped because impossible damage');
Result := True;
Exit;
end;
if (Damage >= FoodHeals) then
begin
if HaveFood(Lx, Ly) then
begin
Mouse(Lx, Ly, 4, 4, True);
FTWait(4);
CheckAndRestoreHealth;
end else
Result := False;
end;
end;
//----------------------------------------------------------------------------//
procedure RunAway2;
begin
RunAway('N', True, 1, 8000);
if FawkiDebug then
Writeln('RunAway2');
Logout;
Terminatescript;
end;
function FindClosestNPC(how: string): TPoint;
var
i, Cx, Cy, Dist, Fx, Fy: integer;
begin
if (how = 'in') then
begin
for Dist := 5 to 62 do
begin
for i := 160 to 520 do
begin
Cx := Round(Dist * Sin(i * Pi / 180)) + MMCx;
Cy := Round(-Dist * Cos(i * Pi / 180)) + MMCy;
if FindColor(Fx, Fy, 195836, Cx, Cy, Cx + 1, Cy + 1) then
begin
Result.x := Fx;
Result.y := Fy;
Exit;
end;
end;
end;
end;
if how = 'out' then
begin
for Dist := 62 downto 5 do
begin
for i := 160 to 520 do
begin
Cx := Round(Dist * Sin(i * Pi / 180)) + MMCx;
Cy := Round(-Dist * Cos(i * Pi / 180)) + MMCy;
if FindColor(Fx, Fy, 195836, Cx, Cy, Cx + 1, Cy + 1) then
begin
Result.x := Fx;
Result.y := Fy;
Exit;
end;
end;
end;
end;
end;
//----------------------------------------------------------------------------//
procedure ClickMMNPC(how: string);
var
TheNPC: TPoint;
begin
TheNPC := FindClosestNPC(how);
Mouse(TheNPC.x, TheNPC.y, 4, 4, True);
FFlag(20);
end;
//----------------------------------------------------------------------------//
function FindLegit: boolean;
var
i, Cx, Cy, Fx, Fy, Dist: integer;
begin
if (not (FindColor(Fx, Fy, 16711422, MMx1, MMy1, MMx2, MMy2))) then
begin
Result := False;
Exit;
end;
for Dist := 5 to 62 do
begin
for i := 0 to 360 do
begin
i := i + 10;
Cx := Round(Dist * Sin(i * Pi / 180)) + MMCx;
Cy := Round(-Dist * Cos(i * Pi / 180)) + MMCy;
if FindColor(Fx, Fy, 16711422, Cx, Cy, Cx + 1, Cy + 1) then // legit dot color
begin
//Result := True;
Dist2Legit := Distance(MMCx, MMCy, Fx, Fy);
if (Dist2Legit < 20) then
begin
ClickMMNPC('out');
Result := True;
Exit;
end;
Status('Dist to Legit = ' + IntToStr(Dist2Legit));
if LegitFlag then
begin
if ((LegitTimeOut + (LegitLogOutTime * 60000)) < GetSystemTime) then
begin
Writeln(IntToStr(LegitLogOutTime) + ' minutes in neigbourhood with Legit. Logging out for 10 mins');
LogOut;
Wait(10 * 60000);
LoginPlayer;
WallColor := GetWallColor;
Inc(LegitLogOut);
LegitTimeOut := GetSystemTime;
Exit;
end;
end else
LegitTimeOut := GetSystemTime;
if (Dist2Legit < 60) then // Legit anywhere in MM.
begin
LegitFlag := True;
Respond;
end else
begin
LegitFlag := False;
Status('LEGITS around. Accpetable Distance');
end;
Exit;
end;
end;
end;
LegitFlag := False;
end;
//----------------------------------------------------------------------------//
function IsFullHit: boolean;
var
x, y, FullHit: integer;
begin
FullHit := BitmapFromString(2, 5, 'beNrjYLbhgKJKBgYgmYtEOgIAL/ADSg==');
Result := FindBitMapToleranceIn(FullHit, x, y, 100, 70, 410, 257, 20);
if FawkiDebug then
WriteLn('IsFullHit returned ' + BoolToStr(Result));
FreeBitmap(FullHit);
end;
//----------------------------------------------------------------------------//
function WTDamage: boolean;
var
hpcolor: string;
begin
if (Combatlevels[8] <> (GetMMlevels('hp', hpcolor))) then
Result := True;
end;
//----------------------------------------------------------------------------//
function FindExperimentOLD: boolean;
var
CBx, CBy, GCIndex, Dumx, Dumy, MSBx1, MSBy1, MSBx2, MSBy2, MSBox: integer;
SkipBox: Tbox;
begin
if (not (HaveFood(Dumx, Dumy))) then
begin
Quit('Out of Food');
end;
SkipBox.x1 := 213;
SkipBox.y1 := 95;
SkipBox.x2 := 276;
SkipBox.y2 := 202;
CBx := MSx2;
CBy := MSy2;
for MSBox := 0 to 9 do
begin
case MSBox of
0, 2, 4: begin
MSBx1 := 294;
MSBy1 := 130;
MSBx2 := MSx2 - 2;
MSBy2 := MSy2 - 2;
Status('Searching in Box 1');
end; // 3-6 hour
1, 3, 5: begin
MSBx1 := MSx1;
MSBy1 := 130;
MSBx2 := 220;
MSBy2 := MSy2 - 2;
Status('Searching in Box 2');
end; // 6 - 9 hour
6, 8: begin
MSBx1 := 294;
MSBy1 := MSy1;
MSBx2 := MSx2 - 2;
MSBy2 := 180;
Status('Searching in Box 3');
end; // 12 - 3 hour
7, 9: begin
MSBx1 := MSx1;
MSBy1 := MSy1;
MSBx2 := 250;
MSBy2 := 180;
Status('Searching in Box 4');
end; // 9 - 12 hour
end;
for GCIndex := 1 to 16 do
begin
Wait(50 + Random(50));
if FawkiDebug then
WriteLn('GC = ' + IntToStr(GCIndex));
if FindColorTolerance(CBx, CBy, NPCColors[GCIndex], MSBx1, MSBy1, MSBx2, MSBy2, 3) then
begin
MMouse(CBx, CBy, 0, 0);
Wait(10);
if FindColorTolerance(Dumx, Dumy, 318168, 42, 8, 120, 21, 50) then // Yellow
begin
if VeryLowDefence then
begin
if IsUpText('25') then
begin
Mouse(CBx, CBy, 0, 0, False);
if ChooseOption('Experiment') then
begin
Result := True;
FlagFTWait;
Exit;
end;
end else
Result := False;
end else
begin
Mouse(CBx, CBy, 0, 0, False);
if ChooseOption('Experiment') then
begin
Result := True;
FlagFTWait;
Exit;
end else
Result := False;
end;
end;
end;
end;
end;
end;
//----------------------------------------------------------------------------//
function FindExperiment: boolean;
var
CBx, CBy, GCIndex, Dumx, Dumy: integer;
begin
if (not (HaveFood(Dumx, Dumy))) then
begin
Quit('Out of Food');
end;
for GCIndex := 1 to 16 do
begin
if FawkiDebug then
Writeln('GC = ' + IntToStr(GCIndex));
if FindColorTolerance(CBx, CBy, NPCColors[GCIndex], MSx1, MSy1, MSx2, MSy2, 3) then
begin
MMouse(CBx, CBy, 0, 0);
Wait(75 + Random(50));
if FindColorTolerance(Dumx, Dumy, 318168, 42, 8, 120, 21, 50) then // Yellow
begin
if VeryLowDefence then
begin
if IsUpText('25') then
begin
Mouse(CBx, CBy, 0, 0, False);
if ChooseOption('Experiment') then
begin
Result := True;
FlagFTWait;
Exit;
end;
end else
Result := False;
end else
begin
Mouse(CBx, CBy, 0, 0, False);
if ChooseOption('Experiment') then
begin
Result := True;
FlagFTWait;
Exit;
end else
Result := False;
end;
end;
end;
end;
end;
//----------------------------------------------------------------------------//
function WaitExperiment: boolean;
var
TimeOut: integer;
begin
TimeOut := GetSystemTime;
repeat
if ((GetSystemTime - TimeOut) > 90000) then
begin
if FawkiDebug then
Writeln('Timeout 1 1/2 minute Break out from WaitExperiment');
Result := False;
Exit;
end;
FindNonInventoryRandoms;
if FindLegit then
begin
Inc(WalkedAwayFromLegits);
Break;
end;
if (not (CheckAndRestoreHealth)) then
begin
Quit('Out of Food');
end;
if ClickContinue(False, False) then
begin
CheckCBLevels;
end;
until IsFullHit;
Result := True;
Inc(ExperimentsKilled);
FTWait(8); // wait for yellow NPCpoint to go away;
end;
//----------------------------------------------------------------------------//
procedure Setup;
//var
// i: integer;
begin
ColorToleranceSpeed(1);
ClearDebug;
SetupSRL;
SetupColors;
DeclarePlayers;
//if MySRLID <> '' then
//begin
//SRLID := MySRLID;
//SRLPassword := MySRLPassword;
//end;
//for I := 0 to 19 do
//ReportVars[I] := 0;
//ReportVars[12] := 1;
//ScriptID := '264';
GraphicsSet := True;
LoginPlayer;
SetChat('Hide', 1);
SetRun(True);
SetAngle(True);
MouseSpeed := 40;
Start := GetSystemTime;
GameTab(Tab_Inv);
SetFood(TheFood);
FirstCheck := True;
CheckCBLevels;
WallColor := GetWallColor;
ProgressReport;
end;
//----------------------------------------------------------------------------//
//----------------------------------------------------------------------------//
//----------------------------------------------------------------------------//
begin
//SmartsetupEx(170, true, true, false);
//SetTargetDC(SmartGetDC);
Setup;
repeat
if FindExperiment then
begin
if WaitExperiment then
ProgressReport;
end else
begin
ClickMMNPC('in');
if FindExperiment then
begin
if WaitExperiment then
ProgressReport;
end else
begin
TurnAwayFromWall;
if FindExperiment then
begin
if WaitExperiment then
ProgressReport
end else
ClickMMNPC('out');
end
end;
if FindLegit then
ClickMMNPC('out');
until(False);
end.
Diff -
2c2
< {.include SRL/SRL/Misc/Smart.scar}
---
> {$DEFINE SMART}
5,23c5,11
< var
< Food, FoodLeft, FoodHeals, Damage: Integer;
< Start: Integer;
< LegitFlag, FirstCheck, ForceEdgeCheck: Boolean;
< LegitTimeOut, LegitLogOut, Dist2Legit, WalkedAwayFromLegits: Integer;
< WallColor: Integer;
< ExperimentsKilled: Integer;
< NPCColors: array[1..16] of integer;
< CombatLevels: array[1..8] of integer;
<
<
< Const TheFood = 'lobster'; // <- one choice for now: 'lobster'
< VersionNumber = '0.24';
< VeryLowDefence = False; // If set to true will not attack Experiment Level-51
< Fawkidebug = False;
< MySRLID = ' '; //<- Your SRLID. Leave blank if you dont have one.
< MySRLPassword = ' '; //<- Your SRL Password here if you want to have yout stats logged
< LegitLogOutTime = 4; // Timeout in minutes for logout (pauze) for legit
< UseCamUpDown = False; // If set, moves cam down for wider range. I have this on by default
---
> const
> TheFood = 'lobster'; // <- one choice for now: 'lobster'
> VersionNumber = '0.24';
> VeryLowDefence = False; // If set to true will not attack Experiment Level-51
> Fawkidebug = False;
> LegitLogOutTime = 4; // Timeout in minutes for logout (pauze) for legit
> UseCamUpDown = False; // If set, moves cam down for wider range. I have this on by default
25,39d12
< var
< WallArray: Array of Integer;
< WallArrayIndex: Integer;
<
< var
< P1, P2: Tpoint;
<
< type
< TWall = Record
< Point: TPoint;
< Dist: Integer;
< end;
<
< var
< Wall: array[0..3] of TWall;
40a14,15
> { MySRLID = ' '; //<- Your SRLID. Leave blank if you dont have one.
> MySRLPassword = ' '; //<- Your SRL Password here if you want to have yout stats logged}
43c18
< Procedure DeclarePlayers;
---
> procedure DeclarePlayers;
48,51c23,29
< Players[0].Name :='';
< Players[0].Pass :='';
< Players[0].Nick :='';
< Players[0].Active := True;
---
> with Players[0] do
> begin
> Name := '';
> Pass := '';
> Nick := '';
> Active := True;
> end;
56c34,53
< procedure Quit(reason:String);
---
> type
> TWall = record
> Point: TPoint;
> Dist: integer;
> end;
>
> var
> Food, FoodLeft, FoodHeals, Damage, Start, WallArrayIndex,
> LegitTimeOut, LegitLogOut, Dist2Legit, WalkedAwayFromLegits,
> WallColor, ExperimentsKilled: integer;
> LegitFlag, FirstCheck, ForceEdgeCheck: boolean;
> NPCColors: array[1..16] of integer;
> CombatLevels: array[1..8] of integer;
> WallArray: array of Integer;
> Wall: array[0..3] of TWall;
> P1, P2: Tpoint;
>
> //----------------------------------------------------------------------------//
>
> procedure Quit(reason: string);
58c55
< writeln('QUIT: '+ reason + ' QUIT');
---
> WriteLn('QUIT: ' + reason + ' QUIT');
65c62
< procedure FTWait(time:Integer);
---
> procedure FTWait(time: integer);
67c64
< x:integer;
---
> x: integer;
69,74c66,72
< for x := 0 to time do
< begin
< Wait(100 + Random(100));
< FindNormalRandoms;
< end;
< If Not Loggedin then Quit('Logged Out');
---
> for x := 0 to time do
> begin
> Wait(100 + Random(100));
> FindNormalRandoms;
> end;
> if (not (Loggedin)) then
> Quit('Logged Out');
81,82c79,81
< function FlagFTWait:Boolean;
< var FlagMark: Integer;
---
> function FlagFTWait: boolean;
> var
> FlagMark: integer;
85c84
< if not FlagPresent then
---
> if (not (FlagPresent)) then
87c86
< Result:=False;
---
> Result := False;
89,90c88
< end
< else
---
> end else
94,96c92,95
< if not(Loggedin) then break;
< until ( (not FlagPresent) or (TimeFromMark(FlagMark) > 6000) ); // waits until flag is gone or 6 seconds.
< Result:=True;
---
> if (not (Loggedin)) then
> Break;
> until ((not (FlagPresent)) or (TimeFromMark(FlagMark) > 6000)); // waits until flag is gone or 6 seconds.
> Result := True;
103c102
< procedure SetFood(WhatFood:String);
---
> procedure SetFood(WhatFood: string);
106,107c105
< 'lobster':
< Begin
---
> 'lobster': begin
109,113c107,110
< 'oIpBRGEADwm45HFJUW5LC41BL1DqizWEMAeLABkblmn');
< FoodHeals := 12;
< End;
< 'anyotherfood':
< Begin
---
> 'oIpBRGEADwm45HFJUW5LC41BL1DqizWEMAeLABkblmn');
> FoodHeals := 12;
> end;
> 'anyotherfood': begin
115,117c112,114
< 'oIpBRGEADwm45HFJUW5LC41BL1DqizWEMAeLABkblmn');
< FoodHeals := 9;
< End;
---
> 'oIpBRGEADwm45HFJUW5LC41BL1DqizWEMAeLABkblmn');
> FoodHeals := 9;
> end;
125d121
<
142c138,139
< end;
---
> end;
>
146c143
< Begin
---
> begin
149,167c146,163
< WriteLn('<=== ========== - Progress Report V' + VersionNumber+ '===============>');
< writeln('Worked for ' + TimeRunning + '. ');
< writeln('Killed '+ IntToStr(ExperimentsKilled) + ' Experiments');
< writeln('XP Gained = '+ IntToStr(ExperimentsKilled * 400));
< writeln('Walked away from Legits: '+ IntToStr(WalkedAwayFromLegits) + ' Times');
< writeln('Logged out for Legits : '+ IntToStr(LegitLogOut) + ' Times');
<
< writeln('WallColor = ' + IntToStr(WallColor));
< Writeln(' ');
< writeln('Start Attack Level = '+ IntToStr(Combatlevels[1]));
< writeln('Start Strength Level = '+ IntToStr(Combatlevels[2]));
< writeln('Start Defence Level = '+ IntToStr(Combatlevels[3]));
< writeln('Start Constitution Level = '+ IntToStr(Combatlevels[4]));
< writeln('Current Attack Level = '+ IntToStr(Combatlevels[5]));
< writeln('Current Strength Level = '+ IntToStr(Combatlevels[6]));
< writeln('Current Defence Level = '+ IntToStr(Combatlevels[7]));
< writeln('Current Constitution Level = '+ IntToStr(Combatlevels[8]));
< Writeln(' ');
< End;
---
> WriteLn('<=== ========== - Progress Report V' + VersionNumber + '===============>');
> WriteLn('Worked for ' + TimeRunning + '. ');
> WriteLn('Killed ' + IntToStr(ExperimentsKilled) + ' Experiments');
> WriteLn('XP Gained = ' + IntToStr(ExperimentsKilled * 400));
> WriteLn('Walked away from Legits: ' + IntToStr(WalkedAwayFromLegits) + ' Times');
> WriteLn('Logged out for Legits : ' + IntToStr(LegitLogOut) + ' Times');
> WriteLn('WallColor = ' + IntToStr(WallColor));
> WriteLn(' ');
> WriteLn('Start Attack Level = ' + IntToStr(Combatlevels[1]));
> WriteLn('Start Strength Level = ' + IntToStr(Combatlevels[2]));
> WriteLn('Start Defence Level = ' + IntToStr(Combatlevels[3]));
> WriteLn('Start Constitution Level = ' + IntToStr(Combatlevels[4]));
> WriteLn('Current Attack Level = ' + IntToStr(Combatlevels[5]));
> WriteLn('Current Strength Level = ' + IntToStr(Combatlevels[6]));
> WriteLn('Current Defence Level = ' + IntToStr(Combatlevels[7]));
> WriteLn('Current Constitution Level = ' + IntToStr(Combatlevels[8]));
> WriteLn(' ');
> end;
173c169
< Procedure Arrow(Direction:String; Time:Integer);
---
> procedure Arrow(Direction: string; Time: integer);
175c171
< Dir:Byte;
---
> Dir: byte;
177,188c173,184
< if UseCamUpDown then // what a wonderful bypass
< begin
< case LowerCase(Direction) of
< 'down','d' : Dir := VK_DOWN;
< 'up','u' : Dir := VK_UP;
< 'left','l' : Dir := VK_LEFT;
< 'right','r': Dir := VK_RIGHT;
< end;
< KeyDown(dir);
< Wait(Time + Random(Time * 2));
< KeyUp(dir);
< end;
---
> if UseCamUpDown then // what a wonderful bypass
> begin
> case LowerCase(Direction) of
> 'down', 'd': Dir := VK_DOWN;
> 'up', 'u': Dir := VK_UP;
> 'left', 'l': Dir := VK_LEFT;
> 'right', 'r': Dir := VK_RIGHT;
> end;
> KeyDown(dir);
> Wait(Time + Random(Time * 2));
> KeyUp(dir);
> end;
195,196c191
< Function GetRoadEdge(RFrom, RTo:Integer):Tpoint;
<
---
> function GetRoadEdge(RFrom, RTo: integer): Tpoint;
198,199c193
< Mx, My, Cx, Cy,i :Integer;
<
---
> Mx, My, Cx, Cy, i: integer;
201c195,197
< if RFrom > RTo then
---
> if RFrom > RTo then
> begin
> for i := RFrom downto RTo do
203,210c199,205
< for i := RFrom downto RTo do
< begin
< Cx := Round( 76 * Sin(i * Pi / 180)) + 627;
< Cy := Round(- 76 * Cos(i * Pi / 180)) + 85;
< FindColor(Mx, My, WallColor, Cx, Cy , Cx + 16, Cy + 16);
< end;
< end
< else
---
> Cx := Round(76 * Sin(i * Pi / 180)) + 627;
> Cy := Round(-76 * Cos(i * Pi / 180)) + 85;
> FindColor(Mx, My, WallColor, Cx, Cy, Cx + 16, Cy + 16);
> end;
> end else
> begin
> for i := RFrom to RTo do
212,217c207,209
< for i := RFrom to RTo do
< begin
< Cx := Round( 76 * Sin(i * Pi / 180)) + 627;
< Cy := Round(- 76 * Cos(i * Pi / 180)) + 85;
< FindColor(Mx, My, WallColor, Cx - 16 , Cy - 16 , Cx, Cy);
< end;
---
> Cx := Round(76 * Sin(i * Pi / 180)) + 627;
> Cy := Round(-76 * Cos(i * Pi / 180)) + 85;
> FindColor(Mx, My, WallColor, Cx - 16, Cy - 16 , Cx, Cy);
219,220c211,213
< Result.x := Mx;
< Result.y := My;
---
> end;
> Result.x := Mx;
> Result.y := My;
227c220
< Function CloseEnough:Boolean;
---
> function CloseEnough: boolean;
229,243c222,235
< if ForceEdgeCheck then
< begin
< P1 := GetRoadEdge(0,180);
< P2 := GetRoadEdge(360,180);
< end;
< Status('P1 = '+ IntToStr(P1.x) + ' ' + IntToStr(P1.y));
< Status('P2 = '+ IntToStr(P2.x) + ' ' + IntToStr(P2.y));
< if (P1.y > P2.y - 30) and (P1.y < P2.y + 30) then // 30 pixels apart on the vertical axes
< begin
< Status('CLoseEnough Returned True');
< Result := True;
< Exit;
< end
< else
< Status('CLoseEnough Returned FALSE');
---
> if ForceEdgeCheck then
> begin
> P1 := GetRoadEdge(0, 180);
> P2 := GetRoadEdge(360, 180);
> end;
> Status('P1 = '+ IntToStr(P1.x) + ' ' + IntToStr(P1.y));
> Status('P2 = '+ IntToStr(P2.x) + ' ' + IntToStr(P2.y));
> if (P1.y > P2.y - 30) and (P1.y < P2.y + 30) then // 30 pixels apart on the vertical axes
> begin
> Status('CLoseEnough Returned True');
> Result := True;
> Exit;
> end else
> Status('CLoseEnough Returned FALSE');
250c242
< Function CallToMid:Boolean;
---
> function CallToMid: boolean;
252,253c244
< TimeOut:Integer;
<
---
> TimeOut: integer;
255,263c246,258
< TimeOut := GetSystemTime;
< while not CloseEnough do
< begin
< If Random(2) = 1 then Arrow('l', 100) else Arrow('r', 100);
< FTWait(1);
< if TimeOut + 1000 < GetSystemTime then Exit;
< end;
< Status('CalToMid Returned True');
< Result := True;
---
> TimeOut := GetSystemTime;
> while (not (CloseEnough)) do
> begin
> if (Random(2) = 1) then
> Arrow('l', 100)
> else
> Arrow('r', 100);
> FTWait(1);
> if ((TimeOut + 1000) < GetSystemTime) then
> Exit;
> end;
> Status('CalToMid Returned True');
> Result := True;
270c265
< function GetWallColor: Integer;
---
> function GetWallColor: integer;
272,274c267,274
< c, x, y, tol, TCCounter, TCColorIndex: Integer;
< RefWallColors: array[0..3] of Integer;
< TC : array[0..10] of array[0..1] of Integer;
---
> c, x, y, tol, TCCounter, TCColorIndex: integer;
> RefWallColors: array[0..3] of integer;
> TC: array[0..10] of array[0..1] of integer;
> begin
> RefWallColors[0] := 15461361;
> RefWallColors[1] := 15988988;
> RefWallColors[2] := 15332584;
> RefWallColors[3] := 15070968;
276,297c276,278
< begin
< RefWallColors[0] := 15461361;
< RefWallColors[1] := 15988988;
< RefWallColors[2] := 15332584;
< RefWallColors[3] := 15070968;
<
< for tol := 0 to 25 do
< begin
< for c := 0 to 3 do
< begin
< if FindColorCircleTolerance(x, y, RefWallColors[c], MMCx, MMCy, 76, tol) then
< begin
< SetArrayLength(WallArray, WallArrayIndex + 1);
< WallArray[WallArrayIndex] := GetColor(x,y);
< Inc(WallArrayIndex);
< end
< end;
< end;
<
< BubbleSort(WallArray);
<
< for c := 1 to GetArrayLength(WallArray) - 1 do
---
> for tol := 0 to 25 do
> begin
> for c := 0 to 3 do
299,306c280,285
< if WallArray[c] = WallArray[c - 1] then
< begin
< TC[TCColorIndex][0] := WallArray[c];
< TC[TCColorIndex][1] := TCCounter;
< Inc(TCCounter);
< end
< else
< Inc(TCColorIndex);
---
> if FindColorCircleTolerance(x, y, RefWallColors[c], MMCx, MMCy, 76, tol) then
> begin
> SetArrayLength(WallArray, WallArrayIndex + 1);
> WallArray[WallArrayIndex] := GetColor(x, y);
> Inc(WallArrayIndex);
> end
307a287
> end;
308a289
> BubbleSort(WallArray);
310c291,293
< for c := 0 to 9 do
---
> for c := 1 to GetArrayLength(WallArray) - 1 do
> begin
> if (WallArray[c] = WallArray[c - 1]) then
312,315c295,307
< if TC[c][1] > TC[c + 1][1] then // replace result until highest count.
< Result := TC[c][0]; // return highest count color.
< end;
< Status('WallColor := '+ IntToStr(Result));
---
> TC[TCColorIndex][0] := WallArray[c];
> TC[TCColorIndex][1] := TCCounter;
> Inc(TCCounter);
> end else
> Inc(TCColorIndex);
> end;
>
> for c := 0 to 9 do
> begin
> if (TC[c][1] > TC[c + 1][1]) then // replace result until highest count.
> Result := TC[c][0]; // return highest count color.
> end;
> Status('WallColor := '+ IntToStr(Result));
322c314
< Procedure GetWalls;
---
> procedure GetWalls;
324,325c316
< x, y :Integer; // fill clockwise 3[0]-6[1]-9[2]-12[3] hours
<
---
> x, y: integer; // fill clockwise 3[0]-6[1]-9[2]-12[3] hours
327,339c318,329
<
< for x := MMCx to MMx2 do
< if FindColor(Wall[0].Point.x, Wall[0].Point.y, WallColor, x, MMCy - 2, x + 4, MMCy + 2) then
< Break;
< for y := MMCy to MMy2 do
< if FindColor(Wall[1].Point.x, Wall[1].Point.y, WallColor, MMCx - 2, y, MMCx + 2, y + 4) then
< Break;
< for x := MMCx downto MMx1 do
< if FindColor(Wall[2].Point.x, Wall[2].Point.y, WallColor, x, MMCy - 2, x + 4, MMCy + 2) then
< Break;
< for y := MMCy downto MMy1 do
< if FindColor(Wall[3].Point.x, Wall[3].Point.y, WallColor, MMCx - 2, y, MMCx + 2, y + 4) then
< Break;
---
> for x := MMCx to MMx2 do
> if FindColor(Wall[0].Point.x, Wall[0].Point.y, WallColor, x, MMCy - 2, x + 4, MMCy + 2) then
> Break;
> for y := MMCy to MMy2 do
> if FindColor(Wall[1].Point.x, Wall[1].Point.y, WallColor, MMCx - 2, y, MMCx + 2, y + 4) then
> Break;
> for x := MMCx downto MMx1 do
> if FindColor(Wall[2].Point.x, Wall[2].Point.y, WallColor, x, MMCy - 2, x + 4, MMCy + 2) then
> Break;
> for y := MMCy downto MMy1 do
> if FindColor(Wall[3].Point.x, Wall[3].Point.y, WallColor, MMCx - 2, y, MMCx + 2, y + 4) then
> Break;
346c336
< Function IsWallBehind:Boolean;
---
> function IsWallBehind: boolean;
348,349c338
< c, SmallDist:Integer;
<
---
> c, SmallDist: integer;
351,376c340,363
< GetWalls;
<
< for c:= 0 to 3 do
< begin
< if (Wall[c].Point.x <> 0) and (Wall[c].Point.y <> 0) then
< begin
< Wall[c].Dist := Distance(MMCx, MMCy, Wall[c].Point.x, Wall[c].Point.y);
< status('ISWALLBEHIND: Wall '+IntToStr(c + 1) +' Distance = ' + IntToStr(Wall[c].Dist));
< end;
< end;
<
< SmallDist := 100;
<
< for c := 0 to 3 do
< begin
< if Wall[c].Dist <> 0 then
< begin
< if SmallDist > Wall[c].Dist then SmallDist := Wall[c].Dist;
< end;
< end;
< status('ISWALLBEHIND: SmallDist = '+ IntToStr(SmallDist));
< if SmallDist = Wall[1].Dist then // is wall below MMCentre?
< begin
< Result := True;
< Status('SmallDist Returned TRUE');
< end;
---
> GetWalls;
> for c := 0 to 3 do
> begin
> if ((Wall[c].Point.x <> 0) and (Wall[c].Point.y <> 0)) then
> begin
> Wall[c].Dist := Distance(MMCx, MMCy, Wall[c].Point.x, Wall[c].Point.y);
> Status('ISWALLBEHIND: Wall ' + IntToStr(c + 1) + ' Distance = ' + IntToStr(Wall[c].Dist));
> end;
> end;
> SmallDist := 100;
> for c := 0 to 3 do
> begin
> if Wall[c].Dist <> 0 then
> begin
> if (SmallDist > Wall[c].Dist) then
> SmallDist := Wall[c].Dist;
> end;
> end;
> Status('ISWALLBEHIND: SmallDist = ' + IntToStr(SmallDist));
> if (SmallDist = Wall[1].Dist) then // is wall below MMCentre?
> begin
> Result := True;
> Status('SmallDist Returned TRUE');
> end;
384c371
< Function WallDist:Integer;
---
> function WallDist: integer;
386,387c373
< c, SmallDist:Integer; // fill clockwise 3[0]-6[1]-9[2]-12[3] hours
<
---
> c, SmallDist: integer; // fill clockwise 3[0]-6[1]-9[2]-12[3] hours
389,390c375,378
< GetWalls;
< for c:= 0 to 3 do
---
> GetWalls;
> for c := 0 to 3 do
> begin
> if ((Wall[c].Point.x <> 0) and (Wall[c].Point.y <> 0)) then
392,396c380,381
< if (Wall[c].Point.x <> 0) and (Wall[c].Point.y <> 0) then
< begin
< Wall[c].Dist := Distance(MMCx, MMCy, Wall[c].Point.x, Wall[c].Point.y);
< status('WALDIST: Wall '+IntToStr(c + 1) +' Distance = ' + IntToStr(Wall[c].Dist));
< end;
---
> Wall[c].Dist := Distance(MMCx, MMCy, Wall[c].Point.x, Wall[c].Point.y);
> Status('WALDIST: Wall ' + IntToStr(c + 1) + ' Distance = ' + IntToStr(Wall[c].Dist));
398,409c383,394
<
< SmallDist := 100;
<
< for c := 0 to 3 do
< begin
< if Wall[c].Dist <> 0 then
< begin
< if SmallDist > Wall[c].Dist then SmallDist := Wall[c].Dist;
< end;
< end;
< status('WALDIST: SmallDist = '+ IntToStr(SmallDist));
< if SmallDist = Wall[1].Dist then // is wall below MMCentre?
---
> end;
> SmallDist := 100;
> for c := 0 to 3 do
> begin
> if (Wall[c].Dist <> 0) then
> begin
> if (SmallDist > Wall[c].Dist) then
> SmallDist := Wall[c].Dist;
> end;
> end;
> Status('WALDIST: SmallDist = '+ IntToStr(SmallDist));
> if (SmallDist = Wall[1].Dist) then // is wall below MMCentre?
420c405
< Procedure TurnAwayFromWall;
---
> procedure TurnAwayFromWall;
422,424c407
< TimeOut:Integer;
< LR:Integer;
<
---
> TimeOut, LR: integer;
426,437c409,429
< TimeOut := GetSystemTime;
< LR := Random(2);
< if LR = 0 then KeyDown(VK_LEFT) else KeyDown(VK_RIGHT);
< repeat
< Wait(100);
< if TimeOut + 5000 < GetSystemTime then
< begin
< if LR = 0 then KeyUp(VK_LEFT) else KeyUp(VK_RIGHT);
< Exit;
< end;
< until IsWallBehind;
< if LR = 0 then KeyUp(VK_LEFT) else KeyUp(VK_RIGHT);
---
> TimeOut := GetSystemTime;
> LR := Random(2);
> if (LR = 0) then
> KeyDown(VK_LEFT)
> else
> KeyDown(VK_RIGHT);
> repeat
> Wait(100);
> if ((TimeOut + 5000) < GetSystemTime) then
> begin
> if (LR = 0) then
> KeyUp(VK_LEFT)
> else
> KeyUp(VK_RIGHT);
> Exit;
> end;
> until IsWallBehind;
> if (LR = 0) then
> KeyDown(VK_LEFT)
> else
> KeyDown(VK_RIGHT);
442,443c434,436
< Function HaveFood(var Lx, Ly:Integer): Boolean;
< var Dx, Dy:integer;
---
> function HaveFood(var Lx, Ly: integer): boolean;
> var
> Dx, Dy: integer;
451c444,445
< if FawkiDebug then writeln('HaveFood returded True');
---
> if FawkiDebug then
> WriteLn('HaveFood returded True');
453,454c447
< end
< else
---
> end else
456,457c449,451
< if FawkiDebug then writeln('HaveFood returded False');
< end
---
> if FawkiDebug then
> WriteLn('HaveFood returded False');
> end;
462,484c456,473
< if FirstCheck then
< begin
< // Players[CurrentPlayer].Level[Skill_Attack] := GetSkillLevel('attack');
< // Players[CurrentPlayer].Level[Skill_Strength] := GetSkillLevel('strength');
< // Players[CurrentPlayer].Level[Skill_Defense] := GetSkillLevel('defence');
< // Players[CurrentPlayer].Level[Skill_HP] := GetSkillLevel('hitpoints');
< CombatLevels[1] := GetSkillLevel('attack');
< CombatLevels[2] := GetSkillLevel('strength');
< CombatLevels[3] := GetSkillLevel('defence');
< CombatLevels[4] := GetSkillLevel('hitpoints');
< CombatLevels[5] := CombatLevels[1];
< CombatLevels[6] := CombatLevels[2];
< CombatLevels[7] := CombatLevels[3];
< CombatLevels[8] := CombatLevels[4];
< FirstCheck := False
< end
< else
< begin
< CombatLevels[5] := GetSkillLevel('attack');
< CombatLevels[6] := GetSkillLevel('strength');
< CombatLevels[7] := GetSkillLevel('defence');
< CombatLevels[8] := GetSkillLevel('hitpoints');
< end
---
> if FirstCheck then
> begin
> CombatLevels[1] := GetSkillLevel('attack');
> CombatLevels[2] := GetSkillLevel('strength');
> CombatLevels[3] := GetSkillLevel('defence');
> CombatLevels[4] := GetSkillLevel('hitpoints');
> CombatLevels[5] := CombatLevels[1];
> CombatLevels[6] := CombatLevels[2];
> CombatLevels[7] := CombatLevels[3];
> CombatLevels[8] := CombatLevels[4];
> FirstCheck := False
> end else
> begin
> CombatLevels[5] := GetSkillLevel('attack');
> CombatLevels[6] := GetSkillLevel('strength');
> CombatLevels[7] := GetSkillLevel('defence');
> CombatLevels[8] := GetSkillLevel('hitpoints');
> end;
489,499c478,497
< Function CheckAndRestoreHealth: Boolean;
< var Lx, Ly, HPAmount:Integer;
< var
< HPColor: String;
< begin
< HPAmount:= GetMMlevels( 'hp', hpcolor);
< Damage := ((Combatlevels[8] * 10) - HPAmount)/10;
< // Status('Damage = ' + IntToStr(Damage));
< If FawkiDebug then Writeln('Damage = ' + IntToStr(Damage));
< Result := True;
< if Damage > 40 then
---
> function CheckAndRestoreHealth: boolean;
> var
> Lx, Ly, HPAmount: integer;
> HPColor: string;
> begin
> HPAmount := GetMMlevels('hp', hpcolor);
> Damage := (((Combatlevels[8] * 10) - HPAmount) / 10);
> if FawkiDebug then
> Writeln('Damage = ' + IntToStr(Damage));
> Result := True;
> if (Damage > 40) then
> begin
> if FawkiDebug then
> Writeln('skipped because impossible damage');
> Result := True;
> Exit;
> end;
> if (Damage >= FoodHeals) then
> begin
> if HaveFood(Lx, Ly) then
501,513c499,502
< If FawkiDebug then Writeln('skipped because impossible damage');
< Result := True;
< Exit;
< End;
< if Damage >= FoodHeals then
< begin
< if HaveFood(Lx,Ly) then
< begin
< Mouse(Lx , Ly , 4, 4, True);
< FTWait(4);
< CheckAndRestoreHealth;
< end
< else
---
> Mouse(Lx, Ly, 4, 4, True);
> FTWait(4);
> CheckAndRestoreHealth;
> end else
515c504
< end;
---
> end;
522,523c511,513
< RunAway('N',True, 1, 8000);
< if FawkiDebug then writeln('RunAway2');
---
> RunAway('N', True, 1, 8000);
> if FawkiDebug then
> Writeln('RunAway2');
528c518
< function FindClosestNPC(how:string): TPoint;
---
> function FindClosestNPC(how: string): TPoint;
530c520
< i, Cx, Cy, Dist, Fx, Fy: Integer;
---
> i, Cx, Cy, Dist, Fx, Fy: integer;
532c522,524
< if how = 'in' then
---
> if (how = 'in') then
> begin
> for Dist := 5 to 62 do
534c526
< for Dist := 5 to 62 do
---
> for i := 160 to 520 do
536,545c528,534
< for i := 160 to 520 do
< begin
< Cx := Round( Dist * Sin(i * Pi / 180)) + MMCx;
< Cy := Round(- Dist * Cos(i * Pi / 180)) + MMCy;
< if FindColor(Fx, Fy, 195836, Cx, Cy, Cx + 1, Cy + 1) then
< begin
< Result.x := Fx;
< Result.y := Fy;
< Exit;
< end;
---
> Cx := Round(Dist * Sin(i * Pi / 180)) + MMCx;
> Cy := Round(-Dist * Cos(i * Pi / 180)) + MMCy;
> if FindColor(Fx, Fy, 195836, Cx, Cy, Cx + 1, Cy + 1) then
> begin
> Result.x := Fx;
> Result.y := Fy;
> Exit;
547c536
< end
---
> end;
549,550c538,541
<
< if how = 'out' then
---
> end;
> if how = 'out' then
> begin
> for Dist := 62 downto 5 do
552c543
< for Dist := 62 downto 5 do
---
> for i := 160 to 520 do
554,563c545,551
< for i := 160 to 520 do
< begin
< Cx := Round( Dist * Sin(i * Pi / 180)) + MMCx;
< Cy := Round(- Dist * Cos(i * Pi / 180)) + MMCy;
< if FindColor(Fx, Fy, 195836, Cx, Cy, Cx + 1, Cy + 1) then
< begin
< Result.x := Fx;
< Result.y := Fy;
< Exit;
< end;
---
> Cx := Round(Dist * Sin(i * Pi / 180)) + MMCx;
> Cy := Round(-Dist * Cos(i * Pi / 180)) + MMCy;
> if FindColor(Fx, Fy, 195836, Cx, Cy, Cx + 1, Cy + 1) then
> begin
> Result.x := Fx;
> Result.y := Fy;
> Exit;
565c553
< end
---
> end;
567c555
<
---
> end;
569a558
> //----------------------------------------------------------------------------//
571c560
< Procedure ClickMMNPC(how:string);
---
> procedure ClickMMNPC(how: string);
577d565
< // MFNF(TheNPC.x, TheNPC.y, 4, 4);
579d566
< // FtWait(5);
584c571
< function FindLegit:Boolean;
---
> function FindLegit: boolean;
586,587c573
< i, Cx, Cy, Fx, Fy, Dist: Integer;
<
---
> i, Cx, Cy, Fx, Fy, Dist: integer;
589,594c575,583
< If not FindColor(Fx, Fy, 16711422, MMx1, MMy1, MMx2, MMy2) then
< begin
< Result := False;
< Exit;
< end;
< for Dist := 5 to 62 do
---
> if (not (FindColor(Fx, Fy, 16711422, MMx1, MMy1, MMx2, MMy2))) then
> begin
> Result := False;
> Exit;
> end;
>
> for Dist := 5 to 62 do
> begin
> for i := 0 to 360 do
596c585,599
< for i := 0 to 360 do
---
> i := i + 10;
> Cx := Round(Dist * Sin(i * Pi / 180)) + MMCx;
> Cy := Round(-Dist * Cos(i * Pi / 180)) + MMCy;
> if FindColor(Fx, Fy, 16711422, Cx, Cy, Cx + 1, Cy + 1) then // legit dot color
> begin
> //Result := True;
> Dist2Legit := Distance(MMCx, MMCy, Fx, Fy);
> if (Dist2Legit < 20) then
> begin
> ClickMMNPC('out');
> Result := True;
> Exit;
> end;
> Status('Dist to Legit = ' + IntToStr(Dist2Legit));
> if LegitFlag then
598,637c601,609
< i := i + 10;
< Cx := Round( Dist * Sin(i * Pi / 180)) + MMCx;
< Cy := Round(- Dist * Cos(i * Pi / 180)) + MMCy;
< if FindColor(Fx, Fy, 16711422, Cx, Cy, Cx + 1, Cy + 1) then // legit dot color
< begin
< // Result := True;
< Dist2Legit := Distance(MMCx, MMCy, Fx, Fy);
< if Dist2Legit < 20 then
< begin
< ClickMMNPC('out');
< Result := True;
< Exit;
< end;
< status('Dist to Legit = ' + IntToStr(Dist2Legit));
< if LegitFlag then
< begin
< if LegitTimeOut + (LegitLogOutTime * 60000) < GetSystemTime then
< begin
< Writeln( IntToStr(LegitLogOutTime ) + ' minutes in neigbourhood with Legit. Logging out for 10 mins');
< LogOut;
< Wait(10 * 60000);
< LoginPlayer;
< WallColor := GetWallColor;
< Inc(LegitLogOut);
< LegitTimeOut := GetSystemTime;
< Exit;
< end
< end
< else
< LegitTimeOut := GetSystemTime;
< if Dist2Legit < 60 then // Legit anywhere in MM.
< begin
< LegitFlag := True;
< Respond;
< end
< else
< begin
< LegitFlag := False;
< Status('LEGITS around. Accpetable Distance');
< end;
---
> if ((LegitTimeOut + (LegitLogOutTime * 60000)) < GetSystemTime) then
> begin
> Writeln(IntToStr(LegitLogOutTime) + ' minutes in neigbourhood with Legit. Logging out for 10 mins');
> LogOut;
> Wait(10 * 60000);
> LoginPlayer;
> WallColor := GetWallColor;
> Inc(LegitLogOut);
> LegitTimeOut := GetSystemTime;
638a611,621
> end;
> end else
> LegitTimeOut := GetSystemTime;
> if (Dist2Legit < 60) then // Legit anywhere in MM.
> begin
> LegitFlag := True;
> Respond;
> end else
> begin
> LegitFlag := False;
> Status('LEGITS around. Accpetable Distance');
639a623,624
> Exit;
> end;
644a630
> //----------------------------------------------------------------------------//
646c632
< Function IsFullHit:Boolean;
---
> function IsFullHit: boolean;
648c634
< x, y, FullHit:Integer;
---
> x, y, FullHit: integer;
650,651c636
< FullHit := BitmapFromString(2, 5, 'beNrjYLbhgKJKBgYgmYtEOgI' +
< 'AL/ADSg==');
---
> FullHit := BitmapFromString(2, 5, 'beNrjYLbhgKJKBgYgmYtEOgIAL/ADSg==');
653c638,639
< if FawkiDebug then writeln('IsFullHit returned ' + BoolToStr(Result));
---
> if FawkiDebug then
> WriteLn('IsFullHit returned ' + BoolToStr(Result));
659c645
< Function WTDamage:Boolean;
---
> function WTDamage: boolean;
661c647
< hpcolor:String;
---
> hpcolor: string;
663c649,650
< if Combatlevels[8] <> (GetMMlevels( 'hp', hpcolor)) then Result := True;
---
> if (Combatlevels[8] <> (GetMMlevels('hp', hpcolor))) then
> Result := True;
668,670c655,658
< Function FindExperimentOLD: Boolean;
< var CBx, CBy, GCIndex, Dumx, Dumy, MSBx1, MSBy1, MSBx2, MSBy2, MSBox: Integer;
< SkipBox:Tbox;
---
> function FindExperimentOLD: boolean;
> var
> CBx, CBy, GCIndex, Dumx, Dumy, MSBx1, MSBy1, MSBx2, MSBy2, MSBox: integer;
> SkipBox: Tbox;
672,680c660,663
< if not HaveFood(Dumx, Dumy) then
< begin
< Quit('Out of Food');
< end;
<
< SkipBox.x1 := 213;
< SkipBox.y1 := 95;
< SkipBox.x2 := 276;
< SkipBox.y2 := 202;
---
> if (not (HaveFood(Dumx, Dumy))) then
> begin
> Quit('Out of Food');
> end;
682,683c665,668
< CBx := MSx2;
< CBy := MSy2;
---
> SkipBox.x1 := 213;
> SkipBox.y1 := 95;
> SkipBox.x2 := 276;
> SkipBox.y2 := 202;
685,720c670,671
< for MSBox := 0 to 9 do
< begin
< Case MSBox of
< 0,2,4:
< begin
< MSBx1 := 294;
< MSBy1 := 130;
< MSBx2 := MSx2 - 2;
< MSBy2 := MSy2 - 2;
< Status('Searching in Box 1');
< end; // 3-6 hour
< 1,3,5:
< begin
< MSBx1 := MSx1;
< MSBy1 := 130;
< MSBx2 := 220 ;
< MSBy2 := MSy2 - 2;
< Status('Searching in Box 2');
< end; // 6 - 9 hour
< 6,8:
< begin
< MSBx1 := 294;
< MSBy1 := MSy1;
< MSBx2 := MSx2 - 2;
< MSBy2 := 180;
< Status('Searching in Box 3');
< end; // 12 - 3 hour
< 7,9:
< begin
< MSBx1 := MSx1;
< MSBy1 := MSy1;
< MSBx2 := 250 ;
< MSBy2 := 180;
< Status('Searching in Box 4');
< end; // 9 - 12 hour
< end;
---
> CBx := MSx2;
> CBy := MSy2;
722c673,715
< for GCIndex := 1 to 16 do
---
> for MSBox := 0 to 9 do
> begin
> case MSBox of
> 0, 2, 4: begin
> MSBx1 := 294;
> MSBy1 := 130;
> MSBx2 := MSx2 - 2;
> MSBy2 := MSy2 - 2;
> Status('Searching in Box 1');
> end; // 3-6 hour
> 1, 3, 5: begin
> MSBx1 := MSx1;
> MSBy1 := 130;
> MSBx2 := 220;
> MSBy2 := MSy2 - 2;
> Status('Searching in Box 2');
> end; // 6 - 9 hour
> 6, 8: begin
> MSBx1 := 294;
> MSBy1 := MSy1;
> MSBx2 := MSx2 - 2;
> MSBy2 := 180;
> Status('Searching in Box 3');
> end; // 12 - 3 hour
> 7, 9: begin
> MSBx1 := MSx1;
> MSBy1 := MSy1;
> MSBx2 := 250;
> MSBy2 := 180;
> Status('Searching in Box 4');
> end; // 9 - 12 hour
> end;
>
> for GCIndex := 1 to 16 do
> begin
> Wait(50 + Random(50));
> if FawkiDebug then
> WriteLn('GC = ' + IntToStr(GCIndex));
> if FindColorTolerance(CBx, CBy, NPCColors[GCIndex], MSBx1, MSBy1, MSBx2, MSBy2, 3) then
> begin
> MMouse(CBx, CBy, 0, 0);
> Wait(10);
> if FindColorTolerance(Dumx, Dumy, 318168, 42, 8, 120, 21, 50) then // Yellow
724,726c717,719
< Wait(50 + Random(50));
< if FawkiDebug then Writeln('GC = ' + IntToStr(GCIndex));
< if FindColorTolerance(CBx, CBy, NPCColors[GCIndex], MSBx1, MSBy1, MSBx2, MSBy2, 3) then
---
> if VeryLowDefence then
> begin
> if IsUpText('25') then
728,730c721,722
< MMouse(CBx, CBy, 0, 0);
< Wait(10);
< if FindColorTolerance(Dumx, Dumy, 318168, 42, 8, 120, 21, 50) then // Yellow
---
> Mouse(CBx, CBy, 0, 0, False);
> if ChooseOption('Experiment') then
732,760c724,740
< if VeryLowDefence then
< begin
< if IsUpText('25') then
< begin
< Mouse(CBx, CBy, 0, 0, False);
< if ChooseOption('Experiment') then
< begin
< Result := True;
< FlagFTWait;
< Exit;
< end
< end
< else
< Result := False;
< end
< else
< begin
< Mouse(CBx, CBy, 0, 0, False);
< if ChooseOption('Experiment') then
< begin
< Result := True;
< FlagFTWait;
< Exit;
< end
< else
< Result := False;
< end;
< end;
< end;
---
> Result := True;
> FlagFTWait;
> Exit;
> end;
> end else
> Result := False;
> end else
> begin
> Mouse(CBx, CBy, 0, 0, False);
> if ChooseOption('Experiment') then
> begin
> Result := True;
> FlagFTWait;
> Exit;
> end else
> Result := False;
> end;
761a742
> end;
762a744
> end;
767,774c749,756
< Function FindExperiment: Boolean;
< var CBx, CBy, GCIndex, Dumx, Dumy, MSBx1, MSBy1, MSBx2, MSBy2, MSBox: Integer;
< SkipBox:Tbox;
< begin
< if not HaveFood(Dumx, Dumy) then
< begin
< Quit('Out of Food');
< end;
---
> function FindExperiment: boolean;
> var
> CBx, CBy, GCIndex, Dumx, Dumy: integer;
> begin
> if (not (HaveFood(Dumx, Dumy))) then
> begin
> Quit('Out of Food');
> end;
776c758,766
< for GCIndex := 1 to 16 do
---
> for GCIndex := 1 to 16 do
> begin
> if FawkiDebug then
> Writeln('GC = ' + IntToStr(GCIndex));
> if FindColorTolerance(CBx, CBy, NPCColors[GCIndex], MSx1, MSy1, MSx2, MSy2, 3) then
> begin
> MMouse(CBx, CBy, 0, 0);
> Wait(75 + Random(50));
> if FindColorTolerance(Dumx, Dumy, 318168, 42, 8, 120, 21, 50) then // Yellow
778,779c768,770
< if FawkiDebug then Writeln('GC = ' + IntToStr(GCIndex));
< if FindColorTolerance(CBx, CBy, NPCColors[GCIndex], MSx1, MSy1, MSx2, MSy2, 3) then
---
> if VeryLowDefence then
> begin
> if IsUpText('25') then
781,783c772,773
< MMouse(CBx, CBy, 0, 0);
< Wait(75 + Random(50));
< if FindColorTolerance(Dumx, Dumy, 318168, 42, 8, 120, 21, 50) then // Yellow
---
> Mouse(CBx, CBy, 0, 0, False);
> if ChooseOption('Experiment') then
785,813c775,791
< if VeryLowDefence then
< begin
< if IsUpText('25') then
< begin
< Mouse(CBx, CBy, 0, 0, False);
< if ChooseOption('Experiment') then
< begin
< Result := True;
< FlagFTWait;
< Exit;
< end
< end
< else
< Result := False;
< end
< else
< begin
< Mouse(CBx, CBy, 0, 0, False);
< if ChooseOption('Experiment') then
< begin
< Result := True;
< FlagFTWait;
< Exit;
< end
< else
< Result := False;
< end;
< end;
< end;
---
> Result := True;
> FlagFTWait;
> Exit;
> end;
> end else
> Result := False;
> end else
> begin
> Mouse(CBx, CBy, 0, 0, False);
> if ChooseOption('Experiment') then
> begin
> Result := True;
> FlagFTWait;
> Exit;
> end else
> Result := False;
> end;
814a793,794
> end;
> end;
819c799
< Function WaitExperiment: Boolean;
---
> function WaitExperiment: boolean;
821c801
< TimeOut:Integer;
---
> TimeOut: integer;
823,848c803,829
< TimeOut := GetSystemTime;
< repeat
< If GetSystemTime - TimeOut > 90000 then
< begin
< if FawkiDebug Then Writeln('Timeout 1 1/2 minute Break out from WaitExperiment');
< Result := False;
< Exit;
< end;
< FindNonInventoryRandoms;
< if FindLegit then
< begin
< Inc(WalkedAwayFromLegits);
< break;
< end;
< if not CheckAndRestoreHealth then
< begin
< Quit('Out of Food');
< end;
< if ClickContinue(False, False) then
< begin
< CheckCBLevels;
< end;
< until IsFullHit;
< Result := True;
< Inc(ExperimentsKilled);
< FTWait(8); // wait for yellow NPCpoint to go away;
---
> TimeOut := GetSystemTime;
> repeat
> if ((GetSystemTime - TimeOut) > 90000) then
> begin
> if FawkiDebug then
> Writeln('Timeout 1 1/2 minute Break out from WaitExperiment');
> Result := False;
> Exit;
> end;
> FindNonInventoryRandoms;
> if FindLegit then
> begin
> Inc(WalkedAwayFromLegits);
> Break;
> end;
> if (not (CheckAndRestoreHealth)) then
> begin
> Quit('Out of Food');
> end;
> if ClickContinue(False, False) then
> begin
> CheckCBLevels;
> end;
> until IsFullHit;
> Result := True;
> Inc(ExperimentsKilled);
> FTWait(8); // wait for yellow NPCpoint to go away;
854,855c835,836
< var
< i:Integer;
---
> //var
> // i: integer;
862,868c843,849
< if MySRLID <> '' then
< begin
< SRLID := MySRLID;
< SRLPassword := MySRLPassword;
< end;
< for I := 0 to 19 do
< ReportVars[I] := 0;
---
> //if MySRLID <> '' then
> //begin
> //SRLID := MySRLID;
> //SRLPassword := MySRLPassword;
> //end;
> //for I := 0 to 19 do
> //ReportVars[I] := 0;
870,871c851,852
< ReportVars[12] := 1;
< ScriptID := '264';
---
> //ReportVars[12] := 1;
> //ScriptID := '264';
873d853
<
875,876c855
< GraphicsSet := True;
< SetChat('Hide',1);
---
> SetChat('Hide', 1);
894,896c873,875
< SmartsetupEx(170, true, true, false);
< SetTargetDC(SmartGetDC);
< Setup;
---
> //SmartsetupEx(170, true, true, false);
> //SetTargetDC(SmartGetDC);
> Setup;
897a877,883
> if FindExperiment then
> begin
> if WaitExperiment then
> ProgressReport;
> end else
> begin
> ClickMMNPC('in');
901,903c887,888
< ProgressReport
< end
< else
---
> ProgressReport;
> end else
905c890
< ClickMMNPC('in');
---
> TurnAwayFromWall;
908,924c893,901
< if WaitExperiment then
< ProgressReport
< end
< else
< begin
< TurnAwayFromWall;
< if FindExperiment then
< begin
< if WaitExperiment then
< ProgressReport
< end
< else
< ClickMMNPC('out');
< end
< end;
< if FindLegit then ClickMMNPC('out');
< until false;
---
> if WaitExperiment then
> ProgressReport
> end else
> ClickMMNPC('out');
> end
> end;
> if FindLegit then
> ClickMMNPC('out');
> until(False);
926d902
<