SRL Archive - Test corner

Fight Caves


NKN

2012-05-20 18:57:53

I made a Fight Cave script today.

I can't afford Guthans at the moment, so I was wondering if someone could test it for me? Here's what I got so far.

Start at the Minigame entrance.

Updated Script, should work pretty flawlessly, with no options running. Haven't testing food and prayer -thoroughly-, they work, but I don't know how well.

Not Updated yet

program FightCaves;
{$DEFINE SMART}
{$i srl/srl.simba}
{$i srl/srl/misc/paintsmart.simba}
{$i srl/srl/skill/fighting.simba}
{$i srl/srl/skill/prayer.simba}
{$i sps/sps.simba}
var
Prayer,Food,PPots,Guthans,Wearing,Banked,PActive,OutOfPots:Boolean;
WhichSlot,HowManyPots,Runs,HowManyLeft,WhenToDrink,FoodAmount,Timerz:Integer;
PrayerSlot:TPoint;
Const
SRLStats_User = '';
SRLStats_Password = '';
{**************************************************************************************************
* Instructions *
* If using Prayer and Food, put prayer in first bank slot, food in second *
* If using Prayer Food and Guthans, keep Guthans in first four inventory slots, then same as above*
* If Only using food, keep food in first bank slot. *
* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING *
* *
* *
* GUTHANS HAS NOT BEEN TESTED *
*************************************************************************************************** }
procedure DeclarePlayers;
begin
HowManyPlayers := 1; // This is set to the total amount of players (more on multiplayer later ;)), for now, just keep it set as 1
NumberOfPlayers(HowManyPlayers); // This is a procedure in SRL which sets up player arrays (also, more on that later), this will always be the same
CurrentPlayer := 0; // This is the player to start with; the first player will always be 0 (you'll find out when you learn all about arrays)

Players[0].Name := ''; // Username
Players[0].Pass := ''; // Password
Players[0].Nick := ''; // 3-4 lowercase letters from username; used for random event detection
Players[0].Active := True; // Set to true if you want to use Player 0
Players[0].Pin := ''; // Leave blank if the player doesn't have a bank pin
Players[0].BoxRewards := ['Xp', 'mote', 'ostume', 'oins', 'aphire', 'ssence'];
Prayer := False;//Use Prayer? Set your Quickprayers to the prayer you want to use.
Food := False;//Use Food?
PPots := False;//Use Prayer Potions?
Guthans := False;//Use Guthans?
HowManyPots := 4;//If using prayer pots, how many to withdraw?
HowManyLeft := 10;//How many food do you want left before you use prayer?
WhenToDrink := 100;//How many prayerPoints before drinking a prayer potion?
end;
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
///////////////////////////DO NOT TOUCH BELOW THIS LINE//////////////////////////
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
procedure Progress;
var
GamesPH:Integer;
begin
GamesPH := Round((Runs * 3600) / (GetTimeRunning / 1000));

