Sir R. M8gic1an
2010-05-08 13:27:09
THIS SCRIPT IS NOT SAFE FOR USE
Hey guys, here's my latest script: RM Rat Pits.
I only advise you to use it if you want to tran magic.
It's not suitable for ranging unless you don't want your arrows back.
It's not suitable for meelee as it attacks the furthest rat.
This was designed in the rat pits below varrock, not sure how well it works elsewhere.
THIS SCRIPT IS NOT FINISHED.
I am posting it here for anyone who wishes to use it as it is, or to complete it.
I've trained magic up to 43 using this script, and so have no intention of further developing it in the near future.
It runs rather well, but it does not include rests, multiplayer nor eating. It does however include anti-randoms.
Well, enjoy.
~RM
Hey guys, here's my latest script: RM Rat Pits.
I only advise you to use it if you want to tran magic.
It's not suitable for ranging unless you don't want your arrows back.
It's not suitable for meelee as it attacks the furthest rat.
This was designed in the rat pits below varrock, not sure how well it works elsewhere.
THIS SCRIPT IS NOT FINISHED.
I am posting it here for anyone who wishes to use it as it is, or to complete it.
I've trained magic up to 43 using this script, and so have no intention of further developing it in the near future.
It runs rather well, but it does not include rests, multiplayer nor eating. It does however include anti-randoms.
Well, enjoy.
From: YoHoJo
Although not shown on this map (it is old), the rat pits are located around here:
http://www.rsbandb.com/interactive_runescape_world_map/position/49.78729248046875/-82.64739990234375/9
program RMRatPits;
{ Last Updated: 18:28 GMT 8th May 2010 }
// RM
// Rat Pits
{$define SMART}
{.include srl/srl.scar}
const
SCRIPT_DEBUG = true;
MM_NPC = 128501; {60909, 195836, 1179390, 1179390, 56797, 195836}
{ RM --------------------------------------------------------------------------]
[ End User Input for players ]
[------------------------------------------------------------------------------}
Procedure DeclarePlayers;
var
i: integer;
begin
NumberOfPlayers(1);
CurrentPlayer := 0;
for i := 0 to HowManyPlayers-1 do
Players[i].BoxRewards := ['mote', 'ostume', 'ystery', 'XP', 'Gem', 'ithril', 'oal', 'une', 'oins'];
with Players[0] do
begin
Name :='';
Pass :='';
Nick :='';
Active := True;
end;
end;
//-------------------- SRL Stats Functions by Nielsie95 ----------------------//
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;
//-------------------- SRL Stats Functions by Nielsie95 ----------------------//
{ 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 --------------------------------------------------------------------------]
[ Debugs ]
[------------------------------------------------------------------------------}
Procedure RMDebug(What: String);
begin
if SCRIPT_DEBUG then
begin
writeln(TheTime+': '+Players[CurrentPlayer].Name+': '+What);
DisGuise(What);
end;
end;
{ RM --------------------------------------------------------------------------]
[ Finds text <> 'under attack'& 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('already under', text) > 0 ) then
if not (Pos('someone else', text) > 0 ) then
break;
end;
Result := i;
end;
{ RM --------------------------------------------------------------------------]
[ Checks what new chatbox text is ]
[------------------------------------------------------------------------------}
function CheckText(line: integer; var text:string): boolean;
var
i: integer;
s: string;
begin
Result := true;
exit;
i := FindNeutralText(s);
if i <> line then
if i < 8 then
Result := false;
if not Result then
text := lowercase(GetChatBoxText(8, clMessage));
end;
var
NeutralLine: integer;
Procedure WhileFighting(TP: TPoint); forward;
{ RM --------------------------------------------------------------------------]
[ Deals with Under Attack & Someone else is fighting that ]
[------------------------------------------------------------------------------}
function DoText: boolean;
var
text: string;
begin
Result := true;
if not CheckText(NeutralLine, text) then
begin
writeln(text);
if (Pos('under attack', text) > 0 ) then
WhileFighting(Point(0,0));
Result := false;
end;
end;
{ RM --------------------------------------------------------------------------]
[ Makes a box of BoxSize with center SPoint, within the MS ]
[------------------------------------------------------------------------------}
function MakeMSBox(SPoint: TPoint; BoxSize: integer): TBox;
begin
Result.x1 := Max(SPoint.x - BoxSize, MSX1);
Result.x2 := Min(SPoint.x + BoxSize, MSX2);
Result.y1 := Max(SPoint.y - BoxSize, MSY1);
Result.y2 := Min(SPoint.y + BoxSize, MSY2);
end;
{ RM --------------------------------------------------------------------------]
[ Checks if TP is within Box ]
[------------------------------------------------------------------------------}
function TPInBoxes(TP: TPoint; Box: TBoxArray): boolean;
var
h: integer;
begin
if Length(Box) = 0 then exit;
for h := 0 to High(Box) do
begin
if not InRange(TP.x, Box[h].x1, Box[h].x2) then
continue;
if not InRange(TP.y, Box[h].y1, Box[h].y2) then
continue;
Result := true;
exit;
end;
end;
{ RM --------------------------------------------------------------------------]
[ FindColorsTolerance in a TBox ]
[------------------------------------------------------------------------------}
function FindColorsToleranceBox(var TPA: TPointArray; Color, Tolerance: Integer; Box: TBox): boolean;
begin
Result := FindColorsTolerance(
TPA,
Color,
Box.x1,
Box.y1,
Box.x2,
Box.y2,
Tolerance
);
end;
{ RM --------------------------------------------------------------------------]
[ Finds rat in a box ]
[------------------------------------------------------------------------------}
function FindRatBox(var TPA: TPointArray; Box: TBox; Single: boolean): boolean;
var
CTS: integer;
h, s: extended;
ATPA: T2DPointArray;
begin
GetCTS(CTS, h, s);
SetCTS(2, 0.20, 0.04);
Result := FindColorsToleranceBox(TPA, 6580585, 14, Box);
if Single then
begin
ATPA := SplitTPA(TPA, 8);
SortATPAFromFirstPoint( ATPA,
Point(
(Box.x1 + Box.x2)/2,
(Box.y1 + Box.y2)/2
) );
try
TPA := ATPA[0];
except end;
end;
SetCTS(CTS, h, s);
end;
{ RM --------------------------------------------------------------------------]
[ Returns true if NPC is Fighting ]
[------------------------------------------------------------------------------}
function FindFight_At(x, y: integer): boolean;
var
CTS: integer;
h, s: extended;
Box: TBox;
TPA: TPointArray;
begin
GetCTS(CTS, h, s);
SetCTS(2, 5.34, 1.90);
Box := IntToBox( x - 25, y - 50, x + 25, y);
Result := FindColorsToleranceBox(TPA, 78641, 3, Box);
SetCTS(CTS, h, s);
end;
{ RM --------------------------------------------------------------------------]
[ Returns true if NPC has HP ]
[------------------------------------------------------------------------------}
function FindLife_At(x, y: integer): boolean;
var
CTS: integer;
h, s: extended;
Box: TBox;
TPA: TPointArray;
begin
GetCTS(CTS, h, s);
SetCTS(2, 4.28, 5.13);
Box := IntToBox( x - 40, y - 50, x + 40, y);
Result := FindColorsToleranceBox(TPA, 75274, 3, Box);
SetCTS(CTS, h, s);
end;
{ RM --------------------------------------------------------------------------]
[ Follows, Checks and Clicks on rats ]
[------------------------------------------------------------------------------}
function MouseRat(var x, y: integer): boolean;
var
Box: TBox;
TPA: TPointArray;
CTS, line: integer;
h, s: extended;
text: string;
begin
try
GetCTS(CTS, h, s);
SetCTS(2, 0.20, 0.04);
Box := MakeMSBox(Point(x, y), 30);
if not FindRatBox(TPA, Box, true) then
exit;
MiddleTPAEx(TPA, x, y);
if FindFight_At(x, y) then
begin
Result := false;
exit;
end;
MMouse(x, y, 2, 2);
if WaitUpText('rat', 500) then
begin
GetMousePos(x, y);
if not SimilarColors(GetColor(x, y), 6580585, 14) then //Rat color
begin
Result := MouseRat(x, y);
exit;
end else begin
NeutralLine := FindNeutralText(text);
Mouse(x, y, 0, 0, true);
Result := DidRedClick;
writeln('Clicked Rat: '+ BoolToStr(Result));
if not Result then
while IsMoving do
wait(250);
if not DoText then
begin
Result := false;
exit;
end;
end;
end else begin
Result := false;
exit;
end;
finally
SetCTS(CTS, h, s);
end;
end;
{ RM --------------------------------------------------------------------------]
[ Clears Canvas ]
[------------------------------------------------------------------------------}
Procedure ClearSmartPaint(canvas: TCanvas);
var
CleanBMP: integer;
begin
CleanBMP := BitmapFromString(MIX2, MIY2, '');
SafeDrawBitmap(CleanBMP, canvas, 0, 0);
try
FreeBitmap(CleanBMP);
except end;
end;
{ caused edited by RM ---------------------------------------------------------]
[ Paint a TPA onto the Smart Debug Canvas ]
[------------------------------------------------------------------------------}
procedure DrawDots(pixels : TPointArray);
var
i : integer;
drawing : TBitmap;
begin
drawing := TBitmap.Create;
drawing.canvas.handle := SmartGetDebugDC;
drawing.canvas.Pen.Color := clRed;
ClearSmartPaint(drawing.canvas);
for i:= 0 to high(pixels) do
begin
drawing.canvas.moveto(pixels[i].x-1,pixels[i].y);
drawing.canvas.LineTo(pixels[i].x,pixels[i].y);
end;
try
FreeBitmap(drawing);
except end;
end;
{ Based on caused by RM -------------------------------------------------------]
[ Paint an ATPA onto the Smart Debug Canvas ]
[------------------------------------------------------------------------------}
procedure DrawDotsMulti(pixels : T2DPointArray);
var
i, h, color : integer;
drawing : TBitmap;
begin
drawing := TBitmap.Create;
drawing.canvas.handle := SmartGetDebugDC;
ClearSmartPaint(drawing.canvas);
for h := 0 to High(pixels) do
begin
color := h div 5 + h mod 5;
case color of
0 : drawing.canvas.Pen.Color := clWhite;
1 : drawing.canvas.Pen.Color := clYellow;
2 : drawing.canvas.Pen.Color := clBlue;
3 : drawing.canvas.Pen.Color := clLime;
4 : drawing.canvas.Pen.Color := clGreen;
end;
for i:= 0 to High(pixels[h]) do
begin
drawing.canvas.moveto(pixels[h][i].x-1, pixels[h][i].y);
drawing.canvas.LineTo(pixels[h][i].x, pixels[h][i].y);
end;
end;
try
FreeBitmap(drawing);
except end;
end;
{ RM based on DrawBoxes by caused ---------------------------------------------]
[ Draws a box, Rock size. ]
[------------------------------------------------------------------------------}
procedure DrawBox(Box: TPointArray; color: TColor);
var
drawing : TBitmap;
TP : TPoint;
B: TBox;
begin
drawing := TBitmap.Create;
drawing.canvas.handle := SmartGetDebugDC;
drawing.canvas.Pen.Color := color;
ClearSmartPaint(drawing.canvas);
TP := MiddleTPA(Box);
B := MakeMSBox(TP, 20);
drawing.canvas.moveto(B.x1,B.y1);
drawing.canvas.LineTo(B.x2,B.y1);
drawing.canvas.LineTo(B.x2,B.y2);
drawing.canvas.LineTo(B.x1,B.y2);
drawing.canvas.LineTo(B.x1,B.y1);
try
FreeBitmap(drawing);
except end;
end;
{ RM --------------------------------------------------------------------------]
[ Checks for Bank or Pin Screen ]
[------------------------------------------------------------------------------}
function RMRandoms(RDebug: boolean): boolean;
var s: string;
begin
if RDebug then
RMDebug('Checking for randoms');
Result := FindNormalRandoms;
if IsFKeyDown(12) then
begin
s := Readln('What would you like to type ingame?');
if s = '' then
exit;
TypeSend(s);
end;
end;
{ RM --------------------------------------------------------------------------]
[ Sets a Player to False ]
[------------------------------------------------------------------------------}
Procedure DeActivatePlayer(Reason: String);
begin
LogOut;
Players[CurrentPlayer].Active := false;
Players[CurrentPlayer].Loc := Reason;
RMDebug('Logged Out - '+Reason);
end;
{ RM --------------------------------------------------------------------------]
[ Finds NPCs on MM ]
[------------------------------------------------------------------------------}
function FindNPCMM(var TP: TPoint): boolean;
var
TPA: TPointArray;
ATPA: T2DPointArray;
CTS: integer;
H, S: extended;
begin
GetCTS(CTS, H, S);
SetCTS(2, 0.00, 0.17);
Result := FindColorsTolerance(TPA, MM_NPC, MMX1, MMY1, MMX2, MMCY, 5);
if Result then
begin
ATPA := TPAToATPAEx(TPA, 4, 4); // 4*4 = NPC size
SortATPAFromFirstPoint(ATPA, Point(MMCX, MMCY));
TP := MiddleTPA(ATPA[0]);
end;
SetCTS(CTS, H, S);
end;
{ RM --------------------------------------------------------------------------]
[ Finds and Clicks Rats ]
[------------------------------------------------------------------------------}
function FindRat(var TP: TPoint): boolean;
var
i, l, CTS: integer;
h, s: extended;
Avoid: TBoxArray;
TPA: TPointArray;
ATPA, ATPA2: T2DPointArray;
begin
writeln('Looking for rats');
Avoid := [IntToBox(0, 0, 0, 0)]
while not Result do
begin
if not FindRatBox(TPA, IntToBox(MSX1, MSY1, MSX2, MSY2), false) then
wait(3000 + random(2000));
ATPA2 := SplitTPA(TPA, 5);
SortATPAFromFirstPoint(ATPA2, Point(MSCX, MSCY));
SetLength(ATPA, Length(ATPA2));
l := 0;
for i:= High(ATPA2) DownTo 0 do
if InRange(Length(ATPA2[i]), 400, 800) then
begin
TP := MiddleTPA(ATPA2[i]);
if TPInBoxes(TP, Avoid) then
continue;
ATPA[l] := ATPA2[i];
inc(l);
end;
if l = 0 then
continue;
SetLength(ATPA, l);
DrawDotsMulti(ATPA);
writeln('Rat Length: '+IntToStr(Length(ATPA[0])));
TP := MiddleTPA(ATPA[0]);
Result := MouseRat(TP.x, TP.y);
if not Result then
begin
l := Length(Avoid);
SetLength(Avoid, l + 1);
Avoid[l] := GetTPABounds(ATPA[0]);
continue;
end else
break;
end;
RMRandoms(false);
SetCTS(CTS, h, s);
end;
{ RM --------------------------------------------------------------------------]
[ Waits while Fighting ]
[------------------------------------------------------------------------------}
Procedure WhileFighting(TP: TPoint);
var
time: integer;
TPA: TPointArray;
FoundFight: boolean;
begin
writeln('WhileFighting');
time := GetSystemTime + 10000;
while (time > GetSystemTime) do
begin
if not FindRatBox(TPA, MakeMSBox(TP, 50), true) then
begin
wait(time - GetSystemTime);
writeln('Failed to track rat');
exit;
end;
if not DoText then
break;
TP := MiddleTPA(TPA);
DrawDots(TPA);
if not FoundFight then
if FindFight_At(TP.x, TP.y) then
FoundFight := true;
if (FoundFight) then
if not FindLife_At(TP.x, TP.y) then
begin
writeln('rat dead');
break;
end else
time := GetSystemTime + 5000;
wait(250);
end;
writeln('Terminating WhileFighting');
end;
{ RM --------------------------------------------------------------------------]
[ Rests the player if it has been running for more than 20+rand(10) minutes ]
[------------------------------------------------------------------------------}
Procedure SetupPlayer; forward;
Procedure Rest;
begin
if AllPlayersInactive then
exit;
//if (GetSystemTime > TimeGoing) then
begin
if PlayersActive > 1 then
NextPlayer(Players[CurrentPlayer].Active)
else begin
RMDebug('sleeping');
LogOut;
wait(3*60*1000 + Random(3*60*1000));
LoginPlayer;
end;
SetupPlayer;
// TimeGoing := (GetSystemTime + FIXED_TIME*60*1000 + Random(RAND_TIME*60*1000));
RMDebug('restarted');
end;
end;
{ RM --------------------------------------------------------------------------]
[ Prepares the Player for Maging ]
{------------------------------------------------------------------------------}
Procedure SetupPlayer;
begin
// TimeGoing := (GetSystemTime + FIXED_TIME*60*1000 + Random(RAND_TIME*60*1000));
if not LoggedIn then
LoginPlayer;
SetAngle(true);
{
PTime.StartTime := GetSystemTime;
PTime.PreviousTime := Players[CurrentPlayer].Worked;
PTime.CurrTime := GetSystemTime - PTime.StartTime;
}
Players[CurrentPlayer].Level[Skill_Mage] := GetSkillLevel(Skill_Mage);
end;
var
TP: TPoint;
begin
DeclarePlayers;
Smart_Server := 61;
Smart_Signed := true;
AllowPVP := false;
SetupSRL;
LoginPlayer;
SetAngle(true);
SmartSetDebug(True);
repeat
if FindRat(TP) then
WhileFighting(TP);
until(IsFKeyDown(12))
end.
~RM