SRL Archive - OSR Help

[Looking for Feedback][RSPS] My 2nd (Successful) Script


Twinki

2013-05-03 01:39:06

I've been working on this script all day, and seem to have it working almost perfectly. This is for an RSPS, but it is pretty much like RS but right before EoC was released. Basically, there is a spot where you can go AFK and monsters are always aggressive and give Slayer XP every kill including Slayer points which can be traded in for rare weapons and XP. It's only 1 point per kill, and items are 3000 points+. As you can see you'd be AFKing these monsters for quite awhile. But these monsters can hit sometimes, and if you sit there for about 15 minutes you will start getting low on health. Requiring you to eat. So I made a script that will automatically eat / use prayer pots (You can use Soul Split + Turmoil) when low on HP / Prayer Points. It also supports banking by using the ::bank command. There is one safespot where you cannot get hit and you can bank using the ::bank command. So I made it automatically eat when low on HP, and run to the safespot when you run out of food and withdraw more food. I haven't scripted the Prayer Pot withdraw yet, I plan on doing that tomorrow. I'm just looking for feedback :)

program SlayerAFKer;
{$I SRL/SRL.Simba}
{$I RLInclude.Simba}
{$i ObjectDTM\ObjDTMInclude.simba}


// If only using Rocktails for health set both to false
Const //Set both to false if not using Prayer at all
UsingPrayer = False; // Set to false if not using prayer
UsingSoulSplit = False; // Set to false if not using Soul Split

MaxHP = 990; //Your Total HP
StartEating = 24; // This will start eating food at 24% of your total HP
StopEating = 90; // This will sttop eating food at 90% of your total HP

MaxPrayer = 990; //Your Total HP
StartDrinking = 24; // This will start eating food at 24% of your total HP
StopDrinking = 90; // This will sttop eating food at 90% of your total HP

Var
PrayerPot, RockTail, AteRocktail, DrankPrayerPot, HPLevel, StartEatHP, StopEatHP, PrayerPoints, StartDrinkPP,
StopDrinkPP, SafeSpot, BankDepositAll, BankCloseButton, HoundSpawnSpot:Integer;

ColourString:String;


// Drinks Prayer Pots when low PP \\
procedure DrinkPrayerPot;
var
X, Y:Integer;
ColourString:String;
begin
if UsingPrayer = True then
begin

PrayerPoints := GetMMLevels('prayer', ColourString);

StartDrinkPP := Round(MaxPrayer / 100 * StartDrinking);
StopDrinkPP := Round(MaxPrayer / 100 * StopDrinking);


if (PrayerPoints <= StartDrinkPP) then // if the value we get is lower than 20% start eating.
begin
Repeat
if FindDTM(PrayerPot, X, Y, MIX1, MIY1,MIX2, MIY2) then
begin
MMouse(x, y, 0, 0);
ClickMouse2(True);
wait(1500);
WriteLn('Drinking Prayer Pot..');
inc(DrankPrayerPot);

PrayerPoints := GetMMLevels('prayer', ColourString); //Call this again, to get new value
end else Exit; //Exits the procedure if we CANNOT find food , failsafe.
Until(PrayerPoints >= StopDrinkPP) // until we get the value of 80%
end;
end;
end;



// Eat Rockatils when low HP \\
procedure EatRocktail;
var
X, Y:Integer;
ColourString:String;
begin
if UsingSoulSplit = False then
begin

HPLevel := GetMMLevels('HP', ColourString);

StartEatHP := Round(MaxHP / 100 * StartEating);
StopEatHP := Round(MaxHP / 100 * StopEating);


if (HPLevel <= StartEatHP) then // if the value we get is lower than 20% start eating.
begin
Repeat
if FindDTM(RockTail, X, Y, MIX1, MIY1,MIX2, MIY2) then
begin
MMouse(x, y, 0, 0);
ClickMouse2(True);
wait(1500);
WriteLn('Eating Rocktail...');
inc(AteRocktail);
Wait(250);
ClearDebug;

HPLevel := GetMMLevels('hp', ColourString); //Call this again, to get new value
end else Exit; //Exits the procedure if we CANNOT find food , failsafe.
Until(HPLevel >= StopEatHP) // until we get the value of 80%
end;
end;
end;