ClearDebug;
Writeln('***********Power Caves**********');
Writeln('* ~By NKN~ ');
Writeln('*Games played: ' + IntToStr(Runs) + ' (' + IntToStr(GamesPH) + ' P/H)');
Writeln('*Total Time: ' + TimeRunning);
Writeln('********************************');
end;
procedure LoginCustom;
var
x,y:integer;
begin
LoginPlayerToLob;
if(FindColorTolerance(x,y,2840170,253,442,509,475,5)) then
Mouse(x,y,4,4,1);
While(not(RsReady)) do
Wait(300+random(200));
end;
procedure FindCave;
var
a,x,y,Timers: Integer;
TPA : TPointArray;
ATPA : T2DPointArray;
MP : TPoint;
tmpCTS : Integer;
Box,SearchArea : TBox;
begin
if not LoggedIn then Exit;
if(FindSymbol(x,y,'minigame')) then
begin
Mouse(x,y,2,2,True);
FFLag(0);
While(IsMoving) do
Wait(5);
end else
begin
if(FindColorTolerance(x,y,459499,MMX1,MMY1,MMX2,MMY2,5)) then
begin
Mouse(x,y,2,2,True);
FFLag(0);
While(IsMoving) do
Wait(5);
end;
end;
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(2.09,0.16);
SearchArea := IntToBox((MSCX - 150),(MSCY - 50),(MSCX),(MSCY + 150));
SMART_DrawBoxEx(True,SearchArea,clPurple);
FindColorsSpiralTolerance(MSCX,MSCY,TPA,3025965,MSCX - 150,MSCY - 50 ,MSCX ,MSCY + 150,4);
SortTPAFrom(TPA,point(MSCX,MSCY));
ATPA := TPAtoATPAEx(TPA,15,15);
SortATPAFrom(ATPA,point(MSCX,MSCY));
for a := 0 to High(ATPA) do
begin
MarkTime(Timers);
MP := MiddleTPA(ATPA[a]);
Box := IntToBox((MP.x - 20),(MP.y - 20),(MP.x + 20),(MP.y + 20));
SMART_DrawBoxEx(False,Box,clYellow);
MMouse(MP.x,MP.y,4,4);
Wait(250+random(50));
if(WaitUpText('ave',400))then
begin
x := MP.x; y := MP.y;
Mouse(x,y,2,2,1);
SMART_ClearCanvas;
MarkTime(Timers);
Break;
end;
if(TimeFromMark(Timers) > 30000) then Exit;
end;
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2,0.2);
end;
function FindDots:Boolean;
var
a,x,y: Integer;
TPA : TPointArray;
ATPA : T2DPointArray;
MP : TPoint;
tmpCTS : Integer;
Box,SearchArea : TBox;
begin
if not LoggedIn then Exit;
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.13,0.76);
FindColorsSpiralTolerance(MSCX,MSCY,TPA,324839,MMX1,MMY1,MMX2,MMY2,5);
SortTPAFrom(TPA,point(MSCX,MSCY));
ATPA := TPAtoATPAEx(TPA,15,15);
SortATPAFrom(ATPA,point(MSCX,MSCY));
for a := 0 to High(ATPA) do
begin
MP := MiddleTPA(ATPA[a]);
x := MP.x; y := MP.y;
SMART_ClearCanvas;
Result := True;
MarkTime(Timerz);
Break;
end;
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2,0.2);
end;
function FindJal(var x,y:integer):Boolean;
var
a: Integer;
TPA : TPointArray;
ATPA : T2DPointArray;
MP : TPoint;
tmpCTS : Integer;
Box,SearchArea : TBox;
begin
if not LoggedIn then Exit;
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.44,1.61);
SearchArea := IntToBox((MSX1),(MSY1),(MSX2 ),(MSY2));
SMART_DrawBoxEx(True,SearchArea,clPurple);
FindColorsSpiralTolerance(MSCX,MSCY,TPA,1476297,MSX1,MSY1 ,MSX2 ,MSY2,9);
SortTPAFrom(TPA,point(MSCX,MSCY));
ATPA := TPAtoATPAEx(TPA,15,15);
SortATPAFrom(ATPA,point(MSCX,MSCY));
for a := 0 to High(ATPA) do
begin
MP := MiddleTPA(ATPA[a]);
Box := IntToBox((MP.x - 20),(MP.y - 20),(MP.x + 20),(MP.y + 20));
SMART_DrawBoxEx(False,Box,clYellow);
MMouse(MP.x,MP.y,4,4);
Wait(250+random(50));
if(WaitUpText('Jal',1000))then
begin
x := MP.x; y := MP.y;
SMART_ClearCanvas;
Result := True;
Break;
end;
end;
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2,0.2);
end;
Procedure Bank;
var
x,y,amount:integer;
begin
if((Food = False) and (PPots = False)) then
Exit;
repeat
if((Food = True) or (PPots = True)) then
begin
CloseBank;
if((Food = True) and (PPots = True)) then
begin
if(FindJal(x,y)) then
begin
Mouse(x,y,2,2,False)
ChooseOption('Bank');
if(WaitFunc(@BankScreen,10,2000)) then
Banked := True;
DepositAll;
MouseBankSlot(1,mouse_left);
for Amount := 0 to HowManyPots do
begin
Wait(400+random(300));
ClickMouse2(mouse_left);
Inc(Amount);
end;
Wait(600+random(100));
MouseBankSlot(2,mouse_right);
ChooseOption('ithdraw-All');
CloseBank;
end;
end;
if((Food = True) and (PPots = False)) then
begin
if(FindJal(x,y)) then
begin
Mouse(x,y,2,2,False)
ChooseOption('Bank');
if(WaitFunc(@BankScreen,10,2000)) then
Banked := True;
DepositAll;
MouseBankSlot(1,mouse_right);
ChooseOption('ithdraw-All');
CloseBank;
Banked := True
end;
end;
end;
until(Banked = True);
end;


