SRL Archive - OSR Help

Counting Ores


Dynamite

2010-01-28 12:18:52

Hi there, this should be my last scripting question for a while :p

Ok, well here is my script:

{/----------------------------------------------------------------------\\
| |
| .: The Man's Extravagant Power Miner :. |
| Version: 1.00 |
| |
| Please Post Progress Reports |
| Please Monitor The Script And Leave Details About How It Runs |
| All Of This Will Help Make The Script Better! |
\\----------------------------------------------------------------------//
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} {
//----------------------------------------------------------------------\\
| .:Script Features:. |
| ¤ Tested With SCAR Divi 3.23 & Latest SRL Developers Revision |
| ¤ Power Mine: tin, copper, iron, coal, gold, silver, mith and addy |
| ¤ Nice and detailed progress report |
| ¤ Helpful Debug |
| ¤ Will drop gems, they are pointless :P |
| ¤ "Stats are optional but encouraged!" Learn how to get stats here: |
| [url]http://www.villavu.com/forum/showthread.php?t=53844[/url] |
\\----------------------------------------------------------------------//
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} {
//----------------------------------------------------------------------\\
| .:Version History:. |
| ¤1.00: |
| -First Release: Please post lots of feedback and Proggies |
| | |
\\----------------------------------------------------------------------//
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} {
//----------------------------------------------------------------------\\
| .:Credits:. |
| ¤ Niels answered a few questions :) |
| ¤ YoHoJo, got ideas from his Progress report xD |
\\----------------------------------------------------------------------//
//----------------------------------------------------------------------\\
| .:Author's Notes:. |
| ¤Stats: |
| Stats_CustomVars[1] = Ores Mined |
| Stats_CustomVars[2] = Pictures Taken |
| Stats_CustomVars[3] = Xp Gained |
| Stats_CustomVars[4] = Loads Done |
| Stats_CustomVars[5] = Switched Worlds |
| Stats_CustomVars[6] = Copper Mined |
| Stats_CustomVars[7] = Tin Mined |
| Stats_CustomVars[8] = Iron Mined |
| Stats_CustomVars[9] = Antiban Performed |
| Stats_CustomVars[10] = Checked For Randoms |
| Stats_CustomVars[11] = Coal Mined |
| Stats_CustomVars[12] = Mith Mined |
\\ //
//----------------------------------------------------------------------\\
| .:Ores Available:.
| ¤ tin
| ¤ copper
| ¤ coal
| ¤ mith
|
|
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}

program ExtravagantPowerMiner;
{.include srl/srl/misc/smart.scar}
{.include srl/srl.scar}
{.include srl/srl/misc/users.scar}
{.include srl/srl/misc/Reports.scar}
{.include srl/srl/misc/Debug.scar}


type
TOre = record
Name : string;
Uptext : TStringArray;
Color : Integer;
Tol : Integer;
Hue : extended;
Sat : extended;
width : integer;
hight : integer;
Level : integer;
end;

var
Stats_UserID, Stats_Password : String;


const
TooManyPlayers = 10; // How many players is too crowded till we move world?
Version = '1.0'; // Leave
ScriptName = 'Extravagant Power Miner'; // Leave
SmartMembers = False; // Are you a member?
SmartWorld = 123; // What SmartWorld?
SaveReport = True; // Save Progress Report so you don't lose it!

procedure DeclarePlayers;
begin
HowManyPlayers := 1; //<------- This May Need Editing
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

Stats_UserID := ''; // Your ID on Nielsies SRL Stats if you dont have Sign up
Stats_Password := ''; // Your Pass on Nielsies SRL Stats if you dont have Sign up

Players[0].Name :=''; // Username
Players[0].Pass :=''; // Password
Players[0].Nick :=''; // 3-4 letters of your username
Players[0].Active := True;
Players[0].Strings[1] := 'iron'; // ore type
Players[0].Integers[2] := 500; // # of loads