// Withdraws Rocktails when it can't find any \\
procedure WithdrawRocktails;
Var
X, Y:Integer;
begin
if UsingPrayer = False then
if not FindDTM(RockTail, X, Y, MIX1, MIY1,MIX2, MIY2) then
begin
ClickDTMRotatedIn(SafeSpot, MMX1,MMY1, MMX2,MMY2, -Pi, Pi, Pi/30, [], mouse_Left);
if FlagPresent = True then
begin
Repeat
WriteLn('Waiting..');
Wait(500);
Until FlagPresent = False
end;
TypeSend('::bank');
Wait(500);
if FindDTM(BankDepositAll, X, Y, MSX1, MSY1,MSX2, MSY2) then
begin
MMouse(X, Y, 0, 0);
Wait(200);
ClickMouse2(True)
end;
if FindDTM(RockTail, X, Y, MSX1, MSY1,MSX2, MSY2) then
begin
MMouse(X, Y, 0, 0);
Wait(200);
ClickMouse2(False)
ChooseOption('Withdraw-All');
end;
if FindDTM(BankCloseButton, X, Y, MSX1, MSY1,MSX2, MSY2) then
begin
MMouse(X, Y, 0, 0);
Wait(200);
ClickMouse2(True)
end;
KeyDown(112);
wait(200);
KeyUp(112);
wait(2000);
if FindDTM(RockTail, X, Y, MIX1, MIY1,MIX2, MIY2) then
ClickDTMRotatedIn(HoundSpawnSpot, MMX1,MMY1, MMX2,MMY2, -Pi, Pi, Pi/30, [], mouse_left);
end;
end;



// Progress Report \\
procedure ProgressReport;
begin
wait(500);
ClearDebug;
WriteLn('***************PROGRESS REPORT*************************************');
WriteLn('* Script has run for : '+ TimeRunning +'');
WriteLn('* Current HP '+ IntToStr(GetMMLevels('hp', ColourString)) +'');
if UsingPrayer = True then
begin
WriteLn('* Current Prayer Points '+ IntToStr(GetMMLevels('prayer', ColourString)) +'');
WriteLn('* Will start drinking pots at '+ IntToStr(StartDrinkPP) +' Prayer Points');
end;
if UsingSoulSplit = False then
begin
WriteLn('* Ate Rocktails '+ IntToStr(AteRocktail) +' times');
WriteLn('* Will start eating at '+ IntToStr(StartEatHP) +' HP');
end;
if UsingPrayer = True then
begin
WriteLn('* Drank Prayer Pots '+ IntToStr(DrankPrayerPot) +' times');
end;
WriteLn('*******************************************************************');

end;


// Main Loop \\
begin
SetupSRL;
ObjDTM_Setup;
ClearDebug;
PrayerPot := DTMFromString('mlwAAAHicY2dgYHjGzMDwEIjfMEPYz4H4IxDfBWINRgYGeSAWBWJ+INZlhIiBsNWhfqBuJqyYlQE3YMSDoQAAVjMI/Q==');
RockTail := DTMFromString('mlwAAAHicY2dgYOABYlEozcUAAfxALA7lc0PlJYBYACrPDMSaAqxAkgkrhpmDDTDiwVAAAHZxARU=');
SafeSpot := DTMFromString('mbQAAAHicY2VgYJjCBMG9QDwHiDuAuBwong/EtUBcAsRZQMy02ZaBnY0ZBWMDjFgwGAAAEvAGYQ==');
BankDepositAll := DTMFromString('mggAAAHicY2NgYKhkZGCoB+IkIE4G4gYgbgJiYyDWgGIHKDYB4r0L0oG6GLFg7ACbSoRqAD+mBdg=');
BankCloseButton := DTMFromString('mbQAAAHicY2VgYHjFyMDwAYofA/FDIFYEimsCsQwQawGxNIgtIcrAxcUFx4ZaSgzYACMWDAYAMDwGaQ==');
HoundSpawnSpot := DTMFromString('mbQAAAHicY2VgYEhmYmCoAeIQII5jgvCbgeINQNwExBFAvAKIY2JCGXg0NRi41VQYPrAxM3x6+4KBGSiOjhmxYDAAAKyiChw=');
Repeat
EatRocktail;
ProgressReport;
DrinkPrayerPot;
WithdrawRocktails;
Until IsKeyDown(123)
FreeDTM(RockTail);
FreeDTM(PrayerPot);
FreeDTM(SafeSpot);
FreeDTM(BankDepositAll);
FreeDTM(BankCloseButton);
FreeDTM(HoundSpawnSpot);
end.

I ran this for 2 hours earlier, and is really stable. I had to stop it to start this thread :P I'm going to run it all night and see what happens, there isn't really a need for failsafes since when you die you don't lose anything. But I will probably add a failsafe in case you die it automatically logs you out and creates a log or something.

Chris!

2013-05-03 02:05:36

From a rough glance, I recommend making a LoadDTMs; procedure and FreeDTMs; procedure. This makes the mainloop cleaner.