function UpTextGone(S: TStringArray; Time: Integer): Boolean;//Waits for uptext to be gone, and then instantly clicks.
var
T,i: Integer;
There:Boolean;
begin
Result := false;
T := GetSystemTime + Time;
while (GetSystemTime < T) do
begin
if(i = 0) then
begin
if (IsUpTextMultiCustom(S)) then
begin
There := True;
Inc(i);
end;
end;
if(There = True) then
begin
i := 0
if not(IsUpTextMultiCustom(S)) then
begin
There := False
Result := True;
Exit;
end;
end;
end;
Wait(20 + Random(20));
end;
procedure CheckPrayer;
var
i:Integer;
begin
if(PrayerPoints = 0) then
Exit;
if(OutOfPots = True) then
Exit;
if(PrayerPoints < WhenToDrink) then
begin
if(Guthans = True) then
begin
for i:= 5 to HowManyPots do
begin
If(ExistsItem(i)) then
begin
OutOfPots := True;
InvMouse(i,3);
if(WaitUpText('Drink',600)) then
begin
InvMouse(i,1)
OutOfPots := False;
end;
end;
end;
end else
begin
for i:= 1 to HowManyPots do
begin
If(ExistsItem(i)) then
begin
InvMouse(i,3);
if(PrayerPoints > WhenToDrink) then
Exit;
OutOfPots := True;
if(WaitUpText('Drink',600)) then
begin
InvMouse(i,1)
OutOfPots := False;
end;
end;
end;
end;
end;
end;

procedure Eat;
var
i,x,y:integer;
begin
if((Food = True) and (PPots = True)) then
begin
for i := HowManyPots + 1 to 28 do
begin
if(ExistsItem(i)) then
begin
if(HPPercent > 60) then
Exit;
InvMouse(i,3);
if(WaitUpText('Eat',600)) then
InvMouse(i,1);
UpTextGone(['Eat'],3000);
Wait(250+Random(100));
end;
end;
end;
if((Food = True) and (PPots = True) and (Guthans = True)) then
begin
for i:= 1 to 4 do
begin
if(ExistsItem(i)) then
begin
InvMouse(i,3);
if(WaitUpText('uthan',600)) then
begin
Mouse(x,y,3,3,True);
WhichSlot := i;
Wearing := True;
UpTextGone(['Uth'],2000);
end;
end;
end;
for i := HowManyPots + 5 to 28 do
begin
if(ExistsItem(i)) then
begin
if(HPPercent > 60) then
Exit;
InvMouse(i,3);
if(WaitUpText('Eat',600)) then
InvMouse(i,1);
UpTextGone(['Eat'],3000);
Wait(250+Random(100));
end;
end;
end;
if((Food = True) and (PPots = False) and (Guthans = True)) then
begin
for i:= 1 to 4 do
begin
if(ExistsItem(i)) then
begin
InvMouse(i,3);
if(WaitUpText('uthan',600)) then
begin
Mouse(x,y,3,3,True);
WhichSlot := i;
Wearing := True;
UpTextGone(['Uth'],2000);
end;
end;
end;
for i := 4 to 28 do
begin
if(ExistsItem(i)) then
begin
if(HPPercent > 60) then
Exit;
InvMouse(i,3);
if(WaitUpText('Eat',600)) then
InvMouse(i,1);
UpTextGone(['Eat'],3000);
Wait(250+Random(100));
end;
end;
end;
if((Food = True) and (PPots = False)) then
begin
for i := HowManyPots + 1 to 28 do
begin
if(ExistsItem(i)) then
begin
if(HPPercent > 60) then
Exit;
InvMouse(i,3);
if(WaitUpText('Eat',600)) then
begin
InvMouse(i,1);
UpTextGone(['Eat'],3000);
Wait(250+Random(100));
end;
end;
end;
end;
end;
procedure Pray;
var
x,y:integer;
begin
if(Guthans = True) then
begin
FoodAmount := InvCount - (HowManyPots + 4);
end else
FoodAmount := InvCount - HowManyPots;
if(Prayer = True) then
begin
if(FoodAmount < HowManyLeft) then
begin
if(PPots = True) then
CheckPrayer;
if(PActive = False) then
if(FindColorTolerance(x,y,6171194,711,65,733,81,15)) then
begin
Mouse(x,y,1,1,True);
PActive := True;
PrayerSlot := Point(x,y);
end;
end;
end;
end;
procedure Fight;
var
Items,i,x,y,Timers:Integer;
Prev:Tbox;
TPA:TPointArray;
InGame:Boolean;
begin
Banked := False;
Wait(5000+random(500));
MarkTime(Timers);
if(ClickContinue(True,True)) then
InGame:=True;
if(InGame = False) then
If(TimeFromMark(Timers) > 15000) then
FindCave;
Wait(2000+random(1000));
MarkTime(Timerz);
repeat
if(Not(LoggedIn)) then
begin
Exit;
end;
if(LobbyScreen) then
begin
LoginCustom;
MarkTime(Timerz);
end;

