Simba Code:
program Ratinator;
{$DEFINE SMART}
{$i SRL\SRL.scar}
{$i Reflection\Reflection.simba}
{$i SRL\SRL\Misc\Debug.simba}
{$i SRL\SRL\Misc\Reports.simba}
{$i SRL\SRL\Misc\stats.simba}
{=========================================================================]
[ ]
[ ]
[ NAME : Ratinator ]
[ WRITER : Bobzilla69 ]
[ CATEGORY : Fighting ]
[ DESCRIPTION : Fights rats west of Lumbridge and deathwalks ]
[ USAGE : Start in lumbridge courtyard, ]
[ with weapon and/or armour three items max ]
[ NOTES : I have noticed that the re equiping of items ]
[ can not work correctly for certain items ]
[ CONTACT : PM me on SRL-Forums or post in thread ]
[ THANKS : I would like to Thank the SRL Team for making ]
[ this great system to be utilized by us ]
[ Thanks to bbri06 for letting me use some of ]
[ the functions from Lumbridge Fighter ]
[=========================================================================]
[ Instructions ]
[=========================================================================]
[ 1. Have character in Lumbridge castle court with items equiped ]
[ 2. Have talked to the Grim Reaper twice (respawning and gravestone) ]
[ 3. Fill out DeclarePlayers. ]
[ (For further instructions on how to fill it out, visit this thread: ]
[ [url]http://www.villavu.com/forum/showthread.php?t=5410[/url]) ]
[ 4. Designed to be used with SMART and Simba ]
[ 5. Start script and enjoy, dont forget to post a proggy! ]
[=========================================================================}
const
World = 169; //world to auto on ( 0 will load random)
Signed = True; //signed client(true) or unsigned (false)
SRLStats_UserID = ''; // Your SRL Stats ID
SRLStats_Password = ''; // Your SRL Stats Password
SmartDebugReport = True; // will paint report on smart (4 players for this to work best)
var
DebugTheTPA, Deathwalk:Boolean;
Time, Report, RunTime, BreakFor:Integer;
procedure DeclarePlayers;
var
I: integer;
begin
HowManyPlayers := 5;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 1;
DebugTheTPA := False; //True if you want to see TPA debug (color only)
for I := 0 to HowManyPlayers - 1 do
with Players[I] do
begin
BoxRewards := ['Xp', 'mote', 'ostume', 'oins', 'aphire', 'ssence'];
end;
end;
procedure Write(WhatsHappening:string);
begin
Writeln(WhatsHappening);
end;
procedure LogoutWhy(Why:string);
begin
Write(Why);
Players[CurrentPlayer].Active := False;
Logout;
end;
//all credit to BobboHobbo for making original version
procedure PrintSmartReport();
var
mx, my, I, B, H, TPH, Numb: Integer;
yInc: Integer;
Shadow, Colour: Integer;
TotalRat, TotalDeathWalk: Integer;
TTP: TPointArray;
Canvas: TCanvas;
TitleBMP, PlayerBMP, TotalBMP: TMufasaBitmap;
TitleStrings: TStringArray;
pString: String;
begin
SmartSetDebug(True);
GetClientDimensions(mx,my);
Colour := clTeal;
Shadow := $1; // black w/ 1 red.
{
Load players.
}
PlayerBMP := TMufasaBitmap.create;
PlayerBMP.SetSize(mx,my);
PlayerBMP.FastDrawClear(clBlack);
yInc := 130;
for I := 0 to HowManyPlayers-1 do
begin
TotalRat:= TotalRat + Players[I].Integers[0]; //rats attacked
TotalDeathWalk:= TotalDeathWalk + Players[I].Integers[1]; //deathwalks
pString := Players[I].Nick + PadL(inttostr(Players[I].Integers[0]), 22) +
PadL(inttostr(Players[I].Integers[1]), 22);
TTP := LoadTextTPA(pString, UpChars, H);
yInc := yInc + 30;
Writeln(Length(TTP));
for B := High(TTP) downto 0 do
begin
Numb := ((I + 1) * 13);
PlayerBMP.FastSetPixel(TTP[b].x + 1, TTP[b].y + Numb + 1 + yInc, Shadow);
PlayerBMP.FastSetPixel(TTP[b].x, TTP[b].y + Numb + yInc, Colour);
end;
end;
DrawBitmapDebugImg(PlayerBMP.Index);
{
Set titles.
}
TitleStrings := [
'Ratinator Version 1.40',
'',
'Running Time : '+MsToTime(TimeFromMark(RunTime), Time_Short),
'', 'Total Rats Attacked : '+Inttostr(TotalRat),
'',
'Total Deathwalks : '+Inttostr(TotalDeathWalk),
'',
'Players Rats DeathWalk'];
TitleBMP := TMufasaBitmap.create;
TitleBMP.SetSize(mx,my);
TitleBMP.FastDrawClear(clBlack);
TPH := High(TitleStrings);
for I := 0 to TPH do
begin
TTP := LoadTextTPA(TitleStrings[i], UpChars, H);
for B := High(TTP) downto 0 do
begin
Numb := ((I + 1) * 13);
TitleBMP.FastSetPixel(TTP[b].x + 1, TTP[b].y + Numb + 1, Shadow);
TitleBMP.FastSetPixel(TTP[b].x, TTP[b].y + Numb, Colour);
end;
end;
Canvas := TCANVAS.Create;
Canvas.Handle := SmartGetDebugDC;
TotalBMP := TMufasaBitmap.create;
TotalBMP.SetSize(mx,my);
// draw the bitmaps. Both onto the total, then only one visible draw.
TitleBMP.SetTransparentColor(clBlack);
PlayerBMP.SetTransparentColor(clBlack);
TitleBMP.FastDrawTransparent(MIX1+5, MIY1, TotalBMP);
PlayerBMP.FastDrawTransparent(MIX1+5, MIY1+130, TotalBMP);
TotalBMP.DrawToCanvas(0, 0, Canvas);
// clean up.
TitleBMP.Free;
PlayerBMP.Free;
TotalBMP.Free;
end;
procedure ProgressReport;
var
I, TotalRat, TotalDeathWalk:Integer;
begin
Writeln('');
TotalRat:= 0; //initilise them as clean variables
TotalDeathWalk:= 0;
for I := 0 to HowManyPlayers - 1 do
begin
TotalRat:= TotalRat + Players[I].Integers[0]; //rats attacked
TotalDeathWalk:= TotalDeathWalk + Players[I].Integers[1]; //deathwalks
end;
SRLProgressReport(ResultDebugBox, 'Ratinator', 'Bobzilla69', '1.40',
['TimeRunning', 'Active Players', 'Total Rats Attacked', 'Total DeathWalks'],
[MsToTime(TimeFromMark(RunTime), Time_Formal), PlayersActive , TotalRat, TotalDeathWalk]);
SRLPlayerReport( ResultDebugBox, 0, false, [False, False, False, False, False, True], ['Rats Attacked', 'Deathwalk Count'], [], [0, 1], [], [] );
SRLRandomsReport;
Writeln('');
Writeln('Please post bugs and report at [url]http://villavu.com/forum/showthread.php?t=60296');[/url]
Writeln('');
Stats_Commit;
SendSRLReport;
end;
function MyFindColor(What:string; Where:boolean):integer; //on minimap(true) or main screen (false) might not need where clause
var
I, J, TheColor, Red, Green, Blue, color,
bL, bH, gL, gH, rL, rH, colTol: integer;
colorArray: TPointArray;
begin
case lowercase(What) of
'floor': begin
color := 8883341;
bL := 130;
bH := 139;
gL := 135;
gH := 144;
rL := 137;
rH := 144;
colTol:= 7;
end;
'tree': begin
color := 1388355;
bL := 16;
bH := 25;
gL := 43;
gH := 50;
rL := 63;
rH := 71;
colTol:= 6;
end;
'rat': begin
color := 4605769;
bL := 67;
bH := 72;
gL := 69;
gH := 73;
rL := 71;
rH := 75;
colTol:= 3;
end;
end;
Result := 0;
if Where then
FindColorsSpiralTolerance(MMCX, MMCY, colorArray, color, MMX1, MMY1, MMX2, MMY2, colTol) //search from center outwards
else
FindColorsSpiralTolerance(MSCX, MSCY, colorArray, color, MSX1, MSY1, MSX2, MSY2, colTol);
J := High(colorArray);
for I := 0 to J do
if ((rs_OnMinimap(colorArray[I].x, colorArray[I].y)) or (not (Where))) then
begin
TheColor := GetColor(colorArray[i].x, colorArray[i].y);
ColorToRGB(TheColor, Red, Green, Blue);
if (InRange(Blue, bL, bH) and InRange(Green, gL, gH) and InRange(Red, rL, rH)) then
begin
Result := TheColor;
//WriteLn(What + ' Colour Found: ' + IntToStr(TheColor)); //not really needed
Exit;
end;
end;
end;
function FindRandoms: Boolean; //copied findnormalrandoms from antirandoms include and edited out FindDead so i can do deathwalking.
var
I: Byte;
Cont : boolean;
begin
if (SRL_OnFindRandomCall <> nil) then
begin;
Result := SRL_OnFindRandomCall(cont);
if not Cont then
exit;
end;
for I := 1 to 7 do
begin
case I of
1: Result := SolveTeleportRandoms;
2: Respond;
3: Result := FindLamp(LampSkill);
4: Result := RC;
5: Result := FindMod;
6: if (SRL_Procs[srl_OnRandomCall] <> nil) then
SRL_Procs[srl_OnRandomCall]();
7: Result := UseRewardBox;
end;
if (Result) then
begin
if (SRL_Procs[srl_OnFindRandom] <> nil) then
SRL_Procs[srl_OnFindRandom]();
Break;
end;
end;
end;
function RandomCheck : Boolean; //thanks mormonman for giveing me this idea and help
var I : Integer;
begin
for I := 0 to 1 do
begin
case I of
0: begin
if Players[CurrentPlayer].Booleans[0] then Result := R_FindRandoms;
end;
1: Result := FindRandoms;
end;
if Result then Exit;
end;
end;
procedure AntiBan;
var
MousePos: TPoint;
begin
if RandomCheck then
if not loggedin then exit;
GetMousePos(MousePos.x, MousePos.y);
case random(100) of
0..4: PickupMouse;
20..24: HoverSkill('random', False);
40..44: GameTab(RandomRange(tab_Combat, tab_Notes));
60..64: Wait(500 + Random(1500));
80..84: RandomAngle(1);
end;
GameTab(Tab_Inv);
MMouse(MousePos.x, MousePos.y, 2, 2);
end;
Function Dead:Boolean; //basicly finddead from antirandoms except it wont log you out
var //also added reflection check tile distance using DistanceFrom(Tiles[High(Tiles)]) < 6) from WalkPath
x, y:Integer;
begin
Result:=False;
If Players[CurrentPlayer].Booleans[0] then
begin
if (DistanceFrom(Tile(3195, 3210)) > 15)then
begin
Write('Player died, Starting deathwalk');
DeathWalk:=True;
Result:=True;
end;
end else
if FindTextTPA(0, 0, MCX1, MCY1, MCX2, MCY2, 'dear', SmallChars, Nothing) then
if FindTextTPA(0, 0, MCX1, MCY1, MCX2, MCY2, 'dead', SmallChars, Nothing) then
begin
Write('Might be dead Double checking');
if FindSymbol(x, y, 'axe shop') or FindSymbol(x, y, 'rest') or (CountColor(1179390, 579, 57, 673, 135)<= 10) then
begin
Write('Player died, Starting deathwalk');
DeathWalk:=True;
Result:=True;
end;
end;
end;
procedure RFWalk;
var
Tiles:TTileArray;
begin
if (not (LoggedIn)) then Exit;
Write('Walking to rats');
Tiles := [Tile(3216, 3207), Tile(3202, 3215), Tile (3195, 3206)];
WalkPath(Tiles);
Write('Walking complete');
end;
Procedure RFAttack; //idea's and help from other reflection fighters like bbri06's Lumbridge Fighter
var
Char : TNPCArray;
P: TPoint;
i, x, y:integer;
begin
if (not (LoggedIn)) then Exit;
Char := (SortNPCS(GetNPCS));
if(Length(Char) = 0)then
Exit;
for i := 0 to High(Char) do
begin //get rat location adn checks its not allready fighting
if((Char[i].Name = 'Giant rat') and (TileOnMS(Char[i].Tile, 0)) and (not(Char[i].Fighting)))then
begin
P := TileToMS(Char[i].Tile, 5);
if FindColorSpiralTolerance(x, y, MyFindColor('rat', false), P.x - 20, P.y - 20, P.x + 20, P.y +20, 15)then
begin
MMouse( x, y , 2, 2);
If WaitUpTextMulti(['Giant rat', 'iant ra'], 400)then //not needed but added failsafe swaped to color version as reflection caused error randomly
begin
case Random(10) of
0..5:begin //simply click rat
Mouse( x, y, 2, 2, True);
Write('Attacking Rat');
end;
6..10:begin //max is 9? no harm having 10 right click choose option attack
Mouse( x, y, 2, 2, False);
WaitOptionMulti(['ack Gia', 'ack Giant', 'Attack Giant'], 500);
Write('Attacking Rat');
end;
end;
R_Flag;
Wait(1200+random(800));
Inc(Players[CurrentPlayer].Integers[0]); //hold how many rats got killed (can miss click and count as attack)
stats_IncVariable('Giant Rats Killed', 1);
Exit;
end;
end;
end;
end;
if RandomCheck then
if not loggedin then exit;
end;
Procedure ColorAttack;
var
x, y, i, ii: Integer;
RatTPA: TPointArray;
RatATPA: T2dPointArray;
begin
if (not (LoggedIn)) then Exit; //if not logged in exit
Write('Attempting to Find Rat');
FindColorsSpiralTolerance(MSCX, MSCY, RatTPA, MyFindColor('rat', False), MSX1, MSY1, MSX2, MSY2, 5);
RatATPA := SplitTPAEx(RatTPA, 10, 10); //TPAtoATPAex( 20, 20)
if Length(RatATPA) = 0 then Exit; //if the split returns nothing TreeATPA will be empty so
SortATPAFromFirstPoint(RatATPA, Point(MSCX, MSCY)); //sort TPA acording to main screen center point
if DebugTheTPA then
begin
DebugATPA(RatATPA, '');
end;
ii := High(RatATPA);
for i := 0 to ii do //from 0 first entry in array to ii highest entry
begin
MiddleTPAEx(RatATPA[i], x, y);//find middle of array entry
MMouse(x, y, 3, 3);
Wait(100);
if WaitUpTextMulti(['Giant rat', 'iant ra'], 400) then
begin
case Random(10) of
0..5:begin //simply click rat
Mouse( x, y, 2, 2, True);
Write('Attacking Rat');
end;
6..10:begin //max is 9? no harm having 10 right click choose option attack
Mouse( x, y, 2, 2, False);
WaitOptionMulti(['ack Gia', 'ack Giant', 'Attack Giant'], 500);
Write('Attacking Rat');
end;
end;
Flag;
Wait(1500 + Random(800));
Inc(Players[CurrentPlayer].Integers[0]); //hold how many rats got killed (can miss click and count as attack)
stats_IncVariable('Giant Rats Killed', 1);
Exit;
end;
end;
if RandomCheck then
if not loggedin then exit;
end;
Function FastFighting:Boolean;
var
i:integer;
begin
write('Checking for Fight')
if Players[CurrentPlayer].Booleans[0] then
begin
if(GetAnimation > -1)then
Result := True
else
for i := 0 to 160 do
begin
Wait(11);
if(GetAnimation > -1)then
begin
Result := True;
wait(200 + random(200));
Exit;
end;
end;
end else
Result := False; //as we use this and srl_InFight when reflection is broken we auto make it true
end;
Function Fighting:Boolean; //from bbri06's Lumbridge Fighter changed slightly
var
i:integer;
begin
write('Checking for Fight')
if Players[CurrentPlayer].Booleans[0] then
begin
if(GetAnimation > -1)then
Result := True
else
for i := 0 to 40 do
begin
Wait(5);
if(GetAnimation > -1)then
begin
Result := True;
Exit;
end;
end;
end else
Result := False; //as we use this and srl_InFight when reflection is broken we auto make it true
end;
Procedure Attack;
begin
if (not (LoggedIn)) then Exit;
if Players[CurrentPlayer].Booleans[0] then //checks if we are using reflection
begin
RFAttack;
end else
ColorAttack;
repeat
if Players[CurrentPlayer].Booleans[1] then break; //fast fighting
Wait(1000+Random(1000));
if Dead then Exit;
AntiBan;
until((not Fighting) or (not(srl_InFight)))
if Players[CurrentPlayer].Booleans[1] then
begin
write('Attempting to Fast Fight');
repeat
if Dead then Exit;
Wait(800 +Random(800));
until(not FastFighting)
end;
if SmartDebugReport then
printSmartReport();
if (TimeFromMark(Report)>=(300000))then //does progress report every 5 minutes
begin
MarkTime(Report);
ProgressReport;
end;
if RandomCheck then
if not loggedin then exit;
end;
Function ClickCheck(x, y, xH, xL, yH, yL:integer):Boolean; //checks expected area is clicked.
begin
if (not (LoggedIn)) then Exit;
if ((InRange( x, xL, xH))and(InRange( y, yL, yH)))then //checks it falls in a expected area
begin
Mouse(x, y, 2, 2, True);
Flag;
Wait(800+Random(800));
Result:= True;
end else
Result:= False;
end;
Function Walking(Location:integer):boolean; //make a case of where to walk
var
MiddleOfTPA: TPoint;
TPA : TPointArray;
begin
if (not (LoggedIn)) then Exit;
Result:=False;
case (Location) of
1: begin
Write('Starting to walk to Rats');
if FindColorsPie(TPA, MyFindColor('floor', true), 15, 200, 250, 50, 70, mmx1, mmy1, mmcx, mmy2, mmcx, mmcy) then //dungeon symbol color
begin
MiddleOfTPA:= MiddleTPA(TPA);
if (DebugTheTPA) then
DebugTPA(TPA, '');
if ClickCheck(MiddleOfTPA.x + 5, MiddleOfTPA.y + 18, 598, 578, 144, 130) then
begin
Result:= True;
Write('Walking Step '+IntToStr(Location)+' Complete');
end else
LogoutWhy('Walking failed step '+IntToStr(Location)+', Logging Out');
end;
end;
2: begin
if FindColorsPie(TPA, MyFindColor('floor', true), 15, 270, 330, 50, 70, mmx1, mmy1, mmcx, mmy2, mmcx, mmcy) then //dungeon symbol color
begin
MiddleOfTPA:= MiddleTPA(TPA);
if (DebugTheTPA) then
DebugTPA(TPA, '');
if ClickCheck(MiddleOfTPA.x + 2, MiddleOfTPA.y + 2, 598, 570, 50, 30) then
begin
Result:= True;
Write('Walking Step '+IntToStr(Location)+' Complete');
end else
LogoutWhy('Walking failed step '+IntToStr(Location)+', Logging Out');
end;
end;
3: begin
if FindColorsPie(TPA, MyFindColor('tree', true), 15, 180, 200, 5, 45, mmx1, mmy1, mmcx, mmy2, mmcx, mmcy) then //dungeon symbol color
begin
MiddleOfTPA:= MiddleTPA(TPA);
if (DebugTheTPA) then
DebugTPA(TPA, '');
if ClickCheck(MiddleOfTPA.x - 12, MiddleOfTPA.y + 18, 620, 585, 140, 90) then
begin
Result:= True;
Write('Walking Step '+IntToStr(Location)+' Complete');
end else
LogoutWhy('Walking failed step '+IntToStr(Location)+', Logging Out');
end;
end;
end; //case end
end;
procedure EquipItems; //needs work will blindly click items atm
var
i,x,y:integer;
Item:TBox;
begin
if (not (LoggedIn)) then Exit;
Write('Searching for Items to wear');
for i:= 1 to 4 do
begin
if ExistsItem(i)then
begin
Item:= InvBox(i);
MouseBox(Item.x1, Item.y1, Item.x2, Item.y2, 3);
if WaitUpTextMulti(['Wield', 'Wear'], 400) then
begin
GetMousePos(x,y);
mouse(x,y,2,2,true);
end;
Wait(800+random(800));
end;
end;
end;
procedure CheckLogged;
var
Break:Integer;
begin
if (TimeFromMark(Time)>=(Players[CurrentPlayer].Integers[2]*60000))then
begin
Write('Script has working for the indicated amount of time, swiching player');
ProgressReport;
if (PlayersActive > 0) then //will perform a break after each player completes there loop
begin
BreakFor:= (Players[CurrentPlayer].Integers[4] + Random(3));
Write('Performing a break for : '+MsToTime((BreakFor*60000), Time_Formal));
Wait(10000); //waits ten seconds needed to insure it loggs out
Logout;
MarkTime(Break);
repeat
Wait(30000) //half a second then writes remaining time
Write('Waiting For Another : '+MsToTime((BreakFor*60000)-TimeFromMark(Break), Time_Formal));
until(TimeFromMark(Break) > BreakFor*60000)
Write('Break Finished');
end;
NextPlayer(True);
MarkTime(Time); //resets timer so new player can work for set amount of time
end;
if (not (LoggedIn)) then
begin
Write('Player not logged in Switching to next');
Write('Choosing Next Player');
Players[CurrentPlayer].Active := False;
Logout; //set current player to false
end;
end;
procedure SetFight(i:integer); //will add check to not click if allready clicked.
begin
GameTab(tab_Combat);
case i of
1:begin
if (CountColor(1711219, 307, 299, 338, 315) >= 10)then //to get rid of auto setup screen at login
begin
MouseBox(578, 258, 631, 288, 1);
Wait(500+Random(800));
end;
end;
2:begin
if (CountColor(1711219, 307, 299, 338, 315) >= 10)then //to get rid of auto setup screen at login
begin
MouseBox(658, 258, 713, 288, 1);
Wait(500+Random(800));
end;
end;
3:begin
if (CountColor(1711219, 307, 299, 338, 315) >= 10)then //to get rid of auto setup screen at login
begin
MouseBox(577, 313, 629, 339, 1);
Wait(500+Random(800));
end;
end;
end;
GameTab(tab_Inv);
end;
procedure Main;
var
i:integer;
begin
repeat
Loginplayer;
Wait(800+random(500));
SetAngle(True);
//SetFight(Players[CurrentPlayer].Integers[3]);
SetFightMode(Players[CurrentPlayer].Integers[3]);
RunEnergy(20);
MarkTime(Report); //counter to allow regular reporting
if Players[CurrentPlayer].Booleans[0] then
begin
RFWalk;
end else
begin
for i:=1 to 3 do
begin
Walking(i);
end;
Write('Walking Complete');
end;
repeat
Attack;
if (not (LoggedIn)) then Break; //checks if logged in and if not breaks out of loop
until((Dead)or(TimeFromMark(Time)>=(Players[CurrentPlayer].Integers[2]*60000)));
CheckLogged; //checks if loggedin and if not set current player to false and logs new player
if (DeathWalk) then
begin
DeathWalk:= False;
SetAngle(True);
EquipItems;
Inc(Players[CurrentPlayer].Integers[1]); //deathwalk
//Inc(Stats_CustomVars[2]);
ProgressReport;
Main;
end;
until(AllPlayersInactive)
end;
procedure Setup;
begin
SetupSRLStats(7, SRLStats_UserID, SRLStats_Password);
Smart_Server := World;
Smart_Signed := Signed;
SetupSRL;
DeclarePlayers;
if Players[CurrentPlayer].Booleans[0] then //checks reflection is usable
begin
if (not (SmartGetFieldInt(0, hook_static_LoginIndex) = -1)) then
begin
Write('Reflection is usable');
end else
begin
Players[CurrentPlayer].Booleans[0]:= False;
Write('Reflection not working, using color');
end;
end;
end;
Procedure ScriptTerminate;
Begin
ProgressReport;
Write('All Players Inactive Ending Script');
TerminateScript;
End;
begin
Setup;
MarkTime(RunTime); //total running time
MarkTime(Time); //starts timing script so players get timed and can switch.
Main;
if AllPlayersInactive then ScriptTerminate; //allows a final progress report before ending.
end.