SCAR Code:
// RM
// Guild Miner
{$define SMART}
{.include srl/srl.scar}
{.include srl/srl/misc/SmartColors.scar}
{||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||}
{|||| REMEMBER TO ALWAYS USE THE LATEST DEVELOPER REVISION |||}
{||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||}
{
avoid rocks with animation
magic mining
detecting where players are far from rocks
avoid clicking black guild
WhileMining
Unwielded pick
Multiplayer
Proggie
}
const
//SRL Stats
SCRIPT_ID = '43';
USER_ID = ''; //the number in bold on you profile page goes here
USER_PW = '';
STATS_LOADS = 1;
//Player Modifiable
pickequiped = true;
//UpText waits
UT_WAIT_FRENZY = 30; //i have these set low
UT_WAIT_FAST = 60;
UT_WAIT_HUMAN = 100;
//InvCount waits
IC_WAIT_FRENZY = 3000; //max time to wait for rock appear into
IC_WAIT_FAST = 3500; //your inventory, after this time script will
IC_WAIT_HUMAN = 7000; //click another rock
//Random wait after rock
R_WAIT_FRENZY = 300;
R_WAIT_FAST = 900;
R_WAIT_HUMAN = 3000;
//Distance to Guild Door
MIN_DOOR_DIST = 55; //this doesnt matter cuz its a powerminer now
//Script Only
//Player Indexes
//bools
P_WIELDED = 0;
//ints
P_MITHP = 0; // x / 100 to check for mith
P_BANK_TRIES = 1;
//Location Indexes
LOC_BANK = 0;
LOC_OUT = 1;
LOC_GUILD = 2;
//Inside Guild Locs
GUILD_ENTRANCE = 3;
GUILD_LEFT = 4;
GUILD_CENTER = 5;
GUILD_TOP = 6;
//Symbols
SYMBOL_BANK = 0;
SYMBOL_DUNGEON = 1;
SYMBOL_MINING = 3;
//SmartColors indexes
ROCK_COAL = 0;
ROCK_MITH = 1;
LADDER_OUTSIDE = 2;
LADDER_INSIDE = 3;
BANK_BOOTH = 4;
//PickAxe Indexes
AXE_BRONZE = 0;
AXE_IRON = 1;
AXE_STEEL = 2;
AXE_MITH = 3;
AXE_ADDY = 4;
AXE_RUNE = 5;
AXE_DRAGON = 6;
//PickAxe Level Requirements
LVL_BRONZE = 1;
LVL_IRON = 1;
LVL_STEEL = 6;
LVL_MITH = 21;
LVL_ADDY = 31;
LVL_RUNE = 41;
LVL_DRAGON = 61;
//Mining Mode
FRENZY = 0;
FAST = 1;
HUMAN = 2;
//Mining Stages
STAGE_TO_ROCK = 0;
STAGE_WAIT_ROCK = 1;
//Mining Messages & Indexes
SWING_PICK = 0;
MANAGE_MINE = 1;
NO_ORE = 2;
MSG_SWING_PICK = 'swing your pick' ;
MSG_MANAGE_MINE = 'manage to mine' ;
MSG_NO_ORE = 'no ore currently';
//Preset Colors
SYMBOL_OUTLINE = 65536;
SYMBOL_FILL = 12632256;
MM_BLACK = 66819; {66309, 67328}
MM_DOOR = 197874; {133101, 197111}
//Rock_Color = 2436419; //that is the color of iron
COLOR_MITH = 2436419; {7954013, 8085343, 7822428, 7822428, 7493719, 6770768, 7230805}
COLOR_BANK = 4153982;
COLOR_OUT_LADDER = 3958140;
COLOR_IN_LADDER = 3754838;
type
TMode = record
WaitUpText : integer;
WaitInvCount : integer;
WaitRandom : integer;
end;
TSymbol = record
Color : integer;
Tol : integer;
Hue : extended;
Sat : extended;
end;
var
UseMode: TMode;
Loads,x,y,oresdid,starttime,dbgw: integer;
TimeGoing: integer;
BankDTM: integer;
PickDTM, Rock_Color: integer;
mtp:tpointarray;
{ RM --------------------------------------------------------------------------]
[ End User Input for players ]
[------------------------------------------------------------------------------}
Procedure DeclarePlayers;
begin
NumberOfPlayers(1);
CurrentPlayer := 0;
Rock_color := 2436419;// that is the color of iron, so you have to change to
// the color of the rock you will be powermining
with Players[0] do
begin
Name :='USERNAME';
Pass :='PASSWORD';
Nick :='a section of your USERNAME thats 3-4letters long';
Active := True; //if you set to false then this player will not be used so dont touch
Integers[P_MITHP] := 00; // percent chance to check for mith, do not change
end; // it from 0 because it is for the guildminer
end;
{$IFNDEF RM}
const
Stats_Link = 'http://scriptmanager.freehostia.com/submit.php';
var
Stats_UserID, Stats_Password, Stats_ScriptID: string;
Stats_LastTime: Integer;
Stats_CustomVars: array [1..20] of Integer;
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;
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;
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;
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('.|€stat€|.', [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;
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('.|€stat€|.', 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;
{$ENDIF}
{ RM --------------------------------------------------------------------------]
[ Checks for Bank or Pin Screen ]
[------------------------------------------------------------------------------}
function BorPScreen: boolean;
begin
Result := ((BankScreen)or(PinScreen));
writeln('BorPScreen: ' + BoolToStr(Result));
end;
{ RM --------------------------------------------------------------------------]
[ Figures out the best axe to use ]
[------------------------------------------------------------------------------}
function BestAxe: integer;
begin
case Players[CurrentPlayer].Level[Skill_Mining] of
LVL_DRAGON .. 99 : Result := AXE_DRAGON ;
LVL_RUNE .. LVL_DRAGON : Result := AXE_RUNE ;
LVL_ADDY .. LVL_RUNE : Result := AXE_ADDY ;
LVL_MITH .. LVL_ADDY : Result := AXE_MITH ;
LVL_STEEL .. LVL_MITH : Result := AXE_STEEL ;
else Result := AXE_IRON;
end;
end;
{ RM --------------------------------------------------------------------------]
[ Checks where the PickAxe is. ]
[------------------------------------------------------------------------------}
Function CheckPickAxe: boolean;
var
CT, i, x, y : Integer;
TC: TIntegerArray;
begin
if not LoggedIn then exit;
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(PickDTM, x, y, MIX1, MIY1, MIX2, MIY2) then
begin
Result := true;
Players[CurrentPlayer].Booleans[P_WIELDED] := (TC[i] = TAB_EQUIP);
if Players[CurrentPlayer].Booleans[P_WIELDED] then
writeln('Pick is Equipped')
else
writeln('Pick is in Inv');
exit;
end;
end;
if i > 1 then
begin
LogOut;
Players[CurrentPlayer].Active := false;
Players[CurrentPlayer].Rand := 'No Pick';
end;
end;
{ RM --------------------------------------------------------------------------]
[ Sets the different mining modes ]
{------------------------------------------------------------------------------}
procedure SetMode(myMode: integer);
begin
case myMode of
FRENZY:
begin
with UseMode do
begin
WaitUpText := UT_WAIT_FRENZY;
WaitInvCount := IC_WAIT_FRENZY;
WaitRandom := R_WAIT_FRENZY;
end;
end;
FAST:
with UseMode do
begin
WaitUpText := UT_WAIT_FAST;
WaitInvCount := IC_WAIT_FAST;
WaitRandom := R_WAIT_FAST;
end;
end;
end;
{ RM --------------------------------------------------------------------------]
[ Results true if sentence matches one of the texts. Uses Pos. Returns the ]
[ Array index. ]
{------------------------------------------------------------------------------}
Function InStrArrExPosReverse(S: String; StrArr: TStringArray; Var Where: Integer): Boolean;
Var
I, H: Integer;
Begin
H := High(StrArr);
For I := 0 To H Do
If (Pos(LowerCase(StrArr[i]), LowerCase(S)) > 0) Then
Begin
Where := i;
Result := True;
Break;
End;
End;
{ RM --------------------------------------------------------------------------]
[ Gets CTS Info ]
[------------------------------------------------------------------------------}
procedure GetCTS(var speed: integer; var H, S: extended);
begin
speed := GetColorToleranceSpeed;
GetColorspeed2Modifiers(H, S);
end;
{ RM --------------------------------------------------------------------------]
[ Sets CTS info ]
[------------------------------------------------------------------------------}
procedure SetCTS(speed: integer; H, S: extended);
begin
ColorToleranceSpeed(speed);
SetColorspeed2Modifiers(H, S);
end;
{ RM --------------------------------------------------------------------------]
[ Finds symbol Which through TPA Analysis ]
[------------------------------------------------------------------------------}
Function FindSymbolWithTPA(Which: integer; var Where: TPoint): boolean;
var
TPA : TPointArray;
ATPA: T2DPointArray;
TBArr : TBoxArray;
i, h, t, waste, CTS: integer;
Hue, Sat: extended;
TIA: TIntegerArray;
Symb: TSymbol;
begin
if not FindColors(TPA, SYMBOL_OUTLINE, MMX1, MMY1, MMX2, MMY2) then
begin
srl_warn('FindSymbolThroughTPA', 'Could not find symbol', warn_AllVersions);
exit;
end;
ATPA := SplitTPA(TPA, 2);
t := 0;
h := High(ATPA);
SetLength(TIA, h + 1);
SetLength(TBArr, h + 1);
for i:= 0 to h do
begin
TBArr[i] := GetTPABounds(ATPA[i]);
if FindColor(waste, waste, SYMBOL_FILL, TBArr[i].x1, TBArr[i].y1, TBArr[i].x2, TBArr[i].y2) then
begin
TIA[t] := i;
Inc(t);
end;
end;
if (t = 0) then
begin
writeln('Impossible walk');
Result := false;
exit;
end;
SetLength(TIA, t);
case which of
SYMBOL_BANK :
with Symb do
begin
Color := 6542813; {2216175, 4694448, 9697013}
Tol := 15;
Hue := 0.10;
Sat := 1.49;
end;
SYMBOL_DUNGEON:
with Symb do
begin
Color := 6645236; {10526972, 2763504, 5263604}
Tol := 13;
Hue := 0.0;
Sat := 0.29;
end;
SYMBOL_MINING:
with Symb do
begin
Color := 8092796;
Tol := 14;
Hue := 2.39;
Sat := 0.03;
end;
end;
GetCTS(CTS, Hue, Sat);
SetCTS(2, Symb.Hue, Symb.sat);
for i:= 0 to t-1 do
begin
h := TIA[i];
if FindColorsTolerance(TPA, Symb.Color, TBArr[h].x1, TBArr[h].y1, TBArr[h].x2, TBArr[h].y2, Symb.Tol) then
begin
Where := MiddleTPA(TPA);
Result := true;
break;
end;
end;
SetCTS(CTS, Hue, Sat);
if i = t then
writeln('could not find symbol fill');
end;
{ RM --------------------------------------------------------------------------]
[ Clicks the Rocks/Ladder Zone ]
[------------------------------------------------------------------------------}
function FindMMLadder(var TP: TPoint): boolean;
var
TB: TBox;
ATPA: T2DPointArray;
TPA: TPointArray;
CTS, i: integer;
H, S: extended;
begin
result := false;
GetCTS(CTS, H, S);
SetCTS(2, 0.45, 4.10);
{143195, 403800, 404566}
if not FindColorsTolerance(TPA, 996441, MMX1, MMY1, MMX2, MMY2, 6) then
begin
SetCTS(CTS, H, S);
exit;
end else begin
SetCTS(CTS, H, S);
//avoiding confusion with mining symbol
ATPA := TPAtoATPAEx(TPA, 10, 20);
for i := 0 to High(ATPA) do
begin
TB := GetTPABounds(ATPA[i]);
writeln('x axis: ' + IntToStr(TB.x2 - TB.x1));
writeln('y axis: ' + IntToStr(TB.y2 - TB.y1));
if ((TB.x2 - TB.x1) > 5) then
if ((TB.y2 - TB.y1) > 11) then
Result := true
else
Result := false
else
Result := false;
if Result then
begin
TPA := ATPA[i];
TP := MiddleTPA(TPA);
if not InCircle(TP.x, TP.y, MMCX, MMCY, ((MMX2 - MMX1) / 2) - 5) then
begin
Result := false;
continue;
end;
break;
end;
end;
end;
end;
{ RM --------------------------------------------------------------------------]
[ Finds the door to noobie guild on Minimap ]
[------------------------------------------------------------------------------}
Function FindMMDoor(var TP: TPoint): boolean;
var
TPA: TPointArray;
ATPA: T2DPointArray;
i, CTS: integer;
H, S: extended;
begin
GetCTS(CTS, H, S);
SetCTS(2, 49.79, 0.84);
Result := FindColorsTolerance(TPA, MM_DOOR, MMX1, MMY1, MMX2, MMCY, 2);
if Result then
begin
Result := False;
ATPA := SplitTPA(TPA, 2);
for i:= High(ATPA) DownTo 0 do
if (Length(ATPA[i]) <= 5) then
begin
Result := True;
TP := MiddleTPA(ATPA[i]);
end;
end;
SetCTS(CTS, H, S);
end;
{ RM --------------------------------------------------------------------------]
[ Finds text <> MSG_SWING_PICK and returns its line ]
[------------------------------------------------------------------------------}
Function FindNeutralText(var text: string): integer;
var
i: integer;
begin
for i := 8 DownTo 1 do
begin
text := lowercase(GetChatBoxText(i, clMessage));
if not (Pos(MSG_SWING_PICK, text) > 0 ) then
break;
end;
Result := i;
end;
{ RM --------------------------------------------------------------------------]
[ Returns true if successfully started mining a rock. False otherwise ]
[------------------------------------------------------------------------------}
function CheckChat(PreviousMessage: string; CheckPlace, Stage, Time: integer): boolean;
var
ChatMessage: string;
NewMsg, MyTime: integer;
begin
writeln('in check chat');
MyTime := GetSystemTime + Time;
ChatMessage := lowercase(GetChatBoxText(CheckPlace, clMessage));
while MyTime > GetSystemTime do
begin
if PreviousMessage = ChatMessage then
begin
wait(50);
ChatMessage := lowercase(GetChatBoxText(CheckPlace, clMessage));
end else
break;
wait(100);
end;
ChatMessage := lowercase(GetChatBoxText(8, clMessage)); // 8 = last line of chat box
if ChatMessage = PreviousMessage then
begin
writeln('No Chat change');
exit;
end;
if not InStrArrExPosReverse(ChatMessage, [MSG_SWING_PICK, MSG_MANAGE_MINE, MSG_NO_ORE], NewMsg) then
begin
writeln('New: unidentified chat; ' + ChatMessage);
// relocating
if Pos('reach that', ChatMessage) > 0 then
Mouse(MMCX, MMCY + 60, 5, 5, true);
wait(4000+random(2000));
exit;
end;
case Stage of
STAGE_TO_ROCK:
begin
case NewMsg of
SWING_PICK:
begin
Result := true;
exit;
end;
else
begin
Result := false;
exit;
end;
end;
end;
STAGE_WAIT_ROCK:
Result := not (ChatMessage = MSG_SWING_PICK);
end;
end;
{ RM --------------------------------------------------------------------------]
[ Returns true if in guild = Wanted ]
[------------------------------------------------------------------------------}
function InGuild(time: integer; Wanted: boolean): boolean;
var
t, CTS: integer;
TPA: TPointArray;
H, S: extended;
begin
if not LoggedIn then exit;
CTS := GetColorToleranceSpeed;
GetColorspeed2Modifiers(H, S);
ColorToleranceSpeed(1);
SetColorspeed2Modifiers(0.20, 0.20);
t := GetSystemTime + time;
while t >= GetSystemTime do
begin
FindColorsTolerance(TPA, MM_BLACK, MMX1, MMY1, MMX2, MMY2, 10);
Result := (Length(TPA) > 2000);
writeln('In Guild? '+ BoolToStr(Result));
writeln('Black Points: ' + IntToStr(Length(TPA)));
if Result = Wanted then
break
else
wait(250);
end;
ColorToleranceSpeed(CTS);
SetColorspeed2Modifiers(H, S);
end;
{ RM --------------------------------------------------------------------------]
[ Returns Which Part of the Guild we are in ]
[------------------------------------------------------------------------------}
function AtGuildLoc : integer;
var
TP: TPoint;
begin
{
//Inside Guild Locs
GUILD_ENTRANCE = 3;
GUILD_LEFT = 4;
GUILD_CENTER = 5;
GUILD_TOP = 6;
}
if FindMMLadder(TP) then
if Distance(TP.x, TP.y, MMCX, MMCY) < 7 then
Result := GUILD_TOP
else
end;
{ RM --------------------------------------------------------------------------]
[ Walks to Where ]
[------------------------------------------------------------------------------}
function WalkSymbol(Where: integer): boolean;
var
TP, TP2: TPoint;
begin
writeln('walking to ' + IntToStr(where));
SetRun(true);
if Where = SYMBOL_BANK then
TP := Point(MMCX - 10, MMCY - 35)
else
TP := Point(MMCX + 10, MMCY + 35);
if not FindSymbolWithTPA(Where, TP2) then
begin
writeln('couldn''t find symbol. Blind Click');
MouseMM(TP.x, TP.y, 3, 3);
Result := false;
while IsMoving do
FFlag(5);
end else begin
Mouse(TP2.x, TP2.y, 2, 2, true);
Result := true;
end;
if not Result then
if FindSymbolWithTPA(Where, TP) then
begin
Mouse(TP.x, TP.y, 2, 2, true);
Result := true;
end else begin
writeln('Unable to Symbol Walk');
Result := false;
exit;
end;
if Result then
begin
FFlag(5);
while IsMoving do
FFlag(5);
end;
writeln('Walked: ' + BoolToStr(Result));
end;
{ RM --------------------------------------------------------------------------]
[ Clicks the Rocks/Ladder Zone ]
[------------------------------------------------------------------------------}
function ClickMMLadder: boolean;
var
TP: TPoint;
begin
writeln('Clicking MM Ladder');
Result := FindMMLadder(TP);
if Result then
begin
Mouse(TP.x, TP.y, 3, 3, true);
writeln('Clicked MM Ladder');
end else
writeln('Couldn''t Click Ladder');
end;
{ RM --------------------------------------------------------------------------]
[ Moves around in the Guild ]
[------------------------------------------------------------------------------}
function RelocateGuild: boolean;
var
TP: TPoint;
begin
writeln('Relocating in Guild');
FindNormalRandoms;
if FindSymbolWithTPA(SYMBOL_MINING, TP) then
begin
Mouse(TP.x, TP.y, 10, 10, true);
Result := true;
end;
end;
{ RM --------------------------------------------------------------------------]
[ Clicks away from MM door if close to it. ]
[------------------------------------------------------------------------------}
function GetAwayFromDoor: boolean;
var
DoorTP: TPoint;
begin
Result := FindMMDoor(DoorTP);
if not Result then
begin
writeln('No door on MM');
exit;
end else
writeln('Door on MM: ' + IntToStr(distance(DoorTP.x, DoorTP.y, MMCX, MMCY)));
Result := (distance(DoorTP.x, DoorTP.y, MMCX, MMCY) < MIN_DOOR_DIST);
if Result then
Mouse(MMCX, MMCY + 25, 3, 5, true);
wait(100);
while IsMoving do
while FFlag(0) do
wait(100);
end;
{ RM --------------------------------------------------------------------------]
[ Gets out of the guild ]
[------------------------------------------------------------------------------}
Procedure WalkOutGuild;
var
i: integer;
ClickedLadder: Boolean;
begin
writeln('WalkOutGuild');
if not InvFull then exit;
repeat
if not LoggedIn then exit;
FindNormalRandoms;
//just in case we lagged and are outside of guild
if not InGuild(500, false) then
break;
writeln('getting out of guild');
writeln('walking to guild entrance');
for i:= 0 to 2 do
begin
if not LoggedIn then break;
if not InGuild(500, false) then
break;
if ClickMMLadder then
ClickedLadder := True
else begin
Mouse(MMCX - 50, MMCY + 15, 5, 5, true);
writeln('Blind Click');
ClickedLadder := False;
end;
FFlag(10);
while IsMoving do
while FFlag(0) do
wait(500);
if ClickedLadder then
begin
writeln('Clicked MM ladder');
break;
end;
end;
if not ClickedLadder then
begin
LogOut;
Players[CurrentPlayer].Active := False;
Players[CurrentPlayer].Loc := 'lost';
writeln('Didn''t manage to get out of guild');
exit;
end;
wait(random(500));
writeln('looking for ladder');
if not SmartColorsEx(LADDER_INSIDE) then
continue
else begin
while IsMoving do
while FFlag(0) do
wait(500);
wait(2000+Random(1000));
end;
until(not InGuild(10000, false))
writeln('out of guild');
wait(1000+Random(1000));
end;
var i,center,ironx3:integer;
{ RM --------------------------------------------------------------------------]
[ Keeps track of rock while player moves around ]
{------------------------------------------------------------------------------}
Function FollowRock(SC_Index: integer; var ThePoint: TPoint): boolean;
var
ColorArray: TIntegerArray;
Timer, i: integer;
TPA: TPointArray;
TP: TPoint;
begin
//unfinished/untweaked/improper for use
Result := true;
exit;
writeln('Received point('+IntToStr(ThePoint.x)+', '+IntToStr(ThePoint.y)+')');
Result := true;
ColorArray := SCObjectsArray[SC_Index].SCArray;
Timer := GetSystemTime + 3000;
if FindColorsTolerance(TPA, ColorArray[i], ThePoint.x - 40, ThePoint.y - 40, ThePoint.x + 40, ThePoint.y + 40, 10) then
TP := MiddleTPA(TPA)
else
TP := ThePoint;
while (Timer > GetSystemTime)or(IsMoving) do
begin
for i:= 0 to Min(3, High(ColorArray)) do
begin
wait(10);
if not FindColorsTolerance(TPA, ColorArray[i], TP.x - 5, TP.y - 5, TP.x + 5, TP.y + 5, 0) then
if not FindColorsTolerance(TPA, ColorArray[i], TP.x - 10, TP.y - 10, TP.x + 10, TP.y + 10, 0) then
if not FindColorsTolerance(TPA, ColorArray[i], TP.x - 10, TP.y - 10, TP.x + 10, TP.y + 10, 5) then
continue;
TP := MiddleTPA(TPA);
break;
wait(10);
end;
if i > High(ColorArray) then
begin
writeln('unable to follow rock');
Result := false;
break;
end;
end;
ThePoint := TP;
end;
{ RM --------------------------------------------------------------------------]
[ Checks if the Rock we are mining still has ore ]
{------------------------------------------------------------------------------}
Function IsRockHere(SC_Index: integer; Where: TPoint): boolean;
var
ColorArray: TIntegerArray;
CInvCount, i, ColorCount, Rmin, Rmax, Timer: integer;
WhereBox: TBox;
TPA: TPointArray;
begin
//unfinished/untweaked/impropper for use
Result := true;
exit;
Result := false;
ColorArray := SCObjectsArray[SC_Index].SCArray;
Rmin := SCObjectsArray[SC_Index].Details.UNIQUE_COLOR_MIN*5;
Rmax := SCObjectsArray[SC_Index].Details.UNIQUE_COLOR_MAX*5;
WhereBox := IntToBox(
Where.x - SCObjectsArray[SC_Index].Details.HALF_BOX_SIZE,
Where.y - SCObjectsArray[SC_Index].Details.HALF_BOX_SIZE,
Where.x + SCObjectsArray[SC_Index].Details.HALF_BOX_SIZE,
Where.y + SCObjectsArray[SC_Index].Details.HALF_BOX_SIZE
);
Timer := GetSystemTime + 1000;
writeln('Max Points: ' + IntToStr(Rmax));
writeln('Min Point: ' + IntToStr(Rmin));
while (not Result) do
if (Timer > GetSystemTime) then
break
else
for i := 0 to High(ColorArray) do
if FindColorsTolerance(TPA, ColorArray[i], WhereBox.x1, WhereBox.y1, WhereBox.x2, WhereBox.y2, 0) then
if InRange(Length(TPA), Rmin, Rmax) then
begin
Result := true;
break;
end else
writeln('Color Points: '+IntToStr(Length(TPA)));
if not Result then
writeln('Rock is gone');
end;
{ RM --------------------------------------------------------------------------]
[ Mines Ore ]
{------------------------------------------------------------------------------}
Function MineOre(var which: integer): boolean;
var
TP: TPoint;
begin
if Random(100) <= Players[CurrentPlayer].Integers[P_MITHP] then
if FindSymbolWithTPA(SYMBOL_MINING, TP) then
if (TP.x - 5) < MMCX then
if (TP.y - 5) < MMCY then
begin
writeln('Searching for Mith');
Result := SmartColorsEx(ROCK_MITH);
which := ROCK_MITH;
end;
if not Result then
begin
writeln('Searching for Coal');
Result := SmartColorsEx(ROCK_COAL);
which := ROCK_COAL;
end;
end;
{ RM --------------------------------------------------------------------------]
[ Mining Loop ]
{------------------------------------------------------------------------------}
Procedure MineLoop;
var
Timer, ThePlace, TheRock, TTime, SCount, invdropslot: integer;
str: string;
Switch: boolean;
RockPoint: TPoint;
begin
writeln('MineLoop');
// if not InGuild(500, true) then
// exit;
writeln('MineLoop - In guild.');
TTime := GetSystemTime + 15*60*1000;
if not LoggedIn then loginplayer;
repeat
if not LoggedIn then loginplayer;
case random(4) of //if i wandered then head back to rocks
0 :
begin
keydown(VK_UP)
wait(1000+random(100))
keyup(VK_UP)
if finddtm(ironx3,x,y,mmx1,mmy1,mmx2,mmy2) then
mouse(x,y,2,4,true)
else
if finddtm(center,x,y,mmx1,mmy1,mmx2,mmy2) then
begin
mouse(x,y,2,2,true);
if finddtm(ironx3,x,y,mmx1,mmy1,mmx2,mmy2) then
mouse(x,y,2,4,true);
end;
end;
end;
//will only be useful when there is multiplayer or world switching.
{
if TTime < GetSystemTime then
begin
writeln('Load took too long');
LogOut;
Players[CurrentPlayer].Active := false;
Players[CurrentPlayer].Loc := 'Load took too long';
exit;
end;
}
GameTab(TAB_INV);
if InvFull then
begin
writeln('Full Load');
Inc(Loads);
if pickequiped then begin dropall; incex(oresmined,28); else dropallexcept([1]);
Inc(Stats_CustomVars[STATS_LOADS]);
Stats_SendReport;
Stats_ManageAccounts;
break;
end;
ClearReport;
prog; //*************************Proggy!!!*******************************
SetMode(Random(2));
FindNormalRandoms;
while IsMoving do
while FFlag(0) do
wait(250);
GameTab(TAB_INV);
SCount := InvCount;
Timer := GetSystemTime;
//if GetAwayFromDoor then
// writeln('Moved away from MM door.');
if MineOre(TheRock) then
begin
if ((GetSystemTime - Timer) > 5000) then
Switch := true; //avoiding bad / empty locations of guild
ThePlace := FindNeutralText(str);
GetMousePos(RockPoint.x, RockPoint.y);
if not FollowRock(TheRock, RockPoint) then
begin
writeln('unable to follow rock');
continue;
end else begin
{
writeln('Moving Mouse to rock');
writeln('RockPoint X: ' + IntToStr(RockPoint.x));
writeln('RockPoint Y: ' + IntToStr(RockPoint.y));
//MMouse(RockPoint.x, RockPoint.y, 3, 3);
//wait(5000);
}
end;
if CheckChat(str, ThePlace, STAGE_TO_ROCK, 5000) then
begin
Timer := GetSystemTime + UseMode.WaitInvCount;
writeln('Max wait time for rock: '+IntToStr(UseMode.WaitInvCount));
Gametab(TAB_INV);
while (SCount = InvCount) do
begin
{ if FindColor(x, y, srl_outline_black, MIX1,MIY1,MIX2,MIY2) then
begin
invdropslot := coordstoitem(x,y)
dropitem(invdropslot);
if not existsitem(invdropslot) then inc(oresdid);
end;
} wait(100);
if not IsRockHere(TheRock, RockPoint) then
begin
writeln('Rock not here');
break;
end;
if GetSystemTime > Timer then
begin
writeln('Rock took too long');
break;
end;
end;
wait(Random(UseMode.WaitRandom));
end;
if scount <> invcount then inc(oresdid)
end;// else
// Switch := True;
if Switch then
begin
// RelocateGuild;
// Switch := False;
end;
until(false)
end;
function Bank: boolean; forward;
{ RM --------------------------------------------------------------------------]
[ Walks from bank to mining guild ]
[------------------------------------------------------------------------------}
Procedure ToGuild;
var
i: integer;
begin
writeln('ToGuild');
if not LoggedIn then exit;
FindNormalRandoms;
for i := 0 to 2 do
begin
if InvFull then
exit;
//just in case we lagged and are INSIDE the guild
if InGuild(500, true) then
exit;
writeln('getting to guild');
if not WalkSymbol(SYMBOL_DUNGEON) then
continue;
wait(100+random(1000));
While IsMoving do
while FFlag(0) do
wait(500);
break;
end;
if i <= 2 then
SmartColorsEx(LADDER_OUTSIDE)
else begin
Players[CurrentPlayer].Active := false;
LogOut;
Players[CurrentPlayer].Loc := 'lost';
writeln('Player got lost on way to guild');
end;
end;
{ RM --------------------------------------------------------------------------]
[ Walks from mining guild to bank ]
[------------------------------------------------------------------------------}
Procedure ToBank;
var
i, bx, by: integer;
WhichAngle: extended;
begin
writeln('ToBank');
if not LoggedIn then exit;
FindNormalRandoms;
for i:= 0 to 2 do
begin
if InGuild(500, false) then
break;
writeln('getting to bank');
if not WalkSymbol(SYMBOL_BANK) then
if not FindDtmRotated(BankDTM, bx, by, MMX1, MMY1, MMX2, MMY2, Radians(-30), Radians(30), 0.05, WhichAngle) then
continue
else
Mouse(bx, by, 0, 0, True);
writeln('waiting while moving');
While IsMoving do
while FFlag(0) do
wait(500);
writeln('done waiting');
break;
end;
if i <= 2 then
if Bank then
exit;
Players[CurrentPlayer].Active := false;
LogOut;
Players[CurrentPlayer].Loc := 'lost';
writeln('Unable to bank, going false');
end;
{ RM --------------------------------------------------------------------------]
[ Banks ]
[------------------------------------------------------------------------------}
function Bank: boolean;
var i: integer;
begin
writeln('Entering Bank function');
if not LoggedIn then exit;
if InvCount = 1 * Integer(Players[CurrentPlayer].Booleans[P_WIELDED]) then
exit;
if InGuild(500, true) then
exit;
FindNormalRandoms;
writeln('banking');
repeat
for i := 0 to 1 do
begin
if BorPScreen then break;
if i = 0 then
if SmartColorsEx(BANK_BOOTH) then
break;
if i = 1 then
if FindBank(BANK_FE) then
break;
end;
if i > 1 then
begin
writeln('Unable to find bank.');
Result := false;
Inc(Players[CurrentPlayer].Integers[P_BANK_TRIES]);
if Players[CurrentPlayer].Integers[P_BANK_TRIES] <= 1 then
begin
writeln('trying again');
ToBank;
end;
exit;
end;
Players[CurrentPlayer].Integers[P_BANK_TRIES] := 0;
wait(2000+random(1000));
while IsMoving do
while FFlag(0) do
wait(100);
if WaitFunc(@BorPScreen, 100, 5000) then
begin
writeln('in here');
wait(1000+random(500));
DepositAll;
CloseBank;
wait(500+random(500));
Result := true;
break;
end;
until(BorPScreen)
end;
{ RM --------------------------------------------------------------------------]
[ Rests the player if it has been running for more than 20+rand(10) minutes ]
[------------------------------------------------------------------------------}
Procedure Rest;
begin
if (GetSystemTime > TimeGoing) then
begin
writeln('sleeping');
LogOut;
wait(3*60*1000 + Random(3*60*1000));
LoginPlayer;
SetAngle(true);
TimeGoing := (GetSystemTime + 20*60*1000 + Random(10*60*1000));
writeln('restarted');
end;
end;
procedure prog;
var reportstrings:array of tstringarray;
reportstrings[r]:= [{1}'Loads done: '+inttostr(loads),
{2}'Ores mined: '+inttostr(loads*28),
{3}'Xp gained: 'inttostr(loads*28*35,
{4}'',
{5}'',
{6}'',
{7}'',
{8}'',
{9}'',
{10}'',
{11}'',
{12}'']
for i := 0 to high(reportstrings) do addtoreport(reportstrings[p][i])
procedure DebugProggy(TP: TStringArray; DC, Colour, Shadow: integer);
var
MX, MY, Pic, OldDC, I, B, H, TPH, Numb: Integer;
TTP: TPointArray;
begin
SmartSetDebug(True);
GetClientDimensions(mx,my);
Pic:= BitmapFromString(mx,my,'');
OldDC := GetTargetDC;
SetTargetDC(DC);
TPH := High(TP);
for I := 0 to TPH do
begin
TTP := LoadTextTPA(TP[i], Friendchars, H);
for B := 0 to High(TTP) do
begin
Numb := ((I + 1) * 16);
FastSetPixel(Pic, TTP[b].x + 10 + 1, TTP[b].y + 10 + Numb + 1, Shadow);
FastSetPixel(Pic, TTP[b].x + 10, TTP[b].y + 10 + Numb, Colour);
end;
end;
CopyCanvas(GetBitmapCanvas(Pic), GetClientCanvas, 0, 0, mx, my, 0, 0, mx, my);
FreeBitmap(Pic);
SetTargetDC(OldDC);
end;
{procedure dbg;
var
ClientCanvas, DebugCanvas, BMapCanvas: TCanvas;
bmap,mw,mh: Integer;
begin
h := 565;
w := 760;
clearreport;
addtoreport('Loads: '+inttostr(loads));
addtoreport('Debug delay: '+ floatostr(timefrommark(dbgw)/1000));
//display debug image window
//this can be used for debugging or displaying
//something to script user
DisplayDebugImgWindow(mw/2, mh/2);
//obtain canvas of RS window and debug window
DebugCanvas:= GetDebugCanvas;
ClientCanvas:= GetClientCanvas;
//display something to user if you wish
//this one displays upper left corner
CopyCanvas(ClientCanvas, DebugCanvas, 0, 0, h, w, 0, 0, h/2, w/2);
//save the part of client screen if you wish
bmap:= BitmapFromString(100, 100, '');
BMapCanvas:= GetBitmapCanvas(bmap);
CopyCanvas(ClientCanvas, BMapCanvas, 0, 0, h, w, 0, 0, h/2, w/2);
SaveBitmap(bmap, AppPath + 'bmap100x100.bmp');
//well, since we don't really don't need bmap anymore
//let's destroy it and free memory
FreeBitmap(bmap);
marktime(dbgw);
settimeout(5000,'dbg');
writeln('Drawn on Debug window<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><')
end;
{procedure Proggy;
var textss:array of string;xpgained,i,loadrate,orerate,ExpRate,seconds:integer;
begin
XPGained:=oresdid*35;
Seconds:= (1+((TimeFromMark(StartTime))/1000));
OreRate:=(3600*(Oresdid))/(Seconds);
LoadRate:=(3600*(Loads))/(Seconds);
ExpRate:=(3600*(XPGained))/(Seconds);
Round(ExpRate);
Round(LoadRate);
for i := 0 to howmanyplayers-1 do
begin
textss[0]:=' Player['+IntToStr(i)+'] Active: '+BoolToStr(Players[i].Active);
textss[1]:=' Time Running: '+TimeRunning;
textss[2]:=' Ores Mined: '+inttostr(oresdid);
textss[3]:=' Loads: '+IntToStr(loads);
textss[4]:=' Ores Mined at a rate of '+IntToStr(OreRate);
textss[5]:=' Loads Mined at a rate of '+IntToStr(LoadRate);
textss[6]:=' EXP Gained '+FloatToStr(XPGained);
textss[7]:=' EXP Gained at a rate of '+inttostr(round(ExpRate))+'XP/H';
// textss[8]:=' Changed player: '+IntToStr(Switched);
end;
end;
{ RM --------------------------------------------------------------------------]
[ Sets up SmartColors ]
[------------------------------------------------------------------------------}
Procedure SetupColors;
begin
{
SetupSmartColorsDetailsEx(
Index, ColorMin, ColorMax,
MaxColors, BoxSize, Tol,
Dist, ClickStyle, R_RL_Chance
: integer);
}
//coal
MakeObjEx(ROCK_COAL, Rock_Color, 4, 0.35, 0.43, ['ine', 'ock'], ['ine']);
SetupSmartColorsDetailsEx(ROCK_COAL, 3, 100, 7, 30, 10, 15, 3, 15);
//mith
MakeObjEx(ROCK_MITH, COLOR_MITH, 10, 0.13, 0.14, ['ine', 'ock'], ['ine']);
SetupSmartColorsDetailsEx(ROCK_COAL, 3, 100, 7, 30, 10, 15, 3, 15);
//bank booth
MakeObjEx(BANK_BOOTH, COLOR_BANK, 5, 0.03, 1.08, ['ank', 'ooth'], ['ickly', 'quic', 'qui', 'ick']);
SetupSmartColorsDetailsEx(BANK_BOOTH, 3, 300, 7, 50, 10, 15, 2, 100);
//Outside Ladder
MakeObjEx(LADDER_OUTSIDE, COLOR_OUT_LADDER, 5, 0.05, 1.21, ['limb', 'own', 'adder'], ['down']);
SetupSmartColorsDetailsEx(LADDER_OUTSIDE, 2, 100, 7, 150, 20, 20, 2, 15);
//Inside Ladder
MakeObjEx(LADDER_INSIDE, COLOR_IN_LADDER, 5, 0.13, 1.55, ['limb', 'up', 'adder'], ['limb']);
SetupSmartColorsDetailsEx(LADDER_INSIDE, 2, 200, 7, 50, 20, 20, 2, 15);
end;
{ RM --------------------------------------------------------------------------]
[ Prepares the Player for Mining ]
{------------------------------------------------------------------------------}
Procedure SetupPlayer;
begin
TimeGoing := (GetSystemTime + 20*60*1000 + Random(10*60*1000));
if not LoggedIn then
LoginPlayer;
SetAngle(true);
Players[CurrentPlayer].Integers[P_BANK_TRIES] := 0;
end;
{ RM --------------------------------------------------------------------------]
[ Sets up All necessities ]
{------------------------------------------------------------------------------}
Procedure SetupScript;
begin
Smart_Server := 100;
Smart_Signed := true;
AllowPVP := false;
DeclarePlayers;
SetupColors;
SetupSRL;
ActivateClient;
BankDTM := DTMFromString('78DA630C67666098C580028E1CD90367FF070' +
'2467FA09A45103E2354FCCF1F260626243E6310116AC2A8A4268A' +
'08357184D500001B001913');
//SRL Stats
Stats_ScriptID := SCRIPT_ID;
Stats_UserID := USER_ID;
Stats_Password := USER_PW;
end;
begin
ironx3 := DTMFromString('78DA6354676660486340015FBE7E00D38C503' +
'EA32A504D060135CA40355904D42801D5641350230B549343408D' +
'3D504D150135764035F5A86AFE7EFA84AAC601A8A609554D559E0' +
'BA65D75A86AA263C351D5B800D5D4A0AA692AF14051030063661E' +
'15');
center := DTMFromString('78DA638C646660C863400131D161609A11CA6' +
'7F403AA2926A0C603A8A602554D61B22DAA1A4F4C355F3FBFC754' +
'5382AAE6FDCB37A86ABC30D5B8B93862AA4173B3958531A65DC50' +
'4DCE30E545348408D33504D017E370300C5C01A43');
SetupScript;
//dbg;
repeat
SetupPlayer;
marktime(starttime);
repeat
if not LoggedIn then loginplayer;
case random(4) of //if i wandered then head back to rocks
0 :
begin
if finddtm(ironx3,x,y,mmx1,mmy1,mmx2,mmy2) then
mouse(x,y,2,4,true)
else
if finddtm(center,x,y,mmx1,mmy1,mmx2,mmy2) then
begin
mouse(x,y,2,2,true);
if finddtm(ironx3,x,y,mmx1,mmy1,mmx2,mmy2) then
mouse(x,y,2,4,true);
end;
mouse(mmcx,mmcy+30,2,2,true);
end;
end;
//ToGuild;
//getting to rocks
//RelocateGuild(GUILD_LEFT)
if not InvFull then
begin
//if not InGuild(5000, true) then
// continue; //waits to be inside guild
{ writeln('getting to rocks');
wait(random(1000));
Mouse(MMCX + 50, MMCY, 5, 5, true);
wait(500);
while IsMoving do
while FFLag(0) do
wait(200);
} end else
begin
dropall;
inc(oresdid);
end;
MineLoop;
// WalkOutGuild;
// ToBank;
// Rest;
until(IsFKeyDown(12))
until(AllPlayersInactive);
FreeDTM(BankDTM);
end.