procedure LoadDTMs;
begin
PrayerPot := DTMFromString('mlwAAAHicY2dgYHjGzMDwEIjfMEPYz4H4IxDfBWINRgYGeSAWBWJ+INZlhIiBsNWhfqBuJqyYlQE3YMSDoQAAVjMI/Q==');
RockTail := DTMFromString('mlwAAAHicY2dgYOABYlEozcUAAfxALA7lc0PlJYBYACrPDMSaAqxAkgkrhpmDDTDiwVAAAHZxARU=');
SafeSpot := DTMFromString('mbQAAAHicY2VgYJjCBMG9QDwHiDuAuBwong/EtUBcAsRZQMy02ZaBnY0ZBWMDjFgwGAAAEvAGYQ==');
BankDepositAll := DTMFromString('mggAAAHicY2NgYKhkZGCoB+IkIE4G4gYgbgJiYyDWgGIHKDYB4r0L0oG6GLFg7ACbSoRqAD+mBdg=');
BankCloseButton := DTMFromString('mbQAAAHicY2VgYHjFyMDwAYofA/FDIFYEimsCsQwQawGxNIgtIcrAxcUFx4ZaSgzYACMWDAYAMDwGaQ==');
HoundSpawnSpot := DTMFromString('mbQAAAHicY2VgYEhmYmCoAeIQII5jgvCbgeINQNwExBFAvAKIY2JCGXg0NRi41VQYPrAxM3x6+4KBGSiOjhmxYDAAAKyiChw=');
end;

procedure FreeDTMs;
begin
FreeDTM(RockTail);
FreeDTM(PrayerPot);
FreeDTM(SafeSpot);
FreeDTM(BankDepositAll);
FreeDTM(BankCloseButton);
FreeDTM(HoundSpawnSpot);
end;

So then your mainloop would look this this:

begin
SetupSRL;
ObjDTM_Setup;
ClearDebug;
LoadDTMs;
repeat
EatRocktail;
ProgressReport;
DrinkPrayerPot;
WithdrawRocktails;
until IsKeyDown(123)
AddOnTerminate('FreeDTMs'); //AddOnTerminate frees the DTM when the script ends, regardless of how it ends.
end.

Looks decent otherwise, good job. :)

Twinki

2013-05-03 02:07:46

From: Chris!
From a rough glance, I recommend making a LoadDTMs; procedure and FreeDTMs; procedure. This makes the mainloop cleaner.

procedure LoadDTMs;
begin
PrayerPot := DTMFromString('mlwAAAHicY2dgYHjGzMDwEIjfMEPYz4H4IxDfBWINRgYGeSAWBWJ+INZlhIiBsNWhfqBuJqyYlQE3YMSDoQAAVjMI/Q==');
RockTail := DTMFromString('mlwAAAHicY2dgYOABYlEozcUAAfxALA7lc0PlJYBYACrPDMSaAqxAkgkrhpmDDTDiwVAAAHZxARU=');
SafeSpot := DTMFromString('mbQAAAHicY2VgYJjCBMG9QDwHiDuAuBwong/EtUBcAsRZQMy02ZaBnY0ZBWMDjFgwGAAAEvAGYQ==');
BankDepositAll := DTMFromString('mggAAAHicY2NgYKhkZGCoB+IkIE4G4gYgbgJiYyDWgGIHKDYB4r0L0oG6GLFg7ACbSoRqAD+mBdg=');
BankCloseButton := DTMFromString('mbQAAAHicY2VgYHjFyMDwAYofA/FDIFYEimsCsQwQawGxNIgtIcrAxcUFx4ZaSgzYACMWDAYAMDwGaQ==');
HoundSpawnSpot := DTMFromString('mbQAAAHicY2VgYEhmYmCoAeIQII5jgvCbgeINQNwExBFAvAKIY2JCGXg0NRi41VQYPrAxM3x6+4KBGSiOjhmxYDAAAKyiChw=');
end;

procedure FreeDTMs;
begin
FreeDTM(RockTail);
FreeDTM(PrayerPot);
FreeDTM(SafeSpot);
FreeDTM(BankDepositAll);
FreeDTM(BankCloseButton);
FreeDTM(HoundSpawnSpot);
end;

So then your mainloop would look this this:

begin
SetupSRL;
ObjDTM_Setup;
ClearDebug;
LoadDTMs;
repeat
EatRocktail;
ProgressReport;
DrinkPrayerPot;
WithdrawRocktails;
until IsKeyDown(123)
AddOnTerminate('FreeDTMs'); //AddOnTerminate frees the DTM when the script ends, regardless of how it ends.
end.

Looks decent otherwise, good job. :)


:o Didn't think of that, Didn't know about the AddOnTerminate either. Thanks :) I'll update it tomorrow and finish it hopefully.

t4q

2013-05-03 03:00:44

Very nice script :)
For RSPS you don't need random waits but if you do script for RS then add it
keep going, next script will be even greater!

Twinki

2013-05-03 08:20:23

Ran for over 5 hours last night :)

***************PROGRESS REPORT*************************************
* Script has run for : 5 Hours, 5 Seconds
* Current HP 739
* Ate Rocktails 54 times
* Will start eating at 216 HP
*******************************************************************