if(FindDots) then
MarkTime(Timerz);
if(TimeFromMark(Timerz) > 45000) then
begin
repeat
ExitToLobby;
Until(LobbyScreen);
LoginCustom;
end;
Pray;
if(Food = True) then
if(HPPercent < 60) then
Eat;
if((Guthans = True) and (Wearing = True)) then
begin
if(HPPercent > 60) then
for i:= 0 to 3 do
begin
InvMouse((WhichSlot + i),1);
WaitUpText('Guthan',2000);
end;
Wearing := False;
end;
until(ClickContinue(True,False));
Runs := Runs + 1;
if(PrayerPoints > 1) then
Mouse(PrayerSlot.x,PrayerSlot.y,1,1,1)
else
PActive := False;
end;

procedure Mainloop;
begin
FindNormalRandoms;
if(LobbyScreen) then
LoginCustom;
Progress;
Bank;
FindCave;
Fight;
Stats_Commit;
end;



begin
// These 4 lines HAVE to be set BEFORE you call SetupSRL;
Smart_Server := 26;
Smart_Members := False;
Smart_Signed := True;
Smart_SuperDetail := False;

ClearDebug;
SetupSRL;
SetupSRLStats(1109, SRLStats_User, SRLStats_Password);
DeclarePlayers; // Calls the procedure, you can't forget this!
LoginCustom;
GameTab(tab_Inv);
ClickNorth(SRL_ANGLE_HIGH);
While(Not RsReady) do
Wait(500+Random(1000));
repeat
Mainloop;
until(AllPlayersInactive);
end.

Mjordan

2012-05-21 11:02:51

Very nice! Glad to see somebody saw my request. Once I get out of the runespan, about 3 more days, I'll test this.

Unless this somehow turns out to be crazy xp or good money from the tokul, I don't see a problem with releasing this to the public section once you get it ironed out. But like I said, I'll test in a few days once I get 99 RC!

NKN

2012-05-21 17:33:02

TokKul is pretty decent, and the XP is pretty good too. :D

P1nky

2012-05-21 21:42:18

Oooo Lovely; I Remember Harry's FightCave … Was such a hit on SRL lol

NKN

2012-05-21 21:46:03


***********Power Caves**********
* ~By NKN~
*Games played: 24 (8 P/H)
*Total Time: 2 Hours, 48 Minutes and 43 Seconds
********************************

^Best Proggy yet. :D

Mjordan

2012-05-22 15:35:06

From: NKN

***********Power Caves**********
* ~By NKN~
*Games played: 24 (8 P/H)
*Total Time: 2 Hours, 48 Minutes and 43 Seconds
********************************

^Best Proggy yet. :D


Very nice, you should implement xp/hour and tokul/hour.

Wetish

2012-05-22 21:40:14

Are randoms a problem there? If not I may have to look into this script.

NKN

2012-05-22 21:44:34

I released it to the public. I've only had one random, though.