{Players[1].Name :=''; // Username
Players[1].Pass :=''; // Password
Players[1].Nick :=''; // 3-4 letters of your username
Players[1].Active := True;
Players[1].Strings[1] := 'copper'; // ore type
Players[1].Integers[2] := 2; // # of loads}
end;

{Do not edit below here unless you know what you are doing}
{---------------------------------------------------------}



{Global Vars}
Var
PicN, g, AxeDTM, OreDTM, Loads, RestTime, Switched, StartTime, i, Mined : Integer;
XpGain: TExtendedArray;
Ore: TOre;


{Stats Vars}
var
Stats_ScriptID,Stats_Link: string;
Stats_LastTime: Integer;
Stats_CustomVars: array [1..20] of Integer;
{Stats Vars}

{*******************************************************************************
procedure Stats_CheckOutput(s: string);
By: Nielsie95.
Description: ???
*******************************************************************************}
procedure Stats_CheckOutput(s: string);
var
i: Integer;
sa: TStringArray;
begin
sa := Explode(#10, s);
for i := 0 to High(sa) do
if (Trim(sa[i]) <> '') then
if StartsWith('ERROR(1)', sa[i]) then
begin
WriteLn('STATS: "' + sa[i] + '"');
Stats_UserID := '';
Stats_Password := '';
end
else if StartsWith('ERROR(2)', sa[i]) then
begin
WriteLn('STATS: "' + sa[i] + '"');
Stats_ScriptID := '';
end
else
WriteLn('STATS: "' + sa[i] + '"');

end;

{*******************************************************************************
function Stats_GetScriptInfo(out Version, News, Link: string; out OutDated: Boolean; out LastUpdate_HoursAgo: Integer): Boolean;
By: Nielsie95.
Description: Gets script info from the online server.
*******************************************************************************}
function Stats_GetScriptInfo(out Version, News, Link: string; out OutDated: Boolean; out LastUpdate_HoursAgo: Integer): Boolean;
var
Client: Integer;
s: string;
sa: TStringArray;
begin
Result := False;
if (Stats_ScriptID = '') then
Exit;

Client := InitializeHTTPClient(False, False);
ClearPostData(Client);
AddPostVariable(Client, 'do', 'getinfo');
AddPostVariable (Client, 'sID', Stats_ScriptID);

s := PostHTTPPageEx(Client, Stats_Link);
sa := Explode(#10'GLUE'#10, s);
if (Length(sa) = 5) then
begin
Result := True;
Version := sa[0];
News := sa[1];
Link := sa[2];
OutDated := sa[3] = '1';
LastUpdate_HoursAgo := StrToIntDef(sa[4], -1);
end
else
Stats_CheckOutput(s);

FreeHTTPClient(Client );
end;

var
Stats_GlobalVars: array[1..24] of Integer;

{*******************************************************************************
procedure Stats_SendReport;
By: Nielsie95.
Description: Sends global vars to server.
*******************************************************************************}
procedure Stats_SendReport;
var
i, Client, Time: Integer;
s: string;
begin
if (Stats_UserID = '') and (Stats_Password = '') and (Stats_ScriptID = '') then
Exit;

Client := InitializeHTTPClient(False, False);
ClearPostData(Client);
AddPostVariable(Client, 'do', 'submit');

Time := (GetTimeRunning - Stats_LastTime) div 1000 div 60;
if (Time < 5) then
Time := 0
else
Stats_LastTime := GetTimeRunning;
AddPostVariable(Client, 'sTime', IntToStr(Time));

if (Stats_UserID <> '') and (Stats_Password <> '') then
begin
AddPostVariable(Client, 'uID', Stats_UserID);
AddPostVariable(Client, 'uPass', Stats_Password);
end
else
begin
AddPostVariable(Client, 'uID', '-1');
AddPostVariable(Client, 'uPass', '');
end;

if (Stats_ScriptID <> '') then
begin
AddPostVariable (Client, 'sID', Stats_ScriptID);

for i := Low(Stats_CustomVars) to High(Stats_CustomVars) do
begin
AddPostVariable(Client, 'rndCustom' + IntToStr(i), IntToStr(Stats_CustomVars[i]));
Stats_CustomVars[i] := 0;
end;
end
else
begin
AddPostVariable (Client, 'sID', '-1');
end;

for i := Low(Stats_GlobalVars) to High(Stats_GlobalVars) do
begin
case i of
1: s := IntToStr(SRL_Logs - Stats_GlobalVars[i]);
2: s := IntToStr(Banks - Stats_GlobalVars[i]);
3: s := IntToStr(RandSolved[rand_Death] - Stats_GlobalVars[i]);
else if ((i - 3) < Length(RandSolved) - 1 {for Death}) then
s := IntToStr(RandSolved[i - 3] - Stats_GlobalVars[i]);
end;
AddPostVariable(Client, 'rndGlobal' + IntToStr(i), s);
Stats_GlobalVars[i] := Stats_GlobalVars[i] + StrToInt(s);
end;

s := PostHTTPPageEx(Client, Stats_Link);
Stats_CheckOutput(s);
FreeHTTPClient(Client);

if (SRL_Procs[srl_OnSendStats] <> nil) then
SRL_Procs[srl_OnSendStats]();
end;

{*******************************************************************************
procedure Stats_SendAccountInfo;
By: Nielsie95.
Description: Sends your personal player info to server.
*******************************************************************************}
procedure Stats_SendAccountInfo;
var
i, Client: Integer;
Accounts: TStringArray;
begin
if (Stats_UserID = '') and (Stats_Password = '') then
Exit;

Client := InitializeHTTPClient(False, False);
ClearPostData(Client);
AddPostVariable(Client, 'do', 'setaccounts');
AddPostVariable(Client, 'uID', Stats_UserID);
AddPostVariable(Client, 'uPass', Stats_Password);
if (Stats_ScriptID <> '') then
AddPostVariable (Client, 'sID', Stats_ScriptID)
else
AddPostVariable (Client, 'sID', '-1');

SetLength(Accounts, HowManyPlayers);
for i := 0 to HowManyPlayers - 1 do
Accounts[i] := Implode('.|&#8364;stat&#8364;|.', [Players[i].Name, Players[i].Loc, IntToStr(Integer(Players[i].Active))]);

AddPostVariable(Client, 'accInfo', Implode(#10'ACC'#10, Accounts));
Stats_CheckOutput(PostHTTPPageEx(Client, Stats_Link));
FreeHTTPClient(Client);
end;

{*******************************************************************************
procedure Stats_ManageAccounts;
By: Nielsie95.
Description: ????
*******************************************************************************}
procedure Stats_ManageAccounts;
var
i, ii, Client: Integer;
s: string;
Accounts, Stats: TStringArray;
begin
if (Stats_UserID = '') and (Stats_Password = '') then
Exit;

Client := InitializeHTTPClient(False, False);
ClearPostData(Client);
AddPostVariable(Client, 'do', 'getaccounts');
AddPostVariable(Client, 'uID', Stats_UserID);
AddPostVariable(Client, 'uPass', Stats_Password);
AddPostVariable (Client, 'sID', '-1');

s := PostHTTPPageEx(Client, Stats_Link);
Accounts := Explode(#10'ACC'#10, s);
for i := 0 to High(Accounts) do
begin
Stats := Explode('.|&#8364;stat&#8364;|.', Accounts[i]);
if (Length(Stats) = 3) then
begin
for ii := 0 to HowManyPlayers - 1 do
if (LowerCase(Players[ii].Name) = LowerCase(Stats[0])) then
begin
Players[ii].Loc := Stats[1];
Players[ii].Active := Stats[2] = '1';
Break;
end;
end
else
begin
Stats_CheckOutput(s);
Break;
end;
end;

FreeHTTPClient(Client);
stats_SendAccountInfo;
end;



procedure ProgressReport; forward;


procedure ScriptTerminate;
begin
ProgressReport;
end;

{*******************************************************************************
procedure TakePic;
By: The Man
Description: Takes a screenshot for debug purposes
*******************************************************************************}
Procedure TakePic;
begin
TakeScreenshot(ScriptPath + ScriptName + IntToStr(PicN));
Inc(PicN);
Inc(Stats_CustomVars[2]);
end;

procedure SwitchWorlds;
begin
if CountDots('white') > TooManyPlayers then
begin
Inc(Stats_CustomVars[5]);
ChooseWorldBy(['players'], [True], SmartMembers, False);
end;
end;

procedure ExpGained;
begin
SetArrayLength(XpGain, 11)
XpGain := [5, 17.5, 17.5, 35, 40, 50, 5, 65, 80, 95, 125];
case Lowercase(Players[CurrentPlayer].Strings[0])of
'rune essence' : g := 0;
'copper' : g := 1;
'tin' : g := 2;
'iron' : g := 3;
'silver' : g := 4;
'coal' : g := 5;
'pure essence' : g := 6;
'gold' : g := 7;
'mithril', 'mith' : g := 8;
'adamantite', 'addy' : g := 9;
'runite', 'rune' : g := 10;
end;
end;

Procedure Antiban;
begin
case (Random(1000)) of
1: begin BoredHuman; PickupMouse; HoverSkill('Mining', False); end;
2: HoverSkill('Woodcutting', False);
3: ExamineInv;
4: begin PickupMouse; RandomRClick; end;
end;
Inc(Stats_CustomVars[9]);
end;

procedure AntiRandoms;
begin
FindNormalRandoms;
Inc(Stats_CustomVars[10]);
end;

function GetAnimation: Integer;
var
I : Integer;
begin
I := SmartGetFieldObject(0, 'at.N');
Result := SmartGetFieldInt(I, 'W');
SmartFreeObject(I);
end;

function WhichOre (which: string): TOre;
begin
case Lowercase(Players[CurrentPlayer].Strings[1]) of
'tin':
with Result do
begin
Name := 'tin';
UpText := ['e Ro', 'Rock'];
Color := 5292379;
Tol := 10;
Hue := 3.18;
Sat := 4.53;
width := 10;
hight := 10;
Level := 1;
end;
'copper':
with Result do
begin
Name := 'copper';
UpText := ['e Ro', 'Rock'];
Color := 4022407;
Tol := 5;
Hue := 0.04;
Sat := 0.13;
width := 10;
hight := 10;
Level := 1;
end;
'iron':
with Result do
begin
Name := 'iron';
Uptext := ['e Ro', 'Rock'];
Color := 2436419;
Tol := 7;
Hue := 0.06;
Sat := 0.17;
Width := 10;
Hight := 10;
level := 1;
end;
'coal':
with Result do
begin
Name := 'coal';
UpText := ['e Ro', 'Rock'];
Color := 2436911;
Tol := 3;
Hue := 0.00;
Sat := 0.31;
width := 10;
hight := 10;
Level := 1;
end;
{'gold' :
with Result do
begin
Name := 'gold'; //NEED TO DO
UpText := ['e Ro', 'Roc'];
Color := 2508085;
Tol := 3;
Hue := 0.18;
Sat := 0.22;
width := 62;
hight := 10;
Level := 68;
end;
'silver' :
with Result do
begin
Name := 'silver';
UpText := ['e Ro', 'Roc'];
Color := 2508085;
Tol := 3; //NEED TO DO
Hue := 0.18;
Sat := 0.22;
width := 62;
hight := 10;
Level := 68;
end;}
'mith', 'mithril' :
with Result do
begin
Name := 'mith';
UpText := ['e Ro', 'Rock'];
Color := 7428183;
Tol := 8;
Hue := 0.09;
Sat := 0.07;
width := 10;
hight := 10;
Level := 1;
end;
{'addy', 'adamant' :
with Result do
begin
Name := 'addy';
UpText := ['e Ro', 'Roc'];
Color := 2508085;
Tol := 3;
Hue := 0.18; //NEED TO DO
Sat := 0.22;
width := 62;
hight := 10;
Level := 68;
end;}
end;
end;


Function CheckAxe: boolean;
var
CT, i, x, y : Integer;
TC: TIntegerArray;
begin
SetLength(TC, 2);
CT := GetCurrentTab;
if CT = tab_inv then
TC := [tab_Inv, tab_Equip]
else
TC := [tab_Equip, tab_Inv];

for i:= 0 to 1 do
begin
GameTab(TC[i]);
if FindDTM(AxeDTM, x, y, MIX1, MIY1, MIX2, MIY2) then
begin
Result := true;
Players[CurrentPlayer].Booleans[0] := (TC[i] = tab_Equip);
if Players[CurrentPlayer].Booleans[0] then
Writeln('Axe is Equipped')
else
Writeln('Axe in Inv');
exit;
end;
end;

if i > 1 then
begin
LogOut;
Players[CurrentPlayer].Active := false;
Players[CurrentPlayer].Rand := 'No Axe';
end;
end;


function FindOre(which: TOre; var fx, fy: Integer): Boolean;
var
arP: TPointArray;
ararP: T2DPointArray;
tmpCTS, i, arL: Integer;
P: TPoint;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(which.Hue, which.Sat);

if not(FindColorsTolerance(arP, which.Color, MSX1, MSY1, MSX2, MSY2, which.Tol)) then
begin
{Writeln('Failed to find the color, no object found - '+Which.Name);}
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

ararP := TPAtoATPAEx(arP, which.width, which.hight);
SortATPAFromFirstPoint(ararP, Point(MSCX, MSCY));
arL := High(ararP);

for i := 0 to arL do
begin
P := MiddleTPA(ararP[i]);
MMouse(P.x, P.y, 1, 1);
if (WaitUptextMulti(which.UpText, 750)) then
begin;
Result := True;
GetMousePos(fx, fy);
Break;
end;
end;

ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);

if (i = arL + 1) then
begin
Writeln('FindObject could not find object - '+which.Name);
Exit;
end;
end;


function WaitUntilMined(Rock: TOre): Boolean;
var
GetAnimationTime, T, CX, CY, IC, P: Integer;
begin
Status('Walking to Rock');
MarkTime(t);
SetColorspeed2Modifiers(Rock.Hue, Rock.Sat);
repeat
Wait(10);
if (TimeFromMark(t) >= 6000) then Exit;
until (not FlagPresent) and FindBlackChatMessage('u swi') and
(FindColorTolerance(cx, cy, Rock.Color, MSCX-65, MSCY-65, MSCX+65, MSCY+65, Rock.Tol));
Status('Mining Rock');
IC := InvCount;
MarkTime(t);
repeat
Wait(10);
if (TimeFromMark(t) >= 12000) then Exit;
if (not FindColorTolerance(cx, cy, Rock.Color, MSCX-65, MSCY-65, MSCX+65, MSCY+65, Rock.Tol)) or
(GetAnimation <= 0) then
begin
if (IC = InvCount) then Exit
else
Break;
end;
until (not IC = InvCount) and (GetAnimation <= 0);
Result := True;
Inc(Mined);
Inc(Players[CurrentPlayer].Integers[10]);
Inc(Stats_CustomVars[1]);
case Players[CurrentPlayer].Strings[0] Of
'copper' : Inc(Stats_CustomVars[6]);
'tin' : Inc(Stats_CustomVars[7]);
'iron' : Inc(Stats_CustomVars[8]);
'coal' : Inc(Stats_CustomVars[11]);
'mith' : Inc(Stats_CustomVars[12]);
End;
end;


Function MineOre(which: TOre): boolean;
var x, y, T:integer;
begin
if not LoggedIn then Exit;
Result := true;
FindNormalRandoms;
wait(random(500));
T := GetSystemTime;
while (not FindOre(which, x, y)) do
begin
AntiRandoms;
Case Random(2) Of
0: Wait(200 + Random(500));
1: SleepAndMoveMouse(400 + Random(1000));
End;
If (GetSystemTime - T > 60000) Then
begin
writeln('couldn''t find ore?'); //lol lol lol lol
Result := false;
exit;
end;
end;
if FindOre(which, x, y) then
begin
case Random(10) of
0..8: Mouse(x, y, 0, 0, True);
9:
begin
Mouse(x, y, 0, 0, False);
if (not WaitOption('ine R', 250)) then Exit;
end;
end;
WaitUntilMined(which);
end;
Status('Finding Rocks');
end;

Procedure TakeCareOfStuff;
var
i, c, x, y : integer;
TB : TBox;
begin
if not InvFull then exit;
FindNormalRandoms;
TakePic;
GameTab(tab_Inv);
Inc(Players[CurrentPlayer].Banked);
Inc(Stats_CustomVars[4]);
c := CountItemsIn('inv', 'dtm', OreDTM, []);
ExpGained;
IncEx(Stats_CustomVars[3], Round(XPGain[g] * c));
if Players[CurrentPlayer].Booleans[0] then
begin
DropAll;
exit;
end;

for i:= 1 to 28 do
begin
if not ExistsItem(i) then continue;
TB := InvBox(i);
if not FindDTM(AxeDTM, x, y, TB.x1, TB.y1, TB.x2, TB.y2) then
DropItem(i);
end;
FindNormalRandoms;
ProgressReport;
end;




Procedure PlayerSetup;
begin
Ore := WhichOre(LowerCase(Players[CurrentPlayer].Strings[0]));
LoginPlayer;
MarkTime(RestTime);
SetAngle(true);
FindNormalRandoms;
CheckAxe;
MakeCompass('s');
Writeln('Player has been Setup');
end;

Procedure SwitchPlayers;
begin
begin
if (PlayersActive > 1)or(not LoggedIn) then
begin
LogOut;
NextPlayer(Players[CurrentPlayer].Active);
PlayerSetup;
Inc(Switched);
exit;
end;
IncEx(Players[CurrentPlayer].Worked, TimeFromMark(RestTime));
PlayerSetup;
end;
end;



Procedure ScriptSetup;
var
a, b, c: string;
d: Boolean;
i : integer;
begin
SetupSRL;
if Stats_GetScriptInfo(a, b, c, d, i) then
begin
WriteLn('Latest Version: ' + a);
if (b <> '') then
WriteLn('News: ' + b);
if (c <> '') then
WriteLn('Link: ' + c);
WriteLn('Oudated: ' + BoolToStr(d));
WriteLn('Last Update: ' + IntToStr(i) + ' hours ago.');
end;
ActivateClient;
SRL_Procs[srl_OnLogOut] := @TakePic;
AxeDTM := DTMFromString('78DA630C67666058C1C8800A98C0244C94310' +
'2A8661901353144989348849A24A09AB54498B391809A04A09A1D' +
'44987380809A78A09AFD44B8791F0135C940353B09A84901AAD94' +
'4404D1A11E1930E54B39A809A0CA09A5504D4E410A1A600A8660D' +
'116A88B18B50DAC802AA594E404D2A50CD1222E27429013551F8D' +
'3BC281003002DD91957');
OreDTM := DTMFromString('78DA63DCCECCC0309D9101153081499828E35' +
'EA09A1904D41C03AA594D40CD41A09A99B8D53083E81340722E01' +
'35EB80E47CDC6AC0780D50CD5A026A5603D5AC2042CD12026AB60' +
'2D56C22A06637116A4E01D52C24A00614CECB8870CF2CFC6A0052' +
'631395');

DeclarePlayers;
StartTime:=GetSystemTime;
end;

procedure ProgressReport;
var
i, P, OresDone, LoadsDone, Sec, Orerate, LoadRate :integer;
tmp, XPGained, ExpRate : Extended;
s: string;
begin
Stats_ManageAccounts;
for P := 0 to HowManyPlayers - 1 do
begin
OresDone := (Players[P].Integers[10] + OresDone);
LoadsDone := (Players[P].Banked);
EXPGained;
tmp := Players[CurrentPlayer].Integers[10]*XpGain[g];
Players[CurrentPlayer].Extendeds[0] := tmp;
XPGained := XPGained + tmp;
end;
Sec:= (1+((Getsystemtime-StartTime)/1000));
OreRate:=(3600*(OresDone))/(Sec);
LoadRate:=(3600*(LoadsDone))/(Sec);
ExpRate:=(3600*(XPGained))/(Sec);
ClearDebug;
Writeln('//---------------------------------------\\');
Writeln('| The Man''s Extravagant Power Miner EPM |');
Writeln('| Version '+Version+' |');
Writeln('\\---------------------------------------//');
if(HowManyPlayers > 1)then
Writeln('//-- Multiplayer ('+IntToStr(HowManyPlayers)+')--')
else
Writeln('//------------ Single Player ------------\\');
for i := 0 to HowManyPlayers - 1 do
begin
Writeln('| Player['+IntToStr(i)+'] Active: '+BoolToStr(Players[i].Active)+'|');
Writeln('| Time Running: '+TimeRunning+' |');
Writeln('| Ores Mined: '+IntToStr(Players[i].Integers[10])+' |');
Writeln('| Loads: '+IntToStr(LoadsDone)+' |');
Writeln('| Ores Mined at a rate of '+IntToStr(OreRate)+' per hour |');
Writeln('| Loads Mined at a rate of '+IntToStr(LoadRate)+' per hour |');
Writeln('| EXP Gained '+FloatToStr(XPGained));
Writeln('| EXP Gained at a rate of '+FloatToStr(ExpRate)+' per hour |');
Writeln('| Changed player: '+IntToStr(Switched)+' time/s |');
Writeln('| Please give feedback |');
Writeln('\\----------------------------------------//');
end;
SrlRandomsReport;
Stats_SendReport;
if SaveReport then
begin
i := ReWriteFile(ScriptPath + ScriptName + '.txt', False);
WriteFileString(i, s);
CloseFile(i);
writeln('Progress report saved to: ' + ScriptPath + ScriptName + '.txt');
end;
end;

begin
{$IFDEF SRL_SMART}
Smart_Server := SmartWorld;
Smart_Signed := True;
Smart_Members := SmartMembers;
{$ENDIF}
Stats_ScriptID := '30'; //DO NOT EDIT
Stats_Link := 'http://scriptmanager.freehostia.com/submit.php';
ScriptSetup;
wait(500);
PlayerSetup;
repeat
for I := 0 to High(Players) do
begin
Disguise('Mined '+IntToStr(Mined)+' Rocks');
End;
if (Players[CurrentPlayer].Banked >= Players[CurrentPlayer].Integers[2]) then
begin
Writeln('Finished '+Players[Currentplayer].Name+'''s Loads');
Logout;
SwitchPlayers;
end;
while not InvFull do
begin
if not LoggedIn then break;
if not MineOre(Ore) then
begin
Writeln('Couldn''t Mine Ore, switching player');
Inc(Players[CurrentPlayer].Integers[1]);
if Players[CurrentPlayer].Integers[1] > 3 then
begin
Players[CurrentPlayer].Active := False;
Writeln('Going to false, failed Ore 3 times');
end;
LogOut;
end;
end;
TakeCareOfStuff;
ProgressReport;
until(false);
end.

Here is the problem:
function WaitUntilMined(Rock: TOre): Boolean;
var
GetAnimationTime, T, CX, CY, IC, P: Integer;
begin
Status('Walking to Rock');
MarkTime(t);
SetColorspeed2Modifiers(Rock.Hue, Rock.Sat);
repeat
Wait(10);
if (TimeFromMark(t) >= 6000) then Exit;
until (not FlagPresent) and FindBlackChatMessage('u swi') and
(FindColorTolerance(cx, cy, Rock.Color, MSCX-65, MSCY-65, MSCX+65, MSCY+65, Rock.Tol));
Status('Mining Rock');
IC := InvCount;
MarkTime(t);
repeat
Wait(10);
if (TimeFromMark(t) >= 12000) then Exit;
if (not FindColorTolerance(cx, cy, Rock.Color, MSCX-65, MSCY-65, MSCX+65, MSCY+65, Rock.Tol)) or
(GetAnimation <= 0) then
begin
if (IC = InvCount) then Exit
else
Break;
end;
until (not IC = InvCount) and (GetAnimation <= 0);
Result := True;
Inc(Mined); // From here
Inc(Players[CurrentPlayer].Integers[10]);
Inc(Stats_CustomVars[1]);
case Players[CurrentPlayer].Strings[0] Of
'copper' : Inc(Stats_CustomVars[6]);
'tin' : Inc(Stats_CustomVars[7]);
'iron' : Inc(Stats_CustomVars[8]);
'coal' : Inc(Stats_CustomVars[11]);
'mith' : Inc(Stats_CustomVars[12]); // To here
End;
end;

It isn't counting my ores :S

And here is my Progress Report:

procedure ProgressReport;
var
i, P, OresDone, LoadsDone, Sec, Orerate, LoadRate :integer;
tmp, XPGained, ExpRate : Extended;
s: string;
begin
Stats_ManageAccounts;
for P := 0 to HowManyPlayers - 1 do
begin
OresDone := (Players[P].Integers[10] + OresDone);
LoadsDone := (Players[P].Banked);
EXPGained;
tmp := Players[CurrentPlayer].Integers[10]*XpGain[g];
Players[CurrentPlayer].Extendeds[0] := tmp;
XPGained := XPGained + tmp;
end;
Sec:= (1+((Getsystemtime-StartTime)/1000));
OreRate:=(3600*(OresDone))/(Sec);
LoadRate:=(3600*(LoadsDone))/(Sec);
ExpRate:=(3600*(XPGained))/(Sec);
ClearDebug;
Writeln('//---------------------------------------\\');
Writeln('| The Man''s Extravagant Power Miner EPM |');
Writeln('| Version '+Version+' |');
Writeln('\\---------------------------------------//');
if(HowManyPlayers > 1)then
Writeln('//-- Multiplayer ('+IntToStr(HowManyPlayers)+')--')
else
Writeln('//------------ Single Player ------------\\');
for i := 0 to HowManyPlayers - 1 do
begin
Writeln('| Player['+IntToStr(i)+'] Active: '+BoolToStr(Players[i].Active)+'|');
Writeln('| Time Running: '+TimeRunning+' |');
Writeln('| Ores Mined: '+IntToStr(Players[i].Integers[10])+' |');
Writeln('| Loads: '+IntToStr(LoadsDone)+' |');
Writeln('| Ores Mined at a rate of '+IntToStr(OreRate)+' per hour |');
Writeln('| Loads Mined at a rate of '+IntToStr(LoadRate)+' per hour |');
Writeln('| EXP Gained '+FloatToStr(XPGained));
Writeln('| EXP Gained at a rate of '+FloatToStr(ExpRate)+' per hour |');
Writeln('| Changed player: '+IntToStr(Switched)+' time/s |');
Writeln('| Please give feedback |');
Writeln('\\----------------------------------------//');
end;
SrlRandomsReport;
Stats_SendReport;
if SaveReport then
begin
i := ReWriteFile(ScriptPath + ScriptName + '.txt', False);
WriteFileString(i, s);
CloseFile(i);
writeln('Progress report saved to: ' + ScriptPath + ScriptName + '.txt');
end;
end;

If someone can help me / Fix it.
I may have a prize :)

Cheers
T~M

Frement

2010-01-28 12:47:46

function WaitUntilMined(Rock: TOre): Boolean;
var
GetAnimationTime, T, CX, CY, IC, P: Integer;
begin
Status('Walking to Rock');
MarkTime(t);
SetColorspeed2Modifiers(Rock.Hue, Rock.Sat);
repeat
Wait(10);
if (TimeFromMark(t) >= 6000) then Exit;
until (not FlagPresent) and FindBlackChatMessage('u swi') and
(FindColorTolerance(cx, cy, Rock.Color, MSCX-65, MSCY-65, MSCX+65, MSCY+65, Rock.Tol));
Status('Mining Rock');
IC := InvCount;
MarkTime(t);
repeat
Wait(10);
if (TimeFromMark(t) >= 12000) then Exit;
if (not FindColorTolerance(cx, cy, Rock.Color, MSCX-65, MSCY-65, MSCX+65, MSCY+65, Rock.Tol)) or
(GetAnimation <= 0) then
begin
if (IC = InvCount) then
begin
Result := True;
Inc(Mined);
Inc(Players[CurrentPlayer].Integers[10]);
Inc(Stats_CustomVars[1]);
case Players[CurrentPlayer].Strings[0] Of
'copper' : Inc(Stats_CustomVars[6]);
'tin' : Inc(Stats_CustomVars[7]);
'iron' : Inc(Stats_CustomVars[8]);
'coal' : Inc(Stats_CustomVars[11]);
'mith' : Inc(Stats_CustomVars[12]);
End;
Exit;
end else
Break;
end;
until (not IC = InvCount) and (GetAnimation <= 0);
Result := True;
Inc(Mined);
Inc(Players[CurrentPlayer].Integers[10]);
Inc(Stats_CustomVars[1]);
case Players[CurrentPlayer].Strings[0] Of
'copper' : Inc(Stats_CustomVars[6]);
'tin' : Inc(Stats_CustomVars[7]);
'iron' : Inc(Stats_CustomVars[8]);
'coal' : Inc(Stats_CustomVars[11]);
'mith' : Inc(Stats_CustomVars[12]);
End;
end;

Now it does count them :)

Dynamite

2010-01-28 13:05:52

Hmm, it counts them now, but counts too many :s

weequ

2010-01-28 14:23:39

if (not FindColorTolerance(cx, cy, Rock.Color, MSCX-65, MSCY-65, MSCX+65, MSCY+65, Rock.Tol)) or
The ore might not always be visible so change try changing it something like:

if (not FindColorTolerance(cx, cy, Rock.Color, MSCX-65, MSCY-65, MSCX+65, MSCY+65, Rock.Tol)) then Inc(I)
else I := 0;
if I > 9 then Exit;

Coh3n

2010-01-29 02:18:38

Probably one of the simplest ways to count your ores would be to make a bitmap mask and use CountItems. Will be faster then what you're doing because you can count when the inventory is full, instead of EVERY time an ore is mined.

And you function, it probably doesn't count it because it's exiting. Try changing those exits to breaks.

code841

2010-01-29 02:52:29

Function OreCount(xItem: string): integer;
var Ore1,Ore2,GemDTM: integer;
begin
Ore1 := BitmapFromString(6, 3, 'beNpTlWFgYDJQUACSUlIiiop' +
'SqqoIETk5cewiAHjOBJE=');
Ore2 := BitmapFromString(7, 3, 'beNqzDGFgYDJQUACSauqW+vp' +
'uRkbeJia+cEEtLTugoKlZgLl5EFxQW8fRwNADKGgBABgJCV0=');
GemDTM := DTMFromString('78DA63CC65626078C28002F885F219FE03694' +
'620FE0F048CC940357719D00013986484F2184B80FC0704D49401' +
'F96F08A8C906F23F10509302E4BFC6AF0600D8760D9F');
Case LowerCase(xItem) of
'coal' : Result:=(CountItems('bmp',Ore1,[15]));
'mith' : Result:=(CountItems('bmp',Ore2,[15]));
'both' : begin
Result:=(CountItems('bmp',Ore1,[15])+CountItems('bmp',Ore2,[15]));
end;
'gem' : Result:=(CountItems('DTM',GemDTM,[15]));
end;
FreeBitmap(Ore1);
FreeBitmap(Ore2);
FreeDTM(GemDTM);
end;

I use that function in my guild miner.

EDIT:
On a similar subject, I was wondering if there is an existing function or list of co-ordinates for every item slot in your inventory.
Like I want to know where the exact center of each itemslot is (their x,y co-ordinates). I manually made a list ages ago but lost it and was wondering if there is an already existing function.

Coh3n

2010-01-29 11:50:34

From: code841

EDIT:
On a similar subject, I was wondering if there is an existing function or list of co-ordinates for every item slot in your inventory.
Like I want to know where the exact center of each itemslot is (their x,y co-ordinates). I manually made a list ages ago but lost it and was wondering if there is an already existing function.

Yes, there is. ;)


{*******************************************************************************
Function InvBox(i :Integer): TBox;
By: Boreas. Coords by Ogre July 15th 2009.
Description: Returns TBox of surrounding Inventory SlotBox
1-2-3-4
5-6-7-8
etc.
*******************************************************************************}

function InvBox(I :Integer): TBox;
var
Slot1, Slot6: TBox;
begin
if not InRange(I, 1, 28) then
begin
srl_Warn('InvBox', 'Incorrect index: ' + IntToStr(i), warn_AllVersions);
Exit;
end;
Slot1 := IntToBox(563, 213, 594, 244);
Slot6 := IntToBox(605, 249, 31415, 92653);
Result.x1 := Slot1.X1 + ((((i + 3) mod 4)) * (Slot6.X1 - Slot1.X1));
Result.y1 := Slot1.Y1 + ((((i - 1) / 4)) * (Slot6.Y1 - Slot1.Y1));
Result.x2 := Result.x1 + (Slot1.X2 - Slot1.X1);
Result.y2 := Result.y1 + (Slot1.Y2 - Slot1.Y1);
end;